Mercurial > ~dholland > hg > tradcpp > index.cgi
comparison output.c @ 143:ed45f2d8d3bc
Don't use the <err.h> functions.
There are still people out there using legacy systems that are missing
them.
author | David A. Holland |
---|---|
date | Sat, 13 Jul 2013 12:47:20 -0400 |
parents | 1cda505ddc78 |
children | 16b4451e34b8 |
comparison
equal
deleted
inserted
replaced
142:26ee741196d1 | 143:ed45f2d8d3bc |
---|---|
28 */ | 28 */ |
29 | 29 |
30 #include <string.h> | 30 #include <string.h> |
31 #include <unistd.h> | 31 #include <unistd.h> |
32 #include <fcntl.h> | 32 #include <fcntl.h> |
33 #include <err.h> | 33 #include <errno.h> |
34 | 34 |
35 #include "utils.h" | 35 #include "utils.h" |
36 #include "mode.h" | 36 #include "mode.h" |
37 #include "place.h" | 37 #include "place.h" |
38 #include "output.h" | 38 #include "output.h" |
51 outputfd = STDOUT_FILENO; | 51 outputfd = STDOUT_FILENO; |
52 } else { | 52 } else { |
53 outputfd = open(mode.output_file, O_WRONLY|O_CREAT|O_TRUNC, | 53 outputfd = open(mode.output_file, O_WRONLY|O_CREAT|O_TRUNC, |
54 0664); | 54 0664); |
55 if (outputfd < 0) { | 55 if (outputfd < 0) { |
56 warn("%s", mode.output_file); | 56 complain(NULL, "%s: %s", |
57 mode.output_file, strerror(errno)); | |
57 die(); | 58 die(); |
58 } | 59 } |
59 } | 60 } |
60 } | 61 } |
61 | 62 |
77 | 78 |
78 done = 0; | 79 done = 0; |
79 while (done < len) { | 80 while (done < len) { |
80 result = write(outputfd, buf+done, len-done); | 81 result = write(outputfd, buf+done, len-done); |
81 if (result == -1) { | 82 if (result == -1) { |
82 warn("%s: write", mode.output_file); | 83 complain(NULL, "%s: write: %s", |
84 mode.output_file, strerror(errno)); | |
83 complain_failed(); | 85 complain_failed(); |
84 write_errors++; | 86 write_errors++; |
85 if (write_errors > 5) { | 87 if (write_errors > 5) { |
86 warnx("%s: giving up", mode.output_file); | 88 complain(NULL, "%s: giving up", |
89 mode.output_file); | |
87 die(); | 90 die(); |
88 } | 91 } |
89 /* XXX is this really a good idea? */ | 92 /* XXX is this really a good idea? */ |
90 sleep(1); | 93 sleep(1); |
91 } | 94 } |