Added ethernet address conversion functions
This commit is contained in:
@ -13,6 +13,7 @@ pkginclude_HEADERS = \
|
||||
gdl.h \
|
||||
htb.h \
|
||||
hton.h \
|
||||
hwad.h \
|
||||
ipad.h \
|
||||
main.h \
|
||||
map.h \
|
||||
|
@ -133,11 +133,11 @@ am__can_run_installinfo = \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
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 \
|
||||
mbwc.h mem.h oht.h opt.h path.h pma.h rbt.h rex.h sll.h slmb.h \
|
||||
str.h time.h tmr.h tre.h uni.h uri.h utf8.h xma.h Mmgr.hpp \
|
||||
StdMmgr.hpp HeapMmgr.hpp Mmged.hpp ScopedPtr.hpp SharedPtr.hpp \
|
||||
StrBase.hpp String.hpp Mpool.hpp Association.hpp \
|
||||
env.h fma.h fmt.h gdl.h htb.h hton.h hwad.h ipad.h main.h \
|
||||
map.h mb8.h mbwc.h mem.h oht.h opt.h path.h pma.h rbt.h rex.h \
|
||||
sll.h slmb.h str.h time.h tmr.h tre.h uni.h uri.h utf8.h xma.h \
|
||||
Mmgr.hpp StdMmgr.hpp HeapMmgr.hpp Mmged.hpp ScopedPtr.hpp \
|
||||
SharedPtr.hpp StrBase.hpp String.hpp Mpool.hpp Association.hpp \
|
||||
LinkedList.hpp HashList.hpp HashTable.hpp RedBlackTree.hpp \
|
||||
RedBlackTable.hpp Array.hpp BinaryHeap.hpp
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
@ -361,6 +361,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@ -372,9 +373,9 @@ top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
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 \
|
||||
mbwc.h mem.h oht.h opt.h path.h pma.h rbt.h rex.h sll.h slmb.h \
|
||||
str.h time.h tmr.h tre.h uni.h uri.h utf8.h xma.h \
|
||||
fma.h fmt.h gdl.h htb.h hton.h hwad.h ipad.h main.h map.h \
|
||||
mb8.h mbwc.h mem.h oht.h opt.h path.h pma.h rbt.h rex.h sll.h \
|
||||
slmb.h str.h time.h tmr.h tre.h uni.h uri.h utf8.h xma.h \
|
||||
$(am__append_1)
|
||||
all: all-am
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/** @file
|
||||
/** \file
|
||||
* This file defines various formatting functions.
|
||||
*/
|
||||
|
||||
@ -128,28 +128,28 @@ extern "C" {
|
||||
#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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* - 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
|
||||
* sign character, the slots between the sign character and the digit part
|
||||
* are filled.
|
||||
* - If neither #QSE_FMTINTMAXTOMBS_FILLRIGHT nor #QSE_FMTINTMAXTOMBS_FILLCENTER
|
||||
* , slots before the formatting string are filled.
|
||||
*
|
||||
* The @a precision parameter specified the minimum number of digits to
|
||||
* produce from the @ value. If @a value produces fewer digits than
|
||||
* @a precision, the actual digits are padded with '0' to meet the precision
|
||||
* The \a precision parameter specified the minimum number of digits to
|
||||
* 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
|
||||
* requirement. You can pass a negative number if you don't wish to specify
|
||||
* precision.
|
||||
*
|
||||
@ -166,13 +166,13 @@ extern "C" {
|
||||
* 0 to produce nothing. If both #QSE_FMTINTMAXTOMBS_NOZERO and
|
||||
* #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.
|
||||
* - negated number of characters required for lossless formatting
|
||||
* - if @a bufsize is 0.
|
||||
* - if #QSE_FMTINTMAXTOMBS_NOTRUNC is set and @a bufsize is less than
|
||||
* - if \a bufsize is 0.
|
||||
* - if #QSE_FMTINTMAXTOMBS_NOTRUNC is set and \a bufsize is less than
|
||||
* the minimum required for lossless formatting.
|
||||
* - number of characters written to the buffer excluding a terminating
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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:
|
||||
*
|
||||
* - 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.
|
||||
* - 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
|
||||
* sign character, the slots between the sign character and the digit part
|
||||
* are filled.
|
||||
* - If neither #QSE_FMTINTMAXTOWCS_FILLRIGHT nor #QSE_FMTINTMAXTOWCS_FILLCENTER
|
||||
* , slots before the formatting string are filled.
|
||||
*
|
||||
* The @a precision parameter specified the minimum number of digits to
|
||||
* produce from the @ value. If @a value produces fewer digits than
|
||||
* @a precision, the actual digits are padded with '0' to meet the precision
|
||||
* The \a precision parameter specified the minimum number of digits to
|
||||
* produce from the \ value. If \a value produces fewer digits than
|
||||
* \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
|
||||
* precision.
|
||||
*
|
||||
@ -226,13 +226,13 @@ QSE_EXPORT int qse_fmtintmaxtombs (
|
||||
* 0 to produce nothing. If both #QSE_FMTINTMAXTOWCS_NOZERO and
|
||||
* #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.
|
||||
* - negated number of characters required for lossless formatting
|
||||
* - if @a bufsize is 0.
|
||||
* - if #QSE_FMTINTMAXTOWCS_NOTRUNC is set and @a bufsize is less than
|
||||
* - if \a bufsize is 0.
|
||||
* - if #QSE_FMTINTMAXTOWCS_NOTRUNC is set and \a bufsize is less than
|
||||
* the minimum required for lossless formatting.
|
||||
* - number of characters written to the buffer excluding a terminating
|
||||
* null in all other cases.
|
||||
@ -247,7 +247,7 @@ QSE_EXPORT int qse_fmtintmaxtowcs (
|
||||
const qse_wchar_t* prefix /**< prefix */
|
||||
);
|
||||
|
||||
/** @def qse_fmtintmax
|
||||
/** \def qse_fmtintmax
|
||||
* The qse_fmtintmax() macro maps to qse_fmtintmaxtombs() if
|
||||
* #QSE_CHAR_IS_MCHAR, and qse_fmtintmaxtowcs() if #QSE_CHAR_IS_WCHAR.
|
||||
*/
|
||||
@ -258,7 +258,7 @@ QSE_EXPORT int qse_fmtintmaxtowcs (
|
||||
#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()
|
||||
* 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
|
||||
* qse_fmtuintmaxtowcs() except that it handles an unsigned integer.
|
||||
*/
|
||||
@ -287,7 +287,7 @@ QSE_EXPORT int qse_fmtuintmaxtowcs (
|
||||
const qse_wchar_t* prefix /**< prefix */
|
||||
);
|
||||
|
||||
/** @def qse_fmtuintmax
|
||||
/** \def qse_fmtuintmax
|
||||
* The qse_fmtuintmax() macro maps to qse_fmtuintmaxtombs() if
|
||||
* #QSE_CHAR_IS_MCHAR, and qse_fmtuintmaxtowcs() if #QSE_CHAR_IS_WCHAR.
|
||||
*/
|
||||
|
96
qse/include/qse/cmn/hwad.h
Normal file
96
qse/include/qse/cmn/hwad.h
Normal 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
|
@ -353,6 +353,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
|
Reference in New Issue
Block a user