home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gle / gle / surfcmd.c < prev    next >
C/C++ Source or Header  |  1992-11-29  |  2KB  |  70 lines

  1. /* This is the surface command which translates to run the individual
  2.    surface programs:
  3.       surface myfile -dps       ---> surf_ps myfile
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <sys/types.h>
  9. #include <sys/wait.h>
  10. #define false 0
  11. #define true (!false)
  12. main(int argc,char *argv[])
  13. {
  14.     static char buff[200];
  15.     static char restofline[200];
  16.     static char surfacefile[200];
  17.     static char device[200];
  18.     static char outfile[200];
  19.     static char bindir[200];
  20.     char *s;
  21.     int i;
  22.  
  23. /*  Get the directory containing the gle_* binaries */
  24.     s = getenv("SURF_TOP");
  25.     if (s!=NULL) {
  26.         strcpy(bindir,s);
  27.     } else {
  28.         strcpy(bindir,GLEBINS);
  29.     }
  30.     if (bindir[strlen(bindir)-1] != '/')
  31.         strcat(bindir,"/");
  32.  
  33.     if (argc<2) {
  34.       printf("Usage: surface filename.gle -ddevice\n");
  35.       printf("    surface test        (Dumb terminal) \n");
  36.       printf("    surface test -dx    (Xwindows) \n");
  37.       printf("    surface test -dtek  (TEK4010) \n");
  38.       printf("    surface test -dhpgl (HP Plotters) \n");
  39.       printf("    surface test -dps   (PostScript) \n");
  40.       printf("To find out what drivers are available type in:\n");
  41.       printf("         ls %ssurf_* \n", bindir);
  42.       printf(" \n");
  43.       return 0;
  44.     }
  45.     strcpy(device,"vt");
  46.     for (i=1;i<argc;i++) {
  47.         if (strncmp(argv[i],"-d",2)==0) strcpy(device,argv[i]+2);
  48.         else if (isalnum(*argv[i])) strcpy(surfacefile,argv[i]);
  49.         else {
  50.             strcat(restofline," ");
  51.             strcat(restofline,argv[i]);
  52.         }
  53.     }
  54.     strcpy(outfile,surfacefile);
  55.     s = strchr(outfile,'.');
  56.     if (s!=NULL) *s = 0;
  57.     strcat(outfile,".");
  58.     strcat(outfile,device);
  59.     sprintf(buff,"%ssurf_",bindir); /* , GLEBINSOD); */
  60.     strcat(buff,device);
  61.     strcat(buff," ");
  62.     strcat(buff,surfacefile);
  63.     strcat(buff," /output=");
  64.     strcat(buff,outfile);
  65.     strcat(buff,restofline);
  66.     printf("%s\n",buff);
  67.     execlp("sh","sh","-c", buff,0);
  68. }
  69.  
  70.