added a new app sample

This commit is contained in:
hyung-hwan 2020-08-18 17:04:51 +00:00
parent 6693fdc059
commit 14ee9d2382
55 changed files with 1880 additions and 66 deletions

View File

@ -369,7 +369,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -344,7 +344,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -351,7 +351,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -377,7 +377,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -342,7 +342,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -342,7 +342,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

27
qse/configure vendored
View File

@ -805,7 +805,6 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
@ -911,7 +910,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@ -1164,15 +1162,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1310,7 +1299,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@ -1463,7 +1452,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@ -18415,7 +18403,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -18461,7 +18449,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -18485,7 +18473,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -18530,7 +18518,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -18554,7 +18542,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -25122,7 +25110,7 @@ QSE_PROJECT_AUTHOR="${PACKAGE_BUGREPORT}"
QSE_PROJECT_URL="${PACKAGE_URL}"
ac_config_files="$ac_config_files Makefile include/Makefile include/qse/Makefile include/qse/cmn/Makefile include/qse/cry/Makefile include/qse/si/Makefile include/qse/awk/Makefile include/qse/sed/Makefile include/qse/xli/Makefile include/qse/http/Makefile include/qse/rad/Makefile include/qse/dhcp/Makefile include/qse/sttp/Makefile lib/Makefile lib/cmn/Makefile lib/cry/Makefile lib/si/Makefile lib/awk/Makefile lib/awkmod/Makefile lib/sed/Makefile lib/xli/Makefile lib/http/Makefile lib/rad/Makefile lib/dhcp/Makefile lib/sttp/Makefile lib/qsecmn.pc lib/qsecry.pc lib/qsesi.pc lib/qsesed.pc lib/qseawk.pc lib/qsexli.pc lib/qsehttp.pc lib/qserad.pc lib/qsedhcp.pc cmd/Makefile cmd/awk/Makefile cmd/sed/Makefile cmd/xli/Makefile cmd/http/Makefile samples/Makefile samples/cmn/Makefile samples/cry/Makefile samples/si/Makefile samples/awk/Makefile samples/sed/Makefile samples/xli/Makefile samples/http/Makefile samples/rad/Makefile samples/dhcp/Makefile regress/Makefile regress/awk/Makefile regress/awk/regress.sh regress/sed/Makefile regress/sed/regress.sh doc/Makefile doc/Doxyfile tools/Makefile"
ac_config_files="$ac_config_files Makefile include/Makefile include/qse/Makefile include/qse/cmn/Makefile include/qse/cry/Makefile include/qse/si/Makefile include/qse/awk/Makefile include/qse/sed/Makefile include/qse/xli/Makefile include/qse/http/Makefile include/qse/rad/Makefile include/qse/dhcp/Makefile include/qse/sttp/Makefile lib/Makefile lib/cmn/Makefile lib/cry/Makefile lib/si/Makefile lib/awk/Makefile lib/awkmod/Makefile lib/sed/Makefile lib/xli/Makefile lib/http/Makefile lib/rad/Makefile lib/dhcp/Makefile lib/sttp/Makefile lib/qsecmn.pc lib/qsecry.pc lib/qsesi.pc lib/qsesed.pc lib/qseawk.pc lib/qsexli.pc lib/qsehttp.pc lib/qserad.pc lib/qsedhcp.pc cmd/Makefile cmd/awk/Makefile cmd/sed/Makefile cmd/xli/Makefile cmd/http/Makefile samples/Makefile samples/cmn/Makefile samples/cry/Makefile samples/si/Makefile samples/awk/Makefile samples/sed/Makefile samples/xli/Makefile samples/http/Makefile samples/rad/Makefile samples/dhcp/Makefile samples/app/Makefile regress/Makefile regress/awk/Makefile regress/awk/regress.sh regress/sed/Makefile regress/sed/regress.sh doc/Makefile doc/Doxyfile tools/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@ -26340,6 +26328,7 @@ do
"samples/http/Makefile") CONFIG_FILES="$CONFIG_FILES samples/http/Makefile" ;;
"samples/rad/Makefile") CONFIG_FILES="$CONFIG_FILES samples/rad/Makefile" ;;
"samples/dhcp/Makefile") CONFIG_FILES="$CONFIG_FILES samples/dhcp/Makefile" ;;
"samples/app/Makefile") CONFIG_FILES="$CONFIG_FILES samples/app/Makefile" ;;
"regress/Makefile") CONFIG_FILES="$CONFIG_FILES regress/Makefile" ;;
"regress/awk/Makefile") CONFIG_FILES="$CONFIG_FILES regress/awk/Makefile" ;;
"regress/awk/regress.sh") CONFIG_FILES="$CONFIG_FILES regress/awk/regress.sh" ;;

View File

