diff -r b3f24e23bc25 -r bf54085ce341 src/c2html.h --- a/src/c2html.h Wed Aug 31 12:58:48 2016 +0200 +++ b/src/c2html.h Wed Aug 31 14:41:56 2016 +0200 @@ -30,6 +30,9 @@ #ifndef C2HTML_H #define C2HTML_H +#include +#include "highlighter.h" + #ifdef __cplusplus extern "C" { #endif @@ -38,14 +41,102 @@ #define VERSION_MINOR 0 #define VERSION_DEVELOP 1 /* set this to zero for release version */ -typedef struct { - char* outfilename; - char* headerfile; - char* footerfile; - char* infilename; - int showlinenumbers; -} Settings; +/** + * Reads a source file from the input buffer and writes at most + * maxlen bytes of the formatted output to the output buffer. + * + * The output buffer must either be large enough to hold maxlen + * bytes or the write function must trigger an automatic extension of the buffer. + * + * @param inputbuffer the input buffer + * @param rfnc a read function operating for the input buffer + * @param ibuf intermediate processing buffer + * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) + * @param outputbuffer the output buffer + * @param wfnc a write function for the output buffer + * @param maxlen the maximum amount bytes which will be written to the + * output buffer + * @param hltr the highlighter function + * @param showln zero, if line numbers shall be omitted, nonzero otherwise + * + * @return total amount of bytes written to the output buffer + * + * @see c2html_plain_highlighter() + * @see c2html_c_highlighter() + * @see c2html_java_highlighter() + */ +size_t c2html_formatn(void* inputbuffer, read_func rfnc, + char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc, + size_t maxlen, c2html_highlighter_func hltr, int showln); + +/** + * Reads a source file from the input buffer and writes the formatted output + * to an output buffer. + * + * The output buffer must either be large enough to hold the formatted data + * or the write function must trigger an automatic extension of the buffer. + * + * @param inputbuffer the input buffer + * @param rfnc a read function operating for the input buffer + * @param ibuf intermediate processing buffer + * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) + * @param outputbuffer the output buffer + * @param wfnc a write function for the output buffer + * @param hltr the highlighter function + * @param showln zero, if line numbers shall be omitted, nonzero otherwise + * + * @return total amount of bytes written to the output buffer + * + * @see c2html_plain_highlighter() + * @see c2html_c_highlighter() + * @see c2html_java_highlighter() + */ +size_t c2html_format(void* inputbuffer, read_func rfnc, + char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc, + c2html_highlighter_func hltr, int showln); +/** + * Reads a source file from the specified input file stream and writes the + * formatted output to an output buffer. + * + * The output buffer must either be large enough to hold the formatted data + * or the write function must trigger an automatic extension of the buffer. + * + * @param inputfile the input file stream + * @param ibuf intermediate processing buffer + * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) + * @param outputbuffer the output buffer + * @param wfnc a write function for the output buffer + * @param hltr the highlighter function + * @param showln zero, if line numbers shall be omitted, nonzero otherwise + * + * @return total amount of bytes written to the output buffer + * + * @see c2html_plain_highlighter() + * @see c2html_c_highlighter() + * @see c2html_java_highlighter() + */ +size_t c2html_format_file(FILE* inputfile, char *ibuf, size_t ibuflen, + void* outputbuffer, write_func wfnc, + c2html_highlighter_func hltr, int showln); + +/** + * Reads a source file from the specified input file stream and directly writes + * the formatted output to the output file stream. + * + * @param inputfile the input file stream + * @param ibuf intermediate processing buffer + * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) + * @param outputfile the output file stream + * @param hltr the highlighter function + * @param showln zero, if line numbers shall be omitted, nonzero otherwise + * + * @see c2html_plain_highlighter() + * @see c2html_c_highlighter() + * @see c2html_java_highlighter() + */ +void c2html_fformat_file(FILE *inputfile, char *ibuf, size_t ibuflen, + FILE* outputfile, c2html_highlighter_func hltr, int showln); #ifdef __cplusplus }