yumapro  24.10-2
YumaPro SDK
Loading...
Searching...
No Matches
CLI Run Stack Support

A stack of CLI contexts. More...

Collaboration diagram for CLI Run Stack Support:

Data Structures

struct  runstack_ifcb_t
 control the conditional state for 1 if...end sequence More...
 
struct  runstack_line_t
 save 1 line for looping purposes More...
 
struct  runstack_loopcb_t
 control the looping for 1 while - end sequence More...
 
struct  runstack_condcb_t
 control the looping for 1 while - end sequence More...
 
struct  runstack_entry_t
 one script run level context entry each time a 'run script' command is encountered, a new stack context is created, unless max_script_level is reached More...
 
struct  runstack_context_t
 Main runstact context control block used by yangcli to process script input loops and conditional statements in scripts. More...
 

Macros

#define RUNSTACK_MAX_PARMS   9
 this is an arbitrary limit, but it must match the yangcli:run rpc P1 - Pn variables, currently set to 9 $1 to $9 parameters passed by yangcli to next script
 
#define RUNSTACK_MAX_NEST   512
 this is an arbitrary max to limit resources and run-away scripts that are called recursively
 
#define RUNSTACK_MAX_LOOP   65535
 this is an arbitrary max to limit run-away scripts that have bugs
 

Enumerations

enum  runstack_src_t {
  RUNSTACK_SRC_NONE ,
  RUNSTACK_SRC_USER ,
  RUNSTACK_SRC_SCRIPT ,
  RUNSTACK_SRC_LOOP
}
 identify the runstack input source More...
 
enum  runstack_condtype_t {
  RUNSTACK_COND_NONE ,
  RUNSTACK_COND_IF ,
  RUNSTACK_COND_LOOP
}
 identify the runstack conditional control block type More...
 
enum  runstack_ifstate_t {
  RUNSTACK_IF_NONE ,
  RUNSTACK_IF_IF ,
  RUNSTACK_IF_ELIF ,
  RUNSTACK_IF_ELSE
}
 keep track of the if,elif,else,end sequence More...
 
enum  runstack_loopstate_t {
  RUNSTACK_LOOP_NONE ,
  RUNSTACK_LOOP_COLLECTING ,
  RUNSTACK_LOOP_LOOPING
}
 keep track of the while,end sequence More...
 
enum  runstack_queue_type_t {
  RUNSTACK_QUE_NONE ,
  RUNSTACK_QUE_LOCAL ,
  RUNSTACK_QUE_SESSION ,
  RUNSTACK_QUE_GROUP ,
  RUNSTACK_QUE_GLOBAL
}
 different queues of variables for que selection More...
 

Functions

uint32 runstack_level (runstack_context_t *rcxt)
 Get the current stack level. More...
 
status_t runstack_push (runstack_context_t *rcxt, const xmlChar *source, FILE *fp)
 Add a script nest level context to the stack. More...
 
void runstack_pop (runstack_context_t *rcxt)
 Remove a script nest level context from the stack Call just after script is completed. More...
 
xmlChar * runstack_get_cmd (runstack_context_t *rcxt, status_t *res)
 Read the current runstack context and construct a command string for processing by do_run_script. More...
 
void runstack_cancel (runstack_context_t *rcxt)
 Cancel all running scripts. More...
 
void runstack_clear_cancel (runstack_context_t *rcxt)
 Clear the cancel flags. More...
 
dlq_hdr_t * runstack_get_que (runstack_context_t *rcxt, runstack_queue_type_t quetype)
 Read the current runstack context and figure out which queue to get. More...
 
dlq_hdr_t * runstack_get_parm_que (runstack_context_t *rcxt)
 Get the parameter queue for the current stack level. More...
 
void runstack_init (void)
 Initialize this module. More...
 
void runstack_cleanup (void)
 Cleanup this module. More...
 
void runstack_clean_context (runstack_context_t *rcxt)
 Clean the runstack context. More...
 
