Bug#370420: new comments by upstream on #370420
On Fri, Jun 23, 2006 at 10:20:56PM +0200, Giuseppe Sacco wrote: > > --- Comment #17 From Lee Howard 2006-06-23 00:01 [reply] --- > Why did the newline get removed from the CallID printf format? > > printf("%9s%u: %s\n", "CallID", i+1, (const char*) callid.id(i)); hm, not sure but guess a line hiccup messed a bit with ':x' while trying to exit vi(1) from remote. > --- Comment #18 From Lee Howard 2006-06-23 13:13 [reply] --- > I think that this is what you want, anyway, instead (uses printField rather > than printf): > >char callidstring[16]; >for (u_int i = 0; i < callid.size(); i++) { >snprintf(callidstring, 15, "CallID%u", i+1); >printField("%s", callidstring, (const char*) callid.id(i)); >} ah, I did overlook that field - never got a CallID in a fax*.tif so far, so didn't realize orig. format patches missed it. thanks -- paolo -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Bug#370420: [PATCH] Re: Bug#370420: new comments by upstream on #370420
On Tue, Jun 20, 2006 at 11:37:09AM +0200, oopla wrote: > Now, if we had e.g. -b meaning 'use basename(filename)', sample use above > would allow to have > > $ ./faxinfo -b ... : > fax07138.tif... ok, my current version goes like: $ ./faxinfo -h ./faxinfo: invalid option -- h Usage: faxinfo [-D] [-b][-n] [-S fmt] [-s fmt] [-e fmt] [-E fmt] -n Print FAX pathname -b Print FAX basename (does _not_ imply -n) -C dQuoted CSV-style output with as the deliminator -c dCSV-style output with as the deliminator -r raw format - values outputed with no names Raw format options: -S fmt Use fmt for the fax start format -s fmt Use fmt for the field start format -e fmt Use fmt for the field end format -E fmt Use fmt for the fax end format -D Debug - print on stderr SseE fmt strings Exit codes are: 0:ok 1:"Could not open..." 2:"Does not look like a facsimile" I've applied patches 1,2,-format-3b,-format-4,-format-shortcuts-1b from http://bugs.hylafax.org/show_bug.cgi?id=786 and the attached patch, to faxinfo.c++ as in 4.3.0. So my patch adds -b, a fix to escapedString(), non-0 exit code on error, and -D. Didn't attempt further fmt string sanitizing other than in prev msg. Seems to WFM so far and does what I need - should upstream come up with better solution I'll likely sync with that :) Reg. embedding +'local' infos in .tif, hence due enhancement in faxinfo to retrieve such, I'll file another bugrep for hylafax-server. thanks -- paolo faxinfo.c++_4p-oo.diff.gz Description: Binary data
Bug#370420: new comments by upstream on #370420
On Mon, Jun 19, 2006 at 11:54:12AM +0200, oopla wrote: > > faxinfo-format-4.patch > > > old format new format > > --- - > > -s '%.0s' -s '' > > -e '%1$s' -e '%s' > > > > Can anyone think of any flexibility *lost* by splitting them up? The > > simplicity gained seems worth it. > > Let me re-check & re-think a bit on that. 1. docs need to point out that opts order is important: $ ./faxinfo -n -C , /home/oopla/fax07138.tif "/home/oopla/fax07138.tif","+49 1234 5678","1","Normal","North American Letter","2002:07:09 15:29:39","1:06","9600 bit/s","1-D MH","No" $ ./faxinfo -C , -n /home/oopla/fax07138.tif /home/oopla/fax07138.tif: ,"+49 1234 5678","1","Normal","North American Letter","2002:07:09 15:29:39","1:06","9600 bit/s","1-D MH","No" the latter looks weird, kinda broken CSV. Also -r -n is different than -n -r. While that's not foolproof, I like the added flexibility, though at present one would need to really look into the code or go screaming away ;) Finally - but that's rather a wishlist for hfaxd, perhaps worth it's own bug# - I'd rather have hylafax embed into the .tif the following infos along with 'Sender',... and perhaps faxinfo() may optionally print them with an opt -l(ocal infos): - [EMAIL PROTECTED] fax was received on - either FAXNumber or LocalIdentifier - either basename(filename) or just the serial# eg.: $ ./faxinfo -l /home/oopla/fax07138.tif Sender: +49 1234 5678 Pages: 1 Quality: Normal Page: North American Letter Received: 2002:07:09 15:29:39 TimeToRecv: 1:06 SignalRate: 9600 bit/s DataFormat: 1-D MH ErrCorrect: No Faxname: fax07138.tif FAXNumber: +39..11 [EMAIL PROTECTED]: [EMAIL PROTECTED] reason is that those infos are (part of) the local side story of the fax that would be lost if file is renamed and archived without embedding/storing such infos into eg. archive pathname or somesuch. 2. surely -SseE empowers the user, so user take responsibility to not shoot on his own foot, still it sounds bad to me to allow for something like: $ ./faxinfo -S '%s%s' -E '\n' /home/oopla/fax07138.tif Segmentation fault fully sanitizing a printf() fmt string might not be trivial, though, so I'd still buy the flexibility/power and let the foolproofness in the todos :) - pls see at end my current tentative/sub-optimal escapedString() which should catch just the simple %n case. 3. the new format sounds ok to me - at least I still can do what I meant, and more, e.g. here's (core part of) a quick .cgi : $ ./faxinfo -S'%1$s' -s'' -e'' -E'\n' /home/oopla/fax07138.tif /home/oopla/fax07138.tif+49 1234 56781NormalNorth American Letter2002:07:09 15:29:391:069600 bit/s1-D MHNo That's with current implementation. Now, if we had e.g. -b meaning 'use basename(filename)', sample use above would allow to have $ ./faxinfo -b ... : fax07138.tif... without 1st do a cd into each faxdir. -- paolo ... escapedString (const char*src) { char* res; int len; len = strlen(src); res = (char*)calloc(len+1, sizeof(char)); if (res) { char* dst = res; for (int i = 0; i < len; i++) { if (i < len-1) { switch (src[i]) { case '\': switch (src[++i]) { case 'n': *dst++ = '\n'; break; case 'r': *dst++ = '\r'; break; case 't': *dst++ = '\t'; break; default: *dst++ = src[i]; } break; case '%': *dst++ = src[i]; switch (src[++i]) { // don't ever want %n, let's squash it to %% case 'n': *dst++ = '%'; break; default: *dst++ = src[i]; } break; default: *dst++ = src[i]; } } else { *dst++ = src[i]; } } } else exit (ENOMEM); return res; } ... -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Bug#370420: new comments by upstream on #370420
On Sun, Jun 18, 2006 at 10:43:17PM +0200, Giuseppe Sacco wrote: > > --- Comment #11 from [EMAIL PROTECTED] 2006-06-16 15:56 --- > > > * ./faxinfo -r '!' fax07138.tif > > Could not open !; either not TIFF or corrupted > > Fixed. > > > * there seems to be an off-by-1 problem with -[cC], it'd print eg. > > [EMAIL PROTECTED] 1234 [EMAIL PROTECTED] > > where '@' shouldn't be there and the printout is actually '[EMAIL > > PROTECTED]' > > Can you give me an example? problem is in escapedString() - solved with [pseudo-diff]: -res = (char*)malloc(len); +res = (char*)calloc(len+1, sizeof(char)); ... - if (src[i] == '\\') + if (src[i] == '\\' && i < len-1) btw, in same function [pseudo-diff]: -} +} else + exit (ENOMEM); return res; } just for fun I've added in main() [pseudo-diff]: + int debug=0; - while ((c = getopt(argc, argv, "C:c:rnS:s:e:E:")) != -1) + while ((c = getopt(argc, argv, "C:c:DrnS:s:e:E:")) != -1) ... +case 'D': + debug = 1; + break; } + if (debug) + fprintf(stderr, + "faxStart='%s'\nfieldStart='%s'\nfieldEnd='%s'\nfaxEnd'%s'\n", + faxStart,fieldStart,fieldEnd,faxEnd); handy to see the mess we're going to have ;) BTW, faxinfo() still always exit with 0 - instead it should exit with non-0 code if any error occurs. > Using the format params S/s/e/E gives you access directly into the printf which reminds me to ask for a sanity check in escapedString() as well - eg. just avoid %n ... thanks for explanation :) > --- Comment #13 from [EMAIL PROTECTED] 2006-06-16 16:04 --- > Created an attachment (id=1089) > --> (http://bugs.hylafax.org/attachment.cgi?id=1089&action=view) > faxinfo-format-4.patch > old format new format > --- - > -s '%.0s' -s '' > -e '%1$s' -e '%s' > > Can anyone think of any flexibility *lost* by splitting them up? The > simplicity gained seems worth it. Let me re-check & re-think a bit on that. thanks -- paolo -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]