/*
 ******************************************************************************
 *  Copyright 1984-1994 United States Data Corporation. All Rights Reserved.
 ******************************************************************************
 *                                - NOTICE -
 *
 *  The information contained herein is confidential information of United
 *  States Data Corporation, a Delaware corporation, and is protected by
 *  United States copyright and trade secret law and international treaties.
 *  This information is not to be disclosed, used or copied by or transferred
 *  to any individual, corporation, company or other person without the
 *  express written permission of United States Data Corporation.
 ******************************************************************************
 *
 * cml.h
 *
 * include file for user-defined FactoryLink 'C' procedures
 *
 */

#ifndef CML_H
#define CML_H

#define MAXMSG         1024      /* maximum string length allowed */
#define MAX_BUF        1024
#define MAXBUF		MAX_BUF
#define MAXDIM          8       /* maximum dimensions of variables and tag arrays */
#define PROCNAMESIZE    18      /* length of procedure name in CT record */

#define TAGEXT          "bin"   /* tag file extension */


/*
 * runtime evaluation stack value
 *
 */

typedef struct
{
	union
	{
		short   ival;
		long    lval;
		double  fval;
		char    *cval;
	}       val;            /* object value */

	int     type;           /* object type */

} VALUE;


typedef struct
{
	TAG     tag;
	int     type;
	int     ndim;
	int     dims[MAXDIM];

} TAGLIST;


typedef struct
{
	void    (*entry)(void);

} PROCLIST;


extern  char **Argvect;
extern  int Argcount;

extern  PROCLIST FAR FLprocs[];
extern  char    *Procname;
extern  char    *OldProcname;

extern  id_t Task_id;

/* cml.c */
double  pow ( double x , double y );
void    status ( char *, ANA );
void    fatal ( char *s );
char    *savstr ( char *s );

/* dofunc.c */
void    doabs ( void );
void    dotrans ( double (*fp )(double ));
void    dolenstr ( void );
void    dosubstr ( void );
void    dogetarg ( void );
void    dochr ( void );
void    doasc ( void );
void    doinstr ( void );
void    dolower ( void );
void    doupper ( void );
void    dotrim ( void );
void    doltrim ( void );

/* dosysos2.c */
void    dosys ( void );
void    dogetdir ( void );
void    dogetdrive ( void );
void    dosetdrive ( void );
void    dosetdir ( void );
void    short_pause ( void );

/* dounary.c */
void    donot ( void );
void    doneg ( VALUE *p1 );
void    dobneg ( VALUE *p1 );

/* dologic.c */
void    dogt ( void );
void    dogte ( void );
void    dolt ( void );
void    dolte ( void );
void    doeq ( void );
void    doneq ( void );
void    door ( void );
void    doand ( void );

/* doarith.c */
void    doadd ( void );
void    dosub ( void );
void    domul ( void );
void    dopow ( void );
int     chkz ( VALUE *p1 );
void    dodiv ( void );
void    domod ( void );

/* stack.c */
VALUE   *nalloc ( VALUE *p );
void    nfree ( VALUE *p );
void    clrstack ( void );
void    resetstack ( void );
void    push ( VALUE *p );
VALUE   *pop ( void );
VALUE   *tos ( int offs );
void    pushint ( int n );
void    pushlong ( long n );
void    pushflp ( double n );
void    pushstr ( char *pbuf );
int     popint ( void );
long    poplong ( void );
double  popflp ( void );
char    *popstr ( void );
int     tosint(int);
long    toslong(int);
double  tosflp(int);
char    *tosstr(int);
VALUE   *makestr ( void );

/* fixtype.c */
void    fixtype ( void );
void    i2l ( VALUE *p );
void    i2f ( VALUE *p );
void    i2s ( VALUE *p );
void    l2f ( VALUE *p );
void    l2s ( VALUE *p );
void    f2s ( VALUE *p );
void    s2i ( VALUE *p );
void    s2f ( VALUE *p );

/* flvar.c */
void    pushdbvar ( TAGLIST *tags, int tagndx );
void    popdbvar  ( TAGLIST *tags, int tagndx, int force );
int     getchng ( TAGLIST *tags, int tagndx );
void    doprint ( VALUE *v );
void    trprint ( char *fmt , VALUE val );
void    dolock ( void );
void    dounlock ( int n );
long    fl_ftol(double f);

/* name2id.c */
int fl_tagname_to_id(TAG *tp, int num, ...);
int fl_tagary_to_id(TAG *tp, int num, char **np);

/* dobool.c */
void doxor ( void );
void dobor ( void );
void doband ( void );

#endif

