1 /* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
30 CONST
enum { SYSCONF
, CONFSTR
, PATHCONF
} call
;
33 static struct conf vars
[] =
35 { "LINK_MAX", _PC_LINK_MAX
, PATHCONF
},
36 { "MAX_CANON", _PC_MAX_CANON
, PATHCONF
},
37 { "MAX_INPUT", _PC_MAX_INPUT
, PATHCONF
},
38 { "NAME_MAX", _PC_NAME_MAX
, PATHCONF
},
39 { "PATH_MAX", _PC_PATH_MAX
, PATHCONF
},
40 { "PIPE_BUF", _PC_PIPE_BUF
, PATHCONF
},
41 { "_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED
, PATHCONF
},
42 { "_POSIX_NO_TRUNC", _PC_NO_TRUNC
, PATHCONF
},
43 { "_POSIX_VDISABLE", _PC_VDISABLE
, PATHCONF
},
45 { "ARG_MAX", _SC_ARG_MAX
, SYSCONF
},
46 { "CHILD_MAX", _SC_CHILD_MAX
, SYSCONF
},
47 { "CLK_TCK", _SC_CLK_TCK
, SYSCONF
},
48 { "NGROUPS_MAX", _SC_NGROUPS_MAX
, SYSCONF
},
49 { "OPEN_MAX", _SC_OPEN_MAX
, SYSCONF
},
50 { "_POSIX_JOB_CONTROL", _SC_JOB_CONTROL
, SYSCONF
},
51 { "_POSIX_SAVED_IDS", _SC_SAVED_IDS
, SYSCONF
},
52 { "_POSIX_VERSION", _SC_VERSION
, SYSCONF
},
54 { "PATH", _CS_PATH
, CONFSTR
},
59 static CONST
char *program
;
64 fprintf (stderr
, _("Usage: %s variable_name [pathname]\n"), program
);
69 DEFUN(main
, (argc
, argv
), int argc AND
char **argv
)
71 register CONST
struct conf
*c
;
73 program
= strrchr (argv
[0], '/');
79 if (argc
< 2 || argc
> 3)
82 for (c
= vars
; c
->name
!= NULL
; ++c
)
83 if (!strcmp (c
->name
, argv
[1]))
93 value
= pathconf (argv
[2], c
->call_name
);
96 fprintf (stderr
, "%s: pathconf: %s: %s\n",
97 program
, argv
[2], strerror (errno
));
100 printf ("%ld\n", value
);
106 value
= sysconf (c
->call_name
);
107 printf ("%ld\n", value
);
113 clen
= confstr (c
->call_name
, (char *) NULL
, 0);
114 cvalue
= (char *) malloc (clen
);
117 fprintf (stderr
, "%s: malloc: %s\n",
118 program
, strerror (errno
));
121 if (confstr (c
->call_name
, cvalue
, clen
) != clen
)
123 fprintf (stderr
, "%s: confstr: %s\n",
124 program
, strerror (errno
));
127 printf ("%.*s\n", (int) clen
, cvalue
);
132 fprintf (stderr
, _("%s: Unrecognized variable `%s'\n"), program
, argv
[1]);