home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / comos2.zip / COMM.H next >
Text File  |  1993-02-21  |  4KB  |  115 lines

  1. /**************************************************************************
  2.  *
  3.  *  COMM.H
  4.  *
  5.  *  This file contains the header file needed to compile COMM16.C and
  6.  *  COMM32.C.  This file should not be included in source code which
  7.  *  wishes to use the CommOS2 library.
  8.  *_________________________________________________________________________
  9.  *
  10.  *  Copyright (c) 1992 by ASH Software, Inc.
  11.  *
  12.  *  Update History
  13.  *
  14.  *    12/ 6/1992 - Module created
  15.  *
  16.  **************************************************************************/
  17.  
  18. #if !defined(COMM__H)
  19.   #define COMM__H
  20.  
  21.   #define INCL_DOS
  22.   #define INCL_ERRORS
  23.   #define INCL_DOSDEVIOCTL
  24.   #define INCL_DOSDEVICES
  25.   
  26.   #include <os2.h>
  27.   #include <stdio.h>
  28.   #include <stdlib.h>
  29.   
  30.   #include "COMMOS2.H"
  31.  
  32.   //
  33.   // This library uses a number of semaphores to serialize access to
  34.   // resources.  The following variable determines how long to wait 
  35.   // before returning to the calling program with an error.  The
  36.   // definition contains the length of time (in msec) to wait for
  37.   // the semaphore.  In addition, the definition SEM_INDEFINITE_WAIT
  38.   // may be used to wait forever and SEM_IMMEDIATE_RETURN to return
  39.   // without waiting.
  40.   //
  41.  
  42.   #define COMMOS2_RESOURCE_SEM_WAIT     5000L  // Wait 5 seconds
  43.  
  44.   #define COMM_QUERY_RXCOUNT             1
  45.   #define COMM_QUERY_RXBUFFER            2
  46.   #define COMM_QUERY_TXCOUNT             3
  47.   #define COMM_QUERY_TXBUFFER            4
  48.  
  49.   #if defined(INCL_COMMOS2_16BIT)
  50.     static DOSFSRSEM hCommSem;
  51.     #define CommGetStruct         COMMSTRUCT16
  52.     #define TimerValue            TIMERVALUE16
  53.     #define TimerDifference       TIMERDIFFERENCE16
  54.     #define CommQueryQueue        COMMQUERYQUEUE16
  55.   #endif
  56.  
  57.   #if defined(INCL_COMMOS2_32BIT)
  58.     static HMTX hCommSem;
  59.     #define CommGetStruct         COMMSTRUCT32
  60.     #define TimerValue            TIMERVALUE32
  61.     #define TimerDifference       TIMERDIFFERENCE32
  62.     #define CommQueryQueue        COMMQUERYQUEUE32
  63.   #endif
  64.  
  65.   //
  66.   // Define the Comm library error structure and declare an external
  67.   // pointer to an array of these structures.  The static global pointer 
  68.   // will be allocated during processing of CommStartSystem and freed
  69.   // during processing of CommStopSystem.
  70.   //
  71.   
  72.   typedef struct
  73.   {
  74.   DCBINFO DCBOriginal;     
  75.   DCBINFO DCBInfo;               // Port DCB Info
  76.   #if defined(INCL_COMMOS2_32BIT)
  77.     HMTX hCommWriteSem;
  78.     HMTX hCommReadSem;
  79.   #endif
  80.   #if defined(INCL_COMMOS2_16BIT)
  81.     DOSFSRSEM hCommWriteSem;
  82.     DOSFSRSEM hCommReadSem;
  83.   #endif
  84.   ULONG ulCommErrorCode;         // Last Comm error code
  85.   ULONG ulDosErrorCode;          // Last Dos error code
  86.   ULONG ulCommMode;              // Last Comm mode
  87.   USHORT usBaudRate;             // Initial baud rate
  88.   USHORT usParity;               // Initial parity
  89.   USHORT usDataBits;             // Initial databits
  90.   USHORT usStopBits;             // Initial stopbits
  91.   USHORT usTxBreak;              // Initial Tx Break
  92.   HFILE hCommPortFile;           // Handle to Comm port
  93.   int fPortOpened;               // An attempt to open the port was made
  94.   int fPortOpen;                 // Comm port is actually open
  95.   } COMMOS2_STRUCT;
  96.   typedef COMMOS2_STRUCT *PCOMMOS2_STRUCT;
  97.   
  98.   static PCOMMOS2_STRUCT
  99.     pCommOS2Struct;
  100.  
  101.   static int
  102.     iMaxNumberCommPorts = 0;
  103.  
  104.   //
  105.   // Declare static functions
  106.   //
  107.  
  108.   static PCOMMOS2_STRUCT CommGetStruct(HCOMMPORT hCommPort);
  109.   static ULONG TimerValue(void);
  110.   static ULONG TimerDifference(ULONG ulBaseTimerValue);
  111.   static ULONG CommQueryQueue(HCOMMPORT hCommPort,short sMode,
  112.     ULONG *ulValue);
  113.  
  114. #endif
  115.