Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-gnome
Path: blob/main/converters/mpack/files/patch-uudecode.c
16151 views
1
--- uudecode.c.orig Mon Jul 21 23:46:37 2003
2
+++ uudecode.c Mon Mar 27 17:27:52 2006
3
@@ -23,8 +23,10 @@
4
* SOFTWARE.
5
*/
6
#include <stdio.h>
7
+#include <stdlib.h>
8
#include <ctype.h>
9
#include <string.h>
10
+#include <unistd.h>
11
#include "xmalloc.h"
12
#include "common.h"
13
#include "part.h"
14
@@ -32,9 +34,25 @@
15
extern char *os_idtodir(char *id);
16
extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams);
17
extern FILE *os_createnewfile(char *fname);
18
+extern int os_binhex(struct part *inpart, int part, int nparts);
19
+extern void os_closetypedfile(FILE *outfile);
20
+extern void os_donewithdir(char *dir);
21
+extern void os_perror(char *str);
22
+extern void chat(char *s);
23
+
24
+extern void part_ungets(char *s, struct part *part);
25
+extern void part_close(struct part *part);
26
+extern int handleMessage(struct part *inpart, char *defaultContentType,
27
+ int inAppleDouble, int extractText);
28
29
static FILE *startDescFile(char *fname);
30
+static void uudecodeline(char *line, FILE *outfile);
31
32
+int parseSubject(unsigned char *subject, char **fnamep, int *partp, int *npartsp);
33
+int saveUuFile(struct part *inpart, char *fname, int part, int nparts,
34
+ char *firstline);
35
+int descEnd(char *line);
36
+int uudecodefiles(char *dir, int nparts);
37
38
/* Length of a normal uuencoded line, including newline */
39
#define UULENGTH 62
40
@@ -266,7 +284,7 @@
41
}
42
else if (part == 1 && fname && !descfile &&
43
!strncasecmp(buf, "x-file-desc: ", 13)) {
44
- if (descfile = startDescFile(fname)) {
45
+ if ((descfile = startDescFile(fname))) {
46
fputs(buf+13, descfile);
47
fclose(descfile);
48
descfile = 0;
49
@@ -454,7 +472,7 @@
50
/* Retrieve any previously saved number of the last part */
51
if (nparts == 0) {
52
sprintf(buf, "%sCT", dir);
53
- if (partfile = fopen(buf, "r")) {
54
+ if ((partfile = fopen(buf, "r"))) {
55
if (fgets(buf, sizeof(buf), partfile)) {
56
nparts = atoi(buf);
57
if (nparts < 0) nparts = 0;
58
@@ -487,9 +505,9 @@
59
* split-uuencoded data.
60
*/
61
int
62
-parseSubject(char *subject, char **fnamep, int *partp, int *npartsp)
63
+parseSubject(unsigned char *subject, char **fnamep, int *partp, int *npartsp)
64
{
65
- char *scan, *bak, *start;
66
+ unsigned char *scan, *bak, *start;
67
int part = -1, nparts = 0, hasdot = 0;
68
69
/* No subject header */
70
@@ -722,7 +740,7 @@
71
if (!*fname) return 1;
72
73
/* Guess the content-type of common filename extensions */
74
- if (p = strrchr(fname, '.')) {
75
+ if ((p = strrchr(fname, '.'))) {
76
if (!strcasecmp(p, ".gif")) contentType = "image/gif";
77
if (!strcasecmp(p, ".jpg")) contentType = "image/jpeg";
78
if (!strcasecmp(p, ".jpeg")) contentType = "image/jpeg";
79
@@ -826,7 +844,7 @@
80
/*
81
* Decode a uuencoded line to 'outfile'
82
*/
83
-int uudecodeline(char *line, FILE *outfile)
84
+static void uudecodeline(char *line, FILE *outfile)
85
{
86
int c, len;
87
88
@@ -845,7 +863,6 @@
89
}
90
line += 4;
91
}
92
- return;
93
}
94
95
96
97