Update.
[glibc.git] / posix / getconf.c
blobc6b10fd27fd2036655f8be96b8cd8fd4001f2fad
1 /* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 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 not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #include <unistd.h>
20 #include <errno.h>
21 #include <error.h>
22 #include <libintl.h>
23 #include <locale.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include <stdio.h>
28 #include "../version.h"
29 #define PACKAGE _libc_intl_domainname
31 struct conf
33 const char *name;
34 const int call_name;
35 const enum { SYSCONF, CONFSTR, PATHCONF } call;
38 static const struct conf vars[] =
40 #ifdef _PC_LINK_MAX
41 { "LINK_MAX", _PC_LINK_MAX, PATHCONF },
42 #endif
43 #ifdef _PC_LINK_MAX
44 { "_POSIX_LINK_MAX", _PC_LINK_MAX, PATHCONF },
45 #endif
46 #ifdef _PC_MAX_CANON
47 { "MAX_CANON", _PC_MAX_CANON, PATHCONF },
48 #endif
49 #ifdef _PC_MAX_CANON
50 { "_POSIX_MAX_CANON", _PC_MAX_CANON, PATHCONF },
51 #endif
52 #ifdef _PC_MAX_INPUT
53 { "MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
54 #endif
55 #ifdef _PC_MAX_INPUT
56 { "_POSIX_MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
57 #endif
58 #ifdef _PC_NAME_MAX
59 { "NAME_MAX", _PC_NAME_MAX, PATHCONF },
60 #endif
61 #ifdef _PC_NAME_MAX
62 { "_POSIX_NAME_MAX", _PC_NAME_MAX, PATHCONF },
63 #endif
64 #ifdef _PC_PATH_MAX
65 { "PATH_MAX", _PC_PATH_MAX, PATHCONF },
66 #endif
67 #ifdef _PC_PATH_MAX
68 { "_POSIX_PATH_MAX", _PC_PATH_MAX, PATHCONF },
69 #endif
70 #ifdef _PC_PIPE_BUF
71 { "PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
72 #endif
73 #ifdef _PC_PIPE_BUF
74 { "_POSIX_PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
75 #endif
76 #ifdef _PC_SOCK_MAXBUF
77 { "SOCK_MAXBUF", _PC_SOCK_MAXBUF, PATHCONF },
78 #endif
79 #ifdef _PC_ASYNC_IO
80 { "_POSIX_ASYNC_IO", _PC_ASYNC_IO, PATHCONF },
81 #endif
82 #ifdef _PC_CHOWN_RESTRICTED
83 { "_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED, PATHCONF },
84 #endif
85 #ifdef _PC_NO_TRUNC
86 { "_POSIX_NO_TRUNC", _PC_NO_TRUNC, PATHCONF },
87 #endif
88 #ifdef _PC_PRIO_IO
89 { "_POSIX_PRIO_IO", _PC_PRIO_IO, PATHCONF },
90 #endif
91 #ifdef _PC_SYNC_IO
92 { "_POSIX_SYNC_IO", _PC_SYNC_IO, PATHCONF },
93 #endif
94 #ifdef _PC_VDISABLE
95 { "_POSIX_VDISABLE", _PC_VDISABLE, PATHCONF },
96 #endif
98 #ifdef _SC_ARG_MAX
99 { "ARG_MAX", _SC_ARG_MAX, SYSCONF },
100 #endif
101 #ifdef _SC_ATEXIT_MAX
102 { "ATEXIT_MAX", _SC_ATEXIT_MAX, SYSCONF },
103 #endif
104 #ifdef _SC_CHAR_BIT
105 { "CHAR_BIT", _SC_CHAR_BIT, SYSCONF },
106 #endif
107 #ifdef _SC_CHAR_MAX
108 { "CHAR_MAX", _SC_CHAR_MAX, SYSCONF },
109 #endif
110 #ifdef _SC_CHAR_MIN
111 { "CHAR_MIN", _SC_CHAR_MIN, SYSCONF },
112 #endif
113 #ifdef _SC_CHILD_MAX
114 { "CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
115 #endif
116 #ifdef _SC_CLK_TCK
117 { "CLK_TCK", _SC_CLK_TCK, SYSCONF },
118 #endif
119 #ifdef _SC_INT_MAX
120 { "INT_MAX", _SC_INT_MAX, SYSCONF },
121 #endif
122 #ifdef _SC_INT_MIN
123 { "INT_MIN", _SC_INT_MIN, SYSCONF },
124 #endif
125 #ifdef _SC_UIO_MAXIOV
126 { "IOV_MAX", _SC_UIO_MAXIOV, SYSCONF },
127 #endif
128 #ifdef _SC_LOGIN_NAME_MAX
129 { "LOGNAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
130 #endif
131 #ifdef _SC_LONG_BIT
132 { "LONG_BIT", _SC_LONG_BIT, SYSCONF },
133 #endif
134 #ifdef _SC_MB_LEN_MAX
135 { "MB_LEN_MAX", _SC_MB_LEN_MAX, SYSCONF },
136 #endif
137 #ifdef _SC_NGROUPS_MAX
138 { "NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
139 #endif
140 #ifdef _SC_NL_ARGMAX
141 { "NL_ARGMAX", _SC_NL_ARGMAX, SYSCONF },
142 #endif
143 #ifdef _SC_NL_LANGMAX
144 { "NL_LANGMAX", _SC_NL_LANGMAX, SYSCONF },
145 #endif
146 #ifdef _SC_NL_MSGMAX
147 { "NL_MSGMAX", _SC_NL_MSGMAX, SYSCONF },
148 #endif
149 #ifdef _SC_NL_NMAX
150 { "NL_NMAX", _SC_NL_NMAX, SYSCONF },
151 #endif
152 #ifdef _SC_NL_SETMAX
153 { "NL_SETMAX", _SC_NL_SETMAX, SYSCONF },
154 #endif
155 #ifdef _SC_NL_TEXTMAX
156 { "NL_TEXTMAX", _SC_NL_TEXTMAX, SYSCONF },
157 #endif
158 #ifdef _SC_GETGR_R_SIZE_MAX
159 { "NSS_BUFLEN_GROUP", _SC_GETGR_R_SIZE_MAX, SYSCONF },
160 #endif
161 #ifdef _SC_GETPW_R_SIZE_MAX
162 { "NSS_BUFLEN_PASSWD", _SC_GETPW_R_SIZE_MAX, SYSCONF },
163 #endif
164 #ifdef _SC_NZERO
165 { "NZERO", _SC_NZERO, SYSCONF },
166 #endif
167 #ifdef _SC_OPEN_MAX
168 { "OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
169 #endif
170 #ifdef _SC_PAGESIZE
171 { "PAGESIZE", _SC_PAGESIZE, SYSCONF },
172 #endif
173 #ifdef _SC_PAGESIZE
174 { "PAGE_SIZE", _SC_PAGESIZE, SYSCONF },
175 #endif
176 #ifdef _SC_PASS_MAX
177 { "PASS_MAX", _SC_PASS_MAX, SYSCONF },
178 #endif
179 #ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
180 { "PTHREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS, SYSCONF },
181 #endif
182 #ifdef _SC_THREAD_KEYS_MAX
183 { "PTHREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX, SYSCONF },
184 #endif
185 #ifdef _SC_THREAD_STACK_MIN
186 { "PTHREAD_STACK_MIN", _SC_THREAD_STACK_MIN, SYSCONF },
187 #endif
188 #ifdef _SC_THREAD_THREADS_MAX
189 { "PTHREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX, SYSCONF },
190 #endif
191 #ifdef _SC_SCHAR_MAX
192 { "SCHAR_MAX", _SC_SCHAR_MAX, SYSCONF },
193 #endif
194 #ifdef _SC_SCHAR_MIN
195 { "SCHAR_MIN", _SC_SCHAR_MIN, SYSCONF },
196 #endif
197 #ifdef _SC_SHRT_MAX
198 { "SHRT_MAX", _SC_SHRT_MAX, SYSCONF },
199 #endif
200 #ifdef _SC_SHRT_MIN
201 { "SHRT_MIN", _SC_SHRT_MIN, SYSCONF },
202 #endif
203 #ifdef _SC_SSIZE_MAX
204 { "SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
205 #endif
206 #ifdef _SC_TTY_NAME_MAX
207 { "TTY_NAME_MAX", _SC_TTY_NAME_MAX, SYSCONF },
208 #endif
209 #ifdef _SC_TZNAME_MAX
210 { "TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
211 #endif
212 #ifdef _SC_UCHAR_MAX
213 { "UCHAR_MAX", _SC_UCHAR_MAX, SYSCONF },
214 #endif
215 #ifdef _SC_UINT_MAX
216 { "UINT_MAX", _SC_UINT_MAX, SYSCONF },
217 #endif
218 #ifdef _SC_UIO_MAXIOV
219 { "UIO_MAXIOV", _SC_UIO_MAXIOV, SYSCONF },
220 #endif
221 #ifdef _SC_ULONG_MAX
222 { "ULONG_MAX", _SC_ULONG_MAX, SYSCONF },
223 #endif
224 #ifdef _SC_USHRT_MAX
225 { "USHRT_MAX", _SC_USHRT_MAX, SYSCONF },
226 #endif
227 #ifdef _SC_WORD_BIT
228 { "WORD_BIT", _SC_WORD_BIT, SYSCONF },
229 #endif
230 #ifdef _SC_AVPHYS_PAGES
231 { "_AVPHYS_PAGES", _SC_AVPHYS_PAGES, SYSCONF },
232 #endif
233 #ifdef _SC_NPROCESSORS_CONF
234 { "_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF, SYSCONF },
235 #endif
236 #ifdef _SC_NPROCESSORS_ONLN
237 { "_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN, SYSCONF },
238 #endif
239 #ifdef _SC_PHYS_PAGES
240 { "_PHYS_PAGES", _SC_PHYS_PAGES, SYSCONF },
241 #endif
242 #ifdef _SC_ARG_MAX
243 { "_POSIX_ARG_MAX", _SC_ARG_MAX, SYSCONF },
244 #endif
245 #ifdef _SC_ASYNCHRONOUS_IO
246 { "_POSIX_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO, SYSCONF },
247 #endif
248 #ifdef _SC_CHILD_MAX
249 { "_POSIX_CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
250 #endif
251 #ifdef _SC_FSYNC
252 { "_POSIX_FSYNC", _SC_FSYNC, SYSCONF },
253 #endif
254 #ifdef _SC_JOB_CONTROL
255 { "_POSIX_JOB_CONTROL", _SC_JOB_CONTROL, SYSCONF },
256 #endif
257 #ifdef _SC_MAPPED_FILES
258 { "_POSIX_MAPPED_FILES", _SC_MAPPED_FILES, SYSCONF },
259 #endif
260 #ifdef _SC_MEMLOCK
261 { "_POSIX_MEMLOCK", _SC_MEMLOCK, SYSCONF },
262 #endif
263 #ifdef _SC_MEMLOCK_RANGE
264 { "_POSIX_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE, SYSCONF },
265 #endif
266 #ifdef _SC_MEMORY_PROTECTION
267 { "_POSIX_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION, SYSCONF },
268 #endif
269 #ifdef _SC_MESSAGE_PASSING
270 { "_POSIX_MESSAGE_PASSING", _SC_MESSAGE_PASSING, SYSCONF },
271 #endif
272 #ifdef _SC_NGROUPS_MAX
273 { "_POSIX_NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
274 #endif
275 #ifdef _SC_OPEN_MAX
276 { "_POSIX_OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
277 #endif
278 #ifdef _SC_PII
279 { "_POSIX_PII", _SC_PII, SYSCONF },
280 #endif
281 #ifdef _SC_PII_INTERNET
282 { "_POSIX_PII_INTERNET", _SC_PII_INTERNET, SYSCONF },
283 #endif
284 #ifdef _SC_PII_INTERNET_DGRAM
285 { "_POSIX_PII_INTERNET_DGRAM", _SC_PII_INTERNET_DGRAM, SYSCONF },
286 #endif
287 #ifdef _SC_PII_INTERNET_STREAM
288 { "_POSIX_PII_INTERNET_STREAM", _SC_PII_INTERNET_STREAM, SYSCONF },
289 #endif
290 #ifdef _SC_PII_OSI
291 { "_POSIX_PII_OSI", _SC_PII_OSI, SYSCONF },
292 #endif
293 #ifdef _SC_PII_OSI_CLTS
294 { "_POSIX_PII_OSI_CLTS", _SC_PII_OSI_CLTS, SYSCONF },
295 #endif
296 #ifdef _SC_PII_OSI_COTS
297 { "_POSIX_PII_OSI_COTS", _SC_PII_OSI_COTS, SYSCONF },
298 #endif
299 #ifdef _SC_PII_OSI_M
300 { "_POSIX_PII_OSI_M", _SC_PII_OSI_M, SYSCONF },
301 #endif
302 #ifdef _SC_PII_SOCKET
303 { "_POSIX_PII_SOCKET", _SC_PII_SOCKET, SYSCONF },
304 #endif
305 #ifdef _SC_PII_XTI
306 { "_POSIX_PII_XTI", _SC_PII_XTI, SYSCONF },
307 #endif
308 #ifdef _SC_POLL
309 { "_POSIX_POLL", _SC_POLL, SYSCONF },
310 #endif
311 #ifdef _SC_PRIORITIZED_IO
312 { "_POSIX_PRIORITIZED_IO", _SC_PRIORITIZED_IO, SYSCONF },
313 #endif
314 #ifdef _SC_PRIORITY_SCHEDULING
315 { "_POSIX_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING, SYSCONF },
316 #endif
317 #ifdef _SC_REALTIME_SIGNALS
318 { "_POSIX_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS, SYSCONF },
319 #endif
320 #ifdef _SC_SAVED_IDS
321 { "_POSIX_SAVED_IDS", _SC_SAVED_IDS, SYSCONF },
322 #endif
323 #ifdef _SC_SELECT
324 { "_POSIX_SELECT", _SC_SELECT, SYSCONF },
325 #endif
326 #ifdef _SC_SEMAPHORES
327 { "_POSIX_SEMAPHORES", _SC_SEMAPHORES, SYSCONF },
328 #endif
329 #ifdef _SC_SHARED_MEMORY_OBJECTS
330 { "_POSIX_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS, SYSCONF },
331 #endif
332 #ifdef _SC_SSIZE_MAX
333 { "_POSIX_SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
334 #endif
335 #ifdef _SC_STREAM_MAX
336 { "_POSIX_STREAM_MAX", _SC_STREAM_MAX, SYSCONF },
337 #endif
338 #ifdef _SC_SYNCHRONIZED_IO
339 { "_POSIX_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO, SYSCONF },
340 #endif
341 #ifdef _SC_THREADS
342 { "_POSIX_THREADS", _SC_THREADS, SYSCONF },
343 #endif
344 #ifdef _SC_THREAD_ATTR_STACKADDR
345 { "_POSIX_THREAD_ATTR_STACKADDR", _SC_THREAD_ATTR_STACKADDR, SYSCONF },
346 #endif
347 #ifdef _SC_THREAD_ATTR_STACKSIZE
348 { "_POSIX_THREAD_ATTR_STACKSIZE", _SC_THREAD_ATTR_STACKSIZE, SYSCONF },
349 #endif
350 #ifdef _SC_THREAD_PRIORITY_SCHEDULING
351 { "_POSIX_THREAD_PRIORITY_SCHEDULING", _SC_THREAD_PRIORITY_SCHEDULING, SYSCONF },
352 #endif
353 #ifdef _SC_THREAD_PRIO_INHERIT
354 { "_POSIX_THREAD_PRIO_INHERIT", _SC_THREAD_PRIO_INHERIT, SYSCONF },
355 #endif
356 #ifdef _SC_THREAD_PRIO_PROTECT
357 { "_POSIX_THREAD_PRIO_PROTECT", _SC_THREAD_PRIO_PROTECT, SYSCONF },
358 #endif
359 #ifdef _SC_THREAD_PROCESS_SHARED
360 { "_POSIX_THREAD_PROCESS_SHARED", _SC_THREAD_PROCESS_SHARED, SYSCONF },
361 #endif
362 #ifdef _SC_THREAD_SAFE_FUNCTIONS
363 { "_POSIX_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS, SYSCONF },
364 #endif
365 #ifdef _SC_TIMERS
366 { "_POSIX_TIMERS", _SC_TIMERS, SYSCONF },
367 #endif
368 #ifdef _SC_TZNAME_MAX
369 { "_POSIX_TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
370 #endif
371 #ifdef _SC_VERSION
372 { "_POSIX_VERSION", _SC_VERSION, SYSCONF },
373 #endif
374 #ifdef _SC_T_IOV_MAX
375 { "_T_IOV_MAX", _SC_T_IOV_MAX, SYSCONF },
376 #endif
377 #ifdef _SC_XOPEN_CRYPT
378 { "_XOPEN_CRYPT", _SC_XOPEN_CRYPT, SYSCONF },
379 #endif
380 #ifdef _SC_XOPEN_ENH_I18N
381 { "_XOPEN_ENH_I18N", _SC_XOPEN_ENH_I18N, SYSCONF },
382 #endif
383 #ifdef _SC_XOPEN_LEGACY
384 { "_XOPEN_LEGACY", _SC_XOPEN_LEGACY, SYSCONF },
385 #endif
386 #ifdef _SC_XOPEN_REALTIME
387 { "_XOPEN_REALTIME", _SC_XOPEN_REALTIME, SYSCONF },
388 #endif
389 #ifdef _SC_XOPEN_REALTIME_THREADS
390 { "_XOPEN_REALTIME_THREADS", _SC_XOPEN_REALTIME_THREADS, SYSCONF },
391 #endif
392 #ifdef _SC_XOPEN_SHM
393 { "_XOPEN_SHM", _SC_XOPEN_SHM, SYSCONF },
394 #endif
395 #ifdef _SC_XOPEN_UNIX
396 { "_XOPEN_UNIX", _SC_XOPEN_UNIX, SYSCONF },
397 #endif
398 #ifdef _SC_XOPEN_VERSION
399 { "_XOPEN_VERSION", _SC_XOPEN_VERSION, SYSCONF },
400 #endif
401 #ifdef _SC_XOPEN_XCU_VERSION
402 { "_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION, SYSCONF },
403 #endif
404 #ifdef _SC_XOPEN_XPG2
405 { "_XOPEN_XPG2", _SC_XOPEN_XPG2, SYSCONF },
406 #endif
407 #ifdef _SC_XOPEN_XPG3
408 { "_XOPEN_XPG3", _SC_XOPEN_XPG3, SYSCONF },
409 #endif
410 #ifdef _SC_XOPEN_XPG4
411 { "_XOPEN_XPG4", _SC_XOPEN_XPG4, SYSCONF },
412 #endif
413 /* POSIX.2 */
414 #ifdef _SC_BC_BASE_MAX
415 { "BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
416 #endif
417 #ifdef _SC_BC_DIM_MAX
418 { "BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
419 #endif
420 #ifdef _SC_BC_SCALE_MAX
421 { "BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
422 #endif
423 #ifdef _SC_BC_STRING_MAX
424 { "BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
425 #endif
426 { "CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX, SYSCONF },
427 #ifdef _SC_COLL_WEIGHTS_MAX
428 { "COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
429 #endif
430 #ifdef _SC_EQUIV_CLASS_MAX
431 { "EQUIV_CLASS_MAX", _SC_EQUIV_CLASS_MAX, SYSCONF },
432 #endif
433 #ifdef _SC_EXPR_NEST_MAX
434 { "EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
435 #endif
436 #ifdef _SC_LINE_MAX
437 { "LINE_MAX", _SC_LINE_MAX, SYSCONF },
438 #endif
439 #ifdef _SC_BC_BASE_MAX
440 { "POSIX2_BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
441 #endif
442 #ifdef _SC_BC_DIM_MAX
443 { "POSIX2_BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
444 #endif
445 #ifdef _SC_BC_SCALE_MAX
446 { "POSIX2_BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
447 #endif
448 #ifdef _SC_BC_STRING_MAX
449 { "POSIX2_BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
450 #endif
451 #ifdef _SC_2_CHAR_TERM
452 { "POSIX2_CHAR_TERM", _SC_2_CHAR_TERM, SYSCONF },
453 #endif
454 #ifdef _SC_COLL_WEIGHTS_MAX
455 { "POSIX2_COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
456 #endif
457 #ifdef _SC_2_C_BIND
458 { "POSIX2_C_BIND", _SC_2_C_BIND, SYSCONF },
459 #endif
460 #ifdef _SC_2_C_DEV
461 { "POSIX2_C_DEV", _SC_2_C_DEV, SYSCONF },
462 #endif
463 #ifdef _SC_2_C_VERSION
464 { "POSIX2_C_VERSION", _SC_2_C_VERSION, SYSCONF },
465 #endif
466 #ifdef _SC_EXPR_NEST_MAX
467 { "POSIX2_EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
468 #endif
469 #ifdef _SC_2_FORT_DEV
470 { "POSIX2_FORT_DEV", _SC_2_FORT_DEV, SYSCONF },
471 #endif
472 #ifdef _SC_2_FORT_RUN
473 { "POSIX2_FORT_RUN", _SC_2_FORT_RUN, SYSCONF },
474 #endif
475 #ifdef _SC_LINE_MAX
476 { "POSIX2_LINE_MAX", _SC_LINE_MAX, SYSCONF },
477 #endif
478 #ifdef _SC_2_LOCALEDEF
479 { "POSIX2_LOCALEDEF", _SC_2_LOCALEDEF, SYSCONF },
480 #endif
481 #ifdef _SC_RE_DUP_MAX
482 { "POSIX2_RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
483 #endif
484 #ifdef _SC_2_SW_DEV
485 { "POSIX2_SW_DEV", _SC_2_SW_DEV, SYSCONF },
486 #endif
487 #ifdef _SC_2_UPE
488 { "POSIX2_UPE", _SC_2_UPE, SYSCONF },
489 #endif
490 #ifdef _SC_2_VERSION
491 { "POSIX2_VERSION", _SC_2_VERSION, SYSCONF },
492 #endif
493 #ifdef _SC_RE_DUP_MAX
494 { "RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
495 #endif
497 #ifdef _CS_PATH
498 { "PATH", _CS_PATH, CONFSTR },
499 #endif
500 #ifdef _CS_PATH
501 { "CS_PATH", _CS_PATH, CONFSTR },
502 #endif
504 /* LFS */
505 #ifdef _CS_LFS_CFLAGS
506 { "LFS_CFLAGS", _CS_LFS_CFLAGS, CONFSTR },
507 #endif
508 #ifdef _CS_LFS_LDFLAGS
509 { "LFS_LDFLAGS", _CS_LFS_LDFLAGS, CONFSTR },
510 #endif
511 #ifdef _CS_LFS_LIBS
512 { "LFS_LIBS", _CS_LFS_LIBS, CONFSTR },
513 #endif
514 #ifdef _CS_LFS_LINTFLAGS
515 { "LFS_LINTFLAGS", _CS_LFS_LINTFLAGS, CONFSTR },
516 #endif
517 #ifdef _CS_LFS64_CFLAGS
518 { "LFS64_CFLAGS", _CS_LFS64_CFLAGS, CONFSTR },
519 #endif
520 #ifdef _CS_LFS64_LDFLAGS
521 { "LFS64_LDFLAGS", _CS_LFS64_LDFLAGS, CONFSTR },
522 #endif
523 #ifdef _CS_LFS64_LIBS
524 { "LFS64_LIBS", _CS_LFS64_LIBS, CONFSTR },
525 #endif
526 #ifdef _CS_LFS64_LINTFLAGS
527 { "LFS64_LINTFLAGS", _CS_LFS64_LINTFLAGS, CONFSTR },
528 #endif
530 /* Programming environments. */
531 #ifdef _SC_XBS5_ILP32_OFF32
532 { "XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32, SYSCONF },
533 #endif
534 #ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
535 { "XBS5_ILP32_OFF32_CFLAGS", _CS_XBS5_ILP32_OFF32_CFLAGS, CONFSTR },
536 #endif
537 #ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
538 { "XBS5_ILP32_OFF32_LDFLAGS", _CS_XBS5_ILP32_OFF32_LDFLAGS, CONFSTR },
539 #endif
540 #ifdef _CS_XBS5_ILP32_OFF32_LIBS
541 { "XBS5_ILP32_OFF32_LIBS", _CS_XBS5_ILP32_OFF32_LIBS, CONFSTR },
542 #endif
543 #ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
544 { "XBS5_ILP32_OFF32_LINTFLAGS", _CS_XBS5_ILP32_OFF32_LINTFLAGS, CONFSTR },
545 #endif
547 #ifdef _SC_XBS5_ILP32_OFFBIG
548 { "XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG, SYSCONF },
549 #endif
550 #ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
551 { "XBS5_ILP32_OFFBIG_CFLAGS", _CS_XBS5_ILP32_OFFBIG_CFLAGS, CONFSTR },
552 #endif
553 #ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
554 { "XBS5_ILP32_OFFBIG_LDFLAGS", _CS_XBS5_ILP32_OFFBIG_LDFLAGS, CONFSTR },
555 #endif
556 #ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
557 { "XBS5_ILP32_OFFBIG_LIBS", _CS_XBS5_ILP32_OFFBIG_LIBS, CONFSTR },
558 #endif
559 #ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
560 { "XBS5_ILP32_OFFBIG_LINTFLAGS", _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
561 #endif
563 #ifdef _SC_XBS5_LP64_OFF64
564 { "XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64, SYSCONF },
565 #endif
566 #ifdef _CS_XBS5_LP64_OFF64_CFLAGS
567 { "XBS5_LP64_OFF64_CFLAGS", _CS_XBS5_LP64_OFF64_CFLAGS, CONFSTR },
568 #endif
569 #ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
570 { "XBS5_LP64_OFF64_LDFLAGS", _CS_XBS5_LP64_OFF64_LDFLAGS, CONFSTR },
571 #endif
572 #ifdef _CS_XBS5_LP64_OFF64_LIBS
573 { "XBS5_LP64_OFF64_LIBS", _CS_XBS5_LP64_OFF64_LIBS, CONFSTR },
574 #endif
575 #ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
576 { "XBS5_LP64_OFF64_LINTFLAGS", _CS_XBS5_LP64_OFF64_LINTFLAGS, CONFSTR },
577 #endif
579 #ifdef _SC_XBS5_LPBIG_OFFBIG
580 { "XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG, SYSCONF },
581 #endif
582 #ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
583 { "XBS5_LPBIG_OFFBIG_CFLAGS", _CS_XBS5_LPBIG_OFFBIG_CFLAGS, CONFSTR },
584 #endif
585 #ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
586 { "XBS5_LPBIG_OFFBIG_LDFLAGS", _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
587 #endif
588 #ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
589 { "XBS5_LPBIG_OFFBIG_LIBS", _CS_XBS5_LPBIG_OFFBIG_LIBS, CONFSTR },
590 #endif
591 #ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
592 { "XBS5_LPBIG_OFFBIG_LINTFLAGS", _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
593 #endif
595 { NULL, 0, SYSCONF }
598 extern const char *__progname;
601 static void
602 usage (void)
604 fprintf (stderr, _("Usage: %s variable_name [pathname]\n"), __progname);
605 exit (2);
609 main (int argc, char *argv[])
611 register const struct conf *c;
613 /* Set locale. Do not set LC_ALL because the other categories must
614 not be affected (according to POSIX.2). */
615 setlocale (LC_CTYPE, "");
616 setlocale (LC_MESSAGES, "");
618 /* Initialize the message catalog. */
619 textdomain (PACKAGE);
621 if (argc > 1 && strcmp (argv[1], "--version") == 0)
623 fprintf (stderr, "getconf (GNU %s) %s\n", PACKAGE, VERSION);
624 fprintf (stderr, gettext ("\
625 Copyright (C) %s Free Software Foundation, Inc.\n\
626 This is free software; see the source for copying conditions. There is NO\n\
627 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
628 "), "1999");
629 fprintf (stderr, gettext ("Written by %s.\n"), "Roland McGrath");
630 return 0;
633 if (argc < 2 || argc > 3)
634 usage ();
636 for (c = vars; c->name != NULL; ++c)
637 if (!strcmp (c->name, argv[1]))
639 long int value;
640 size_t clen;
641 char *cvalue;
642 switch (c->call)
644 case PATHCONF:
645 if (argc < 3)
646 usage ();
647 errno = 0;
648 value = pathconf (argv[2], c->call_name);
649 if (value == -1)
651 if (errno)
652 error (3, errno, "pathconf: %s", argv[2]);
653 else
654 puts (_("undefined"));
656 else
657 printf ("%ld\n", value);
658 exit (0);
660 case SYSCONF:
661 if (argc > 2)
662 usage ();
663 value = sysconf (c->call_name);
664 if (value == -1l)
666 if (c->call_name == _SC_UINT_MAX
667 || c->call_name == _SC_ULONG_MAX)
668 printf ("%lu\n", value);
669 else
670 puts (_("undefined"));
672 else
673 printf ("%ld\n", value);
674 exit (0);
676 case CONFSTR:
677 if (argc > 2)
678 usage ();
679 clen = confstr (c->call_name, (char *) NULL, 0);
680 cvalue = (char *) malloc (clen);
681 if (cvalue == NULL)
682 error (3, 0, _("memory exhausted"));
684 if (confstr (c->call_name, cvalue, clen) != clen)
685 error (3, errno, "confstr");
687 printf ("%.*s\n", (int) clen, cvalue);
688 exit (0);
692 error (2, 0, _("Unrecognized variable `%s'"), argv[1]);
693 /* NOTREACHED */
694 return 2;