📄 ictautil.c
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//* (c) Copyright Systems Integration Specialists Company, Inc., *//* 1996-1998, All Rights Reserved *//* *//* *//* MODULE NAME : ictautil.c *//* PRODUCT(S) : ICCP toolkit *//* *//* MODULE DESCRIPTION : *//* Some utilities for the ICCP toolkit test application *//* *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : *//* ICTA_TYPE *findUserType (char *aType) *//* static int findStdType (char *aType) *//* static int findAcctType (char *aType) *//* int findOutWho (void) *//* ICTA_REMOTE_INFO *findRemote(int, char *) *//* ICTA_LINK_INFO *findOutWhichLink(...) *//* ICTA_VAR_INFO *findOutWhichVar(pstRemote, who) *//* ICTA_VAR_INFO *findClientVar(ICTA_REMOTE_INFO) *//* char *findVarType(int iccpType); *//* ICTA_MSG_INFO *findServerMsg(int nRef); *//* ICTA_DEVICE *findClientDevice(devName,pstRemote)*//* ICTA_DEVICE *findServerDevice(char *deviceName);*//* ICTA_SIMPLE_ACCT *findSimpleAccount(); *//* ICTA_MATRIX_ACCT *findMatrixAccount(); *//* ST_VOID pause_msg (ST_CHAR *str); *//* void startInterval( void ) *//* double endInterval( void ) *//* ICTA_LINK_INFO *findLink(ICTA_REMOTE_INFO, name)*//* void freeVCC (void) *//* void defAllObjForRemote *//* *//* MODIFICATION LOG : *//* Date Who Rev Comments *//* -------- --- ------ ------------------------------------------- *//* 08/05/02 nav 12 changes to test 8 remotes *//* 09/27/00 nav 11 Watch for bUseNewB4B8 when defining objects *//* 05/09/00 nav 10 Use StartTime in icDefineTransferGroup *//* 05/05/00 nav 9 Change printfs to print name not address *//* 04/05/00 nav 8 free up the extraPtr *//* 02/23/00 nav 7 Add \n to some printf's */ /* 06/03/99 nav 6 change sendMsgCallBack to reqInfoMsgCallBack *//* 05/18/98 nav 5 add defAllObjForRemote *//* 05/13/98 nav 4 move dyn_iccp_slog_fun to iccp_log.c *//* 01/16/98 EJV 3 Unix compiler don't like '//' for comment *//* Added typecast in list functions. *//* 06/20/97 nav 2 add findLink & overHaul *//* 06/05/97 nav 1 Convert to MMS-EASE V7.00 *//* 12/20/96 NAV Created *//************************************************************************/#include "ictamain.h"#include "scrndefs.h"#include "gvaldefs.h"#include "fkeydefs.h"static char *thisFileName = __FILE__;typedef struct typeConvType { char *name; ST_INT constant; } TYPE_CONV;static TYPE_CONV typeConvTable[] = { { "Data_State", IC_TYPE_STATE }, { "Data_StateQ", IC_TYPE_STATE_Q }, { "Data_StateQTimeTag", IC_TYPE_STATE_Q_TIME_TAG }, { "Data_StateExtended", IC_TYPE_STATE_EXTENDED }, { "Data_Discrete", IC_TYPE_DISCRETE }, { "Data_DiscreteQ", IC_TYPE_DISCRETE_Q }, { "Data_DiscreteQTimeTag", IC_TYPE_DISCRETE_Q_TIME_TAG }, { "Data_DiscreteExtended", IC_TYPE_DISCRETE_Q_EXTENDED }, { "Data_Real", IC_TYPE_REAL }, { "Data_RealQ", IC_TYPE_REAL_Q }, { "Data_RealQTimeTag", IC_TYPE_REAL_Q_TIME_TAG }, { "Data_RealExtended", IC_TYPE_REAL_EXTENDED } };#define NUM_STD_TYPES (sizeof (typeConvTable)/sizeof (TYPE_CONV))static TYPE_CONV acctTypeTable[] = { {"PeriodicNameSeg", IC_TYPE_NAME_SEG_PRD }, {"PeriodicSeg", IC_TYPE_SEG_PRD }, {"PeriodicName", IC_TYPE_NAME_PRD }, {"Periodic", IC_TYPE_PERIODIC }, {"ProfileNameSeg", IC_TYPE_NAME_SEG_PRF }, {"ProfileSeg", IC_TYPE_SEG_PRF }, {"ProfileName", IC_TYPE_NAME_PRF }, {"Profile", IC_TYPE_PROFILE } };#define NUM_ACCT_TYPES (sizeof (acctTypeTable)/sizeof (TYPE_CONV))#if 0#ifdef _WIN32/* nav i dont think we need this anymore */struct timeval { long tv_sec ; /* seconds */ long tv_usec; /* microseconds */ };#endif#endifST_VOID do_key_wait_service (void);static void defAllLinksForRemote (ICTA_REMOTE_INFO *pstRemote);static void defAllVarsForRemote (ICTA_REMOTE_INFO *pstRemote);static void defAllTGForRemote (ICTA_REMOTE_INFO *pstRemote);static void defAllMsgForRemote (ICTA_REMOTE_INFO *pstRemote);static void defAllDevForRemote (ICTA_REMOTE_INFO *pstRemote);static void defAllTAForRemote (ICTA_REMOTE_INFO *pstRemote);/************************************************************************//* findUserType *//* search typeList for user type *//************************************************************************/ICTA_TYPE *findUserType (char *aType) {ICTA_TYPE *pstAType, *rtnVal = NULL;icBoolean bDone = icFalse; pstAType = pstVCC->typeList; while (pstAType && !bDone) { if (strcmp(pstAType->typeName, aType) == 0) { rtnVal = pstAType; bDone = icTrue; } pstAType = (ICTA_TYPE *) list_get_next ((ST_VOID *)pstVCC->typeList, (ST_VOID *)pstAType); } return (rtnVal); }/************************************************************************//* findStdType *//* search typeConvTable for standard type *//************************************************************************/int findStdType (char *aType) {int i = 0, rtnVal = -1;icBoolean bDone = icFalse; while (i<NUM_STD_TYPES && !bDone) { if (strcmp(typeConvTable[i].name, aType) == 0) { rtnVal = typeConvTable[i].constant; bDone = icTrue; } i++; } return (rtnVal); }/************************************************************************//* findAcctType *//* search acctTypeTable for account type *//************************************************************************/int findAcctType (char *aType) {int i = 0, rtnVal = -1;icBoolean bDone = icFalse; while (i<NUM_ACCT_TYPES && !bDone) { if (strcmp(acctTypeTable[i].name, aType) == 0) { rtnVal = acctTypeTable[i].constant; bDone = icTrue; } i++; } return (rtnVal); }/************************************************************************//* findOutWho: ask Client/Server/Both and return response *//************************************************************************/int findOutWho(void) {ST_BOOLEAN dataEntered;ST_CHAR buffer[256];int rtnVal; printf("\nChoose C=Client, S=Server or B=Both: "); if (dataEntered = strget(buffer)) { switch (buffer[0]) { case 'C': rtnVal = ICTA_CLIENT; break; case 'S': rtnVal = ICTA_SERVER; break; case 'B': rtnVal = ICTA_BOTH; break; default: rtnVal = ICTA_NOONE; break; } } else /* no data entered */ rtnVal = ICTA_NOONE; return rtnVal; }/************************************************************************//* findRemote: search whose remoteList for remoteName *//************************************************************************/ICTA_REMOTE_INFO *findRemote(int whose, char *remoteName) {ICTA_REMOTE_INFO *pstRemote;ST_BOOLEAN bFound = SD_FALSE; pstRemote = pstVCC->remoteList; while (pstRemote && !bFound) { if (strcmp(pstRemote->remoteName, remoteName) == 0) bFound = SD_TRUE; else pstRemote = (ICTA_REMOTE_INFO *) list_get_next ((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote); } if (pstRemote) { if ( (whose == ICTA_CLIENT) && !pstRemote->bIsClient) pstRemote = NULL; if ( (whose == ICTA_SERVER) && !pstRemote->bIsServer) pstRemote = NULL; } return pstRemote; }/************************************************************************//* findOutWhichLink: get linkName, search links and return ptr *//************************************************************************/ICTA_LINK_INFO *findOutWhichLink(ICTA_REMOTE_INFO **pstRemote) {ST_BOOLEAN dataEntered;ST_CHAR buffer[256];ICTA_LINK_INFO *pstLink;ST_BOOLEAN bFound = SD_FALSE;ICTA_REMOTE_INFO *pstRemoteList, *pstRem; printf("\nEnter Link Name: "); dataEntered = strget(buffer); if (!dataEntered) return NULL; pstRemoteList = *pstRemote; pstRem = pstRemoteList; while (pstRem && !bFound) { pstLink = pstRem->linkList; while (pstLink && !bFound) { if (strcmp(pstLink->linkName, buffer) == 0) { bFound = SD_TRUE; *pstRemote = pstRem; } else pstLink = (ICTA_LINK_INFO *) list_get_next ((ST_VOID *)pstRem->linkList, (ST_VOID *)pstLink); } if (!bFound) pstRem = (ICTA_REMOTE_INFO *) list_get_next ((ST_VOID *)pstRemoteList, (ST_VOID *)pstRem); } return pstLink; }/************************************************************************//* findOutWhichVar: input var name and search selected var list for it *//************************************************************************/ICTA_VAR_INFO *findOutWhichVar(ICTA_REMOTE_INFO *pstRemote, int who) {ST_BOOLEAN dataEntered;ST_CHAR buffer[256];ICTA_VAR_INFO *pstVar, *theVarList;ST_BOOLEAN bFound = SD_FALSE; printf("\nEnter Variable Name: "); dataEntered = strget(buffer); if (!dataEntered) return NULL; if (who == ICTA_CLIENT) theVarList = pstRemote->clientObj->variableList; else theVarList = pstRemote->serverObj->variableList; pstVar = theVarList; while (pstVar && !bFound) { if (strcmp(pstVar->varName, buffer) == 0) bFound = SD_TRUE; else pstVar = (ICTA_VAR_INFO *) list_get_next ((ST_VOID *)theVarList, (ST_VOID *)pstVar); } return pstVar; }/************************************************************************//* findVar: search selected remote var list for var name *//************************************************************************/ICTA_VAR_INFO *findClientVar(ICTA_REMOTE_INFO *pstRemote, icChar *varName) {ICTA_VAR_INFO *pstVar;ST_BOOLEAN bFound = SD_FALSE; pstVar = pstRemote->clientObj->variableList;; while (pstVar && !bFound) { if (strcmp(pstVar->varName, varName) == 0) bFound = SD_TRUE; else pstVar = (ICTA_VAR_INFO *) list_get_next ((ST_VOID *)pstRemote->clientObj->variableList, (ST_VOID *)pstVar); } return pstVar; }/************************************************************************//* findVarType: recv toolkit type constant and return type name *//************************************************************************/static char rtnJunk[]="NonStandardType!";char *findVarType(int iccpType) {int i = 0;icBoolean bDone = icFalse;char *rtnVal = rtnJunk; while (i<NUM_STD_TYPES && !bDone) { if (typeConvTable[i].constant == iccpType) { rtnVal = typeConvTable[i].name; bDone = icTrue; } i++; } return (rtnVal); }/************************************************************************//* findServerMsg: search server msg list for nRef *//************************************************************************/ICTA_MSG_INFO *findServerMsg(int nRef, ICTA_REMOTE_INFO *pstRemote) {ST_BOOLEAN bDone = SD_FALSE;ICTA_MSG_INFO *pstMsg, *msgList; msgList = pstRemote->serverObj->infoMsgsList; pstMsg = msgList; while (pstMsg && !bDone) { if (pstMsg->nRef == nRef) bDone = SD_TRUE; else pstMsg = (ICTA_MSG_INFO *) list_get_next ((ST_VOID *)msgList, (ST_VOID *)pstMsg); } return pstMsg; } /************************************************************************//* findClientDevice: search remote device list for device name *//************************************************************************/ICTA_DEVICE *findClientDevice(char *deviceName, ICTA_REMOTE_INFO *pstRemote) {ICTA_DEVICE *pstDevice;ST_BOOLEAN bDone = SD_FALSE; pstDevice = pstRemote->clientObj->devicesList; while (pstDevice && !bDone) { if (strcmp(pstDevice->name, deviceName) == 0) bDone = SD_TRUE; else pstDevice = (ICTA_DEVICE *) list_get_next ((ST_VOID *)pstRemote->clientObj->devicesList, (ST_VOID *)pstDevice); } return pstDevice; }/************************************************************************//* findServerDevice: search all server remotes for named device *//************************************************************************/ICTA_DEVICE *findServerDevice(char *deviceName) {ICTA_REMOTE_INFO *pstRemote;ICTA_DEVICE *pstDevice;ST_BOOLEAN bDone = SD_FALSE; pstRemote = pstVCC->remoteList; while (pstRemote && !bDone) { pstDevice = pstRemote->serverObj->devicesList; while (pstDevice && !bDone) { if (strcmp(deviceName, pstDevice->name) == 0) bDone = SD_TRUE; else pstDevice = (ICTA_DEVICE *) list_get_next ((ST_VOID *)pstRemote->serverObj->devicesList, (ST_VOID *)pstDevice); } pstRemote = (ICTA_REMOTE_INFO *) list_get_next ((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote); } return pstDevice;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -