int main (int argc, char *argv[]) { DEPTH_T bpp; int aga; HMODE_T hmode; unsigned int i; do_bigendian = 0; for (i = 1; i < argc; i++) { if (argv[i][0] != '-') continue; if (argv[i][1] == 'b' && argv[i][2] == '\0') do_bigendian = 1; } set_outfile (stdout); outln ("/*"); outln (" * E-UAE - The portable Amiga emulator."); outln (" *"); outln (" * This file was generated by genlinetoscr. Don't edit."); outln (" */"); outln (""); for (bpp = DEPTH_8BPP; bpp <= DEPTH_MAX; bpp++) { for (aga = 0; aga <= 1 ; aga++) { for (hmode = HMODE_NORMAL; hmode <= HMODE_MAX; hmode++) out_linetoscr (bpp, hmode, aga); } } return 0; }
/*------------------------------------------------------------*/ void eps_first_plot (void) { image_first_plot(); set_outfile ("w"); if (fprintf (outfile, "%%!PS-Adobe-3.0 EPSF-3.0\n") < 0) yyerror ("could not write to the output EPS file"); fprintf (outfile, "%%%%BoundingBox: 0 0 %i %i\n", (int) (scale * output_width + 0.49999), (int) (scale * output_height + 0.4999)); if (title) fprintf (outfile, "%%%%Title: %s\n", title); fprintf (outfile, "%%%%Creator: %s, %s\n", program_str, copyright_str); if (user_str[0] != '\0') fprintf (outfile, "%%%%For: %s\n", user_str); PRINT ("%%EndComments\n"); PRINT ("%%BeginProlog\n"); PRINT ("10 dict begin\n"); PRINT ("/bwproc {\n"); PRINT (" rgbproc\n"); PRINT (" dup length 3 idiv string 0 3 0\n"); PRINT (" 5 -1 roll {\n"); PRINT (" add 2 1 roll 1 sub dup 0 eq\n"); PRINT (" { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n"); PRINT (" 3 1 roll 5 -1 roll put 1 add 3 0 }\n"); PRINT (" { 2 1 roll } ifelse\n"); PRINT (" } forall\n"); PRINT (" pop pop pop\n"); PRINT ("} def\n"); PRINT ("systemdict /colorimage known not {\n"); PRINT (" /colorimage {\n"); PRINT (" pop pop\n"); PRINT (" /rgbproc exch def\n"); PRINT (" { bwproc } image\n"); PRINT (" } def\n"); PRINT ("} if\n"); fprintf (outfile, "/picstr %i string def\n", components * output_width); PRINT ("%%EndProlog\n"); PRINT ("%%BeginSetup\n"); PRINT ("gsave\n"); fprintf (outfile, "%g %g scale\n", scale * (float) output_width, scale * (float) output_height); PRINT ("%%EndSetup\n"); fprintf (outfile, "%i %i 8\n", output_width, output_height); fprintf (outfile, "[%i 0 0 %i 0 0]\n", output_width, output_height); PRINT ("{currentfile picstr readhexstring pop}\n"); fprintf (outfile, "false %i\n", components); fprintf (outfile, "%%%%BeginData: %i Hex Bytes\n", 2 * output_width * output_height * components + 11); PRINT ("colorimage\n"); }
/*------------------------------------------------------------*/ void gifi_first_plot (void) { int r, g, b, slot; image_first_plot(); set_outfile ("wb"); image = gdImageCreate (output_width, output_height); for (r = 0; r < 6; r++) { for (g = 0; g < 6; g++) { for (b = 0; b < 6; b++) { slot = gdImageColorAllocate (image, 51 * r, 51 * g, 51 * b); assert (slot >= 0); } } } }
int main(int argc, char *argv[]) { FTS *ftsp; FTSENT *entry; const struct compressor *method; const char *s; char *p, *infile; char outfile[MAXPATHLEN], _infile[MAXPATHLEN], suffix[16]; char *nargv[512]; /* some estimate based on ARG_MAX */ int bits, ch, error, i, rc, cflag, oflag; static const char *optstr[3] = { "123456789ab:cdfghlLnNOo:qrS:tvV", "cfhlNno:qrtv", "fghqr" }; bits = cflag = oflag = 0; storename = -1; p = __progname; if (p[0] == 'g') { method = M_DEFLATE; bits = 6; p++; } else #ifdef SMALL method = M_DEFLATE; #else method = M_COMPRESS; #endif /* SMALL */ decomp = 0; pmode = MODE_COMP; if (!strcmp(p, "zcat")) { decomp++; cflag = 1; pmode = MODE_CAT; } else { if (p[0] == 'u' && p[1] == 'n') { p += 2; decomp++; pmode = MODE_DECOMP; } if (strcmp(p, "zip") && strcmp(p, "compress")) errx(1, "unknown program name"); } strlcpy(suffix, method->suffix, sizeof(suffix)); nargv[0] = NULL; if (method == M_DEFLATE && (p = getenv("GZIP")) != NULL) { char *last; nargv[0] = *argv++; for (i = 1, (p = strtok_r(p, " ", &last)); p != NULL; (p = strtok_r(NULL, " ", &last)), i++) if (i < sizeof(nargv)/sizeof(nargv[1]) - argc - 1) nargv[i] = p; else errx(1, "GZIP is too long"); argc += i - 1; while ((nargv[i++] = *argv++)) ; argv = nargv; } while ((ch = getopt_long(argc, argv, optstr[pmode], longopts, NULL)) != -1) switch(ch) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': method = M_DEFLATE; strlcpy(suffix, method->suffix, sizeof(suffix)); bits = ch - '0'; break; case 'a': warnx("option -a is ignored on this system"); break; case 'b': bits = strtol(optarg, &p, 10); /* * POSIX 1002.3 says 9 <= bits <= 14 for portable * apps, but says the implementation may allow * greater. */ if (*p) errx(1, "illegal bit count -- %s", optarg); break; case 'c': cflag = 1; break; case 'd': /* Backward compatible. */ decomp++; break; case 'f': force++; break; case 'g': method = M_DEFLATE; strlcpy(suffix, method->suffix, sizeof(suffix)); bits = 6; break; case 'l': list++; testmode = 1; decomp++; break; case 'n': storename = 0; break; case 'N': storename = 1; break; #ifndef SMALL case 'O': method = M_COMPRESS; strlcpy(suffix, method->suffix, sizeof(suffix)); break; #endif /* SMALL */ case 'o': if (strlcpy(outfile, optarg, sizeof(outfile)) >= sizeof(outfile)) errx(1, "-o argument is too long"); oflag = 1; break; case 'q': verbose = -1; break; case 'S': p = suffix; if (optarg[0] != '.') *p++ = '.'; strlcpy(p, optarg, sizeof(suffix) - (p - suffix)); p = optarg; break; case 't': testmode = 1; decomp++; break; #ifndef SMALL case 'V': printf("%s\n%s\n", main_rcsid, gz_rcsid); printf("%s\n%s\n", z_rcsid, null_rcsid); #endif exit (0); case 'v': verbose++; break; #ifndef SMALL case 'L': fputs(copyright, stderr); fputs(license, stderr); #endif exit (0); case 'r': recurse++; break; case 'h': usage(0); break; default: usage(1); } argc -= optind; argv += optind; if (argc == 0) { if (nargv[0] == NULL) argv = nargv; /* XXX - make sure we don't oflow nargv in $GZIP case (millert) */ argv[0] = "-"; argv[1] = NULL; } if (oflag && (recurse || argc > 1)) errx(1, "-o option may only be used with a single input file"); if ((cat && argc) + testmode + oflag > 1) errx(1, "may not mix -o, -c, or -t options"); /* * By default, when compressing store the original name and timestamp * in the header. Do not restore these when decompressing unless * the -N option is given. */ if (storename == -1) storename = !decomp; if ((ftsp = fts_open(argv, FTS_PHYSICAL|FTS_NOCHDIR, 0)) == NULL) err(1, NULL); for (rc = SUCCESS; (entry = fts_read(ftsp)) != NULL;) { cat = cflag; pipin = 0; infile = entry->fts_path; if (infile[0] == '-' && infile[1] == '\0') { infile = "stdin"; pipin++; if (!oflag) cat = 1; } else switch (entry->fts_info) { case FTS_D: if (!recurse) { warnx("%s is a directory: ignored", infile); fts_set(ftsp, entry, FTS_SKIP); } continue; case FTS_DP: continue; case FTS_NS: /* * If file does not exist and has no suffix, * tack on the default suffix and try that. */ if (entry->fts_errno == ENOENT) { p = strrchr(entry->fts_accpath, '.'); if ((p == NULL || strcmp(p, suffix) != 0) && snprintf(_infile, sizeof(_infile), "%s%s", infile, suffix) < sizeof(_infile) && stat(_infile, entry->fts_statp) == 0 && S_ISREG(entry->fts_statp->st_mode)) { infile = _infile; break; } } case FTS_ERR: case FTS_DNR: warnx("%s: %s", infile, strerror(entry->fts_errno)); rc = rc ? rc : WARNING; continue; default: if (!S_ISREG(entry->fts_statp->st_mode) && !(S_ISLNK(entry->fts_statp->st_mode) && cat)) { warnx("%s not a regular file%s", infile, cat ? "" : ": unchanged"); rc = rc ? rc : WARNING; continue; } break; } if (!decomp && !pipin && (s = check_suffix(infile)) != NULL) { warnx("%s already has %s suffix -- unchanged", infile, s); rc = rc ? rc : WARNING; continue; } if (!oflag) { if (cat) strlcpy(outfile, "stdout", sizeof(outfile)); else if (decomp) { if (set_outfile(infile, outfile, sizeof outfile) == NULL) { if (!recurse) { warnx("%s: unknown suffix: " "ignored", infile); rc = rc ? rc : WARNING; } continue; } } else { if (snprintf(outfile, sizeof(outfile), "%s%s", infile, suffix) >= sizeof(outfile)) { warnx("%s%s: name too long", infile, suffix); rc = rc ? rc : WARNING; continue; } } } if (verbose > 0 && !pipin && !list) fprintf(stderr, "%s:\t", infile); error = (decomp ? dodecompress : docompress) (infile, outfile, method, bits, entry->fts_statp); switch (error) { case SUCCESS: if (!cat && !testmode) { if (!pipin && unlink(infile) && verbose >= 0) warn("input: %s", infile); } break; case WARNING: rc = rc ? rc : WARNING; break; default: rc = FAILURE; break; } } if (list) list_stats(NULL, NULL, NULL); exit(rc); }