Back to index

radiance  4R0+20100331
pexpand.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char    RCSid[] = "$Id: pexpand.c,v 1.3 2003/11/15 02:13:37 schorsch Exp $";
00003 #endif
00004 /*
00005  *   Program to expand meta-file commands
00006  *
00007  *   cc pexpand.c expand.o mfio.o segment.o palloc.o syscalls.o misc.o
00008  */
00009 
00010 
00011 #include  "meta.h"
00012 
00013 
00014 char  *progname;
00015 
00016 int  maxalloc = 0;          /* no limit */
00017 
00018 
00019 int
00020 main(
00021        int  argc,
00022        char  **argv
00023 )
00024 {
00025  FILE  *fp;
00026  int  i;
00027  char  *cp;
00028  int  com;
00029  short  exlist[NCOMMANDS];  /* 1==expand, 0==pass, -1==discard */
00030 
00031  progname = *argv++;
00032  argc--;
00033 
00034  for (i = 0; i < NCOMMANDS; i++)
00035     exlist[i] = 0;
00036 
00037  while (argc && (**argv == '+' || **argv == '-'))  {
00038     i = (**argv == '+') ? 1 : -1;
00039     for (cp = *argv+1; *cp ; cp++)  {
00040        if ((com = comndx(*cp)) == -1 || *cp == PEOF) {
00041           sprintf(errmsg, "unknown option '%c'", *cp);
00042          error(WARNING, errmsg);
00043          }
00044        else
00045          exlist[com] = i;
00046        }
00047     argv++;
00048     argc--;
00049     }
00050 
00051  if (argc)
00052     while (argc)  {
00053        fp = efopen(*argv, "r");
00054        expand(fp, exlist);
00055        fclose(fp);
00056        argv++;
00057        argc--;
00058        }
00059  else
00060     expand(stdin, exlist);
00061 
00062  writeof(stdout);
00063 
00064  return(0);
00065  }