home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TIERRA40.ZIP / BEAGLE / TIEOUT.C < prev    next >
C/C++ Source or Header  |  1992-09-11  |  1KB  |  58 lines

  1. /* 92-4-1  makes x,y list of parameters from tierra.log files */
  2. /* Copyright (c) Daniel Pirone & Virtual Life 1991, 1992 */
  3.  
  4. #include <stdio.h>
  5.  
  6. void main(ac,av)
  7. int  ac;
  8. char  *av[];
  9. {   int  x, y;
  10.     char  data[81], buf[81], xbuf[255], ybuf[255];
  11.     FILE  *inf;
  12.  
  13.     if(ac != 4)
  14.     {   fprintf(stderr,"syntax:  %s infile xfield yfield \n",av[0]);
  15.         exit(-666);
  16.     }
  17.     if (av[1][0] == '-')
  18.         inf = stdin;
  19.     else
  20.     {   inf = fopen(av[1],"r");
  21.         if(inf == NULL)
  22.         {   fprintf(stderr,"tieout error: file %s not opened\n", av[1]);
  23.             exit(0);
  24.         }
  25.     }
  26.     printf("\n\"%s_%s\n",av[2],av[3]);
  27.     x = y = -1;
  28.     if (!strcmp(av[3],"ex")) 
  29.         for(;;)
  30.         {   if(fscanf(inf,"%s",buf) == EOF)
  31.                 break ;
  32.             if(!strncmp(buf,av[2],2))
  33.                 sscanf(&buf[2],"%d", &x);
  34.             if(!strncmp(buf,av[3],2))
  35.             {   fscanf(inf,"%*[^0-9]%d", &y);
  36.                 printf("%d %d\n", x, y);
  37.             }
  38.      
  39.         }
  40.     else
  41.         for(;;)
  42.         {   XXX: if(fscanf(inf,"%s",buf) == EOF)
  43.                 break ;
  44.             if(!strncmp(buf,av[2],2))
  45.                 sscanf(&buf[2],"%d", &x);
  46.             else goto XXX ;
  47.             YYY: if (fscanf(inf,"%s",buf) == EOF)
  48.                 break ;
  49.             if(!strncmp(buf,av[3],2))
  50.             {   sscanf(&buf[2],"%d", &y);
  51.                 printf("%d %d\n", x, y);
  52.             }
  53.         else goto YYY;
  54.      
  55.         }
  56.     fclose(inf);
  57. }
  58.