30
30
#include "ApvlvCmds.hpp"
31
31
#include "ApvlvParams.hpp"
36
33
#include <iostream>
42
39
ApvlvParams *gParams = NULL;
44
ApvlvParams::ApvlvParams ()
41
ApvlvParams::ApvlvParams ()
43
push ("inverted", "no");
46
44
push ("fullscreen", "no");
47
45
push ("zoom", "fitwidth");
48
46
push ("continuous", "yes");
89
87
if (!os.is_open ())
91
errp ("Open configure file %s error", filename);
89
errp ("Open configure file %s error", filename);
95
93
while ((getline (os, str)) != NULL)
97
string argu, data, crap;
98
stringstream is (str);
99
// avoid commet line, continue next
101
if (crap[0] == '\"' || crap == "")
105
// parse the line like "set fullscreen=yes" or set "set zoom=1.5"
106
else if (crap == "set")
109
size_t off = argu.find ('=');
110
if (off == string::npos)
115
push (argu.c_str (), data.c_str ());
121
char k[32], v[32], *p;
122
memcpy (k, argu.c_str (), off);
125
p = (char *) argu.c_str () + off + 1;
131
g_snprintf (v, sizeof v, "%s", *p ? p : "");
133
p = (char *) v + strlen (v) - 1;
134
while (isspace (*p) && p >= v)
144
errp ("Syntax error: set: %s", str.c_str ());
146
// like "map n next-page"
147
else if (crap == "map")
151
if (argu.length () == 0)
153
errp ("map command not complete");
159
while (data.length () > 0 && isspace (data[0]))
162
if (argu.length () > 0 && data.length () > 0)
164
gCmds->buildmap (argu.c_str (), data.c_str ());
168
errp ("Syntax error: map: %s", str.c_str ());
173
errp ("Unknown rc command: %s: %s", crap.c_str (), str.c_str ());
95
string argu, data, crap;
96
stringstream is (str);
97
// avoid commet line, continue next
99
if (crap[0] == '\"' || crap == "")
103
// parse the line like "set fullscreen=yes" or set "set zoom=1.5"
104
else if (crap == "set")
107
size_t off = argu.find ('=');
108
if (off == string::npos)
113
push (argu.c_str (), data.c_str ());
119
char k[32], v[32], *p;
120
memcpy (k, argu.c_str (), off);
123
p = (char *) argu.c_str () + off + 1;
129
g_snprintf (v, sizeof v, "%s", *p ? p : "");
131
p = (char *) v + strlen (v) - 1;
132
while (isspace (*p) && p >= v)
142
errp ("Syntax error: set: %s", str.c_str ());
144
// like "map n next-page"
145
else if (crap == "map")
149
if (argu.length () == 0)
151
errp ("map command not complete");
157
while (data.length () > 0 && isspace (data[0]))
160
if (argu.length () > 0 && data.length () > 0)
162
gCmds->buildmap (argu.c_str (), data.c_str ());
166
errp ("Syntax error: map: %s", str.c_str ());
171
errp ("Unknown rc command: %s: %s", crap.c_str (), str.c_str ());