/*
 *  kermitvar.c
 */
#include "types.h"
#include "xproto.h"
#include "kermitproto.h"
#include "kermitvar.h"
#include <exec/memory.h>
#include <functions.h>

/* Perform setup and initializations common to both Send and Receive routines */
struct Vars *setup(io)
register struct XPR_IO *io;
{
  register struct Vars *v;

  /* Allocate memory for our unshared variables, to provide reentrancy */  
  if (!(v = AllocMem((long)sizeof(struct Vars),MEMF_CLEAR))) {
nomem:
    ioerr(io,"Not enough memory");
    return NULL;
  }

  /* Copy caller's io struct into our Vars for easier passing */
  v->io = *io;

  /* Initialize Vars as required */
  v->cx = 0;
  v->cz = 0;
  v->rpsiz = MAXRP;
  v->limit = 5;
  v->warn = 0;
  v->rpadn = 0;
  v->rtimo = 10;
  v->rmark = '\1';
  v->reol = '\r';
  v->start = 0;
  v->sctlq = '#';
  v->rpadc = '\0';

  v->spsiz = DSPSIZ;
  v->wsize = MAXWS;
  v->bctu = 1;
  v->ebq = '&';
  v->ebqflg = 0;
  v->rq = 0;
  v->sq = 'Y';
  v->rpt = 0;
  v->rptq = '~';
  v->rptflg = 0;
  v->capas = 10;
  v->atcapr = 0;
  v->atcapu = 0;
  v->swcapr = 0;
  v->swcapu = 0;
  v->lpcapr = 0;
  v->lpcapu = 0;
  v->seq = 0;
  v->first = 0;
  v->stimo = 5;
  v->spadn = 0;

  v->smark = '\1';
  v->spadc = '\0';
  v->seol = '\r';
  v->rctlq = '#';
  v->isp = NULL;
  v->osp = NULL;
  v->state = 0;

  return v;
}