void runstack_free_context (runstack_context_t *rcxt)
 Clean and free the runstack context. More...
 
void runstack_init_context (runstack_context_t *rcxt)
 Initialize a pre-malloced runstack context. More...
 
runstack_context_trunstack_new_context (void)
 Malloc and init a new runstack context. More...
 
void runstack_session_cleanup (runstack_context_t *rcxt)
 Cleanup after a yangcli session has ended. More...
 
runstack_src_t runstack_get_source (runstack_context_t *rcxt)
 Get the current input source for the runstack context. More...
 
status_t runstack_save_line (runstack_context_t *rcxt, const xmlChar *line)
 Save the current line if needed if a loop is active. More...
 
xmlChar * runstack_get_loop_cmd (runstack_context_t *rcxt, status_t *res)
 Get the next command during loop processing. More...
 
boolean runstack_get_cond_state (runstack_context_t *rcxt)
 Get the current conditional code state for the context. More...
 
status_t runstack_handle_while (runstack_context_t *rcxt, uint32 maxloops, struct xpath_pcb_t_ *xpathpcb, val_value_t *docroot)
 Process the current command, which is a 'while' command. More...
 
status_t runstack_handle_if (runstack_context_t *rcxt, boolean startcond)
 Handle the if command for the specific runstack context. More...
 
status_t runstack_handle_elif (runstack_context_t *rcxt, boolean startcond)
 Handle the elif command for the specific runstack context. More...
 
status_t runstack_handle_else (runstack_context_t *rcxt)
 Handle the elsecommand for the specific runstack context. More...
 
status_t runstack_handle_end (runstack_context_t *rcxt)
 Handle the end command for the specific runstack context. More...
 
boolean runstack_get_if_used (runstack_context_t *rcxt)
 Check if the run context, which should be inside an if-stmt now, has used the 'true' block already. More...
 
void runstack_set_sessionQ (runstack_context_t *rcxt, dlq_hdr_t *sessionQ)
 Set the current session-specific variable Q. More...
 
void runstack_set_groupQ (runstack_context_t *rcxt, dlq_hdr_t *groupQ)
 Set the current group-specific variable Q. More...
 

Detailed Description

A stack of CLI contexts.

Each 'run' command causes a new context to be created on the stack.

Enumeration Type Documentation

◆ runstack_condtype_t

identify the runstack conditional control block type

Enumerator
RUNSTACK_COND_NONE 

not set

RUNSTACK_COND_IF 

if-stmt condition

RUNSTACK_COND_LOOP 

while loop condition

◆ runstack_ifstate_t

keep track of the if,elif,else,end sequence

Enumerator
RUNSTACK_IF_NONE 

not set

RUNSTACK_IF_IF 

if state

RUNSTACK_IF_ELIF 

elif state

RUNSTACK_IF_ELSE 

else state

◆ runstack_loopstate_t

keep track of the while,end sequence

Enumerator
RUNSTACK_LOOP_NONE 

not set

RUNSTACK_LOOP_COLLECTING 

collecting loop commands

RUNSTACK_LOOP_LOOPING 

playing loop commands

◆ runstack_queue_type_t

different queues of variables for que selection

Enumerator
RUNSTACK_QUE_NONE 

not set

RUNSTACK_QUE_LOCAL 

local variables

RUNSTACK_QUE_SESSION 

session variables

RUNSTACK_QUE_GROUP 

group variables

RUNSTACK_QUE_GLOBAL 

global variables

◆ runstack_src_t

identify the runstack input source

Enumerator
RUNSTACK_SRC_NONE 

not set

RUNSTACK_SRC_USER 

source is interactive input

RUNSTACK_SRC_SCRIPT 

source is a yangcli script

RUNSTACK_SRC_LOOP 

source is captured from a loop

Function Documentation

◆ runstack_cancel()

void runstack_cancel ( runstack_context_t rcxt)

Cancel all running scripts.

Parameters
rcxtrunstack context to use

