]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Track cover pages in page range handling
authorAidan Van Dyk <aidan@ifax.com>
Wed, 1 Oct 2008 20:03:39 +0000 (20:03 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Wed, 1 Oct 2008 20:03:39 +0000 (20:03 +0000)
Making the "page range" be inclusive of everything is problematic, since
continuation cover pages can "change" the pages of a document.  This
tracks cover pages, and makes the page-range handling exlude cover pages
from it's range handling.

faxd/FaxRequest.c++
faxd/FaxRequest.h
faxd/faxQueueApp.c++
faxd/mkhash.c
man/sendfax.1

index ef178be16bd0b85736e46e2cb60bb30431b14b5b..79a51148cbfecae44b587ff6ea5fc3da7c07d759 100644 (file)
@@ -58,7 +58,7 @@ FaxRequest::reset(void)
     pri = (u_short) -1;
     usrpri = FAX_DEFPRIORITY;
     pagewidth = pagelength = resolution = 0;
-    npages = totpages = skippages = 0;
+    npages = totpages = skippages = coverpages = 0;
     ntries = ndials = 0;
     minbr = BR_2400;
     desiredbr = BR_33600;
@@ -127,6 +127,7 @@ FaxRequest::shortval FaxRequest::shortvals[] = {
     { "npages",                &FaxRequest::npages },
     { "totpages",      &FaxRequest::totpages },
     { "skippages",     &FaxRequest::skippages },
+    { "coverpages",    &FaxRequest::coverpages },
     { "ntries",                &FaxRequest::ntries },
     { "ndials",                &FaxRequest::ndials },
     { "totdials",      &FaxRequest::totdials },
@@ -341,6 +342,7 @@ FaxRequest::readQFile(bool& rejectJob)
        case H_DONEOP:          doneop = tag; break;
        case H_RETURNED:        status = (FaxSendStatus) atoi(tag); break;
        case H_MINBR:           minbr = atoi(tag); break;
+       case H_COVERPAGES:      coverpages = atoi(tag); break;
 
        case H_STATUS:
            /*
index 54c8032c52c3cf43b8d089fa656666199681813f..46ebc147f3b54447e3870e541c3fa7f1edb96e99 100644 (file)
@@ -114,6 +114,7 @@ public:
     u_short    totpages;       // total cummulative pages in documents
     u_short    skippages;      // skipped pages in documents
     u_short    npages;         // total pages sent/received
+    u_short    coverpages;     // number of cover pages 1st
     u_short    ntries;         // # tries to send current page
     u_short    ndials;         // # consecutive failed tries to call dest
     u_short    totdials;       // total # calls to dest
index 6274896bc5c8fcd9ef9559d3e3ed9b4574cab4a2..d0306eb13b1a2c338049b7941ea47e523ea0ca65 100644 (file)
@@ -832,6 +832,7 @@ faxQueueApp::preparePageHandling(Job& job, FaxRequest& req,
     req.skippages = 0;
     bool firstpage = true;
     bool skiplast = false;
+    bool coverdoc = false;
     for (u_int i = 0;;) {
        if (!tif || TIFFLastDirectory(tif)) {
            /*
@@ -859,6 +860,12 @@ faxQueueApp::preparePageHandling(Job& job, FaxRequest& req,
                return (true);
            }
            const FaxItem& fitem = req.items[i];
+
+           if (fitem.item.find(0, "/cover") < fitem.item.length())
+               coverdoc = true;
+           else
+               coverdoc = false;
+
            tif = TIFFOpen(fitem.item, "r");
            if (tif == NULL) {
                result = Status(314, "Can not open document file %s", (const char*)fitem.item);
@@ -900,7 +907,10 @@ faxQueueApp::preparePageHandling(Job& job, FaxRequest& req,
        next = params;
        setupParams(tif, next, info);
 
-       u_int p = req.totpages;
+       if (coverdoc)
+           req.coverpages++;
+
+       u_int p = req.totpages - req.coverpages;
 
        if (!firstpage) {
            /*
@@ -916,7 +926,7 @@ faxQueueApp::preparePageHandling(Job& job, FaxRequest& req,
            if (skiplast) {     // skip previous page
                req.skippages++;
                req.pagehandling.append('X');
-               if (range.contains(p))
+               if (coverdoc || range.contains(p))
                {
                    req.pagehandling.replace('#', c);
                    skiplast = false;
@@ -930,7 +940,7 @@ faxQueueApp::preparePageHandling(Job& job, FaxRequest& req,
                req.pagehandling.append(c);
            }
        } else {
-           if (! range.contains(p))
+           if (! (coverdoc || range.contains(p)) )
                skiplast = true;
            firstpage = false;
        }
index 1c9aa3748979a9c189cfe594cf1be8d5e9dcaa51..98c9a51f87275214e9eeac47a6ce6bb5d44b7a68 100644 (file)
@@ -102,6 +102,7 @@ main()
     hash("subaddr");
     hash("passwd");
     hash("state");
+    hash("coverpages");
     hash("npages");
     hash("totpages");
     hash("skippages");
index 3d91cc4ae3273ff65a3c0d76e8a5f56988efd961..b9090d705f06327d9ff5ea0c6a078cf36df79217 100644 (file)
@@ -678,11 +678,15 @@ server process that does the submission work on the
 remote machine is also displayed.
 .TP 12
 .BI \-Z " range"
-Specify that only certain pages of the fax should actually
-be transmitted.  The range is in a comma-seperated list of ranges in the
-form of A[-B][,....].  The range is specified agains the resulting document to be
-faxed, so if you have more than one document, and cover pages, make sure to account
-for them in the range specification.
+Specify that only certain pages of the fax should actually be transmitted.  The
+range is in a comma-seperated list of ranges in the form of A[-B][,....].  The
+range is specified agains the resulting document to be faxed, excluding any
+cover pages.  So if you have more than one document, make sure to account for
+them, and exclude the cover pages in the range specification.  Cover pages will
+always be faxed, so a fax with a coverpage and 2 5 page documents with a range
+specified of of 1,3,10 will fax the cover page, and pages 1, 3, and 10 of the
+combined documents (page 1 and 3 from the first document, and page 5 of the
+second document).
 .SH "CONFIGURATION PARAMETERS"
 .I sendfax
 reads configuration information from the files