|
@@ -152,16 +152,16 @@ void print_usage ( struct command_descriptor *cmd, char **argv ) {
|
152
|
152
|
}
|
153
|
153
|
|
154
|
154
|
/**
|
155
|
|
- * Parse command-line options
|
|
155
|
+ * Reparse command-line options
|
156
|
156
|
*
|
157
|
157
|
* @v argc Argument count
|
158
|
158
|
* @v argv Argument list
|
159
|
159
|
* @v cmd Command descriptor
|
160
|
|
- * @v opts Options
|
|
160
|
+ * @v opts Options (already initialised with default values)
|
161
|
161
|
* @ret rc Return status code
|
162
|
162
|
*/
|
163
|
|
-int parse_options ( int argc, char **argv, struct command_descriptor *cmd,
|
164
|
|
- void *opts ) {
|
|
163
|
+int reparse_options ( int argc, char **argv, struct command_descriptor *cmd,
|
|
164
|
+ void *opts ) {
|
165
|
165
|
struct option longopts[ cmd->num_options + 1 /* help */ + 1 /* end */ ];
|
166
|
166
|
char shortopts[ cmd->num_options * 3 /* possible "::" */ + 1 /* "h" */
|
167
|
167
|
+ 1 /* NUL */ ];
|
|
@@ -193,9 +193,6 @@ int parse_options ( int argc, char **argv, struct command_descriptor *cmd,
|
193
|
193
|
DBGC ( cmd, "Command \"%s\" has options \"%s\", %d-%d args, len %d\n",
|
194
|
194
|
argv[0], shortopts, cmd->min_args, cmd->max_args, cmd->len );
|
195
|
195
|
|
196
|
|
- /* Clear options */
|
197
|
|
- memset ( opts, 0, cmd->len );
|
198
|
|
-
|
199
|
196
|
/* Parse options */
|
200
|
197
|
while ( ( c = getopt_long ( argc, argv, shortopts, longopts,
|
201
|
198
|
NULL ) ) >= 0 ) {
|
|
@@ -233,3 +230,21 @@ int parse_options ( int argc, char **argv, struct command_descriptor *cmd,
|
233
|
230
|
|
234
|
231
|
return 0;
|
235
|
232
|
}
|
|
233
|
+
|
|
234
|
+/**
|
|
235
|
+ * Parse command-line options
|
|
236
|
+ *
|
|
237
|
+ * @v argc Argument count
|
|
238
|
+ * @v argv Argument list
|
|
239
|
+ * @v cmd Command descriptor
|
|
240
|
+ * @v opts Options (may be uninitialised)
|
|
241
|
+ * @ret rc Return status code
|
|
242
|
+ */
|
|
243
|
+int parse_options ( int argc, char **argv, struct command_descriptor *cmd,
|
|
244
|
+ void *opts ) {
|
|
245
|
+
|
|
246
|
+ /* Clear options */
|
|
247
|
+ memset ( opts, 0, cmd->len );
|
|
248
|
+
|
|
249
|
+ return reparse_options ( argc, argv, cmd, opts );
|
|
250
|
+}
|