summaryrefslogtreecommitdiff
path: root/main.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2003-10-02 05:04:38 +0000
committerJohn Wiegley <johnw@newartisans.com>2003-10-02 05:04:38 +0000
commit3cfae2794784c1629dd98c0b600b2731e27a3f57 (patch)
tree5339db0e7df4b6f925788270d8c805111e729ae1 /main.cc
parentbfff951c310b0b1b4f2ddaf3d69549bd3bac2717 (diff)
downloadfork-ledger-3cfae2794784c1629dd98c0b600b2731e27a3f57.tar.gz
fork-ledger-3cfae2794784c1629dd98c0b600b2731e27a3f57.tar.bz2
fork-ledger-3cfae2794784c1629dd98c0b600b2731e27a3f57.zip
*** empty log message ***
Diffstat (limited to 'main.cc')
-rw-r--r--main.cc32
1 files changed, 19 insertions, 13 deletions
diff --git a/main.cc b/main.cc
index 2ecaaecb..ca2f4201 100644
--- a/main.cc
+++ b/main.cc
@@ -8,10 +8,14 @@ namespace ledger {
extern bool parse_gnucash(std::istream& in, bool compute_balances);
#endif
- extern void report_balances(int argc, char **argv, std::ostream& out);
- extern void print_register(int argc, char **argv, std::ostream& out);
- extern void print_ledger(int argc, char *argv[], std::ostream& out);
- extern void equity_ledger(int argc, char **argv, std::ostream& out);
+ extern void report_balances(int argc, char ** argv, regexps_t& regexps,
+ std::ostream& out);
+ extern void print_register(int argc, char ** argv, regexps_t& regexps,
+ std::ostream& out);
+ extern void print_ledger(int argc, char ** argv, regexps_t& regexps,
+ std::ostream& out);
+ extern void equity_ledger(int argc, char ** argv, regexps_t& regexps,
+ std::ostream& out);
bool show_cleared;
bool get_quotes;
@@ -75,7 +79,7 @@ static const char *formats[] = {
NULL
};
-static bool parse_date(const char * date_str, std::time_t * result)
+static bool parse_date(const std::string& date_str, std::time_t * result)
{
struct std::tm when;
@@ -84,7 +88,7 @@ static bool parse_date(const char * date_str, std::time_t * result)
for (const char ** f = formats; *f; f++) {
memset(&when, INT_MAX, sizeof(struct std::tm));
- if (strptime(date_str, *f, &when)) {
+ if (strptime(date_str.c_str(), *f, &when)) {
when.tm_hour = 0;
when.tm_min = 0;
when.tm_sec = 0;
@@ -113,12 +117,12 @@ static bool parse_date(const char * date_str, std::time_t * result)
// Command-line parser and top-level logic.
//
-int main(int argc, char *argv[])
+int main(int argc, char * argv[])
{
- // Parse the command-line options
-
std::istream * file = NULL;
+ regexps_t regexps;
+
#ifdef HUQUQULLAH
bool compute_huquq = true;
#endif
@@ -126,6 +130,8 @@ int main(int argc, char *argv[])
have_ending = false;
show_cleared = false;
+ // Parse the command-line options
+
int c;
while (-1 != (c = getopt(argc, argv, "+b:e:d:cChHwf:i:p:Pv"))) {
switch (char(c)) {
@@ -328,13 +334,13 @@ int main(int argc, char *argv[])
// Process the command
if (command == "balance")
- report_balances(argc - optind, &argv[optind], std::cout);
+ report_balances(argc - optind, &argv[optind], regexps, std::cout);
else if (command == "register")
- print_register(argc - optind, &argv[optind], std::cout);
+ print_register(argc - optind, &argv[optind], regexps, std::cout);
else if (command == "print")
- print_ledger(argc - optind, &argv[optind], std::cout);
+ print_ledger(argc - optind, &argv[optind], regexps, std::cout);
else if (command == "equity")
- equity_ledger(argc - optind, &argv[optind], std::cout);
+ equity_ledger(argc - optind, &argv[optind], regexps, std::cout);
}
// main.cc ends here.