home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / sna / msendrcv / msend.h < prev    next >
Text File  |  1997-04-09  |  9KB  |  179 lines

  1. /* msend.h */
  2. /* (C) COPYRIGHT DATA CONNECTION LIMITED 1994 */
  3.  
  4. /*****************************************************************************/
  5. /* Change History                                                            */
  6. /*                                                                           */
  7. /*       11/01/94 DK  Created                                                */
  8. /*       14/04/94 DK  Name table added for tracing                           */
  9. /*****************************************************************************/
  10.  
  11. /*****************************************************************************/
  12. /* static configuration constants                                            */
  13. /*****************************************************************************/
  14. #define MAX_SEND_PER_THREAD 64
  15.  
  16. /*****************************************************************************/
  17. /* global critical section                                                   */
  18. /*****************************************************************************/
  19. CRITICAL_SECTION runsem;
  20.  
  21. /*****************************************************************************/
  22. /* APPC verb control block and macros for manipulation of vcb                */
  23. /*****************************************************************************/
  24. #define CLEARVCB memset(vcbptr,0,sizeof(VCB));
  25. #define P_TPS(X)    ((struct tp_started *)X)
  26. #define P_TPE(X)    ((struct tp_ended *)X)
  27.  
  28. #define P_M_ALC(X)  ((struct mc_allocate *)X)
  29. #define P_M_CNF(X)  ((struct mc_confirm *)X)
  30. #define P_M_DAL(X)  ((struct mc_deallocate *)X)
  31. #define P_M_SDD(X)  ((struct mc_send_data *)X)
  32.  
  33. typedef struct vcb
  34. {
  35.   union
  36.   {
  37.     struct appc_hdr             hdr;
  38.     struct tp_started           tpstart;
  39.     struct tp_ended             tpend;
  40.     struct mc_allocate          allocate;
  41.     struct mc_confirm           confirm;
  42.     struct mc_deallocate        deallocate;
  43.     struct mc_send_data         snddata;
  44.   } U_VCB;
  45. } VCB;
  46.  
  47. /*****************************************************************************/
  48. /* structures for convert verb                                               */
  49. /*****************************************************************************/
  50. struct convert cnvt;
  51. char * cnvtptr;
  52.  
  53. /*****************************************************************************/
  54. /* conversation control block - one per conversation                         */
  55. /*****************************************************************************/
  56. typedef struct convcb
  57. {
  58.   char           TPid[8];
  59.   char           type[8];
  60.   unsigned long  Convid;
  61.   HANDLE         async_corr;
  62.   char *         DataPtr;
  63.   unsigned short thread;
  64.   unsigned short conv;
  65.   unsigned short SendSize;
  66.   unsigned short SendCount;
  67.   unsigned short ConfirmCount;
  68.   BOOL           TPEnded;
  69.   BOOL           Deallocated;
  70.   BOOL           Counted;
  71.   HANDLE         hEvent;
  72.   VCB            vcb;
  73. } CONVCB;
  74.  
  75. /*****************************************************************************/
  76. /* File Names and handle for trace file                                      */
  77. /*****************************************************************************/
  78. char FileName [60];
  79. char TraceFile[60];
  80. FILE *t = NULL;
  81.  
  82. /*****************************************************************************/
  83. /* APPC Names from configuration file                                        */
  84. /*****************************************************************************/
  85. char TPName[64];
  86. char LocalTPName[64];
  87. char LocalLUAlias[8];
  88. char RemoteLUAlias[8];
  89. char ModeName[8];
  90. char RemoteTPName[64];
  91.  
  92. /*****************************************************************************/
  93. /* Global Variables from configuration file                                  */
  94. /*****************************************************************************/
  95. unsigned short NumSends;
  96. unsigned short SendSize;
  97. unsigned short NumSendConvs;
  98. unsigned short ConfirmEvery;
  99.  
  100. /*****************************************************************************/
  101. /* Global Variables                                                          */
  102. /*****************************************************************************/
  103. unsigned short NumRalcs;                /* number of receive_allocs issued   */
  104. unsigned short ThreadCount;             /* total thread count                */
  105. unsigned short SendThreads;             /* count of send threads             */
  106. unsigned short SimSendConvs;            /* number of simultaneous send convs */
  107. unsigned short SendConvs;               /* number of send convs completed    */
  108.  
  109. /*****************************************************************************/
  110. /* Names of verbs for tracing                                                */
  111. /*****************************************************************************/
  112. char *VerbName[] =
  113. {
  114.   "UNKNOWN_VERB",                       /* 0x0000                            */
  115.   "MC_ALLOCATE",                        /* 0x0001                            */
  116.   "UNKNOWN_VERB",                       /* 0x0002                            */
  117.   "MC_CONFIRM",                         /* 0x0003                            */
  118.   "MC_CONFIRMED",                       /* 0x0004                            */
  119.   "MC_DEALLOCATE",                      /* 0x0005                            */
  120.   "MC_FLUSH",                           /* 0x0006                            */
  121.   "MC_GET_ATTRIBUTES",                  /* 0x0007                            */
  122.   "UNKNOWN_VERB",                       /* 0x0008                            */
  123.   "UNKNOWN_VERB",                       /* 0x0009                            */
  124.   "MC_PREPARE_TO_RECEIVE",              /* 0x000a                            */
  125.   "MC_RECEIVE_AND_WAIT",                /* 0x000b                            */
  126.   "MC_RECEIVE_IMMEDIATE",               /* 0x000c                            */
  127.   "MC_RECEIVE_AND_POST",                /* 0x000d                            */
  128.   "MC_REQUEST_TO_SEND",                 /* 0x000e                            */
  129.   "MC_SEND_DATA",                       /* 0x000f                            */
  130.   "MC_SEND_ERROR",                      /* 0x0010                            */
  131.   "UNKNOWN_VERB",                       /* 0x0011                            */
  132.   "MC_TEST_RTS",                        /* 0x0012                            */
  133.   "TP_ENDED",                           /* 0x0013                            */
  134.   "TP_STARTED",                         /* 0x0014                            */
  135.   "UNKNOWN_VERB",                       /* 0x0015                            */
  136.   "RECEIVE_ALLOCATE",                   /* 0x0016                            */
  137.   "UNKNOWN_VERB",                       /* 0x0017                            */
  138.   "MC_SEND_CONVERSATION"                /* 0x0018                            */
  139. };
  140.  
  141. /*****************************************************************************/
  142. /* Character for filling buffer                                              */
  143. /*****************************************************************************/
  144. char datach;
  145.  
  146. /*****************************************************************************/
  147. /* Windows stuff                                                             */
  148. /*****************************************************************************/
  149. HWND hWndMain;
  150. char title[40]={'\0'};
  151. #define OUTPUTNUMBER sprintf(title,"thrd simS done  %d  %d  %d", \
  152.                      ThreadCount,SimSendConvs,SendConvs);  \
  153.                      SetWindowText(hWndMain,title);
  154.  
  155. /*****************************************************************************/
  156. /* Function Prototypes                                                       */
  157. /*****************************************************************************/
  158. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  159.                    LPSTR lpCmdLine, int nCmdShow);
  160. BOOL InitializeWinMain(HINSTANCE hInstance);
  161. LONG PASCAL TPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  162. void InitializeMain(void);
  163. BOOL IssueSendVerb(CONVCB * convptr);
  164. BOOL ProcessReturns(CONVCB * convptr);
  165. void ReadConfig(void);
  166. void CONV_A_TO_E(char * string,int length);
  167. void CONV_E_TO_A(char * string,int length);
  168. int  ReadString(char * lpValueName, char FAR * lpData, int maxlen);
  169. void PadString(char * string, int length);
  170. void Build_TP_STARTED(CONVCB * convptr);
  171. void Build_TP_ENDED(CONVCB * convptr);
  172. void Build_MC_ALLOCATE(CONVCB * convptr);
  173. void Build_MC_CONFIRM(CONVCB * convptr);
  174. void Build_MC_DEALLOCATE(CONVCB * convptr);
  175. void Build_MC_SEND_DATA(CONVCB * convptr);
  176. void GenerateData(CONVCB * convptr);
  177. DWORD WINAPI SendThread(DWORD k);
  178.  
  179.