--- jpeg2ps-1.9-orig/jpeg2ps.c 2002-02-04 12:39:21.000000000 +0100 +++ jpeg2ps-1.9/jpeg2ps.c 2008-04-09 22:14:19.000000000 +0200 @@ -32,6 +32,11 @@ #include #endif +#ifdef HAVE_LIBPAPER +#include +#include +#endif + #ifndef MAC extern char *optarg; extern int optind; @@ -73,6 +78,7 @@ static char buffer[BUFFERSIZE]; static char *ColorSpaceNames[] = {"", "Gray", "", "RGB", "CMYK" }; +#ifndef HAVE_LIBPAPER /* Array of known page sizes including name, width, and height */ typedef struct { const char *name; int width; int height; } PageSize_s; @@ -96,6 +102,7 @@ }; #define PAGESIZELIST (sizeof(PageSizes)/sizeof(PageSizes[0])) +#endif #ifdef A4 int PageWidth = 595; /* page width A4 */ @@ -294,8 +301,12 @@ fprintf(stderr, "-b binary mode: output 8 bit data (default: 7 bit with ASCII85)\n"); fprintf(stderr, "-h hex mode: output 7 bit data in ASCIIHex encoding\n"); fprintf(stderr, "-o output file name\n"); +#ifdef HAVE_LIBPAPER + fprintf(stderr, "-p page size name. See \"paperconf -a\" for a list of known names\n"); +#else fprintf(stderr, "-p page size name. Known names are:\n"); fprintf(stderr, " a0, a1, a2, a3, a4, a5, a6, b5, letter, legal, ledger, p11x17\n"); +#endif fprintf(stderr, "-q quiet mode: suppress all informational messages\n"); fprintf(stderr, "-r resolution value (dots per inch)\n"); fprintf(stderr, " 0 means use value given in file, if any (disables autorotate)\n"); @@ -314,6 +325,10 @@ int opt, pagesizeindex = -1; #endif +#ifdef HAVE_LIBPAPER + const struct paper *pinfo_default, *pinfo = NULL; +#endif + image.filename = NULL; image.mode = ASCII85; image.startpos = 0L; @@ -326,6 +341,15 @@ if (argc == 1) usage(); +#ifdef HAVE_LIBPAPER + /* get default paper size from libpaper */ + paperinit(); + if ((pinfo_default = paperinfo(systempapername()))) { + PageWidth = rint(paperpswidth(pinfo_default)); + PageHeight = rint(paperpsheight(pinfo_default)); + } +#endif + #ifndef MAC while ((opt = getopt(argc, argv, "abho:p:qr:")) != -1) switch (opt) { @@ -346,6 +370,18 @@ } break; case 'p': +#ifdef HAVE_LIBPAPER + for (pinfo = paperfirst(); pinfo; pinfo = papernext(pinfo)) + if (!strcmp((const char *)optarg, papername(pinfo))) { + PageWidth = rint(paperpswidth(pinfo)); + PageHeight = rint(paperpsheight(pinfo)); + break; + } + if (!pinfo) { /* page size name not found */ + fprintf(stderr, "Error: Unknown page size %s.\n", optarg); + exit(-3); + } +#else for(pagesizeindex=0; pagesizeindex < PAGESIZELIST; pagesizeindex++) if (!strcmp((const char *) optarg, PageSizes[pagesizeindex].name)) { PageHeight = PageSizes[pagesizeindex].height; @@ -356,6 +392,7 @@ fprintf(stderr, "Error: Unknown page size %s.\n", optarg); exit(-3); } +#endif break; case 'q': quiet = TRUE; @@ -371,9 +408,15 @@ usage(); } +#ifdef HAVE_LIBPAPER + if (pinfo && !quiet) /* page size user option given */ + fprintf(stderr, "Note: Using %s page size.\n", papername(pinfo)); + paperdone(); +#else if (pagesizeindex != -1 && ! quiet) /* page size user option given */ fprintf(stderr, "Note: Using %s page size.\n", PageSizes[pagesizeindex].name); +#endif if (optind == argc) /* filename missing */ usage();