home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 3.ddi / OS2LAN / CTPIPES.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-18  |  5.4 KB  |  176 lines

  1. /*
  2.  *    OS/2 Lan Manager using named pipes version of c-tree server
  3.  *
  4.  * CTPIPES.H
  5.  *
  6.  * Written by Personlige Systemer Norge A.S
  7.  *            Waldmar Thranes gate 77
  8.  *            0175 OSLO 1
  9.  *            NORWAY
  10.  *            Phone: +47 2 113550
  11.  *
  12.  *            Carl Henrik Bache 
  13.  *            Februar 1989
  14.  *
  15.  */
  16.  
  17. /*
  18.  * This file included in all sources for NAMED PIPES SUPPORT
  19.  *  In sources handeling pipes (ctsmsg.c & ctamsg.c) include:
  20.  *  - Server side of pipe
  21.  *      #define INCL_SERVERPIPE
  22.  *      #include "ctpipes.h"
  23.  *  - Client side of pipe 
  24.  *      #define INCL_CLIENTPIPE
  25.  *      #include "ctpipes.h"
  26.  */
  27.  
  28.  
  29.  
  30. #ifdef INCL_DOSNMPIPES   /* This define i set if MS SDK 1.06 include files */
  31.  
  32. /*
  33.  * DosNamedPipes API Support from Microsoft SDK Toolkit 1.06
  34.  * This is copied from <net\nmpipe.h> included with
  35.  * 3Com Lan-Manager 1.0 release
  36.  * Microsoft SDK Toolkit 1.06 does not have these defines yet ? ! ?
  37.  */
  38.  
  39. /**************************************************************** 
  40.  *
  41.  *          Special values and constants
  42.  *
  43.  ****************************************************************/
  44.  
  45. /* defined bits in pipe mode */
  46. #define    NP_NBLK        0x8000            /* non-blocking read/write */
  47. #define    NP_SERVER    0x4000            /* set if server end */
  48. #define    NP_WMESG    0x0400            /* write messages */
  49. #define    NP_RMESG    0x0100            /* read as messages */
  50. #define    NP_ICOUNT    0x00FF            /* instance count field */
  51.  
  52.  
  53. /*    Named pipes may be in one of several states depending on the actions
  54.  *    that have been taken on it by the server end and client end.  The
  55.  *    following state/action table summarizes the valid state transitions:
  56.  *
  57.  *    Current state        Action            Next state
  58.  *
  59.  *     <none>            server DosMakeNmPipe    DISCONNECTED
  60.  *     DISCONNECTED        server connect        LISTENING
  61.  *     LISTENING        client open            CONNECTED
  62.  *     CONNECTED        server disconn        DISCONNECTED
  63.  *     CONNECTED        client close        CLOSING
  64.  *     CLOSING        server disconn        DISCONNECTED
  65.  *     CONNECTED        server close        CLOSING
  66.  *     <any other>        server close        <pipe deallocated>
  67.  *
  68.  *    If a server disconnects his end of the pipe, the client end will enter a
  69.  *    special state in which any future operations (except close) on the file
  70.  *    descriptor associated with the pipe will return an error.
  71.  */
  72.  
  73. /*
  74.  *    Values for named pipe state
  75.  */
  76.  
  77. #define    NP_DISCONNECTED    1        /* after pipe creation or Disconnect */
  78. #define    NP_LISTENING    2        /* after DosNmPipeConnect */
  79. #define    NP_CONNECTED    3        /* after Client open */
  80. #define    NP_CLOSING    4        /* after Client or Server close */
  81.  
  82.  
  83. #endif
  84.  
  85.  
  86.  
  87.  
  88. /*
  89.  *  - 0 for local use (running as background task)  "\PIPE\pipename"
  90.  *  - 1 for LAN-server is to be used                "\\SERVER\PIPE\pipename"
  91.  */ 
  92. #define ct_srv_use    0       /* server or local use  */
  93.         /*
  94.          * This could be modified to an external variables
  95.          * to be set to server or local use at startup 
  96.          */
  97.  
  98. #define  SRV_NETNAME  "SERVER" /* server network name */
  99. #define  USR_NETNAME  "USER"   /* user net name */
  100. #define  USR_NAME_LEN  20      /* Maximum user name length */
  101. /* must be the same as UNLEN in NETCONS.H */
  102.  
  103. #define  ISAM_PIPENAME    "\\PIPE\\CTPIPE" /* name of pipe to communicate */
  104.  
  105. #define  ISAM_SRV_PROGNAME "CTSRVR.EXE"   /* ig. ctsrvr.exe */
  106. /* default argument to server-program */
  107. #define  ISAM_SRV_PARAMS   "CTSRVR\0U30 F90 Z4096\0\0"
  108.  
  109.  
  110. #define  PIPESIZE         4096             /* maximum pipe size, used at open */
  111. #define  CLI_OPENFLAG     1
  112. #define  CLI_DOSOPENMODE  0x4012
  113. #define  SRV_DOSOPENMODE  2
  114. #define  SRV_PIPOPENMODE  (NP_WMESG | NP_RMESG | NP_ICOUNT)    
  115. #define  PIPE_TIMEOUT     50L
  116.  
  117.  
  118. /* 
  119.  * Function codes for the pipe-communication
  120.  */
  121. #define  PIPE_TEST          0xFEEF4321
  122. #define  PIPE_ANSW          0xFEEF1234
  123. #define  PIPE_TERM_SRV      0xFEEFEFFE
  124.  
  125. #define  PIPE_ERR_NO_ANSW          800
  126. #define  PIPE_STARTED_LOCAL        810
  127. #define  PIPE_ERR_COULD_NOT_START  811
  128.  
  129. #define  NAMESIZE    64
  130.  
  131. /*
  132.  * PROTOTYPES
  133.  */
  134. extern unsigned _CDECL makepipe(unsigned *handle, char *pipename);
  135. extern unsigned _CDECL startusepipe(char *pipename,
  136.                                     char *prog, char *prog_param, int local);
  137. extern unsigned _CDECL sendlogonreply(unsigned handle);
  138. extern unsigned _CDECL dopipe(char *pname,
  139.                               char far *pipe_inp, unsigned ilen,
  140.                               char far *pipe_outp);
  141. extern unsigned _CDECL startpipe(char *pname, char *pargs);
  142. extern unsigned _CDECL readpipe(unsigned handle, char far *buffer);
  143. extern unsigned _CDECL writepipe(unsigned handle,
  144.                                  char far *buffer, unsigned len);
  145. extern unsigned _CDECL disconnect_pipe(unsigned handle);
  146. extern char*    _CDECL get_net_user_name(void);
  147. extern char*    _CDECL get_net_computer_name(void);
  148. extern void     _CDECL set_max_file_handles(int maxfh);
  149. extern int      _CDECL get_process_type(void);
  150. extern int      _CDECL get_process_id(void);
  151. extern int      _CDECL get_curr_screen_group(void);
  152. extern void     _CDECL set_exec_priority(int max_min);
  153. extern char*    _CDECL get_time_stamp(void);
  154. extern char*    _CDECL konvert_drive_to_local(char *filename);
  155. extern unsigned _CDECL stfarmov(char far *src, char far *dest, unsigned n);
  156. extern int      _CDECL get_os2_version(void);
  157.  
  158. extern unsigned pipe_errcode;
  159.  
  160. #ifdef INCL_CLIENTPIPE
  161.  
  162. static char pipename[NAMESIZE];
  163.  
  164. #endif
  165.  
  166.  
  167. #ifdef INCL_SERVERPIPE
  168.  
  169. static char pipename[NAMESIZE];
  170.  
  171. #endif
  172.  
  173.  
  174.  
  175.  
  176.