renamed qse_basenameasmbs() back to qse_mbsbasename()

renamed qse_basenameaswcs back to qse_wcsbasename()
added qse_get_log_priority_by_wcsname()
added qse_get_log_priority_by_mbsname()
added qse_get_log_facility_by_wcsname()
added qse_get_log_facility_by_mbsname()
added qse_wcsmbscmp(), qse_mbswcscmp()
added qse_wcsxmbscmp(), qse_mbsxwcscmp()
This commit is contained in:
hyung-hwan 2019-09-10 08:53:59 +00:00
parent f89efc150a
commit df8cff2451
15 changed files with 246 additions and 67 deletions

View File

@ -1126,11 +1126,11 @@ static void open_mpi (mpi_t* mpi, int argc, qse_achar_t* argv[])
#if defined(USE_LTDL) #if defined(USE_LTDL)
#if defined(QSE_ACHAR_IS_MCHAR) #if defined(QSE_ACHAR_IS_MCHAR)
if (qse_mbscmp (qse_basenameasmbs(argv[0]), QSE_MT("qseawkmp")) != 0 && if (qse_mbscmp(qse_mbsbasename(argv[0]), QSE_MT("qseawkmp")) != 0 &&
qse_mbscmp (qse_basenameasmbs(argv[0]), QSE_MT("qseawkmpi")) != 0) return; qse_mbscmp(qse_mbsbasename(argv[0]), QSE_MT("qseawkmpi")) != 0) return;
#else #else
if (qse_wcscmp (qse_basenameaswcs(argv[0]), QSE_WT("qseawkmp")) != 0 && if (qse_wcscmp(qse_wcsbasename(argv[0]), QSE_WT("qseawkmp")) != 0 &&
qse_wcscmp (qse_basenameaswcs(argv[0]), QSE_WT("qseawkmpi")) != 0) return; qse_wcscmp(qse_wcsbasename(argv[0]), QSE_WT("qseawkmpi")) != 0) return;
#endif #endif
if (lt_dlinit () != 0) return; if (lt_dlinit () != 0) return;

View File

