/** * Prints out the values of all the CQP configuration options. */ void print_option_values() { int opt; int lc_opt = find_option("LeftContext"); /* left and right context are automatically shown together with context option */ int rc_opt = find_option("RightContext"); if (!silent) printf("Variable settings:\n"); opt = 0; for (opt = 0; cqpoptions[opt].opt_name; opt++) if ((cqpoptions[opt].flags & OPTION_CQP) || (user_level >=1)) { if ((opt != lc_opt) && (opt != rc_opt)) print_option_value(opt); } }
static void print_current_option_section(option_help * args, option_value_type type){ option_help * o; for(o = args; o->shortVar != 0 || o->longVar != 0 ; o++){ if (o->arg == type){ int pos = 0; if (o->arg == OPTION_FLAG && (*(int*)o->variable) == 0){ continue; } printf("\t"); if(o->shortVar != 0 && o->longVar != 0){ pos += printf("%s", o->longVar); }else if(o->shortVar != 0){ pos += printf("%c", o->shortVar); }else if(o->longVar != 0){ pos += printf("%s", o->longVar); } pos += print_option_value(o); printf("\n"); } } }
void print_option_value(int opt) { int show_lc_rc = 0; /* "set context;" should also display left and right context settings */ if (cqpoptions[opt].opt_abbrev != NULL) printf("[%s]\t", cqpoptions[opt].opt_abbrev); else printf("\t"); printf("%-22s", cqpoptions[opt].opt_name); if (cqpoptions[opt].address != NULL) { printf("= "); switch (cqpoptions[opt].type) { case OptString: if (strcasecmp(cqpoptions[opt].opt_name, "PrintOptions") == 0) { printf("%ctbl %chdr %cwrap %cbdr %cnum", GlobalPrintOptions.print_tabular ? '+' : '-', GlobalPrintOptions.print_header ? '+' : '-', GlobalPrintOptions.print_wrap ? '+' : '-', GlobalPrintOptions.print_border ? '+' : '-', GlobalPrintOptions.number_lines ? '+' : '-'); } else if (*((char **)cqpoptions[opt].address)) printf("%s", *((char **)cqpoptions[opt].address)); else printf("<no value>"); break; case OptBoolean: printf((*((int *)cqpoptions[opt].address)) ? "yes" : "no"); break; case OptInteger: printf("%d", *((int *)cqpoptions[opt].address)); break; case OptContext: if (strcasecmp(cqpoptions[opt].opt_name, "Context") == 0) { printf("(see below)"); show_lc_rc = 1; } else if (strcasecmp(cqpoptions[opt].opt_name, "LeftContext") == 0) { printf("%d ", ((ContextDescriptor *)cqpoptions[opt].address)->left_width); switch (((ContextDescriptor *)cqpoptions[opt].address)->left_type) { case STRUC_CONTEXT: case ALIGN_CONTEXT: printf("%s", ((ContextDescriptor *)cqpoptions[opt].address)->left_structure_name ? ((ContextDescriptor *)cqpoptions[opt].address)->left_structure_name : "(empty?)"); break; case CHAR_CONTEXT: printf("characters"); break; case WORD_CONTEXT: printf("words"); break; default: assert(0 && "Can't be"); } } else if (strcasecmp(cqpoptions[opt].opt_name, "RightContext") == 0) { printf("%d ", ((ContextDescriptor *)cqpoptions[opt].address)->right_width); switch (((ContextDescriptor *)cqpoptions[opt].address)->right_type) { case STRUC_CONTEXT: case ALIGN_CONTEXT: printf("%s", ((ContextDescriptor *)cqpoptions[opt].address)->right_structure_name ? ((ContextDescriptor *)cqpoptions[opt].address)->right_structure_name : "(empty?)"); break; case CHAR_CONTEXT: printf("characters"); break; case WORD_CONTEXT: printf("words"); break; default: assert(0 && "Can't be"); } } else { assert (0 && "Unknown option of type OptContext ???"); } break; default: printf("WARNING: Illegal Option Type!"); break; } } else { /* no address given for option -> this is only LeftContext and RightContext in normal mode, so refer people to the Context option */ printf("<not bound to variable>"); } printf("\n"); if (show_lc_rc) { print_option_value(find_option("LeftContext")); print_option_value(find_option("RightContext")); } }