This commit was manufactured by cvs2svn to create tag 'v1_2_4'.
[automated_linux_from_scratch.git] / nALFS / src / option-struct.h
blob48f7374a34712d381428986183692912afe1503d
1 /*
2 * option-struct.h - Structures and enums used to process program options.
4 * Copyright (C) 2002
6 * Neven Has <haski@sezampro.yu>
7 * Kevin P. Fleming <kpfleming@linuxfromscratch.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef H_OPTION_STRUCT_
26 #define H_OPTION_STRUCT_
30 * Types of some options.
33 typedef enum timer_type {
34 TIMER_NONE = 0,
35 TIMER_TOTAL,
36 TIMER_CURRENT
37 } timer_type_t;
39 typedef enum jump_location {
40 JUMP_TO_FAILED = 0,
41 JUMP_TO_RUNNING,
42 JUMP_TO_DONE,
43 JUMP_TO_PACKAGE
44 } jump_location_t;
46 /* We're looping through this enum (toggling) - 0 markes the first value. */
47 typedef enum logging_method {
48 LOG_OFF = 0,
49 LOG_USING_ONE_FIND,
50 } logging_method_t;
52 #define LAST_LOGGING_METHOD LOG_USING_ONE_FIND
56 * Options themselves.
59 #define BOOL int
60 #define NUMBER int
61 #define STRING char *
63 enum option_type {
64 O_BOOL,
65 O_NUMBER,
66 O_STRING
69 struct option_s {
70 char *name;
72 enum option_type type;
74 union {
75 struct {
76 STRING value;
77 STRING const def_value;
78 int (*validate)(const struct option_s *option,
79 const STRING value);
80 void (*post_validate)(const struct option_s *option);
81 } u_str;
82 struct {
83 BOOL value;
84 BOOL const def_value;
85 int (*validate)(const struct option_s *option,
86 const BOOL value);
87 void (*post_validate)(const struct option_s *option);
88 } u_bool;
89 struct {
90 NUMBER value;
91 NUMBER const def_value;
92 NUMBER const min_value;
93 NUMBER const max_value;
94 int (*validate)(const struct option_s *option,
95 const NUMBER value);
96 void (*post_validate)(const struct option_s *option);
97 } u_num;
98 } val;
101 #ifndef STRING_OPTION
102 #define STRING_OPTION(opt_name, opt_def_value, opt_other...) \
103 extern STRING * const opt_##opt_name
104 #endif /* STRING_OPTION */
106 #ifndef BOOL_OPTION
107 #define BOOL_OPTION(opt_name, opt_def_value, opt_other...) \
108 extern BOOL * const opt_##opt_name
109 #endif /* BOOL_OPTION */
111 #ifndef NUMBER_OPTION
112 #define NUMBER_OPTION(opt_name, opt_def_value, opt_other...) \
113 extern NUMBER * const opt_##opt_name
114 #endif /* NUMBER_OPTION */
116 void set_string_option(STRING * const var, const STRING value);
117 void append_string_option(STRING * const var, const STRING value);
118 void set_options_to_defaults(void);
119 void post_validate_options(void);
121 char *alloc_real_status_logfile_name(void);
122 char *alloc_real_packages_directory_name(void);
123 char *alloc_real_stamp_directory_name(void);
126 * Setting option from RC file parser.
129 typedef enum set_opt_e {
130 OPTION_SET,
131 OPTION_UNKNOWN,
132 OPTION_INVALID_VALUE
133 } set_opt_e;
135 set_opt_e set_yet_unknown_option(const char *opt, const char *val);
138 #endif /* H_OPTION_STRUCT_ */