#ifndef TB_RUNTIME_H_
#define TB_RUNTIME_H_

#include <stdbool.h>

struct Token;

typedef struct RtCmd {
  struct RtCmd *next;
  char *cmdname;
  bool (*fn)(struct Token *tks);
} RtCmd;

#define RTALIAS_NAMEBUF_MAX 0x100
#define RTALIAS_VALBUF_MAX 0x1000

typedef struct RtAlias {
  struct RtAlias *next;
  char namebuf[RTALIAS_NAMEBUF_MAX];
  char valbuf[RTALIAS_VALBUF_MAX];
} RtAlias;

typedef struct RtStringV {
  struct RtStringV *next;
  char *data;
} RtStringV;

void rt_init(void);

extern RtCmd *RTCMDS;
extern RtAlias *RTALIASES;

bool rt_print(struct Token *);
bool rt_mkalias(struct Token *);
bool rt_PID(struct Token *);
bool rt_do(struct Token *);
bool rt_stackpush(struct Token *);
bool rt_stackpop(struct Token *);
bool rt_eachfile(struct Token *);
bool rt_mkaliasbn(struct Token *);
bool rt_setlogcmds(struct Token *);

void rtstringv_stackpushcopy(char *s, size_t len);
char *rtstringv_stackpop(void);
char *rtstringv_stackpeek(void);

#endif // TB_RUNTIME_H_
