LAL  7.5.0.1-8083555
cache.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007 Jolien Creighton
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19 
20 #include <string.h>
21 #include <lal/LALStdlib.h>
22 #include <lal/LALCache.h>
23 #include <lal/FileIO.h>
24 
25 int main( int argc, char *argv[] )
26 {
27  LALFILE *outfile = NULL;
28  LALCache *cache;
29  int arg = 1;
31  if ( argc > 1 && ! strcmp(argv[1],"-o") ) {
32  outfile = XLALFileOpen( argv[2], "w" );
33  arg += 2;
34  }
35  cache = XLALCacheGlob( NULL, argc == 1 ? NULL : argv[arg++] );
36  for ( ; arg < argc; ++arg ) {
37  LALCache *tmp = cache;
38  LALCache *add;
39  add = XLALCacheGlob( NULL, argv[arg] );
40  cache = XLALCacheMerge( tmp, add );
41  XLALDestroyCache( add );
42  XLALDestroyCache( tmp );
43  }
44  XLALCacheFileWrite( outfile ? outfile : LALSTDOUT, cache );
45  XLALFileClose( outfile );
46  XLALDestroyCache( cache );
48  return 0;
49 }
void LALCheckMemoryLeaks(void)
Definition: LALMalloc.c:784
int main(int argc, char *argv[])
Definition: cache.c:25
int XLALFileClose(LALFILE *file)
Definition: FileIO.c:389
LALFILE * XLALFileOpen(const char *path, const char *mode)
Definition: FileIO.c:370
#define LALSTDOUT
Definition: FileIO.h:55
LALCache * XLALCacheMerge(const LALCache *cache1, const LALCache *cache2)
Returns a new LALCache structure that is the merge of two.
Definition: LALCache.c:201
void XLALDestroyCache(LALCache *cache)
Destroys a LALCache structure.
Definition: LALCache.c:172
LALCache * XLALCacheGlob(const char *dirstr, const char *fnptrn)
Globs a directory and construct LALCache from matching entries.
Definition: LALCache.c:314
int XLALCacheFileWrite(LALFILE *fp, const LALCache *cache)
Writes a LALCache structure to output LALFILE.
Definition: LALCache.c:382
void XLALExitErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that calls exit.
Definition: XLALError.c:607
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
Sets the error handler to a new handler and returns the old handler.
Definition: XLALError.c:372
The LALCache structure is an array of entries.
Definition: LALCache.h:63