/*
 * ALSIMPLE.H
 *
 *  Header file for ArchiveLib 2.0
 *
 *  Copyright (c) 1996 Greenleaf Software, Inc.
 *  All Rights Reserved
 *
 * DESCRIPTION
 *
 * This header file contains the definitions for the C/C++
 * simplified interface.  This interface consists of eight
 * functions and a structure definition, all of which are
 * found here.  The idea is that this interface lets you
 * manipulate PKZip archives containing files with little
 * or not knowledge about the depths of ArchiveLib.
 *
 * CLASS DEFINITIONS:
 *
 *  ALZipDir            : A description of a single entry in an ZIP
 *                        file. Some of the simplified interface
 *                        functions use an array of ALZipDir entries
 *                        to describe an archive.
 *
 *  ALSimpleMonitor     : The monitor used by the simplified interface
 *                        functions.  However, you don't have to know
 *                        anything about this monitor class, its use
 *                        is hidden.
 *
 * FUNCTIONS
 *
 *   ALFreeDir()
 *   ALReadDir()
 *   ALWriteDir()
 *   ALSetName()
 *   ALSetComment()
 *   ALCreate()
 *   ALAppend()
 *   ALExtract()
 *   ALDelete()
 *
 * REVISION HISTORY
 *
 *  February 14, 1996  2.0A : First release
 */

#if !defined( _ALSIMPLE_H )
#define _ALSIMPLE_H

#include "aldefs.h"
#include "monitor.h"

struct AL_CLASS_TYPE ALZipDir {
    char AL_DLL_FAR *name;      /* These two members are allocated using  */
    char AL_DLL_FAR *comment;   /* new char[].  Let the library take care */
                                /* of allocation and deletion.            */
    long compressed_size;
    long compressed_position;
    long size;
    long crc;
    short int mark;
    short int month;
    short int date;
    short int year;
    short int hour;
    short int minute;
    short int second;
    unsigned char r;
    unsigned char a;
    unsigned char s;
    unsigned char h;
    unsigned char d;
    unsigned char level;
};

typedef void (AL_DLL_FAR * CALLBACK_FN )( const char AL_DLL_FAR *file_name,
                                          int file_ratio,
                                          int job_ratio );

#if defined( __cplusplus )

/*
 * class ALSimpleMonitor
 *
 * DESCRIPTION
 *
 *  This class is used by the simplified interface functions as a monitor.
 *  For C and C++ programmers, the monitor simply calls a callback function
 *  supplied by the user.  VB and Delphi users see the monitor as an object
 *  that sends text messages to windows they are using as part of their
 *  user interface.
 *
 *  Regardless of the language you are using, this monitor class is hidden
 *  from you.  However, it is pretty simple, and the details of what it
 *  is doing may help you understand the simplified interfaces.
 *
 * DATA MEMBERS
 *
 *  mpCallbackFunction          : A pointer to a callback function that
 *                                the monitor will call from both
 *                                Progress() and ArchiveOperation().
 *
 *  mhTextWindow                : The text window where file names will
 *                                be sent from ArchiveOperation().
 *
 *  mhFileProgressWindow        : The text window where progress ratios
 *                                will be sent from Progress().
 *
 *  mhJobProgressWindow         : The text window were job ratios will be
 *                                sent from Progress().
 *
 * ALSimpleMonitor()     : The constructor, two versions
 * ~ALSimpleMonitor()    : The destructor.
 * Progress()            : The archiving file/job progress function
 * ArchiveOperation()    : The function called at key points in the
 *                         archiving routine.
 *
 * REVISION HISTORY
 *
 *  February 14, 1996  2.0A : First release
 */

class AL_CLASS_TYPE ALSimpleMonitor : public ALMonitor {  /* Tag public class */
/*
 * Constructors, destructors, and friend classes
 */
     public :
          AL_PROTO ALSimpleMonitor( CALLBACK_FN fn );
//
// Alternate constructor, used by VB and Delphi
//
#if defined( AL_VB ) || defined( AL_VB32 )
          AL_PROTO ALSimpleMonitor( HWND text_window,
                                    HWND file_progress_window,
                                    HWND job_progress_window );
#endif
          virtual AL_PROTO ~ALSimpleMonitor();
#if defined( AL_USING_DLL ) || defined( AL_BUILDING_DLL )
        void AL_DLL_FAR * AL_PROTO operator new( size_t size );
#endif
/*
 * The copy constructor and assignment operator do not exist.
 */
     protected :
          AL_PROTO ALSimpleMonitor( const ALSimpleMonitor AL_DLL_FAR & );
          ALSimpleMonitor AL_DLL_FAR & AL_PROTO operator=( const ALSimpleMonitor AL_DLL_FAR & );
/*
 * Member functions
 */
     protected :
          virtual void AL_PROTO Progress( long object_so_far,
                                          ALStorage AL_DLL_FAR & object );
          virtual void AL_PROTO
          ArchiveOperation( ALArchiveOperation operation,
                            ALArchive AL_DLL_FAR *archive,
                            ALEntry AL_DLL_FAR *job );
/*
 * Data Members
 */
    protected :
        CALLBACK_FN mpCallbackFunction;
#if defined( AL_VB ) || defined( AL_VB32 )
        HWND mhTextWindow;
        HWND mhFileProgressWindow;
        HWND mhJobProgressWindow;
#endif
     public :
          AL_CLASS_TAG( _ALSimpleMonitorTag );
};
#endif


#if defined( __cplusplus )
extern "C" {
#endif

AL_LINKAGE void AL_FUNCTION ALFreeDir( struct ALZipDir AL_DLL_FAR *z );
AL_LINKAGE struct ALZipDir AL_DLL_FAR * AL_FUNCTION
ALReadDir( char AL_DLL_FAR *filename,
           int AL_DLL_FAR *count,
           int AL_DLL_FAR *error );
AL_LINKAGE int AL_FUNCTION ALWriteDir( struct ALZipDir AL_DLL_FAR *z );
AL_LINKAGE void AL_FUNCTION ALSetName( struct ALZipDir AL_DLL_FAR *z,
                                       char AL_DLL_FAR *name );
AL_LINKAGE void AL_FUNCTION ALSetComment( struct ALZipDir AL_DLL_FAR *z,
                                          char AL_DLL_FAR *comment );
AL_LINKAGE int AL_FUNCTION ALCreate( char AL_DLL_FAR *name,
                                     char AL_DLL_FAR *file_list,
                                     int strip_path,
                                     CALLBACK_FN callback );
AL_LINKAGE int AL_FUNCTION ALAppend( char AL_DLL_FAR *archive_name,
                                     char AL_DLL_FAR *input_files,
                                     int strip_path,
                                     CALLBACK_FN callback );
AL_LINKAGE int AL_FUNCTION ALExtract( struct ALZipDir AL_DLL_FAR *z,
                                      int strip_path,
                                      CALLBACK_FN callback );
AL_LINKAGE int AL_FUNCTION ALDelete( struct ALZipDir AL_DLL_FAR *z,
                                     CALLBACK_FN callback );

#if defined( __cplusplus )
};
#endif

#endif