home *** CD-ROM | disk | FTP | other *** search
/ CGI How-To / CGI HOW-TO.iso / chap7 / 7_2 / ht72b.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-15  |  689 b   |  37 lines

  1. /* Compile with: cc ht72b.c -o ht72b.cgi */
  2.  
  3. #include <stdio.h>
  4.  
  5. #ifndef GNUPLOT
  6. #    define GNUPLOT   "/usr/bin/gnuplot"
  7. #endif
  8. #ifndef PPMTOGIF
  9. #    define PPMTOGIF  "/usr2/local/netpbm/bin/ppmtogif"
  10. #endif
  11.  
  12. void main()
  13. {
  14.     char buf[200];
  15.     FILE *GP;
  16.    
  17.     sprintf(buf,"%s | %s -interlace", GNUPLOT, PPMTOGIF);
  18.     GP = popen(buf,"w");
  19.  
  20.     printf("Content-type: image/gif\n\n");
  21.     fflush(stdout);
  22.  
  23.     /* select the ppm device driver   */
  24.     fprintf(GP,"set terminal pbm color\n");
  25.    
  26.     /* render at half the normal size */
  27.     fprintf(GP,"set size 0.5,0.5\n");
  28.    
  29.     /* a very simple gnuplot program  */
  30.     fprintf(GP,"plot cos(x)\n");
  31.  
  32.     pclose(GP);
  33.  
  34.     exit(0);
  35. }
  36.  
  37.