1 /* 2 Copyright (C) 2015-2021, Dirk Krause 3 SPDX-License-Identifier: BSD-3-Clause 4 */ 5 6 /* 7 WARNING: This file was generated by the dkct program (see 8 http://dktools.sourceforge.net/ for details). 9 Changes you make here will be lost if dkct is run again! 10 You should modify the original source and run dkct on it. 11 Original source: dk4stt.ctr 12 */ 13 14 #ifndef DK4STT_H_INCLUDED 15 /** Avoid multiple inclusions. */ 16 #define DK4STT_H_INCLUDED 1 17 18 19 /** @file 20 String table data type. 21 Normally there is no need for you to deal with string tables 22 manually. String tables are handled by the dk4_app_t related 23 functions. 24 25 CRT on Windows: Optional. 26 */ 27 28 #ifndef DK4CONF_H_INCLUDED 29 #if DK4_BUILDING_DKTOOLS4 30 #include "dk4conf.h" 31 #else 32 #include <dktools-4/dk4conf.h> 33 #endif 34 #endif 35 36 #ifndef DK4TYPES_H_INCLUDED 37 #if DK4_BUILDING_DKTOOLS4 38 #include <libdk4base/dk4types.h> 39 #else 40 #include <dktools-4/dk4types.h> 41 #endif 42 #endif 43 44 #ifndef DK4STRM_H_INCLUDED 45 #if DK4_BUILDING_DKTOOLS4 46 #include <libdk4c/dk4strm.h> 47 #else 48 #include <dktools-4/dk4strm.h> 49 #endif 50 #endif 51 52 #ifndef DK4ERROR_H_INCLUDED 53 #if DK4_BUILDING_DKTOOLS4 54 #include <libdk4base/dk4error.h> 55 #else 56 #include <dktools-4/dk4error.h> 57 #endif 58 #endif 59 60 /** String table. 61 */ 62 typedef struct { 63 dkChar *shrtfn; /**< Short file name. */ 64 dkChar **strings; /**< Strings read from file. */ 65 size_t nstrings; /**< Number of strings. */ 66 } dk4_string_table_t; 67 68 69 70 #ifdef __cplusplus 71 extern "C" { 72 #endif 73 74 /** Create string table from file. 75 @param fn Short file name to store in structure. 76 @param sz Number of lines required. 77 @param erp Error report, may be NULL. 78 @return Pointer to new string table structure on success, NULL 79 on error. 80 */ 81 dk4_string_table_t * 82 dk4stt_open(const dkChar *fn, size_t sz, dk4_er_t *erp); 83 84 /** Apply a text stream to a string table. 85 @param tptr String table to configure. 86 @param strm Text stream, opened for reading. 87 @param pre Processing encoding. 88 @param erp2 Error report for processing, may be NULL. 89 @return 1 on success, 0 on error. 90 */ 91 int 92 dk4stt_apply_stream( 93 dk4_string_table_t *tptr, 94 dk4_stream_t *strm, 95 int pre, 96 dk4_er_t *erp2 97 ); 98 99 /** Destroy a string table, free allocated memory. 100 @param ptr String table to destroy. 101 */ 102 void 103 dk4stt_close(dk4_string_table_t *ptr); 104 105 /** Compare two string tables by short name. 106 @param l Left pointer (always string table). 107 @param r Right pointer (string table or short name). 108 @param cr Comparison criteria 109 (0=string table/string table, 110 1=string table/short name). 111 @return Comparison result. 112 */ 113 int 114 dk4stt_compare(const void *l, const void *r, int cr); 115 116 #ifdef __cplusplus 117 } 118 #endif 119 120 121 122 #endif 123