1 /* longopt.h 2 * Copyright (C) 2001-2014, Parrot Foundation. 3 * Overview: 4 * Command line option parsing (for pre-initialized code) 5 */ 6 7 #ifndef PARROT_LONGOPT_H_GUARD 8 #define PARROT_LONGOPT_H_GUARD 9 10 #include "parrot/api.h" 11 12 /* I use a char* here because this needs to be easily statically 13 * initialized, and because the interpreter is probably not running 14 * yet. 15 */ 16 typedef const char* longopt_string_t; 17 18 /* &gen_from_enum(longopt.pasm) subst(s/(\w+)/uc($1)/e) */ 19 typedef enum { 20 OPTION_required_FLAG = 0x1, 21 OPTION_optional_FLAG = 0x2 22 } OPTION_flags; 23 /* &end_gen */ 24 25 struct longopt_opt_decl { 26 int opt_short; 27 int opt_id; 28 OPTION_flags opt_flags; 29 longopt_string_t opt_long[10]; /* An array of long aliases */ 30 }; 31 32 struct longopt_opt_info { 33 int opt_index; /* The index within argv */ 34 int opt_id; /* 0 signifies end of options */ 35 longopt_string_t opt_arg; /* A pointer to any argument's position */ 36 longopt_string_t opt_error; 37 38 const char* _shortopt_pos; 39 }; 40 41 #define LONGOPT_OPT_INFO_INIT { 1, 0, NULL, NULL, NULL } 42 43 #define OPT_GC_DEBUG 128 44 #define OPT_DESTROY_FLAG 129 45 #define OPT_HELP_DEBUG 130 46 #define OPT_PBC_OUTPUT 131 47 #define OPT_RUNTIME_PREFIX 132 48 #define OPT_HASH_SEED 133 49 #define OPT_GC_DYNAMIC_THRESHOLD 134 50 #define OPT_GC_MIN_THRESHOLD 135 51 #define OPT_GC_NURSERY_SIZE 136 52 #define OPT_NUMTHREADS 137 53 54 /* HEADERIZER BEGIN: src/longopt.c */ 55 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 56 57 PARROT_EXPORT 58 int Parrot_longopt_get( 59 int argc, 60 ARGIN(const char* argv[]), 61 ARGIN(const struct longopt_opt_decl options[]), 62 ARGMOD(struct longopt_opt_info* info_buf)) 63 __attribute__nonnull__(2) 64 __attribute__nonnull__(3) 65 __attribute__nonnull__(4) 66 FUNC_MODIFIES(* info_buf); 67 68 #define ASSERT_ARGS_Parrot_longopt_get __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 69 PARROT_ASSERT_ARG(argv) \ 70 , PARROT_ASSERT_ARG(options) \ 71 , PARROT_ASSERT_ARG(info_buf)) 72 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 73 /* HEADERIZER END: src/longopt.c */ 74 75 #endif /* PARROT_LONGOPT_H_GUARD */ 76 77 /* 78 * Local variables: 79 * c-file-style: "parrot" 80 * End: 81 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' : 82 */ 83