4 * Supports option processing.
5 * Declaration functions are used to declare an option:
6 * - specify either var or handler, not both.
7 * - handler will be called just once.
10 typedef enum option_class
{
11 OPT_MISC
, /* Miscellaneous options */
12 OPT_PAGE_FURNITURE
, /* Options that affect page furniture */
13 OPT_TEXT_FORMAT
, /* Options that affect text layout */
14 OPT_PRINT
, /* Options that (de)select stuff to print */
15 OPT_PAGE_FORMAT
, /* Options that affect overall page presentation */
16 OPT_OUTPUT
/* Options that affect or control where output goes */
19 void setup_options(void);
20 void handle_string_options(char *);
21 unsigned int handle_options(int, char **);
22 void set_option_defaults(void);
23 void print_usage_msgs(option_class
);
26 * noparm option - option with no parameter
27 * If default_opt is true then the handler will always
28 * be called. It is up to the handler to work out if this
29 * option should be obeyed or not. This is intended to
30 * handle the case e.g. for -1, -2, -3 or -4 where
31 * -1 is the default - the handler will remember if
32 * any other option was invoked first. If invoked
33 * because of the default_opt flag then set_default will
35 * Must specify a handler and a set_default.
37 void noparm_option(char *c
, char *s
,
39 void (*handler
)(const char *p
, const char *s
),
40 void (*set_default
)(void),
44 /* option that takes an optional string */
45 void optional_string_option(char *c
, char *s
,
46 void (*handler
)(const char *p
, const char *s
, char *value
),
51 * boolean option - either y or n
53 void boolean_option(char *c
, char *s1
, char *s2
, boolean default_value
,
55 void (*handler
)(const char *p
, const char *s
, boolean value
),
56 void (*set_default
)(boolean value
),
58 char *true_help_string
,
59 char *false_help_string
);
61 void choice_option(char *c
, char *s1
, char *s2
,
62 char choice1
, char choice2
,
64 void (*handler
)(const char *p
, const char *s
, char value
),
65 void (*set_default
)(char value
),
67 char *choice1_help_string
,
68 char *choice2_help_string
);
70 /* char option - one of a set of characters */
71 void char_option(char *c
, char *s
, char default_value
,
74 void (*handler
)(const char *p
, const char *s
, char value
, char *var
),
75 void (*set_default
)(char value
),
79 /* short & int options */
80 void short_option(char *c
, char *s
, short default_value
,
81 char *special
, short special_value
,
84 void (*handler
)(const char *p
, const char *s
, short value
, short min
, short max
),
85 void (*set_default
)(short value
),
88 char *special_help_string
);
90 void int_option(char *c
, char *s
, int default_value
,
91 char *special
, int special_value
,
94 void (*handler
)(const char *p
, const char *s
, int value
, int min
, int max
),
95 void (*set_default
)(int value
),
98 char *special_help_string
);
101 void string_option(char *c
, char *s
, char *default_value
,
103 void (*handler
)(const char *p
, const char *s
, char *value
),
104 void (*set_default
)(char *value
),
108 /* flag option for setting string */
109 void flag_string_option(char *c
, char *s1
, char *s2
, boolean default_value
,
110 char *true_value
, char *false_value
,
112 void (*handler
)(const char *p
, const char *s
, boolean value
, char *true_value
, char *false_value
),
113 void (*set_default
)(boolean value
, char *string
),
115 char *set_help_string
,
116 char *not_set_help_string
);