source: SH_SHM/trunk/util/emscev2oed.c @ 92

Revision 16, 2.5 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 emscev2oed.c
3 *      ============
4 *
5 * version 1, 1-Oct-2005
6 *
7 * Convert output of EMSC page (get_latest_emsc_evemts.csh) to
8 * SH/SHM oed format.
9 * K. Stammler, 1-Oct-2005
10 */
11
12/*
13 *
14 *  SeismicHandler, seismic analysis software
15 *  Copyright (C) 1996,  Klaus Stammler, Federal Institute for Geosciences
16 *                                       and Natural Resources (BGR), Germany
17 *
18 *  This program is free software; you can redistribute it and/or modify
19 *  it under the terms of the GNU General Public License as published by
20 *  the Free Software Foundation; either version 2 of the License, or
21 *  (at your option) any later version.
22 *
23 *  This program is distributed in the hope that it will be useful,
24 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26 *  GNU General Public License for more details.
27 *
28 *  You should have received a copy of the GNU General Public License
29 *  along with this program; if not, write to the Free Software
30 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
31 *
32 */
33
34
35#include <stdio.h>
36#include <string.h>
37
38#define STRLTH 132
39
40
41int main( int argc, char *argv[] )
42{
43        /* local variables */
44        char     fname[STRLTH+1];     /* name of input file */
45        char     line[STRLTH+1];      /* current line of file */
46        FILE     *fp;                 /* pointer to input file */
47
48        /* executable code */
49
50        if  (argc != 2)  {
51                fprintf( stderr, "Usage: emscev2oed <inputfile>\n" );
52                return 1;
53        } /*endif*/
54
55        /* get parameters */
56        if  (strlen(argv[1]) > STRLTH)  {
57                fprintf( stderr, "%s: filename too long.  Abort.\n", argv[0] );
58                return 1;
59        } /*endif*/
60        strcpy( fname, argv[1] );
61
62        fp = fopen( fname, "r" );
63        if  (fp == NULL)  {
64                fprintf( stderr, "%s: cannot open input file %s.  Abort.\n",
65                        argv[0], fname );
66                return 1;
67        } /*endif*/
68
69        while  (fgets(line,STRLTH,fp) != NULL)  {
70                if  (strlen(line) < 54)  continue;
71                if  (line[4] != '/')  continue;
72                if  (line[7] != '/')  continue;
73                if  (line[10] == ' ')  line[10] = '_';
74                if  (line[23] == ' ')  line[23] = '0';
75                if  (line[29] == 'S')  line[22] = '-';
76                line[29] = ' ';
77                if  (line[31] == ' ')  line[31] = '0';
78                if  (line[32] == ' ')  line[32] = '0';
79                if  (line[38] == 'W')  line[30] = '-';
80                line[38] = ' ';
81                line[43] = ' ';
82                line[44] = line[45];
83                line[45] = line[46];
84                line[46] = ' ';
85                if  (line[42] == ' ')  line[41] = line[42] = '3';
86                fprintf( stdout, "%s", line );
87        } /*endwhile*/
88
89        fclose( fp );
90
91        return 0;
92
93} /* end of main */
Note: See TracBrowser for help on using the repository browser.