1 /* Copyright (C) 1991, 1992, 1995, 1996 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 { "SOCK_MAXBUF", _PC_SOCK_MAXBUF
, PATHCONF
},
42 { "_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED
, PATHCONF
},
43 { "_POSIX_NO_TRUNC", _PC_NO_TRUNC
, PATHCONF
},
44 { "_POSIX_VDISABLE", _PC_VDISABLE
, PATHCONF
},
45 { "_POSIX_SYNC_IO", _PC_SYNC_IO
, PATHCONF
},
46 { "_POSIX_ASYNC_IO", _PC_ASYNC_IO
, PATHCONF
},
47 { "_POSIX_PRIO_IO", _PC_PRIO_IO
, PATHCONF
},
49 { "ARG_MAX", _SC_ARG_MAX
, SYSCONF
},
50 { "CHILD_MAX", _SC_CHILD_MAX
, SYSCONF
},
51 { "CLK_TCK", _SC_CLK_TCK
, SYSCONF
},
52 { "NGROUPS_MAX", _SC_NGROUPS_MAX
, SYSCONF
},
53 { "OPEN_MAX", _SC_OPEN_MAX
, SYSCONF
},
54 { "_POSIX_JOB_CONTROL", _SC_JOB_CONTROL
, SYSCONF
},
55 { "_POSIX_SAVED_IDS", _SC_SAVED_IDS
, SYSCONF
},
56 { "_POSIX_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS
, SYSCONF
},
57 { "_POSIX_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING
, SYSCONF
},
58 { "_POSIX_TIMERS", _SC_TIMERS
, SYSCONF
},
59 { "_POSIX_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO
, SYSCONF
},
60 { "_POSIX_PRIORITIZED_IO", _SC_PRIORITIZED_IO
, SYSCONF
},
61 { "_POSIX_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO
, SYSCONF
},
62 { "_POSIX_FSYNC", _SC_FSYNC
, SYSCONF
},
63 { "_POSIX_MAPPED_FILES", _SC_MAPPED_FILES
, SYSCONF
},
64 { "_POSIX_MEMLOCK", _SC_MEMLOCK
, SYSCONF
},
65 { "_POSIX_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE
, SYSCONF
},
66 { "_POSIX_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION
, SYSCONF
},
67 { "_POSIX_MESSAGE_PASSING", _SC_MESSAGE_PASSING
, SYSCONF
},
68 { "_POSIX_SEMAPHORES", _SC_SEMAPHORES
, SYSCONF
},
69 { "_POSIX_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS
, SYSCONF
},
70 { "_POSIX_VERSION", _SC_VERSION
, SYSCONF
},
71 { "_POSIX_PII", _SC_PII
, SYSCONF
},
72 { "_POSIX_PII_XTI", _SC_PII_XTI
, SYSCONF
},
73 { "_POSIX_PII_SOCKET", _SC_PII_SOCKET
, SYSCONF
},
74 { "_POSIX_PII_INTERNET", _SC_PII_INTERNET
, SYSCONF
},
75 { "_POSIX_PII_OSI", _SC_PII_OSI
, SYSCONF
},
76 { "_POSIX_POLL", _SC_POLL
, SYSCONF
},
77 { "_POSIX_SELECT", _SC_SELECT
, SYSCONF
},
78 { "UIO_MAXIOV", _SC_UIO_MAXIOV
, SYSCONF
},
79 { "_POSIX_PII_INTERNET_STREAM", _SC_PII_INTERNET_STREAM
, SYSCONF
},
80 { "_POSIX_PII_INTERNET_DGRAM", _SC_PII_INTERNET_DGRAM
, SYSCONF
},
81 { "_POSIX_PII_OSI_COTS", _SC_PII_OSI_COTS
, SYSCONF
},
82 { "_POSIX_PII_OSI_CLTS", _SC_PII_OSI_CLTS
, SYSCONF
},
83 { "_POSIX_PII_OSI_M", _SC_PII_OSI_M
, SYSCONF
},
84 { "_T_IOV_MAX", _SC_T_IOV_MAX
, SYSCONF
},
86 { "PATH", _CS_PATH
, CONFSTR
},
91 static CONST
char *program
;
96 fprintf (stderr
, _("Usage: %s variable_name [pathname]\n"), program
);
101 DEFUN(main
, (argc
, argv
), int argc AND
char **argv
)
103 register CONST
struct conf
*c
;
105 program
= strrchr (argv
[0], '/');
111 if (argc
< 2 || argc
> 3)
114 for (c
= vars
; c
->name
!= NULL
; ++c
)
115 if (!strcmp (c
->name
, argv
[1]))
125 value
= pathconf (argv
[2], c
->call_name
);
128 fprintf (stderr
, "%s: pathconf: %s: %s\n",
129 program
, argv
[2], strerror (errno
));
132 printf ("%ld\n", value
);
138 value
= sysconf (c
->call_name
);
139 printf ("%ld\n", value
);
145 clen
= confstr (c
->call_name
, (char *) NULL
, 0);
146 cvalue
= (char *) malloc (clen
);
149 fprintf (stderr
, "%s: malloc: %s\n",
150 program
, strerror (errno
));
153 if (confstr (c
->call_name
, cvalue
, clen
) != clen
)
155 fprintf (stderr
, "%s: confstr: %s\n",
156 program
, strerror (errno
));
159 printf ("%.*s\n", (int) clen
, cvalue
);
164 fprintf (stderr
, _("%s: Unrecognized variable `%s'\n"), program
, argv
[1]);