| 1 |
#ifdef RCSID |
| 2 |
static char RCSid[] = |
| 3 |
"$Header: d:/cvsroot/tads/TADS2/CMD.C,v 1.2 1999/05/17 02:52:11 MJRoberts Exp $"; |
| 4 |
#endif |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include "os.h" |
| 24 |
#include "std.h" |
| 25 |
#include "err.h" |
| 26 |
#include "cmd.h" |
| 27 |
|
| 28 |
|
| 29 |
int cmdtog(errcxdef *ec, int prv, char *argp, int ofs, |
| 30 |
void (*usagefn)(errcxdef *)) |
| 31 |
{ |
| 32 |
switch(argp[ofs + 1]) |
| 33 |
{ |
| 34 |
case '+': |
| 35 |
return(TRUE); |
| 36 |
|
| 37 |
case '-': |
| 38 |
return(FALSE); |
| 39 |
|
| 40 |
case '\0': |
| 41 |
return(!prv); |
| 42 |
|
| 43 |
default: |
| 44 |
|
| 45 |
if (usagefn != 0) |
| 46 |
(*usagefn)(ec); |
| 47 |
NOTREACHEDV(int); |
| 48 |
return 0; |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
char *cmdarg(errcxdef *ec, char ***argpp, int *ip, int argc, int ofs, |
| 54 |
void (*usagefn)(errcxdef *)) |
| 55 |
{ |
| 56 |
char *ret; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
ret = (**argpp) + ofs + 1; |
| 63 |
if (*ret == '\0') |
| 64 |
{ |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
++(*ip); |
| 70 |
++(*argpp); |
| 71 |
ret = (*ip >= argc ? 0 : **argpp); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
if ((ret == 0 || *ret == 0) && usagefn != 0) |
| 79 |
(*usagefn)(ec); |
| 80 |
|
| 81 |
return ret; |
| 82 |
} |
| 83 |
|