/*************************************************************************/
/*                                                                       */
/* COMPC.C et DECOMP.C Compression et décompression de fichiers source C */
/*              V1.00 FREEWARE Christian BRUNON 20-08-1993               */
/*                                                                       */
/*             +-----------------------------------------+               */
/*             | Logiciel placé dans le domaine FREEWARE |               */
/*             +-----------------------------------------+               */
/* L'utilisation et la diffusion de ce programme, des fichiers sources   */
/* et de la documentation sont entièrement libres.                       */
/*                                                                       */
/*                           Christian BRUNON                            */
/*                        30 Rue Georges Brassens                        */
/*                      43140 LA SEAUVE SUR SEMENE                       */
/*                                FRANCE                                 */
/*                                                                       */
/*            Fichier source Lattice C AmigaDOS Version 5.04             */
/*                                                                       */
/*************************************************************************/

/* Fichier Header contenant les constantes, macros, variables globales,  */
/* structures et fonctions externes des fichiers sources Comp.C et DeCompC.C */

/* Fichiers INCLUDE */
#define strlen __builtin_strlen
#define strcpy __builtin_strcpy
extern char *strcat(char *, char *);
extern int strlen(char *);
extern char *strcpy(char *, char *);
#include <StdIO.H>

/* MACROS */
#define UpChar(C) ((C) & (255-32))

/* Définitions de pseudo-types */
#define BPTR  long
#define UBYTE unsigned char
#define LONG  long
#define ULONG unsigned long
#define UWORD unsigned short

/* CONSTANTES GLOBALES */
/* Constantes d'erreur */
#define FileOpenReadError 2
#define CreateError       3
#define WriteError        4
#define ReadError         5
#define MemoryError       6
#define BreakError        7

#define MaxLongMot  30
#define MaxMots    700

/* Codes de compression */
#define NouveauMot '\0'
#define MotExistant '\1'
/* Début de commentaire /*  */
#define Commentaire1On  2
/* Fin de commentaire   étoile/  */
#define Commentaire1Off 3
/* Début de commentaire /* + espace */
#define Commentaire2On  4
/* Fin de commentaire   espace + étoile/ */
#define Commentaire2Off 5
#define LigneVide     255

/* VARIABLES GLOBALES */
FILE *FIn,  /* Fichier lu    */
     *FOut; /* Fichier écrit */

UBYTE NomFicIn[90],            /* Nom du fichier lu         */
      NomFicOut[90],           /* Nom du fichier écrit      */
      CodeErreur=0,            /* Code d'erreur             */
      Mot[MaxLongMot],         /* Un mot lu                 */
      LongMot,                 /* Longueur du mot lu        */
      ComptLignes;             /* Compteur de lignes modulo */

static UWORD NbMots,  /* Nb de mots enregistrés */
             CodeMot; /* Code du mot            */

static ULONG LongFicIn;

/* Structure utilisée par la structure FileInfoBlock */
struct DateStamp
  {
   LONG ds_Days,
        ds_Minute,
        ds_Tick;
  };

/* Structure utilisée pour Examine(), doit étre alignée sur une adresse divisible par 4 */
struct FileInfoBlock
  {
   LONG   fib_DiskKey;
   LONG   fib_DirEntryType;  /* Type of Directory. If < 0, then a plain file. If > 0 a directory */
   char   fib_FileName[108]; /* Null terminated. Max 30 chars used for now */
   LONG   fib_Protection;    /* bit mask of protection, rwed are 3-0.      */
   LONG   fib_EntryType;
   LONG   fib_Size;          /* Number of bytes in file */
   LONG   fib_NumBlocks;     /* Number of blocks in file */
   struct DateStamp fib_Date;/* Date file last changed */
   char   fib_Comment[80];   /* Null terminated comment associated with file */
   char   fib_Reserved[36];
  };

/* Type à passer à la fonction Lock() */
/* #define SHARED_LOCK    -2L  File is readable by others */
   #define ACCESS_READ    -2L  /* Synonym                 */
/* #define EXCLUSIVE_LOCK -1L  No other access allowed    */
/* #define ACCESS_WRITE   -1L  Synonym                    */

#define LastChar(S) S[strlen(S)-1]
