home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warphead.zip / H / NMPIPE.H < prev    next >
C/C++ Source or Header  |  1997-09-05  |  5KB  |  146 lines

  1. /**************************************************************************/
  2. /*                                                                        */
  3. /*              IBM OS/2(tm) File and Print Client Services               */
  4. /* (c) Copyright International Business Machines Corporation, 1988, 1996  */
  5. /*                                                                        */
  6. /**************************************************************************/
  7.  
  8. /********************************************************************
  9.  *                                    *
  10.  *  About this file ...  NMPIPE.H                    *
  11.  *                                    *
  12.  *  This file contains information about the Named Pipe APIs.        *
  13.  *                                    *
  14.  *    Function prototypes.                        *
  15.  *                                    *
  16.  *    Data structure templates.                    *
  17.  *                                    *
  18.  *    Definition of special values.                    *
  19.  *                                    *
  20.  ********************************************************************/
  21.  
  22.  
  23. /**************************************************************** 
  24.  *                                *
  25.  *          Function prototypes                 *
  26.  *                                *
  27.  ****************************************************************/
  28.  
  29. extern API_FUNCTION
  30.   DosMakeNmPipe(char far *, unsigned far *, unsigned short, unsigned short,
  31.                 unsigned short, unsigned short, long);
  32.  
  33. extern API_FUNCTION
  34.   DosQNmPipeInfo(unsigned, unsigned short, char far *, unsigned short);
  35.  
  36. extern API_FUNCTION
  37.   DosConnectNmPipe(unsigned);
  38.  
  39. extern API_FUNCTION
  40.   DosDisconnectNmPipe(unsigned);
  41.  
  42. extern API_FUNCTION
  43.   DosQNmpHandState(unsigned, unsigned short far *);
  44.  
  45. extern API_FUNCTION
  46.   DosSetNmpHandState(unsigned, unsigned short);
  47.  
  48. extern API_FUNCTION
  49.   DosPeekNmPipe(unsigned, char far *, unsigned short, unsigned short far *,
  50.                 unsigned short far *, unsigned short far *);
  51.  
  52. extern API_FUNCTION
  53.   DosWaitNmPipe(char far *, long);
  54.  
  55. extern API_FUNCTION
  56.   DosTransactNmPipe(unsigned, char far *, unsigned short, char far *,
  57.                 unsigned short, unsigned short far *);
  58.  
  59. extern API_FUNCTION
  60.   DosCallNmPipe(char far *, char far *, unsigned short, char far *,
  61.                 unsigned short, unsigned short far *, long);
  62.  
  63. extern API_FUNCTION
  64.   DosSetNmPipeSem(unsigned, long, unsigned short);
  65.  
  66. extern API_FUNCTION
  67.   DosQNmPipeSemState(long, char far *, unsigned short);
  68.  
  69.  
  70. /**************************************************************** 
  71.  *                                *
  72.  *          Data structure templates            *
  73.  *                                *
  74.  ****************************************************************/
  75.  
  76.  
  77. struct    npi_data1 {    /* PipeInfo data block (returned, level 1) */
  78.     unsigned short    npi_obuflen;    /* length of outgoing I/O buffer */
  79.     unsigned short    npi_ibuflen;    /* length of incoming I/O buffer */
  80.     unsigned char    npi_maxicnt;    /* maximum number of instances */
  81.     unsigned char    npi_curicnt;    /* current number of instances */
  82.     unsigned char    npi_namlen;    /* length of pipe name */
  83.     char    npi_name[1];        /* start of name */
  84. };    /* npi_data1 */
  85.  
  86. struct    npss    {    /* QNmPipeSemState information record */
  87.     unsigned char    npss_status;    /* type of record, 0 = EOI, 1 = read ok,
  88.                      *   2 = write ok, 3 = pipe closed */
  89.     unsigned char    npss_flag;    /* additional info, 01 = waiting thread */
  90.     unsigned short    npss_key;    /* user's key value */
  91.     unsigned short    npss_avail;    /* available data/space if status = 1/2 */
  92. };    /* npss */
  93.  
  94. /* values in npss_status */
  95. #define    NPSS_EOI    0    /* End Of Information */
  96. #define    NPSS_RDATA    1    /* read data available */
  97. #define    NPSS_WSPACE    2    /* write space available */
  98. #define    NPSS_CLOSE    3    /* pipe in CLOSING state */
  99.  
  100. /* values in npss_flag */
  101. #define    NPSS_WAIT    0x01    /* waiting thread on other end of pipe */
  102.  
  103.  
  104. /**************************************************************** 
  105.  *                                *
  106.  *          Special values and constants            *
  107.  *                                *
  108.  ****************************************************************/
  109.  
  110. /* defined bits in pipe mode */
  111. #define    NP_NBLK        0x8000            /* non-blocking read/write */
  112. #define    NP_SERVER    0x4000            /* set if server end */
  113. #define    NP_WMESG    0x0400            /* write messages */
  114. #define    NP_RMESG    0x0100            /* read as messages */
  115. #define    NP_ICOUNT    0x00FF            /* instance count field */
  116.  
  117.  
  118. /*    Named pipes may be in one of several states depending on the actions
  119.  *    that have been taken on it by the server end and client end.  The
  120.  *    following state/action table summarizes the valid state transitions:
  121.  *
  122.  *    Current state        Action            Next state
  123.  *
  124.  *     <none>            server DosMakeNmPipe    DISCONNECTED
  125.  *     DISCONNECTED        server connect        LISTENING
  126.  *     LISTENING        client open            CONNECTED
  127.  *     CONNECTED        server disconn        DISCONNECTED
  128.  *     CONNECTED        client close        CLOSING
  129.  *     CLOSING        server disconn        DISCONNECTED
  130.  *     CONNECTED        server close        CLOSING
  131.  *     <any other>        server close        <pipe deallocated>
  132.  *
  133.  *    If a server disconnects his end of the pipe, the client end will enter a
  134.  *    special state in which any future operations (except close) on the file
  135.  *    descriptor associated with the pipe will return an error.
  136.  */
  137.  
  138. /*
  139.  *    Values for named pipe state
  140.  */
  141.  
  142. #define    NP_DISCONNECTED    1        /* after pipe creation or Disconnect */
  143. #define    NP_LISTENING    2        /* after DosNmPipeConnect */
  144. #define    NP_CONNECTED    3        /* after Client open */
  145. #define    NP_CLOSING    4        /* after Client or Server close */
  146.