src/c2html.h

Wed, 31 Aug 2016 14:41:56 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 31 Aug 2016 14:41:56 +0200
changeset 55
bf54085ce341
parent 52
33ded421c512
child 56
81d99e9ceb20
permissions
-rw-r--r--

adds appropriate public API

     1 /*
     2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3  *
     4  * Copyright 2016 Mike Becker. All rights reserved.
     5  *
     6  * Redistribution and use in source and binary forms, with or without
     7  * modification, are permitted provided that the following conditions are met:
     8  *
     9  *   1. Redistributions of source code must retain the above copyright
    10  *      notice, this list of conditions and the following disclaimer.
    11  *
    12  *   2. Redistributions in binary form must reproduce the above copyright
    13  *      notice, this list of conditions and the following disclaimer in the
    14  *      documentation and/or other materials provided with the distribution.
    15  *
    16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    26  * POSSIBILITY OF SUCH DAMAGE.
    27  *
    28  */
    30 #ifndef C2HTML_H
    31 #define	C2HTML_H
    33 #include <stdio.h>
    34 #include "highlighter.h"
    36 #ifdef	__cplusplus
    37 extern "C" {
    38 #endif
    40 #define VERSION_MAJOR   2
    41 #define VERSION_MINOR   0
    42 #define VERSION_DEVELOP 1 /* set this to zero for release version */
    44 /**
    45  * Reads a source file from the input buffer and writes at most
    46  * <code>maxlen</code> bytes of the formatted output to the output buffer.
    47  * 
    48  * The output buffer must either be large enough to hold <code>maxlen</code>
    49  * bytes or the write function must trigger an automatic extension of the buffer.
    50  * 
    51  * @param inputbuffer the input buffer
    52  * @param rfnc a read function operating for the input buffer
    53  * @param ibuf intermediate processing buffer
    54  * @param ibuflen length of intermediate processing buffer (recommended: 4 KB)
    55  * @param outputbuffer the output buffer
    56  * @param wfnc a write function for the output buffer
    57  * @param maxlen the maximum amount bytes which will be written to the
    58  * output buffer
    59  * @param hltr the highlighter function
    60  * @param showln zero, if line numbers shall be omitted, nonzero otherwise
    61  * 
    62  * @return total amount of bytes written to the output buffer
    63  * 
    64  * @see c2html_plain_highlighter()
    65  * @see c2html_c_highlighter()
    66  * @see c2html_java_highlighter()
    67  */
    68 size_t c2html_formatn(void* inputbuffer, read_func rfnc,
    69         char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc,
    70         size_t maxlen, c2html_highlighter_func hltr, int showln);
    72 /**
    73  * Reads a source file from the input buffer and writes the formatted output
    74  * to an output buffer.
    75  * 
    76  * The output buffer must either be large enough to hold the formatted data
    77  * or the write function must trigger an automatic extension of the buffer.
    78  * 
    79  * @param inputbuffer the input buffer
    80  * @param rfnc a read function operating for the input buffer
    81  * @param ibuf intermediate processing buffer
    82  * @param ibuflen length of intermediate processing buffer (recommended: 4 KB)
    83  * @param outputbuffer the output buffer
    84  * @param wfnc a write function for the output buffer
    85  * @param hltr the highlighter function
    86  * @param showln zero, if line numbers shall be omitted, nonzero otherwise
    87  * 
    88  * @return total amount of bytes written to the output buffer
    89  * 
    90  * @see c2html_plain_highlighter()
    91  * @see c2html_c_highlighter()
    92  * @see c2html_java_highlighter()
    93  */
    94 size_t c2html_format(void* inputbuffer, read_func rfnc,
    95         char* ibuf, size_t ibuflen, void* outputbuffer, write_func wfnc,
    96         c2html_highlighter_func hltr, int showln);
    98 /**
    99  * Reads a source file from the specified input file stream and writes the
   100  * formatted output to an output buffer.
   101  * 
   102  * The output buffer must either be large enough to hold the formatted data
   103  * or the write function must trigger an automatic extension of the buffer.
   104  * 
   105  * @param inputfile the input file stream
   106  * @param ibuf intermediate processing buffer
   107  * @param ibuflen length of intermediate processing buffer (recommended: 4 KB)
   108  * @param outputbuffer the output buffer
   109  * @param wfnc a write function for the output buffer
   110  * @param hltr the highlighter function
   111  * @param showln zero, if line numbers shall be omitted, nonzero otherwise
   112  * 
   113  * @return total amount of bytes written to the output buffer
   114  * 
   115  * @see c2html_plain_highlighter()
   116  * @see c2html_c_highlighter()
   117  * @see c2html_java_highlighter()
   118  */
   119 size_t c2html_format_file(FILE* inputfile, char *ibuf, size_t ibuflen,
   120         void* outputbuffer, write_func wfnc,
   121         c2html_highlighter_func hltr, int showln);
   123 /**
   124  * Reads a source file from the specified input file stream and directly writes
   125  * the formatted output to the output file stream.
   126  * 
   127  * @param inputfile the input file stream
   128  * @param ibuf intermediate processing buffer
   129  * @param ibuflen length of intermediate processing buffer (recommended: 4 KB)
   130  * @param outputfile the output file stream
   131  * @param hltr the highlighter function
   132  * @param showln zero, if line numbers shall be omitted, nonzero otherwise
   133  * 
   134  * @see c2html_plain_highlighter()
   135  * @see c2html_c_highlighter()
   136  * @see c2html_java_highlighter()
   137  */
   138 void c2html_fformat_file(FILE *inputfile, char *ibuf, size_t ibuflen,
   139         FILE* outputfile, c2html_highlighter_func hltr, int showln);
   141 #ifdef	__cplusplus
   142 }
   143 #endif
   145 #endif	/* C2HTML_H */

mercurial