📄 ictatran.c
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//* (c) Copyright Systems Integration Specialists Company, Inc., *//* 1996-1998, All Rights Reserved *//* *//* MODULE NAME : ICTATRAN.C *//* *//* MODULE DESCRIPTION : *//* handle transfer group functions *//* *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : *//* ST_VOID defCfgTrans (ST_VOID) *//* ST_VOID defNewTrans (ST_VOID) *//* ST_VOID showTranSummary (ST_VOID) *//* void doGetDataSetNames (void) *//* *//* *//* MODIFICATION LOG : *//* Date Who Rev Comments *//* -------- --- ------ ------------------------------------------- *//* 08/22/02 nav 9 Fix printf parameter (Tru64Unix warning) *//* 08/05/02 nav 8 watch for nulls *//* 05/22/00 nav 7 Add getDataSetNames *//* 05/09/00 nav 6 Use StartTime in icDefineTransferGroup *//* 03/24/98 nav 5 Add ctrlTranGroup *//* 01/19/98 EJV 4 Added typecast in list functions. *//* 06/20/97 nav 3 Overhaul - One process can be client& server *//* 06/05/97 nav 2 Convert to MMS-EASE V7.00 *//* 04/04/97 nav 1 change starttime for tran group *//* 12/27/96 NAV creation *//************************************************************************/#include "ictamain.h"#include "scrndefs.h"#include "gvaldefs.h"#include "fkeydefs.h"/************************************************************************//* Global and Local variables *//************************************************************************/static char *thisFileName = __FILE__;/************************************************************************//* Static Function Declarations *//************************************************************************/static void ctrlTranGroupCB (icTransferGroupId tranGroupId, icBoolean bOperational);static ICTA_TRANSFER_INFO *findTranGroup (icTransferGroupId tranId);void getDataSetsCallBack(icLinkId link, icInt status, icInt scope, icInt numberNames, icChar **nameList, icBoolean last);/************************************************************************//* defCfgTrans: define configured transfer groups *//************************************************************************/ST_VOID defCfgTrans (ST_VOID) { printf("\n\nDefine Configured Transfer Groups . . .\n"); if (doDefTranGroups() != SD_SUCCESS) printf("\nErrors defining Transfer Groups - See log file for details."); pause_msg("\nPress a key to continue!"); showCurrMenu(); }/************************************************************************//* defNewTrans: define a new transfer group *//************************************************************************/ST_VOID defNewTrans (ST_VOID) { printf("\n\n****** SORRY! defNewTrans Just a Stub!"); pause_msg("\nPress a key to continue!"); showCurrMenu(); }/************************************************************************//* showTranSummary: display summary of define transfer groups *//************************************************************************/ST_VOID showTranSummary (ST_VOID) { printf("\n\n****** SORRY! showTranSummary Just a Stub!"); pause_msg("\nPress a key to continue!"); showCurrMenu(); }/************************************************************************//* ctrlTranGroup: call icControlTransferGroup */ /************************************************************************/void ctrlTranGroup (void) {ST_BOOLEAN dataEntered, bFound = SD_FALSE;ST_INT tranRef;ICTA_TRANSFER_INFO *pstTran;ICTA_REMOTE_INFO *pstRemote;ST_CHAR buffer[100];icBoolean bEnable; printf("\nEnter Remote Name: "); dataEntered = strget(buffer); if (!dataEntered) { pause_msg("\nPress a key to continue!"); showCurrMenu(); return; } pstRemote = findRemote(ICTA_CLIENT, buffer); if (!pstRemote) { printf("\nInvalid Remote Name!!!!!\n\n"); pause_msg("\nPress a key to continue!"); showCurrMenu(); return; } printf("\nEnter Transfer Group Reference #: "); if (!(dataEntered = intget(&tranRef))) { pause_msg("\nPress a key to continue!"); showCurrMenu(); return; } pstTran = pstRemote->clientObj->tranGroupList; while (pstTran && !bFound) { if (pstTran->nRef == tranRef) bFound = SD_TRUE; else { pstTran = (ICTA_TRANSFER_INFO *) list_get_next ((ST_VOID *)pstRemote->clientObj->tranGroupList, (ST_VOID *)pstTran); } } if (!bFound) { printf ("\nTransfer Group %d not found.", tranRef); pause_msg ("\nPress a key to continue."); showCurrMenu(); return; } printf ("\nEnter E)nable or D)isable: "); dataEntered = strget(buffer); if (!dataEntered) { pause_msg("\nPress a key to continue!"); showCurrMenu(); return; } if ( (buffer[0] == 'd') || (buffer[0] == 'D') ) bEnable = icFalse; else if ( (buffer[0] == 'e') || (buffer[0] == 'E') ) bEnable = icTrue; else { printf ("\nInvalid selection %s", buffer); pause_msg("\nPress a key to continue!"); showCurrMenu(); return; } icControlTransferGroup (pstTran->transferGroupId, bEnable, ctrlTranGroupCB); printf ("\nicControlTransferGroup has been called."); pause_msg("\nPress a key to continue!"); showCurrMenu(); }/************************************************************************//* doDefTranGroups: do the real define transfer groups work here *//************************************************************************/ST_RET doDefTranGroups(ST_VOID) {ICTA_REMOTE_INFO *pstRemote;ICTA_LINK_INFO *pstLink;ICTA_TRANSFER_INFO *pstTran;ICTA_VAR_LIST *pstVarList;icInt status;ST_RET rtnVal = SD_SUCCESS;icLong startTime;icVariableId theVars[5000];struct timeval tp;int i; pstRemote = pstVCC->remoteList; while (pstRemote ) { if (!pstRemote->bRemoteDefined || !pstRemote->bIsClient) { pstRemote = (ICTA_REMOTE_INFO *) list_get_next ((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote); continue; } pstTran = pstRemote->clientObj->tranGroupList; while (pstTran) { pstLink = findLink (pstRemote, pstTran->linkName); if (pstLink) { if (!pstTran->bGroupDefined) { if (pstTran->bUseStartTime) startTime = pstTran->startTime; else if (pstTran->nStartBuf > 0) { gettimeofday (&tp, (void *) NULL); startTime = tp.tv_sec+pstTran->nStartBuf; } else startTime = 0; pstVarList = pstTran->varList; pstTran->numVars = list_get_sizeof(pstVarList); for (i=0; i<pstTran->numVars; i++) { theVars[i] = pstVarList->pstVariable->varId; pstVarList = (ICTA_VAR_LIST *) list_get_next ((ST_VOID *)pstTran->varList, (ST_VOID *)pstVarList); } status = icDefineTransferGroup(pstLink->linkId, pstTran->bPeriodic, pstTran->nPerInterval, pstTran->nPerOffset, pstTran->bExceptOnly, pstTran->nBufInterval, pstTran->nIntegInterval, pstTran->bCritical, (void*)&startTime, &theVars[0], pstTran->numVars, transRejectCallBack, &pstTran->transferGroupId); if (status) { ICA_Log_Err2("ERROR: DefineTransferGroup status=%d %s\n", status, icPerror(status)); rtnVal = SD_FAILURE; } else { ICA_Log_Flow0("TransferGroup started OK"); pstTran->bGroupDefined = icTrue; } } /* end if !bGroupDefined */ } /* end if pstLink */ pstTran = (ICTA_TRANSFER_INFO *) list_get_next ((ST_VOID *)pstRemote->clientObj->tranGroupList, (ST_VOID *)pstTran); } /* end while pstTran */ pstRemote = (ICTA_REMOTE_INFO *) list_get_next ((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote); } /* end while pstRemote */ return rtnVal; }/************************************************************************//* Transfer Group Call Back Functions *//************************************************************************//* transRejectCallBack: Called by API if transfer group is rejected *//************************************************************************/void transRejectCallBack(icInt status, icLinkId linkid ) { printf("*** Transfer group rejected.\n"); pause_msg("\nPress a key to continue!"); }/************************************************************************//* ctrlTranGroupCB: control transfer group call back function *//************************************************************************/static void ctrlTranGroupCB (icTransferGroupId tranGroupId, icBoolean bOperational) {ICTA_TRANSFER_INFO *pstTran; pstTran = findTranGroup (tranGroupId); if (pstTran) { printf ("\n\nControlTranfserGroupCallBack:"); printf ("\n\t Transfer Group %d is %s", pstTran->nRef, bOperational ? "Enabled" : "Disabled"); } else { printf ("\n\nControlTransferGroupCallBack: unknown transfer group (%p)", tranGroupId); } ICA_Log_Always2 ("ctrlTranGroupCB: group=%p, operation=%d", tranGroupId, bOperational); } /************************************************************************//* findTranGroup: *//************************************************************************/static ICTA_TRANSFER_INFO *findTranGroup (icTransferGroupId tranId) {ICTA_REMOTE_INFO *pstRemote;ICTA_TRANSFER_INFO *pstTran;ST_BOOLEAN bFound = SD_FALSE; pstRemote = pstVCC->remoteList; while (pstRemote && !bFound) { if (pstRemote->bIsClient) { pstTran = pstRemote->clientObj->tranGroupList; while (pstTran && !bFound) { if (pstTran->transferGroupId == tranId) bFound = SD_TRUE; else { pstTran = (ICTA_TRANSFER_INFO *) list_get_next ((ST_VOID *)pstRemote->clientObj->tranGroupList, (ST_VOID *)pstTran); } } } pstRemote = (ICTA_REMOTE_INFO *) list_get_next ((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote); } return (pstTran); }/************************************************************************//* doGetDataSetNames: call TK API icGetDataSetNames *//************************************************************************/void doGetDataSetNames (void) {ICTA_LINK_INFO *pstLink;ICTA_REMOTE_INFO *pstRemote;ST_BOOLEAN dataEntered;ST_CHAR buffer[100];ST_CHAR varName[MAX_ID_LEN];icInt status, scope;ST_BOOLEAN bIsClient = SD_FALSE; varName[0] = '\0'; printf("\n\nGet Data Set Names . . .\n"); pstRemote = pstVCC->remoteList; while (pstRemote && !bIsClient) { bIsClient = pstRemote->bIsClient; pstRemote = (ICTA_REMOTE_INFO *) list_get_next ((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote); } if (!bIsClient) { printf("Client not defined - get Data Set names option not available.\n"); pause_msg("Press a key to continue!\n"); showCurrMenu(); return; } pstRemote = pstVCC->remoteList; pstLink = findOutWhichLink(&pstRemote); if (!pstLink) { printf ("Invalid LinkName"); pause_msg("Press a key to continue!\n"); showCurrMenu(); return; } printf("\nEnter Start After Data Set Name: "); dataEntered = strget(varName); printf("\nEnter V=VMD Scope or D=Domain Scope: "); dataEntered = strget(buffer); if (!dataEntered || ( (buffer[0]!='V') && (buffer[0]!='D') ) ) { pause_msg("\nPress a key to continue!"); showCurrMenu(); return; } if (buffer[0] == 'D') scope = IC_SCOPE_DOMAIN; else scope = IC_SCOPE_VMD; status = icGetDataSetNames(pstLink->linkId, scope, varName, getDataSetsCallBack); if (status) { printf("Get Data Set Names Failed - see log file for details.\n"); ICA_Log_Err2("ERROR: GetDataSetNames status = %d %s", status, icPerror(status)); ICA_Log_ErrC2(" Link = %s, Var=%s", pstLink->linkName, varName); } }/*************************************************************************//* getDataSetsCallBack: Called by API *after* fetching list of dataSets *//*************************************************************************/void getDataSetsCallBack(icLinkId link, icInt status, icInt scope, icInt numberNames, icChar **nameList, icBoolean last) {int i ; if (status != IC_OK) { printf("\n\n getDataSetNames status %d - %s\n", status,icPerror(status)); ICA_Log_Err2("ERROR: getDataSetNames Resp status = %d %s", status, icPerror(status)); return; } printf("\n\nGetDataSetNames Response:"); printf("\n\t%d %s DataSet Names Received", numberNames, scope == IC_SCOPE_VMD ? "VMD" : "DOMAIN"); if (numberNames == 0 || nameList == NULL) { printf("No Data Sets returned.\n"); } else { for(i=0; i<numberNames; i++) { printf("\n%s DataSet %2d: '%s' ", scope==IC_SCOPE_VMD?"VMD":"DOMAIN",i+1,*nameList++) ; } if (last) { printf("\n<<< All %s DataSet(s) received >>> ", scope==IC_SCOPE_VMD?"VMD":"DOMAIN"); } else { printf("\n<<< More %s DataSet(s) to follow >>> ", scope==IC_SCOPE_VMD?"VMD":"DOMAIN"); } } pause_msg("\nPress a key to continue!"); showCurrMenu(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -