From 634763e80e93dd32eff71309cd6f122214d2954e Mon Sep 17 00:00:00 2001 From: msweet Date: Thu, 24 Apr 2008 00:13:12 +0000 Subject: [PATCH] Merge CUPS 1.4svn-r7493. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@723 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.3.txt | 2 + CHANGES.txt | 4 +- INSTALL.txt | 23 +- Makefile | 2 +- backend/testbackend.c | 97 +- cups/emit.c | 20 +- cups/file.c | 254 ++- cups/testfile.c | 250 ++- doc/help/spec-ppd.html | 58 +- packaging/cups.list.in | 129 +- packaging/cups.spec.in | 202 +- ppd/Makefile | 111 -- ppd/deskjet.ppd | 725 ------- ppd/dymo.ppd | 481 ----- ppd/epson24.ppd | 344 ---- ppd/epson9.ppd | 312 --- ppd/generic.ppd | 607 ------ ppd/generpcl.ppd | 742 ------- ppd/intelbar.ppd | 1529 --------------- ppd/laserjet.ppd | 758 -------- ppd/okidat24.ppd | 344 ---- ppd/okidata9.ppd | 312 --- ppd/stcolor.ppd | 420 ---- ppd/stcolor2.ppd | 420 ---- ppd/stphoto.ppd | 420 ---- ppd/stphoto2.ppd | 420 ---- ppd/zebra.ppd | 3975 -------------------------------------- ppd/zebracpl.ppd | 1978 ------------------- ppd/zebraep1.ppd | 1627 ---------------- ppd/zebraep2.ppd | 1758 ----------------- ppdc/Makefile | 8 + {ppd => ppdc}/sample.drv | 0 test/run-stp-tests.sh | 4 +- 33 files changed, 616 insertions(+), 17720 deletions(-) delete mode 100644 ppd/Makefile delete mode 100644 ppd/deskjet.ppd delete mode 100644 ppd/dymo.ppd delete mode 100644 ppd/epson24.ppd delete mode 100644 ppd/epson9.ppd delete mode 100644 ppd/generic.ppd delete mode 100644 ppd/generpcl.ppd delete mode 100644 ppd/intelbar.ppd delete mode 100644 ppd/laserjet.ppd delete mode 100644 ppd/okidat24.ppd delete mode 100644 ppd/okidata9.ppd delete mode 100644 ppd/stcolor.ppd delete mode 100644 ppd/stcolor2.ppd delete mode 100644 ppd/stphoto.ppd delete mode 100644 ppd/stphoto2.ppd delete mode 100644 ppd/zebra.ppd delete mode 100644 ppd/zebracpl.ppd delete mode 100644 ppd/zebraep1.ppd delete mode 100644 ppd/zebraep2.ppd rename {ppd => ppdc}/sample.drv (100%) diff --git a/CHANGES-1.3.txt b/CHANGES-1.3.txt index f668b502f..d62d2d031 100644 --- a/CHANGES-1.3.txt +++ b/CHANGES-1.3.txt @@ -4,6 +4,8 @@ CHANGES-1.3.txt CHANGES IN CUPS V1.3.8 - Documentation updates (STR #2785) + - cupsFileTell() did not work for log files opened in append + mode (STR #2810) - The scheduler did not set QUERY_STRING all of the time for CGI scripts (STR #2781) - The scheduler now returns an error for bad job-sheets diff --git a/CHANGES.txt b/CHANGES.txt index 2e1f937a2..6f6e3ed92 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,10 @@ -CHANGES.txt - 2008-04-21 +CHANGES.txt - 2008-04-23 ------------------------ CHANGES IN CUPS V1.4b1 + - Added support for cupsPJLDisplay attribute to control what + PJL commands are used to display the job information. - Driver information files can now be installed in /Library/Printers/PPDs.drv on Mac OS X. - The CUPS image library now supports reading images larger diff --git a/INSTALL.txt b/INSTALL.txt index ba785ed4d..46104948d 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -1,4 +1,4 @@ -INSTALL - CUPS v1.4svn - 2008-04-08 +INSTALL - CUPS v1.4svn - 2008-04-23 ----------------------------------- This file describes how to compile and install CUPS from source @@ -14,10 +14,10 @@ code. For more information on CUPS see the file called BEFORE YOU BEGIN - You'll need an ANSI-compliant C compiler, plus a make program - and Bourne shell. The GNU compiler tools work well - we've - tested the current CUPS code against several versions of GCC - with excellent results. + You'll need ANSI-compliant C and C++ compilers, plus a make + program and Bourne shell. The GNU compiler tools work well - + we've tested the current CUPS code against several versions + of GCC with excellent results. The makefiles used by the project should work with most versions of make. We've tested them with GNU make as well as @@ -96,6 +96,10 @@ CONFIGURATION LDFLAGS="-L/some/directory" \ ./configure ... + The "--enable-debug" option compiles CUPS with debugging enabled, + as well as support for debug logging via the CUPS_DEBUG_LOG + environment variable at run-time. + Once you have configured things, just type: make ENTER @@ -164,6 +168,15 @@ CREATING BINARY DISTRIBUTIONS WITH EPM tardist - Builds an IRIX package (also inst) +GETTING DEBUG LOGGING FROM CUPS + + When configured with the "--enable-debug" option, CUPS compiles + in additional debug logging support in the scheduler, CUPS API, + and CUPS Imaging API. Set the CUPS_DEBUG_LOG environment + variable to a filename to append logging information at run-time. + Use the name "-" to send the messages to stderr. + + REPORTING PROBLEMS If you have problems, READ THE DOCUMENTATION FIRST! If the diff --git a/Makefile b/Makefile index 2a6d27b9f..3b2c44ead 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ include Makedefs DIRS = cups filter backend berkeley cgi-bin driver locale man monitor \ notifier ppdc scheduler systemv test \ $(PHPDIR) \ - conf data doc $(FONTS) ppd templates + conf data doc $(FONTS) templates # diff --git a/backend/testbackend.c b/backend/testbackend.c index 4835ac6f6..4868beee1 100644 --- a/backend/testbackend.c +++ b/backend/testbackend.c @@ -55,6 +55,7 @@ main(int argc, /* I - Number of command-line args */ char *argv[]) /* I - Command-line arguments */ { int first_arg, /* First argument for backend */ + do_query = 0, /* Do PostScript query? */ do_side_tests = 0, /* Test side-channel ops? */ do_trickle = 0; /* Trickle data to backend */ char scheme[255], /* Scheme in URI == backend */ @@ -74,7 +75,9 @@ main(int argc, /* I - Number of command-line args */ for (first_arg = 1; argv[first_arg] && argv[first_arg][0] == '-'; first_arg ++) - if (!strcmp(argv[first_arg], "-s")) + if (!strcmp(argv[first_arg], "-ps")) + do_query = 1; + else if (!strcmp(argv[first_arg], "-s")) do_side_tests = 1; else if (!strcmp(argv[first_arg], "-t")) do_trickle = 1; @@ -130,27 +133,97 @@ main(int argc, /* I - Number of command-line args */ * Execute the trickle process as needed... */ - if (do_trickle) + if (do_trickle || do_query) { pipe(data_fds); if ((pid = fork()) == 0) { /* - * Trickle child comes here... + * Trickle/query child comes here... Rearrange file descriptors so that + * FD */ - int i; /* Looping var */ + close(0); + open("/dev/null", O_RDONLY); + close(1); + dup(data_fds[1]); close(data_fds[0]); - for (i = 0; i < 10; i ++) + close(data_fds[1]); + + close(3); + dup(back_fds[0]); + close(back_fds[0]); + close(back_fds[1]); + + close(4); + dup(side_fds[0]); + close(side_fds[0]); + close(side_fds[1]); + + if (do_trickle) + { + /* + * Write 10 spaces, 1 per second... + */ + + int i; /* Looping var */ + + for (i = 0; i < 10; i ++) + { + write(1, " ", 1); + sleep(1); + } + } + else { /* - * Write 10 spaces, 1 per second... + * Do a simple PostScript query job to get the default page size. */ - write(data_fds[1], " ", 1); - sleep(1); + char buffer[1024]; /* Buffer for response data */ + ssize_t bytes; /* Number of bytes of response data */ + static const char *ps_query = /* PostScript query file */ + "%!\n" + "save\n" + "currentpagedevice /PageSize get aload pop\n" + "2 copy gt {exch} if\n" + "(Unknown)\n" + "19 dict\n" + "dup [612 792] (Letter) put\n" + "dup [612 1008] (Legal) put\n" + "dup [612 935] (w612h935) put\n" + "dup [522 756] (Executive) put\n" + "dup [595 842] (A4) put\n" + "dup [420 595] (A5) put\n" + "dup [499 709] (ISOB5) put\n" + "dup [516 728] (B5) put\n" + "dup [612 936] (w612h936) put\n" + "dup [284 419] (Postcard) put\n" + "dup [419.5 567] (DoublePostcard) put\n" + "dup [558 774] (w558h774) put\n" + "dup [553 765] (w553h765) put\n" + "dup [522 737] (w522h737) put\n" + "dup [499 709] (EnvISOB5) put\n" + "dup [297 684] (Env10) put\n" + "dup [459 649] (EnvC5) put\n" + "dup [312 624] (EnvDL) put\n" + "dup [279 540] (EnvMonarch) put\n" + "{ exch aload pop 4 index sub abs 5 le exch\n" + " 5 index sub abs 5 le and\n" + " {exch pop exit} {pop} ifelse\n" + "} bind forall\n" + "= flush pop pop\n" + "restore\n" + "\004"; + + + write(1, ps_query, strlen(ps_query)); + write(2, "DEBUG: START\n", 13); + while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 30.0)) > 0) + write(2, buffer, bytes); + write(2, "\nDEBUG: END\n", 12); } exit(0); @@ -174,7 +247,7 @@ main(int argc, /* I - Number of command-line args */ * Child comes here... */ - if (do_trickle) + if (do_trickle || do_query) { close(0); dup(data_fds[0]); @@ -207,7 +280,7 @@ main(int argc, /* I - Number of command-line args */ * Parent comes here, setup back and side channel file descriptors... */ - if (do_trickle) + if (do_trickle || do_query) { close(data_fds[0]); close(data_fds[1]); @@ -299,8 +372,8 @@ main(int argc, /* I - Number of command-line args */ static void usage(void) { - fputs("Usage: betest [-s] [-t] device-uri job-id user title copies options " - "[file]\n", stderr); + fputs("Usage: betest [-ps] [-s] [-t] device-uri job-id user title copies " + "options [file]\n", stderr); exit(1); } diff --git a/cups/emit.c b/cups/emit.c index da76ea36e..636f3e7fb 100644 --- a/cups/emit.c +++ b/cups/emit.c @@ -413,6 +413,7 @@ ppdEmitJCL(ppd_file_t *ppd, /* I - PPD file record */ */ ppd_attr_t *charset; /* PJL charset */ + ppd_attr_t *display; /* PJL display command */ if ((charset = ppdFindAttr(ppd, "cupsPJLCharset", NULL)) != NULL) @@ -421,6 +422,12 @@ ppdEmitJCL(ppd_file_t *ppd, /* I - PPD file record */ charset = NULL; } + if ((display = ppdFindAttr(ppd, "cupsPJLDisplay", NULL)) != NULL) + { + if (!display->value) + display = NULL; + } + fputs("\033%-12345X@PJL\n", fp); for (ptr = ppd->jcl_begin + 9; *ptr;) if (!strncmp(ptr, "@PJL JOB", 8)) @@ -477,9 +484,16 @@ ppdEmitJCL(ppd_file_t *ppd, /* I - PPD file record */ * Send PJL JOB and PJL RDYMSG commands before we enter PostScript mode... */ - fprintf(fp, "@PJL JOB NAME = \"%s\" DISPLAY = \"%d %s %s\"\n", temp, - job_id, user, temp); - fprintf(fp, "@PJL RDYMSG DISPLAY = \"%d %s %s\"\n", job_id, user, temp); + if (display && strcmp(display->value, "job")) + { + fprintf(fp, "@PJL JOB NAME = \"%s\"\n", temp); + + if (display && !strcmp(display->value, "rdymsg")) + fprintf(fp, "@PJL RDYMSG DISPLAY = \"%d %s %s\"\n", job_id, user, temp); + } + else + fprintf(fp, "@PJL JOB NAME = \"%s\" DISPLAY = \"%d %s %s\"\n", temp, + job_id, user, temp); } else fputs(ppd->jcl_begin, fp); diff --git a/cups/file.c b/cups/file.c index 9f92727a2..28453952a 100644 --- a/cups/file.c +++ b/cups/file.c @@ -111,7 +111,8 @@ struct _cups_file_s /**** CUPS file structure... ****/ buf[4096], /* Buffer */ *ptr, /* Pointer into buffer */ *end; /* End of buffer data */ - off_t pos; /* File position for start of buffer */ + off_t pos, /* Position in file */ + bufpos; /* File position for start of buffer */ #ifdef HAVE_LIBZ z_stream stream; /* (De)compression stream */ @@ -413,13 +414,14 @@ cupsFileFlush(cups_file_t *fp) /* I - CUPS file */ if (!fp || fp->mode != 'w') { - DEBUG_puts(" Attempt to flush a read-only file..."); + DEBUG_puts("cupsFileFlush: Attempt to flush a read-only file..."); return (-1); } bytes = (ssize_t)(fp->ptr - fp->buf); - DEBUG_printf((" Flushing %ld bytes...\n", (long)bytes)); + DEBUG_printf(("cupsFileFlush: Flushing " CUPS_LLFMT " bytes...\n", + CUPS_LLCAST bytes)); if (bytes > 0) { @@ -453,6 +455,8 @@ cupsFileGetChar(cups_file_t *fp) /* I - CUPS file */ * Range check input... */ + DEBUG_printf(("cupsFileGetChar(fp=%p)\n", fp)); + if (!fp || (fp->mode != 'r' && fp->mode != 's')) { DEBUG_puts("cupsFileGetChar: Bad arguments!"); @@ -476,6 +480,10 @@ cupsFileGetChar(cups_file_t *fp) /* I - CUPS file */ DEBUG_printf(("cupsFileGetChar: Returning %d...\n", *(fp->ptr) & 255)); + fp->pos ++; + + DEBUG_printf(("cupsFileGetChar: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + return (*(fp->ptr)++ & 255); } @@ -500,6 +508,10 @@ cupsFileGetConf(cups_file_t *fp, /* I - CUPS file */ * Range check input... */ + DEBUG_printf(("cupsFileGetConf(fp=%p, buf=%p, buflen=" CUPS_LLFMT + ", value=%p, linenum=%p)\n", fp, buf, CUPS_LLCAST buflen, + value, linenum)); + if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 2 || !value) { @@ -640,6 +652,9 @@ cupsFileGetLine(cups_file_t *fp, /* I - File to read from */ * Range check input... */ + DEBUG_printf(("cupsFileGetLine(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")\n", + fp, buf, CUPS_LLCAST buflen)); + if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 3) return (0); @@ -654,6 +669,7 @@ cupsFileGetLine(cups_file_t *fp, /* I - File to read from */ break; *ptr++ = ch = *(fp->ptr)++; + fp->pos ++; if (ch == '\r') { @@ -666,7 +682,10 @@ cupsFileGetLine(cups_file_t *fp, /* I - File to read from */ break; if (*(fp->ptr) == '\n') + { *ptr++ = *(fp->ptr)++; + fp->pos ++; + } break; } @@ -682,6 +701,8 @@ cupsFileGetLine(cups_file_t *fp, /* I - File to read from */ *ptr = '\0'; + DEBUG_printf(("cupsFileGetLine: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + return (ptr - buf); } @@ -706,6 +727,9 @@ cupsFileGets(cups_file_t *fp, /* I - CUPS file */ * Range check input... */ + DEBUG_printf(("cupsFileGets(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")\n", fp, buf, + CUPS_LLCAST buflen)); + if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 2) return (NULL); @@ -725,6 +749,7 @@ cupsFileGets(cups_file_t *fp, /* I - CUPS file */ } ch = *(fp->ptr)++; + fp->pos ++; if (ch == '\r') { @@ -737,7 +762,10 @@ cupsFileGets(cups_file_t *fp, /* I - CUPS file */ break; if (*(fp->ptr) == '\n') - fp->ptr ++; + { + fp->ptr ++; + fp->pos ++; + } break; } @@ -755,6 +783,8 @@ cupsFileGets(cups_file_t *fp, /* I - CUPS file */ *ptr = '\0'; + DEBUG_printf(("cupsFileGets: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + return (buf); } @@ -811,8 +841,9 @@ cupsFileNumber(cups_file_t *fp) /* I - CUPS file */ * existing file, "a" to append to an existing file or create a new file, * or "s" to open a socket connection. * - * When opening for writing ("w") or appending ("a"), an optional number from - * 1 to 9 can be supplied which enables Flate compression of the file. + * When opening for writing ("w"), an optional number from 1 to 9 can be + * supplied which enables Flate compression of the file. Compression is + * not supported for the "a" (append) mode. * * When opening a socket connection, the filename is a string of the form * "address:port" or "hostname:port". The socket will make an IPv4 or IPv6 @@ -841,7 +872,8 @@ cupsFileOpen(const char *filename, /* I - Name of file */ */ if (!filename || !mode || - (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's')) + (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's') || + (*mode == 'a' && isdigit(mode[1] & 255))) return (NULL); /* @@ -918,11 +950,12 @@ cupsFileOpen(const char *filename, /* I - Name of file */ /* * 'cupsFileOpenFd()' - Open a CUPS file using a file descriptor. * - * The "mode" parameter can be "r" to read, "a" or "w" to write, or "s" - * to treat the file descriptor as a bidirectional socket connection. + * The "mode" parameter can be "r" to read, "w" to write, "a" to append, + * or "s" to treat the file descriptor as a bidirectional socket connection. * - * When opening for writing ("w") or appending ("a"), an optional number from - * 1 to 9 can be supplied which enables Flate compression of the file. + * When opening for writing ("w"), an optional number from 1 to 9 can be + * supplied which enables Flate compression of the file. Compression is + * not supported for the "a" (append) mode. * * @since CUPS 1.2@ */ @@ -941,7 +974,8 @@ cupsFileOpenFd(int fd, /* I - File descriptor */ */ if (fd < 0 || !mode || - (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's')) + (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's') || + (*mode == 'a' && isdigit(mode[1] & 255))) return (NULL); /* @@ -959,8 +993,10 @@ cupsFileOpenFd(int fd, /* I - File descriptor */ switch (*mode) { - case 'w' : case 'a' : + fp->pos = lseek(fd, 0, SEEK_END); + + case 'w' : fp->mode = 'w'; fp->ptr = fp->buf; fp->end = fp->buf + sizeof(fp->buf); @@ -1091,7 +1127,16 @@ cupsFilePrintf(cups_file_t *fp, /* I - CUPS file */ return (-1); if (fp->mode == 's') - return (cups_write(fp, buf, bytes)); + { + if (cups_write(fp, buf, bytes) < 0) + return (-1); + + fp->pos += bytes; + + DEBUG_printf(("cupsFilePrintf: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + + return (bytes); + } if ((fp->ptr + bytes) > fp->end) if (cupsFileFlush(fp)) @@ -1099,6 +1144,8 @@ cupsFilePrintf(cups_file_t *fp, /* I - CUPS file */ fp->pos += bytes; + DEBUG_printf(("cupsFilePrintf: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + if (bytes > sizeof(fp->buf)) { #ifdef HAVE_LIBZ @@ -1163,6 +1210,8 @@ cupsFilePutChar(cups_file_t *fp, /* I - CUPS file */ fp->pos ++; + DEBUG_printf(("cupsFilePutChar: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + return (0); } @@ -1202,6 +1251,8 @@ cupsFilePuts(cups_file_t *fp, /* I - CUPS file */ fp->pos += bytes; + DEBUG_printf(("cupsFilePuts: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + return (bytes); } @@ -1211,6 +1262,8 @@ cupsFilePuts(cups_file_t *fp, /* I - CUPS file */ fp->pos += bytes; + DEBUG_printf(("cupsFilePuts: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + if (bytes > sizeof(fp->buf)) { #ifdef HAVE_LIBZ @@ -1244,8 +1297,8 @@ cupsFileRead(cups_file_t *fp, /* I - CUPS file */ ssize_t count; /* Bytes read */ - DEBUG_printf(("cupsFileRead(fp=%p, buf=%p, bytes=%ld)\n", fp, buf, - (long)bytes)); + DEBUG_printf(("cupsFileRead(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", fp, buf, + CUPS_LLCAST bytes)); /* * Range check input... @@ -1267,7 +1320,8 @@ cupsFileRead(cups_file_t *fp, /* I - CUPS file */ if (fp->ptr >= fp->end) if (cups_fill(fp) <= 0) { - DEBUG_printf((" cups_fill() returned -1, total=%d\n", (int)total)); + DEBUG_printf(("cupsFileRead: cups_fill() returned -1, total=" CUPS_LLFMT "\n", + CUPS_LLCAST total)); if (total > 0) return ((ssize_t)total); @@ -1281,6 +1335,9 @@ cupsFileRead(cups_file_t *fp, /* I - CUPS file */ memcpy(buf, fp->ptr, count); fp->ptr += count; + fp->pos += count; + + DEBUG_printf(("cupsFileRead: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); /* * Update the counts for the last read... @@ -1295,7 +1352,7 @@ cupsFileRead(cups_file_t *fp, /* I - CUPS file */ * Return the total number of bytes read... */ - DEBUG_printf((" total=%d\n", (int)total)); + DEBUG_printf(("cupsFileRead: total=%d\n", (int)total)); return ((ssize_t)total); } @@ -1315,6 +1372,9 @@ cupsFileRewind(cups_file_t *fp) /* I - CUPS file */ * Range check input... */ + DEBUG_printf(("cupsFileRewind(fp=%p)\n", fp)); + DEBUG_printf(("cupsFileRewind: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + if (!fp || fp->mode != 'r') return (-1); @@ -1322,18 +1382,22 @@ cupsFileRewind(cups_file_t *fp) /* I - CUPS file */ * Handle special cases... */ - if (fp->pos == 0) + if (fp->bufpos == 0) { /* * No seeking necessary... */ + fp->pos = 0; + if (fp->ptr) { fp->ptr = fp->buf; fp->eof = 0; } + DEBUG_printf(("cupsFileRewind: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + return (0); } @@ -1351,10 +1415,13 @@ cupsFileRewind(cups_file_t *fp) /* I - CUPS file */ lseek(fp->fd, 0, SEEK_SET); - fp->pos = 0; - fp->ptr = NULL; - fp->end = NULL; - fp->eof = 0; + fp->bufpos = 0; + fp->pos = 0; + fp->ptr = NULL; + fp->end = NULL; + fp->eof = 0; + + DEBUG_printf(("cupsFileRewind: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); return (0); } @@ -1373,9 +1440,10 @@ cupsFileSeek(cups_file_t *fp, /* I - CUPS file */ ssize_t bytes; /* Number bytes in buffer */ - DEBUG_printf(("cupsFileSeek(fp=%p, pos=" CUPS_LLFMT ")\n", fp, pos)); - DEBUG_printf((" fp->pos=" CUPS_LLFMT "\n", fp->pos)); - DEBUG_printf((" fp->ptr=%p, fp->end=%p\n", fp->ptr, fp->end)); + DEBUG_printf(("cupsFileSeek(fp=%p, pos=" CUPS_LLFMT ")\n", fp, + CUPS_LLCAST pos)); + DEBUG_printf(("cupsFileSeek: fp->pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + DEBUG_printf(("cupsFileSeek: fp->ptr=%p, fp->end=%p\n", fp->ptr, fp->end)); /* * Range check input... @@ -1391,19 +1459,22 @@ cupsFileSeek(cups_file_t *fp, /* I - CUPS file */ if (pos == 0) return (cupsFileRewind(fp)); - if (fp->pos == pos) + if (fp->ptr) { - /* - * No seeking necessary... - */ + bytes = (ssize_t)(fp->end - fp->buf); - if (fp->ptr) + if (pos >= fp->bufpos && pos < (fp->bufpos + bytes)) { - fp->ptr = fp->buf; + /* + * No seeking necessary... + */ + + fp->pos = pos; + fp->ptr = fp->buf + pos - fp->bufpos; fp->eof = 0; - } - return (pos); + return (pos); + } } #ifdef HAVE_LIBZ @@ -1419,26 +1490,20 @@ cupsFileSeek(cups_file_t *fp, /* I - CUPS file */ #endif /* HAVE_LIBZ */ /* - * Figure out the number of bytes in the current buffer, and then - * see if we are outside of it... + * Seek forwards or backwards... */ - if (fp->ptr) - bytes = (ssize_t)(fp->end - fp->buf); - else - bytes = 0; - fp->eof = 0; - DEBUG_printf((" bytes=" CUPS_LLFMT "\n", CUPS_LLCAST bytes)); + DEBUG_printf(("cupsFileSeek: bytes=" CUPS_LLFMT "\n", CUPS_LLCAST bytes)); - if (pos < fp->pos) + if (pos < fp->bufpos) { /* * Need to seek backwards... */ - DEBUG_puts(" SEEK BACKWARDS"); + DEBUG_puts("cupsFileSeek: SEEK BACKWARDS"); #ifdef HAVE_LIBZ if (fp->compressed) @@ -1446,72 +1511,70 @@ cupsFileSeek(cups_file_t *fp, /* I - CUPS file */ inflateEnd(&fp->stream); lseek(fp->fd, 0, SEEK_SET); - fp->pos = 0; - fp->ptr = NULL; - fp->end = NULL; + fp->bufpos = 0; + fp->pos = 0; + fp->ptr = NULL; + fp->end = NULL; while ((bytes = cups_fill(fp)) > 0) - if (pos >= fp->pos && pos < (fp->pos + bytes)) + if (pos >= fp->bufpos && pos < (fp->bufpos + bytes)) break; if (bytes <= 0) return (-1); - fp->ptr = fp->buf + pos - fp->pos; + fp->ptr = fp->buf + pos - fp->bufpos; + fp->pos = pos; } else #endif /* HAVE_LIBZ */ { - fp->pos = lseek(fp->fd, pos, SEEK_SET); - fp->ptr = NULL; - fp->end = NULL; + fp->bufpos = lseek(fp->fd, pos, SEEK_SET); + fp->pos = fp->bufpos; + fp->ptr = NULL; + fp->end = NULL; - DEBUG_printf((" lseek() returned %ld...\n", (long)fp->pos)); + DEBUG_printf(("cupsFileSeek: lseek() returned " CUPS_LLFMT "...\n", + CUPS_LLCAST fp->pos)); } } - else if (pos >= (fp->pos + bytes)) + else { /* * Need to seek forwards... */ - DEBUG_puts(" SEEK FORWARDS"); + DEBUG_puts("cupsFileSeek: SEEK FORWARDS"); #ifdef HAVE_LIBZ if (fp->compressed) { while ((bytes = cups_fill(fp)) > 0) { - if (pos >= fp->pos && pos < (fp->pos + bytes)) + if (pos >= fp->bufpos && pos < (fp->bufpos + bytes)) break; } if (bytes <= 0) return (-1); - fp->ptr = fp->buf + pos - fp->pos; + fp->ptr = fp->buf + pos - fp->bufpos; + fp->pos = pos; } else #endif /* HAVE_LIBZ */ { - fp->pos = lseek(fp->fd, pos, SEEK_SET); - fp->ptr = NULL; - fp->end = NULL; + fp->bufpos = lseek(fp->fd, pos, SEEK_SET); + fp->pos = fp->bufpos; + fp->ptr = NULL; + fp->end = NULL; - DEBUG_printf((" lseek() returned " CUPS_LLFMT "...\n", fp->pos)); + DEBUG_printf(("cupsFileSeek: lseek() returned " CUPS_LLFMT "...\n", + CUPS_LLCAST fp->pos)); } } - else - { - /* - * Just reposition the current pointer, since we have the right - * range... - */ - DEBUG_puts(" SEEK INSIDE BUFFER"); - - fp->ptr = fp->buf + pos - fp->pos; - } + DEBUG_printf(("cupsFileSeek: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); return (fp->pos); } @@ -1628,6 +1691,9 @@ cupsFileStdout(void) off_t /* O - File position */ cupsFileTell(cups_file_t *fp) /* I - CUPS file */ { + DEBUG_printf(("cupsFileTell(fp=%p)\n", fp)); + DEBUG_printf(("cupsFileTell: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + return (fp ? fp->pos : 0); } @@ -1645,6 +1711,8 @@ cupsFileUnlock(cups_file_t *fp) /* I - CUPS file */ * Range check... */ + DEBUG_printf(("cupsFileUnlock(fp=%p)\n", fp)); + if (!fp || fp->mode == 's') return (-1); @@ -1675,6 +1743,9 @@ cupsFileWrite(cups_file_t *fp, /* I - CUPS file */ * Range check input... */ + DEBUG_printf(("cupsFileWrite(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", + fp, buf, CUPS_LLCAST bytes)); + if (!fp || !buf || bytes < 0 || (fp->mode != 'w' && fp->mode != 's')) return (-1); @@ -1692,6 +1763,8 @@ cupsFileWrite(cups_file_t *fp, /* I - CUPS file */ fp->pos += (off_t)bytes; + DEBUG_printf(("cupsFileWrite: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + return ((ssize_t)bytes); } @@ -1701,6 +1774,8 @@ cupsFileWrite(cups_file_t *fp, /* I - CUPS file */ fp->pos += (off_t)bytes; + DEBUG_printf(("cupsFileWrite: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos)); + if (bytes > sizeof(fp->buf)) { #ifdef HAVE_LIBZ @@ -1729,8 +1804,8 @@ cups_compress(cups_file_t *fp, /* I - CUPS file */ const char *buf, /* I - Buffer */ size_t bytes) /* I - Number bytes */ { - DEBUG_printf(("cups_compress(fp=%p, buf=%p, bytes=%ld)\n", fp, buf, - (long)bytes)); + DEBUG_printf(("cups_compress(fp=%p, buf=%p, bytes=" CUPS_LLFMT "\n", fp, buf, + CUPS_LLCAST bytes)); /* * Update the CRC... @@ -1751,8 +1826,8 @@ cups_compress(cups_file_t *fp, /* I - CUPS file */ * Flush the current buffer... */ - DEBUG_printf((" avail_in=%d, avail_out=%d\n", fp->stream.avail_in, - fp->stream.avail_out)); + DEBUG_printf(("cups_compress: avail_in=%d, avail_out=%d\n", + fp->stream.avail_in, fp->stream.avail_out)); if (fp->stream.avail_out < (int)(sizeof(fp->cbuf) / 8)) { @@ -1787,19 +1862,15 @@ cups_fill(cups_file_t *fp) /* I - CUPS file */ DEBUG_printf(("cups_fill(fp=%p)\n", fp)); - DEBUG_printf((" fp->ptr=%p, fp->end=%p, fp->buf=%p, " - "fp->pos=" CUPS_LLFMT ", fp->eof=%d\n", - fp->ptr, fp->end, fp->buf, fp->pos, fp->eof)); - - /* - * Update the "pos" element as needed... - */ + DEBUG_printf(("cups_fill: fp->ptr=%p, fp->end=%p, fp->buf=%p, " + "fp->bufpos=" CUPS_LLFMT ", fp->eof=%d\n", + fp->ptr, fp->end, fp->buf, CUPS_LLCAST fp->bufpos, fp->eof)); if (fp->ptr && fp->end) - fp->pos += (off_t)(fp->end - fp->buf); + fp->bufpos += fp->end - fp->ptr; #ifdef HAVE_LIBZ - DEBUG_printf((" fp->compressed=%d\n", fp->compressed)); + DEBUG_printf(("cups_fill: fp->compressed=%d\n", fp->compressed)); while (!fp->ptr || fp->compressed) { @@ -1827,7 +1898,7 @@ cups_fill(cups_file_t *fp) /* I - CUPS file */ * Can't read from file! */ - DEBUG_printf((" cups_read() returned " CUPS_LLFMT "!\n", + DEBUG_printf(("cups_fill: cups_read() returned " CUPS_LLFMT "!\n", CUPS_LLCAST bytes)); return (-1); @@ -2107,6 +2178,9 @@ cups_read(cups_file_t *fp, /* I - CUPS file */ ssize_t total; /* Total bytes read */ + DEBUG_printf(("cups_read(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", fp, buf, + CUPS_LLCAST bytes)); + /* * Loop until we read at least 0 bytes... */ @@ -2125,6 +2199,8 @@ cups_read(cups_file_t *fp, /* I - CUPS file */ total = read(fp->fd, buf, bytes); #endif /* WIN32 */ + DEBUG_printf(("cups_read: total=" CUPS_LLFMT "\n", CUPS_LLCAST total)); + if (total >= 0) break; @@ -2159,8 +2235,8 @@ cups_write(cups_file_t *fp, /* I - CUPS file */ ssize_t count; /* Count this time */ - DEBUG_printf(("cups_write(fp=%p, buf=%p, bytes=%ld)\n", fp, buf, - (long)bytes)); + DEBUG_printf(("cups_write(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", fp, buf, + CUPS_LLCAST bytes)); /* * Loop until all bytes are written... @@ -2181,6 +2257,8 @@ cups_write(cups_file_t *fp, /* I - CUPS file */ count = write(fp->fd, buf, bytes); #endif /* WIN32 */ + DEBUG_printf(("cups_write: count=" CUPS_LLFMT "\n", CUPS_LLCAST count)); + if (count < 0) { /* @@ -2193,8 +2271,6 @@ cups_write(cups_file_t *fp, /* I - CUPS file */ return (-1); } - DEBUG_printf((" count=%ld\n", (long)count)); - /* * Update the counts for the last write call... */ diff --git a/cups/testfile.c b/cups/testfile.c index 3b9b9d515..4f0f39e10 100644 --- a/cups/testfile.c +++ b/cups/testfile.c @@ -41,6 +41,7 @@ * Local functions... */ +static int random_tests(void); static int read_write_tests(int compression); @@ -76,6 +77,12 @@ main(int argc, /* I - Number of command-line arguments */ status += read_write_tests(1); #endif /* HAVE_LIBZ */ + /* + * Do uncompressed random I/O tests... + */ + + status = random_tests(); + /* * Test fdopen and close without reading... */ @@ -83,7 +90,7 @@ main(int argc, /* I - Number of command-line arguments */ pipe(fds); close(fds[1]); - fputs("cupsFileOpenFd(fd, \"r\"): ", stdout); + fputs("\ncupsFileOpenFd(fd, \"r\"): ", stdout); fflush(stdout); if ((fdfile = cupsFileOpenFd(fds[0], "r")) == NULL) @@ -114,7 +121,7 @@ main(int argc, /* I - Number of command-line arguments */ * Test path functions... */ - fputs("cupsFileFind: ", stdout); + fputs("\ncupsFileFind: ", stdout); #ifdef WIN32 if (cupsFileFind("notepad.exe", "C:/WINDOWS", 1, filename, sizeof(filename)) && cupsFileFind("notepad.exe", "C:/WINDOWS;C:/WINDOWS/SYSTEM32", 1, filename, sizeof(filename))) @@ -171,6 +178,190 @@ main(int argc, /* I - Number of command-line arguments */ } +/* + * 'random_tests()' - Do random access tests. + */ + +static int /* O - Status */ +random_tests(void) +{ + int status, /* Status of tests */ + pass, /* Current pass */ + count, /* Number of records read */ + record, /* Current record */ + num_records; /* Number of records */ + ssize_t pos, /* Position in file */ + expected; /* Expected position in file */ + cups_file_t *fp; /* File */ + char buffer[512]; /* Data buffer */ + + + /* + * Run 4 passes, each time appending to a data file and then reopening the + * file for reading to validate random records in the file. + */ + + for (status = 0, pass = 0; pass < 4; pass ++) + { + /* + * cupsFileOpen(append) + */ + + printf("\ncupsFileOpen(append %d): ", pass); + + if ((fp = cupsFileOpen("testfile.dat", "a")) == NULL) + { + printf("FAIL (%s)\n", strerror(errno)); + status ++; + break; + } + else + puts("PASS"); + + /* + * cupsFileTell() + */ + + expected = 256 * sizeof(buffer) * pass; + + fputs("cupsFileTell(): ", stdout); + if ((pos = cupsFileTell(fp)) != expected) + { + printf("FAIL (" CUPS_LLFMT " instead of " CUPS_LLFMT ")\n", + CUPS_LLCAST pos, CUPS_LLCAST expected); + status ++; + break; + } + else + puts("PASS"); + + /* + * cupsFileWrite() + */ + + fputs("cupsFileWrite(256 512-byte records): ", stdout); + for (record = 0; record < 256; record ++) + { + memset(buffer, record, sizeof(buffer)); + if (cupsFileWrite(fp, buffer, sizeof(buffer)) < sizeof(buffer)) + break; + } + + if (record < 256) + { + printf("FAIL (%d: %s)\n", record, strerror(errno)); + status ++; + break; + } + else + puts("PASS"); + + /* + * cupsFileTell() + */ + + expected += 256 * sizeof(buffer); + + fputs("cupsFileTell(): ", stdout); + if ((pos = cupsFileTell(fp)) != expected) + { + printf("FAIL (" CUPS_LLFMT " instead of " CUPS_LLFMT ")\n", + CUPS_LLCAST pos, CUPS_LLCAST expected); + status ++; + break; + } + else + puts("PASS"); + + cupsFileClose(fp); + + /* + * cupsFileOpen(read) + */ + + printf("\ncupsFileOpen(read %d): ", pass); + + if ((fp = cupsFileOpen("testfile.dat", "r")) == NULL) + { + printf("FAIL (%s)\n", strerror(errno)); + status ++; + break; + } + else + puts("PASS"); + + /* + * cupsFileSeek, cupsFileRead + */ + + fputs("cupsFileSeek(), cupsFileRead(): ", stdout); + + for (num_records = (pass + 1) * 256, count = (pass + 1) * 256, + record = rand() % num_records; + count > 0; + count --, record = (record + (rand() & 31) - 16 + num_records) % + num_records) + { + /* + * The last record is always the first... + */ + + if (count == 1) + record = 0; + + /* + * Try reading the data for the specified record, and validate the + * contents... + */ + + expected = sizeof(buffer) * record; + + if ((pos = cupsFileSeek(fp, expected)) != expected) + { + printf("FAIL (" CUPS_LLFMT " instead of " CUPS_LLFMT ")\n", + CUPS_LLCAST pos, CUPS_LLCAST expected); + status ++; + break; + } + else + { + if (cupsFileRead(fp, buffer, sizeof(buffer)) != sizeof(buffer)) + { + printf("FAIL (%s)\n", strerror(errno)); + status ++; + break; + } + else if ((buffer[0] & 255) != (record & 255) || + memcmp(buffer, buffer + 1, sizeof(buffer) - 1)) + { + printf("FAIL (Bad Data - %d instead of %d)\n", buffer[0] & 255, + record & 255); + status ++; + break; + } + } + } + + if (count == 0) + puts("PASS"); + + cupsFileClose(fp); + } + + /* + * Remove the test file... + */ + + unlink("testfile.dat"); + + /* + * Return the test status... + */ + + return (status); +} + + /* * 'read_write_tests()' - Perform read/write tests. */ @@ -179,7 +370,7 @@ static int /* O - Status */ read_write_tests(int compression) /* I - Use compression? */ { int i; /* Looping var */ - cups_file_t *fp; /* First file */ + cups_file_t *fp; /* File */ int status; /* Exit status */ char line[1024], /* Line from file */ *value; /* Directive value from line */ @@ -187,6 +378,7 @@ read_write_tests(int compression) /* I - Use compression? */ unsigned char readbuf[8192], /* Read buffer */ writebuf[8192]; /* Write buffer */ int byte; /* Byte from file */ + off_t length; /* Length of file */ static const char *partial_line = "partial line"; /* Partial line */ @@ -258,7 +450,7 @@ read_write_tests(int compression) /* I - Use compression? */ fputs("cupsFilePrintf(): ", stdout); for (i = 0; i < 1000; i ++) - if (cupsFilePrintf(fp, "TestLine %d\n", i) < 0) + if (cupsFilePrintf(fp, "TestLine %03d\n", i) < 0) break; if (i >= 1000) @@ -319,6 +511,20 @@ read_write_tests(int compression) /* I - Use compression? */ status ++; } + /* + * cupsFileTell() + */ + + fputs("cupsFileTell(): ", stdout); + + if ((length = cupsFileTell(fp)) == 81933283) + puts("PASS"); + else + { + printf("FAIL (" CUPS_LLFMT " instead of 81933283)\n", CUPS_LLCAST length); + status ++; + } + /* * cupsFileClose() */ @@ -343,7 +549,7 @@ read_write_tests(int compression) /* I - Use compression? */ * cupsFileOpen(read) */ - fputs("cupsFileOpen(read): ", stdout); + fputs("\ncupsFileOpen(read): ", stdout); fp = cupsFileOpen(compression ? "testfile.dat.gz" : "testfile.dat", "r"); if (fp) @@ -422,23 +628,9 @@ read_write_tests(int compression) /* I - Use compression? */ fputs("cupsFileGetChar(): ", stdout); -#ifdef DEBUG - puts("\ni byte\n----- -----"); - - for (i = 0; i < 256; i ++) - { - byte = cupsFileGetChar(fp); - - printf("%-5d %-5d\n", i, byte); - - if (byte != i) - break; - } -#else for (i = 0; i < 256; i ++) if ((byte = cupsFileGetChar(fp)) != i) break; -#endif /* DEBUG */ if (i >= 256) puts("PASS"); @@ -504,6 +696,20 @@ read_write_tests(int compression) /* I - Use compression? */ status ++; } + /* + * cupsFileTell() + */ + + fputs("cupsFileTell(): ", stdout); + + if ((length = cupsFileTell(fp)) == 81933283) + puts("PASS"); + else + { + printf("FAIL (" CUPS_LLFMT " instead of 81933283)\n", CUPS_LLCAST length); + status ++; + } + /* * cupsFileClose() */ @@ -524,6 +730,12 @@ read_write_tests(int compression) /* I - Use compression? */ status ++; } + /* + * Remove the test file... + */ + + unlink(compression ? "testfile.dat.gz" : "testfile.dat"); + /* * Return the test status... */ diff --git a/doc/help/spec-ppd.html b/doc/help/spec-ppd.html index 5aa7b357a..dc73164e0 100644 --- a/doc/help/spec-ppd.html +++ b/doc/help/spec-ppd.html @@ -1192,20 +1192,6 @@ http://www.vendor.com/help" *End -

CUPS 1.4cupsMarkerName

- -

*cupsMarkerName/Name Text: ""

- -

This optional attribute maps marker-names strings that are -generated by the driver to human readable text.

- -

Examples:

- -
-*% Map cyanToner to "Cyan Toner"
-*cupsMarkerName cyanToner/Cyan Toner: ""
-
-

CUPS 1.2cupsLanguages

*cupsLanguages: "locale list"

@@ -1236,6 +1222,20 @@ hardware. The default value is false.

*cupsManualCopies: true +

CUPS 1.4cupsMarkerName

+ +

*cupsMarkerName/Name Text: ""

+ +

This optional attribute maps marker-names strings that are +generated by the driver to human readable text.

+ +

Examples:

+ +
+*% Map cyanToner to "Cyan Toner"
+*cupsMarkerName cyanToner/Cyan Toner: ""
+
+

cupsModelNumber

*cupsModelNumber: number

@@ -1251,7 +1251,6 @@ the output for a specific model of printer.

*cupsModelNumber: 1234 -

CUPS 1.3cupsPJLCharset

*cupsPJLCharset: "ISO character set name"

@@ -1267,6 +1266,24 @@ assumed.

*cupsPJLCharset: "UTF-8" +

CUPS 1.4cupsPJLDisplay

+ +

*cupsPJLDisplay: "what"

+ +

This optional attribute specifies which command is used to display the +job ID, name, and user on the printer's control panel. "What" is either "none" +to disable this functionality, "job" to use "@PJL JOB DISPLAY", or "rdymsg" +to use "@PJL RDYMSG DISPLAY". The default is "job".

+ +

Examples:

+ +
+*% Display job information using @PJL SET RDYMSG DISPLAY="foo"
+*cupsPJLDisplay: "rdymsg"
+
+*% Display job information display
+*cupsPJLDisplay: "none"
+

CUPS 1.2cupsPortMonitor

@@ -1588,6 +1605,17 @@ the device.

Change History

+

Changes in CUPS 1.4

+ + + +

Changes in CUPS 1.3.1