summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2008-09-26 18:15:01 -0700
committerPixel <pixel@nobis-crew.org>2008-09-26 18:15:01 -0700
commit600c2ef2d8dd8dcf71166ec5a0b1b7fdf2eb6f4f (patch)
tree9c3fdb89685658e280ab0da1b350463bc15401da /lib
parent1cf900a817761badd343b69918101074c45e4e56 (diff)
Adding the ability to hash data from handles.
Diffstat (limited to 'lib')
-rw-r--r--lib/LuaHttp.cc35
1 files changed, 25 insertions, 10 deletions
diff --git a/lib/LuaHttp.cc b/lib/LuaHttp.cc
index 89e55e7..dd2e74d 100644
--- a/lib/LuaHttp.cc
+++ b/lib/LuaHttp.cc
@@ -135,11 +135,11 @@ struct lua_functypes_t HttpResponse_methods[] = {
struct lua_functypes_t HttpResponse_functions[] = {
{ HTTPRESPONSE_NEWHTTPRESPONSE, "HttpResponse", 0, 0, { } },
- { HTTPRESPONSE_BASE64_ENCODE, "Base64Encode", 1, 1, { BLUA_STRING | BLUA_OBJECT} },
+ { HTTPRESPONSE_BASE64_ENCODE, "Base64Encode", 1, 1, { BLUA_STRING | BLUA_OBJECT } },
{ HTTPRESPONSE_BASE64_DECODE, "Base64Decode", 1, 1, { BLUA_STRING } },
- { HTTPRESPONSE_MD5, "MD5", 1, 1, { BLUA_STRING } },
- { HTTPRESPONSE_SHA1, "SHA1", 1, 1, { BLUA_STRING } },
- { HTTPRESPONSE_SHA256, "SHA256", 1, 1, { BLUA_STRING } },
+ { HTTPRESPONSE_MD5, "MD5", 1, 1, { BLUA_STRING | BLUA_OBJECT } },
+ { HTTPRESPONSE_SHA1, "SHA1", 1, 1, { BLUA_STRING | BLUA_OBJECT } },
+ { HTTPRESPONSE_SHA256, "SHA256", 1, 1, { BLUA_STRING | BLUA_OBJECT } },
{ HTTPRESPONSE_GENTICKET, "GenTicket", 0, 1, { BLUA_NUMBER } },
{ -1, 0, 0, 0, 0 }
};
@@ -322,29 +322,44 @@ int sLua_HttpResponse::HttpResponse_proceed_statics(Lua * L, int n, int caller)
break;
case HTTPRESPONSE_MD5:
- dec = L->tostring();
- {
+ if (L->isstring()) {
+ dec = L->tostring();
MD5 h;
h.Update(dec);
L->push(h.Finish());
+ } else {
+ Handle * hdata = (Handle *) LuaObject::getme(L, 1);
+ MD5 h;
+ h.Update(hdata);
+ L->push(h.Finish());
}
r = 1;
break;
case HTTPRESPONSE_SHA1:
- dec = L->tostring();
- {
+ if (L->isstring()) {
+ dec = L->tostring();
SHA1 h;
h.Update(dec);
L->push(h.Finish());
+ } else {
+ Handle * hdata = (Handle *) LuaObject::getme(L, 1);
+ SHA1 h;
+ h.Update(hdata);
+ L->push(h.Finish());
}
r = 1;
break;
case HTTPRESPONSE_SHA256:
- dec = L->tostring();
- {
+ if (L->isstring()) {
+ dec = L->tostring();
SHA256 h;
h.Update(dec);
L->push(h.Finish());
+ } else {
+ Handle * hdata = (Handle *) LuaObject::getme(L, 1);
+ SHA256 h;
+ h.Update(hdata);
+ L->push(h.Finish());
}
r = 1;
break;