#ifndef _GLOBAL_PROTOTYPES_H_MODULE_
#define _GLOBAL_PROTOTYPES_H_MODULE_

#include "glbtypes.h"
/*
	#if (TARGET_SYSTEM==DOS)

	#define Strcmp(x,y)	_fstrcmp(x,y)
	#define Strcpy(x,y)	_fstrcpy(x,y)
	#define Strncpy(x,y,z)	_fstrncpy(x,y,z)
	#define Strncmp(x,y,z)	_fstrncmp(x,y,z)
	#define Strlen(x)	_fstrlen(x)
	#define Strdup(x)	_fstrdup(x)
	#define Memset(x,y,z)	_fmemset(x,y,x)
	#define Free(x)		farfree(x)

	#else
*/
	#define Strcmp(x,y)	strcmp(x,y)
	#define Strcpy(x,y)	strcpy(x,y)
	#define Strncpy(x,y,z)	strncpy(x,y,z)
	#define Strncmp(x,y,z)	strncmp(x,y,z)
	#define Strlen(x)	strlen(x)
	#define Strdup(x)	strdup(x)
	#define Memset(x,y,z)	memset(x,y,x)
	#define Free(x)		free(x)

/*	#endif*/



	#ifndef _USED_STD_LIB_FILES_
	#define _USED_STD_LIB_FILES_

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

	#ifdef __USE_CTYPE_H__
	#include <ctype.h>
	#endif

	#endif


/************************ String tools - strtools.c ***********************************/

extern char * get_nth_token(int n,char * str);

extern cmp_str str_cmp(char * s1,char * s2);

extern char * next_token1(char * str);

extern char * next_token(char * str);

extern char * get_variable_name(char *);

extern char * get_variable(char *);


extern int refresh_buffer(char * buffer,int howmuch,int bufsize);

extern char * create_new_buffer(char * bufptr,int bufsize);

extern int normalize_buffer(char * bufptr,int bufsize);

/********************* Operator def tools - opdtools.c *********************************/

extern void opdef_ins(defined_op op, defined_op oda);

extern inline_op inline_opdef_last(inline_op l);

extern int inline_op_list_count_part(inline_op from,inline_op to);

extern int inline_op_list_count(inline_op i_op);

extern void destroy_inline_op_list_part(inline_op from,inline_op to);

extern void destroy_inline_op_list(inline_op src);

extern inline_op copy_inline_op_list_part(inline_op from,inline_op to);

extern inline_op copy_inline_op_list(inline_op); 
/* copies entire inline defs list */

extern int opdef_count(defined_op d_op);

extern void print_opd(defined_op l);

extern defined_op opdef_last(defined_op l);

extern void opdef_ins(defined_op op, defined_op oda);

extern int get_opdef_def(char *,defined_op,listnode,struct vardecl_listoflist *,struct type_listoflist *,listnode);



extern void mk_opd(struct op_definition PTR res,char * form,char * defn,int attr,int prec);

extern void install_opd(defined_op base,char * form,char * defn,int attr,int prec);

extern void finstall_opd(defined_op base, char * form, char * defn, char * fdef,int attr,int prec);

/* int install_iopd(inline_op base,char * form,char * defn,int attr,int prec); */



extern int op_recognize(char *,listnode,defined_op,listnode,int,struct type_listoflist PTR,struct vardecl_listoflist PTR,listnode);

extern int inline_op_recognize(char *,listnode,inline_op,defined_op,listnode,listnode,listnode,struct vardecl_listoflist PTR,struct type_listoflist PTR,listnode,int,int);





extern int get_function(char *,listnode,defined_op,listnode,int,struct type_listoflist PTR,struct vardecl_listoflist PTR,listnode);

extern int get_expression(char *,listnode,defined_op,listnode,int,struct type_listoflist PTR,struct vardecl_listoflist PTR,listnode);

extern listnode get_exp_lst_ins(listnode mainlist,listnode toappend,int usebrct);

extern listnode op_to_function(listnode);






extern void mk_asm_output(listnode ,listnode ,struct vardecl_listoflist PTR ,struct type_listoflist PTR,listnode);

extern char PTR get_local_label(char PTR, listnode, enum lnd_attr);

extern void print_asm_output(listnode, listnode,struct vardecl_listoflist PTR, struct type_listoflist PTR,listnode);

extern int exec_inline_func(struct fundef PTR fn,listnode args,listnode labels,struct vardecl_listoflist PTR vars,struct type_listoflist PTR types,listnode fnlist);

extern int get_typeof_decl(char *,struct type_listoflist PTR,struct vardecl_listoflist PTR,defined_op,listnode,struct typerec PTR*);

extern int get_code_block(char *,listnode,listnode,defined_op,listnode,listnode,struct vardecl_listoflist PTR,struct type_listoflist PTR,listnode,int);

extern int get_var_decl(char *,struct type_listoflist PTR tlist,struct vardecl_listoflist PTR vlist,listnode,listnode,defined_op,listnode,listnode,int,int *);

extern struct typerec PTR get_new_type_declaration(char *,struct type_listoflist PTR,struct vardecl_listoflist PTR,listnode,listnode,defined_op,listnode,listnode);

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

extern void PTR set_typerec(struct typerec PTR,int,char PTR,enum typekind,enum typemodf,enum tb_built_in,struct fundef_list PTR);

extern listnode convert_type(struct type_listoflist PTR,struct typerec PTR,struct typerec PTR,listnode);

