/* Copyright 2020, Dirk Krause. All rights reserved. SPDX-License-Identifier: BSD-3-Clause */ #ifndef UC2L_H_INCLUDED /** Protection against multiple inclusions. */ #define UC2L_H_INCLUDED 1 /** @file uc2l.h Prototypes for functions shared between dk4uc2l and dk4uc2la modules. */ #ifndef DK4CONF_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4conf.h" #else #include #endif #endif #ifndef DK4UC2L_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4uc2l.h" #else #include #endif #endif #ifdef __cplusplus extern "C" { #endif /** Open range structure. @param c32 Initial start and end of range. @param fptr File the range is loaded from. @param erp Error report, may be NULL. @return Valid pointer on success, NULL on error. */ dk4_uc2l_range_t * dk4uc2l_i_open_range( dk4_c32_t c32, dk4_uc2l_file_t *fptr, dk4_er_t *erp ); /** Close a range, releasse resources. @param rptr Range to close. */ void dk4uc2l_i_close_range(dk4_uc2l_range_t *rptr); /** Allocate a file structure and resources. @param fn File name. @param erp Error report, may be NULL. @return Valid pointer on success, NULL on error. */ dk4_uc2l_file_t * dk4uc2l_i_open_file(const dkChar *fn, dk4_er_t *erp); /** Close a file structure, release resources. @param fptr File structure to close. */ void dk4uc2l_i_close_file(dk4_uc2l_file_t *fptr); /** Open a package structure, allocate resources. @param pn Package name. @param erp Error report, may be NULL. @return Valid pointer on success, NULL on error. */ dk4_uc2l_pkg_t * dk4uc2l_i_open_pkg(const char *pn, dk4_er_t *erp); /** Create package structure and add to storage. @param s_pkgs Storage containing all package structures. @param pname Name of new package. @return Valid pointer to new package structure on success, NULL on error. */ dk4_uc2l_pkg_t * dk4uc2l_i_create_pkg( dk4_sto_t *s_pkgs, const char *pname ); /** Close a package, release resources. @param pptr Package to close. */ void dk4uc2l_i_close_pkg(dk4_uc2l_pkg_t *pptr); /** Allocate memory for conversion struct and components. @param dn Directory name for conversion struct. @param erp Error report, may be NULL. @return Valid pointer on success, NULL on error (memory allocation failed). */ dk4_uc2l_t * dk4uc2l_i_new(const dkChar *dn, dk4_er_t *erp); /** Find suffix index for file name. Supported suffixes at this time are ".t2l", ".t2l.gz" and ".tl2.bz2". The corresponding indices are 0, 1 and 2. @param fn File name to inspect. @return Non-negative index on success, -1 on error (not a valid suffix for data files). */ int dk4uc2l_i_find_suffix_index(const dkChar *fn); /** Check if a file name suffix indicating a compression type is supported. @param i File name suffix index to check. @return Check result: 1=supported, 0=unsupported. */ int dk4uc2l_i_suffix_index_supported(int i); /** Compare two range informations or a range information against a character. @param l Left pointer, always a range information structure. @param r Right pointer. @param cr Comparison criteria: 0 if the right pointer is a range information strucutre, 1 if the right pointer is a pointer to a dk4_c32_t. @return Comparison result: -1 if lr. */ int dk4uc2l_i_range_compare(const void *l, const void *r, int cr); /** Initialize a range, allocate memory for components. @param rptr Range to initialize. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ int dk4uc2l_i_init_range( dk4_uc2l_range_t *rptr, dk4_er_t *erp ); /** Find index of pkey in keyword array. @param pkey Key text. @return Non-negative index on success, -1 on error. */ int dk4uc2l_i_keyword_index(const char *pkey); /** Retrieve font encoding by name. @param pname Font encoding name. @return Non-null font encoding on success, 0 on error. */ unsigned char dk4uc2l_font_encoding_from_name(const char *pname); #ifdef __cplusplus } #endif /* vim: set ai sw=4 ts=4 : */ #endif