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