home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / NAMEPIPE.LIB < prev    next >
Text File  |  1994-03-08  |  2KB  |  77 lines

  1. // NamePipe.lib - Some interfaces to named pipes
  2. // ver.1
  3.  
  4. #define NP_INDEFINITE_WAIT      -1
  5. #define NP_DEFAULT_WAIT         0
  6.  
  7. // DosPeekNmPipe() pipe states
  8.  
  9. #define NP_STATE_DISCONNECTED    0x0001
  10. #define NP_STATE_LISTENING       0x0002
  11. #define NP_STATE_CONNECTED       0x0003
  12. #define NP_STATE_CLOSING         0x0004
  13.  
  14. // DosCreateNPipe open modes
  15.  
  16. #define NP_ACCESS_INBOUND        0x0000
  17. #define NP_ACCESS_OUTBOUND       0x0001
  18. #define NP_ACCESS_DUPLEX         0x0002
  19. #define NP_INHERIT               0x0000
  20. #define NP_NOINHERIT             0x0080
  21. #define NP_WRITEBEHIND           0x0000
  22. #define NP_NOWRITEBEHIND         0x4000
  23.  
  24. // DosCreateNPipe and DosQueryNPHState state
  25.  
  26. #define NP_READMODE_BYTE         0x0000
  27. #define NP_READMODE_MESSAGE      0x0100
  28. #define NP_TYPE_BYTE             0x0000
  29. #define NP_TYPE_MESSAGE          0x0400
  30. #define NP_END_CLIENT            0x0000
  31. #define NP_END_SERVER            0x4000
  32. #define NP_WAIT                  0x0000
  33. #define NP_NOWAIT                0x8000
  34. #define NP_UNLIMITED_INSTANCES   0x00FF
  35.  
  36. #define ERROR_PIPE_NOT_CONNECTED 233
  37.  
  38. DosCreateNPipe(pszName,pHpipe,openmode,pipemode,cbInbuf,cbOutbuf,msec)
  39. {
  40.    #define ORD_DOS32CREATENPIPE  243
  41.    _rc = DynamicLink("doscalls",ORD_DOS32CREATENPIPE,BIT32,CDECL,
  42.                      pszName,_pHpipe,openmode,pipemode,cbInbuf,cbOutbuf,msec);
  43.    pHpipe = _pHpipe;
  44.    return(_rc);
  45. }
  46.  
  47. DosConnectNPipe(hpipe)
  48. {
  49.    #define ORD_DOS32CONNECTNPIPE 241
  50.    return DynamicLink("doscalls",ORD_DOS32CONNECTNPIPE,BIT32,CDECL,hpipe);
  51. }
  52.  
  53. DosDisConnectNPipe(hpipe)
  54. {
  55.    #define ORD_DOS32DISCONNECTNPIPE 242
  56.    return DynamicLink("doscalls",ORD_DOS32DISCONNECTNPIPE,BIT32,CDECL,hpipe);
  57. }
  58.  
  59. DosSetNPHState(hpipe,newState)
  60. {
  61.    #define ORD_DOS32SETNPHSTATE  250
  62.    return DynamicLink("doscalls",ORD_DOS32SETNPHSTATE,BIT32,CDECL,hpipe,newState);
  63. }
  64.  
  65. DosTransactNPipe(hpipe,pOutbuf,cbOut,pInbuf,cbIn,pcbRead)
  66. {
  67.    #define ORD_DOS32TRANSACTNPIPE   252
  68.    // Make sure that input buffer area is big enough
  69.    if ( !defined(pInbuf)  ||  BLObSize(pInbuf) < cbIn )
  70.       BLObSize(pInBuf,cbIn);
  71.    lrc = DynamicLink("doscalls",ORD_DOS32TRANSACTNPIPE,BIT32,CDECL,
  72.                      hpipe,pOutbuf,cbOut,pInbuf,cbIn,_pcbRead);
  73.    pcbRead = defined(_pcbRead) ? _pcbRead : 0 ;
  74.    return( lrc );
  75. }
  76.  
  77.