home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol10n21.zip / IACA.ZIP / IACAMAIN.C < prev    next >
Text File  |  1991-10-31  |  1KB  |  45 lines

  1. IACAMAIN.C
  2.  
  3.  
  4. /* IACAMAIN.C
  5.   Demonstrate the use of the Intra-Application Communication Area (IACA)
  6. */
  7.  
  8. #include<process.h>
  9. #include<stdio.h>
  10. #include<stdlib.h>
  11. #include<string.h>
  12. #include<malloc.h>
  13. #include"iaca.h"
  14.  
  15. void main(void);
  16.  
  17. #define BUFFER_SIZE     20
  18.  
  19. void main(void)
  20.         {
  21.         char *message_buffer;
  22.  
  23.         if((message_buffer = malloc(BUFFER_SIZE)) == NULL)
  24.                 {
  25.                 puts("\nError! Unable to allocate memory.");
  26.                 exit(-1);
  27.                 }
  28.  
  29.                 // Store return buffer address in first 4 bytes of the IACA
  30.     _Iaca[0] = (void far *)message_buffer;
  31.     printf("IacaMain: message_buffer set to %Fp...running child...\n",
  32.         (void far *)message_buffer);
  33.  
  34.         if(spawnl(P_WAIT,"IACACHLD.EXE",NULL) == -1)
  35.                 {
  36.                 puts("\nError! Unable to locate IACACHLD.EXE.");
  37.                 exit(-1);
  38.                 }
  39.         printf("IacaMain: message from child is \'%s\'\n",message_buffer);
  40.     free(message_buffer);
  41.         }
  42.  
  43.  
  44.  
  45.