home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD2.mdf
/
c
/
library
/
mslang
/
fxexpand
/
doc
/
fexpand.doc
next >
Wrap
Text File
|
1993-03-22
|
9KB
|
266 lines
FILE TEMPLATE EXPANDER
A Shareware 'C' Utility Library
from
Joe Acunzo
10 Conifer Drive
Branford, CT 06405
1. WHAT IS IT ANYWAY?
2. INSTALLATION
3. WILDCARDING CHARACTERS
4. EXAMPLES
5. SORTING
6. 'C' FUNCTIONS
7. COMPILERS SUPPORTED
8. AUTOMATIC COMMAND LINE EXPANSION
9. REGISTERING
1. WHAT IS IT ANYWAY?
The File Template Expander (FTE) is a shareware library of 'C'
callable function to expand wildcard characters in filenames (i.e.
"file templates"). It is a more powerful expander than those
provided with most 'C' runtime libraries (i.e. Microsofts
"setargv"). Most 'C' runtime libraries only support wildcarding of
file names using the standard '*' and '?' characters (multiple and
single character matches respectively). Besides this support, FTE
also allows for wildcarding of directories names (0-N levels deep), a
"not" templating ability, and putting file templates into a file.
There is also the abililty to pass a string containing one or more
file templates and have that expanded as well.
In summary, FTE supports:
o 0-N characters matching (using '*')
o 1 character matching (using '?')
o directory name matching
o any level of directories deep
o not template ability
o file templates in a file
o file templates in a string
o sorts matches
o setargv replacement
2. INSTALLATION
FTE is distributed as a ZIP file. It should be unzipped with the -d
switch which automatically creates subdirectories that are stored in
the ZIP file.
3. WILDCARDING CHARACTERS
Besides the astericks ('*') and question mark ('?'), FTE also
considers the pound sign ('#'), commercial at sign ('@'), and
apostrophe (') specially. Here is summary of these characters:
* match 0 or more characters
? match exactly one character
# match 0 or more directories
!<template> don't match <template>
@<filename> <filename> contains additional templates.
'....' any string enclosed in single quotes is not expanded
4. EXAMPLES
Some examples will help illustrate the power of FTE. To the left are
file templates and to the right are files that would match:
File Template Possible Matches
--------------------------------------------------
*.c a.c
b.c
a?.c a1.c
a2.c
\rd\fexp*\*.c \rd\fexp\a.c
\rd\fexpand\a.c
\rd\fexp*\#\*.c \rd\fexp\a.c
\rd\fexpand\a.c
\rd\fexpnew\a.c
\rd\fexp\src\a.c
\rd\fexpand\src\old\a.c
\#\*.* <matches ALL files on the current drive>
D:\#\help.exe <matches ALL help.exe files on the D: drive>
'\rd\f*\a.c' \rd\f*\a.c <single quotes prevents expansion>
If the file FILE.LST contained these three lines:
*.C *.H
MAKEFILE
*.DOC
then the following would match:
@file.lst a.c
b.c
exp.doc
makefile
z.h
If there where three files as follows: X1.C, X2.C, and Y.C then:
*.c !x*.c y.c
For some coding examples of using the File Template Expander see the
files example1.c and example2.c (mscbuild.bat compiles/links these
examples for Microsoft C and bccbuild compiles/links them for Borland C).
5. SORTING
All files that match a specified template are sorted, but not merged
across templates. For example:
*.c *.h
would result in all C files sorted and then all H files sorted separately.
If the desired result is to sort across all templates (that is, merge
all sorts), then the "merge flag" must be set to TRUE. Duplicate
file expansions are ignored. For example, abc.c and *.c would yield
only one abc.c.
With the merge option, ALL arguments are sorted in. This may not be
the desired result if an argument given is not a file name since it
will be sorted in with all of the matching file names. For example,
if you would like to expand the following command line:
/C *.c /H *.h
and you had the "merge flag" set to TRUE, then the /C and the /H
switches would be sorted in with all of the matches for *.c and *.h.
6. 'C' FUNCTIONS
This section lists the callable 'C' functions in the library.
Fexpand.h contains prototypes for the functions listed here.
NOTE: If you would rather have the command line expanded before main()
is ever called, see section 8.AUTOMATIC COMMAND LINE EXPANSION.
FUNCTIONS:
char **FileTemplateExpand(
int count, char *templates[],
int ignore_first, int merge_all, int *new_count);
char **FileTemplateExpandString(
char *string,
int ignore_first, int merge_all, int *new_count);
char **FileTemplateExpandFilter(
int (*filter)(char *),
int count, char *templates[], int ignore_first,
int merge_all, int *new_count);
char **FileTemplateExpandFilterString(
int (*filter)(char *),
char *string,
int ignore_first, int merge_all, int *new_count);
PASSED ARGUMENTS:
count Number of elements in the 'templates' array.
templates An array of pointers to strings that may (or may not)
contain file templates to be expanded.
int ignore_first If TRUE, don't try and expand file_templates[0].
Just put in into the new template array at position 0.
(Usefull if you are passing argv where argv[0]
is the program name and not an argument to expand.)
int merge_all If TRUE, then matches to all templates are sorted together.
string A string containing space and tab delimited file templates.
Double quotes may be used to embed white space.
(For example, A "B C" D are four arguments.)
filter A pointer to a function that is called with every match.
It is passed the full path to the matching file name.
If it returns TRUE, the file is included. If it returns
FALSE, the file is discarded.
RETURNED ARGUMENTS:
int new_count Count of pointers in the returned array of pointers.
<return> Pointer to an array of pointers that contain the expansion.
The returned array of pointers and everything it points at is
allocated on the running programs heap (using malloc). When no
longer needed it can be freed up using the standard free() function.
As you can see from the functions above, there are basically two ways
to call it - with an array of pointers and a count (ala argc/argv) or
with a string. Then, you can decide if you would like a "filter"
function which can "weed out" unwanted files.
For some coding examples of using the File Template Expander see the
files example1.c and example2.c (mscbuild.bat compiles/links these
examples for Microsoft C and bccbuild compiles/links them for Borland C).
7. COMPILERS SUPPORTED
The Microsoft and Borland C compilers are supported. There is a
library for each of the small, compact, medium, and large models for
each compiler as follows:
Microsoft Borland
------------------------------------
Small msc\Sfexpand.lib bcc\Sfexpand.lib
Medium msc\Mfexpand.lib bcc\Mfexpand.lib
Compact msc\Cfexpand.lib bcc\Cfexpand.lib
Large msc\Lfexpand.lib bcc\Lfexpand.lib
Source code is available (which is in an ANSI standard format). See
the information about registering.
8. AUTOMATIC COMMAND LINE EXPANSION
For the Microsoft compiler/library, there is the ability to have the
command line automatically expanded (i.e. argv[] is expanded before
ever being passed to main().) With FTE, this is possible by linking
with the appropriate Xsetargv.obj module where 'X' is one of S, M, C,
or L for Small, Medium, Compact, and Large model respectively. The
batch file src\mscbuild.bat gives an example of building such a
program.
9. REGISTERING
FTE is shareware, and as such, should be registered if you intend to
continue to use it. For a description of the shareware concept, see
the file SHARWAR.DOC. By registering, you will receive the latest
version and a version which does not have that annoying prompt that
the unregistered version has. Source code is also available. To
register, see the file REGISTER.DOC.