Annotation of src/usr.bin/getconf/getconf.c, Revision 1.17
1.17 ! millert 1: /* $OpenBSD: getconf.c,v 1.16 2013/03/28 03:29:45 guenther Exp $ */
1.3 deraadt 2:
1.2 deraadt 3: /*-
4: * Copyright (c) 1996 The NetBSD Foundation, Inc.
1.1 deraadt 5: * All rights reserved.
6: *
1.2 deraadt 7: * This code is derived from software contributed to The NetBSD Foundation
8: * by J.T. Conklin.
9: *
1.1 deraadt 10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: * 1. Redistributions of source code must retain the above copyright
14: * notice, this list of conditions and the following disclaimer.
15: * 2. Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: * 3. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed by Winning Strategies, Inc.
21: * 4. The name of the author may not be used to endorse or promote products
22: * derived from this software without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34: */
35:
36: /*
37: * POSIX.2 getconf utility
38: *
39: * Written by:
40: * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
41: */
42:
43: #include <stdio.h>
44: #include <stdlib.h>
1.9 david 45: #include <string.h>
1.1 deraadt 46: #include <limits.h>
47: #include <locale.h>
48: #include <unistd.h>
1.5 deraadt 49: #include <err.h>
1.1 deraadt 50: #include <errno.h>
51:
1.6 millert 52: static void usage(void);
1.13 guenther 53: static void list_var(int);
54: static int compilation_spec_valid(const char *);
1.1 deraadt 55:
56: struct conf_variable
57: {
58: const char *name;
59: enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT } type;
60: long value;
61: };
62:
1.13 guenther 63:
64: #define constant_row(name) { #name, CONSTANT, name },
65: #define sysconf_row(name) { #name, SYSCONF, _SC_##name },
66: #define pathconf_row(name) { #name, PATHCONF, _PC_##name },
67: #define confstr_row(name) { #name, CONFSTR, _CS_##name },
68: #define posix_constant_row(name) { #name, CONSTANT, _POSIX_##name },
69: #define posix_confstr_row(name) { #name, CONFSTR, _CS_POSIX_##name },
70: #define compat_posix2_sysconf_row(name) { #name, SYSCONF, _SC_2_##name },
71: #define compat_posix2_constant_row(name) { #name, CONSTANT, _POSIX2_##name },
72:
73: /* Some sysconf variables don't follow the pattern of the others */
74: #define posix2_sysconf_row(name) \
75: { "_POSIX2_" #name, SYSCONF, _SC_2_##name },
76: #define posix2_pathconf_row(name) \
77: { "_POSIX2_" #name, PATHCONF, _PC_2_##name },
78: #define pthread_sysconf_row(name) \
79: { "_PTHREAD_" #name, SYSCONF, _SC_THREAD_##name },
80: #define xopen_sysconf_row(name) \
81: { "_XOPEN_" #name, SYSCONF, _SC_XOPEN_##name },
82:
1.1 deraadt 83: const struct conf_variable conf_table[] =
84: {
1.13 guenther 85: /* Configuration strings */
86: confstr_row(PATH)
87: confstr_row(V7_ENV)
88: confstr_row(V6_ENV)
89:
90: /* Symbolic Utility Limits */
91: sysconf_row(BC_BASE_MAX)
92: sysconf_row(BC_DIM_MAX)
93: sysconf_row(BC_SCALE_MAX)
94: sysconf_row(BC_STRING_MAX)
95: sysconf_row(COLL_WEIGHTS_MAX)
96: sysconf_row(EXPR_NEST_MAX)
97: sysconf_row(LINE_MAX)
98: sysconf_row(RE_DUP_MAX)
1.1 deraadt 99:
1.13 guenther 100: /* POSIX.1 Configurable System Variables */
101: sysconf_row(AIO_LISTIO_MAX)
102: sysconf_row(AIO_MAX)
103: sysconf_row(AIO_PRIO_DELTA_MAX)
104: sysconf_row(ARG_MAX)
105: sysconf_row(CHILD_MAX)
106: sysconf_row(CLK_TCK)
107: sysconf_row(NGROUPS_MAX)
108: sysconf_row(OPEN_MAX)
109: sysconf_row(STREAM_MAX)
110: sysconf_row(TZNAME_MAX)
111: sysconf_row(PAGE_SIZE)
112: sysconf_row(PAGESIZE)
113:
114: sysconf_row(SEM_NSEMS_MAX)
115: sysconf_row(SEM_VALUE_MAX)
116: sysconf_row(HOST_NAME_MAX)
117: sysconf_row(LOGIN_NAME_MAX)
118:
119: sysconf_row(ATEXIT_MAX)
120: sysconf_row(DELAYTIMER_MAX)
121: sysconf_row(IOV_MAX)
122: sysconf_row(MQ_OPEN_MAX)
123: sysconf_row(MQ_PRIO_MAX)
124: sysconf_row(RTSIG_MAX)
125: sysconf_row(SIGQUEUE_MAX)
126: sysconf_row(SYMLOOP_MAX)
127: sysconf_row(TIMER_MAX)
128: sysconf_row(TTY_NAME_MAX)
129:
130: posix2_sysconf_row(PBS)
131: posix2_sysconf_row(PBS_ACCOUNTING)
132: posix2_sysconf_row(PBS_CHECKPOINT)
133: posix2_sysconf_row(PBS_LOCATE)
134: posix2_sysconf_row(PBS_MESSAGE)
135: posix2_sysconf_row(PBS_TRACK)
136:
137: pthread_sysconf_row(DESTRUCTOR_ITERATIONS)
138: pthread_sysconf_row(KEYS_MAX)
139: pthread_sysconf_row(STACK_MIN)
140: pthread_sysconf_row(THREADS_MAX)
141:
142: xopen_sysconf_row(SHM)
143: xopen_sysconf_row(CRYPT)
144: xopen_sysconf_row(ENH_I18N)
145: xopen_sysconf_row(REALTIME)
146: xopen_sysconf_row(REALTIME_THREADS)
147: xopen_sysconf_row(STREAMS)
148: xopen_sysconf_row(UNIX)
149: xopen_sysconf_row(UUCP)
150: xopen_sysconf_row(VERSION)
151:
152: pathconf_row(FILESIZEBITS)
153: pathconf_row(LINK_MAX)
154: pathconf_row(MAX_CANON)
155: pathconf_row(MAX_INPUT)
156: pathconf_row(NAME_MAX)
157: pathconf_row(PATH_MAX)
158: pathconf_row(PIPE_BUF)
159: pathconf_row(SYMLINK_MAX)
160:
161: posix2_pathconf_row(SYMLINKS)
162:
163: constant_row(_POSIX2_CHARCLASS_NAME_MAX)
164: constant_row(_XOPEN_IOV_MAX)
165: constant_row(_XOPEN_NAME_MAX)
166: constant_row(_XOPEN_PATH_MAX)
1.17 ! millert 167:
! 168: /* Extensions */
! 169: sysconf_row(PHYS_PAGES)
! 170: sysconf_row(AVPHYS_PAGES)
! 171: sysconf_row(NPROCESSORS_CONF)
! 172: sysconf_row(NPROCESSORS_ONLN)
1.13 guenther 173:
174: { NULL }
175: };
176:
177: /*
178: * Lots of names have a leading "_POSIX_", so put them in a table with
179: * that prefix trimmed
180: */
181: const char uposix_prefix[] = "_POSIX_";
182: const struct conf_variable uposix_conf_table[] =
183: {
184: /* POSIX.1 Maximum Values */
185: posix_constant_row(CLOCKRES_MIN)
1.1 deraadt 186:
187: /* POSIX.1 Minimum Values */
1.13 guenther 188: /*posix_constant_row(AIO_LISTIO_MAX)*/
189: /*posix_constant_row(AIO_MAX)*/
190: posix_constant_row(ARG_MAX)
191: posix_constant_row(CHILD_MAX)
192: /*posix_constant_row(DELAYTIMER_MAX)*/
193: posix_constant_row(HOST_NAME_MAX)
194: posix_constant_row(LINK_MAX)
195: posix_constant_row(LOGIN_NAME_MAX)
196: posix_constant_row(MAX_CANON)
197: posix_constant_row(MAX_INPUT)
198: /*posix_constant_row(MQ_OPEN_MAX)*/
199: /*posix_constant_row(MQ_PRIO_MAX)*/
200: posix_constant_row(NAME_MAX)
201: posix_constant_row(NGROUPS_MAX)
202: posix_constant_row(OPEN_MAX)
203: posix_constant_row(PATH_MAX)
204: posix_constant_row(PIPE_BUF)
205: posix_constant_row(RE_DUP_MAX)
206: /*posix_constant_row(RTSIG_MAX)*/
207: posix_constant_row(SEM_NSEMS_MAX)
208: posix_constant_row(SEM_VALUE_MAX)
209: /*posix_constant_row(SIGQUEUE_MAX)*/
210: posix_constant_row(SSIZE_MAX)
211: /*posix_constant_row(SS_REPL_MAX)*/
212: posix_constant_row(STREAM_MAX)
213: posix_constant_row(SYMLINK_MAX)
214: posix_constant_row(SYMLOOP_MAX)
215: posix_constant_row(THREAD_DESTRUCTOR_ITERATIONS)
216: posix_constant_row(THREAD_KEYS_MAX)
217: posix_constant_row(THREAD_THREADS_MAX)
218: /*posix_constant_row(TIMER_MAX)*/
219: posix_constant_row(TTY_NAME_MAX)
220: posix_constant_row(TZNAME_MAX)
221:
222: /* POSIX.1 Configurable System Variables */
223: sysconf_row(JOB_CONTROL)
224: sysconf_row(SAVED_IDS)
225: sysconf_row(VERSION)
226: sysconf_row(FSYNC)
227: sysconf_row(MONOTONIC_CLOCK)
228: sysconf_row(THREAD_SAFE_FUNCTIONS)
229: sysconf_row(ADVISORY_INFO)
230: sysconf_row(BARRIERS)
231: sysconf_row(ASYNCHRONOUS_IO)
232: sysconf_row(CLOCK_SELECTION)
233: sysconf_row(CPUTIME)
234: sysconf_row(IPV6)
235: sysconf_row(MAPPED_FILES)
236: sysconf_row(MEMLOCK)
237: sysconf_row(MEMLOCK_RANGE)
238: sysconf_row(MEMORY_PROTECTION)
239: sysconf_row(MESSAGE_PASSING)
240: sysconf_row(PRIORITIZED_IO)
241: sysconf_row(PRIORITY_SCHEDULING)
242: sysconf_row(RAW_SOCKETS)
243: sysconf_row(READER_WRITER_LOCKS)
244: sysconf_row(REALTIME_SIGNALS)
245: sysconf_row(REGEXP)
246: sysconf_row(SEMAPHORES)
247: sysconf_row(SHARED_MEMORY_OBJECTS)
248: sysconf_row(SHELL)
249: sysconf_row(SPAWN)
250: sysconf_row(SPIN_LOCKS)
251: sysconf_row(SPORADIC_SERVER)
252: sysconf_row(SS_REPL_MAX)
253: sysconf_row(SYNCHRONIZED_IO)
254: sysconf_row(THREAD_ATTR_STACKADDR)
255: sysconf_row(THREAD_ATTR_STACKSIZE)
256: sysconf_row(THREAD_CPUTIME)
257: sysconf_row(THREAD_PRIO_INHERIT)
258: sysconf_row(THREAD_PRIO_PROTECT)
259: sysconf_row(THREAD_PRIORITY_SCHEDULING)
260: sysconf_row(THREAD_PROCESS_SHARED)
261: sysconf_row(THREAD_ROBUST_PRIO_INHERIT)
262: sysconf_row(THREAD_SPORADIC_SERVER)
263: sysconf_row(THREADS)
264: sysconf_row(TIMEOUTS)
265: sysconf_row(TIMERS)
266: sysconf_row(TRACE)
267: sysconf_row(TRACE_EVENT_FILTER)
268: sysconf_row(TRACE_EVENT_NAME_MAX)
269: sysconf_row(TRACE_INHERIT)
270: sysconf_row(TRACE_LOG)
271: sysconf_row(TRACE_NAME_MAX)
272: sysconf_row(TRACE_SYS_MAX)
273: sysconf_row(TRACE_USER_EVENT_MAX)
274: sysconf_row(TYPED_MEMORY_OBJECTS)
275:
276: /*
277: * If new compilation specification are added (V8_*?) then add them
278: * to the compilation_specs array below too
279: */
280: sysconf_row(V7_ILP32_OFF32)
281: sysconf_row(V7_ILP32_OFFBIG)
282: sysconf_row(V7_LP64_OFF64)
283: sysconf_row(V7_LPBIG_OFFBIG)
284: sysconf_row(V6_ILP32_OFF32)
285: sysconf_row(V6_ILP32_OFFBIG)
286: sysconf_row(V6_LP64_OFF64)
287: sysconf_row(V6_LPBIG_OFFBIG)
288:
289: /* POSIX.1 Configurable Path Variables */
290: pathconf_row(CHOWN_RESTRICTED)
291: pathconf_row(NO_TRUNC)
292: pathconf_row(VDISABLE)
293: pathconf_row(ASYNC_IO)
294: pathconf_row(PRIO_IO)
295: pathconf_row(SYNC_IO)
1.16 guenther 296: pathconf_row(TIMESTAMP_RESOLUTION)
1.1 deraadt 297:
1.13 guenther 298: { NULL }
299: };
300:
301: /*
302: * Then there are the "POSIX_*" values
303: */
304: const char posix_prefix[] = "POSIX_";
305: const struct conf_variable posix_conf_table[] =
306: {
307: pathconf_row(ALLOC_SIZE_MIN)
308: pathconf_row(REC_INCR_XFER_SIZE)
309: pathconf_row(REC_MAX_XFER_SIZE)
310: pathconf_row(REC_MIN_XFER_SIZE)
311: pathconf_row(REC_XFER_ALIGN)
312:
313: posix_confstr_row(V7_ILP32_OFF32_CFLAGS)
314: posix_confstr_row(V7_ILP32_OFF32_LDFLAGS)
315: posix_confstr_row(V7_ILP32_OFF32_LIBS)
316: posix_confstr_row(V7_ILP32_OFFBIG_CFLAGS)
317: posix_confstr_row(V7_ILP32_OFFBIG_LDFLAGS)
318: posix_confstr_row(V7_ILP32_OFFBIG_LIBS)
319: posix_confstr_row(V7_LP64_OFF64_CFLAGS)
320: posix_confstr_row(V7_LP64_OFF64_LDFLAGS)
321: posix_confstr_row(V7_LP64_OFF64_LIBS)
322: posix_confstr_row(V7_LPBIG_OFFBIG_CFLAGS)
323: posix_confstr_row(V7_LPBIG_OFFBIG_LDFLAGS)
324: posix_confstr_row(V7_LPBIG_OFFBIG_LIBS)
325: posix_confstr_row(V7_THREADS_CFLAGS)
326: posix_confstr_row(V7_THREADS_LDFLAGS)
327: posix_confstr_row(V7_WIDTH_RESTRICTED_ENVS)
328: posix_confstr_row(V6_ILP32_OFF32_CFLAGS)
329: posix_confstr_row(V6_ILP32_OFF32_LDFLAGS)
330: posix_confstr_row(V6_ILP32_OFF32_LIBS)
331: posix_confstr_row(V6_ILP32_OFFBIG_CFLAGS)
332: posix_confstr_row(V6_ILP32_OFFBIG_LDFLAGS)
333: posix_confstr_row(V6_ILP32_OFFBIG_LIBS)
334: posix_confstr_row(V6_LP64_OFF64_CFLAGS)
335: posix_confstr_row(V6_LP64_OFF64_LDFLAGS)
336: posix_confstr_row(V6_LP64_OFF64_LIBS)
337: posix_confstr_row(V6_LPBIG_OFFBIG_CFLAGS)
338: posix_confstr_row(V6_LPBIG_OFFBIG_LDFLAGS)
339: posix_confstr_row(V6_LPBIG_OFFBIG_LIBS)
340: posix_confstr_row(V6_WIDTH_RESTRICTED_ENVS)
341:
342: { NULL }
343: };
1.1 deraadt 344:
1.13 guenther 345: /*
346: * Finally, there are variables that are accepted with a prefix
347: * of either "_POSIX2_" or "POSIX2_"
348: */
349: const char compat_posix2_prefix[] = "POSIX2_";
350: const struct conf_variable compat_posix2_conf_table[] =
351: {
1.1 deraadt 352: /* Optional Facility Configuration Values */
1.13 guenther 353: compat_posix2_sysconf_row(VERSION)
354: compat_posix2_sysconf_row(C_BIND)
355: compat_posix2_sysconf_row(C_DEV)
356: compat_posix2_sysconf_row(CHAR_TERM)
357: compat_posix2_sysconf_row(FORT_DEV)
358: compat_posix2_sysconf_row(FORT_RUN)
359: compat_posix2_sysconf_row(LOCALEDEF)
360: compat_posix2_sysconf_row(SW_DEV)
361: compat_posix2_sysconf_row(UPE)
1.1 deraadt 362:
1.13 guenther 363: /* Utility Limit Minimum Values */
364: compat_posix2_constant_row(BC_BASE_MAX)
365: compat_posix2_constant_row(BC_DIM_MAX)
366: compat_posix2_constant_row(BC_SCALE_MAX)
367: compat_posix2_constant_row(BC_STRING_MAX)
368: compat_posix2_constant_row(COLL_WEIGHTS_MAX)
369: compat_posix2_constant_row(EXPR_NEST_MAX)
370: compat_posix2_constant_row(LINE_MAX)
371: compat_posix2_constant_row(RE_DUP_MAX)
1.1 deraadt 372:
373: { NULL }
374: };
375:
1.13 guenther 376: #undef constant_row
377: #undef sysconf_row
378: #undef pathconf_row
379: #undef confstr_row
380: #undef posix_constant_row
381: #undef posix_confstr_row
382: #undef compat_posix2_sysconf_row
383: #undef compat_posix2_constant_row
384:
385:
386: /*
387: * What values are possibly accepted by the -v option?
388: * These are implied to have a prefix of posix_prefix
389: */
390: const char *compilation_specs[] = {
391: "V7_ILP32_OFF32",
392: "V7_ILP32_OFFBIG",
393: "V7_LP64_OFF64",
394: "V7_LPBIG_OFFBIG",
395: "V6_ILP32_OFF32",
396: "V6_ILP32_OFFBIG",
397: "V6_LP64_OFF64",
398: "V6_LPBIG_OFFBIG",
399: NULL
400: };
1.1 deraadt 401:
402: int
1.8 deraadt 403: main(int argc, char *argv[])
1.1 deraadt 404: {
405: int ch;
406: const struct conf_variable *cp;
407:
408: long val;
409: size_t slen;
410: char * sval;
411:
412: setlocale(LC_ALL, "");
413:
1.13 guenther 414: while ((ch = getopt(argc, argv, "lLv:")) != -1) {
1.1 deraadt 415: switch (ch) {
1.13 guenther 416: case 'l': /* nonstandard: list system variables */
417: list_var(0);
418: return (0);
419: case 'L': /* nonstandard: list path variables */
420: list_var(1);
421: return (0);
422: case 'v':
423: if (! compilation_spec_valid(optarg))
424: errx(1, "%s: unknown specification", optarg);
425: break;
1.1 deraadt 426: case '?':
427: default:
428: usage();
429: }
430: }
431: argc -= optind;
432: argv += optind;
433:
1.15 guenther 434: if (argc < 1 || argc > 2)
1.1 deraadt 435: usage();
436:
1.13 guenther 437: /* pick a table based on a possible prefix */
438: if (strncmp(*argv, uposix_prefix, sizeof(uposix_prefix) - 1) == 0) {
439: cp = uposix_conf_table;
440: slen = sizeof(uposix_prefix) - 1;
441: } else if (strncmp(*argv, posix_prefix,
442: sizeof(posix_prefix) - 1) == 0) {
443: cp = posix_conf_table;
444: slen = sizeof(posix_prefix) - 1;
445: } else {
446: cp = conf_table;
447: slen = 0;
448: }
449:
450: /* scan the table */
451: for (; cp->name != NULL; cp++)
452: if (strcmp(*argv + slen, cp->name) == 0)
1.1 deraadt 453: break;
1.13 guenther 454:
455: /*
456: * If no match, then make a final check against
457: * compat_posix2_conf_table, with special magic to accept/skip
458: * a leading underbar
459: */
460: slen = argv[0][0] == '_';
461: if (cp->name == NULL && strncmp(*argv + slen, compat_posix2_prefix,
462: sizeof(compat_posix2_prefix) - 1) == 0) {
463: slen += sizeof(compat_posix2_prefix) - 1;
464: for (cp = compat_posix2_conf_table; cp->name != NULL; cp++) {
465: if (strcmp(*argv + slen, cp->name) == 0)
466: break;
467: }
1.1 deraadt 468: }
1.13 guenther 469:
1.15 guenther 470: if (cp->name == NULL)
1.2 deraadt 471: errx(1, "%s: unknown variable", *argv);
1.1 deraadt 472:
473: if (cp->type == PATHCONF) {
474: if (argc != 2) usage();
475: } else {
476: if (argc != 1) usage();
477: }
478:
479: switch (cp->type) {
480: case CONSTANT:
481: printf("%ld\n", cp->value);
482: break;
483:
484: case CONFSTR:
1.10 otto 485: errno = 0;
1.15 guenther 486: if ((slen = confstr(cp->value, NULL, 0)) == 0) {
487: if (errno != 0)
488: err(1, NULL);
489:
490: printf("undefined\n");
491: } else {
492: if ((sval = malloc(slen)) == NULL)
493: err(1, NULL);
494:
495: confstr(cp->value, sval, slen);
496: printf("%s\n", sval);
1.10 otto 497: }
1.1 deraadt 498: break;
499:
500: case SYSCONF:
501: errno = 0;
502: if ((val = sysconf(cp->value)) == -1) {
1.15 guenther 503: if (errno != 0)
1.1 deraadt 504: err(1, NULL);
505:
1.15 guenther 506: printf("undefined\n");
1.1 deraadt 507: } else {
508: printf("%ld\n", val);
509: }
510: break;
511:
512: case PATHCONF:
513: errno = 0;
514: if ((val = pathconf(argv[1], cp->value)) == -1) {
1.15 guenther 515: if (errno != 0)
1.1 deraadt 516: err(1, "%s", argv[1]);
517:
1.15 guenther 518: printf("undefined\n");
1.1 deraadt 519: } else {
1.15 guenther 520: printf("%ld\n", val);
1.1 deraadt 521: }
522: break;
523: }
524:
1.15 guenther 525: exit(ferror(stdout));
1.1 deraadt 526: }
527:
528:
529: static void
1.8 deraadt 530: usage(void)
1.1 deraadt 531: {
1.4 aaron 532: extern char *__progname;
533:
1.14 jmc 534: (void)fprintf(stderr,
535: "usage: %s [-Ll] [-v specification] name [pathname]\n",
1.13 guenther 536: __progname);
1.4 aaron 537: exit(1);
1.13 guenther 538: }
539:
540: static void
541: list_var(int do_pathconf)
542: {
543: const struct conf_variable *cp;
544:
545: for (cp = uposix_conf_table; cp->name != NULL; cp++)
546: if ((cp->type == PATHCONF) == do_pathconf)
547: printf("%s%s\n", uposix_prefix, cp->name);
548: for (cp = posix_conf_table; cp->name != NULL; cp++)
549: if ((cp->type == PATHCONF) == do_pathconf)
550: printf("%s%s\n", posix_prefix, cp->name);
551: for (cp = conf_table; cp->name != NULL; cp++)
552: if ((cp->type == PATHCONF) == do_pathconf)
553: printf("%s\n", cp->name);
554: for (cp = compat_posix2_conf_table; cp->name != NULL; cp++)
555: if ((cp->type == PATHCONF) == do_pathconf)
556: printf("_%s%s\n", compat_posix2_prefix, cp->name);
557: }
558:
559: static int
560: compilation_spec_valid(const char *spec)
561: {
562: const char **sp;
563: const struct conf_variable *cp;
564:
565: if (strncmp(spec, posix_prefix, sizeof(posix_prefix) - 1) != 0)
566: return (0);
567:
568: spec += sizeof(posix_prefix) - 1;
569: for (sp = compilation_specs; *sp != NULL; sp++)
570: if (strcmp(spec, *sp) == 0)
571: break;
572: if (*sp == NULL)
573: return (0);
574:
575: for (cp = uposix_conf_table; cp->name != NULL; cp++)
576: if (strcmp(spec, cp->name) == 0 && cp->type == SYSCONF)
577: return (sysconf(cp->value) != -1);
578:
579: return (0);
1.1 deraadt 580: }