ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/mports/trunk/mail/faces/files/patch-cb
Revision: 16349
Committed: Sun Apr 20 18:32:36 2014 UTC (10 years ago) by laffer1
File size: 6854 byte(s)
Log Message:
remove cvs2svn:cvs-rev prop

File Contents

# Content
1 *** compface/cmain.c Thu Feb 21 16:42:54 2002
2 --- /home/lkoeller/tmp/ports/mail/faces/work/faces/compface/cmain.c Thu Oct 24 03:28:07 1991
3 ***************
4 *** 13,89 ****
5 * to me, then an attempt will be made to fix them.
6 */
7
8 - #include <stdlib.h>
9 - #include <unistd.h>
10 #include <fcntl.h>
11 #include "compface.h"
12
13 ! #define STRCAT (void) strcat
14 ! #define STRCPY (void) strcpy
15 ! #define WRITE (void) write
16 !
17 ! /* The buffer is longer than needed to handle sparse input formats */
18 !
19 #define FACEBUFLEN 2048
20 char fbuf[FACEBUFLEN];
21
22 /* IO file descriptors and their names */
23 -
24 int infile = 0;
25 char *inname = "<stdin>";
26 int outfile = 1;
27 char *outname = "<stdout>";
28
29 ! char *cmdname; /* Basename of executable */
30
31 ! /* Error handling definitions follow */
32
33 extern int errno, sys_nerr;
34 extern char *sys_errlist[];
35
36 #define ERR ((errno < sys_nerr) ? sys_errlist[errno] : "")
37 ! #define INITERR(s) { \
38 ! STRCPY(fbuf, cmdname); \
39 ! STRCAT(fbuf, ": "); \
40 ! STRCAT(fbuf, (s));\
41 ! }
42 ! #define ADDERR(s) STRCAT(fbuf, (s));
43 ! #define ERROR { \
44 ! STRCAT(fbuf, "\n"); \
45 ! WRITE(2, fbuf, strlen(fbuf)); \
46 ! exit(1); \
47 ! }
48 ! #define INITWARN(s) { \
49 ! STRCPY(fbuf, cmdname); \
50 ! STRCAT(fbuf, ": (warning) "); \
51 ! STRCAT(fbuf, (s)); \
52 ! }
53 ! #define ADDWARN(s) STRCAT(fbuf, (s));
54 ! #define WARN { \
55 ! STRCAT(fbuf, "\n"); \
56 ! WRITE(2, fbuf, strlen(fbuf)); \
57 ! }
58
59 int
60 ! main(int argc, char *argv[])
61 {
62 cmdname = *argv;
63 ! while (**argv) {
64 ! if (*((*argv)++) == '/') {
65 ! cmdname = *argv; /* Find the command's basename */
66 ! }
67 ! }
68
69 ! if (argc > 3) {
70 INITERR("usage: ")
71 ADDERR(cmdname)
72 ADDERR(" [infile [outfile]]")
73 ERROR
74 }
75
76 ! if ((argc > 1) && strcmp(*++argv, "-")) {
77 inname = *argv;
78 ! if ((infile = open(inname, O_RDONLY)) == -1) {
79 INITERR(inname)
80 ADDERR(": ")
81 ADDERR(ERR)
82 --- 15,78 ----
83 * to me, then an attempt will be made to fix them.
84 */
85
86 #include <fcntl.h>
87 #include "compface.h"
88
89 ! /* the buffer is longer than needed to handle sparse input formats */
90 #define FACEBUFLEN 2048
91 char fbuf[FACEBUFLEN];
92
93 /* IO file descriptors and their names */
94 int infile = 0;
95 char *inname = "<stdin>";
96 int outfile = 1;
97 char *outname = "<stdout>";
98
99 ! /* basename of executable */
100 ! char *cmdname;
101
102 ! /* error handling definitions follow */
103
104 extern int errno, sys_nerr;
105 extern char *sys_errlist[];
106
107 + extern void exit P((int)) ;
108 +
109 #define ERR ((errno < sys_nerr) ? sys_errlist[errno] : "")
110 ! #define INITERR(s) {(void)strcpy(fbuf, cmdname); (void)strcat(fbuf, ": ");\
111 ! (void)strcat(fbuf, (s));}
112 ! #define ADDERR(s) (void)strcat(fbuf, (s));
113 ! #define ERROR {(void)strcat(fbuf, "\n");\
114 ! (void)write(2, fbuf, strlen(fbuf)); exit(1);}
115 ! #define INITWARN(s) {(void)strcpy(fbuf, cmdname);\
116 ! (void)strcat(fbuf, ": (warning) ");\
117 ! (void)strcat(fbuf, (s));}
118 ! #define ADDWARN(s) (void)strcat(fbuf, (s));
119 ! #define WARN {(void)strcat(fbuf, "\n"); (void)write(2, fbuf, strlen(fbuf));}
120
121 int
122 ! main(argc, argv)
123 ! int argc;
124 ! char *argv[];
125 {
126 cmdname = *argv;
127 ! while (**argv)
128 ! if (*((*argv)++) == '/')
129 ! cmdname = *argv; /* find the command's basename */
130
131 ! if (argc > 3)
132 ! {
133 INITERR("usage: ")
134 ADDERR(cmdname)
135 ADDERR(" [infile [outfile]]")
136 ERROR
137 }
138
139 ! if ((argc > 1) && strcmp(*++argv, "-"))
140 ! {
141 inname = *argv;
142 ! if ((infile = open(inname, O_RDONLY)) == -1)
143 ! {
144 INITERR(inname)
145 ADDERR(": ")
146 ADDERR(ERR)
147 ***************
148 *** 91,100 ****
149 }
150 }
151
152 ! if (argc > 2) {
153 outname = *++argv;
154 ! if ((outfile = open(outname, O_WRONLY | O_CREAT |
155 ! O_TRUNC, 0644)) == -1) {
156 INITERR(outname)
157 ADDERR(": ")
158 ADDERR(ERR)
159 --- 80,90 ----
160 }
161 }
162
163 ! if (argc > 2)
164 ! {
165 outname = *++argv;
166 ! if ((outfile = open(outname, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
167 ! {
168 INITERR(outname)
169 ADDERR(": ")
170 ADDERR(ERR)
171 ***************
172 *** 103,109 ****
173 }
174
175 (void) ReadBuf();
176 ! switch (compface(fbuf)) {
177 case -2 : INITERR("internal error")
178 ERROR
179 case -1 : INITERR(inname)
180 --- 93,100 ----
181 }
182
183 (void) ReadBuf();
184 ! switch (compface(fbuf))
185 ! {
186 case -2 : INITERR("internal error")
187 ERROR
188 case -1 : INITERR(inname)
189 ***************
190 *** 123,135 ****
191 int
192 WriteBuf()
193 {
194 ! char *s, *t;
195 ! int len;
196
197 s = fbuf;
198 t = s + strlen(s);
199 ! while (s < t) {
200 ! if ((len = write(outfile, s, t - s)) == -1) {
201 INITERR(outname)
202 ADDERR(": ")
203 ADDERR(ERR)
204 --- 114,128 ----
205 int
206 WriteBuf()
207 {
208 ! register char *s, *t;
209 ! register int len;
210
211 s = fbuf;
212 t = s + strlen(s);
213 ! while (s < t)
214 ! {
215 ! if ((len = write(outfile, s, t - s)) == -1)
216 ! {
217 INITERR(outname)
218 ADDERR(": ")
219 ADDERR(ERR)
220 ***************
221 *** 137,163 ****
222 }
223 s += len;
224 }
225 ! return(0);
226 }
227
228
229 int
230 ReadBuf()
231 {
232 ! int count, len;
233 ! char *t;
234
235 count = 0;
236 t = fbuf;
237 ! while ((len = read(infile, t, FACEBUFLEN - count))) {
238 ! if (len == -1) {
239 INITERR(inname)
240 ADDERR(": ")
241 ADDERR(ERR)
242 ERROR
243 }
244 t += len;
245 ! if ((count += len) >= FACEBUFLEN) {
246 INITWARN(inname)
247 ADDWARN(" exceeds internal buffer size. Data may be lost")
248 WARN
249 --- 130,159 ----
250 }
251 s += len;
252 }
253 ! return 0;
254 }
255
256
257 int
258 ReadBuf()
259 {
260 ! register int count, len;
261 ! register char *t;
262
263 count = 0;
264 t = fbuf;
265 ! while (len = read(infile, t, FACEBUFLEN - count))
266 ! {
267 ! if (len == -1)
268 ! {
269 INITERR(inname)
270 ADDERR(": ")
271 ADDERR(ERR)
272 ERROR
273 }
274 t += len;
275 ! if ((count += len) >= FACEBUFLEN)
276 ! {
277 INITWARN(inname)
278 ADDWARN(" exceeds internal buffer size. Data may be lost")
279 WARN
280 ***************
281 *** 165,169 ****
282 }
283 }
284 *t = '\0';
285 ! return(count);
286 }
287 --- 161,165 ----
288 }
289 }
290 *t = '\0';
291 ! return count;
292 }