diff options
Diffstat (limited to 'src/tinyradutil/tinyradutil.c')
| -rw-r--r-- | src/tinyradutil/tinyradutil.c | 118 |
1 files changed, 2 insertions, 116 deletions
diff --git a/src/tinyradutil/tinyradutil.c b/src/tinyradutil/tinyradutil.c index b9eac75..b8c7a60 100644 --- a/src/tinyradutil/tinyradutil.c +++ b/src/tinyradutil/tinyradutil.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. |
| 30 | */ | 30 | */ |
| 31 | #define _SRC_TINYRADUTIL_TINYRADUTIL_C 1 | 31 | #define _SRC_TINYRADUTIL_TINYRADUTIL_C 1 |
| 32 | #include "tinyradutil.h" | ||
| 32 | 33 | ||
| 33 | /////////////// | 34 | /////////////// |
| 34 | // // | 35 | // // |
| @@ -62,40 +63,6 @@ | |||
| 62 | /////////////////// | 63 | /////////////////// |
| 63 | #pragma mark - Definitions | 64 | #pragma mark - Definitions |
| 64 | 65 | ||
| 65 | #undef PROGRAM_NAME | ||
| 66 | #define PROGRAM_NAME "tinyrad" | ||
| 67 | |||
| 68 | #define MY_OPT_DICT_DEFAULTS 0x0001UL | ||
| 69 | #define MY_OPT_DICT_DUMP 0x0002UL | ||
| 70 | #define MY_OPT_DICT_LOADED 0x0004UL | ||
| 71 | #define MY_OPT_CONFIG_PRINT 0x0008UL | ||
| 72 | |||
| 73 | |||
| 74 | #define MY_GETOPT_MATCHED -2 | ||
| 75 | #define MY_GETOPT_ERROR -3 | ||
| 76 | #define MY_GETOPT_EXIT -4 | ||
| 77 | |||
| 78 | |||
| 79 | #define TINYRAD_GETOPT_SHORT "d:f:hqVv" | ||
| 80 | #define TINYRAD_GETOPT_LONG \ | ||
| 81 | { "debug", optional_argument, NULL, 'd' }, \ | ||
| 82 | { "help", no_argument, NULL, 'h' }, \ | ||
| 83 | { "quiet", no_argument, NULL, 'q' }, \ | ||
| 84 | { "silent", no_argument, NULL, 'q' }, \ | ||
| 85 | { "version", no_argument, NULL, 'V' }, \ | ||
| 86 | { "verbose", no_argument, NULL, 'v' }, \ | ||
| 87 | { NULL, 0, NULL, 0 } | ||
| 88 | |||
| 89 | |||
| 90 | #define TINYRAD_DICT_GETOPT_SHORT "bD:I:" | ||
| 91 | #define TINYRAD_DICT_GETOPT_LONG \ | ||
| 92 | { "builtin-dict", no_argument, NULL, 'b' }, \ | ||
| 93 | |||
| 94 | |||
| 95 | #define TINYRAD_REQ_GETOPT_SHORT "D:I:" | ||
| 96 | #define TINYRAD_REQ_GETOPT_LONG \ | ||
| 97 | { "file", optional_argument, NULL, 'f' }, \ | ||
| 98 | |||
| 99 | 66 | ||
| 100 | ////////////////// | 67 | ////////////////// |
| 101 | // // | 68 | // // |
| @@ -104,47 +71,6 @@ | |||
| 104 | ////////////////// | 71 | ////////////////// |
| 105 | #pragma mark - Data Types | 72 | #pragma mark - Data Types |
| 106 | 73 | ||
| 107 | typedef struct tinyrad_util_config TinyRadUtilConf; | ||
| 108 | typedef struct tinyrad_util_widget TinyRadUtilWidget; | ||
| 109 | |||
| 110 | |||
| 111 | typedef struct my_request_av | ||
| 112 | { | ||
| 113 | char * attr_name; | ||
| 114 | char * attr_value; | ||
| 115 | } MyRequestAV; | ||
| 116 | |||
| 117 | |||
| 118 | struct tinyrad_util_config | ||
| 119 | { | ||
| 120 | unsigned opts; | ||
| 121 | unsigned tr_opts; | ||
| 122 | int padint; | ||
| 123 | int cmd_argc; | ||
| 124 | char ** cmd_argv; | ||
| 125 | const char * cmd_name; | ||
| 126 | size_t cmd_len; | ||
| 127 | void * padptr; | ||
| 128 | const TinyRadUtilWidget * cmd; | ||
| 129 | TinyRad * tr; | ||
| 130 | const char * url; | ||
| 131 | char ** dict_files; | ||
| 132 | char ** dict_paths; | ||
| 133 | }; | ||
| 134 | |||
| 135 | |||
| 136 | struct tinyrad_util_widget | ||
| 137 | { | ||
| 138 | const char * name; | ||
| 139 | int (*func)(TinyRadUtilConf * cnf); | ||
| 140 | const char * shortopts; | ||
| 141 | struct option * longopts; | ||
| 142 | int min_arg; | ||
| 143 | int max_arg; | ||
| 144 | const char * usage; | ||
| 145 | const char * desc; | ||
| 146 | }; | ||
| 147 | |||
| 148 | 74 | ||
| 149 | ////////////////// | 75 | ////////////////// |
| 150 | // // | 76 | // // |
| @@ -153,46 +79,6 @@ struct tinyrad_util_widget | |||
| 153 | ////////////////// | 79 | ////////////////// |
| 154 | #pragma mark - Prototypes | 80 | #pragma mark - Prototypes |
| 155 | 81 | ||
| 156 | int | ||
| 157 | main( | ||
| 158 | int argc, | ||
| 159 | char * argv[] ); | ||
| 160 | |||
| 161 | |||
| 162 | void | ||
| 163 | tru_cleanup( | ||
| 164 | TinyRadUtilConf * cnf ); | ||
| 165 | |||
| 166 | |||
| 167 | int | ||
| 168 | tru_widget_config( | ||
| 169 | TinyRadUtilConf * cnf ); | ||
| 170 | |||
| 171 | |||
| 172 | int | ||
| 173 | tru_widget_dict( | ||
| 174 | TinyRadUtilConf * cnf ); | ||
| 175 | |||
| 176 | |||
| 177 | int | ||
| 178 | tru_getopt( | ||
| 179 | TinyRadUtilConf * cnf, | ||
| 180 | int argc, | ||
| 181 | char * const * argv, | ||
| 182 | const char * short_opt, | ||
| 183 | const struct option * long_opt, | ||
| 184 | int * opt_index ); | ||
| 185 | |||
| 186 | |||
| 187 | int | ||
| 188 | tru_load_tinyrad( | ||
| 189 | TinyRadUtilConf * cnf ); | ||
| 190 | |||
| 191 | |||
| 192 | int | ||
| 193 | tru_usage( | ||
| 194 | TinyRadUtilConf * cnf ); | ||
| 195 | |||
| 196 | 82 | ||
| 197 | ///////////////// | 83 | ///////////////// |
| 198 | // // | 84 | // // |
| @@ -202,7 +88,7 @@ tru_usage( | |||
| 202 | #pragma mark - Variables | 88 | #pragma mark - Variables |
| 203 | 89 | ||
| 204 | #pragma mark tinyrad_cmdmap[] | 90 | #pragma mark tinyrad_cmdmap[] |
| 205 | static const TinyRadUtilWidget tru_widget_map[] = | 91 | const TinyRadUtilWidget tru_widget_map[] = |
| 206 | { | 92 | { |
| 207 | { | 93 | { |
| 208 | .name = "configuration", | 94 | .name = "configuration", |
