
#include <stdio.h>
#include <stdlib.h>
#include <zlib.h>

#include <glib.h>

#include "zip_header.h"
#include "inflate.h"
#include "zip_testcrc.h"
#include "zip_utils.h"

#ifndef TK_ZIP_WRAPPER_H
#define TK_ZIP_WRAPPER_H

typedef struct _ZipFile {
	char *filename;
	
	GSList *records; /* central dir records */
	ZipCDREnd *cdre;

	int opened;

} ZipFile;

typedef struct _ZipFileVars{
	int skip_errors;
	const char *dir;
	int error_count;
	FILE *file;
	GSList *errors;
} ZipFileVars;

#ifdef __cplusplus
extern "C" {
#endif

ZipFile* zip_file_new(void); /* NULL = failure */
int zip_file_open(const char *filename,ZipFile *zip); /* 0 = failure */
int zip_file_add_records_with_file(FILE *file,ZipFile *zip); /* 0 = failure */
int zip_file_add_records(ZipFile *zip); /* 0 = failure */
void zip_file_free_current(gpointer data,gpointer user_data);
int zip_file_free(ZipFile *zip); /* 0 = failure */
int zip_file_close(ZipFile *zip); /* 0 = failure */
int zip_file_uncompress_all(const char *dir,
			    ZipFile *zip,int extra_flags); /* 1 = success */
int zip_file_uncompress_nth(unsigned int n,const char *dir,ZipFile *zip,
			    int extra_flags); /* 1 = success */
void zip_file_uncompress_current(gpointer data,gpointer user_data);
GSList* zip_file_test(ZipFile *zip,int *status); /* damaged files are in list */
void zip_file_test_current(gpointer data,gpointer user_data);

#ifdef __cplusplus
}
#endif

#endif
