src/c2html.h

Sun, 11 Jun 2023 14:05:28 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 11 Jun 2023 14:05:28 +0200
changeset 69
ff56b28e2cdd
parent 66
1b12cf799fee
child 70
60cecca5e484
permissions
-rw-r--r--

add separate Makefile for test

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
abaf2489c549 adjusted copyright info
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
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
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
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
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
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
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
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
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
48 * @param inputbuffer the source file data as string
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
49 * @param inputbuflen the length of the source file
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
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
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
61 size_t c2html_bformat(char const* inputbuffer, size_t inputbuflen,
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
62 void* outbuf, cx_write_func wfnc,
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
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
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
66 * Writes the formatted source data to the output buffer.
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
67 *
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
68 * This function takes a list of \c char* that point to the beginning of each
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
69 * line. These pointers may point directly into the source text and the strings
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
70 * do not need to be zero-terminated, but the line-breaks must be included.
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
71 *
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
72 * @param lines a list of pointers to the beginning of each line
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
73 * @param outbuf the output buffer
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
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
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
77 *
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
78 * @return total amount of bytes written to the output buffer
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
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
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
84 size_t c2html_format(CxList const* lines,
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
85 void* outbuf, cx_write_func wfnc,
1b12cf799fee upgrade to ucx 3.0
Mike Becker <universe@uap-core.de>
parents: 57
diff changeset
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

mercurial