archivelib-sys 0.2.0

An implementaton(in C++) of the Greenleaf ArchiveLib compression/decompression algorithm
Documentation
/*
Copyright 1990-2008 Light Infocon Tecnologia S/A

Este arquivo é parte do programa LightBase - Banco de Dados Textual Documental

O LightBase é um software livre; você pode redistribui-lo e/ou modifica-lo dentro
dos termos da Licença Pública Geral GNU como publicada pela Fundação do Software
Livre (FSF); na versão 2 da Licença.

Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO
EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.

Você deve ter recebido uma cópia da Licença Pública Geral GNU versao 2, sob o
título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do
Software Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/


#include "arclib.h"
#pragma hdrstop

#include "al.h"
#include "alcxl.h"

//
// extern "C" hALExpander newALExpander( char *wild_spec,
//                                       int traverse_flag,
//                                       ALCase name_case )
//
// ARGUMENTS:
//
//  wild_spec     : A sequence of wild card file specifications separated
//                  by spaces or semicolons.
//
//  traverse_flag : set this guy if you want the wild card expansion
//                  to traverse all subdirectories.
//
//  name_case     : How the names will be returned, AL_UPPER, AL_MIXED,
//                  or AL_LOWER.
//
//
// RETURNS
//
//  Returns a handle for (pointer to) a newly constructed
//  ALWildCardExpander object.
//
// DESCRIPTION
//
//  This ctor is used to create a new ALWildCardExpander object from
//  C or VB.  It operates identically to the wild card expander
//  constructors defined in WILDCARD.CPP.
//
//  You don't get to see much of the wild card expander code in this
//  module, since this is just a translation layer.  Look at WILDCARD.CPP
//  for lots of neat stuff.
//
//  This function passes the arguments it receives to the constructor
//  with no changes.  It then casts the return value to the appropriate
//  handle type, and returns it to the calling procedure.
//
// REVISION HISTORY
//
//   May 25, 1994  1.0A  : First release
//

extern "C" hALExpander AL_FUNCTION newALExpander( char *wild_spec,
                                                  int recurse_flag,
                                                  ALCase name_case )
{
    ALWildCardExpander *expander;

    expander = new ALWildCardExpander( wild_spec, recurse_flag, name_case );
    return (hALExpander) expander;
}

// C TRANSLATION FUNCTION
//
// extern "C" char * ALExpanderGetNextFile( hALExpander this_object )
//
// VB TRANSLATION FUNCTION
//
// extern "C" long ALExpanderGetNextFileVB( hALExpander this_object )
//
// ARGUMENTS:
//
//  this_object :  A handle for (pointer to) an ALWildCardExpander
//                 object.
//
// RETURNS
//
//  A string containing the next expanded wild card generated by
//  the wild card engine.  Note that under C, you will get a pointer
//  to a string that is residing inside the ALWildCardExpander
//  object, which you are free to copy or duplicate.  The VB translation
//  function actually creates a new string using the ALCreateVBString
//  function.
//
// DESCRIPTION
//
//  This function provides a C or VB translation layer that allows you to
//  access the ALWildCardExpander::GetNextFile() function.  The function
//  operators by first checking the single handle argument for correct
//  type (in debug mode).  It then casts the handle to an object pointer,
//  and uses that to invoke the member function.  Under C, the return from
//  the member function is passed directly back to the calling routine.
//  Under VB, the return is first converted to a Visual Basic string, then
//  returned.
//
//  To see the details of ALWildCardExpander::GetNextFile(), look at
//  WILDCARD.CPP.
//
// REVISION HISTORY
//
//   May 25, 1994  1.0A   : First release
//
//   August 10, 1994 1.0B : Combined a bunch of #ifdefs into a single test
//                          against AL_VB

//
// The C translation layer.
//
extern "C" char * AL_FUNCTION
ALExpanderGetNextFile( hALExpander this_object )
{
    AL_ASSERT_OBJECT( this_object, ALWildCardExpander, "ALExpanderGetNextFile" );
    return ( (ALWildCardExpander *) this_object )->GetNextFile();
}

#if defined( AL_VB )
//
// VB translation layer.
//
extern "C" long AL_FUNCTION
ALExpanderGetNextFileVB( hALExpander this_object )
{
    AL_ASSERT_OBJECT( this_object, ALWildCardExpander, "ALExpanderGetNextFileVB" );
    char _far *ret_guy = ( (ALWildCardExpander *) this_object )->GetNextFile();
    if ( ret_guy == 0 )
        ret_guy = "";
    return ALCreateVBString( ret_guy, (unsigned short int) _fstrlen( ret_guy ) );
}
#endif

//
// extern "C" void deleteALExpander( hALExpander this_object )
//
// ARGUMENTS:
//
//  this_object :  A handle for (pointer to) an ALWildCardExpander
//                 object.
//
// RETURNS
//
//  Nothing, this is a destructor.
//
// DESCRIPTION
//
//  This function provides a C or VB translation layer that allows you to
//  access the ALWildCardExpander destructor.  The function works
//  by first checking the single handle argument for correct
//  type (in debug mode).  It then casts the handle to an object pointer,
//  and uses that to invoke the destructor.
//
//  To see the details of the ALWildCardExpander destructor, look at
//  WILDCARD.CPP.
//
// REVISION HISTORY
//
//   May 25, 1994  1.0A  : First release
//

extern "C" void AL_FUNCTION deleteALExpander( hALExpander this_object )
{
    AL_ASSERT_OBJECT( this_object, ALWildCardExpander, "deleteALExpander" );
    delete (ALWildCardExpander *) this_object;
}