summaryrefslogtreecommitdiff
path: root/support/dktools/uc2l.h
blob: 7dd69a7a21800c176497afdc130a4d497ecfad80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
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 <dktools-4/dk4conf.h>
#endif
#endif

#ifndef	DK4UC2L_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4uc2l.h"
#else
#include <dktools-4/dk4uc2l.h>
#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 l<r, 0 if l=r, 1 if l>r.
*/
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