-
Notifications
You must be signed in to change notification settings - Fork 4
/
hdds-md5.cpp
128 lines (108 loc) · 3.13 KB
/
hdds-md5.cpp
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
121
122
123
124
125
126
127
/*
* hdds-geant : an interface utility that reads in a HDDS document
* (Hall D Detector Specification) and writes out a
* GEANT-3 geometry description in the form of a
* fortran subroutine.
*
* Revision - Richard Jones, November 25, 2006.
* -added output of optical properties for materials with optical
* properties defined
*
* Revision - Richard Jones, January 25, 2005.
* -added the sphere section as a new supported volume type
*
* Original version - Richard Jones, May 19 2001.
*
* Notes:
* ------
* 1. Output is sent to standard out through the ordinary c++ i/o library.
* 2. As a by-product of using the DOM parser to access the xml source,
* hdds-geant verifies the source against the schema before translating it.
* Therefore it may also be used as a validator of the xml specification
* (see the -v option).
*/
#define APP_NAME "hdds-md5"
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLStringTokenizer.hpp>
#include <xercesc/sax/SAXParseException.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/sax/ErrorHandler.hpp>
using namespace xercesc;
#include "XString.hpp"
#include "XParsers.hpp"
#include "hddsCommon.hpp"
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#define X(str) XString(str).unicode_str()
#define S(str) str.c_str()
void usage()
{
std::cerr
<< "Usage: " << APP_NAME << " [-v] {HDDS file}"
<< std::endl << "Options:" << std::endl
<< " -v validate only" << std::endl;
}
int main(int argC, char* argV[])
{
try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
XString message(toCatch.getMessage());
std::cerr
<< APP_NAME << " - error during initialization!"
<< std::endl << S(message) << std::endl;
return 1;
}
if (argC < 2)
{
usage();
return 1;
}
else if ((argC == 2) && (strcmp(argV[1], "-?") == 0))
{
usage();
return 2;
}
XString xmlFile;
int argInd;
for (argInd = 1; argInd < argC; argInd++)
{
if (argV[argInd][0] != '-')
break;
if ( ! (strcmp(argV[argInd], "-v") == 0))
std::cerr
<< "Unknown option \'" << argV[argInd]
<< "\', ignoring it\n" << std::endl;
}
if (argInd != argC - 1)
{
usage();
return 1;
}
xmlFile = argV[argInd];
// Parse the XML input file, calculating the checksum at the end
// and leaving it in the global variable "last_md5_checksum"
//DOMDocument* document = // commented out to avoid compiler warnings
parseInputDocument(xmlFile,false);
std::cout << "HDDS Geometry MD5 Checksum: " << last_md5_checksum << std::endl;
XMLPlatformUtils::Terminate();
return 0;
}