00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __SETTINGS_H__
00010 #define __SETTINGS_H__
00011
00012
00013 #include "global.h"
00014 #include "actions.h"
00015
00016
00023 enum opt__settings_e {
00024
00025
00028 OPT__PATH=0,
00031 OPT__LOG_MAXREV,
00034 OPT__LOG_OUTPUT,
00038 OPT__COLORDIFF,
00041 OPT__DIR_SORT,
00044 OPT__STATUS_COLOR,
00047 OPT__STOP_ON_CHANGE,
00049 OPT__FILTER,
00051 OPT__CHANGECHECK,
00054 OPT__ALL_REMOVED,
00056 OPT__VERBOSE,
00057
00060 OPT__DEBUG_OUTPUT,
00063 OPT__DEBUG_BUFFER,
00066 OPT__GROUP_STATS,
00067
00068
00071 OPT__CONFLICT,
00074 OPT__MERGE_OPT,
00077 OPT__MERGE_PRG,
00078
00081 OPT__DIFF_PRG,
00084 OPT__DIFF_OPT,
00087 OPT__DIFF_EXTRA,
00088
00091 OPT__WARNINGS,
00094 OPT__SOFTROOT,
00095
00098 OPT__COMMIT_TO,
00101 OPT__EMPTY_MESSAGE,
00105 OPT__MKDIR_BASE,
00106
00109 OPT__AUTHOR,
00112 OPT__EMPTY_COMMIT,
00116 OPT__DELAY,
00119 OPT__COPYFROM_EXP,
00120
00123 OPT__WAA_PATH,
00126 OPT__CONF_PATH,
00129 OPT__CONFIG_DIR,
00130
00132 OPT__COUNT
00133 };
00140 enum opt__prio_e {
00142 PRIO_DEFAULT=0,
00145 PRIO_ETC_FILE,
00147 PRIO_USER_FILE,
00149 PRIO_ETC_WC,
00151 PRIO_USER_WC,
00153 PRIO_ENV,
00157 PRIO_PRE_CMDLINE,
00159 PRIO_CMDLINE,
00161 PRIO_MUSTHAVE,
00162 };
00163
00164
00165
00166 struct opt__list_t;
00167
00169 typedef int (opt___parse_t)(struct opt__list_t *, char *, enum opt__prio_e);
00170
00173 struct opt__list_t {
00175 char name[16];
00176
00178 opt___parse_t *parse;
00180 const void *parm;
00181
00183 const char *cp_val;
00185 int i_val;
00186
00188 enum opt__prio_e prio;
00189 };
00190
00193 extern struct opt__list_t opt__list[OPT__COUNT];
00194
00195
00197 static inline __attribute__((const)) FASTCALL
00198 int opt__get_int(enum opt__settings_e which)
00199 {
00200 return opt__list[which].i_val;
00201 }
00202
00204 static inline __attribute__((const)) FASTCALL
00205 const char* opt__get_string(enum opt__settings_e which)
00206 {
00207 return opt__list[which].cp_val;
00208 }
00209
00211 static inline __attribute__((const)) FASTCALL
00212 enum opt__prio_e opt__get_prio(enum opt__settings_e which)
00213 {
00214 return opt__list[which].prio;
00215 }
00216
00218 static inline FASTCALL
00219 void opt__set_int(enum opt__settings_e which, enum opt__prio_e prio,
00220 int val)
00221 {
00222 if (opt__list[which].prio <= prio)
00223 {
00224 opt__list[which].i_val=val;
00225 opt__list[which].prio=prio;
00226 }
00227 }
00228
00232 static inline FASTCALL
00233 void opt__set_string(enum opt__settings_e which, enum opt__prio_e prio,
00234 char *stg)
00235 {
00236 if (opt__list[which].prio <= prio)
00237 {
00238 opt__list[which].cp_val=stg;
00239 opt__list[which].prio=prio;
00240 }
00241 }
00242
00243
00245 int opt__parse_option(enum opt__settings_e which, enum opt__prio_e prio,
00246 char *string);
00248 int opt__parse(char *key, char *value, enum opt__prio_e prio,
00249 int quiet_errors);
00250
00252 int opt__load_env(char **env);
00253
00255 #define OPT__MAX_LINE_LEN (512)
00256
00258 int opt__load_settings(char *path, char *name, enum opt__prio_e prio);
00259
00262 int opt__doesnt_say_off(const char *string);
00263
00265 char *opt__variable_from_option(enum opt__settings_e which);
00266
00274 enum opt_paths_t {
00276 PATH_WCRELATIVE=0,
00278 PATH_PARMRELATIVE,
00280 PATH_ABSOLUTE,
00282 PATH_CACHEDENVIRON,
00284 PATH_FULLENVIRON,
00285 };
00291 enum opt__delay_e {
00292 DELAY_CHECKOUT = 1 << 0,
00293 DELAY_COMMIT = 1 << 1,
00294 DELAY_UPDATE = 1 << 2,
00295 DELAY_REVERT = 1 << 3,
00296 };
00302 enum opt__chcheck_e {
00303 CHCHECK_NONE = 0,
00304 CHCHECK_FILE = 1 << 0,
00305 CHCHECK_DIRS = 1 << 1,
00306 CHCHECK_ALLFILES = 1 << 2,
00307 };
00315 enum opt__verbosity_e {
00316 VERBOSITY_VERYQUIET = 0,
00317 VERBOSITY_QUIET = 1 << 0,
00318 VERBOSITY_SHOWCHG = 1 << 1,
00319 VERBOSITY_SHOWSIZE = 1 << 2,
00320 VERBOSITY_SHOWNAME = 1 << 3,
00321
00322 VERBOSITY_DEFAULT =
00323 VERBOSITY_SHOWCHG | VERBOSITY_SHOWSIZE | VERBOSITY_SHOWNAME,
00324
00325
00326
00327
00328
00329 VERBOSITY_DEFAULT_v = VERBOSITY_DEFAULT | (VERBOSITY_DEFAULT << 1),
00330
00331 VERBOSITY_SHOWTIME = 1 << 4,
00332 VERBOSITY_COPYFROM = 1 << 5,
00333 VERBOSITY_TOP_URL = 1 << 6,
00334 VERBOSITY_GROUP = 1 << 7,
00335 VERBOSITY_ALL_URLS = 1 << 8,
00336 VERBOSITY_STACKTRACE= 1 << 16,
00337 };
00341 static inline unsigned opt__verbosity()
00342 {
00343
00344
00345 return (unsigned)opt__get_int(OPT__VERBOSE);
00346 }
00347
00348
00351 static inline int opt__is_verbose(void) {
00352 if (opt__verbosity() > VERBOSITY_DEFAULT) return +1;
00353 if (opt__verbosity() < VERBOSITY_DEFAULT) return -1;
00354 return 0;
00355 }
00356
00357
00358
00361 enum opt__conflict_e {
00362 CONFLICT_STOP=0,
00363 CONFLICT_LOCAL,
00364 CONFLICT_REMOTE,
00365 CONFLICT_BOTH,
00366 CONFLICT_MERGE,
00367 };
00372 #define FILTER__ALL (-1)
00373
00376 #define OPT__YES (1)
00377 #define OPT__NO (0)
00378
00383 work_t opt__work;
00384
00385 #endif
00386