1.1 --- a/src/c2html.h Wed Aug 31 12:58:48 2016 +0200 1.2 +++ b/src/c2html.h Wed Aug 31 14:41:56 2016 +0200 1.3 @@ -30,6 +30,9 @@ 1.4 #ifndef C2HTML_H 1.5 #define C2HTML_H 1.6 1.7 +#include <stdio.h> 1.8 +#include "highlighter.h" 1.9 + 1.10 #ifdef __cplusplus 1.11 extern "C" { 1.12 #endif 1.13 @@ -38,14 +41,102 @@ 1.14 #define VERSION_MINOR 0 1.15 #define VERSION_DEVELOP 1 /* set this to zero for release version */ 1.16 1.17 -typedef struct { 1.18 - char* outfilename; 1.19 - char* headerfile; 1.20 - char* footerfile; 1.21 - char* infilename; 1.22 - int showlinenumbers; 1.23 -} Settings; 1.24 +/** 1.25 + * Reads a source file from the input buffer and writes at most 1.26 + * <code>maxlen</code> bytes of the formatted output to the output buffer. 1.27 + * 1.28 + * The output buffer must either be large enough to hold <code>maxlen</code> 1.29 + * bytes or the write function must trigger an automatic extension of the buffer. 1.30 + * 1.31 + * @param inputbuffer the input buffer 1.32 + * @param rfnc a read function operating for the input buffer 1.33 + * @param ibuf intermediate processing buffer 1.34 + * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) 1.35 + * @param outputbuffer the output buffer 1.36 + * @param wfnc a write function for the output buffer 1.37 + * @param maxlen the maximum amount bytes which will be written to the 1.38 + * output buffer 1.39 + * @param hltr the highlighter function 1.40 + * @param showln zero, if line numbers shall be omitted, nonzero otherwise 1.41 + * 1.42 + * @return total amount of bytes written to the output buffer 1.43 + * 1.44 + * @see c2html_plain_highlighter() 1.45 + * @see c2html_c_highlighter() 1.46 + * @see c2html_java_highlighter() 1.47 + */ 1.48 +size_t c2html_formatn(void* inputbuffer, read_func rfnc, 1.49 + char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc, 1.50 + size_t maxlen, c2html_highlighter_func hltr, int showln); 1.51 + 1.52 +/** 1.53 + * Reads a source file from the input buffer and writes the formatted output 1.54 + * to an output buffer. 1.55 + * 1.56 + * The output buffer must either be large enough to hold the formatted data 1.57 + * or the write function must trigger an automatic extension of the buffer. 1.58 + * 1.59 + * @param inputbuffer the input buffer 1.60 + * @param rfnc a read function operating for the input buffer 1.61 + * @param ibuf intermediate processing buffer 1.62 + * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) 1.63 + * @param outputbuffer the output buffer 1.64 + * @param wfnc a write function for the output buffer 1.65 + * @param hltr the highlighter function 1.66 + * @param showln zero, if line numbers shall be omitted, nonzero otherwise 1.67 + * 1.68 + * @return total amount of bytes written to the output buffer 1.69 + * 1.70 + * @see c2html_plain_highlighter() 1.71 + * @see c2html_c_highlighter() 1.72 + * @see c2html_java_highlighter() 1.73 + */ 1.74 +size_t c2html_format(void* inputbuffer, read_func rfnc, 1.75 + char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc, 1.76 + c2html_highlighter_func hltr, int showln); 1.77 1.78 +/** 1.79 + * Reads a source file from the specified input file stream and writes the 1.80 + * formatted output to an output buffer. 1.81 + * 1.82 + * The output buffer must either be large enough to hold the formatted data 1.83 + * or the write function must trigger an automatic extension of the buffer. 1.84 + * 1.85 + * @param inputfile the input file stream 1.86 + * @param ibuf intermediate processing buffer 1.87 + * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) 1.88 + * @param outputbuffer the output buffer 1.89 + * @param wfnc a write function for the output buffer 1.90 + * @param hltr the highlighter function 1.91 + * @param showln zero, if line numbers shall be omitted, nonzero otherwise 1.92 + * 1.93 + * @return total amount of bytes written to the output buffer 1.94 + * 1.95 + * @see c2html_plain_highlighter() 1.96 + * @see c2html_c_highlighter() 1.97 + * @see c2html_java_highlighter() 1.98 + */ 1.99 +size_t c2html_format_file(FILE* inputfile, char *ibuf, size_t ibuflen, 1.100 + void* outputbuffer, write_func wfnc, 1.101 + c2html_highlighter_func hltr, int showln); 1.102 + 1.103 +/** 1.104 + * Reads a source file from the specified input file stream and directly writes 1.105 + * the formatted output to the output file stream. 1.106 + * 1.107 + * @param inputfile the input file stream 1.108 + * @param ibuf intermediate processing buffer 1.109 + * @param ibuflen length of intermediate processing buffer (recommended: 4 KB) 1.110 + * @param outputfile the output file stream 1.111 + * @param hltr the highlighter function 1.112 + * @param showln zero, if line numbers shall be omitted, nonzero otherwise 1.113 + * 1.114 + * @see c2html_plain_highlighter() 1.115 + * @see c2html_c_highlighter() 1.116 + * @see c2html_java_highlighter() 1.117 + */ 1.118 +void c2html_fformat_file(FILE *inputfile, char *ibuf, size_t ibuflen, 1.119 + FILE* outputfile, c2html_highlighter_func hltr, int showln); 1.120 1.121 #ifdef __cplusplus 1.122 }