-
Notifications
You must be signed in to change notification settings - Fork 0
/
datasafe.cpp
81 lines (66 loc) · 1.71 KB
/
datasafe.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
//*****************************************************************************
//
// Copyright (C) 2005 Steve Connet. All rights reserved.
//
// Source File Name : ds.cpp
// Author : Steve Connet
//
// File Overview : Main entry point
//
//*****************************************************************************
#include "datasafe.h"
#include <signal.h>
// global variables
Document *document;
Input *input;
Config *config;
static char const *version = "0.1a (01/13/05)";
int help()
{
char const *use =
"DataSafe v%s Copyright (C) 2005 Steve Connet. All rights reserved.\n"
"Usage: ds [-h] [-f datafile]\n\n"
"Options:\n"
" h\tThis help screen\n";
printf(use, version);
exit(0);
}
int main(int argc, char *argv[])
{
// create and load config file
config = new Config("dsconfig");
// parse command line argument for options
while(argc--)
{
if('-' == argv[argc][0])
{
switch(argv[argc][1])
{
case 'h':
help();
break;
case 'f':
if(argv[argc + 1])
{
config->modify("datafile", argv[argc + 1]);
}
break;
}
}
}
// create a new document with which to load the datafile
document = new Document(config->get("datafile"));
#if DEBUG
document->write(std::cout);
exit(1);
#endif
// keyboard & mouse interface object
input = new Input;
// handle input (main loop here)
input->read();
// perform cleanup
delete input;
delete document;
delete config;
return EXIT_SUCCESS;
}