libtranscript
/home/gertjan/projects/transcript/src/handle.h
00001 /* Copyright (C) 2011-2012 G.P. Halkes
00002    This program is free software: you can redistribute it and/or modify
00003    it under the terms of the GNU General Public License version 3, as
00004    published by the Free Software Foundation.
00005 
00006    This program is distributed in the hope that it will be useful,
00007    but WITHOUT ANY WARRANTY; without even the implied warranty of
00008    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00009    GNU General Public License for more details.
00010 
00011    You should have received a copy of the GNU General Public License
00012    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00013 */
00014 #ifndef TRANSCRIPT_HANDLE_H
00015 #define TRANSCRIPT_HANDLE_H
00016 #include <transcript/bool.h>
00017 
00018 typedef transcript_error_t (*conversion_func_t)(transcript_t *handle, const char **inbuf, const char *inbuflimit,
00019         char **outbuf, const char *outbuflimit, int flags);
00020 typedef transcript_error_t (*flush_func_t)(transcript_t *handle, char **outbuf, const char *outbuflimit);
00021 typedef transcript_error_t (*skip_func_t)(transcript_t *handle, const char **inbuf, const char *inbuflimit);
00022 typedef transcript_error_t (*put_unicode_func_t)(uint_fast32_t codepoint, char **outbuf, const char *outbuflimit);
00023 typedef uint_fast32_t (*get_unicode_func_t)(const char **inbuf, const char *inbuflimit, bool_t skip);
00024 typedef void (*reset_func_t)(transcript_t *handle);
00025 typedef void (*close_func_t)(transcript_t *handle);
00026 typedef void (*save_load_func_t)(transcript_t *handle, void *state);
00027 
00028 struct transcript_t {
00029         conversion_func_t convert_to;
00030         conversion_func_t convert_from;
00031         /* flush_func_t flush_to; */ /* The same for all converters! */
00032         flush_func_t flush_from;
00033         skip_func_t skip_to;
00034         /* skip_func_t skip_from; */ /* The same for all converters! */
00035         put_unicode_func_t put_unicode;
00036         get_unicode_func_t get_unicode;
00037         reset_func_t reset_to;
00038         reset_func_t reset_from;
00039         close_func_t close;
00040         save_load_func_t save;
00041         save_load_func_t load;
00042         void *library_handle;
00043         int flags;
00044 };
00045 
00046 TRANSCRIPT_API transcript_t *transcript_open_converter_nolock(const char *name, transcript_utf_t utf_type,
00047         int flags, transcript_error_t *error);
00048 TRANSCRIPT_API void transcript_close_converter_nolock(transcript_t *handle);
00049 #endif
 All Data Structures Variables