/* uid.c
*
* Convert logname to uid.
*/
#include <stdio.h>
#include <stdfun.h>
#include <string.h>
#include <pwd.h>
static char _sccsid[] = { " %M% %I% %H% " };
int main( argc, argv )
int argc;
char *argv[];
{
extern struct passwd *getpwnam();
struct passwd pw, *ppw;
int nolf;
if( argc == 1 ) {
fprintf( stderr, "usage: uid [-n] logname\n" );
exit( 1 );
}
if( *argv[1] == '-' ) {
if( strcmp( argv[1], "-n" ) == 0 ) {
ppw = getpwnam( argv[2] );
nolf = 1;
}
else {
fprintf( stderr, "uid: illegal option %s\n", argv[1] );
exit( 1 );
}
}
else {
ppw = getpwnam( argv[1] );
nolf = 0;
}
if( ppw == (struct passwd *)0 ) {
puts( "NOLOGNANE" );
exit( 1 );
}
printf( "%d", ppw->pw_uid );
if( nolf == 0 )
putchar( '\n' );
exit( 0 );
return( 0 );
}
Return to Home Page
Return to Metayoga Page
Return to C Language Page
The URL for this document is:
http://graham.main.nc.us/~bhammel/graham/CPROGS/uid.html
Created: 1997
Last Updated: May 28, 2000
Email me, Bill Hammel at
bhammel@graham.main.nc.us
READ WARNING BEFORE SENDING E-MAIL