int main(int argc, char **argv) { double rexp, gexp, bexp; double radd, gadd, badd; double rmul, gmul, bmul; double pre_exp; int i; /* check for flags */ bu_opterr = 0; while ((i=bu_getopt(argc, argv, options)) != -1) { switch (i) { case 'v': verbose++; break; case 'F': framebuffer = bu_optarg; break; case 'f': input_file = bu_optarg; break; default: bu_exit(2, "fbgammamod: Unrecognized option '%c'\n%s", i, usage); } } if (bu_optind != argc - 13) { bu_exit(1, "%s", usage); } /* Gobble 13 positional args */ ra = atof(argv[bu_optind+0]); rm = atof(argv[bu_optind+1]); rg = atof(argv[bu_optind+2]); ga = atof(argv[bu_optind+3]); gm = atof(argv[bu_optind+4]); gg = atof(argv[bu_optind+5]); ba = atof(argv[bu_optind+6]); bm = atof(argv[bu_optind+7]); bg = atof(argv[bu_optind+8]); pre_gam = atof(argv[bu_optind+9]); add = atof(argv[bu_optind+10]); mul = atof(argv[bu_optind+11]); post_gam = atof(argv[bu_optind+12]); if (verbose) { fprintf(stderr, "r+ = %g, r* = %g, r_gam=%g\n", ra, rm, rg); fprintf(stderr, "g+ = %g, g* = %g, g_gam=%g\n", ga, gm, gg); fprintf(stderr, "b+ = %g, b* = %g, b_gam=%g\n", ba, bm, bg); fprintf(stderr, "pre_gam = %g, + = %g, * = %g, post_gam = %g\n", pre_gam, add, mul, post_gam); } /* Build the color map, per specifications */ pre_exp = 1.0 / pre_gam; rexp = 1.0 / (post_gam + rg - 1); gexp = 1.0 / (post_gam + gg - 1); bexp = 1.0 / (post_gam + bg - 1); radd = (ra + add) / 255.0; gadd = (ga + add) / 255.0; badd = (ba + add) / 255.0; rmul = rm * mul; gmul = gm * mul; bmul = bm * mul; for (i=0; i<256; i++) { double t; int val; t = (pow(i/255.0, pre_exp) + radd) * rmul; CLAMP(t, 0, 1); val = (int)(65535 * pow(t, rexp)); CLAMP(val, 0, 65535); map.cm_red[i] = val; t = (pow(i/255.0, pre_exp) + gadd) * gmul; CLAMP(t, 0, 1); val = (int)(65535 * pow(t, gexp)); CLAMP(val, 0, 65535); map.cm_green[i] = val; t = (pow(i/255.0, pre_exp) + badd) * bmul; CLAMP(t, 0, 1); val = (int)(65535 * pow(t, bexp)); CLAMP(val, 0, 65535); map.cm_blue[i] = val; /* use cmap-fb format */ if (verbose) fprintf(stderr, "%d %4x %4x %4x\n", i, map.cm_red[i], map.cm_green[i], map.cm_blue[i]); } if (!input_file) { do_fb(); } else { do_file(); } return 0; }
/* * chat [-esSvV] [-f chat-file] [-r report-file] [-t timeout] * [-T phone-number] [-U phone-number2] [chat-script] * where chat-script has the form: * [...[[expect[-send[-expect...]] send expect[-send[-expect]] ...]]] * * Perform a UUCP-dialer-like chat script on stdin and stdout. */ int main(int argc, char *argv[]) { int option; tzset(); while ((option = getopt(argc, argv, "ef:r:sSt:T:U:vV")) != -1) { switch (option) { case 'e': ++echo; break; case 'f': if (chat_file != NULL) free(chat_file); chat_file = copy_of(optarg); break; case 'r': if (report_fp != NULL) fclose(report_fp); if (report_file != NULL) free(report_file); report_file = copy_of(optarg); report_fp = fopen(report_file, "a"); if (report_fp != NULL) { if (verbose) fprintf(report_fp, "Opening \"%s\"...\n", report_file); } else fatal(2, "cannot open \"%s\" for appending", report_file); break; case 's': ++to_stderr; break; case 'S': to_log = 0; break; case 't': timeout = atoi(optarg); break; case 'T': if (phone_num != NULL) free(phone_num); phone_num = copy_of(optarg); break; case 'U': if (phone_num2 != NULL) free(phone_num2); phone_num2 = copy_of(optarg); break; case 'v': ++verbose; break; case 'V': ++Verbose; break; default: usage(); break; } } argc -= optind; argv += optind; /* * Default the report file to the stderr location */ if (report_fp == NULL) report_fp = stderr; if (to_log) { openlog("chat", LOG_PID | LOG_NDELAY, LOG_LOCAL2); if (verbose) setlogmask(LOG_UPTO(LOG_INFO)); else setlogmask(LOG_UPTO(LOG_WARNING)); } if (chat_file != NULL) { if (*argv != NULL) usage(); else { init(); do_file(chat_file); } } else { init(); while (*argv != NULL && argc > 0) { chat_expect(*argv); argv++; argc--; if (*argv != NULL && argc > 0) { chat_send(*argv); argv++; argc--; } } } terminate(0); return 0; }