#ifndef MICONV_HEADER
#define MICONV_HEADER

#ifdef WIN32
#define USING_STATIC_LIBICONV 1
#endif 
#include "ziconv.h"

struct miconv;
typedef struct miconv Miconv;

//create iconv for converting to 'to' encoding
Miconv *miconv_new_real(char *to, char *file, int line);
#define miconv_new(a) miconv_new_real(a,__FILE__,__LINE__)

//free iconv handle and buffer
void miconv_free(Miconv **i);

//choose 'from' encoding
//return: if encoding is supported
int miconv_set(Miconv *i, char *from);
int miconv_set2(Miconv *i, char *from, int iconv_ascii2iso, int iconv_translit, int iconv_ilseq);

//close handle, un-set encoding.
int miconv_close(Miconv *i);

//check if we have valid 'from' encoding set
int miconv_isset(Miconv *i);

//convert src from 'from' to 'to' encoding
//return: length of result or 0 for failure
int miconv_direct(Miconv *i, char *src, size_t bytes, char **dst, size_t length);
int miconv(Miconv *i, char *src, size_t bytes);

//obtain result of 'miconv' conversion
char *miconv_res(Miconv *i);


//obtain iconv handle
iconv_t miconv_handle(Miconv *i);

//decode a mime/email header encoded in the form =?<enc>?<b|q>?<data>?=
char *miconv_header_decode(char *header, char *res, int bfsz);

char *miconv_buf(Miconv *i, int bytes, int *bfsz);


//char *sw_iconv_buf(Sw *sw, int bytes, int *bfsz);

//void sw_iconv_set(Sw *sw, char *from);

//void sw_iconv_free(Sw *w);

//int sw_iconv(Sw *sw, char *src, size_t bytes);


#endif
