Basic C library to easily parse arguments
Go to file
2023-05-11 21:40:12 +01:00
.github/workflows Create c.yml 2023-05-11 21:40:12 +01:00
.gitignore better stress 2023-05-11 21:37:32 +01:00
carg-parse.c remove unused headers 2023-05-11 20:56:37 +01:00
carg-parse.h remove unused headers 2023-05-11 20:56:37 +01:00
LICENSE Initial commit 2023-05-11 11:33:09 +01:00
makefile Update makefile 2023-05-11 21:38:27 +01:00
README.md highlighting 2023-05-11 20:50:16 +01:00
stress.sh better stress 2023-05-11 21:37:32 +01:00
test.c updated label 2023-05-11 21:28:11 +01:00

carg-parse

Basic C library to easily parse arguments

Usage

for a full example of usage look at test.c

Call carg_parse(int argc, char** argv) it will return a struct containing:

typedef struct 
{
    char* exec_name;

    uint32_t values_len;
    char** values;

    uint32_t lv_len;
    char** lv_labels;
    char** lv_values;
} carg_parse_data;

Values is an array of all of the free standing arguments passed in

LV is a dictionary, labels in lv_labels and values in lv_values, it contains any labeled arguments '-a b', if a value is not provided lv_value will point to NULL

values and lv_values both point to argv, and lv_labels points to argv + 1, as to ignore the dash('-')

when done with the data, call carg_parse_free(carg_parse_data* data) to free the data