Skip to content

Commit ec00077

Browse files
committed
rename name to path in ctl
1 parent 2494032 commit ec00077

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

include/umf/experimental/ctl.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,34 @@ extern "C" {
1717
#endif
1818

1919
///
20-
/// @brief Get value of a specified attribute at the given name.
21-
/// @param name name of an attribute to be retrieved
20+
/// @brief Get value of a specified attribute at the given path.
21+
/// @param path path of an attribute to be retrieved
2222
/// @param arg [out] pointer to the variable where the value will be stored
2323
/// @param size size of the value, depends on the context
2424
/// @param ... additional arguments that can be passed to the callback
2525
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
2626
///
27-
umf_result_t umfCtlGet(const char *name, void *arg, size_t size, ...);
27+
umf_result_t umfCtlGet(const char *path, void *arg, size_t size, ...);
2828

2929
///
30-
/// @brief Set value of a specified attribute at the given name.
31-
/// @param name name of an attribute to be set
30+
/// @brief Set value of a specified attribute at the given path.
31+
/// @param path path of an attribute to be set
3232
/// @param arg [in] pointer to the value that will be set
3333
/// @param size [in] size of the value, depends on the context
3434
/// @param ... additional arguments that can be passed to the callback
3535
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
3636
///
37-
umf_result_t umfCtlSet(const char *name, void *arg, size_t size, ...);
37+
umf_result_t umfCtlSet(const char *path, void *arg, size_t size, ...);
3838

3939
///
4040
/// @brief Execute callback related with the specified attribute.
41-
/// @param name name of an attribute to be executed
41+
/// @param path path of an attribute to be executed
4242
/// @param arg [in/out] pointer to the value, can be used as an input or output
4343
/// @param size [in] size of the value, depends on the context
4444
/// @param ... additional arguments that can be passed to the callback
4545
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
4646
///
47-
umf_result_t umfCtlExec(const char *name, void *arg, size_t size, ...);
47+
umf_result_t umfCtlExec(const char *path, void *arg, size_t size, ...);
4848

4949
#ifdef __cplusplus
5050
}

