#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;
return buf;
}
-void free_conv_buffer(struct conv_buffer* buf)
+void free_conv_buffer(conv_buffer_t buf)
{
if (buf) {
free(buf->buffer);
}
}
-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;
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;
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 <sys/types.h>
+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
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);