int main(int argc, char **argv) { if(argc == 1) { readline_main(); }else if(argc == 2) { file_main(argv); }else{ printf("Error.\n"); } return 0; }
/** * Main function for the interactive CQP program. * * Doesn't do much except call the initialisation function, * and then one of the loop-and-parse-input functions. * * @param argc Number of commandline arguments. * @param argv Pointer to commandline arguments. * @return Return value to OS. */ int main(int argc, char *argv[]) { which_app = cqp; if (!initialize_cqp(argc, argv)) { fprintf(stderr, "Can't initialize CQP\n"); exit(1); } /* Test ANSI colours (if CQP was invoked with -C switch) */ if (use_colour) { #ifndef __MINGW__ char *blue = get_colour_escape('b', 1); char *green = get_colour_escape('g', 1); char *red = get_colour_escape('r', 1); char *pink = get_colour_escape('p', 1); char *cyanBack = get_colour_escape('c', 0); char *greenBack = get_colour_escape('g', 0); char *yellowBack = get_colour_escape('y', 0); char *bold = get_typeface_escape('b'); char *underline = get_typeface_escape('u'); char *standout = get_typeface_escape('s'); char *normal = get_typeface_escape('n'); char sc_colour[256]; int i, j; printf("%s%sWelcome%s to %s%sC%s%sQ%s%sP%s -- ", green, bold, normal, red, bold, pink, bold, blue, bold, normal); printf("the %s Colourful %s Query %s Processor %s.\n", yellowBack, greenBack, cyanBack, normal); for (i = 3; i <= 4; i++) { printf("["); for (j = 0; j < 8; j++) { sprintf(sc_colour, "\x1B[0;%d%dm", i,j); printf("%d%d: %sN%s%sB%s%sU%s%sS%s ", i, j, sc_colour, sc_colour, bold, sc_colour, underline, sc_colour, standout, normal); } printf("]\n"); } #else fprintf(stderr, "We're sorry, CQP's Colourful Mode is not available under Windows.\n"); fprintf(stderr, "CQP will continue as normal without it...\n"); use_colour = 0; #endif } /* endif use_colour */ install_signal_handler(); if (child_process) { printf("CQP version " VERSION "\n"); fflush(stdout); } if (batchmode) { if (batchfd == NULL) fprintf(stderr, "Can't open batch file\n"); else cqp_parse_file(batchfd, 1); } else { #ifdef USE_READLINE if (use_readline) readline_main(); else #endif /* USE_READLINE */ cqp_parse_file(stdin, 0); } if (macro_debug) macro_statistics(); return (cqp_error_status == 0 ? 0 : 1); }