Added ethernet address conversion functions

This commit is contained in:
hyung-hwan 2017-08-28 10:25:54 +00:00
parent 1f9632b151
commit b0008974c3
10 changed files with 373 additions and 58 deletions

View File

@ -2774,7 +2774,7 @@ static int httpd_main (int argc, qse_char_t* argv[])
setup_signal_handlers (); setup_signal_handlers ();
qse_httpd_getopt (httpd, QSE_HTTPD_TRAIT, &trait); qse_httpd_getopt (httpd, QSE_HTTPD_TRAIT, &trait);
trait |= QSE_HTTPD_CGIERRTONUL | QSE_HTTPD_LOGACT; trait |= QSE_HTTPD_CGIERRTONUL | QSE_HTTPD_LOGACT /*| QSE_HTTPD_PROXYNOVIA*/;
qse_httpd_setopt (httpd, QSE_HTTPD_TRAIT, &trait); qse_httpd_setopt (httpd, QSE_HTTPD_TRAIT, &trait);
tmout.sec = 10; tmout.sec = 10;

View File

@ -13,6 +13,7 @@ pkginclude_HEADERS = \
gdl.h \ gdl.h \
htb.h \ htb.h \
hton.h \ hton.h \
hwad.h \
ipad.h \ ipad.h \
main.h \ main.h \
map.h \ map.h \

View File

@ -133,11 +133,11 @@ am__can_run_installinfo = \
*) (install-info --version) >/dev/null 2>&1;; \ *) (install-info --version) >/dev/null 2>&1;; \
esac esac
am__pkginclude_HEADERS_DIST = alg.h arr.h chr.h cp949.h cp950.h dll.h \ am__pkginclude_HEADERS_DIST = alg.h arr.h chr.h cp949.h cp950.h dll.h \
env.h fma.h fmt.h gdl.h htb.h hton.h ipad.h main.h map.h mb8.h \ env.h fma.h fmt.h gdl.h htb.h hton.h hwad.h ipad.h main.h \
mbwc.h mem.h oht.h opt.h path.h pma.h rbt.h rex.h sll.h slmb.h \ map.h mb8.h mbwc.h mem.h oht.h opt.h path.h pma.h rbt.h rex.h \
str.h time.h tmr.h tre.h uni.h uri.h utf8.h xma.h Mmgr.hpp \ sll.h slmb.h str.h time.h tmr.h tre.h uni.h uri.h utf8.h xma.h \
StdMmgr.hpp HeapMmgr.hpp Mmged.hpp ScopedPtr.hpp SharedPtr.hpp \ Mmgr.hpp StdMmgr.hpp HeapMmgr.hpp Mmged.hpp ScopedPtr.hpp \
StrBase.hpp String.hpp Mpool.hpp Association.hpp \ SharedPtr.hpp StrBase.hpp String.hpp Mpool.hpp Association.hpp \
LinkedList.hpp HashList.hpp HashTable.hpp RedBlackTree.hpp \ LinkedList.hpp HashList.hpp HashTable.hpp RedBlackTree.hpp \
RedBlackTable.hpp Array.hpp BinaryHeap.hpp RedBlackTable.hpp Array.hpp BinaryHeap.hpp
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@ -361,6 +361,7 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
@ -372,9 +373,9 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
pkginclude_HEADERS = alg.h arr.h chr.h cp949.h cp950.h dll.h env.h \ pkginclude_HEADERS = alg.h arr.h chr.h cp949.h cp950.h dll.h env.h \
fma.h fmt.h gdl.h htb.h hton.h ipad.h main.h map.h mb8.h \ fma.h fmt.h gdl.h htb.h hton.h hwad.h ipad.h main.h map.h \
mbwc.h mem.h oht.h opt.h path.h pma.h rbt.h rex.h sll.h slmb.h \ mb8.h mbwc.h mem.h oht.h opt.h path.h pma.h rbt.h rex.h sll.h \
str.h time.h tmr.h tre.h uni.h uri.h utf8.h xma.h \ slmb.h str.h time.h tmr.h tre.h uni.h uri.h utf8.h xma.h \
$(am__append_1) $(am__append_1)
all: all-am all: all-am

View File

