[Avcheck] sophie error strings
Michael Tokarev
mjt@tls.msk.ru
Sat, 27 Jul 2002 16:22:25 +0400
Michael Tokarev wrote:
>
> [Answering an old post, again]
>
> Max Kalika wrote at Thu, 20 Jun 2002 23:40:52 -0700:
> >
> > I haven't had a chance to look at the code, but I figure this isn't a
> > terribly complicated question. Does avcheck support sophie's extended
> > error strings (if sophie is built with --enable-error-strings). I am
> > getting some mail queued up because some attachments are encrypted or
> > corrupt archives. Avcheck only sees the -1 error and queues the mail. If
> > I enable error strings in sophie will avcheck know to look at that and not
> > queue if the error is unrecoverable? Thanks.
>
> I looked at sophie today, finally. This option, --enable-error-strings,
> adds an error *message text* (description) to an output, in addition to
> error code (always -1). Well, avcheck may call a bunch of strcmp()s to
> compare this error description with a predefined set of descriptions built
> into avcheck. Here is a list of such errors defined in sophie_code.h,
> as of 1.40rc1:
[]
> This is not a small list, but the only one message, "Error: File was encrypted",
> is of any interest (if I not missed some more). Ok, this may be done, and I perhaps
> will do that
[]
Something like:
Index: avcheck.c
===================================================================
RCS file: /var/cvs/avcheck/avcheck.c,v
retrieving revision 1.15
diff -u -r1.15 avcheck.c
--- avcheck.c 17 Jun 2002 18:17:29 -0000 1.15
+++ avcheck.c 27 Jul 2002 12:18:52 -0000
@@ -636,9 +636,17 @@
r[l] = '\0';
if ((p = strchr(r, '\n')) != NULL)
*p = '\0';
- if (*r == '-')
+ p = strchr(r, ':');
+ if (*r == '-') {
+ if (p) {
+ /* check for some error messages and skip some */
+ ++p;
+ if (memcmp(p, "Error: File was encrypted", 26) == 0) return 0;
+ /*XXX? if (memcmp(p, "Error: File corrupted", 21) == 0) return 0;*/
+ }
err(0, "error in %s: return code %s", avname, r);
- if ((p = strchr(r, ':')) != NULL) {
+ }
+ if (p) {
++p;
while(*p == ' ' || *p == '\t') ++p;
if (*p)
But I should admit that this is .. at least ugly. Error message may be
chanhed (incl. case) etc. The best way is to use a code for that, but
sophie always returns -1. But at least this should solve a problem,
at least for now.
/mjt