[comp.sources.d] vt100clock

neubauer@bsu-cs.bsu.edu (Paul Neubauer) (05/09/89)

I tried to compile Joel Spolsky's vt100clock program from Vol. 6, Issue 98,
archived as clock.msk.  I am running on a BSD 4.3 system, if that is any
help.  The command 'cc vt100clock.c' produced the output:

Undefined:
_cuserid

Joel #includes a number of the usual sorts of .h files, but none of them
contain cuserid(), in fact, a grep of /usr/include and /usr/include/sys gave
me no clue about the function or what it does.  I assume that it is a SysV
function, but a quick look at the ATT SysV Programmers Guide (I don't have
the books in front of me so that may not be a completely accurate title)
(Vols. I and II) also did not find cuserid() in the index.  It shows up in
two places in Joel's program:

    /* remember where mail is kept */
    sprintf(path, MAILFILE, cuserid(NULL));

and

	/* check mail */
	old_size = new_size;
	if (!stat(sprintf(path, MAILFILE, cuserid(NULL)), &st))
	    new_size = st.st_size;
	else 
	    new_size = 0;

Can anybody tell me (1) what it does, (2) if there is a BSD equivalent or
near-equivalent, and/or (3) what to do about it?  

Thanks much.


-- 
Paul Neubauer         neubauer@bsu-cs.bsu.edu        neubauer@bsu-cs.UUCP
                      <backbones>!{iuvax,pur-ee}!bsu-cs!neubauer

dold@mitisft.Convergent.COM (Clarence Dold) (05/10/89)

in article <7150@bsu-cs.bsu.edu>, neubauer@bsu-cs.bsu.edu (Paul Neubauer) says:

> I tried to compile Joel Spolsky's vt100clock program from Vol. 6, Issue 98,
> archived as clock.msk.  I am running on a BSD 4.3 system, if that is any
> help.  The command 'cc vt100clock.c' produced the output:

> Undefined:
> _cuserid

> Can anybody tell me (1) what it does, (2) if there is a BSD equivalent or
> near-equivalent, and/or (3) what to do about it?  

It returns the LOGNAME, used to find /usr/mail/LOGNAME mail storage file.
You might be able to derive it from a getenv of LOGNAME or ...

I also changed the line
	signal(SIGINT,clear&exit) to trap to a null function on SIGINT
so that the clock wouldn't go away when I interrupted a program.
I'm running SysV 3.0, and I don't get the 'mail' prompt, just the clock.
I went to sdb, which is kind of hard(?) on a program that is in background.

Thanks Joel.  I don't even care about the mail stuff, the clock is great.
-- 
---
Clarence A Dold - dold@tsmiti.Convergent.COM		(408) 434-5293
		...pyramid!ctnews!tsmiti!dold
		P.O.Box 6685, San Jose, CA 95150-6685	MS#10-007

jeff@quark.WV.TEK.COM (Jeff Beadles;X2568;61-215) (05/11/89)

In article <7150@bsu-cs.bsu.edu> neubauer@bsu-cs.bsu.edu (Paul Neubauer) writes:
>I tried to compile Joel Spolsky's vt100clock program from Vol. 6, Issue 98,
>archived as clock.msk.  I am running on a BSD 4.3 system, if that is any
>help.  The command 'cc vt100clock.c' produced the output:

>Undefined:
>_cuserid

>Can anybody tell me (1) what it does, (2) if there is a BSD equivalent or
>near-equivalent, and/or (3) what to do about it?  

>Thanks much.

Well, here's what I have in my manual...  cuserid(3S)

#include <stdio.h>
char *cuserid(s)
char *s;

Generate a string representation of the login name of the owner of the
current process.  If s is a NULL pointer, then cuserid will allocate space
for the login name.  If not, then cuserid expects s to be an array of at
least L_cuserid characters.  (Defined in stdio.h)  If an error, a null
pointer is returned if called with a null pointer, else s[0]='\0'

Something could be easily make with getpwuid(getuid()) to return the
desired results.

	-Jeff

--
Jeff Beadles		Utek Sustaining Engineering, Tektronix Inc.
jeff@quark.WV.TEK.COM

guy@auspex.auspex.com (Guy Harris) (05/12/89)

>Something could be easily make with getpwuid(getuid()) to return the
>desired results.

Call "getlogin()" first, and if that fails use "getpwuid()" - that's
what "cuserid()" does.