Jump to content

DosCreatePipe: Difference between revisions

From EDM2
Created page with "==Description== Creates an unnamed pipe. ==Syntax== <PRE> #define INCL_DOSQUEUES #include <os2.h> PHFILE phfRead; /* A pointer to an HFILE where the read handle for th..."
 
Ak120 (talk | contribs)
mNo edit summary
Line 7: Line 7:
#include <os2.h>
#include <os2.h>


PHFILE   phfRead;  /* A pointer to an HFILE where the read handle for the pipe is returned. */
PHFILE phfRead;  /* A pointer to an HFILE where the read handle for the pipe is returned. */
PHFILE   phfWrite;  /* A pointer to an HFILE where the write handle for the pipe is returned. */
PHFILE phfWrite;  /* A pointer to an HFILE where the write handle for the pipe is returned. */
ULONG     cb;        /* The amount of storage to reserve for the pipe. */
ULONG   cb;        /* The amount of storage to reserve for the pipe. */
APIRET   ulrc;      /* Return Code. */
APIRET ulrc;      /* Return Code. */


ulrc = DosCreatePipe(phfRead, phfWrite, cb);
ulrc = DosCreatePipe(phfRead, phfWrite, cb);
</PRE>


</PRE>
==Parameters==
==Parameters==
; phfRead (PHFILE) - output : A pointer to an HFILE where the read handle for the pipe is returned.  
;phfRead (PHFILE) - output : A pointer to an HFILE where the read handle for the pipe is returned.
 
; phfWrite (PHFILE) - output : A pointer to an HFILE where the write handle for the pipe is returned.
; phfWrite (PHFILE) - output : A pointer to an HFILE where the write handle for the pipe is returned.  
 
; cb (ULONG) - input : The amount of storage to reserve for the pipe.
; cb (ULONG) - input : The amount of storage to reserve for the pipe.


Line 26: Line 24:


DosCreatePipe returns one of the following values:
DosCreatePipe returns one of the following values:
 
* 0 NO_ERROR
* 0       NO_ERROR  
* 8 ERROR_NOT_ENOUGH_MEMORY
* 8       ERROR_NOT_ENOUGH_MEMORY  
 
==Remarks==
 


==Example Code==
==Example Code==
Line 68: Line 62:
return NO_ERROR;
return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosClose|DosClose]]
* [[DosClose]]
* [[OS2 API:CPI:DosDupHandle|DosDupHandle]]
* [[DosDupHandle]]
* [[OS2 API:CPI:DosRead|DosRead]]
* [[DosRead]]
* [[OS2 API:CPI:DosWrite|DosWrite]]
* [[DosWrite]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Revision as of 22:52, 15 November 2016

Description

Creates an unnamed pipe.

Syntax

#define INCL_DOSQUEUES
#include <os2.h>

PHFILE  phfRead;   /* A pointer to an HFILE where the read handle for the pipe is returned. */
PHFILE  phfWrite;  /* A pointer to an HFILE where the write handle for the pipe is returned. */
ULONG   cb;        /* The amount of storage to reserve for the pipe. */
APIRET  ulrc;      /* Return Code. */

ulrc = DosCreatePipe(phfRead, phfWrite, cb);

Parameters

phfRead (PHFILE) - output
A pointer to an HFILE where the read handle for the pipe is returned.
phfWrite (PHFILE) - output
A pointer to an HFILE where the write handle for the pipe is returned.
cb (ULONG) - input
The amount of storage to reserve for the pipe.

Return Code

ulrc (APIRET) - returns

DosCreatePipe returns one of the following values:

  • 0 NO_ERROR
  • 8 ERROR_NOT_ENOUGH_MEMORY

Example Code

This example creates an unnamed pipe, and then closes its read and write handles.

#define INCL_DOSQUEUES        /* Queue values */
#define INCL_DOSERRORS        /* DOS Error values */
#include <os2.h>
#include <stdio.h>

int main(VOID) {
HFILE    ReadHandle  = 0;          /* Read handle of pipe */
HFILE    WriteHandle = 0;          /* Write handle of pipe */
ULONG    PipeSize    = 4096;       /* Size of pipe */
APIRET   rc          = NO_ERROR;   /* API return code */

rc = DosCreatePipe(&ReadHandle, &WriteHandle, PipeSize);

if (rc != NO_ERROR) {
   printf("DosCreatePipe error: return code = %u\n", rc);
   return 1;
}

rc = DosClose(ReadHandle);
if (rc != NO_ERROR) {
   printf("DosClose error: return code = %u\n", rc);
   return 1;
}

rc = DosClose(WriteHandle);
if (rc != NO_ERROR) {
   printf("DosClose error: return code = %u\n", rc);
   return 1;
}

return NO_ERROR;
}

Related Functions