@ -30,7 +30,7 @@
#include <qse/types.h> #include <qse/types.h>
#include <qse/macros.h> #include <qse/macros.h>
/** @file /** \file
* This file defines various formatting functions. * This file defines various formatting functions.
*/ */
@ -128,28 +128,28 @@ extern "C" {
#endif #endif
/** /**
* The qse_fmtintmaxtombs() function formats an integer @a value to a * The qse_fmtintmaxtombs() function formats an integer \a value to a
* multibyte string according to the given base and writes it to a buffer * multibyte string according to the given base and writes it to a buffer
* pointed to by @a buf. It writes to the buffer at most @a size characters * pointed to by \a buf. It writes to the buffer at most \a size characters
* including the terminating null. The base must be between 2 and 36 inclusive * including the terminating null. The base must be between 2 and 36 inclusive
* and can be ORed with zero or more #qse_fmtintmaxtombs_flag_t enumerators. * and can be ORed with zero or more #qse_fmtintmaxtombs_flag_t enumerators.
* This ORed value is passed to the function via the @a base_and_flags * This ORed value is passed to the function via the \a base_and_flags
* parameter. If the formatted string is shorter than @a bufsize, the redundant * parameter. If the formatted string is shorter than \a bufsize, the redundant
* slots are filled with the fill character @a fillchar if it is not a null * slots are filled with the fill character \a fillchar if it is not a null
* character. The filling behavior is determined by the flags shown below: * character. The filling behavior is determined by the flags shown below:
* *
* - If #QSE_FMTINTMAXTOMBS_FILLRIGHT is set in @a base_and_flags, slots * - If #QSE_FMTINTMAXTOMBS_FILLRIGHT is set in \a base_and_flags, slots
* after the formatting string are filled. * after the formatting string are filled.
* - If #QSE_FMTINTMAXTOMBS_FILLCENTER is set in @a base_and_flags, slots * - If #QSE_FMTINTMAXTOMBS_FILLCENTER is set in \a base_and_flags, slots
* before the formatting string are filled. However, if it contains the * before the formatting string are filled. However, if it contains the
* sign character, the slots between the sign character and the digit part * sign character, the slots between the sign character and the digit part
* are filled. * are filled.
* - If neither #QSE_FMTINTMAXTOMBS_FILLRIGHT nor #QSE_FMTINTMAXTOMBS_FILLCENTER * - If neither #QSE_FMTINTMAXTOMBS_FILLRIGHT nor #QSE_FMTINTMAXTOMBS_FILLCENTER
* , slots before the formatting string are filled. * , slots before the formatting string are filled.
* *
* The @a precision parameter specified the minimum number of digits to * The \a precision parameter specified the minimum number of digits to
* produce from the @ value. If @a value produces fewer digits than * produce from the \a value. If \a value produces fewer digits than
* @a precision, the actual digits are padded with '0' to meet the precision * \a precision, the actual digits are padded with '0' to meet the precision
* requirement. You can pass a negative number if you don't wish to specify * requirement. You can pass a negative number if you don't wish to specify
* precision. * precision.
* *
@ -166,13 +166,13 @@ extern "C" {
* 0 to produce nothing. If both #QSE_FMTINTMAXTOMBS_NOZERO and * 0 to produce nothing. If both #QSE_FMTINTMAXTOMBS_NOZERO and
* #QSE_FMTINTMAXTOMBS_ZEROLEAD are specified, '0' is still produced. * #QSE_FMTINTMAXTOMBS_ZEROLEAD are specified, '0' is still produced.
* *
* If @a prefix is not #QSE_NULL, it is inserted before the digits. * If \a prefix is not #QSE_NULL, it is inserted before the digits.
* *
* @return * \return
* - -1 if the base is not between 2 and 36 inclusive. * - -1 if the base is not between 2 and 36 inclusive.
* - negated number of characters required for lossless formatting * - negated number of characters required for lossless formatting
* - if @a bufsize is 0. * - if \a bufsize is 0.
* - if #QSE_FMTINTMAXTOMBS_NOTRUNC is set and @a bufsize is less than * - if #QSE_FMTINTMAXTOMBS_NOTRUNC is set and \a bufsize is less than
* the minimum required for lossless formatting. * the minimum required for lossless formatting.
* - number of characters written to the buffer excluding a terminating * - number of characters written to the buffer excluding a terminating
* null in all other cases. * null in all other cases.
@ -188,28 +188,28 @@ QSE_EXPORT int qse_fmtintmaxtombs (
); );
/** /**
* The qse_fmtintmaxtowcs() function formats an integer @a value to a * The qse_fmtintmaxtowcs() function formats an integer \a value to a
* wide-character string according to the given base and writes it to a buffer * wide-character string according to the given base and writes it to a buffer
* pointed to by @a buf. It writes to the buffer at most @a size characters * pointed to by \a buf. It writes to the buffer at most \a size characters
* including the terminating null. The base must be between 2 and 36 inclusive * including the terminating null. The base must be between 2 and 36 inclusive
* and can be ORed with zero or more #qse_fmtintmaxtowcs_flag_t enumerators. * and can be ORed with zero or more #qse_fmtintmaxtowcs_flag_t enumerators.
* This ORed value is passed to the function via the @a base_and_flags * This ORed value is passed to the function via the \a base_and_flags
* parameter. If the formatted string is shorter than @a bufsize, the redundant * parameter. If the formatted string is shorter than \a bufsize, the redundant
* slots are filled with the fill character @a fillchar if it is not a null * slots are filled with the fill character \a fillchar if it is not a null
* character. The filling behavior is determined by the flags shown below: * character. The filling behavior is determined by the flags shown below:
* *
* - If #QSE_FMTINTMAXTOWCS_FILLRIGHT is set in @a base_and_flags, slots * - If #QSE_FMTINTMAXTOWCS_FILLRIGHT is set in \a base_and_flags, slots
* after the formatting string are filled. * after the formatting string are filled.
* - If #QSE_FMTINTMAXTOWCS_FILLCENTER is set in @a base_and_flags, slots * - If #QSE_FMTINTMAXTOWCS_FILLCENTER is set in \a base_and_flags, slots
* before the formatting string are filled. However, if it contains the * before the formatting string are filled. However, if it contains the
* sign character, the slots between the sign character and the digit part * sign character, the slots between the sign character and the digit part
* are filled. * are filled.
* - If neither #QSE_FMTINTMAXTOWCS_FILLRIGHT nor #QSE_FMTINTMAXTOWCS_FILLCENTER * - If neither #QSE_FMTINTMAXTOWCS_FILLRIGHT nor #QSE_FMTINTMAXTOWCS_FILLCENTER
* , slots before the formatting string are filled. * , slots before the formatting string are filled.
* *
* The @a precision parameter specified the minimum number of digits to * The \a precision parameter specified the minimum number of digits to
* produce from the @ value. If @a value produces fewer digits than * produce from the \ value. If \a value produces fewer digits than
* @a precision, the actual digits are padded with '0' to meet the precision * \a precision, the actual digits are padded with '0' to meet the precision
* requirement. You can pass a negative number if don't wish to specify * requirement. You can pass a negative number if don't wish to specify
* precision. * precision.
* *
@ -226,13 +226,13 @@ QSE_EXPORT int qse_fmtintmaxtombs (
* 0 to produce nothing. If both #QSE_FMTINTMAXTOWCS_NOZERO and * 0 to produce nothing. If both #QSE_FMTINTMAXTOWCS_NOZERO and
* #QSE_FMTINTMAXTOWCS_ZEROLEAD are specified, '0' is still produced. * #QSE_FMTINTMAXTOWCS_ZEROLEAD are specified, '0' is still produced.
* *
* If @a prefix is not #QSE_NULL, it is inserted before the digits. * If \a prefix is not #QSE_NULL, it is inserted before the digits.
* *
* @return * \return
* - -1 if the base is not between 2 and 36 inclusive. * - -1 if the base is not between 2 and 36 inclusive.
* - negated number of characters required for lossless formatting * - negated number of characters required for lossless formatting
* - if @a bufsize is 0. * - if \a bufsize is 0.
* - if #QSE_FMTINTMAXTOWCS_NOTRUNC is set and @a bufsize is less than * - if #QSE_FMTINTMAXTOWCS_NOTRUNC is set and \a bufsize is less than
* the minimum required for lossless formatting. * the minimum required for lossless formatting.
* - number of characters written to the buffer excluding a terminating * - number of characters written to the buffer excluding a terminating
* null in all other cases. * null in all other cases.
@ -247,7 +247,7 @@ QSE_EXPORT int qse_fmtintmaxtowcs (
const qse_wchar_t* prefix /**< prefix */ const qse_wchar_t* prefix /**< prefix */
); );
/** @def qse_fmtintmax /** \def qse_fmtintmax
* The qse_fmtintmax() macro maps to qse_fmtintmaxtombs() if * The qse_fmtintmax() macro maps to qse_fmtintmaxtombs() if
* #QSE_CHAR_IS_MCHAR, and qse_fmtintmaxtowcs() if #QSE_CHAR_IS_WCHAR. * #QSE_CHAR_IS_MCHAR, and qse_fmtintmaxtowcs() if #QSE_CHAR_IS_WCHAR.
*/ */
@ -258,7 +258,7 @@ QSE_EXPORT int qse_fmtintmaxtowcs (
#endif #endif
/** /**
* The qse_fmtuintmaxtombs() function formats an unsigned integer @a value * The qse_fmtuintmaxtombs() function formats an unsigned integer \a value
* to a multibyte string buffer. It behaves the same as qse_fmtuintmaxtombs() * to a multibyte string buffer. It behaves the same as qse_fmtuintmaxtombs()
* except that it handles an unsigned integer. * except that it handles an unsigned integer.
*/ */
@ -273,7 +273,7 @@ QSE_EXPORT int qse_fmtuintmaxtombs (
); );
/** /**
* The qse_fmtuintmaxtowcs() function formats an unsigned integer @a value * The qse_fmtuintmaxtowcs() function formats an unsigned integer \a value
* to a wide-character string buffer. It behaves the same as * to a wide-character string buffer. It behaves the same as
* qse_fmtuintmaxtowcs() except that it handles an unsigned integer. * qse_fmtuintmaxtowcs() except that it handles an unsigned integer.
*/ */
@ -287,7 +287,7 @@ QSE_EXPORT int qse_fmtuintmaxtowcs (
const qse_wchar_t* prefix /**< prefix */ const qse_wchar_t* prefix /**< prefix */
); );
/** @def qse_fmtuintmax /** \def qse_fmtuintmax
* The qse_fmtuintmax() macro maps to qse_fmtuintmaxtombs() if * The qse_fmtuintmax() macro maps to qse_fmtuintmaxtombs() if
* #QSE_CHAR_IS_MCHAR, and qse_fmtuintmaxtowcs() if #QSE_CHAR_IS_WCHAR. * #QSE_CHAR_IS_MCHAR, and qse_fmtuintmaxtowcs() if #QSE_CHAR_IS_WCHAR.
*/ */

