Mod aaa-12 添加web server插件接口
RCA: SOL: 修改人:huangxin 检视人:huangxin
This commit is contained in:
parent
e43238ff4c
commit
bd8083dfe9
|
@ -1,6 +1,6 @@
|
|||
|
||||
#var.log_root = "/home/cmhi/secogateway/libs/files/lighttpd/log"
|
||||
var.server_root = "/usr/Product_usr/files/lighttpd"
|
||||
var.server_root = "/mnt/e/wsl/webs"
|
||||
#var.state_dir = "/home/cmhi/secogateway/libs/files/lighttpd"
|
||||
#var.home_dir = "/home/cmhi/secogateway/libs/files/lighttpd"
|
||||
#var.conf_dir = "/home/cmhi/secogateway/libs/files/lighttpd/config"
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
server.modules = (
|
||||
"mod_portal",
|
||||
"mod_usermagnet",
|
||||
"mod_object",
|
||||
# "mod_webm",
|
||||
# "mod_access",
|
||||
# "mod_alias",
|
||||
|
|
|
@ -134,7 +134,7 @@ mod_evasive_la_LIBADD = $(common_libadd)
|
|||
|
||||
lib_LTLIBRARIES += mod_webdav.la
|
||||
mod_webdav_la_SOURCES = mod_webdav.c
|
||||
mod_webdav_la_CFLAGS = $(AM_CFLAGS) $(XML_CFLAGS) $(SQLITE_CFLAGS)
|
||||
mod_webdav_la_CFLAGS = $(AM_CFLAGS) $(XML_CFLAGS) $(SQLITE_CFLAGS)
|
||||
mod_webdav_la_LDFLAGS = $(common_module_ldflags)
|
||||
mod_webdav_la_LIBADD = $(common_libadd) $(XML_LIBS) $(SQLITE_LIBS) $(UUID_LIBS)
|
||||
|
||||
|
@ -146,7 +146,7 @@ mod_magnet_la_LDFLAGS = $(common_module_ldflags)
|
|||
mod_magnet_la_LIBADD = $(common_libadd) $(LUA_LIBS) -lm
|
||||
endif
|
||||
|
||||
if BUILD_WITH_LUA
|
||||
if BUILD_WITH_LUA
|
||||
lib_LTLIBRARIES += mod_cml.la
|
||||
mod_cml_la_SOURCES = mod_cml.c mod_cml_lua.c mod_cml_funcs.c
|
||||
mod_cml_la_CFLAGS = $(AM_CFLAGS) $(LUA_CFLAGS)
|
||||
|
@ -411,14 +411,19 @@ mod_webm_la_LIBADD = $(common_libadd)
|
|||
|
||||
lib_LTLIBRARIES += mod_portal.la
|
||||
mod_portal_la_SOURCES = mod_portal.c json.c user_hashtable.c user_auth.c
|
||||
mod_portal_la_LDFLAGS = -module -export-dynamic -avoid-version -L../../../../Platform/build/debug/
|
||||
mod_portal_la_LDFLAGS = -module -export-dynamic -avoid-version -L../../../../Platform/build/debug/
|
||||
mod_portal_la_LIBADD = $(common_libadd) -ldatabase-$(host_cpu)
|
||||
|
||||
lib_LTLIBRARIES += mod_usermagnet.la
|
||||
mod_usermagnet_la_SOURCES = mod_usermagnet.c json.c user_hashtable.c user_auth.c
|
||||
mod_usermagnet_la_LDFLAGS = -module -export-dynamic -avoid-version -L../../../../Platform/build/debug/
|
||||
mod_usermagnet_la_LDFLAGS = -module -export-dynamic -avoid-version -L../../../../Platform/build/debug/
|
||||
mod_usermagnet_la_LIBADD = $(common_libadd) -ldatabase-$(host_cpu)
|
||||
|
||||
lib_LTLIBRARIES += mod_object.la
|
||||
mod_object_la_SOURCES = mod_object.c
|
||||
mod_object_la_LDFLAGS = -module -export-dynamic -avoid-version -L../../../../Platform/build/debug/
|
||||
mod_object_la_LIBADD = $(common_libadd)
|
||||
|
||||
hdr = server.h base64.h buffer.h burl.h network.h log.h http_kv.h keyvalue.h \
|
||||
response.h request.h fastcgi.h chunk.h \
|
||||
first.h settings.h http_chunk.h \
|
||||
|
@ -477,7 +482,7 @@ lighttpd_SOURCES = \
|
|||
mod_userdir.c \
|
||||
mod_usertrack.c \
|
||||
mod_vhostdb.c \
|
||||
mod_webdav.c
|
||||
mod_webdav.c
|
||||
lighttpd_CPPFLAGS = \
|
||||
-DLIGHTTPD_STATIC \
|
||||
$(XML_CFLAGS) $(SQLITE_CFLAGS) \
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
#include "first.h"
|
||||
|
||||
#include "base.h"
|
||||
#include "log.h"
|
||||
#include "buffer.h"
|
||||
#include "http_header.h"
|
||||
#include "sock_addr.h"
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define OBJECT_PATH ("/object")
|
||||
|
||||
typedef struct {
|
||||
unsigned short max_conns;
|
||||
unsigned short silent;
|
||||
buffer *location;
|
||||
} plugin_config;
|
||||
|
||||
typedef struct {
|
||||
PLUGIN_DATA;
|
||||
|
||||
plugin_config **config_storage;
|
||||
|
||||
plugin_config conf;
|
||||
} plugin_data;
|
||||
|
||||
INIT_FUNC(mod_object_init)
|
||||
{
|
||||
plugin_data *p;
|
||||
p = calloc(1, sizeof(*p));
|
||||
return p;
|
||||
}
|
||||
|
||||
FREE_FUNC(mod_object_free)
|
||||
{
|
||||
plugin_data *p = p_d;
|
||||
UNUSED(srv);
|
||||
|
||||
if(!p) {
|
||||
return HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
free(p);
|
||||
return HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
SETDEFAULTS_FUNC(mod_object_set_defaults)
|
||||
{
|
||||
plugin_data *p = p_d;
|
||||
UNUSED(p);
|
||||
UNUSED(srv);
|
||||
return HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
URIHANDLER_FUNC(mod_object_uri_handler)
|
||||
{
|
||||
plugin_data *p = p_d;
|
||||
UNUSED(p);
|
||||
log_error_write(srv, __FILE__, __LINE__, "s", "test");
|
||||
|
||||
if(buffer_is_empty(con->uri.path)) {
|
||||
return HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
log_error_write(srv, __FILE__, __LINE__, "s", "test");
|
||||
|
||||
if(0 == strncmp(con->uri.path->ptr, OBJECT_PATH, strlen(OBJECT_PATH))) {
|
||||
chunk *c;
|
||||
chunkqueue *cq = con->request_content_queue;
|
||||
buffer *result_info = buffer_init();
|
||||
buffer *content_buffer = buffer_init();
|
||||
log_error_write(srv, __FILE__, __LINE__, "ss", "path:", con->uri.path->ptr);
|
||||
|
||||
for(c = cq->first; c && content_buffer; c = c->next) {
|
||||
size_t len = buffer_string_length(c->mem) - c->offset;
|
||||
buffer_append_string_len(content_buffer, c->mem->ptr + c->offset, len);
|
||||
}
|
||||
|
||||
log_error_write(srv, __FILE__, __LINE__, "ss", "Json:", content_buffer->ptr);
|
||||
|
||||
if(result_info) {
|
||||
buffer_copy_string(result_info, "{\"message\" : \"OK\"}");
|
||||
chunkqueue_append_buffer(con->write_queue, result_info);
|
||||
buffer_free(result_info);
|
||||
con->mode = DIRECT;
|
||||
con->http_status = 200;
|
||||
con->file_finished = 1;
|
||||
}
|
||||
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
log_error_write(srv, __FILE__, __LINE__, "s", "test");
|
||||
return HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
int mod_object_plugin_init(plugin *p)
|
||||
{
|
||||
p->version = LIGHTTPD_VERSION_ID;
|
||||
p->name = buffer_init_string("object");
|
||||
p->init = mod_object_init;
|
||||
p->set_defaults = mod_object_set_defaults;
|
||||
p->handle_uri_clean = mod_object_uri_handler;
|
||||
p->cleanup = mod_object_free;
|
||||
p->data = NULL;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue