universe@22: /* universe@22: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. universe@22: * universe@35: * Copyright 2016 Mike Becker. All rights reserved. universe@22: * universe@22: * Redistribution and use in source and binary forms, with or without universe@22: * modification, are permitted provided that the following conditions are met: universe@22: * universe@22: * 1. Redistributions of source code must retain the above copyright universe@22: * notice, this list of conditions and the following disclaimer. universe@22: * universe@22: * 2. Redistributions in binary form must reproduce the above copyright universe@22: * notice, this list of conditions and the following disclaimer in the universe@22: * documentation and/or other materials provided with the distribution. universe@22: * universe@22: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" universe@22: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE universe@22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE universe@22: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE universe@22: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR universe@22: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF universe@22: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS universe@22: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN universe@22: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) universe@22: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE universe@22: * POSSIBILITY OF SUCH DAMAGE. universe@22: * universe@22: */ universe@22: universe@22: #ifndef C2HTML_H universe@22: #define C2HTML_H universe@22: universe@55: #include universe@55: #include "highlighter.h" universe@55: universe@22: #ifdef __cplusplus universe@22: extern "C" { universe@22: #endif universe@37: universe@37: #define VERSION_MAJOR 2 universe@37: #define VERSION_MINOR 0 universe@39: #define VERSION_DEVELOP 1 /* set this to zero for release version */ universe@22: universe@55: /** universe@55: * Reads a source file from the input buffer and writes at most universe@55: * maxlen bytes of the formatted output to the output buffer. universe@55: * universe@55: * The output buffer must either be large enough to hold maxlen universe@55: * bytes or the write function must trigger an automatic extension of the buffer. universe@55: * universe@55: * @param inputbuffer the input buffer universe@55: * @param rfnc a read function operating for the input buffer universe@55: * @param ibuf intermediate processing buffer universe@55: * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) universe@55: * @param outputbuffer the output buffer universe@55: * @param wfnc a write function for the output buffer universe@55: * @param maxlen the maximum amount bytes which will be written to the universe@55: * output buffer universe@55: * @param hltr the highlighter function universe@55: * @param showln zero, if line numbers shall be omitted, nonzero otherwise universe@55: * universe@55: * @return total amount of bytes written to the output buffer universe@55: * universe@55: * @see c2html_plain_highlighter() universe@55: * @see c2html_c_highlighter() universe@55: * @see c2html_java_highlighter() universe@55: */ universe@55: size_t c2html_formatn(void* inputbuffer, read_func rfnc, universe@55: char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc, universe@55: size_t maxlen, c2html_highlighter_func hltr, int showln); universe@55: universe@55: /** universe@55: * Reads a source file from the input buffer and writes the formatted output universe@55: * to an output buffer. universe@55: * universe@55: * The output buffer must either be large enough to hold the formatted data universe@55: * or the write function must trigger an automatic extension of the buffer. universe@55: * universe@55: * @param inputbuffer the input buffer universe@55: * @param rfnc a read function operating for the input buffer universe@55: * @param ibuf intermediate processing buffer universe@55: * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) universe@55: * @param outputbuffer the output buffer universe@55: * @param wfnc a write function for the output buffer universe@55: * @param hltr the highlighter function universe@55: * @param showln zero, if line numbers shall be omitted, nonzero otherwise universe@55: * universe@55: * @return total amount of bytes written to the output buffer universe@55: * universe@55: * @see c2html_plain_highlighter() universe@55: * @see c2html_c_highlighter() universe@55: * @see c2html_java_highlighter() universe@55: */ universe@55: size_t c2html_format(void* inputbuffer, read_func rfnc, universe@55: char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc, universe@55: c2html_highlighter_func hltr, int showln); universe@22: universe@55: /** universe@55: * Reads a source file from the specified input file stream and writes the universe@55: * formatted output to an output buffer. universe@55: * universe@55: * The output buffer must either be large enough to hold the formatted data universe@55: * or the write function must trigger an automatic extension of the buffer. universe@55: * universe@55: * @param inputfile the input file stream universe@55: * @param ibuf intermediate processing buffer universe@55: * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) universe@55: * @param outputbuffer the output buffer universe@55: * @param wfnc a write function for the output buffer universe@55: * @param hltr the highlighter function universe@55: * @param showln zero, if line numbers shall be omitted, nonzero otherwise universe@55: * universe@55: * @return total amount of bytes written to the output buffer universe@55: * universe@55: * @see c2html_plain_highlighter() universe@55: * @see c2html_c_highlighter() universe@55: * @see c2html_java_highlighter() universe@55: */ universe@55: size_t c2html_format_file(FILE* inputfile, char *ibuf, size_t ibuflen, universe@55: void* outputbuffer, write_func wfnc, universe@55: c2html_highlighter_func hltr, int showln); universe@55: universe@55: /** universe@55: * Reads a source file from the specified input file stream and directly writes universe@55: * the formatted output to the output file stream. universe@55: * universe@55: * @param inputfile the input file stream universe@55: * @param ibuf intermediate processing buffer universe@55: * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) universe@55: * @param outputfile the output file stream universe@55: * @param hltr the highlighter function universe@55: * @param showln zero, if line numbers shall be omitted, nonzero otherwise universe@55: * universe@55: * @see c2html_plain_highlighter() universe@55: * @see c2html_c_highlighter() universe@55: * @see c2html_java_highlighter() universe@55: */ universe@55: void c2html_fformat_file(FILE *inputfile, char *ibuf, size_t ibuflen, universe@55: FILE* outputfile, c2html_highlighter_func hltr, int showln); universe@22: universe@22: #ifdef __cplusplus universe@22: } universe@22: #endif universe@22: universe@22: #endif /* C2HTML_H */ universe@22: