Regarding cuserid(), getlogin() and getpwuid() function in 'C'

Hi,

I am currently on OS :- Red Hat Linux Version 3.0. The script I am running is a HP Tru64 Unix compatible script
which I am trying to run on the Linux Version 3.0.

I am doing a (Make gapw), where I have the following line of code at Line No.96 :-

96 DISCARD strcpy(user , (char*) cuserid((char*)0));

But I am not able to compile due to the only 1 following error :-

gapw.c: In function `main':
gapw.c:96: warning: cast to pointer from integer of different size

I included #include <stdlib.h> and #include <libgen.h>, in the file, but still I am not able to compile.

I think, there is a problem with the usage of cuserid() function.

Now instead of :- DISCARD strcpy(user , (char*) cuserid((char*)0));

I used each of the following:-

DISCARD strcpy(user, (char*) getlogin((char*)0));

or

DISCARD strcpy(user , (char*) getpwuid(getuid((char*)0)));

but still its showing me the following errors :-

$ make gapw
cc -c -o gapw.o gapw.c
gapw.c: In function `main':
gapw.c:101: error: too many arguments to function `getlogin'
make: *** [gapw.o] Error 1

or

$ make gapw
cc -c -o gapw.o gapw.c
gapw.c: In function `main':
gapw.c:102: error: too many arguments to function `getuid'
gapw.c:102: warning: cast to pointer from integer of different size
make: *** [gapw.o] Error 1

Request you to pls give ur inputs.

Regards,
Marconi.

I think getuid takes 0 arguments.
you are passing getuid ((char*) 0)

I think , The main use of getuid is to return your(the current user) uid.

--siva