]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 424: include Caller-ID into FaxRecvInfo and record in recvstats
authorLee Howard <faxguy@howardsilvan.com>
Sat, 28 Feb 2004 18:02:51 +0000 (18:02 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Sat, 28 Feb 2004 18:02:51 +0000 (18:02 +0000)
         and also include into the TIFF tags for faxinfo reporting

26 files changed:
faxd/Class1.h
faxd/Class1Recv.c++
faxd/Class2.h
faxd/Class2Recv.c++
faxd/CopyQuality.c++
faxd/FaxAcctInfo.c++
faxd/FaxAcctInfo.h
faxd/FaxModem.h
faxd/FaxPoll.c++
faxd/FaxRecv.c++
faxd/FaxServer.h
faxd/faxGettyApp.c++
faxd/faxGettyApp.h
faxd/faxSendApp.c++
faxd/pageSendApp.c++
hfaxd/RecvQueue.c++
man/faxstat.1
man/recvstats.1m
man/xferfaxlog.4f
util/FaxClient.c++
util/FaxRecvInfo.c++
util/FaxRecvInfo.h
util/faxinfo.c++
util/faxrcvd.sh.in
util/recvstats.sh.in
util/xferfaxstats.sh.in

index dde806b99be6b81013701b0d5f6bad991722cca8..68b435b4000d5fa2e12630788d2d0e2813bf32bd 100644 (file)
@@ -192,7 +192,7 @@ public:
     bool       setupReceive();
     bool       recvBegin(fxStr& emsg);
     bool       recvEOMBegin(fxStr& emsg);
-    bool       recvPage(TIFF*, u_int& ppm, fxStr& emsg);
+    bool       recvPage(TIFF*, u_int& ppm, fxStr& emsg, const fxStr& id);
     bool       recvEnd(fxStr& emsg);
     void       recvAbort();
 
index fc281b490a89477f50cbecbc48ecd954e749b0bd..4d2dbbc2d6c8b3a9d21638bce027d0242bd28d42 100644 (file)
@@ -411,7 +411,7 @@ const u_int Class1Modem::modemPPMCodes[8] = {
  * sending a post-page response in a multi-page document.
  */
 bool
-Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg)
+Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg, const fxStr& id)
 {
     if (/* sendingHDLC */ lastPPM == FCF_MPS && prevPage && pageGood && !sentERR) {
        // sendingHDLC = false
@@ -480,7 +480,7 @@ Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg)
                 * receive the Phase C data.
                 */
                protoTrace("RECV: begin page");
-               recvSetupTIFF(tif, group3opts, FILLORDER_LSB2MSB);
+               recvSetupTIFF(tif, group3opts, FILLORDER_LSB2MSB, id);
                pageGood = recvPageData(tif, emsg);
                protoTrace("RECV: end page");
                if (!wasTimeout()) {
index 32726f9b2e96fdfe00704412c716371d20462edd..eb459e6746d795e9779c208d2766671fa900a610 100644 (file)
@@ -147,7 +147,7 @@ public:
     bool       setupReceive();
     bool       recvBegin(fxStr& emsg);
     bool       recvEOMBegin(fxStr& emsg);
-    bool       recvPage(TIFF*, u_int& ppm, fxStr& emsg);
+    bool       recvPage(TIFF*, u_int& ppm, fxStr& emsg, const fxStr& id);
     bool       recvEnd(fxStr& emsg);
     void       recvAbort();
 
index acbeae19236426b177e0c32a2e558d44cdbe643c..feb088014e8e0e4a729647ae5e3b97de385e15c1 100644 (file)
@@ -139,7 +139,7 @@ Class2Modem::recvDCS(const char* cp)
  * received post-page-message.
  */
 bool
-Class2Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg)
+Class2Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg, const fxStr& id)
 {
     int ppr;
     bool prevPage = false;
@@ -196,7 +196,7 @@ Class2Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg)
         * NB: always write data in LSB->MSB for folks that
         *     don't understand the FillOrder tag!
         */
-       recvSetupTIFF(tif, group3opts, FILLORDER_LSB2MSB);
+       recvSetupTIFF(tif, group3opts, FILLORDER_LSB2MSB, id);
        if (!recvPageData(tif, emsg)) {
            prevPage = false;
            goto bad;
index 7e63821b4bcdb69cdf7584c1c11ad0648207c170..89c4e33c4b785c58e63568c06423e3c34a598284 100644 (file)
@@ -311,7 +311,7 @@ FaxModem::recvPageDLEData(TIFF* tif, bool checkQuality,
  * Setup "stock TIFF tags" in preparation for receiving a page of data.
  */
 void
-FaxModem::recvSetupTIFF(TIFF* tif, long, int fillOrder)
+FaxModem::recvSetupTIFF(TIFF* tif, long, int fillOrder, const fxStr& id)
 {
     TIFFSetField(tif, TIFFTAG_SUBFILETYPE,     FILETYPE_PAGE);
     TIFFSetField(tif, TIFFTAG_IMAGEWIDTH,      (uint32) params.pageWidth());
@@ -326,7 +326,7 @@ FaxModem::recvSetupTIFF(TIFF* tif, long, int fillOrder)
     TIFFSetField(tif, TIFFTAG_YRESOLUTION,     (float) params.verticalRes());
     TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT,  RESUNIT_INCH);
     TIFFSetField(tif, TIFFTAG_SOFTWARE,                HYLAFAX_VERSION);
-    TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION,        (const char*) tsi);
+    TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION,        (const char*) id);
     char dateTime[24];
     time_t now = Sys::now();
     strftime(dateTime, sizeof (dateTime), "%Y:%m:%d %H:%M:%S", localtime(&now));
