Dispatcher test additions
This commit is contained in:
parent
d2d3454177
commit
93d1149925
7 changed files with 72 additions and 16 deletions
|
|
@ -1,5 +1,36 @@
|
|||
/*
|
||||
* Copyright 2021 Rubicon Communications LLC (Netgate)
|
||||
*
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
|
||||
Copyright (C) 2021 Rubicon Communications, LLC(Netgate)
|
||||
|
||||
This file is part of CLIXON.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
the GNU General Public License Version 3 or later (the "GPL"),
|
||||
in which case the provisions of the GPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of the GPL, and not to allow others to
|
||||
use your version of this file under the terms of Apache License version 2,
|
||||
indicate your decision by deleting the provisions above and replace them with
|
||||
the notice and other provisions required by the GPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the Apache License version 2 or the GPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
* @see https://github.com/dcornejo/dispatcher
|
||||
*/
|
||||
|
||||
|
|
@ -285,11 +316,8 @@ get_entry(dispatcher_entry_t *root,
|
|||
|
||||
/* some elements may have keys defined, strip them off */
|
||||
for (int i = 0; i < split_path_len; i++) {
|
||||
char *kptr = strchr(split_path_list[i], '=');
|
||||
|
||||
if ((kptr != NULL) && (*kptr == '=')) {
|
||||
*(kptr + 1) = 0;
|
||||
}
|
||||
char *kptr = split_path_list[i];
|
||||
strsep(&kptr, "=[]");
|
||||
}
|
||||
|
||||
/* search down the tree */
|
||||
|
|
@ -423,8 +451,12 @@ dispatcher_call_handlers(dispatcher_entry_t *root,
|
|||
void *user_args)
|
||||
{
|
||||
int ret = 0;
|
||||
dispatcher_entry_t *best = get_entry(root, path);
|
||||
dispatcher_entry_t *best;
|
||||
|
||||
if ((best = get_entry(root, path)) == NULL){
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
if (best->children != NULL) {
|
||||
call_handler_helper(best->children, handle, path, user_args);
|
||||
}
|
||||
|
|
@ -450,3 +482,24 @@ dispatcher_free(dispatcher_entry_t *root)
|
|||
free(root);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! Pretty-print dispatcher tree
|
||||
*/
|
||||
#define INDENT 3
|
||||
int
|
||||
dispatcher_print(FILE *f,
|
||||
int level,
|
||||
dispatcher_entry_t *de)
|
||||
{
|
||||
fprintf(f, "%*s%s", level*INDENT, "", de->node_name);
|
||||
if (de->handler)
|
||||
fprintf(f, " %p", de->handler);
|
||||
if (de->arg)
|
||||
fprintf(f, " (%p)", de->arg);
|
||||
fprintf(f, "\n");
|
||||
if (de->children)
|
||||
dispatcher_print(f, level+1, de->children);
|
||||
if (de->peer)
|
||||
dispatcher_print(f, level, de->peer);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3585,7 +3585,7 @@ yang_extension_value(yang_stmt *ys,
|
|||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
yext = NULL; /* This loop gets complicated in trhe case the extension is augmented */
|
||||
yext = NULL; /* This loop gets complicated in the case the extension is augmented */
|
||||
while ((yext = yn_each(ys, yext)) != NULL) {
|
||||
if (yang_keyword_get(yext) != Y_UNKNOWN)
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue