/* apccomm_all.h
   Part of "APCComm" 
   Copyright (C) 2000,2001 Ralf Hoffmann
   Contact: ralf.hoffmann@epost.de

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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  
*/
/* $Id: apccomm_all.h,v 1.8 2002/06/11 19:11:32 ralf Exp $ */

#ifndef APCCOMM_ALL_H
#define APCCOMM_ALL_H

#define MAJOR 2
#define MINOR 1
#define PATCH 0
#define AMIGA_VERSION_STR "\0$VER: apccomm 2.1.0 ("__DATE__" "__TIME__")"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>

#ifndef _DCC
  #include <unistd.h>
#endif

#ifdef USE_OPEN
  #include <sys/stat.h>
  #include <fcntl.h> 
#endif

/* If you change this, you also have to change the _opt.a-file! */
#define TRANSFERBLOCKSIZE 1024

extern unsigned char *outblock,*inblock;

void transferblock( void );

typedef struct pc_file_tag {
#ifdef USE_OPEN
  int fp;
#else
  FILE *fp;
#endif
  int size;
  int checksum;
  char *name;
} pc_file_t;

extern pc_file_t outfile;
extern pc_file_t infile;

extern char *basedir;

int init_outgoing_file(const char*name);
void close_outgoing_file( void );
int init_incoming_file(const char*name);
void close_incoming_file( void );

void putint(unsigned char *buffer,int value);
int getint(unsigned char *buffer);
int readtobuffer(unsigned char* buffer,int maxsize,int *return_checksum);
int writefrombuffer(unsigned char *buffer,int size,int *return_checksum);
int init_transferblocks( void );

typedef enum { APC_COMMAND_FILETRANSFER=0,
               APC_COMMAND_ERROR,
               APC_COMMAND_ENTERDIR,
               APC_COMMAND_LEAVEDIR,
	       APC_COMMAND_FINISHED,
	       APC_COMMAND_NOP,
	       APC_COMMAND_ABORT,
	       APC_COMMAND_SKIPFILE } apc_command_t;

int min(int a, int b);

/* -1 = quiet (only errors)
 *  0 = normal
 *  1 = verbose (every message)
 */

extern int verbose;

#define BE_VERBOSE ( verbose > 0)
#define BE_QUIET ( verbose < 0 )

extern int ignore_prot;

#endif