View File

@ -0,0 +1,96 @@
/*
* $Id$
*
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _QSE_CMN_HWAD_H_
#define _QSE_CMN_HWAD_H_
#include <qse/types.h>
#include <qse/macros.h>
#define QSE_ETHWAD_LEN 6
#include <qse/pack1.h>
struct qse_ethwad_t
{
qse_uint8_t value[QSE_ETHWAD_LEN];
};
#include <qse/unpack.h>
typedef struct qse_ethwad_t qse_ethwad_t;
#if defined(__cplusplus)
extern "C" {
#endif
QSE_EXPORT int qse_mbstoethwad (
const qse_mchar_t* mbs,
qse_ethwad_t* hwad
);
QSE_EXPORT int qse_mbsntoethwad (
const qse_mchar_t* mbs,
qse_size_t len,
qse_ethwad_t* hwad
);
QSE_EXPORT qse_size_t qse_ethwadtombs (
const qse_ethwad_t* hwaddr,
qse_mchar_t* buf,
qse_size_t size
);
QSE_EXPORT int qse_wcstoethwad (
const qse_wchar_t* mbs,
qse_ethwad_t* hwad
);
QSE_EXPORT int qse_wcsntoethwad (
const qse_wchar_t* mbs,
qse_size_t len,
qse_ethwad_t* hwad
);
QSE_EXPORT qse_size_t qse_ethwadtowcs (
const qse_ethwad_t* hwaddr,
qse_wchar_t* buf,
qse_size_t size
);
#if defined(QSE_CHAR_IS_MCHAR)
# define qse_strtoethwad(ptr,hwad) qse_mbstoethwad(ptr,hwad)
# define qse_strntoethwad(ptr,len,hwad) qse_mbsntoethwad(ptr,len,hwad)
# define qse_ethwadtostr(hwad,ptr,len,flags) qse_ethwadtombs(hwad,ptr,len,flags)
#else
# define qse_strtoethwad(ptr,hwad) qse_wcstoethwad(ptr,hwad)
# define qse_strntoethwad(ptr,len,hwad) qse_wcsntoethwad(ptr,len,hwad)
# define qse_ethwadtostr(hwad,ptr,len,flags) qse_ethwadtowcs(hwad,ptr,len,flags)
#endif
#if defined(__cplusplus)
}
#endif
#endif

View File

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

View File

@ -46,6 +46,7 @@ libqsecmn_la_SOURCES = \
fmt-intmax.c \ fmt-intmax.c \
fmt-out.c \ fmt-out.c \
hton.c \ hton.c \
hwad.c \
ipad.c \ ipad.c \
main.c \ main.c \
mb8.c \ mb8.c \

View File

@ -144,8 +144,8 @@ libqsecmn_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \ am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \
alg-sort.c arr.c assert.c chr.c dll.c env.c gdl.c htb.c fma.c \ alg-sort.c arr.c assert.c chr.c dll.c env.c gdl.c htb.c fma.c \
fmt-intmax.c fmt-out.c hton.c ipad.c main.c mb8.c mbwc.c \ fmt-intmax.c fmt-out.c hton.c hwad.c ipad.c main.c mb8.c \
mbwc-str.c mem.c oht.c opt.c path-base.c path-canon.c \ mbwc.c mbwc-str.c mem.c oht.c opt.c path-base.c path-canon.c \
path-core.c path-merge.c pma.c rbt.c rex.c sll.c slmb.c \ path-core.c path-merge.c pma.c rbt.c rex.c sll.c slmb.c \
str-beg.c str-cat.c str-chr.c str-cnv.c str-cmp.c str-cpy.c \ str-beg.c str-cat.c str-chr.c str-cnv.c str-cmp.c str-cpy.c \
str-del.c str-dup.c str-dyn.c str-end.c str-excl.c str-fcpy.c \ str-del.c str-dup.c str-dyn.c str-end.c str-excl.c str-fcpy.c \
@ -159,18 +159,19 @@ am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \
@ENABLE_XCMGRS_TRUE@am__objects_2 = cp949.lo cp950.lo @ENABLE_XCMGRS_TRUE@am__objects_2 = cp949.lo cp950.lo
am_libqsecmn_la_OBJECTS = alg-base64.lo alg-rand.lo alg-search.lo \ am_libqsecmn_la_OBJECTS = alg-base64.lo alg-rand.lo alg-search.lo \
alg-sort.lo arr.lo assert.lo chr.lo dll.lo env.lo gdl.lo \ alg-sort.lo arr.lo assert.lo chr.lo dll.lo env.lo gdl.lo \
htb.lo fma.lo fmt-intmax.lo fmt-out.lo hton.lo ipad.lo main.lo \ htb.lo fma.lo fmt-intmax.lo fmt-out.lo hton.lo hwad.lo ipad.lo \
mb8.lo mbwc.lo mbwc-str.lo mem.lo oht.lo opt.lo path-base.lo \ main.lo mb8.lo mbwc.lo mbwc-str.lo mem.lo oht.lo opt.lo \
path-canon.lo path-core.lo path-merge.lo pma.lo rbt.lo rex.lo \ path-base.lo path-canon.lo path-core.lo path-merge.lo pma.lo \
sll.lo slmb.lo str-beg.lo str-cat.lo str-chr.lo str-cnv.lo \ rbt.lo rex.lo sll.lo slmb.lo str-beg.lo str-cat.lo str-chr.lo \
str-cmp.lo str-cpy.lo str-del.lo str-dup.lo str-dyn.lo \ str-cnv.lo str-cmp.lo str-cpy.lo str-del.lo str-dup.lo \
str-end.lo str-excl.lo str-fcpy.lo str-fmt.lo str-fnmat.lo \ str-dyn.lo str-end.lo str-excl.lo str-fcpy.lo str-fmt.lo \
str-incl.lo str-join.lo str-len.lo str-pac.lo str-pbrk.lo \ str-fnmat.lo str-incl.lo str-join.lo str-len.lo str-pac.lo \
str-put.lo str-rev.lo str-rot.lo str-set.lo str-spl.lo \ str-pbrk.lo str-put.lo str-rev.lo str-rot.lo str-set.lo \
str-spn.lo str-str.lo str-subst.lo str-tok.lo str-trm.lo \ str-spl.lo str-spn.lo str-str.lo str-subst.lo str-tok.lo \
str-word.lo time.lo tmr.lo tre.lo tre-ast.lo tre-compile.lo \ str-trm.lo str-word.lo time.lo tmr.lo tre.lo tre-ast.lo \
tre-match-bt.lo tre-match-pa.lo tre-parse.lo tre-stack.lo \ tre-compile.lo tre-match-bt.lo tre-match-pa.lo tre-parse.lo \
uri.lo utf8.lo xma.lo $(am__objects_1) $(am__objects_2) tre-stack.lo uri.lo utf8.lo xma.lo $(am__objects_1) \
$(am__objects_2)
libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS) libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@) AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -442,6 +443,7 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
@ -484,8 +486,8 @@ noinst_HEADERS = \
libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.c \ libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.c \
arr.c assert.c chr.c dll.c env.c gdl.c htb.c fma.c \ arr.c assert.c chr.c dll.c env.c gdl.c htb.c fma.c \
fmt-intmax.c fmt-out.c hton.c ipad.c main.c mb8.c mbwc.c \ fmt-intmax.c fmt-out.c hton.c hwad.c ipad.c main.c mb8.c \
mbwc-str.c mem.c oht.c opt.c path-base.c path-canon.c \ mbwc.c mbwc-str.c mem.c oht.c opt.c path-base.c path-canon.c \
path-core.c path-merge.c pma.c rbt.c rex.c sll.c slmb.c \ path-core.c path-merge.c pma.c rbt.c rex.c sll.c slmb.c \
str-beg.c str-cat.c str-chr.c str-cnv.c str-cmp.c str-cpy.c \ str-beg.c str-cat.c str-chr.c str-cnv.c str-cmp.c str-cpy.c \
str-del.c str-dup.c str-dyn.c str-end.c str-excl.c str-fcpy.c \ str-del.c str-dup.c str-dyn.c str-end.c str-excl.c str-fcpy.c \
@ -606,6 +608,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hton.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hton.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hwad.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipad.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipad.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mb8.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mb8.Plo@am__quote@

211
qse/lib/cmn/hwad.c Normal file
View File

@ -0,0 +1,211 @@
/*
* $Id$
*
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
Redimbsibution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redimbsibutions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redimbsibutions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the dimbsibution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <qse/cmn/hwad.h>
#include <qse/cmn/chr.h>
#include <qse/cmn/fmt.h>
int qse_mbstoethwad (const qse_mchar_t* mbs, qse_ethwad_t* hwaddr)
{
qse_size_t idx = 0;
const qse_mchar_t* p = mbs;
int tmp;
/*while (QSE_ISMSPACE(*p)) p++;*/
while (*p != QSE_MT('\0'))
{
tmp = QSE_MXDIGITTONUM (*p);
if (tmp <= -1) return -1;
hwaddr->value[idx] = hwaddr->value[idx] * 16 + tmp;
p++;
tmp = QSE_MXDIGITTONUM (*p);
if (tmp <= -1) return -1;
hwaddr->value[idx] = hwaddr->value[idx] * 16 + tmp;
p++;
if (idx < QSE_ETHWAD_LEN - 1)
{
if (*p != QSE_MT(':')) return -1;
p++; idx++;
}
else
{
return (*p == QSE_MT('\0'))? 0: -1;
}
}
return -1;
}
int qse_mbsxtoethwaddr (const qse_mchar_t* mbs, qse_size_t len, qse_ethwad_t* hwaddr)
{
qse_size_t idx = 0;
const qse_mchar_t* p = mbs, * end = mbs + len;
int tmp;
/*while (QSE_ISWSPACE(*p)) p++;*/
while (p < end)
{
tmp = QSE_MXDIGITTONUM (*p);
if (tmp <= -1) return -1;
hwaddr->value[idx] = hwaddr->value[idx] * 16 + tmp;
p++;
if (p >= end) return -1;
tmp = QSE_MXDIGITTONUM (*p);
if (tmp <= -1) return -1;
hwaddr->value[idx] = hwaddr->value[idx] * 16 + tmp;
p++;
if (idx < QSE_ETHWAD_LEN - 1)
{
if (p >= end || *p != QSE_MT(':')) return -1;
p++; idx++;
}
else
{
return (p >= end)? 0: -1;
}
}
return -1;
}
qse_size_t qse_ethwadtombs (const qse_ethwad_t* hwaddr, qse_mchar_t* buf, qse_size_t size)
{
qse_size_t i;
qse_mchar_t tmp[QSE_ETHWAD_LEN][3];
if (size <= 0) return 0;
QSE_ASSERT (QSE_COUNTOF(hwaddr->value) == QSE_ETHWAD_LEN);
for (i = 0; i < QSE_COUNTOF(hwaddr->value); i++)
{
qse_fmtuintmaxtombs (tmp[i], QSE_COUNTOF(tmp[i]), hwaddr->value[i], 16 | QSE_FMTUINTMAXTOMBS_UPPERCASE, 2, QSE_MT('\0'), QSE_NULL);
}
return qse_mbsxjoin (buf, size,
tmp[0], QSE_MT(":"), tmp[1], QSE_MT(":"),
tmp[2], QSE_MT(":"), tmp[3], QSE_MT(":"),
tmp[4], QSE_MT(":"), tmp[5], QSE_NULL);
}
/* -------------------------------------------------------------------------- */
int qse_wcstoethwad (const qse_wchar_t* wcs, qse_ethwad_t* hwaddr)
{
qse_size_t idx = 0;
const qse_wchar_t* p = wcs;
int tmp;
/*while (qse_ismspace(*p)) p++;*/
while (*p != QSE_WT('\0'))
{
tmp = QSE_WXDIGITTONUM (*p);
if (tmp <= -1) return -1;
hwaddr->value[idx] = hwaddr->value[idx] * 16 + tmp;
p++;
tmp = QSE_WXDIGITTONUM (*p);
if (tmp <= -1) return -1;
hwaddr->value[idx] = hwaddr->value[idx] * 16 + tmp;
p++;
if (idx < QSE_ETHWAD_LEN - 1)
{
if (*p != QSE_WT(':')) return -1;
p++; idx++;
}
else
{
return (*p == QSE_WT('\0'))? 0: -1;
}
}
return -1;
}
int qse_wcsxtoethwaddr (const qse_wchar_t* wcs, qse_size_t len, qse_ethwad_t* hwaddr)
{
qse_size_t idx = 0;
const qse_wchar_t* p = wcs, * end = wcs + len;
int tmp;
/*while (qse_ismspace(*p)) p++;*/
while (p < end)
{
tmp = QSE_WXDIGITTONUM (*p);
if (tmp <= -1) return -1;
hwaddr->value[idx] = hwaddr->value[idx] * 16 + tmp;
p++;
if (p >= end) return -1;
tmp = QSE_WXDIGITTONUM (*p);
if (tmp <= -1) return -1;
hwaddr->value[idx] = hwaddr->value[idx] * 16 + tmp;
p++;
if (idx < QSE_ETHWAD_LEN - 1)
{
if (p >= end || *p != QSE_WT(':')) return -1;
p++; idx++;
}
else
{
return (p >= end)? 0: -1;
}
}
return -1;
}
qse_size_t qse_ethwadtowcs (const qse_ethwad_t* hwaddr, qse_wchar_t* buf, qse_size_t size)
{
qse_size_t i;
qse_wchar_t tmp[QSE_ETHWAD_LEN][3];
if (size <= 0) return 0;
QSE_ASSERT (QSE_COUNTOF(hwaddr->value) == QSE_ETHWAD_LEN);
for (i = 0; i < QSE_COUNTOF(hwaddr->value); i++)
{
qse_fmtuintmaxtowcs (tmp[i], QSE_COUNTOF(tmp[i]), hwaddr->value[i], 16 | QSE_FMTUINTMAXTOWCS_UPPERCASE, 2, QSE_WT('\0'), QSE_NULL);
}
return qse_wcsxjoin (buf, size,
tmp[0], QSE_WT(":"), tmp[1], QSE_WT(":"),
tmp[2], QSE_WT(":"), tmp[3], QSE_WT(":"),
tmp[4], QSE_WT(":"), tmp[5], QSE_NULL);
}

View File

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