show: normalize fwrite calls

pull/1/merge
Christian Neukirchen 8 years ago
parent 6710fd9cd5
commit f03343c5e6

@ -156,7 +156,7 @@ render_mime(int depth, char *ct, char *body, size_t bodylen)
perror("popen"); perror("popen");
goto nofilter; goto nofilter;
} }
fwrite(body, bodylen, 1, p); fwrite(body, 1, bodylen, p);
if (pclose(p) != 0) { if (pclose(p) != 0) {
perror("pclose"); perror("pclose");
goto nofilter; goto nofilter;
@ -174,7 +174,7 @@ nofilter:
strcasecmp(charset, "utf-8") == 0 || strcasecmp(charset, "utf-8") == 0 ||
strcasecmp(charset, "utf8") == 0 || strcasecmp(charset, "utf8") == 0 ||
strcasecmp(charset, "us-ascii") == 0) strcasecmp(charset, "us-ascii") == 0)
fwrite(body, bodylen, 1, stdout); fwrite(body, 1, bodylen, stdout);
else else
print_u8recode(body, bodylen, charset); print_u8recode(body, bodylen, charset);
free(charset); free(charset);
@ -295,7 +295,7 @@ extract_mime(int depth, char *ct, char *body, size_t bodylen)
if (extract_argc == 0) { if (extract_argc == 0) {
if (extract_stdout) { // output all parts if (extract_stdout) { // output all parts
fwrite(body, bodylen, 1, stdout); fwrite(body, 1, bodylen, stdout);
} else { // extract all named attachments } else { // extract all named attachments
if (filename) { if (filename) {
printf("%s\n", filename); printf("%s\n", filename);
@ -312,7 +312,7 @@ extract_mime(int depth, char *ct, char *body, size_t bodylen)
if (errno == 0 && !*b && d == mimecount) { if (errno == 0 && !*b && d == mimecount) {
// extract by id // extract by id
if (extract_stdout) { if (extract_stdout) {
fwrite(body, bodylen, 1, stdout); fwrite(body, 1, bodylen, stdout);
} else { } else {
char buf[255]; char buf[255];
if (!filename) { if (!filename) {
@ -326,7 +326,7 @@ extract_mime(int depth, char *ct, char *body, size_t bodylen)
} else if (filename && strcmp(a, filename) == 0) { } else if (filename && strcmp(a, filename) == 0) {
// extract by name // extract by name
if (extract_stdout) { if (extract_stdout) {
fwrite(body, bodylen, 1, stdout); fwrite(body, 1, bodylen, stdout);
} else { } else {
printf("%s\n", filename); printf("%s\n", filename);
writefile(filename, body, bodylen); writefile(filename, body, bodylen);
@ -386,7 +386,7 @@ show(char *file)
if (fd == -1) if (fd == -1)
return; return;
hl = read(fd, header, hl); hl = read(fd, header, hl);
fwrite(header, hl, 1, stdout); fwrite(header, 1, hl, stdout);
} else if (Lflag) { // all headers } else if (Lflag) { // all headers
char *h = 0; char *h = 0;
while ((h = blaze822_next_header(msg, h))) { while ((h = blaze822_next_header(msg, h))) {
@ -421,7 +421,7 @@ show(char *file)
printf("\n"); printf("\n");
if (rflag || !blaze822_check_mime(msg)) { // raw body if (rflag || !blaze822_check_mime(msg)) { // raw body
fwrite(blaze822_body(msg), blaze822_bodylen(msg), 1, stdout); fwrite(blaze822_body(msg), 1, blaze822_bodylen(msg), stdout);
goto done; goto done;
} }

Loading…
Cancel
Save