home *** CD-ROM | disk | FTP | other *** search
- #define CATCOMP_NUMBERS
- #include "compare.module.strings"
-
- #define _DOPUS_MODULE_DEF
- #include <dopus/modules.h>
-
- #include <math.h>
- #include <ctype.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdarg.h>
- #include <exec/exec.h>
- #include <proto/exec.h>
- #include <dos/dos.h>
- #include <clib/dos_protos.h>
- #include <pragmas/dos_pragmas.h>
- #include <clib/intuition_protos.h>
- #include <pragmas/intuition_pragmas.h>
-
- #include "ResourceNodes.h"
-
- /**************************************************************************************/
-
- /*= Magic Numbers ====================================================================*/
-
- #define MIN_OPUS_VERSION 55 // Minimum version of dopus5.library required.
- #define PUDDLESIZE 4096 // Size of memory-pool puddles.
- #define THRESHSIZE 3072 // Allocations above this size get own puddle.
- #define INFORMUSERBUFFERSIZE 1024 // Buffer for writting InformUser() strings to.
- #define PATHBUFFSIZE 512 // Size of buffers for file paths.
- #define NAMEBUFFSIZE 32 // Size of buffers for file names.
- #define COMMBUFFSIZE 512 // Size of buffers for (ARexx) command strings.
- #define DEFCOMPAREBUFFSIZE (30*1024) // Size of each comparison buffer (there are 2).
- // (Default which may be changed by user.)
- #define DISPLAYLINEBUFFSIZE 2048 // Buffer for each line of the Report.
- // Must also be able to hold two path strings.
- // I have calculated this is larger than the
- // worst-case length of a report line, too.
- #define HEXBUFFSIZE 72 // Buffer for building hex-dumps.
- #define ASCBUFFSIZE 72 // Buffer for building ASCII dumps.
- // I have also calculated these for worst-case.
- #define IU_DISPLAY 1
-
- #define CMD_TEMPLATE "BUFFSIZE/K/N,NOSIZEWARN/S"
- enum {ARG_BUFFSIZE,ARG_NOSIZEWARN};
-
- /*= Non-localized strings ============================================================*/
-
- /*= Macros ===========================================================================*/
- #define TEXT_INTERNAL_ERROR DOpusGetString(locale,MSG_INTERNAL_ERROR)
- #define dgs(A) DOpusGetString(locale,A)
- #define TAGIF(expr,tag) ((expr) ? (tag) : (TAG_IGNORE))
- #define TAGNOT(expr,tag) ((expr) ? (TAG_IGNORE) : (tag))
- #define printchar(C) ( (isprint(C)) ? (C) : ('.') )
-
- /*= Difference Range structure and constants =========================================*/
-
- #define DR_EXTEND 8 // No. extra chars shown either side of actual range.
-
- struct DiffRange
- {
- struct DiffRange *next;
- LONG start;
- LONG end;
- };
-
- /*= Pseudo-global variables ==========================================================-.
- || This is a re-entrant library so real global variables cannot be used. ||
- || Instead we allocate this structure and pass the pointer to it around. ||
- ||------------------------------------------------------------------------------------||
- || These must all default to NULL when allocated (MEMF_CLEAR must be given). ||
- `-====================================================================================*/
- typedef struct
- {
- IPCData *ipc; // -._ Copies of commonly used
- EXT_FUNC(func_callback); // -' values from Opus.
-
- ResNode_Data rnd; // For ResourceNode routines.
-
- APTR listerhandle; // Handle of our lister.
-
- struct DiffRange *drbase; // First item in linked list of DiffRanges
-
- char file1path[PATHBUFFSIZE]; // -._ Full path and name of first
- char file1name[NAMEBUFFSIZE]; // -' file to compare with second.
- char file2path[PATHBUFFSIZE]; // -._ Full path and name of second
- char file2name[NAMEBUFFSIZE]; // -' file to compare with first.
-
- LONG minsize; // Minimum size of the two files.
- LONG buffsize; // Size of each compare buffer.
-
- BOOL nosizewarn; // If TRUE, don't warn about diffnt size files.
-
- ResNode *file1rn; // -._ A ResourceNode for
- ResNode *file2rn; // -' each of the files.
-
- } Compare_Data;
-
- /*= Prototypes =======================================================================*/
-
- BOOL informUser(Compare_Data *data,char *format,BOOL window,ULONG flags,...);
-
- BOOL get_files_to_compare(Compare_Data *data,char *path1,char *name1,\
- char *path2,char *name2);
- BOOL get_s_twice(Compare_Data *data,ResNode *rn1,char *path1,char *name1,
- char *path2,char *name2);
- BOOL get_s_and_d(Compare_Data *data,ResNode *rn1,char *path1,char *name1,
- char *path2,char *name2);
-
- BOOL open_files_to_compare(Compare_Data *data);
- LONG compare_files(Compare_Data *data);
-
- BOOL report_num_diffs(Compare_Data *data,LONG diffbytes);
- void report_full_display(Compare_Data *data);
- BOOL outrepline(Compare_Data *data,BPTR outfile,char *f1block,char *f2block,\
- LONG dobytes, LONG donebytes,char *disline,char *hex1,char *hex2,
- char *asc1,char *asc2);
-
- struct Window *getListerWindow(Compare_Data *data);
- struct Screen *getDOpusScreen(Compare_Data *data);
-
- void sendExtCmd_nr(Compare_Data *data,char *cmdstring,struct command_packet *cpp);
-
- void copyword(char *dest,char *source);
- void copywordquoted(char *dest,char *source);
-
- FuncArgs *parseArgs(Compare_Data *data,char *args);
- void freeArgs(FuncArgs *fa);
-