diff --git a/qse/configure b/qse/configure index b8b13f7a..ccf3c5d6 100755 --- a/qse/configure +++ b/qse/configure @@ -23898,7 +23898,7 @@ QSE_PROJECT_AUTHOR="${PACKAGE_BUGREPORT}" QSE_PROJECT_URL="${PACKAGE_URL}" -ac_config_files="$ac_config_files Makefile README 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 lib/Makefile lib/cmn/Makefile lib/cry/Makefile lib/si/Makefile lib/awk/Makefile lib/sed/Makefile lib/xli/Makefile lib/http/Makefile lib/rad/Makefile lib/dhcp/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/http/Makefile samples/rad/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 README 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 lib/Makefile lib/cmn/Makefile lib/cry/Makefile lib/si/Makefile lib/awk/Makefile lib/sed/Makefile lib/xli/Makefile lib/http/Makefile lib/rad/Makefile lib/dhcp/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/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" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -25121,6 +25121,7 @@ do "samples/sed/Makefile") CONFIG_FILES="$CONFIG_FILES samples/sed/Makefile" ;; "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" ;; "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" ;; diff --git a/qse/configure.ac b/qse/configure.ac index d16e5819..1d75ff0c 100644 --- a/qse/configure.ac +++ b/qse/configure.ac @@ -834,6 +834,7 @@ AC_CONFIG_FILES([ samples/sed/Makefile samples/http/Makefile samples/rad/Makefile + samples/dhcp/Makefile regress/Makefile regress/awk/Makefile regress/awk/regress.sh diff --git a/qse/include/qse/cmn/Makefile.am b/qse/include/qse/cmn/Makefile.am index 16162c96..ca590210 100644 --- a/qse/include/qse/cmn/Makefile.am +++ b/qse/include/qse/cmn/Makefile.am @@ -33,6 +33,7 @@ pkginclude_HEADERS = \ time.h \ tmr.h \ tre.h \ + test.h \ uni.h \ uri.h \ utf8.h \ diff --git a/qse/include/qse/cmn/Makefile.in b/qse/include/qse/cmn/Makefile.in index ba735754..c93d2d60 100644 --- a/qse/include/qse/cmn/Makefile.in +++ b/qse/include/qse/cmn/Makefile.in @@ -135,8 +135,8 @@ am__can_run_installinfo = \ 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 htl.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 \ + rex.h sll.h slmb.h str.h time.h tmr.h tre.h test.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 @@ -374,8 +374,8 @@ 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 htl.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) + sll.h slmb.h str.h time.h tmr.h tre.h test.h uni.h uri.h \ + utf8.h xma.h $(am__append_1) all: all-am .SUFFIXES: diff --git a/qse/include/qse/cmn/test.h b/qse/include/qse/cmn/test.h new file mode 100644 index 00000000..279b59c6 --- /dev/null +++ b/qse/include/qse/cmn/test.h @@ -0,0 +1,38 @@ +/* + * $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_TEST_H_ +#define _QSE_CMN_TEST_H_ + +#include + +#define QSE_TESASSERT_FAIL1(msg1) qse_printf(QSE_T("FAILURE in %hs[%d] - %s\n"), __func__, (int)__LINE__, msg1) +#define QSE_TESASSERT_FAIL2(msg1,msg2) qse_printf(QSE_T("FAILURE in %hs[%d] - %s - %s\n"), __func__, (int)__LINE__, msg1, msg2) + +#define QSE_TESASSERT1(test,msg1) do { if (!(test)) { QSE_TESASSERT_FAIL1(msg1); goto oops; } } while(0) +#define QSE_TESASSERT2(test,msg1,msg2) do { if (!(test)) { QSE_TESASSERT_FAIL2(msg1,msg2); goto oops; } } while(0) + +#endif diff --git a/qse/include/qse/dhcp/dhcpmsg.h b/qse/include/qse/dhcp/dhcpmsg.h index ddba9d22..bdb4e51e 100644 --- a/qse/include/qse/dhcp/dhcpmsg.h +++ b/qse/include/qse/dhcp/dhcpmsg.h @@ -11,8 +11,19 @@ /* operation code */ enum qse_dhcp4_op_t { - QSE_DHCP4OP_BOOTREQUEST = 1, - QSE_DHCP4OP_BOOTREPLY = 2 + QSE_DHCP4_OP_BOOTREQUEST = 1, + QSE_DHCP4_OP_BOOTREPLY = 2 +}; + +enum qse_dhcp4_htype_t +{ + QSE_DHCP4_HTYPE_ETHERNET = 1, + QSE_DHCP4_HTYPE_IEEE802 = 6, + QSE_DHCP4_HTYPE_ARCNET = 7, + QSE_DHCP4_HTYPE_APPLETALK = 8, + QSE_DHCP4_HTYPE_HDLC = 17, + QSE_DHCP4_HTYPE_ATM = 19, + QSE_DHCP4_HTYPE_INFINIBAND = 32 }; /* option codes (partial) */ @@ -71,17 +82,29 @@ enum qse_dhcp4_opt_relay_t /* message type */ enum qse_dhcp4_msg_t { - QSE_DHCP4MSG_DISCOVER = 1, - QSE_DHCP4MSG_OFFER = 2, - QSE_DHCP4MSG_REQUEST = 3, - QSE_DHCP4MSG_DECLINE = 4, - QSE_DHCP4MSG_ACK = 5, - QSE_DHCP4MSG_NAK = 6, - QSE_DHCP4MSG_RELEASE = 7, - QSE_DHCP4MSG_INFORM = 8 + QSE_DHCP4_MSG_DISCOVER = 1, + QSE_DHCP4_MSG_OFFER = 2, + QSE_DHCP4_MSG_REQUEST = 3, + QSE_DHCP4_MSG_DECLINE = 4, + QSE_DHCP4_MSG_ACK = 5, + QSE_DHCP4_MSG_NAK = 6, + QSE_DHCP4_MSG_RELEASE = 7, + QSE_DHCP4_MSG_INFORM = 8, + + /*QSE_DHCP4_MSG_RENEW = 9,*/ + + QSE_DHCP4_MSG_LEASE_QUERY = 10, + QSE_DHCP4_MSG_LEASE_UNASSIGNED = 11, + QSE_DHCP4_MSG_LEASE_UNKNOWN = 12, + QSE_DHCP4_MSG_LEASE_ACTIVE = 13, + + QSE_DHCP4_MSG_BULK_LEASE_QUERY = 14, + QSE_DHCP4_MSG_LEASE_QUERY_DONE = 15 }; -struct qse_dhcp4_pkt_t +#include + +struct qse_dhcp4_pkt_hdr_t { qse_uint8_t op; qse_uint8_t htype; @@ -103,24 +126,74 @@ struct qse_dhcp4_pkt_t * the first four bytes of the options compose a magic cookie * 0x63 0x82 0x53 0x63 */ }; +typedef struct qse_dhcp4_pkt_hdr_t qse_dhcp4_pkt_hdr_t; -typedef struct qse_dhcp4_pkt_t qse_dhcp4_pkt_t; +struct qse_dhcp4_opt_hdr_t +{ + qse_uint8_t code; + qse_uint8_t len; +}; +typedef struct qse_dhcp4_opt_hdr_t qse_dhcp4_opt_hdr_t; + +typedef int (*qse_dhcp4_opt_walker_t) (qse_dhcp4_opt_hdr_t* opt); + +struct qse_dhcp4_pktinf_t +{ + qse_dhcp4_pkt_hdr_t* hdr; + qse_size_t len; +}; +typedef struct qse_dhcp4_pktinf_t qse_dhcp4_pktinf_t; + +struct qse_dhcp4_pktbuf_t +{ + qse_dhcp4_pkt_hdr_t* hdr; + qse_size_t len; + qse_size_t capa; +}; +typedef struct qse_dhcp4_pktbuf_t qse_dhcp4_pktbuf_t; + +#include #ifdef __cplusplus extern "C" { #endif -QSE_EXPORT qse_uint8_t* qse_dhcp4_get_options ( - const qse_dhcp4_pkt_t* pkt, - qse_size_t len, - qse_size_t* olen /* option area length */ +QSE_EXPORT int qse_dhcp4_initialize_pktbuf ( + qse_dhcp4_pktbuf_t* pkt, + void* buf, + qse_size_t capa ); -QSE_EXPORT qse_uint8_t* qse_dhcp4_get_option ( - const qse_dhcp4_pkt_t* pkt, - qse_size_t len, - int code, - qse_uint8_t* olen +QSE_EXPORT int qse_dhcp4_add_option ( + qse_dhcp4_pktbuf_t* pkt, + int code, + void* optr, /**< option data pointer */ + qse_uint8_t olen /**< option data length */ +); + +QSE_EXPORT void qse_dhcp4_compact_options ( + qse_dhcp4_pktbuf_t* pkt +); + +#if 0 +QSE_EXPORT int qse_dhcp4_add_options ( + qse_dhcp4_pkt_hdr_t* pkt, + qse_size_t len, + qse_size_t max, + int code, + qse_uint8_t* optr, /* option data */ + qse_uint8_t olen /* option length */ +); +#endif + +QSE_EXPORT int qse_dhcp4_walk_options ( + const qse_dhcp4_pktinf_t* pkt, + qse_dhcp4_opt_walker_t walker +); + +QSE_EXPORT qse_dhcp4_opt_hdr_t* qse_dhcp4_find_option ( + const qse_dhcp4_pktinf_t* pkt, + int ode ); QSE_EXPORT qse_uint8_t* qse_dhcp4_get_relay_suboption ( @@ -130,16 +203,6 @@ QSE_EXPORT qse_uint8_t* qse_dhcp4_get_relay_suboption ( qse_uint8_t* olen ); - -QSE_EXPORT int qse_dhcp4_add_option ( - qse_dhcp4_pkt_t* pkt, - qse_size_t len, - qse_size_t max, - int code, - qse_uint8_t* optr, /* option data */ - qse_uint8_t olen /* option length */ -); - #ifdef __cplusplus } #endif diff --git a/qse/lib/dhcp/dhcpmsg.c b/qse/lib/dhcp/dhcpmsg.c index d19ff0c4..af33bdd4 100644 --- a/qse/lib/dhcp/dhcpmsg.c +++ b/qse/lib/dhcp/dhcpmsg.c @@ -2,44 +2,121 @@ #include #include "../cmn/mem-prv.h" -qse_uint8_t* qse_dhcp4_get_options (const qse_dhcp4_pkt_t* pkt, qse_size_t len, qse_size_t* olen) +#include +struct magic_cookie_t { - qse_uint32_t cookie; - qse_size_t optlen; - qse_uint8_t* opt; + qse_uint32_t value; +}; +typedef struct magic_cookie_t magic_cookie_t; +#include - /* check if a packet is large enough to hold the known header */ - if (len < QSE_SIZEOF(qse_dhcp4_pkt_t)) return QSE_NULL; - - /* get the length of option fields */ - optlen = len - QSE_SIZEOF(qse_dhcp4_pkt_t); - - /* check if a packet is large enough to have a magic cookie */ - if (optlen < QSE_SIZEOF(cookie)) return QSE_NULL; - - /* get the pointer to the beginning of options */ - opt = (qse_uint8_t*)(pkt + 1); - - /* use QSE_MEMCPY to prevent any alignment issues */ - QSE_MEMCPY (&cookie, opt, QSE_SIZEOF(cookie)); - /* check if the packet contains the right magic cookie */ - if (cookie != qse_hton32(QSE_DHCP4_MAGIC_COOKIE)) return QSE_NULL; - - *olen = optlen - QSE_SIZEOF(cookie); - return (qse_uint8_t*)(opt + QSE_SIZEOF(cookie)); +int qse_dhcp4_initialize_pktbuf (qse_dhcp4_pktbuf_t* pkt, void* buf, qse_size_t capa) +{ + if (capa < QSE_SIZEOF(*pkt->hdr)) return -1; + pkt->hdr = (qse_dhcp4_pkt_hdr_t*)buf; + pkt->len = QSE_SIZEOF(*pkt->hdr); + pkt->capa = capa; + QSE_MEMSET (pkt->hdr, 0, QSE_SIZEOF(*pkt->hdr)); + return 0; } -qse_uint8_t* qse_dhcp4_get_option (const qse_dhcp4_pkt_t* pkt, qse_size_t len, int code, qse_uint8_t* olen) +int qse_dhcp4_add_option (qse_dhcp4_pktbuf_t* pkt, int code, void* optr, qse_uint8_t olen) +{ + qse_dhcp4_opt_hdr_t* opthdr; + magic_cookie_t* cookie; + int optlen; + +/* TODO: support to override sname and file */ + if (pkt->len < QSE_SIZEOF(*pkt->hdr) || pkt->capa < pkt->len) + { + /* the pktbuf_t structure got messy */ + return -1; + } + + if (pkt->len == QSE_SIZEOF(*pkt->hdr)) + { + /* the first option is being added */ + if (pkt->capa - pkt->len < QSE_SIZEOF(*cookie)) return -1; + cookie = (magic_cookie_t*)((qse_uint8_t*)pkt->hdr + pkt->len); + cookie->value = QSE_CONST_HTON32(QSE_DHCP4_MAGIC_COOKIE); + pkt->len += QSE_SIZEOF(*cookie); + } + else if (pkt->len < QSE_SIZEOF(*pkt->hdr) + QSE_SIZEOF(*cookie)) + { + /* no space for cookie */ + return -1; + } + else + { + cookie = (magic_cookie_t*)(pkt->hdr + 1); + if (cookie->value != QSE_CONST_HTON32(QSE_DHCP4_MAGIC_COOKIE)) return -1; + } + +/* do i need to disallow adding a new option if END is found? */ + + if (code == QSE_DHCP4_OPT_PADDING || code == QSE_DHCP4_OPT_END) + { + optlen = 1; /* no length field in the header and no option palyload */ + if (pkt->capa - pkt->len < optlen) return -1; + opthdr = (qse_dhcp4_opt_hdr_t*)((qse_uint8_t*)pkt->hdr + pkt->len); + } + else + { + optlen = QSE_SIZEOF(*opthdr) + olen; + + if (pkt->capa - pkt->len < optlen) return -1; + opthdr = (qse_dhcp4_opt_hdr_t*)((qse_uint8_t*)pkt->hdr + pkt->len); + + opthdr->len = olen; + if (olen > 0) QSE_MEMCPY (opthdr + 1, optr, olen); + } + + opthdr->code = code; + pkt->len += optlen; + + return 0; +} + +void qse_dhcp4_compact_options (qse_dhcp4_pktbuf_t* pkt) +{ + /* TODO: move some optiosn to sname or file fields if they are not in use. */ +} + +static qse_uint8_t* get_option_start (const qse_dhcp4_pkt_hdr_t* pkt, qse_size_t len, qse_size_t* olen) +{ + magic_cookie_t* cookie; + qse_size_t optlen; + + /* check if a packet is large enough to hold the known header */ + if (len < QSE_SIZEOF(qse_dhcp4_pkt_hdr_t)) return QSE_NULL; + + /* get the length of option fields */ + optlen = len - QSE_SIZEOF(qse_dhcp4_pkt_hdr_t); + + /* check if a packet is large enough to have a magic cookie */ + if (optlen < QSE_SIZEOF(*cookie)) return QSE_NULL; + + /* get the pointer to the beginning of options */ + cookie = (magic_cookie_t*)(pkt + 1); + + /* check if the packet contains the right magic cookie */ + if (cookie->value != QSE_CONST_HTON32(QSE_DHCP4_MAGIC_COOKIE)) return QSE_NULL; + + *olen = optlen - QSE_SIZEOF(*cookie); + return (qse_uint8_t*)(cookie + 1); +} + +int qse_dhcp4_walk_options (const qse_dhcp4_pktinf_t* pkt, qse_dhcp4_opt_walker_t walker) { const qse_uint8_t* optptr[3]; qse_size_t optlen[3]; int i; - optptr[0] = qse_dhcp4_get_options (pkt, len, &optlen[0]); - if (optptr[0] == QSE_NULL) return QSE_NULL; + optptr[0] = get_option_start(pkt->hdr, pkt->len, &optlen[0]); + if (optptr[0] == QSE_NULL) return -1; - optptr[1] = (const qse_uint8_t*)pkt->file; - optptr[2] = (const qse_uint8_t*)pkt->sname; + optptr[1] = (const qse_uint8_t*)pkt->hdr->file; + optptr[2] = (const qse_uint8_t*)pkt->hdr->sname; optlen[1] = 0; optlen[2] = 0; @@ -51,49 +128,99 @@ qse_uint8_t* qse_dhcp4_get_option (const qse_dhcp4_pkt_t* pkt, qse_size_t len, i while (opt < end) { /* option code */ - qse_uint8_t oc, ol; + qse_dhcp4_opt_hdr_t* opthdr; - oc = *opt++; + if (opt + QSE_SIZEOF(*opthdr) >= end) return -1; + opthdr = (qse_dhcp4_opt_hdr_t*)opt; + opt += QSE_SIZEOF(*opthdr); - if (oc == QSE_DHCP4_OPT_PADDING) continue; - if (oc == QSE_DHCP4_OPT_END) break; - - if (opt >= end) + /* no len field exists for PADDING and END */ + if (opthdr->code == QSE_DHCP4_OPT_PADDING) continue; + if (opthdr->code == QSE_DHCP4_OPT_END) break; + + if (opt + opthdr->len >= end) return -1; /* the length field is wrong */ + + if (opthdr->code == QSE_DHCP4_OPT_OVERLOAD) + { + if (opthdr->len != 1) return -1; + if (*opt & QSE_DHCP4_OPT_OVERLOAD_FILE) optlen[1] = QSE_SIZEOF(pkt->hdr->file); + if (*opt & QSE_DHCP4_OPT_OVERLOAD_SNAME) optlen[2] = QSE_SIZEOF(pkt->hdr->sname); + } + else + { + int n; + if ((n = walker(opthdr)) <= -1) return -1; + if (n == 0) break; /* stop */ + } + + opt += opthdr->len; + } + } + + return 0; +} + +qse_dhcp4_opt_hdr_t* qse_dhcp4_find_option (const qse_dhcp4_pktinf_t* pkt, int code) +{ + const qse_uint8_t* optptr[3]; + qse_size_t optlen[3]; + int i; + + optptr[0] = get_option_start(pkt->hdr, pkt->len, &optlen[0]); + if (optptr[0] == QSE_NULL) return QSE_NULL; + + optptr[1] = (const qse_uint8_t*)pkt->hdr->file; + optptr[2] = (const qse_uint8_t*)pkt->hdr->sname; + optlen[1] = 0; + optlen[2] = 0; + + for (i = 0; i < 3; i++) + { + const qse_uint8_t* opt = optptr[i]; + const qse_uint8_t* end = opt + optlen[i]; + + while (opt < end) + { + /* option code */ + qse_dhcp4_opt_hdr_t* opthdr; + + if (opt + QSE_SIZEOF(*opthdr) >= end) { /*return QSE_NULL; */ break; } + opthdr = (qse_dhcp4_opt_hdr_t*)opt; + opt += QSE_SIZEOF(*opthdr); + + if (opthdr->code == QSE_DHCP4_OPT_PADDING) continue; + if (opthdr->code == QSE_DHCP4_OPT_END) break; /* option length */ - ol = *opt++; - if (oc == code) + if (opthdr->code == code) { - if (opt + ol >= end) + if (opt + opthdr->len >= end) { /*return QSE_NULL; */ break; } - *olen = ol; - return (qse_uint8_t*)opt; + return opthdr; } - if (oc == QSE_DHCP4_OPT_OVERLOAD) + if (opthdr->code == QSE_DHCP4_OPT_OVERLOAD) { - if (ol != 1) + if (opthdr->len != 1) { /*return QSE_NULL; */ break; } - if (*opt & QSE_DHCP4_OPT_OVERLOAD_FILE) - optlen[1] = QSE_SIZEOF(pkt->file); - if (*opt & QSE_DHCP4_OPT_OVERLOAD_SNAME) - optlen[2] = QSE_SIZEOF(pkt->sname); + if (*opt & QSE_DHCP4_OPT_OVERLOAD_FILE) optlen[1] = QSE_SIZEOF(pkt->hdr->file); + if (*opt & QSE_DHCP4_OPT_OVERLOAD_SNAME) optlen[2] = QSE_SIZEOF(pkt->hdr->sname); } - opt += ol; + opt += opthdr->len; } } @@ -126,32 +253,3 @@ qse_uint8_t* qse_dhcp4_get_relay_suboption (const qse_uint8_t* ptr, qse_uint8_t } -int qse_dhcp4_add_option (qse_dhcp4_pkt_t* pkt, qse_size_t len, qse_size_t max, int code, qse_uint8_t* optr, qse_uint8_t olen) -{ - qse_size_t optlen; - -#if 0 - /* check if a packet is large enough to hold the known header */ - if (len < QSE_SIZEOF(qse_dhcp4_pkt_t)) return -1; - - /* get the length of option fields */ - optlen = len - QSE_SIZEOF(qse_dhcp4_pkt_t); - - /* check if a packet is large enough to have a magic cookie */ - if (optlen < QSE_SIZEOF(cookie)) return QSE_NULL; - - /* get the pointer to the beginning of options */ - opt = (qse_uint8_t*)(pkt + 1); - - /* use QSE_MEMCPY to prevent any alignment issues */ - QSE_MEMCPY (&cookie, opt, QSE_SIZEOF(cookie)); - /* check if the packet contains the right magic cookie */ - if (cookie != qse_hton32(QSE_DHCP4_MAGIC_COOKIE)) return QSE_NULL; - - *olen = optlen - QSE_SIZEOF(cookie); - optr = (qse_uint8_t*)(opt + QSE_SIZEOF(cookie)); -#endif - - return -1; -} - diff --git a/qse/samples/Makefile.am b/qse/samples/Makefile.am index d579a014..c6081350 100644 --- a/qse/samples/Makefile.am +++ b/qse/samples/Makefile.am @@ -1 +1 @@ -SUBDIRS = cmn cry si awk sed http rad +SUBDIRS = cmn cry si awk sed http rad dhcp diff --git a/qse/samples/Makefile.in b/qse/samples/Makefile.in index b70708dc..1ef8f1b1 100644 --- a/qse/samples/Makefile.in +++ b/qse/samples/Makefile.in @@ -366,7 +366,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 http rad +SUBDIRS = cmn cry si awk sed http rad dhcp all: all-recursive .SUFFIXES: diff --git a/qse/samples/cmn/sp02.cpp b/qse/samples/cmn/sp02.cpp index 93e36c8d..b18834b1 100644 --- a/qse/samples/cmn/sp02.cpp +++ b/qse/samples/cmn/sp02.cpp @@ -1,69 +1,105 @@ #include #include #include +#include + +static int test_marker[1000] = { 0, }; +static int array_deleted = 0; class X { public: X(int y = 0): y(y) { - printf ("X(%d) constructured\n", this->y); + qse_printf (QSE_T("X(%d) constructured\n"), this->y); + test_marker[y]++; } ~X() { - printf ("X(%d) destructed\n", this->y); + qse_printf (QSE_T("X(%d) destructed\n"), this->y); + test_marker[y]--; } int y; }; +struct array_deleter: QSE::SharedPtrArrayDeleter +{ + void operator() (X* ptr, void* arg) + { + array_deleted++; + QSE::SharedPtrArrayDeleter::operator() (ptr, arg); + } +}; + struct destroy_x_in_mmgr { void operator() (X* x, void* arg) { - x->~X(); + array_deleted++; + x->~X(); ::operator delete (x, (QSE::Mmgr*)arg); } }; -void f2 () +int f2 () { - QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 30000); - QSE::HeapMmgr heap_mmgr_2 (QSE::Mmgr::getDFL(), 30000); + QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 30000); + QSE::HeapMmgr heap_mmgr_2 (QSE::Mmgr::getDFL(), 30000); QSE::SharedPtr y (new X(1)); QSE::SharedPtr > k (&heap_mmgr); - { - QSE::SharedPtr x1 (y); - } - printf ("----------------------------\n"); + QSE_TESASSERT1 (y->y == 1, QSE_T("unexpected value")); + QSE_TESASSERT1 (test_marker[y->y] == 1, QSE_T("allocation tally wrong")); { - QSE::SharedPtr > x3 (new X[10]); + QSE::SharedPtr x1 (y); + QSE_TESASSERT1 (x1->y == 1, QSE_T("unexpected value")); } - printf ("----------------------------\n"); + QSE_TESASSERT1 (test_marker[y->y] == 1, QSE_T("allocation tally wrong")); + qse_printf (QSE_T("----------------------------\n")); + + { + //QSE::SharedPtr > x3 (new X[10]); + QSE::SharedPtr x3 (new X[10]); + } + QSE_TESASSERT1 (array_deleted == 1, QSE_T("array not deleted")); + qse_printf (QSE_T("----------------------------\n")); { //QSE::SharedPtr x2 (new(&heap_mmgr) X, destroy_x); + QSE_TESASSERT1 (test_marker[2] == 0, QSE_T("allocation tally wrong")); QSE::SharedPtr x2 (&heap_mmgr, new(&heap_mmgr) X(2), &heap_mmgr); + QSE_TESASSERT1 (x2->y == 2, QSE_T("unexpected value")); + QSE_TESASSERT1 (test_marker[2] == 1, QSE_T("allocation tally wrong")); } - printf ("----------------------------\n"); + QSE_TESASSERT1 (test_marker[2] == 0, QSE_T("allocation tally wrong")); + qse_printf (QSE_T("----------------------------\n")); { + QSE_TESASSERT1 (test_marker[3] == 0, QSE_T("allocation tally wrong")); QSE::SharedPtr > x4 (new(&heap_mmgr_2) X(3), &heap_mmgr_2); + QSE_TESASSERT1 (test_marker[3] == 1, QSE_T("allocation tally wrong")); k = x4; QSE::SharedPtr > x5 (k); } - printf ("----------------------------\n"); + QSE_TESASSERT1 (test_marker[3] == 1, QSE_T("allocation tally wrong")); + qse_printf (QSE_T("----------------------------\n")); - QSE_ASSERT (k->y == 3); + QSE_TESASSERT1 (k->y == 3, QSE_T("unexpected value")); + return 0; + +oops: + return -1; } int main () { + qse_open_stdsios(); f2 (); + qse_close_stdsios(); return 0; } diff --git a/qse/samples/dhcp/Makefile.am b/qse/samples/dhcp/Makefile.am new file mode 100644 index 00000000..198132ab --- /dev/null +++ b/qse/samples/dhcp/Makefile.am @@ -0,0 +1,21 @@ +AiUTOMAKE_OPTIONS = nostdinc + +AM_CPPFLAGS = \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(includedir) + +bin_PROGRAMS = dhcp01 + +AM_LDFLAGS = -L../../lib/cmn -L../../lib/si -L../../lib/dhcp +LDADD = -lqsedhcp -lqsesi -lqsecmn + +if WIN32 +if WCHAR +LDADD += $(UNICOWS_LIBS) +endif +endif + +dhcp01_SOURCES = dhcp01.c + +dhcp01_LDADD = $(LDADD) diff --git a/qse/samples/dhcp/Makefile.in b/qse/samples/dhcp/Makefile.in new file mode 100644 index 00000000..2ce8f872 --- /dev/null +++ b/qse/samples/dhcp/Makefile.in @@ -0,0 +1,706 @@ +# Makefile.in generated by automake 1.15 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2014 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 = dhcp01$(EXEEXT) +@WCHAR_TRUE@@WIN32_TRUE@am__append_1 = $(UNICOWS_LIBS) +subdir = samples/dhcp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.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/ltargz.m4 $(top_srcdir)/m4/ltdl.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)/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 = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_dhcp01_OBJECTS = dhcp01.$(OBJEXT) +dhcp01_OBJECTS = $(am_dhcp01_OBJECTS) +am__DEPENDENCIES_1 = +@WCHAR_TRUE@@WIN32_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) +am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2) +dhcp01_DEPENDENCIES = $(am__DEPENDENCIES_3) +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 = -I.@am__isrc@ -I$(top_builddir)/include/qse +depcomp = $(SHELL) $(top_srcdir)/ac/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +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 = $(dhcp01_SOURCES) +DIST_SOURCES = $(dhcp01_SOURCES) +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@ +CHAR_MODE = @CHAR_MODE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +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@ +INCLTDL = @INCLTDL@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBADD_DL = @LIBADD_DL@ +LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ +LIBADD_DLOPEN = @LIBADD_DLOPEN@ +LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ +LIBLTDL = @LIBLTDL@ +LIBM = @LIBM@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTDLDEPS = @LTDLDEPS@ +LTDLINCL = @LTDLINCL@ +LTDLOPEN = @LTDLOPEN@ +LTLIBOBJS = @LTLIBOBJS@ +LT_ARGZ_H = @LT_ARGZ_H@ +LT_CONFIG_H = @LT_CONFIG_H@ +LT_DLLOADERS = @LT_DLLOADERS@ +LT_DLPREOPEN = @LT_DLPREOPEN@ +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_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@ +ltdl_LIBOBJS = @ltdl_LIBOBJS@ +ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ +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@ +subdirs = @subdirs@ +sys_symbol_underscore = @sys_symbol_underscore@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AiUTOMAKE_OPTIONS = nostdinc +AM_CPPFLAGS = \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(includedir) + +AM_LDFLAGS = -L../../lib/cmn -L../../lib/si -L../../lib/dhcp +LDADD = -lqsedhcp -lqsesi -lqsecmn $(am__append_1) +dhcp01_SOURCES = dhcp01.c +dhcp01_LDADD = $(LDADD) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .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/dhcp/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign samples/dhcp/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__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + 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 + +dhcp01$(EXEEXT): $(dhcp01_OBJECTS) $(dhcp01_DEPENDENCIES) $(EXTRA_dhcp01_DEPENDENCIES) + @rm -f dhcp01$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(dhcp01_OBJECTS) $(dhcp01_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhcp01.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -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: $(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 -rf ./$(DEPDIR) + -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 -rf ./$(DEPDIR) + -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 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: diff --git a/qse/samples/dhcp/dhcp01.c b/qse/samples/dhcp/dhcp01.c new file mode 100644 index 00000000..d361fda6 --- /dev/null +++ b/qse/samples/dhcp/dhcp01.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include + +#define R(f) \ + do { \ + qse_printf (QSE_T("== %s ==\n"), QSE_T(#f)); \ + if (f() == -1) goto oops; \ + } while (0) + + +static int test10() +{ + struct sockaddr_in sin; + int s; + qse_uint8_t buf[10000]; + qse_dhcp4_pktbuf_t pb; + qse_ip4ad_t ip4ad[3]; + + if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) return -1; + + memset (&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = inet_addr("192.168.1.2"); + sin.sin_port = htons(67); + + qse_dhcp4_initialize_pktbuf (&pb, buf, QSE_SIZEOF(buf)); + pb.hdr->op = QSE_DHCP4_OP_BOOTREQUEST; + pb.hdr->htype = QSE_DHCP4_HTYPE_ETHERNET; + pb.hdr->hlen = 6; + + qse_dhcp4_add_option (&pb, QSE_DHCP4_OPT_HOST_NAME, "my.server", 9); + qse_dhcp4_add_option (&pb, QSE_DHCP4_OPT_PADDING, QSE_NULL, 0); + qse_dhcp4_add_option (&pb, QSE_DHCP4_OPT_PADDING, QSE_NULL, 0); + qse_dhcp4_add_option (&pb, QSE_DHCP4_OPT_PADDING, QSE_NULL, 0); + qse_strtoip4ad (QSE_T("192.168.1.1"), &ip4ad[0]); + qse_strtoip4ad (QSE_T("192.168.1.2"), &ip4ad[1]); + qse_strtoip4ad (QSE_T("192.168.1.3"), &ip4ad[2]); + qse_dhcp4_add_option (&pb, QSE_DHCP4_OPT_NAME_SERVER, ip4ad, QSE_SIZEOF(ip4ad)); + qse_dhcp4_add_option (&pb, QSE_DHCP4_OPT_END, QSE_NULL, 0); + sendto (s, pb.hdr, pb.len, 0, &sin, sizeof(sin)); + + close (s); + return 0; +} + +int main () +{ + qse_open_stdsios (); + + R (test10); + +oops: + qse_close_stdsios (); + return 0; +} + diff --git a/qse/samples/rad/raddic01.c b/qse/samples/rad/raddic01.c index 6e291db5..cc7f19b3 100644 --- a/qse/samples/rad/raddic01.c +++ b/qse/samples/rad/raddic01.c @@ -3,6 +3,7 @@ #include #include #include +#include #if 0 #include @@ -17,42 +18,36 @@ if (f() == -1) goto oops; \ } while (0) -#define FAIL(msg) qse_printf(QSE_T("FAILURE in %hs line %d - %s\n"), __func__, __LINE__, msg) -#define FAIL2(msg1,msg2) qse_printf(QSE_T("FAILURE in %hs line %d - %s - %s\n"), __func__, __LINE__, msg1, msg2) -#define _assert(test,msg) do { if (!(test)) { FAIL(msg); goto oops; } } while(0) -#define _assert2(test,msg1,msg2) do { if (!(test)) { FAIL2(msg1,msg2); goto oops; } } while(0) -#define _verify(test) do { int r=test(); tests_run++; if(r) return r; } while(0) - static int test1 () { qse_raddic_t* dic; - qse_raddic_vendor_t* vendor, * v; + qse_raddic_vendor_t* vendor, * v; int i; dic = qse_raddic_open (QSE_MMGR_GETDFL(), 0); - _assert (dic != QSE_NULL, QSE_T("unable to create a radius dictionary")); + QSE_TESASSERT1 (dic != QSE_NULL, QSE_T("unable to create a radius dictionary")); vendor = qse_raddic_addvendor (dic, QSE_T("abiyo.net"), 12365); - _assert (vendor != QSE_NULL, QSE_T("unable to add the first vendor")); - _assert (vendor->vendorpec == 12365, QSE_T("the vendor value is not 12365")); - _assert (qse_strcasecmp(vendor->name, QSE_T("abiyo.net")) == 0, QSE_T("the vendor name is not abiyo.net")); + QSE_TESASSERT1 (vendor != QSE_NULL, QSE_T("unable to add the first vendor")); + QSE_TESASSERT1 (vendor->vendorpec == 12365, QSE_T("the vendor value is not 12365")); + QSE_TESASSERT1 (qse_strcasecmp(vendor->name, QSE_T("abiyo.net")) == 0, QSE_T("the vendor name is not abiyo.net")); vendor = qse_raddic_addvendor (dic, QSE_T("abiyo.net"), 99999); - _assert (vendor == QSE_NULL, QSE_T("a duplicate name must not be allowed")); + QSE_TESASSERT1 (vendor == QSE_NULL, QSE_T("a duplicate name must not be allowed")); vendor = qse_raddic_addvendor (dic, QSE_T("abiyo-aliased.net"), 12365); - _assert (vendor != QSE_NULL, QSE_T("unable to add a duplicate id")); + QSE_TESASSERT1 (vendor != QSE_NULL, QSE_T("unable to add a duplicate id")); vendor = qse_raddic_findvendorbyname (dic, QSE_T("Abiyo.Net")); - _assert (vendor != QSE_NULL && vendor->vendorpec == 12365, QSE_T("unable to find a vendor named Abiyo.Net")); + QSE_TESASSERT1 (vendor != QSE_NULL && vendor->vendorpec == 12365, QSE_T("unable to find a vendor named Abiyo.Net")); vendor = qse_raddic_findvendorbyvalue (dic, 12365); - _assert (vendor != QSE_NULL && vendor->vendorpec == 12365, QSE_T("unable to find a vendor of value 12365")); - _assert (qse_strcasecmp(vendor->name, QSE_T("abiyo-aliased.net")) == 0, QSE_T("unable to find a vendor of value 12365")); + QSE_TESASSERT1 (vendor != QSE_NULL && vendor->vendorpec == 12365, QSE_T("unable to find a vendor of value 12365")); + QSE_TESASSERT1 (qse_strcasecmp(vendor->name, QSE_T("abiyo-aliased.net")) == 0, QSE_T("unable to find a vendor of value 12365")); vendor = qse_raddic_findvendorbyname (dic, QSE_T("Abiyo-aliased.Net")); - _assert (vendor != QSE_NULL && vendor->vendorpec == 12365, QSE_T("unable to find a vendor named Abiyo-aliased.Net")); - _assert (qse_strcasecmp(vendor->name, QSE_T("abiyo-aliased.net")) == 0, QSE_T("unable to find a vendor of value 12365")); + QSE_TESASSERT1 (vendor != QSE_NULL && vendor->vendorpec == 12365, QSE_T("unable to find a vendor named Abiyo-aliased.Net")); + QSE_TESASSERT1 (qse_strcasecmp(vendor->name, QSE_T("abiyo-aliased.net")) == 0, QSE_T("unable to find a vendor of value 12365")); #define COUNT1 600 #define COUNT2 700 @@ -62,9 +57,9 @@ static int test1 () qse_char_t tmp[64]; qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i); vendor = qse_raddic_addvendor (dic, tmp, i); - _assert (vendor != QSE_NULL, QSE_T("unable to add a vendor")); - _assert (vendor->vendorpec == i, QSE_T("wrong vendor value")); - _assert (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name")); + QSE_TESASSERT1 (vendor != QSE_NULL, QSE_T("unable to add a vendor")); + QSE_TESASSERT1 (vendor->vendorpec == i, QSE_T("wrong vendor value")); + QSE_TESASSERT1 (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name")); } for (i = 1; i < COUNT1; i++) @@ -72,9 +67,9 @@ static int test1 () qse_char_t tmp[64]; qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i); vendor = qse_raddic_findvendorbyname (dic, tmp); - _assert (vendor != QSE_NULL, QSE_T("unable to find a vendor")); - _assert (vendor->vendorpec == i, QSE_T("wrong vendor value")); - _assert (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name")); + QSE_TESASSERT1 (vendor != QSE_NULL, QSE_T("unable to find a vendor")); + QSE_TESASSERT1 (vendor->vendorpec == i, QSE_T("wrong vendor value")); + QSE_TESASSERT1 (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name")); } for (i = 1; i < COUNT1; i++) @@ -82,9 +77,9 @@ static int test1 () qse_char_t tmp[64]; qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i); vendor = qse_raddic_findvendorbyvalue (dic, i); - _assert (vendor != QSE_NULL, QSE_T("unable to find a vendor")); - _assert (vendor->vendorpec == i, QSE_T("wrong vendor value")); - _assert (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name")); + QSE_TESASSERT1 (vendor != QSE_NULL, QSE_T("unable to find a vendor")); + QSE_TESASSERT1 (vendor->vendorpec == i, QSE_T("wrong vendor value")); + QSE_TESASSERT1 (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name")); } for (i = COUNT1; i < COUNT2; i++) @@ -93,12 +88,12 @@ static int test1 () qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i); vendor = qse_raddic_addvendor (dic, tmp, COUNT1); // insert different items with the same value - _assert (vendor != QSE_NULL, QSE_T("unable to add a vendor")); - _assert (vendor->vendorpec == COUNT1, QSE_T("wrong vendor value")); - _assert (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name")); + QSE_TESASSERT1 (vendor != QSE_NULL, QSE_T("unable to add a vendor")); + QSE_TESASSERT1 (vendor->vendorpec == COUNT1, QSE_T("wrong vendor value")); + QSE_TESASSERT1 (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name")); v = qse_raddic_findvendorbyvalue (dic, COUNT1); - _assert (vendor == v, QSE_T("unable to find a last added vendor by value")); + QSE_TESASSERT1 (vendor == v, QSE_T("unable to find a last added vendor by value")); } for (i = COUNT1; i < COUNT2 - 1; i++) @@ -109,24 +104,24 @@ static int test1 () qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i); n = qse_raddic_deletevendorbyname (dic, tmp); - _assert (n == 0, QSE_T("unable to delete a vendor")); + QSE_TESASSERT1 (n == 0, QSE_T("unable to delete a vendor")); v = qse_raddic_findvendorbyname (dic, tmp); - _assert (v == QSE_NULL, QSE_T("vendor found errorenously")); + QSE_TESASSERT1 (v == QSE_NULL, QSE_T("vendor found errorenously")); if (i == COUNT2 - 1) { v = qse_raddic_findvendorbyvalue (dic, COUNT1); - _assert (v == QSE_NULL, QSE_T("vendor of COUNT1 found errorenously")); + QSE_TESASSERT1 (v == QSE_NULL, QSE_T("vendor of COUNT1 found errorenously")); } else { qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i + 1); v = qse_raddic_findvendorbyname (dic, tmp); - _assert (v != QSE_NULL && v->vendorpec == COUNT1 && qse_strcasecmp(tmp, v->name) == 0, QSE_T("unable to find an expected vendor")); + QSE_TESASSERT1 (v != QSE_NULL && v->vendorpec == COUNT1 && qse_strcasecmp(tmp, v->name) == 0, QSE_T("unable to find an expected vendor")); v = qse_raddic_findvendorbyvalue (dic, COUNT1); - _assert (v != QSE_NULL && v->vendorpec == COUNT1, QSE_T("unable to find the vendor of COUNT1")); + QSE_TESASSERT1 (v != QSE_NULL && v->vendorpec == COUNT1, QSE_T("unable to find the vendor of COUNT1")); } } @@ -137,7 +132,7 @@ static int test1 () qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i); n = qse_raddic_deletevendorbyname (dic, tmp); - _assert (n == 0, QSE_T("unable to delete a vendor")); + QSE_TESASSERT1 (n == 0, QSE_T("unable to delete a vendor")); } for (i = 1; i < COUNT1; i++) @@ -145,31 +140,31 @@ static int test1 () qse_char_t tmp[64]; qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i); v = qse_raddic_addvendor (dic, tmp, i); - _assert (v != QSE_NULL && v->vendorpec == i, QSE_T("unable to add a vendor")); + QSE_TESASSERT1 (v != QSE_NULL && v->vendorpec == i, QSE_T("unable to add a vendor")); qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testx-%d"), i); v = qse_raddic_addvendor (dic, tmp, i); - _assert (v != QSE_NULL && v->vendorpec == i, QSE_T("unable to add a vendor")); + QSE_TESASSERT1 (v != QSE_NULL && v->vendorpec == i, QSE_T("unable to add a vendor")); qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testy-%d"), i); v = qse_raddic_addvendor (dic, tmp, i); - _assert (v != QSE_NULL && v->vendorpec == i, QSE_T("unable to add a vendor")); + QSE_TESASSERT1 (v != QSE_NULL && v->vendorpec == i, QSE_T("unable to add a vendor")); } for (i = 1; i < COUNT1; i++) { int n; n = qse_raddic_deletevendorbyvalue (dic, i); - _assert (n == 0, QSE_T("unable to delete a vendor by value")); + QSE_TESASSERT1 (n == 0, QSE_T("unable to delete a vendor by value")); n = qse_raddic_deletevendorbyvalue (dic, i); - _assert (n == 0, QSE_T("unable to delete a vendor by value")); + QSE_TESASSERT1 (n == 0, QSE_T("unable to delete a vendor by value")); n = qse_raddic_deletevendorbyvalue (dic, i); - _assert (n == 0, QSE_T("unable to delete a vendor by value")); + QSE_TESASSERT1 (n == 0, QSE_T("unable to delete a vendor by value")); n = qse_raddic_deletevendorbyvalue (dic, i); - _assert (n <= -1, QSE_T("erroreneously successful vendor deletion by value")); + QSE_TESASSERT1 (n <= -1, QSE_T("erroreneously successful vendor deletion by value")); } qse_raddic_close (dic); @@ -190,7 +185,7 @@ static int test2 () int i, j; dic = qse_raddic_open (QSE_MMGR_GETDFL(), 0); - _assert (dic != QSE_NULL, QSE_T("unable to create a radius dictionary")); + QSE_TESASSERT1 (dic != QSE_NULL, QSE_T("unable to create a radius dictionary")); memset (&f, 0, QSE_SIZEOF(f)); @@ -201,9 +196,9 @@ static int test2 () qse_char_t tmp[64]; qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d-%d"), j, i); attr = qse_raddic_addattr (dic, tmp, j, QSE_RADDIC_ATTR_TYPE_UINT32, i, &f); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); } } @@ -214,14 +209,14 @@ static int test2 () qse_char_t tmp[64]; qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d-%d"), j, i); attr = qse_raddic_findattrbyname (dic, tmp); - _assert (attr != QSE_NULL, QSE_T("unable to find an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to find an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); attr = qse_raddic_findattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(j, i)); - _assert (attr != QSE_NULL, QSE_T("unable to find an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to find an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); } } @@ -232,15 +227,15 @@ static int test2 () qse_char_t tmp[64]; qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testx-%d-%d"), j, i); attr = qse_raddic_addattr (dic, tmp, j, QSE_RADDIC_ATTR_TYPE_UINT32, i, &f); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testy-%d-%d"), j, i); attr = qse_raddic_addattr (dic, tmp, j, QSE_RADDIC_ATTR_TYPE_UINT32, i, &f); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); } } @@ -254,34 +249,34 @@ static int test2 () qse_strxfmt(tmpy, QSE_COUNTOF(tmpy), QSE_T("testy-%d-%d"), j, i); attr = qse_raddic_findattrbyname (dic, tmp); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); attr = qse_raddic_findattrbyname (dic, tmpx); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmpx) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmpx) == 0, QSE_T("wrong attr name")); attr = qse_raddic_findattrbyname (dic, tmpy); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name")); attr = qse_raddic_findattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(j, i)); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name")); - _assert (attr->nexta != QSE_NULL, QSE_T("unable to find an old attribute")); - _assert (attr->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->nexta->name, tmpx) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr->nexta != QSE_NULL, QSE_T("unable to find an old attribute")); + QSE_TESASSERT1 (attr->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->nexta->name, tmpx) == 0, QSE_T("wrong attr name")); - _assert (attr->nexta->nexta != QSE_NULL, QSE_T("unable to find an old attribute")); - _assert (attr->nexta->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->nexta->nexta->name, tmp) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr->nexta->nexta != QSE_NULL, QSE_T("unable to find an old attribute")); + QSE_TESASSERT1 (attr->nexta->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->nexta->nexta->name, tmp) == 0, QSE_T("wrong attr name")); - _assert (attr->nexta->nexta->nexta == QSE_NULL, QSE_T("wrong attribute chian")); + QSE_TESASSERT1 (attr->nexta->nexta->nexta == QSE_NULL, QSE_T("wrong attribute chian")); } } @@ -294,7 +289,7 @@ static int test2 () qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testx-%d-%d"), j, i); n = qse_raddic_deleteattrbyname (dic, tmp); - _assert (n == 0, QSE_T("erroreneous attribute deletion failure by name")); + QSE_TESASSERT1 (n == 0, QSE_T("erroreneous attribute deletion failure by name")); } } @@ -308,28 +303,28 @@ static int test2 () qse_strxfmt(tmpy, QSE_COUNTOF(tmpy), QSE_T("testy-%d-%d"), j, i); attr = qse_raddic_findattrbyname (dic, tmp); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name")); attr = qse_raddic_findattrbyname (dic, tmpx); - _assert (attr == QSE_NULL, QSE_T("erroneous search success")); + QSE_TESASSERT1 (attr == QSE_NULL, QSE_T("erroneous search success")); attr = qse_raddic_findattrbyname (dic, tmpy); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name")); attr = qse_raddic_findattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(j, i)); - _assert (attr != QSE_NULL, QSE_T("unable to add an attribute")); - _assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr != QSE_NULL, QSE_T("unable to add an attribute")); + QSE_TESASSERT1 (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name")); - _assert (attr->nexta != QSE_NULL, QSE_T("unable to find an old attribute")); - _assert (attr->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); - _assert (qse_strcasecmp(attr->nexta->name, tmp) == 0, QSE_T("wrong attr name")); + QSE_TESASSERT1 (attr->nexta != QSE_NULL, QSE_T("unable to find an old attribute")); + QSE_TESASSERT1 (attr->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value")); + QSE_TESASSERT1 (qse_strcasecmp(attr->nexta->name, tmp) == 0, QSE_T("wrong attr name")); - _assert (attr->nexta->nexta == QSE_NULL, QSE_T("wrong attribute chian")); + QSE_TESASSERT1 (attr->nexta->nexta == QSE_NULL, QSE_T("wrong attribute chian")); } } @@ -337,13 +332,13 @@ static int test2 () { int n; n = qse_raddic_deleteattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(0, 0)); - _assert (n == 0, QSE_T("erroneous deletion failure by value")); + QSE_TESASSERT1 (n == 0, QSE_T("erroneous deletion failure by value")); n = qse_raddic_deleteattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(0, 0)); - _assert (n == 0, QSE_T("erroneous deletion failure by value")); + QSE_TESASSERT1 (n == 0, QSE_T("erroneous deletion failure by value")); n = qse_raddic_deleteattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(0, 0)); - _assert (n <= -1, QSE_T("erroneous deletion success by value")); + QSE_TESASSERT1 (n <= -1, QSE_T("erroneous deletion success by value")); } @@ -356,9 +351,9 @@ static int test2 () qse_strxfmt(attrstr, QSE_COUNTOF(attrstr), QSE_T("test-%d-%d"), j, i); qse_strxfmt(constr, QSE_COUNTOF(constr), QSE_T("const-%d-%d"), j, i); con = qse_raddic_addconst (dic, constr, attrstr, 10); - _assert2 (con != QSE_NULL, QSE_T("unable to add an constant"), qse_raddic_geterrmsg(dic)); - _assert (con->value == 10, QSE_T("wrong constant value")); - _assert (qse_strcasecmp(con->name, constr) == 0, QSE_T("wrong constant name")); + QSE_TESASSERT2 (con != QSE_NULL, QSE_T("unable to add an constant"), qse_raddic_geterrmsg(dic)); + QSE_TESASSERT1 (con->value == 10, QSE_T("wrong constant value")); + QSE_TESASSERT1 (qse_strcasecmp(con->name, constr) == 0, QSE_T("wrong constant name")); } } @@ -371,14 +366,14 @@ static int test2 () qse_strxfmt(constr, QSE_COUNTOF(constr), QSE_T("const-%d-%d"), j, i); con = qse_raddic_findconstbyname (dic, QSE_RADDIC_ATTR_MAKE(j, i), constr); - _assert (con != QSE_NULL, QSE_T("unable to find an constant")); - _assert (con->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong constant value")); - _assert (con->value == 10, QSE_T("wrong constant value")); + QSE_TESASSERT1 (con != QSE_NULL, QSE_T("unable to find an constant")); + QSE_TESASSERT1 (con->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong constant value")); + QSE_TESASSERT1 (con->value == 10, QSE_T("wrong constant value")); con = qse_raddic_findconstbyvalue (dic, QSE_RADDIC_ATTR_MAKE(j, i), 10); - _assert (con != QSE_NULL, QSE_T("unable to find an constant")); - _assert (con->value == 10, QSE_T("wrong constant value")); - _assert (con->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong constant value")); + QSE_TESASSERT1 (con != QSE_NULL, QSE_T("unable to find an constant")); + QSE_TESASSERT1 (con->value == 10, QSE_T("wrong constant value")); + QSE_TESASSERT1 (con->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong constant value")); } } @@ -386,19 +381,19 @@ static int test2 () int n; n = qse_raddic_deleteconstbyname (dic, QSE_RADDIC_ATTR_MAKE(1,1), QSE_T("const-1-1")); - _assert (n == 0, QSE_T("erroneous constant deletion failure")); + QSE_TESASSERT1 (n == 0, QSE_T("erroneous constant deletion failure")); n = qse_raddic_deleteconstbyname (dic, QSE_RADDIC_ATTR_MAKE(1,1), QSE_T("const-1-1")); - _assert (n <= -1, QSE_T("erroneous constant deletion success")); + QSE_TESASSERT1 (n <= -1, QSE_T("erroneous constant deletion success")); n = qse_raddic_deleteconstbyvalue (dic, QSE_RADDIC_ATTR_MAKE(2,2), 20); - _assert (n <= -1, QSE_T("erroneous constant deletion success")); + QSE_TESASSERT1 (n <= -1, QSE_T("erroneous constant deletion success")); n = qse_raddic_deleteconstbyvalue (dic, QSE_RADDIC_ATTR_MAKE(2,2), 10); - _assert (n == 0, QSE_T("erroneous constant deletion success")); + QSE_TESASSERT1 (n == 0, QSE_T("erroneous constant deletion success")); n = qse_raddic_deleteconstbyvalue (dic, QSE_RADDIC_ATTR_MAKE(2,2), 10); - _assert (n <= -1, QSE_T("erroneous constant deletion success")); + QSE_TESASSERT1 (n <= -1, QSE_T("erroneous constant deletion success")); } qse_raddic_close (dic); @@ -417,20 +412,20 @@ static int test3 () int n, trait; dic = qse_raddic_open (QSE_MMGR_GETDFL(), 0); - _assert (dic != QSE_NULL, QSE_T("unable to create a radius dictionary")); + QSE_TESASSERT1 (dic != QSE_NULL, QSE_T("unable to create a radius dictionary")); trait = QSE_RADDIC_ALLOW_CONST_WITHOUT_ATTR | QSE_RADDIC_ALLOW_DUPLICATE_CONST; n = qse_raddic_setopt (dic, QSE_RADDIC_TRAIT, &trait); - _assert (n == 0, QSE_T("cannot set trait")); + QSE_TESASSERT1 (n == 0, QSE_T("cannot set trait")); n = qse_raddic_load (dic, QSE_T("fr/dictionary")); - _assert2 (n == 0, QSE_T("unabled to load dictionary"), qse_raddic_geterrmsg(dic)); + QSE_TESASSERT2 (n == 0, QSE_T("unabled to load dictionary"), qse_raddic_geterrmsg(dic)); v = qse_raddic_findvendorbyname (dic, QSE_T("cisco")); - _assert (v && v->vendorpec == 9, "wrong vendor value"); + QSE_TESASSERT1 (v && v->vendorpec == 9, "wrong vendor value"); c = qse_raddic_findconstbyname (dic, QSE_RADDIC_ATTR_MAKE(0,49), QSE_T("Reauthentication-Failure")); - _assert (c && c->value == 20, QSE_T("wrong constant value")); + QSE_TESASSERT1 (c && c->value == 20, QSE_T("wrong constant value")); qse_raddic_close (dic); return 0;