campo-sirio/arch/cxl_wild.cpp

185 lines
5.2 KiB
C++
Executable File

//
// CXL_UTIL.CPP
//
// Source file for ArchiveLib 1.0
//
// Copyright (c) Greenleaf Software, Inc. 1994
// All Rights Reserved
//
// CONTENTS
//
// newALExpander()
// ALExpanderGetNextFile()
// ALExpanderGetNextFileVB()
// deleteALExpander()
//
// DESCRIPTION
//
// This file contains the C and VB interface functions for using
// the ALWildCardExpander class. This consists of only a
// constructor, destructor, and a Get Next File function.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
//
#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
//
//
// 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_BUILDING_DLL ) && defined( AL_WINDOWS_GUI ) && !defined( AL_FLAT_MODEL )
//
// 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;
}