git.stg.codes
/
stg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
0c552f3
)
Added handling of "AuthBy" info.
author
Maxim Mamontov
<faust.madf@gmail.com>
Tue, 27 May 2014 14:11:48 +0000
(17:11 +0300)
committer
Maxim Mamontov
<faust.madf@gmail.com>
Tue, 27 May 2014 14:11:48 +0000
(17:11 +0300)
projects/sgconf/users.cpp
patch
|
blob
|
history
stglibs/srvconf.lib/include/stg/servconf_types.h
patch
|
blob
|
history
stglibs/srvconf.lib/parsers/get_user.cpp
patch
|
blob
|
history
stglibs/srvconf.lib/parsers/get_user.h
patch
|
blob
|
history
diff --git
a/projects/sgconf/users.cpp
b/projects/sgconf/users.cpp
index 61d367366ca1680aa0d8f0ab838026d0feb4b6ec..37b3db5e10168c708d5902d2f94342f713f75057 100644
(file)
--- a/
projects/sgconf/users.cpp
+++ b/
projects/sgconf/users.cpp
@@
-57,6
+57,12
@@
for (size_t i = 0; i < DIR_NUM; ++i)
std::cout << Indent(level) << "user data:\n";
for (size_t i = 0; i < USERDATA_NUM; ++i)
std::cout << Indent(level + 1, true) << "user data " << i << ": " << info.userData[i] << "\n";
std::cout << Indent(level) << "user data:\n";
for (size_t i = 0; i < USERDATA_NUM; ++i)
std::cout << Indent(level + 1, true) << "user data " << i << ": " << info.userData[i] << "\n";
+if (!info.authBy.empty())
+ {
+ std::cout << Indent(level) << "auth by:\n";
+ for (size_t i = 0; i < info.authBy.size(); ++i)
+ std::cout << Indent(level + 1, true) << info.authBy[i] << "\n";
+ }
}
void SimpleCallback(bool result,
}
void SimpleCallback(bool result,
diff --git
a/stglibs/srvconf.lib/include/stg/servconf_types.h
b/stglibs/srvconf.lib/include/stg/servconf_types.h
index 84ceae89ac81a5efa057788b7626dbff9459db7a..7cdf2475a4e527b1de1080f226841b43904c1b3f 100644
(file)
--- a/
stglibs/srvconf.lib/include/stg/servconf_types.h
+++ b/
stglibs/srvconf.lib/include/stg/servconf_types.h
@@
-162,6
+162,7
@@
struct INFO
time_t pingTime;
time_t lastActivityTime;
ARRAY<std::string, USERDATA_NUM> userData;
time_t pingTime;
time_t lastActivityTime;
ARRAY<std::string, USERDATA_NUM> userData;
+ std::vector<std::string> authBy;
};
typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
};
typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
diff --git
a/stglibs/srvconf.lib/parsers/get_user.cpp
b/stglibs/srvconf.lib/parsers/get_user.cpp
index e796d45094cd249ca5a8933b7f78209ac0f1c7c6..a851e38077ec16b22e25036461e9b08afca6177b 100644
(file)
--- a/
stglibs/srvconf.lib/parsers/get_user.cpp
+++ b/
stglibs/srvconf.lib/parsers/get_user.cpp
@@
-112,6
+112,9
@@
if (depth == 1)
if (depth == 2 && parsingAnswer)
ParseUserParams(el, attr);
if (depth == 2 && parsingAnswer)
ParseUserParams(el, attr);
+if (depth == 3 && parsingAnswer)
+ ParseAuthBy(el, attr);
+
return 0;
}
//-----------------------------------------------------------------------------
return 0;
}
//-----------------------------------------------------------------------------
@@
-149,6
+152,17
@@
if (strcasecmp(el, "user") == 0)
//-----------------------------------------------------------------------------
void GET_USER::PARSER::ParseUserParams(const char * el, const char ** attr)
{
//-----------------------------------------------------------------------------
void GET_USER::PARSER::ParseUserParams(const char * el, const char ** attr)
{
-if (!TryParse(propertyParsers, ToLower(el), attr))
+if (strcasecmp(el, "AuthorizedBy") != 0 &&
+ !TryParse(propertyParsers, ToLower(el), attr))
error = "Invalid parameter.";
}
error = "Invalid parameter.";
}
+//-----------------------------------------------------------------------------
+void GET_USER::PARSER::ParseAuthBy(const char * el, const char ** attr)
+{
+if (strcasecmp(el, "Auth") == 0 &&
+ attr && attr[0] && attr[1] &&
+ strcasecmp(attr[0], "name") == 0)
+ info.authBy.push_back(attr[1]);
+else
+ error = "Invalid auth description.";
+}
diff --git
a/stglibs/srvconf.lib/parsers/get_user.h
b/stglibs/srvconf.lib/parsers/get_user.h
index eba12ed5614c3138f7aa602773476880fcc06a38..ffd6f2248d54649d69b2a0e3c16e9e234e82f70e 100644
(file)
--- a/
stglibs/srvconf.lib/parsers/get_user.h
+++ b/
stglibs/srvconf.lib/parsers/get_user.h
@@
-56,6
+56,7
@@
private:
void ParseUser(const char * el, const char ** attr);
void ParseUserParams(const char * el, const char ** attr);
void ParseUser(const char * el, const char ** attr);
void ParseUserParams(const char * el, const char ** attr);
+ void ParseAuthBy(const char * el, const char ** attr);
};
} // namespace GET_USER
};
} // namespace GET_USER