23 |
* SOFTWARE. |
* SOFTWARE. |
24 |
*/ |
*/ |
25 |
#include <stdio.h> |
#include <stdio.h> |
26 |
|
#include <stdlib.h> |
27 |
#include <ctype.h> |
#include <ctype.h> |
28 |
#include <string.h> |
#include <string.h> |
29 |
|
#include <unistd.h> |
30 |
#include "xmalloc.h" |
#include "xmalloc.h" |
31 |
#include "common.h" |
#include "common.h" |
32 |
#include "part.h" |
#include "part.h" |
34 |
extern char *os_idtodir(char *id); |
extern char *os_idtodir(char *id); |
35 |
extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams); |
extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams); |
36 |
extern FILE *os_createnewfile(char *fname); |
extern FILE *os_createnewfile(char *fname); |
37 |
|
extern int os_binhex(struct part *inpart, int part, int nparts); |
38 |
|
extern void os_closetypedfile(FILE *outfile); |
39 |
|
extern void os_donewithdir(char *dir); |
40 |
|
extern void os_perror(char *str); |
41 |
|
extern void chat(char *s); |
42 |
|
|
43 |
|
extern void part_ungets(char *s, struct part *part); |
44 |
|
extern void part_close(struct part *part); |
45 |
|
extern int handleMessage(struct part *inpart, char *defaultContentType, |
46 |
|
int inAppleDouble, int extractText); |
47 |
|
|
48 |
static FILE *startDescFile(char *fname); |
static FILE *startDescFile(char *fname); |
49 |
|
static void uudecodeline(char *line, FILE *outfile); |
50 |
|
|
51 |
|
int parseSubject(char *subject, char **fnamep, int *partp, int *npartsp); |
52 |
|
int saveUuFile(struct part *inpart, char *fname, int part, int nparts, |
53 |
|
char *firstline); |
54 |
|
int descEnd(char *line); |
55 |
|
int uudecodefiles(char *dir, int nparts); |
56 |
|
|
57 |
/* Length of a normal uuencoded line, including newline */ |
/* Length of a normal uuencoded line, including newline */ |
58 |
#define UULENGTH 62 |
#define UULENGTH 62 |
284 |
} |
} |
285 |
else if (part == 1 && fname && !descfile && |
else if (part == 1 && fname && !descfile && |
286 |
!strncasecmp(buf, "x-file-desc: ", 13)) { |
!strncasecmp(buf, "x-file-desc: ", 13)) { |
287 |
if (descfile = startDescFile(fname)) { |
if ((descfile = startDescFile(fname))) { |
288 |
fputs(buf+13, descfile); |
fputs(buf+13, descfile); |
289 |
fclose(descfile); |
fclose(descfile); |
290 |
descfile = 0; |
descfile = 0; |
472 |
/* Retrieve any previously saved number of the last part */ |
/* Retrieve any previously saved number of the last part */ |
473 |
if (nparts == 0) { |
if (nparts == 0) { |
474 |
sprintf(buf, "%sCT", dir); |
sprintf(buf, "%sCT", dir); |
475 |
if (partfile = fopen(buf, "r")) { |
if ((partfile = fopen(buf, "r"))) { |
476 |
if (fgets(buf, sizeof(buf), partfile)) { |
if (fgets(buf, sizeof(buf), partfile)) { |
477 |
nparts = atoi(buf); |
nparts = atoi(buf); |
478 |
if (nparts < 0) nparts = 0; |
if (nparts < 0) nparts = 0; |
740 |
if (!*fname) return 1; |
if (!*fname) return 1; |
741 |
|
|
742 |
/* Guess the content-type of common filename extensions */ |
/* Guess the content-type of common filename extensions */ |
743 |
if (p = strrchr(fname, '.')) { |
if ((p = strrchr(fname, '.'))) { |
744 |
if (!strcasecmp(p, ".gif")) contentType = "image/gif"; |
if (!strcasecmp(p, ".gif")) contentType = "image/gif"; |
745 |
if (!strcasecmp(p, ".jpg")) contentType = "image/jpeg"; |
if (!strcasecmp(p, ".jpg")) contentType = "image/jpeg"; |
746 |
if (!strcasecmp(p, ".jpeg")) contentType = "image/jpeg"; |
if (!strcasecmp(p, ".jpeg")) contentType = "image/jpeg"; |
844 |
/* |
/* |
845 |
* Decode a uuencoded line to 'outfile' |
* Decode a uuencoded line to 'outfile' |
846 |
*/ |
*/ |
847 |
int uudecodeline(char *line, FILE *outfile) |
static void uudecodeline(char *line, FILE *outfile) |
848 |
{ |
{ |
849 |
int c, len; |
int c, len; |
850 |
|
|
863 |
} |
} |
864 |
line += 4; |
line += 4; |
865 |
} |
} |
|
return; |
|
866 |
} |
} |
867 |
|
|
868 |
|
|