📄 cli_intp.inc
字号:
/************************************************************************
Copyright 200X - 200X+1.
filename : CLI_Intp.inc
description : 声明命令解释的各种状态定义、数据结构、宏与函数
author : Woodhead
modification : Woodhead create 2004-12-07
************************************************************************/
#ifndef _CLI_INTP_H_
#define _CLI_INTP_H_
#include "Cli_Cmdreg.inc"
#define CT_INTP_RETURNED_FOR_HELP 44
#define CT_INTP_RETURNED_FOR_NEWLINE 55
/* 命令执行标志 */
#define COMMAND_ACCOMPLISHED 1
#define COMMAND_UNFINISHED 0
/* 解释过程中的总体状态字*/
#define STAT_ENV_SILENT 0x00040000
#define STAT_ENV_SYSTEM 0x00080000 /* 该标志位已经不用, 留待扩展 */
#define STAT_ENV_ENTER 0x00100000
#define STAT_ENV_RUNCFG 0x00200000
#define STAT_ENV_NEWLINE 0x00400000
#define CTMF_PARTIAL 0xf0
#define CTMF_FULL 0x0f
#define IS_ENV_SILENT(s) ((s) & STAT_ENV_SILENT)
#define IS_ENV_SYSTEM(s) ((s) & STAT_ENV_SYSTEM)
#define IS_ENV_ENTER(s) ((s) & STAT_ENV_ENTER)
#define IS_ENV_RUNCFG(s) ((s) & STAT_ENV_RUNCFG)
#define IS_ENV_NEWLINE(s) ((s) & STAT_ENV_NEWLINE)
/* 解释解析的状态机状态位定义 */
#define WAIT_NULL 0x00 /* Initial state */
#define WAIT_OBJ 0x01 /* expecting a object */
#define WAIT_PARAM 0x02 /* expecting a parameter */
#define WAIT_VALUE 0x04 /* expecting a value */
#define NO_FORM 0x20 /* a no form command */
#define INTERACTIVE 0x40 /* interactive command mode */
#define SKIP_ELEMENT 0x80 /* skip an optional element */
#define RES_COMPLETE 0x100 /* Research Completed */
#define LAST_TOKEN 0x200 /* Last token to be matched */
#define MUTEX_PARAM 0x400 /* Now Parameter Mutex */
#define VIRTUAL_P 0x800 /* Current element is */
#define MUTEX_VALUE 0x1000 /* Now Value Mutex */
#define BIG_TOKEN 0x8000 /* Token too big error */
#define _UNWANTED 0x10000 /* Unwanted token exists. */
#define MATCH_SUCC 0x20000 /* Match Success */
#define MASK_STATUS 0x0f /* Mask Bits */
#define MASK_SKIPFLAG 0x80 /* Mask Bits */
#define MASK_INTERACTIVE 0x40 /* Mask Bits */
#define MASK_NOFORM 0x20 /* Mask Bits */
#define MASK_COMPLETE 0x100 /* Mask Bits */
#define MASK_LASTTOKEN 0x200 /* Mask Bits */
#define MASK_MUTEXPARAM 0x400 /* Mask Bits */
#define MASK_VIRTUAL_P 0x800 /* Mask Bits */
#define MASK_MUTEXVALUE 0x1000 /* Mask Bits */
#define MASK_BIGTOKEN 0x8000 /* Mask Bits */
#define MASK_UNWANTED 0x10000 /* Mask Bits */
#define MASK_MATCHSUCC 0x20000 /* Mask Bits */
enum
{
HAVEACTIONS,
HAVENOACTIONS
};
/* -------------------------------- 宏操作定义 ------------------------------ */
/* 解析状态位的判断、设置与清除 */
/* 状态位判断 */
#define IS_WAIT_NULL(s) (((s) & MASK_STATUS) == WAIT_NULL )
#define IS_WAIT_OBJ(s) (((s) & MASK_STATUS) == WAIT_OBJ )
#define IS_WAIT_PARAM(s) (((s) & MASK_STATUS) == WAIT_PARAM )
#define IS_WAIT_VALUE(s) (((s) & MASK_STATUS) == WAIT_VALUE )
#define IS_SKIP_FLAG(s) (((s) & MASK_SKIPFLAG) != 0 )
#define IS_INTERACTIVE(s) (((s) & MASK_INTERACTIVE) != 0 )
#define IS_NOFORM(s) (((s) & MASK_NOFORM) != 0 )
#define IS_COMPLETE(s) (((s) & MASK_COMPLETE) != 0 )
#define IS_LASTTOKEN(s) (((s) & MASK_LASTTOKEN) != 0 )
#define IS_MUTEXPARAM(s) (((s) & MASK_MUTEXPARAM) != 0 )
#define IS_VIRTUAL_P(s) (((s) & MASK_VIRTUAL_P) != 0 )
#define IS_MUTEXVALUE(s) (((s) & MASK_MUTEXVALUE) != 0 )
#define IS_BIGTOKEN(s) (((s) & MASK_BIGTOKEN) != 0 )
#define IS_UNWANTED(s) (((s) & MASK_UNWANTED) != 0 )
#define IS_MATCHSUCC(s) (((s) & MASK_MATCHSUCC) != 0 )
/* 状态位的设置与清除 */
#define SET_WAIT_NULL(s) ((s) = ((s) & 0xfffffff0) | WAIT_NULL )
#define SET_WAIT_OBJ(s) ((s) = ((s) & 0xfffffff0) | WAIT_OBJ )
#define SET_WAIT_PARAM(s) ((s) = ((s) & 0xfffffff0) | WAIT_PARAM )
#define SET_WAIT_VALUE(s) ((s) = ((s) & 0xfffffff0) | WAIT_VALUE )
#define SET_SKIP_FLAG(s) ((s) = (s) | SKIP_ELEMENT )
#define CLR_SKIP_FLAG(s) ((s) = (s) & (~SKIP_ELEMENT) )
#define SET_INTERACTIVE(s) ((s) = (s) | INTERACTIVE )
#define CLR_INTERACTIVE(s) ((s) = (s) & (~INTERACTIVE) )
#define SET_NOFORM(s) ((s) = (s) | NO_FORM )
#define SET_COMPLETE(s) ((s) = (s) | RES_COMPLETE )
#define SET_LASTTOKEN(s) ((s) = (s) | LAST_TOKEN )
#define SET_MUTEXPARAM(s) ((s) = (s) | MUTEX_PARAM )
#define CLR_MUTEXPARAM(s) ((s) = (s) & (~MUTEX_PARAM) )
#define SET_VIRTUAL_P(s) ((s) = (s) | VIRTUAL_P )
#define CLR_VIRTUAL_P(s) ((s) = (s) & (~VIRTUAL_P) )
#define SET_MUTEXVALUE(s) ((s) = (s) | MUTEX_VALUE )
#define CLR_MUTEXVALUE(s) ((s) = (s) & (~MUTEX_VALUE) )
#define SET_BIGTOKEN(s) ((s) = (s) | BIG_TOKEN )
#define SET_UNWANTED(s) ((s) = (s) | _UNWANTED )
#define SET_MATCHSUCC(s) ((s) = (s) | MASK_MATCHSUCC )
#define CLR_MATCHSUCC(s) ((s) = (s) & (~MASK_MATCHSUCC))
/* 命令解释过程中的状态变迁的宏定义开始 {
*/
/*【1】对象*/
/* (1.1) 检查对象是否可执行 */
#define CT_OBJ_HAVE_ACTION(pObj) \
( ((pObj)->action.pFunction != G_NULL) || \
((pObj)->noAction.pFunction != G_NULL) )
/* (1.2) 获取前一个对象 */
#define CT_OBJ_ELDER_BROTHER(pObj) ((pObj)->pPrevious)
/* (1.3) 获取后一个对象 */
#define CT_OBJ_YOUNGER_BROTHER(pObj) ((pObj)->pNext)
/* (1.4) 获取对象名 */
#define CT_OBJ_NAME(pObj) ((pObj)->szName)
/* (1.5) 判断是否为模式转换对象 */
#define CT_OBJ_CHANGE_MODE(pObj) ((pObj)->action.modeConv != CT_MC_NULL)
/* (1.6) 判断对象是否有参数 */
#define CT_OBJ_HAVE_PARAMETER0(pObj) \
( ((pObj)->action.pParamLink != G_NULL) && \
((pObj)->action.pParamLink->ulNumber > 0) )
#define CT_OBJ_HAVE_PARAMETER1(pObj) \
( ((pObj)->noAction.pParamLink != G_NULL) && \
((pObj)->noAction.pParamLink->ulNumber > 0) )
/* (1.7) 判断对象是否有子对象 */
#define CT_OBJ_HAVE_SUBOBJECTS(pObj) \
( (pObj)->pSubObject != G_NULL )
/* (1.8) 对象是否超大 */
#define CT_IS_BIG_OBJECT(p1,p2) \
( strcmp((p1)->szName,(p2)->szName) > 0 )
/* (1.9) 获取对象模式 */
#define CT_GET_OBJ_MODE(pObj) ((pObj)->action.ulMode)
/* (1.9) 是否可被当前用户与模式执行*/
#define CT_IS_CURRENT_KNOWN_OBJ(pObj, pWS) \
(((_U32)(pObj->action.rightLevel) <= pWS->ulLevel)\
&& ((pObj->action.ulMode == pWS->ulCurrentMode)\
|| (pObj->action.ulMode == CTM_GLOBAL)))
/*【2】参数*/
/* (2.1) 判断参数是否可选 */
#define CT_PARAM_IS_OPTIONAL(pParam) \
( (pParam)->paramType.ucAttrib & CT_PRMPROP_OPTIONAL )
/* (2.2) 判断参数是否互斥属性 */
#define CT_PARAM_IS_MUTEX(pParam) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -