home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / business / clockin2.zip / OEMDATA.C_ / OEMDATA.bin
Text File  |  1993-09-03  |  28KB  |  739 lines

  1. /*
  2.                 Final Specification for the OEM Direct Link Interface
  3.                     (c) 1993 Mission Critical Software
  4.  
  5. Fast direct links are possible between your cooperating Windows program
  6. and Clock-IN!  By signing a limited agreement you can arrange a free license
  7. to use and distribute this program when you sell Clock-IN! with it as
  8. a bundle.  By using global shared memory, your Terminal Server program
  9. will enjoy the fasted possible bi-directional communication with
  10. Clock-IN!'s time engine.
  11.  
  12. All you have to do to implement your terminal server is convert your
  13. existing terminal a) communications, and b) terminal key definition
  14. downloading code.  Then paste it into this program and test directly
  15. with Clock-IN!
  16.  
  17. Two global shared memory handles are allocated by Clock-IN! as follows under
  18. Windows:
  19.  
  20.     HGLOBAL hGlobalInputData,hGlobalResponseBuffer;
  21.  
  22. The OEM program should not allocate the memory, but it does need to declare
  23. the handles above.
  24.  
  25. Your Windows program must have a Window which handles I/O to Clock-IN!
  26. During WM_CREATE (or WM_INITDIALOG) for that window you will get the
  27. handle to ClockIN!'s "ClockInput" window, and send your Window handle.
  28. You post a message with your Window Handle and Clock-IN! responds by
  29. sending you the handles to the global shared memory objects.
  30.  
  31. As transactions become available through this OEM program, you fill the
  32. global buffer as indicated by IDD_SENDDATA.  Be sure the data is per
  33. the specification in the manual on page 130.  EXCEPT that enclosing
  34. the data fields in quotations marks" is PURELY optional.  Clock-IN!
  35. strips these marks anyway and uses strtok(",") to break the buffer into
  36. data fields.  There must be exactly the 14 commas separating the 15
  37. data fields, however.
  38.  
  39. When Clock-IN! receives data, it processes the data and clears the first byte
  40. of the global memory buffer.  Your program is sent an IDD_ACK, which is
  41. qualified with a response string buffer that you can send back to your
  42. terminal user, if desired.  When the OEM program receives the ACK, reset your flag
  43. WAITINGFORCLOCKIN to false.
  44.  
  45. This working program follows per the above specifications, and does it
  46. all for you.  So you can cut and paste your code into this Windows
  47. program.
  48.  
  49. TIP-Your program downloads function key definitions and prompts to the
  50. terminals, almost exactly like the pre-defined function keys, prompts
  51. and validation file defintions in Clock-IN's two files, funckeys.db
  52. and valfiles.db.  RUN OFF THE TWO REPORTS NAMED FUNCKEYS and VALFILES
  53. so you know how to define the prompts for CLOCK_IN!, and what files to
  54. download for validation.
  55.  
  56. Or use Comm, Function Keys Browse, to browse the table of the definitions.
  57.  
  58. OPTIONAL FEATURES-Full adjustments, debits/credits, absence entries, etc.
  59. all from your terminals.
  60.  
  61. This program supports the following structure, which
  62. you can design into your initial implementation if you wish.  You can
  63. pass this structure to Clock-IN! to do Adjustments. See the
  64. A)ctions, A)dustments pulldown menu item.  All the screens therein allow
  65. the user to do numerous time adjustments.  For you to provide these
  66. functions at your terminal, simply design the transactions, and fill in this
  67. simple structure. Tran_types are DCR for debit/credit, ADJ for force
  68. pay hours today to a number, NTE for note, ABS for absence.
  69.  
  70. You'll get a handle to load the structure to global memory, and then
  71. send a message to Clock-IN! to process it.
  72.  
  73. */
  74.  
  75. #define SIZEOFTIME 24
  76. #define SIZEOFTRANSACCESS 52
  77. #define SIZEOFPW 9
  78. #define SIZEOFDATENTIME 9
  79.  
  80. #define SIZEOFBADGE 14
  81. #define SIZEID 13
  82.  
  83. #define SIZEOFCHARGE 17
  84. #define InputArraySize 17
  85.  
  86. #define SIZEOFTRANSTYPE 4
  87. #define SIZEOFUSERNOTE 80
  88.  
  89. typedef struct
  90.     {
  91.       char id[SIZEOFBADGE];
  92.       char supervisor[SIZEOFBADGE];
  93.       char pw[SIZEOFBADGE];
  94.       char note[100];
  95.       char postdate[SIZEOFDATENTIME];
  96.       char absence[10];
  97.       float abshours;
  98.       char debit[SIZEOFCHARGE];
  99.       float debithours;
  100.       char credit[SIZEOFCHARGE];
  101.       float credithours;
  102.       char forcechg[SIZEOFCHARGE];
  103.       float forcehours;
  104.       char tran_type[4];
  105.       char posttime[SIZEOFDATENTIME];
  106.     } adjustment;
  107. adjustment tranadj;
  108.  
  109.  
  110. #define STRICT
  111. #include <windows.h>
  112.  
  113. #ifdef __cplusplus
  114. #error  This should compile as a C program
  115. #endif
  116. #ifdef __BORLANDC__
  117. #pragma argsused       /* This pragma is used for Borland C++ */
  118. #endif
  119. #include <ctype.h>
  120. #include <dos.h>
  121. #include <errno.h>
  122. #include <time.h>
  123. #include <stdio.h>
  124. #include <string.h>
  125.  
  126. #define IDS_ERR_REGISTER_CLASS   1
  127. #define IDS_ERR_CREATE_WINDOW    2
  128. LONG FAR PASCAL WndProc(HWND, WORD, WORD, LONG);
  129. int nCwRegisterClasses(void);
  130. void CwUnRegisterClasses(void);
  131. BOOL putGlobalAdjustment(void);
  132. HWND hActive;
  133. char szAppName[14];
  134. HINSTANCE hInst=0;
  135. HWND hWndMain=0;
  136. char szString[256];
  137. HWND gethandlewindow(void);
  138. BOOL CALLBACK AboutDlgProc( HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam );
  139. BOOL getGlobal(void);
  140.  
  141. #define IDD_SENDDATA 2100
  142. #define IDD_SENDADJ  2101
  143. #define IDD_EXIT     2102
  144.  
  145. BOOL getOEMdata(char *yourdata,int bufsize);
  146. BOOL putOEMdata(char *yourdata);
  147. BOOL WAITINGFORCLOCKIN=FALSE;
  148. HWND hClockin,hOEMWindow;
  149. HGLOBAL hGlobalInputData,hGlobalResponseBuffer,hGlobalAdjustData;
  150. #define IDD_MEM         9000
  151. #define IDD_DATAREADY 9002
  152. #define IDD_OEMWINDOW 9003
  153. #define IDD_ACK       9004
  154. #define IDD_ABOUT      999
  155. #define IDD_RECONNECT  9001
  156. #define IDD_CLOCKINQUIT 9008
  157. #define IDD_RESPONSEBUFFER 9009
  158. #define IDD_ADJUSTBUFFER 9010
  159. #define IDD_ACKADJ       9011
  160. #define IDD_ADJDATAREADY 9012
  161.  
  162. #define ACCEPT_MOVE     0   // figurehours totals, stamp up the time
  163. #define ACCEPT_NOMOVE   1
  164. #define REJECT_NOMOVE   2   // no figurehours, carryfwd last stamp
  165. #define BADID           3
  166. #define BADSUPERVISORPW 4
  167. #define QUEUED          5
  168. #define BADFORMAT       6
  169. #define OLDERTRAN       7
  170.  
  171. #define ACCESSFAIL 1
  172. #define IDFAIL     2
  173. #define DATEFAIL   3
  174. #define ADJUSTOK   0
  175.  
  176. FILE *fp;
  177. char termdata[256];
  178. char szDisplayString[100];
  179. char respondbuf[64];
  180.  
  181. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
  182. {
  183.  /***********************************************************************/
  184.  /* HANDLE hInstance;       handle for this instance                    */
  185.  /* HANDLE hPrevInstance;   handle for possible previous instances      */
  186.  /* LPSTR  lpszCmdLine;     long pointer to exec command line           */
  187.  /* int    nCmdShow;        Show code for main window display           */
  188.  /***********************************************************************/
  189.  
  190.     MSG        msg;           /* MSG structure to store your messages        */
  191.     int        nRc;           /* return value from Register Classes          */
  192.     long       nWndunits;     /* window units for size and location          */
  193.     int        nWndx;         /* the x axis multiplier                       */
  194.     int        nWndy;         /* the y axis multiplier                       */
  195.     int        nX;            /* the resulting starting point (x, y)         */
  196.     int        nY,i;
  197.     int        nWidth;        /* the resulting width and height for this     */
  198.     int        nHeight;       /* window                                      */
  199.     BOOL Msgprocessed;
  200.  
  201.     hActive=GetActiveWindow();
  202.     strcpy(szAppName,"OEMDATA\0");
  203.     hInst = hInstance;
  204.     if(!hPrevInstance)
  205.         {
  206.     /* register window classes if first instance of application         */
  207.         if ((nRc = nCwRegisterClasses()) == -1)
  208.             {
  209.        /* registering one of the windows failed                         */
  210.             LoadString(hInst, IDS_ERR_REGISTER_CLASS, szString, sizeof(szString));
  211.             MessageBox(NULL, szString, NULL, MB_ICONEXCLAMATION);
  212.             return nRc;
  213.             }
  214.         } else
  215.         {
  216.         return 1;
  217.         } ;
  218.     nWndunits = GetDialogBaseUnits();
  219.     nWndx = LOWORD(nWndunits);
  220.     nWndy = HIWORD(nWndunits);
  221.     nX = 0; // ((1 * nWndx) / 4);
  222.     nY = 0; // ((1 * nWndy) / 8);
  223.     nWidth = ((236 * nWndx) / 4);
  224.     nHeight = ((83 * nWndy) / 8);
  225.  
  226.     hWndMain = CreateWindow(
  227.         //   WS_EX_TOPMOST   ,       //  extended box to force topmost window
  228.         //szButtonClassName,
  229.            szAppName,               /* Window class name           */
  230.            "OEM Data Interface",             /* Window's title              */
  231.            WS_CAPTION      |        /* Title and Min/Max           */
  232.            WS_SYSMENU      |        /* Add system menu box         */
  233.            WS_MINIMIZEBOX  |        /* Add minimize box            */
  234.            WS_MAXIMIZEBOX  |        /* Add maximize box            */
  235.            WS_THICKFRAME   |        /* thick sizeable frame        */
  236.            WS_CLIPCHILDREN |         /* don't draw in child windows areas */
  237.            WS_OVERLAPPED,
  238.            nX, nY,                  /* X, Y                        */
  239.            nWidth, nHeight,         /* Width, Height of window     */
  240.            NULL,                    /* Parent window's handle      */
  241.            NULL,                    /* Default to Class Menu       */
  242.            hInst,                   /* Instance of window          */
  243.            NULL);                   /* Create struct for WM_CREATE */
  244.  
  245.     if(hWndMain == NULL)
  246.         {
  247.         LoadString(hInst, IDS_ERR_CREATE_WINDOW, szString, sizeof(szString));
  248.         MessageBox(NULL, szString, NULL, MB_ICONEXCLAMATION);
  249.         return IDS_ERR_CREATE_WINDOW;
  250.         }
  251.  
  252.     ShowWindow(hWndMain, nCmdShow);            /* display main window      */
  253.     //putenv("TZ=GMT0   ");  // otherwise it compensates to EST, and makes it 5 hours off
  254.     while ( GetMessage( &msg, NULL, 0, 0 ) )  // if any messages, place it in msg
  255.         {
  256.         Msgprocessed=FALSE;
  257.  
  258.         if (! Msgprocessed ) //message dropped without being processed
  259.             // produces WM_CHAR msgs only for ASCII characters
  260.             {
  261.             TranslateMessage( &msg );
  262.             // dispatch the message to main window
  263.             DispatchMessage( &msg );
  264.             }
  265.         }
  266.  
  267.  /* Do clean up before exiting from the application                     */
  268.     CwUnRegisterClasses();
  269.     return msg.wParam;
  270. } /*  End of WinMain                                                    */
  271.  
  272.  
  273. /************************************************************************/
  274. /*                                                                      */
  275. /* Main Window Procedure                                                */
  276. /************************************************************************/
  277.  
  278. LONG FAR PASCAL WndProc(HWND hWnd, WORD Message, WORD wParam, LONG lParam)
  279. {
  280.  
  281.     char *s;
  282.     HDC hDC;
  283.     PAINTSTRUCT ps;
  284.     char *p;
  285.     int dataok;
  286.     unsigned long timemark;
  287.     unsigned long ticktimer;
  288.  
  289.     switch (Message)
  290.         {
  291.         case WM_COMMAND:
  292.  
  293.             switch (wParam)
  294.                 {
  295.  
  296.                 case IDD_SENDDATA:
  297.                     //one of your terminals triggered this message and you
  298.                     //have data ready
  299.                     respondbuf[0]='\0';
  300.                     if (hClockin==NULL || WAITINGFORCLOCKIN )
  301.                         {
  302.                         //CLOCKIN could have quit or terminated input
  303.                         //while the User is doing massive adjustments
  304.                         //in this latter case, you should only retry every
  305.                         //several seconds, not continuously
  306.                         //CLOCKIN will restore the input window when the
  307.                         //user is done
  308.                         strcpy(szDisplayString,"Lost connection,retrying");
  309.                         InvalidateRect(hWnd,NULL,TRUE);
  310.                         //retry to establish link
  311.                         hClockin=gethandlewindow();            //get clockins window
  312.                         InvalidateRect(hWnd,NULL,TRUE);
  313.                         if (hClockin!=NULL)
  314.                             PostMessage(hClockin,WM_COMMAND, IDD_OEMWINDOW, (long) hWnd);
  315.                         break;
  316.                         }
  317.                     if (!WAITINGFORCLOCKIN)
  318.                         {
  319.                         //sample program reads from a file, instead of from your terminals
  320.                         termdata[0]=';';
  321.                         while (termdata[0]==';')
  322.                         {
  323.                         s=fgets(termdata,256,fp);
  324.                         if (s==NULL)
  325.                             {
  326.                             strcpy(szDisplayString,"Input file exhausted");
  327.                             break;
  328.                             }
  329.                         }
  330.                         if (strlen(termdata)<2) break;
  331.  
  332.                         //must have null terminated string,overwriting here the carriage return \x0A
  333.                         p=strchr(termdata,10);
  334.                         *p='\0';
  335.                             //sample 1st line is
  336.                             //"0","05/17/93","06:53:12","ATO","B100","","","","","","","","","",""
  337.                             //tries until global memory freed
  338.                         timemark=GetTickCount()+5000;
  339.                         dataok=FALSE;
  340.                         while ( !dataok && timemark>GetTickCount()  )
  341.                             dataok=putOEMdata(termdata);
  342.                         if (dataok)
  343.                             {
  344.                             WAITINGFORCLOCKIN=TRUE;
  345.                             strcpy(szDisplayString,"Sent data record");
  346.                             }
  347.                             else
  348.                             {
  349.                             strcpy(szDisplayString,"Unable to send data record");
  350.                             PostMessage(hWnd,WM_COMMAND,IDD_RECONNECT,0L);
  351.                             }
  352.                         InvalidateRect(hWnd,NULL,TRUE);
  353.                         }
  354.                     break;
  355.  
  356.                 case IDD_SENDADJ:
  357.                     //one of your terminals triggered this message and you
  358.                     //have data ready
  359.                     respondbuf[0]='\0';
  360.                     if (hClockin==NULL || WAITINGFORCLOCKIN )
  361.                         {
  362.                         strcpy(szDisplayString,"Lost connection,retrying");
  363.                         InvalidateRect(hWnd,NULL,TRUE);
  364.                         //retry to establish link
  365.                         hClockin=gethandlewindow();            //get clockins window
  366.                         InvalidateRect(hWnd,NULL,TRUE);
  367.                         if (hClockin!=NULL)
  368.                             PostMessage(hClockin,WM_COMMAND, IDD_OEMWINDOW, (long) hWnd);
  369.                         break;
  370.                         }
  371.                     if (!WAITINGFORCLOCKIN)
  372.                         {
  373.                         //sample program creates an adjustment
  374.                         strcpy(tranadj.id,"B100");
  375.                         strcpy(tranadj.supervisor,"SUPERVIS");
  376.                         strcpy(tranadj.pw,"MASTER");
  377.                         strcpy(tranadj.note,"Test adjustment");
  378.                         strcpy(tranadj.postdate,"08/31/93");
  379.                         strcpy(tranadj.tran_type,"ABS");
  380.                         strcpy(tranadj.absence,"AE");
  381.                         tranadj.abshours=2.0;
  382.                         
  383.                         timemark=GetTickCount()+5000;
  384.                         dataok=FALSE;
  385.                         while ( !dataok && timemark>GetTickCount()  )
  386.                             dataok=putGlobalAdjustment();
  387.                         if (dataok)
  388.                             {
  389.                             WAITINGFORCLOCKIN=TRUE;
  390.                             strcpy(szDisplayString,"Sent adjust record");
  391.                             }
  392.                             else
  393.                             {
  394.                             strcpy(szDisplayString,"Unable to send adjust record");
  395.                             PostMessage(hWnd,WM_COMMAND,IDD_RECONNECT,0L);
  396.                             }
  397.                         InvalidateRect(hWnd,NULL,TRUE);
  398.                         }
  399.                     break;
  400.  
  401.  
  402.                 case IDD_RECONNECT:
  403.                         //retry to establish link
  404.                     hGlobalInputData=NULL;
  405.                     hClockin=NULL;
  406.                     hGlobalAdjustData;
  407.                     hClockin=gethandlewindow();            //get clockins window
  408.                     InvalidateRect(hWnd,NULL,TRUE);
  409.                     if (hClockin!=NULL)
  410.                         PostMessage(hClockin,WM_COMMAND, IDD_OEMWINDOW, (long) hWnd);
  411.                     break;
  412.  
  413.                 case IDD_MEM:
  414.                     hGlobalInputData=(HGLOBAL) lParam;
  415.                     strcpy(szDisplayString,"Connected to Clock-IN!");
  416.                     InvalidateRect(hWnd,NULL,TRUE);
  417.                     break;
  418.  
  419.                 case IDD_RESPONSEBUFFER:
  420.                     hGlobalResponseBuffer=(HGLOBAL) lParam;
  421.                     break;
  422.  
  423.                 case IDD_ADJUSTBUFFER:
  424.                     hGlobalAdjustData=(HGLOBAL) lParam;
  425.                     break;
  426.  
  427.                 case IDD_CLOCKINQUIT:
  428.                     hGlobalInputData=NULL;
  429.                     hClockin=NULL;
  430.                     hGlobalAdjustData=NULL;
  431.                     strcpy(szDisplayString,"Clock-IN! quit");
  432.                     //set timer for reconnect attempt
  433.                     ticktimer=GetTickCount()+10000;
  434.                     WAITINGFORCLOCKIN=FALSE;
  435.                     break;
  436.  
  437.                 case IDD_ACKADJ:
  438.                     getGlobal();
  439.                     strcpy(szDisplayString,"Ack for adjustment received");
  440.                     if (!respondbuf[0])
  441.                         strcpy(respondbuf,"Ack w/Nothing in reponse buffer");
  442.                     else
  443.                         respondbuf[0]='\0';
  444.                     //do whatever you want with the return values
  445.                     WAITINGFORCLOCKIN=FALSE;
  446.                     switch ( (int) lParam)
  447.                     {
  448.                     case ADJUSTOK:
  449.                           strcat(szDisplayString,"/Adjust OK");
  450.                         break;
  451.                     case ACCESSFAIL:
  452.                         strcat(szDisplayString,"/Permission Denied");
  453.                         break;
  454.                     case IDFAIL:
  455.                         strcat(szDisplayString,"/Bad employee badge");
  456.                         break;
  457.                     case DATEFAIL:
  458.                         strcat(szDisplayString,"/Bad date or format");
  459.                         break;
  460.                     case QUEUED:
  461.                           //had to queue transaction for later processing
  462.                         strcat(szDisplayString,"/Queued");
  463.                         break;
  464.                     default:
  465.                         break;
  466.                     }
  467.                     InvalidateRect(hWnd,NULL,TRUE);
  468.                     break;
  469.  
  470.                 case IDD_ACK:
  471.                     //look in the global buffer to get any text explanation
  472.                     //that can be sent back to the terminal user
  473.                     getGlobal();
  474.                     if (!respondbuf[0])
  475.                         strcpy(respondbuf,"Ack w/Nothing in reponse buffer");
  476.                     strcpy(szDisplayString,"Ack");
  477.                     InvalidateRect(hWnd,NULL,TRUE);
  478.                     WAITINGFORCLOCKIN=FALSE;
  479.                     //look in the lParam for the error code
  480.                     switch ( (int) lParam )
  481.                         {
  482.                         case ACCEPT_MOVE:
  483.                             //processed the transaction,moved the employee clock
  484.                             //message is in respondbuf
  485.                             strcat(szDisplayString,"/Accept/moved");
  486.                             break;
  487.                         case ACCEPT_NOMOVE:
  488.                             //processed the transaction,did not move the employee clock
  489.                             //message is in respondbuf
  490.                             strcat(szDisplayString,"/Accept/nomove");
  491.                             break;
  492.                         case REJECT_NOMOVE:
  493.                             //rejected the transaction,did not move the employee clock
  494.                             //rejection reason is in respondbuf
  495.                             strcat(szDisplayString,"/Reject/nomove");
  496.                             break;
  497.                         case BADID:
  498.                             //bad badge ID failure
  499.                             strcat(szDisplayString,"/BadID");
  500.                             break;
  501.                         case BADSUPERVISORPW:
  502.                             //override transaction failed with bad username/password
  503.                             strcat(szDisplayString,"/BadOverride");
  504.                             break;
  505.                         case QUEUED:
  506.                             //had to queue transaction for later processing
  507.                             strcat(szDisplayString,"/Queued");
  508.                             break;
  509.                         case BADFORMAT:
  510.                             strcat(szDisplayString,"/Bad format");
  511.                             break;
  512.                         case OLDERTRAN:
  513.                             //the employee clock is past that date & time
  514.                             //you cant send an older transaction, you must
  515.                             //use an adjustment
  516.                             strcat(szDisplayString,"/Older tran");
  517.                             break;
  518.                         default:
  519.                             break;
  520.                         }
  521.                     break;
  522.  
  523.                 case IDD_ABOUT:
  524.                     Modalbox( (LPSTR) "ABOUT", (FARPROC) AboutDlgProc, TRUE);
  525.                     break;
  526.  
  527.                 case IDD_EXIT:
  528.                     PostMessage(hWnd,WM_CLOSE,0,0L);
  529.                     break;
  530.                 }
  531.             break;
  532.  
  533.         case WM_CREATE:
  534.             //handshaking
  535.             respondbuf[0]='\0';
  536.             fp=fopen("importta.txt","r");
  537.             hClockin=gethandlewindow();            //get clockins window
  538.             InvalidateRect(hWnd,NULL,TRUE);
  539.             if (hClockin==NULL)
  540.                 {
  541.                      //couyld optionally quit here
  542.                      //PostMessage(hWnd,WM_CLOSE,0,0L);  //cant get a connection, quit
  543.                 }
  544.                 else
  545.                 //notify Clock-IN! of your Window Handle!
  546.                 //it will send back the global data handle
  547.                 PostMessage(hClockin,WM_COMMAND, IDD_OEMWINDOW, (long) hWnd);
  548.             MoveWindow(hWnd,200,200,420,80,TRUE);
  549.             return 0;
  550.  
  551.         case WM_PAINT:
  552.             hDC =    BeginPaint(hWnd, &ps);
  553.             SetBkMode(hDC, OPAQUE);
  554.             SetTextColor(hDC,GetSysColor(COLOR_WINDOWTEXT));
  555.             SetBkColor(hDC,GetSysColor(COLOR_BTNFACE));
  556.             if(szDisplayString[0])
  557.                 TextOut(hDC,0,0,szDisplayString,lstrlen(szDisplayString));
  558.             if (respondbuf[0]);
  559.                 TextOut(hDC,0,18,respondbuf,lstrlen(respondbuf));
  560.             EndPaint(hWnd, &ps);
  561.             break;
  562.  
  563.         case WM_CLOSE:  /* close the window                                 */
  564.             fclose(fp);
  565.             if (hWnd == hWndMain)
  566.                 PostQuitMessage(0);  /* Quit the application                 */
  567.             break;
  568.  
  569.         default:
  570.             return DefWindowProc(hWnd, Message, wParam, lParam);
  571.         }
  572.     return 0L;
  573. }
  574.  
  575.  
  576.     //**********************************************************************************
  577. BOOL putOEMdata(char *yourdata)
  578. {
  579.     LPSTR lpv;
  580.     if (WAITINGFORCLOCKIN) return FALSE;
  581.     lpv=GlobalLock(hGlobalInputData);
  582.     if (lpv==NULL) return FALSE;              //failed to put the data
  583.         //before you copy the data to the buffer, make sure the buffer
  584.         //is empty, other Clock-IN! input processes, including DDE use
  585.         //the buffer, and the Clock-IN! processor may not have grabbed
  586.         //the input there yet
  587.     if (lpv[0]!=NULL)
  588.         {
  589.         GlobalUnlock(hGlobalInputData);
  590.         return FALSE;
  591.         }
  592.     yourdata[lstrlen(yourdata)+1]='\0';   //insure terminating null
  593.     _fmemcpy(lpv,(LPSTR) yourdata,lstrlen(yourdata)+1 );
  594.     GlobalUnlock(hGlobalInputData);
  595.     //lParam must be 1, so Clock-IN! can recognize your processs
  596.     PostMessage(hClockin,WM_COMMAND,IDD_DATAREADY,1L);
  597.     return TRUE;
  598. }
  599.  
  600.  
  601.     //**********************************************************************************
  602. BOOL getGlobal(void)
  603. {
  604.     LPSTR lpv;
  605.     lpv=GlobalLock(hGlobalResponseBuffer);
  606.     if (lpv==NULL)
  607.         return FALSE;              //failed to get the data
  608.     _fmemcpy((LPSTR) respondbuf,lpv,64 );
  609.     //clear the buffer, in case you get it back again
  610.     lpv[0]='\0';
  611.     GlobalUnlock(hGlobalResponseBuffer);
  612.     return TRUE;
  613. }
  614.  
  615.     //**********************************************************************************
  616. BOOL getOEMdata(char *yourdata,int bufsize)
  617. {
  618.     LPSTR lpv;
  619.     lpv=GlobalLock(hGlobalInputData);
  620.     if (lpv==NULL) return FALSE;              //failed to get the data
  621.     _fmemcpy((LPSTR) yourdata,lpv,bufsize );
  622.     yourdata[bufsize]='\0';
  623.         //clear the buffer for use by other processes
  624.     lpv[0]='\0';
  625.     GlobalUnlock(hGlobalInputData);
  626.     PostMessage(hOEMWindow,WM_COMMAND,IDD_ACK,0L);
  627.     return TRUE;
  628. }
  629.  
  630. //**********************************************************************************
  631. BOOL putGlobalAdjustment(void)
  632. {   LPSTR lpv;
  633.     lpv=GlobalLock(hGlobalAdjustData);
  634.     if (lpv==NULL) return FALSE;              //failed to put the data
  635.     if (lpv[0]!=NULL)
  636.         {
  637.         GlobalUnlock(hGlobalInputData);
  638.         return FALSE;
  639.         }
  640.     _fmemcpy(lpv,(LPSTR) &tranadj,sizeof(adjustment) );
  641.     GlobalUnlock(hGlobalAdjustData);
  642.     PostMessage(hClockin,WM_COMMAND,IDD_ADJDATAREADY,1L);
  643.     return TRUE;
  644. }
  645.  
  646. //****************************************************************************************
  647. HWND gethandlewindow(void)
  648. {
  649.     HWND hwndNext;
  650.     char workbuf[256];
  651.  
  652.     hwndNext=GetWindow(GetActiveWindow(),GW_HWNDFIRST);   //hwndMain your main wdo
  653.     while (hwndNext)
  654.         {
  655.         GetWindowText(hwndNext,(LPSTR)workbuf,256);
  656.         if (strcmp(workbuf,"ClockInput")==0) return hwndNext;
  657.         hwndNext=GetWindow(hwndNext,GW_HWNDNEXT);
  658.         }
  659.     strcpy(szDisplayString,"Clock-IN! is not running, cannot establish link");
  660.     return NULL;
  661. }
  662.  
  663.  
  664. //***************************************************************************************
  665. void CwUnRegisterClasses(void)
  666. {
  667.     WNDCLASS   wndclass;
  668.     memset(&wndclass, 0x00, sizeof(WNDCLASS));
  669.     UnregisterClass(szAppName, hInst);
  670. }
  671.  
  672. //*****************************************************************************************
  673. int nCwRegisterClasses(void)
  674. {
  675.     WNDCLASS   wndclass;//,buttonwindowclass;    /* struct to define a window class             */
  676.     memset(&wndclass, 0x00, sizeof(WNDCLASS));
  677.  /* load WNDCLASS with window's characteristics                         */
  678.     wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW;
  679.     wndclass.lpfnWndProc = WndProc;
  680.  /* Extra storage for Class and Window objects                          */
  681.     wndclass.cbClsExtra = 0;
  682.     wndclass.cbWndExtra = 0;
  683.     wndclass.hInstance = hInst;
  684.     wndclass.hIcon = LoadIcon(hInst, "OEMDATA\0");
  685.     wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  686.  /* Create brush for erasing background                                 */
  687.     wndclass.hbrBackground = (HBRUSH)( GetStockObject(LTGRAY_BRUSH) );
  688.     wndclass.lpszMenuName = szAppName;
  689.     wndclass.lpszClassName = szAppName; /* Class Name is App Name */
  690.     if(!RegisterClass(&wndclass))
  691.         return -1;
  692.     return(0);
  693. }
  694.  
  695. BOOL CALLBACK AboutDlgProc( HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam )
  696. {
  697.     switch ( iMessage )
  698.         {
  699.  
  700.         case WM_INITDIALOG:
  701.             return TRUE;
  702.  
  703.         case WM_COMMAND:
  704.  
  705.             if ( wParam == IDOK )
  706.                 {
  707.                 EndDialog( hDlg, TRUE );
  708.                 return TRUE;
  709.                 }
  710.             break;
  711.  
  712.         case WM_CLOSE:
  713.             EndDialog( hDlg, 0 );
  714.             break;
  715.         }
  716.  
  717.     return FALSE;
  718. }
  719.  
  720. BOOL Modalbox( LPSTR TemplateName, FARPROC FunctionName, BOOL modal)
  721. {
  722.     DLGPROC lpfn;
  723.     int retval;
  724.     HWND hWnd;
  725.     if ( (lpfn=(DLGPROC) MakeProcInstance( (FARPROC) FunctionName, hInst))==NULL)
  726.         {
  727.         return FALSE;
  728.         }
  729.     if (modal) hWnd=hWndMain; else hWnd=GetActiveWindow();
  730.                  //must use getactivewindow to make modal frames work
  731.     if ( (retval=DialogBox( hInst, (LPSTR) TemplateName, hWnd, lpfn )) ==-1)
  732.         {
  733.         retval=FALSE;
  734.         }
  735.         else retval=TRUE;
  736.     FreeProcInstance( (FARPROC)lpfn );
  737.     return retval;
  738. }
  739.