home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / 3COMM.ZIP / H.ZIP / NMPIPE.H < prev    next >
C/C++ Source or Header  |  1989-05-17  |  5KB  |  144 lines

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