added more code for httpd
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: str_cnv.c 441 2011-04-22 14:28:43Z hyunghwan.chung $
|
||||
* $Id: str_cnv.c 504 2011-07-11 16:31:33Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/chr.h>
|
||||
#include "mem.h"
|
||||
|
||||
int qse_strtoi (const qse_char_t* str)
|
||||
{
|
||||
@ -397,6 +398,41 @@ int qse_wcstombs_strict (
|
||||
return 0;
|
||||
}
|
||||
|
||||
qse_wchar_t* qse_mbstowcsdup (
|
||||
const qse_mchar_t* mbs, qse_mmgr_t* mmgr)
|
||||
{
|
||||
qse_size_t n, req;
|
||||
qse_wchar_t* wcs;
|
||||
|
||||
n = qse_mbstowcslen (mbs, &req);
|
||||
if (mbs[n] != QSE_WT('\0')) return QSE_NULL;
|
||||
|
||||
req++;
|
||||
|
||||
wcs = QSE_MMGR_ALLOC (mmgr, req * QSE_SIZEOF(*wcs));
|
||||
if (wcs == QSE_NULL) return QSE_NULL;
|
||||
|
||||
qse_mbstowcs (mbs, wcs, &req);
|
||||
return wcs;
|
||||
}
|
||||
|
||||
qse_mchar_t* qse_wcstombsdup (
|
||||
const qse_wchar_t* wcs, qse_mmgr_t* mmgr)
|
||||
{
|
||||
qse_size_t n, req;
|
||||
qse_mchar_t* mbs;
|
||||
|
||||
n = qse_wcstombslen (wcs, &req);
|
||||
if (wcs[n] != QSE_WT('\0')) return QSE_NULL;
|
||||
|
||||
req++;
|
||||
|
||||
mbs = QSE_MMGR_ALLOC (mmgr, req * QSE_SIZEOF(*mbs));
|
||||
if (mbs == QSE_NULL) return QSE_NULL;
|
||||
|
||||
qse_wcstombs (wcs, mbs, &req);
|
||||
return mbs;
|
||||
}
|
||||
|
||||
/* case conversion */
|
||||
|
||||
|
@ -422,12 +422,12 @@ void qse_htrd_setoption (qse_htrd_t* http, int opts)
|
||||
|
||||
const qse_htrd_recbs_t* qse_htrd_getrecbs (qse_htrd_t* http)
|
||||
{
|
||||
return &http->recbs;
|
||||
return http->recbs;
|
||||
}
|
||||
|
||||
void qse_htrd_setrecbs (qse_htrd_t* http, const qse_htrd_recbs_t* recbs)
|
||||
{
|
||||
http->recbs = *recbs;
|
||||
http->recbs = recbs;
|
||||
}
|
||||
|
||||
#define octet_tolower(c) (((c) >= 'A' && (c) <= 'Z') ? ((c) | 0x20) : (c))
|
||||
@ -1091,7 +1091,7 @@ int qse_htrd_feed (qse_htrd_t* http, const qse_htoc_t* req, qse_size_t len)
|
||||
|
||||
if (http->retype == QSE_HTRD_RETYPE_Q &&
|
||||
http->re.attr.expect_continue &&
|
||||
http->recbs.expect_continue && ptr >= end)
|
||||
http->recbs->expect_continue && ptr >= end)
|
||||
{
|
||||
int n;
|
||||
|
||||
@ -1102,7 +1102,7 @@ int qse_htrd_feed (qse_htrd_t* http, const qse_htoc_t* req, qse_size_t len)
|
||||
* not fed here?
|
||||
*/
|
||||
|
||||
n = http->recbs.expect_continue (http, &http->re);
|
||||
n = http->recbs->expect_continue (http, &http->re);
|
||||
|
||||
if (n <= -1)
|
||||
{
|
||||
@ -1243,20 +1243,20 @@ int qse_htrd_feed (qse_htrd_t* http, const qse_htoc_t* req, qse_size_t len)
|
||||
if (http->retype == QSE_HTRD_RETYPE_S)
|
||||
{
|
||||
QSE_ASSERTX (
|
||||
http->recbs.response != QSE_NULL,
|
||||
http->recbs->response != QSE_NULL,
|
||||
"set response callback before feeding"
|
||||
);
|
||||
|
||||
n = http->recbs.response (http, &http->re);
|
||||
n = http->recbs->response (http, &http->re);
|
||||
}
|
||||
else
|
||||
{
|
||||
QSE_ASSERTX (
|
||||
http->recbs.request != QSE_NULL,
|
||||
http->recbs->request != QSE_NULL,
|
||||
"set request callback before feeding"
|
||||
);
|
||||
|
||||
n = http->recbs.request (http, &http->re);
|
||||
n = http->recbs->request (http, &http->re);
|
||||
}
|
||||
|
||||
if (n <= -1)
|
||||
@ -1309,12 +1309,12 @@ int qse_htrd_read (qse_htrd_t* http)
|
||||
qse_ssize_t n;
|
||||
|
||||
QSE_ASSERTX (
|
||||
http->recbs.reader != QSE_NULL,
|
||||
http->recbs->reader != QSE_NULL,
|
||||
"You must set the octet reader to be able to call qse_htrd_read()"
|
||||
);
|
||||
|
||||
http->errnum = QSE_HTRD_ENOERR;
|
||||
n = http->recbs.reader (http, http->rbuf, QSE_SIZEOF(http->rbuf));
|
||||
n = http->recbs->reader (http, http->rbuf, QSE_SIZEOF(http->rbuf));
|
||||
if (n <= -1)
|
||||
{
|
||||
if (http->errnum == QSE_HTRD_ENOERR) http->errnum = QSE_HTRD_ERECBS;
|
||||
@ -1376,12 +1376,12 @@ int qse_htrd_scanqparam (qse_htrd_t* http, const qse_mcstr_t* cstr)
|
||||
}
|
||||
|
||||
QSE_ASSERTX (
|
||||
http->recbs.qparamstr != QSE_NULL,
|
||||
http->recbs->qparamstr != QSE_NULL,
|
||||
"set request parameter string callback before scanning"
|
||||
);
|
||||
|
||||
http->errnum = QSE_HTRD_ENOERR;
|
||||
if (http->recbs.qparamstr (http, &key, &val) <= -1)
|
||||
if (http->recbs->qparamstr (http, &key, &val) <= -1)
|
||||
{
|
||||
if (http->errnum == QSE_HTRD_ENOERR)
|
||||
http->errnum = QSE_HTRD_ERECBS;
|
||||
|
@ -146,3 +146,4 @@ int qse_gethttpdatetimefromstr (const qse_mcstr_t* str, qse_ntime_t* t)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
1478
qse/lib/net/httpd.c
1478
qse/lib/net/httpd.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user