@@ -99,12 +99,13 @@ int umfCtlExec(const char *name, void *ctx, void *arg) {
9999 * ctl_find_node -- (internal) searches for a matching entry point in the
100100 * provided nodes
101101 *
102+ * Name offset is used to return the offset of the name in the query string.
102103 * The caller is responsible for freeing all of the allocated indexes,
103104 * regardless of the return value.
104105 */
105106static const struct ctl_node * ctl_find_node (const struct ctl_node * nodes ,
106107 const char * name ,
107- struct ctl_index_utlist * indexes ) {
108+ struct ctl_index_utlist * indexes , int * name_offset ) {
108109 const struct ctl_node * n = NULL ;
109110 char * sptr = NULL ;
110111 char * parse_str = Strdup (name );
@@ -119,6 +120,7 @@ static const struct ctl_node *ctl_find_node(const struct ctl_node *nodes,
119120 * in the main ctl tree.
120121 */
121122 while (node_name != NULL ) {
123+ * name_offset = node_name - parse_str ;
122124 if (n != NULL && n -> type == CTL_NODE_SUBTREE ) {
123125 break ;
124126 }
@@ -362,13 +364,14 @@ int ctl_query(struct ctl *ctl, void *ctx, enum ctl_query_source source,
362364 }
363365
364366 int ret = -1 ;
367+ int name_offset = 0 ;
365368
366- const struct ctl_node * n = ctl_find_node (CTL_NODE (global ), name , indexes );
369+ const struct ctl_node * n = ctl_find_node (CTL_NODE (global ), name , indexes , & name_offset );
367370
368371 if (n == NULL && ctl ) {
369372 ctl_delete_indexes (indexes );
370373 indexes = NULL ;
371- n = ctl_find_node (ctl -> root , name , indexes );
374+ n = ctl_find_node (ctl -> root , name , indexes , & name_offset );
372375 }
373376
374377 if (n == NULL ||
0 commit comments