blob: adfdfc189803a8888e35e04701dfcb6fcb053b4a (
plain)
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
|
// standard C++ includes
#include <fstream>
// our includes
#include "XMLParser.h"
#include "XMLSpec.h"
// display some usage
int usage()
{
printf("Usage: xml2spec input [output]\n");
printf("Converts the input pkg.spec.xml file to a pkg.spec\n");
printf("file for use in an rpmbuild command.\n\n");
return 1;
}
// program entry point
int main(int argc,
char** argv)
{
printf("\nxml2spec, version 0.01\n");
if (argc != 2 && argc != 3) {
usage();
return 1;
}
XMLSpec* pSpec = NULL;
if (parseXMLSpec(argv[1], pSpec) == 0 && pSpec) {
if (argc == 3) {
printf("Writing spec to %s ... ", argv[2]);
ofstream fOut(argv[2]);
if (fOut.is_open()) {
pSpec->toSpecFile(fOut);
fOut.close();
printf("Ok.\n");
}
else {
delete pSpec;
printf("Failed.\n");
return 2;
}
}
else if (argc == 2) {
pSpec->toSpecFile(cout);
}
delete pSpec;
return 0;
}
return 3;
}
|