#ifndef INETH__
#define INETH__

#if _WIN32
	#include <windows.h>
#else
	#define WINAPI
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
	INETST_CONNECTING,
	INETST_AUTHENTICATING,
	INETST_STARTING,
	INETST_PREPARING,
	INETST_TRANSFERRING,
	INETST_REDIRECTING,
	INETST_FINISHED
} inet_status_type;

typedef enum {
	/*  0 */ INETERR_NOERROR,
	/*  1 */ INETERR_BADPARMS,
	/*  2 */ INETERR_BADURL,
	/*  3 */ INETERR_NOCONNECT,
	/*  4 */ INETERR_CANNOTSEND,
	/*  5 */ INETERR_CANCELED,
	/*  6 */ INETERR_BADRESPONSE,
	/*  7 */ INETERR_NOLOGIN,
	/*  8 */ INETERR_BADPATH,
	/*  9 */ INETERR_BADFILE,
	/* 10 */ INETERR_NODATA,
	/* 11 */ INETERR_REDIRECTED,
	/* 12 */ INETERR_BADREDIRECTION,
	/* 13 */ INETERR_SHORTFILE,
	/* 14 */ INETERR_BADZSTREAM,
	/* 15 */ INETERR_NOPOSTFILE,
	/* 16 */ INETERR_BADPOSTFILE,
	/* 17 */ INETERR_TIMEOUT,
	/* 18 */ INETERR_NOCURLINIT,
	/* 19 */ INETERR_CANNOTREAD
} inet_error_type;

typedef enum {
	/* 0 */ INETURLTYPE_BAD,
	/* 1 */ INETURLTYPE_HTTP,
	/* 2 */ INETURLTYPE_HTTPS,
	/* 3 */ INETURLTYPE_FTP
} inet_url_type;

typedef int (WINAPI *inet_transferprocptr)(void *,unsigned char *,int);
typedef int (WINAPI *inet_transresetprocptr)(void *);
typedef int (WINAPI *inet_statusprocptr)(void *, inet_status_type, int, int, char *, unsigned, unsigned);

inet_error_type  inet_fetch(char *url, inet_transferprocptr transf_f,
                            inet_transresetprocptr transr_f,
                            inet_statusprocptr status_f,
                            int get_hdrs, int use_cookies,
                            char *referer, void *cookie,
                            unsigned timeout_seconds,
                            char *real_url);

inet_error_type  inet_put(char *url, inet_transferprocptr transf_f,
                          inet_statusprocptr status_f, void *cookie);

inet_error_type  inet_post(char *url, char *post_data_file,
                           inet_transferprocptr transf_f,
                           inet_statusprocptr status_f,
                           int use_cookies,
                           char *referer, void *cookie,
                           unsigned timeout_seconds );

const char *inet_error_str(int v);
const char *inet_url_type_str(int v);

void   inet_init(void);
void   inet_done(void);
#ifdef __cplusplus
}
#endif

#endif
