Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
SFTvalidate.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Karl Wette
3 * Copyright (C) 2004, 2005 Bruce Allen
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with with program; see the file COPYING. If not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301 USA
19 */
20
21/**
22 * \author Bruce Allen
23 * \file
24 * \ingroup lalpulsar_bin_SFTTools
25 * \brief
26 * Verify that a set of SFT files is valid
27 *
28 * The exit status will be zero if all SFTs are valid. The exit status
29 * will be non-zero if any of the SFTs was invalid. grep SFTE
30 * SFTReferenceLibrary.h will show the return values.
31 */
32
33#include <math.h>
34#include <stdio.h>
35#include <string.h>
36#include <stdlib.h>
37#include <errno.h>
38#include <lal/LALStdlib.h>
39#include <lal/SFTReferenceLibrary.h>
40#include <lal/LALPulsarVCSInfo.h>
41
42int main( int argc, char **argv )
43{
44
45 if ( argc == 2 && ( strcmp( argv[1], "-v" ) == 0 || strcmp( argv[1], "--version" ) == 0 ) ) {
46 fprintf( stdout, "%s: %s %s\n", argv[0], lalPulsarVCSInfo.vcsId, lalPulsarVCSInfo.vcsStatus );
47 return EXIT_SUCCESS;
48 }
49
50 if ( argc == 2 && ( strcmp( argv[1], "-h" ) == 0 || strcmp( argv[1], "--help" ) == 0 ) ) {
51 fprintf( stdout, "usage:\n" );
52 fprintf( stdout, " %s *.sft\n", argv[0] );
53 fprintf( stdout, " ls *.sft | %s\n", argv[0] );
54 fprintf( stdout, " find -name '*.sft' | %s >valid-sfts.txt 2>errors.log\n", argv[0] );
55 return EXIT_SUCCESS;
56 }
57
58 int errcode = EXIT_SUCCESS;
59
60 if ( argc > 1 ) {
61
62 /* loop over all file names on command line */
63 for ( int i = 1; i < argc; ++i ) {
64 /* we on purpose do not call the XLAL version here,
65 * so as to have the same stdout printing
66 * and return code handling as older versions of this executable.
67 */
68 if ( ValidateSFTFile( argv[i] ) != 0 ) {
69 errcode = EXIT_FAILURE;
70 } else {
71 fprintf( stdout, "%s\n", argv[i] );
72 fflush( stdout );
73 }
74 }
75
76 } else {
77
78 char line[2048];
79
80 /* loop over all file names from standard input */
81 while ( fgets( line, sizeof( line ) - 1, stdin ) != NULL ) {
82 size_t len = strlen( line );
83 if ( len > 1 ) {
84 line[len - 1] = '\0';
85 /* we on purpose do not call the XLAL version here,
86 * so as to have the same stdout printing
87 * and return code handling as older versions of this executable.
88 */
89 if ( ValidateSFTFile( line ) != 0 ) {
90 errcode = EXIT_FAILURE;
91 } else {
92 fprintf( stdout, "%s\n", line );
93 fflush( stdout );
94 }
95 }
96 }
97
98 }
99
100 return errcode;
101
102}
const LALVCSInfo lalPulsarVCSInfo
VCS and build information for LALPulsar.
int main(int argc, char **argv)
Definition: SFTvalidate.c:42
#define fprintf
int ValidateSFTFile(const char *fname)
Verify that the contents of a SFT file are valid.
const char *const vcsStatus
const char *const vcsId