source: SH_SHM/trunk/source/gcf/gcfquickdump.c @ 1237

Revision 16, 2.2 KB checked in by marcus, 15 years ago (diff)

r1 | svn | 2007-12-13 11:10:29 +0100 (Do, 13 Dez 2007) | 2 lines

Initial import

Line 
1
2/* file gcftest.c
3 *      =========
4 *
5 * version 1, 18-Oct-2003
6 *
7 * test module for GCF data
8 * K. Stammler, 18-Oct-2003
9 */
10
11
12#include <stdio.h>
13#include <string.h>
14#include "basecnst.h"
15#include "sysbase.h"
16#include "tcusrdef.h"
17#include "gcflib.h"
18
19
20
21int main( int argc, char *argv[] )
22{
23        /* local variables */
24        char     gcffile[cBcFileLth+1];  /* input GCF file */
25        FILE     *gcf;                   /* pointer to GCF file */
26        GcfRawHeaderT rhdr;              /* raw header */
27        GcfHeaderT hdr;                  /* decoded header */
28        int      i;                      /* counter */
29        char     str[cBcLineLth+1];      /* text string */
30        char     recend[cBcTimeLth+1];   /* end time of block */
31        char     lasttime[cBcTimeLth+1]; /* last block end time */
32        float    gaplth;                 /* length of data gap */
33        TSyStatus status;                /* return status */
34
35        /* executable code */
36
37        if  (argc != 2)  {
38                fprintf( stderr, "Usage: %s <inpfile>\n", argv[0] );
39                return 1;
40        } /*endif*/
41
42        /* get parameters */
43        strcpy ( gcffile, argv[1] );
44
45        status = cBcNoError;
46
47        GcfSetTapcode( 2, "HH", &status );
48        if  (SySevere(&status))  err_writemsg( status, "setting tapcode", TRUE );
49
50        gcf = fopen( gcffile, "r" );
51        if  (gcf == NULL)  {
52                fprintf( stderr, "%s: cannot open input file %s\n", argv[0], gcffile );
53                return 1;
54        } /*endif*/
55
56        *lasttime = '\0';
57        gaplth = 0.0;
58
59        FOREVER  {
60
61                GcfReadRawHeader( gcf, &rhdr, &status );
62                if  (status == GcfERR_EOF_FOUND)  {
63                        status = cBcNoError;
64                        break;
65                } /*endif*/
66                if  (SySevere(&status))  err_writemsg( status, "error reading header", TRUE );
67
68                GcfDecodeHeader( &rhdr, &hdr, &status );
69                if  (SySevere(&status))
70                        err_writemsg( status, "error reading header", TRUE );
71
72                /* check for data gap */
73                tc_tadd( hdr.blktime, (float)(hdr.numrec*hdr.cmpcode/hdr.smprate),
74                        recend, &status );
75                if  (SySevere(&status))
76                        err_writemsg( status, "error computing end time", TRUE );
77                if  (*lasttime != '\0')
78                        gaplth = tc_tdiff( hdr.blktime, lasttime, &status );
79
80                GcfPrintHeader( stdout, &hdr );
81                if  (gaplth == 0.0)  {
82                        printf( " cont" );
83                } else {
84                        printf( " %4.1f", gaplth );
85                } /*endif*/
86                printf( "\n" );
87
88                GcfSkipDataBlock( gcf, &rhdr );
89
90                strcpy( lasttime, recend );
91
92        } /*endwhile*/
93
94        fclose( gcf );
95
96        return 0;
97
98} /* end of main */
Note: See TracBrowser for help on using the repository browser.