/**************************************************************************** * set_params * * Set coreboot parameters according to the contents of file 'f'. ****************************************************************************/ static void set_params(FILE * f) { /* First process the input file. Then perform writes only if there were * no problems processing the input. Either all values will be written * successfully or no values will be written. */ do_cmos_writes(process_input_file(f)); }
int main(int argc, char *argv[]) { kdu_customize_warnings(&pretty_cout); kdu_customize_errors(&pretty_cerr); kdu_args args(argc,argv,"-s"); if ((args.get_first() == NULL) || (args.find("-usage") != NULL)) print_usage(args.get_prog_name(),true); if (args.find("-u") != NULL) print_usage(args.get_prog_name(),false); bool quiet = false; if (args.find("-quiet") != NULL) { quiet = true; args.advance(); } kd_message *messages=NULL; while (args.find("-i") != NULL) { const char *string = args.advance(); if (string == NULL) { kdu_error e; e << "The \"-i\" argument requires an input file name."; } FILE *in = fopen(string,"r"); if (in == NULL) { kdu_error e; e << "Cannot open input file, \"" << string << "\"."; } process_input_file(in,messages,string,quiet); fclose(in); args.advance(); } if (args.find("-o") != NULL) { const char *string = args.advance(); if (string == NULL) { kdu_error e; e << "The \"-o\" argument requires an output file name."; } FILE *out = fopen(string,"w"); if (out == NULL) { kdu_error e; e << "Cannot open output file, \"" << string << "\"."; } generate_output_file(out,messages,string,quiet); fclose(out); args.advance(); } if (args.show_unrecognized(pretty_cout) != 0) { kdu_error e; e << "There were unrecognized command line arguments!"; } return 0; }
int main(int argc, char **argv) { program_name = argv[0]; static char stderr_buf[BUFSIZ]; setbuf(stderr, stderr_buf); int opt; static const struct option long_options[] = { { "help", no_argument, 0, CHAR_MAX + 1 }, { "version", no_argument, 0, 'v' }, { NULL, 0, 0, 0 } }; while ((opt = getopt_long(argc, argv, "vCT:", long_options, NULL)) != EOF) switch (opt) { case 'C': compatible_flag = 1; break; case 'v': { printf("GNU tbl (groff) version %s\n", Version_string); exit(0); break; } case 'T': // I'm sick of getting bug reports from IRIX users break; case CHAR_MAX + 1: // --help usage(stdout); exit(0); break; case '?': usage(stderr); exit(1); break; default: assert(0); } printf(".if !\\n(.g .ab GNU tbl requires GNU troff.\n" ".if !dTS .ds TS\n" ".if !dTE .ds TE\n"); if (argc > optind) { for (int i = optind; i < argc; i++) if (argv[i][0] == '-' && argv[i][1] == '\0') { current_filename = "-"; current_lineno = 1; printf(".lf 1 -\n"); process_input_file(stdin); } else { errno = 0; FILE *fp = fopen(argv[i], "r"); if (fp == 0) fatal("can't open `%1': %2", argv[i], strerror(errno)); else { current_lineno = 1; current_filename = argv[i]; printf(".lf 1 %s\n", current_filename); process_input_file(fp); } } } else { current_filename = "-"; current_lineno = 1; printf(".lf 1 -\n"); process_input_file(stdin); } if (ferror(stdout) || fflush(stdout) < 0) fatal("output error"); return 0; }