index aa8739d04073748a3e6eb140d4e0276e489c8025..776acd88d2b3150bc4a629a5a9379488e6baaba7 100644 (file)
@@ -70,6 +70,8 @@ FaxAcctInfo::record(const char* cmd) const
        record.fput("\t%s", fmtTime(duration)); // $12 = duration
        record.fput("\t%s", fmtTime(conntime)); // $13 = conntime
        record.fput("\t\"%s\"", status);        // $14 = status
+       record.fput("\t\"%s\"", cidname);       // $15 = CIDName
+       record.fput("\t\"%s\"", cidnumber);     // $16 = CIDNumber
        record.put('\n');
        flock(fd, LOCK_EX);
        ok = (Sys::write(fd, record, record.getLength()) == (ssize_t)record.getLength());
index 0aa8edae0167950f8b5b5037d5e8a496b38170e9..f8d227e8f4b5652bf00fcceecb48d0881f82b0ce 100644 (file)
@@ -43,6 +43,8 @@ struct FaxAcctInfo {
     u_int      npages;         // pages successfully sent/rcvd
     u_int      params;         // encoded transfer parameters
     const char*        status;         // status info (optional)
+    const char*        cidname;        // caller id name
+    const char*        cidnumber;      // caller id number
 
     bool record(const char* cmd) const;
 };
index f1dbebc44a8fdd58e2384928b662ce3e3d273ace..87c51d629d8e97c44f201f623b6918a6cc8da073 100644 (file)
@@ -124,7 +124,7 @@ protected:
     void       recvNSF(const NSF&);
     void       recvCSI(const fxStr&);
     void       recvDCS(const Class2Params&);
-    void       recvSetupTIFF(TIFF* tif, long group3opts, int fillOrder);
+    void       recvSetupTIFF(TIFF* tif, long group3opts, int fillOrder, const fxStr& id);
     void       recvStartPage(TIFF* tif);
     void       recvResetPage(TIFF* tif);
     u_int      decodePageChop(const fxStr& pph, const Class2Params&);
@@ -263,7 +263,7 @@ public:
     virtual bool setupReceive() = 0;
     virtual bool recvBegin(fxStr& emsg);
     virtual bool recvEOMBegin(fxStr& emsg);
-    virtual bool recvPage(TIFF*, u_int& ppm, fxStr& em) = 0;
+    virtual bool recvPage(TIFF*, u_int& ppm, fxStr& em, const fxStr& id) = 0;
     virtual bool recvEnd(fxStr& emsg) = 0;
     virtual void recvAbort() = 0;
     virtual void recvSucceeded();
