NAME
expand - expand filename specification

SYNOPSIS
int expand (spec,buffer,bufsize);
char *spec,**buffer;
int bufsize;

DESCRIPTION
Expand takes a file specification, and expands it into a set of
filenames by resolving the characters ’*’, ’?’, ’[’, ’{’, and ’~’
in the same way as the shell does.

You must provide buffer, an array of string pointers (char *), and
you tell how big this array is in bufsize. Expand will compute the
corresponding filenames, and fill up the entries of buffer, putting
ponters to malloc’d strings into the slots.

The value returned by expand is the number of filenames found. If
any error occurs, the value returned will be -1. In such a case,
not all of the files were discoverable. If too many files are
found, then the value returned will be bufsize + 1; you should try
again with a bigger buffer.

SEE ALSO
sh(1), getwd(3), malloc(3), path(3)

DIAGNOSTICS
Returns -1 on error; bufsize + 1 if too many files are found.

BUGS
Error recovery is too drastic; it should continue to find all the
names that can be found. Also, if an error occurs, the strings
malloc’d so far will never be garbage-collected.

Within braces {...}, the substrings may contain other meta-
characters but may not contain slashes / or additional braces {}.