|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T d
Length: 2160 (0x870) Types: TextFile Names: »doargs.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Hangman1/doargs.c«
/* doargs.c * handles command line arguments * written by: ritcv!jxs7451 */ #include "hangman.h" #include<stdio.h> #include<strings.h> #define OPLEN 7 /* max length of input options string */ doargs(argc, argv, debug, hard, length) int argc; char *argv[]; int *debug; int *hard; int *length; { char *strcpy(); char buf[OPLEN]; /* holds argv[1] for decoding */ int i; /* loop counter */ if ((argc > 2) || (strlen(argv[1]) > (OPLEN - 1))) /* too many arguments */ usage(); if (argc == 2) /* must be an attempted option */ { strcpy(buf,argv[1]); if (buf[0] != '-') usage(); for(i=1;buf[i] != '\0';i++) switch(buf[i]) { case 'D' : if (!(*debug)) if (DBUG == getuid()) (*debug)++; else { puts("Debug permission denied."); exit(0); /* terminate program */ } else usage(); break; case 'h': if (!(*hard)) *hard = 1; else if (*hard == 2) twolev(); else usage(); break; case 'e': if (!(*hard)) *hard = 2; else if (*hard == 1) twolev(); else usage(); break; case 'l': if (!(*length)) *length = 1; else if (*length == 2) twolen(); else usage(); break; case 'L': if (!(*length)) *length = 2; else if (*length == 1) twolen(); else usage(); break; default: usage(); break; } /* switch */ } }