plain = apr_pstrdup(r->pool, escaped);
strncpy(plain, escaped, x);
y = ap_unescape_urlencoded(plain);
- lua_pushstring(L, plain);
- return 1;
+ if (!y) {
+ lua_pushstring(L, plain);
+ return 1;
+ }
+ return 0;
}
/* lua_ap_escape; r:escape(string) - URL-escapes a string */
r = ap_lua_check_request_rec(L, 1);
luaL_checktype(L, 2, LUA_TSTRING);
plain = lua_tolstring(L, 2, &x);
- escaped = apr_pcalloc(r->pool, x*3);
escaped = ap_escape_urlencoded(r->pool, plain);
lua_pushstring(L, escaped);
return 1;
static int lua_apr_md5(lua_State *L)
{
/*~~~~~~~~~~~~~~~~*/
- int n;
union {
- char chr[16];
+ unsigned char chr[16];
uint32_t num[4];
} digest;
apr_md5_ctx_t md5;
static int lua_apr_sha1(lua_State *L)
{
/*~~~~~~~~~~~~~~~~*/
- int n;
union {
- char chr[16];
+ unsigned char chr[16];
uint32_t num[4];
} digest;
apr_sha1_ctx_t sha1;
const char* buffer;
char* result;
- char Rsha1[16];
+ unsigned char Rsha1[20];
uint32_t *sha1X;
size_t x,y;
request_rec *r;
static int lua_ap_mpm_query(lua_State *L)
{
/*~~~~~~~~~~~~~~~~~~*/
- request_rec *r;
int x,y;
/*~~~~~~~~~~~~~~~~~~*/
x = lua_tonumber(L, 1);
if (ap_regcomp(®ex, pattern,0)) {
return 0;
}
-
-
- if (!err) {
- int i;
- x = ap_regexec(®ex, source, 10, matches, 0);
- if (x < 0) {
- lua_pushstring(L, err);
- return 1;
+
+ int i;
+ x = ap_regexec(®ex, source, 10, matches, 0);
+ if (x < 0) {
+ lua_pushstring(L, err);
+ return 1;
+ }
+ lua_newtable(L);
+ for (i=0;i<10;i++) {
+ lua_pushinteger(L, i);
+ if (matches[i].rm_so >= 0 && matches[i].rm_eo >= 0) {
+ lua_pushstring(L,apr_pstrndup(r->pool, source+matches[i].rm_so, matches[i].rm_eo - matches[i].rm_so));
}
- lua_newtable(L);
- for (i=0;i<10;i++) {
- lua_pushinteger(L, i);
- if (matches[i].rm_so >= 0 && matches[i].rm_eo >= 0) {
- lua_pushstring(L,apr_pstrndup(r->pool, source+matches[i].rm_so, matches[i].rm_eo - matches[i].rm_so));
- }
- else {
- lua_pushnil(L);
- }
- lua_settable(L, -3);
-
+ else {
+ lua_pushnil(L);
}
- return 1;
+ lua_settable(L, -3);
+
}
- return 0;
+ return 1;
}
static int lua_ap_scoreboard_process(lua_State *L)
{
/*~~~~~~~~~~~~~~~~~~*/
- request_rec *r;
int i;
process_score* ps_record;
/*~~~~~~~~~~~~~~~~~~*/
luaL_checktype(L, 1, LUA_TUSERDATA);
luaL_checktype(L, 2, LUA_TNUMBER);
- r = ap_lua_check_request_rec(L, 1);
i = lua_tonumber(L, 2);
ps_record = ap_get_scoreboard_process(i);
if (ps_record) {
static int lua_ap_scoreboard_worker(lua_State *L)
{
/*~~~~~~~~~~~~~~~~~~*/
- request_rec *r;
int i,j;
worker_score* ws_record;
/*~~~~~~~~~~~~~~~~~~*/
luaL_checktype(L, 1, LUA_TUSERDATA);
luaL_checktype(L, 2, LUA_TNUMBER);
luaL_checktype(L, 3, LUA_TNUMBER);
- r = ap_lua_check_request_rec(L, 1);
i = lua_tonumber(L, 2);
j = lua_tonumber(L, 3);
ws_record = ap_get_scoreboard_worker_from_indexes(i, j);
request_rec* r;
/*~~~~~~~~~~~~~~~~~~*/
- r = r = ap_lua_check_request_rec(L, 1);
+ r = ap_lua_check_request_rec(L, 1);
filename = luaL_optstring(L, 2, 0);
if (r) {
static int lua_ap_module_info(lua_State *L)
{
/*~~~~~~~~~~~~~~~~~~*/
- request_rec *r;
const char* moduleName;
module* mod;
/*~~~~~~~~~~~~~~~~~~*/
int i, z;
size_t vlen = 0;
size_t len = 0;
- if (lua_read_body(r, &data, &size) != OK) {
+ if (lua_read_body(r, &data, (apr_off_t*) &size) != OK) {
return 2;
}
len = strlen(multipart);
lua_pushboolean(L, 0);
}
else {
- if (r) {
- apr_size_t sent;
- apr_status_t rc;
- apr_file_t *file;
-
- rc = apr_file_open(&file, filename, APR_READ, APR_OS_DEFAULT,
- r->pool);
- if (rc == APR_SUCCESS) {
- ap_send_fd(file, r, 0, file_info.size, &sent);
- apr_file_close(file);
- lua_pushinteger(L, sent);
- }
- else
- lua_pushboolean(L, 0);
+ apr_size_t sent;
+ apr_status_t rc;
+ apr_file_t *file;
+
+ rc = apr_file_open(&file, filename, APR_READ, APR_OS_DEFAULT,
+ r->pool);
+ if (rc == APR_SUCCESS) {
+ ap_send_fd(file, r, 0, file_info.size, &sent);
+ apr_file_close(file);
+ lua_pushinteger(L, sent);
}
- else
+ else {
lua_pushboolean(L, 0);
+ }
}
return (1);