home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 334_01 / corplot.c < prev    next >
Text File  |  1991-02-05  |  881b  |  42 lines

  1. #include <stdio.h>
  2. #include <process.h>
  3. #include <dos.h>
  4.  
  5. #define BOUNDARY 32768
  6. #define segment(addr) (FP_SEG(m) + ((FP_OFF(m)+15) >> 4));
  7. #define round(value,boundary) (((value) + (boundary) - 1) & ~((boundary) - 1))
  8.  
  9. char *malloc(),*realloc();
  10.  
  11. char prog[] = "gnuplot";
  12. char corscreen[] = "CORSCREEN=0";
  13.  
  14. main()
  15. {
  16. register unsigned int segm,start;
  17. char *m;
  18.     if (!(m = malloc(BOUNDARY))) {
  19.         printf("malloc() failed\n");
  20.         exit(1);
  21.     }
  22.     segm = segment(m);
  23.     start = round(segm,BOUNDARY/16);
  24.  
  25.     if (realloc(m,BOUNDARY+(start-segm)*16) != m) {
  26.         printf("can't realloc() memory\n");
  27.         exit(2);
  28.     }
  29.  
  30.     if ((segm = start >> 11) >= 8) {
  31.         printf("not enough room in first 256K\n");
  32.         exit(3);
  33.     }
  34.  
  35.     corscreen[sizeof(corscreen)-2] = '0' + segm;
  36.     if (putenv(corscreen))
  37.         perror("putenv");
  38.  
  39.     if (spawnlp(P_WAIT,prog,prog,NULL))
  40.         perror("spawnlp");
  41. }
  42.