index cb5ad6e4c4909d244cc04b1a94e352c241cca5e3..6fa85ed9090cc14ea662df301307427206218c3f 100644 (file)
@@ -55,6 +55,7 @@ FaxServer::pollFaxPhaseB(const fxStr& sep, const fxStr& pwd, FaxRecvInfoArray& d
        recvPages = 0;                  // count of received pages
        fileStart = Sys::now();         // count initial negotiation on failure
        if (modem->pollBegin(canonicalizePhoneNumber(FAXNumber), sep, pwd, emsg)) {
+           const CallerID cid;         // null
            pollOK = recvDocuments(tif, info, docs, emsg);
            if (!pollOK)
                traceProtocol("POLL FAX: %s", (const char*) emsg);
index fe50f5059600c5a00ecbbdceb4660ba2763a9357..fd418634e28a8533d2f4c9597a6464c832820cb7 100644 (file)
@@ -58,6 +58,8 @@ FaxServer::recvFax(const CallerID& cid)
      * after recvBegin can cause part of the first page to
      * be lost.)
      */
+    info.cidname = cid.name;
+    info.cidnumber = cid.number;
     TIFF* tif = setupForRecv(info, docs, emsg);
     if (tif) {
        recvPages = 0;                  // total count of received pages
@@ -96,11 +98,7 @@ FaxServer::recvFax(const CallerID& cid)
        else
            Sys::chmod(ri.qfile, recvFileMode);
        if (faxRecognized)
-           // It would be cleaner and more versatile to include
-           // cid as part of ri now instead of continuing to
-           // pass it along.  This would require alterations to
-           // FaxRecvInfo, though - not as simple an approach.
-           notifyRecvDone(ri, cid);
+           notifyRecvDone(ri);
     }
     traceProtocol("RECV FAX: end");
     return (faxRecognized);
@@ -253,12 +251,16 @@ FaxServer::recvDocuments(TIFF* tif, FaxRecvInfo& info, FaxRecvInfoArray& docs, f
 bool
 FaxServer::recvFaxPhaseD(TIFF* tif, FaxRecvInfo& info, u_int& ppm, fxStr& emsg)
 {
+    fxStr id = info.sender;
+    if (info.cidname.length() || info.cidnumber.length()) id.append("\n" | info.cidname);
+    if (info.cidnumber.length()) id.append("\n" | info.cidnumber);
+
     do {
        if (++recvPages > maxRecvPages) {
            emsg = "Maximum receive page count exceeded, job terminated";
            return (false);
        }
-       if (!modem->recvPage(tif, ppm, emsg))
+       if (!modem->recvPage(tif, ppm, emsg, id))
            return (false);
        info.npages++;
        info.time = (u_int) getPageTransferTime();
@@ -317,7 +319,7 @@ FaxServer::notifyDocumentRecvd(const FaxRecvInfo& ri)
  * Handle final actions associated with a document being received.
  */
 void
-FaxServer::notifyRecvDone(const FaxRecvInfo& ri, const CallerID& cid)
+FaxServer::notifyRecvDone(const FaxRecvInfo& ri)
 {
     if (ri.reason != "")
        traceServer("RECV FAX (%s): session with %s terminated abnormally: %s"
index 8c8db8c7d01b2329516a32d2be48beb51446ab79..37b50086eb9a82744e912ef598a696d89eb61599 100644 (file)
@@ -108,7 +108,7 @@ protected:
     virtual void notifyRecvBegun(const FaxRecvInfo&);
     virtual void notifyPageRecvd(TIFF* tif, const FaxRecvInfo&, int ppm);
     virtual void notifyDocumentRecvd(const FaxRecvInfo& req);
-    virtual void notifyRecvDone(const FaxRecvInfo& req, const CallerID& cid);
+    virtual void notifyRecvDone(const FaxRecvInfo& req);
 public:
     virtual ~FaxServer();
 
index 52b366a7458e828699643623a5ab752d92ca5b0f..83e2a8c147b2dfd9493de43a6d1eaad6cd8c4618 100644 (file)
@@ -715,6 +715,8 @@ faxGettyApp::notifyDocumentRecvd(const FaxRecvInfo& ri)
     ai.status = ri.reason;
     ai.jobid = "";
     ai.jobtag = "";
+    ai.cidname = ri.cidname;
+    ai.cidnumber = ri.cidnumber;
     if (!ai.record("RECV"))
        logError("Error writing RECV accounting record, dest=%s",
            (const char*) ai.dest);
@@ -724,9 +726,9 @@ faxGettyApp::notifyDocumentRecvd(const FaxRecvInfo& ri)
  * Handle notification that a document has been received.
  */
 void
-faxGettyApp::notifyRecvDone(const FaxRecvInfo& ri, const CallerID& cid)
+faxGettyApp::notifyRecvDone(const FaxRecvInfo& ri)
 {
-    FaxServer::notifyRecvDone(ri, cid);
+    FaxServer::notifyRecvDone(ri);
 
     // hand to delivery/notification command
     fxStr cmd(faxRcvdCmd
@@ -734,8 +736,8 @@ faxGettyApp::notifyRecvDone(const FaxRecvInfo& ri, const CallerID& cid)
        | quote |   getModemDeviceID()  | enquote
        | quote |           getCommID() | enquote
        | quote |            ri.reason  | enquote
-       | quote |           cid.number  | enquote
-       | quote |             cid.name  | enquote
+       | quote |         ri.cidnumber  | enquote
+       | quote |           ri.cidname  | enquote
     );
     traceServer("RECV FAX: %s", (const char*) cmd);
     setProcessPriority(BASE);                  // lower priority
index 355cae8dd17a13e0f292065cca2331a1ff76c06f..69d9ac843da34aecc55b040a098acd61f956acda 100644 (file)
@@ -136,7 +136,7 @@ private:
     void       notifyRecvBegun(const FaxRecvInfo&);
     void       notifyPageRecvd(TIFF* tif, const FaxRecvInfo&, int ppm);
     void       notifyDocumentRecvd(const FaxRecvInfo&);
-    void       notifyRecvDone(const FaxRecvInfo&, const CallerID&);
+    void       notifyRecvDone(const FaxRecvInfo&);
 public:
     faxGettyApp(const fxStr& device, const fxStr& devID);
     ~faxGettyApp();
index ff50a5e85969bcc26c37de8e639bb164244dceaa..da85ebf9c9a05c9475ca5ee54f72def9b8203cf0 100644 (file)
@@ -164,6 +164,8 @@ faxSendApp::send(const char* filename)
                ai.jobtag = req->jobtag;
                ai.user = req->mailaddr;
                ai.csi = info.getCSI();
+               ai.cidname = "";
+               ai.cidnumber = "";
                if (req->status == send_done)
                    ai.status = "";
                else
@@ -303,6 +305,8 @@ faxSendApp::notifyPollRecvd(FaxRequest& req, const FaxRecvInfo& ri)
     ai.status = ri.reason;
     ai.jobid = req.jobid;
     ai.jobtag = req.jobtag;
+    ai.cidname = "";
+    ai.cidnumber = "";
     if (!ai.record("POLL"))
        logError("Error writing POLL accounting record, dest=%s",
            (const char*) ai.dest);
index 8e6328892b89994c6cc80e23f58c44e16cfeeff1..ad74715b852dd529a3553687f191ca58d7566d52 100644 (file)
@@ -139,6 +139,8 @@ pageSendApp::send(const char* filename)
                    ai.dest = req->external;
                    ai.csi = "";
                    ai.params = 0;
+                   ai.cidname = "";
+                   ai.cidnumber = "";
                    if (req->status == send_done)
                        ai.status = "";
                    else
index 5c2198922bdc8acfa1b1ade1ada948643ba60730..d9e8f880992ffbe645275ca5f28baaf8ca66f6f2 100644 (file)
@@ -137,9 +137,31 @@ HylaFAXServer::getRecvDocStatus(RecvInfo& ri)
     }
 #endif
     char* cp;
+    ri.sender = "";
+    ri.cidname = "";
+    ri.cidnumber = "";
     if (TIFFGetField(tif, TIFFTAG_IMAGEDESCRIPTION, &cp)) {
-       ri.sender = cp;
+       while (cp[0] != '\0' and cp[0] != '\n') {       // sender 
+           ri.sender.append(cp[0]);
+           cp++;
+       }
+       if (cp[0] == '\n') {
+           cp++;
+           while (cp[0] != '\0' and cp[0] != '\n') {   // cidname
+               ri.cidname.append(cp[0]);
+               cp++;
+           }
+       }
+       if (cp[0] == '\n') {
+           cp++;
+           while (cp[0] != '\0' and cp[0] != '\n') {   // cidnumber
+               ri.cidnumber.append(cp[0]);
+               cp++;
+           }
+       }
        sanitize(ri.sender);
+       sanitize(ri.cidname);
+       sanitize(ri.cidnumber);
     } else
        ri.sender = "<unknown>";
 #ifdef TIFFTAG_FAXSUBADDRESS
@@ -279,8 +301,8 @@ static const char rformat[] = {
     's',               // f (filename)
     'g',               // g
     's',               // h (time spent receiving)
-    'i',               // i
-    'j',               // j
+    's',               // i (CIDName)
+    's',               // j (CIDNumber)
     'k',               // k
     'u',               // l (pagelength)
     's',               // m (protection mode)
@@ -384,6 +406,12 @@ HylaFAXServer::Rprintf(FILE* fd, const char* fmt,
            case 'h':
                fprintf(fd, fspec, fmtTime(ri.time));
                break;
+           case 'i':
+               fprintf(fd, fspec, (const char*) ri.cidname);
+               break;
+           case 'j':
+               fprintf(fd, fspec, (const char*) ri.cidnumber);
+               break;
            case 'l':
                fprintf(fd, fspec, ri.params.pageLength());
                break;
index c42076e9e5b949cb8951205043fff8a409e460da..667d124e1458b46312661b347cb905f47086ca1f 100644 (file)
@@ -436,6 +436,8 @@ d   Data format used during receive
 e      Error description if an error occurred during receive
 f      Document filename (relative to the \fBrecvq\fP directory)
 h      Time spent receiving document (HH:MM:SS)
+i      CIDName value for received fax
+j      CIDNumber value for received fax
 l      Page length in mm
 m      Fax-style protection mode string (``-rwxrwx'')
 n      File size (number of bytes)
index 2cc147f6ee73f21dc61d0ff3e4c9347ab0bca1bb..f9568222424f2e38ac0b870c13aae8cfff86333d 100644 (file)
@@ -42,8 +42,8 @@ recvstats \- summarize \*(Fx receive accounting information
 is a command script that prints a summary of the \*(Fx
 accounting statistics for received facsimile.
 The statistics can be sorted using one of several keys:
-the caller's \s-1CSI\s+1 (default),
-the communication speed, and
+the caller's \s-1CSI\s+1 (default), CIDName, CIDNumber,
+the communication speed, or
 the communication data format.
 Statistics are read from the file
 .B ${SPOOL}/etc/xferfaxlog
@@ -54,26 +54,26 @@ The following table is an example of the output from
 (using the default sort key):
 .sp .5
 .nf
-.ta \w'\s-1ALDUS CORPORATION\s+1   'u +\w'Pages   'u +\w'15:03:58  'u +\w'Pg/min   'u +\w'Errs   'u +\w'TypRate   'u
-\fBSender      Pages   Time    Pg/min  Errs    TypRate TypData\fP
-       61      30:47   2.0     16      9600    1-D     MR
-+13037904674   5       1:34    3.2     2       9600    1-D     MH
-+14159657824   1       1:00    1.0     0       9600    1-D     MH
-+15086636852   2       0:00    2.0     0       9600    1-D     MH
-+15105268781   740     5:47:51 2.1     59      9600    1-D     MH
-+15105287164   20      7:00    2.9     0       9600    1-D     MH
-+15123713545   3       1:19    2.3     0       9600    1-D     MH
-+15123713641   5       1:04    4.6     0       9600    1-D     MH
-+16099211926   3       2:00    1.5     0       9600    1-D     MH
-+17088987617   1       0:18    3.3     0       9600    1-D     MH
-415 390 6175   22      6:01    3.6     0       9600    1-D     MH
-415 965 7651   56      34:52   1.6     14      9600    1-D     MH
-415 973 6723   1       2:09    0.5     0       9600    2-D     MR
-49 211 161514  1       0:00    1.0     0       9600    2-D     MR
-8185970503     1       0:28    2.1     0       9600    2-D     MR
-\s-1ALDUS CORPORATION\s+1      3       2:34    1.2     0       9600    1-D     MH
-------------------------------------------------------------
-Total  925     7:19:03 2.1     91
+.ta \w'\s-1ALDUS CORPORATION\s+1   'u +\w'1234567890'u +\w'1234567890'u +\w'Pages   'u +\w'15:03:58  'u +\w'Pg/min   'u +\w'Errs   'u +\w'TypRate   'u
+\fBSender      CIDName CIDNumber       Pages   Time    Pg/min  Errs    TypRate TypData\fP
+                       61      30:47   2.0     16      9600    1-D     MR
++13037904674                   5       1:34    3.2     2       9600    1-D     MH
++14159657824                   1       1:00    1.0     0       9600    1-D     MH
++15086636852                   2       0:00    2.0     0       9600    1-D     MH
++15105268781                   740     5:47:51 2.1     59      9600    1-D     MH
++15105287164                   20      7:00    2.9     0       9600    1-D     MH
++15123713545                   3       1:19    2.3     0       9600    1-D     MH
++15123713641                   5       1:04    4.6     0       9600    1-D     MH
++16099211926                   3       2:00    1.5     0       9600    1-D     MH
++17088987617                   1       0:18    3.3     0       9600    1-D     MH
+415 390 6175                   22      6:01    3.6     0       9600    1-D     MH
+415 965 7651                   56      34:52   1.6     14      9600    1-D     MH
+415 973 6723                   1       2:09    0.5     0       9600    2-D     MR
+49 211 161514                  1       0:00    1.0     0       9600    2-D     MR
+8185970503                     1       0:28    2.1     0       9600    2-D     MR
+\s-1ALDUS CORPORATION\s+1      ALDUS CO        5551212 3       2:34    1.2     0       9600    1-D     MH
+--------------------------------------------------------------------------------------------------
+Total                  925     7:19:03 2.1     91
 .sp .5
 .fi
 The
@@ -81,6 +81,12 @@ The
 column shows the caller's \s-1TSI\s+1 (notice that some callers have
 not setup a \s-1TSI\s+1).
 The
+.I CIDName
+column is the received CIDName value for the sender.
+The
+.I CIDNumber
+column is the received CIDNumber value for the sender.
+The
 .I Pages
 column is the total number of good pages received.
 The
@@ -108,6 +114,12 @@ data were received.
 Sort output by caller's
 .SM CSI.
 .TP 12
+.B \-cidname
+Sort output by CIDName
+.TP 12
+.B \-cidnumber
+Sort output by CIDNumber
+.TP 12
 .B \-format
 Sort output by data format.
 .TP 12
index 42ef61f29ada374286bb8f83f5142b4c7b229f0f..06276e78014d4a6296522b4c4cd9363cb0abadd2 100644 (file)
@@ -44,24 +44,24 @@ strings.
 Each record of a facsimile transmission is of the form:
 .sp .5
 .ti +0.5i
-date \s-1SEND\s+1 commid modem jobid jobtag sender ``dest-number'' ``\s-1CSI\s+1'' params #pages jobtime conntime ``reason''
+date \s-1SEND\s+1 commid modem jobid jobtag sender ``dest-number'' ``\s-1CSI\s+1'' params #pages jobtime conntime ``reason'' \fI<null>\fP \fI<null>\fP
 .sp .5
 .PP
 A facsimile reception record is of the form:
 .sp .5
 .ti +0.5i
-date \s-1RECV\s+1 commid modem \fI<null>\fP \fI<null>\fP fax ``local-number'' ``\s-1TSI\s+1'' params #pages jobtime conntime ``reason''
+date \s-1RECV\s+1 commid modem \fI<null>\fP \fI<null>\fP fax ``local-number'' ``\s-1TSI\s+1'' params #pages jobtime conntime ``reason'' ``CIDName'' ``CIDNumber''
 .sp .5
 .PP
 Each facsimile document retrieved by polling has a record of the form:
 .sp .5
 .ti +0.5i
-date \s-1POLL\s+1 commid modem jobid jobtag sender ``dest-number'' ``\s-1TSI\s+1'' params #pages jobtime conntime ``reason''
+date \s-1POLL\s+1 commid modem jobid jobtag sender ``dest-number'' ``\s-1TSI\s+1'' params #pages jobtime conntime ``reason'' \fI<null>\fP \fI<null>\fP
 .sp .5
 An alphanumeric pager request has a record of the form:
 .sp .5
 .ti +0.5i
-date \s-1PAGE\s+1 commid modem jobid jobtag sender ``dest-number'' ``\fI<null>\fP'' 0 0 jobtime conntime ``reason''
+date \s-1PAGE\s+1 commid modem jobid jobtag sender ``dest-number'' ``\fI<null>\fP'' 0 0 jobtime conntime ``reason'' \fI<null>\fP \fI<null>\fP
 .sp .5
 .PP
 The following describes the fields in the above records:
@@ -129,6 +129,12 @@ This should be the time used by the PTT to calculate usage charges.
 .TP 14
 .B reason
 A string that indicates if any problem occured during the session.
+.TP 14
+.B CIDName
+The received CIDName value for the session.
+.TP 14
+.B CIDNumber
+The received CIDNumber value for the session.
 .PP
 Note that fields may have embedded blanks.
 Session parameters are encoded as a decimal number that contains
index eccd582f88f59a324c608f6771aabc82f6ca9915..17bb1a6ec142b9768e8cffa6ba848140e0003f02 100644 (file)
@@ -1647,6 +1647,8 @@ const FaxClient::FaxFmtHeader FaxClient::recvFormats[] = {
     { 'e',     "Error" },      // e (error description)
     { 'f',     "Filename" },   // f (filename)
     { 'h',     "Time" },       // h (time spent receiving)
+    { 'i',     "CIDName" },    // i (caller id name)
+    { 'j',     "CIDNumber" },  // j (caller id number)
     { 'l',     "Length" },     // l (pagelength)
     { 'm',     "Protect" },    // m (fax-style protection mode, no group bits)
     { 'n',     "Size" },       // n (file size)
index d2259941f73d887b0e0990c40861bca1b9f69bff..3bb0a0a5348b9255a99e10da9ddc2f1fb1372665 100644 (file)
@@ -38,6 +38,8 @@ FaxRecvInfo::FaxRecvInfo(const FaxRecvInfo& other)
     , subaddr(other.subaddr)
     , params(other.params)
     , reason(other.reason)
+    , cidname(other.cidname)
+    , cidnumber(other.cidnumber)
 {
     npages = other.npages;
     time = other.time;
@@ -47,7 +49,7 @@ FaxRecvInfo::~FaxRecvInfo() {}
 fxStr
 FaxRecvInfo::encode() const
 {
-    return fxStr::format("%x,%x,%x,%s,%s,\"%s\",\"%s\",\"%s\""
+    return fxStr::format("%x,%x,%x,%s,%s,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\""
        , time
        , npages
        , params.encode()
@@ -56,6 +58,8 @@ FaxRecvInfo::encode() const
        , (const char*) sender
        , (const char*) subaddr
        , (const char*) reason
+       , (const char*) cidname
+       , (const char*) cidnumber
     );
 }
 
@@ -94,5 +98,15 @@ FaxRecvInfo::decode(const char* cp)
        return (false);
     reason = cp+3;                     // +1 for "/+1 for ,/+1 for "
     reason.resize(reason.next(0,'"'));
+    cp = strchr(cp+1, '"');
+    if (cp == NULL || cp[1] != ',' || cp[2] != '"')
+       return (false);
+    reason = cp+3;                     // +1 for "/+1 for ,/+1 for "
+    cidname.resize(cidname.next(0,'"'));
+    cp = strchr(cp+1, '"');
+    if (cp == NULL || cp[1] != ',' || cp[2] != '"')
+       return (false);
+    reason = cp+3;                     // +1 for "/+1 for ,/+1 for "
+    cidnumber.resize(cidnumber.next(0,'"'));
     return (true);
 }
index e721fd81aaa96add5d4ca4e71bcf87f60df86e75..722f9dcfda60c79fef135c188b702bf582a41933 100644 (file)
@@ -42,6 +42,8 @@ public:
     u_int      time;           // time on the phone
     Class2Params params;       // transfer parameters
     fxStr      reason;         // reason for failure (if not null)
+    fxStr      cidname;        // caller id name
+    fxStr      cidnumber;      // caller id number
 
     FaxRecvInfo();
     FaxRecvInfo(const FaxRecvInfo& other);
index f84b5778eb0df4a31681d3941ff508163f522f39..f54d227f3c8bc153846a30f5b929e6a9d9f7da1b 100644 (file)
@@ -140,11 +140,32 @@ main(int argc, char** argv)
 #ifdef TIFFTAG_FAXRECVPARAMS
     }
 #endif
-    fxStr sender;
+    fxStr sender = "";
+    fxStr cidname = "";
+    fxStr cidnumber = "";
     char* cp;
     if (TIFFGetField(tif, TIFFTAG_IMAGEDESCRIPTION, &cp)) {
-       sender = cp;
+       while (cp[0] != '\0' && cp[0] != '\n') {        // sender
+           sender.append(cp[0]);
+           cp++;
+       }
+       if (cp[0] == '\n') {
+           cp++;
+           while (cp[0] != '\0' && cp[0] != '\n') {    // cidname
+               cidname.append(cp[0]);
+               cp++;
+           }
+       }
+       if (cp[0] == '\n') {
+           cp++;
+           while (cp[0] != '\0' && cp[0] != '\n') {    // cidnumber
+               cidnumber.append(cp[0]);
+               cp++;
+           }
+       }
        sanitize(sender);
+       sanitize(cidname);
+       sanitize(cidnumber);
     } else
        sender = "<unknown>";
     printf("%11s %s\n", "Sender:", (const char*) sender);
@@ -215,5 +236,9 @@ main(int argc, char** argv)
     printf("%11s %s\n", "TimeToRecv:", time == 0 ? "<unknown>" : fmtTime(time));
     printf("%11s %s\n", "SignalRate:", params.bitRateName());
     printf("%11s %s\n", "DataFormat:", params.dataFormatName());
+    if (cidname != "")
+       printf("%11s %s\n", "CIDName:", (const char*) cidname);
+    if (cidnumber != "")
+       printf("%11s %s\n", "CIDNumber:", (const char*) cidnumber);
     return (0);
 }
index aa24cd5cd99e4a64515f1ea7894cc506d9d92e25..efe5bd65c3b37599b09c1e334d8431cd5b2d1529 100644 (file)
@@ -173,12 +173,6 @@ if [ -f $FILE ]; then
        else
            echo "    CommID: c$COMMID (ftp://$HOSTNAME:$PORT/log/c$COMMID)"
        fi
-       if [ "$CIDNUMBER" ]; then
-           echo " CIDNumber: $CIDNUMBER"
-       fi
-       if [ "$CIDNAME" ]; then
-           echo "   CIDName: $CIDNAME"
-       fi
        if [ -n "$SENDTO" ]; then
            echo ""
            echo "The facsimile was automatically dispatched to: $SENDTO." 
@@ -220,12 +214,6 @@ if [ -f $FILE ]; then
         else
            echo "    CommID: c$COMMID (ftp://$HOSTNAME:$PORT/log/c$COMMID)"
         fi
-        if [ "$CIDNUMBER" ]; then
-           echo " CIDNumber: $CIDNUMBER"
-        fi
-        if [ "$CIDNAME" ]; then
-           echo "   CIDName: $CIDNAME"
-        fi
         echo ""
         echo "--$MIMEBOUNDARY"
         if [ "$FILETYPE" = "tif" ]; then
index 2c61ed34fa788a9a5cb39c7141ae699a48324cfb..91d43246ecebb4f8c88b8060dd75a18ed1b53165 100644 (file)
@@ -58,7 +58,7 @@ SINCE=
 
 while [ x"$1" != x"" ] ; do
     case $1 in
-    -send*|-csi|-dest*|-speed|-rate|-format)
+    -send*|-csi|-dest*|-speed|-rate|-format|-cidname|-cidnumber)
            SORTKEY=$1;;
     -age)   shift; AGE=$1;;
     -since) shift; SINCE=$1;;
@@ -87,6 +87,17 @@ case $SORTKEY in
        $2 == "RECV" && NF == 12 { acct($7, $10, $11, $8, $9, $12); }
        $2 == "RECV" && NF == 13 { acct($9, $11, $12, getBR($10), getDF($10), $13); }
        $2 == "RECV" && NF == 14 { acct($9, $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "RECV" && NF == 16 { acct($9, $11, $13, getBR($10), getDF($10), $14, $15, $16); }
+       '
+    ;;
+-cidname)
+    AWKRULES='
+       $2 == "RECV" && NF == 16 { acct($15, $11, $13, getBR($10), getDF($10), $14, $15, $16); }
+       '
+    ;;
+-cidnumber)
+    AWKRULES='
+       $2 == "RECV" && NF == 16 { acct($16, $11, $13, getBR($10), getDF($10), $14, $15, $16); }
        '
     ;;
 -dest*)
@@ -95,6 +106,7 @@ case $SORTKEY in
        $2 == "RECV" && NF == 11 { acct($5, $9, $10, $7, $8, $11); }
        $2 == "RECV" && NF == 12 { acct($6, $10, $11, $8, $9, $12); }
        $2 == "RECV" && NF == 14 { acct($8, $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "RECV" && NF == 16 { acct($8, $11, $13, getBR($10), getDF($10), $14, $15, $16); }
        '
     ;;
 -speed|-rate)
@@ -104,6 +116,7 @@ case $SORTKEY in
        $2 == "RECV" && NF == 12 { acct($8, $10, $11, $8, $9, $12); }
        $2 == "RECV" && NF == 13 { acct(getBR($10), $11, $12, getBR($10), getDF($10), $13); }
        $2 == "RECV" && NF == 14 { acct(getBR($10), $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "RECV" && NF == 16 { acct(getBR($10), $11, $13, getBR($10), getDF($10), $14, $15, $16); }
        '
     ;;
 -format)
@@ -113,6 +126,7 @@ case $SORTKEY in
        $2 == "RECV" && NF == 12 { acct($9, $10, $11, $8, $9, $12); }
        $2 == "RECV" && NF == 13 { acct(getDF($10), $11, $12, getBR($10), getDF($10), $13); }
        $2 == "RECV" && NF == 14 { acct(getDF($10), $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "RECV" && NF == 16 { acct(getDF($10), $11, $13, getBR($10), getDF($10), $14, $15, $16); }
        '
     ;;
 esac
@@ -298,7 +312,7 @@ function getDF(params)
 #
 # Accumulate a statistics record.
 #
-function acct(key, pages, time, br, df, status)
+function acct(key, pages, time, br, df, status, cidname, cidnumber)
 {
     if (cvtDateTime($1) < KEEP)
        return;
@@ -316,6 +330,10 @@ function acct(key, pages, time, br, df, status)
     recvrate[key] = addToMap(recvrate[key], br, pages, rateMap);
     gsub("\"", "", df);
     recvdata[key] = addToMap(recvdata[key], df, pages, dataMap);
+    gsub("\"", "", cidname);
+    gsub("\"", "", cidnumber);
+    lastcidname[key] = cidname;
+    lastcidnumber[key] = cidnumber;
 }
 
 #
@@ -350,9 +368,9 @@ END         { OFS="\t"; setupDigits();
                      sorted[nsorted++] = i;
                  }
                  qsort(sorted, 0, nsorted-1);
-                 fmt = "%-" maxlen "." maxlen "s";     # e.g. %-24.24s
+                 fmt = "%-" maxlen "." maxlen "s" " %-" maxlen "." maxlen "s" " %-" maxlen "." maxlen "s";     # e.g. %-24.24s
                  printf fmt " %5s %8s %6s %4s %7s %7s\n",
-                     "Sender", "Pages", "Time", "Pg/min",
+                     "Sender", "CIDName", "CIDNumber", "Pages", "Time", "Pg/min",
                      "Errs", "TypRate", "TypData";
                  tpages = 0;
                  ttime = 0;
@@ -363,7 +381,7 @@ END         { OFS="\t"; setupDigits();
                      n = recvpages[i]; if (n == 0) n = 1;
                      brate = best
                      printf fmt " %5d %8s %6.1f %4d %7d %7s\n",
-                         i, recvpages[i], fmtTime(recvtime[i]),
+                         i, lastcidname[i], lastcidnumber[i], recvpages[i], fmtTime(recvtime[i]),
                          recvpages[i] / t, recverrs[i],
                          bestInMap(recvrate[i], rates),
                          bestInMap(recvdata[i], datas);
@@ -371,10 +389,10 @@ END               { OFS="\t"; setupDigits();
                        ttime += recvtime[i];
                        terrs += recverrs[i];
                  }
-                 printRule(maxlen+1+5+1+8+6+1+4+1+7+1+7, "-");
+                 printRule(maxlen+1+maxlen+1+maxlen+1+5+1+8+6+1+4+1+7+1+7, "-");
                  t = ttime/60; if (t == 0) t = 1;
                  printf fmt " %5d %8s %6.1f %4d\n",
-                     "Total", tpages, fmtTime(ttime), tpages/t, terrs;
+                     "Total", "", "", tpages, fmtTime(ttime), tpages/t, terrs;
                }
 EOF
 echo "$AWKRULES"
index 70127e94943a6041e48609f1aa7b1370aa28e33b..f743ccc6187068814f5f9805e37fd9e084e3d5b5 100644 (file)
@@ -85,6 +85,7 @@ case $SORTKEY in
        $2 == "SEND" && NF == 12 { acct($5, $6, $10, $11, $8, $9, $12); }
        $2 == "SEND" && NF == 13 { acct($7, $8, $11, $12, getBR($10), getDF($10), $13); }
        $2 == "SEND" && NF == 14 { acct($7, $8, $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "SEND" && NF == 16 { acct($7, $8, $11, $13, getBR($10), getDF($10), $14); }
        '
     KEYTITLE="Sender"
     ;;
@@ -95,6 +96,7 @@ case $SORTKEY in
        $2 == "SEND" && NF == 12 { acct($7, $6, $10, $11, $8, $9, $12); }
        $2 == "SEND" && NF == 13 { acct($9, $8, $11, $12, getBR($10), getDF($10), $13); }
        $2 == "SEND" && NF == 14 { acct($9, $8, $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "SEND" && NF == 16 { acct($9, $8, $11, $13, getBR($10), getDF($10), $14); }
        '
     KEYTITLE="CSI"
     MAPNAMES=no
@@ -106,6 +108,7 @@ case $SORTKEY in
        $2 == "SEND" && NF == 12 { acct($6, $6, $10, $11, $8, $9, $12); }
        $2 == "SEND" && NF == 13 { acct($8, $8, $11, $12, getBR($10), getDF($10), $13); }
        $2 == "SEND" && NF == 14 { acct($8, $8, $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "SEND" && NF == 16 { acct($8, $8, $11, $13, getBR($10), getDF($10), $14); }
        '
     KEYTITLE="Destination"
     MAPNAMES=no
@@ -117,6 +120,7 @@ case $SORTKEY in
        $2 == "SEND" && NF == 12 { acct($8, $6, $10, $11, $8, $9, $12); }
        $2 == "SEND" && NF == 13 { acct(getBR($10), $8, $11, $12, getBR($10), getDF($10), $13); }
        $2 == "SEND" && NF == 14 { acct(getBR($10), $8, $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "SEND" && NF == 16 { acct(getBR($10), $8, $11, $13, getBR($10), getDF($10), $14); }
        '
     KEYTITLE="Speed"
     MAPNAMES=no
@@ -128,6 +132,7 @@ case $SORTKEY in
        $2 == "SEND" && NF == 12 { acct($9, $6, $10, $11, $8, $9, $12); }
        $2 == "SEND" && NF == 13 { acct(getDF($10), $8, $11, $12, getBR($10), getDF($10), $13); }
        $2 == "SEND" && NF == 14 { acct(getDF($10), $8, $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "SEND" && NF == 16 { acct(getDF($10), $8, $11, $13, getBR($10), getDF($10), $14); }
        '
     KEYTITLE="Format"
     MAPNAMES=no
@@ -136,6 +141,7 @@ case $SORTKEY in
     AWKRULES='
        $2 == "SEND" && NF == 13 { acct($6, $8, $11, $12, getBR($10), getDF($10), $13); }
        $2 == "SEND" && NF == 14 { acct($6, $8, $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "SEND" && NF == 16 { acct($6, $8, $11, $13, getBR($10), getDF($10), $14); }
        '
     KEYTITLE="JobTag"
     MAPNAMES=no
@@ -144,6 +150,7 @@ case $SORTKEY in
     AWKRULES='
        $2 == "SEND" && NF == 13 { acct($4, $8, $11, $12, getBR($10), getDF($10), $13); }
        $2 == "SEND" && NF == 14 { acct($4, $8, $11, $13, getBR($10), getDF($10), $14); }
+       $2 == "SEND" && NF == 16 { acct($4, $8, $11, $13, getBR($10), getDF($10), $14); }
        '
     KEYTITLE="Device"
     MAPNAMES=no