#ifndef UTIL_H
#define UTIL_H

#ifdef  LEAK_DEBUG

/*
 * Leak debug stuff
 */ 
void_p mem_alloc_z(u32_t bs);

#define memAlloc(bs)	mem_alloc_z(bs)
#define memAllocZ(bs)   mem_alloc_z(bs)

#endif  /* LEAK_DEBUG */

#define MAT_SAME_SIZE(m1,m2) \
	((m1)->rows == (m2)->rows && (m1)->cols == (m2)->cols)

#define VEC_SAME_SIZE(v1,v2) \
	((v1)->size == (v2)->size)

#define STR_COMP			strcasecmp
#define STR_EQ(str1,str2)   (!STR_COMP((str1),(str2)))

extern char dotchar;
extern vhandle_t random_gen;
extern u32_t random_seed;
extern u32_t tic_start;

vec_t iplRunTime(void);

/*
 * Recursive seach for same-level token
 */
vboolean	lexSkip_r(vhandle_t lexer,char *keyword);

void		filePrintFloatStr(vhandle_t out,char dotchar,vec_t v,char *str);
vboolean	scriptSearchPair(vhandle_t lexer,char *key,char *name);

/*
 * Input / output
 */
matrix_p iplLoadMatrix(char *file_name);
vboolean iplSaveMatrix(char *file_name,matrix_p m);
vector_p iplLoadVector(char *file_name);
vboolean iplSaveVector(char *file_name,vector_p v);
matrix_p tga_load_gray32(char *file_name);
vboolean tga_save_gray32(char *file_name,matrix_p data);

#endif

