comparison archive/readpst.c.short_filename.diff @ 57:de3753c3160a

add archive directory with history of alioth versions that have been merged here
author Carl Byington <carl@five-ten-sg.com>
date Sat, 02 Feb 2008 12:54:07 -0800
parents
children
comparison
equal deleted inserted replaced
56:b504411ad213 57:de3753c3160a
1 Index: readpst.c
2 ===================================================================
3 --- readpst.c (revision 45)
4 +++ readpst.c (working copy)
5 @@ -149,6 +149,7 @@
6 int attach_num = 0;
7 int skip_child = 0;
8 struct file_ll *f, *head;
9 + char *attach_filename = NULL;
10 prog_name = argv[0];
11 // }}}2
12 // command-line option handling {{{2
13 @@ -832,18 +833,25 @@
14 }
15 if (mode == MODE_SEPERATE) {
16 f->name = check_filename(f->name);
17 - if (item->current_attach->filename2 == NULL) {
18 + // If there is a long filename (filename2) use that, otherwise
19 + // use the 8.3 filename (filename1)
20 + if (item->current_attach->filename2) {
21 + attach_filename = item->current_attach->filename2;
22 + } else {
23 + attach_filename = item->current_attach->filename1;
24 + }
25 + if (attach_filename == NULL) {
26 temp = xmalloc(strlen(f->name)+15);
27 sprintf(temp, "%s-attach%i", f->name, attach_num);
28 } else {
29 - temp = xmalloc(strlen(f->name)+strlen(item->current_attach->filename2)+15);
30 + temp = xmalloc(strlen(f->name)+strlen(attach_filename)+15);
31 fp = NULL; x=0;
32 do {
33 if (fp != NULL) fclose(fp);
34 if (x == 0)
35 - sprintf(temp, "%s-%s", f->name, item->current_attach->filename2);
36 + sprintf(temp, "%s-%s", f->name, attach_filename);
37 else
38 - sprintf(temp, "%s-%s-%i", f->name, item->current_attach->filename2, x);
39 + sprintf(temp, "%s-%s-%i", f->name, attach_filename, x);
40 } while ((fp = fopen(temp, "r"))!=NULL && ++x < 99999999);
41 if (x > 99999999) {
42 DIE(("error finding attachment name. exhausted possibilities to %s\n", temp));
43 @@ -878,11 +886,18 @@
44 fprintf(f->output, "Content-type: %s\n", item->current_attach->mimetype);
45 }
46 fprintf(f->output, "Content-transfer-encoding: base64\n");
47 - if (item->current_attach->filename2 == NULL) {
48 + // If there is a long filename (filename2) use that, otherwise
49 + // use the 8.3 filename (filename1)
50 + if (item->current_attach->filename2) {
51 + attach_filename = item->current_attach->filename2;
52 + } else {
53 + attach_filename = item->current_attach->filename1;
54 + }
55 + if (attach_filename == NULL) {
56 fprintf(f->output, "Content-Disposition: inline\n\n");
57 } else {
58 fprintf(f->output, "Content-Disposition: attachment; filename=\"%s\"\n\n",
59 - item->current_attach->filename2);
60 + attach_filename);
61 }
62 }
63 if (item->current_attach->data != NULL) {