int open_config() { FILE *fp = NULL; char *line; key_cmd *cmd; confentry *lastnode = NULL, *newnode = NULL; int lineno = 1, ret = 0; size_t n = 0; /* Allow the configuration file to be overridden */ if (!config) config = CONFIG; fp = fopen(config, "r"); if (fp == NULL) { lprintf("Warning: could not open the configuration file %s: %s\n", config, strerror(errno)); return OK; } if (verbose > 1) lprintf("Using configuration file %s\n", config); while (!feof(fp) && (ret >=0)) { line = NULL; ret = getline(&line, &n, fp); if ((ret > 0) && (proc_config(lineno, line, &cmd) == OK)) { newnode = (confentry *)(malloc(sizeof(confentry))); if (newnode == NULL) { lprintf("Error: memory allocation failed\n"); close_config(); free(line); return MEMERR; } newnode->cmd = cmd; newnode->next = NULL; if (list == NULL) { list = newnode; } else { lastnode->next = newnode; } lastnode = newnode; if (verbose > 1) { lprintf("Config: "); lprint_mask(cmd->keys); lprintf(" -:- "); print_etype(cmd->type); lprintf(" -:- "); print_attrs(cmd); lprintf(" -:- %s\n", cmd->command); } } free(line); ++lineno; } fclose(fp); return OK; }
void print_class_details(FILE *f, egraph_t *egraph, class_t c) { occ_t root; eterm_t t; fputs("--- Class ", f); print_class_id(f, c); fputs("---\n", f); root = egraph_class_root(egraph, c); fputs("root: ", f); print_occurrence(f, root); fputc('\n', f); fputs("dmask: ", f); print_dmask(f, egraph_class_dmask(egraph, c)); fputc('\n', f); fputs("type: ", f); print_etype(f, egraph_class_type(egraph, c)); fputc('\n', f); fputs("thvar: ", f); print_thvar(f, egraph_class_thvar(egraph, c)); fputc('\n', f); fputs("members: ", f); print_list(f, egraph, root); fputc('\n', f); fputs("member defs:\n", f); t = term_of_occ(root); do { fputs(" ", f); print_eterm_def(f, egraph, t); t = egraph_term_next(egraph, t); } while (t != term_of_occ(root)); fputs("parents:\n", f); print_parents_details(f, egraph_class_parents(egraph, c)); fputc('\n', f); }