};
enum {optn_silenterr = -1, optn_err = 0, optn_ok};
-enum requests {do_nothing, do_init, do_set, do_handler, get_val};
+enum requests {do_nothing, do_init, do_set, do_handler, get_val, get_cnf_val};
static struct allopt_t allopt[SIZE(allopt_init)];
boolean duplicate, using_alias;
static boolean give_opt_msg = TRUE;
+static boolean got_from_config[OPTCOUNT];
+
static NEARDATA const char *OptS_type[OptS_Advanced+1] = {
"General", "Behavior", "Map", "Status", "Advanced"
};
static unsigned int longest_option_name(int, int);
static void doset_add_menu(winid, const char *, int, int);
static int handle_add_list_remove(const char *, int);
+static void all_options_menucolors(strbuf_t *);
+static void all_options_msgtypes(strbuf_t *);
+static void all_options_apes(strbuf_t *);
static void remove_autopickup_exception(struct autopickup_exception *);
static int count_apes(void);
static int count_cond(void);
op = string_for_opt(opts, TRUE);
optresult = (*allopt[matchidx].optfn)(allopt[matchidx].idx,
do_set, negated, opts, op);
+ if (optresult == optn_ok)
+ got_from_config[matchidx] = TRUE;
}
}
return optn_silenterr;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", rolestring(flags.initalign, aligns, adj));
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
int which;
if (!opts)
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
int which;
if (!opts)
#endif
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
flags.autounlock = newflags;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (!flags.autounlock) {
return optn_err;
#endif
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
Sprintf(opts, "%s", g.catname[0] ? g.catname : none);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ if (g.catname[0])
+ Sprintf(opts, "%s", g.catname);
+ else
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
return optn_err;
#endif
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
return optn_err;
#endif
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
sanitize_name(g.dogname);
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", g.dogname[0] ? g.dogname : none);
Sprintf(opts, "%s", to_be_done);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
Sprintf(opts, "%s", to_be_done);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
*/
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", g.pl_fruit);
return optn_silenterr;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", rolestring(flags.initgend, genders, adj));
Sprintf(opts, "%s", to_be_done);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
return optn_err;
#endif
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
+ opts[0] = '\0';
#ifdef STATUS_HILITES
- Strcpy(opts, count_status_hilites()
+ if (req == get_val)
+ Strcpy(opts, count_status_hilites()
? "(see \"status highlight rules\" below)"
: "(none)");
-#else
- opts[0] = '\0';
#endif
return optn_ok;
}
Sprintf(opts, "%s", g.horsename[0] ? g.horsename : none);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ if (g.horsename[0])
+ Sprintf(opts, "%s", g.horsename);
+ else
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
return optn_err;
#endif
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
i = iflags.wc_map_mode;
Sprintf(opts, "%s", to_be_done);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
iflags.menu_headings = tmpattr;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", attr2attrname(iflags.menu_headings));
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%d", iflags.menuinvertmode);
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", menutype[(int) flags.menu_style][0]);
if (req == do_set) {
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
Sprintf(opts, "%s%s", mousemodes[ms][0], mousemodes[ms][1]);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ Sprintf(opts, "%i", iflags.wc_mouse_support);
+ return optn_ok;
+ }
return optn_ok;
}
#endif
return retval;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%u", iflags.msg_history);
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", g.plname);
number_pad(iflags.num_pad ? 1 : 0);
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
static const char *const numpadmodes[] = {
"0=off", "1=on", "2=on, MSDOS compatible",
"3=on, phone-style layout",
if (!opts)
return optn_err;
- Strcpy(opts, numpadmodes[indx]);
+ if (req == get_val)
+ Strcpy(opts, numpadmodes[indx]);
+ else {
+ Sprintf(opts, "%i", (indx == 5) ? -1 : indx);
+ }
return optn_ok;
}
if (req == do_handler) {
Sprintf(opts, "%s", to_be_done);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
char ocl[MAXOCLASSES + 1];
if (!opts)
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
char tmpbuf[QBUFSZ];
if (!opts)
}
return retval;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
#endif
if (iflags.wc2_petattr != 0)
Sprintf(opts, "0x%08x", iflags.wc2_petattr);
+ else if (req == get_cnf_val)
+ opts[0] = '\0';
else
Strcpy(opts, defopt);
}
case 'n': /* no pet */
g.preferred_pet = 'n';
break;
+ case 'r': /* random */
case '*': /* random */
g.preferred_pet = '\0';
break;
: "random");
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ if (g.preferred_pet)
+ Sprintf(opts, "%c", g.preferred_pet);
+ else
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", burdentype[flags.pickup_burden]);
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
oc_to_str(flags.pickup_types, ocl);
flags.pile_limit = PILE_LIMIT_DFLT;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%d", flags.pile_limit);
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s",
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Strcpy(opts, wizard ? "debug" : discover ? "explore" : "normal");
return optn_silenterr;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", rolestring(flags.initrace, races, noun));
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s",
return optn_silenterr;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", rolestring(flags.initrole, roles, name.m));
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", runmodes[flags.runmode]);
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
*opts = '\0';
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (iflags.wc_scroll_amount)
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (iflags.wc_scroll_margin)
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
extern const char *const disco_orders_descr[]; /* o_init.c */
extern const char disco_order_let[];
const char *p = index(disco_order_let, flags.discosort);
if (!p)
flags.discosort = 'o', p = disco_order_let;
- Strcpy(opts, disco_orders_descr[p - disco_order_let]);
+ if (req == get_cnf_val)
+ Sprintf(opts, "%c", flags.discosort);
+ else
+ Strcpy(opts, disco_orders_descr[p - disco_order_let]);
return optn_ok;
}
if (req == do_handler) {
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
for (i = 0; i < SIZE(sortltype); i++)
#endif
return optn_ok;
}
+ if (req == get_cnf_val) {
+#ifdef STATUS_HILITES
+ if (!opts)
+ return optn_err;
+ Sprintf(opts, "%ld", iflags.hilite_delta);
+#endif
+ }
return optn_ok;
}
}
return retval;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (wc2_supported(allopt[optidx].name))
#endif
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
(void) feature_alert_opts(op, allopt[optidx].name);
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
- if (flags.suppress_alert == 0L)
+ if (req == get_cnf_val && flags.suppress_alert == 0L)
+ opts[0] = '\0';
+ else if (flags.suppress_alert == 0L)
Strcpy(opts, none);
else
Sprintf(opts, "%lu.%lu.%lu", FEATURE_NOTICE_VER_MAJ,
}
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ Sprintf(opts, "%s",
+ g.symset[PRIMARYSET].name ? g.symset[PRIMARYSET].name : "default");
+ return optn_ok;
+ }
if (req == do_handler) {
int reslt;
}
return retval;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (iflags.wc2_term_cols)
Sprintf(opts, "%d", iflags.wc2_term_cols);
+ else if (req == get_cnf_val)
+ opts[0] = '\0';
else
Strcpy(opts, defopt);
return optn_ok;
}
return retval;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (iflags.wc2_term_rows)
Sprintf(opts, "%d", iflags.wc2_term_rows);
+ else if (req == get_cnf_val)
+ opts[0] = '\0';
else
Strcpy(opts, defopt);
return optn_ok;
iflags.wc_tile_file ? iflags.wc_tile_file : defopt);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ if (iflags.wc_tile_file)
+ Sprintf(opts, "%s", iflags.wc_tile_file);
+ else
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (iflags.wc_tile_height)
Sprintf(opts, "%d", iflags.wc_tile_height);
+ else if (req == get_cnf_val)
+ opts[0] = '\0';
else
Strcpy(opts, defopt);
return optn_ok;
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (iflags.wc_tile_width)
Sprintf(opts, "%d", iflags.wc_tile_width);
+ else if (req == get_cnf_val)
+ opts[0] = '\0';
else
Strcpy(opts, defopt);
return optn_ok;
Sprintf(opts, "%s", to_be_done);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (iflags.wc_vary_msgcount)
Sprintf(opts, "%d", iflags.wc_vary_msgcount);
+ else if (req == get_cnf_val)
+ opts[0] = '\0';
else
Strcpy(opts, defopt);
return optn_ok;
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d",
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s-%s-%s", shade[0], shade[1], shade[2]);
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
Sprintf(opts, "%s", to_be_done);
return optn_ok;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ opts[0] = '\0';
+ return optn_ok;
+ }
return optn_ok;
}
reslt = warning_opts(opts, allopt[optidx].name);
return reslt ? optn_ok : optn_err;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s",
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s",
}
return retval;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ Sprintf(opts, "%i", iflags.wc2_windowborders);
+ return optn_ok;
+ }
if (req == get_val) {
if (!opts)
return optn_err;
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, "%s", windowprocs.name);
g.opt_need_redraw = TRUE;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
if (req == do_set) {
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
return optn_err;
}
+ if (req == get_cnf_val) {
+ if (!opts)
+ return optn_err;
+ opts[0] = '\0';
+ return optn_ok;
+ }
if (req == get_val) {
if (!opts)
return optn_err;
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
return optn_ok;
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
}
if (req == do_set) {
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, n_currently_set, count_apes());
}
if (req == do_set) {
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, n_currently_set, count_bind_keys());
}
if (req == do_set) {
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, n_currently_set, count_menucolors());
}
if (req == do_set) {
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, n_currently_set, msgtype_count());
}
if (req == do_set) {
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, n_currently_set, count_cond());
}
if (req == do_set) {
}
- if (req == get_val) {
+ if (req == get_val || req == get_cnf_val) {
if (!opts)
return optn_err;
Sprintf(opts, n_currently_set, count_status_hilites());
* Currently handles only boolean and compound options.
*/
char *
-get_option_value(const char *optname)
+get_option_value(const char *optname, boolean cnfvalid)
{
static char retbuf[BUFSZ];
boolean *bool_p;
} else if (allopt[i].opttyp == CompOpt && allopt[i].optfn) {
int reslt = optn_err;
- reslt = (*allopt[i].optfn)(allopt[i].idx, get_val,
+ reslt = (*allopt[i].optfn)(allopt[i].idx,
+ cnfvalid ? get_cnf_val : get_val,
FALSE, retbuf, empty_optstr);
if (reslt == optn_ok && retbuf[0])
return retbuf;
return;
}
+/* append menucolor lines to strbuf */
+static void
+all_options_menucolors(strbuf_t *sbuf)
+{
+ int i = 0, ncolors = count_menucolors();
+ struct menucoloring *tmp = g.menu_colorings;
+ char buf[BUFSZ];
+ struct menucoloring **arr;
+
+ if (!ncolors)
+ return;
+
+ /* reverse the order */
+ arr = (struct menucoloring **)alloc(ncolors * sizeof(struct menucoloring *));
+ while (tmp) {
+ arr[i++] = tmp;
+ tmp = tmp->next;
+ }
+
+ for (i = ncolors; i > 0; i--) {
+ tmp = arr[i-1];
+ const char *sattr = attr2attrname(tmp->attr);
+ const char *sclr = clr2colorname(tmp->color);
+ Sprintf(buf, "MENUCOLOR=\"%s\"=%s%s%s\n",
+ tmp->origstr,
+ sclr,
+ (tmp->attr != ATR_NONE) ? "&" : "",
+ (tmp->attr != ATR_NONE) ? sattr : "");
+ strbuf_append(sbuf, buf);
+ }
+
+ free(arr);
+}
+
+static void
+all_options_msgtypes(strbuf_t *sbuf)
+{
+ struct plinemsg_type *tmp = g.plinemsg_types;
+ char buf[BUFSZ];
+
+ while (tmp) {
+ const char *mtype = msgtype2name(tmp->msgtype);
+ Sprintf(buf, "MSGTYPE=%s \"%s\"\n",
+ mtype, tmp->pattern);
+ strbuf_append(sbuf, buf);
+ tmp = tmp->next;
+ }
+}
+
+static void
+all_options_apes(strbuf_t *sbuf)
+{
+ struct autopickup_exception *tmp = g.apelist;
+ char buf[BUFSZ];
+
+ while (tmp) {
+ Sprintf(buf, "autopickup_exception=\"%c%s\"\n",
+ tmp->grab ? '<' : '>', tmp->pattern);
+ strbuf_append(sbuf, buf);
+ tmp = tmp->next;
+ }
+}
+
+/* return strbuf of all options, to write to file */
+void
+all_options_strbuf(strbuf_t *sbuf)
+{
+ const char *name;
+ char tmp[BUFSZ];
+ char *buf2;
+ boolean *bool_p;
+ int i;
+
+ strbuf_init(sbuf);
+ Sprintf(tmp, "# NetHack config, saved %s\n#\n",
+ yyyymmddhhmmss((time_t) 0));
+ strbuf_append(sbuf, tmp);
+
+ for (i = 0; (name = allopt[i].name) != 0; i++) {
+ if (!got_from_config[i])
+ continue;
+ switch (allopt[i].opttyp) {
+ case BoolOpt:
+ bool_p = allopt[i].addr;
+ if (!bool_p || bool_p == &flags.female)
+ break; /* obsolete */
+ if (*bool_p != allopt[i].initval) {
+ Sprintf(tmp, "OPTIONS=%s%s\n", *bool_p ? "" : "!", name);
+ strbuf_append(sbuf, tmp);
+ }
+ break;
+ case CompOpt:
+ if (!(allopt[i].setwhere == set_in_config
+ || allopt[i].setwhere == set_gameview
+ || allopt[i].setwhere == set_in_game))
+ break;
+ /* FIXME: get_option_value for:
+ - menu_deselect_all &c menu control keys,
+ - mouse_support
+ - pettype
+ - term_cols, term_rows
+ - verbose */
+ buf2 = get_option_value(name, TRUE);
+ if (buf2) {
+ Sprintf(tmp, "OPTIONS=%s:%s\n", name, buf2);
+ strbuf_append(sbuf, tmp);
+ }
+ break;
+ case OthrOpt:
+ break;
+ }
+ }
+
+ /* TODO: BINDs */
+ savedsym_strbuf(sbuf);
+ all_options_menucolors(sbuf);
+ all_options_msgtypes(sbuf);
+ all_options_apes(sbuf);
+#ifdef STATUS_HILITES
+ all_options_statushilites(sbuf);
+#endif
+
+ if (g.wizkit[0]) {
+ Sprintf(tmp, "WIZKIT=%s\n", g.wizkit);
+ strbuf_append(sbuf, tmp);
+ }
+}
+
/*
* prints the next boolean option, on the same line if possible, on a new
* line if not. End with next_opt("").