/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	This program is distributed in the hope that it will be 
	useful, but WITHOUT ANY WARRANTY; without even the 
	implied warranty of MERCHANTABILITY or FITNESS FOR A 
	PARTICULAR PURPOSE.

**********************************************************************/



#ifndef ___INCLUDE_H___
#define ___INCLUDE_H___

#include "gb_windows.h"
/*
#ifdef VA2
#include	<varargs.h>
#else
#include	<stdarg.h>
#endif
*/
#ifdef __cplusplus
extern "C++" {
#endif
#include	<stdlib.h>
#include	<string.h>
#include	<stdio.h>
#include	<fcntl.h>
#include 	<ctype.h>
#include	<io.h>
#include	<direct.h>
#include	<stdarg.h>
#include	<time.h>
#include <sys/stat.h>
#include <sys/utime.h>
#include	<winsock2.h>
#include	<Ws2tcpip.h>
#include	"u_math.h"
#ifdef __cplusplus
}
#endif
#ifndef INLINE
#ifdef MSC_VER
#define INLINE __inline
#elif __GNUC__
#define INLINE __inline__
#else
#define INLINE 
#endif
#endif

#define INTEGER64	__int64
#define U_INTEGER64	unsigned __int64
#define CONST_INT64(val) (val##i64)

#define ftruncate64	ftruncate

#define INLINE_STATIC	INLINE static

#ifndef _MAXNAMLEN
#define _MAXNAMLEN 260
#endif

struct dirent {
	long            d_ino; /* if dirent is valid, always 1 .otherwise 0 */
	int             d_off; /* always 0 */
	unsigned short  d_reclen; /* always sizeof(dirent) */
	char            *d_name;
};

typedef struct dir{
	HANDLE h;
	WIN32_FIND_DATA fd;
	struct  dirent de;
	unsigned char firsttime;
}DIR;

/*
struct direct {
     unsigned long d_ino;
	 unsigned short d_reclen;
	 unsigned short d_namlen;
	 char     d_name[_MAXNAMLEN + 1];
};
*/

DIR *opendir(const char *dirname);
int closedir(DIR *dirp);
struct dirent *readdir(DIR *dirp);

#define open64    open
#define lseek64    _lseeki64

#define INTEGER64 __int64
#define I64_FORMAT "%I64i"

#define strcasecmp stricmp

#define m_mkdir(name,mode)		mkdir(name)
/*#define _get_tid	get_tid */

/*
#define S_IFMT	_S_IFMT
#define S_IFREG	_S_IFREG
#define S_IFDIR	_S_IFDIR
*/

int ftruncate(int fd, long _len );
int vsnprintf( char *buffer, size_t count, const char *format, va_list argptr );
void print_win_error();

char *m_getcwd(char *buf, int buf_size);
#define m_utime utime

typedef int uid_t;
typedef int gid_t;

#define XLPATH_DELIM	";\t\n\r"
#define ENABLE_SERIALIZER


#endif
