/* This file is part of the origami distrubution. (Amiga Port)
 *
 * Source code written by Thomas Hadig in September 1991
 * Version : 1.6.42 alpha, June 1992
 * Arexx Version : gamma
 * (C) 1992 by Thomas Hadig
 * may be distributed unchanged ! (see copyright notes)
 *
 * Please read the file  readme.arexx
 */

#include <exec/ports.h>
#define REXX_RETURN_ERROR ((struct RexxMsg *)-1L)

/*{{{  prototypes and pragmas for arexx stuff*/
#ifdef ORI_AREXX_C
/*{{{  prototypes*/
struct RexxMsg *CreateRexxMsg(struct MsgPort *,char *,char *);
void *CreateArgstring(char *,long);
void DeleteRexxMsg(struct RexxMsg *);
void DeleteArgstring(char *);
BOOL IsRexxMsg(struct Message *);
/*}}}  */
/*{{{  pragmas*/
#pragma libcall OrigamiARexx.RexxSysBase CreateRexxMsg 90 09803
#pragma libcall OrigamiARexx.RexxSysBase CreateArgstring 7E 0802
#pragma libcall OrigamiARexx.RexxSysBase DeleteRexxMsg 96 801
#pragma libcall OrigamiARexx.RexxSysBase DeleteArgstring 84 801
#pragma libcall OrigamiARexx.RexxSysBase IsRexxMsg A8 801
/*}}}  */
/*{{{  prototypes*/
long CheckRexxMsg(struct RexxMsg *);
long GetRexxVar(struct RexxMsg *,char *,char **);
long SetRexxVar(struct RexxMsg *,char *,char *,long);
/*}}}  */
#endif
/*}}}  */

/*{{{  My_ArexxMessage*/
struct My_ArexxMessage
 {
  struct Message  ExecMessage;
  long            class; /* 0L if child process terminated */
  short           ended;
  short           running;
  char            my_message[256];
 };
/*}}}  */
/*{{{  class defines*/
/** Types for class  **/
typedef enum
{
  AREXX_CAME_DOWN=0,   /* defined by the Lattice forkv/forkl routine */
  AREXX_CAME_UP,       /* startup message of origami_arexx to get the
                        * port, messages will be send to */
  AREXX_COME_DOWN,     /* message send by origami to origami_arexx
                        * to terminate origami_arexx */
  AREXX_OUT,           /* message send by origami to origami_arexx
                        * containing the command name (without AREXX:) */
  AREXX_OCL,           /* message send by origami_arexx to origami
                        * macro definition to be started by origami */
  AREXX_REQUEST        /* old command */
} MES_REXX_CLASS;
/*}}}  */
/*{{{  AR_types*/
typedef enum
{
  AR_OCL    /* no result */
} AR_TYPES;
/*}}}  */
/*{{{  arexx_fix_macros*/
#ifdef SIGNALS_C
  extern bool arexx_tag;
  extern struct My_ArexxMessage *arexx_tag_msg;
  /*{{{  requester*/
  TOKEN arexx_fix_macro_req[] =
   { M_NULL_COUNTER, 0,              /* clear arexx_var (indicates false) */
     M_JMP_FALSE, 3,                 /* behind set arexx_var */
     M_SET_COUNTER , 0, 1,           /* set arexx_var (indicates true) */
     M_END_MACRO
   };
  /*}}}  */
  /*{{{  ocl*/
  TOKEN arexx_fix_macro_ocl[] =
   { M_NULL_COUNTER, 0,      /* clear arexx_var (indicates end of macro) */
     M_END_MACRO
   };
  /*}}}  */
#endif

/* these are the adresses of arexx_var, must be inserted during running */
#define set_both     1
#define set_only_req 5
/*}}}  */
/*{{{  OrigamiARexx*/
/*{{{  MacroDefs*/
struct MacroDefs
{
  int op;
  int lg;
  TOKEN *token;
};
/*}}}  */

struct OrigamiARexx
{
  /* Arexx Part */
  struct  MsgPort *ARexxPort;
  struct  Library *RexxSysBase;
  long  Outstanding;
  char  ARexxPortName[24];
  char  ErrorName[28];
  char  Extension[8];
  /* Origami Part */
  struct MsgPort *OrigamiPort;
  char  OrigamiPortName[24];
  struct MsgPort *MyPort;
  char  *OriPid;
  /* Token storage */
  int macro_free;
  int macro_max;
  struct MacroDefs **macro_list;
  struct  RexxMsg *AktMsg;
  int ArgNum;
  int ArgPos;
};

#define ORIGAMI_LEN  7     /* strlen("ORIGAMI") */
/*}}}  */

/*{{{  prototypes and variables for amiga files*/
/*{{{  Ori_Arexx.c*/
#ifdef I_ORI_AREXX_C
extern struct OrigamiARexx OrigamiARexx;

bool write_macro_rc (readtags tag, TOKEN op, int lg, TOKEN *code);
int read_in (void);
#endif
/*}}}  */
/*{{{  Rexxscan.c*/
#ifdef I_REXXSCAN_C
extern int input;
extern KEYNAME *tk_key;
extern OP *tk_operation;

TOKEN get_token (bool code);
bool process_command (TOKEN token);
#endif
/*}}}  */
/*}}}  */
