From: Lee Howard Date: Sat, 28 Feb 2004 18:02:51 +0000 (+0000) Subject: Bug 424: include Caller-ID into FaxRecvInfo and record in recvstats X-Git-Tag: HYLAFAX-4_2_0BETA1~28 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=bcf41b82f6f4e19c14f6a1cfe79ee97e9d6d6d50;p=thirdparty%2FHylaFAX.git Bug 424: include Caller-ID into FaxRecvInfo and record in recvstats and also include into the TIFF tags for faxinfo reporting --- diff --git a/faxd/Class1.h b/faxd/Class1.h index dde806b9..68b435b4 100644 --- a/faxd/Class1.h +++ b/faxd/Class1.h @@ -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(); diff --git a/faxd/Class1Recv.c++ b/faxd/Class1Recv.c++ index fc281b49..4d2dbbc2 100644 --- a/faxd/Class1Recv.c++ +++ b/faxd/Class1Recv.c++ @@ -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()) { diff --git a/faxd/Class2.h b/faxd/Class2.h index 32726f9b..eb459e67 100644 --- a/faxd/Class2.h +++ b/faxd/Class2.h @@ -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(); diff --git a/faxd/Class2Recv.c++ b/faxd/Class2Recv.c++ index acbeae19..feb08801 100644 --- a/faxd/Class2Recv.c++ +++ b/faxd/Class2Recv.c++ @@ -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; diff --git a/faxd/CopyQuality.c++ b/faxd/CopyQuality.c++ index 7e63821b..89c4e33c 100644 --- a/faxd/CopyQuality.c++ +++ b/faxd/CopyQuality.c++ @@ -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)); diff --git a/faxd/FaxAcctInfo.c++ b/faxd/FaxAcctInfo.c++ index aa8739d0..776acd88 100644 --- a/faxd/FaxAcctInfo.c++ +++ b/faxd/FaxAcctInfo.c++ @@ -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()); diff --git a/faxd/FaxAcctInfo.h b/faxd/FaxAcctInfo.h index 0aa8edae..f8d227e8 100644 --- a/faxd/FaxAcctInfo.h +++ b/faxd/FaxAcctInfo.h @@ -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; }; diff --git a/faxd/FaxModem.h b/faxd/FaxModem.h index f1dbebc4..87c51d62 100644 --- a/faxd/FaxModem.h +++ b/faxd/FaxModem.h @@ -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(); diff --git a/faxd/FaxPoll.c++ b/faxd/FaxPoll.c++ index cb5ad6e4..6fa85ed9 100644 --- a/faxd/FaxPoll.c++ +++ b/faxd/FaxPoll.c++ @@ -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); diff --git a/faxd/FaxRecv.c++ b/faxd/FaxRecv.c++ index fe50f505..fd418634 100644 --- a/faxd/FaxRecv.c++ +++ b/faxd/FaxRecv.c++ @@ -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" diff --git a/faxd/FaxServer.h b/faxd/FaxServer.h index 8c8db8c7..37b50086 100644 --- a/faxd/FaxServer.h +++ b/faxd/FaxServer.h @@ -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(); diff --git a/faxd/faxGettyApp.c++ b/faxd/faxGettyApp.c++ index 52b366a7..83e2a8c1 100644 --- a/faxd/faxGettyApp.c++ +++ b/faxd/faxGettyApp.c++ @@ -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 diff --git a/faxd/faxGettyApp.h b/faxd/faxGettyApp.h index 355cae8d..69d9ac84 100644 --- a/faxd/faxGettyApp.h +++ b/faxd/faxGettyApp.h @@ -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(); diff --git a/faxd/faxSendApp.c++ b/faxd/faxSendApp.c++ index ff50a5e8..da85ebf9 100644 --- a/faxd/faxSendApp.c++ +++ b/faxd/faxSendApp.c++ @@ -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); diff --git a/faxd/pageSendApp.c++ b/faxd/pageSendApp.c++ index 8e632889..ad74715b 100644 --- a/faxd/pageSendApp.c++ +++ b/faxd/pageSendApp.c++ @@ -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 diff --git a/hfaxd/RecvQueue.c++ b/hfaxd/RecvQueue.c++ index 5c219892..d9e8f880 100644 --- a/hfaxd/RecvQueue.c++ +++ b/hfaxd/RecvQueue.c++ @@ -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 = ""; #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; diff --git a/man/faxstat.1 b/man/faxstat.1 index c42076e9..667d124e 100644 --- a/man/faxstat.1 +++ b/man/faxstat.1 @@ -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) diff --git a/man/recvstats.1m b/man/recvstats.1m index 2cc147f6..f9568222 100644 --- a/man/recvstats.1m +++ b/man/recvstats.1m @@ -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 diff --git a/man/xferfaxlog.4f b/man/xferfaxlog.4f index 42ef61f2..06276e78 100644 --- a/man/xferfaxlog.4f +++ b/man/xferfaxlog.4f @@ -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\fP \fI\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\fP \fI\fP fax ``local-number'' ``\s-1TSI\s+1'' params #pages jobtime conntime ``reason'' +date \s-1RECV\s+1 commid modem \fI\fP \fI\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\fP \fI\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\fP'' 0 0 jobtime conntime ``reason'' +date \s-1PAGE\s+1 commid modem jobid jobtag sender ``dest-number'' ``\fI\fP'' 0 0 jobtime conntime ``reason'' \fI\fP \fI\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 diff --git a/util/FaxClient.c++ b/util/FaxClient.c++ index eccd582f..17bb1a6e 100644 --- a/util/FaxClient.c++ +++ b/util/FaxClient.c++ @@ -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) diff --git a/util/FaxRecvInfo.c++ b/util/FaxRecvInfo.c++ index d2259941..3bb0a0a5 100644 --- a/util/FaxRecvInfo.c++ +++ b/util/FaxRecvInfo.c++ @@ -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); } diff --git a/util/FaxRecvInfo.h b/util/FaxRecvInfo.h index e721fd81..722f9dcf 100644 --- a/util/FaxRecvInfo.h +++ b/util/FaxRecvInfo.h @@ -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); diff --git a/util/faxinfo.c++ b/util/faxinfo.c++ index f84b5778..f54d227f 100644 --- a/util/faxinfo.c++ +++ b/util/faxinfo.c++ @@ -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 = ""; printf("%11s %s\n", "Sender:", (const char*) sender); @@ -215,5 +236,9 @@ main(int argc, char** argv) printf("%11s %s\n", "TimeToRecv:", time == 0 ? "" : 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); } diff --git a/util/faxrcvd.sh.in b/util/faxrcvd.sh.in index aa24cd5c..efe5bd65 100644 --- a/util/faxrcvd.sh.in +++ b/util/faxrcvd.sh.in @@ -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 diff --git a/util/recvstats.sh.in b/util/recvstats.sh.in index 2c61ed34..91d43246 100644 --- a/util/recvstats.sh.in +++ b/util/recvstats.sh.in @@ -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" diff --git a/util/xferfaxstats.sh.in b/util/xferfaxstats.sh.in index 70127e94..f743ccc6 100644 --- a/util/xferfaxstats.sh.in +++ b/util/xferfaxstats.sh.in @@ -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