/* WARNING: This file was generated by dkct. Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4uc2l.ctr */ /* Copyright (C) 2015-2017, Dirk Krause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above opyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef DK4UC2L_H_INCLUDED /** Avoid multiple inclusions. */ #define DK4UC2L_H_INCLUDED 1 #line 10 "dk4uc2l.ctr" /** @file dk4uc2l.h Text to LaTeX conversion. LaTeX sequences to represent a 32 bit character are found in lookup tables in the ${datarootdir}/dktools/charmap directory. The functions in this module read those lookup tables needed, cache the contents and provide LaTeX sequences. After finishing output you can write recommendations (i.e. LaTeX packages to include, font encoding to use) as comments to the file. */ #ifndef DK4ERROR_H_INCLUDED #include "dk4app.h" #endif #ifndef DK4STO_H_INCLUDED #include "dk4sto.h" #endif /** Information about a package. */ typedef struct { char *pn; /**< Package name. */ unsigned char used; /**< Flag: Package used. */ } dk4_uc2l_pkg_t; /** Data for contents of one file. The structure contains information about the character ranges covered by the file. */ typedef struct { dkChar *fn; /**< Short file name. */ unsigned char loaded; /**< Flag: File loaded. */ } dk4_uc2l_file_t; /** Range of characters. */ typedef struct { dk4_uc2l_file_t *file; /**< File containing data. */ char **both; /**< LaTeX text both modes. */ char **text; /**< LaTeX text text mode. */ char **math; /**< LaTeX text math mode. */ dk4_uc2l_pkg_t ***pkgs; /**< Packages for characters. */ unsigned char *fenc; /**< Required font encodings. */ dk4_c32_t start; /**< First character of range. */ dk4_c32_t end; /**< Final character of range. */ unsigned char ia; /**< Flag: Initialisation att. */ } dk4_uc2l_range_t; /** Text to LaTeX conversion structure. */ typedef struct { char buf[16]; /**< Buffer for direct output. */ const dkChar * const *msgs; /**< Localized messages */ dkChar *dname; /**< Directory name. */ dk4_sto_t *s_ranges; /**< Ranges container. */ dk4_sto_it_t *i_ranges; /**< Ranges container iterator. */ dk4_sto_t *s_files; /**< Files container. */ dk4_sto_it_t *i_files; /**< Files container iterator. */ dk4_sto_t *s_pkgs; /**< Package information container. */ dk4_sto_it_t *i_pkgs; /**< Package information iterator. */ size_t szmsgs; /**< Number of messages in msgs. */ int had_error; /**< Flag: Errors occured. */ unsigned char utf8allowed; /**< Flag: UTF-8 output allowed. */ unsigned char fallowed; /**< Allowed font encodings. */ } dk4_uc2l_t; /** Font encodings */ enum { /** OT1 font encoding. */ DK4_UC2L_FONT_ENCODING_OT1 = 1 , /** T1 font encoding. */ DK4_UC2L_FONT_ENCODING_T1 = 2 , /** T4 font encoding. */ DK4_UC2L_FONT_ENCODING_T4 = 4 , /** T5 font encoding. */ DK4_UC2L_FONT_ENCODING_T5 = 8 , DK4_UC2L_FONT_ENCODING_ALL = ( 0 | DK4_UC2L_FONT_ENCODING_OT1 | DK4_UC2L_FONT_ENCODING_T1 | DK4_UC2L_FONT_ENCODING_T4 | DK4_UC2L_FONT_ENCODING_T5 ) }; /** Errors from this module */ enum { /** Memory allocation failed. */ DK4_UC2L_ERROR_MEMORY = 1 , /** Syntax error in configuration file. */ DK4_UC2L_ERROR_SYNTAX = 2 , /** Decoding error in configuration file. */ DK4_UC2L_ERROR_DECODING = 4 , /** Other processing errors while reading data. */ DK4_UC2L_ERROR_PROCESSING = 8 , /** Failed to open one of the data files. */ DK4_UC2L_ERROR_FOPEN = 16 , }; #ifdef __cplusplus extern "C" { #endif /** Open conversion structure, dynamically allocate memory. @param dn Directory name containing the data files. @param app Application structure for diagnostics, may be NULL. @return Pointer to conversion structure on success, NULL on error. Use dk4uc2l_close() to close the conversion structure when done with it. */ dk4_uc2l_t * dk4uc2l_open(const dkChar *dn, dk4_app_t *app); /** Open conversion structure, dynamically allocate memory. The directory containing the data files is obtained from the application (if not NULL), ${datarootdir}/dktools/charmap is used by default. @param app Application structure for diagnostics, may be NULL. @return Pointer to conversion structure on success, NULL on error. Use dk4uc2l_close() to close the conversion structure when done with it. */ dk4_uc2l_t * dk4uc2l_open_from_app(dk4_app_t *app); /** Close conversion structure, release memory. @param ulptr Conversion structure to close. */ void dk4uc2l_close(dk4_uc2l_t *ulptr); /** Enable or disable direct UTF-8 output. If you use usepackage[utf-8]{inputenc} you might want to enable UTF-8 output. @param ulptr Conversion structure to set up. @param enabled Flag: Enable UTF-8 output. */ void dk4uc2l_allow_utf8(dk4_uc2l_t *ulptr, int enabled); /** Reset information about used packages and allowed and denied font encodings. Typically you want to use this function only after finishing one output file and starting a new one. @param ulptr Conversion structure to reset. */ void dk4uc2l_clean_packages_and_fonts(dk4_uc2l_t *ulptr); /** Find LaTeX encoding for one 32 bit character. @param ulptr Conversion structure. @param c Character to search encoding for. @param mm Flag: Math mode (1) or text mode (0). @param app Application structure for diagnostics, may be NULL. @return Pointer to encoding string on success, NULL on error. */ const char * dk4uc2l_find(dk4_uc2l_t *ulptr, dk4_c32_t c, int mm, dk4_app_t *app); /** Retrieve or-combination of all allowed font encodings. You should use this function after processing all characters. */ unsigned char dk4uc2l_retrieve_allowed_fe(dk4_uc2l_t *ulptr); /** Check whether a character can be written to a LaTeX file directly. @param c32 Character to check. @return 1 for yes, 0 for no. */ int dk4uc2lat_direct(dk4_c32_t c32); /** Issue recommendations about font encodings and packages. Use this function after processing all characters. @param ulptr Conversion structure. @param fipo File to write to. */ void dk4uc2l_recommendations(dk4_uc2l_t *ulptr, FILE *fipo); /** Retrieve internal error status from conversion structure. @param ulptr Conversion structure. @return Error status, 0 or combination of DK4_UC2L_ERROR_MEMORY, DK4_UC2L_ERROR_SYNTAX, DK4_UC2L_ERROR_DECODING, DK4_UC2L_ERROR_PROCESSING, and DK4_UC2L_ERROR_FOPEN. */ int dk4uc2l_retrieve_errors(dk4_uc2l_t *ulptr); #ifdef __cplusplus } #endif #endif