yumapro  25.10-1
YumaPro SDK
Loading...
Searching...
No Matches
cli.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3 * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4 *
5 * Unless required by applicable law or agreed to in writing,
6 * software distributed under the License is distributed on an
7 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 * KIND, either express or implied. See the License for the
9 * specific language governing permissions and limitations
10 * under the License.
11 */
12#ifndef _H_cli
13#define _H_cli
14
15/* FILE: cli.h
16*********************************************************************
17* *
18* P U R P O S E *
19* *
20*********************************************************************/
21
28/*********************************************************************
29* *
30* C H A N G E H I S T O R Y *
31* *
32*********************************************************************
33
34date init comment
35----------------------------------------------------------------------
3621-oct-05 abb Begun
3709-feb-06 abb Change from xmlTextReader to rpc_agt callback
38 API format
3910-feb-07 abb Split out common functions from agt_ps_parse.h
4029-jul-08 abb change to cli.h; remove all by CLI parsing;
41 conversion from NCX parmset to YANG object
4207-feb-09 abb Add cli_rawparm_t and cli_parse_raw
43 for bootstrap CLI support
44
45*/
46
47#include <xmlstring.h>
48
49#ifndef _H_dlq
50#include "dlq.h"
51#endif
52
53#ifndef _H_ncxtypes
54#include "ncxtypes.h"
55#endif
56
57#ifndef _H_obj
58#include "obj.h"
59#endif
60
61#ifndef _H_runstack
62#include "runstack.h"
63#endif
64
65#ifndef _H_status
66#include "status.h"
67#endif
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73/********************************************************************
74* *
75* C O N S T A N T S *
76* *
77*********************************************************************/
78
79/* value only of full test values for the valonly parameter */
80#define VALONLY TRUE
81#define FULLTEST FALSE
82
83
84/* plain or script values for the climode parameter */
85#define SCRIPTMODE TRUE
86#define PLAINMODE FALSE
87
88/********************************************************************
89* *
90* T Y P E S *
91* *
92*********************************************************************/
93
94/* Heading only */
95
121typedef enum cli_mode_t_ {
126
127
128
130typedef struct cli_rawparm_t_ {
131 dlq_hdr_t qhdr;
132 const char *name;
133 char *value;
134 boolean hasvalue;
135 boolean xsdlist;
137 int32 count;
139
140
151typedef val_value_t *
152 (*cli_xml_buffer_fn_t) (const xmlChar *xmlbuff,
153 obj_template_t *targetobj,
154 status_t *res);
155
156
157
168typedef status_t
170 val_value_t *val);
171
172
173
174
180typedef struct cli_inline_parms_t_ {
186
192 boolean valonly;
193
198 boolean script;
199
206 boolean autocomp;
207
212 boolean rawxml;
213
222
231
234
237
239
240
241
242/********************************************************************
243* *
244* F U N C T I O N S *
245* *
246*********************************************************************/
247
256extern cli_rawparm_t *
257 cli_new_rawparm (const xmlChar *name, boolean xsdlist);
258
259
266extern cli_rawparm_t *
267 cli_new_empty_rawparm (const xmlChar *name);
268
269
275extern void
277
278
284extern void
285 cli_clean_rawparmQ (dlq_hdr_t *parmQ);
286
287
295extern cli_rawparm_t *
296 cli_find_rawparm (const xmlChar *name,
297 dlq_hdr_t *parmQ);
298
299
352extern status_t
353 cli_parse_raw (int argc,
354 char *argv[],
355 dlq_hdr_t *rawparmQ);
356
357
445extern val_value_t *
447 int argc,
448 char *argv[],
449 obj_template_t *obj,
450 boolean valonly,
451 boolean script,
452 boolean autocomp,
453 cli_mode_t mode,
454 status_t *status);
455
456
457
498extern val_value_t *
500 int argc,
501 char *argv[],
502 obj_template_t *obj,
503 boolean valonly,
504 boolean script,
505 boolean autocomp,
506 boolean rawxml,
507 cli_mode_t mode,
508 status_t *status,
511
512
513
536extern val_value_t *
538 int argc,
539 char *argv[],
540 cli_inline_parms_t *parms,
541 status_t *status);
542
543
544
545
565extern status_t
567 val_value_t *val,
568 obj_template_t *obj,
569 const xmlChar *strval,
570 boolean script);
571
572
594extern status_t
596 val_value_t *val,
597 obj_template_t *obj,
598 const xmlChar *strval,
599 boolean script,
600 val_value_t **retval);
601
602
624extern status_t
626 val_value_t *val,
627 obj_template_t *obj,
628 const xmlChar *strval,
629 boolean script,
630 val_value_t **retval);
631
632
654extern status_t
656 val_value_t *val,
657 obj_template_t *obj,
658 const xmlChar *strval,
659 boolean script,
660 ncx_bad_data_t bad_data);
661
664#ifdef __cplusplus
665} /* end extern 'C' */
666#endif
667
668#endif /* _H_cli */
dlq provides general double-linked list and queue support:
status_t
global error return code
Definition: status_enum.h:219
status_t(* cli_var_replace_fn_t)(runstack_context_t *rcxt, val_value_t *val)
Check a val_value_t for variable usage to be replaced by the variable value.
Definition: cli.h:169
cli_rawparm_t * cli_new_empty_rawparm(const xmlChar *name)
Malloc and init a raw parm entry that has no value (NCX_BT_EMPTY)
Definition: cli.c:1422
val_value_t * cli_parse_inline(runstack_context_t *rcxt, int argc, char *argv[], obj_template_t *obj, boolean valonly, boolean script, boolean autocomp, boolean rawxml, cli_mode_t mode, status_t *status, cli_xml_buffer_fn_t cbfn, cli_var_replace_fn_t cbfn2)
schema based CLI support
Definition: cli.c:1931
void cli_clean_rawparmQ(dlq_hdr_t *parmQ)
Clean and free a Q of raw parm entries.
Definition: cli.c:1479
void cli_free_rawparm(cli_rawparm_t *parm)
Clean and free a raw parm entry.
Definition: cli.c:1451
status_t cli_parse_parm_ex(runstack_context_t *rcxt, val_value_t *val, obj_template_t *obj, const xmlChar *strval, boolean script, ncx_bad_data_t bad_data)
Create a val_value_t struct for the specified parm value, and insert it into the parent container val...
Definition: cli.c:2785
status_t cli_parse_parm_ret(runstack_context_t *rcxt, val_value_t *val, obj_template_t *obj, const xmlChar *strval, boolean script, val_value_t **retval)
Create a val_value_t struct for the specified parm value, and insert it into the parent container val...
Definition: cli.c:2739
val_value_t * cli_parse_inline2(runstack_context_t *rcxt, int argc, char *argv[], cli_inline_parms_t *parms, status_t *status)
schema based CLI support
Definition: cli.c:1989
cli_rawparm_t * cli_find_rawparm(const xmlChar *name, dlq_hdr_t *parmQ)
Find the specified raw parm entry.
Definition: cli.c:1510
status_t cli_parse_raw(int argc, char *argv[], dlq_hdr_t *rawparmQ)
Generate N sets of variable/value pairs for the specified boot-strap CLI parameters.
Definition: cli.c:1582
cli_mode_t
CLI parsing modes.
Definition: cli.h:121
cli_rawparm_t * cli_new_rawparm(const xmlChar *name, boolean xsdlist)
bootstrap CLI support Malloc and init a raw parm entry
Definition: cli.c:1388
status_t cli_parse_parm(runstack_context_t *rcxt, val_value_t *val, obj_template_t *obj, const xmlChar *strval, boolean script)
Create a val_value_t struct for the specified parm value, and insert it into the parent container val...
Definition: cli.c:2700
val_value_t *(* cli_xml_buffer_fn_t)(const xmlChar *xmlbuff, obj_template_t *targetobj, status_t *res)
Read an XML buffer and convert it into a real data structure.
Definition: cli.h:152
val_value_t * cli_parse(runstack_context_t *rcxt, int argc, char *argv[], obj_template_t *obj, boolean valonly, boolean script, boolean autocomp, cli_mode_t mode, status_t *status)
schema based CLI support
Definition: cli.c:1904
status_t cli_parse_parm_binary(runstack_context_t *rcxt, val_value_t *val, obj_template_t *obj, const xmlChar *strval, boolean script, val_value_t **retval)
Create a val_value_t struct for the specified parm value, and insert it into the value set Extended.
Definition: cli.c:680
@ CLI_MODE_PROGRAM
real argc, argv
Definition: cli.h:123
@ CLI_MODE_NONE
mode not set
Definition: cli.h:122
@ CLI_MODE_COMMAND
called from yangcli command parser
Definition: cli.h:124
ncx_bad_data_t
enumeration for CLI handling of bad input data used by yangcli, all others use NCX_BAD_DATA_ERROR
Definition: ncxtypes.h:595
YANG module data structures Many internal representations of YANG module constructs.
Data Object Support.
CLI run stack manager.
Global error messages for status code enumerations.
CLI inline parser parameter block.
Definition: cli.h:180
obj_template_t * obj
obj_template_t of the container that should be used to validate the input against the child nodes of ...
Definition: cli.h:185
cli_mode_t mode
mode
Definition: cli.h:230
boolean valonly
valonly
Definition: cli.h:192
boolean hide_unknown_error
hide_unknown_error used for show raw testing of the command line to see if it should be processed or ...
Definition: cli.h:221
cli_var_replace_fn_t cbfn2
cbfn2 inline data variable replacement callback function
Definition: cli.h:236
cli_xml_buffer_fn_t cbfn
cbfn inline XML data only: callback for XML buffer parsing
Definition: cli.h:233
boolean autocomp
autocomp
Definition: cli.h:206
boolean script
script
Definition: cli.h:198
boolean rawxml
rawxml XML parsing mode
Definition: cli.h:212
used for bootstrap CLI parms only, no validation
Definition: cli.h:130
int32 count
count field if duplicates
Definition: cli.h:137
char * value
stored value if set
Definition: cli.h:133
dlq_hdr_t qhdr
queue header to store rawparm in a dlq
Definition: cli.h:131
boolean hasvalue
indicates value is set
Definition: cli.h:134
const char * name
parameter name
Definition: cli.h:132
ncx_list_t * ncx_list
value if a list is expected
Definition: cli.h:136
boolean xsdlist
true if a list is expected
Definition: cli.h:135
header for a NCX List
Definition: ncxtypes.h:838
One YANG data-def-stmt.
Definition: obj.h:1284
Main runstact context control block used by yangcli to process script input loops and conditional sta...
Definition: runstack.h:256
one value to match one type
Definition: val.h:939