Migrated libfast to INIT/METHOD macros
This commit is contained in:
+47
-55
@@ -180,14 +180,12 @@ static session_entry_t *session_entry_create(private_dispatcher_t *this,
|
|||||||
{
|
{
|
||||||
session_entry_t *entry;
|
session_entry_t *entry;
|
||||||
|
|
||||||
entry = malloc_thing(session_entry_t);
|
INIT(entry,
|
||||||
entry->in_use = FALSE;
|
.cond = condvar_create(CONDVAR_TYPE_DEFAULT),
|
||||||
entry->closed = FALSE;
|
.session = load_session(this),
|
||||||
entry->cond = condvar_create(CONDVAR_TYPE_DEFAULT);
|
.used = time_monotonic(NULL),
|
||||||
entry->session = load_session(this);
|
.host = strdup(host),
|
||||||
entry->used = time_monotonic(NULL);
|
);
|
||||||
entry->host = strdup(host);
|
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,29 +200,28 @@ static void session_entry_destroy(session_entry_t *entry)
|
|||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(dispatcher_t, add_controller, void,
|
||||||
* Implementation of dispatcher_t.add_controller.
|
private_dispatcher_t *this, controller_constructor_t constructor,
|
||||||
*/
|
void *param)
|
||||||
static void add_controller(private_dispatcher_t *this,
|
|
||||||
controller_constructor_t constructor, void *param)
|
|
||||||
{
|
{
|
||||||
controller_entry_t *entry = malloc_thing(controller_entry_t);
|
controller_entry_t *entry;
|
||||||
|
|
||||||
entry->constructor = constructor;
|
INIT(entry,
|
||||||
entry->param = param;
|
.constructor = constructor,
|
||||||
|
.param = param,
|
||||||
|
);
|
||||||
this->controllers->insert_last(this->controllers, entry);
|
this->controllers->insert_last(this->controllers, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(dispatcher_t, add_filter, void,
|
||||||
* Implementation of dispatcher_t.add_filter.
|
private_dispatcher_t *this, filter_constructor_t constructor, void *param)
|
||||||
*/
|
|
||||||
static void add_filter(private_dispatcher_t *this,
|
|
||||||
filter_constructor_t constructor, void *param)
|
|
||||||
{
|
{
|
||||||
filter_entry_t *entry = malloc_thing(filter_entry_t);
|
filter_entry_t *entry;
|
||||||
|
|
||||||
entry->constructor = constructor;
|
INIT(entry,
|
||||||
entry->param = param;
|
.constructor = constructor,
|
||||||
|
.param = param,
|
||||||
|
);
|
||||||
this->filters->insert_last(this->filters, entry);
|
this->filters->insert_last(this->filters, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,10 +346,8 @@ static void dispatch(private_dispatcher_t *this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(dispatcher_t, run, void,
|
||||||
* Implementation of dispatcher_t.run.
|
private_dispatcher_t *this, int threads)
|
||||||
*/
|
|
||||||
static void run(private_dispatcher_t *this, int threads)
|
|
||||||
{
|
{
|
||||||
this->thread_count = threads;
|
this->thread_count = threads;
|
||||||
this->threads = malloc(sizeof(thread_t*) * threads);
|
this->threads = malloc(sizeof(thread_t*) * threads);
|
||||||
@@ -367,10 +362,8 @@ static void run(private_dispatcher_t *this, int threads)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(dispatcher_t, waitsignal, void,
|
||||||
* Implementation of dispatcher_t.waitsignal.
|
private_dispatcher_t *this)
|
||||||
*/
|
|
||||||
static void waitsignal(private_dispatcher_t *this)
|
|
||||||
{
|
{
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
int sig;
|
int sig;
|
||||||
@@ -383,10 +376,8 @@ static void waitsignal(private_dispatcher_t *this)
|
|||||||
sigwait(&set, &sig);
|
sigwait(&set, &sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(dispatcher_t, destroy, void,
|
||||||
* Implementation of dispatcher_t.destroy
|
private_dispatcher_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_dispatcher_t *this)
|
|
||||||
{
|
{
|
||||||
char *sid;
|
char *sid;
|
||||||
session_entry_t *entry;
|
session_entry_t *entry;
|
||||||
@@ -419,26 +410,27 @@ static void destroy(private_dispatcher_t *this)
|
|||||||
dispatcher_t *dispatcher_create(char *socket, bool debug, int timeout,
|
dispatcher_t *dispatcher_create(char *socket, bool debug, int timeout,
|
||||||
context_constructor_t constructor, void *param)
|
context_constructor_t constructor, void *param)
|
||||||
{
|
{
|
||||||
private_dispatcher_t *this = malloc_thing(private_dispatcher_t);
|
private_dispatcher_t *this;
|
||||||
|
|
||||||
this->public.add_controller = (void(*)(dispatcher_t*, controller_constructor_t, void*))add_controller;
|
INIT(this,
|
||||||
this->public.add_filter = (void(*)(dispatcher_t*,filter_constructor_t constructor, void *param))add_filter;
|
.public = {
|
||||||
this->public.run = (void(*)(dispatcher_t*, int threads))run;
|
.add_controller = _add_controller,
|
||||||
this->public.waitsignal = (void(*)(dispatcher_t*))waitsignal;
|
.add_filter = _add_filter,
|
||||||
this->public.destroy = (void(*)(dispatcher_t*))destroy;
|
.run = _run,
|
||||||
|
.waitsignal = _waitsignal,
|
||||||
this->sessions = hashtable_create((void*)session_hash,
|
.destroy = _destroy,
|
||||||
(void*)session_equals, 4096);
|
},
|
||||||
this->controllers = linked_list_create();
|
.sessions = hashtable_create((void*)session_hash,
|
||||||
this->filters = linked_list_create();
|
(void*)session_equals, 4096),
|
||||||
this->context_constructor = constructor;
|
.controllers = linked_list_create(),
|
||||||
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
.filters = linked_list_create(),
|
||||||
this->param = param;
|
.context_constructor = constructor,
|
||||||
this->fd = 0;
|
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
|
||||||
this->timeout = timeout;
|
.param = param,
|
||||||
this->last_cleanup = time_monotonic(NULL);
|
.timeout = timeout,
|
||||||
this->debug = debug;
|
.last_cleanup = time_monotonic(NULL),
|
||||||
this->threads = NULL;
|
.debug = debug,
|
||||||
|
);
|
||||||
|
|
||||||
FCGX_Init();
|
FCGX_Init();
|
||||||
|
|
||||||
|
|||||||
+70
-111
@@ -160,86 +160,66 @@ static int iterenv_cb(void *null, int num, char **key, char **value)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, get_cookie, char*,
|
||||||
* Implementation of request_t.get_cookie.
|
private_request_t *this, char *name)
|
||||||
*/
|
|
||||||
static char* get_cookie(private_request_t *this, char *name)
|
|
||||||
{
|
{
|
||||||
return hdf_get_valuef(this->hdf, "Cookie.%s", name);
|
return hdf_get_valuef(this->hdf, "Cookie.%s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, get_path, char*,
|
||||||
* Implementation of request_t.get_path.
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static char* get_path(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
char * path = FCGX_GetParam("PATH_INFO", this->req.envp);
|
char * path = FCGX_GetParam("PATH_INFO", this->req.envp);
|
||||||
return path ? path : "";
|
return path ? path : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, get_host, char*,
|
||||||
* Implementation of request_t.get_host.
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static char* get_host(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
char *addr = FCGX_GetParam("REMOTE_ADDR", this->req.envp);
|
char *addr = FCGX_GetParam("REMOTE_ADDR", this->req.envp);
|
||||||
return addr ? addr : "";
|
return addr ? addr : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, get_user_agent, char*,
|
||||||
* Implementation of request_t.get_user_agent.
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static char* get_user_agent(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
char *agent = FCGX_GetParam("HTTP_USER_AGENT", this->req.envp);
|
char *agent = FCGX_GetParam("HTTP_USER_AGENT", this->req.envp);
|
||||||
return agent ? agent : "";
|
return agent ? agent : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, get_query_data, char*,
|
||||||
* Implementation of request_t.get_post_data.
|
private_request_t *this, char *name)
|
||||||
*/
|
|
||||||
static char* get_query_data(private_request_t *this, char *name)
|
|
||||||
{
|
{
|
||||||
return hdf_get_valuef(this->hdf, "Query.%s", name);
|
return hdf_get_valuef(this->hdf, "Query.%s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, get_env_var, char*,
|
||||||
* Implementation of request_t.get_env_var.
|
private_request_t *this, char *name)
|
||||||
*/
|
|
||||||
static char* get_env_var(private_request_t *this, char *name)
|
|
||||||
{
|
{
|
||||||
return FCGX_GetParam(name, this->req.envp);
|
return FCGX_GetParam(name, this->req.envp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, read_data, int,
|
||||||
* Implementation of request_t.read_data.
|
private_request_t *this, char *buf, int len)
|
||||||
*/
|
|
||||||
static int read_data(private_request_t *this, char *buf, int len)
|
|
||||||
{
|
{
|
||||||
return FCGX_GetStr(buf, len, this->req.in);
|
return FCGX_GetStr(buf, len, this->req.in);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, get_base, char*,
|
||||||
* Implementation of request_t.get_base.
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static char* get_base(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
return FCGX_GetParam("SCRIPT_NAME", this->req.envp);
|
return FCGX_GetParam("SCRIPT_NAME", this->req.envp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, add_cookie, void,
|
||||||
* Implementation of request_t.add_cookie.
|
private_request_t *this, char *name, char *value)
|
||||||
*/
|
|
||||||
static void add_cookie(private_request_t *this, char *name, char *value)
|
|
||||||
{
|
{
|
||||||
thread_this->set(thread_this, this);
|
thread_this->set(thread_this, this);
|
||||||
cgi_cookie_set (this->cgi, name, value, get_base(this), NULL, NULL, 0, 0);
|
cgi_cookie_set (this->cgi, name, value, get_base(this), NULL, NULL, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, redirect, void,
|
||||||
* Implementation of request_t.redirect.
|
private_request_t *this, char *fmt, ...)
|
||||||
*/
|
|
||||||
static void redirect(private_request_t *this, char *fmt, ...)
|
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@@ -252,18 +232,14 @@ static void redirect(private_request_t *this, char *fmt, ...)
|
|||||||
FCGX_FPrintF(this->req.out, "\n\n");
|
FCGX_FPrintF(this->req.out, "\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, get_referer, char*,
|
||||||
* Implementation of request_t.get_referer.
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static char* get_referer(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
return FCGX_GetParam("HTTP_REFERER", this->req.envp);
|
return FCGX_GetParam("HTTP_REFERER", this->req.envp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, to_referer, void,
|
||||||
* Implementation of request_t.to_referer.
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static void to_referer(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
char *referer;
|
char *referer;
|
||||||
|
|
||||||
@@ -279,36 +255,28 @@ static void to_referer(private_request_t *this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, session_closed, bool,
|
||||||
* Implementation of request_t.session_closed.
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static bool session_closed(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
return this->closed;
|
return this->closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, close_session, void,
|
||||||
* Implementation of request_t.close_session.
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static void close_session(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
this->closed = TRUE;
|
this->closed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, serve, void,
|
||||||
* Implementation of request_t.serve.
|
private_request_t *this, char *headers, chunk_t chunk)
|
||||||
*/
|
|
||||||
static void serve(private_request_t *this, char *headers, chunk_t chunk)
|
|
||||||
{
|
{
|
||||||
FCGX_FPrintF(this->req.out, "%s\n\n", headers);
|
FCGX_FPrintF(this->req.out, "%s\n\n", headers);
|
||||||
|
|
||||||
FCGX_PutStr(chunk.ptr, chunk.len, this->req.out);
|
FCGX_PutStr(chunk.ptr, chunk.len, this->req.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, render, void,
|
||||||
* Implementation of request_t.render.
|
private_request_t *this, char *template)
|
||||||
*/
|
|
||||||
static void render(private_request_t *this, char *template)
|
|
||||||
{
|
{
|
||||||
NEOERR* err;
|
NEOERR* err;
|
||||||
|
|
||||||
@@ -319,13 +287,10 @@ static void render(private_request_t *this, char *template)
|
|||||||
cgi_neo_error(this->cgi, err);
|
cgi_neo_error(this->cgi, err);
|
||||||
nerr_log_error(err);
|
nerr_log_error(err);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, streamf, int,
|
||||||
* Implementation of request_t.streamf.
|
private_request_t *this, char *format, ...)
|
||||||
*/
|
|
||||||
static int streamf(private_request_t *this, char *format, ...)
|
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
int written;
|
int written;
|
||||||
@@ -341,18 +306,14 @@ static int streamf(private_request_t *this, char *format, ...)
|
|||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, set, void,
|
||||||
* Implementation of request_t.set.
|
private_request_t *this, char *key, char *value)
|
||||||
*/
|
|
||||||
static void set(private_request_t *this, char *key, char *value)
|
|
||||||
{
|
{
|
||||||
hdf_set_value(this->hdf, key, value);
|
hdf_set_value(this->hdf, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, setf, void,
|
||||||
* Implementation of request_t.setf.
|
private_request_t *this, char *format, ...)
|
||||||
*/
|
|
||||||
static void setf(private_request_t *this, char *format, ...)
|
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@@ -361,19 +322,15 @@ static void setf(private_request_t *this, char *format, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, get_ref, request_t*,
|
||||||
* Implementation of request_t.get_ref.
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static request_t* get_ref(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
ref_get(&this->ref);
|
ref_get(&this->ref);
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(request_t, destroy, void,
|
||||||
* Implementation of request_t.destroy
|
private_request_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_request_t *this)
|
|
||||||
{
|
{
|
||||||
if (ref_put(&this->ref))
|
if (ref_put(&this->ref))
|
||||||
{
|
{
|
||||||
@@ -401,9 +358,36 @@ static void init(void)
|
|||||||
request_t *request_create(int fd, bool debug)
|
request_t *request_create(int fd, bool debug)
|
||||||
{
|
{
|
||||||
NEOERR* err;
|
NEOERR* err;
|
||||||
private_request_t *this = malloc_thing(private_request_t);
|
private_request_t *this;
|
||||||
bool failed = FALSE;
|
bool failed = FALSE;
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.get_path = _get_path,
|
||||||
|
.get_base = _get_base,
|
||||||
|
.get_host = _get_host,
|
||||||
|
.get_user_agent = _get_user_agent,
|
||||||
|
.add_cookie = _add_cookie,
|
||||||
|
.get_cookie = _get_cookie,
|
||||||
|
.get_query_data = _get_query_data,
|
||||||
|
.get_env_var = _get_env_var,
|
||||||
|
.read_data = _read_data,
|
||||||
|
.session_closed = _session_closed,
|
||||||
|
.close_session = _close_session,
|
||||||
|
.redirect = _redirect,
|
||||||
|
.get_referer = _get_referer,
|
||||||
|
.to_referer = _to_referer,
|
||||||
|
.render = _render,
|
||||||
|
.streamf = _streamf,
|
||||||
|
.serve = _serve,
|
||||||
|
.set = _set,
|
||||||
|
.setf = _setf,
|
||||||
|
.get_ref = _get_ref,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.ref = 1,
|
||||||
|
);
|
||||||
|
|
||||||
thread_cleanup_push(free, this);
|
thread_cleanup_push(free, this);
|
||||||
if (FCGX_InitRequest(&this->req, fd, 0) != 0 ||
|
if (FCGX_InitRequest(&this->req, fd, 0) != 0 ||
|
||||||
FCGX_Accept_r(&this->req) != 0)
|
FCGX_Accept_r(&this->req) != 0)
|
||||||
@@ -416,34 +400,9 @@ request_t *request_create(int fd, bool debug)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->public.get_path = (char*(*)(request_t*))get_path;
|
|
||||||
this->public.get_base = (char*(*)(request_t*))get_base;
|
|
||||||
this->public.get_host = (char*(*)(request_t*))get_host;
|
|
||||||
this->public.get_user_agent = (char*(*)(request_t*))get_user_agent;
|
|
||||||
this->public.add_cookie = (void(*)(request_t*, char *name, char *value))add_cookie;
|
|
||||||
this->public.get_cookie = (char*(*)(request_t*,char*))get_cookie;
|
|
||||||
this->public.get_query_data = (char*(*)(request_t*, char *name))get_query_data;
|
|
||||||
this->public.get_env_var = (char*(*)(request_t*, char *name))get_env_var;
|
|
||||||
this->public.read_data = (int(*)(request_t*, char*, int))read_data;
|
|
||||||
this->public.session_closed = (bool(*)(request_t*))session_closed;
|
|
||||||
this->public.close_session = (void(*)(request_t*))close_session;
|
|
||||||
this->public.redirect = (void(*)(request_t*, char *fmt,...))redirect;
|
|
||||||
this->public.get_referer = (char*(*)(request_t*))get_referer;
|
|
||||||
this->public.to_referer = (void(*)(request_t*))to_referer;
|
|
||||||
this->public.render = (void(*)(request_t*,char*))render;
|
|
||||||
this->public.streamf = (int(*)(request_t*, char *format, ...))streamf;
|
|
||||||
this->public.serve = (void(*)(request_t*,char*,chunk_t))serve;
|
|
||||||
this->public.set = (void(*)(request_t*, char *, char*))set;
|
|
||||||
this->public.setf = (void(*)(request_t*, char *format, ...))setf;
|
|
||||||
this->public.get_ref = (request_t*(*)(request_t*))get_ref;
|
|
||||||
this->public.destroy = (void(*)(request_t*))destroy;
|
|
||||||
|
|
||||||
pthread_once(&once, init);
|
pthread_once(&once, init);
|
||||||
thread_this->set(thread_this, this);
|
thread_this->set(thread_this, this);
|
||||||
|
|
||||||
this->ref = 1;
|
|
||||||
this->closed = FALSE;
|
|
||||||
this->req_env_len = 0;
|
|
||||||
while (this->req.envp[this->req_env_len] != NULL)
|
while (this->req.envp[this->req_env_len] != NULL)
|
||||||
{
|
{
|
||||||
this->req_env_len++;
|
this->req_env_len++;
|
||||||
|
|||||||
+23
-31
@@ -63,18 +63,14 @@ struct private_session_t {
|
|||||||
context_t *context;
|
context_t *context;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
METHOD(session_t, add_controller, void,
|
||||||
* Implementation of session_t.add_controller.
|
private_session_t *this, controller_t *controller)
|
||||||
*/
|
|
||||||
static void add_controller(private_session_t *this, controller_t *controller)
|
|
||||||
{
|
{
|
||||||
this->controllers->insert_last(this->controllers, controller);
|
this->controllers->insert_last(this->controllers, controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(session_t, add_filter, void,
|
||||||
* Implementation of session_t.add_filter.
|
private_session_t *this, filter_t *filter)
|
||||||
*/
|
|
||||||
static void add_filter(private_session_t *this, filter_t *filter)
|
|
||||||
{
|
{
|
||||||
this->filters->insert_last(this->filters, filter);
|
this->filters->insert_last(this->filters, filter);
|
||||||
}
|
}
|
||||||
@@ -120,10 +116,8 @@ static bool run_filter(private_session_t *this, request_t *request, char *p0,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(session_t, process, void,
|
||||||
* Implementation of session_t.process.
|
private_session_t *this, request_t *request)
|
||||||
*/
|
|
||||||
static void process(private_session_t *this, request_t *request)
|
|
||||||
{
|
{
|
||||||
char *pos, *start, *param[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
|
char *pos, *start, *param[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
@@ -184,18 +178,14 @@ static void process(private_session_t *this, request_t *request)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(session_t, get_sid, char*,
|
||||||
* Implementation of session_t.get_sid.
|
private_session_t *this)
|
||||||
*/
|
|
||||||
static char* get_sid(private_session_t *this)
|
|
||||||
{
|
{
|
||||||
return this->sid;
|
return this->sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(session_t, destroy, void,
|
||||||
* Implementation of session_t.destroy
|
private_session_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_session_t *this)
|
|
||||||
{
|
{
|
||||||
this->controllers->destroy_offset(this->controllers, offsetof(controller_t, destroy));
|
this->controllers->destroy_offset(this->controllers, offsetof(controller_t, destroy));
|
||||||
this->filters->destroy_offset(this->filters, offsetof(filter_t, destroy));
|
this->filters->destroy_offset(this->filters, offsetof(filter_t, destroy));
|
||||||
@@ -208,19 +198,21 @@ static void destroy(private_session_t *this)
|
|||||||
*/
|
*/
|
||||||
session_t *session_create(context_t *context)
|
session_t *session_create(context_t *context)
|
||||||
{
|
{
|
||||||
private_session_t *this = malloc_thing(private_session_t);
|
private_session_t *this;
|
||||||
|
|
||||||
this->public.add_controller = (void(*)(session_t*, controller_t*))add_controller;
|
|
||||||
this->public.add_filter = (void(*)(session_t*, filter_t*))add_filter;
|
|
||||||
this->public.process = (void(*)(session_t*,request_t*))process;
|
|
||||||
this->public.get_sid = (char*(*)(session_t*))get_sid;
|
|
||||||
this->public.destroy = (void(*)(session_t*))destroy;
|
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.add_controller = _add_controller,
|
||||||
|
.add_filter = _add_filter,
|
||||||
|
.process = _process,
|
||||||
|
.get_sid = _get_sid,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.controllers = linked_list_create(),
|
||||||
|
.filters = linked_list_create(),
|
||||||
|
.context = context,
|
||||||
|
);
|
||||||
create_sid(this);
|
create_sid(this);
|
||||||
this->cookie_sent = FALSE;
|
|
||||||
this->controllers = linked_list_create();
|
|
||||||
this->filters = linked_list_create();
|
|
||||||
this->context = context;
|
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user