Exemplo n.º 1
0
int
parse_arg_byte_stream(char *name, int max_len, uint8_t *dst, int *out_len)
{
    char *sval;

    sval = parse_arg_find(name);
    if (sval == NULL) {
        return ENOENT;
    }

    return parse_arg_byte_stream_delim(sval, ":-", max_len, dst, out_len);
}
Exemplo n.º 2
0
int
parse_arg_kv(char *name, struct kv_pair *kvs)
{
    struct kv_pair *kv;
    char *sval;

    sval = parse_arg_find(name);
    if (sval == NULL) {
        return ENOENT;
    }

    kv = parse_kv_find(kvs, sval);
    if (kv == NULL) {
        return EINVAL;
    }

    return kv->val;
}
Exemplo n.º 3
0
uint64_t
parse_arg_uint64_bounds(char *name, uint64_t min, uint64_t max, int *out_status)
{
    char *endptr;
    char *sval;
    uint64_t lval;

    sval = parse_arg_find(name);
    if (sval == NULL) {
        *out_status = ENOENT;
        return 0;
    }

    lval = strtoull(sval, &endptr, parse_arg_long_base(sval));
    if (sval[0] != '\0' && *endptr == '\0' &&
        lval >= min && lval <= max) {

        *out_status = 0;
        return lval;
    }

    *out_status = EINVAL;
    return 0;
}
Exemplo n.º 4
0
long
parse_arg_long_bounds(char *name, long min, long max, int *out_status)
{
    char *endptr;
    char *sval;
    long lval;

    sval = parse_arg_find(name);
    if (sval == NULL) {
        *out_status = ENOENT;
        return 0;
    }

    lval = strtol(sval, &endptr, 0);
    if (sval[0] != '\0' && *endptr == '\0' &&
        lval >= min && lval <= max) {

        *out_status = 0;
        return lval;
    }

    *out_status = EINVAL;
    return 0;
}