-
Notifications
You must be signed in to change notification settings - Fork 22
/
test_string_then_config.cc
124 lines (67 loc) · 2.02 KB
/
test_string_then_config.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
// ** Copyright UCAR (c) 1992 - 2021
// ** University Corporation for Atmospheric Research (UCAR)
// ** National Center for Atmospheric Research (NCAR)
// ** Research Applications Lab (RAL)
// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
////////////////////////////////////////////////////////////////////////
static const bool debug = false;
////////////////////////////////////////////////////////////////////////
using namespace std;
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <stdlib.h>
#include <cmath>
#include "vx_util.h"
#include "config_file.h"
#include "threshold.h"
////////////////////////////////////////////////////////////////////////
static ConcatString program_name;
////////////////////////////////////////////////////////////////////////
int main(int argc, char * argv [])
{
program_name = get_short_name(argv[0]);
if ( argc != 3 ) {
cerr << "\n\n usage: " << program_name << " config_string config_filename\n\n";
exit ( 1 );
}
MetConfig config;
//
// redirect stderr to stdout
//
if ( dup2(1, 2) < 0 ) {
cerr << "\n\n " << program_name << ": dup2 failed\n\n";
exit ( 1 );
}
config.set_debug(debug);
bool status = false;
ConcatString config_string = (string)argv[1];
ConcatString config_filename = (string)argv[2];
//
// read the string
//
status = config.read_string(config_string.c_str());
if ( ! status ) {
cerr << "\n\n " << program_name << ": failed to parse string \"" << config_string << "\"\n\n";
exit ( 1 );
}
//
// read the file
//
status = config.read(config_filename.c_str());
if ( ! status ) {
cerr << "\n\n " << program_name << ": failed to parse file \"" << config_filename << "\"\n\n";
exit ( 1 );
}
//
// dump
//
config.dump(cout);
//
// done
//
return ( 0 );
}
////////////////////////////////////////////////////////////////////////