37 #include <lal/ConfigFile.h>
68 struct _finddata_t entry;
72 const CHAR *ptr1, *ptr2;
75 CHAR **filelist = NULL;
76 UINT4 numFiles = 0, newNumFiles = 0;
80 CHAR *thisFname = NULL;
84 #define FILE_SEPARATOR ';'
89 ptr1 = (
const CHAR * )globstring;
94 namelen = ptr2 - ptr1;
95 if ( ( thisFname =
LALRealloc( thisFname, ( namelen + 1 ) *
sizeof(
CHAR ) ) ) == NULL ) {
96 for (
j = 0;
j < numFiles;
j++ ) {
104 strncpy( thisFname, ptr1, namelen );
105 thisFname[namelen] =
'\0';
112 newNumFiles = numFiles + ret->
length;
114 if ( ( filelist =
LALRealloc( filelist, ( newNumFiles ) *
sizeof(
CHAR * ) ) ) == NULL ) {
121 filelist[numFiles +
j] = ret->
data[
j];
125 numFiles = newNumFiles;
127 for (
j = 0;
j < numFiles;
j++ ) {
145 newNumFiles = numFiles + ret->
length;
147 if ( ( filelist =
LALRealloc( filelist, ( newNumFiles ) *
sizeof(
CHAR * ) ) ) == NULL ) {
153 filelist[numFiles +
j] = ret->
data[
j];
157 numFiles = newNumFiles;
163 #define LIST_PREFIX "list:"
166 CHAR *listfname = NULL;
181 if ( numFiles == 0 ) {
187 if ( ( filelist =
LALRealloc( filelist, numFiles *
sizeof(
CHAR * ) ) ) == NULL ) {
194 for (
j = 0;
j < numFiles; ++
j ) {
198 #define FILE_PREFIX "file://localhost/"
204 #define FILE_PREFIX "file:///"
211 if ( ( filelist[
j] =
LALCalloc( 1, strlen( ptr1 ) + 1 ) ) == NULL ) {
222 strcpy( filelist[
j], ptr1 );
239 #define DIR_SEPARATOR '/'
241 #define DIR_SEPARATOR '\\'
248 dirlen = ( size_t )( ptr1 - globstring ) + 1;
249 if ( ( dname =
LALCalloc( 1, dirlen ) ) == NULL ) {
252 strncpy( dname, globstring, dirlen );
253 dname[dirlen - 1] =
'\0';
257 if ( ( fpattern =
LALCalloc( 1, strlen( ptr1 ) + 1 ) ) == NULL ) {
261 strcpy( fpattern, ptr1 );
265 if ( ( dname =
LALCalloc( 1, 2 ) ) == NULL ) {
268 strcpy( dname,
"." );
270 if ( ( fpattern =
LALCalloc( 1, strlen( globstring ) + 1 ) ) == NULL ) {
274 strcpy( fpattern, globstring );
280 if ( ( dir = opendir( dname ) ) == NULL ) {
286 if ( ( ptr3 = (
CHAR * )
LALMalloc( strlen( dname ) + 3 ) ) == NULL ) {
289 sprintf( ptr3,
"%s\\*", dname );
290 dir = _findfirst( ptr3, &entry );
300 while ( ( entry = readdir( dir ) ) != NULL )
306 thisFname = entry->d_name;
308 thisFname = entry.name;
312 if (
amatch( thisFname, fpattern )
314 && strcmp( thisFname,
"." ) && strcmp( thisFname,
".." ) ) {
317 if ( ( filelist =
LALRealloc( filelist, numFiles *
sizeof(
CHAR * ) ) ) == NULL ) {
323 namelen = strlen( thisFname ) + strlen( dname ) + 2 ;
325 if ( ( filelist[ numFiles - 1 ] =
LALCalloc( 1, namelen ) ) == NULL ) {
326 for (
j = 0;
j < numFiles;
j++ ) {
335 sprintf( filelist[numFiles - 1],
"%s%c%s", dname,
DIR_SEPARATOR, thisFname );
341 while ( _findnext( dir, &entry ) == 0 );
361 if ( ( filelist =
LALRealloc( filelist, numFiles *
sizeof(
CHAR * ) ) ) == NULL ) {
364 namelen = strlen( globstring ) + 1;
365 if ( ( filelist[ numFiles - 1 ] =
LALCalloc( 1, namelen ) ) == NULL ) {
369 strcpy( filelist[numFiles - 1], globstring );
373 if ( numFiles == 0 ) {
380 for (
j = 0;
j < numFiles;
j++ ) {
387 ret->
data = filelist;
390 if ( numFiles > 1 ) {
402 while ( ( *
c !=
'\0' ) && ( *
c !=
'*' ) && ( *
c !=
'?' ) && ( *
c !=
'[' ) ) {
405 return ( *
c !=
'\0' );
449 if ( !*
str && *
p !=
'*' ) {
453 switch (
c = *
p++ ) {
456 while ( *
p ==
'*' ) {
464 if ( *
p !=
'?' && *
p !=
'[' && *
p !=
'\\' )
497 while ( !match && (
c = *
p++ ) ) {
530 if ( negate == match ) {
536 while ( *
p && *
p !=
']' ) {
548 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
#define __func__
log an I/O error, i.e.
static BOOLEAN is_pattern(const char *c)
static int amatch(char *str, char *p)
Internal SFT types and functions.
int XLALParseDataFile(LALParsedDataFile **cfgdata, const CHAR *fname)
void XLALDestroyParsedDataFile(LALParsedDataFile *cfgdata)
char char * XLALStringDuplicate(const char *s)
LALStringVector * XLALFindFiles(const CHAR *globstring)
Returns a list of filenames matching the input argument, which may be one of the following:
void XLALDestroyStringVector(LALStringVector *vect)
int XLALSortStringVector(LALStringVector *strings)
#define XLAL_ERROR_NULL(...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int int XLALPrintWarning(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK_NULL(assertion,...)
p
RUN ANALYSIS SCRIPT ###.