1 /*
2  * File:
3  *	options.h
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.
8  */
9 
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 */
17 } option_class;
18 
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);
24 
25 	/*
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
34 	 * be used.
35 	 * Must specify a handler and a set_default.
36 	 */
37 void noparm_option(char *c, char *s,
38 		   boolean default_opt,
39 		   void (*handler)(const char *p, const char *s),
40 		   void (*set_default)(void),
41 		   option_class class,
42 		   char *help_string);
43 
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),
47 			    option_class class,
48 			    char *help_string);
49 
50 	/*
51 	 * boolean option - either y or n
52 	 */
53 void boolean_option(char *c, char *s1, char *s2, boolean default_value,
54 		    boolean *var,
55 		    void (*handler)(const char *p, const char *s, boolean value),
56 		    void (*set_default)(boolean value),
57 		    option_class class,
58 		    char *true_help_string,
59 		    char *false_help_string);
60 
61 void choice_option(char *c, char *s1, char *s2,
62 		   char choice1, char choice2,
63 		   char *var,
64 		   void (*handler)(const char *p, const char *s, char value),
65 		   void (*set_default)(char value),
66 		   option_class class,
67 		   char *choice1_help_string,
68 		   char *choice2_help_string);
69 
70 	/* char option - one of a set of characters */
71 void char_option(char *c, char *s, char default_value,
72 		 char *valid_set,
73 		 char *var,
74 		 void (*handler)(const char *p, const char *s, char value, char *var),
75 		 void (*set_default)(char value),
76 		 option_class class,
77 		 char *help_string);
78 
79 	/* short & int options */
80 void short_option(char *c, char *s, short default_value,
81 		  char *special, short special_value,
82 		  short min, short max,
83 		  short *var,
84 		  void (*handler)(const char *p, const char *s, short value, short min, short max),
85 		  void (*set_default)(short value),
86 		  option_class class,
87 		  char *help_string,
88 		  char *special_help_string);
89 
90 void int_option(char *c, char *s, int default_value,
91 		char *special, int special_value,
92 		int min, int max,
93 		int *var,
94 		void (*handler)(const char *p, const char *s, int value, int min, int max),
95 		void (*set_default)(int value),
96 		option_class class,
97 		char *help_string,
98 		char *special_help_string);
99 
100 	/* string option */
101 void string_option(char *c, char *s, char *default_value,
102 		   char **var,
103 		   void (*handler)(const char *p, const char *s, char *value),
104 		   void (*set_default)(char *value),
105 		   option_class class,
106 		   char *help_string);
107 
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,
111 			char **var,
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),
114 			option_class class,
115 			char *set_help_string,
116 			char *not_set_help_string);
117 
118 
119