fixed a formatting bug in qse_strtonwad()

renamed qse_httpd_addserver() to qse_httpd_attachserver().
added qse_httpd_detachserver().
added the predetach field to qse_httpd_server_t.
added qse_httpd_cbstd_t and changed qse_htpd_loopstd() to accept this cbstd.
enhanced server uri parsing to include 'docroot'.
enhanced qse_httpd_entasktext() and added qse_httpd_entask_text() for internal use.
added nwif functions like qse_nwifindextombs().
added qse_env_insertmbsa()/qse_env_insertwcsa()/qse_env_inserta().
enhanced TPROXY handling
This commit is contained in:
2012-09-25 02:47:25 +00:00
parent fdba865863
commit cb34385ded
28 changed files with 1466 additions and 815 deletions

View File

@ -22,6 +22,7 @@ pkginclude_HEADERS = \
mbwc.h \
mem.h \
nwad.h \
nwif.h \
nwio.h \
oht.h \
opt.h \

View File

@ -53,9 +53,10 @@ SOURCES =
DIST_SOURCES =
am__pkginclude_HEADERS_DIST = alg.h chr.h cp949.h cp950.h dll.h env.h \
fio.h fma.h fmt.h fs.h gdl.h glob.h htb.h hton.h ipad.h lda.h \
main.h map.h mbwc.h mem.h nwad.h nwio.h oht.h opt.h path.h \
pio.h pma.h rbt.h rex.h sio.h sll.h slmb.h stdio.h str.h \
time.h tio.h tre.h utf8.h xma.h Mmgr.hpp StdMmgr.hpp Mmged.hpp
main.h map.h mbwc.h mem.h nwad.h nwif.h nwio.h oht.h opt.h \
path.h pio.h pma.h rbt.h rex.h sio.h sll.h slmb.h stdio.h \
str.h time.h tio.h tre.h utf8.h xma.h Mmgr.hpp StdMmgr.hpp \
Mmged.hpp
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@ -244,9 +245,9 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
pkginclude_HEADERS = alg.h chr.h cp949.h cp950.h dll.h env.h fio.h \
fma.h fmt.h fs.h gdl.h glob.h htb.h hton.h ipad.h lda.h main.h \
map.h mbwc.h mem.h nwad.h nwio.h oht.h opt.h path.h pio.h \
pma.h rbt.h rex.h sio.h sll.h slmb.h stdio.h str.h time.h \
tio.h tre.h utf8.h xma.h $(am__append_1)
map.h mbwc.h mem.h nwad.h nwif.h nwio.h oht.h opt.h path.h \
pio.h pma.h rbt.h rex.h sio.h sll.h slmb.h stdio.h str.h \
time.h tio.h tre.h utf8.h xma.h $(am__append_1)
all: all-am
.SUFFIXES:

View File

