yumapro  24.10-2
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* *
175* F U N C T I O N S *
176* *
177*********************************************************************/
178
187extern cli_rawparm_t *
188 cli_new_rawparm (const xmlChar *name, boolean xsdlist);
189
190
197extern cli_rawparm_t *
198 cli_new_empty_rawparm (const xmlChar *name);
199
200
206extern void
208
209
215extern void
216 cli_clean_rawparmQ (dlq_hdr_t *parmQ);
217
218
226extern cli_rawparm_t *
227 cli_find_rawparm (const xmlChar *name,
228 dlq_hdr_t *parmQ);
229
230
283extern status_t
284 cli_parse_raw (int argc,
285 char *argv[],
286 dlq_hdr_t *rawparmQ);
287
288
376extern val_value_t *
378 int argc,
379 char *argv[],
380 obj_template_t *obj,
381 boolean valonly,
382 boolean script,
383 boolean autocomp,
384 cli_mode_t mode,
385 status_t *status);
386
387
388
429extern val_value_t *
431 int argc,
432 char *argv[],
433 obj_template_t *obj,
434 boolean valonly,
435 boolean script,
436 boolean autocomp,
437 boolean rawxml,
438 cli_mode_t mode,
439 status_t *status,
442
443
463extern status_t
465 val_value_t *val,
466 obj_template_t *obj,
467 const xmlChar *strval,
468 boolean script);
469
470
492extern status_t
494 val_value_t *val,
495 obj_template_t *obj,
496 const xmlChar *strval,
497 boolean script,
498 val_value_t **retval);
499
500
522extern status_t
524 val_value_t *val,
525 obj_template_t *obj,
526 const xmlChar *strval,
527 boolean script,
528 val_value_t **retval);
529
530
552extern status_t
554 val_value_t *val,
555 obj_template_t *obj,
556 const xmlChar *strval,
557 boolean script,
558 ncx_bad_data_t bad_data);
559
562#ifdef __cplusplus
563} /* end extern 'C' */
564#endif
565
566#endif /* _H_cli */
dlq provides general double-linked list and queue support:
status_t
global error return code
Definition: status_enum.h:210
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:1930
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:2715
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:2669
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:2630
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:594
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.
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:859
One YANG data-def-stmt.
Definition: obj.h:1229
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:912