home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / header45.zip / nmpipe.h < prev    next >
C/C++ Source or Header  |  1999-04-29  |  5KB  |  148 lines

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