Mon, 24 Apr 2023 21:01:41 +0200
merge upstream changes
22
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1 | /* |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
3 | * |
35 | 4 | * Copyright 2016 Mike Becker. All rights reserved. |
22
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
5 | * |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
8 | * |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
11 | * |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
15 | * |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
27 | * |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
28 | */ |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
29 | |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
30 | #ifndef C2HTML_H |
56
81d99e9ceb20
fixes ancient header macro
Mike Becker <universe@uap-core.de>
parents:
55
diff
changeset
|
31 | #define C2HTML_H |
22
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
32 | |
55
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
33 | #include <stdio.h> |
66 | 34 | #include <cx/list.h> |
55
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
35 | #include "highlighter.h" |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
36 | |
56
81d99e9ceb20
fixes ancient header macro
Mike Becker <universe@uap-core.de>
parents:
55
diff
changeset
|
37 | #ifdef __cplusplus |
22
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
38 | extern "C" { |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
39 | #endif |
37
1a67185e5496
adds version number and changes build system
Mike Becker <universe@uap-core.de>
parents:
35
diff
changeset
|
40 | |
66 | 41 | #define VERSION_MAJOR 3 |
37
1a67185e5496
adds version number and changes build system
Mike Becker <universe@uap-core.de>
parents:
35
diff
changeset
|
42 | #define VERSION_MINOR 0 |
57
eba880c1705c
improves API and adds functions for strings
Mike Becker <universe@uap-core.de>
parents:
56
diff
changeset
|
43 | #define VERSION_DEVELOP 0 /* set this to zero for release version */ |
22
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
44 | |
55
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
45 | /** |
66 | 46 | * Writes the formatted source data to the output buffer. |
55
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
47 | * |
66 | 48 | * @param inputbuffer the source file data as string |
49 | * @param inputbuflen the length of the source file | |
50 | * @param outbuf the output buffer | |
55
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
51 | * @param wfnc a write function for the output buffer |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
52 | * @param hltr the highlighter function |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
53 | * @param showln zero, if line numbers shall be omitted, nonzero otherwise |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
54 | * |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
55 | * @return total amount of bytes written to the output buffer |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
56 | * |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
57 | * @see c2html_plain_highlighter() |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
58 | * @see c2html_c_highlighter() |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
59 | * @see c2html_java_highlighter() |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
60 | */ |
66 | 61 | size_t c2html_bformat(char const* inputbuffer, size_t inputbuflen, |
62 | void* outbuf, cx_write_func wfnc, | |
63 | c2html_highlighter_func hltr, int showln); | |
55
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
64 | |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
65 | /** |
66 | 66 | * Writes the formatted source data to the output buffer. |
67 | * | |
68 | * This function takes a list of \c char* that point to the beginning of each | |
69 | * line. These pointers may point directly into the source text and the strings | |
70 | * do not need to be zero-terminated, but the line-breaks must be included. | |
71 | * | |
72 | * @param lines a list of pointers to the beginning of each line | |
73 | * @param outbuf the output buffer | |
74 | * @param wfnc a write function for the output buffer | |
55
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
75 | * @param hltr the highlighter function |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
76 | * @param showln zero, if line numbers shall be omitted, nonzero otherwise |
66 | 77 | * |
78 | * @return total amount of bytes written to the output buffer | |
79 | * | |
55
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
80 | * @see c2html_plain_highlighter() |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
81 | * @see c2html_c_highlighter() |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
82 | * @see c2html_java_highlighter() |
bf54085ce341
adds appropriate public API
Mike Becker <universe@uap-core.de>
parents:
52
diff
changeset
|
83 | */ |
66 | 84 | size_t c2html_format(CxList const* lines, |
85 | void* outbuf, cx_write_func wfnc, | |
86 | c2html_highlighter_func hltr, int showln); | |
22
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
87 | |
56
81d99e9ceb20
fixes ancient header macro
Mike Becker <universe@uap-core.de>
parents:
55
diff
changeset
|
88 | #ifdef __cplusplus |
22
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
89 | } |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
90 | #endif |
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
91 | |
56
81d99e9ceb20
fixes ancient header macro
Mike Becker <universe@uap-core.de>
parents:
55
diff
changeset
|
92 | #endif /* C2HTML_H */ |
22
f463693b5eeb
added command line parameters for header and footer file
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
93 |