getopt_nolong.h (1464B)
- // utils-std: Collection of commonly available Unix tools
- // SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- // SPDX-License-Identifier: MPL-2.0
- #include <stdbool.h>
- extern const char *argv0;
- extern bool got_long_opt;
- int getopt_nolong(int argc, char *const argv[], const char *optstring);
- #ifdef HAS_GETOPT_LONG
- #define GETOPT_UNKNOWN_OPT \
- if(argv[optind - 1] && argv[optind - 1][0] == '-' && argv[optind - 1][1] == '-' && \
- argv[optind - 1][2] != '\0') \
- { \
- fprintf(stderr, "%s: error: Unrecognised long option: '%s'\n", argv0, argv[optind - 1]); \
- } \
- else if(!got_long_opt) \
- { \
- fprintf(stderr, "%s: error: Unrecognised option: '-%c'\n", argv0, optopt); \
- }
- #else
- #define GETOPT_UNKNOWN_OPT \
- if(!got_long_opt) fprintf(stderr, "%s: error: Unrecognised option: '-%c'\n", argv0, optopt);
- #endif