/*	 -- 

Copyright (C) 1998 Ogochan.

This module is part of ***.

	**** is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves
any particular purpose or works at all, unless he says so in writing.
Refer to the GNU General Public License for full details. 

	Everyone is granted permission to copy, modify and redistribute
MACE, but only under the conditions described in the GNU General
Public License.  A copy of this license is supposed to have been given
to you along with MACE so you can know your rights and
responsibilities.  It should be in a file named COPYING.  Among other
things, the copyright notice and this notice must be preserved on all
copies. 
*/
/*
*	misc
*
*	98.07.14.	Ogochan	V1.0 create & release
*/

#ifndef	_MISC_H
#define	_MISC_H
#include	"types.h"

/*
#define	COBOL_COMPATIBLITY
*/

#include	<strings.h>

#define	STRCMP		stricmp
#define	STREQ		!stricmp

#define	memclear(s,l)	memset((s),0,(l))

#ifndef	max
#define	max(a,b)	(((a)>(b))?(a):(b))
#endif
#ifndef	min
#define	min(a,b)	(((a)<(b))?(a):(b))
#endif


/*	misc.c	*/
#ifdef	__cplusplus
extern	"C" {
#endif
extern	void	*_xmalloc(size_t,char *,int);
extern	void	_xfree(void *,char *,int);
#define	New(t)	(t *)xmalloc(sizeof(t))
#define	NewArray(t,n)	(t *)xmalloc(sizeof(t)*(n))
extern	void	Error(char *);

#ifdef	__GNUC__
extern	int		stricmp(char *,char *);
extern	int		strnicmp(char *,char *,size_t);
#endif
extern	int		strlcmp(char *,char *);
extern	int		strlicmp(char *,char *);

extern	long	StrToInt(char *,size_t);
extern	long	HexToInt(char *,size_t);
extern	char	*IntToStr(char *,long,size_t);
#ifdef	COBOL_COMPATIBLITY
extern	void	MakeCobolX(char *,size_t,char *);
extern	void	CopyCobol(char *,char *);
#endif
extern	void	PrintFixString(char *,int);
extern	char	*StrDup(char *);
extern	void	StrFree(char *);
extern	void	AdjustByteOrder(void *,void *,size_t);
#ifdef	__cplusplus
}
#endif

#ifndef		offsetof
#define		offsetof(t,m)		(size_t)(&(((t *)0)->m))
#endif

#endif
