
#ifndef __GENERAL_H__
#define __GENERAL_H__

#include <sys/param.h>


#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef countof
#define countof(a) (sizeof(a)/sizeof(*(a)))
#endif

// _AIX -- right define name?
#ifdef _AIX
#define FILELINE	__FILE__, __LINE__, __FUNCTION__
#else
#define FILELINE	__FILE__, __LINE__, ""
#endif

#define NULLCH ((char) 0)
#define NULLP(ty) ((ty *) 0)
#define MALLOC(obj)	((obj *) malloc (sizeof (obj)))
#define CALLOC(n,obj)	((obj *) calloc (n, sizeof (obj)))

#define DEBUG_ERROR	(0)
#define DEBUG_WARN	(1)
#define DEBUG_INFO	(2)
#define DEBUG_TRACE	(3)

#define ERROR FILELINE,DEBUG_ERROR
#define WARN  FILELINE,DEBUG_WARN
#define INFO  FILELINE,DEBUG_INFO
#define TRACE FILELINE,DEBUG_TRACE

void log (const char *file, int line, const char *function, int debug,
	 const char *format,
          ...);
void loghex (const char *file, int line, const char *function, int debug,
	     const char *buffer, int size);

#endif
