libt3key
 All Data Structures Functions Variables Typedefs Enumerator Groups
key.h
1 /* Copyright (C) 2011 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_KEY_H
15 #define T3_KEY_H
16 
21 #include <stdlib.h>
22 #include <t3key/key_api.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
41 #define T3_KEY_VERSION 0
42 
43 /* To allow modification of the structures within the key library, it defines
44  the macro T3_KEY_CONST as emtpy. However, for external use the structures
45  should be regarded as constant. This will prevent inadvertent modification
46  of these structures.
47 */
48 #ifndef T3_KEY_CONST
49 #define T3_KEY_CONST const
50 #endif
51 
52 typedef struct t3_key_node_t t3_key_node_t;
53 
55 struct t3_key_node_t {
56  T3_KEY_CONST char *key;
57  T3_KEY_CONST char *string;
58  T3_KEY_CONST size_t string_length;
59  T3_KEY_CONST t3_key_node_t *next;
60 };
61 
63 
66  T3_KEY_CONST char *string;
67  T3_KEY_CONST t3_key_string_list_t *next;
68 };
69 
70 #include "key_errors.h"
71 
75 #define T3_ERR_INVALID_FORMAT (-32)
76 
77 #define T3_ERR_TERMINFO_UNKNOWN (-31)
78 
79 #define T3_ERR_NOMAP (-30)
80 
81 #define T3_ERR_TRUNCATED_DB (-29)
82 
83 #define T3_ERR_READ_ERROR (-28)
84 
85 #define T3_ERR_WRONG_VERSION (-27)
86 
102 T3_KEY_API T3_KEY_CONST t3_key_node_t *t3_key_load_map(const char *term, const char *map_name, int *error);
103 
107 T3_KEY_API void t3_key_free_map(T3_KEY_CONST t3_key_node_t *list);
108 
117 T3_KEY_API T3_KEY_CONST t3_key_string_list_t *t3_key_get_map_names(const char *term, int *error);
118 
122 T3_KEY_API void t3_key_free_names(T3_KEY_CONST t3_key_string_list_t *list);
123 
132 T3_KEY_API char *t3_key_get_best_map_name(const char *term, int *error);
133 
143 T3_KEY_API T3_KEY_CONST t3_key_node_t *t3_key_get_named_node(T3_KEY_CONST t3_key_node_t *map, const char *name);
144 
154 T3_KEY_API long t3_key_get_version(void);
155 
160 T3_KEY_API const char *t3_key_strerror(int error);
161 
162 #ifdef __cplusplus
163 } /* extern "C" */
164 #endif
165 
166 #endif