written more http code
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
pkgincludedir= $(includedir)/qse/net
|
||||
pkginclude_HEADERS = htre.h htrd.h http.h
|
||||
pkginclude_HEADERS = http.h htre.h htrd.h httpd.h
|
||||
|
||||
|
||||
|
@ -213,7 +213,7 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
pkginclude_HEADERS = htre.h htrd.h http.h
|
||||
pkginclude_HEADERS = http.h htre.h htrd.h httpd.h
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
@ -32,11 +32,9 @@ enum qse_htrd_errnum_t
|
||||
QSE_HTRD_ENOMEM,
|
||||
|
||||
QSE_HTRD_EDISCON,
|
||||
QSE_HTRD_EREADER,
|
||||
|
||||
QSE_HTRD_EBADRE,
|
||||
QSE_HTRD_EBADHDR,
|
||||
QSE_HTRD_EREQCBS
|
||||
QSE_HTRD_ERECBS
|
||||
};
|
||||
|
||||
typedef enum qse_htrd_errnum_t qse_htrd_errnum_t;
|
||||
@ -58,6 +56,8 @@ struct qse_htrd_recbs_t
|
||||
int (*request) (qse_htrd_t* htrd, qse_htre_t* req);
|
||||
int (*response) (qse_htrd_t* htrd, qse_htre_t* res);
|
||||
int (*expect_continue) (qse_htrd_t* htrd, qse_htre_t* req);
|
||||
|
||||
int (*qparamstr) (qse_htrd_t* htrd, const qse_mcstr_t* key, const qse_mcstr_t* val);
|
||||
};
|
||||
|
||||
struct qse_htrd_t
|
||||
@ -96,11 +96,19 @@ struct qse_htrd_t
|
||||
void* chl;
|
||||
} fed;
|
||||
|
||||
struct
|
||||
{
|
||||
/* temporary space to store a key and value pair
|
||||
* during the call to qse_http_scanqparamstr() */
|
||||
qse_htob_t qparam;
|
||||
} tmp;
|
||||
|
||||
enum
|
||||
{
|
||||
QSE_HTRD_RETYPE_Q,
|
||||
QSE_HTRD_RETYPE_S
|
||||
} retype;
|
||||
|
||||
qse_htre_t re;
|
||||
|
||||
qse_htoc_t rbuf[4096];
|
||||
@ -172,6 +180,11 @@ int qse_htrd_read (
|
||||
qse_htrd_t* htrd /**< htrd */
|
||||
);
|
||||
|
||||
int qse_htrd_scanqparam (
|
||||
qse_htrd_t* http,
|
||||
const qse_mcstr_t* cstr
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -36,7 +36,7 @@ struct qse_htre_t
|
||||
|
||||
int qmethod_or_sstatus;
|
||||
qse_htob_t qpath_or_smesg;
|
||||
qse_htob_t qparamstr;
|
||||
qse_htob_t qparam;
|
||||
|
||||
/* special attributes derived from the header */
|
||||
struct
|
||||
@ -68,20 +68,49 @@ struct qse_htre_t
|
||||
#define qse_htre_getsstatus(re) ((re)->qmethod_or_sstatus)
|
||||
#define qse_htre_setsstatus(re,v) QSE_BLOCK((re)->qmethod_or_sstatus=(v);)
|
||||
|
||||
#define qse_htre_getqpath(re) (&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getqpathptr(re) QSE_MBS_PTR(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getqpathlen(re) QSE_MBS_LEN(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getqpath(re) (&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getqpathxstr(re) QSE_MBS_XSTR(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getqpathcstr(re) QSE_MBS_CSTR(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getqpathptr(re) QSE_MBS_PTR(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getqpathlen(re) QSE_MBS_LEN(&(re)->qpath_or_smesg)
|
||||
|
||||
#define qse_htre_getqparamstr(re) (&(re)->qparamstr)
|
||||
#define qse_htre_getqparamstrptr(re) QSE_MBS_PTR(&(re)->qparamstr)
|
||||
#define qse_htre_getqparamstrlen(re) QSE_MBS_LEN(&(re)->qparamstr)
|
||||
#define qse_htre_getqparam(re) (&(re)->qparam)
|
||||
#define qse_htre_getqparamxstr(re) QSE_MBS_XSTR(&(re)->qparam)
|
||||
#define qse_htre_getqparamcstr(re) QSE_MBS_CSTR(&(re)->qparam)
|
||||
#define qse_htre_getqparamptr(re) QSE_MBS_PTR(&(re)->qparam)
|
||||
#define qse_htre_getqparamlen(re) QSE_MBS_LEN(&(re)->qparam)
|
||||
|
||||
#define qse_htre_getsmessage(re) (&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getsmessageptr(re) QSE_MBS_PTR(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getsmessagelen(re) QSE_MBS_LEN(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getsmessage(re) (&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getsmessagexstr(re) QSE_MBS_XSTR(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getsmessagecstr(re) QSE_MBS_CSTR(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getsmessageptr(re) QSE_MBS_PTR(&(re)->qpath_or_smesg)
|
||||
#define qse_htre_getsmessagelen(re) QSE_MBS_LEN(&(re)->qpath_or_smesg)
|
||||
|
||||
#define qse_htre_setqpath(re,v) qse_htre_setbuf((re),qse_htre_getqpath(re),(v))
|
||||
#define qse_htre_setsmessage(re,v) qse_htre_setbuf((re),qse_htre_getsmessage(re),(v))
|
||||
#define qse_htre_getcontent(re) (&(re)->content)
|
||||
#define qse_htre_getcontentxstr(re) QSE_MBS_XSTR(&(re)->content)
|
||||
#define qse_htre_getcontentcstr(re) QSE_MBS_CSTR(&(re)->content)
|
||||
#define qse_htre_getcontentptr(re) QSE_MBS_PTR(&(re)->content)
|
||||
#define qse_htre_getcontentlen(re) QSE_MBS_LEN(&(re)->content)
|
||||
|
||||
#define qse_htre_setqpathfromcstr(re,v) \
|
||||
qse_htre_setstrfromcstr((re),qse_htre_getqpath(re),(v))
|
||||
#define qse_htre_setqpathfromxstr(re,v) \
|
||||
qse_htre_setstrfromxstr((re),qse_htre_getqpath(re),(v))
|
||||
|
||||
#define qse_htre_setqparamfromcstr(re,v) \
|
||||
qse_htre_setstrfromcstr((re),qse_htre_getqparam(re),(v))
|
||||
#define qse_htre_setqparamfromxstr(re,v) \
|
||||
qse_htre_setstrfromxstr((re),qse_htre_getqparam(re),(v))
|
||||
|
||||
#define qse_htre_setsmessagefromcstr(re,v) \
|
||||
qse_htre_setstrfromcstr((re),qse_htre_getsmessage(re),(v))
|
||||
#define qse_htre_setsmessagefromxstr(re,v) \
|
||||
qse_htre_setstrfromxstr((re),qse_htre_getsmessage(re),(v))
|
||||
|
||||
#define qse_htre_setcontentfromcstr(re,v) \
|
||||
qse_htre_setstrfromcstr((re),qse_htre_getcontent(re),(v))
|
||||
#define qse_htre_setcontentfromxstr(re,v) \
|
||||
qse_htre_setstrfromxstr((re),qse_htre_getcontent(re),(v))
|
||||
|
||||
#define qse_htre_setdiscard(re,v) QSE_BLOCK((re)->discard = (v);)
|
||||
|
||||
@ -102,21 +131,16 @@ void qse_htre_clear (
|
||||
qse_htre_t* re
|
||||
);
|
||||
|
||||
int qse_htre_setbuf (
|
||||
qse_htre_t* re,
|
||||
qse_htob_t* buf,
|
||||
const qse_mcstr_t* str
|
||||
int qse_htre_setstrfromcstr (
|
||||
qse_htre_t* re,
|
||||
qse_htob_t* str,
|
||||
const qse_mcstr_t* cstr
|
||||
);
|
||||
|
||||
void qse_htre_getbuf (
|
||||
qse_htre_t* re,
|
||||
const qse_htob_t* buf,
|
||||
qse_mcstr_t* str
|
||||
);
|
||||
|
||||
int qse_htre_setqparamstr (
|
||||
qse_htre_t* re,
|
||||
const qse_mcstr_t* str
|
||||
int qse_htre_setstrfromxstr (
|
||||
qse_htre_t* re,
|
||||
qse_htob_t* str,
|
||||
const qse_mxstr_t* xstr
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <qse/macros.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/htb.h>
|
||||
#include <qse/cmn/time.h>
|
||||
|
||||
/*typedef qse_byte_t qse_htoc_t;*/
|
||||
typedef qse_mchar_t qse_htoc_t;
|
||||
@ -56,12 +57,6 @@ enum qse_http_method_t
|
||||
|
||||
typedef enum qse_http_method_t qse_http_method_t;
|
||||
|
||||
typedef int (*qse_scanhttpparamstr_callback_t) (
|
||||
void* ctx,
|
||||
const qse_mcstr_t* key,
|
||||
const qse_mcstr_t* val
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -80,10 +75,14 @@ int qse_gethttpmethodtypefromstr (
|
||||
qse_http_method_t* type
|
||||
);
|
||||
|
||||
int qse_scanhttpparamstr (
|
||||
const qse_htoc_t* paramstr,
|
||||
qse_scanhttpparamstr_callback_t callback,
|
||||
void* ctx
|
||||
int qse_gethttpdatetime (
|
||||
const qse_htoc_t* str,
|
||||
qse_ntime_t* t
|
||||
);
|
||||
|
||||
int qse_gethttpdatetimefromstr (
|
||||
const qse_mcstr_t* str,
|
||||
qse_ntime_t* t
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
69
qse/include/qse/net/httpd.h
Normal file
69
qse/include/qse/net/httpd.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* $Id: htrd.h 223 2008-06-26 06:44:41Z baconevi $
|
||||
*
|
||||
Copyright 2006-2011 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 <htrd://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_NET_HTTPD_H_
|
||||
#define _QSE_NET_HTTPD_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
typedef struct qse_httpd_t qse_httpd_t;
|
||||
struct qse_httpd_t
|
||||
{
|
||||
QSE_DEFINE_COMMON_FIELDS (httpd)
|
||||
|
||||
int stopreq;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
QSE_DEFINE_COMMON_FUNCTIONS (httpd)
|
||||
|
||||
/**
|
||||
* The qse_httpd_open() function creates a httpd processor.
|
||||
*/
|
||||
qse_httpd_t* qse_httpd_open (
|
||||
qse_mmgr_t* mmgr, /**< memory manager */
|
||||
qse_size_t xtnsize /**< extension size in bytes */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_httpd_close() function destroys a httpd processor.
|
||||
*/
|
||||
void qse_httpd_close (
|
||||
qse_httpd_t* httpd
|
||||
);
|
||||
|
||||
qse_httpd_t* qse_httpd_init (
|
||||
qse_httpd_t* httpd,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
void qse_httpd_fini (
|
||||
qse_httpd_t* httpd
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user