added QSE_GLOB_TOLERANT
enhanced check for __int128_t added qse_getnwifcfg() added qse_skad_t, qse_skadtonwad(), qse_nwadtoskad() added more checks to configure.ac
This commit is contained in:
@ -49,7 +49,9 @@ libqsecmn_la_SOURCES = \
|
||||
mem.c \
|
||||
mux.c \
|
||||
nwad.c \
|
||||
nwad-skad.c \
|
||||
nwif.c \
|
||||
nwif-cfg.c \
|
||||
nwio.c \
|
||||
oht.c \
|
||||
opt.c \
|
||||
|
@ -90,33 +90,34 @@ libqsecmn_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \
|
||||
alg-sort.c assert.c chr.c dir.c dll.c env.c gdl.c htb.c fio.c \
|
||||
fma.c fmt.c fs.c fs-err.c fs-move.c glob.c hton.c ipad.c lda.c \
|
||||
main.c mbwc.c mbwc-str.c mem.c mux.c nwad.c nwif.c nwio.c \
|
||||
oht.c opt.c path-basename.c path-canon.c pio.c pma.c rbt.c \
|
||||
rex.c sio.c sll.c slmb.c stdio.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-dynm.c \
|
||||
str-dynw.c str-end.c str-excl.c str-fcpy.c str-fnmat.c \
|
||||
str-incl.c str-len.c str-pac.c str-pbrk.c str-put.c str-rev.c \
|
||||
str-rot.c str-set.c str-spl.c str-spn.c str-str.c str-subst.c \
|
||||
str-tok.c str-trm.c str-word.c task.c time.c tio.c tre.c \
|
||||
tre-ast.c tre-compile.c tre-match-backtrack.c \
|
||||
tre-match-parallel.c tre-parse.c tre-stack.c uri.c utf8.c \
|
||||
xma.c cp949.c cp950.c
|
||||
main.c mbwc.c mbwc-str.c mem.c mux.c nwad.c nwad-skad.c nwif.c \
|
||||
nwif-cfg.c nwio.c oht.c opt.c path-basename.c path-canon.c \
|
||||
pio.c pma.c rbt.c rex.c sio.c sll.c slmb.c stdio.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-dynm.c str-dynw.c str-end.c str-excl.c \
|
||||
str-fcpy.c str-fnmat.c str-incl.c str-len.c str-pac.c \
|
||||
str-pbrk.c str-put.c str-rev.c str-rot.c str-set.c str-spl.c \
|
||||
str-spn.c str-str.c str-subst.c str-tok.c str-trm.c str-word.c \
|
||||
task.c time.c tio.c tre.c tre-ast.c tre-compile.c \
|
||||
tre-match-backtrack.c tre-match-parallel.c tre-parse.c \
|
||||
tre-stack.c uri.c utf8.c xma.c cp949.c cp950.c
|
||||
@INCLUDE_MORE_CMGRS_TRUE@am__objects_1 = cp949.lo cp950.lo
|
||||
am_libqsecmn_la_OBJECTS = alg-base64.lo alg-rand.lo alg-search.lo \
|
||||
alg-sort.lo assert.lo chr.lo dir.lo dll.lo env.lo gdl.lo \
|
||||
htb.lo fio.lo fma.lo fmt.lo fs.lo fs-err.lo fs-move.lo glob.lo \
|
||||
hton.lo ipad.lo lda.lo main.lo mbwc.lo mbwc-str.lo mem.lo \
|
||||
mux.lo nwad.lo nwif.lo nwio.lo oht.lo opt.lo path-basename.lo \
|
||||
path-canon.lo pio.lo pma.lo rbt.lo rex.lo sio.lo sll.lo \
|
||||
slmb.lo stdio.lo str-beg.lo str-cat.lo str-chr.lo str-cnv.lo \
|
||||
str-cmp.lo str-cpy.lo str-del.lo str-dup.lo str-dynm.lo \
|
||||
str-dynw.lo str-end.lo str-excl.lo str-fcpy.lo str-fnmat.lo \
|
||||
str-incl.lo str-len.lo str-pac.lo str-pbrk.lo str-put.lo \
|
||||
str-rev.lo str-rot.lo str-set.lo str-spl.lo str-spn.lo \
|
||||
str-str.lo str-subst.lo str-tok.lo str-trm.lo str-word.lo \
|
||||
task.lo time.lo tio.lo tre.lo tre-ast.lo tre-compile.lo \
|
||||
tre-match-backtrack.lo tre-match-parallel.lo tre-parse.lo \
|
||||
tre-stack.lo uri.lo utf8.lo xma.lo $(am__objects_1)
|
||||
mux.lo nwad.lo nwad-skad.lo nwif.lo nwif-cfg.lo nwio.lo oht.lo \
|
||||
opt.lo path-basename.lo path-canon.lo pio.lo pma.lo rbt.lo \
|
||||
rex.lo sio.lo sll.lo slmb.lo stdio.lo str-beg.lo str-cat.lo \
|
||||
str-chr.lo str-cnv.lo str-cmp.lo str-cpy.lo str-del.lo \
|
||||
str-dup.lo str-dynm.lo str-dynw.lo str-end.lo str-excl.lo \
|
||||
str-fcpy.lo str-fnmat.lo str-incl.lo str-len.lo str-pac.lo \
|
||||
str-pbrk.lo str-put.lo str-rev.lo str-rot.lo str-set.lo \
|
||||
str-spl.lo str-spn.lo str-str.lo str-subst.lo str-tok.lo \
|
||||
str-trm.lo str-word.lo task.lo time.lo tio.lo tre.lo \
|
||||
tre-ast.lo tre-compile.lo tre-match-backtrack.lo \
|
||||
tre-match-parallel.lo tre-parse.lo tre-stack.lo uri.lo utf8.lo \
|
||||
xma.lo $(am__objects_1)
|
||||
libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS)
|
||||
libqsecmn_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
@ -352,16 +353,17 @@ noinst_HEADERS = \
|
||||
libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.c \
|
||||
assert.c chr.c dir.c dll.c env.c gdl.c htb.c fio.c fma.c fmt.c \
|
||||
fs.c fs-err.c fs-move.c glob.c hton.c ipad.c lda.c main.c \
|
||||
mbwc.c mbwc-str.c mem.c mux.c nwad.c nwif.c nwio.c oht.c opt.c \
|
||||
path-basename.c path-canon.c pio.c pma.c rbt.c rex.c sio.c \
|
||||
sll.c slmb.c stdio.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-dynm.c str-dynw.c \
|
||||
str-end.c str-excl.c str-fcpy.c str-fnmat.c str-incl.c \
|
||||
str-len.c str-pac.c str-pbrk.c str-put.c str-rev.c str-rot.c \
|
||||
str-set.c str-spl.c str-spn.c str-str.c str-subst.c str-tok.c \
|
||||
str-trm.c str-word.c task.c time.c tio.c tre.c tre-ast.c \
|
||||
tre-compile.c tre-match-backtrack.c tre-match-parallel.c \
|
||||
tre-parse.c tre-stack.c uri.c utf8.c xma.c $(am__append_1)
|
||||
mbwc.c mbwc-str.c mem.c mux.c nwad.c nwad-skad.c nwif.c \
|
||||
nwif-cfg.c nwio.c oht.c opt.c path-basename.c path-canon.c \
|
||||
pio.c pma.c rbt.c rex.c sio.c sll.c slmb.c stdio.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-dynm.c str-dynw.c str-end.c str-excl.c \
|
||||
str-fcpy.c str-fnmat.c str-incl.c str-len.c str-pac.c \
|
||||
str-pbrk.c str-put.c str-rev.c str-rot.c str-set.c str-spl.c \
|
||||
str-spn.c str-str.c str-subst.c str-tok.c str-trm.c str-word.c \
|
||||
task.c time.c tio.c tre.c tre-ast.c tre-compile.c \
|
||||
tre-match-backtrack.c tre-match-parallel.c tre-parse.c \
|
||||
tre-stack.c uri.c utf8.c xma.c $(am__append_1)
|
||||
libqsecmn_la_LDFLAGS = -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||
libqsecmn_la_LIBADD = $(SOCKET_LIBS)
|
||||
@ENABLE_CXX_TRUE@libqsecmnxx_la_SOURCES = \
|
||||
@ -475,7 +477,9 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbwc.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mux.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nwad-skad.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nwad.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nwif-cfg.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nwif.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nwio.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oht.Plo@am__quote@
|
||||
|
@ -74,6 +74,7 @@ struct glob_t
|
||||
void* cbctx;
|
||||
|
||||
qse_mmgr_t* mmgr;
|
||||
int flags;
|
||||
|
||||
qse_str_t path;
|
||||
qse_str_t tbuf; /* temporary buffer */
|
||||
@ -417,7 +418,11 @@ entry:
|
||||
qse_str_setlen (&g->path, tmp2);
|
||||
|
||||
x = qse_dir_read (dp, &ent);
|
||||
if (x <= -1) goto oops;
|
||||
if (x <= -1)
|
||||
{
|
||||
if (g->flags & QSE_GLOB_TOLERANT) break;
|
||||
else goto oops;
|
||||
}
|
||||
if (x == 0) break;
|
||||
|
||||
if (qse_str_cat (&g->path, ent.name) == (qse_size_t)-1) goto oops;
|
||||
@ -545,6 +550,7 @@ int qse_glob (const qse_char_t* pattern, qse_glob_cbimpl_t cbimpl, void* cbctx,
|
||||
g.cbimpl = cbimpl;
|
||||
g.cbctx = cbctx;
|
||||
g.mmgr = mmgr;
|
||||
g.flags = flags;
|
||||
|
||||
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
|
||||
g.fnmat_flags |= QSE_STRFNMAT_IGNORECASE;
|
||||
|
167
qse/lib/cmn/nwad-skad.c
Normal file
167
qse/lib/cmn/nwad-skad.c
Normal file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2012 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <qse/cmn/nwad.h>
|
||||
#include "mem.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h> /* sockaddr_in6 */
|
||||
# include <windows.h>
|
||||
#elif defined(__OS2__)
|
||||
# include <types.h>
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# pragma library("tcpip32.lib")
|
||||
#elif defined(__DOS__)
|
||||
/* TODO: consider watt-32 */
|
||||
#else
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
union sockaddr_t
|
||||
{
|
||||
#if defined(AF_INET) || defined(AF_INET6)
|
||||
#if defined(AF_INET)
|
||||
struct sockaddr_in in4;
|
||||
#endif
|
||||
#if defined(AF_INET6)
|
||||
struct sockaddr_in6 in6;
|
||||
#endif
|
||||
#else
|
||||
int dummy;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef union sockaddr_t sockaddr_t;
|
||||
|
||||
#if defined(AF_INET)
|
||||
# define FAMILY(x) (((struct sockaddr_in*)(x))->sin_family)
|
||||
#elif defined(AF_INET6)
|
||||
# define FAMILY(x) (((struct sockaddr_in6*)(x))->sin6_family)
|
||||
#else
|
||||
# define FAMILY(x) (-1)
|
||||
#endif
|
||||
|
||||
static QSE_INLINE int skad_to_nwad (const sockaddr_t* skad, qse_nwad_t* nwad)
|
||||
{
|
||||
int addrsize = -1;
|
||||
|
||||
switch (FAMILY(skad))
|
||||
{
|
||||
#if defined(AF_INET)
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in* in;
|
||||
in = (struct sockaddr_in*)skad;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
|
||||
QSE_MEMSET (nwad, 0, QSE_SIZEOF(*nwad));
|
||||
nwad->type = QSE_NWAD_IN4;
|
||||
nwad->u.in4.addr.value = in->sin_addr.s_addr;
|
||||
nwad->u.in4.port = in->sin_port;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AF_INET6)
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6* in;
|
||||
in = (struct sockaddr_in6*)skad;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
|
||||
QSE_MEMSET (nwad, 0, QSE_SIZEOF(*nwad));
|
||||
nwad->type = QSE_NWAD_IN6;
|
||||
QSE_MEMCPY (&nwad->u.in6.addr, &in->sin6_addr, QSE_SIZEOF(nwad->u.in6.addr));
|
||||
nwad->u.in6.scope = in->sin6_scope_id;
|
||||
nwad->u.in6.port = in->sin6_port;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return addrsize;
|
||||
}
|
||||
|
||||
static QSE_INLINE int nwad_to_skad (const qse_nwad_t* nwad, sockaddr_t* skad)
|
||||
{
|
||||
int addrsize = -1;
|
||||
|
||||
switch (nwad->type)
|
||||
{
|
||||
case QSE_NWAD_IN4:
|
||||
{
|
||||
#if defined(AF_INET)
|
||||
struct sockaddr_in* in;
|
||||
|
||||
in = (struct sockaddr_in*)skad;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
QSE_MEMSET (in, 0, addrsize);
|
||||
|
||||
in->sin_family = AF_INET;
|
||||
in->sin_addr.s_addr = nwad->u.in4.addr.value;
|
||||
in->sin_port = nwad->u.in4.port;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case QSE_NWAD_IN6:
|
||||
{
|
||||
#if defined(AF_INET6)
|
||||
struct sockaddr_in6* in;
|
||||
|
||||
in = (struct sockaddr_in6*)skad;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
QSE_MEMSET (in, 0, addrsize);
|
||||
|
||||
in->sin6_family = AF_INET6;
|
||||
QSE_MEMCPY (&in->sin6_addr, &nwad->u.in6.addr, QSE_SIZEOF(nwad->u.in6.addr));
|
||||
in->sin6_scope_id = nwad->u.in6.scope;
|
||||
in->sin6_port = nwad->u.in6.port;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return addrsize;
|
||||
}
|
||||
|
||||
int qse_skadtonwad (const qse_skad_t* skad, qse_nwad_t* nwad)
|
||||
{
|
||||
QSE_ASSERT (QSE_SIZEOF(*skad) >= QSE_SIZEOF(sockaddr_t));
|
||||
return skad_to_nwad ((const sockaddr_t*)skad, nwad);
|
||||
}
|
||||
|
||||
int qse_nwadtoskad (const qse_nwad_t* nwad, qse_skad_t* skad)
|
||||
{
|
||||
QSE_ASSERT (QSE_SIZEOF(*skad) >= QSE_SIZEOF(sockaddr_t));
|
||||
return nwad_to_skad (nwad, (sockaddr_t*)skad);
|
||||
}
|
||||
|
||||
int qse_skadfamily (const qse_skad_t* skad)
|
||||
{
|
||||
QSE_ASSERT (QSE_SIZEOF(*skad) >= QSE_SIZEOF(sockaddr_t));
|
||||
return FAMILY(skad);
|
||||
}
|
@ -440,7 +440,7 @@ qse_size_t qse_nwadtombs (
|
||||
if (xlen + 1 >= len) goto done;
|
||||
|
||||
tmp = qse_nwifindextombs (nwad->u.in6.scope, &buf[xlen], len - xlen);
|
||||
if (tmp <= 0)
|
||||
if (tmp <= -1)
|
||||
{
|
||||
xlen += qse_fmtuintmaxtombs (
|
||||
&buf[xlen], len - xlen,
|
||||
@ -547,7 +547,7 @@ qse_size_t qse_nwadtowcs (
|
||||
if (xlen + 1 >= len) goto done;
|
||||
|
||||
tmp = qse_nwifindextowcs (nwad->u.in6.scope, &buf[xlen], len - xlen);
|
||||
if (tmp <= 0)
|
||||
if (tmp <= -1)
|
||||
{
|
||||
xlen += qse_fmtuintmaxtowcs (
|
||||
&buf[xlen], len - xlen,
|
||||
|
390
qse/lib/cmn/nwif-cfg.c
Normal file
390
qse/lib/cmn/nwif-cfg.c
Normal file
@ -0,0 +1,390 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2012 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it uheadr the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <qse/cmn/nwif.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include "mem.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
# include <iphlpapi.h>
|
||||
#elif defined(__OS2__)
|
||||
# include <types.h>
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# include <tcpustd.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <nerrno.h>
|
||||
# pragma library("tcpip32.lib")
|
||||
#elif defined(__DOS__)
|
||||
/* TODO: */
|
||||
#else
|
||||
# include "syscall.h"
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# if defined(HAVE_SYS_IOCTL_H)
|
||||
# include <sys/ioctl.h>
|
||||
# endif
|
||||
# if defined(HAVE_NET_IF_H)
|
||||
# include <net/if.h>
|
||||
# endif
|
||||
# if defined(HAVE_SYS_SOCKIO_H)
|
||||
# include <sys/sockio.h>
|
||||
# endif
|
||||
# if defined(HAVE_IFADDRS_H)
|
||||
# include <ifaddrs.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
||||
#if defined(HAVE_NET_IF_DL_H)
|
||||
# include <net/if_dl.h>
|
||||
#endif
|
||||
#ifndef SIOCGLIFHWADDR
|
||||
#define SIOCGLIFHWADDR _IOWR('i', 192, struct lifreq)
|
||||
#endif
|
||||
|
||||
struct lifreq lif;
|
||||
|
||||
memset(&lif, 0, sizeof(lif));
|
||||
strlcpy(lif.lifr_name, ifname, sizeof(lif.lifr_name));
|
||||
|
||||
if (ioctl(sock, SIOCGLIFHWADDR, &lif) != -1) {
|
||||
struct sockaddr_dl *sp;
|
||||
sp = (struct sockaddr_dl *)&lif.lifr_addr;
|
||||
memcpy(buf, &sp->sdl_data[0], sp->sdl_alen);
|
||||
return sp->sdl_alen;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(SIOCGLIFCONF)
|
||||
static int get_nwifs (qse_mmgr_t* mmgr, int s, int f, qse_xptl_t* nwifs)
|
||||
{
|
||||
struct lifnum ifn;
|
||||
struct lifconf ifc;
|
||||
qse_xptl_t b;
|
||||
qse_size_t ifcount;
|
||||
|
||||
ifcount = 0;
|
||||
|
||||
b.ptr = QSE_NULL;
|
||||
b.len = 0;
|
||||
|
||||
do
|
||||
{
|
||||
ifn.lifn_family = f;
|
||||
ifn.lifn_flags = 0;
|
||||
if (ioctl (s, SIOCGLIFNUM, &ifn) <= -1) goto oops;
|
||||
|
||||
if (b.ptr)
|
||||
{
|
||||
/* b.ptr won't be QSE_NULL when retrying */
|
||||
if (ifn.lifn_count <= ifcount) break;
|
||||
}
|
||||
|
||||
/* +1 for extra space to leave empty
|
||||
* if SIOCGLIFCONF returns the same number of
|
||||
* intefaces as SIOCLIFNUM */
|
||||
b.len = (ifn.lifn_count + 1) * QSE_SIZEOF(struct lifreq);
|
||||
b.ptr = QSE_MMGR_ALLOC (mmgr, b.len);
|
||||
if (b.ptr == QSE_NULL) goto oops;
|
||||
|
||||
ifc.lifc_family = f;
|
||||
ifc.lifc_flags = 0;
|
||||
ifc.lifc_len = b.len;
|
||||
ifc.lifc_buf = b.ptr;
|
||||
|
||||
if (ioctl (s, SIOCGLIFCONF, &ifc) <= -1) goto oops;
|
||||
|
||||
ifcount = ifc.lifc_len / QSE_SIZEOF(struct lifreq);
|
||||
}
|
||||
while (ifcount > ifn.lifn_count);
|
||||
/* the while condition above is for checking if
|
||||
* the buffer got full. when it's full, there is a chance
|
||||
* that there are more interfaces. */
|
||||
|
||||
nwifs->ptr = b.ptr;
|
||||
nwifs->len = ifcount;
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
if (b.ptr) QSE_MMGR_FREE (mmgr, b.ptr);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void free_nwifcfg (qse_mmgr_t* mmgr, qse_nwifcfg_node_t* cfg)
|
||||
{
|
||||
qse_nwifcfg_node_t* cur;
|
||||
|
||||
while (cfg)
|
||||
{
|
||||
cur = cfg;
|
||||
cfg = cur->next;
|
||||
if (cur->name) QSE_MMGR_FREE (mmgr, cur->name);
|
||||
QSE_MMGR_FREE (mmgr, cur);
|
||||
}
|
||||
}
|
||||
|
||||
int qse_getnwifcfg (qse_nwifcfg_t* cfg)
|
||||
{
|
||||
#if defined(SIOCGLIFCONF)
|
||||
struct lifreq* ifr, ifrbuf;
|
||||
qse_size_t i;
|
||||
int s, f;
|
||||
int s4 = -1;
|
||||
int s6 = -1;
|
||||
qse_xptl_t nwifs = { QSE_NULL, 0 };
|
||||
qse_nwifcfg_node_t* head = QSE_NULL;
|
||||
qse_nwifcfg_node_t* tmp;
|
||||
|
||||
QSE_ASSERT (cfg->mmgr != QSE_NULL);
|
||||
|
||||
#if defined(AF_INET) || defined(AF_INET6)
|
||||
#if defined(AF_INET)
|
||||
s4 = socket (AF_INET, SOCK_DGRAM, 0);
|
||||
if (s4 <= -1) goto oops;
|
||||
#endif
|
||||
|
||||
#if defined(AF_INET6)
|
||||
s6 = socket (AF_INET6, SOCK_DGRAM, 0);
|
||||
if (s6 <= -1) goto oops;
|
||||
#endif
|
||||
#else
|
||||
/* no implementation */
|
||||
goto oops;
|
||||
#endif
|
||||
|
||||
if (get_nwifs (cfg->mmgr, s4, AF_UNSPEC, &nwifs) <= -1) goto oops;
|
||||
|
||||
ifr = nwifs.ptr;
|
||||
for (i = 0; i < nwifs.len; i++, ifr++)
|
||||
{
|
||||
f = ifr->lifr_addr.ss_family;
|
||||
|
||||
if (f == AF_INET) s = s4;
|
||||
else if (f == AF_INET6) s = s6;
|
||||
else continue;
|
||||
|
||||
tmp = QSE_MMGR_ALLOC (cfg->mmgr, QSE_SIZEOF(*tmp));
|
||||
if (tmp == QSE_NULL) goto oops;
|
||||
|
||||
QSE_MEMSET (tmp, 0, QSE_SIZEOF(*tmp));
|
||||
tmp->next = head;
|
||||
head = tmp;
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
head->name = qse_mbsdup (ifr->lifr_name, cfg->mmgr);
|
||||
#else
|
||||
head->name = qse_mbstowcsdup (ifr->lifr_name, QSE_NULL, cfg->mmgr);
|
||||
#endif
|
||||
if (head->name == QSE_NULL) goto oops;
|
||||
|
||||
qse_skadtonwad (&ifr->lifr_addr, &head->addr);
|
||||
|
||||
qse_mbsxcpy (ifrbuf.lifr_name, QSE_SIZEOF(ifrbuf.lifr_name), ifr->lifr_name);
|
||||
if (ioctl (s, SIOCGLIFFLAGS, &ifrbuf) <= -1) goto oops;
|
||||
if (ifrbuf.lifr_flags & IFF_UP) head->flags |= QSE_NWIFCFG_UP;
|
||||
if (ifrbuf.lifr_flags & IFF_BROADCAST)
|
||||
{
|
||||
if (ioctl (s, SIOCGLIFBRDADDR, &ifrbuf) <= -1) goto oops;
|
||||
qse_skadtonwad (&ifrbuf.lifr_addr, &head->bcast);
|
||||
head->flags |= QSE_NWIFCFG_BCAST;
|
||||
}
|
||||
if (ifrbuf.lifr_flags & IFF_POINTOPOINT)
|
||||
{
|
||||
if (ioctl (s, SIOCGLIFDSTADDR, &ifrbuf) <= -1) goto oops;
|
||||
qse_skadtonwad (&ifrbuf.lifr_addr, &head->ptop);
|
||||
head->flags |= QSE_NWIFCFG_PTOP;
|
||||
}
|
||||
|
||||
if (ioctl (s, SIOCGLIFINDEX, &ifrbuf) <= -1) goto oops;
|
||||
head->index = ifrbuf.lifr_index;
|
||||
|
||||
if (ioctl (s, SIOCGLIFNETMASK, &ifrbuf) <= -1) goto oops;
|
||||
qse_skadtonwad (&ifrbuf.lifr_addr, &head->mask);
|
||||
}
|
||||
|
||||
QSE_MMGR_FREE (cfg->mmgr, nwifs.ptr);
|
||||
close (s6);
|
||||
close (s4);
|
||||
|
||||
cfg->list = head;
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
if (head) free_nwifcfg (cfg->mmgr, head);
|
||||
if (nwifs.ptr) QSE_MMGR_FREE (cfg->mmgr, nwifs.ptr);
|
||||
if (s6 >= 0) close (s6);
|
||||
if (s4 >= 0) close (s4);
|
||||
return -1;
|
||||
#else
|
||||
|
||||
/* TODO */
|
||||
return QSE_NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void qse_freenwifcfg (qse_nwifcfg_t* cfg)
|
||||
{
|
||||
free_nwifcfg (cfg->mmgr, cfg->list);
|
||||
cfg->list = QSE_NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static int get_nwifcfg (int s, qse_nwifcfg_t* cfg)
|
||||
{
|
||||
#if defined(SIOCGLIFADDR)
|
||||
struct lifreq ifrbuf;
|
||||
qse_size_t ml, wl;
|
||||
|
||||
QSE_MEMSET (&ifrbuf, 0, QSE_SIZEOF(ifrbuf));
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
qse_mbsxcpy (ifrbuf.lifr_name, QSE_SIZEOF(ifrbuf.lifr_name), cfg->name);
|
||||
#else
|
||||
ml = QSE_COUNTOF(ifrbuf.lifr_name);
|
||||
if (qse_wcstombs (cfg->name, &wl, ifrbuf.lifr_name, &ml) <= -1) return -1;
|
||||
#endif
|
||||
|
||||
if (ioctl (s, SIOCGLIFINDEX, &ifrbuf) <= -1) return -1;
|
||||
cfg->index = ifrbuf.lifr_index;
|
||||
|
||||
if (ioctl (s, SIOCGLIFADDR, &ifrbuf) <= -1) return -1;
|
||||
qse_skadtonwad (&ifrbuf.lifr_addr, &cfg->addr);
|
||||
|
||||
if (ioctl (s, SIOCGLIFNETMASK, &ifrbuf) <= -1) return -1;
|
||||
qse_skadtonwad (&ifrbuf.lifr_addr, &cfg->mask);
|
||||
|
||||
if (ioctl (s, SIOCGLIFMTU, &ifrbuf) <= -1) return -1;
|
||||
cfg->mtu = ifrbuf.lifr_mtu;
|
||||
|
||||
if (ioctl (s, SIOCGLIFFLAGS, &ifrbuf) <= -1) return -1;
|
||||
if (ifrbuf.lifr_flags & IFF_UP) cfg->flags |= QSE_NWIFCFG_UP;
|
||||
if (ifrbuf.lifr_flags & IFF_RUNNING) cfg->flags |= QSE_NWIFCFG_RUNNING;
|
||||
if (ifrbuf.lifr_flags & IFF_BROADCAST)
|
||||
{
|
||||
if (ioctl (s, SIOCGLIFBRDADDR, &ifrbuf) <= -1) return -1;
|
||||
qse_skadtonwad (&ifrbuf.lifr_broadaddr, &cfg->bcast);
|
||||
cfg->flags |= QSE_NWIFCFG_BCAST;
|
||||
}
|
||||
if (ifrbuf.lifr_flags & IFF_POINTOPOINT)
|
||||
{
|
||||
if (ioctl (s, SIOCGLIFDSTADDR, &ifrbuf) <= -1) return -1;
|
||||
qse_skadtonwad (&ifrbuf.lifr_dstaddr, &cfg->ptop);
|
||||
cfg->flags |= QSE_NWIFCFG_PTOP;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
#elif defined(SIOCGIFADDR)
|
||||
struct ifreq ifrbuf;
|
||||
qse_size_t ml, wl;
|
||||
|
||||
QSE_MEMSET (&ifrbuf, 0, QSE_SIZEOF(ifrbuf));
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
qse_mbsxcpy (ifrbuf.ifr_name, QSE_SIZEOF(ifrbuf.ifr_name), cfg->name);
|
||||
#else
|
||||
ml = QSE_COUNTOF(ifrbuf.ifr_name);
|
||||
if (qse_wcstombs (cfg->name, &wl, ifrbuf.ifr_name, &ml) <= -1) return -1;
|
||||
#endif
|
||||
|
||||
#if defined(SIOCGIFINDEX)
|
||||
if (ioctl (s, SIOCGIFINDEX, &ifrbuf) <= -1) return -1;
|
||||
#if defined(HAVE_STRUCT_IFREQ_IFR_IFINDEX)
|
||||
cfg->index = ifrbuf.ifr_ifindex;
|
||||
#else
|
||||
cfg->index = ifrbuf.ifr_index;
|
||||
#endif
|
||||
#else
|
||||
cfg->index = 0;
|
||||
#endif
|
||||
|
||||
if (ioctl (s, SIOCGIFADDR, &ifrbuf) <= -1) return -1;
|
||||
qse_skadtonwad (&ifrbuf.ifr_addr, &cfg->addr);
|
||||
|
||||
if (ioctl (s, SIOCGIFNETMASK, &ifrbuf) <= -1) return -1;
|
||||
qse_skadtonwad (&ifrbuf.ifr_addr, &cfg->mask);
|
||||
|
||||
if (ioctl (s, SIOCGIFMTU, &ifrbuf) <= -1) return -1;
|
||||
#if defined(HAVE_STRUCT_IFREQ_IFR_MTU)
|
||||
cfg->mtu = ifrbuf.ifr_mtu;
|
||||
#else
|
||||
/* well, this is a bit dirty. but since all these are unions,
|
||||
* the name must not really matter. some OSes just omitts defining
|
||||
* the MTU field */
|
||||
cfg->mtu = ifrbuf.ifr_metric;
|
||||
#endif
|
||||
|
||||
if (ioctl (s, SIOCGIFFLAGS, &ifrbuf) <= -1) return -1;
|
||||
if (ifrbuf.ifr_flags & IFF_UP) cfg->flags |= QSE_NWIFCFG_UP;
|
||||
if (ifrbuf.ifr_flags & IFF_RUNNING) cfg->flags |= QSE_NWIFCFG_RUNNING;
|
||||
if (ifrbuf.ifr_flags & IFF_BROADCAST)
|
||||
{
|
||||
if (ioctl (s, SIOCGIFBRDADDR, &ifrbuf) <= -1) return -1;
|
||||
qse_skadtonwad (&ifrbuf.ifr_broadaddr, &cfg->bcast);
|
||||
cfg->flags |= QSE_NWIFCFG_BCAST;
|
||||
}
|
||||
else QSE_MEMSET (&cfg->bcast, 0, QSE_SIZEOF(cfg->bcast));
|
||||
if (ifrbuf.ifr_flags & IFF_POINTOPOINT)
|
||||
{
|
||||
if (ioctl (s, SIOCGIFDSTADDR, &ifrbuf) <= -1) return -1;
|
||||
qse_skadtonwad (&ifrbuf.ifr_dstaddr, &cfg->ptop);
|
||||
cfg->flags |= QSE_NWIFCFG_PTOP;
|
||||
}
|
||||
else QSE_MEMSET (&cfg->ptop, 0, QSE_SIZEOF(cfg->ptop));
|
||||
|
||||
return 0;
|
||||
#else
|
||||
|
||||
/* TODO */
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int qse_getnwifcfg (qse_nwifcfg_t* cfg)
|
||||
{
|
||||
int s = -1;
|
||||
|
||||
if (cfg->type == QSE_NWIFCFG_IN4)
|
||||
{
|
||||
#if defined(AF_INET)
|
||||
s = socket (AF_INET, SOCK_DGRAM, 0);
|
||||
#endif
|
||||
}
|
||||
else if (cfg->type == QSE_NWIFCFG_IN6)
|
||||
{
|
||||
#if defined(AF_INET6)
|
||||
s = socket (AF_INET6, SOCK_DGRAM, 0);
|
||||
#endif
|
||||
}
|
||||
if (s <= -1) return -1;
|
||||
|
||||
return get_nwifcfg (s, cfg);
|
||||
}
|
@ -38,11 +38,65 @@
|
||||
# if defined(HAVE_NET_IF_H)
|
||||
# include <net/if.h>
|
||||
# endif
|
||||
# if defined(HAVE_SYS_SOCKIO_H)
|
||||
# include <sys/sockio.h>
|
||||
# endif
|
||||
# if !defined(IF_NAMESIZE)
|
||||
# define IF_NAMESIZE 63
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(SIOCGIFINDEX) && !defined(SIOCGIFNAME) && \
|
||||
!defined(HAVE_IF_NAMETOINDEX) && !defined(HAVE_IF_INDEXTONAME) && \
|
||||
defined(SIOCGIFCONF) && (defined(SIOCGIFANUM) || defined(SIOCGIFNUM))
|
||||
static int get_sco_ifconf (struct ifconf* ifc)
|
||||
{
|
||||
/* SCO doesn't have have any IFINDEX thing.
|
||||
* i emultate it using IFCONF */
|
||||
int h, num;
|
||||
struct ifreq* ifr;
|
||||
|
||||
h = socket (AF_INET, SOCK_DGRAM, 0);
|
||||
if (h <= -1) return -1;
|
||||
|
||||
ifc->ifc_len = 0;
|
||||
ifc->ifc_buf = QSE_NULL;
|
||||
|
||||
#if defined(SIOCGIFANUM)
|
||||
if (ioctl (h, SIOCGIFANUM, &num) <= -1) goto oops;
|
||||
#else
|
||||
if (ioctl (h, SIOCGIFNUM, &num) <= -1) goto oops;
|
||||
#endif
|
||||
|
||||
/* sco needs reboot when you add an network interface.
|
||||
* it should be safe not to consider the case when the interface
|
||||
* is added after SIOCGIFANUM above.
|
||||
* another thing to note is that SIOCGIFCONF ends with segfault
|
||||
* if the buffer is not large enough unlike some other OSes
|
||||
* like opensolaris which truncates the configuration. */
|
||||
|
||||
ifc->ifc_len = num * QSE_SIZEOF(*ifr);
|
||||
ifc->ifc_buf = QSE_MMGR_ALLOC (QSE_MMGR_GETDFL(), ifc->ifc_len);
|
||||
if (ifc->ifc_buf == QSE_NULL) goto oops;
|
||||
|
||||
if (ioctl (h, SIOCGIFCONF, ifc) <= -1) goto oops;
|
||||
QSE_CLOSE (h); h = -1;
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
if (ifc->ifc_buf) QSE_MMGR_FREE (QSE_MMGR_GETDFL(), ifc->ifc_buf);
|
||||
if (h >= 0) QSE_CLOSE (h);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static QSE_INLINE void free_sco_ifconf (struct ifconf* ifc)
|
||||
{
|
||||
QSE_MMGR_FREE (QSE_MMGR_GETDFL(), ifc->ifc_buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
unsigned int qse_nwifmbstoindex (const qse_mchar_t* ptr)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
@ -70,7 +124,11 @@ unsigned int qse_nwifmbstoindex (const qse_mchar_t* ptr)
|
||||
x = ioctl (h, SIOCGIFINDEX, &ifr);
|
||||
QSE_CLOSE (h);
|
||||
|
||||
#if defined(HAVE_STRUCT_IFREQ_IFR_IFINDEX)
|
||||
return (x <= -1)? 0u: ifr.ifr_ifindex;
|
||||
#else
|
||||
return (x <= -1)? 0u: ifr.ifr_index;
|
||||
#endif
|
||||
|
||||
#elif defined(HAVE_IF_NAMETOINDEX)
|
||||
qse_mchar_t tmp[IF_NAMESIZE + 1];
|
||||
@ -80,6 +138,26 @@ unsigned int qse_nwifmbstoindex (const qse_mchar_t* ptr)
|
||||
if (ptr[len] != QSE_MT('\0')) return 0u; /* name too long */
|
||||
return if_nametoindex (tmp);
|
||||
|
||||
#elif defined(SIOCGIFCONF) && (defined(SIOCGIFANUM) || defined(SIOCGIFNUM))
|
||||
|
||||
struct ifconf ifc;
|
||||
int num, i;
|
||||
|
||||
if (get_sco_ifconf (&ifc) <= -1) return 0u;
|
||||
|
||||
num = ifc.ifc_len / QSE_SIZEOF(struct ifreq);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
if (qse_mbscmp (ptr, ifc.ifc_req[i].ifr_name) == 0)
|
||||
{
|
||||
free_sco_ifconf (&ifc);
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
free_sco_ifconf (&ifc);
|
||||
return 0u;
|
||||
|
||||
#else
|
||||
return 0u;
|
||||
#endif
|
||||
@ -110,13 +188,37 @@ unsigned int qse_nwifmbsntoindex (const qse_mchar_t* ptr, qse_size_t len)
|
||||
x = ioctl (h, SIOCGIFINDEX, &ifr);
|
||||
QSE_CLOSE (h);
|
||||
|
||||
#if defined(HAVE_STRUCT_IFREQ_IFR_IFINDEX)
|
||||
return (x <= -1)? 0u: ifr.ifr_ifindex;
|
||||
#else
|
||||
return (x <= -1)? 0u: ifr.ifr_index;
|
||||
#endif
|
||||
|
||||
#elif defined(HAVE_IF_NAMETOINDEX)
|
||||
qse_mchar_t tmp[IF_NAMESIZE + 1];
|
||||
if (qse_mbsxncpy (tmp, QSE_COUNTOF(tmp), ptr, len) < len) return 0u; /* name too long */
|
||||
return if_nametoindex (tmp);
|
||||
|
||||
#elif defined(SIOCGIFCONF) && (defined(SIOCGIFANUM) || defined(SIOCGIFNUM))
|
||||
|
||||
struct ifconf ifc;
|
||||
int num, i;
|
||||
|
||||
if (get_sco_ifconf (&ifc) <= -1) return 0u;
|
||||
|
||||
num = ifc.ifc_len / QSE_SIZEOF(struct ifreq);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
if (qse_mbsxcmp (ptr, len, ifc.ifc_req[i].ifr_name) == 0)
|
||||
{
|
||||
free_sco_ifconf (&ifc);
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
free_sco_ifconf (&ifc);
|
||||
return 0u;
|
||||
|
||||
#else
|
||||
return 0u;
|
||||
#endif
|
||||
@ -143,22 +245,51 @@ unsigned int qse_nwifwcstoindex (const qse_wchar_t* ptr)
|
||||
if (h <= -1) return 0u;
|
||||
|
||||
ml = QSE_COUNTOF(ifr.ifr_name);
|
||||
if (qse_wcstombs (ptr, &wl, ifr.ifr_name, &ml) <= -1) return 0;
|
||||
if (qse_wcstombs (ptr, &wl, ifr.ifr_name, &ml) <= -1) return 0u;
|
||||
|
||||
x = ioctl (h, SIOCGIFINDEX, &ifr);
|
||||
QSE_CLOSE (h);
|
||||
|
||||
#if defined(HAVE_STRUCT_IFREQ_IFR_IFINDEX)
|
||||
return (x <= -1)? 0u: ifr.ifr_ifindex;
|
||||
#else
|
||||
return (x <= -1)? 0u: ifr.ifr_index;
|
||||
#endif
|
||||
|
||||
#elif defined(HAVE_IF_NAMETOINDEX)
|
||||
qse_mchar_t tmp[IF_NAMESIZE + 1];
|
||||
qse_size_t wl, ml;
|
||||
|
||||
ml = QSE_COUNTOF(tmp);
|
||||
if (qse_wcstombs (ptr, &wl, tmp, &ml) <= -1) return 0;
|
||||
if (qse_wcstombs (ptr, &wl, tmp, &ml) <= -1) return 0u;
|
||||
|
||||
return if_nametoindex (tmp);
|
||||
|
||||
#elif defined(SIOCGIFCONF) && (defined(SIOCGIFANUM) || defined(SIOCGIFNUM))
|
||||
|
||||
struct ifconf ifc;
|
||||
int num, i;
|
||||
qse_mchar_t tmp[IF_NAMESIZE + 1];
|
||||
qse_size_t wl, ml;
|
||||
|
||||
ml = QSE_COUNTOF(tmp);
|
||||
if (qse_wcstombs (ptr, &wl, tmp, &ml) <= -1) return 0u;
|
||||
|
||||
if (get_sco_ifconf (&ifc) <= -1) return 0u;
|
||||
|
||||
num = ifc.ifc_len / QSE_SIZEOF(struct ifreq);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
if (qse_mbscmp (tmp, ifc.ifc_req[i].ifr_name) == 0)
|
||||
{
|
||||
free_sco_ifconf (&ifc);
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
free_sco_ifconf (&ifc);
|
||||
return 0u;
|
||||
|
||||
#else
|
||||
return 0u;
|
||||
#endif
|
||||
@ -191,33 +322,63 @@ unsigned int qse_nwifwcsntoindex (const qse_wchar_t* ptr, qse_size_t len)
|
||||
x = ioctl (h, SIOCGIFINDEX, &ifr);
|
||||
QSE_CLOSE (h);
|
||||
|
||||
#if defined(HAVE_STRUCT_IFREQ_IFR_IFINDEX)
|
||||
return (x <= -1)? 0u: ifr.ifr_ifindex;
|
||||
#else
|
||||
return (x <= -1)? 0u: ifr.ifr_index;
|
||||
#endif
|
||||
|
||||
#elif defined(HAVE_IF_NAMETOINDEX)
|
||||
qse_mchar_t tmp[IF_NAMESIZE + 1];
|
||||
qse_size_t wl, ml;
|
||||
|
||||
wl = len; ml = QSE_COUNTOF(tmp) - 1;
|
||||
if (qse_wcsntombsn (ptr, &wl, tmp, &ml) <= -1) return 0;
|
||||
if (qse_wcsntombsn (ptr, &wl, tmp, &ml) <= -1) return 0u;
|
||||
tmp[ml] = QSE_MT('\0');
|
||||
return if_nametoindex (tmp);
|
||||
|
||||
#elif defined(SIOCGIFCONF) && (defined(SIOCGIFANUM) || defined(SIOCGIFNUM))
|
||||
struct ifconf ifc;
|
||||
int num, i;
|
||||
qse_mchar_t tmp[IF_NAMESIZE + 1];
|
||||
qse_size_t wl, ml;
|
||||
|
||||
wl = len; ml = QSE_COUNTOF(tmp) - 1;
|
||||
if (qse_wcsntombsn (ptr, &wl, tmp, &ml) <= -1) return 0u;
|
||||
tmp[ml] = QSE_MT('\0');
|
||||
|
||||
if (get_sco_ifconf (&ifc) <= -1) return -1;
|
||||
|
||||
num = ifc.ifc_len / QSE_SIZEOF(struct ifreq);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
if (qse_mbscmp (tmp, ifc.ifc_req[i].ifr_name) == 0)
|
||||
{
|
||||
free_sco_ifconf (&ifc);
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
free_sco_ifconf (&ifc);
|
||||
return 0u;
|
||||
#else
|
||||
return 0u;
|
||||
#endif
|
||||
}
|
||||
|
||||
qse_size_t qse_nwifindextombs (unsigned int index, qse_mchar_t* buf, qse_size_t len)
|
||||
/* ---------------------------------------------------------- */
|
||||
|
||||
int qse_nwifindextombs (unsigned int index, qse_mchar_t* buf, qse_size_t len)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
/* TODO: */
|
||||
return 0u;
|
||||
return -1;
|
||||
#elif defined(__OS2__)
|
||||
/* TODO: */
|
||||
return 0u;
|
||||
return -1;
|
||||
#elif defined(__DOS__)
|
||||
/* TODO: */
|
||||
return 0u;
|
||||
return -1;
|
||||
|
||||
#elif defined(SIOCGIFNAME)
|
||||
|
||||
@ -225,36 +386,61 @@ qse_size_t qse_nwifindextombs (unsigned int index, qse_mchar_t* buf, qse_size_t
|
||||
struct ifreq ifr;
|
||||
|
||||
h = socket (AF_INET, SOCK_DGRAM, 0);
|
||||
if (h <= -1) return 0u;
|
||||
if (h <= -1) return -1;
|
||||
|
||||
QSE_MEMSET (&ifr, 0, QSE_SIZEOF(ifr));
|
||||
#if defined(HAVE_STRUCT_IFREQ_IFR_IFINDEX)
|
||||
ifr.ifr_ifindex = index;
|
||||
#else
|
||||
ifr.ifr_index = index;
|
||||
#endif
|
||||
|
||||
x = ioctl (h, SIOCGIFNAME, &ifr);
|
||||
QSE_CLOSE (h);
|
||||
|
||||
return (x <= -1)? 0: qse_mbsxcpy (buf, len, ifr.ifr_name);
|
||||
return (x <= -1)? -1: qse_mbsxcpy (buf, len, ifr.ifr_name);
|
||||
|
||||
#elif defined(HAVE_IF_INDEXTONAME)
|
||||
qse_mchar_t tmp[IF_NAMESIZE + 1];
|
||||
if (if_indextoname (index, tmp) == QSE_NULL) return 0;
|
||||
if (if_indextoname (index, tmp) == QSE_NULL) return -1;
|
||||
return qse_mbsxcpy (buf, len, tmp);
|
||||
|
||||
#elif defined(SIOCGIFCONF) && (defined(SIOCGIFANUM) || defined(SIOCGIFNUM))
|
||||
|
||||
struct ifconf ifc;
|
||||
qse_size_t ml;
|
||||
int num;
|
||||
|
||||
if (index <= 0) return -1;
|
||||
if (get_sco_ifconf (&ifc) <= -1) return -1;
|
||||
|
||||
num = ifc.ifc_len / QSE_SIZEOF(struct ifreq);
|
||||
if (index > num)
|
||||
{
|
||||
free_sco_ifconf (&ifc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ml = qse_mbsxcpy (buf, len, ifc.ifc_req[index - 1].ifr_name);
|
||||
free_sco_ifconf (&ifc);
|
||||
return ml;
|
||||
|
||||
#else
|
||||
return 0;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
qse_size_t qse_nwifindextowcs (unsigned int index, qse_wchar_t* buf, qse_size_t len)
|
||||
int qse_nwifindextowcs (unsigned int index, qse_wchar_t* buf, qse_size_t len)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
/* TODO: */
|
||||
return 0u;
|
||||
return -1;
|
||||
#elif defined(__OS2__)
|
||||
/* TODO: */
|
||||
return 0u;
|
||||
return -1;
|
||||
#elif defined(__DOS__)
|
||||
/* TODO: */
|
||||
return 0u;
|
||||
return -1;
|
||||
|
||||
#elif defined(SIOCGIFNAME)
|
||||
|
||||
@ -263,20 +449,24 @@ qse_size_t qse_nwifindextowcs (unsigned int index, qse_wchar_t* buf, qse_size_t
|
||||
qse_size_t wl, ml;
|
||||
|
||||
h = socket (AF_INET, SOCK_DGRAM, 0);
|
||||
if (h <= -1) return 0u;
|
||||
if (h <= -1) return -1;
|
||||
|
||||
QSE_MEMSET (&ifr, 0, QSE_SIZEOF(ifr));
|
||||
#if defined(HAVE_STRUCT_IFREQ_IFR_IFINDEX)
|
||||
ifr.ifr_ifindex = index;
|
||||
#else
|
||||
ifr.ifr_index = index;
|
||||
#endif
|
||||
|
||||
x = ioctl (h, SIOCGIFNAME, &ifr);
|
||||
QSE_CLOSE (h);
|
||||
|
||||
if (x <= -1) return 0;
|
||||
if (x <= -1) return -1;
|
||||
|
||||
wl = len;
|
||||
x = qse_mbstowcs (ifr.ifr_name, &ml, buf, &wl);
|
||||
if (x == -2 && wl > 1) buf[wl - 1] = QSE_WT('\0');
|
||||
else if (x != 0) return 0;
|
||||
else if (x != 0) return -1;
|
||||
return wl;
|
||||
|
||||
#elif defined(HAVE_IF_INDEXTONAME)
|
||||
@ -284,13 +474,38 @@ qse_size_t qse_nwifindextowcs (unsigned int index, qse_wchar_t* buf, qse_size_t
|
||||
qse_size_t ml, wl;
|
||||
int x;
|
||||
|
||||
if (if_indextoname (index, tmp) == QSE_NULL) return 0;
|
||||
if (if_indextoname (index, tmp) == QSE_NULL) return -1;
|
||||
wl = len;
|
||||
x = qse_mbstowcs (tmp, &ml, buf, &wl);
|
||||
if (x == -2 && wl > 1) buf[wl - 1] = QSE_WT('\0');
|
||||
else if (x != 0) return 0;
|
||||
else if (x != 0) return -1;
|
||||
return wl;
|
||||
|
||||
#elif defined(SIOCGIFCONF) && (defined(SIOCGIFANUM) || defined(SIOCGIFNUM))
|
||||
|
||||
struct ifconf ifc;
|
||||
qse_size_t wl, ml;
|
||||
int num, x;
|
||||
|
||||
if (index <= 0) return -1;
|
||||
if (get_sco_ifconf (&ifc) <= -1) return -1;
|
||||
|
||||
num = ifc.ifc_len / QSE_SIZEOF(struct ifreq);
|
||||
if (index > num)
|
||||
{
|
||||
free_sco_ifconf (&ifc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
wl = len;
|
||||
x = qse_mbstowcs (ifc.ifc_req[index - 1].ifr_name, &ml, buf, &wl);
|
||||
free_sco_ifconf (&ifc);
|
||||
|
||||
if (x == -2 && wl > 1) buf[wl - 1] = QSE_WT('\0');
|
||||
else if (x != 0) return -1;
|
||||
|
||||
return wl;
|
||||
#else
|
||||
return 0;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
@ -55,63 +55,8 @@ static qse_ssize_t socket_output (
|
||||
static qse_ssize_t socket_input (
|
||||
qse_tio_t* tio, qse_tio_cmd_t cmd, void* buf, qse_size_t size);
|
||||
|
||||
#if defined(AF_INET)
|
||||
union sockaddr_t
|
||||
{
|
||||
struct sockaddr_in in4;
|
||||
#if defined(AF_INET6) && !defined(__OS2__)
|
||||
struct sockaddr_in6 in6;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
#define TMOUT_ENABLED(tmout) (tmout.sec >= 0 && tmout.nsec >= 0)
|
||||
|
||||
static int nwad_to_sockaddr (const qse_nwad_t* nwad, int* family, void* addr)
|
||||
{
|
||||
int addrsize = -1;
|
||||
|
||||
switch (nwad->type)
|
||||
{
|
||||
case QSE_NWAD_IN4:
|
||||
{
|
||||
#if defined(AF_INET)
|
||||
struct sockaddr_in* in;
|
||||
|
||||
in = (struct sockaddr_in*)addr;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
QSE_MEMSET (in, 0, addrsize);
|
||||
|
||||
*family = AF_INET;
|
||||
in->sin_family = AF_INET;
|
||||
in->sin_addr.s_addr = nwad->u.in4.addr.value;
|
||||
in->sin_port = nwad->u.in4.port;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case QSE_NWAD_IN6:
|
||||
{
|
||||
#if defined(AF_INET6) && !defined(__OS2__)
|
||||
struct sockaddr_in6* in;
|
||||
|
||||
in = (struct sockaddr_in6*)addr;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
QSE_MEMSET (in, 0, addrsize);
|
||||
|
||||
*family = AF_INET6;
|
||||
in->sin6_family = AF_INET6;
|
||||
memcpy (&in->sin6_addr, &nwad->u.in6.addr, QSE_SIZEOF(nwad->u.in6.addr));
|
||||
in->sin6_scope_id = nwad->u.in6.scope;
|
||||
in->sin6_port = nwad->u.in6.port;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return addrsize;
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
static qse_nwio_errnum_t syserr_to_errnum (DWORD e)
|
||||
{
|
||||
@ -361,16 +306,13 @@ int qse_nwio_init (
|
||||
qse_nwio_t* nwio, qse_mmgr_t* mmgr, const qse_nwad_t* nwad,
|
||||
int flags, const qse_nwio_tmout_t* tmout)
|
||||
{
|
||||
#if defined(AF_INET)
|
||||
union sockaddr_t addr;
|
||||
#endif
|
||||
qse_skad_t addr;
|
||||
#if defined(HAVE_SOCKLEN_T)
|
||||
socklen_t addrlen;
|
||||
#else
|
||||
int addrlen;
|
||||
#endif
|
||||
int family, type;
|
||||
int tmp;
|
||||
int family, type, tmp;
|
||||
|
||||
QSE_MEMSET (nwio, 0, QSE_SIZEOF(*nwio));
|
||||
nwio->mmgr = mmgr;
|
||||
@ -385,8 +327,7 @@ int qse_nwio_init (
|
||||
nwio->tmout.a.sec = -1;
|
||||
}
|
||||
|
||||
#if defined(AF_INET)
|
||||
tmp = nwad_to_sockaddr (nwad, &family, &addr);
|
||||
tmp = qse_nwadtoskad (nwad, &addr);
|
||||
if (tmp <= -1)
|
||||
{
|
||||
nwio->errnum = QSE_NWIO_EINVAL;
|
||||
@ -394,6 +335,8 @@ int qse_nwio_init (
|
||||
}
|
||||
addrlen = tmp;
|
||||
|
||||
|
||||
#if defined(SOCK_STREAM) && defined(SOCK_DGRAM)
|
||||
if (flags & QSE_NWIO_TCP) type = SOCK_STREAM;
|
||||
else if (flags & QSE_NWIO_UDP) type = SOCK_DGRAM;
|
||||
else
|
||||
@ -403,6 +346,8 @@ int qse_nwio_init (
|
||||
return -1;
|
||||
}
|
||||
|
||||
family = qse_skadfamily (&addr);
|
||||
|
||||
#if defined(_WIN32)
|
||||
nwio->handle = socket (family, type, 0);
|
||||
if (nwio->handle == INVALID_SOCKET)
|
||||
@ -703,10 +648,12 @@ int qse_nwio_init (
|
||||
}
|
||||
else
|
||||
{
|
||||
int orgfl, xret;
|
||||
int xret;
|
||||
|
||||
if (TMOUT_ENABLED(nwio->tmout.c) && (flags & QSE_NWIO_TCP))
|
||||
{
|
||||
int orgfl;
|
||||
|
||||
orgfl = fcntl (nwio->handle, F_GETFL, 0);
|
||||
if (orgfl <= -1 ||
|
||||
fcntl (nwio->handle, F_SETFL, orgfl | O_NONBLOCK) <= -1)
|
||||
@ -714,12 +661,9 @@ int qse_nwio_init (
|
||||
nwio->errnum = syserr_to_errnum (errno);
|
||||
goto oops;
|
||||
}
|
||||
}
|
||||
|
||||
xret = connect (nwio->handle, (struct sockaddr*)&addr, addrlen);
|
||||
xret = connect (nwio->handle, (struct sockaddr*)&addr, addrlen);
|
||||
|
||||
if (TMOUT_ENABLED(nwio->tmout.c) && (flags & QSE_NWIO_TCP))
|
||||
{
|
||||
if ((xret <= -1 && errno != EINPROGRESS) ||
|
||||
fcntl (nwio->handle, F_SETFL, orgfl) <= -1)
|
||||
{
|
||||
@ -750,6 +694,7 @@ int qse_nwio_init (
|
||||
}
|
||||
else
|
||||
{
|
||||
xret = connect (nwio->handle, (struct sockaddr*)&addr, addrlen);
|
||||
if (xret <= -1)
|
||||
{
|
||||
nwio->errnum = syserr_to_errnum (errno);
|
||||
@ -907,7 +852,7 @@ static qse_ssize_t nwio_read (qse_nwio_t* nwio, void* buf, qse_size_t size)
|
||||
|
||||
if (nwio->status & STATUS_UDP_CONNECT)
|
||||
{
|
||||
union sockaddr_t addr;
|
||||
qse_skad_t addr;
|
||||
int addrlen;
|
||||
|
||||
addrlen = QSE_SIZEOF(addr);
|
||||
@ -951,7 +896,7 @@ static qse_ssize_t nwio_read (qse_nwio_t* nwio, void* buf, qse_size_t size)
|
||||
|
||||
if (nwio->status & STATUS_UDP_CONNECT)
|
||||
{
|
||||
union sockaddr_t addr;
|
||||
qse_skad_t addr;
|
||||
int addrlen;
|
||||
|
||||
addrlen = QSE_SIZEOF(addr);
|
||||
@ -1002,7 +947,7 @@ static qse_ssize_t nwio_read (qse_nwio_t* nwio, void* buf, qse_size_t size)
|
||||
reread:
|
||||
if (nwio->status & STATUS_UDP_CONNECT)
|
||||
{
|
||||
union sockaddr_t addr;
|
||||
qse_skad_t addr;
|
||||
#if defined(HAVE_SOCKLEN_T)
|
||||
socklen_t addrlen;
|
||||
#else
|
||||
|
@ -436,107 +436,13 @@ void* qse_httpd_getxtnstd (qse_httpd_t* httpd)
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
|
||||
union sockaddr_t
|
||||
{
|
||||
struct sockaddr_in in4;
|
||||
#if defined(AF_INET6)
|
||||
struct sockaddr_in6 in6;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef union sockaddr_t sockaddr_t;
|
||||
|
||||
#define SOCKADDR_FAMILY(x) (((struct sockaddr_in*)(x))->sin_family)
|
||||
|
||||
static int sockaddr_to_nwad (const sockaddr_t* addr, qse_nwad_t* nwad)
|
||||
{
|
||||
int addrsize = -1;
|
||||
|
||||
switch (SOCKADDR_FAMILY(addr))
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in* in;
|
||||
in = (struct sockaddr_in*)addr;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
|
||||
QSE_MEMSET (nwad, 0, QSE_SIZEOF(*nwad));
|
||||
nwad->type = QSE_NWAD_IN4;
|
||||
nwad->u.in4.addr.value = in->sin_addr.s_addr;
|
||||
nwad->u.in4.port = in->sin_port;
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(AF_INET6)
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6* in;
|
||||
in = (struct sockaddr_in6*)addr;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
|
||||
QSE_MEMSET (nwad, 0, QSE_SIZEOF(*nwad));
|
||||
nwad->type = QSE_NWAD_IN6;
|
||||
QSE_MEMCPY (&nwad->u.in6.addr, &in->sin6_addr, QSE_SIZEOF(nwad->u.in6.addr));
|
||||
nwad->u.in6.scope = in->sin6_scope_id;
|
||||
nwad->u.in6.port = in->sin6_port;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return addrsize;
|
||||
}
|
||||
|
||||
static int nwad_to_sockaddr (const qse_nwad_t* nwad, sockaddr_t* addr)
|
||||
{
|
||||
int addrsize = -1;
|
||||
|
||||
switch (nwad->type)
|
||||
{
|
||||
case QSE_NWAD_IN4:
|
||||
{
|
||||
struct sockaddr_in* in;
|
||||
|
||||
in = (struct sockaddr_in*)addr;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
QSE_MEMSET (in, 0, addrsize);
|
||||
|
||||
in->sin_family = AF_INET;
|
||||
in->sin_addr.s_addr = nwad->u.in4.addr.value;
|
||||
in->sin_port = nwad->u.in4.port;
|
||||
break;
|
||||
}
|
||||
|
||||
case QSE_NWAD_IN6:
|
||||
{
|
||||
#if defined(AF_INET6)
|
||||
struct sockaddr_in6* in;
|
||||
|
||||
in = (struct sockaddr_in6*)addr;
|
||||
addrsize = QSE_SIZEOF(*in);
|
||||
QSE_MEMSET (in, 0, addrsize);
|
||||
|
||||
in->sin6_family = AF_INET6;
|
||||
QSE_MEMCPY (&in->sin6_addr, &nwad->u.in6.addr, QSE_SIZEOF(nwad->u.in6.addr));
|
||||
in->sin6_scope_id = nwad->u.in6.scope;
|
||||
in->sin6_port = nwad->u.in6.port;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return addrsize;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
|
||||
static int server_open (qse_httpd_t* httpd, qse_httpd_server_t* server)
|
||||
{
|
||||
int fd = -1, flag;
|
||||
sockaddr_t addr;
|
||||
qse_skad_t addr;
|
||||
int addrsize;
|
||||
|
||||
addrsize = nwad_to_sockaddr (&server->nwad, &addr);
|
||||
addrsize = qse_nwadtoskad (&server->nwad, &addr);
|
||||
if (addrsize <= -1)
|
||||
{
|
||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
|
||||
@ -667,7 +573,7 @@ static void server_close (qse_httpd_t* httpd, qse_httpd_server_t* server)
|
||||
static int server_accept (
|
||||
qse_httpd_t* httpd, qse_httpd_server_t* server, qse_httpd_client_t* client)
|
||||
{
|
||||
sockaddr_t addr;
|
||||
qse_skad_t addr;
|
||||
|
||||
#if defined(HAVE_SOCKLEN_T)
|
||||
socklen_t addrlen;
|
||||
@ -704,7 +610,7 @@ qse_fprintf (QSE_STDERR, QSE_T("Error: too many client?\n"));
|
||||
if (flag >= 0) fcntl (fd, F_SETFL, flag | O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
if (sockaddr_to_nwad (&addr, &client->remote_addr) <= -1)
|
||||
if (qse_skadtonwad (&addr, &client->remote_addr) <= -1)
|
||||
{
|
||||
/* TODO: logging */
|
||||
client->remote_addr = server->nwad;
|
||||
@ -712,7 +618,7 @@ qse_fprintf (QSE_STDERR, QSE_T("Error: too many client?\n"));
|
||||
|
||||
addrlen = QSE_SIZEOF(addr);
|
||||
if (getsockname (fd, (struct sockaddr*)&addr, &addrlen) <= -1 ||
|
||||
sockaddr_to_nwad (&addr, &client->local_addr) <= -1)
|
||||
qse_skadtonwad (&addr, &client->local_addr) <= -1)
|
||||
{
|
||||
/* TODO: logging */
|
||||
client->local_addr = server->nwad;
|
||||
@ -725,7 +631,7 @@ qse_fprintf (QSE_STDERR, QSE_T("Error: too many client?\n"));
|
||||
|
||||
addrlen = QSE_SIZEOF(addr);
|
||||
if (getsockopt (fd, SOL_IP, SO_ORIGINAL_DST, (char*)&addr, &addrlen) <= -1 ||
|
||||
sockaddr_to_nwad (&addr, &client->orgdst_addr) <= -1)
|
||||
qse_skadtonwad (&addr, &client->orgdst_addr) <= -1)
|
||||
{
|
||||
client->orgdst_addr = client->local_addr;
|
||||
}
|
||||
@ -751,7 +657,7 @@ qse_fprintf (QSE_STDERR, QSE_T("Error: too many client?\n"));
|
||||
|
||||
static int peer_open (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
|
||||
{
|
||||
sockaddr_t connaddr, bindaddr;
|
||||
qse_skad_t connaddr, bindaddr;
|
||||
int connaddrsize, bindaddrsize;
|
||||
int connected = 1;
|
||||
#if defined(_WIN32)
|
||||
@ -768,8 +674,8 @@ static int peer_open (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
|
||||
int flag;
|
||||
#endif
|
||||
|
||||
connaddrsize = nwad_to_sockaddr (&peer->nwad, &connaddr);
|
||||
bindaddrsize = nwad_to_sockaddr (&peer->local, &bindaddr);
|
||||
connaddrsize = qse_nwadtoskad (&peer->nwad, &connaddr);
|
||||
bindaddrsize = qse_nwadtoskad (&peer->local, &bindaddr);
|
||||
if (connaddrsize <= -1 || bindaddrsize <= -1)
|
||||
{
|
||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
|
||||
@ -1239,15 +1145,12 @@ static void file_close (qse_httpd_t* httpd, qse_ubi_t handle)
|
||||
#if defined(_WIN32)
|
||||
/* TODO: */
|
||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
|
||||
return -1;
|
||||
#elif defined(__OS2__)
|
||||
/* TODO: */
|
||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
|
||||
return -1;
|
||||
#elif defined(__DOS__)
|
||||
/* TODO: */
|
||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
|
||||
return -1;
|
||||
#else
|
||||
qse_printf (QSE_T("closing file %d\n"), handle.i);
|
||||
QSE_CLOSE (handle.i);
|
||||
@ -1386,7 +1289,15 @@ static int dir_read (qse_httpd_t* httpd, qse_ubi_t handle, qse_httpd_dirent_t* d
|
||||
static void client_close (
|
||||
qse_httpd_t* httpd, qse_httpd_client_t* client)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
/* TODO: */
|
||||
#elif defined(__OS2__)
|
||||
/* TODO: */
|
||||
#elif defined(__DOS__)
|
||||
/* TODO: */
|
||||
#else
|
||||
QSE_CLOSE (client->handle.i);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void client_shutdown (
|
||||
@ -2075,7 +1986,6 @@ auth_ok:
|
||||
#if defined(_WIN32)
|
||||
/* TODO */
|
||||
#elif defined(__OS2__)
|
||||
|
||||
/* TODO */
|
||||
#elif defined(__DOS__)
|
||||
|
||||
@ -2099,7 +2009,16 @@ auth_ok:
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* TODO */
|
||||
#elif defined(__OS2__)
|
||||
/* TODO */
|
||||
#elif defined(__DOS__)
|
||||
|
||||
/* TODO */
|
||||
#else
|
||||
if (QSE_STAT (tpath, &st) == 0 && S_ISREG(st.st_mode))
|
||||
#endif
|
||||
{
|
||||
/* the index file is found */
|
||||
QSE_MMGR_FREE (httpd->mmgr, xpath);
|
||||
|
Reference in New Issue
Block a user