23 |
* SOFTWARE. |
* SOFTWARE. |
24 |
*/ |
*/ |
25 |
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
|
26 |
#include <string.h> |
#include <string.h> |
27 |
|
|
28 |
extern char *magic_look(FILE *infile); |
extern char *magic_look(FILE *infile); |
29 |
extern char *os_genid(void); |
extern char *os_genid(void); |
30 |
extern FILE *os_createnewfile(char *fname); |
extern FILE *os_createnewfile(char *fname); |
31 |
extern char *md5digest(FILE *infile, long int *len); |
extern char *md5digest(FILE *infile, long int *len); |
|
extern void os_perror(char *str); |
|
|
extern int to64(FILE *infile, FILE *outfile, long int limit); |
|
32 |
|
|
33 |
#define NUMREFERENCES 4 |
#define NUMREFERENCES 4 |
|
int attachment; |
|
34 |
|
|
35 |
/* |
/* |
36 |
* Encode a file into one or more MIME messages, each |
* Encode a file into one or more MIME messages, each |
43 |
char *type; |
char *type; |
44 |
FILE *outfile; |
FILE *outfile; |
45 |
char *cleanfname, *p; |
char *cleanfname, *p; |
46 |
char *digest, *appledigest = NULL; |
char *digest, *appledigest; |
47 |
long filesize, l, written; |
long filesize, l, written; |
48 |
int thispart, numparts = 1; |
int thispart, numparts = 1; |
49 |
int wrotefiletype = 0; |
int wrotefiletype = 0; |
57 |
/* This filename-cleaning knowledge will probably |
/* This filename-cleaning knowledge will probably |
58 |
* be moved to the os layer in a future version. |
* be moved to the os layer in a future version. |
59 |
*/ |
*/ |
60 |
if ((p = strrchr(cleanfname, '.'))) cleanfname = p+1; |
if (p = strrchr(cleanfname, '.')) cleanfname = p+1; |
61 |
#else |
#else |
62 |
if ((p = strrchr(cleanfname, '/'))) cleanfname = p+1; |
if (p = strrchr(cleanfname, '/')) cleanfname = p+1; |
63 |
if ((p = strrchr(cleanfname, '\\'))) cleanfname = p+1; |
if (p = strrchr(cleanfname, '\\')) cleanfname = p+1; |
64 |
#endif |
#endif |
65 |
if ((p = strrchr(cleanfname, ':'))) cleanfname = p+1; |
if (p = strrchr(cleanfname, ':')) cleanfname = p+1; |
66 |
|
|
67 |
/* Find file type */ |
/* Find file type */ |
68 |
if (typeoverride) { |
if (typeoverride) { |
189 |
"Content-Type: multipart/appledouble; boundary=\"=\"; name=\"%s\"\n", |
"Content-Type: multipart/appledouble; boundary=\"=\"; name=\"%s\"\n", |
190 |
cleanfname); |
cleanfname); |
191 |
fprintf(outfile, |
fprintf(outfile, |
192 |
"Content-Disposition: %s; filename=\"%s\"\n", |
"Content-Disposition: inline; filename=\"%s\"\n", |
193 |
attachment ? "attachment" : "inline", cleanfname); |
cleanfname); |
194 |
fprintf(outfile, "\n\n--=\n"); |
fprintf(outfile, "\n\n--=\n"); |
195 |
fprintf(outfile, "Content-Type: application/applefile\n"); |
fprintf(outfile, "Content-Type: application/applefile\n"); |
196 |
fprintf(outfile, "Content-Transfer-Encoding: base64\n"); |
fprintf(outfile, "Content-Transfer-Encoding: base64\n"); |
219 |
fprintf(outfile, "Content-Type: %s; name=\"%s\"\n", type, |
fprintf(outfile, "Content-Type: %s; name=\"%s\"\n", type, |
220 |
cleanfname); |
cleanfname); |
221 |
fprintf(outfile, "Content-Transfer-Encoding: base64\n"); |
fprintf(outfile, "Content-Transfer-Encoding: base64\n"); |
222 |
fprintf(outfile, "Content-Disposition: %s; filename=\"%s\"\n", |
fprintf(outfile, "Content-Disposition: inline; filename=\"%s\"\n", |
223 |
attachment ? "attachment" : "inline", cleanfname); |
cleanfname); |
224 |
fprintf(outfile, "Content-MD5: %s\n\n", digest); |
fprintf(outfile, "Content-MD5: %s\n\n", digest); |
225 |
free(digest); |
free(digest); |
226 |
written += 80; |
written += 80; |