@ -119,12 +119,24 @@ int qse_env_insertwcs (
const qse_wchar_t* value
);
int qse_env_insertwcsa (
qse_env_t* env,
const qse_wchar_t* name,
const qse_wchar_t* value[]
);
int qse_env_insertmbs (
qse_env_t* env,
const qse_mchar_t* name,
const qse_mchar_t* value
);
int qse_env_insertmbsa (
qse_env_t* env,
const qse_mchar_t* name,
const qse_mchar_t* value[]
);
int qse_env_deletewcs (
qse_env_t* env,
const qse_wchar_t* name
@ -135,12 +147,14 @@ int qse_env_deletembs (
const qse_mchar_t* name
);
#if defined(QSE_CHAR_IS_WCHAR)
# define qse_env_insert(env,name,value) qse_env_insertwcs(env,name,value)
# define qse_env_delete(env,name) qse_env_deletewcs(env,name)
#else
#if defined(QSE_CHAR_IS_MCHAR)
# define qse_env_insert(env,name,value) qse_env_insertmbs(env,name,value)
# define qse_env_inserta(env,name,value) qse_env_insertmbsa(env,name,value)
# define qse_env_delete(env,name) qse_env_deletembs(env,name)
#else
# define qse_env_insert(env,name,value) qse_env_insertwcs(env,name,value)
# define qse_env_inserta(env,name,value) qse_env_insertwcsa(env,name,value)
# define qse_env_delete(env,name) qse_env_deletewcs(env,name)
#endif
#ifdef __cplusplus

View File

@ -38,11 +38,11 @@ struct qse_gdl_t
};
/**
* The QSE_GDL_INIT macro initializes a host link to be used for internal
* The QSE_GDL_INIT macro initializes a link to be used for internal
* management.
*/
#define QSE_GDL_INIT(host) QSE_BLOCK ( \
(host)->next = (host); (host)->prev = (host); \
#define QSE_GDL_INIT(link) QSE_BLOCK ( \
(link)->next = (link); (link)->prev = (link); \
)
/**
@ -59,17 +59,17 @@ struct qse_gdl_t
/**
* The QSE_GDL_ISEMPTY macro checks if the chain is empty.
*/
#define QSE_GDL_ISEMPTY(host) ((host)->next == (host))
#define QSE_GDL_ISEMPTY(link) ((link)->next == (link))
/**
* The QSE_GDL_HEAD macro get the first node in the chain.
*/
#define QSE_GDL_HEAD(host) ((host)->next)
#define QSE_GDL_HEAD(link) ((link)->next)
/**
* The QSE_GDL_TAIL macro gets the last node in the chain.
*/
#define QSE_GDL_TAIL(host) ((host)->prev)
#define QSE_GDL_TAIL(link) ((link)->prev)
#ifdef __cplusplus
extern "C" {

View File

@ -0,0 +1,75 @@
/*
* $Id$
*
Copyright 2006-2012 Chung, Hyung-Hwan.
This file is part of QSE.
QSE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
QSE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _QSE_CMN_NWIF_H_
#define _QSE_CMN_NWIF_H_
#include <qse/types.h>
#include <qse/macros.h>
#ifdef __cplusplus
extern "C" {
#endif
unsigned int qse_nwifmbstoindex (
const qse_mchar_t* ptr
);
unsigned int qse_nwifwcstoindex (
const qse_wchar_t* ptr
);
unsigned int qse_nwifmbsntoindex (
const qse_mchar_t* ptr,
qse_size_t len
);
unsigned int qse_nwifwcsntoindex (
const qse_wchar_t* ptr,
qse_size_t len
);
qse_size_t qse_nwifindextombs (
unsigned int index,
qse_mchar_t* buf,
qse_size_t len
);
qse_size_t qse_nwifindextowcs (
unsigned int index,
qse_wchar_t* buf,
qse_size_t len
);
#if defined(QSE_CHAR_IS_MCHAR)
# define qse_nwifstrtoindex(ptr) qse_nwifmbstoindex(ptr)
# define qse_nwifstrntoindex(ptr,len) qse_nwifmbsntoindex(ptr,len)
# define qse_nwifindextostr(index,buf,len) qse_nwifindextombs(index,buf,len)
#else
# define qse_nwifstrtoindex(ptr) qse_nwifwcstoindex(ptr)
# define qse_nwifstrntoindex(ptr,len) qse_nwifwcsntoindex(ptr,len)
# define qse_nwifindextostr(index,buf,len) qse_nwifindextowcs(index,buf,len)
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -299,6 +299,9 @@
/* Define to 1 if you have the <sys/epoll.h> header file. */
#undef HAVE_SYS_EPOLL_H
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H

View File

@ -69,26 +69,37 @@ struct qse_httpd_stat_t
qse_long_t ino;
qse_foff_t size;
qse_ntime_t mtime;
const qse_mchar_t* mime;
};
enum qse_httpd_server_flag_t
{
QSE_HTTPD_SERVER_ACTIVE = (1 << 0),
QSE_HTTPD_SERVER_SECURE = (1 << 1),
QSE_HTTPD_SERVER_BINDTONWIF = (1 << 2)
};
typedef struct qse_httpd_server_t qse_httpd_server_t;
struct qse_httpd_server_t
{
qse_httpd_server_t* next;
int active;
qse_nwad_t nwad;
int secure;
/* ---------------------------------------------- */
int flags;
qse_nwad_t nwad; /* binding address */
unsigned int nwif; /* interface number to bind to */
void (*predetach) (qse_httpd_t*, qse_httpd_server_t*);
/* set by server.open callback */
qse_ubi_t handle;
/* private */
qse_httpd_server_t* next;
qse_httpd_server_t* prev;
};
typedef struct qse_httpd_peer_t qse_httpd_peer_t;
struct qse_httpd_peer_t
{
qse_nwad_t nwad;
qse_nwad_t local; /* local side address facing the peer */
qse_ubi_t handle;
};
@ -285,6 +296,8 @@ struct qse_httpd_client_t
qse_nwad_t remote_addr;
qse_nwad_t local_addr;
qse_nwad_t orgdst_addr;
qse_httpd_server_t* server;
int initial_ifindex;
/* == PRIVATE == */
qse_htrd_t* htrd;
@ -308,6 +321,73 @@ struct qse_httpd_client_t
} task;
};
/**
* The qse_httpd_rsrc_type_t defines the resource type than can
* be entasked with qse_httpd_entaskrsrc().
*/
enum qse_httpd_rsrc_type_t
{
QSE_HTTPD_RSRC_AUTH,
QSE_HTTPD_RSRC_CGI,
QSE_HTTPD_RSRC_DIR,
QSE_HTTPD_RSRC_ERROR,
QSE_HTTPD_RSRC_FILE,
QSE_HTTPD_RSRC_PROXY,
QSE_HTTPD_RSRC_RELOC,
QSE_HTTPD_RSRC_TEXT
};
typedef enum qse_httpd_rsrc_type_t qse_httpd_rsrc_type_t;
typedef struct qse_httpd_rsrc_t qse_httpd_rsrc_t;
struct qse_httpd_rsrc_t
{
qse_httpd_rsrc_type_t type;
union
{
struct
{
const qse_mchar_t* realm;
} auth;
struct
{
const qse_mchar_t* path;
const qse_mchar_t* script;
const qse_mchar_t* suffix;
const qse_mchar_t* docroot;
int nph;
} cgi;
struct
{
const qse_mchar_t* path;
} dir;
int error;
struct
{
const qse_mchar_t* path;
const qse_mchar_t* mime;
} file;
struct
{
qse_nwad_t dst;
qse_nwad_t src;
} proxy;
struct
{
const qse_mchar_t* dst;
} reloc;
struct
{
const qse_mchar_t* ptr;
const qse_mchar_t* mime;
} text;
} u;
};
/**
* The qse_httpd_ecb_close_t type defines the callback function
* called when an httpd object is closed.
@ -335,6 +415,13 @@ struct qse_httpd_ecb_t
};
typedef struct qse_httpd_cbstd_t qse_httpd_cbstd_t;
struct qse_httpd_cbstd_t
{
int (*makersrc) (qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req, qse_httpd_rsrc_t* rsrc); /* required */
void (*freersrc) (qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req, qse_httpd_rsrc_t* rsrc); /* optional */
};
#ifdef __cplusplus
extern "C" {
#endif
@ -408,9 +495,17 @@ void qse_httpd_stop (
qse_httpd_t* httpd
);
int qse_httpd_addserver (
qse_httpd_t* httpd,
const qse_char_t* uri
#define qse_httpd_getserverxtn(httpd,server) ((void*)(server+1))
qse_httpd_server_t* qse_httpd_attachserver (
qse_httpd_t* httpd,
const qse_httpd_server_t* tmpl,
qse_size_t xtnsize
);
void qse_httpd_detachserver (
qse_httpd_t* httpd,
qse_httpd_server_t* server
);
void qse_httpd_discardcontent (
@ -424,7 +519,6 @@ void qse_httpd_completecontent (
);
/**
* The qse_httpd_setname() function changes the string
* to be used as the value for the server header.
@ -473,19 +567,6 @@ qse_httpd_task_t* qse_httpd_entaskdisconnect (
qse_httpd_task_t* pred
);
qse_httpd_task_t* qse_httpd_entasktext (
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* pred,
const qse_mchar_t* text
);
qse_httpd_task_t* qse_httpd_entaskstatictext (
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* pred,
const qse_mchar_t* text
);
qse_httpd_task_t* qse_httpd_entaskformat (
qse_httpd_t* httpd,
@ -497,6 +578,15 @@ qse_httpd_task_t* qse_httpd_entaskformat (
/* -------------------------------------------- */
qse_httpd_task_t* qse_httpd_entasktext (
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* pred,
const qse_mchar_t* text,
const qse_mchar_t* mime,
qse_htre_t* req
);
qse_httpd_task_t* qse_httpd_entaskerror (
qse_httpd_t* httpd,
qse_httpd_client_t* client,
@ -523,6 +613,14 @@ qse_httpd_task_t* qse_httpd_entaskauth (
qse_htre_t* req
);
qse_httpd_task_t* qse_httpd_entaskreloc (
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* pred,
const qse_mchar_t* dst,
qse_htre_t* req
);
qse_httpd_task_t* qse_httpd_entaskdir (
qse_httpd_t* httpd,
qse_httpd_client_t* client,
@ -536,20 +634,7 @@ qse_httpd_task_t* qse_httpd_entaskfile (
qse_httpd_client_t* client,
qse_httpd_task_t* pred,
const qse_mchar_t* name,
qse_htre_t* req
);
/**
* The qse_httpd_entaskphat() functions a dispatcher between
* qse_httpd_entaskdir() and qse_httpd_entaskfile(). It calls
* the former if @a name is a directory and calls the latter
* otherwise.
*/
qse_httpd_task_t* qse_httpd_entaskpath (
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* pred,
const qse_mchar_t* name,
const qse_mchar_t* mime,
qse_htre_t* req
);
@ -560,6 +645,7 @@ qse_httpd_task_t* qse_httpd_entaskcgi (
const qse_mchar_t* path,
const qse_mchar_t* script,
const qse_mchar_t* suffix,
const qse_mchar_t* docroot,
int nph,
qse_htre_t* req
);
@ -568,7 +654,18 @@ qse_httpd_task_t* qse_httpd_entaskproxy (
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* pred,
const qse_nwad_t* nwad,
const qse_nwad_t* dst,
const qse_nwad_t* src,
qse_htre_t* req
);
/* -------------------------------------------- */
qse_httpd_task_t* qse_httpd_entaskrsrc (
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* pred,
qse_httpd_rsrc_t* rsrc,
qse_htre_t* req
);
@ -606,10 +703,16 @@ void* qse_httpd_getxtnstd (
qse_httpd_t* httpd
);
qse_httpd_server_t* qse_httpd_attachserverstd (
qse_httpd_t* httpd,
const qse_char_t* uri,
qse_size_t xtnsize
);
int qse_httpd_loopstd (
qse_httpd_t* httpd,
qse_httpd_rcb_t* rcb,
qse_ntime_t timeout
qse_httpd_t* httpd,
qse_httpd_cbstd_t* cbstd,
qse_ntime_t timeout
);
#ifdef __cplusplus