cmd: implement b_arglist_get_* functions
This commit is contained in:
@@ -757,6 +757,60 @@ void b_arglist_destroy(struct b_arglist *args)
|
||||
free(args);
|
||||
}
|
||||
|
||||
b_status b_arglist_get_string(
|
||||
const b_arglist *args, unsigned int opt_id, unsigned int arg_id,
|
||||
unsigned int index, const char **out)
|
||||
{
|
||||
b_arglist_iterator it = {0};
|
||||
b_arglist_iterator_begin(args, opt_id, arg_id, &it);
|
||||
while (b_arglist_iterator_is_valid(&it)) {
|
||||
if (it.value && it.value->val_str) {
|
||||
*out = it.value->val_str;
|
||||
return B_SUCCESS;
|
||||
}
|
||||
|
||||
b_arglist_iterator_next(&it);
|
||||
}
|
||||
|
||||
return B_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
b_status b_arglist_get_int(
|
||||
const b_arglist *args, unsigned int opt_id, unsigned int arg_id,
|
||||
unsigned int index, long long *out)
|
||||
{
|
||||
b_arglist_iterator it = {0};
|
||||
b_arglist_iterator_begin(args, opt_id, arg_id, &it);
|
||||
while (b_arglist_iterator_is_valid(&it)) {
|
||||
if (it.value) {
|
||||
*out = it.value->val_int;
|
||||
return B_SUCCESS;
|
||||
}
|
||||
|
||||
b_arglist_iterator_next(&it);
|
||||
}
|
||||
|
||||
return B_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
b_status b_arglist_get_uint(
|
||||
const b_arglist *args, unsigned int opt_id, unsigned int arg_id,
|
||||
unsigned int index, unsigned long long *out)
|
||||
{
|
||||
b_arglist_iterator it = {0};
|
||||
b_arglist_iterator_begin(args, opt_id, arg_id, &it);
|
||||
while (b_arglist_iterator_is_valid(&it)) {
|
||||
if (it.value && it.value->val_uint) {
|
||||
*out = it.value->val_uint;
|
||||
return B_SUCCESS;
|
||||
}
|
||||
|
||||
b_arglist_iterator_next(&it);
|
||||
}
|
||||
|
||||
return B_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
size_t b_arglist_get_count(
|
||||
const b_arglist *args, unsigned int opt_id, unsigned int arg_id)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user