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);
85 extern int alternative_rcfile;
92 if(!alternative_rcfile)
96 conff_free_nodes(abook_config);
102 return ( (0 == access(SYSWIDE_RCFILE, F_OK)) ||
103 (0 == access(rcfile, F_OK)) );
111 if( (ret = conff_load_file(&abook_config, rcfile,
113 fprintf(stderr, "%s: parse error at line %d\n", rcfile, ret);
117 if( (ret = conff_load_file(&abook_config, SYSWIDE_RCFILE,
118 DONT_REPLACE_KEY )) > 0) {
119 fprintf(stderr, "%s: parse error at line %d\n",
120 SYSWIDE_RCFILE, ret);
129 if( rcfile_exist() ) /* don't overwrite existing config */
132 conff_save_file(abook_config, rcfile);
137 options_add_key(char *key, char *value)
139 const int flags = DONT_REPLACE_KEY;
141 conff_add_key(&abook_config, key, value, flags);
147 options_add_key("autosave", "true");
149 options_add_key("show_all_emails", "true");
150 options_add_key("emailpos", "25");
151 options_add_key("extra_column", "7");
152 options_add_key("extra_alternative", "-1");
153 options_add_key("extrapos", "65");
155 options_add_key("mutt_command", "mutt");
156 options_add_key("mutt_return_all_emails", "true");
158 options_add_key("print_command", "lpr");
160 options_add_key("filesel_sort", "false");
162 options_add_key("www_command", "lynx");
164 options_add_key("address_style", "eu");
166 options_add_key("use_ascii_only", "false");