MCPcopy Create free account
hub / github.com/NetHack/NetHack / get_option_value

Function get_option_value

src/options.c:8480–8505  ·  view source on GitHub ↗

Get string value of configuration option. * Currently handles only boolean and compound options. */

Source from the content-addressed store, hash-verified

8478 * Currently handles only boolean and compound options.
8479 */
8480char *
8481get_option_value(const char *optname, boolean cnfvalid)
8482{
8483 static char retbuf[BUFSZ];
8484 boolean *bool_p;
8485 int i;
8486
8487 for (i = 0; allopt[i].name != 0; i++)
8488 if (!strcmp(optname, allopt[i].name)) {
8489 if (allopt[i].opttyp == BoolOpt
8490 && (bool_p = allopt[i].addr) != 0) {
8491 Sprintf(retbuf, "%s", *bool_p ? "true" : "false");
8492 return retbuf;
8493 } else if (allopt[i].opttyp == CompOpt && allopt[i].optfn) {
8494 int reslt = optn_err;
8495
8496 reslt = (*allopt[i].optfn)(allopt[i].idx,
8497 cnfvalid ? get_cnf_val : get_val,
8498 FALSE, retbuf, empty_optstr);
8499 if (reslt == optn_ok && retbuf[0])
8500 return retbuf;
8501 return (char *) 0;
8502 }
8503 }
8504 return (char *) 0;
8505}
8506
8507staticfn unsigned int
8508longest_option_name(int startpass, int endpass)

Callers 2

all_options_strbufFunction · 0.85
nhl_get_configFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected