🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
3 messages
3 total messages Started by Ajay Kumar Gummadi Wed, 27 Mar 1996 08:55
getpwnam() -error checking
#3157
Author: Ajay Kumar Gummadi
Date: Wed, 27 Mar 1996 08:55
16 lines
792 bytes
Hi all,

  The function getpwnam() takes the user-id as input argument and returns 
a pointer to a structure, that contains all the user information.

  If I give a wrong /non-existent user-id as input argument, how can I 
check the error condition that may arise, before, the system dumps core.

  Reply by email will be very helpful.

  Thanks.


bye
ajay 
Re: getpwnam() -error checking
#3158
Author: Lawrence Kirby
Date: Wed, 27 Mar 1996 12:22
22 lines
1285 bytes
In article <Pine.SOL.3.91.960327025242.5526B-100000@ee.tamu.edu>
           ajay@ee.tamu.edu "Ajay Kumar Gummadi" writes:

>
>Hi all,
>
>  The function getpwnam() takes the user-id as input argument and returns 
>a pointer to a structure, that contains all the user information.

Or a null pointer on error.

>  If I give a wrong /non-existent user-id as input argument, how can I 
>check the error condition that may arise, before, the system dumps core.

Note that getpwnam() is not a part of the C language - it was inappropriate
to cross-post this to comp.lang.c.

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Re: getpwnam() -error checking
#3166
Author: Mark J. Bobak
Date: Thu, 04 Apr 1996 17:45
26 lines
1459 bytes
In article <Pine.SOL.3.91.960327025242.5526B-100000@ee.tamu.edu>,
Ajay Kumar Gummadi  <ajay@ee.tamu.edu> wrote:
>
>Hi all,
>
>  The function getpwnam() takes the user-id as input argument and returns 
>a pointer to a structure, that contains all the user information.
>
>  If I give a wrong /non-existent user-id as input argument, how can I 
>check the error condition that may arise, before, the system dumps core.
>
>  Reply by email will be very helpful.

getpwnam() will return a pointer to a struct passwd on success or a NULL
on failure.  So, just check to see if you were passed a NULL.  If you were,
then the user id probably doesn't exist.  (I say probably doesn't exist because
there may be other error conditions that would cause getpwnam() to return NULL.)

You'd be better off asking this in comp.unix.programmer.

-Mark
-- 
Mark J. Bobak, Application Developer
Advanced Vehicle & Computer Aided Engineering Systems Department
Process Leadership, Ford Motor Company
mbobak@ford.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads