/*
    $Header: Welmat:src/RCS/modem7.c,v 1.11 92/09/12 20:43:25 rwm Exp Locker: rwm $

    Main include file for XPR FTS protocol

    Copyright (C) 1992 Russell McOrmond

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 */

/* Return codes */
#define OK            0
#define NODCD       (-1)
#define ERROR       (-2)

#define SCRATCHLEN 256

struct Vars {
     /* Copy of XProtocol IO struct passed in by term prog. */
  struct XPR_IO io;                   
     /* Scratchpad xpr_update() control struct */
  struct XPR_UPDATE __aligned xpru;  
  int adjust;
  long year;
     /* Scratchpad buffer for printing messages */
  UBYTE __aligned scratch[SCRATCHLEN];     
};

/* Option settings and other variables needed outside of XProtocolSend/Receive;
   separated from rest of Vars so that huge Vars struct doesn't have to be
   allocated except during transfers.  Pointer to this struct kept in xpr_data. */
struct SetupVars {
  UBYTE *matchptr, *bufpos;
  short buflen;
  UBYTE year[5],adjust[10];
};


/* Function prototypes */

long  __saveds XProtocolSend(struct XPR_IO *io);
long __saveds XProtocolReceive(struct XPR_IO *io);
long __saveds XProtocolSetup(struct XPR_IO *io);
long __saveds XProtocolCleanup(struct XPR_IO *io);
long __saveds XProtocolHostMon(struct XPR_IO *io,UBYTE *serbuff,long actual,long maxsize);
long __saveds XProtocolUserMon(struct XPR_IO *io,UBYTE *serbuff,long actual,long maxsize);
struct Vars *setup(struct XPR_IO *io);
UBYTE *find_option(UBYTE *buf,UBYTE option);
void ioerr(struct XPR_IO *io,char *msg);
void upderr(struct Vars *v,char *msg);
void updmsg(struct Vars *v,char *msg);

/* format.asm */
int SPrintF(UBYTE *buf, UBYTE *format,...);

/* debug.lib */
int KPrintF(UBYTE *format,...);

void * __asm xpr_fopen(register __a3 struct XPR_IO *io,register __a0 char *filename,register __a1 char *accessmode);
void __asm xpr_fclose(register __a3 struct XPR_IO *io,register __a0 void *fileptr);
long __asm xpr_fread(register __a3 struct XPR_IO *io,register __a0 char *buffer,register __d0 long size,register __d1 long count,register __a1 void *fileptr);
long __asm xpr_fwrite(register __a3 struct XPR_IO *io,register __a0 char *buffer,register __d0 long size,register __d1 long count,register __a1 void *fileptr);
long __asm xpr_sread(register __a3 struct XPR_IO *io,register __a0 char *buffer,register __d0 long size,register __d1 long timeout);
long __asm xpr_swrite(register __a3 struct XPR_IO *io,register __a0 char *buffer,register __d0 long size);
long __asm xpr_sflush(register __a3 struct XPR_IO *io);
void __asm xpr_update(register __a3 struct XPR_IO *io,register __a0 struct XPR_UPDATE *updatestruct);
long __asm xpr_chkabort(register __a3 struct XPR_IO *io);
long __asm xpr_chkmisc(register __a3 struct XPR_IO *io);
long __asm xpr_gets(register __a3 struct XPR_IO *io,register __a0 char *prompt,register __a1 char *buffer);
long __asm xpr_setserial(register __a3 struct XPR_IO *io,register __d0 long newstatus);
long __asm xpr_ffirst(register __a3 struct XPR_IO *io,register __a0 char *buffer,register __a1 char *pattern);
long __asm xpr_fnext(register __a3 struct XPR_IO *io,register __d0 long oldstate,register __a0 char *buffer,register __a1 char *pattern);
long __asm xpr_finfo(register __a3 struct XPR_IO *io,register __a0 char *filename,register __d0 long typeofinfo);
long __asm xpr_fseek(register __a3 struct XPR_IO *io,register __a0 void *fileptr,register __d0 long offset,register __d1 long origin);
long __asm xpr_options(register __a3 struct XPR_IO *io,register __d0 long n,register __a0 struct xpr_option **opt);
long __asm xpr_unlink(register __a3 struct XPR_IO *io,register __a0 char *filename);
long __asm xpr_squery(register __a3 struct XPR_IO *io);
long * __asm xpr_getptr(register __a3 struct XPR_IO *io,register __d0 long type);
