#include <fcntl.h>
#include <h/signals.h>
#include <h/md5.h>
-#include <setjmp.h>
#include <h/mts.h>
#include <h/tws.h>
#include <h/mime.h>
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
} else {
+ char *charset = content_charset (ct);
admonish (NULL, "unable to convert character set%s%s to %s",
ct->c_partno ? " of part " : "",
ct->c_partno ? ct->c_partno : "",
- content_charset (ct));
+ charset);
+ free (charset);
}
}
}
while ((cc = read(fd, readbuf, sizeof(readbuf))) > 0) {
- fwrite(readbuf, sizeof(char), cc, stdout);
+ if ((ssize_t) fwrite(readbuf, sizeof(char), cc, stdout) < cc) {
+ advise ("putline", "fwrite");
+ }
lastchar = readbuf[cc - 1];
}
int alternating, nowalternate, result;
struct multipart *m = (struct multipart *) ct->c_ctparams;
struct part *part;
- int any_part_ok;
+ int request_matched;
CT p;
alternating = 0;
alternating = 1;
}
-/*
- * alternate -> we are a part inside an multipart/alternative
- * alternating -> we are a multipart/alternative
- */
+ /*
+ * alternate -> we are a part inside an multipart/alternative
+ * alternating -> we are a multipart/alternative
+ */
result = alternate ? NOTOK : OK;
- any_part_ok = 0;
+ request_matched = 0;
for (part = m->mp_parts; part; part = part->mp_next) {
p = part->mp_part;
if (part_ok (p, 1) && type_ok (p, 1)) {
int inneresult;
- any_part_ok = 1;
+ request_matched = 1;
inneresult = show_switch (p, nowalternate, concatsw, textonly,
inlineonly, fmt);
}
}
- if (alternating && !part && any_part_ok) {
+ if (alternating && !part && request_matched) {
if (!alternate)
content_error (NULL, ct, "don't know how to display any of the contents");
result = NOTOK;
}
out:
- return result;
+ /* if no parts matched what was requested, there can't have been
+ * any display errors, so we report OK. */
+ return request_matched ? result : OK;
}
if ((conv_desc = iconv_open (dest_charset, src_charset)) ==
(iconv_t) -1) {
advise (NULL, "Can't convert %s to %s", src_charset, dest_charset);
+ free (src_charset);
return NOTOK;
}
#endif /* ! HAVE_ICONV */
}
+ free (src_charset);
return status;
}
} else {
status = NOTOK;
}
-
- free (charset);
}
+ free (charset);
#else /* ! HAVE_ICONV */
NMH_UNUSED (ct);
NMH_UNUSED (file);