mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
sync
This commit is contained in:
parent
fa4adeccab
commit
cee99c923d
|
@ -57,7 +57,6 @@ extern U_EXPORT void runDynamicPage_ir_web(int param);
|
||||||
}
|
}
|
||||||
|
|
||||||
UHTTP::mime_index = U_html;
|
UHTTP::mime_index = U_html;
|
||||||
U_http_info.endHeader = 0;
|
|
||||||
if (UHTTP::getDataSession() == false) UHTTP::setSessionCookie();
|
if (UHTTP::getDataSession() == false) UHTTP::setSessionCookie();
|
||||||
const char* ref = "?ext=help";
|
const char* ref = "?ext=help";
|
||||||
uint32_t num_args = UHTTP::processForm() / 2;
|
uint32_t num_args = UHTTP::processForm() / 2;
|
||||||
|
@ -192,5 +191,6 @@ extern U_EXPORT void runDynamicPage_ir_web(int param);
|
||||||
U_CONSTANT_TO_PARAM(" </div>\n</body>\n</html>")
|
U_CONSTANT_TO_PARAM(" </div>\n</body>\n</html>")
|
||||||
);
|
);
|
||||||
UHTTP::putDataSession();
|
UHTTP::putDataSession();
|
||||||
|
U_http_info.endHeader = 0;
|
||||||
|
|
||||||
} }
|
} }
|
|
@ -96,16 +96,18 @@ public:
|
||||||
records = output;
|
records = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if defined(U_EVASIVE_SUPPORT) || defined(U_THROTTLING_SUPPORT)
|
||||||
UString basename = UStringExt::basename(filename);
|
UString basename = UStringExt::basename(filename);
|
||||||
|
|
||||||
const char* p = basename.data();
|
const char* p = basename.data();
|
||||||
|
|
||||||
# ifdef U_EVASIVE_SUPPORT
|
# ifdef U_EVASIVE_SUPPORT
|
||||||
if (memcmp(p, U_CONSTANT_TO_PARAM("Evasive")) == 0) UCDB::getValueFromBuffer = UServer_Base::getEvasiveRecFromBuffer;
|
if (memcmp(p, U_CONSTANT_TO_PARAM("Evasive")) == 0) UCDB::getValueFromBuffer = UServer_Base::getEvasiveRecFromBuffer;
|
||||||
# endif
|
# endif
|
||||||
# ifdef U_THROTTLING_SUPPORT
|
# ifdef U_THROTTLING_SUPPORT
|
||||||
if (memcmp(p, U_CONSTANT_TO_PARAM("BandWidthThrottling")) == 0) UCDB::getValueFromBuffer = UServer_Base::getThrottlingRecFromBuffer;
|
if (memcmp(p, U_CONSTANT_TO_PARAM("BandWidthThrottling")) == 0) UCDB::getValueFromBuffer = UServer_Base::getThrottlingRecFromBuffer;
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
istrstream is(U_STRING_TO_PARAM(records));
|
istrstream is(U_STRING_TO_PARAM(records));
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ extern U_EXPORT void runDynamicPage_wi_auth2(int param);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
U_http_info.endHeader = 0;
|
|
||||||
static UHTTP::service_info GET_table[] = { // NB: the table must be ordered alphabetically for binary search...
|
static UHTTP::service_info GET_table[] = { // NB: the table must be ordered alphabetically for binary search...
|
||||||
GET_ENTRY(anagrafica),
|
GET_ENTRY(anagrafica),
|
||||||
GET_ENTRY(checkCaptive),
|
GET_ENTRY(checkCaptive),
|
||||||
|
@ -43,5 +42,6 @@ extern U_EXPORT void runDynamicPage_wi_auth2(int param);
|
||||||
|
|
||||||
UHTTP::manageRequest(GET_table, U_NUM_ELEMENTS(GET_table), POST_table, U_NUM_ELEMENTS(POST_table));
|
UHTTP::manageRequest(GET_table, U_NUM_ELEMENTS(GET_table), POST_table, U_NUM_ELEMENTS(POST_table));
|
||||||
|
|
||||||
|
U_http_info.endHeader = 0;
|
||||||
|
|
||||||
} }
|
} }
|
|
@ -22,7 +22,6 @@ extern U_EXPORT void runDynamicPage_wi_auth(int param);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
U_http_info.endHeader = 0;
|
|
||||||
static UHTTP::service_info GET_table[] = { // NB: the table must be ordered alphabetically for binary search...
|
static UHTTP::service_info GET_table[] = { // NB: the table must be ordered alphabetically for binary search...
|
||||||
GET_ENTRY(admin),
|
GET_ENTRY(admin),
|
||||||
GET_ENTRY(admin_continuing_status_ap),
|
GET_ENTRY(admin_continuing_status_ap),
|
||||||
|
@ -104,5 +103,6 @@ extern U_EXPORT void runDynamicPage_wi_auth(int param);
|
||||||
|
|
||||||
if (U_http_info.nResponseCode == 0) (void) UClientImage_Base::environment->append(U_CONSTANT_TO_PARAM("HTTP_RESPONSE_CODE=0\n"));
|
if (U_http_info.nResponseCode == 0) (void) UClientImage_Base::environment->append(U_CONSTANT_TO_PARAM("HTTP_RESPONSE_CODE=0\n"));
|
||||||
|
|
||||||
|
U_http_info.endHeader = 0;
|
||||||
|
|
||||||
} }
|
} }
|
|
@ -228,16 +228,16 @@ if (envp) \
|
||||||
# define U_DUMP_CONTAINER(obj) { if (utr.active[0] && (obj).getSpaceToDump() < U_MAX_SIZE_PREALLOCATE) u_trace_dump(U_CONSTANT_TO_PARAM(#obj" = %O"), U_OBJECT_TO_TRACE((obj))); }
|
# define U_DUMP_CONTAINER(obj) { if (utr.active[0] && (obj).getSpaceToDump() < U_MAX_SIZE_PREALLOCATE) u_trace_dump(U_CONSTANT_TO_PARAM(#obj" = %O"), U_OBJECT_TO_TRACE((obj))); }
|
||||||
|
|
||||||
# define U_DUMP_OBJECT_TO_TMP(obj,fname) \
|
# define U_DUMP_OBJECT_TO_TMP(obj,fname) \
|
||||||
{ char _buffer[2 * 1024 * 1024]; \
|
{ char _lbuffer[2 * 1024 * 1024]; \
|
||||||
uint32_t _n = UObject2String((obj), _buffer, sizeof(_buffer)); \
|
uint32_t _n = UObject2String((obj), _lbuffer, sizeof(_lbuffer)); \
|
||||||
U_INTERNAL_ASSERT_MINOR(_n, sizeof(_buffer)) \
|
U_INTERNAL_ASSERT_MINOR(_n, sizeof(_lbuffer)) \
|
||||||
(void) UFile::writeToTmp(_buffer, _n, O_RDWR | O_TRUNC, U_CONSTANT_TO_PARAM(#fname".%P"), 0); }
|
(void) UFile::writeToTmp(_lbuffer, _n, O_RDWR | O_TRUNC, U_CONSTANT_TO_PARAM(#fname".%P"), 0); }
|
||||||
|
|
||||||
# define U_DUMP_OBJECT_WITH_CHECK(msg,check_object) \
|
# define U_DUMP_OBJECT_WITH_CHECK(msg,check_object) \
|
||||||
if (UObjectDB::fd > 0) { \
|
if (UObjectDB::fd > 0) { \
|
||||||
char _buffer[4096]; \
|
char _lbuffer[4096]; \
|
||||||
uint32_t _n = UObjectDB::dumpObject(_buffer, sizeof(_buffer), (check_object)); \
|
uint32_t _n = UObjectDB::dumpObject(_lbuffer, sizeof(_lbuffer), (check_object)); \
|
||||||
if (utr.active[0]) u_trace_dump(U_CONSTANT_TO_PARAM(msg " = \n%.*s\n"), U_min(_n,4000), _buffer); }
|
if (utr.active[0]) u_trace_dump(U_CONSTANT_TO_PARAM(msg " = \n%.*s\n"), U_min(_n,4000), _lbuffer); }
|
||||||
|
|
||||||
# else /* U_STDCPP_ENABLE */
|
# else /* U_STDCPP_ENABLE */
|
||||||
# define U_REGISTER_OBJECT(CLASS)
|
# define U_REGISTER_OBJECT(CLASS)
|
||||||
|
|
|
@ -327,13 +327,7 @@ public:
|
||||||
{
|
{
|
||||||
U_TRACE_NO_PARAM(0, "UMySqlStatementBindResult::setString()")
|
U_TRACE_NO_PARAM(0, "UMySqlStatementBindResult::setString()")
|
||||||
|
|
||||||
U_INTERNAL_ASSERT_POINTER(pstr)
|
USqlStatementBindResult::setString(str_data, length);
|
||||||
U_INTERNAL_ASSERT(pstr->invariant())
|
|
||||||
|
|
||||||
if (length > 0) pstr->setConstant(str_data, length);
|
|
||||||
else pstr->setEmpty();
|
|
||||||
|
|
||||||
U_INTERNAL_DUMP("pstr(%u) = %V", length, pstr->rep)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
|
|
@ -326,10 +326,12 @@ public:
|
||||||
|
|
||||||
U_CHECK_MEMORY
|
U_CHECK_MEMORY
|
||||||
|
|
||||||
int r = memcmp(str, s, U_min(_length, n));
|
|
||||||
|
|
||||||
U_INTERNAL_DUMP("str = %.*S", U_min(_length, n), str)
|
U_INTERNAL_DUMP("str = %.*S", U_min(_length, n), str)
|
||||||
|
|
||||||
|
if (*str != *s) U_RETURN(*(const unsigned char*)str - *(const unsigned char*)s);
|
||||||
|
|
||||||
|
int r = memcmp(str+1, s+1, U_min(_length, n)-1);
|
||||||
|
|
||||||
if (r == 0) r = (_length - n);
|
if (r == 0) r = (_length - n);
|
||||||
|
|
||||||
U_RETURN(r);
|
U_RETURN(r);
|
||||||
|
|
|
@ -3,12 +3,11 @@
|
||||||
#ifndef FORTUNE_H
|
#ifndef FORTUNE_H
|
||||||
#define FORTUNE_H 1
|
#define FORTUNE_H 1
|
||||||
|
|
||||||
#include <ulib/base/coder/xml.h>
|
|
||||||
|
|
||||||
#include <ulib/orm/orm.h>
|
#include <ulib/orm/orm.h>
|
||||||
#include <ulib/json/value.h>
|
#include <ulib/json/value.h>
|
||||||
#include <ulib/utility/uhttp.h>
|
#include <ulib/utility/uhttp.h>
|
||||||
#include <ulib/orm/orm_driver.h>
|
#include <ulib/orm/orm_driver.h>
|
||||||
|
#include <ulib/utility/xml_escape.h>
|
||||||
#include <ulib/net/server/client_image.h>
|
#include <ulib/net/server/client_image.h>
|
||||||
|
|
||||||
class Fortune {
|
class Fortune {
|
||||||
|
@ -33,16 +32,20 @@ public:
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Fortune(uint32_t _id, const UString& _message) : id(_id), message(_message)
|
Fortune(uint32_t _id, const UString& _message) : id(_id), message(100U)
|
||||||
{
|
{
|
||||||
U_TRACE_CTOR(5, Fortune, "%u,%V", _id, _message.rep)
|
U_TRACE_CTOR(5, Fortune, "%u,%V", _id, _message.rep)
|
||||||
|
|
||||||
|
UXMLEscape::encode(_message, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fortune(const Fortune& f) : id(f.id), message(f.message)
|
Fortune(const Fortune& f) : id(f.id), message(100U)
|
||||||
{
|
{
|
||||||
U_TRACE_CTOR(5, Fortune, "%p", &f)
|
U_TRACE_CTOR(5, Fortune, "%p", &f)
|
||||||
|
|
||||||
U_MEMORY_TEST_COPY(f)
|
U_MEMORY_TEST_COPY(f)
|
||||||
|
|
||||||
|
UXMLEscape::encode(f.message, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Fortune()
|
~Fortune()
|
||||||
|
@ -137,7 +140,7 @@ public:
|
||||||
|
|
||||||
Fortune* elem;
|
Fortune* elem;
|
||||||
|
|
||||||
for (uint32_t i = 0, n = pvfortune->size(); i < n; ++i)
|
for (uint32_t sz, i = 0, n = pvfortune->size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
elem = pvfortune->at(i);
|
elem = pvfortune->at(i);
|
||||||
|
|
||||||
|
@ -150,7 +153,8 @@ public:
|
||||||
|
|
||||||
*pwbuffer++ = '>';
|
*pwbuffer++ = '>';
|
||||||
|
|
||||||
pwbuffer += u_xml_encode((const unsigned char*)U_STRING_TO_PARAM(elem->message), (unsigned char*)pwbuffer);
|
(void) memcpy(pwbuffer, elem->message.data(), sz = elem->message.size());
|
||||||
|
pwbuffer += sz;
|
||||||
|
|
||||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
|
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
|
||||||
u_put_unalignedp16(pwbuffer+8, U_MULTICHAR_CONSTANT16('r','>'));
|
u_put_unalignedp16(pwbuffer+8, U_MULTICHAR_CONSTANT16('r','>'));
|
||||||
|
|
|
@ -328,13 +328,14 @@ public:
|
||||||
|
|
||||||
setDirectiveItem(directive, U_CONSTANT_SIZE("vcode"));
|
setDirectiveItem(directive, U_CONSTANT_SIZE("vcode"));
|
||||||
|
|
||||||
U_INTERNAL_ASSERT(token)
|
if (token)
|
||||||
|
{
|
||||||
|
token = UStringExt::substitute(token, '\n', U_CONSTANT_TO_PARAM("\n\t"));
|
||||||
|
|
||||||
token = UStringExt::substitute(token, '\n', U_CONSTANT_TO_PARAM("\n\t"));
|
vcode.setBuffer(20U + token.size());
|
||||||
|
|
||||||
vcode.setBuffer(20U + token.size());
|
vcode.snprintf(U_CONSTANT_TO_PARAM("\n\t%v\n\t\n"), token.rep);
|
||||||
|
}
|
||||||
vcode.snprintf(U_CONSTANT_TO_PARAM("\n\t%v\n\t\n"), token.rep);
|
|
||||||
}
|
}
|
||||||
else if (strncmp(directive, U_CONSTANT_TO_PARAM("pcode")) == 0) // parallelization code (long running task)
|
else if (strncmp(directive, U_CONSTANT_TO_PARAM("pcode")) == 0) // parallelization code (long running task)
|
||||||
{
|
{
|
||||||
|
@ -342,15 +343,18 @@ public:
|
||||||
|
|
||||||
setDirectiveItem(directive, U_CONSTANT_SIZE("pcode"));
|
setDirectiveItem(directive, U_CONSTANT_SIZE("pcode"));
|
||||||
|
|
||||||
U_INTERNAL_ASSERT(token)
|
if (token)
|
||||||
|
{
|
||||||
|
if (U_STRING_FIND(token, 0, "return") != U_NOT_FOUND) U_WARNING("use of 'return' inside usp can cause problem, please avoid it");
|
||||||
|
|
||||||
token = UStringExt::substitute(token, '\n', U_CONSTANT_TO_PARAM("\n\t"));
|
token = UStringExt::substitute(token, '\n', U_CONSTANT_TO_PARAM("\n\t"));
|
||||||
|
|
||||||
(void) output0.reserve(20U + token.size());
|
(void) output0.reserve(20U + token.size());
|
||||||
|
|
||||||
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\t%v\n\t\n"), token.rep);
|
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\t%v\n\t\n"), token.rep);
|
||||||
|
|
||||||
(void) vcode.append(U_CONSTANT_TO_PARAM("\tif (UServer_Base::startParallelization()) { U_http_info.nResponseCode = HTTP_CONTINUE; return; }\n\t\n"));
|
(void) vcode.append(U_CONSTANT_TO_PARAM("\tif (UServer_Base::startParallelization()) { U_http_info.nResponseCode = HTTP_CONTINUE; return; }\n\t\n"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (strncmp(directive, U_CONSTANT_TO_PARAM("lcode")) == 0) // load balance code
|
else if (strncmp(directive, U_CONSTANT_TO_PARAM("lcode")) == 0) // load balance code
|
||||||
{
|
{
|
||||||
|
@ -358,19 +362,22 @@ public:
|
||||||
|
|
||||||
setDirectiveItem(directive, U_CONSTANT_SIZE("lcode"));
|
setDirectiveItem(directive, U_CONSTANT_SIZE("lcode"));
|
||||||
|
|
||||||
U_INTERNAL_ASSERT(token)
|
if (token)
|
||||||
|
{
|
||||||
|
if (U_STRING_FIND(token, 0, "return") != U_NOT_FOUND) U_WARNING("use of 'return' inside usp can cause problem, please avoid it");
|
||||||
|
|
||||||
token = UStringExt::substitute(token, '\n', U_CONSTANT_TO_PARAM("\n\t"));
|
token = UStringExt::substitute(token, '\n', U_CONSTANT_TO_PARAM("\n\t"));
|
||||||
|
|
||||||
(void) output0.reserve(20U + token.size());
|
(void) output0.reserve(20U + token.size());
|
||||||
|
|
||||||
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\t%v\n\t\n"), token.rep);
|
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\t%v\n\t\n"), token.rep);
|
||||||
|
|
||||||
(void) vcode.append(U_CONSTANT_TO_PARAM("\tif (UServer_Base::startParallelization()) { U_http_info.nResponseCode = HTTP_CONTINUE; return; }\n\t\n"));
|
(void) vcode.append(U_CONSTANT_TO_PARAM("\tif (UServer_Base::startParallelization()) { U_http_info.nResponseCode = HTTP_CONTINUE; return; }\n\t\n"));
|
||||||
|
|
||||||
# ifdef USE_LOAD_BALANCE
|
# ifdef USE_LOAD_BALANCE
|
||||||
(void) vcode.append(U_CONSTANT_TO_PARAM("\tif (UHTTP::manageRequestOnRemoteServer()) return;\n\t\n"));
|
(void) vcode.append(U_CONSTANT_TO_PARAM("\tif (UHTTP::manageRequestOnRemoteServer()) return;\n\t\n"));
|
||||||
# endif
|
# endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (strncmp(directive, U_CONSTANT_TO_PARAM("code")) == 0) // generic code
|
else if (strncmp(directive, U_CONSTANT_TO_PARAM("code")) == 0) // generic code
|
||||||
{
|
{
|
||||||
|
@ -380,6 +387,8 @@ public:
|
||||||
|
|
||||||
if (token)
|
if (token)
|
||||||
{
|
{
|
||||||
|
if (U_STRING_FIND(token, 0, "return") != U_NOT_FOUND) U_WARNING("use of 'return' inside usp can cause problem, please avoid it");
|
||||||
|
|
||||||
token = UStringExt::substitute(token, '\n', U_CONSTANT_TO_PARAM("\n\t"));
|
token = UStringExt::substitute(token, '\n', U_CONSTANT_TO_PARAM("\n\t"));
|
||||||
|
|
||||||
(void) output0.reserve(20U + token.size());
|
(void) output0.reserve(20U + token.size());
|
||||||
|
@ -479,12 +488,13 @@ public:
|
||||||
|
|
||||||
U_ASSERT(encoded.isQuoted())
|
U_ASSERT(encoded.isQuoted())
|
||||||
|
|
||||||
|
(void) output2.reserve(200U);
|
||||||
(void) http_header.reserve(200U + encoded.size());
|
(void) http_header.reserve(200U + encoded.size());
|
||||||
|
|
||||||
(void) http_header.snprintf(U_CONSTANT_TO_PARAM("\n\tU_ASSERT_EQUALS(UClientImage_Base::wbuffer->findEndHeader(),false)"
|
(void) http_header.snprintf(U_CONSTANT_TO_PARAM("\n\tU_ASSERT_EQUALS(UClientImage_Base::wbuffer->findEndHeader(),false)"
|
||||||
"\n\tU_http_info.endHeader = %.*s%u;"
|
"\n\t(void) UClientImage_Base::wbuffer->insert(0, U_CONSTANT_TO_PARAM(%v));\n\t\n"), encoded.rep);
|
||||||
"\n\t(void) UClientImage_Base::wbuffer->insert(0, U_CONSTANT_TO_PARAM(%v));\n\t\n"),
|
|
||||||
bheader ? U_CONSTANT_SIZE("(uint32_t)-") : 0, "(uint32_t)-", n, encoded.rep);
|
(void) output2.snprintf_add(U_CONSTANT_TO_PARAM("\n\tU_http_info.endHeader = %.*s%u;\n"), bheader ? U_CONSTANT_SIZE("(uint32_t)-") : 0, "(uint32_t)-", n);
|
||||||
}
|
}
|
||||||
else if (strncmp(directive, U_CONSTANT_TO_PARAM("number")) == 0)
|
else if (strncmp(directive, U_CONSTANT_TO_PARAM("number")) == 0)
|
||||||
{
|
{
|
||||||
|
@ -504,11 +514,12 @@ public:
|
||||||
|
|
||||||
setDirectiveItem(directive, U_CONSTANT_SIZE("puts"));
|
setDirectiveItem(directive, U_CONSTANT_SIZE("puts"));
|
||||||
|
|
||||||
U_INTERNAL_ASSERT(token)
|
if (token)
|
||||||
|
{
|
||||||
|
(void) output0.reserve(100U + token.size());
|
||||||
|
|
||||||
(void) output0.reserve(100U + token.size());
|
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\t(void) UClientImage_Base::wbuffer->append((%v));\n"), token.rep);
|
||||||
|
}
|
||||||
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\t(void) UClientImage_Base::wbuffer->append((%v));\n"), token.rep);
|
|
||||||
}
|
}
|
||||||
else if (strncmp(directive, U_CONSTANT_TO_PARAM("xmlputs")) == 0)
|
else if (strncmp(directive, U_CONSTANT_TO_PARAM("xmlputs")) == 0)
|
||||||
{
|
{
|
||||||
|
@ -516,11 +527,12 @@ public:
|
||||||
|
|
||||||
setDirectiveItem(directive, U_CONSTANT_SIZE("xmlputs"));
|
setDirectiveItem(directive, U_CONSTANT_SIZE("xmlputs"));
|
||||||
|
|
||||||
U_INTERNAL_ASSERT(token)
|
if (token)
|
||||||
|
{
|
||||||
|
(void) output0.reserve(100U + token.size());
|
||||||
|
|
||||||
(void) output0.reserve(100U + token.size());
|
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\tUSP_XML_PUTS((%v));\n"), token.rep);
|
||||||
|
}
|
||||||
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\tUSP_XML_PUTS((%v));\n"), token.rep);
|
|
||||||
}
|
}
|
||||||
else if (strncmp(directive, U_CONSTANT_TO_PARAM("cout")) == 0)
|
else if (strncmp(directive, U_CONSTANT_TO_PARAM("cout")) == 0)
|
||||||
{
|
{
|
||||||
|
@ -530,12 +542,13 @@ public:
|
||||||
|
|
||||||
setDirectiveItem(directive, U_CONSTANT_SIZE("cout"));
|
setDirectiveItem(directive, U_CONSTANT_SIZE("cout"));
|
||||||
|
|
||||||
U_INTERNAL_ASSERT(token)
|
if (token)
|
||||||
|
{
|
||||||
|
(void) output0.reserve(200U + token.size());
|
||||||
|
|
||||||
(void) output0.reserve(200U + token.size());
|
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\tusp_sz = UObject2String((%v), usp_buffer, sizeof(usp_buffer));"
|
||||||
|
"\n\t(void) UClientImage_Base::wbuffer->append(usp_buffer, usp_sz);\n"), token.rep);
|
||||||
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\tusp_sz = UObject2String((%v), usp_buffer, sizeof(usp_buffer));"
|
}
|
||||||
"\n\t(void) UClientImage_Base::wbuffer->append(usp_buffer, usp_sz);\n"), token.rep);
|
|
||||||
}
|
}
|
||||||
else if (strncmp(directive, U_CONSTANT_TO_PARAM("print")) == 0)
|
else if (strncmp(directive, U_CONSTANT_TO_PARAM("print")) == 0)
|
||||||
{
|
{
|
||||||
|
@ -547,26 +560,27 @@ public:
|
||||||
|
|
||||||
setDirectiveItem(directive, (bfor ? U_CONSTANT_SIZE("printfor") : U_CONSTANT_SIZE("print")));
|
setDirectiveItem(directive, (bfor ? U_CONSTANT_SIZE("printfor") : U_CONSTANT_SIZE("print")));
|
||||||
|
|
||||||
U_INTERNAL_ASSERT(token)
|
if (token)
|
||||||
|
|
||||||
(void) output0.reserve(200U + token.size());
|
|
||||||
|
|
||||||
UVector<UString> vec(token, ';');
|
|
||||||
|
|
||||||
if (bfor)
|
|
||||||
{
|
{
|
||||||
U_ASSERT_EQUALS(vec.size(), 5)
|
(void) output0.reserve(200U + token.size());
|
||||||
|
|
||||||
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\tfor (%v; %v; %v) { usp_sz = u__snprintf(usp_buffer, sizeof(usp_buffer), %v, %v);"
|
UVector<UString> vec(token, ';');
|
||||||
"(void) UClientImage_Base::wbuffer->append(usp_buffer, usp_sz); }\n"),
|
|
||||||
vec[0].rep, vec[1].rep, vec[2].rep, vec[3].rep, vec[4].rep);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
U_ASSERT_EQUALS(vec.size(), 2)
|
|
||||||
|
|
||||||
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\tusp_sz = u__snprintf(usp_buffer, sizeof(usp_buffer), %v, %v);"
|
if (bfor)
|
||||||
"(void) UClientImage_Base::wbuffer->append(usp_buffer, usp_sz);\n"), vec[0].rep, vec[1].rep);
|
{
|
||||||
|
U_ASSERT_EQUALS(vec.size(), 5)
|
||||||
|
|
||||||
|
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\tfor (%v; %v; %v) { usp_sz = u__snprintf(usp_buffer, sizeof(usp_buffer), %v, %v);"
|
||||||
|
"(void) UClientImage_Base::wbuffer->append(usp_buffer, usp_sz); }\n"),
|
||||||
|
vec[0].rep, vec[1].rep, vec[2].rep, vec[3].rep, vec[4].rep);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
U_ASSERT_EQUALS(vec.size(), 2)
|
||||||
|
|
||||||
|
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\tusp_sz = u__snprintf(usp_buffer, sizeof(usp_buffer), %v, %v);"
|
||||||
|
"(void) UClientImage_Base::wbuffer->append(usp_buffer, usp_sz);\n"), vec[0].rep, vec[1].rep);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -829,10 +843,10 @@ loop: distance = t.getDistance();
|
||||||
{
|
{
|
||||||
if (is_html) (void) http_header.append(U_CONSTANT_TO_PARAM("\n\tUHTTP::mime_index = U_html;\n"));
|
if (is_html) (void) http_header.append(U_CONSTANT_TO_PARAM("\n\tUHTTP::mime_index = U_html;\n"));
|
||||||
|
|
||||||
(void) http_header.append(U_CONSTANT_TO_PARAM("\n\tU_http_info.endHeader = 0;\n"));
|
(void) output2.append(U_CONSTANT_TO_PARAM("\n\tU_http_info.endHeader = 0;\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
UString result(1024U + declaration.size() + http_header.size() + output0.size() + output1.size() + vars.size());
|
UString result(1024U + declaration.size() + http_header.size() + output0.size() + output1.size() + output2.size() + vars.size());
|
||||||
|
|
||||||
result.snprintf(U_CONSTANT_TO_PARAM(
|
result.snprintf(U_CONSTANT_TO_PARAM(
|
||||||
"// %.*s.cpp - dynamic page translation (%.*s.usp => %.*s.cpp)\n"
|
"// %.*s.cpp - dynamic page translation (%.*s.usp => %.*s.cpp)\n"
|
||||||
|
@ -867,6 +881,7 @@ loop: distance = t.getDistance();
|
||||||
"%s"
|
"%s"
|
||||||
"%v"
|
"%v"
|
||||||
"%v"
|
"%v"
|
||||||
|
"%v"
|
||||||
"\t\n"
|
"\t\n"
|
||||||
"} }\n"),
|
"} }\n"),
|
||||||
basename_sz, basename_ptr,
|
basename_sz, basename_ptr,
|
||||||
|
@ -889,7 +904,8 @@ loop: distance = t.getDistance();
|
||||||
http_header.rep,
|
http_header.rep,
|
||||||
ptr8,
|
ptr8,
|
||||||
output0.rep,
|
output0.rep,
|
||||||
output1.rep);
|
output1.rep,
|
||||||
|
output2.rep);
|
||||||
|
|
||||||
UString name(200U);
|
UString name(200U);
|
||||||
|
|
||||||
|
@ -901,7 +917,7 @@ loop: distance = t.getDistance();
|
||||||
private:
|
private:
|
||||||
UTokenizer t;
|
UTokenizer t;
|
||||||
UVector<UString> vdefine;
|
UVector<UString> vdefine;
|
||||||
UString pinclude, usp, token, output0, output1, declaration, vcode, http_header, sseloop, vars;
|
UString pinclude, usp, token, output0, output1, output2, declaration, vcode, http_header, sseloop, vars;
|
||||||
const char* basename_ptr;
|
const char* basename_ptr;
|
||||||
uint32_t basename_sz;
|
uint32_t basename_sz;
|
||||||
bool bvar, bsession, bstorage, bfirst_pass, is_html, test_if_html, bpreprocessing_failed;
|
bool bvar, bsession, bstorage, bfirst_pass, is_html, test_if_html, bpreprocessing_failed;
|
||||||
|
|
|
@ -371,7 +371,7 @@ bool UMySqlStatement::setBindParam(UOrmDriver* pdrv)
|
||||||
|
|
||||||
MYSQL_BIND* mysql_param = mysql_vparam+i;
|
MYSQL_BIND* mysql_param = mysql_vparam+i;
|
||||||
|
|
||||||
if ((mysql_param->buffer_type = (enum_field_types)param->type) == U_UTF_VALUE)
|
if ((mysql_param->buffer_type = (enum_field_types)param->type) == (enum_field_types)U_UTF_VALUE)
|
||||||
{
|
{
|
||||||
U_INTERNAL_ASSERT_POINTER(param->pstr)
|
U_INTERNAL_ASSERT_POINTER(param->pstr)
|
||||||
U_INTERNAL_ASSERT(param->pstr->invariant())
|
U_INTERNAL_ASSERT(param->pstr->invariant())
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0134
|
0142
|
||||||
|
|
|
@ -3,12 +3,11 @@
|
||||||
#ifndef FORTUNE_H
|
#ifndef FORTUNE_H
|
||||||
#define FORTUNE_H 1
|
#define FORTUNE_H 1
|
||||||
|
|
||||||
#include <ulib/base/coder/xml.h>
|
|
||||||
|
|
||||||
#include <ulib/orm/orm.h>
|
#include <ulib/orm/orm.h>
|
||||||
#include <ulib/json/value.h>
|
#include <ulib/json/value.h>
|
||||||
#include <ulib/utility/uhttp.h>
|
#include <ulib/utility/uhttp.h>
|
||||||
#include <ulib/orm/orm_driver.h>
|
#include <ulib/orm/orm_driver.h>
|
||||||
|
#include <ulib/utility/xml_escape.h>
|
||||||
#include <ulib/net/server/client_image.h>
|
#include <ulib/net/server/client_image.h>
|
||||||
|
|
||||||
class Fortune {
|
class Fortune {
|
||||||
|
@ -33,16 +32,20 @@ public:
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Fortune(uint32_t _id, const UString& _message) : id(_id), message(_message)
|
Fortune(uint32_t _id, const UString& _message) : id(_id), message(100U)
|
||||||
{
|
{
|
||||||
U_TRACE_CTOR(5, Fortune, "%u,%V", _id, _message.rep)
|
U_TRACE_CTOR(5, Fortune, "%u,%V", _id, _message.rep)
|
||||||
|
|
||||||
|
UXMLEscape::encode(_message, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fortune(const Fortune& f) : id(f.id), message((void*)U_STRING_TO_PARAM(f.message))
|
Fortune(const Fortune& f) : id(f.id), message(100U)
|
||||||
{
|
{
|
||||||
U_TRACE_CTOR(5, Fortune, "%p", &f)
|
U_TRACE_CTOR(5, Fortune, "%p", &f)
|
||||||
|
|
||||||
U_MEMORY_TEST_COPY(f)
|
U_MEMORY_TEST_COPY(f)
|
||||||
|
|
||||||
|
UXMLEscape::encode(f.message, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Fortune()
|
~Fortune()
|
||||||
|
@ -137,7 +140,7 @@ public:
|
||||||
|
|
||||||
Fortune* elem;
|
Fortune* elem;
|
||||||
|
|
||||||
for (uint32_t i = 0, n = pvfortune->size(); i < n; ++i)
|
for (uint32_t sz, i = 0, n = pvfortune->size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
elem = pvfortune->at(i);
|
elem = pvfortune->at(i);
|
||||||
|
|
||||||
|
@ -150,7 +153,8 @@ public:
|
||||||
|
|
||||||
*pwbuffer++ = '>';
|
*pwbuffer++ = '>';
|
||||||
|
|
||||||
pwbuffer += u_xml_encode((const unsigned char*)U_STRING_TO_PARAM(elem->message), (unsigned char*)pwbuffer);
|
(void) memcpy(pwbuffer, elem->message.data(), sz = elem->message.size());
|
||||||
|
pwbuffer += sz;
|
||||||
|
|
||||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
|
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
|
||||||
u_put_unalignedp16(pwbuffer+8, U_MULTICHAR_CONSTANT16('r','>'));
|
u_put_unalignedp16(pwbuffer+8, U_MULTICHAR_CONSTANT16('r','>'));
|
||||||
|
|
|
@ -40,10 +40,10 @@ public:
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
unsigned char* dst;
|
unsigned char* dst;
|
||||||
UString token, name, value;
|
UString token, name, value;
|
||||||
uint8_t prefix_max, pattern;
|
uint8_t prefix_max = 0x00, pattern = 0x00;
|
||||||
UVector<UString> vline(content,'\n'), vtoken;
|
UVector<UString> vline(content,'\n'), vtoken;
|
||||||
uint32_t i, l, n = vline.size(), num, cnt = 0, idx, index;
|
uint32_t i, l, n = vline.size(), num, cnt = 0, idx, index;
|
||||||
bool cut = false, bvalue_is_indexed = false, binsert_dynamic_table = false;
|
bool bvalue_is_indexed = false, binsert_dynamic_table = false;
|
||||||
|
|
||||||
UHTTP2::HpackHeaderTableEntry* entry;
|
UHTTP2::HpackHeaderTableEntry* entry;
|
||||||
UHTTP2::HpackDynamicTable* dyntbl = &(UHTTP2::pConnection->odyntbl);
|
UHTTP2::HpackDynamicTable* dyntbl = &(UHTTP2::pConnection->odyntbl);
|
||||||
|
@ -79,7 +79,6 @@ start: token = vtoken[0];
|
||||||
U_INTERNAL_ASSERT_MAJOR(cnt, 0)
|
U_INTERNAL_ASSERT_MAJOR(cnt, 0)
|
||||||
|
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
cut = true;
|
|
||||||
}
|
}
|
||||||
else if (token.equal(U_CONSTANT_TO_PARAM("trim")))
|
else if (token.equal(U_CONSTANT_TO_PARAM("trim")))
|
||||||
{
|
{
|
||||||
|
@ -204,7 +203,7 @@ start: token = vtoken[0];
|
||||||
|
|
||||||
for (l = 5; l < num; ++l) value += ' ' + vtoken[l];
|
for (l = 5; l < num; ++l) value += ' ' + vtoken[l];
|
||||||
|
|
||||||
check1: if (vtoken[1].equal(U_CONSTANT_TO_PARAM("idx")) == false)
|
if (vtoken[1].equal(U_CONSTANT_TO_PARAM("idx")) == false)
|
||||||
{
|
{
|
||||||
// not-existing name
|
// not-existing name
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user