src/frontend.c

Mon, 03 Oct 2022 12:56:28 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 03 Oct 2022 12:56:28 +0200
changeset 65
7dd4fd1e7071
parent 61
47a5fc33590a
child 67
5da2cb5aea6b
permissions
-rw-r--r--

rewrite Makefile to work with different getopt implementations

55
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2016 Mike Becker. All rights reserved.
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 *
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 */
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 #include <stdio.h>
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31 #include <stdlib.h>
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 #include <unistd.h>
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 #include <string.h>
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 #include "c2html.h"
61
47a5fc33590a ucx is now used as external library
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
36 #include <ucx/utils.h>
55
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 #define FILEBUF_SIZE 4096
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 typedef struct {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 char* outfilename;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 char* headerfile;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 char* footerfile;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 char* infilename;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 int showlinenumbers;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 } Settings;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 static int appendfile(const char *filename, FILE *fout,
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 char *copybuf, size_t copybuflen, const char *errmsg) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 FILE *headerfile = fopen(filename, "r");
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 if (!headerfile) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 perror(errmsg);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 if (fout != stdout) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 fclose(fout);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 return 1;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 }
61
47a5fc33590a ucx is now used as external library
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
58 ucx_stream_bncopy(headerfile, fout,
55
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 (read_func) fread, (write_func) fwrite,
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 copybuf, copybuflen, (size_t)-1);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 fclose(headerfile);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 return 0;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 static void printhelp() {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66 printf("Formats source code using HTML.\n\nUsage:\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 " c2html [Options] FILE\n\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 " Options:\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 " -h Prints this help message\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 " -j Highlight Java instead of C source code\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 " -o <output> Output file (stdout, if not specified)\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 " -H <header> Prepend header file\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 " -F <footer> Append footer file\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 " -p Disable highlighting (plain text)\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 " -l Disable line numbers\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 " -V, -v Prints version and exits\n"
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 "\n");
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 int main(int argc, char** argv) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 /* Default settings */
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 Settings settings;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84 memset(&settings, 0, sizeof(settings));
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85 settings.showlinenumbers = 1;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 c2html_highlighter_func hltr = c2html_c_highlighter;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 /* Parse command line */
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89 char optc;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90 while ((optc = getopt(argc, argv, "hljo:pH:F:vV")) != -1) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 switch (optc) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92 case 'o':
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93 if (!(optarg[0] == '-' && optarg[1] == 0)) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
94 settings.outfilename = optarg;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 break;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 case 'F':
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98 settings.footerfile = optarg;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
99 break;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 case 'H':
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 settings.headerfile = optarg;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 break;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103 case 'j':
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104 hltr = c2html_java_highlighter;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 break;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 case 'p':
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 hltr = c2html_plain_highlighter;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
108 break;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
109 case 'l':
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 settings.showlinenumbers = 0;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 break;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 case 'h':
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 printhelp();
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114 return EXIT_SUCCESS;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 case 'v':
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
116 case 'V':
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
117 #ifdef VERSION_DEVELOP
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
118 printf("%d.%d (unstable)\n", VERSION_MAJOR, VERSION_MINOR);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
119 #else
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
120 printf("%d.%d\n", VERSION_MAJOR, VERSION_MINOR);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 #endif
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 return EXIT_SUCCESS;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
123 default:
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124 return EXIT_FAILURE;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
125 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128 if (optind != argc-1) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
129 printhelp();
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130 return EXIT_FAILURE;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
131 } else {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
132 /* Open output file */
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
133 settings.infilename = argv[optind];
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
134 FILE *fout;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
135 if (settings.outfilename) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
136 fout = fopen(settings.outfilename, "w");
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
137 if (!fout) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
138 perror("Error opening output file");
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
139 return EXIT_FAILURE;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
140 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
141 } else {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
142 fout = stdout;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
143 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
144
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
145 /* Allocate file buffer */
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
146 char *filebuf = malloc(FILEBUF_SIZE);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
147 if (!filebuf) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
148 perror("Error allocating file buffer");
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
149 return EXIT_FAILURE;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
150 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
151
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152 /* Prepend header file */
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
153 if (appendfile(settings.headerfile, fout, filebuf, FILEBUF_SIZE,
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
154 "Error opening header file")) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 return EXIT_FAILURE;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
157
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
158 /* Process input file */
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
159 FILE *inputfile = fopen(settings.infilename, "r");
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
160 if (inputfile) {
57
eba880c1705c improves API and adds functions for strings
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
161 c2html_fformatf(
55
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
162 inputfile, filebuf, FILEBUF_SIZE,
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
163 fout, hltr, settings.showlinenumbers
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
164 );
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
165 fclose(inputfile);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166 } else {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 perror("Error opening input file");
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 if (fout != stdout) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169 fclose(fout);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
170 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
171 return EXIT_FAILURE;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
173
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
174 /* Append footer file */
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
175 if (appendfile(settings.footerfile, fout, filebuf, FILEBUF_SIZE,
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
176 "Error opening footer file")) {
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
177 return EXIT_FAILURE;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
178 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
179
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
180 free(filebuf);
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
181
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
182 return EXIT_SUCCESS;
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
183 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
184 }
bf54085ce341 adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
185

mercurial