blob: b0711286c7445fa75d142039a76c55f6d683a044 (
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
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
|
#include "config.h"
#include "acconf.h"
#include "option.h"
//#include "quotes.h"
#include "valexpr.h"
#include "walk.h"
namespace ledger {
string expand_path(const string& pathname)
{
if (pathname.length() == 0 || pathname[0] != '~')
return pathname;
const char * pfx = NULL;
string::size_type pos = pathname.find_first_of('/');
if (pathname.length() == 1 || pos == 1) {
pfx = std::getenv("HOME");
#ifdef HAVE_GETPWUID
if (! pfx) {
// Punt. We're trying to expand ~/, but HOME isn't set
struct passwd * pw = getpwuid(getuid());
if (pw)
pfx = pw->pw_dir;
}
#endif
}
#ifdef HAVE_GETPWNAM
else {
string user(pathname, 1, pos == string::npos ?
string::npos : pos - 1);
struct passwd * pw = getpwnam(user.c_str());
if (pw)
pfx = pw->pw_dir;
}
#endif
// if we failed to find an expansion, return the pathname unchanged.
if (! pfx)
return pathname;
string result(pfx);
if (pos == string::npos)
return result;
if (result.length() == 0 || result[result.length() - 1] != '/')
result += '/';
result += pathname.substr(pos + 1);
return result;
}
// jww (2008-04-22): This needs to be changed to use boost::filesystem
string resolve_path(const string& pathname)
{
if (pathname[0] == '~')
return expand_path(pathname);
return pathname;
}
config_t::config_t()
{
balance_format = "%20T %2_%-a\n";
register_format = ("%D %-.20P %-.22A %12.67t %!12.80T\n%/"
"%32|%-.22A %12.67t %!12.80T\n");
wide_register_format = ("%D %-.35P %-.38A %22.108t %!22.132T\n%/"
"%48|%-.38A %22.108t %!22.132T\n");
plot_amount_format = "%D %(@S(@t))\n";
plot_total_format = "%D %(@S(@T))\n";
print_format = "\n%d %Y%C%P\n %-34W %12o%n\n%/ %-34W %12o%n\n";
write_hdr_format = "%d %Y%C%P\n";
write_xact_format = " %-34W %12o%n\n";
equity_format = "\n%D %Y%C%P\n%/ %-34W %12t\n";
prices_format = "%[%Y/%m/%d %H:%M:%S %Z] %-10A %12t %12T\n";
pricesdb_format = "P %[%Y/%m/%d %H:%M:%S] %A %t\n";
pricing_leeway = 24 * 3600;
download_quotes = false;
use_cache = false;
cache_dirty = false;
debug_mode = false;
verbose_mode = false;
trace_mode = false;
}
} // namespace ledger
|