extern struct typerec PTR mk_ref_type_from_type(struct typerec PTR,enum typemodf, struct type_listoflist PTR,int);

extern struct type_list PTR install_type(struct type_list PTR tl,int,char PTR,enum typekind,enum typemodf,enum tb_built_in,struct fundef_list PTR);

extern struct typerec PTR validate_function(listnode,listnode,struct vardecl_listoflist PTR,struct type_listoflist PTR,listnode,int);

extern struct vardecl_list PTR global_find_var_decl(char PTR,struct vardecl_listoflist PTR);

extern void destroy_vardecl_list(struct vardecl_list PTR vlst);

extern int get_type_from_code(char *,listnode,listnode,struct type_listoflist PTR,struct vardecl_listoflist PTR,char *,listnode,defined_op,listnode,struct typerec PTR*);

extern struct vardecl_list PTR global_find_var_decl(char PTR, struct vardecl_listoflist PTR);

extern int get_subtype_from_code(char *,struct typerec PTR,listnode,listnode,struct type_listoflist PTR,struct vardecl_listoflist PTR,listnode,defined_op,listnode,char PTR *,struct typerec PTR *);

extern struct vardecl_list PTR insert_var_decl(struct vardecl_list PTR,char PTR,struct typerec PTR,void *,int);

extern struct typerec PTR lookup_class_func(listnode,struct typerec PTR,struct vardecl_listoflist PTR,struct type_listoflist PTR,listnode);

extern struct typerec PTR get_type_by_name(char PTR name,enum typemodf tm, struct type_listoflist PTR tll);

extern struct typerec PTR get_type_by_name_skip(long skip_id,char PTR name,enum typemodf tm, struct type_listoflist PTR tll);

extern int check_top_class(struct typerec PTR type,int top_cl_id);

extern struct typerec PTR eval_type_refr(struct typerec PTR type,listnode fnlist,struct vardecl_listoflist PTR vars,struct type_listoflist PTR types,listnode labels,int bind);

extern struct typerec PTR mk_subtype_by_type(struct typerec PTR type1,struct typerec PTR type2, struct type_listoflist PTR tll,int);

extern struct typerec PTR mk_subtype_by_name(struct typerec PTR type,char PTR name,enum typemodf tm, struct type_listoflist PTR tll);

extern struct typerec PTR apply_modifier(struct typerec PTR type,listnode modif,listnode * std_constr,struct type_listoflist *);

extern struct vardecl_list PTR copy_vardecl_list(struct vardecl_list PTR vlst);

extern struct vardecl_list PTR lookup_var_decl(char PTR name,struct vardecl_list PTR lst);

extern struct vardecl_list PTR global_find_var_decl(char PTR name, struct vardecl_listoflist PTR vars);

extern struct vardecl_list PTR lookup_var_decl_attr(enum var_attr attr,struct vardecl_list PTR lst);

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

extern listnode mk_set_lnd(listnode,void PTR,enum lnd_attr);

extern listnode lnd_cdre(listnode l);

extern listnode mk_listnode(listnode l);

extern listnode mk_set_lnd(listnode l,void PTR data,enum lnd_attr attr);

extern listnode mk_head_lnd(listnode lst,void PTR data,enum lnd_attr attr);

extern listnode rm_listnode(listnode l);

extern listnode rm_last_node(listnode l);

extern listnode rm_lnd_all(listnode l);

extern listnode lnd_iapnde(listnode l,char PTR s);

extern listnode lnd_sapnde(listnode l,char PTR s);

extern listnode lnd_asapnde(listnode l,char PTR s,enum lnd_attr attr);

extern listnode lnd_rapnde(listnode l1,listnode l2);

extern listnode lnd_capnde(listnode l1,listnode l2);

extern int lnd_count(listnode l);

extern listnode get_nth_lnd(listnode l, int n);

extern listnode lnd_reverse_r(listnode l);

extern listnode rm_cdr_next(listnode l);

extern listnode copylist(listnode l);

extern listnode lnd_find(listnode l,char * d1,enum lnd_attr a1);

extern listnode lnd_replace(listnode l,void * d1,enum lnd_attr a1,void * d2,enum lnd_attr a2,int saveold,int repeat);

extern int spec_lnd_count(listnode l,enum lnd_attr attr);

extern void printlist(listnode l);

extern void printlist1(listnode l,int step);

extern int printlist2(listnode l,int step,int j);

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

extern int get_fn_arg_decl(char *,struct type_listoflist PTR,struct vardecl_listoflist PTR,listnode,listnode,defined_op,listnode,listnode,int);

extern int test_get_constr_destr(char *,struct typerec PTR,struct type_listoflist PTR,struct vardecl_listoflist PTR,listnode,listnode,defined_op,listnode,listnode,struct fundef PTR*);

extern int test_get_fn_decl(char *,struct type_listoflist PTR,struct vardecl_listoflist PTR,listnode,listnode,defined_op,listnode,listnode,struct fundef PTR*);

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

extern listnode inline_op_find_var(char PTR name,listnode lst);

extern listnode inline_op_find_prefix(char PTR pref,listnode lst);

extern listnode inline_op_subst_lvar(char PTR name,listnode lst, listnode l);

extern int get_inl_varinfo(char PTR name, struct inline_varinfo PTR lst);

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

#ifndef __USE_CTYPE_H__

extern int isalnum(char);

extern int isalpha(char);

#endif

extern int isidch(char);

extern int isnum(char);

extern int isalnumsp(char);

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

extern void PTR my_malloc(unsigned long);

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

#endif

