[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
getpwnam
From: |
Bruce Korb |
Subject: |
getpwnam |
Date: |
Mon, 29 Dec 2003 13:09:12 -0800 |
Hi Jim, Paul, et. al.,
Attached is my effort to get getpwnam to use the coreutils
infrastructure. These are the hand edited files:
> Makefile.am.patch
> getpwnam.c
> getpwnam-opts.def
> getopt.tpl
And these are the derived files, using the above template
and some that are incorporated into autogen:
> getpwnam-opts.c
> getpwnam-opts.h
> getpwnam.1
> getpwnam.menu
> getpwnam.texi
> getopt-getpwnam.c
The Makefile.am.patch incorporates rules for regenerating these
files, but they are generated independently from the executable
dependency tree. Consequently, they should be distributed and
be rebuilt only by a maintainer.
--- Makefile.am Thu Aug 14 23:50:29 2003
+++ /home/bkorb/tools/coreutils/coreutils-5.0.92-pre1/src/Makefile.am Mon Dec
29 12:41:44 2003
@@ -10,7 +10,7 @@
nl od paste pr ptx sha1sum sort split sum tac tail tr tsort unexpand uniq wc
\
basename date dirname echo env expr factor false \
hostname id kill logname pathchk printenv printf pwd seq sleep tee \
- test true tty whoami yes \
+ test true tty whoami yes getpwnam \
$(OPTIONAL_BIN_PROGS) $(DF_PROG)
noinst_PROGRAMS = setuidgid
@@ -20,7 +20,8 @@
chown-core.h fs.h \
wheel.h wheel-size.h
EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
- groups.sh wheel-gen.pl extract-magic
+ groups.sh wheel-gen.pl extract-magic getpwnam-opts.def getopt.tpl
+
CLEANFILES = $(SCRIPTS) su
AM_CPPFLAGS = -I.. -I$(srcdir) -I$(top_srcdir)/lib -I../lib
@@ -204,6 +205,32 @@
@chmod a-w address@hidden
mv address@hidden $@
+getpwnam_SOURCES= getpwnam.c getpwnam-opts.c getopt-getpwnam.c
+
+clobber : getpwnam-clobber maintainer-clean
+gen : all-getpwnam
+all-getpwnam : getpwnam-opts.h getopt-getpwnam.c getpwnam.1 getpwnam.texi
+
+$(OBJ) : getpwnam-opts.h
+getpwnam-opts.h : getpwnam-opts.def
+ cd $(srcdir) && autogen getpwnam-opts.def
+
+getpwnam.1 : getpwnam-opts.def
+ cd $(srcdir) && autogen -bgetpwnam -T agman1.tpl getpwnam-opts.def
+
+getpwnam.texi : getpwnam
+ autogen -bgetpwnam -T aginfo.tpl $(srcdir)/getpwnam-opts.def
+
+getpwnam-clobber:
+ rm -f getpwnam.texi getpwnam.menu
+ cd $(srcdir) && \
+ rm -f getpwnam.1 getopt-getpwnam.c getpwnam-opts.[ch]
+
+getopt-getpwnam.c : getpwnam-opts.def getpwnam-opts.c getopt.tpl
+ CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
+ export CC CFLAGS LDFLAGS ; cd $(srcdir) ; \
+ autogen -T getopt.tpl getpwnam-opts.def
+
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
all_programs = \
/*
Copyright (C) 85, 88, 90, 91, 1995-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* This is basically a wrapper program around the getpwnam(3) and getpwuid(3)
library calls. */
/* Written by Bruce Korb. */
#include <sys/types.h>
#include <stdlib.h>
#include <getopt.h>
#include <errno.h>
#include <grp.h>
#include <limits.h>
#include <pwd.h>
#ifdef __sun
# include <inttypes.h>
#else
# include <stdint.h>
#endif
#include "getpwnam-opts.h"
#include "system.h"
void
printInfo (struct passwd* pw);
void
printInfoVerbosely (struct passwd* pw);
int
main (int argc, char** argv)
{
const char* pzBadUser =
_("%s error: '%s' is not a valid user name or id\n");
uid_t uid = getuid();
struct passwd* pw;
char* pzUser;
process_getpwnam_opts (argc, argv);
argc -= optind;
pzUser = argv[ optind ];
switch (argc) {
default:
fputs (_("Error: Too many command line arguments\n"), stderr);
USAGE (EXIT_FAILURE);
/* NOTREACHED */
case 1:
pw = getpwnam (pzUser);
if (pw != NULL)
break;
errno = 0;
{
char* pz;
long l = strtol (pzUser, &pz, 0);
switch (l) {
case LONG_MIN:
case LONG_MAX:
case 0:
if (errno != 0) {
fprintf (stderr, pzBadUser, getpwnamOptions.pzProgName,
pzUser);
USAGE(EXIT_FAILURE);
}
}
uid = (uid_t)l;
}
/* FALLTHROUGH */
case 0:
pw = getpwuid (uid);
if (pw != NULL)
break;
if (argc == 0) {
fprintf (stderr, _("%s error: uid %d has no password entry\n"),
getpwnamOptions.pzProgName, uid);
} else {
fprintf (stderr, pzBadUser, getpwnamOptions.pzProgName, pzUser);
}
return EXIT_FAILURE;
}
if (selectCt > 0) {
if (HAVE_OPT( VERBOSE ))
printInfoVerbosely (pw);
else
printInfo (pw);
}
return EXIT_SUCCESS;
}
void
printInfoVerbosely (struct passwd* pw)
{
const char* pzBadGrp =
_("%s error: the primary group for %s is invalid\n");
int ix = 0;
do {
switch (selections[ix]) {
case INDEX_OPT_NAME:
printf (_("user name: %s\n"), pw->pw_name );
break;
case INDEX_OPT_PASSWD:
printf (_("password: '%s' (encrypted)\n"), pw->pw_passwd );
break;
case INDEX_OPT_UID:
printf (_("user id: %d\n"), pw->pw_uid );
break;
case INDEX_OPT_GNAME: {
struct group* pg = getgrgid (pw->pw_gid);
if (pg == NULL) {
fprintf (stderr, pzBadGrp, getpwnamOptions.pzProgName,
pw->pw_name);
exit (EXIT_FAILURE);
}
printf (_("group name: %s\n"), pg->gr_name );
break;
}
case INDEX_OPT_GID:
printf (_("group id: %d\n"), pw->pw_gid );
break;
case INDEX_OPT_GECOS:
printf (_("full name: %s\n"), pw->pw_gecos );
break;
case INDEX_OPT_DIR:
printf (_("directory: %s\n"), pw->pw_dir );
break;
case INDEX_OPT_SHELL:
printf (_("login shell: %s\n"), pw->pw_shell );
break;
default:
fprintf (stderr, _("%s error: unknown selection: %d\n"),
getpwnamOptions.pzProgName, selections[ix]);
exit (EXIT_FAILURE);
}
} while (++ix < selectCt);
}
void
printInfo (struct passwd* pw)
{
const char* pzBadGrp =
_("%s error: the primary group for %s is invalid\n");
int ix = 0;
for (;;) {
switch (selections[ix]) {
case INDEX_OPT_NAME: fputs (pw->pw_name, stdout); break;
case INDEX_OPT_PASSWD: fputs (pw->pw_passwd, stdout); break;
case INDEX_OPT_UID: printf ("%d", pw->pw_uid); break;
case INDEX_OPT_GNAME: {
struct group* pg = getgrgid (pw->pw_gid);
if (pg == NULL) {
fprintf (stderr, pzBadGrp, getpwnamOptions.pzProgName,
pw->pw_name);
exit (EXIT_FAILURE);
}
fputs (pg->gr_name, stdout);
break;
}
case INDEX_OPT_GID: printf ("%d", pw->pw_gid); break;
case INDEX_OPT_GECOS: fputs (pw->pw_gecos, stdout); break;
case INDEX_OPT_DIR: fputs (pw->pw_dir, stdout); break;
case INDEX_OPT_SHELL: fputs (pw->pw_shell, stdout); break;
default:
fprintf (stderr, _("%s error: unknown selection: %d\n"),
getpwnamOptions.pzProgName, selections[ix]);
exit (EXIT_FAILURE);
}
if (++ix >= selectCt)
break;
fputc (' ', stdout);
}
fputc ('\n', stdout);
}
/*
* Local Variables:
* mode: C
* c-file-style: "gnu"
* indent-tabs-mode: nil
* End:
* end of getpwnam.c */
autogen definitions options;
copyright = {
date = "2003";
owner = "Free Software Foundation";
author= "Bruce Korb";
eaddr = "address@hidden";
type = gpl;
};
/*
* $Id: opts.def,v 1.4 2003/12/17 05:04:43 bkorb Exp $
*/
prog-name = "getpwnam";
prog-title = "Get user information from the passwd file";
argument = "[ user-name-or-id ]";
test-main;
gnu-usage;
long-opts;
version = "1.0";
explain = <<- _EndExplanation_
get (and print) information from the /etc/passwd database.
By default, information for the current user is provided.
_EndExplanation_;
detail = <<- _EndOfDetail_
This command uses getpwnam(3) or getpwuid(3) to obtain the
requested information. If a user name or user id is not provided,
the information for the current user is obtained. The results are
printed in the order selected. If you select no options, nothing
is printed on success, but the user name/user id will have been
validated.
_EndOfDetail_;
export = <<- _EndExport_
#include <stdio.h>
extern int selectCt;
int selections[INDEX_OPT_ALL];
extern int process_getpwnam_opts( int argc, char** argv );
_EndExport_;
include = <<- _EndInclude_
int selectCt = 0;
int selections[INDEX_OPT_ALL] = { 0 };
_EndInclude_;
flag = {
name = name;
value = n;
descrip = "Print the user name";
doc = "The user login name will be printed.";
flag-code = <<- _EndCode_
int ix = selectCt++;
if (selectCt >= INDEX_OPT_ALL) {
fprintf( stderr, "%s PROGRAM BUG: too many
selections\n",
pOptions->pzProgName );
exit( 1 );
}
selections[ ix ] = pOptDesc->optIndex;
_EndCode_;
settable;
};
flag = {
name = passwd;
value = p;
descrip = "Print the (encrypted) user password";
doc = <<- _EODoc_
The encrypted password will be printed. If a shadow password
is used, the value will typically be the single letter "x".
_EODoc_;
flag-proc = name;
settable;
};
flag = {
name = uid;
value = u;
descrip = "Print the user id";
doc = "The numeric user id will be printed.";
flag-proc = name;
settable;
};
flag = {
name = gname;
value = g;
descrip = "Print the group name";
doc = "The name of the user's primary group will be printed.";
flag-proc = name;
settable;
};
flag = {
name = gid;
value = G;
descrip = "Print the group id";
doc = "The numeric primary group id will be printed.";
flag-proc = name;
settable;
};
flag = {
name = gecos;
value = N;
descrip = "Print the real user name (comment string)";
doc = "The real user name will be printed, usually.\n"
"It is designated as the account \"comment string\".";
flag-proc = name;
settable;
};
flag = {
name = dir;
value = d;
descrip = "Print the home directory";
doc = "The user's home directory will be printed.";
flag-proc = name;
settable;
};
flag = {
name = shell;
value = s;
descrip = "Print the login shell";
doc = "The name of the program that is run when the user logs in "
"will be printed.";
flag-proc = name;
settable;
};
flag = {
name = all;
value = A;
descrip = "Print everything";
doc = "Print all of the available fields, including the name of\n"
"the primary group.";
flags-cant = name, passwd, uid, gname, gid, gecos, dir, shell;
flag-code = <<- _EndCode_
int sel = INDEX_OPT_NAME;
int ix = 0;
do {
selections[ ix++ ] = sel++;
} while ( sel < INDEX_OPT_ALL );
selectCt = ix;
_EndCode_;
settable;
};
flag = {
name = verbose;
value = V;
descrip = "Verbose output";
doc = "Print each item of information on a separate line, with\n"
"a short description of each.";
settable;
};
help-value = 'h';
more-help-value;
version-value;
/* -*- buffer-read-only: t -*- vi: set ro:
*
* DO NOT EDIT THIS FILE (getpwnam-opts.c)
*
* It has been AutoGen-ed Monday December 29, 2003 at 12:44:06 PM PST
* From the definitions getpwnam-opts.def
* and the template file options
*/
#include "getpwnam-opts.h"
#ifdef __cplusplus
extern "C" {
#endif
tSCC zCopyright[] =
"getpwnam copyright (c) 2003 Free Software Foundation, all rights
reserved";
tSCC zCopyrightNotice[] =
"getpwnam is free software.\n\n\
You may redistribute it and/or modify it under the terms of the\n\
GNU General Public License, as published by the Free Software\n\
Foundation; either version 2, or (at your option) any later version.\n\n\
getpwnam is distributed in the hope that it will be useful,\n\
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
See the GNU General Public License for more details.\n\n\
You should have received a copy of the GNU General Public License\n\
along with getpwnam. See the file \"COPYING\". If not,\n\
write to: The Free Software Foundation, Inc.,\n\
59 Temple Place - Suite 330,\n\
Boston, MA 02111-1307, USA.";
extern tOptProc doVersionStderr, doVersion, doPagedUsage;
static tOptProc doUsageOpt, doOptName, doOptAll;
extern tUsageProc optionUsage;
/*
* global included definitions
*/
int selectCt = 0;
int selections[INDEX_OPT_ALL] = { 0 };
#ifndef NULL
# define NULL 0
#endif
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif
/*
* Name option description:
*/
tSCC zNameText[] =
"Print the user name";
tSCC zName_NAME[] = "NAME";
#define zNotName_Pfx NULL
#define zNotName_Name NULL
tSCC zName_Name[] = "name";
#define NAME_FLAGS (OPTST_DISABLED)
/*
* Passwd option description:
*/
tSCC zPasswdText[] =
"Print the (encrypted) user password";
tSCC zPasswd_NAME[] = "PASSWD";
#define zNotPasswd_Pfx NULL
#define zNotPasswd_Name NULL
tSCC zPasswd_Name[] = "passwd";
#define PASSWD_FLAGS (OPTST_DISABLED)
/*
* Uid option description:
*/
tSCC zUidText[] =
"Print the user id";
tSCC zUid_NAME[] = "UID";
#define zNotUid_Pfx NULL
#define zNotUid_Name NULL
tSCC zUid_Name[] = "uid";
#define UID_FLAGS (OPTST_DISABLED)
/*
* Gname option description:
*/
tSCC zGnameText[] =
"Print the group name";
tSCC zGname_NAME[] = "GNAME";
#define zNotGname_Pfx NULL
#define zNotGname_Name NULL
tSCC zGname_Name[] = "gname";
#define GNAME_FLAGS (OPTST_DISABLED)
/*
* Gid option description:
*/
tSCC zGidText[] =
"Print the group id";
tSCC zGid_NAME[] = "GID";
#define zNotGid_Pfx NULL
#define zNotGid_Name NULL
tSCC zGid_Name[] = "gid";
#define GID_FLAGS (OPTST_DISABLED)
/*
* Gecos option description:
*/
tSCC zGecosText[] =
"Print the real user name (comment string)";
tSCC zGecos_NAME[] = "GECOS";
#define zNotGecos_Pfx NULL
#define zNotGecos_Name NULL
tSCC zGecos_Name[] = "gecos";
#define GECOS_FLAGS (OPTST_DISABLED)
/*
* Dir option description:
*/
tSCC zDirText[] =
"Print the home directory";
tSCC zDir_NAME[] = "DIR";
#define zNotDir_Pfx NULL
#define zNotDir_Name NULL
tSCC zDir_Name[] = "dir";
#define DIR_FLAGS (OPTST_DISABLED)
/*
* Shell option description:
*/
tSCC zShellText[] =
"Print the login shell";
tSCC zShell_NAME[] = "SHELL";
#define zNotShell_Pfx NULL
#define zNotShell_Name NULL
tSCC zShell_Name[] = "shell";
#define SHELL_FLAGS (OPTST_DISABLED)
/*
* All option description with
* "Must also have options" and "Incompatible options":
*/
tSCC zAllText[] =
"Print everything";
tSCC zAll_NAME[] = "ALL";
#define zNotAll_Pfx NULL
#define zNotAll_Name NULL
tSCC zAll_Name[] = "all";
static const int
aAllCantList[] = {
INDEX_OPT_NAME,
INDEX_OPT_PASSWD,
INDEX_OPT_UID,
INDEX_OPT_GNAME,
INDEX_OPT_GID,
INDEX_OPT_GECOS,
INDEX_OPT_DIR,
INDEX_OPT_SHELL, NO_EQUIVALENT };
#define ALL_FLAGS (OPTST_DISABLED)
/*
* Verbose option description:
*/
tSCC zVerboseText[] =
"Verbose output";
tSCC zVerbose_NAME[] = "VERBOSE";
#define zNotVerbose_Pfx NULL
#define zNotVerbose_Name NULL
tSCC zVerbose_Name[] = "verbose";
#define VERBOSE_FLAGS (OPTST_DISABLED)
/*
* Help option description:
*/
tSCC zHelpText[] = "Display usage information and exit";
tSCC zHelp_Name[] = "help";
/*
* More_Help option description:
*/
tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
tSCC zMore_Help_Name[] = "more-help";
/*
* Version option description:
*/
tSCC zVersionText[] = "Output version information and exit";
tSCC zVersion_Name[] = "version";
#if ! defined( TEST_GETPWNAM_OPTS )
#else /* *is* defined( TEST_GETPWNAM_OPTS ) */
/*
* Under test, omit argument processing, or call stackOptArg,
* if multiple copies are allowed.
*/
#define doOptName NULL
#define doOptAll NULL
#endif /* defined( TEST_GETPWNAM_OPTS ) */
#ifdef TEST_GETPWNAM_OPTS
# define DOVERPROC doVersionStderr
#else
# define DOVERPROC doVersion
#endif /* TEST_GETPWNAM_OPTS */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Define the Getpwnam Option Descriptions.
*/
static tOptDesc optDesc[ OPTION_CT ] = {
{ /* entry idx, value */ 0, VALUE_OPT_NAME,
/* equiv idx, value */ 0, VALUE_OPT_NAME,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ NAME_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doOptName,
/* desc, NAME, name */ zNameText, zName_NAME,
zName_Name,
/* disablement strs */ zNotName_Name, zNotName_Pfx },
{ /* entry idx, value */ 1, VALUE_OPT_PASSWD,
/* equiv idx, value */ 1, VALUE_OPT_PASSWD,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ PASSWD_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doOptName,
/* desc, NAME, name */ zPasswdText, zPasswd_NAME,
zPasswd_Name,
/* disablement strs */ zNotPasswd_Name, zNotPasswd_Pfx },
{ /* entry idx, value */ 2, VALUE_OPT_UID,
/* equiv idx, value */ 2, VALUE_OPT_UID,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ UID_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doOptName,
/* desc, NAME, name */ zUidText, zUid_NAME,
zUid_Name,
/* disablement strs */ zNotUid_Name, zNotUid_Pfx },
{ /* entry idx, value */ 3, VALUE_OPT_GNAME,
/* equiv idx, value */ 3, VALUE_OPT_GNAME,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ GNAME_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doOptName,
/* desc, NAME, name */ zGnameText, zGname_NAME,
zGname_Name,
/* disablement strs */ zNotGname_Name, zNotGname_Pfx },
{ /* entry idx, value */ 4, VALUE_OPT_GID,
/* equiv idx, value */ 4, VALUE_OPT_GID,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ GID_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doOptName,
/* desc, NAME, name */ zGidText, zGid_NAME,
zGid_Name,
/* disablement strs */ zNotGid_Name, zNotGid_Pfx },
{ /* entry idx, value */ 5, VALUE_OPT_GECOS,
/* equiv idx, value */ 5, VALUE_OPT_GECOS,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ GECOS_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doOptName,
/* desc, NAME, name */ zGecosText, zGecos_NAME,
zGecos_Name,
/* disablement strs */ zNotGecos_Name, zNotGecos_Pfx },
{ /* entry idx, value */ 6, VALUE_OPT_DIR,
/* equiv idx, value */ 6, VALUE_OPT_DIR,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ DIR_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doOptName,
/* desc, NAME, name */ zDirText, zDir_NAME,
zDir_Name,
/* disablement strs */ zNotDir_Name, zNotDir_Pfx },
{ /* entry idx, value */ 7, VALUE_OPT_SHELL,
/* equiv idx, value */ 7, VALUE_OPT_SHELL,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ SHELL_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doOptName,
/* desc, NAME, name */ zShellText, zShell_NAME,
zShell_Name,
/* disablement strs */ zNotShell_Name, zNotShell_Pfx },
{ /* entry idx, value */ 8, VALUE_OPT_ALL,
/* equiv idx, value */ 8, VALUE_OPT_ALL,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ ALL_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, aAllCantList,
/* option proc */ doOptAll,
/* desc, NAME, name */ zAllText, zAll_NAME,
zAll_Name,
/* disablement strs */ zNotAll_Name, zNotAll_Pfx },
{ /* entry idx, value */ 9, VALUE_OPT_VERBOSE,
/* equiv idx, value */ 9, VALUE_OPT_VERBOSE,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ VERBOSE_FLAGS,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ NULL,
/* desc, NAME, name */ zVerboseText, zVerbose_NAME,
zVerbose_Name,
/* disablement strs */ zNotVerbose_Name, zNotVerbose_Pfx },
{ /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
/* equiv idx value */ NO_EQUIVALENT, 0,
/* option argument */ ARG_MAY,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max act ct */ 0, 1, 0,
/* opt state flags */ OPTST_INIT,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ DOVERPROC,
/* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
/* disablement strs */ NULL, NULL },
{ /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
/* equiv idx value */ NO_EQUIVALENT, 0,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max act ct */ 0, 1, 0,
/* opt state flags */ OPTST_IMM,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doUsageOpt,
/* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
/* disablement strs */ NULL, NULL },
{ /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
/* equiv idx value */ NO_EQUIVALENT, 0,
/* option argument */ ARG_NONE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max act ct */ 0, 1, 0,
/* opt state flags */ OPTST_IMM,
/* last opt argumnt */ NULL,
/* arg list/cookie */ NULL,
/* must/cannot opts */ NULL, NULL,
/* option proc */ doPagedUsage,
/* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
/* disablement strs */ NULL, NULL }
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Define the Getpwnam Option Environment
*/
tSCC zPROGNAME[] = "GETPWNAM";
tSCC zUsageTitle[] =
"getpwnam - Get user information from the passwd file - Ver. 1.0\n\
USAGE: %s [ -<flag> | --<name> ]... [ user-name-or-id ]\n";
#define zRcName NULL
#define apzHomeList NULL
tSCC zBugsAddr[] = "address@hidden";
tSCC zExplain[] = "\n\
get (and print) information from the /etc/passwd database.\n\
By default, information for the current user is provided.\n";
tSCC zDetail[] = "\n\
This command uses getpwnam(3) or getpwuid(3) to obtain the\n\
requested information. If a user name or user id is not provided,\n\
the information for the current user is obtained. The results are\n\
printed in the order selected. If you select no options, nothing\n\
is printed on success, but the user name/user id will have been\n\
validated.\n";
tSCC zFullVersion[] = GETPWNAM_FULL_VERSION;
tOptions getpwnamOptions = {
OPTIONS_STRUCT_VERSION,
NULL, NULL, zPROGNAME,
zRcName, zCopyright, zCopyrightNotice,
zFullVersion, apzHomeList, zUsageTitle,
zExplain, zDetail, NULL, optionUsage,
( OPTPROC_NONE
+ OPTPROC_ERRSTOP
+ OPTPROC_SHORTOPT
+ OPTPROC_LONGOPT
+ OPTPROC_NO_REQ_OPT
+ OPTPROC_GNUUSAGE ),
0, NULL,
{ INDEX_OPT_MORE_HELP,
0 /* no option state saving */,
NO_EQUIVALENT /* no '-#' option */,
NO_EQUIVALENT /* no default option */ },
OPTION_CT, 10 /* user option count */,
optDesc,
0, (char**)NULL, /* original argc + argv */
zBugsAddr /* address to send bugs to */
};
/*
* Create the static procedure(s) declared above.
*/
static void
doUsageOpt(
tOptions* pOptions,
tOptDesc* pOptDesc )
{
USAGE( EXIT_SUCCESS );
}
#if ! defined( TEST_GETPWNAM_OPTS )
/* * * * * * *
*
* For the "Name Option".
*/
static void
doOptName(
tOptions* pOptions,
tOptDesc* pOptDesc )
{
int ix = selectCt++;
if (selectCt >= INDEX_OPT_ALL) {
fprintf( stderr, "%s PROGRAM BUG: too many selections\n",
pOptions->pzProgName );
exit( 1 );
}
selections[ ix ] = pOptDesc->optIndex;
}
#endif /* ! defined TEST_GETPWNAM_OPTS */
#if ! defined( TEST_GETPWNAM_OPTS )
/* * * * * * *
*
* For the "All Option".
*/
static void
doOptAll(
tOptions* pOptions,
tOptDesc* pOptDesc )
{
int sel = INDEX_OPT_NAME;
int ix = 0;
do {
selections[ ix++ ] = sel++;
} while ( sel < INDEX_OPT_ALL );
selectCt = ix;
}
#endif /* ! defined TEST_GETPWNAM_OPTS */
#if defined( TEST_GETPWNAM_OPTS )
int
main( int argc, char** argv )
{
(void)optionProcess( &getpwnamOptions, argc, argv );
{
void putBourneShell( tOptions* );
putBourneShell( &getpwnamOptions );
}
return EXIT_SUCCESS;
}
#endif /* defined TEST_GETPWNAM_OPTS */
#ifdef __cplusplus
}
#endif
/* -*- buffer-read-only: t -*- vi: set ro:
*
* DO NOT EDIT THIS FILE (getpwnam-opts.h)
*
* It has been AutoGen-ed Monday December 29, 2003 at 12:44:06 PM PST
* From the definitions getpwnam-opts.def
* and the template file options
*/
/*
* This file contains the programmatic interface to the Automated
* Options generated for the getpwnam program.
* These macros are documented in the AutoGen info file in the
* "AutoOpts" chapter. Please refer to that doc for usage help.
*/
#ifndef AUTOOPTS_GETPWNAM_OPTS_H_GUARD
#define AUTOOPTS_GETPWNAM_OPTS_H_GUARD
/*
* getpwnam copyright 2003 Free Software Foundation - all rights reserved
*
* getpwnam is free software.
*
* You may redistribute it and/or modify it under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation; either version 2, or (at your option) any later version.
*
* getpwnam is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with getpwnam. See the file "COPYING". If not,
* write to: The Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <options.h>
/*
* Enumeration of each option:
*/
typedef enum {
INDEX_OPT_NAME = 0,
INDEX_OPT_PASSWD = 1,
INDEX_OPT_UID = 2,
INDEX_OPT_GNAME = 3,
INDEX_OPT_GID = 4,
INDEX_OPT_GECOS = 5,
INDEX_OPT_DIR = 6,
INDEX_OPT_SHELL = 7,
INDEX_OPT_ALL = 8,
INDEX_OPT_VERBOSE = 9,
INDEX_OPT_VERSION = 10,
INDEX_OPT_HELP = 11,
INDEX_OPT_MORE_HELP = 12
} teOptIndex;
#define OPTION_CT 13
#define GETPWNAM_VERSION "1.0"
#define GETPWNAM_FULL_VERSION "getpwnam - Get user information from the passwd
file - Ver. 1.0"
/*
* Interface defines for all options. Replace "n" with
* the UPPER_CASED option name (as in the teOptIndex
* enumeration above). e.g. HAVE_OPT( NAME )
*/
#define DESC(n) getpwnamOptions.pOptDesc[INDEX_OPT_ ## n]
#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
#define OPT_ARG(n) (DESC(n).pzLastArg)
#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
#define COUNT_OPT(n) (DESC(n).optOccCt)
#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
#define CLEAR_OPT(n) STMTS( \
DESC(n).fOptState &= OPTST_PERSISTENT; \
if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
DESC(n).fOptState |= OPTST_DISABLED; \
DESC(n).optCookie = NULL )
/*
* Interface defines for specific options.
*/
#define VALUE_OPT_NAME 'n'
#define SET_OPT_NAME STMTS( \
DESC(NAME).optActualIndex = 0; \
DESC(NAME).optActualValue = VALUE_OPT_NAME; \
DESC(NAME).fOptState &= OPTST_PERSISTENT; \
DESC(NAME).fOptState |= OPTST_SET; \
(*(DESC(NAME).pOptProc))( &getpwnamOptions, \
getpwnamOptions.pOptDesc + 0 ) )
#define VALUE_OPT_PASSWD 'p'
#define SET_OPT_PASSWD STMTS( \
DESC(PASSWD).optActualIndex = 1; \
DESC(PASSWD).optActualValue = VALUE_OPT_PASSWD; \
DESC(PASSWD).fOptState &= OPTST_PERSISTENT; \
DESC(PASSWD).fOptState |= OPTST_SET; \
(*(DESC(PASSWD).pOptProc))( &getpwnamOptions, \
getpwnamOptions.pOptDesc + 1 ) )
#define VALUE_OPT_UID 'u'
#define SET_OPT_UID STMTS( \
DESC(UID).optActualIndex = 2; \
DESC(UID).optActualValue = VALUE_OPT_UID; \
DESC(UID).fOptState &= OPTST_PERSISTENT; \
DESC(UID).fOptState |= OPTST_SET; \
(*(DESC(UID).pOptProc))( &getpwnamOptions, \
getpwnamOptions.pOptDesc + 2 ) )
#define VALUE_OPT_GNAME 'g'
#define SET_OPT_GNAME STMTS( \
DESC(GNAME).optActualIndex = 3; \
DESC(GNAME).optActualValue = VALUE_OPT_GNAME; \
DESC(GNAME).fOptState &= OPTST_PERSISTENT; \
DESC(GNAME).fOptState |= OPTST_SET; \
(*(DESC(GNAME).pOptProc))( &getpwnamOptions, \
getpwnamOptions.pOptDesc + 3 ) )
#define VALUE_OPT_GID 'G'
#define SET_OPT_GID STMTS( \
DESC(GID).optActualIndex = 4; \
DESC(GID).optActualValue = VALUE_OPT_GID; \
DESC(GID).fOptState &= OPTST_PERSISTENT; \
DESC(GID).fOptState |= OPTST_SET; \
(*(DESC(GID).pOptProc))( &getpwnamOptions, \
getpwnamOptions.pOptDesc + 4 ) )
#define VALUE_OPT_GECOS 'N'
#define SET_OPT_GECOS STMTS( \
DESC(GECOS).optActualIndex = 5; \
DESC(GECOS).optActualValue = VALUE_OPT_GECOS; \
DESC(GECOS).fOptState &= OPTST_PERSISTENT; \
DESC(GECOS).fOptState |= OPTST_SET; \
(*(DESC(GECOS).pOptProc))( &getpwnamOptions, \
getpwnamOptions.pOptDesc + 5 ) )
#define VALUE_OPT_DIR 'd'
#define SET_OPT_DIR STMTS( \
DESC(DIR).optActualIndex = 6; \
DESC(DIR).optActualValue = VALUE_OPT_DIR; \
DESC(DIR).fOptState &= OPTST_PERSISTENT; \
DESC(DIR).fOptState |= OPTST_SET; \
(*(DESC(DIR).pOptProc))( &getpwnamOptions, \
getpwnamOptions.pOptDesc + 6 ) )
#define VALUE_OPT_SHELL 's'
#define SET_OPT_SHELL STMTS( \
DESC(SHELL).optActualIndex = 7; \
DESC(SHELL).optActualValue = VALUE_OPT_SHELL; \
DESC(SHELL).fOptState &= OPTST_PERSISTENT; \
DESC(SHELL).fOptState |= OPTST_SET; \
(*(DESC(SHELL).pOptProc))( &getpwnamOptions, \
getpwnamOptions.pOptDesc + 7 ) )
#define VALUE_OPT_ALL 'A'
#define SET_OPT_ALL STMTS( \
DESC(ALL).optActualIndex = 8; \
DESC(ALL).optActualValue = VALUE_OPT_ALL; \
DESC(ALL).fOptState &= OPTST_PERSISTENT; \
DESC(ALL).fOptState |= OPTST_SET; \
(*(DESC(ALL).pOptProc))( &getpwnamOptions, \
getpwnamOptions.pOptDesc + 8 ) )
#define VALUE_OPT_VERBOSE 'V'
#define SET_OPT_VERBOSE STMTS( \
DESC(VERBOSE).optActualIndex = 9; \
DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \
DESC(VERBOSE).fOptState &= OPTST_PERSISTENT; \
DESC(VERBOSE).fOptState |= OPTST_SET )
#define VALUE_OPT_VERSION INDEX_OPT_VERSION
#define VALUE_OPT_HELP 'h'
#define VALUE_OPT_MORE_HELP INDEX_OPT_MORE_HELP
/*
* Interface defines not associated with particular options
*/
#define ERRSKIP_OPTERR STMTS( getpwnamOptions.fOptSet &= ~OPTPROC_ERRSTOP )
#define ERRSTOP_OPTERR STMTS( getpwnamOptions.fOptSet |= OPTPROC_ERRSTOP )
#define RESTART_OPT(n) STMTS( \
getpwnamOptions.curOptIdx = (n); \
getpwnamOptions.pzCurOpt = NULL )
#define START_OPT RESTART_OPT(1)
#define USAGE(c) (*getpwnamOptions.pUsageProc)( &getpwnamOptions, c )
/* * * * * *
*
* Declare the getpwnam option descriptor.
*/
#ifdef __cplusplus
extern "C" {
#endif
extern tOptions getpwnamOptions;
/* * * * * *
*
* Globals exported from the Get user information from the passwd file option
definitions
*/
#include <stdio.h>
extern int selectCt;
int selections[INDEX_OPT_ALL];
extern int process_getpwnam_opts( int argc, char** argv );
#ifdef __cplusplus
}
#endif
#endif /* AUTOOPTS_GETPWNAM_OPTS_H_GUARD */
.TH GETPWNAM 1 2003-12-29 "" "Programmer's Manual"
.\" DO NOT EDIT THIS FILE (getpwnam.1)
.\"
.\" It has been AutoGen-ed Monday December 29, 2003 at 12:44:07 PM PST
.\" From the definitions getpwnam-opts.def
.\" and the template file agman1.tpl
.\"
.SH NAME
getpwnam \- Get user information from the passwd file
.SH SYNOPSIS
.B getpwnam
.\" Mixture of short (flag) options and long options
.RB [ -\fIflag\fP " [\fIvalue\fP]]... [" --\fIopt-name\fP " [[=|
]\fIvalue\fP]]..."
.br
.in +8
[ user-name-or-id ]
.PP
get (and print) information from the /etc/passwd database.
By default, information for the current user is provided.
.SH "DESCRIPTION"
This manual page documents, briefly, the \fBgetpwnam\fP command.
This command uses getpwnam(3) or getpwuid(3) to obtain the
requested information. If a user name or user id is not provided,
the information for the current user is obtained. The results are
printed in the order selected. If you select no options, nothing
is printed on success, but the user name/user id will have been
validated.
.SH OPTIONS
.TP
.BR -n ", " --name
Print the user name.
.sp
The user login name will be printed.
.TP
.BR -p ", " --passwd
Print the (encrypted) user password.
.sp
The encrypted password will be printed. If a shadow password
is used, the value will typically be the single letter "x".
.TP
.BR -u ", " --uid
Print the user id.
.sp
The numeric user id will be printed.
.TP
.BR -g ", " --gname
Print the group name.
.sp
The name of the user's primary group will be printed.
.TP
.BR -G ", " --gid
Print the group id.
.sp
The numeric primary group id will be printed.
.TP
.BR -N ", " --gecos
Print the real user name (comment string).
.sp
The real user name will be printed, usually.
It is designated as the account "comment string".
.TP
.BR -d ", " --dir
Print the home directory.
.sp
The user's home directory will be printed.
.TP
.BR -s ", " --shell
Print the login shell.
.sp
The name of the program that is run when the user logs in will be printed.
.TP
.BR -A ", " --all
Print everything.
This option must not appear in combination with any of the following options:
name, passwd, uid, gname, gid, gecos, dir, shell.
.sp
Print all of the available fields, including the name of
the primary group.
.TP
.BR -V ", " --verbose
Verbose output.
.sp
Print each item of information on a separate line, with
a short description of each.
.TP
.BR \-h , " \--help"
Display usage information and exit.
.TP
.BR \- , " \--more-help"
Extended usage information passed thru pager.
.TP
.BR \- " [{\fIv|c|n\fP}]," " \--version" "[=\fI{v|c|n}\fP]"
Output version of program and exit. The default mode is `v', a simple
version. The `c' mode will print copyright information and `n' will
print the full copyright notice.
.SH AUTHOR
Bruce Korb
.br
Please send bug reports to: address@hidden
.PP
Released under the GNU General Public License.
.PP
This manual page was \fIAutoGen\fP-erated from the \fBgetpwnam\fP
option definitions.
* getpwnam Invocation:: Invoking getpwnam
getpwnam.texi
Description: TeXInfo document
/* -*- buffer-read-only: t -*- vi: set ro:
*
* DO NOT EDIT THIS FILE (getopt-getpwnam.c)
*
* It has been AutoGen-ed Monday December 29, 2003 at 12:44:25 PM PST
* From the definitions getpwnam-opts.def
* and the template file getopt.tpl
*
* getpwnam is free software.
*
* You may redistribute it and/or modify it under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation; either version 2, or (at your option) any later version.
*
* getpwnam is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with getpwnam. See the file "COPYING". If not,
* write to: The Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <sys/types.h>
#include "getpwnam-opts.h"
#include <getopt.h>
#include "system.h"
static struct option a_long_opts[] = {
{ "name", 0, NULL, 'n' },
{ "passwd", 0, NULL, 'p' },
{ "uid", 0, NULL, 'u' },
{ "gname", 0, NULL, 'g' },
{ "gid", 0, NULL, 'G' },
{ "gecos", 0, NULL, 'N' },
{ "dir", 0, NULL, 'd' },
{ "shell", 0, NULL, 's' },
{ "all", 0, NULL, 'A' },
{ "verbose", 0, NULL, 'V' },
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 138 },
{ NULL, 0, NULL, 0 }
};
static char z_opts[] =
"npugGNdsAV";
/*
* AutoOpts library replacement routines:
*/
void
optionUsage (tOptions* pOptions, int status)
{
if (status != 0)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
getpwnamOptions.pzProgName);
else
{
fputs (_(
"getpwnam - Get user information from the passwd file - Ver. 1.0\n\
USAGE: getpwnam [ -<flag> | --<name> ]... [ user-name-or-id ]\n\n\
-n, --name Print the user name\n\
-p, --passwd Print the (encrypted) user password\n\
-u, --uid Print the user id\n\
-g, --gname Print the group name\n\
-G, --gid Print the group id\n\
-N, --gecos Print the real user name (comment string)\n\
-d, --dir Print the home directory\n\
-s, --shell Print the login shell\n\
-A, --all Print everything\n\
-V, --verbose Verbose output\n\
--version Output version information and exit\n\
-h, --help Display usage information and exit\n\n\
Options are specified by doubled hyphens and their name\n\
or by a single hyphen and the flag character.\n\n\
get (and print) information from the /etc/passwd database.\n\
By default, information for the current user is provided.\n\n\
please send bug reports to: address@hidden"), stdout);
}
exit (status);
}
void
doPagedUsage(
tOptions* pOptions,
tOptDesc* pOptDesc )
{
optionUsage (pOptions, EXIT_SUCCESS);
}
void
doVersion(
tOptions* pOptions,
tOptDesc* pOptDesc )
{
char* pz_by = _("getpwnam (core-utils) 1.0\n\
Written by Bruce Korb\n\n\
Copyright (C) 2003 by Free Software Foundation\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
fputs (pz_by, stdout);
exit (EXIT_SUCCESS);
}
static void
usage_too_many (const char* pz_optname)
{
char* pz = _("getpwnam error: the '%s' option appears more than once\n");
printf (pz, pz_optname);
USAGE( EXIT_FAILURE );
}
static void
usage_cannot (const char* pz_what, const char* pz_cant)
{
char* pz = _("getpwnam error: the %s option cannot appear with the %s
option\n");
printf (pz, pz_what, pz_cant);
USAGE (EXIT_FAILURE);
}
int
process_getpwnam_opts (int argc, char** argv)
{
{
char* pz_prog = strrchr (argv[0], '/');
if (pz_prog != NULL)
pz_prog++;
else
pz_prog = argv[0];
getpwnamOptions.pzProgName = pz_prog;
}
for (;;) {
int lidx;
int optc = getopt_long (argc, argv, z_opts, a_long_opts, &lidx);
switch (optc) {
case -1: goto leave_processing;
case 0: break;
case 'n':
if (HAVE_OPT( NAME ))
usage_too_many ("name");
SET_OPT_NAME;
break;
case 'p':
if (HAVE_OPT( PASSWD ))
usage_too_many ("passwd");
SET_OPT_PASSWD;
break;
case 'u':
if (HAVE_OPT( UID ))
usage_too_many ("uid");
SET_OPT_UID;
break;
case 'g':
if (HAVE_OPT( GNAME ))
usage_too_many ("gname");
SET_OPT_GNAME;
break;
case 'G':
if (HAVE_OPT( GID ))
usage_too_many ("gid");
SET_OPT_GID;
break;
case 'N':
if (HAVE_OPT( GECOS ))
usage_too_many ("gecos");
SET_OPT_GECOS;
break;
case 'd':
if (HAVE_OPT( DIR ))
usage_too_many ("dir");
SET_OPT_DIR;
break;
case 's':
if (HAVE_OPT( SHELL ))
usage_too_many ("shell");
SET_OPT_SHELL;
break;
case 'A':
if (HAVE_OPT( ALL ))
usage_too_many ("all");
SET_OPT_ALL;
break;
case 'V':
if (HAVE_OPT( VERBOSE ))
usage_too_many ("verbose");
SET_OPT_VERBOSE;
break;
case 'h': USAGE( EXIT_SUCCESS ); break;
case 138:
version_etc (stdout, "getpwnam",
"getpwnam",
"1.0", "Bruce Korb");
exit (EXIT_SUCCESS);
break;
default:
optionUsage (&getpwnamOptions, EXIT_FAILURE);
}
} leave_processing:;
if (HAVE_OPT( ALL )) {
static const char z_what[] = "all";
if (HAVE_OPT( NAME ))
usage_cannot (z_what, "name");
if (HAVE_OPT( PASSWD ))
usage_cannot (z_what, "passwd");
if (HAVE_OPT( UID ))
usage_cannot (z_what, "uid");
if (HAVE_OPT( GNAME ))
usage_cannot (z_what, "gname");
if (HAVE_OPT( GID ))
usage_cannot (z_what, "gid");
if (HAVE_OPT( GECOS ))
usage_cannot (z_what, "gecos");
if (HAVE_OPT( DIR ))
usage_cannot (z_what, "dir");
if (HAVE_OPT( SHELL ))
usage_cannot (z_what, "shell");
}
return 0;
}