Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALFrame 3.0.7.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cksum.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Duncan Brown, Jolien Creighton, Robert Adam Mercer
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/**
21 * @defgroup lalfr_cksum lalfr-cksum
22 * @ingroup lalframe_programs
23 *
24 * @brief Validates the checksum of a frame file
25 *
26 * ### Synopsis
27 *
28 * lalfr-cksum file [files ...]
29 *
30 * ### Description
31 *
32 * The `lalfr-cksum` utility validates the checksum on the specified files to
33 * the standard output. The file operands are processed in command-line order.
34 * If file is a single dash (`-`) or absent, `lalfr-cksum` reads from the
35 * standard input.
36 *
37 * ### Exit Status
38 *
39 * The `lalfr-cksum` utility exits 0 on success, and >0 if one or more of the
40 * frame files have invalid checksums.
41 *
42 * ### Example
43 *
44 * The command:
45 *
46 * lalfr-cksum file1.gwf file2.gwf
47 *
48 * will validate frame files `file1.gwf` and `file2.gwf`.
49 */
50
51#include <stdio.h>
52#include <stdlib.h>
53#include <lal/LALFrameU.h>
54
55#define FAILURE(...) do { fprintf(stderr, __VA_ARGS__); exit(99); } while (0)
56
57int main(int argc, char *argv[])
58{
59 int retval = 0;
60
61 if (argc == 1) {
62 fprintf(stderr, "usage: %s framefiles\n", argv[0]);
63 return 1;
64 }
65
66 while (--argc > 0) {
67 char *fname = *++argv;
68 LALFrameUFrFile *frfile;
69 int valid;
70
71 frfile = XLALFrameUFrFileOpen(fname, "r");
72 if (!frfile)
73 FAILURE("file %s not found\n", fname);
74
75 valid = XLALFrameUFileCksumValid(frfile);
76 retval += !valid;
77
78 fprintf(stdout, "%svalid checksum for %s\n", valid ? "" : "in",
79 fname);
80
82 }
83
84 return retval;
85}
#define fprintf
int main(int argc, char *argv[])
Definition: cksum.c:57
#define FAILURE(...)
Definition: cksum.c:55
LALFrameUFrFile * XLALFrameUFrFileOpen(const char *filename, const char *mode)
Open a frame file FrFile stream.
Definition: LALFrameU.c:130
void XLALFrameUFrFileClose(LALFrameUFrFile *stream)
Close a FrFile stream.
Definition: LALFrameU.c:125
int XLALFrameUFileCksumValid(LALFrameUFrFile *stream)
Use checksum to determine if FrFile stream is valid.
Definition: LALFrameU.c:135