pxfile(3)

NAME
pxfile - Extended file opening with search path and optional extensions.

SYNOPSIS
#include pxfile.h
FILE* px_fopen(filename,mode,pattern,path,show)
char * filename;
char * mode;
char ** pattern;
char ** path;
int (*show)();
char **px_s2p(specification,seperator)
char *specification;
int seperator;

DESCRIPTION
The extended file opening routine allows to open a file like fopen(3) The file is searched on a path and additional modifications of the file name are possible. E.g. the addion of an extension or prepending a fixed prefix is posible. px_fopen() opens a file named filename with the mode mode which is the same as the mode used by fopen(3). path is a NULL terminated array of strings indicating the possible directories to search for the file. A value of NULL indicates that only the current directory should be examined. px_s2p() can be used to allocate and fill a path array form a simple string specification. pattern is a NULL terminated array of format specifications to be used with fprintf(3). Two strings are indicated with the special '%s'. The first '%s' is replaced by the directory name. The second '%s' is replaced by the file name given. A value of NULL is the same as
{ "%s/%s",
  NULL
}
The following example value of pattern shows how default extensions can be tried. First the pure file name is tried. Afterwards the extensions .tex and .TeX are tried.
{ "%s/%s",
  "%s/%s.tex",
  "%s/%s.TeX",
  NULL
}
show is a pointer to a function. This function is called before an attempt is made to open a file. The argument of the function is the complete file name as string. The open is tried only if show returns an integer different from 0. This function can be used to display the file names before trying to open. A value of NULL can be used to indicate that no such function should be used. px_s2p() constructs a pattern for px_fopen() from a specification. Memory is allocated to store the array and the strings contained. specification is a strings where the different directories are separated by the character seperator. If not enough memory is available NULL is returned. The memory allocated consists of one block which can be freed with free(3).

FILES
pxfile.h

SEE ALSO
fopen(3), fprintf(3), free(3)

DIAGNOSTICS
NULL is returned to indicate failure.

BUGS
Mainly UN*X type file names are supported.