universe@23: /* universe@23: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. universe@23: * universe@35: * Copyright 2016 Mike Becker. All rights reserved. universe@23: * universe@23: * Redistribution and use in source and binary forms, with or without universe@23: * modification, are permitted provided that the following conditions are met: universe@23: * universe@23: * 1. Redistributions of source code must retain the above copyright universe@23: * notice, this list of conditions and the following disclaimer. universe@23: * universe@23: * 2. Redistributions in binary form must reproduce the above copyright universe@23: * notice, this list of conditions and the following disclaimer in the universe@23: * documentation and/or other materials provided with the distribution. universe@23: * universe@23: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" universe@23: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE universe@23: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE universe@23: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE universe@23: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR universe@23: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF universe@23: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS universe@23: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN universe@23: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) universe@23: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE universe@23: * POSSIBILITY OF SUCH DAMAGE. universe@23: * universe@23: */ universe@52: universe@52: #include universe@52: universe@22: #include "c2html.h" universe@52: #include "highlighter.h" universe@1: universe@39: #include "ucx/list.h" universe@1: universe@53: static int appendfile(const char *filename, FILE *fout, universe@53: char *copybuf, size_t copybuflen, const char *errmsg) { universe@53: FILE *headerfile = fopen(filename, "r"); universe@53: if (!headerfile) { universe@53: perror(errmsg); universe@53: if (fout != stdout) { universe@53: fclose(fout); universe@53: } universe@53: return 1; universe@53: } universe@53: ucx_stream_copy(headerfile, fout, universe@53: (read_func) fread, (write_func) fwrite, universe@53: copybuf, copybuflen, (size_t)-1); universe@53: fclose(headerfile); universe@53: return 0; universe@53: } universe@53: universe@53: static void printhelp() { universe@19: printf("Formats source code using HTML.\n\nUsage:\n" universe@19: " c2html [Options] FILE\n\n" universe@19: " Options:\n" universe@19: " -h Prints this help message\n" universe@19: " -j Highlight Java instead of C source code\n" universe@19: " -o Output file (stdout, if not specified)\n" universe@22: " -H
Prepend header file\n" universe@22: " -F