LAL 7.7.0.1-eeff03c
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
25int main( int argc, char *argv[] )
26{
27 if ( argc > 1 && ( !strcmp(argv[1],"-h") || !strcmp(argv[1],"--help") ) ) {
28 printf("usage: %s <filenames>\n", argv[0]);
29 return 0;
30 }
31 LALFILE *outfile = NULL;
32 LALCache *cache;
33 int arg = 1;
35 if ( argc > 1 && ! strcmp(argv[1],"-o") ) {
36 outfile = XLALFileOpen( argv[2], "w" );
37 arg += 2;
38 }
39 cache = XLALCacheGlob( NULL, argc == 1 ? NULL : argv[arg++] );
40 for ( ; arg < argc; ++arg ) {
41 LALCache *tmp = cache;
42 LALCache *add;
43 add = XLALCacheGlob( NULL, argv[arg] );
44 cache = XLALCacheMerge( tmp, add );
45 XLALDestroyCache( add );
46 XLALDestroyCache( tmp );
47 }
48 XLALCacheFileWrite( outfile ? outfile : LALSTDOUT, cache );
49 XLALFileClose( outfile );
50 XLALDestroyCache( cache );
52 return 0;
53}
void LALCheckMemoryLeaks(void)
Definition: LALMalloc.c:784
int main(int argc, char *argv[])
Definition: cache.c:25
int XLALFileClose(LALFILE *file)
Definition: FileIO.c:423
LALFILE * XLALFileOpen(const char *path, const char *mode)
Definition: FileIO.c:404
#define LALSTDOUT
Definition: FileIO.h:55
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
LALCache * XLALCacheMerge(const LALCache *cache1, const LALCache *cache2)
Returns a new LALCache structure that is the merge of two.
Definition: LALCache.c:201
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
Sets the error handler to a new handler and returns the old handler.
Definition: XLALError.c:372
void XLALExitErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that calls exit.
Definition: XLALError.c:607
The LALCache structure is an array of entries.
Definition: LALCache.h:63