◆ runstack_clean_context()

void runstack_clean_context ( runstack_context_t rcxt)

Clean the runstack context.

Parameters
rcxtrunstack context to clean, but not free
Here is the call graph for this function:
Here is the caller graph for this function:

◆ runstack_cleanup()

void runstack_cleanup ( void  )

Cleanup this module.

Must cleanup this module after using it!!!

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runstack_clear_cancel()

void runstack_clear_cancel ( runstack_context_t rcxt)

Clear the cancel flags.

Parameters
rcxtrunstack context to use
Here is the caller graph for this function:

◆ runstack_free_context()

void runstack_free_context ( runstack_context_t rcxt)

Clean and free the runstack context.

Parameters
rcxtrunstack context to free
Here is the call graph for this function:

◆ runstack_get_cmd()

xmlChar * runstack_get_cmd ( runstack_context_t rcxt,
status_t res 
)

Read the current runstack context and construct a command string for processing by do_run_script.

  • Comment lines will be skipped.
  • Extended lines will be concatenated in the buffer. If a buffer overflow occurs due to this concatenation, an error will be returned
Parameters
rcxtrunstack context to use
[out]resaddress of status result
  • *res function result status
Returns
pointer to the command line to process (should treat as CONST !!!) NULL if some error
Here is the call graph for this function:

◆ runstack_get_cond_state()

boolean runstack_get_cond_state ( runstack_context_t rcxt)

Get the current conditional code state for the context.

Parameters
rcxtrunstack context to use
Returns
TRUE if in a TRUE conditional or no conditional
FALSE if in a FALSE conditional statement right now
Here is the caller graph for this function:

◆ runstack_get_if_used()

boolean runstack_get_if_used ( runstack_context_t rcxt)

Check if the run context, which should be inside an if-stmt now, has used the 'true' block already.

Parameters
rcxtrunstack context to use
Returns
TRUE if TRUE block already used
FALSE if FALSE not already used or not in an if-block

◆ runstack_get_loop_cmd()

xmlChar * runstack_get_loop_cmd ( runstack_context_t rcxt,
status_t res 
)

Get the next command during loop processing.

This function is called after the while loop end has been reached, and buffered commands are used

Parameters
rcxtrunstack context to use
[out]resaddress of status result
  • *res function result status
  • ERR_NCX_LOOP_ENDED if the loop expr was just evaluated to FALSE; In this case the caller must use the runstack_get_source function to determine the source of the next line. If this occurs, the loopcb (and while context) will be removed from the curent runstack frame
Returns
pointer to the command line to process (should treat as CONST !!!) NULL if some error
Here is the call graph for this function:

◆ runstack_get_parm_que()

dlq_hdr_t * runstack_get_parm_que ( runstack_context_t rcxt)

Get the parameter queue for the current stack level.

Parameters
rcxtrunstack context to use
Returns
que for current stack level, NULL if an error

◆ runstack_get_que()

dlq_hdr_t * runstack_get_que ( runstack_context_t rcxt,
runstack_queue_type_t  quetype 
)

Read the current runstack context and figure out which queue to get.

Parameters
rcxtrunstack context to use
quetyperunstack_queue_type_t enumeration
Returns
pointer to the requested que
Here is the caller graph for this function:

◆ runstack_get_source()

runstack_src_t runstack_get_source ( runstack_context_t rcxt)

Get the current input source for the runstack context.

Parameters
rcxtrunstack context to use

◆ runstack_handle_elif()

status_t runstack_handle_elif ( runstack_context_t rcxt,
boolean  startcond 
)

Handle the elif command for the specific runstack context.

Parameters
rcxtrunstack context to use
startcondstart condition state for this if block may be FALSE because the current conditional state is already FALSE
Returns
status

◆ runstack_handle_else()

status_t runstack_handle_else ( runstack_context_t rcxt)

Handle the elsecommand for the specific runstack context.

Parameters
rcxtrunstack context to use
Returns
status