@ -1122,6 +1122,7 @@ AC_CONFIG_FILES([
samples/http/Makefile
samples/rad/Makefile
samples/dhcp/Makefile
samples/app/Makefile
regress/Makefile
regress/awk/Makefile
regress/awk/regress.sh

View File

@ -287,7 +287,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -345,7 +345,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -385,7 +385,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -336,7 +336,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -367,7 +367,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -334,7 +334,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -334,7 +334,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -334,7 +334,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -334,7 +334,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -336,7 +336,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -350,7 +350,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -336,7 +336,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -336,7 +336,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -379,7 +379,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -497,7 +497,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -432,7 +432,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -475,7 +475,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -372,7 +372,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -367,7 +367,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -389,7 +389,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -367,7 +367,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -390,7 +390,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -447,7 +447,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -366,7 +366,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -395,7 +395,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -345,7 +345,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -287,7 +287,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -289,7 +289,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -1 +1 @@
SUBDIRS = cmn cry si awk sed xli http rad dhcp
SUBDIRS = cmn cry si awk sed xli http rad dhcp app

View File

@ -345,7 +345,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -354,7 +353,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = cmn cry si awk sed xli http rad dhcp
SUBDIRS = cmn cry si awk sed xli http rad dhcp app
all: all-recursive
.SUFFIXES:

178
qse/samples/app/Main.cpp Normal file
View File

@ -0,0 +1,178 @@
#include "MainApp.hpp"
#include <qse/cmn/main.h>
#include <qse/cmn/opt.h>
#include <qse/cmn/time.h>
#include <qse/si/sio.h>
#include <locale.h>
static void print_usage (const qse_cli_t* cli)
{
qse_fprintf (QSE_STDERR, QSE_T("[USAGE] %s [options]\n"), cli->verb);
qse_fprintf (QSE_STDERR, QSE_T("Options as follows:\n"));
qse_fprintf (QSE_STDERR, QSE_T(" --foreground run the program in the foreground mode\n"));
qse_fprintf (QSE_STDERR, QSE_T(" --guardian=yes|no run the program under the guardian process\n"));
qse_fprintf (QSE_STDERR, QSE_T(" --chroot=path specify the directory to chroot to\n"));
qse_fprintf (QSE_STDERR, QSE_T(" --sysconfdir=path specify the directory to store system configuration\n"));
qse_fprintf (QSE_STDERR, QSE_T(" --logfile=path specify the log file\n"));
qse_fprintf (QSE_STDERR, QSE_T(" --logtype=string specify logging types\n"));
qse_fprintf (QSE_STDERR, QSE_T(" --loglevel=string specify logging levels\n"));
qse_fprintf (QSE_STDERR, QSE_T(" --gate-addresses=string\n"));
qse_fprintf (QSE_STDERR, QSE_T(" specify the control channel address\n"));
qse_fprintf (QSE_STDERR, QSE_T(" --chroot=path speficy the special root\n"));
qse_fprintf (QSE_STDERR, QSE_T("\n"));
qse_fprintf (QSE_STDERR, QSE_T("logging type string: one or more of the followings delimited by a comma:\n"));
qse_fprintf (QSE_STDERR, QSE_T(" console, file, syslog\n"));
qse_fprintf (QSE_STDERR, QSE_T("logging level string: one or more of the followings delimited by a comma:\n"));
qse_fprintf (QSE_STDERR, QSE_T(" panic, alert, critical, error, warning, notice, info, debug\n"));
qse_fprintf (QSE_STDERR, QSE_T(" each item may get suffixed with +, -, ! to mean\n"));
qse_fprintf (QSE_STDERR, QSE_T(" 'higher', 'lower', 'not' respectively (e.g. info+,notice!,alert!,debug)\n"));
}
static int handle_cli_error (qse_cli_t* cli, qse_cli_error_code_t code, const qse_char_t* name, const qse_char_t* value)
{
switch (code)
{
case QSE_CLI_ERROR_INVALID_OPTNAME:
qse_fprintf (QSE_STDERR, QSE_T("[ERROR] unknown option - %s\n"), name);
break;
case QSE_CLI_ERROR_MISSING_OPTNAME:
qse_fprintf (QSE_STDERR, QSE_T("[ERROR] missing option - %s\n"), name);
break;
case QSE_CLI_ERROR_REDUNDANT_OPTVAL:
qse_fprintf (QSE_STDERR, QSE_T("[ERROR] redundant value %s for %s\n"), value, name);
break;
case QSE_CLI_ERROR_MISSING_OPTVAL:
qse_fprintf (QSE_STDERR, QSE_T("[ERROR] missing value for %s\n"), name);
break;
case QSE_CLI_ERROR_MEMORY:
qse_fprintf (QSE_STDERR, QSE_T("[ERROR] memory error in processing %s\n"), name);
break;
default:
qse_fprintf (QSE_STDERR, QSE_T("[ERROR] unknown cli error - %d\n"), code);
break;
}
print_usage (cli);
return -1;
}
static int parse_cli (int argc, qse_char_t* argv[], qse_cli_t* cli)
{
static const qse_char_t* optsta[] =
{
QSE_T("--"), QSE_NULL
};
static qse_cli_opt_t opts[] =
{
{ QSE_T("foreground"), QSE_CLI_DISCRETIONARY_OPTVAL },
{ QSE_T("guardian"), QSE_CLI_REQUIRE_OPTVAL },
{ QSE_T("chroot"), QSE_CLI_REQUIRE_OPTVAL },
{ QSE_T("gate-addresses"), QSE_CLI_REQUIRE_OPTVAL },
{ QSE_T("sysconfdir"), QSE_CLI_REQUIRE_OPTVAL },
{ QSE_T("logfile"), QSE_CLI_REQUIRE_OPTVAL },
{ QSE_T("logtype"), QSE_CLI_REQUIRE_OPTVAL },
{ QSE_T("loglevel"), QSE_CLI_REQUIRE_OPTVAL },
{ QSE_NULL, 0 }
};
static qse_cli_data_t cli_data =
{
handle_cli_error,
optsta,
QSE_T("="),
opts,
QSE_NULL
};
return qse_parsecli(cli, QSE_NULL, argc, argv, &cli_data);
}
static int app_main (int argc, qse_char_t* argv[])
{
qse_cli_t cli;
int rc = -1;
/* parse command line */
if (parse_cli(argc, argv, &cli) <= -1) return -1;
if (qse_getncliparams(&cli) > 0)
{
print_usage (&cli);
qse_fprintf (QSE_STDERR, QSE_T("<error> redundant cli parameters"));
qse_clearcli (&cli);
return -1;
}
try
{
MainApp main_app;
const qse_char_t* tmp;
bool foreground = false;
tmp = qse_getclioptval(&cli, QSE_T("foreground"));
if (tmp) foreground = (tmp[0] == '\0' || qse_strcasecmp(tmp, APP_YES) == 0);
tmp = qse_getclioptval(&cli, QSE_T("guardian"));
if (tmp) main_app.setGuardian(qse_strcasecmp(tmp, APP_YES) == 0);
tmp = qse_getclioptval(&cli, QSE_T("chroot"));
if (tmp) main_app.setChroot (tmp);
tmp = qse_getclioptval(&cli, QSE_T("sysconfdir"));
if (tmp) main_app.setSysconfDir (tmp);
tmp = qse_getclioptval(&cli, QSE_T("logfile"));
if (tmp) main_app.setLogFile (tmp);
tmp = qse_getclioptval(&cli, QSE_T("logtype"));
if (tmp) main_app.setLogType (tmp);
tmp = qse_getclioptval(&cli, QSE_T("loglevel"));
if (tmp) main_app.setLogLevel (tmp);
tmp = qse_getclioptval(&cli, QSE_T("gate-addresses"));
if (tmp) main_app.setGateAddresses (tmp);
if (!foreground && main_app.daemonize(true) <= -1)
{
qse_printf (QSE_T("Error: unable to daemonize the process\n"));
rc = -1;
}
else
{
rc = main_app.run(foreground);
}
}
catch (QSE::Exception& e)
{
qse_printf (QSE_T("Exception: %js\n"), QSE_EXCEPTION_NAME(e), QSE_EXCEPTION_MSG(e));
}
catch (...)
{
qse_printf (QSE_T("Exception: unknown exception\n"));
}
qse_clearcli (&cli);
return rc;
}
int main (int argc, char* argv[])
{
int rc;
setlocale (LC_ALL, "");
qse_open_stdsios ();
rc = qse_run_main(argc, argv, app_main);
qse_close_stdsios ();
return rc;
}

275
qse/samples/app/MainApp.cpp Normal file
View File

@ -0,0 +1,275 @@
#include "MainApp.hpp"
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <qse/si/sio.h>
// ---------------------------------------------------------------------------
MainApp::Env::Env (MainApp* app, QSE::Mmgr* mmgr): SkvEnv(mmgr), app(app), log_type_preset(false), log_level_preset(false)
{
this->addItem (APP_ENV_LOG_TYPE,
APP_LOG_TYPE_FILE,
(ProbeProc)&MainApp::Env::probe_log_type);
this->addItem (
APP_ENV_LOG_LEVEL,
QSE_T("info+"),
(ProbeProc)&MainApp::Env::probe_log_level);
this->addItem (
APP_ENV_CHROOT,
QSE_T(""),
(ProbeProc)&MainApp::Env::probe_chroot);
this->addItem (
APP_ENV_GATE_ADDRESSES,
APP_GATE_ADDRESSES,
(ProbeProc)&MainApp::Env::probe_gate_addresses);
this->addItem (
APP_ENV_GATE_MAX_CONNECTIONS,
QSE_Q(APP_GATE_MAX_CONNECTIONS),
(ProbeProc)&MainApp::Env::probe_gate_max_connections);
this->addItem (
APP_ENV_GATE_TIMEOUT,
APP_GATE_TIMEOUT,
(ProbeProc)&MainApp::Env::probe_gate_timeout);
}
int MainApp::Env::probe_log_type (const qse_char_t* v)
{
int tmask = 0;
const qse_char_t* p = v;
qse_cstr_t tok;
while (p)
{
p = qse_strtok(p, QSE_T(","), &tok);
if (qse_strxcmp(tok.ptr, tok.len, APP_LOG_TYPE_FILE) == 0)
tmask |= QSE_LOG_FILE;
else if (qse_strxcmp(tok.ptr, tok.len, APP_LOG_TYPE_SYSLOG) == 0)
tmask |= QSE_LOG_SYSLOG;
else if (qse_strxcmp(tok.ptr, tok.len, APP_LOG_TYPE_CONSOLE) == 0)
tmask |= QSE_LOG_CONSOLE;
else return -1;
};
if (!this->log_type_preset)
{
qse_log_target_data_t logtype;
this->app->getLogTarget (logtype);
this->app->setLogTarget (tmask, logtype);
}
return 0;
}
int MainApp::Env::probe_log_level (const qse_char_t* v)
{
if (v[0] == '\0' || qse_stristype(v, QSE_CTYPE_SPACE)) return -1;
int prio = qse_get_log_priority_by_name(v, QSE_T(","));
if (prio == 0) return -1; // unknown name inside
if (!this->log_level_preset) this->app->setLogPriorityMask(prio);
return 0;
}
int MainApp::Env::probe_chroot (const qse_char_t* v)
{
// nothing to inspect
if (v[0] != '\0' && qse_stristype(v, QSE_CTYPE_SPACE)) return -1;
this->chroot.update (v);
return 0;
}
int MainApp::Env::probe_gate_addresses (const qse_char_t* v)
{
if (v[0] == '\0' || qse_stristype(v, QSE_CTYPE_SPACE)) return -1;
this->gate_addresses.update (v);
return 0;
}
int MainApp::Env::probe_gate_max_connections (const qse_char_t* v)
{
if (v[0] == QSE_T('\0')) return -1;
if (!qse_stristype(v, QSE_CTYPE_DIGIT)) return -1;
/* don't care about the overflow */
unsigned int num = qse_strtoui(v, 10, QSE_NULL);
if (num < APP_GATE_MAX_CONNECTIONS_MIN || num > APP_GATE_MAX_CONNECTIONS_MAX) return -1;
this->gate_max_connections = num;
// TODO:
// this->app->setMaxTcpGateConnections (this->gate_max_connections);
return 0;
}
int MainApp::Env::probe_gate_timeout (const qse_char_t* v)
{
if (v[0] == QSE_T('\0')) return -1;
/* don't care about the overflow */
qse_ntime_t tmout;
if (qse_str_to_ntime(v, &tmout) <= -1) return -1;
this->gate_timeout = tmout;
return 0;
}
// ---------------------------------------------------------------------------
// TODO: get application name... use it for log files and for other purposes...
MainApp::MainApp (QSE::Mmgr* mmgr): QSE::App(mmgr), exit_code(0), guardian(true), conffile(APP_INI_FILE), env(this), tcp_gate(this)
{
}
MainApp::~MainApp ()
{
}
int MainApp::run (bool foreground)
{
QSE::App::SignalSet sigs;
sigs.set (SIGINT);
sigs.set (SIGHUP);
sigs.set (SIGTERM);
sigs.set (SIGUSR1);
sigs.set (SIGUSR2);
if (this->guardProcess(sigs, this->guardian) > 0)
{
this->acceptSignals (sigs);
this->setName (APP_NAME);
this->init_logger (foreground);
// assuming the above statements outside 'try..catch' throw no exceptions,
// no log message should be produced before configuration is loaded fully.
// any exceptions thrown before entering 'run()' is handled in Main.cc.
// for instance, setSysconfDir() which is supposed to be called in Main.cc
// may throw an exception. but it's treated as fatal error that prevents
// the program start-up in Main.cc.
try
{
int x = this->load_config();
QSE_APP_LOG1 (this, QSE_LOG_INFO, QSE_T("starting application %d\n"), (int)getpid());
if (x <= -1) QSE_APP_LOG1 (this, QSE_LOG_WARNING, QSE_T("unable to load configuration from %js\n"), this->conffile.getData());
else QSE_APP_LOG1 (this, QSE_LOG_INFO, QSE_T("loaded configuration from %js\n"), this->conffile.getData());
this->chroot_if_needed ();
this->tcp_gate.setBindAddress (this->gate_addresses.isEmpty()? this->env.getGateAddresses(): this->gate_addresses.getData());
if (this->tcp_gate.start() <= -1)
{
QSE_APP_LOG1 (this, QSE_LOG_ERROR, QSE_T("starting %d\n"), (int)getpid());
this->exit_code = 88;
goto done;
}
// TODO: start other worker threads and joins on them
this->tcp_gate.join ();
done:
QSE_APP_LOG2 (this, QSE_LOG_INFO, QSE_T("exiting application %d with code %d\n"), (int)getpid(), this->exit_code);
}
catch (QSE::Exception& e)
{
QSE_APP_LOG2 (this, QSE_LOG_INFO, QSE_T("terminating application for exception - %js - %js\n"), QSE_EXCEPTION_NAME(e), QSE_EXCEPTION_MSG(e));
}
catch (...)
{
QSE_APP_LOG0 (this, QSE_LOG_INFO, QSE_T("terminating application for unknown exception\n"));
}
this->discardSignals (sigs);
return this->exit_code;
}
this->neglectSignals (sigs, true);
return 0;
}
void MainApp::on_signal (int sig)
{
if (!this->isGuardian())
{
QSE_APP_LOG2 (this, QSE_LOG_INFO, QSE_T("terminating application %d on signal %d\n"), (int)getpid(), sig);
this->stop ((sig == SIGSEGV)? 99: 0);
}
}
void MainApp::stop (int code)
{
this->exit_code = code;
this->tcp_gate.stop ();
// TODO: stop all other worker threads...
}
void MainApp::setSysconfDir (const qse_char_t* v)
{
this->sysconfdir.update (v);
if (!this->sysconfdir.isEmpty())
{
this->conffile = this->sysconfdir;
if (this->conffile.getLastChar() != '/') this->conffile.append (QSE_T("/"));
this->conffile.append (QSE_T(APP_INI_FILE_));
}
}
void MainApp::init_logger (bool foreground)
{
qse_log_target_data_t logtgt;
memset (&logtgt, 0, QSE_SIZEOF(logtgt));
this->setLogOption (QSE_LOG_INCLUDE_PID | QSE_LOG_KEEP_FILE_OPEN);
this->setLogPriorityMask (QSE_LOG_ALL_PRIORITIES);
if (!this->loglevel.isEmpty() && this->env.probe_log_level(this->loglevel.getData()) >= 0) this->env.log_level_preset = true;
logtgt.file = this->logfile.isEmpty()? APP_LOG_FILE: this->logfile.getData();
this->setLogTarget (QSE_LOG_FILE, logtgt);
if (!this->logtype.isEmpty() && this->env.probe_log_type(this->logtype.getData()) >= 0) this->env.log_type_preset = true;
}
int MainApp::load_config ()
{
int n = this->env.load(this->conffile.getData());
// reset these to false so that ENVSET over the control channel
// take effect. these might be set to true in init_logger()
// and load_config() doesn't apply the relevant items when they are true
this->env.log_type_preset = false;
this->env.log_level_preset = false;
return n;
}
void MainApp::chroot_if_needed ()
{
const qse_char_t* root;
root = this->chroot_path.getData();
if (root[0] == '\0') root = this->env.getChroot();
if (root[0] != '\0')
{
if (this->chroot(root) <= -1)
{
QSE_APP_LOG1 (this, QSE_LOG_WARNING, QSE_T("unable to chroot to %js\n"), root);
}
else
{
QSE_APP_LOG1 (this, QSE_LOG_INFO, QSE_T("chrooted to %js\n"), root);
}
}
}

130
qse/samples/app/MainApp.hpp Normal file
View File

@ -0,0 +1,130 @@
#ifndef _MAINAPP_CLASS_
#define _MAINAPP_CLASS_
#include <qse/si/App.hpp>
#include <qse/si/Mutex.hpp>
#include <qse/xli/SkvEnv.hpp>
#include "TcpGate.hpp"
#define APP_NAME QSE_T("app01")
#define APP_VERSION QSE_T("1.0.0")
#define APP_INI_FILE_ "app01.ini"
#define APP_LOG_FILE_ "app01.log"
#define APP_FILE_PERM 0600
#if defined(APP_CFG_DIR_)
# define APP_INI_FILE QSE_T(APP_CFG_DIR_ "/" APP_INI_FILE_)
# define APP_CFG_DIR QSE_T(APP_CFG_DIR_)
#else
# define APP_INI_FILE QSE_T("/etc/" APP_INI_FILE_)
# define APP_CFG_DIR QSE_T("/etc")
#endif
#if defined(APP_LOG_DIR_)
# define APP_LOG_FILE QSE_T(APP_LOG_DIR_ "/" APP_LOG_FILE_)
#else
# define APP_LOG_FILE QSE_T("/var/log/" APP_LOG_FILE_)
#endif
#define APP_YES QSE_T("yes")
#define APP_NO QSE_T("no")
#define APP_GATE_ADDRESSES QSE_T("[::]:9998,0.0.0.0:9998")
#define APP_GATE_MAX_CONNECTIONS_MIN 0 // 0 means unlimited, however
#define APP_GATE_MAX_CONNECTIONS_MAX 100
#define APP_GATE_MAX_CONNECTIONS 30
#define APP_GATE_TIMEOUT QSE_T("-1.000000000")
#define APP_LOG_TYPE_FILE QSE_T("file")
#define APP_LOG_TYPE_SYSLOG QSE_T("syslog")
#define APP_LOG_TYPE_CONSOLE QSE_T("console")
#define APP_ENV_LOG_TYPE QSE_T("MAIN*LOG_TYPE")
#define APP_ENV_LOG_LEVEL QSE_T("MAIN*LOG_LEVEL")
#define APP_ENV_CHROOT QSE_T("MAIN*CHROOT")
#define APP_ENV_GATE_ADDRESSES QSE_T("GATE*ADDRESSES")
#define APP_ENV_GATE_MAX_CONNECTIONS QSE_T("GATE*MAX_CONNECTIONS")
#define APP_ENV_GATE_TIMEOUT QSE_T("GATE*TIMEOUT")
class MainApp: public QSE::App
{
public:
class Env: public QSE::SkvEnv
{
public:
friend class MainApp;
Env (MainApp* app, QSE::Mmgr* mmgr = QSE_NULL);
const qse_char_t* getChroot () const { return this->chroot.getData(); }
const qse_char_t* getGateAddresses () const { return this->gate_addresses.getData(); }
unsigned int getGateMaxConnections () const { return this->gate_max_connections; }
const qse_ntime_t* getGateTimeout () const { return &this->gate_timeout; }
protected:
MainApp* app;
QSE::String chroot;
QSE::String gate_addresses;
unsigned int gate_max_connections;
qse_ntime_t gate_timeout;
private:
bool log_type_preset;
bool log_level_preset;
int probe_log_type (const qse_char_t* v);
int probe_log_level (const qse_char_t* v);
int probe_chroot (const char_t* v);
int probe_gate_addresses (const qse_char_t* v);
int probe_gate_max_connections (const qse_char_t* v);
int probe_gate_timeout (const qse_char_t* v);
};
MainApp (QSE::Mmgr* mmgr = QSE_NULL);
~MainApp ();
int run (bool foreground);
void stop (int code);
// assignment of bool to int, -1 means it's not set.
void setGuardian (bool guardian) { this->guardian = guardian; };
void setChroot (const qse_char_t* v) { this->chroot_path.update (v); }
void setSysconfDir (const qse_char_t* v);
void setLogFile (const qse_char_t* v) { this->logfile.update (v); }
void setLogType (const qse_char_t* v) { this->logtype.update (v); }
void setLogLevel (const qse_char_t* v) { this->loglevel.update (v); }
void setGateAddresses (const qse_char_t* v) { this->gate_addresses.update (v); }
QSE::Mutex& getEnvMutex() { return this->env_mutex; }
Env& getEnv() { return this->env; }
const Env& getEnv() const { return this->env; }
const QSE::String& getConfFile() const { return this->conffile; }
protected:
int exit_code;
bool guardian;
QSE::String chroot_path;
QSE::String sysconfdir;
QSE::String logfile;
QSE::String logtype;
QSE::String loglevel;
QSE::String gate_addresses;
QSE::String conffile;
QSE::Mutex env_mutex;
Env env;
TcpGate tcp_gate;
void on_signal (int sig);
void init_logger (bool foreground);
int load_config ();
void chroot_if_needed ();
};
#endif

View File

@ -0,0 +1,24 @@
AUTOMAKE_OPTIONS = nostdinc
AM_CPPFLAGS = \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(includedir)
bin_PROGRAMS =
AM_LDFLAGS = -L../../lib/xli -L../../lib/sttp -L../../lib/si -L../../lib/cmn
LDADD = -lqsexli -lqsesttp -lqsesi -lqsecmn
if WIN32
LDADD += $(UNICOWS_LIBS)
endif
if ENABLE_CXX
bin_PROGRAMS += app01
app01_SOURCES = Main.cpp MainApp.cpp MainApp.hpp TcpGate.cpp TcpGate.hpp
endif

732
qse/samples/app/Makefile.in Normal file
View File

@ -0,0 +1,732 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = $(am__EXEEXT_1)
@WIN32_TRUE@am__append_1 = $(UNICOWS_LIBS)
@ENABLE_CXX_TRUE@am__append_2 = app01
subdir = samples/app
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/lx_find_mpi.m4 \
$(top_srcdir)/m4/qse_try_cflags.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@ENABLE_CXX_TRUE@am__EXEEXT_1 = app01$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am__app01_SOURCES_DIST = Main.cpp MainApp.cpp MainApp.hpp TcpGate.cpp \
TcpGate.hpp
@ENABLE_CXX_TRUE@am_app01_OBJECTS = Main.$(OBJEXT) MainApp.$(OBJEXT) \
@ENABLE_CXX_TRUE@ TcpGate.$(OBJEXT)
app01_OBJECTS = $(am_app01_OBJECTS)
app01_LDADD = $(LDADD)
am__DEPENDENCIES_1 =
@WIN32_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
app01_DEPENDENCIES = $(am__DEPENDENCIES_2)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/Main.Po ./$(DEPDIR)/MainApp.Po \
./$(DEPDIR)/TcpGate.Po
am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_@AM_V@)
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
am__v_CXX_0 = @echo " CXX " $@;
am__v_CXX_1 =
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(app01_SOURCES)
DIST_SOURCES = $(am__app01_SOURCES_DIST)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_MODE = @BUILD_MODE@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DL_LIBS = @DL_LIBS@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAVE_CXX = @HAVE_CXX@
HAVE_CXX11 = @HAVE_CXX11@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
LN_S = @LN_S@
LTDL_LIBS = @LTDL_LIBS@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MPICC = @MPICC@
MPI_CFLAGS = @MPI_CFLAGS@
MPI_CLDFLAGS = @MPI_CLDFLAGS@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
MYSQL_LIBS = @MYSQL_LIBS@
MYSQL_VERSION = @MYSQL_VERSION@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
PACKAGE_VERSION_PATCH = @PACKAGE_VERSION_PATCH@
PATH_SEPARATOR = @PATH_SEPARATOR@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
QSE_PROJECT_AUTHOR = @QSE_PROJECT_AUTHOR@
QSE_PROJECT_URL = @QSE_PROJECT_URL@
QSE_SIZEOF_CHAR = @QSE_SIZEOF_CHAR@
QSE_SIZEOF_DOUBLE = @QSE_SIZEOF_DOUBLE@
QSE_SIZEOF_FLOAT = @QSE_SIZEOF_FLOAT@
QSE_SIZEOF_INT = @QSE_SIZEOF_INT@
QSE_SIZEOF_LONG = @QSE_SIZEOF_LONG@
QSE_SIZEOF_LONG_DOUBLE = @QSE_SIZEOF_LONG_DOUBLE@
QSE_SIZEOF_LONG_LONG = @QSE_SIZEOF_LONG_LONG@
QSE_SIZEOF_OFF64_T = @QSE_SIZEOF_OFF64_T@
QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@
QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@
QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@
QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@
QUADMATH_LIBS = @QUADMATH_LIBS@
RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
SSL_LIBS = @SSL_LIBS@
STRIP = @STRIP@
TRUE = @TRUE@
UCI_LIBS = @UCI_LIBS@
UNICOWS_LIBS = @UNICOWS_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_pthread_config = @ax_pthread_config@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = nostdinc
AM_CPPFLAGS = \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(includedir)
AM_LDFLAGS = -L../../lib/xli -L../../lib/sttp -L../../lib/si -L../../lib/cmn
LDADD = -lqsexli -lqsesttp -lqsesi -lqsecmn $(am__append_1)
@ENABLE_CXX_TRUE@app01_SOURCES = Main.cpp MainApp.cpp MainApp.hpp TcpGate.cpp TcpGate.hpp
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign samples/app/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign samples/app/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
|| test -f $$p1 \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
app01$(EXEEXT): $(app01_OBJECTS) $(app01_DEPENDENCIES) $(EXTRA_app01_DEPENDENCIES)
@rm -f app01$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(app01_OBJECTS) $(app01_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Main.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MainApp.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TcpGate.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.cpp.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f ./$(DEPDIR)/Main.Po
-rm -f ./$(DEPDIR)/MainApp.Po
-rm -f ./$(DEPDIR)/TcpGate.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/Main.Po
-rm -f ./$(DEPDIR)/MainApp.Po
-rm -f ./$(DEPDIR)/TcpGate.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

497
qse/samples/app/TcpGate.cpp Normal file
View File

@ -0,0 +1,497 @@
#include "TcpGate.hpp"
#include "MainApp.hpp"
#include <qse/sttp/Sttp.hpp>
#include <qse/cmn/HashTable.hpp>
#include <qse/cmn/ErrorGrab.hpp>
#include <qse/cmn/fmt.h>
// --------------------------------------------------------------------------
#define CMD_OK "OK"
#define CMD_ERR "ERR"
#define CMD_WARN "WARN"
#define CMD_DISCON "DISCON"
#define CMD_SHTDWN "SHTDWN"
#define CMD_ENVGET "ENVGET"
#define CMD_ENVSET "ENVSET"
#define CMD_ENVLST "ENVLST"
#define CMD_ENVITM "ENVITM"
#define PROC_CHECK_ARG_COUNT(cmd,n) do { \
if (cmd.getArgCount() != (n)) { \
this->sendErrCmd (E_ENARGS, (const qse_mchar_t*)QSE_NULL); \
return 0; \
} \
} while(0)
#define PROC_CHECK_ARG_COUNT2(cmd,n1,n2) do { \
if (cmd.getArgCount() != (n1) && cmd.getArgCount() != (n2)) { \
this->sendErrCmd (E_ENARGS, (const qse_mchar_t*)QSE_NULL); \
return 0; \
} \
} while(0)
#define PROC_CHECK_ARG_COUNT_RANGE(cmd,n1,n2) do { \
if (cmd.getArgCount() < (n1) || cmd.getArgCount() > (n2)) { \
this->sendErrCmd (E_ENARGS, (const qse_mchar_t*)QSE_NULL); \
return 0; \
} \
} while(0)
class Proto: public QSE::Sttp
{
public:
typedef int (Proto::*CmdProc) (const QSE::SttpCmd& cmd);
Proto (MainApp* app, QSE::Socket* sck): QSE::Sttp(), app(app), sck(sck)
{
this->cmd_dict.insert (QSE_T(CMD_DISCON), &Proto::proc_discon);
this->cmd_dict.insert (QSE_T(CMD_SHTDWN), &Proto::proc_shtdwn);
this->cmd_dict.insert (QSE_T(CMD_ENVLST), &Proto::proc_envlst);
this->cmd_dict.insert (QSE_T(CMD_ENVGET), &Proto::proc_envget);
this->cmd_dict.insert (QSE_T(CMD_ENVSET), &Proto::proc_envset);
}
int sendCmd (const qse_mchar_t* cmd, qse_size_t nargs, ...)
{
int x;
va_list ap;
va_start (ap, nargs);
if (QSE_APP_LOG_ENABLED(this->app, QSE_LOG_INFO))
{
va_list xap;
int h = (int)this->sck->getHandle();
va_copy (xap, ap);
// ugly - any better way to call QSE_APP_LOGX in a single call? better to store arguments to a buffer first and call QSE_APP_LOGX with it?
switch (nargs)
{
case 0:
QSE_APP_LOG2 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %hs\n"), h, cmd);
break;
case 1:
QSE_APP_LOG3 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %hs %hs\n"), h, cmd, va_arg(xap, qse_mchar_t*));
break;
case 2:
{
qse_mchar_t* x[] = { va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*) };
QSE_APP_LOG4 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %hs %hs %hs\n"), h, cmd, x[0], x[1]);
break;
}
case 3:
{
qse_mchar_t* x[] = { va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*) };
QSE_APP_LOG5 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %hs %hs %hs %hs\n"), h, cmd, x[0], x[1], x[2]);
break;
}
case 4:
{
qse_mchar_t* x[] = { va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*) };
QSE_APP_LOG6 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %hs %hs %hs %hs %hs\n"), h, cmd, x[0], x[1], x[2], x[3]);
break;
}
case 5:
{
qse_mchar_t* x[] = { va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*) };
QSE_APP_LOG7 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %hs %hs %hs %hs %hs %hs\n"), h, cmd, x[0], x[1], x[2], x[3], x[4]);
break;
}
case 6:
{
qse_mchar_t* x[] = { va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*) };
QSE_APP_LOG8 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %hs %hs %hs %hs %hs %hs %hs\n"), h, cmd, x[0], x[1], x[2], x[3], x[4], x[5]);
break;
}
case 7:
{
qse_mchar_t* x[] = { va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*) };
QSE_APP_LOG9 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %hs %hs %hs %hs %hs %hs %hs %hs\n"), h, cmd, x[0], x[1], x[2], x[3], x[4], x[5], x[6]);
break;
}
default:
{
qse_mchar_t* x[] = { va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*), va_arg(xap, qse_mchar_t*) };
QSE_APP_LOG9 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %hs %hs %hs %hs %hs %hs %hs %hs %hs ...\n"), h, cmd, x[0], x[1], x[2], x[3], x[4], x[5], x[6]);
break;
}
}
va_end (xap);
}
x = QSE::Sttp::sendCmdV(cmd, nargs, ap);
va_end (ap);
return x;
}
int sendCmd (const qse_wchar_t* cmd, qse_size_t nargs, ...)
{
int x;
va_list ap;
va_start (ap, nargs);
if (QSE_APP_LOG_ENABLED(this->app, QSE_LOG_INFO))
{
va_list xap;
int h = (int)this->sck->getHandle();
va_copy (xap, ap);
// ugly - any better way to call QSE_APP_LOGX in a single call? better to store arguments to a buffer first and call QSE_APP_LOGX with it?
switch (nargs)
{
case 0:
QSE_APP_LOG2 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %ls\n"), h, cmd);
break;
case 1:
QSE_APP_LOG3 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %ls %ls\n"), h, cmd, va_arg(xap, qse_wchar_t*));
break;
case 2:
{
qse_wchar_t* x[] = { va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*) };
QSE_APP_LOG4 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %ls %ls %ls\n"), h, cmd, x[0], x[1]);
break;
}
case 3:
{
qse_wchar_t* x[] = { va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*) };
QSE_APP_LOG5 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %ls %ls %ls %ls\n"), h, cmd, x[0], x[1], x[2]);
break;
}
case 4:
{
qse_wchar_t* x[] = { va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*) };
QSE_APP_LOG6 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %ls %ls %ls %ls %ls\n"), h, cmd, x[0], x[1], x[2], x[3]);
break;
}
case 5:
{
qse_wchar_t* x[] = { va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*) };
QSE_APP_LOG7 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %ls %ls %ls %ls %ls %ls\n"), h, cmd, x[0], x[1], x[2], x[3], x[4]);
break;
}
case 6:
{
qse_wchar_t* x[] = { va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*) };
QSE_APP_LOG8 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %ls %ls %ls %ls %ls %ls %ls\n"), h, cmd, x[0], x[1], x[2], x[3], x[4], x[5]);
break;
}
case 7:
{
qse_wchar_t* x[] = { va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*) };
QSE_APP_LOG9 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %ls %ls %ls %ls %ls %ls %ls %ls\n"), h, cmd, x[0], x[1], x[2], x[3], x[4], x[5], x[6]);
break;
}
default:
{
qse_wchar_t* x[] = { va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*), va_arg(xap, qse_wchar_t*) };
QSE_APP_LOG9 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,R] %ls %ls %ls %ls %ls %ls %ls %ls %ls ...\n"), h, cmd, x[0], x[1], x[2], x[3], x[4], x[5], x[6]);
break;
}
}
va_end (xap);
}
x = QSE::Sttp::sendCmdV(cmd, nargs, ap);
va_end (ap);
return x;
}
int sendErrCmd (ErrorNumber err, const qse_mchar_t* msg)
{
qse_mchar_t buf[32];
qse_fmtintmaxtombs(buf, QSE_COUNTOF(buf), err, 10, -1, '\0', QSE_NULL);
QSE::TypesErrorNumberToMbstr x;
return this->sendCmd(CMD_ERR, 2, buf, (msg? msg: x(err)));
}
int sendErrCmd (ErrorNumber err, const qse_wchar_t* msg)
{
qse_wchar_t buf[32];
qse_fmtintmaxtowcs(buf, QSE_COUNTOF(buf), err, 10, -1, '\0', QSE_NULL);
QSE::TypesErrorNumberToWcstr x;
return this->sendCmd(QSE_WT(CMD_ERR), 2, buf, (msg? msg: x(err)));
}
int sendWarnCmd (ErrorNumber err, const qse_mchar_t* msg)
{
qse_mchar_t buf[32];
qse_fmtintmaxtombs(buf, QSE_COUNTOF(buf), err, 10, -1, '\0', QSE_NULL);
QSE::TypesErrorNumberToMbstr x;
return this->sendCmd(CMD_WARN, 2, buf, (msg? msg: x(err)));
}
int sendWarnCmd (ErrorNumber err, const qse_wchar_t* msg)
{
qse_wchar_t buf[32];
qse_fmtintmaxtowcs(buf, QSE_COUNTOF(buf), err, 10, -1, '\0', QSE_NULL);
QSE::TypesErrorNumberToWcstr x;
return this->sendCmd(QSE_WT(CMD_WARN), 2, buf, (msg? msg: x(err)));
}
int sendOkCmd ()
{
return this->sendCmd(CMD_OK, 0);
}
int sendOkCmd (const qse_mchar_t* msg1)
{
return this->sendCmd(CMD_OK, 1, msg1);
}
int sendOkCmd (const qse_mchar_t* msg1, const qse_mchar_t* msg2)
{
return this->sendCmd(CMD_OK, 2, msg1, msg2);
}
int sendOkCmd (const qse_wchar_t* msg1)
{
return this->sendCmd(QSE_WT(CMD_OK), 1, msg1);
}
int sendOkCmd (const qse_wchar_t* msg1, const qse_wchar_t* msg2)
{
return this->sendCmd(QSE_WT(CMD_OK), 2, msg1, msg2);
}
protected:
MainApp* app;
QSE::Socket* sck;
typedef QSE::HashTable<QSE::String, CmdProc> CmdDict;
CmdDict cmd_dict;
int handle_command (const QSE::SttpCmd& cmd)
{
if (QSE_APP_LOG_ENABLED(this->app, QSE_LOG_INFO))
{
int h = this->sck->getHandle();
const qse_char_t* name = cmd.name.getData();
// ugly - any better way to call QSE_APP_LOGX in a single call? better to store arguments to a buffer first and call QSE_APP_LOGX with it?
switch (cmd.getArgCount())
{
case 0:
QSE_APP_LOG2 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,Q] %js\n"), h, name);
break;
case 1:
QSE_APP_LOG3 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,Q] %js %js\n"), h, name, cmd.getArgAt(0));
break;
case 2:
QSE_APP_LOG4 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,Q] %js %js %js\n"), h, name, cmd.getArgAt(0), cmd.getArgAt(1));
break;
case 3:
QSE_APP_LOG5 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,Q] %js %js %js %js\n"), h, name, cmd.getArgAt(0), cmd.getArgAt(1), cmd.getArgAt(2));
break;
case 4:
QSE_APP_LOG6 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,Q] %js %js %js %js %js\n"), h, name, cmd.getArgAt(0), cmd.getArgAt(1), cmd.getArgAt(2), cmd.getArgAt(3));
break;
case 5:
QSE_APP_LOG7 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,Q] %js %js %js %js %js %js\n"), h, name, cmd.getArgAt(0), cmd.getArgAt(1), cmd.getArgAt(2), cmd.getArgAt(3), cmd.getArgAt(4));
break;
case 6:
QSE_APP_LOG8 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,Q] %js %js %js %js %js %js %js\n"), h, name, cmd.getArgAt(0), cmd.getArgAt(1), cmd.getArgAt(2), cmd.getArgAt(3), cmd.getArgAt(4), cmd.getArgAt(5));
break;
case 7:
QSE_APP_LOG9 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,Q] %js %js %js %js %js %js %js %js\n"), h, name, cmd.getArgAt(0), cmd.getArgAt(1), cmd.getArgAt(2), cmd.getArgAt(3), cmd.getArgAt(4), cmd.getArgAt(5), cmd.getArgAt(6));
break;
default:
QSE_APP_LOG9 (this->app, QSE_LOG_INFO, QSE_T("[h=%d,Q] %js %js %js %js %js %js %js %js ...\n"), h, name, cmd.getArgAt(0), cmd.getArgAt(1), cmd.getArgAt(2), cmd.getArgAt(3), cmd.getArgAt(4), cmd.getArgAt(5), cmd.getArgAt(6));
break;
}
}
CmdDict::Pair* pair = this->cmd_dict.search(cmd.name);
if (!pair) return this->sendErrCmd(E_ENOENT, "unknown command");
return (this->*(pair->value))(cmd);
}
int write_bytes (const qse_uint8_t* data, qse_size_t len)
{
int n = this->sck->sendx(data, len, QSE_NULL);
if (QSE_UNLIKELY(n <= -1)) this->setErrorFmt(E_ESYSERR, QSE_T("%js"), sck->getErrorMsg());
return n;
}
int proc_discon (const QSE::SttpCmd& cmd)
{
PROC_CHECK_ARG_COUNT (cmd, 0);
this->sendOkCmd (); // success and failure doesn't matter
sck->shutdown ();
return 0;
}
int proc_shtdwn (const QSE::SttpCmd& cmd)
{
PROC_CHECK_ARG_COUNT_RANGE(cmd, 0, 1);
int ret = 0;
if (cmd.getArgCount() >= 1) ret = qse_strtoi(cmd.getArgAt(0), 0, QSE_NULL);
this->sendOkCmd (); // success and failure doesn't matter
this->app->stop (ret);
return 0;
}
int proc_envlst (const QSE::SttpCmd& cmd)
{
PROC_CHECK_ARG_COUNT (cmd, 0);
{
QSE::ScopedMutexLocker sml (this->app->getEnvMutex());
const MainApp::Env::ItemList& item_list = this->app->getEnv().getItemList();
for (const MainApp::Env::ItemList::Node* np = item_list.getHeadNode(); np; np = np->getNextNode())
{
const MainApp::Env::Item& item = np->value;
const qse_char_t* val = this->app->getEnv().getValue(item.name);
QSE_ASSERT (val != QSE_NULL);
if (this->sendCmd(QSE_T(CMD_ENVITM), 2, item.name, val) <= -1) return -1;
}
}
return this->sendOkCmd();
}
int proc_envget (const QSE::SttpCmd& cmd)
{
PROC_CHECK_ARG_COUNT (cmd, 1);
{
QSE::ScopedMutexLocker sml (this->app->getEnvMutex());
const qse_char_t* val = this->app->getEnv().getValue(cmd.getArgAt(0));
if (!val) goto noent;
return this->sendOkCmd(val);
}
noent:
return this->sendErrCmd(E_ENOENT, (const qse_mchar_t*)QSE_NULL);
}
int proc_envset (const QSE::SttpCmd& cmd)
{
PROC_CHECK_ARG_COUNT (cmd, 2);
const qse_char_t* name = cmd.getArgAt(0);
const qse_char_t* val = cmd.getArgAt(1);
// TODO: session acl?
//if (!this->_login.isRootUser()) return this->sendErrCmd (ERR_EPERM);
MainApp::Env& env = this->app->getEnv();
QSE::ScopedMutexLocker sml (this->app->getEnvMutex());
if (this->app->getEnv().setValue(name, val) <= -1)
{
return this->sendErrCmd(E_EOTHER, "unable to set value");
}
const qse_char_t* v = env.getValue(name);
QSE_ASSERT (v != QSE_NULL);
if (env.store(this->app->getConfFile().getData()) <= -1) // TODO: full path
{
if (this->sendWarnCmd(E_EOTHER, "unable to store") <= -1) return -1;
}
return this->sendOkCmd(v);
}
};
// --------------------------------------------------------------------------
int TcpGate::main ()
{
this->setStackSize (1024u * 1024u * 2); // 2MB
return this->execute(this->bind_address);
}
int TcpGate::stop () QSE_CPP_NOEXCEPT
{
this->halt ();
return 0;
}
int TcpGate::handle_connection (Connection* connection)
{
qse_char_t addrbuf[128];
qse_uint8_t bb[256];
qse_ssize_t n;
connection->address.toStrBuf(addrbuf, QSE_COUNTOF(addrbuf));
Proto proto (this->app, &connection->socket);
while (!this->isHaltRequested())
{
if ((n = connection->socket.receive(bb, QSE_COUNTOF(bb))) <= 0)
{
if (n <= -1)
QSE_APP_LOG2 (this->app, QSE_LOG_INFO, QSE_T("receive failure from %js - %js\n"), addrbuf, connection->socket.getErrorMsg());
break;
}
#if 0
for (int i = 0; i < n; i++)
{
if (proto.feed(&bb[i], 1, QSE_NULL) <= -1)
{
QSE_APP_LOG1 (this->app, QSE_LOG_ERROR, QSE_T("protocol error - %js\n"), proto.getErrorMsg());
goto done;
}
}
#else
if (proto.feed(bb, n, QSE_NULL) <= -1)
{
QSE_APP_LOG1 (this->app, QSE_LOG_ERROR, QSE_T("protocol error - %js\n"), proto.getErrorMsg());
break;
}
#endif
}
done:
//QSE_APP_LOG2 (this->app, QSE_LOG_INFO, QSE_T("byte to %s -> wid %zu\n"), addrbuf, connection->getWid());
return 0;
}
void TcpGate::logfmt (qse_log_priority_flag_t pri, const qse_char_t* fmt, ...)
{
if (QSE_APP_LOG_ENABLED(this->app, pri))
{
va_list ap;
va_start (ap, fmt);
this->app->logfmtv (pri, fmt, ap);
va_end (ap);
}
}

View File

@ -0,0 +1,33 @@
#ifndef _TCPGATE_CLASS_
#define _TCPGATE_CLASS_
#include <qse/si/TcpServer.hpp>
#include <qse/cmn/String.hpp>
class MainApp;
class TcpGate: public QSE::TcpServer, public QSE::Thread
{
public:
TcpGate (MainApp* app): app(app)
{
}
void setBindAddress (const qse_char_t* bind_address)
{
this->bind_address = bind_address;
}
int main ();
int stop () QSE_CPP_NOEXCEPT;
protected:
MainApp* app;
bool stop_requested;
QSE::String bind_address;
int handle_connection (Connection* connection);
void logfmt (qse_log_priority_flag_t pri, const qse_char_t* fmt, ...);
};
#endif

View File

@ -476,7 +476,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -568,7 +568,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -345,7 +345,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -341,7 +341,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -342,7 +342,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -341,7 +341,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -383,7 +383,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -496,7 +496,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -342,7 +342,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -287,7 +287,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@