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