Option: merge function to supported AIORI module reuse.
parent
4258e14c11
commit
5e465ac8bf
17
src/option.c
17
src/option.c
|
@ -7,6 +7,23 @@
|
|||
|
||||
#include <option.h>
|
||||
|
||||
|
||||
/* merge two option lists and return the total size */
|
||||
option_help * option_merge(option_help * a, option_help * b){
|
||||
int count_a = 0;
|
||||
for(option_help * i = a; i->type != 0; i++){
|
||||
count_a++;
|
||||
}
|
||||
int count = count_a + 1; // LAST_OPTION is one
|
||||
for(option_help * i = b; i->type != 0; i++){
|
||||
count++;
|
||||
}
|
||||
option_help * h = malloc(sizeof(option_help) * count);
|
||||
memcpy(h, a, sizeof(option_help) * count_a);
|
||||
memcpy(h + count_a, b, sizeof(option_help) * (count - count_a));
|
||||
return h;
|
||||
}
|
||||
|
||||
/*
|
||||
* Takes a string of the form 64, 8m, 128k, 4g, etc. and converts to bytes.
|
||||
*/
|
||||
|
|
|
@ -43,6 +43,7 @@ void option_print_current(option_help * args);
|
|||
//@return the number of parsed arguments
|
||||
int option_parse(int argc, char ** argv, options_all_t * args);
|
||||
int option_parse_str(char*val, options_all_t * opt_all);
|
||||
option_help * option_merge(option_help * a, option_help * b);
|
||||
|
||||
/* Parse a single line */
|
||||
int option_parse_key_value(char * key, char * value, options_all_t * opt_all);
|
||||
|
|
Loading…
Reference in New Issue