?? 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) )
( ((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
搜索代碼
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -