summaryrefslogtreecommitdiff
path: root/mail/metamail/files/patch-metamail_mailto.c
blob: 3fb39e3f9cd144c56ffcf3af0935f580696cdae2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
--- metamail/mailto.c.orig	1994-02-09 20:30:26 UTC
+++ metamail/mailto.c
@@ -37,6 +37,8 @@ STILL NEED TO DO/SUPPORT:
 */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <ctype.h>
 #include <config.h>
 #include <pwd.h>
@@ -60,7 +62,6 @@ extern char *getenv();
 #include <unistd.h>
 #endif
 
-extern char *malloc(), *realloc(), *index(), *getmyname();
 struct mailpart *CreateNewPart();
 
 /* The main data structure for the multiple parts of the mail */
@@ -570,6 +571,7 @@ char **argv;
         if (isupper(*sdum)) *sdum = tolower(*sdum);
     }
     if (strcmp(CharacterSet, "us-ascii")
+	 && strcmp(CharacterSet, "koi8-r")
          && strncmp(CharacterSet, "iso-8859-", 9)) {
         fprintf(stderr, "mailto:  Unsupported character set: %s\n", CharacterSet);
         exit(-1);
@@ -1072,7 +1074,7 @@ struct mailpart *FirstPart;
 #endif
     }
     fprintf(fp, "Message-ID: %s\n", newid());
-    if (!FirstPart) return; /* empty body */
+    if (!FirstPart) return(0); /* empty body */
     if (FirstPart->next) {
         char boundary[120];
 #ifdef AMIGA
@@ -1130,6 +1132,7 @@ struct mailpart *part;
         if (part->isrich) {
             if (strcmp(CharacterSet, "us-ascii")
                  && (strncmp(CharacterSet, "iso-8859-", 9) 
+		     && strcmp(CharacterSet, "koi8-r")
                       || part->encoding_type_needed != ENC_NONE)) {
                 fprintf(fp, "Content-type: text/richtext; charset=\"%s\"\n", CharacterSet);
             } else {
@@ -1140,6 +1143,7 @@ struct mailpart *part;
             WriteCtypeNicely(fp, part->content_type);
             if (strcmp(CharacterSet, "us-ascii")
                  && (strncmp(CharacterSet, "iso-8859-", 9) 
+		     && strcmp(CharacterSet, "koi8-r")
                       || part->encoding_type_needed != ENC_NONE)) {
                 fprintf(fp, "; charset=\"%s\"\n", CharacterSet);
             } else fputs("\n", fp);
@@ -1346,7 +1350,7 @@ int EightBitMode, RightToLeftMode;
         }
         part->isrich = 1;
         PartEndsWithNewline=1;
-        return;
+        return(0);
     }
     InNewLineSequence = 0;
     if (RightToLeftMode) {
@@ -1745,6 +1749,7 @@ CreateNewPart() {
     }
     printf("\n\nEnter your choice as a number from 0 to %d: ", i);
     fflush(stdout);
+    *LineBuf = '\0';
     fgets(LineBuf, sizeof(LineBuf), stdin);
     ans = atoi(LineBuf);
     if (ans == 0 || ans == 1) {
@@ -1752,8 +1757,9 @@ CreateNewPart() {
         FILE *fpi, *fpo;
 	printf("\nIf you want to include non-textual data from a file, enter the file name.\nTo include the output of a command, enter \"|\" followed by the command.\nIf you do not want to include anything, just press ENTER (RETURN).\n> ");
         fflush(stdout);
+        *CTLineBuf = '\0';
         fgets(CTLineBuf, sizeof(CTLineBuf), stdin);
-        sdum = CTLineBuf+strlen(CTLineBuf) -1;
+        sdum = *CTLineBuf ? CTLineBuf+strlen(CTLineBuf) -1 : CTLineBuf;
         while (sdum >= CTLineBuf && isspace((unsigned char) *sdum)) {
             *sdum = '\0';
             --sdum;
@@ -1791,7 +1797,10 @@ CreateNewPart() {
                 int ct;
                 printf("\nEnter the MIME Content-type value for the data from file %s\n    (type '?' for a list of locally-valid content-types): ", sdum);
                 fflush(stdout);
-                gets(LineBuf);
+                *LineBuf = '\0';
+                fgets(LineBuf, sizeof(LineBuf), stdin);
+                if (*LineBuf)
+                    LineBuf[strlen(LineBuf) - 1] = '\0';
                 if (index(LineBuf, '/')) {
                     char lc[100], *s, AnsBuf[100];
                     strcpy(lc, LineBuf);
@@ -1809,7 +1818,7 @@ CreateNewPart() {
                     }
                     if (mc) break;
                     printf("The MIME content-type '%s' is not listed in your local mailcap files,\nand may not be a valid MIME type.  Do you want to use it anyway [no] ? ", LineBuf);
-                    s = gets(AnsBuf);
+                    s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
                     while (s && *s && isspace((unsigned char) *s)) ++s;
                     if (s && (*s == 'y' || *s == 'Y')) break;
                     continue;
@@ -2109,7 +2118,7 @@ int UseVisual;
         fpout = fopen(FirstPart->filename, "a");
         free(CmdBuf);
         free(CmdBuf2);
-        return;
+        return(0);
     }
     lastmp = mp = FirstPart;
     while (mp) {
@@ -2137,6 +2146,7 @@ int UseVisual;
             printf("2: %s\n", CmdBuf);
             printf("\n\nEnter 1 or 2, or 0 to not edit it: ");
             fflush(stdout);
+            *LineBuf = '\0';
             fgets(LineBuf, sizeof(LineBuf), stdin);
             ans = atoi(LineBuf);
         } else ans = 2;
@@ -2221,7 +2231,7 @@ int IsAndrew;
     int LineAlloced = 0, LineCount = 0;
 
     fp = fopen(fname, "r");
-    if (!fp) return;
+    if (!fp) return(0);
     do {
         LineBuf=NextAliasLine(LineBuf, &LineAlloced, &LineCount, fp, IsAndrew);
         if (LineCount == 0) continue;
@@ -2310,7 +2320,7 @@ char *aliasline;
         if (s != s2) printf("mailto: ignoring bad alias line in init file: %s\n", aliasline);
         free(s);
         free(tmpalias);
-        return;
+        return(0);
     }
     *s2++ = '\0';
     tmpalias->shortname = s;
@@ -2364,7 +2374,7 @@ char *hdr;
 {
     char *firstnonascii, *firstascii;
 
-    if (!s) return;
+    if (!s) return(0);
     firstnonascii=firstbad(s);
     if (firstnonascii) {
         if (!strcmp(CharacterSet, "us-ascii")) {
@@ -2454,7 +2464,7 @@ char *hdr;
 /*        if (!lc2strcmp(name, tmpalias->shortname)) { */
             *end = savechar;
             EmitAddresses(fp, tmpalias->longname, hdr);
-            return;
+            return(0);
         }
     }
     *end = savechar;