Path: blob/main/converters/mpack/files/patch-decode.c
16151 views
--- decode.c.orig 2003-07-21 22:47:54.000000000 +02001+++ decode.c 2012-01-12 19:22:04.000000000 +01002@@ -26,8 +26,10 @@3* SOFTWARE. */45#include <stdio.h>6+#include <stdlib.h>7#include <string.h>8#include <ctype.h>9+#include <unistd.h>10#include "xmalloc.h"11#include "common.h"12#include "part.h"13@@ -35,8 +37,22 @@1415extern char *os_idtodir(char *id);16extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams);17+extern FILE *os_createfile(char *fname);18extern FILE *os_createnewfile(char *fname);19extern char *md5contextTo64(MD5_CTX *context);20+extern void warn(char *s);21+extern void os_perror(char *str);22+extern void chat(char *s);23+extern void os_donewithdir(char *dir);24+extern void os_warnMD5mismatch(void);25+extern void os_closetypedfile(FILE *outfile);26+27+extern int part_depth(struct part *part);28+extern void part_ungets(char *s, struct part *part);29+extern void part_close(struct part *part);30+extern int part_fill(struct part *part);31+extern void part_addboundary(struct part *part, char *boundary);32+extern int part_readboundary(struct part *part);3334/* The possible content transfer encodings */35enum encoding { enc_none, enc_qp, enc_base64 };36@@ -49,6 +65,17 @@37void from64(struct part *inpart, FILE *outfile, char **digestp, int suppressCR);38void fromqp(struct part *inpart, FILE *outfile, char **digestp);39void fromnone(struct part *inpart, FILE *outfile, char **digestp);40+int handlePartial(struct part *inpart, char *headers, params contentParams,41+ int extractText);42+int ignoreMessage(struct part *inpart);43+int handleMultipart(struct part *inpart, char *contentType,44+ params contentParams, int extractText);45+int handleUuencode(struct part *inpart, char *subject, int extractText);46+int handleText(struct part *inpart, enum encoding contentEncoding);47+int saveToFile(struct part *inpart, int inAppleDouble, char *contentType,48+ params contentParams, enum encoding contentEncoding,49+ char *contentDisposition, char *contentMD5);50+51/*52* Read and handle an RFC 822 message from the body-part 'inpart'.53*/54@@ -624,7 +651,7 @@55}56thispart = atoi(p);5758- if (p = getParam(contentParams, "total")) {59+ if ((p = getParam(contentParams, "total"))) {60nparts = atoi(p);61if (nparts <= 0) {62warn("partial message has invalid number of parts");63@@ -632,7 +659,7 @@64}65/* Store number of parts in reassembly directory */66sprintf(buf, "%sCT", dir);67- partfile = os_createnewfile(buf);68+ partfile = os_createfile(buf);69if (!partfile) {70os_perror(buf);71goto ignore;72@@ -643,7 +670,7 @@73else {74/* Try to retrieve number of parts from reassembly directory */75sprintf(buf, "%sCT", dir);76- if (partfile = fopen(buf, "r")) {77+ if ((partfile = fopen(buf, "r"))) {78if (fgets(buf, sizeof(buf), partfile)) {79nparts = atoi(buf);80if (nparts < 0) nparts = 0;818283