mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
sync
This commit is contained in:
parent
56ccb34441
commit
3539f934d4
|
@ -3,7 +3,7 @@
|
|||
AUTOMAKE_OPTIONS = no-dependencies ## dist-shar dist-zip
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
EXTRA_DIST = cdb configure.help TODO LICENSE* README* *.spec* \
|
||||
EXTRA_DIST = cdb configure.help TODO LICENSE* README* *.spec* ulib.html \
|
||||
ULib.m4 rpm.sh rpmpkgreq.lst rpmpkgreq.lst.suse openwrt \
|
||||
doc/Doxyfile doc/readme.txt shtool *.awk .travis.yml autogen.sh nativejson-benchmark \
|
||||
fuzz/http1-corpus fuzz/http2-corpus fuzz/build_libFuzzer.sh fuzz/Makefile.in fuzz/Makefile.am fuzz/uclient_fuzzer.cpp fuzz/uclient.cfg
|
||||
|
|
|
@ -444,7 +444,7 @@ top_builddir = @top_builddir@
|
|||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = no-dependencies ## dist-shar dist-zip
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
EXTRA_DIST = cdb configure.help TODO LICENSE* README* *.spec* \
|
||||
EXTRA_DIST = cdb configure.help TODO LICENSE* README* *.spec* ulib.html \
|
||||
ULib.m4 rpm.sh rpmpkgreq.lst rpmpkgreq.lst.suse openwrt \
|
||||
doc/Doxyfile doc/readme.txt shtool *.awk .travis.yml autogen.sh nativejson-benchmark \
|
||||
fuzz/http1-corpus fuzz/http2-corpus fuzz/build_libFuzzer.sh fuzz/Makefile.in fuzz/Makefile.am fuzz/uclient_fuzzer.cpp fuzz/uclient.cfg
|
||||
|
|
|
@ -13,7 +13,7 @@ It include as application example a powerful search engine with relative [web in
|
|||
|
||||
The current version offers the following features :
|
||||
|
||||
* HTTP/1.0 and 1.1 protocols supported and experimental implementations of HTTP/2 ([h2spec compliant](https://github.com/summerwind/h2spec)).
|
||||
* HTTP/1.0, 1.1 and HTTP/2 ([h2spec compliant](https://github.com/summerwind/h2spec)) protocols supported.
|
||||
* Persistent connections for HTTP/1.1 and Keep-Alive support for HTTP/1.0.
|
||||
* Browser cache management (headers: If-Modified-Since/Last-modified).
|
||||
* Chunk-encoding transfers support.
|
||||
|
@ -42,6 +42,7 @@ The current version offers the following features :
|
|||
* [C Servlet Support](http://bellard.org/tcc/) with libtcc (if available) as a backend for dynamic code generation (experimental).
|
||||
* Support for running Ruby on Rails applications natively (experimental).
|
||||
* Support for running natively PHP applications whith a php (embedded) library (experimental).
|
||||
* Support for load balance support between physical server via udp brodcast (experimental).
|
||||
* Preforking mode to improve concurrency with dedicated process for long-time request.
|
||||
* Support for Windows (without preforking).
|
||||
* Customizable builds (you can remove unneeded functionality).
|
||||
|
@ -78,6 +79,10 @@ It is the main software component of [city of Florence wireless network](http://
|
|||
|
||||
userver application server is since 10th round in the [TechEmpower's web framework benchmarks](http://www.techempower.com/benchmarks). This independent work tests a large number of frameworks and platforms against a set of tests common to web applications, such as JSON serialization, database queries and templating.
|
||||
|
||||
## Getting Started With ULib (donated generously by jonathan kelly)
|
||||
|
||||
* [ulib.html](https://github.com/stefanocasazza/ULib/blob/master/ulib.html)
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Fork it ( http://github.com/<my-github-username>/ULib/fork )
|
||||
|
|
2
configure
vendored
2
configure
vendored
|
@ -32158,7 +32158,7 @@ $as_echo "$ulib_cc_flag" >&6; }
|
|||
else
|
||||
## _FORTIFY_SOURCE is enabled by default from g++ 4.7.2
|
||||
MAYBE_FLAGS="$MAYBE_FLAGS -Wunsafe-loop-optimizations -Wno-unused-parameter -rdynamic -fdiagnostics-color=auto -Wmisleading-indentation"
|
||||
CXX_MAYBE_FLAGS="$CXX_MAYBE_FLAGS -Wc++11-compat -Wzero-as-null-pointer-constant -Wimplicit-fallthrough=0"
|
||||
CXX_MAYBE_FLAGS="$CXX_MAYBE_FLAGS -Wc++11-compat -Wzero-as-null-pointer-constant -Wno-implicit-fallthrough"
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc supported flags" >&5
|
||||
|
|
|
@ -2342,7 +2342,7 @@ if test "$ac_cv_c_compiler_gnu" = "yes" -a "x$GCC_IS_CLANG" = xno -a "x$OPERATIN
|
|||
else
|
||||
## _FORTIFY_SOURCE is enabled by default from g++ 4.7.2
|
||||
MAYBE_FLAGS="$MAYBE_FLAGS -Wunsafe-loop-optimizations -Wno-unused-parameter -rdynamic -fdiagnostics-color=auto -Wmisleading-indentation"
|
||||
CXX_MAYBE_FLAGS="$CXX_MAYBE_FLAGS -Wc++11-compat -Wzero-as-null-pointer-constant -Wimplicit-fallthrough=0"
|
||||
CXX_MAYBE_FLAGS="$CXX_MAYBE_FLAGS -Wc++11-compat -Wzero-as-null-pointer-constant -Wno-implicit-fallthrough"
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for gcc supported flags], ulib_cv_flags, [
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
// search to LDAP
|
||||
|
||||
char buffer[4096];
|
||||
const char* attr_name[] = { username.c_str(), password.c_str(), 0 };
|
||||
const char* attr_name[] = { username.c_str(), password.c_str(), U_NULLPTR };
|
||||
|
||||
(void) u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("%v=%s,%.*s"), subject_attr.rep, buf, U_STRING_TO_TRACE(LDAP_searchbase));
|
||||
|
||||
|
|
|
@ -125,11 +125,11 @@ private:
|
|||
U_DISALLOW_ASSIGN(UOrmTypeHandler_Base)
|
||||
};
|
||||
|
||||
#define U_ORM_TYPE_HANDLER(class_name, name_object_member, type_object_member) \
|
||||
UOrmTypeHandler<type_object_member>(((class_name*)pval)->name_object_member)
|
||||
#define U_ORM_TYPE_HANDLER(name_object_member, type_object_member) UOrmTypeHandler<type_object_member>(name_object_member)
|
||||
|
||||
/**
|
||||
* Converts Rows to a Type and the other way around. Provide template specializations to support your own complex types.
|
||||
* Converts Rows to a Type and the other way around.
|
||||
* Provide template specializations to support your own complex types.
|
||||
*
|
||||
* Take as example the following (simplified) class:
|
||||
*
|
||||
|
@ -140,30 +140,25 @@ private:
|
|||
* UString firstName;
|
||||
* };
|
||||
*
|
||||
* The UOrmTypeHandler must provide a custom bindParam and bindResult method:
|
||||
*
|
||||
* template <> class UOrmTypeHandler<Person> : public UOrmTypeHandler_Base {
|
||||
* public:
|
||||
* explicit UOrmTypeHandler(Person& val) : UOrmTypeHandler_Base(&val)
|
||||
* add this methods to the (simplified) class:
|
||||
*
|
||||
* void bindParam(UOrmStatement* stmt)
|
||||
* {
|
||||
* // the table is defined as Person (LastName VARCHAR(30), FirstName VARCHAR, Age INTEGER(3))
|
||||
*
|
||||
* stmt->bindParam(U_ORM_TYPE_HANDLER(Person, age, int));
|
||||
* stmt->bindParam(U_ORM_TYPE_HANDLER(Person, lastName, UString));
|
||||
* stmt->bindParam(U_ORM_TYPE_HANDLER(Person, firstName, UString));
|
||||
* stmt->bindParam(U_ORM_TYPE_HANDLER(age, int));
|
||||
* stmt->bindParam(U_ORM_TYPE_HANDLER( lastName, UString));
|
||||
* stmt->bindParam(U_ORM_TYPE_HANDLER(firstName, UString));
|
||||
* }
|
||||
*
|
||||
* void bindResult(UOrmStatement* stmt)
|
||||
* {
|
||||
* // the table is defined as Person (LastName VARCHAR(30), FirstName VARCHAR, Age INTEGER(3))
|
||||
*
|
||||
* stmt->bindResult(U_ORM_TYPE_HANDLER(Person, age, int));
|
||||
* stmt->bindResult(U_ORM_TYPE_HANDLER(Person, lastName, UString));
|
||||
* stmt->bindResult(U_ORM_TYPE_HANDLER(Person, firstName, UString));
|
||||
* stmt->bindResult(U_ORM_TYPE_HANDLER(age, int));
|
||||
* stmt->bindResult(U_ORM_TYPE_HANDLER( lastName, UString));
|
||||
* stmt->bindResult(U_ORM_TYPE_HANDLER(firstName, UString));
|
||||
* }
|
||||
* };
|
||||
*/
|
||||
|
||||
template <class T> class U_EXPORT UOrmTypeHandler : public UOrmTypeHandler_Base {
|
||||
|
@ -173,8 +168,19 @@ public:
|
|||
|
||||
// SERVICES
|
||||
|
||||
void bindParam( UOrmStatement* stmt);
|
||||
void bindResult(UOrmStatement* stmt);
|
||||
void bindParam(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<T>::bindParam(%p)", stmt)
|
||||
|
||||
((T*)pval)->bindParam(stmt);
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<T>::bindResult(%p)", stmt)
|
||||
|
||||
((T*)pval)->bindResult(stmt);
|
||||
}
|
||||
|
||||
private:
|
||||
U_DISALLOW_ASSIGN(UOrmTypeHandler)
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -178,7 +178,7 @@ public:
|
|||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -313,7 +313,7 @@ public:
|
|||
|
||||
HTTP2Push() : UEventTime(15L * 60L, 0L), message(U_STRING_FROM_CONSTANT("{aps:{content-available:1},check:health}")), token(U_CAPACITY)
|
||||
{
|
||||
U_TRACE_REGISTER_OBJECT(0, HTTP2Push, "", 0)
|
||||
U_TRACE_REGISTER_OBJECT(0, HTTP2Push, "", U_NULLPTR)
|
||||
|
||||
# ifdef USE_LIBCURL
|
||||
UCURL::initHTTP2Push("https://api.development.push.apple.com", "/certificates/samplepush/development.pem", "GoGo.Hopscotch");
|
||||
|
@ -337,7 +337,7 @@ public:
|
|||
|
||||
// child
|
||||
|
||||
token.snprintf(U_CONSTANT_TO_PARAM("dbdaeae86abcde56rtyww1859fb41d2c7b2cberrttyyy053ec48987847"), 0);
|
||||
(void) token.assign(U_CONSTANT_TO_PARAM("dbdaeae86abcde56rtyww1859fb41d2c7b2cberrttyyy053ec48987847"));
|
||||
|
||||
# ifdef USE_LIBCURL
|
||||
if (UCURL::sendHTTP2Push(token, message) == false)
|
||||
|
@ -381,7 +381,7 @@ static void usp_fork_businesses()
|
|||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect(0,0) == false)
|
||||
if (mc->connect(U_NULLPTR, 0) == false)
|
||||
{
|
||||
U_WARNING("usp_fork_businesses(): connection failed");
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ static void usp_fork_db()
|
|||
{
|
||||
U_NEW(UOrmStatement, pstmt_db, UOrmStatement(*psql_db, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
||||
|
||||
if (pstmt_db == 0)
|
||||
if (pstmt_db == U_NULLPTR)
|
||||
{
|
||||
U_WARNING("usp_fork_db(): we cound't connect to db");
|
||||
|
||||
|
|
|
@ -87,6 +87,24 @@ public:
|
|||
json.fromJSON(U_JSON_METHOD_HANDLER(message, UString));
|
||||
}
|
||||
|
||||
// ORM
|
||||
|
||||
void bindParam(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "Fortune::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(id, unsigned int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(message, UString));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "Fortune::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(id, unsigned int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(message, UString));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* dump(bool breset) const
|
||||
{
|
||||
|
@ -100,34 +118,11 @@ public:
|
|||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
U_DISALLOW_ASSIGN(Fortune)
|
||||
};
|
||||
|
||||
// ORM TEMPLATE SPECIALIZATIONS
|
||||
|
||||
template <> class U_EXPORT UOrmTypeHandler<Fortune> : public UOrmTypeHandler_Base {
|
||||
public:
|
||||
explicit UOrmTypeHandler(Fortune& val) : UOrmTypeHandler_Base(&val) {}
|
||||
|
||||
void bindParam(UOrmStatement* stmt) const
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Fortune>::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Fortune, id, unsigned int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Fortune, message, UString));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Fortune>::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Fortune, id, unsigned int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Fortune, message, UString));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@ static void usp_fork_fortune()
|
|||
{
|
||||
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
|
||||
|
||||
if (pstmt_fortune == 0)
|
||||
if (pstmt_fortune == U_NULLPTR)
|
||||
{
|
||||
U_WARNING("usp_fork_fortune(): we cound't connect to db");
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ static void usp_fork_mdb()
|
|||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect(0,0) == false)
|
||||
if (mc->connect(U_NULLPTR, 0) == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mdb(): connection failed");
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ static void usp_fork_mfortune()
|
|||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect(0,0) == false)
|
||||
if (mc->connect(U_NULLPTR, 0) == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mfortune(): connection failed");
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ static void usp_fork_mquery()
|
|||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect(0,0) == false)
|
||||
if (mc->connect(U_NULLPTR, 0) == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mquery(): connection disabled or failed");
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ static void usp_fork_mupdate()
|
|||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect(0,0) == false)
|
||||
if (mc->connect(U_NULLPTR, 0) == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mupdate(): connection disabled or failed");
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ static void usp_fork_query()
|
|||
{
|
||||
U_NEW(UOrmStatement, pstmt_query, UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
||||
|
||||
if (pstmt_query == 0)
|
||||
if (pstmt_query == U_NULLPTR)
|
||||
{
|
||||
U_WARNING("usp_fork_query(): we cound't connect to db");
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ static void usp_fork_update()
|
|||
U_NEW(UOrmStatement, pstmt1, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
||||
U_NEW(UOrmStatement, pstmt2, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
|
||||
|
||||
if (pstmt1 == 0 ||
|
||||
pstmt2 == 0)
|
||||
if (pstmt1 == U_NULLPTR ||
|
||||
pstmt2 == U_NULLPTR)
|
||||
{
|
||||
U_WARNING("usp_fork_update(): we cound't connect to db");
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
"\t\n" \
|
||||
"%s" \
|
||||
"%s" \
|
||||
"\n\tif (UHTTP::db_session == 0) UHTTP::initSession();\n" \
|
||||
"\n\tif (UHTTP::db_session == U_NULLPTR) UHTTP::initSession();\n" \
|
||||
"}"
|
||||
|
||||
#define USP_TEMPLATE \
|
||||
|
@ -533,8 +533,8 @@ public:
|
|||
buffer.snprintf(U_CONSTANT_TO_PARAM(USP_SESSION_INIT),
|
||||
size, ptr,
|
||||
size, ptr,
|
||||
(bsession ? "\n\tif (UHTTP::data_session == 0) U_NEW(UDataSession, UHTTP::data_session, UDataSession);\n\t" : ""),
|
||||
(bstorage ? "\n\tif (UHTTP::data_storage == 0) { U_NEW(UDataSession, UHTTP::data_storage, UDataSession(*UString::str_storage_keyid)); }\n\t" : ""));
|
||||
(bsession ? "\n\tif (UHTTP::data_session == U_NULLPTR) U_NEW(UDataSession, UHTTP::data_session, UDataSession);\n\t" : ""),
|
||||
(bstorage ? "\n\tif (UHTTP::data_storage == U_NULLPTR) { U_NEW(UDataSession, UHTTP::data_storage, UDataSession(*UString::str_storage_keyid)); }\n\t" : ""));
|
||||
|
||||
(void) declaration.append(buffer);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,24 @@ public:
|
|||
json.fromJSON(U_JSON_METHOD_HANDLER(randomNumber, unsigned int));
|
||||
}
|
||||
|
||||
// ORM
|
||||
|
||||
void bindParam(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "World::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(id, unsigned int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(randomNumber, unsigned int));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "World::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(id, unsigned int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(randomNumber, unsigned int));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* dump(bool breset) const
|
||||
{
|
||||
|
@ -68,34 +86,11 @@ public:
|
|||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
U_DISALLOW_ASSIGN(World)
|
||||
};
|
||||
|
||||
// ORM TEMPLATE SPECIALIZATIONS
|
||||
|
||||
template <> class U_EXPORT UOrmTypeHandler<World> : public UOrmTypeHandler_Base {
|
||||
public:
|
||||
explicit UOrmTypeHandler(World& val) : UOrmTypeHandler_Base(&val) {}
|
||||
|
||||
void bindParam(UOrmStatement* stmt) const
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<World>::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(World, id, unsigned int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(World, randomNumber, unsigned int));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<World>::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(World, id, unsigned int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(World, randomNumber, unsigned int));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -2406,6 +2406,10 @@ window_update:
|
|||
pConnection->inp_window = (HTTP2_MAX_WINDOW_SIZE + pConnection->inp_window);
|
||||
|
||||
sendWindowUpdate();
|
||||
|
||||
U_INTERNAL_DUMP("nerror = %u", nerror)
|
||||
|
||||
if (nerror != NO_ERROR) goto end;
|
||||
}
|
||||
|
||||
goto loop;
|
||||
|
@ -3478,9 +3482,15 @@ loop: U_DUMP("pStream->id = %u pStream->state = (%u, %s) pStream->headers(%u) =
|
|||
|
||||
if (pConnection->inp_window < 8192) // Send Window Update if current window size is not sufficient
|
||||
{
|
||||
pConnection->inp_window = HTTP2_MAX_WINDOW_SIZE;
|
||||
pConnection->inp_window = HTTP2_MAX_WINDOW_SIZE - pConnection->inp_window;
|
||||
|
||||
sendWindowUpdate();
|
||||
|
||||
U_INTERNAL_DUMP("nerror = %u", nerror)
|
||||
|
||||
if (nerror != NO_ERROR) goto err;
|
||||
|
||||
pConnection->inp_window = HTTP2_MAX_WINDOW_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
|
@ -19,7 +19,7 @@ static void usp_fork_db()
|
|||
{
|
||||
U_NEW(UOrmStatement, pstmt_db, UOrmStatement(*psql_db, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
||||
|
||||
if (pstmt_db == 0)
|
||||
if (pstmt_db == U_NULLPTR)
|
||||
{
|
||||
U_WARNING("usp_fork_db(): we cound't connect to db");
|
||||
|
||||
|
|
|
@ -87,6 +87,24 @@ public:
|
|||
json.fromJSON(U_JSON_METHOD_HANDLER(message, UString));
|
||||
}
|
||||
|
||||
// ORM
|
||||
|
||||
void bindParam(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "Fortune::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(id, unsigned int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(message, UString));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "Fortune::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(id, unsigned int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(message, UString));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* dump(bool breset) const
|
||||
{
|
||||
|
@ -100,34 +118,11 @@ public:
|
|||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
U_DISALLOW_ASSIGN(Fortune)
|
||||
};
|
||||
|
||||
// ORM TEMPLATE SPECIALIZATIONS
|
||||
|
||||
template <> class U_EXPORT UOrmTypeHandler<Fortune> : public UOrmTypeHandler_Base {
|
||||
public:
|
||||
explicit UOrmTypeHandler(Fortune& val) : UOrmTypeHandler_Base(&val) {}
|
||||
|
||||
void bindParam(UOrmStatement* stmt) const
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Fortune>::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Fortune, id, unsigned int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Fortune, message, UString));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Fortune>::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Fortune, id, unsigned int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Fortune, message, UString));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@ static void usp_fork_fortune()
|
|||
{
|
||||
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
|
||||
|
||||
if (pstmt_fortune == 0)
|
||||
if (pstmt_fortune == U_NULLPTR)
|
||||
{
|
||||
U_WARNING("usp_fork_fortune(): we cound't connect to db");
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ static void usp_fork_mdb()
|
|||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect(0,0) == false)
|
||||
if (mc->connect(U_NULLPTR, 0) == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mdb(): connection failed");
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ static void usp_fork_mfortune()
|
|||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect(0,0) == false)
|
||||
if (mc->connect(U_NULLPTR, 0) == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mfortune(): connection failed");
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ static void usp_fork_mquery()
|
|||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect(0,0) == false)
|
||||
if (mc->connect(U_NULLPTR, 0) == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mquery(): connection disabled or failed");
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ static void usp_fork_mupdate()
|
|||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect(0,0) == false)
|
||||
if (mc->connect(U_NULLPTR, 0) == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mupdate(): connection disabled or failed");
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ static void usp_fork_query()
|
|||
{
|
||||
U_NEW(UOrmStatement, pstmt_query, UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
||||
|
||||
if (pstmt_query == 0)
|
||||
if (pstmt_query == U_NULLPTR)
|
||||
{
|
||||
U_WARNING("usp_fork_query(): we cound't connect to db");
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ static void usp_fork_update()
|
|||
U_NEW(UOrmStatement, pstmt1, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
||||
U_NEW(UOrmStatement, pstmt2, UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
|
||||
|
||||
if (pstmt1 == 0 ||
|
||||
pstmt2 == 0)
|
||||
if (pstmt1 == U_NULLPTR ||
|
||||
pstmt2 == U_NULLPTR)
|
||||
{
|
||||
U_WARNING("usp_fork_update(): we cound't connect to db");
|
||||
|
||||
|
|
|
@ -55,6 +55,24 @@ public:
|
|||
json.fromJSON(U_JSON_METHOD_HANDLER(randomNumber, unsigned int));
|
||||
}
|
||||
|
||||
// ORM
|
||||
|
||||
void bindParam(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "World::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(id, unsigned int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(randomNumber, unsigned int));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "World::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(id, unsigned int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(randomNumber, unsigned int));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* dump(bool breset) const
|
||||
{
|
||||
|
@ -68,34 +86,11 @@ public:
|
|||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
U_DISALLOW_ASSIGN(World)
|
||||
};
|
||||
|
||||
// ORM TEMPLATE SPECIALIZATIONS
|
||||
|
||||
template <> class U_EXPORT UOrmTypeHandler<World> : public UOrmTypeHandler_Base {
|
||||
public:
|
||||
explicit UOrmTypeHandler(World& val) : UOrmTypeHandler_Base(&val) {}
|
||||
|
||||
void bindParam(UOrmStatement* stmt) const
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<World>::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(World, id, unsigned int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(World, randomNumber, unsigned int));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<World>::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(World, id, unsigned int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(World, randomNumber, unsigned int));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -68,6 +68,7 @@ userver {
|
|||
#REQ_TIMEOUT 300
|
||||
#PLUGIN "ssi http"
|
||||
#ORM_DRIVER "sqlite mysql"
|
||||
ORM_DRIVER sqlite
|
||||
DOCUMENT_ROOT benchmark/docroot
|
||||
PLUGIN_DIR ../../../../src/ulib/net/server/plugin/.libs
|
||||
ORM_DRIVER_DIR ../../../../src/ulib/orm/driver/.libs
|
||||
|
|
|
@ -60,6 +60,30 @@ public:
|
|||
return (_address < p._address);
|
||||
}
|
||||
|
||||
void bindParam(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "Person::bindParam(%p)", stmt)
|
||||
|
||||
// the table is defined as Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Age INTEGER)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(_lastName, UString));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(_firstName, UString));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(_address, UString));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(_age, int));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "Person::bindResult(%p)", stmt)
|
||||
|
||||
// the table is defined as Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Age INTEGER)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(_lastName, UString));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(_firstName, UString));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(_address, UString));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(_age, int));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* dump(bool breset) const
|
||||
{
|
||||
|
@ -75,7 +99,7 @@ public:
|
|||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -117,6 +141,22 @@ public:
|
|||
U_TRACE_UNREGISTER_OBJECT(5, Test1)
|
||||
}
|
||||
|
||||
void bindParam(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Test1>::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(id, int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(name, UString));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Test1>::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(id, int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(name, UString));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* dump(bool breset) const
|
||||
{
|
||||
|
@ -130,7 +170,7 @@ public:
|
|||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -138,56 +178,6 @@ private:
|
|||
Test1& operator=(const Test1&) { return *this; }
|
||||
};
|
||||
|
||||
// ORM TEMPLATE SPECIALIZATIONS
|
||||
|
||||
template <> class UOrmTypeHandler<Person> : public UOrmTypeHandler_Base {
|
||||
public:
|
||||
explicit UOrmTypeHandler(Person& val) : UOrmTypeHandler_Base(&val) {}
|
||||
|
||||
// the table is defined as Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Age INTEGER)
|
||||
|
||||
void bindParam(UOrmStatement* stmt) const
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Person>::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Person, _lastName, UString));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Person, _firstName, UString));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Person, _address, UString));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Person, _age, int));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Person>::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Person, _lastName, UString));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Person, _firstName, UString));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Person, _address, UString));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Person, _age, int));
|
||||
}
|
||||
};
|
||||
|
||||
template <> class U_EXPORT UOrmTypeHandler<Test1> : public UOrmTypeHandler_Base {
|
||||
public:
|
||||
explicit UOrmTypeHandler(Test1& val) : UOrmTypeHandler_Base(&val) {}
|
||||
|
||||
void bindParam(UOrmStatement* stmt) const
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Test1>::bindParam(%p)", stmt)
|
||||
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Test1, id, int));
|
||||
stmt->bindParam(U_ORM_TYPE_HANDLER(Test1, name, UString));
|
||||
}
|
||||
|
||||
void bindResult(UOrmStatement* stmt)
|
||||
{
|
||||
U_TRACE(0, "UOrmTypeHandler<Test1>::bindResult(%p)", stmt)
|
||||
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Test1, id, int));
|
||||
stmt->bindResult(U_ORM_TYPE_HANDLER(Test1, name, UString));
|
||||
}
|
||||
};
|
||||
|
||||
static void testBinding(UOrmSession* sql)
|
||||
{
|
||||
U_TRACE(5, "testBinding(%p)", sql)
|
||||
|
@ -488,7 +478,7 @@ U_EXPORT main(int argc, char* argv[])
|
|||
value1 = 10;
|
||||
str = "Hello 'World'";
|
||||
float f = 3.1415926565;
|
||||
time_t tt = time(NULL);
|
||||
time_t tt = time(U_NULLPTR);
|
||||
struct tm t = *localtime(&tt);
|
||||
|
||||
cout << asctime(&t);
|
||||
|
|
402
ulib.html
Normal file
402
ulib.html
Normal file
|
@ -0,0 +1,402 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>ULib</title>
|
||||
<!-- 2017-05-07 Sun 13:21 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="generator" content="Org-mode" />
|
||||
<meta name="author" content="nemsys" />
|
||||
<style type="text/css">
|
||||
<!--/*--><![CDATA[/*><!--*/
|
||||
.title { text-align: center; }
|
||||
.todo { font-family: monospace; color: red; }
|
||||
.done { color: green; }
|
||||
.tag { background-color: #eee; font-family: monospace;
|
||||
padding: 2px; font-size: 80%; font-weight: normal; }
|
||||
.timestamp { color: #bebebe; }
|
||||
.timestamp-kwd { color: #5f9ea0; }
|
||||
.right { margin-left: auto; margin-right: 0px; text-align: right; }
|
||||
.left { margin-left: 0px; margin-right: auto; text-align: left; }
|
||||
.center { margin-left: auto; margin-right: auto; text-align: center; }
|
||||
.underline { text-decoration: underline; }
|
||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
|
||||
p.verse { margin-left: 3%; }
|
||||
pre {
|
||||
border: 1px solid #ccc;
|
||||
box-shadow: 3px 3px 3px #eee;
|
||||
padding: 8pt;
|
||||
font-family: monospace;
|
||||
overflow: auto;
|
||||
margin: 1.2em;
|
||||
}
|
||||
pre.src {
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
padding-top: 1.2em;
|
||||
}
|
||||
pre.src:before {
|
||||
display: none;
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
top: -10px;
|
||||
right: 10px;
|
||||
padding: 3px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
pre.src:hover:before { display: inline;}
|
||||
pre.src-sh:before { content: 'sh'; }
|
||||
pre.src-bash:before { content: 'sh'; }
|
||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
|
||||
pre.src-R:before { content: 'R'; }
|
||||
pre.src-perl:before { content: 'Perl'; }
|
||||
pre.src-java:before { content: 'Java'; }
|
||||
pre.src-sql:before { content: 'SQL'; }
|
||||
|
||||
table { border-collapse:collapse; }
|
||||
caption.t-above { caption-side: top; }
|
||||
caption.t-bottom { caption-side: bottom; }
|
||||
td, th { vertical-align:top; }
|
||||
th.right { text-align: center; }
|
||||
th.left { text-align: center; }
|
||||
th.center { text-align: center; }
|
||||
td.right { text-align: right; }
|
||||
td.left { text-align: left; }
|
||||
td.center { text-align: center; }
|
||||
dt { font-weight: bold; }
|
||||
.footpara:nth-child(2) { display: inline; }
|
||||
.footpara { display: block; }
|
||||
.footdef { margin-bottom: 1em; }
|
||||
.figure { padding: 1em; }
|
||||
.figure p { text-align: center; }
|
||||
.inlinetask {
|
||||
padding: 10px;
|
||||
border: 2px solid gray;
|
||||
margin: 10px;
|
||||
background: #ffffcc;
|
||||
}
|
||||
#org-div-home-and-up
|
||||
{ text-align: right; font-size: 70%; white-space: nowrap; }
|
||||
textarea { overflow-x: auto; }
|
||||
.linenr { font-size: smaller }
|
||||
.code-highlighted { background-color: #ffff00; }
|
||||
.org-info-js_info-navigation { border-style: none; }
|
||||
#org-info-js_console-label
|
||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
|
||||
.org-info-js_search-highlight
|
||||
{ background-color: #ffff00; color: #000000; font-weight: bold; }
|
||||
/*]]>*/-->
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
@licstart The following is the entire license notice for the
|
||||
JavaScript code in this tag.
|
||||
|
||||
Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||
|
||||
The JavaScript code in this tag is free software: you can
|
||||
redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License (GNU GPL) as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option)
|
||||
any later version. The code is distributed WITHOUT ANY WARRANTY;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
|
||||
|
||||
As additional permission under GNU GPL version 3 section 7, you
|
||||
may distribute non-source (e.g., minimized or compacted) forms of
|
||||
that code without the copy of the GNU GPL normally required by
|
||||
section 4, provided you include this license notice and a URL
|
||||
through which recipients can access the Corresponding Source.
|
||||
|
||||
|
||||
@licend The above is the entire license notice
|
||||
for the JavaScript code in this tag.
|
||||
*/
|
||||
<!--/*--><![CDATA[/*><!--*/
|
||||
function CodeHighlightOn(elem, id)
|
||||
{
|
||||
var target = document.getElementById(id);
|
||||
if(null != target) {
|
||||
elem.cacheClassElem = elem.className;
|
||||
elem.cacheClassTarget = target.className;
|
||||
target.className = "code-highlighted";
|
||||
elem.className = "code-highlighted";
|
||||
}
|
||||
}
|
||||
function CodeHighlightOff(elem, id)
|
||||
{
|
||||
var target = document.getElementById(id);
|
||||
if(elem.cacheClassElem)
|
||||
elem.className = elem.cacheClassElem;
|
||||
if(elem.cacheClassTarget)
|
||||
target.className = elem.cacheClassTarget;
|
||||
}
|
||||
/*]]>*///-->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1 class="title">ULib</h1>
|
||||
<div id="table-of-contents">
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#sec-1">1. Getting Started With ULib</a>
|
||||
<ul>
|
||||
<li><a href="#sec-1-1">1.1. What is userver</a></li>
|
||||
<li><a href="#sec-1-2">1.2. Get a copy of the ULib source code</a></li>
|
||||
<li><a href="#sec-1-3">1.3. configure your build</a></li>
|
||||
<li><a href="#sec-1-4">1.4. configure userver</a></li>
|
||||
<li><a href="#sec-1-5">1.5. debug environment</a></li>
|
||||
<li><a href="#sec-1-6">1.6. Running your server (static pages)</a></li>
|
||||
<li><a href="#sec-1-7">1.7. USP ULib Servlet Page (dynamic pages)</a></li>
|
||||
<li><a href="#sec-1-8">1.8. Tags</a>
|
||||
<ul>
|
||||
<li><a href="#sec-1-8-1">1.8.1. c++ header file .h</a></li>
|
||||
<li><a href="#sec-1-8-2">1.8.2. c++ code file .cpp</a></li>
|
||||
<li><a href="#sec-1-8-3">1.8.3. html template</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#sec-1-9">1.9. Compiling</a></li>
|
||||
<li><a href="#sec-1-10">1.10. Test</a></li>
|
||||
<li><a href="#sec-1-11">1.11. SECURITY</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-sec-1" class="outline-2">
|
||||
<h2 id="sec-1"><span class="section-number-2">1</span> Getting Started With ULib</h2>
|
||||
<div class="outline-text-2" id="text-1">
|
||||
<p>
|
||||
To help those curious souls that want to see if userver is a good fit for their needs I have recorded my own experiences below.
|
||||
Firstly a huge thankyou to Stefano Casazza not only for making ULib but for all his patience in answering all my questions.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-1" class="outline-3">
|
||||
<h3 id="sec-1-1"><span class="section-number-3">1.1</span> What is userver</h3>
|
||||
<div class="outline-text-3" id="text-1-1">
|
||||
<p>
|
||||
UServer is a extensible plugin based web server that is build on top of ULib.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
ULib is installed as a set of shared object libraries and header files (like Boost).
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-2" class="outline-3">
|
||||
<h3 id="sec-1-2"><span class="section-number-3">1.2</span> Get a copy of the ULib source code</h3>
|
||||
<div class="outline-text-3" id="text-1-2">
|
||||
<p>
|
||||
git clone <a href="https://github.com/stefanocasazza/ULib.git">https://github.com/stefanocasazza/ULib.git</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-3" class="outline-3">
|
||||
<h3 id="sec-1-3"><span class="section-number-3">1.3</span> configure your build</h3>
|
||||
<div class="outline-text-3" id="text-1-3">
|
||||
<p>
|
||||
For those of you like me who havn't had much experience playing with autotools read the config help or:
|
||||
</p>
|
||||
|
||||
<p>
|
||||
./configure -h
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Having now decided on what features you need let ./configure do its magic.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example:
|
||||
./configure –enable-debug –with-sqlite3
|
||||
</p>
|
||||
|
||||
<p>
|
||||
make
|
||||
sudo make install
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-4" class="outline-3">
|
||||
<h3 id="sec-1-4"><span class="section-number-3">1.4</span> configure userver</h3>
|
||||
<div class="outline-text-3" id="text-1-4">
|
||||
<p>
|
||||
Assuming you haven't changed the PREFIX make will install userver to /usr/local
|
||||
</p>
|
||||
|
||||
<p>
|
||||
At this point we need to configure /usr/local/etc/userver.cfg
|
||||
The file is well annotated at a bare minimum setup the following values:
|
||||
<br>
|
||||
DOCUMENT_ROOT /var/www<br>
|
||||
LOG_FILE userver.log<br>
|
||||
PLUGIN "http"<br>
|
||||
PLUGIN_DIR /usr/local/libexec<br>
|
||||
ORM_DRIVER_DIR /usr/local/libexec<br>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
This environment variables are for ORM management:
|
||||
<br>
|
||||
ORM_DRIVER "sqlite"<br>
|
||||
ORM_OPTION "host=localhost user=user password=pass character-set=utf8 dbname=/path_to_db/dbname.db"
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-5" class="outline-3">
|
||||
<h3 id="sec-1-5"><span class="section-number-3">1.5</span> debug environment</h3>
|
||||
<div class="outline-text-3" id="text-1-5">
|
||||
<p>
|
||||
userver_tcp expects some environment variables for debug mode to save typing it is easiest to put these into a bash script like this:
|
||||
</p>
|
||||
|
||||
<p>
|
||||
#!/bin/sh
|
||||
</p>
|
||||
|
||||
<p>
|
||||
UTRACE="0 20M 0"<br>
|
||||
UTRACE_SIGNAL="0 20M 0"<br>
|
||||
#UOBJDUMP="0 10M 100"<br>
|
||||
#USIMERR="error.sim"<br>
|
||||
export UTRACE UOBJDUMP USIMERR UTRACE_SIGNAL
|
||||
</p>
|
||||
|
||||
<p>
|
||||
userver_tcp
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-sec-1-6" class="outline-3">
|
||||
<h3 id="sec-1-6"><span class="section-number-3">1.6</span> Running your server (static pages)</h3>
|
||||
<div class="outline-text-3" id="text-1-6">
|
||||
<p>
|
||||
Once you have configured your userver.cfg and placed the relevant html documents in your docroot just execute the bash script above.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Point your browser to localhost/filename you should now have a working server.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-7" class="outline-3">
|
||||
<h3 id="sec-1-7"><span class="section-number-3">1.7</span> USP ULib Servlet Page (dynamic pages)</h3>
|
||||
<div class="outline-text-3" id="text-1-7">
|
||||
<p>
|
||||
userver offers a wide variety of ways to generate dynamic content we will be looking at USP method.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A USP page is a multi-format document that permits c++ code to be embedded into html.
|
||||
This document is then compiled into a shared object library that will be executed by userver.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The document consists of overloaded html comment tags that the USP compiler will extract.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-8" class="outline-3">
|
||||
<h3 id="sec-1-8"><span class="section-number-3">1.8</span> Tags</h3>
|
||||
<div class="outline-text-3" id="text-1-8">
|
||||
<p>
|
||||
Have a look at the examples in the ULib source directory ULib/src/ulib/net/server/plugin/usp for usage but in very simple terms.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-8-1" class="outline-4">
|
||||
<h4 id="sec-1-8-1"><span class="section-number-4">1.8.1</span> c++ header file .h</h4>
|
||||
<div class="outline-text-4" id="text-1-8-1">
|
||||
<p>
|
||||
<!–#declaration
|
||||
–>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-8-2" class="outline-4">
|
||||
<h4 id="sec-1-8-2"><span class="section-number-4">1.8.2</span> c++ code file .cpp</h4>
|
||||
<div class="outline-text-4" id="text-1-8-2">
|
||||
<p>
|
||||
<!–#code
|
||||
UString name = U_STRING_FROM_CONSTANT("Hello World");
|
||||
–>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-8-3" class="outline-4">
|
||||
<h4 id="sec-1-8-3"><span class="section-number-4">1.8.3</span> html template</h4>
|
||||
<div class="outline-text-4" id="text-1-8-3">
|
||||
<p>
|
||||
<h1>Hello <!–#xmlputs name –></h1>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-9" class="outline-3">
|
||||
<h3 id="sec-1-9"><span class="section-number-3">1.9</span> Compiling</h3>
|
||||
<div class="outline-text-3" id="text-1-9">
|
||||
<p>
|
||||
Once you have written your .usp file it needs to be compiled.
|
||||
I found it easiest to navigate to the folder where the file.usp was saved and execute the compilation in the shell for example:
|
||||
</p>
|
||||
|
||||
<p>
|
||||
cd /srv/http/servlet
|
||||
/usr/local/bin/usp_compile.sh test
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Please note that usp_compile.sh wants the usp file without the extension.
|
||||
The shell script will call the relevant programs to generate c++ code from the usp file and finally call gcc and libtool to create a shared library.Any compilation errors will be output to console and no .so file will be generated.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
It would be trivial to execute usp_compile as a custom command from most IDEs.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-10" class="outline-3">
|
||||
<h3 id="sec-1-10"><span class="section-number-3">1.10</span> Test</h3>
|
||||
<div class="outline-text-3" id="text-1-10">
|
||||
<p>
|
||||
Now point your browser to localhost/nameofusp and userver will execute the USP file.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-1-11" class="outline-3">
|
||||
<h3 id="sec-1-11"><span class="section-number-3">1.11</span> SECURITY</h3>
|
||||
<div class="outline-text-3" id="text-1-11">
|
||||
<p>
|
||||
As with all web servers do not run them as the root user.
|
||||
This introduction has been written to give you an idea of the ULib/UServer workflow. It 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. It is your responsibility to secure your web server and follow sound security conscious programming practices.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<p class="author">Author: nemsys</p>
|
||||
<p class="date">Created: 2017-05-07 Sun 13:21</p>
|
||||
<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 25.2.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10)</p>
|
||||
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user