diff options
Diffstat (limited to 'extlibs')
-rw-r--r-- | extlibs/arg.c | 10 | ||||
-rw-r--r-- | extlibs/arg.h | 103 |
2 files changed, 72 insertions, 41 deletions
diff --git a/extlibs/arg.c b/extlibs/arg.c index 3d4475b..7a34641 100644 --- a/extlibs/arg.c +++ b/extlibs/arg.c @@ -203,9 +203,11 @@ arg_t* arg_load( int argc, char **argv, def_arg *argl ) { ENL(); } + argl[pos].used = 1; + ((s_arg_list *)argl[pos].def)->result = list; used[i] = 1; used[i+1] = 1; @@ -236,12 +238,12 @@ arg_t* arg_load( int argc, char **argv, def_arg *argl ) //if (((s_arg_val*)argl[pos].def)->ptr != NULL) // val->def = 0; - //val->used = 1; val->ptr = argv[i+1]; __add_arg( ret, ARGT_VAL, val ); //set that requied option allready where at cmd argl[pos].used = 1; + ((s_arg_val *)argl[pos].def)->result = val; //set used cmd arg used[i ] = 1; @@ -266,13 +268,17 @@ arg_t* arg_load( int argc, char **argv, def_arg *argl ) flg = __create_arg( argl[pos].type, argl[pos].def ); - //flg->used = 1; flg->flag = 1; __add_arg( ret, ARGT_FLAG, flg ); + argl[pos].used = 1; + ((s_arg_flag *)argl[pos].def)->result = flg; + + printf("result = ?\n"); + used[i] = 1; break; diff --git a/extlibs/arg.h b/extlibs/arg.h index 18105dc..98c4681 100644 --- a/extlibs/arg.h +++ b/extlibs/arg.h @@ -27,6 +27,7 @@ typedef struct def_arg void *def; //define default values, NULL if no default values uint8_t used; char *help; //command description + void *result; //result } def_arg; typedef struct argv_t @@ -38,11 +39,20 @@ typedef struct argv_t typedef struct arg_t { + int used; int size; //number of arguments argv_t **arg; //list of pointers to arguments } arg_t; //ip argument default behaviour structure + +//resulting structure with ip/port values +typedef struct arg_ip +{ + int used; + uint32_t ip; //IP4 ip addrers + uint16_t port;//port number +} arg_ip; /* Supported ip addresses: ...1 = 127.0.0.1:[default port] @@ -56,16 +66,20 @@ typedef struct s_arg_ip uint32_t default_ip; uint16_t port; uint32_t default_port; + arg_ip *result; } s_arg_ip; -//resulting structure with ip/port values -typedef struct arg_ip -{ - uint32_t ip; //IP4 ip addrers - uint16_t port;//port number -} arg_ip; + //configure range argument behaviour +//configuration structure for range argument +typedef struct arg_range +{ + int used; + uint32_t start; + uint32_t end; + uint32_t step; +} arg_range; /* number format decimal ones 1k = 1000 @@ -86,38 +100,42 @@ typedef struct s_arg_range uint32_t default_end; //default end value uint32_t step; // uint32_t default_step; //default step value + arg_range *result; } s_arg_range; -//configuration structure for range argument -typedef struct arg_range -{ - uint32_t start; - uint32_t end; - uint32_t step; -} arg_range; + //configuration structure for float argument +typedef struct arg_float +{ + int used; + float val; +} arg_float; + typedef struct s_arg_float { int used; int def; //says if default should be used if no value in cmd float val; float default_val; + arg_float *result; } s_arg_float; -typedef struct arg_float -{ - float val; -} arg_float; + //configuration structure for list argument +typedef struct arg_list +{ + int used; + uint32_t num; + char **vals; +} arg_list; /* list arguments by name supports PARAM1|PARAM2|PARAM3 */ - typedef struct s_arg_list { int used; @@ -125,17 +143,24 @@ typedef struct s_arg_list uint32_t num; char **vals; //list of supported arguments char *default_val; //points to default arguments in da list + arg_list *result; } s_arg_list; -typedef struct arg_list -{ - uint32_t num; - char **vals; -} arg_list; + /* configuration structure to default file argument */ +/* +resulting structure for file argument +*/ +typedef struct arg_file +{ + int used; + char *name; + char *abspath; +} arg_file; + typedef struct s_arg_file { int used; @@ -144,42 +169,42 @@ typedef struct s_arg_file char *default_name; //default filename char *abspath; //dire where to search stuff? char *default_abspath; //default absoulute file path + arg_file *result; } s_arg_file; -/* -resulting structure for file argument -*/ -typedef struct arg_file -{ - char *name; - char *abspath; -} arg_file; +typedef struct arg_val +{ + int used; + char *ptr; +} arg_val; + typedef struct s_arg_val { int used; int def; //says if default should be used if no value in cmd char *ptr; char *default_ptr; + arg_val *result; } s_arg_val; -typedef struct arg_val + +//no need as there is no default values +typedef struct arg_flag { - char *ptr; -} arg_val; + int used; + int flag; +} arg_flag; typedef struct s_arg_flag { int used; int flag; + arg_flag *result; } s_arg_flag; -//no need as there is no default values -typedef struct arg_flag -{ - int flag; -} arg_flag; + arg_t* arg_load( int argc, char **argv, def_arg *argl ); void arg_free( arg_t *arg ); |