src/ctl/ctl.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -298,26 +298,26 @@ ctl_exec_query_subtree(void *ctx, const umf_ctl_node_t *n,
298298
* ctl_find_and_execulte_node -- (internal) searches for a matching entry point in the
299299
* provided nodes
300300
*
301-
* Name offset is used to return the offset of the name in the query string.
301+
* Path offset is used to return the offset of the path in the query string.
302302
* The caller is responsible for freeing all of the allocated indexes,
303303
* regardless of the return value.
304304
*/
305305

306306
static optional_umf_result_t
307307
ctl_find_and_execute_node(const umf_ctl_node_t *nodes, void *ctx,
308-
umf_ctl_query_source_t source, const char *name,
308+
umf_ctl_query_source_t source, const char *path,
309309
umf_ctl_query_type_t type, void *arg, size_t size,
310310
va_list args) {
311311
assert(nodes != NULL);
312-
assert(name != NULL);
312+
assert(path != NULL);
313313

314314
const umf_ctl_node_t *n = NULL;
315315
optional_umf_result_t ret;
316-
size_t name_offset = 0;
316+
size_t path_offset = 0;
317317
ret.is_valid = true;
318318
ret.value = UMF_RESULT_SUCCESS;
319319
char *sptr = NULL;
320-
char *parse_str = Strdup(name);
320+
char *parse_str = Strdup(path);
321321
if (parse_str == NULL) {
322322
ret.is_valid = false;
323323
return ret;
@@ -336,7 +336,7 @@ ctl_find_and_execute_node(const umf_ctl_node_t *nodes, void *ctx,
336336
*/
337337
while (node_name != NULL) {
338338
char *next_node = strtok_r(NULL, CTL_QUERY_NODE_SEPARATOR, &sptr);
339-
name_offset = node_name - parse_str;
339+
path_offset = node_name - parse_str;
340340
if (n != NULL && n->type == CTL_NODE_SUBTREE) {
341341
// if a subtree occurs, the subtree handler should be called
342342
break;
@@ -500,7 +500,7 @@ ctl_find_and_execute_node(const umf_ctl_node_t *nodes, void *ctx,
500500
// if the node is a subtree, then we need to call the subtree handler
501501
ret.value =
502502
ctl_exec_query_subtree(ctx, n, source, arg, size, indexes->next,
503-
name + name_offset, type, args);
503+
path + path_offset, type, args);
504504
} else {
505505
switch (type) {
506506
case CTL_QUERY_READ:
@@ -530,25 +530,25 @@ ctl_find_and_execute_node(const umf_ctl_node_t *nodes, void *ctx,
530530
}
531531

532532
/*
533-
* ctl_query -- (internal) parses the name and calls the appropriate methods
533+
* ctl_query -- (internal) parses the path and calls the appropriate methods
534534
* from the ctl tree
535535
*/
536536
umf_result_t ctl_query(struct ctl *ctl, void *ctx,
537-
umf_ctl_query_source_t source, const char *name,
537+
umf_ctl_query_source_t source, const char *path,
538538
umf_ctl_query_type_t type, void *arg, size_t size,
539539
va_list args) {
540-
if (name == NULL) {
540+
if (path == NULL) {
541541
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
542542
}
543543

544544
va_list args_copy;
545545
va_copy(args_copy, args);
546546

547547
optional_umf_result_t ret = ctl_find_and_execute_node(
548-
CTL_NODE(global), ctx, source, name, type, arg, size, args_copy);
548+
CTL_NODE(global), ctx, source, path, type, arg, size, args_copy);
549549

550550
if (ret.is_valid == false && ctl) {
551-
ret = ctl_find_and_execute_node(ctl->root, ctx, source, name, type, arg,
551+
ret = ctl_find_and_execute_node(ctl->root, ctx, source, path, type, arg,
552552
size, args);
553553
}
554554

@@ -573,16 +573,16 @@ void ctl_register_module_node(struct ctl *c, const char *name,
573573

574574
/*
575575
* ctl_parse_query -- (internal) splits an entire query string
576-
* into name and value
576+
* into path and value
577577
*/
578-
static int ctl_parse_query(char *qbuf, char **name, char **value) {
578+
static int ctl_parse_query(char *qbuf, char **path, char **value) {
579579
if (qbuf == NULL) {
580580
return -1;
581581
}
582582

583583
char *sptr = NULL;
584-
*name = strtok_r(qbuf, CTL_NAME_VALUE_SEPARATOR, &sptr);
585-
if (*name == NULL) {
584+
*path = strtok_r(qbuf, CTL_NAME_VALUE_SEPARATOR, &sptr);
585+
if (*path == NULL) {
586586
return -1;
587587
}
588588

@@ -608,20 +608,20 @@ static umf_result_t ctl_load_config_helper(struct ctl *ctl, void *ctx,
608608
char *buf, ...) {
609609
umf_result_t ret = UMF_RESULT_SUCCESS;
610610
char *sptr = NULL; /* for internal use of strtok */
611-
char *name;
611+
char *path;
612612
char *value;
613613
char *qbuf = strtok_r(buf, CTL_STRING_QUERY_SEPARATOR, &sptr);
614614
va_list empty_args;
615615
va_start(empty_args, buf);
616616
while (qbuf != NULL) {
617-
int parse_res = ctl_parse_query(qbuf, &name, &value);
617+
int parse_res = ctl_parse_query(qbuf, &path, &value);
618618
if (parse_res != 0) {
619619
ret = UMF_RESULT_ERROR_INVALID_ARGUMENT;
620620
goto end;
621621
}
622622
// we do not need to copy va_list before call as we know that for query_config_input
623623
// ctl_query will not call va_arg on it. Ref 7.15/3 of C99 standard
624-
ret = ctl_query(ctl, ctx, CTL_QUERY_CONFIG_INPUT, name, CTL_QUERY_WRITE,
624+
ret = ctl_query(ctl, ctx, CTL_QUERY_CONFIG_INPUT, path, CTL_QUERY_WRITE,
625625
value, strlen(value) + 1, empty_args);
626626

627627
if (ret != UMF_RESULT_SUCCESS && ctx != NULL) {

src/ctl/ctl_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ int ctl_arg_string(const void *arg, void *dest, size_t dest_size);
198198
#define CTL_NODE(name, ...) ctl_node_##__VA_ARGS__##_##name
199199

200200
umf_result_t ctl_query(struct ctl *ctl, void *ctx,
201-
umf_ctl_query_source_t source, const char *name,
201+
umf_ctl_query_source_t source, const char *path,
202202
umf_ctl_query_type_t type, void *arg, size_t size,
203203
va_list args);
204204

src/libumf.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,41 +157,41 @@ umf_result_t umfTearDown(void) {
157157

158158
int umfGetCurrentVersion(void) { return UMF_VERSION_CURRENT; }
159159

160-
umf_result_t umfCtlGet(const char *name, void *arg, size_t size, ...) {
160+
umf_result_t umfCtlGet(const char *path, void *arg, size_t size, ...) {
161161
libumfInit();
162162
// ctx can be NULL when getting defaults
163-
if (name == NULL || arg == NULL || size == 0) {
163+
if (path == NULL || arg == NULL || size == 0) {
164164
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
165165
}
166166
va_list args;
167167
va_start(args, size);
168168

169-
umf_result_t ret = ctl_query(NULL, NULL, CTL_QUERY_PROGRAMMATIC, name,
169+
umf_result_t ret = ctl_query(NULL, NULL, CTL_QUERY_PROGRAMMATIC, path,
170170
CTL_QUERY_READ, arg, size, args);
171171
va_end(args);
172172
return ret;
173173
}
174174

175-
umf_result_t umfCtlSet(const char *name, void *arg, size_t size, ...) {
175+
umf_result_t umfCtlSet(const char *path, void *arg, size_t size, ...) {
176176
libumfInit();
177177
// ctx can be NULL when setting defaults
178-
if (name == NULL || arg == NULL || size == 0) {
178+
if (path == NULL || arg == NULL || size == 0) {
179179
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
180180
}
181181
va_list args;
182182
va_start(args, size);
183-
umf_result_t ret = ctl_query(NULL, NULL, CTL_QUERY_PROGRAMMATIC, name,
183+
umf_result_t ret = ctl_query(NULL, NULL, CTL_QUERY_PROGRAMMATIC, path,
184184
CTL_QUERY_WRITE, arg, size, args);
185185
va_end(args);
186186
return ret;
187187
}
188188

189-
umf_result_t umfCtlExec(const char *name, void *arg, size_t size, ...) {
189+
umf_result_t umfCtlExec(const char *path, void *arg, size_t size, ...) {
190190
libumfInit();
191191
// arg can be NULL when executing a command
192192
// ctx can be NULL when executing defaults
193193
// size can depends on the arg
194-
if (name == NULL) {
194+
if (path == NULL) {
195195
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
196196
}
197197

@@ -201,7 +201,7 @@ umf_result_t umfCtlExec(const char *name, void *arg, size_t size, ...) {
201201
va_list args;
202202
va_start(args, size);
203203

204-
umf_result_t ret = ctl_query(NULL, NULL, CTL_QUERY_PROGRAMMATIC, name,
204+
umf_result_t ret = ctl_query(NULL, NULL, CTL_QUERY_PROGRAMMATIC, path,
205205
CTL_QUERY_RUNNABLE, arg, size, args);
206206
va_end(args);
207207
return ret;

0 commit comments

Comments
 (0)