getconf.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  1. /* Copyright (C) 1991, 92, 1995-2008, 2009 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published
  5. by the Free Software Foundation; version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  14. #define _GNU_SOURCE 1
  15. #include "porting.h"
  16. #include <unistd.h>
  17. #include <errno.h>
  18. #include <string.h>
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #define PACKAGE "getconf regression test"
  22. #define VERSION ""
  23. #define _(x) x
  24. #define error(status, errnum, fmt, ...) \
  25. {fprintf(stderr, fmt "\n", ## __VA_ARGS__); exit(status);}
  26. struct conf
  27. {
  28. const char *name;
  29. const int call_name;
  30. const enum { SYSCONF, CONFSTR, PATHCONF } call;
  31. };
  32. static const struct conf vars[] =
  33. {
  34. #ifdef _PC_LINK_MAX
  35. { "LINK_MAX", _PC_LINK_MAX, PATHCONF },
  36. #endif
  37. #ifdef _PC_LINK_MAX
  38. { "_POSIX_LINK_MAX", _PC_LINK_MAX, PATHCONF },
  39. #endif
  40. #ifdef _PC_MAX_CANON
  41. { "MAX_CANON", _PC_MAX_CANON, PATHCONF },
  42. #endif
  43. #ifdef _PC_MAX_CANON
  44. { "_POSIX_MAX_CANON", _PC_MAX_CANON, PATHCONF },
  45. #endif
  46. #ifdef _PC_MAX_INPUT
  47. { "MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
  48. #endif
  49. #ifdef _PC_MAX_INPUT
  50. { "_POSIX_MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
  51. #endif
  52. #ifdef _PC_NAME_MAX
  53. { "NAME_MAX", _PC_NAME_MAX, PATHCONF },
  54. #endif
  55. #ifdef _PC_NAME_MAX
  56. { "_POSIX_NAME_MAX", _PC_NAME_MAX, PATHCONF },
  57. #endif
  58. #ifdef _PC_PATH_MAX
  59. { "PATH_MAX", _PC_PATH_MAX, PATHCONF },
  60. #endif
  61. #ifdef _PC_PATH_MAX
  62. { "_POSIX_PATH_MAX", _PC_PATH_MAX, PATHCONF },
  63. #endif
  64. #ifdef _PC_PIPE_BUF
  65. { "PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
  66. #endif
  67. #ifdef _PC_PIPE_BUF
  68. { "_POSIX_PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
  69. #endif
  70. #ifdef _PC_SOCK_MAXBUF
  71. { "SOCK_MAXBUF", _PC_SOCK_MAXBUF, PATHCONF },
  72. #endif
  73. #ifdef _PC_ASYNC_IO
  74. { "_POSIX_ASYNC_IO", _PC_ASYNC_IO, PATHCONF },
  75. #endif
  76. #ifdef _PC_CHOWN_RESTRICTED
  77. { "_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED, PATHCONF },
  78. #endif
  79. #ifdef _PC_NO_TRUNC
  80. { "_POSIX_NO_TRUNC", _PC_NO_TRUNC, PATHCONF },
  81. #endif
  82. #ifdef _PC_PRIO_IO
  83. { "_POSIX_PRIO_IO", _PC_PRIO_IO, PATHCONF },
  84. #endif
  85. #ifdef _PC_SYNC_IO
  86. { "_POSIX_SYNC_IO", _PC_SYNC_IO, PATHCONF },
  87. #endif
  88. #ifdef _PC_VDISABLE
  89. { "_POSIX_VDISABLE", _PC_VDISABLE, PATHCONF },
  90. #endif
  91. #ifdef _SC_ARG_MAX
  92. { "ARG_MAX", _SC_ARG_MAX, SYSCONF },
  93. #endif
  94. #ifdef _SC_ATEXIT_MAX
  95. { "ATEXIT_MAX", _SC_ATEXIT_MAX, SYSCONF },
  96. #endif
  97. #ifdef _SC_CHAR_BIT
  98. { "CHAR_BIT", _SC_CHAR_BIT, SYSCONF },
  99. #endif
  100. #ifdef _SC_CHAR_MAX
  101. { "CHAR_MAX", _SC_CHAR_MAX, SYSCONF },
  102. #endif
  103. #ifdef _SC_CHAR_MIN
  104. { "CHAR_MIN", _SC_CHAR_MIN, SYSCONF },
  105. #endif
  106. #ifdef _SC_CHILD_MAX
  107. { "CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
  108. #endif
  109. #ifdef _SC_CLK_TCK
  110. { "CLK_TCK", _SC_CLK_TCK, SYSCONF },
  111. #endif
  112. #ifdef _SC_INT_MAX
  113. { "INT_MAX", _SC_INT_MAX, SYSCONF },
  114. #endif
  115. #ifdef _SC_INT_MIN
  116. { "INT_MIN", _SC_INT_MIN, SYSCONF },
  117. #endif
  118. #ifdef _SC_UIO_MAXIOV
  119. { "IOV_MAX", _SC_UIO_MAXIOV, SYSCONF },
  120. #endif
  121. #ifdef _SC_LOGIN_NAME_MAX
  122. { "LOGNAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
  123. #endif
  124. #ifdef _SC_LONG_BIT
  125. { "LONG_BIT", _SC_LONG_BIT, SYSCONF },
  126. #endif
  127. #ifdef _SC_MB_LEN_MAX
  128. { "MB_LEN_MAX", _SC_MB_LEN_MAX, SYSCONF },
  129. #endif
  130. #ifdef _SC_NGROUPS_MAX
  131. { "NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
  132. #endif
  133. #ifdef _SC_NL_ARGMAX
  134. { "NL_ARGMAX", _SC_NL_ARGMAX, SYSCONF },
  135. #endif
  136. #ifdef _SC_NL_LANGMAX
  137. { "NL_LANGMAX", _SC_NL_LANGMAX, SYSCONF },
  138. #endif
  139. #ifdef _SC_NL_MSGMAX
  140. { "NL_MSGMAX", _SC_NL_MSGMAX, SYSCONF },
  141. #endif
  142. #ifdef _SC_NL_NMAX
  143. { "NL_NMAX", _SC_NL_NMAX, SYSCONF },
  144. #endif
  145. #ifdef _SC_NL_SETMAX
  146. { "NL_SETMAX", _SC_NL_SETMAX, SYSCONF },
  147. #endif
  148. #ifdef _SC_NL_TEXTMAX
  149. { "NL_TEXTMAX", _SC_NL_TEXTMAX, SYSCONF },
  150. #endif
  151. #ifdef _SC_GETGR_R_SIZE_MAX
  152. { "NSS_BUFLEN_GROUP", _SC_GETGR_R_SIZE_MAX, SYSCONF },
  153. #endif
  154. #ifdef _SC_GETPW_R_SIZE_MAX
  155. { "NSS_BUFLEN_PASSWD", _SC_GETPW_R_SIZE_MAX, SYSCONF },
  156. #endif
  157. #ifdef _SC_NZERO
  158. { "NZERO", _SC_NZERO, SYSCONF },
  159. #endif
  160. #ifdef _SC_OPEN_MAX
  161. { "OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
  162. #endif
  163. #ifdef _SC_PAGESIZE
  164. { "PAGESIZE", _SC_PAGESIZE, SYSCONF },
  165. #endif
  166. #ifdef _SC_PAGESIZE
  167. { "PAGE_SIZE", _SC_PAGESIZE, SYSCONF },
  168. #endif
  169. #ifdef _SC_PASS_MAX
  170. { "PASS_MAX", _SC_PASS_MAX, SYSCONF },
  171. #endif
  172. #ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
  173. { "PTHREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS, SYSCONF },
  174. #endif
  175. #ifdef _SC_THREAD_KEYS_MAX
  176. { "PTHREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX, SYSCONF },
  177. #endif
  178. #ifdef _SC_THREAD_STACK_MIN
  179. { "PTHREAD_STACK_MIN", _SC_THREAD_STACK_MIN, SYSCONF },
  180. #endif
  181. #ifdef _SC_THREAD_THREADS_MAX
  182. { "PTHREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX, SYSCONF },
  183. #endif
  184. #ifdef _SC_SCHAR_MAX
  185. { "SCHAR_MAX", _SC_SCHAR_MAX, SYSCONF },
  186. #endif
  187. #ifdef _SC_SCHAR_MIN
  188. { "SCHAR_MIN", _SC_SCHAR_MIN, SYSCONF },
  189. #endif
  190. #ifdef _SC_SHRT_MAX
  191. { "SHRT_MAX", _SC_SHRT_MAX, SYSCONF },
  192. #endif
  193. #ifdef _SC_SHRT_MIN
  194. { "SHRT_MIN", _SC_SHRT_MIN, SYSCONF },
  195. #endif
  196. #ifdef _SC_SSIZE_MAX
  197. { "SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
  198. #endif
  199. #ifdef _SC_TTY_NAME_MAX
  200. { "TTY_NAME_MAX", _SC_TTY_NAME_MAX, SYSCONF },
  201. #endif
  202. #ifdef _SC_TZNAME_MAX
  203. { "TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
  204. #endif
  205. #ifdef _SC_UCHAR_MAX
  206. { "UCHAR_MAX", _SC_UCHAR_MAX, SYSCONF },
  207. #endif
  208. #ifdef _SC_UINT_MAX
  209. { "UINT_MAX", _SC_UINT_MAX, SYSCONF },
  210. #endif
  211. #ifdef _SC_UIO_MAXIOV
  212. { "UIO_MAXIOV", _SC_UIO_MAXIOV, SYSCONF },
  213. #endif
  214. #ifdef _SC_ULONG_MAX
  215. { "ULONG_MAX", _SC_ULONG_MAX, SYSCONF },
  216. #endif
  217. #ifdef _SC_USHRT_MAX
  218. { "USHRT_MAX", _SC_USHRT_MAX, SYSCONF },
  219. #endif
  220. #ifdef _SC_WORD_BIT
  221. { "WORD_BIT", _SC_WORD_BIT, SYSCONF },
  222. #endif
  223. #ifdef _SC_AVPHYS_PAGES
  224. { "_AVPHYS_PAGES", _SC_AVPHYS_PAGES, SYSCONF },
  225. #endif
  226. #ifdef _SC_NPROCESSORS_CONF
  227. { "_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF, SYSCONF },
  228. #endif
  229. #ifdef _SC_NPROCESSORS_ONLN
  230. { "_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN, SYSCONF },
  231. #endif
  232. #ifdef _SC_PHYS_PAGES
  233. { "_PHYS_PAGES", _SC_PHYS_PAGES, SYSCONF },
  234. #endif
  235. #ifdef _SC_ARG_MAX
  236. { "_POSIX_ARG_MAX", _SC_ARG_MAX, SYSCONF },
  237. #endif
  238. #ifdef _SC_ASYNCHRONOUS_IO
  239. { "_POSIX_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO, SYSCONF },
  240. #endif
  241. #ifdef _SC_CHILD_MAX
  242. { "_POSIX_CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
  243. #endif
  244. #ifdef _SC_FSYNC
  245. { "_POSIX_FSYNC", _SC_FSYNC, SYSCONF },
  246. #endif
  247. #ifdef _SC_JOB_CONTROL
  248. { "_POSIX_JOB_CONTROL", _SC_JOB_CONTROL, SYSCONF },
  249. #endif
  250. #ifdef _SC_MAPPED_FILES
  251. { "_POSIX_MAPPED_FILES", _SC_MAPPED_FILES, SYSCONF },
  252. #endif
  253. #ifdef _SC_MEMLOCK
  254. { "_POSIX_MEMLOCK", _SC_MEMLOCK, SYSCONF },
  255. #endif
  256. #ifdef _SC_MEMLOCK_RANGE
  257. { "_POSIX_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE, SYSCONF },
  258. #endif
  259. #ifdef _SC_MEMORY_PROTECTION
  260. { "_POSIX_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION, SYSCONF },
  261. #endif
  262. #ifdef _SC_MESSAGE_PASSING
  263. { "_POSIX_MESSAGE_PASSING", _SC_MESSAGE_PASSING, SYSCONF },
  264. #endif
  265. #ifdef _SC_NGROUPS_MAX
  266. { "_POSIX_NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
  267. #endif
  268. #ifdef _SC_OPEN_MAX
  269. { "_POSIX_OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
  270. #endif
  271. #ifdef _SC_PII
  272. { "_POSIX_PII", _SC_PII, SYSCONF },
  273. #endif
  274. #ifdef _SC_PII_INTERNET
  275. { "_POSIX_PII_INTERNET", _SC_PII_INTERNET, SYSCONF },
  276. #endif
  277. #ifdef _SC_PII_INTERNET_DGRAM
  278. { "_POSIX_PII_INTERNET_DGRAM", _SC_PII_INTERNET_DGRAM, SYSCONF },
  279. #endif
  280. #ifdef _SC_PII_INTERNET_STREAM
  281. { "_POSIX_PII_INTERNET_STREAM", _SC_PII_INTERNET_STREAM, SYSCONF },
  282. #endif
  283. #ifdef _SC_PII_OSI
  284. { "_POSIX_PII_OSI", _SC_PII_OSI, SYSCONF },
  285. #endif
  286. #ifdef _SC_PII_OSI_CLTS
  287. { "_POSIX_PII_OSI_CLTS", _SC_PII_OSI_CLTS, SYSCONF },
  288. #endif
  289. #ifdef _SC_PII_OSI_COTS
  290. { "_POSIX_PII_OSI_COTS", _SC_PII_OSI_COTS, SYSCONF },
  291. #endif
  292. #ifdef _SC_PII_OSI_M
  293. { "_POSIX_PII_OSI_M", _SC_PII_OSI_M, SYSCONF },
  294. #endif
  295. #ifdef _SC_PII_SOCKET
  296. { "_POSIX_PII_SOCKET", _SC_PII_SOCKET, SYSCONF },
  297. #endif
  298. #ifdef _SC_PII_XTI
  299. { "_POSIX_PII_XTI", _SC_PII_XTI, SYSCONF },
  300. #endif
  301. #ifdef _SC_POLL
  302. { "_POSIX_POLL", _SC_POLL, SYSCONF },
  303. #endif
  304. #ifdef _SC_PRIORITIZED_IO
  305. { "_POSIX_PRIORITIZED_IO", _SC_PRIORITIZED_IO, SYSCONF },
  306. #endif
  307. #ifdef _SC_PRIORITY_SCHEDULING
  308. { "_POSIX_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING, SYSCONF },
  309. #endif
  310. #ifdef _SC_REALTIME_SIGNALS
  311. { "_POSIX_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS, SYSCONF },
  312. #endif
  313. #ifdef _SC_SAVED_IDS
  314. { "_POSIX_SAVED_IDS", _SC_SAVED_IDS, SYSCONF },
  315. #endif
  316. #ifdef _SC_SELECT
  317. { "_POSIX_SELECT", _SC_SELECT, SYSCONF },
  318. #endif
  319. #ifdef _SC_SEMAPHORES
  320. { "_POSIX_SEMAPHORES", _SC_SEMAPHORES, SYSCONF },
  321. #endif
  322. #ifdef _SC_SHARED_MEMORY_OBJECTS
  323. { "_POSIX_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS, SYSCONF },
  324. #endif
  325. #ifdef _SC_SSIZE_MAX
  326. { "_POSIX_SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
  327. #endif
  328. #ifdef _SC_STREAM_MAX
  329. { "_POSIX_STREAM_MAX", _SC_STREAM_MAX, SYSCONF },
  330. #endif
  331. #ifdef _SC_SYNCHRONIZED_IO
  332. { "_POSIX_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO, SYSCONF },
  333. #endif
  334. #ifdef _SC_THREADS
  335. { "_POSIX_THREADS", _SC_THREADS, SYSCONF },
  336. #endif
  337. #ifdef _SC_THREAD_ATTR_STACKADDR
  338. { "_POSIX_THREAD_ATTR_STACKADDR", _SC_THREAD_ATTR_STACKADDR, SYSCONF },
  339. #endif
  340. #ifdef _SC_THREAD_ATTR_STACKSIZE
  341. { "_POSIX_THREAD_ATTR_STACKSIZE", _SC_THREAD_ATTR_STACKSIZE, SYSCONF },
  342. #endif
  343. #ifdef _SC_THREAD_PRIORITY_SCHEDULING
  344. { "_POSIX_THREAD_PRIORITY_SCHEDULING", _SC_THREAD_PRIORITY_SCHEDULING, SYSCONF },
  345. #endif
  346. #ifdef _SC_THREAD_PRIO_INHERIT
  347. { "_POSIX_THREAD_PRIO_INHERIT", _SC_THREAD_PRIO_INHERIT, SYSCONF },
  348. #endif
  349. #ifdef _SC_THREAD_PRIO_PROTECT
  350. { "_POSIX_THREAD_PRIO_PROTECT", _SC_THREAD_PRIO_PROTECT, SYSCONF },
  351. #endif
  352. #ifdef _SC_THREAD_ROBUST_PRIO_INHERIT
  353. { "_POSIX_THREAD_ROBUST_PRIO_INHERIT", _SC_THREAD_ROBUST_PRIO_INHERIT,
  354. SYSCONF },
  355. #endif
  356. #ifdef _SC_THREAD_ROBUST_PRIO_PROTECT
  357. { "_POSIX_THREAD_ROBUST_PRIO_PROTECT", _SC_THREAD_ROBUST_PRIO_PROTECT,
  358. SYSCONF },
  359. #endif
  360. #ifdef _SC_THREAD_PROCESS_SHARED
  361. { "_POSIX_THREAD_PROCESS_SHARED", _SC_THREAD_PROCESS_SHARED, SYSCONF },
  362. #endif
  363. #ifdef _SC_THREAD_SAFE_FUNCTIONS
  364. { "_POSIX_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS, SYSCONF },
  365. #endif
  366. #ifdef _SC_TIMERS
  367. { "_POSIX_TIMERS", _SC_TIMERS, SYSCONF },
  368. #endif
  369. #ifdef _SC_TIMER_MAX
  370. { "TIMER_MAX", _SC_TIMER_MAX, SYSCONF },
  371. #endif
  372. #ifdef _SC_TZNAME_MAX
  373. { "_POSIX_TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
  374. #endif
  375. #ifdef _SC_VERSION
  376. { "_POSIX_VERSION", _SC_VERSION, SYSCONF },
  377. #endif
  378. #ifdef _SC_T_IOV_MAX
  379. { "_T_IOV_MAX", _SC_T_IOV_MAX, SYSCONF },
  380. #endif
  381. #ifdef _SC_XOPEN_CRYPT
  382. { "_XOPEN_CRYPT", _SC_XOPEN_CRYPT, SYSCONF },
  383. #endif
  384. #ifdef _SC_XOPEN_ENH_I18N
  385. { "_XOPEN_ENH_I18N", _SC_XOPEN_ENH_I18N, SYSCONF },
  386. #endif
  387. #ifdef _SC_XOPEN_LEGACY
  388. { "_XOPEN_LEGACY", _SC_XOPEN_LEGACY, SYSCONF },
  389. #endif
  390. #ifdef _SC_XOPEN_REALTIME
  391. { "_XOPEN_REALTIME", _SC_XOPEN_REALTIME, SYSCONF },
  392. #endif
  393. #ifdef _SC_XOPEN_REALTIME_THREADS
  394. { "_XOPEN_REALTIME_THREADS", _SC_XOPEN_REALTIME_THREADS, SYSCONF },
  395. #endif
  396. #ifdef _SC_XOPEN_SHM
  397. { "_XOPEN_SHM", _SC_XOPEN_SHM, SYSCONF },
  398. #endif
  399. #ifdef _SC_XOPEN_UNIX
  400. { "_XOPEN_UNIX", _SC_XOPEN_UNIX, SYSCONF },
  401. #endif
  402. #ifdef _SC_XOPEN_VERSION
  403. { "_XOPEN_VERSION", _SC_XOPEN_VERSION, SYSCONF },
  404. #endif
  405. #ifdef _SC_XOPEN_XCU_VERSION
  406. { "_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION, SYSCONF },
  407. #endif
  408. #ifdef _SC_XOPEN_XPG2
  409. { "_XOPEN_XPG2", _SC_XOPEN_XPG2, SYSCONF },
  410. #endif
  411. #ifdef _SC_XOPEN_XPG3
  412. { "_XOPEN_XPG3", _SC_XOPEN_XPG3, SYSCONF },
  413. #endif
  414. #ifdef _SC_XOPEN_XPG4
  415. { "_XOPEN_XPG4", _SC_XOPEN_XPG4, SYSCONF },
  416. #endif
  417. /* POSIX.2 */
  418. #ifdef _SC_BC_BASE_MAX
  419. { "BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
  420. #endif
  421. #ifdef _SC_BC_DIM_MAX
  422. { "BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
  423. #endif
  424. #ifdef _SC_BC_SCALE_MAX
  425. { "BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
  426. #endif
  427. #ifdef _SC_BC_STRING_MAX
  428. { "BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
  429. #endif
  430. { "CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX, SYSCONF },
  431. #ifdef _SC_COLL_WEIGHTS_MAX
  432. { "COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
  433. #endif
  434. #ifdef _SC_EQUIV_CLASS_MAX
  435. { "EQUIV_CLASS_MAX", _SC_EQUIV_CLASS_MAX, SYSCONF },
  436. #endif
  437. #ifdef _SC_EXPR_NEST_MAX
  438. { "EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
  439. #endif
  440. #ifdef _SC_LINE_MAX
  441. { "LINE_MAX", _SC_LINE_MAX, SYSCONF },
  442. #endif
  443. #ifdef _SC_BC_BASE_MAX
  444. { "POSIX2_BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
  445. #endif
  446. #ifdef _SC_BC_DIM_MAX
  447. { "POSIX2_BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
  448. #endif
  449. #ifdef _SC_BC_SCALE_MAX
  450. { "POSIX2_BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
  451. #endif
  452. #ifdef _SC_BC_STRING_MAX
  453. { "POSIX2_BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
  454. #endif
  455. #ifdef _SC_2_CHAR_TERM
  456. { "POSIX2_CHAR_TERM", _SC_2_CHAR_TERM, SYSCONF },
  457. #endif
  458. #ifdef _SC_COLL_WEIGHTS_MAX
  459. { "POSIX2_COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
  460. #endif
  461. #ifdef _SC_2_C_BIND
  462. { "POSIX2_C_BIND", _SC_2_C_BIND, SYSCONF },
  463. #endif
  464. #ifdef _SC_2_C_DEV
  465. { "POSIX2_C_DEV", _SC_2_C_DEV, SYSCONF },
  466. #endif
  467. #ifdef _SC_2_C_VERSION
  468. { "POSIX2_C_VERSION", _SC_2_C_VERSION, SYSCONF },
  469. #endif
  470. #ifdef _SC_EXPR_NEST_MAX
  471. { "POSIX2_EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
  472. #endif
  473. #ifdef _SC_2_FORT_DEV
  474. { "POSIX2_FORT_DEV", _SC_2_FORT_DEV, SYSCONF },
  475. #endif
  476. #ifdef _SC_2_FORT_RUN
  477. { "POSIX2_FORT_RUN", _SC_2_FORT_RUN, SYSCONF },
  478. #endif
  479. #ifdef _SC_LINE_MAX
  480. { "_POSIX2_LINE_MAX", _SC_LINE_MAX, SYSCONF },
  481. { "POSIX2_LINE_MAX", _SC_LINE_MAX, SYSCONF },
  482. #endif
  483. #ifdef _SC_2_LOCALEDEF
  484. { "POSIX2_LOCALEDEF", _SC_2_LOCALEDEF, SYSCONF },
  485. #endif
  486. #ifdef _SC_RE_DUP_MAX
  487. { "POSIX2_RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
  488. #endif
  489. #ifdef _SC_2_SW_DEV
  490. { "POSIX2_SW_DEV", _SC_2_SW_DEV, SYSCONF },
  491. #endif
  492. #ifdef _SC_2_UPE
  493. { "POSIX2_UPE", _SC_2_UPE, SYSCONF },
  494. #endif
  495. #ifdef _SC_2_VERSION
  496. { "POSIX2_VERSION", _SC_2_VERSION, SYSCONF },
  497. #endif
  498. #ifdef _SC_RE_DUP_MAX
  499. { "RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
  500. #endif
  501. #ifdef _CS_PATH
  502. { "PATH", _CS_PATH, CONFSTR },
  503. { "CS_PATH", _CS_PATH, CONFSTR },
  504. #endif
  505. /* LFS */
  506. #ifdef _CS_LFS_CFLAGS
  507. { "LFS_CFLAGS", _CS_LFS_CFLAGS, CONFSTR },
  508. #endif
  509. #ifdef _CS_LFS_LDFLAGS
  510. { "LFS_LDFLAGS", _CS_LFS_LDFLAGS, CONFSTR },
  511. #endif
  512. #ifdef _CS_LFS_LIBS
  513. { "LFS_LIBS", _CS_LFS_LIBS, CONFSTR },
  514. #endif
  515. #ifdef _CS_LFS_LINTFLAGS
  516. { "LFS_LINTFLAGS", _CS_LFS_LINTFLAGS, CONFSTR },
  517. #endif
  518. #ifdef _CS_LFS64_CFLAGS
  519. { "LFS64_CFLAGS", _CS_LFS64_CFLAGS, CONFSTR },
  520. #endif
  521. #ifdef _CS_LFS64_LDFLAGS
  522. { "LFS64_LDFLAGS", _CS_LFS64_LDFLAGS, CONFSTR },
  523. #endif
  524. #ifdef _CS_LFS64_LIBS
  525. { "LFS64_LIBS", _CS_LFS64_LIBS, CONFSTR },
  526. #endif
  527. #ifdef _CS_LFS64_LINTFLAGS
  528. { "LFS64_LINTFLAGS", _CS_LFS64_LINTFLAGS, CONFSTR },
  529. #endif
  530. /* Programming environments. */
  531. #ifdef _CS_V5_WIDTH_RESTRICTED_ENVS
  532. { "_XBS5_WIDTH_RESTRICTED_ENVS", _CS_V5_WIDTH_RESTRICTED_ENVS, CONFSTR },
  533. { "XBS5_WIDTH_RESTRICTED_ENVS", _CS_V5_WIDTH_RESTRICTED_ENVS, CONFSTR },
  534. #endif
  535. #ifdef _SC_XBS5_ILP32_OFF32
  536. { "_XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32, SYSCONF },
  537. #endif
  538. #ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
  539. { "XBS5_ILP32_OFF32_CFLAGS", _CS_XBS5_ILP32_OFF32_CFLAGS, CONFSTR },
  540. #endif
  541. #ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
  542. { "XBS5_ILP32_OFF32_LDFLAGS", _CS_XBS5_ILP32_OFF32_LDFLAGS, CONFSTR },
  543. #endif
  544. #ifdef _CS_XBS5_ILP32_OFF32_LIBS
  545. { "XBS5_ILP32_OFF32_LIBS", _CS_XBS5_ILP32_OFF32_LIBS, CONFSTR },
  546. #endif
  547. #ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
  548. { "XBS5_ILP32_OFF32_LINTFLAGS", _CS_XBS5_ILP32_OFF32_LINTFLAGS, CONFSTR },
  549. #endif
  550. #ifdef _SC_XBS5_ILP32_OFFBIG
  551. { "_XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG, SYSCONF },
  552. #endif
  553. #ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
  554. { "XBS5_ILP32_OFFBIG_CFLAGS", _CS_XBS5_ILP32_OFFBIG_CFLAGS, CONFSTR },
  555. #endif
  556. #ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
  557. { "XBS5_ILP32_OFFBIG_LDFLAGS", _CS_XBS5_ILP32_OFFBIG_LDFLAGS, CONFSTR },
  558. #endif
  559. #ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
  560. { "XBS5_ILP32_OFFBIG_LIBS", _CS_XBS5_ILP32_OFFBIG_LIBS, CONFSTR },
  561. #endif
  562. #ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
  563. { "XBS5_ILP32_OFFBIG_LINTFLAGS", _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
  564. #endif
  565. #ifdef _SC_XBS5_LP64_OFF64
  566. { "_XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64, SYSCONF },
  567. #endif
  568. #ifdef _CS_XBS5_LP64_OFF64_CFLAGS
  569. { "XBS5_LP64_OFF64_CFLAGS", _CS_XBS5_LP64_OFF64_CFLAGS, CONFSTR },
  570. #endif
  571. #ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
  572. { "XBS5_LP64_OFF64_LDFLAGS", _CS_XBS5_LP64_OFF64_LDFLAGS, CONFSTR },
  573. #endif
  574. #ifdef _CS_XBS5_LP64_OFF64_LIBS
  575. { "XBS5_LP64_OFF64_LIBS", _CS_XBS5_LP64_OFF64_LIBS, CONFSTR },
  576. #endif
  577. #ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
  578. { "XBS5_LP64_OFF64_LINTFLAGS", _CS_XBS5_LP64_OFF64_LINTFLAGS, CONFSTR },
  579. #endif
  580. #ifdef _SC_XBS5_LPBIG_OFFBIG
  581. { "_XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG, SYSCONF },
  582. #endif
  583. #ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
  584. { "XBS5_LPBIG_OFFBIG_CFLAGS", _CS_XBS5_LPBIG_OFFBIG_CFLAGS, CONFSTR },
  585. #endif
  586. #ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
  587. { "XBS5_LPBIG_OFFBIG_LDFLAGS", _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
  588. #endif
  589. #ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
  590. { "XBS5_LPBIG_OFFBIG_LIBS", _CS_XBS5_LPBIG_OFFBIG_LIBS, CONFSTR },
  591. #endif
  592. #ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
  593. { "XBS5_LPBIG_OFFBIG_LINTFLAGS", _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
  594. #endif
  595. #ifdef _SC_V6_ILP32_OFF32
  596. { "_POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32, SYSCONF },
  597. #endif
  598. #ifdef _CS_POSIX_V6_ILP32_OFF32_CFLAGS
  599. { "POSIX_V6_ILP32_OFF32_CFLAGS", _CS_POSIX_V6_ILP32_OFF32_CFLAGS, CONFSTR },
  600. #endif
  601. #ifdef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
  602. { "POSIX_V6_ILP32_OFF32_LDFLAGS", _CS_POSIX_V6_ILP32_OFF32_LDFLAGS, CONFSTR },
  603. #endif
  604. #ifdef _CS_POSIX_V6_ILP32_OFF32_LIBS
  605. { "POSIX_V6_ILP32_OFF32_LIBS", _CS_POSIX_V6_ILP32_OFF32_LIBS, CONFSTR },
  606. #endif
  607. #ifdef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
  608. { "POSIX_V6_ILP32_OFF32_LINTFLAGS", _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS, CONFSTR },
  609. #endif
  610. #ifdef _CS_V6_WIDTH_RESTRICTED_ENVS
  611. { "_POSIX_V6_WIDTH_RESTRICTED_ENVS", _CS_V6_WIDTH_RESTRICTED_ENVS, CONFSTR },
  612. { "POSIX_V6_WIDTH_RESTRICTED_ENVS", _CS_V6_WIDTH_RESTRICTED_ENVS, CONFSTR },
  613. #endif
  614. #ifdef _SC_V6_ILP32_OFFBIG
  615. { "_POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG, SYSCONF },
  616. #endif
  617. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
  618. { "POSIX_V6_ILP32_OFFBIG_CFLAGS", _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, CONFSTR },
  619. #endif
  620. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
  621. { "POSIX_V6_ILP32_OFFBIG_LDFLAGS", _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS, CONFSTR },
  622. #endif
  623. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_LIBS
  624. { "POSIX_V6_ILP32_OFFBIG_LIBS", _CS_POSIX_V6_ILP32_OFFBIG_LIBS, CONFSTR },
  625. #endif
  626. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
  627. { "POSIX_V6_ILP32_OFFBIG_LINTFLAGS", _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
  628. #endif
  629. #ifdef _SC_V6_LP64_OFF64
  630. { "_POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64, SYSCONF },
  631. #endif
  632. #ifdef _CS_POSIX_V6_LP64_OFF64_CFLAGS
  633. { "POSIX_V6_LP64_OFF64_CFLAGS", _CS_POSIX_V6_LP64_OFF64_CFLAGS, CONFSTR },
  634. #endif
  635. #ifdef _CS_POSIX_V6_LP64_OFF64_LDFLAGS
  636. { "POSIX_V6_LP64_OFF64_LDFLAGS", _CS_POSIX_V6_LP64_OFF64_LDFLAGS, CONFSTR },
  637. #endif
  638. #ifdef _CS_POSIX_V6_LP64_OFF64_LIBS
  639. { "POSIX_V6_LP64_OFF64_LIBS", _CS_POSIX_V6_LP64_OFF64_LIBS, CONFSTR },
  640. #endif
  641. #ifdef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
  642. { "POSIX_V6_LP64_OFF64_LINTFLAGS", _CS_POSIX_V6_LP64_OFF64_LINTFLAGS, CONFSTR },
  643. #endif
  644. #ifdef _SC_V6_LPBIG_OFFBIG
  645. { "_POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG, SYSCONF },
  646. #endif
  647. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
  648. { "POSIX_V6_LPBIG_OFFBIG_CFLAGS", _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS, CONFSTR },
  649. #endif
  650. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
  651. { "POSIX_V6_LPBIG_OFFBIG_LDFLAGS", _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
  652. #endif
  653. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
  654. { "POSIX_V6_LPBIG_OFFBIG_LIBS", _CS_POSIX_V6_LPBIG_OFFBIG_LIBS, CONFSTR },
  655. #endif
  656. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
  657. { "POSIX_V6_LPBIG_OFFBIG_LINTFLAGS", _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
  658. #endif
  659. #ifdef _SC_V7_ILP32_OFF32
  660. { "_POSIX_V7_ILP32_OFF32", _SC_V7_ILP32_OFF32, SYSCONF },
  661. #endif
  662. #ifdef _CS_POSIX_V7_ILP32_OFF32_CFLAGS
  663. { "POSIX_V7_ILP32_OFF32_CFLAGS", _CS_POSIX_V7_ILP32_OFF32_CFLAGS, CONFSTR },
  664. #endif
  665. #ifdef _CS_POSIX_V7_ILP32_OFF32_LDFLAGS
  666. { "POSIX_V7_ILP32_OFF32_LDFLAGS", _CS_POSIX_V7_ILP32_OFF32_LDFLAGS, CONFSTR },
  667. #endif
  668. #ifdef _CS_POSIX_V7_ILP32_OFF32_LIBS
  669. { "POSIX_V7_ILP32_OFF32_LIBS", _CS_POSIX_V7_ILP32_OFF32_LIBS, CONFSTR },
  670. #endif
  671. #ifdef _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS
  672. { "POSIX_V7_ILP32_OFF32_LINTFLAGS", _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS, CONFSTR },
  673. #endif
  674. #ifdef _CS_V7_WIDTH_RESTRICTED_ENVS
  675. { "_POSIX_V7_WIDTH_RESTRICTED_ENVS", _CS_V7_WIDTH_RESTRICTED_ENVS, CONFSTR },
  676. { "POSIX_V7_WIDTH_RESTRICTED_ENVS", _CS_V7_WIDTH_RESTRICTED_ENVS, CONFSTR },
  677. #endif
  678. #ifdef _SC_V7_ILP32_OFFBIG
  679. { "_POSIX_V7_ILP32_OFFBIG", _SC_V7_ILP32_OFFBIG, SYSCONF },
  680. #endif
  681. #ifdef _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
  682. { "POSIX_V7_ILP32_OFFBIG_CFLAGS", _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS, CONFSTR },
  683. #endif
  684. #ifdef _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
  685. { "POSIX_V7_ILP32_OFFBIG_LDFLAGS", _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS, CONFSTR },
  686. #endif
  687. #ifdef _CS_POSIX_V7_ILP32_OFFBIG_LIBS
  688. { "POSIX_V7_ILP32_OFFBIG_LIBS", _CS_POSIX_V7_ILP32_OFFBIG_LIBS, CONFSTR },
  689. #endif
  690. #ifdef _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS
  691. { "POSIX_V7_ILP32_OFFBIG_LINTFLAGS", _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
  692. #endif
  693. #ifdef _SC_V7_LP64_OFF64
  694. { "_POSIX_V7_LP64_OFF64", _SC_V7_LP64_OFF64, SYSCONF },
  695. #endif
  696. #ifdef _CS_POSIX_V7_LP64_OFF64_CFLAGS
  697. { "POSIX_V7_LP64_OFF64_CFLAGS", _CS_POSIX_V7_LP64_OFF64_CFLAGS, CONFSTR },
  698. #endif
  699. #ifdef _CS_POSIX_V7_LP64_OFF64_LDFLAGS
  700. { "POSIX_V7_LP64_OFF64_LDFLAGS", _CS_POSIX_V7_LP64_OFF64_LDFLAGS, CONFSTR },
  701. #endif
  702. #ifdef _CS_POSIX_V7_LP64_OFF64_LIBS
  703. { "POSIX_V7_LP64_OFF64_LIBS", _CS_POSIX_V7_LP64_OFF64_LIBS, CONFSTR },
  704. #endif
  705. #ifdef _CS_POSIX_V7_LP64_OFF64_LINTFLAGS
  706. { "POSIX_V7_LP64_OFF64_LINTFLAGS", _CS_POSIX_V7_LP64_OFF64_LINTFLAGS, CONFSTR },
  707. #endif
  708. #ifdef _SC_V7_LPBIG_OFFBIG
  709. { "_POSIX_V7_LPBIG_OFFBIG", _SC_V7_LPBIG_OFFBIG, SYSCONF },
  710. #endif
  711. #ifdef _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
  712. { "POSIX_V7_LPBIG_OFFBIG_CFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS, CONFSTR },
  713. #endif
  714. #ifdef _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
  715. { "POSIX_V7_LPBIG_OFFBIG_LDFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
  716. #endif
  717. #ifdef _CS_POSIX_V7_LPBIG_OFFBIG_LIBS
  718. { "POSIX_V7_LPBIG_OFFBIG_LIBS", _CS_POSIX_V7_LPBIG_OFFBIG_LIBS, CONFSTR },
  719. #endif
  720. #ifdef _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS
  721. { "POSIX_V7_LPBIG_OFFBIG_LINTFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
  722. #endif
  723. #ifdef _SC_ADVISORY_INFO
  724. { "_POSIX_ADVISORY_INFO", _SC_ADVISORY_INFO, SYSCONF },
  725. #endif
  726. #ifdef _SC_BARRIERS
  727. { "_POSIX_BARRIERS", _SC_BARRIERS, SYSCONF },
  728. #endif
  729. #ifdef _SC_BASE
  730. { "_POSIX_BASE", _SC_BASE, SYSCONF },
  731. #endif
  732. #ifdef _SC_C_LANG_SUPPORT
  733. { "_POSIX_C_LANG_SUPPORT", _SC_C_LANG_SUPPORT, SYSCONF },
  734. #endif
  735. #ifdef _SC_C_LANG_SUPPORT_R
  736. { "_POSIX_C_LANG_SUPPORT_R", _SC_C_LANG_SUPPORT_R, SYSCONF },
  737. #endif
  738. #ifdef _SC_CLOCK_SELECTION
  739. { "_POSIX_CLOCK_SELECTION", _SC_CLOCK_SELECTION, SYSCONF },
  740. #endif
  741. #ifdef _SC_CPUTIME
  742. { "_POSIX_CPUTIME", _SC_CPUTIME, SYSCONF },
  743. #endif
  744. #ifdef _SC_THREAD_CPUTIME
  745. { "_POSIX_THREAD_CPUTIME", _SC_THREAD_CPUTIME, SYSCONF },
  746. #endif
  747. #ifdef _SC_DEVICE_SPECIFIC
  748. { "_POSIX_DEVICE_SPECIFIC", _SC_DEVICE_SPECIFIC, SYSCONF },
  749. #endif
  750. #ifdef _SC_DEVICE_SPECIFIC_R
  751. { "_POSIX_DEVICE_SPECIFIC_R", _SC_DEVICE_SPECIFIC_R, SYSCONF },
  752. #endif
  753. #ifdef _SC_FD_MGMT
  754. { "_POSIX_FD_MGMT", _SC_FD_MGMT, SYSCONF },
  755. #endif
  756. #ifdef _SC_FIFO
  757. { "_POSIX_FIFO", _SC_FIFO, SYSCONF },
  758. #endif
  759. #ifdef _SC_PIPE
  760. { "_POSIX_PIPE", _SC_PIPE, SYSCONF },
  761. #endif
  762. #ifdef _SC_FILE_ATTRIBUTES
  763. { "_POSIX_FILE_ATTRIBUTES", _SC_FILE_ATTRIBUTES, SYSCONF },
  764. #endif
  765. #ifdef _SC_FILE_LOCKING
  766. { "_POSIX_FILE_LOCKING", _SC_FILE_LOCKING, SYSCONF },
  767. #endif
  768. #ifdef _SC_FILE_SYSTEM
  769. { "_POSIX_FILE_SYSTEM", _SC_FILE_SYSTEM, SYSCONF },
  770. #endif
  771. #ifdef _SC_MONOTONIC_CLOCK
  772. { "_POSIX_MONOTONIC_CLOCK", _SC_MONOTONIC_CLOCK, SYSCONF },
  773. #endif
  774. #ifdef _SC_MULTI_PROCESS
  775. { "_POSIX_MULTI_PROCESS", _SC_MULTI_PROCESS, SYSCONF },
  776. #endif
  777. #ifdef _SC_SINGLE_PROCESS
  778. { "_POSIX_SINGLE_PROCESS", _SC_SINGLE_PROCESS, SYSCONF },
  779. #endif
  780. #ifdef _SC_NETWORKING
  781. { "_POSIX_NETWORKING", _SC_NETWORKING, SYSCONF },
  782. #endif
  783. #ifdef _SC_READER_WRITER_LOCKS
  784. { "_POSIX_READER_WRITER_LOCKS", _SC_READER_WRITER_LOCKS, SYSCONF },
  785. #endif
  786. #ifdef _SC_SPIN_LOCKS
  787. { "_POSIX_SPIN_LOCKS", _SC_SPIN_LOCKS, SYSCONF },
  788. #endif
  789. #ifdef _SC_REGEXP
  790. { "_POSIX_REGEXP", _SC_REGEXP, SYSCONF },
  791. #endif
  792. #ifdef _SC_REGEX_VERSION
  793. { "_REGEX_VERSION", _SC_REGEX_VERSION, SYSCONF },
  794. #endif
  795. #ifdef _SC_SHELL
  796. { "_POSIX_SHELL", _SC_SHELL, SYSCONF },
  797. #endif
  798. #ifdef _SC_SIGNALS
  799. { "_POSIX_SIGNALS", _SC_SIGNALS, SYSCONF },
  800. #endif
  801. #ifdef _SC_SPAWN
  802. { "_POSIX_SPAWN", _SC_SPAWN, SYSCONF },
  803. #endif
  804. #ifdef _SC_SPORADIC_SERVER
  805. { "_POSIX_SPORADIC_SERVER", _SC_SPORADIC_SERVER, SYSCONF },
  806. #endif
  807. #ifdef _SC_THREAD_SPORADIC_SERVER
  808. { "_POSIX_THREAD_SPORADIC_SERVER", _SC_THREAD_SPORADIC_SERVER, SYSCONF },
  809. #endif
  810. #ifdef _SC_SYSTEM_DATABASE
  811. { "_POSIX_SYSTEM_DATABASE", _SC_SYSTEM_DATABASE, SYSCONF },
  812. #endif
  813. #ifdef _SC_SYSTEM_DATABASE_R
  814. { "_POSIX_SYSTEM_DATABASE_R", _SC_SYSTEM_DATABASE_R, SYSCONF },
  815. #endif
  816. #ifdef _SC_TIMEOUTS
  817. { "_POSIX_TIMEOUTS", _SC_TIMEOUTS, SYSCONF },
  818. #endif
  819. #ifdef _SC_TYPED_MEMORY_OBJECTS
  820. { "_POSIX_TYPED_MEMORY_OBJECTS", _SC_TYPED_MEMORY_OBJECTS, SYSCONF },
  821. #endif
  822. #ifdef _SC_USER_GROUPS
  823. { "_POSIX_USER_GROUPS", _SC_USER_GROUPS, SYSCONF },
  824. #endif
  825. #ifdef _SC_USER_GROUPS_R
  826. { "_POSIX_USER_GROUPS_R", _SC_USER_GROUPS_R, SYSCONF },
  827. #endif
  828. #ifdef _SC_2_PBS
  829. { "POSIX2_PBS", _SC_2_PBS, SYSCONF },
  830. #endif
  831. #ifdef _SC_2_PBS_ACCOUNTING
  832. { "POSIX2_PBS_ACCOUNTING", _SC_2_PBS_ACCOUNTING, SYSCONF },
  833. #endif
  834. #ifdef _SC_2_PBS_LOCATE
  835. { "POSIX2_PBS_LOCATE", _SC_2_PBS_LOCATE, SYSCONF },
  836. #endif
  837. #ifdef _SC_2_PBS_TRACK
  838. { "POSIX2_PBS_TRACK", _SC_2_PBS_TRACK, SYSCONF },
  839. #endif
  840. #ifdef _SC_2_PBS_MESSAGE
  841. { "POSIX2_PBS_MESSAGE", _SC_2_PBS_MESSAGE, SYSCONF },
  842. #endif
  843. #ifdef _SC_SYMLOOP_MAX
  844. { "SYMLOOP_MAX", _SC_SYMLOOP_MAX, SYSCONF },
  845. #endif
  846. #ifdef _SC_STREAM_MAX
  847. { "STREAM_MAX", _SC_STREAM_MAX, SYSCONF },
  848. #endif
  849. #ifdef _SC_AIO_LISTIO_MAX
  850. { "AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX, SYSCONF },
  851. #endif
  852. #ifdef _SC_AIO_MAX
  853. { "AIO_MAX", _SC_AIO_MAX, SYSCONF },
  854. #endif
  855. #ifdef _SC_AIO_PRIO_DELTA_MAX
  856. { "AIO_PRIO_DELTA_MAX", _SC_AIO_PRIO_DELTA_MAX, SYSCONF },
  857. #endif
  858. #ifdef _SC_DELAYTIMER_MAX
  859. { "DELAYTIMER_MAX", _SC_DELAYTIMER_MAX, SYSCONF },
  860. #endif
  861. #ifdef _SC_HOST_NAME_MAX
  862. { "HOST_NAME_MAX", _SC_HOST_NAME_MAX, SYSCONF },
  863. #endif
  864. #ifdef _SC_LOGIN_NAME_MAX
  865. { "LOGIN_NAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
  866. #endif
  867. #ifdef _SC_MQ_OPEN_MAX
  868. { "MQ_OPEN_MAX", _SC_MQ_OPEN_MAX, SYSCONF },
  869. #endif
  870. #ifdef _SC_MQ_PRIO_MAX
  871. { "MQ_PRIO_MAX", _SC_MQ_PRIO_MAX, SYSCONF },
  872. #endif
  873. #ifdef _SC_DEVICE_IO
  874. { "_POSIX_DEVICE_IO", _SC_DEVICE_IO, SYSCONF },
  875. #endif
  876. #ifdef _SC_TRACE
  877. { "_POSIX_TRACE", _SC_TRACE, SYSCONF },
  878. #endif
  879. #ifdef _SC_TRACE_EVENT_FILTER
  880. { "_POSIX_TRACE_EVENT_FILTER", _SC_TRACE_EVENT_FILTER, SYSCONF },
  881. #endif
  882. #ifdef _SC_TRACE_INHERIT
  883. { "_POSIX_TRACE_INHERIT", _SC_TRACE_INHERIT, SYSCONF },
  884. #endif
  885. #ifdef _SC_TRACE_LOG
  886. { "_POSIX_TRACE_LOG", _SC_TRACE_LOG, SYSCONF },
  887. #endif
  888. #ifdef _SC_RTSIG_MAX
  889. { "RTSIG_MAX", _SC_RTSIG_MAX, SYSCONF },
  890. #endif
  891. #ifdef _SC_SEM_NSEMS_MAX
  892. { "SEM_NSEMS_MAX", _SC_SEM_NSEMS_MAX, SYSCONF },
  893. #endif
  894. #ifdef _SC_SEM_VALUE_MAX
  895. { "SEM_VALUE_MAX", _SC_SEM_VALUE_MAX, SYSCONF },
  896. #endif
  897. #ifdef _SC_SIGQUEUE_MAX
  898. { "SIGQUEUE_MAX", _SC_SIGQUEUE_MAX, SYSCONF },
  899. #endif
  900. #ifdef _PC_FILESIZEBITS
  901. { "FILESIZEBITS", _PC_FILESIZEBITS, PATHCONF },
  902. #endif
  903. #ifdef _PC_ALLOC_SIZE_MIN
  904. { "POSIX_ALLOC_SIZE_MIN", _PC_ALLOC_SIZE_MIN, PATHCONF },
  905. #endif
  906. #ifdef _PC_REC_INCR_XFER_SIZE
  907. { "POSIX_REC_INCR_XFER_SIZE", _PC_REC_INCR_XFER_SIZE, PATHCONF },
  908. #endif
  909. #ifdef _PC_REC_MAX_XFER_SIZE
  910. { "POSIX_REC_MAX_XFER_SIZE", _PC_REC_MAX_XFER_SIZE, PATHCONF },
  911. #endif
  912. #ifdef _PC_REC_MIN_XFER_SIZE
  913. { "POSIX_REC_MIN_XFER_SIZE", _PC_REC_MIN_XFER_SIZE, PATHCONF },
  914. #endif
  915. #ifdef _PC_REC_XFER_ALIGN
  916. { "POSIX_REC_XFER_ALIGN", _PC_REC_XFER_ALIGN, PATHCONF },
  917. #endif
  918. #ifdef _PC_SYMLINK_MAX
  919. { "SYMLINK_MAX", _PC_SYMLINK_MAX, PATHCONF },
  920. #endif
  921. #ifdef _CS_GNU_LIBC_VERSION
  922. { "GNU_LIBC_VERSION", _CS_GNU_LIBC_VERSION, CONFSTR },
  923. #endif
  924. #ifdef _CS_GNU_LIBPTHREAD_VERSION
  925. { "GNU_LIBPTHREAD_VERSION", _CS_GNU_LIBPTHREAD_VERSION, CONFSTR },
  926. #endif
  927. #ifdef _PC_2_SYMLINKS
  928. { "POSIX2_SYMLINKS", _PC_2_SYMLINKS, PATHCONF },
  929. #endif
  930. #ifdef _SC_LEVEL1_ICACHE_SIZE
  931. { "LEVEL1_ICACHE_SIZE", _SC_LEVEL1_ICACHE_SIZE, SYSCONF },
  932. #endif
  933. #ifdef _SC_LEVEL1_ICACHE_ASSOC
  934. { "LEVEL1_ICACHE_ASSOC", _SC_LEVEL1_ICACHE_ASSOC, SYSCONF },
  935. #endif
  936. #ifdef _SC_LEVEL1_ICACHE_LINESIZE
  937. { "LEVEL1_ICACHE_LINESIZE", _SC_LEVEL1_ICACHE_LINESIZE, SYSCONF },
  938. #endif
  939. #ifdef _SC_LEVEL1_DCACHE_SIZE
  940. { "LEVEL1_DCACHE_SIZE", _SC_LEVEL1_DCACHE_SIZE, SYSCONF },
  941. #endif
  942. #ifdef _SC_LEVEL1_DCACHE_ASSOC
  943. { "LEVEL1_DCACHE_ASSOC", _SC_LEVEL1_DCACHE_ASSOC, SYSCONF },
  944. #endif
  945. #ifdef _SC_LEVEL1_DCACHE_LINESIZE
  946. { "LEVEL1_DCACHE_LINESIZE", _SC_LEVEL1_DCACHE_LINESIZE, SYSCONF },
  947. #endif
  948. #ifdef _SC_LEVEL2_CACHE_SIZE
  949. { "LEVEL2_CACHE_SIZE", _SC_LEVEL2_CACHE_SIZE, SYSCONF },
  950. #endif
  951. #ifdef _SC_LEVEL2_CACHE_ASSOC
  952. { "LEVEL2_CACHE_ASSOC", _SC_LEVEL2_CACHE_ASSOC, SYSCONF },
  953. #endif
  954. #ifdef _SC_LEVEL2_CACHE_LINESIZE
  955. { "LEVEL2_CACHE_LINESIZE", _SC_LEVEL2_CACHE_LINESIZE, SYSCONF },
  956. #endif
  957. #ifdef _SC_LEVEL3_CACHE_SIZE
  958. { "LEVEL3_CACHE_SIZE", _SC_LEVEL3_CACHE_SIZE, SYSCONF },
  959. #endif
  960. #ifdef _SC_LEVEL3_CACHE_ASSOC
  961. { "LEVEL3_CACHE_ASSOC", _SC_LEVEL3_CACHE_ASSOC, SYSCONF },
  962. #endif
  963. #ifdef _SC_LEVEL3_CACHE_LINESIZE
  964. { "LEVEL3_CACHE_LINESIZE", _SC_LEVEL3_CACHE_LINESIZE, SYSCONF },
  965. #endif
  966. #ifdef _SC_LEVEL4_CACHE_SIZE
  967. { "LEVEL4_CACHE_SIZE", _SC_LEVEL4_CACHE_SIZE, SYSCONF },
  968. #endif
  969. #ifdef _SC_LEVEL4_CACHE_ASSOC
  970. { "LEVEL4_CACHE_ASSOC", _SC_LEVEL4_CACHE_ASSOC, SYSCONF },
  971. #endif
  972. #ifdef _SC_LEVEL4_CACHE_LINESIZE
  973. { "LEVEL4_CACHE_LINESIZE", _SC_LEVEL4_CACHE_LINESIZE, SYSCONF },
  974. #endif
  975. #ifdef _SC_IPV6
  976. { "IPV6", _SC_IPV6, SYSCONF },
  977. #endif
  978. #ifdef _SC_RAW_SOCKETS
  979. { "RAW_SOCKETS", _SC_RAW_SOCKETS, SYSCONF },
  980. #endif
  981. { NULL, 0, SYSCONF }
  982. };
  983. static const struct { const char *name; int num; } specs[] =
  984. {
  985. #ifdef _SC_XBS5_ILP32_OFF32
  986. { "XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32 },
  987. #endif
  988. #ifdef _SC_XBS5_ILP32_OFFBIG
  989. { "XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG },
  990. #endif
  991. #ifdef _SC_XBS5_LP64_OFF64
  992. { "XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64 },
  993. #endif
  994. #ifdef _SC_XBS5_LPBIG_OFFBIG
  995. { "XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG },
  996. #endif
  997. #ifdef _SC_V6_ILP32_OFF32
  998. { "POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32 },
  999. #endif
  1000. #ifdef _SC_V6_ILP32_OFFBIG
  1001. { "POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG },
  1002. #endif
  1003. #ifdef _SC_V6_LP64_OFF64
  1004. { "POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64 },
  1005. #endif
  1006. #ifdef _SC_V6_LPBIG_OFFBIG
  1007. { "POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG },
  1008. #endif
  1009. #ifdef _SC_V7_ILP32_OFF32
  1010. { "POSIX_V7_ILP32_OFF32", _SC_V7_ILP32_OFF32 },
  1011. #endif
  1012. #ifdef _SC_V7_ILP32_OFFBIG
  1013. { "POSIX_V7_ILP32_OFFBIG", _SC_V7_ILP32_OFFBIG },
  1014. #endif
  1015. #ifdef _SC_V7_LP64_OFF64
  1016. { "POSIX_V7_LP64_OFF64", _SC_V7_LP64_OFF64 },
  1017. #endif
  1018. #ifdef _SC_V7_LPBIG_OFFBIG
  1019. { "POSIX_V7_LPBIG_OFFBIG", _SC_V7_LPBIG_OFFBIG },
  1020. #endif
  1021. };
  1022. static const int nspecs = sizeof (specs) / sizeof (specs[0]);
  1023. #ifndef __UCLIBC_HAS___PROGNAME__
  1024. static const char *__progname = "getconf"
  1025. #endif
  1026. static attribute_noreturn void
  1027. usage (void)
  1028. {
  1029. fprintf (stderr,
  1030. _("Usage: %s [-v specification] variable_name [pathname]\n"),
  1031. __progname);
  1032. fprintf (stderr,
  1033. _(" %s -a [pathname]\n"), __progname);
  1034. exit (2);
  1035. }
  1036. static attribute_noreturn void
  1037. print_all (const char *path)
  1038. {
  1039. register const struct conf *c;
  1040. size_t clen;
  1041. long int value;
  1042. char *cvalue;
  1043. for (c = vars; c->name != NULL; ++c) {
  1044. printf("%-35s", c->name);
  1045. switch (c->call) {
  1046. case PATHCONF:
  1047. value = pathconf (path, c->call_name);
  1048. if (value != -1) {
  1049. printf("%ld", value);
  1050. }
  1051. printf("\n");
  1052. break;
  1053. case SYSCONF:
  1054. value = sysconf (c->call_name);
  1055. if (value == -1l) {
  1056. if (c->call_name == _SC_UINT_MAX
  1057. || c->call_name == _SC_ULONG_MAX)
  1058. printf ("%lu", value);
  1059. }
  1060. else {
  1061. printf ("%ld", value);
  1062. }
  1063. printf ("\n");
  1064. break;
  1065. case CONFSTR:
  1066. clen = confstr (c->call_name, (char *) NULL, 0);
  1067. cvalue = (char *) malloc (clen);
  1068. if (cvalue == NULL)
  1069. error (3, 0, _("memory exhausted"));
  1070. if (confstr (c->call_name, cvalue, clen) != clen)
  1071. error (3, errno, "confstr");
  1072. printf ("%.*s\n", (int) clen, cvalue);
  1073. free (cvalue);
  1074. break;
  1075. }
  1076. }
  1077. exit (0);
  1078. }
  1079. int
  1080. main (int argc, char *argv[])
  1081. {
  1082. register const struct conf *c;
  1083. /* Set locale. Do not set LC_ALL because the other categories must
  1084. not be affected (according to POSIX.2). */
  1085. /* Initialize the message catalog. */
  1086. if (argc > 1 && strcmp (argv[1], "--version") == 0)
  1087. {
  1088. printf ("getconf (GNU %s) %s\n", PACKAGE, VERSION);
  1089. printf ("\
  1090. Copyright (C) %s Free Software Foundation, Inc.\n\
  1091. This is free software; see the source for copying conditions. There is NO\n\
  1092. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
  1093. ", "2009");
  1094. printf ("Written by %s.\n", "Roland McGrath");
  1095. return 0;
  1096. }
  1097. if (argc > 1 && strcmp (argv[1], "--help") == 0)
  1098. {
  1099. printf ("\
  1100. Usage: getconf [-v SPEC] VAR\n\
  1101. or: getconf [-v SPEC] PATH_VAR PATH\n\
  1102. \n\
  1103. Get the configuration value for variable VAR, or for variable PATH_VAR\n\
  1104. for path PATH. If SPEC is given, give values for compilation\n\
  1105. environment SPEC.\n\n");
  1106. fputs ("For bug reporting instructions, please see:\n\
  1107. <http://www.gnu.org/software/libc/bugs.html>.\n", stdout);
  1108. return 0;
  1109. }
  1110. const char *getconf_dir = getenv ("GETCONF_DIR") ?: GETCONF_DIR;
  1111. size_t getconf_dirlen = strlen (getconf_dir);
  1112. const char *spec = NULL;
  1113. char buf[sizeof "POSIX_V6_LPBIG_OFFBIG"];
  1114. char *argv0 = argv[0];
  1115. if (argc > 1 && strncmp (argv[1], "-v", 2) == 0)
  1116. {
  1117. if (argv[1][2] == '\0')
  1118. {
  1119. if (argc < 3)
  1120. usage ();
  1121. spec = argv[2];
  1122. argv += 2;
  1123. argc -= 2;
  1124. }
  1125. else
  1126. {
  1127. spec = &argv[1][2];
  1128. argv += 1;
  1129. argc += 1;
  1130. }
  1131. }
  1132. else
  1133. {
  1134. char default_name[getconf_dirlen + sizeof "/default"];
  1135. memcpy (mempcpy (default_name, getconf_dir, getconf_dirlen),
  1136. "/default", sizeof "/default");
  1137. int len = readlink (default_name, buf, sizeof buf - 1);
  1138. if (len > 0)
  1139. {
  1140. buf[len] = '\0';
  1141. spec = buf;
  1142. }
  1143. }
  1144. /* Check for the specifications we know. */
  1145. if (spec != NULL)
  1146. {
  1147. int i;
  1148. for (i = 0; i < nspecs; ++i)
  1149. if (strcmp (spec, specs[i].name) == 0)
  1150. break;
  1151. if (i == nspecs)
  1152. error (2, 0, _("unknown specification \"%s\""), spec);
  1153. switch (specs[i].num)
  1154. {
  1155. #if !defined(_XBS5_ILP32_OFF32) && defined(_SC_XBS5_ILP32_OFF32)
  1156. case _SC_XBS5_ILP32_OFF32:
  1157. #endif
  1158. #if !defined(_XBS5_ILP32_OFFBIG) && defined(_SC_XBS5_ILP32_OFFBIG)
  1159. case _SC_XBS5_ILP32_OFFBIG:
  1160. #endif
  1161. #if !defined(_XBS5_LP64_OFF64) && defined(_SC_XBS5_LP64_OFF64)
  1162. case _SC_XBS5_LP64_OFF64:
  1163. #endif
  1164. #if !defined(_XBS5_LPBIG_OFFBIG) && defined(_SC_XBS5_LPBIG_OFFBIG)
  1165. case _SC_XBS5_LPBIG_OFFBIG:
  1166. #endif
  1167. #if !defined(_POSIX_V6_ILP32_OFF32) && defined(_SC_V6_ILP32_OFF32)
  1168. case _SC_V6_ILP32_OFF32:
  1169. #endif
  1170. #if !defined(_POSIX_V6_ILP32_OFFBIG) && defined(_SC_V6_ILP32_OFFBIG)
  1171. case _SC_V6_ILP32_OFFBIG:
  1172. #endif
  1173. #if !defined(_POSIX_V6_LP64_OFF64) && defined(_SC_V6_LP64_OFF64)
  1174. case _SC_V6_LP64_OFF64:
  1175. #endif
  1176. #if !defined(_POSIX_V6_LPBIG_OFFBIG) && defined(_SC_V6_LPBIG_OFFBIG)
  1177. case _SC_V6_LPBIG_OFFBIG:
  1178. #endif
  1179. #if !defined(_POSIX_V7_ILP32_OFF32) && defined(_SC_V7_ILP32_OFF32)
  1180. case _SC_V7_ILP32_OFF32:
  1181. #endif
  1182. #if !defined(_POSIX_V7_ILP32_OFFBIG) && defined(_SC_V7_ILP32_OFFBIG)
  1183. case _SC_V7_ILP32_OFFBIG:
  1184. #endif
  1185. #if !defined(_POSIX_V7_LP64_OFF64) && defined(_SC_V7_LP64_OFF64)
  1186. case _SC_V7_LP64_OFF64:
  1187. #endif
  1188. #if !defined(_POSIX_V7_LPBIG_OFFBIG) && defined(_SC_V7_LPBIG_OFFBIG)
  1189. case _SC_V7_LPBIG_OFFBIG:
  1190. #endif
  1191. {
  1192. const char *args[argc + 3];
  1193. size_t spec_len = strlen (spec);
  1194. char getconf_name[getconf_dirlen + 1 + spec_len + 1];
  1195. memcpy (mempcpy (mempcpy (getconf_name, getconf_dir,
  1196. getconf_dirlen),
  1197. "/", 1), spec, spec_len + 1);
  1198. args[0] = argv0;
  1199. args[1] = "-v";
  1200. args[2] = spec;
  1201. memcpy (&args[3], &argv[1], argc * sizeof (argv[1]));
  1202. execv (getconf_name, (char * const *) args);
  1203. error (4, errno, _("Couldn't execute %s"), getconf_name);
  1204. }
  1205. default:
  1206. break;
  1207. }
  1208. }
  1209. if (argc > 1 && strcmp (argv[1], "-a") == 0)
  1210. {
  1211. if (argc == 2)
  1212. print_all ("/");
  1213. else if (argc == 3)
  1214. print_all (argv[2]);
  1215. else
  1216. usage ();
  1217. }
  1218. int ai = 1;
  1219. if (argc > ai && strcmp (argv[ai], "--") == 0)
  1220. ++ai;
  1221. if (argc - ai < 1 || argc - ai > 2)
  1222. usage ();
  1223. for (c = vars; c->name != NULL; ++c)
  1224. if (strcmp (c->name, argv[ai]) == 0
  1225. || (strncmp (c->name, "_POSIX_", 7) == 0
  1226. && strcmp (c->name + 7, argv[ai]) == 0))
  1227. {
  1228. long int value;
  1229. size_t clen;
  1230. char *cvalue;
  1231. switch (c->call)
  1232. {
  1233. case PATHCONF:
  1234. if (argc - ai < 2)
  1235. usage ();
  1236. errno = 0;
  1237. value = pathconf (argv[ai + 1], c->call_name);
  1238. if (value == -1)
  1239. {
  1240. if (errno) {
  1241. error (3, errno, "pathconf: %s", argv[ai + 1]);
  1242. } else
  1243. puts (_("undefined"));
  1244. }
  1245. else
  1246. printf ("%ld\n", value);
  1247. exit (0);
  1248. case SYSCONF:
  1249. if (argc - ai > 1)
  1250. usage ();
  1251. value = sysconf (c->call_name);
  1252. if (value == -1l)
  1253. {
  1254. if (c->call_name == _SC_UINT_MAX
  1255. || c->call_name == _SC_ULONG_MAX)
  1256. printf ("%lu\n", value);
  1257. else
  1258. puts (_("undefined"));
  1259. }
  1260. else
  1261. printf ("%ld\n", value);
  1262. exit (0);
  1263. case CONFSTR:
  1264. if (argc - ai > 1)
  1265. usage ();
  1266. clen = confstr (c->call_name, (char *) NULL, 0);
  1267. cvalue = (char *) malloc (clen);
  1268. if (cvalue == NULL)
  1269. error (3, 0, _("memory exhausted"));
  1270. if (confstr (c->call_name, cvalue, clen) != clen)
  1271. error (3, errno, "confstr");
  1272. printf ("%.*s\n", (int) clen, cvalue);
  1273. exit (0);
  1274. }
  1275. }
  1276. error (2, 0, _("Unrecognized variable `%s'"), argv[ai]);
  1277. /* NOTREACHED */
  1278. return 2;
  1279. }