⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ictainfo.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//*   (c) Copyright Systems Integration Specialists Company, Inc.,       *//*          1996-1998, All Rights Reserved                              *//*                                                                      *//* MODULE NAME : ICTAINFO.C                                            	*//*                                                                      *//* MODULE DESCRIPTION :                                                 *//*   handle information message functions				*//*                                                                      *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE :				*//*				ST_VOID defCfgMsgs (ST_VOID)		*//*				ST_VOID sendMsg (ST_VOID)		*//*									*//*                                                                      *//* MODIFICATION LOG :                                                   *//*  Date     Who   Rev                     Comments                     *//* --------  ---  ------   -------------------------------------------  *//* 08/22/02  nav    8      Fix printf - (Tru64Unix warning)             *//* 07/05/02  nav    7      doDefMsgs: watch for nulls                   *//* 09/18/00  nav    6      Send binary message				*//* 08/28/00  nav    5      Watch for bUseNewB4B8			*//* 06/03/99  nav    4      Add more flow logging for testing		*//* 01/19/98  EJV    3      Added typecast in list functions.		*//* 06/20/97  nav    2      Overhaul - One process can be client& server	*//* 06/05/97  nav    1      Convert to MMS-EASE V7.00			*//* 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 icInt localRef = 1000;static icInt seqNum = 0;static ST_CHAR buffer[512];/************************************************************************//*      Static Function Declarations                           		*//************************************************************************//************************************************************************//* defCfgMsgs:  define configured messages for the client and server	*//************************************************************************/ST_VOID defCfgMsgs (ST_VOID)  {int todo;  printf("\n\nDefine Configured Information Messages . . .\n");  todo = findOutWho();  switch (todo)    {    case ICTA_CLIENT:      if (doDefMsgs (ICTA_CLIENT, pstVCC->remoteList) == SD_SUCCESS)        printf ("Client Messages Defined.\n");      else	printf ("Define Client Messages Failed - See Log File.\n");    break;    case ICTA_SERVER:      if (doDefMsgs (ICTA_SERVER, pstVCC->remoteList) == SD_SUCCESS)        printf ("Server Messages Defined.\n");      else        printf ("Define Server Messages Failed - See Log File.\n");    break;    case ICTA_BOTH:      if (doDefMsgs (ICTA_SERVER, pstVCC->remoteList) == SD_SUCCESS)        printf ("Server Messages Defined.\n");      else        printf ("Define Server Messages Failed - See Log File.\n");      if (doDefMsgs (ICTA_CLIENT, pstVCC->remoteList) == SD_SUCCESS)        printf ("Client Messages Defined.\n");      else	printf ("Define Client Messages Failed - See Log File.\n");    break;    default:      printf ("NO MESSAGES defined.\n");    break;    }  pause_msg("\nPress a key to continue!");  showCurrMenu();  }/************************************************************************//* sendMsg:  server option to send infor message to client		*//************************************************************************/ST_VOID sendMsg (ST_VOID)  {icInt 			status;ST_INT 			nRef;ICTA_MSG_INFO 		*pstMsg;ICTA_REMOTE_INFO	*pstRemote;ICTA_LINK_INFO		*pstLink;ST_BOOLEAN		dataEntered, bIsServer = SD_FALSE;int i, bufLen;  printf("\n\nSend Information Messages . . .\n");  pstRemote = pstVCC->remoteList;  while (pstRemote && !bIsServer)    {    bIsServer = pstRemote->bIsServer;    pstRemote = (ICTA_REMOTE_INFO *) list_get_next		((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote);    }  if (!bIsServer)    {    printf("\n\nSERVER OPTION ONLY!!!!!");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }   printf("\nEnter Remote Name:  ");    dataEntered = strget(buffer);  if (!dataEntered)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  pstRemote = findRemote(ICTA_SERVER, buffer);  if (!pstRemote)    {    printf("\nInvalid Remote Name!!!!!\n\n");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  printf("\nEnter Reference Number of Message to Send:  ");  intget(&nRef);  pstMsg = findServerMsg((int) nRef, pstRemote);  if (!pstMsg)    {    printf("\nInvalid Message Ref Number.");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }   pstLink = findOutWhichLink(&pstRemote);  if (!pstLink)    {    printf("\nInvalid Link!!!");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }   printf("\nEnter the Message to Send:  ");  dataEntered = strget(buffer);  if (!dataEntered)    {    for (i=0; i< 127; i++)      memset (buffer+i, i+1, 1);    buffer[127] = '\0';    bufLen =128;    }  else    bufLen = strlen (buffer);  status = icSendMessage(pstLink->linkId, 			 pstMsg->msgId,			 pstMsg->nRef,			 localRef++,			 seqNum++,			 bufLen,		         (void *) buffer);  if (status)    {    ICA_Log_Err3("ERROR:  Send Message %d status = %d %s",                  pstMsg->nRef, status, icPerror(status));    printf("\n\nSend Message Failed - see log file for details.");    }  else    {    printf ("\n\n Message Sent OK.");    printf ("\n\tMessage Id = %d", seqNum-1);    printf ("\n\tLocalRef = %d", localRef-1);    printf ("\n\tMessage = %s", buffer);    ICA_Log_Flow0("Sent IM Message OK!");    ICA_Log_CFlow1 ("Message Id = %d", seqNum-1);    ICA_Log_CFlow1 ("LocalRef = %d", localRef-1);    ICA_Log_CFlow1 ("Message = %s", buffer);    }  pause_msg("\nPress a key to continue!");  showCurrMenu();  }/************************************************************************//* Static Functions for Information Messages . . .			*//************************************************************************//* doDefMsgs:  define messages for all remotes in remoteList		*//************************************************************************/ST_RET doDefMsgs(int who, ICTA_REMOTE_INFO *remoteList)  {ICTA_REMOTE_INFO *pstRemote;ICTA_MSG_INFO    *pstMsg, *pstMsgList;icInt		 status;ST_RET		 rtnVal = SD_SUCCESS;  pstRemote = remoteList;  while (pstRemote)    {    if (!pstRemote->bRemoteDefined)      {      pstRemote = (ICTA_REMOTE_INFO *) list_get_next		  ((ST_VOID *)remoteList, (ST_VOID *)pstRemote);      continue;      }    if (bUseNewB4B8)      {      if (who == ICTA_CLIENT)	setupB4Client (pstRemote);      else	setupB4Server (pstRemote);      pstRemote = (ICTA_REMOTE_INFO *) list_get_next		  ((ST_VOID *)remoteList, (ST_VOID *)pstRemote);      continue;      }    pstMsgList = NULL;    if (who == ICTA_CLIENT)      {      if (pstRemote->bIsClient)        pstMsgList = pstRemote->clientObj->infoMsgsList;      }    else      {      if (pstRemote->bIsServer)        pstMsgList = pstRemote->serverObj->infoMsgsList;      }    pstMsg = pstMsgList;    while (pstMsg)      {      if (!pstMsg->bMsgDefined)        {        switch (who)          {      	  case ICTA_CLIENT:	    status = icDefineClientMessage(pstRemote->remoteId,					   pstMsg->nRef,					   pstMsg->scope,					   pstMsg->maxMsgSize,					   &pstMsg->msgId,					   (icUserData) pstMsg,					   recvMsgCallBack);            if (status)	      {	      rtnVal = SD_FAILURE;	      ICA_Log_Err3("ERROR:  DefineClientMessage ref#=%d status = %d %s",	                   pstMsg->nRef, status, icPerror(status));	      }	    else	      pstMsg->bMsgDefined = icTrue;	    break;	  case ICTA_SERVER:	    status = icDefineServerMessage(pstRemote->remoteId,					   pstMsg->nRef,					   pstMsg->scope,					   pstMsg->maxMsgSize,					   &pstMsg->msgId,					   (icUserData) pstMsg,					   reqInfoMsgCallBack);            if (status)	      {	      rtnVal = SD_FAILURE;	      ICA_Log_Err3("ERROR:  DefineServerMessage ref#=%d status = %d %s",	                   pstMsg->nRef, status, icPerror(status));	      }	    else	      pstMsg->bMsgDefined = icTrue;	    break;	  }		/* end the switch	*/	}		/* end the if		*/      pstMsg = (ICTA_MSG_INFO *) list_get_next	       ((ST_VOID *)pstMsgList, (ST_VOID *)pstMsg);      }			/* end while pstMsg	*/    pstRemote = (ICTA_REMOTE_INFO *) list_get_next		((ST_VOID *)remoteList, (ST_VOID *)pstRemote);    }			/* end while pstRemote	*/  return rtnVal;  }/************************************************************************//* CallBack Function for Information Messages . . .			*//************************************************************************//* recvMsgCallBack:  Client Received a Message				*//* 		     called by API when receiv Info Message Objects 	*//************************************************************************/void recvMsgCallBack(icInt status, icInt infoRefNum, icInt localRef,     	   	     icInt messageId, icInt  msgSize, void *msgByteArrayPtr,                     icUserData  userData)  {  printf ("\n Client Info Message Received  \n");  printf ("\tInfoRefNum  %d\n", infoRefNum);  printf ("\tLocalRef    %d\n", localRef);  printf ("\tMessageId   %d\n", messageId);  printf ("\tMsgSize     %d\n", msgSize);  printf ("\tMessage content '%s'\n", (char *) msgByteArrayPtr );  ICA_Log_Flow3 ("Received Information Message %d, localRef=%d, message ID=%d",  		  infoRefNum, localRef, messageId);  ICA_Log_CFlow1 ("Message = %s", msgByteArrayPtr);  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }/************************************************************************//* reqInfoMsgCallBack:  called by API after receipt of a client request *//*		        to start or stop transferring information msgs	*//************************************************************************/void  reqInfoMsgCallBack(icInt status, icLinkId linkId, icBoolean startTransfer,    		         icUserData usrData)  {ICTA_MSG_INFO *pstMsg;  pstMsg = (ICTA_MSG_INFO *) usrData;  if (startTransfer)    {    printf ("Server IMTransfer Start for nRef = %d \n", pstMsg->nRef);    ICA_Log_Flow2 ("Server IMTransfer Start for nRef %d, status=%d",    		    pstMsg->nRef, status);    }  else    {    printf ("Server IMTransfer Stop for nRef = %d \n", pstMsg->nRef);    ICA_Log_Flow2 ("Server IMTransfer Stop for nRef %d, status=%d",    		    pstMsg->nRef, status);    }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -