1: /*
2: * Copyright (c) 1990 Michael A. Cooper.
3: * This software may be freely distributed provided it is not sold for
4: * profit and the author is credited appropriately.
5: */
6:
7: /*
8: * $Header: RCS/options.h,v 1.7.1 96/3/23 18:13:30 sms Exp $
9: *
10: * $Log: options.h,v $
11: * Revision 1.7 90/12/15 18:13:30 mcooper
12: * Add copywrite notice.
13: *
14: * Revision 1.6 90/11/13 15:28:39 mcooper
15: * Add OptBool cvtarg routine.
16: *
17: * Revision 1.5 90/10/29 19:34:03 mcooper
18: * Fixed comment for NoArg.
19: *
20: * Revision 1.4 90/10/29 18:48:43 mcooper
21: * Cleanup some comments.
22: *
23: * Revision 1.3 90/10/29 14:47:29 mcooper
24: * UsageString is now a real function.
25: *
26: * Revision 1.2 90/10/26 15:55:44 mcooper
27: * Add defines for "__" and ArgHidden.
28: *
29: * Revision 1.1 90/10/26 14:42:53 mcooper
30: * Initial revision
31: *
32: */
33:
34:
35: #include <stdio.h>
36: #include <sys/types.h>
37: #include <sys/errno.h>
38:
39: #define Num_Opts(o) (sizeof(o)/sizeof(OptionDescRec))
40: #define HELPSTR "-help"
41: #define __ (caddr_t)
42:
43: #ifndef TRUE
44: #define TRUE 1
45: #endif
46: #ifndef FALSE
47: #define FALSE 0
48: #endif
49:
50: /*
51: * Values for OptionDescRec.flags.
52: */
53: #define NoArg 0x001 /* No argument for this option. Use
54: OptionDescRec.value. */
55: #define IsArg 0x002 /* Value is the option string itself */
56: #define SepArg 0x004 /* Value is in next argument in argv */
57: #define StickyArg 0x008 /* Value is characters immediately following
58: option */
59: #define SkipArg 0x010 /* Ignore this option and the next argument in
60: argv */
61: #define SkipLine 0x020 /* Ignore this option and the rest of argv */
62: #define SkipNArgs 0x040 /* Ignore this option and the next
63: OptionDescRes.value arguments in argv */
64: #define ArgHidden 0x080 /* Don't show in usage or help messages */
65:
66: /*
67: * Option description record.
68: */
69: typedef struct {
70: char *option; /* Option string in argv */
71: int flags; /* Flag bits */
72: int (*cvtarg)(); /* Function to convert argument */
73: caddr_t valp; /* Variable to set */
74: caddr_t value; /* Default value to provide */
75: char *usage; /* Usage message */
76: char *desc; /* Description message */
77: } OptionDescRec, *OptionDescList;
78:
79: void UsageOptions();
80: void HelpOptions();
81: void UserError();
82: int ParseOptions();
83: OptionDescRec *FindOption();
84:
85: int OptBool();
86: int OptInt();
87: int OptLong();
88: int OptShort();
89: int OptStr();
90:
91: extern char *OptionChars;
92: extern int errno;
93: extern char *sys_errlist[];
94: extern long strtol();
95: extern char *malloc();
96: extern char *strcpy();
Defined macros
FALSE
defined in line
47; used 29 times
- in line 46
- in /usr/src/local/qterm/options.c line
127-132(2),
246,
367,
383,
399,
415,
431
- in /usr/src/local/qterm/qterm.c line
231-239(9),
335-336(2),
414,
498,
531,
591,
655,
681,
883,
903,
919
IsArg
defined in line
55; used 1 times
NoArg
defined in line
53; used 21 times
TRUE
defined in line
44; used 21 times
- in line 43
- in /usr/src/local/qterm/options.c line
150,
165,
181,
242,
369,
385,
401,
417,
440
- in /usr/src/local/qterm/qterm.c line
240,
393,
409-413(3),
476,
527,
581,
674-676(2),
884
__
defined in line
41; used 3 times
Usage of this include