@ -879,7 +879,7 @@ found:
if (apath) if (apath)
{ {
const qse_mchar_t* base; const qse_mchar_t* base;
base = qse_basenameasmbs (apath); base = qse_mbsbasename (apath);
for (i = 0; i < QSE_COUNTOF(loccfg->auth_rule); i++) for (i = 0; i < QSE_COUNTOF(loccfg->auth_rule); i++)
{ {
@ -977,7 +977,7 @@ found:
#endif #endif
if (!qinfo->xpath_nx) if (!qinfo->xpath_nx)
{ {
xpath_base = qse_basenameasmbs (qinfo->xpath); xpath_base = qse_mbsbasename (qinfo->xpath);
for (i = 0; i < QSE_COUNTOF(loccfg->cgi); i++) for (i = 0; i < QSE_COUNTOF(loccfg->cgi); i++)
{ {
struct cgi_t* cgi; struct cgi_t* cgi;
@ -1004,7 +1004,7 @@ found:
qse_size_t i; qse_size_t i;
const qse_mchar_t* xpath_base; const qse_mchar_t* xpath_base;
xpath_base = qse_basenameasmbs (qinfo->xpath); xpath_base = qse_mbsbasename (qinfo->xpath);
*(const qse_mchar_t**)result = QSE_NULL; *(const qse_mchar_t**)result = QSE_NULL;
for (i = 0; i < QSE_COUNTOF(loccfg->mime); i++) for (i = 0; i < QSE_COUNTOF(loccfg->mime); i++)
@ -1043,7 +1043,7 @@ found:
id = (code == QSE_HTTPD_SERVERSTD_DIRACC)? 0: 1; id = (code == QSE_HTTPD_SERVERSTD_DIRACC)? 0: 1;
xpath_base = qse_basenameasmbs (qinfo->xpath); xpath_base = qse_mbsbasename (qinfo->xpath);
*(int*)result = 200; *(int*)result = 200;
for (i = 0; i < QSE_COUNTOF(loccfg->access[id]); i++) for (i = 0; i < QSE_COUNTOF(loccfg->access[id]); i++)

20
qse/configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for qse 0.8.3. # Generated by GNU Autoconf 2.69 for qse 0.8.4.
# #
# Report bugs to <Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)>. # Report bugs to <Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)>.
# #
@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='qse' PACKAGE_NAME='qse'
PACKAGE_TARNAME='qse' PACKAGE_TARNAME='qse'
PACKAGE_VERSION='0.8.3' PACKAGE_VERSION='0.8.4'
PACKAGE_STRING='qse 0.8.3' PACKAGE_STRING='qse 0.8.4'
PACKAGE_BUGREPORT='Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)' PACKAGE_BUGREPORT='Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)'
PACKAGE_URL='http://code.miflux.com/@qse' PACKAGE_URL='http://code.miflux.com/@qse'
@ -1414,7 +1414,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures qse 0.8.3 to adapt to many kinds of systems. \`configure' configures qse 0.8.4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1484,7 +1484,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of qse 0.8.3:";; short | recursive ) echo "Configuration of qse 0.8.4:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1629,7 +1629,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
qse configure 0.8.3 qse configure 0.8.4
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -2413,7 +2413,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by qse $as_me 0.8.3, which was It was created by qse $as_me 0.8.4, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -3288,7 +3288,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='qse' PACKAGE='qse'
VERSION='0.8.3' VERSION='0.8.4'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -24311,7 +24311,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by qse $as_me 0.8.3, which was This file was extended by qse $as_me 0.8.4, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -24378,7 +24378,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
qse config.status 0.8.3 qse config.status 0.8.4
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -4,7 +4,7 @@ dnl Make sure you change the version information
dnl in include/qse/conf_*.h whenever you change the version dnl in include/qse/conf_*.h whenever you change the version
dnl here. Those files don't depend on autoconf, thus requiring dnl here. Those files don't depend on autoconf, thus requiring
dnl manual change. dnl manual change.
AC_INIT([qse],[0.8.3],[Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)],[],[http://code.miflux.com/@qse]) AC_INIT([qse],[0.8.4],[Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)],[],[http://code.miflux.com/@qse])
AC_CONFIG_HEADER([include/qse/config.h]) AC_CONFIG_HEADER([include/qse/config.h])
AC_CONFIG_AUX_DIR([ac]) AC_CONFIG_AUX_DIR([ac])

View File

@ -129,10 +129,10 @@ QSE_EXPORT int qse_ismbsdrivecurpath (
); );
/** /**
* The qse_basenameasmbs() function returns the pointer to the file name * The qse_mbsbasename() function returns the pointer to the file name
* segment in a multibyte path name. * segment in a multibyte path name.
*/ */
QSE_EXPORT const qse_mchar_t* qse_basenameasmbs ( QSE_EXPORT const qse_mchar_t* qse_mbsbasename (
const qse_mchar_t* path const qse_mchar_t* path
); );
@ -237,10 +237,10 @@ QSE_EXPORT int qse_iswcsdrivecurpath (
); );
/** /**
* The qse_basenameaswcs() function returns the pointer to the file name * The qse_wcsbasename() function returns the pointer to the file name
* segment in a wide-character path name. * segment in a wide-character path name.
*/ */
QSE_EXPORT const qse_wchar_t* qse_basenameaswcs ( QSE_EXPORT const qse_wchar_t* qse_wcsbasename (
const qse_wchar_t* path const qse_wchar_t* path
); );
@ -313,7 +313,7 @@ QSE_EXPORT qse_wchar_t* qse_mergewcspathdup (
# define qse_isdrivepath(p) qse_ismbsdrivepath(p) # define qse_isdrivepath(p) qse_ismbsdrivepath(p)
# define qse_isdriveabspath(p) qse_ismbsdriveabspath(p) # define qse_isdriveabspath(p) qse_ismbsdriveabspath(p)
# define qse_isdrivecurpath(p) qse_ismbsdrivecurpath(p) # define qse_isdrivecurpath(p) qse_ismbsdrivecurpath(p)
# define qse_basename(path) qse_basenameasmbs(path) # define qse_basename(path) qse_mbsbasename(path)
# define qse_pathcore(p) qse_mbspathcore(p) # define qse_pathcore(p) qse_mbspathcore(p)
# define qse_canonpath(p,c,f) qse_canonmbspath(p,c,f) # define qse_canonpath(p,c,f) qse_canonmbspath(p,c,f)
# define qse_mergepathdup(d,f,m) qse_mergembspathdup(d,f,m) # define qse_mergepathdup(d,f,m) qse_mergembspathdup(d,f,m)
@ -323,7 +323,7 @@ QSE_EXPORT qse_wchar_t* qse_mergewcspathdup (
# define qse_isdrivepath(p) qse_iswcsdrivepath(p) # define qse_isdrivepath(p) qse_iswcsdrivepath(p)
# define qse_isdriveabspath(p) qse_iswcsdriveabspath(p) # define qse_isdriveabspath(p) qse_iswcsdriveabspath(p)
# define qse_isdrivecurpath(p) qse_iswcsdrivecurpath(p) # define qse_isdrivecurpath(p) qse_iswcsdrivecurpath(p)
# define qse_basename(path) qse_basenameaswcs(path) # define qse_basename(path) qse_wcsbasename(path)
# define qse_pathcore(p) qse_wcspathcore(p) # define qse_pathcore(p) qse_wcspathcore(p)
# define qse_canonpath(p,c,f) qse_canonwcspath(p,c,f) # define qse_canonpath(p,c,f) qse_canonwcspath(p,c,f)
# define qse_mergepathdup(d,f,m) qse_mergewcspathdup(d,f,m) # define qse_mergepathdup(d,f,m) qse_mergewcspathdup(d,f,m)

View File

@ -1418,6 +1418,31 @@ QSE_EXPORT int qse_wcszcasecmp (
# define qse_strzcasecmp qse_wcszcasecmp # define qse_strzcasecmp qse_wcszcasecmp
#endif #endif
/**
* The wcsmbscmp() function compares a wide-character string
* wit a byte string without considering charcter encoding.
* It compares each wide-character in s1 with each byte in s2.
*/
QSE_EXPORT int qse_wcsmbscmp (
const qse_wchar_t* s1,
const qse_mchar_t* s2
);
#define qse_mbswcscmp(s1, s2) (-qse_wcsmbscmp(s2, s1))
QSE_EXPORT int qse_wcsxmbscmp (
const qse_wchar_t* s1,
qse_size_t ln,
const qse_mchar_t* s2
);
QSE_EXPORT int qse_mbsxwcscmp (
const qse_mchar_t* s1,
qse_size_t ln,
const qse_wchar_t* s2
);
QSE_EXPORT qse_mchar_t* qse_mbsdup ( QSE_EXPORT qse_mchar_t* qse_mbsdup (
const qse_mchar_t* str, const qse_mchar_t* str,
qse_mmgr_t* mmgr qse_mmgr_t* mmgr

View File

@ -290,11 +290,22 @@ static QSE_INLINE void* qse_log_getxtn (qse_log_t* log) { return QSE_XTN(log); }
#define qse_log_getxtn(log) (QSE_XTN(log)) #define qse_log_getxtn(log) (QSE_XTN(log))
#endif #endif
QSE_EXPORT void qse_log_setident ( QSE_EXPORT void qse_log_setidentwithmbs (
qse_log_t* log, qse_log_t* log,
const qse_char_t* ident const qse_mchar_t* ident
); );
QSE_EXPORT void qse_log_setidentwithwcs (
qse_log_t* log,
const qse_wchar_t* ident
);
#if defined(QSE_CHAR_IS_MCHAR)
# define qse_log_setident qse_log_setidentwithmbs
#else
# define qse_log_setident qse_log_setidentwithwcs
#endif
/** /**
* \return 0 on success, -1 on failure * \return 0 on success, -1 on failure
*/ */
@ -385,16 +396,34 @@ QSE_EXPORT qse_size_t qse_make_log_priority_name (
* \return an integer bitwised-ORed of priority bits if \a name is valid. * \return an integer bitwised-ORed of priority bits if \a name is valid.
* 0 if \a name is invalid or empty. * 0 if \a name is invalid or empty.
*/ */
QSE_EXPORT int qse_get_log_priority_by_name ( QSE_EXPORT int qse_get_log_priority_by_mbsname (
const qse_char_t* name, const qse_mchar_t* name,
const qse_char_t* delim const qse_mchar_t* delim
); );
QSE_EXPORT int qse_get_log_facility_by_name ( QSE_EXPORT int qse_get_log_priority_by_wcsname (
const qse_char_t* name, const qse_wchar_t* name,
const qse_wchar_t* delim
);
QSE_EXPORT int qse_get_log_facility_by_mbsname (
const qse_mchar_t* name,
qse_log_facility_t* fcode qse_log_facility_t* fcode
); );
QSE_EXPORT int qse_get_log_facility_by_wcsname (
const qse_wchar_t* name,
qse_log_facility_t* fcode
);
#if defined(QSE_CHAR_IS_MCHAR)
# define qse_get_log_priority_by_name qse_get_log_priority_by_mbsname
# define qse_get_log_facility_by_name qse_get_log_facility_by_mbsname
#else
# define qse_get_log_priority_by_name qse_get_log_priority_by_wcsname
# define qse_get_log_facility_by_name qse_get_log_facility_by_wcsname
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -30,7 +30,7 @@
#define IS_MSEP(c) QSE_ISPATHMBSEP(c) #define IS_MSEP(c) QSE_ISPATHMBSEP(c)
#define IS_WSEP(c) QSE_ISPATHWCSEP(c) #define IS_WSEP(c) QSE_ISPATHWCSEP(c)
const qse_mchar_t* qse_basenameasmbs (const qse_mchar_t* path) const qse_mchar_t* qse_mbsbasename (const qse_mchar_t* path)
{ {
const qse_mchar_t* p, * last = QSE_NULL; const qse_mchar_t* p, * last = QSE_NULL;
@ -42,7 +42,7 @@ const qse_mchar_t* qse_basenameasmbs (const qse_mchar_t* path)
return (last == QSE_NULL)? path: (last + 1); return (last == QSE_NULL)? path: (last + 1);
} }
const qse_wchar_t* qse_basenameaswcs (const qse_wchar_t* path) const qse_wchar_t* qse_wcsbasename (const qse_wchar_t* path)
{ {
const qse_wchar_t* p, * last = QSE_NULL; const qse_wchar_t* p, * last = QSE_NULL;
@ -61,7 +61,7 @@ qse_mchar_t* qse_substmbsbasenamedup (const qse_mchar_t* path, const qse_mchar_t
qse_mcstr_t seg[3]; qse_mcstr_t seg[3];
qse_size_t idx = 0; qse_size_t idx = 0;
b = qse_basenameasmbs(path); b = qse_mbsbasename(path);
if (b) if (b)
{ {
seg[idx].ptr = (qse_mchar_t*)path; seg[idx].ptr = (qse_mchar_t*)path;
@ -85,7 +85,7 @@ qse_wchar_t* qse_substwcsbasenamedup (const qse_wchar_t* path, const qse_wchar_t
qse_wcstr_t seg[3]; qse_wcstr_t seg[3];
qse_size_t idx = 0; qse_size_t idx = 0;
b = qse_basenameaswcs(path); b = qse_wcsbasename(path);
if (b) if (b)
{ {
seg[idx].ptr = (qse_wchar_t*)path; seg[idx].ptr = (qse_wchar_t*)path;

View File

@ -275,3 +275,42 @@ int qse_wcszcasecmp (const qse_wchar_t* s1, const qse_wchar_t* s2, qse_size_t n)
return (QSE_TOWUPPER((qse_wchau_t)*s1) > QSE_TOWUPPER((qse_wchau_t)*s2))? 1: -1; return (QSE_TOWUPPER((qse_wchau_t)*s1) > QSE_TOWUPPER((qse_wchau_t)*s2))? 1: -1;
} }
/* ------------------------------------------------------------- */
int qse_wcsmbscmp (const qse_wchar_t* s1, const qse_mchar_t* s2)
{
while (*s1 == *s2)
{
if (*s1 == QSE_WT('\0')) return 0;
s1++; s2++;
}
return (*s1 > *s2)? 1: -1;
}
int qse_wcsxmbscmp (const qse_wchar_t* s1, qse_size_t ln, const qse_mchar_t* s2)
{
const qse_wchar_t* end = s1 + ln;
while (s1 < end && *s2 != QSE_MT('\0'))
{
if (*s1 != *s2) return ((qse_wchau_t)*s1 > (qse_wchau_t)(qse_mchau_t)*s2)? 1: -1;
s1++; s2++;
}
return (s1 < end)? 1: ((*s2 == QSE_MT('\0'))? 0: -1);
}
int qse_mbsxwcscmp (const qse_mchar_t* s1, qse_size_t ln, const qse_wchar_t* s2)
{
const qse_mchar_t* end = s1 + ln;
while (s1 < end && *s2 != QSE_WT('\0'))
{
if (*s1 != *s2) return ((qse_wchau_t)(qse_mchau_t)*s1 > (qse_wchau_t)*s2)? 1: -1;
s1++; s2++;
}
return (s1 < end)? 1: ((*s2 == QSE_WT('\0'))? 0: -1);
}

View File

@ -43,12 +43,12 @@
#if defined(QSE_HTTPD_DEBUG) #if defined(QSE_HTTPD_DEBUG)
# include <qse/si/sio.h> # include <qse/si/sio.h>
# include <qse/cmn/path.h> # include <qse/cmn/path.h>
# define HTTPD_DBGOUT0(fmt) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__)) # define HTTPD_DBGOUT0(fmt) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__))
# define HTTPD_DBGOUT1(fmt,a1) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1)) # define HTTPD_DBGOUT1(fmt,a1) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1))
# define HTTPD_DBGOUT2(fmt,a1,a2) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1), (a2)) # define HTTPD_DBGOUT2(fmt,a1,a2) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1), (a2))
# define HTTPD_DBGOUT3(fmt,a1,a2,a3) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1), (a2), (a3)) # define HTTPD_DBGOUT3(fmt,a1,a2,a3) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1), (a2), (a3))
# define HTTPD_DBGOUT4(fmt,a1,a2,a3,a4) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1), (a2), (a3), (a4)) # define HTTPD_DBGOUT4(fmt,a1,a2,a3,a4) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1), (a2), (a3), (a4))
# define HTTPD_DBGOUT5(fmt,a1,a2,a3,a4,a5) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1), (a2), (a3), (a4), (a5)) # define HTTPD_DBGOUT5(fmt,a1,a2,a3,a4,a5) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1), (a2), (a3), (a4), (a5))
#else #else
# define HTTPD_DBGOUT0(fmt) # define HTTPD_DBGOUT0(fmt)
# define HTTPD_DBGOUT1(fmt,a1) # define HTTPD_DBGOUT1(fmt,a1)

View File

@ -321,7 +321,7 @@ int App::unset_signal_handler_no_mutex(int sig, int ignore)
sa.sa_handler = (SignalHandler)App::_sighrs[1][sig]; sa.sa_handler = (SignalHandler)App::_sighrs[1][sig];
} }
if (::sigaction (sig, &sa, QSE_NULL) <= -1) return -1; if (::sigaction(sig, &sa, QSE_NULL) <= -1) return -1;
App::_sighrs[0][sig] = 0; App::_sighrs[0][sig] = 0;
App::_sighrs[1][sig] = 0; App::_sighrs[1][sig] = 0;

View File

@ -94,14 +94,14 @@
# define canon_fspath(path,canon,flags) qse_canonmbspath(path,canon,flags) # define canon_fspath(path,canon,flags) qse_canonmbspath(path,canon,flags)
# define merge_fspath_dup(dir,file,mmgr) qse_mergembspathdup(dir,file,mmgr) # define merge_fspath_dup(dir,file,mmgr) qse_mergembspathdup(dir,file,mmgr)
# define get_fspath_core(fspath) qse_mbspathcore(fspath) # define get_fspath_core(fspath) qse_mbspathcore(fspath)
# define get_fspath_base(fspath) qse_basenameasmbs(fspath) # define get_fspath_base(fspath) qse_mbsbasename(fspath)
# define IS_FSPATHSEP(x) QSE_ISPATHMBSEP(x) # define IS_FSPATHSEP(x) QSE_ISPATHMBSEP(x)
# define QSE_FS_T(x) QSE_MT(x) # define QSE_FS_T(x) QSE_MT(x)
#else #else
# define canon_fspath(fspath,canon,flags) qse_canonwcspath(fspath,canon,flags) # define canon_fspath(fspath,canon,flags) qse_canonwcspath(fspath,canon,flags)
# define merge_fspath_dup(dir,file,mmgr) qse_mergewcspathdup(dir,file,mmgr) # define merge_fspath_dup(dir,file,mmgr) qse_mergewcspathdup(dir,file,mmgr)
# define get_fspath_core(fspath) qse_wcspathcore(fspath) # define get_fspath_core(fspath) qse_wcspathcore(fspath)
# define get_fspath_base(fspath) qse_basenameaswcs(fspath) # define get_fspath_base(fspath) qse_wcsbasename(fspath)
# define IS_FSPATHSEP(x) QSE_ISPATHWCSEP(x) # define IS_FSPATHSEP(x) QSE_ISPATHWCSEP(x)
# define QSE_FS_T(x) QSE_WT(x) # define QSE_FS_T(x) QSE_WT(x)
#endif #endif

View File

@ -27,6 +27,7 @@
#include <qse/si/log.h> #include <qse/si/log.h>
#include <qse/cmn/str.h> #include <qse/cmn/str.h>
#include <qse/cmn/time.h> #include <qse/cmn/time.h>
#include <qse/cmn/mbwc.h>
#include "../cmn/mem-prv.h" #include "../cmn/mem-prv.h"
#include "../cmn/va_copy.h" #include "../cmn/va_copy.h"
@ -204,7 +205,7 @@ qse_log_t* qse_log_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, const qse_char_t*
log = (qse_log_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_log_t) + xtnsize); log = (qse_log_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_log_t) + xtnsize);
if (log) if (log)
{ {
if (qse_log_init (log, mmgr, ident, potflags, target) <= -1) if (qse_log_init(log, mmgr, ident, potflags, target) <= -1)
{ {
QSE_MMGR_FREE (mmgr, log); QSE_MMGR_FREE (mmgr, log);
return QSE_NULL; return QSE_NULL;
@ -234,7 +235,7 @@ int qse_log_init (qse_log_t* log, qse_mmgr_t* mmgr, const qse_char_t* ident, int
{ {
if (qse_strlen(target->file) >= QSE_COUNTOF(log->t.file.pathbuf)) if (qse_strlen(target->file) >= QSE_COUNTOF(log->t.file.pathbuf))
{ {
log->t.file.path = qse_strdup (target->file, log->mmgr); log->t.file.path = qse_strdup(target->file, log->mmgr);
if (!log->t.file.path) return -1; if (!log->t.file.path) return -1;
} }
else else
@ -321,7 +322,7 @@ void qse_log_fini (qse_log_t* log)
} }
void qse_log_setident (qse_log_t* log, const qse_char_t* ident) static QSE_INLINE void set_ident (qse_log_t* log, const qse_char_t* ident)
{ {
/* set the base identifer to use */ /* set the base identifer to use */
if (ident) if (ident)
@ -343,6 +344,32 @@ void qse_log_setident (qse_log_t* log, const qse_char_t* ident)
} }
} }
void qse_log_setidentwithmbs (qse_log_t* log, const qse_mchar_t* ident)
{
#if defined(QSE_CHAR_IS_MCHAR)
set_ident(log, ident);
#else
qse_wchar_t* id;
id = qse_mbstowcsdup(ident, QSE_NULL, log->mmgr);
if (id) set_ident(log, id); /* don't care about failure */
QSE_MMGR_FREE (log->mmgr, id);
#endif
}
void qse_log_setidentwithwcs (qse_log_t* log, const qse_wchar_t* ident)
{
#if defined(QSE_CHAR_IS_MCHAR)
qse_mchar_t* id;
id = qse_wcstombsdup(ident, QSE_NULL, log->mmgr);
if (id) set_ident(log, id); /* don't care about failure */
QSE_MMGR_FREE (log->mmgr, id);
#else
set_ident(log, ident);
#endif
}
int qse_log_settarget (qse_log_t* log, int flags, const qse_log_target_t* target) int qse_log_settarget (qse_log_t* log, int flags, const qse_log_target_t* target)
{ {
qse_char_t* target_file = QSE_NULL; qse_char_t* target_file = QSE_NULL;
@ -566,7 +593,7 @@ void qse_log_reportv (qse_log_t* log, const qse_char_t* ident, int pri, const qs
if (!log->dmsgbuf) goto done; if (!log->dmsgbuf) goto done;
#if defined(QSE_CHAR_IS_WCHAR) #if defined(QSE_CHAR_IS_WCHAR)
if (!log->wmsgbuf) log->wmsgbuf = qse_wcs_open (log->mmgr, 0, 0); if (!log->wmsgbuf) log->wmsgbuf = qse_wcs_open(log->mmgr, 0, 0);
if (!log->wmsgbuf) goto done; if (!log->wmsgbuf) goto done;
#endif #endif
@ -602,30 +629,30 @@ void qse_log_reportv (qse_log_t* log, const qse_char_t* ident, int pri, const qs
if (log->ident[0]) if (log->ident[0])
{ {
if (qse_mbs_fcat (log->dmsgbuf, identfmt, log->ident) == (qse_size_t)-1) goto done; if (qse_mbs_fcat(log->dmsgbuf, identfmt, log->ident) == (qse_size_t)-1) goto done;
if (ident && ident[0] && if (ident && ident[0] &&
qse_mbs_fcat (log->dmsgbuf, identparenfmt, ident) == (qse_size_t)-1) goto done; qse_mbs_fcat(log->dmsgbuf, identparenfmt, ident) == (qse_size_t)-1) goto done;
id_out = 1; id_out = 1;
} }
else else
{ {
if (ident && ident[0]) if (ident && ident[0])
{ {
if (qse_mbs_fcat (log->dmsgbuf, identfmt, ident) == (qse_size_t)-1) goto done; if (qse_mbs_fcat(log->dmsgbuf, identfmt, ident) == (qse_size_t)-1) goto done;
id_out = 1; id_out = 1;
} }
} }
if (log->flags & QSE_LOG_INCLUDE_PID) if (log->flags & QSE_LOG_INCLUDE_PID)
{ {
fpdilen = qse_mbs_fcat (log->dmsgbuf, QSE_MT("[%d]"), (int)QSE_GETPID()); fpdilen = qse_mbs_fcat(log->dmsgbuf, QSE_MT("[%d]"), (int)QSE_GETPID());
if (fpdilen == (qse_size_t)-1) goto done; if (fpdilen == (qse_size_t)-1) goto done;
id_out = 1; id_out = 1;
} }
if (id_out) if (id_out)
{ {
fpdilen = qse_mbs_fcat (log->dmsgbuf, QSE_MT(": ")); fpdilen = qse_mbs_fcat(log->dmsgbuf, QSE_MT(": "));
if (fpdilen == (qse_size_t)-1) goto done; if (fpdilen == (qse_size_t)-1) goto done;
} }
else else
@ -635,10 +662,10 @@ void qse_log_reportv (qse_log_t* log, const qse_char_t* ident, int pri, const qs
va_copy (xap, ap); va_copy (xap, ap);
#if defined(QSE_CHAR_IS_MCHAR) #if defined(QSE_CHAR_IS_MCHAR)
if (qse_mbs_vfcat (log->dmsgbuf, fmt, xap) == (qse_size_t)-1) goto done; if (qse_mbs_vfcat(log->dmsgbuf, fmt, xap) == (qse_size_t)-1) goto done;
#else #else
if (qse_wcs_vfmt (log->wmsgbuf, fmt, xap) == (qse_size_t)-1 || if (qse_wcs_vfmt(log->wmsgbuf, fmt, xap) == (qse_size_t)-1 ||
qse_mbs_fcat (log->dmsgbuf, QSE_MT("%.*ls"), QSE_WCS_LEN(log->wmsgbuf), QSE_WCS_PTR(log->wmsgbuf)) == (qse_size_t)-1) goto done; qse_mbs_fcat(log->dmsgbuf, QSE_MT("%.*ls"), QSE_WCS_LEN(log->wmsgbuf), QSE_WCS_PTR(log->wmsgbuf)) == (qse_size_t)-1) goto done;
#endif #endif
if (log->flags & QSE_LOG_SYSLOG) if (log->flags & QSE_LOG_SYSLOG)
@ -762,22 +789,26 @@ qse_size_t qse_make_log_priority_name (int pri, const qse_char_t* delim, qse_cha
return tlen; return tlen;
} }
int qse_get_log_priority_by_name (const qse_char_t* name, const qse_char_t* delim) int qse_get_log_priority_by_wcsname (const qse_wchar_t* name, const qse_wchar_t* delim)
{ {
qse_size_t i; qse_size_t i;
qse_cstr_t tok; qse_wcstr_t tok;
const qse_char_t* ptr; const qse_wchar_t* ptr;
int pri = 0; int pri = 0;
ptr = name; ptr = name;
while (ptr) while (ptr)
{ {
ptr = qse_strtok (ptr, delim, &tok); ptr = qse_wcstok(ptr, delim, &tok);
if (tok.ptr) if (tok.ptr)
{ {
for (i = 0; i < QSE_COUNTOF(__priority_names); i++) for (i = 0; i < QSE_COUNTOF(__priority_names); i++)
{ {
#if defined(QSE_CHAR_IS_MCHAR)
if (qse_wcsxmbscmp(tok.ptr, tok.len, __priority_names[i]) == 0)
#else
if (qse_strxcmp(tok.ptr, tok.len, __priority_names[i]) == 0) if (qse_strxcmp(tok.ptr, tok.len, __priority_names[i]) == 0)
#endif
{ {
pri |= (1UL << i); pri |= (1UL << i);
break; break;
@ -790,14 +821,69 @@ int qse_get_log_priority_by_name (const qse_char_t* name, const qse_char_t* deli
return pri; return pri;
} }
int qse_get_log_priority_by_mbsname (const qse_mchar_t* name, const qse_mchar_t* delim)
{
qse_size_t i;
qse_mcstr_t tok;
const qse_mchar_t* ptr;
int pri = 0;
int qse_get_log_facility_by_name (const qse_char_t* name, qse_log_facility_t* fcode) ptr = name;
while (ptr)
{
ptr = qse_mbstok(ptr, delim, &tok);
if (tok.ptr)
{
for (i = 0; i < QSE_COUNTOF(__priority_names); i++)
{
#if defined(QSE_CHAR_IS_MCHAR)
if (qse_strxcmp(tok.ptr, tok.len, __priority_names[i]) == 0)
#else
if (qse_mbsxwcscmp(tok.ptr, tok.len, __priority_names[i]) == 0)
#endif
{
pri |= (1UL << i);
break;
}
}
if (i >= QSE_COUNTOF(__priority_names)) return 0; /* unknown name included */
}
}
return pri;
}
int qse_get_log_facility_by_wcsname (const qse_wchar_t* name, qse_log_facility_t* fcode)
{ {
qse_size_t i; qse_size_t i;
for (i = 0; i < QSE_COUNTOF(__syslog_fac_info); i++) for (i = 0; i < QSE_COUNTOF(__syslog_fac_info); i++)
{ {
if (qse_strcmp (__syslog_fac_info[i].name, name) == 0) #if defined(QSE_CHAR_IS_MCHAR)
if (qse_mbswcscmp(__syslog_fac_info[i].name, name) == 0)
#else
if (qse_wcscmp(__syslog_fac_info[i].name, name) == 0)
#endif
{
*fcode = __syslog_fac_info[i].code;
return 0;
}
}
return -1;
}
int qse_get_log_facility_by_mbsname (const qse_mchar_t* name, qse_log_facility_t* fcode)
{
qse_size_t i;
for (i = 0; i < QSE_COUNTOF(__syslog_fac_info); i++)
{
#if defined(QSE_CHAR_IS_MCHAR)
if (qse_mbscmp(__syslog_fac_info[i].name, name) == 0)
#else
if (qse_wcsmbscmp(__syslog_fac_info[i].name, name) == 0)
#endif
{ {
*fcode = __syslog_fac_info[i].code; *fcode = __syslog_fac_info[i].code;
return 0; return 0;

View File

@ -61,7 +61,7 @@ int main (int argc, char* argv[])
else if (argc == 2 && qse_mbscmp(argv[1], "-w") == 0) omode = 2; else if (argc == 2 && qse_mbscmp(argv[1], "-w") == 0) omode = 2;
else else
{ {
qse_fprintf (QSE_STDERR, QSE_T("USAGE: %hs [-m | -w]\n"), qse_basenameasmbs(argv[0])); qse_fprintf (QSE_STDERR, QSE_T("USAGE: %hs [-m | -w]\n"), qse_mbsbasename(argv[0]));
ret = -1; goto oops; ret = -1; goto oops;
} }
} }

View File

@ -166,7 +166,7 @@ int main (int argc, char* argv[])
switch (c) switch (c)
{ {
case 'h': case 'h':
print_usage (qse_basenameasmbs(argv[0])); print_usage (qse_mbsbasename(argv[0]));
return 0; return 0;
case 'k': case 'k':