📄 parse.c
字号:
/* Process the next argument */
un32Setting++;
/* Get the next token */
pArg = strtok (NULL, TB640_ISDN_LINE_PARSING_DELIMITERS);
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
/* Print error message */
TB640_ISDN_LOG (TRACE_LEVEL_ALWAYS, "%s (Result = 0x%08X, %s, line %d)\n", TBX_ERROR_DESCRIPTION, TBX_ERROR_RESULT, __FILE__, TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
}
RETURN;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| TB640IsdnParseStackConfigurationLine: Parses the content of a stack configuration line and stores them into our structure
|
| in_pszLine : Pointer to the text line
| in_pszOriginalLine: Pointer to the original text line
| in_un32Line : Line number in the configuration file
| in_un32Index : Index of the argument in the original string
| in_un32Adapter : Adapter index in our internal array
| in_un32TrunkNb : Trunk number to which the stack is connected
|
| Note : Line must be converted in CAPS
|
| Return : TBX_RESULT_OK
| TBX_RESULT_FAIL
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT
TB640IsdnParseStackConfigurationLine(
IN const PTBX_CHAR in_pszLine,
IN const PTBX_CHAR in_pszOriginalLine,
IN TBX_UINT32 in_un32Line,
IN TBX_UINT32 in_un32Index,
IN TBX_UINT32 in_un32Adapter,
IN TBX_UINT32 in_un32TrunkNb)
{
TBX_CHAR szLine [TB640_ISDN_MAX_CONFIGURATION_LINE_LENGTH];
TBX_UINT32 un32Setting;
TBX_UINT32 un32SizeOfEntry;
TBX_BOOL fOverlap;
PTBX_CHAR pArg;
PTB640_ISDN_ADAPTER_INFO pAdapterInfo;
PTB640_ISDN_TRUNK_INFO pTrunkInfo;
PTB640_ISDN_CFG pStackCfg;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
/* Initialize local variable */
strcpy (szLine, in_pszLine);
un32Setting = 0;
pAdapterInfo = &(g_AppContext->ahAdapterInfo [in_un32Adapter]);
pTrunkInfo = &(pAdapterInfo->aTrunkInfo [in_un32TrunkNb]);
pStackCfg = &(pTrunkInfo->StackConfiguration);
/* Initialize parameters not in the configuration file */
pStackCfg->un32StructVersion = 1;
pStackCfg->Options = 0;
TB640_ISDN_SET_DEFAULT_TIMERS (&pStackCfg->Timers);
/* Begin parsing */
pArg = strtok (szLine, TB640_ISDN_LINE_PARSING_DELIMITERS);
while (NULL != pArg)
{
switch (un32Setting)
{
/* First argument is the stack variant */
case 0:
TB640_ISDN_PARSE_GET_PARAMETER ( \
g_aParseStackVariant, \
&(pStackCfg->IsdnVariant), \
"Invalid value. Expecting stack variant [4ESS/AUS/5ESS/NET5/DMS/NI2/HK]");
break;
/* Second argument is the stack side */
case 1:
TB640_ISDN_PARSE_GET_PARAMETER ( \
g_aParseStackSide, \
&(pStackCfg->ProtocolSide), \
"Invalid value. Expecting protocol side [USER/NETWORK]");
break;
/* Third argument is the overlapped sending */
case 2:
TB640_ISDN_PARSE_GET_PARAMETER ( \
g_aParseBoolean, \
&(fOverlap), \
"Invalid value. Expecting overlapped sending [TRUE/FALSE]");
if (fOverlap)
{
pStackCfg->Options |= TB640_ISDN_STACK_OPTIONS_OVERLAP_SUPPORT;
}
break;
default:
/* Too many argument found */
TB640_ISDN_PARSE_ERROR_DISPLAY (in_un32Line, (pArg-szLine+in_un32Index), in_pszOriginalLine, "Too many arguments");
TBX_EXIT_SUCCESS(TBX_RESULT_FAIL);
break;
}
/* Process the next argument */
un32Setting++;
/* Get the next token */
pArg = strtok (NULL, TB640_ISDN_LINE_PARSING_DELIMITERS);
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
/* Print error message */
TB640_ISDN_LOG (TRACE_LEVEL_ALWAYS, "%s (Result = 0x%08X, %s, line %d)\n", TBX_ERROR_DESCRIPTION, TBX_ERROR_RESULT, __FILE__, TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
}
RETURN;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| TB640IsdnParseCTBusConfigurationLine: Parses the content of a CTBus configuration line and stores them into our structure
|
| in_pszLine : Pointer to the text line
| in_pszOriginalLine: Pointer to the original text line
| in_un32Line : Line number in the configuration file
| in_un32Index : Index of the argument in the original string
| out_pfCTBusConn : Output flag from the configuration file
|
| Note : Line must be converted in CAPS
|
| Return : TBX_RESULT_OK
| TBX_RESULT_FAIL
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT
TB640IsdnParseCTBusConfigurationLine(
IN const PTBX_CHAR in_pszLine,
IN const PTBX_CHAR in_pszOriginalLine,
IN TBX_UINT32 in_un32Line,
IN TBX_UINT32 in_un32Index,
IN PTBX_BOOL out_pfCTBusConn)
{
TBX_CHAR szLine [TB640_ISDN_MAX_CONFIGURATION_LINE_LENGTH];
TBX_UINT32 un32Setting;
TBX_UINT32 un32SizeOfEntry;
TBX_BOOL fCTBusConfig;
PTBX_CHAR pArg;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
/* Initialize local variable */
strcpy (szLine, in_pszLine);
un32Setting = 0;
/* Begin parsing */
pArg = strtok (szLine, TB640_ISDN_LINE_PARSING_DELIMITERS);
while (NULL != pArg)
{
switch (un32Setting)
{
/* First argument is the CTBus config */
case 0:
{
TB640_ISDN_PARSE_GET_PARAMETER ( \
g_aParseBoolean, \
&(fCTBusConfig), \
"Invalid value. Expecting CTBus connection enable [TRUE/FALSE]");
*out_pfCTBusConn = fCTBusConfig;
}
break;
default:
/* Too many argument found */
TB640_ISDN_PARSE_ERROR_DISPLAY (in_un32Line, (pArg-szLine+in_un32Index), in_pszOriginalLine, "Too many arguments");
TBX_EXIT_SUCCESS(TBX_RESULT_FAIL);
break;
}
/* Process the next argument */
un32Setting++;
/* Get the next token */
pArg = strtok (NULL, TB640_ISDN_LINE_PARSING_DELIMITERS);
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
/* Print error message */
TB640_ISDN_LOG (TRACE_LEVEL_ALWAYS, "%s (Result = 0x%08X, %s, line %d)\n", TBX_ERROR_DESCRIPTION, TBX_ERROR_RESULT, __FILE__, TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
}
RETURN;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| TB640IsdnParseCallConfigurationLine: Parses the content of a call configuration line and stores them into our structure
|
| in_pszLine : Pointer to the text line
| in_pszOriginalLine: Pointer to the original text line
| in_un32Line : Line number in the configuration file
| in_un32Index : Index of the argument in the original string
| in_un32Adapter : Adapter index in our internal array
| in_un32TrunkNb : Trunk number to which the stack is connected
|
| Note : Line must be converted in CAPS
|
| Return : TBX_RESULT_OK
| TBX_RESULT_FAIL
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT
TB640IsdnParseCallConfigurationLine(
IN const PTBX_CHAR in_pszLine,
IN const PTBX_CHAR in_pszOriginalLine,
IN TBX_UINT32 in_un32Line,
IN TBX_UINT32 in_un32Index,
IN TBX_UINT32 in_un32Adapter,
IN TBX_UINT32 in_un32TrunkNb)
{
TBX_CHAR szLine [TB640_ISDN_MAX_CONFIGURATION_LINE_LENGTH];
TBX_UINT32 un32Setting;
PTBX_CHAR pArg;
PTB640_ISDN_ADAPTER_INFO pAdapterInfo;
PTB640_ISDN_TRUNK_INFO pTrunkInfo;
PTB640_ISDN_CALL_CFG pCallCfg;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
/* Initialize local variable */
strcpy (szLine, in_pszLine);
un32Setting = 0;
pAdapterInfo = &(g_AppContext->ahAdapterInfo [in_un32Adapter]);
pTrunkInfo = &(pAdapterInfo->aTrunkInfo [in_un32TrunkNb]);
pCallCfg = &(pTrunkInfo->CallConfiguration);
/* Begin parsing */
pArg = strtok (szLine, TB640_ISDN_LINE_PARSING_DELIMITERS);
while (NULL != pArg)
{
switch (un32Setting)
{
/* First argument is the calling number */
case 0:
strncpy (pCallCfg->szCallingPhoneNb, pArg, sizeof(pCallCfg->szCallingPhoneNb));
pCallCfg->szCallingPhoneNb[ sizeof(pCallCfg->szCallingPhoneNb)-1 ] = '\0';
break;
/* Second argument is the called number */
case 1:
strncpy (pCallCfg->szCalledPhoneNb, pArg, sizeof(pCallCfg->szCalledPhoneNb));
pCallCfg->szCalledPhoneNb[ sizeof(pCallCfg->szCalledPhoneNb)-1 ] = '\0';
break;
/* Third argument is the redirecting number */
case 2:
strncpy (pCallCfg->szRedirectingPhoneNb, pArg, sizeof(pCallCfg->szRedirectingPhoneNb));
pCallCfg->szRedirectingPhoneNb[ sizeof(pCallCfg->szRedirectingPhoneNb)-1 ] = '\0';
break;
default:
/* Too many argument found */
TB640_ISDN_PARSE_ERROR_DISPLAY (in_un32Line, (pArg-szLine+in_un32Index), in_pszOriginalLine, "Too many arguments");
TBX_EXIT_SUCCESS(TBX_RESULT_FAIL);
break;
}
/* Process the next argument */
un32Setting++;
/* Get the next token */
pArg = strtok (NULL, TB640_ISDN_LINE_PARSING_DELIMITERS);
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
/* Print error message */
TB640_ISDN_LOG (TRACE_LEVEL_ALWAYS, "%s (Result = 0x%08X, %s, line %d)\n", TBX_ERROR_DESCRIPTION, TBX_ERROR_RESULT, __FILE__, TBX_ERROR_LINE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -