| @@ -1,169 +1,178 @@ | | | @@ -1,169 +1,178 @@ |
1 | $NetBSD: patch-af,v 1.4 2012/10/26 20:27:15 joerg Exp $ | | 1 | $NetBSD: patch-af,v 1.5 2012/12/30 05:38:55 dholland Exp $ |
| | | 2 | |
| | | 3 | - use required standard headers |
| | | 4 | - don't provide own declarations of standard functions |
| | | 5 | - declare own functions |
| | | 6 | - use C89 |
| | | 7 | - don't use gets() |
| | | 8 | - ...? (XXX) |
2 | | | 9 | |
3 | --- metamail/mailto.c.orig 1994-02-09 20:30:26.000000000 +0000 | | 10 | --- metamail/mailto.c.orig 1994-02-09 20:30:26.000000000 +0000 |
4 | +++ metamail/mailto.c | | 11 | +++ metamail/mailto.c |
5 | @@ -36,6 +36,7 @@ STILL NEED TO DO/SUPPORT: | | 12 | @@ -36,7 +36,9 @@ STILL NEED TO DO/SUPPORT: |
6 | -- Replace EditString with something that does the right thing in-line. | | 13 | -- Replace EditString with something that does the right thing in-line. |
7 | */ | | 14 | */ |
8 | | | 15 | |
9 | +#include <stdlib.h> | | 16 | +#include <stdlib.h> |
10 | #include <stdio.h> | | 17 | #include <stdio.h> |
| | | 18 | +#include <string.h> |
11 | #include <ctype.h> | | 19 | #include <ctype.h> |
12 | #include <config.h> | | 20 | #include <config.h> |
13 | @@ -50,8 +51,6 @@ STILL NEED TO DO/SUPPORT: | | 21 | #include <pwd.h> |
| | | 22 | @@ -50,8 +52,6 @@ STILL NEED TO DO/SUPPORT: |
14 | #include <getfiles.h> | | 23 | #include <getfiles.h> |
15 | #include <time.h> | | 24 | #include <time.h> |
16 | #include <lib_protos.h> | | 25 | #include <lib_protos.h> |
17 | -#else | | 26 | -#else |
18 | -extern char *getenv(); | | 27 | -extern char *getenv(); |
19 | #endif | | 28 | #endif |
20 | | | 29 | |
21 | #ifdef SYSV | | 30 | #ifdef SYSV |
22 | @@ -60,9 +59,16 @@ extern char *getenv(); | | 31 | @@ -60,9 +60,16 @@ extern char *getenv(); |
23 | #include <unistd.h> | | 32 | #include <unistd.h> |
24 | #endif | | 33 | #endif |
25 | | | 34 | |
26 | -extern char *malloc(), *realloc(), *index(), *getmyname(); | | 35 | -extern char *malloc(), *realloc(), *index(), *getmyname(); |
27 | struct mailpart *CreateNewPart(); | | 36 | struct mailpart *CreateNewPart(); |
28 | | | 37 | |
29 | +void DeAlias(char *name, FILE *fp, char *hdr); | | 38 | +void DeAlias(char *name, FILE *fp, char *hdr); |
30 | +void HeaderFputs(char *s, FILE *fp, char *hdr); | | 39 | +void HeaderFputs(char *s, FILE *fp, char *hdr); |
31 | +void HandleAliasCommand(char *aliasline); | | 40 | +void HandleAliasCommand(char *aliasline); |
32 | +void ProcessOneMailRC(char *fname, int IsAndrew); | | 41 | +void ProcessOneMailRC(char *fname, int IsAndrew); |
33 | +void EditCurrentMessage(int UseVisual); | | 42 | +void EditCurrentMessage(int UseVisual); |
34 | +void FputsQuotingLT(char *s, FILE *fp, struct mailpart *part, int EightBitMode, int RightToLeftMode); | | 43 | +void FputsQuotingLT(char *s, FILE *fp, struct mailpart *part, int EightBitMode, int RightToLeftMode); |
35 | +void WriteOutMessage(FILE *fp, char *ToList, char *Subject, char *CCList, struct mailpart *FirstPart); | | 44 | +void WriteOutMessage(FILE *fp, char *ToList, char *Subject, char *CCList, struct mailpart *FirstPart); |
36 | + | | 45 | + |
37 | /* The main data structure for the multiple parts of the mail */ | | 46 | /* The main data structure for the multiple parts of the mail */ |
38 | | | 47 | |
39 | struct mailpart { | | 48 | struct mailpart { |
40 | @@ -570,6 +576,7 @@ char **argv; | | 49 | @@ -570,6 +577,7 @@ char **argv; |
41 | if (isupper(*sdum)) *sdum = tolower(*sdum); | | 50 | if (isupper(*sdum)) *sdum = tolower(*sdum); |
42 | } | | 51 | } |
43 | if (strcmp(CharacterSet, "us-ascii") | | 52 | if (strcmp(CharacterSet, "us-ascii") |
44 | + && strcmp(CharacterSet, "koi8-r") | | 53 | + && strcmp(CharacterSet, "koi8-r") |
45 | && strncmp(CharacterSet, "iso-8859-", 9)) { | | 54 | && strncmp(CharacterSet, "iso-8859-", 9)) { |
46 | fprintf(stderr, "mailto: Unsupported character set: %s\n", CharacterSet); | | 55 | fprintf(stderr, "mailto: Unsupported character set: %s\n", CharacterSet); |
47 | exit(-1); | | 56 | exit(-1); |
48 | @@ -1042,10 +1049,7 @@ char *newid() { | | 57 | @@ -1042,10 +1050,7 @@ char *newid() { |
49 | return(idbuf); | | 58 | return(idbuf); |
50 | } | | 59 | } |
51 | | | 60 | |
52 | -WriteOutMessage(fp, ToList, Subject, CCList, FirstPart) | | 61 | -WriteOutMessage(fp, ToList, Subject, CCList, FirstPart) |
53 | -FILE *fp; | | 62 | -FILE *fp; |
54 | -char *ToList, *Subject, *CCList; | | 63 | -char *ToList, *Subject, *CCList; |
55 | -struct mailpart *FirstPart; | | 64 | -struct mailpart *FirstPart; |
56 | +void WriteOutMessage(FILE *fp, char *ToList, char *Subject, char *CCList, struct mailpart *FirstPart) | | 65 | +void WriteOutMessage(FILE *fp, char *ToList, char *Subject, char *CCList, struct mailpart *FirstPart) |
57 | { | | 66 | { |
58 | FILE *fpin; | | 67 | FILE *fpin; |
59 | static int ctr = 0; | | 68 | static int ctr = 0; |
60 | @@ -1130,6 +1134,7 @@ struct mailpart *part; | | 69 | @@ -1130,6 +1135,7 @@ struct mailpart *part; |
61 | if (part->isrich) { | | 70 | if (part->isrich) { |
62 | if (strcmp(CharacterSet, "us-ascii") | | 71 | if (strcmp(CharacterSet, "us-ascii") |
63 | && (strncmp(CharacterSet, "iso-8859-", 9) | | 72 | && (strncmp(CharacterSet, "iso-8859-", 9) |
64 | + && strcmp(CharacterSet, "koi8-r") | | 73 | + && strcmp(CharacterSet, "koi8-r") |
65 | || part->encoding_type_needed != ENC_NONE)) { | | 74 | || part->encoding_type_needed != ENC_NONE)) { |
66 | fprintf(fp, "Content-type: text/richtext; charset=\"%s\"\n", CharacterSet); | | 75 | fprintf(fp, "Content-type: text/richtext; charset=\"%s\"\n", CharacterSet); |
67 | } else { | | 76 | } else { |
68 | @@ -1140,6 +1145,7 @@ struct mailpart *part; | | 77 | @@ -1140,6 +1146,7 @@ struct mailpart *part; |
69 | WriteCtypeNicely(fp, part->content_type); | | 78 | WriteCtypeNicely(fp, part->content_type); |
70 | if (strcmp(CharacterSet, "us-ascii") | | 79 | if (strcmp(CharacterSet, "us-ascii") |
71 | && (strncmp(CharacterSet, "iso-8859-", 9) | | 80 | && (strncmp(CharacterSet, "iso-8859-", 9) |
72 | + && strcmp(CharacterSet, "koi8-r") | | 81 | + && strcmp(CharacterSet, "koi8-r") |
73 | || part->encoding_type_needed != ENC_NONE)) { | | 82 | || part->encoding_type_needed != ENC_NONE)) { |
74 | fprintf(fp, "; charset=\"%s\"\n", CharacterSet); | | 83 | fprintf(fp, "; charset=\"%s\"\n", CharacterSet); |
75 | } else fputs("\n", fp); | | 84 | } else fputs("\n", fp); |
76 | @@ -1328,11 +1334,7 @@ struct mailpart *part; | | 85 | @@ -1328,11 +1335,7 @@ struct mailpart *part; |
77 | } | | 86 | } |
78 | } | | 87 | } |
79 | | | 88 | |
80 | -FputsQuotingLT(s, fp, part, EightBitMode, RightToLeftMode) | | 89 | -FputsQuotingLT(s, fp, part, EightBitMode, RightToLeftMode) |
81 | -char *s; | | 90 | -char *s; |
82 | -FILE *fp; | | 91 | -FILE *fp; |
83 | -struct mailpart *part; | | 92 | -struct mailpart *part; |
84 | -int EightBitMode, RightToLeftMode; | | 93 | -int EightBitMode, RightToLeftMode; |
85 | +void FputsQuotingLT(char *s, FILE *fp, struct mailpart *part, int EightBitMode, int RightToLeftMode) | | 94 | +void FputsQuotingLT(char *s, FILE *fp, struct mailpart *part, int EightBitMode, int RightToLeftMode) |
86 | { | | 95 | { |
87 | static int InNewLineSequence=1; | | 96 | static int InNewLineSequence=1; |
88 | int c=0; | | 97 | int c=0; |
89 | @@ -1745,6 +1747,7 @@ CreateNewPart() { | | 98 | @@ -1745,6 +1748,7 @@ CreateNewPart() { |
90 | } | | 99 | } |
91 | printf("\n\nEnter your choice as a number from 0 to %d: ", i); | | 100 | printf("\n\nEnter your choice as a number from 0 to %d: ", i); |
92 | fflush(stdout); | | 101 | fflush(stdout); |
93 | + *LineBuf = '\0'; | | 102 | + *LineBuf = '\0'; |
94 | fgets(LineBuf, sizeof(LineBuf), stdin); | | 103 | fgets(LineBuf, sizeof(LineBuf), stdin); |
95 | ans = atoi(LineBuf); | | 104 | ans = atoi(LineBuf); |
96 | if (ans == 0 || ans == 1) { | | 105 | if (ans == 0 || ans == 1) { |
97 | @@ -1791,7 +1794,7 @@ CreateNewPart() { | | 106 | @@ -1791,7 +1795,7 @@ CreateNewPart() { |
98 | int ct; | | 107 | int ct; |
99 | printf("\nEnter the MIME Content-type value for the data from file %s\n (type '?' for a list of locally-valid content-types): ", sdum); | | 108 | printf("\nEnter the MIME Content-type value for the data from file %s\n (type '?' for a list of locally-valid content-types): ", sdum); |
100 | fflush(stdout); | | 109 | fflush(stdout); |
101 | - gets(LineBuf); | | 110 | - gets(LineBuf); |
102 | + fgets(LineBuf, sizeof(LineBuf), stdin); | | 111 | + fgets(LineBuf, sizeof(LineBuf), stdin); |
103 | if (index(LineBuf, '/')) { | | 112 | if (index(LineBuf, '/')) { |
104 | char lc[100], *s, AnsBuf[100]; | | 113 | char lc[100], *s, AnsBuf[100]; |
105 | strcpy(lc, LineBuf); | | 114 | strcpy(lc, LineBuf); |
106 | @@ -1809,7 +1812,7 @@ CreateNewPart() { | | 115 | @@ -1809,7 +1813,7 @@ CreateNewPart() { |
107 | } | | 116 | } |
108 | if (mc) break; | | 117 | if (mc) break; |
109 | 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); | | 118 | 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); |
110 | - s = gets(AnsBuf); | | 119 | - s = gets(AnsBuf); |
111 | + s = fgets(AnsBuf, sizeof(AnsBuf), stdin); | | 120 | + s = fgets(AnsBuf, sizeof(AnsBuf), stdin); |
112 | while (s && *s && isspace((unsigned char) *s)) ++s; | | 121 | while (s && *s && isspace((unsigned char) *s)) ++s; |
113 | if (s && (*s == 'y' || *s == 'Y')) break; | | 122 | if (s && (*s == 'y' || *s == 'Y')) break; |
114 | continue; | | 123 | continue; |
115 | @@ -2073,8 +2076,7 @@ char *ctype, *pat; | | 124 | @@ -2073,8 +2077,7 @@ char *ctype, *pat; |
116 | return(0); | | 125 | return(0); |
117 | } | | 126 | } |
118 | | | 127 | |
119 | -EditCurrentMessage(UseVisual) | | 128 | -EditCurrentMessage(UseVisual) |
120 | -int UseVisual; | | 129 | -int UseVisual; |
121 | +void EditCurrentMessage(int UseVisual) | | 130 | +void EditCurrentMessage(int UseVisual) |
122 | { | | 131 | { |
123 | char *editor = NULL; | | 132 | char *editor = NULL; |
124 | char *CmdBuf, *CmdBuf2, LineBuf[100]; | | 133 | char *CmdBuf, *CmdBuf2, LineBuf[100]; |
125 | @@ -2212,9 +2214,7 @@ int IsAndrew; | | 134 | @@ -2212,9 +2215,7 @@ int IsAndrew; |
126 | } | | 135 | } |
127 | } | | 136 | } |
128 | | | 137 | |
129 | -ProcessOneMailRC(fname, IsAndrew) | | 138 | -ProcessOneMailRC(fname, IsAndrew) |
130 | -char *fname; | | 139 | -char *fname; |
131 | -int IsAndrew; | | 140 | -int IsAndrew; |
132 | +void ProcessOneMailRC(char *fname, int IsAndrew) | | 141 | +void ProcessOneMailRC(char *fname, int IsAndrew) |
133 | { | | 142 | { |
134 | FILE *fp; | | 143 | FILE *fp; |
135 | char *LineBuf = NULL, *sdum; | | 144 | char *LineBuf = NULL, *sdum; |
136 | @@ -2290,8 +2290,7 @@ struct alias { | | 145 | @@ -2290,8 +2291,7 @@ struct alias { |
137 | struct alias *next; | | 146 | struct alias *next; |
138 | } *FirstAlias = NULL; | | 147 | } *FirstAlias = NULL; |
139 | | | 148 | |
140 | -HandleAliasCommand(aliasline) | | 149 | -HandleAliasCommand(aliasline) |
141 | -char *aliasline; | | 150 | -char *aliasline; |
142 | +void HandleAliasCommand(char *aliasline) | | 151 | +void HandleAliasCommand(char *aliasline) |
143 | { | | 152 | { |
144 | struct alias *tmpalias; | | 153 | struct alias *tmpalias; |
145 | char *s, *s2; | | 154 | char *s, *s2; |
146 | @@ -2357,10 +2356,7 @@ char *s; | | 155 | @@ -2357,10 +2357,7 @@ char *s; |
147 | return(NULL); | | 156 | return(NULL); |
148 | } | | 157 | } |
149 | | | 158 | |
150 | -HeaderFputs(s, fp, hdr) | | 159 | -HeaderFputs(s, fp, hdr) |
151 | -char *s; | | 160 | -char *s; |
152 | -FILE *fp; | | 161 | -FILE *fp; |
153 | -char *hdr; | | 162 | -char *hdr; |
154 | +void HeaderFputs(char *s, FILE *fp, char *hdr) | | 163 | +void HeaderFputs(char *s, FILE *fp, char *hdr) |
155 | { | | 164 | { |
156 | char *firstnonascii, *firstascii; | | 165 | char *firstnonascii, *firstascii; |
157 | | | 166 | |
158 | @@ -2436,10 +2432,7 @@ char *hdr; | | 167 | @@ -2436,10 +2433,7 @@ char *hdr; |
159 | } | | 168 | } |
160 | } | | 169 | } |
161 | | | 170 | |
162 | -DeAlias(name, fp, hdr) | | 171 | -DeAlias(name, fp, hdr) |
163 | -char *name; | | 172 | -char *name; |
164 | -FILE *fp; | | 173 | -FILE *fp; |
165 | -char *hdr; | | 174 | -char *hdr; |
166 | +void DeAlias(char *name, FILE *fp, char *hdr) | | 175 | +void DeAlias(char *name, FILE *fp, char *hdr) |
167 | { | | 176 | { |
168 | struct alias *tmpalias; | | 177 | struct alias *tmpalias; |
169 | char *end, savechar; | | 178 | char *end, savechar; |