| 1 | /* gopt-errors.c PUBILC DOMAIN 2015 [email protected] */cxx . . $ `<file>/tools/gopt-errors.c`/ |
| 2 | |
| 3 | /* <http:///www.purposeful.co.uk/software/gopt> */ |
| 4 | |
| 5 | /* |
| 6 | I, Tom Vajzovic, am the author of this software and its documentation. |
| 7 | I permanently abandon all intellectual property rights in them, including |
| 8 | copyright, trademarks, design rights, database right, patents, and the right |
| 9 | to be identified as the author. |
| 10 | |
| 11 | I am fairly certain that the software does what the documentation says it |
| 12 | does, but I do not guarantee that it does, or that it does what you think it |
| 13 | should. I do not guarantee that it will not have undesirable side effects. |
| 14 | |
| 15 | You are free to use, modify and distribute this software as you please, but |
| 16 | you do so at your own risk. If you do not pass on this warning then you may |
| 17 | be responsible for any problems encountered by those who obtain the software |
| 18 | through you. |
| 19 | */ |
| 20 | |
| 21 | #include <stdlib.h> |
| 22 | #include <stdio.h> |
| 23 | |
| 24 | #ifdef _BSD_SOURCE |
| 25 | #include <sysexits.h> |
| 26 | #else |
| 27 | #define EX_USAGEcxx . . $ `tools/gopt-errors.c:27:9`! EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`! |
| 28 | #endif |
| 29 | |
| 30 | #include "gopt.h"cxx . . $ `<file>/tools/gopt.h`/ |
| 31 | |
| 32 | void gopt_errorscxx . . $ gopt_errors(fd2d4ff1d55e8b12). (const char *argv0, const struct optioncxx . . $ option# *options) |
| 33 | { |
| 34 | unsigned int bad_option_index = 0; |
| 35 | unsigned int i; |
| 36 | |
| 37 | while (!(options[bad_option_index].flagscxx . . $ option#flags. & GOPT_LASTcxx . . $ `tools/gopt.h:52:9`!)) |
| 38 | { |
| 39 | bad_option_index++; |
| 40 | } |
| 41 | |
| 42 | if (options[bad_option_index].short_namecxx . . $ option#short_name.) |
| 43 | { |
| 44 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: unrecognised option -%c\n", argv0, options[bad_option_index].short_namecxx . . $ option#short_name.); |
| 45 | exitcxx . . $ exit(3ca292c338df9bb3). (EX_USAGEcxx . . $ `tools/gopt-errors.c:27:9`!); |
| 46 | } |
| 47 | |
| 48 | if (options[bad_option_index].long_namecxx . . $ option#long_name.) |
| 49 | { |
| 50 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: unrecognised option --%s\n", argv0, options[bad_option_index].long_namecxx . . $ option#long_name.); |
| 51 | exitcxx . . $ exit(3ca292c338df9bb3). (EX_USAGEcxx . . $ `tools/gopt-errors.c:27:9`!); |
| 52 | } |
| 53 | |
| 54 | for (i = 0; i < bad_option_index; i++) |
| 55 | { |
| 56 | if ((options[i].flagscxx . . $ option#flags. & GOPT_SEEN_SHORT_WITHOUTcxx . . $ `tools/gopt.h:48:9`!) && (options[i].flagscxx . . $ option#flags. & GOPT_ARGUMENT_REQUIREDcxx . . $ `tools/gopt.h:45:9`!)) |
| 57 | { |
| 58 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: option -%c requires an option-argument\n", argv0, options[i].short_namecxx . . $ option#short_name.); |
| 59 | exitcxx . . $ exit(3ca292c338df9bb3). (EX_USAGEcxx . . $ `tools/gopt-errors.c:27:9`!); |
| 60 | } |
| 61 | |
| 62 | if ((options[i].flagscxx . . $ option#flags. & GOPT_SEEN_SHORT_WITHcxx . . $ `tools/gopt.h:49:9`!) && (options[i].flagscxx . . $ option#flags. & GOPT_ARGUMENT_FORBIDDENcxx . . $ `tools/gopt.h:44:9`!)) |
| 63 | { |
| 64 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: option -%c must not have an option-argument\n", argv0, options[i].short_namecxx . . $ option#short_name.); |
| 65 | exitcxx . . $ exit(3ca292c338df9bb3). (EX_USAGEcxx . . $ `tools/gopt-errors.c:27:9`!); |
| 66 | } |
| 67 | |
| 68 | if ((options[i].flagscxx . . $ option#flags. & GOPT_SEEN_LONG_WITHOUTcxx . . $ `tools/gopt.h:50:9`!) && (options[i].flagscxx . . $ option#flags. & GOPT_ARGUMENT_REQUIREDcxx . . $ `tools/gopt.h:45:9`!)) |
| 69 | { |
| 70 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: option --%s requires an option-argument\n", argv0, options[i].long_namecxx . . $ option#long_name.); |
| 71 | exitcxx . . $ exit(3ca292c338df9bb3). (EX_USAGEcxx . . $ `tools/gopt-errors.c:27:9`!); |
| 72 | } |
| 73 | |
| 74 | if ((options[i].flagscxx . . $ option#flags. & GOPT_SEEN_LONG_WITHcxx . . $ `tools/gopt.h:51:9`!) && (options[i].flagscxx . . $ option#flags. & GOPT_ARGUMENT_FORBIDDENcxx . . $ `tools/gopt.h:44:9`!)) |
| 75 | { |
| 76 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: option --%s must not have an option-argument\n", argv0, options[i].long_namecxx . . $ option#long_name.); |
| 77 | exitcxx . . $ exit(3ca292c338df9bb3). (EX_USAGEcxx . . $ `tools/gopt-errors.c:27:9`!); |
| 78 | } |
| 79 | |
| 80 | if ((options[i].countcxx . . $ option#count. > 1) && !(options[i].flagscxx . . $ option#flags. & GOPT_REPEATABLEcxx . . $ `tools/gopt.h:47:9`!)) |
| 81 | { |
| 82 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: option -%c/--%s may not be repeated\n", argv0, options[i].short_namecxx . . $ option#short_name., options[i].long_namecxx . . $ option#long_name.); |
| 83 | exitcxx . . $ exit(3ca292c338df9bb3). (EX_USAGEcxx . . $ `tools/gopt-errors.c:27:9`!); |
| 84 | } |
| 85 | } |
| 86 | } |