LALApps 10.1.0.1-eeff03c
extr.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Duncan Brown
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 <config.h>
21#include <stdio.h>
22
23#include <FrameL.h>
24
25int main( int argc, char *argv[] )
26{
27 char history[] = "Created by " PACKAGE "-" VERSION ".";
28 struct FrFile *frfileout;
29 struct FrFile *frfilein;
30 struct FrameH *frameout;
31 struct FrameH *framein;
32 char *fnameout;
33 char *fnamein;
34 char **channels;
35 int nchannels;
36
37 if ( argc < 4 )
38 {
39 fprintf( stderr, "usage: %s outfile infile channels\n", argv[0] );
40 return 1;
41 }
42
43 fnameout = argv[1];
44 fnamein = argv[2];
45 channels = &argv[3];
46 nchannels = argc - 3;
47
48 FrLibIni( NULL, stderr, 0 );
49
50 if ( ! ( frfilein = FrFileINew( fnamein ) ) )
51 return fputs( "input file not found!\n", stderr ), 1;
52 if ( ! ( frfileout = FrFileONewH( fnameout, 0, history ) ) )
53 return fputs( "could not open output file!\n", stderr ), 1;
54
55 while ( ( framein = FrameRead( frfilein ) ) )
56 {
57 int chan;
58 if ( ! ( frameout = FrameHNew( framein->name ) ) )
59 return fputs( "allocation error!\n", stderr ), 1;
60 frameout->run = framein->run;
61 frameout->frame = framein->frame;
62 frameout->dataQuality = framein->dataQuality;
63 frameout->GTimeS = framein->GTimeS;
64 frameout->GTimeN = framein->GTimeN;
65 frameout->ULeapS = framein->ULeapS;
66 /* frameout->localTime = framein->localTime; */
67 frameout->dt = framein->dt;
68 for ( chan = 0; chan < nchannels; ++chan )
69 {
70 struct FrAdcData *adc;
71 if ( ! ( adc = FrAdcDataFind( framein, channels[chan] ) ) )
72 return fprintf( stderr, "channel %s not found!\n", channels[chan] ), 1;
73 if ( ! FrAdcDataCopy( adc, frameout ) )
74 return fputs( "allocation error!\n", stderr ), 1;
75 }
76 FrameWrite( frameout, frfileout );
77 FrameFree( frameout );
78 FrameFree( framein );
79 }
80
81 FrFileOEnd( frfileout );
82 FrFileIEnd( frfilein );
83
84 return 0;
85}
#define fprintf
int main(int argc, char *argv[])
Definition: extr.c:25
string PACKAGE