5 * by JH <jheinonen@users.sourceforge.net>
7 * Copyright (C) Jaakko Heinonen
13 #include "abook_curses.h"
20 struct conff_node *abook_config;
22 static int rcfile_exist();
23 static void default_options();
28 abook_opt_conff_get_val(char *key)
34 for(tried = 0; tried < 2; ) {
35 if( ( value = conff_get_value(abook_config, key) )
38 default_options(); /* try with defaults */
46 options_get_int(char *key)
51 if( ( value = abook_opt_conff_get_val(key) )
55 if( !strcasecmp(value, "true") )
58 if( !strcasecmp(value, "false") )
61 ret = safe_atoi(value);
67 options_get_str(char *key)
69 return abook_opt_conff_get_val(key);
88 conff_free_nodes(abook_config);
94 return ( (0 == access(SYSWIDE_RCFILE, F_OK)) ||
95 (0 == access(rcfile, F_OK)) );
103 if( (ret = conff_load_file(&abook_config, rcfile,
105 fprintf(stderr, "%s: parse error at line %d\n", rcfile, ret);
109 if( (ret = conff_load_file(&abook_config, SYSWIDE_RCFILE,
110 DONT_REPLACE_KEY )) > 0) {
111 fprintf(stderr, "%s: parse error at line %d\n",
112 SYSWIDE_RCFILE, ret);
120 if( rcfile_exist() ) /* don't overwrite existing config */
123 conff_save_file(abook_config, rcfile);
127 options_add_key(char *key, char *value)
129 const int flags = DONT_REPLACE_KEY;
131 conff_add_key(&abook_config, key, value, flags);
137 options_add_key("autosave", "true");
139 options_add_key("show_all_emails", "true");
140 options_add_key("emailpos", "25");
141 options_add_key("extra_column", "7");
142 options_add_key("extra_alternative", "-1");
143 options_add_key("extrapos", "65");
145 options_add_key("mutt_command", "mutt");
146 options_add_key("mutt_return_all_emails", "true");
148 options_add_key("print_command", "lpr");
150 options_add_key("filesel_sort", "false");
152 options_add_key("www_command", "lynx");
154 options_add_key("address_style", "eu");
156 options_add_key("use_ascii_only", "false");