--- os2sdk/demos/examples/pipes/pchild.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/pipes/pchild.c 2018/08/09 12:26:11 1.1.1.2 @@ -1,16 +1,22 @@ /*** pchild.c - child program * - * Example of DOSMAKEPIPE usage in parent/child communication + * Example of DosMakePipe usage in parent/child communication * * This is the child program which read the data sent down * from the parent in the pipe. + * + * Created by Microsoft Corp. 1987 */ +#define INCL_DOSFILEMGR +#define INCL_DOSMEMMGR + +#include #include -#include +#include typedef struct { - unsigned read_handle; /* pipe read handle */ - unsigned write_handle; /* pipe write handle */ + SHANDLE read_handle; /* pipe read handle */ + SHANDLE write_handle; /* pipe write handle */ } SharedData; @@ -22,22 +28,22 @@ main() char readin[21]; /* DosRead input buffer */ int retcode; /* holds return code from call */ SharedData far *fp; /* pointer to shared memory */ - unsigned mem_handle; /* selector of the allocated segment */ - unsigned buflen = 21; /* DosRead buffer length */ - unsigned read; /* number bytes read by DosRead */ + SEL mem_handle; /* selector of the allocated segment */ + USHORT buflen = 21; /* DosRead buffer length */ + USHORT read; /* number bytes read by DosRead */ /* access shared memory 'public' */ printf("Accessing shared memory\n"); - retcode = DOSGETSHRSEG((char far *)pname, (unsigned far *)&mem_handle); + retcode = DosGetShrSeg((PSZ)pname, &mem_handle); /* create pointer to shared memory segment */ - fp = (SharedData far *)((unsigned long)mem_handle << 16); + fp = (SharedData far *)MAKEP(mem_handle,0); /* read from the pipe */ printf("Reading from pipe\n"); - if( retcode = DOSREAD( fp->read_handle, readin, buflen, - (unsigned far *)&read)) { + if( retcode = DosRead( fp->read_handle, readin, buflen, + &read)) { printf("Read from pipe handle %d failed, retcode %d\n", fp->read_handle, retcode); } @@ -57,11 +63,11 @@ main() } /* free the segment and return to parent */ - DOSFREESEG( mem_handle ); + DosFreeSeg( mem_handle ); printf("Exiting child\n"); /* Exit without terminating other children */ - DOSEXIT(0,0); + DosExit(EXIT_THREAD,0); }