1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
/*
O P T I O N S . C
*/
#include "icmake.h"
int options (char **argv, int *argc)
{
register int
c;
char
*cp;
#ifdef MSDOS
FILE
*new;
#endif
char
pid_string[30]; /* used with -x */
while ((c = getopt(argc, argv)) != -1)
{
switch (c)
{
case 'a':
about();
break;
case 'b':
flags |= f_blunt;
break;
case 'c':
flags |= f_compiler;
break;
case 'i':
flags |= f_icmake; /* flag icmake taken literally */
if (!(source_name = getoptval(argc, argv)))
error("-i requires source-filename");
return (getoptindex()); /* and return the index of args */
/* to icm-exec */
#ifdef MSDOS
case 'o':
if (!(cp = getoptval(argc, argv)))
error("-o requires output-filename");
if (!(new = fopen(cp, "w")))
error("Can't open redirection file `%s'", cp);
redirect_nr = fileno(new);
break;
#endif
case 'p':
flags |= f_preprocessor;
break;
case 'q':
flags |= f_quiet; /* no banner */
break;
#ifndef MSDOS
case 't':
flags |= f_tmpbim | f_icmake; /* flag use temporary bimfile */
if (!(cp = getoptval(argc, argv)))
error("-t requires temporary bim-filename");
while (*cp == ' ') /* skip initial blanks in optval*/
cp++;
/* build pid-string */
sprintf(pid_string, "%d", getpid());
/* destination with pid-extension */
dest_name = change_ext(cp, pid_string);
strcat(pid_string, "a"); /* temp. pim-file extension */
temporary = change_ext(cp, pid_string);
source_name = argv[1];
return (getoptindex() + 1); /* index of remaining args */
/* + 1 for the extra arg on the */
/* #!/...-x... line */
#endif
case '-':
return (getoptindex()); /* return index of args to icm-exec
*/
}
}
return (*argc); /* return index of args to icm-exec
*/
}
/*
int flags;
void main(int argc, char **argv)
{
options(argv, &argc);
printf("flags: %x\n"
"arguments:\n"
,
flags);
while (argc--)
puts(*argv++);
}
*/
|