win_getopt.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. #ifndef __GETOPT_H__
  2. /**
  3. * DISCLAIMER
  4. * This file is part of the mingw-w64 runtime package.
  5. *
  6. * The mingw-w64 runtime package and its code is distributed in the hope that it
  7. * will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
  8. * IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
  9. * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. */
  11. /*
  12. * Copyright (c) 2002 Todd C. Miller <[email protected]>
  13. *
  14. * Permission to use, copy, modify, and distribute this software for any
  15. * purpose with or without fee is hereby granted, provided that the above
  16. * copyright notice and this permission notice appear in all copies.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  19. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  20. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  21. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  22. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  23. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  24. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  25. *
  26. * Sponsored in part by the Defense Advanced Research Projects
  27. * Agency (DARPA) and Air Force Research Laboratory, Air Force
  28. * Materiel Command, USAF, under agreement number F39502-99-1-0512.
  29. */
  30. /*-
  31. * Copyright (c) 2000 The NetBSD Foundation, Inc.
  32. * All rights reserved.
  33. *
  34. * This code is derived from software contributed to The NetBSD Foundation
  35. * by Dieter Baron and Thomas Klausner.
  36. *
  37. * Redistribution and use in source and binary forms, with or without
  38. * modification, are permitted provided that the following conditions
  39. * are met:
  40. * 1. Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * 2. Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in the
  44. * documentation and/or other materials provided with the distribution.
  45. *
  46. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  47. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  48. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  49. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  50. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  51. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  52. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  53. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  54. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  55. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  56. * POSSIBILITY OF SUCH DAMAGE.
  57. */
  58. #pragma warning(disable:4996)
  59. #define __GETOPT_H__
  60. /* All the headers include this file. */
  61. #include <crtdefs.h>
  62. #include <errno.h>
  63. #include <stdlib.h>
  64. #include <string.h>
  65. #include <stdarg.h>
  66. #include <stdio.h>
  67. //#include <windows.h>
  68. #ifdef __cplusplus
  69. extern "C" {
  70. #endif
  71. #define REPLACE_GETOPT /* use this getopt as the system getopt(3) */
  72. #ifdef REPLACE_GETOPT
  73. int opterr = 1; /* if error message should be printed */
  74. int optind = 1; /* index into parent argv vector */
  75. int optopt = '?'; /* character checked for validity */
  76. #undef optreset /* see getopt.h */
  77. #define optreset __mingw_optreset
  78. int optreset; /* reset getopt */
  79. char *optarg; /* argument associated with option */
  80. #endif
  81. //extern int optind; /* index of first non-option in argv */
  82. //extern int optopt; /* single option character, as parsed */
  83. //extern int opterr; /* flag to enable built-in diagnostics... */
  84. // /* (user may set to zero, to suppress) */
  85. //
  86. //extern char *optarg; /* pointer to argument of current option */
  87. #define PRINT_ERROR ((opterr) && (*options != ':'))
  88. #define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
  89. #define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
  90. #define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
  91. /* return values */
  92. #define BADCH (int)'?'
  93. #define BADARG ((*options == ':') ? (int)':' : (int)'?')
  94. #define INORDER (int)1
  95. #ifndef __CYGWIN__
  96. #define __progname __argv[0]
  97. #else
  98. extern char __declspec(dllimport) *__progname;
  99. #endif
  100. #ifdef __CYGWIN__
  101. static char EMSG[] = "";
  102. #else
  103. #define EMSG ""
  104. #endif
  105. static int getopt_internal(int, char * const *, const char *,
  106. const struct option *, int *, int);
  107. static int parse_long_options(char * const *, const char *,
  108. const struct option *, int *, int);
  109. static int gcd(int, int);
  110. static void permute_args(int, int, int, char * const *);
  111. static char *place = EMSG; /* option letter processing */
  112. /* XXX: set optreset to 1 rather than these two */
  113. static int nonopt_start = -1; /* first non option argument (for permute) */
  114. static int nonopt_end = -1; /* first option after non options (for permute) */
  115. /* Error messages */
  116. static const char recargchar[] = "option requires an argument -- %c";
  117. static const char recargstring[] = "option requires an argument -- %s";
  118. static const char ambig[] = "ambiguous option -- %.*s";
  119. static const char noarg[] = "option doesn't take an argument -- %.*s";
  120. static const char illoptchar[] = "unknown option -- %c";
  121. static const char illoptstring[] = "unknown option -- %s";
  122. static void
  123. _vwarnx(const char *fmt,va_list ap)
  124. {
  125. (void)fprintf(stderr,"%s: ",__progname);
  126. if (fmt != NULL)
  127. (void)vfprintf(stderr,fmt,ap);
  128. (void)fprintf(stderr,"\n");
  129. }
  130. static void
  131. warnx(const char *fmt,...)
  132. {
  133. va_list ap;
  134. va_start(ap,fmt);
  135. _vwarnx(fmt,ap);
  136. va_end(ap);
  137. }
  138. /*
  139. * Compute the greatest common divisor of a and b.
  140. */
  141. static int
  142. gcd(int a, int b)
  143. {
  144. int c;
  145. c = a % b;
  146. while (c != 0) {
  147. a = b;
  148. b = c;
  149. c = a % b;
  150. }
  151. return (b);
  152. }
  153. /*
  154. * Exchange the block from nonopt_start to nonopt_end with the block
  155. * from nonopt_end to opt_end (keeping the same order of arguments
  156. * in each block).
  157. */
  158. static void
  159. permute_args(int panonopt_start, int panonopt_end, int opt_end,
  160. char * const *nargv)
  161. {
  162. int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
  163. char *swap;
  164. /*
  165. * compute lengths of blocks and number and size of cycles
  166. */
  167. nnonopts = panonopt_end - panonopt_start;
  168. nopts = opt_end - panonopt_end;
  169. ncycle = gcd(nnonopts, nopts);
  170. cyclelen = (opt_end - panonopt_start) / ncycle;
  171. for (i = 0; i < ncycle; i++) {
  172. cstart = panonopt_end+i;
  173. pos = cstart;
  174. for (j = 0; j < cyclelen; j++) {
  175. if (pos >= panonopt_end)
  176. pos -= nnonopts;
  177. else
  178. pos += nopts;
  179. swap = nargv[pos];
  180. /* LINTED const cast */
  181. ((char **) nargv)[pos] = nargv[cstart];
  182. /* LINTED const cast */
  183. ((char **)nargv)[cstart] = swap;
  184. }
  185. }
  186. }
  187. #ifdef REPLACE_GETOPT
  188. /*
  189. * getopt --
  190. * Parse argc/argv argument vector.
  191. *
  192. * [eventually this will replace the BSD getopt]
  193. */
  194. int
  195. getopt(int nargc, char * const *nargv, const char *options)
  196. {
  197. /*
  198. * We don't pass FLAG_PERMUTE to getopt_internal() since
  199. * the BSD getopt(3) (unlike GNU) has never done this.
  200. *
  201. * Furthermore, since many privileged programs call getopt()
  202. * before dropping privileges it makes sense to keep things
  203. * as simple (and bug-free) as possible.
  204. */
  205. return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
  206. }
  207. #endif /* REPLACE_GETOPT */
  208. //extern int getopt(int nargc, char * const *nargv, const char *options);
  209. #ifdef _BSD_SOURCE
  210. /*
  211. * BSD adds the non-standard `optreset' feature, for reinitialisation
  212. * of `getopt' parsing. We support this feature, for applications which
  213. * proclaim their BSD heritage, before including this header; however,
  214. * to maintain portability, developers are advised to avoid it.
  215. */
  216. # define optreset __mingw_optreset
  217. extern int optreset;
  218. #endif
  219. #ifdef __cplusplus
  220. }
  221. #endif
  222. /*
  223. * POSIX requires the `getopt' API to be specified in `unistd.h';
  224. * thus, `unistd.h' includes this header. However, we do not want
  225. * to expose the `getopt_long' or `getopt_long_only' APIs, when
  226. * included in this manner. Thus, close the standard __GETOPT_H__
  227. * declarations block, and open an additional __GETOPT_LONG_H__
  228. * specific block, only when *not* __UNISTD_H_SOURCED__, in which
  229. * to declare the extended API.
  230. */
  231. #endif /* !defined(__GETOPT_H__) */
  232. #if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
  233. #define __GETOPT_LONG_H__
  234. #ifdef __cplusplus
  235. extern "C" {
  236. #endif
  237. struct option /* specification for a long form option... */
  238. {
  239. const char *name; /* option name, without leading hyphens */
  240. int has_arg; /* does it take an argument? */
  241. int *flag; /* where to save its status, or NULL */
  242. int val; /* its associated status value */
  243. };
  244. enum /* permitted values for its `has_arg' field... */
  245. {
  246. no_argument = 0, /* option never takes an argument */
  247. required_argument, /* option always requires an argument */
  248. optional_argument /* option may take an argument */
  249. };
  250. /*
  251. * parse_long_options --
  252. * Parse long options in argc/argv argument vector.
  253. * Returns -1 if short_too is set and the option does not match long_options.
  254. */
  255. static int
  256. parse_long_options(char * const *nargv, const char *options,
  257. const struct option *long_options, int *idx, int short_too)
  258. {
  259. char *current_argv, *has_equal;
  260. size_t current_argv_len;
  261. int i, ambiguous, match;
  262. #define IDENTICAL_INTERPRETATION(_x, _y) \
  263. (long_options[(_x)].has_arg == long_options[(_y)].has_arg && \
  264. long_options[(_x)].flag == long_options[(_y)].flag && \
  265. long_options[(_x)].val == long_options[(_y)].val)
  266. current_argv = place;
  267. match = -1;
  268. ambiguous = 0;
  269. optind++;
  270. if ((has_equal = strchr(current_argv, '=')) != NULL) {
  271. /* argument found (--option=arg) */
  272. current_argv_len = has_equal - current_argv;
  273. has_equal++;
  274. } else
  275. current_argv_len = strlen(current_argv);
  276. for (i = 0; long_options[i].name; i++) {
  277. /* find matching long option */
  278. if (strncmp(current_argv, long_options[i].name,
  279. current_argv_len))
  280. continue;
  281. if (strlen(long_options[i].name) == current_argv_len) {
  282. /* exact match */
  283. match = i;
  284. ambiguous = 0;
  285. break;
  286. }
  287. /*
  288. * If this is a known short option, don't allow
  289. * a partial match of a single character.
  290. */
  291. if (short_too && current_argv_len == 1)
  292. continue;
  293. if (match == -1) /* partial match */
  294. match = i;
  295. else if (!IDENTICAL_INTERPRETATION(i, match))
  296. ambiguous = 1;
  297. }
  298. if (ambiguous) {
  299. /* ambiguous abbreviation */
  300. if (PRINT_ERROR)
  301. warnx(ambig, (int)current_argv_len,
  302. current_argv);
  303. optopt = 0;
  304. return (BADCH);
  305. }
  306. if (match != -1) { /* option found */
  307. if (long_options[match].has_arg == no_argument
  308. && has_equal) {
  309. if (PRINT_ERROR)
  310. warnx(noarg, (int)current_argv_len,
  311. current_argv);
  312. /*
  313. * XXX: GNU sets optopt to val regardless of flag
  314. */
  315. if (long_options[match].flag == NULL)
  316. optopt = long_options[match].val;
  317. else
  318. optopt = 0;
  319. return (BADARG);
  320. }
  321. if (long_options[match].has_arg == required_argument ||
  322. long_options[match].has_arg == optional_argument) {
  323. if (has_equal)
  324. optarg = has_equal;
  325. else if (long_options[match].has_arg ==
  326. required_argument) {
  327. /*
  328. * optional argument doesn't use next nargv
  329. */
  330. optarg = nargv[optind++];
  331. }
  332. }
  333. if ((long_options[match].has_arg == required_argument)
  334. && (optarg == NULL)) {
  335. /*
  336. * Missing argument; leading ':' indicates no error
  337. * should be generated.
  338. */
  339. if (PRINT_ERROR)
  340. warnx(recargstring,
  341. current_argv);
  342. /*
  343. * XXX: GNU sets optopt to val regardless of flag
  344. */
  345. if (long_options[match].flag == NULL)
  346. optopt = long_options[match].val;
  347. else
  348. optopt = 0;
  349. --optind;
  350. return (BADARG);
  351. }
  352. } else { /* unknown option */
  353. if (short_too) {
  354. --optind;
  355. return (-1);
  356. }
  357. if (PRINT_ERROR)
  358. warnx(illoptstring, current_argv);
  359. optopt = 0;
  360. return (BADCH);
  361. }
  362. if (idx)
  363. *idx = match;
  364. if (long_options[match].flag) {
  365. *long_options[match].flag = long_options[match].val;
  366. return (0);
  367. } else
  368. return (long_options[match].val);
  369. #undef IDENTICAL_INTERPRETATION
  370. }
  371. /*
  372. * getopt_internal --
  373. * Parse argc/argv argument vector. Called by user level routines.
  374. */
  375. static int
  376. getopt_internal(int nargc, char * const *nargv, const char *options,
  377. const struct option *long_options, int *idx, int flags)
  378. {
  379. char *oli; /* option letter list index */
  380. int optchar, short_too;
  381. static int posixly_correct = -1;
  382. if (options == NULL)
  383. return (-1);
  384. /*
  385. * XXX Some GNU programs (like cvs) set optind to 0 instead of
  386. * XXX using optreset. Work around this braindamage.
  387. */
  388. if (optind == 0)
  389. optind = optreset = 1;
  390. /*
  391. * Disable GNU extensions if POSIXLY_CORRECT is set or options
  392. * string begins with a '+'.
  393. *
  394. * CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or
  395. * optreset != 0 for GNU compatibility.
  396. */
  397. if (posixly_correct == -1 || optreset != 0)
  398. posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
  399. if (*options == '-')
  400. flags |= FLAG_ALLARGS;
  401. else if (posixly_correct || *options == '+')
  402. flags &= ~FLAG_PERMUTE;
  403. if (*options == '+' || *options == '-')
  404. options++;
  405. optarg = NULL;
  406. if (optreset)
  407. nonopt_start = nonopt_end = -1;
  408. start:
  409. if (optreset || !*place) { /* update scanning pointer */
  410. optreset = 0;
  411. if (optind >= nargc) { /* end of argument vector */
  412. place = EMSG;
  413. if (nonopt_end != -1) {
  414. /* do permutation, if we have to */
  415. permute_args(nonopt_start, nonopt_end,
  416. optind, nargv);
  417. optind -= nonopt_end - nonopt_start;
  418. }
  419. else if (nonopt_start != -1) {
  420. /*
  421. * If we skipped non-options, set optind
  422. * to the first of them.
  423. */
  424. optind = nonopt_start;
  425. }
  426. nonopt_start = nonopt_end = -1;
  427. return (-1);
  428. }
  429. if (*(place = nargv[optind]) != '-' ||
  430. (place[1] == '\0' && strchr(options, '-') == NULL)) {
  431. place = EMSG; /* found non-option */
  432. if (flags & FLAG_ALLARGS) {
  433. /*
  434. * GNU extension:
  435. * return non-option as argument to option 1
  436. */
  437. optarg = nargv[optind++];
  438. return (INORDER);
  439. }
  440. if (!(flags & FLAG_PERMUTE)) {
  441. /*
  442. * If no permutation wanted, stop parsing
  443. * at first non-option.
  444. */
  445. return (-1);
  446. }
  447. /* do permutation */
  448. if (nonopt_start == -1)
  449. nonopt_start = optind;
  450. else if (nonopt_end != -1) {
  451. permute_args(nonopt_start, nonopt_end,
  452. optind, nargv);
  453. nonopt_start = optind -
  454. (nonopt_end - nonopt_start);
  455. nonopt_end = -1;
  456. }
  457. optind++;
  458. /* process next argument */
  459. goto start;
  460. }
  461. if (nonopt_start != -1 && nonopt_end == -1)
  462. nonopt_end = optind;
  463. /*
  464. * If we have "-" do nothing, if "--" we are done.
  465. */
  466. if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
  467. optind++;
  468. place = EMSG;
  469. /*
  470. * We found an option (--), so if we skipped
  471. * non-options, we have to permute.
  472. */
  473. if (nonopt_end != -1) {
  474. permute_args(nonopt_start, nonopt_end,
  475. optind, nargv);
  476. optind -= nonopt_end - nonopt_start;
  477. }
  478. nonopt_start = nonopt_end = -1;
  479. return (-1);
  480. }
  481. }
  482. /*
  483. * Check long options if:
  484. * 1) we were passed some
  485. * 2) the arg is not just "-"
  486. * 3) either the arg starts with -- we are getopt_long_only()
  487. */
  488. if (long_options != NULL && place != nargv[optind] &&
  489. (*place == '-' || (flags & FLAG_LONGONLY))) {
  490. short_too = 0;
  491. if (*place == '-')
  492. place++; /* --foo long option */
  493. else if (*place != ':' && strchr(options, *place) != NULL)
  494. short_too = 1; /* could be short option too */
  495. optchar = parse_long_options(nargv, options, long_options,
  496. idx, short_too);
  497. if (optchar != -1) {
  498. place = EMSG;
  499. return (optchar);
  500. }
  501. }
  502. if ((optchar = (int)*place++) == (int)':' ||
  503. (optchar == (int)'-' && *place != '\0') ||
  504. (oli = (char*)strchr(options, optchar)) == NULL) {
  505. /*
  506. * If the user specified "-" and '-' isn't listed in
  507. * options, return -1 (non-option) as per POSIX.
  508. * Otherwise, it is an unknown option character (or ':').
  509. */
  510. if (optchar == (int)'-' && *place == '\0')
  511. return (-1);
  512. if (!*place)
  513. ++optind;
  514. if (PRINT_ERROR)
  515. warnx(illoptchar, optchar);
  516. optopt = optchar;
  517. return (BADCH);
  518. }
  519. if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
  520. /* -W long-option */
  521. if (*place) /* no space */
  522. /* NOTHING */;
  523. else if (++optind >= nargc) { /* no arg */
  524. place = EMSG;
  525. if (PRINT_ERROR)
  526. warnx(recargchar, optchar);
  527. optopt = optchar;
  528. return (BADARG);
  529. } else /* white space */
  530. place = nargv[optind];
  531. optchar = parse_long_options(nargv, options, long_options,
  532. idx, 0);
  533. place = EMSG;
  534. return (optchar);
  535. }
  536. if (*++oli != ':') { /* doesn't take argument */
  537. if (!*place)
  538. ++optind;
  539. } else { /* takes (optional) argument */
  540. optarg = NULL;
  541. if (*place) /* no white space */
  542. optarg = place;
  543. else if (oli[1] != ':') { /* arg not optional */
  544. if (++optind >= nargc) { /* no arg */
  545. place = EMSG;
  546. if (PRINT_ERROR)
  547. warnx(recargchar, optchar);
  548. optopt = optchar;
  549. return (BADARG);
  550. } else
  551. optarg = nargv[optind];
  552. }
  553. place = EMSG;
  554. ++optind;
  555. }
  556. /* dump back option letter */
  557. return (optchar);
  558. }
  559. /*
  560. * getopt_long --
  561. * Parse argc/argv argument vector.
  562. */
  563. int
  564. getopt_long(int nargc, char * const *nargv, const char *options,
  565. const struct option *long_options, int *idx)
  566. {
  567. return (getopt_internal(nargc, nargv, options, long_options, idx,
  568. FLAG_PERMUTE));
  569. }
  570. /*
  571. * getopt_long_only --
  572. * Parse argc/argv argument vector.
  573. */
  574. int
  575. getopt_long_only(int nargc, char * const *nargv, const char *options,
  576. const struct option *long_options, int *idx)
  577. {
  578. return (getopt_internal(nargc, nargv, options, long_options, idx,
  579. FLAG_PERMUTE|FLAG_LONGONLY));
  580. }
  581. //extern int getopt_long(int nargc, char * const *nargv, const char *options,
  582. // const struct option *long_options, int *idx);
  583. //extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
  584. // const struct option *long_options, int *idx);
  585. /*
  586. * Previous MinGW implementation had...
  587. */
  588. #ifndef HAVE_DECL_GETOPT
  589. /*
  590. * ...for the long form API only; keep this for compatibility.
  591. */
  592. # define HAVE_DECL_GETOPT 1
  593. #endif
  594. #ifdef __cplusplus
  595. }
  596. #endif
  597. #endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */