src/c2html.h

changeset 66
1b12cf799fee
parent 57
eba880c1705c
child 70
60cecca5e484
equal deleted inserted replaced
60:9f25df78925e 66:1b12cf799fee
29 29
30 #ifndef C2HTML_H 30 #ifndef C2HTML_H
31 #define C2HTML_H 31 #define C2HTML_H
32 32
33 #include <stdio.h> 33 #include <stdio.h>
34 #include <cx/list.h>
34 #include "highlighter.h" 35 #include "highlighter.h"
35 36
36 #ifdef __cplusplus 37 #ifdef __cplusplus
37 extern "C" { 38 extern "C" {
38 #endif 39 #endif
39 40
40 #define VERSION_MAJOR 2 41 #define VERSION_MAJOR 3
41 #define VERSION_MINOR 0 42 #define VERSION_MINOR 0
42 #define VERSION_DEVELOP 0 /* set this to zero for release version */ 43 #define VERSION_DEVELOP 0 /* set this to zero for release version */
43 44
44 /** 45 /**
45 * Reads a source file from the input buffer and writes at most 46 * Writes the formatted source data to the output buffer.
46 * <code>maxlen</code> bytes of the formatted output to the output buffer.
47 * 47 *
48 * The output buffer must either be large enough to hold <code>maxlen</code> 48 * @param inputbuffer the source file data as string
49 * bytes or the write function must trigger an automatic extension of the 49 * @param inputbuflen the length of the source file
50 * buffer. 50 * @param outbuf the output buffer
51 *
52 * The input is copied via an intermediate buffer to an internal buffer.
53 *
54 * @param inputbuffer the input buffer
55 * @param rfnc a read function operating for the input buffer
56 * @param ibuf intermediate processing buffer
57 * @param ibuflen length of intermediate processing buffer
58 * @param outputbuffer the output buffer
59 * @param wfnc a write function for the output buffer
60 * @param maxlen the maximum amount bytes which will be written to the
61 * output buffer
62 * @param hltr the highlighter function
63 * @param showln zero, if line numbers shall be omitted, nonzero otherwise
64 *
65 * @return total amount of bytes written to the output buffer
66 *
67 * @see c2html_plain_highlighter()
68 * @see c2html_c_highlighter()
69 * @see c2html_java_highlighter()
70 */
71 size_t c2html_formatn(void* inputbuffer, read_func rfnc,
72 char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc,
73 size_t maxlen, c2html_highlighter_func hltr, int showln);
74
75 /**
76 * Reads a source file from the input buffer and writes the formatted output
77 * to an output buffer.
78 *
79 * The output buffer must either be large enough to hold the formatted data
80 * or the write function must trigger an automatic extension of the buffer.
81 *
82 * The input is copied via an intermediate buffer to an internal buffer.
83 *
84 * @param inputbuffer the input buffer
85 * @param rfnc a read function operating for the input buffer
86 * @param ibuf intermediate processing buffer
87 * @param ibuflen length of intermediate processing buffer
88 * @param outputbuffer the output buffer
89 * @param wfnc a write function for the output buffer 51 * @param wfnc a write function for the output buffer
90 * @param hltr the highlighter function 52 * @param hltr the highlighter function
91 * @param showln zero, if line numbers shall be omitted, nonzero otherwise 53 * @param showln zero, if line numbers shall be omitted, nonzero otherwise
92 * 54 *
93 * @return total amount of bytes written to the output buffer 55 * @return total amount of bytes written to the output buffer
94 * 56 *
95 * @see c2html_plain_highlighter() 57 * @see c2html_plain_highlighter()
96 * @see c2html_c_highlighter() 58 * @see c2html_c_highlighter()
97 * @see c2html_java_highlighter() 59 * @see c2html_java_highlighter()
98 */ 60 */
99 size_t c2html_format(void* inputbuffer, read_func rfnc, 61 size_t c2html_bformat(char const* inputbuffer, size_t inputbuflen,
100 char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc, 62 void* outbuf, cx_write_func wfnc,
101 c2html_highlighter_func hltr, int showln); 63 c2html_highlighter_func hltr, int showln);
102 64
103 /** 65 /**
104 * Reads a source file from the specified input file stream and writes the 66 * Writes the formatted source data to the output buffer.
105 * formatted output to an output buffer. 67 *
106 * 68 * This function takes a list of \c char* that point to the beginning of each
107 * The output buffer must either be large enough to hold the formatted data 69 * line. These pointers may point directly into the source text and the strings
108 * or the write function must trigger an automatic extension of the buffer. 70 * do not need to be zero-terminated, but the line-breaks must be included.
109 * 71 *
110 * The input is copied via an intermediate buffer to an internal buffer. 72 * @param lines a list of pointers to the beginning of each line
111 * For files, the recommended intermediate buffer length is the file system 73 * @param outbuf the output buffer
112 * block size.
113 *
114 * @param inputfile the input file stream
115 * @param ibuf intermediate processing buffer
116 * @param ibuflen length of intermediate processing buffer
117 * @param outputbuffer the output buffer
118 * @param wfnc a write function for the output buffer 74 * @param wfnc a write function for the output buffer
119 * @param hltr the highlighter function 75 * @param hltr the highlighter function
120 * @param showln zero, if line numbers shall be omitted, nonzero otherwise 76 * @param showln zero, if line numbers shall be omitted, nonzero otherwise
121 * 77 *
122 * @return total amount of bytes written to the output buffer 78 * @return total amount of bytes written to the output buffer
123 * 79 *
124 * @see c2html_plain_highlighter() 80 * @see c2html_plain_highlighter()
125 * @see c2html_c_highlighter() 81 * @see c2html_c_highlighter()
126 * @see c2html_java_highlighter() 82 * @see c2html_java_highlighter()
127 */ 83 */
128 size_t c2html_fformat(FILE* inputfile, char *ibuf, size_t ibuflen, 84 size_t c2html_format(CxList const* lines,
129 void* outputbuffer, write_func wfnc, 85 void* outbuf, cx_write_func wfnc,
130 c2html_highlighter_func hltr, int showln); 86 c2html_highlighter_func hltr, int showln);
131
132 /**
133 * Reads a source file from the specified input file stream and directly writes
134 * the formatted output to the output file stream.
135 *
136 * For files, the recommended intermediate buffer length is the file system
137 * block size.
138 *
139 * @param inputfile the input file stream
140 * @param ibuf intermediate processing buffer
141 * @param ibuflen length of intermediate processing buffer (recommended: 4 KB)
142 * @param outputfile the output file stream
143 * @param hltr the highlighter function
144 * @param showln zero, if line numbers shall be omitted, nonzero otherwise
145 *
146 * @see c2html_plain_highlighter()
147 * @see c2html_c_highlighter()
148 * @see c2html_java_highlighter()
149 */
150 void c2html_fformatf(FILE *inputfile, char *ibuf, size_t ibuflen,
151 FILE* outputfile, c2html_highlighter_func hltr, int showln);
152
153
154 /**
155 * Writes at most <code>maxlen</code> bytes of formatted source data to the
156 * output buffer.
157 *
158 * @param inputbuffer the source file data as string
159 * @param inputbuflen the length of the source file
160 * @param outputbuffer the output buffer
161 * @param wfnc a write function for the output buffer
162 * @param maxlen the maximum amount bytes which will be written to the
163 * output buffer
164 * @param hltr the highlighter function
165 * @param showln zero, if line numbers shall be omitted, nonzero otherwise
166 *
167 * @return total amount of bytes written to the output buffer
168 *
169 * @see c2html_plain_highlighter()
170 * @see c2html_c_highlighter()
171 * @see c2html_java_highlighter()
172 */
173 size_t c2html_bformatn(const char* inputbuffer, size_t inputbuflen,
174 void* outputbuffer, write_func wfnc,
175 size_t maxlen, c2html_highlighter_func hltr, int showln);
176
177
178 /**
179 * Writes the formatted source data to the output buffer.
180 *
181 * @param inputbuffer the source file data as string
182 * @param inputbuflen the length of the source file
183 * @param outputbuffer the output buffer
184 * @param wfnc a write function for the output buffer
185 * @param hltr the highlighter function
186 * @param showln zero, if line numbers shall be omitted, nonzero otherwise
187 *
188 * @return total amount of bytes written to the output buffer
189 *
190 * @see c2html_plain_highlighter()
191 * @see c2html_c_highlighter()
192 * @see c2html_java_highlighter()
193 */
194 size_t c2html_bformat(const char* inputbuffer, size_t inputbuflen,
195 void* outputbuffer, write_func wfnc,
196 c2html_highlighter_func hltr, int showln);
197
198
199 /**
200 * Writes the formatted source data directly to the specified file stream.
201 *
202 * @param inputbuffer the source file data as string
203 * @param inputbuflen the length of the source file
204 * @param outputfile the output file stream
205 * @param hltr the highlighter function
206 * @param showln zero, if line numbers shall be omitted, nonzero otherwise
207 *
208 * @see c2html_plain_highlighter()
209 * @see c2html_c_highlighter()
210 * @see c2html_java_highlighter()
211 */
212 void c2html_bformatf(const char* inputbuffer, size_t inputbuflen,
213 FILE* outputfile, c2html_highlighter_func hltr, int showln);
214 87
215 #ifdef __cplusplus 88 #ifdef __cplusplus
216 } 89 }
217 #endif 90 #endif
218 91

mercurial