errr process_pref_file_command(const char *s) { struct parser *p = init_parse_prefs(TRUE); errr e = parser_parse(p, s); mem_free(parser_priv(p)); parser_destroy(p); return e; }
/* * Process the user pref file with the given name. * "quiet" means "don't complain about not finding the file. * * Returns TRUE if everything worked OK, false otherwise */ bool process_pref_file(const char *name, bool quiet) { char buf[1024]; ang_file *f; struct parser *p; errr e = 0; int line_no = 0; /* Build the filename */ path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name); if (!file_exists(buf)) path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name); f = file_open(buf, MODE_READ, -1); if (!f) { if (!quiet) msg("Cannot open '%s'.", buf); } else { char line[1024]; p = init_parse_prefs(); while (file_getl(f, line, sizeof line)) { line_no++; e = parser_parse(p, line); if (e != PARSE_ERROR_NONE) { print_error(buf, p); break; } } file_close(f); mem_free(parser_priv(p)); parser_destroy(p); } /* Result */ return e == PARSE_ERROR_NONE; }