# HG changeset patch # User Mike Becker # Date 1472647316 -7200 # Node ID bf54085ce341ec303887171ee5e70003428d01ee # Parent b3f24e23bc2519ae0b79756f4e69a36e6941415c adds appropriate public API diff -r b3f24e23bc25 -r bf54085ce341 Makefile --- a/Makefile Wed Aug 31 12:58:48 2016 +0200 +++ b/Makefile Wed Aug 31 14:41:56 2016 +0200 @@ -31,8 +31,8 @@ include $(CONF).mk - -SRC = c2html.c +SRC = frontend.c +SRC += c2html.c SRC += highlighter.c SRC += ucx/allocator.c SRC += ucx/buffer.c diff -r b3f24e23bc25 -r bf54085ce341 src/c2html.c --- a/src/c2html.c Wed Aug 31 12:58:48 2016 +0200 +++ b/src/c2html.c Wed Aug 31 14:41:56 2016 +0200 @@ -27,47 +27,21 @@ * */ -#include - #include "c2html.h" -#include "highlighter.h" #include "ucx/list.h" +#include "ucx/utils.h" -static int appendfile(const char *filename, FILE *fout, - char *copybuf, size_t copybuflen, const char *errmsg) { - FILE *headerfile = fopen(filename, "r"); - if (!headerfile) { - perror(errmsg); - if (fout != stdout) { - fclose(fout); - } - return 1; +#define try_write(wfnc, str, n, buf, written, maxlen) \ + { \ + size_t m = maxlen-written; \ + written += wfnc(str, 1, n > m ? m : n, buf); \ } - ucx_stream_copy(headerfile, fout, - (read_func) fread, (write_func) fwrite, - copybuf, copybuflen, (size_t)-1); - fclose(headerfile); - return 0; -} -static void printhelp() { - printf("Formats source code using HTML.\n\nUsage:\n" - " c2html [Options] FILE\n\n" - " Options:\n" - " -h Prints this help message\n" - " -j Highlight Java instead of C source code\n" - " -o Output file (stdout, if not specified)\n" - " -H
Prepend header file\n" - " -F