From: Peter Verthez Date: Sun, 1 Dec 2002 12:35:32 +0000 (+0000) Subject: Hide the implementation of some types. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=8535a64e18dcc9b7cefb6d7d7e53de3cee58641e;p=gedcom-parse.git Hide the implementation of some types. --- diff --git a/utf8/utf8-convert.c b/utf8/utf8-convert.c index 9db6fdf..097f199 100644 --- a/utf8/utf8-convert.c +++ b/utf8/utf8-convert.c @@ -22,12 +22,27 @@ #define INTERNAL_BUFFER 0 #define EXTERNAL_BUFFER 1 -void reset_conv_buffer(struct conv_buffer* buf) +struct conv_buffer { + char* buffer; + size_t size; + int type; /* For internal use */ +}; + +struct convert { + iconv_t from_utf8; + iconv_t to_utf8; + struct conv_buffer* inbuf; + size_t insize; + struct conv_buffer* outbuf; + char* unknown; +}; + +void reset_conv_buffer(conv_buffer_t buf) { memset(buf->buffer, 0, buf->size); } -struct conv_buffer* create_conv_buffer(int size) +conv_buffer_t create_conv_buffer(int size) { struct conv_buffer* buf = NULL; @@ -47,7 +62,7 @@ struct conv_buffer* create_conv_buffer(int size) return buf; } -void free_conv_buffer(struct conv_buffer* buf) +void free_conv_buffer(conv_buffer_t buf) { if (buf) { free(buf->buffer); @@ -55,7 +70,7 @@ void free_conv_buffer(struct conv_buffer* buf) } } -char* grow_conv_buffer(struct conv_buffer* buf, char* curr_pos) +char* grow_conv_buffer(conv_buffer_t buf, char* curr_pos) { size_t outlen, new_size; char* new_buffer; @@ -142,7 +157,7 @@ int conversion_set_unknown(convert_t conv, const char* unknown) return result; } -int conversion_set_output_buffer(convert_t conv, struct conv_buffer* buf) +int conversion_set_output_buffer(convert_t conv, conv_buffer_t buf) { if (!conv) return 0; diff --git a/utf8/utf8.h b/utf8/utf8.h index e2a6f3b..131dfbc 100644 --- a/utf8/utf8.h +++ b/utf8/utf8.h @@ -16,23 +16,11 @@ extern "C" { #endif -#include "iconv.h" - -struct conv_buffer { - char* buffer; - size_t size; - int type; /* For internal use */ -}; - -struct convert { - iconv_t from_utf8; - iconv_t to_utf8; - struct conv_buffer* inbuf; - size_t insize; - struct conv_buffer* outbuf; - char* unknown; -}; +#include +struct conv_buffer; +struct convert; +typedef struct conv_buffer *conv_buffer_t; typedef struct convert *convert_t; /* Returns -1 if the string is not a valid UTF-8 string, returns its @@ -43,15 +31,15 @@ int utf8_strlen(const char* input); int is_utf8_string(const char* input); /* Functions for creating and freeing conversion buffers yourself */ -struct conv_buffer* create_conv_buffer(int size); -void free_conv_buffer(struct conv_buffer* buf); +conv_buffer_t create_conv_buffer(int size); +void free_conv_buffer(conv_buffer_t buf); /* General conversion interface (is bidirectional) */ /* Pass 0 for external_outbuf unless you want to control the output buffer yourself */ convert_t initialize_utf8_conversion(const char* charset, int external_outbuf); int conversion_set_unknown(convert_t conv, const char* unknown); -int conversion_set_output_buffer(convert_t conv, struct conv_buffer* buf); +int conversion_set_output_buffer(convert_t conv, conv_buffer_t buf); void cleanup_utf8_conversion(convert_t conv); char* convert_from_utf8(convert_t conv, const char* input, int* conv_fails); char* convert_to_utf8(convert_t conv, const char* input);