◆ runstack_handle_end()

status_t runstack_handle_end ( runstack_context_t rcxt)

Handle the end command for the specific runstack context.

Parameters
rcxtrunstack context to use
Returns
status
Here is the call graph for this function:

◆ runstack_handle_if()

status_t runstack_handle_if ( runstack_context_t rcxt,
boolean  startcond 
)

Handle the if command for the specific runstack context.

Parameters
rcxtrunstack context to use
startcondstart condition state for this if block may be FALSE because the current conditional state is already FALSE
Returns
status
Here is the call graph for this function:

◆ runstack_handle_while()

status_t runstack_handle_while ( runstack_context_t rcxt,
uint32  maxloops,
struct xpath_pcb_t_ *  xpathpcb,
val_value_t docroot 
)

Process the current command, which is a 'while' command.

This must be called before the next command is retrieved during runstack context processing

Parameters
rcxtrunstack context to use
maxloopsmax number of loop iterations
xpathpcbXPath control block to save which contains the expression to be processed.
                 !!! this memory is handed off here; it will
                 !!!  be freed as part of the loopcb context
docrootdocroot var struct that represents the XML document to run the XPath expr against
                 !!! this memory is handed off here; it will
                 !!!  be freed as part of the loopcb context
Returns
status; if status != NO_ERR then the xpathpcb and docroot parameters need to be freed by the caller

◆ runstack_init()

void runstack_init ( void  )

Initialize this module.

Must Init this module before using it!!!

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runstack_init_context()

void runstack_init_context ( runstack_context_t rcxt)

Initialize a pre-malloced runstack context.

Parameters
rcxtrunstack context to free
Here is the call graph for this function:
Here is the caller graph for this function:

◆ runstack_level()

uint32 runstack_level ( runstack_context_t rcxt)

Get the current stack level.

Parameters
rcxtrunstack context to use
Returns
current stack level; 0 --> not in any script

◆ runstack_new_context()

runstack_context_t * runstack_new_context ( void  )

Malloc and init a new runstack context.

Returns
malloced and initialized runstack context
Here is the call graph for this function:

◆ runstack_pop()

void runstack_pop ( runstack_context_t rcxt)

Remove a script nest level context from the stack Call just after script is completed.

Parameters
rcxtrunstack context to use
Here is the call graph for this function:
Here is the caller graph for this function:

◆ runstack_push()

status_t runstack_push ( runstack_context_t rcxt,
const xmlChar *  source,
FILE *  fp 
)

Add a script nest level context to the stack.

Call just after the file is opened and before the first line has been read

Still need to add the script parameters (if any) with the runstack_setparm

Parameters
rcxtrunstack context to use
sourcefile source
fpfile pointer
Returns
status
Here is the call graph for this function:

◆ runstack_save_line()

status_t runstack_save_line ( runstack_context_t rcxt,
const xmlChar *  line 
)

Save the current line if needed if a loop is active.

Parameters
rcxtrunstack context to use
lineline to save, a copy will be made
Returns
status
Here is the call graph for this function:

◆ runstack_session_cleanup()

void runstack_session_cleanup ( runstack_context_t rcxt)

Cleanup after a yangcli session has ended.

Parameters
rcxtrunstack context to use
Here is the call graph for this function:

◆ runstack_set_groupQ()

void runstack_set_groupQ ( runstack_context_t rcxt,
dlq_hdr_t *  groupQ 
)

Set the current group-specific variable Q.

Parameters
rcxtrunstack context to use
groupQpointer to Q of ncx_var_t to use as current group vars NULL to clear the current sessionQ

◆ runstack_set_sessionQ()

void runstack_set_sessionQ ( runstack_context_t rcxt,
dlq_hdr_t *  sessionQ 
)

Set the current session-specific variable Q.

Parameters
rcxtrunstack context to use
sessionQpointer to Q of ncx_var_t to use as current session vars NULL to clear the current sessionQ