added unicode trait and case functions.
fixed some code for os2
This commit is contained in:
@ -108,13 +108,15 @@ libqsecmn_la_SOURCES = \
|
||||
utf8.c \
|
||||
xma.c
|
||||
|
||||
if ENABLE_BUNDLED_UNICODE
|
||||
libqsecmn_la_SOURCES += uni.c
|
||||
endif
|
||||
|
||||
if INCLUDE_MORE_CMGRS
|
||||
libqsecmn_la_SOURCES += \
|
||||
cp949.c \
|
||||
cp950.c
|
||||
libqsecmn_la_SOURCES += cp949.c cp950.c
|
||||
endif
|
||||
|
||||
|
||||
libqsecmn_la_LDFLAGS = -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||
libqsecmn_la_LIBADD = $(SOCKET_LIBS)
|
||||
|
||||
|
@ -35,11 +35,9 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@INCLUDE_MORE_CMGRS_TRUE@am__append_1 = \
|
||||
@INCLUDE_MORE_CMGRS_TRUE@ cp949.c \
|
||||
@INCLUDE_MORE_CMGRS_TRUE@ cp950.c
|
||||
|
||||
@ENABLE_CXX_TRUE@am__append_2 = libqsecmnxx.la
|
||||
@ENABLE_BUNDLED_UNICODE_TRUE@am__append_1 = uni.c
|
||||
@INCLUDE_MORE_CMGRS_TRUE@am__append_2 = cp949.c cp950.c
|
||||
@ENABLE_CXX_TRUE@am__append_3 = libqsecmnxx.la
|
||||
subdir = lib/cmn
|
||||
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in
|
||||
@ -100,8 +98,9 @@ am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.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
|
||||
tre-stack.c uri.c utf8.c xma.c uni.c cp949.c cp950.c
|
||||
@ENABLE_BUNDLED_UNICODE_TRUE@am__objects_1 = uni.lo
|
||||
@INCLUDE_MORE_CMGRS_TRUE@am__objects_2 = 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 \
|
||||
@ -117,7 +116,7 @@ am_libqsecmn_la_OBJECTS = alg-base64.lo alg-rand.lo alg-search.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)
|
||||
xma.lo $(am__objects_1) $(am__objects_2)
|
||||
libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS)
|
||||
libqsecmn_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
@ -336,7 +335,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(includedir)
|
||||
|
||||
lib_LTLIBRARIES = libqsecmn.la $(am__append_2)
|
||||
lib_LTLIBRARIES = libqsecmn.la $(am__append_3)
|
||||
noinst_HEADERS = \
|
||||
cp949.h \
|
||||
cp950.h \
|
||||
@ -363,7 +362,7 @@ libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.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)
|
||||
tre-stack.c uri.c utf8.c xma.c $(am__append_1) $(am__append_2)
|
||||
libqsecmn_la_LDFLAGS = -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||
libqsecmn_la_LIBADD = $(SOCKET_LIBS)
|
||||
@ENABLE_CXX_TRUE@libqsecmnxx_la_SOURCES = \
|
||||
@ -533,6 +532,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tre-parse.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tre-stack.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tre.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uni.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uri.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xma.Plo@am__quote@
|
||||
|
@ -21,12 +21,12 @@
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#if !defined(NDEBUG)
|
||||
|
||||
#include <qse/cmn/sio.h>
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
#if defined(HAVE_EXECINFO_H)
|
||||
# include <execinfo.h>
|
||||
# include <stdlib.h>
|
||||
# include <qse/cmn/str.h>
|
||||
@ -91,7 +91,7 @@ void qse_assert_failed (
|
||||
const qse_char_t* expr, const qse_char_t* desc,
|
||||
const qse_char_t* file, qse_size_t line)
|
||||
{
|
||||
#ifdef HAVE_BACKTRACE
|
||||
#if defined(HAVE_BACKTRACE)
|
||||
void *btarray[128];
|
||||
qse_size_t btsize, i;
|
||||
char **btsyms;
|
||||
@ -138,7 +138,7 @@ void qse_assert_failed (
|
||||
qse_sio_putmbs (sio, QSE_MT("\n"));
|
||||
}
|
||||
|
||||
#ifdef HAVE_BACKTRACE
|
||||
#if defined(HAVE_BACKTRACE)
|
||||
btsize = backtrace (btarray, QSE_COUNTOF(btarray));
|
||||
btsyms = backtrace_symbols (btarray, btsize);
|
||||
if (btsyms != QSE_NULL)
|
||||
|
@ -22,13 +22,18 @@
|
||||
#include <qse/cmn/str.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
# include <qse/cmn/uni.h>
|
||||
#else
|
||||
# include <wctype.h>
|
||||
#endif
|
||||
|
||||
static QSE_INLINE int is_malpha (qse_mcint_t c) { return isalpha(c); }
|
||||
static QSE_INLINE int is_malnum (qse_mcint_t c) { return isalnum(c); }
|
||||
static QSE_INLINE int is_mblank (qse_mcint_t c)
|
||||
{
|
||||
#ifdef HAVE_ISBLANK
|
||||
#if defined(HAVE_ISBLANK)
|
||||
return isblank(c);
|
||||
#else
|
||||
return c == QSE_MT(' ') || c == QSE_MT('\t');
|
||||
@ -45,25 +50,105 @@ static QSE_INLINE int is_mupper (qse_mcint_t c) { return isupper(c); }
|
||||
static QSE_INLINE int is_mxdigit (qse_mcint_t c) { return isxdigit(c); }
|
||||
|
||||
|
||||
static QSE_INLINE int is_walpha (qse_wcint_t c) { return iswalpha(c); }
|
||||
static QSE_INLINE int is_walnum (qse_wcint_t c) { return iswalnum(c); }
|
||||
static QSE_INLINE int is_walpha (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isunialpha (c);
|
||||
#else
|
||||
return iswalpha(c);
|
||||
#endif
|
||||
}
|
||||
static QSE_INLINE int is_walnum (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isunialnum (c);
|
||||
#else
|
||||
return iswalnum(c);
|
||||
#endif
|
||||
}
|
||||
static QSE_INLINE int is_wblank (qse_wcint_t c)
|
||||
{
|
||||
#ifdef HAVE_ISWBLANK
|
||||
#if defined(HAVE_ISWBLANK)
|
||||
return iswblank(c);
|
||||
#else
|
||||
return c == QSE_WT(' ') || c == QSE_WT('\t');
|
||||
#endif
|
||||
}
|
||||
static QSE_INLINE int is_wcntrl (qse_wcint_t c) { return iswcntrl(c); }
|
||||
static QSE_INLINE int is_wdigit (qse_wcint_t c) { return iswdigit(c); }
|
||||
static QSE_INLINE int is_wgraph (qse_wcint_t c) { return iswgraph(c); }
|
||||
static QSE_INLINE int is_wlower (qse_wcint_t c) { return iswlower(c); }
|
||||
static QSE_INLINE int is_wprint (qse_wcint_t c) { return iswprint(c); }
|
||||
static QSE_INLINE int is_wpunct (qse_wcint_t c) { return iswpunct(c); }
|
||||
static QSE_INLINE int is_wspace (qse_wcint_t c) { return iswspace(c); }
|
||||
static QSE_INLINE int is_wupper (qse_wcint_t c) { return iswupper(c); }
|
||||
static QSE_INLINE int is_wxdigit (qse_wcint_t c) { return iswxdigit(c); }
|
||||
static QSE_INLINE int is_wcntrl (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isunicntrl (c);
|
||||
#else
|
||||
return iswcntrl(c);
|
||||
#endif
|
||||
}
|
||||
static QSE_INLINE int is_wdigit (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isunidigit (c);
|
||||
#else
|
||||
return iswdigit(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
static QSE_INLINE int is_wgraph (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isunigraph (c);
|
||||
#else
|
||||
return iswgraph(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
static QSE_INLINE int is_wlower (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isunilower (c);
|
||||
#else
|
||||
return iswlower(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
static QSE_INLINE int is_wprint (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isuniprint (c);
|
||||
#else
|
||||
return iswprint(c);
|
||||
#endif
|
||||
}
|
||||
static QSE_INLINE int is_wpunct (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isunipunct (c);
|
||||
#else
|
||||
return iswpunct(c);
|
||||
#endif
|
||||
}
|
||||
static QSE_INLINE int is_wspace (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isunispace (c);
|
||||
#else
|
||||
return iswspace(c);
|
||||
#endif
|
||||
}
|
||||
static QSE_INLINE int is_wupper (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isuniupper (c);
|
||||
#else
|
||||
return iswupper(c);
|
||||
#endif
|
||||
}
|
||||
static QSE_INLINE int is_wxdigit (qse_wcint_t c)
|
||||
{
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
return qse_isunixdigit (c);
|
||||
#else
|
||||
return iswxdigit(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
int qse_ismctype (qse_mcint_t c, qse_mctype_t type)
|
||||
{
|
||||
@ -172,6 +257,21 @@ int qse_iswctype (qse_wcint_t c, qse_wctype_t type)
|
||||
is_wupper,
|
||||
is_wxdigit
|
||||
#endif
|
||||
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
qse_isunialnum,
|
||||
qse_isunialpha,
|
||||
is_wblank,
|
||||
qse_isunicntrl,
|
||||
qse_isunidigit,
|
||||
qse_isunigraph,
|
||||
qse_isunilower,
|
||||
qse_isuniprint,
|
||||
qse_isunipunct,
|
||||
qse_isunispace,
|
||||
qse_isuniupper,
|
||||
qse_isunixdigit
|
||||
#else
|
||||
iswalnum,
|
||||
iswalpha,
|
||||
is_wblank,
|
||||
@ -184,6 +284,7 @@ int qse_iswctype (qse_wcint_t c, qse_wctype_t type)
|
||||
iswspace,
|
||||
iswupper,
|
||||
iswxdigit
|
||||
#endif
|
||||
};
|
||||
|
||||
QSE_ASSERTX (type >= QSE_WCTYPE_ALNUM && type <= QSE_WCTYPE_XDIGIT,
|
||||
@ -219,8 +320,13 @@ qse_wcint_t qse_towctype (qse_wcint_t c, qse_wctype_t type)
|
||||
*/
|
||||
QSE_ASSERTX (type == QSE_WCTYPE_UPPER || type == QSE_WCTYPE_LOWER,
|
||||
"The type should be one of QSE_WCTYPE_UPPER and QSE_WCTYPE_LOWER");
|
||||
#if defined(QSE_ENABLE_BUNDLED_UNICODE)
|
||||
if (type == QSE_WCTYPE_UPPER) return qse_touniupper(c);
|
||||
if (type == QSE_WCTYPE_LOWER) return qse_tounilower(c);
|
||||
#else
|
||||
if (type == QSE_WCTYPE_UPPER) return towupper(c);
|
||||
if (type == QSE_WCTYPE_LOWER) return towlower(c);
|
||||
#endif
|
||||
return c;
|
||||
/*
|
||||
#endif
|
||||
|
@ -51,7 +51,11 @@ struct qse_dir_t
|
||||
int done;
|
||||
#elif defined(__OS2__)
|
||||
HDIR h;
|
||||
#if defined(FIL_STANDARDL)
|
||||
FILEFINDBUF3L ffb;
|
||||
#else
|
||||
FILEFINDBUF3 ffb;
|
||||
#endif
|
||||
ULONG count;
|
||||
int opened;
|
||||
#elif defined(__DOS__)
|
||||
@ -326,7 +330,12 @@ static int reset_to_path (qse_dir_t* dir, const qse_char_t* path)
|
||||
&dir->ffb,
|
||||
QSE_SIZEOF(dir->ffb),
|
||||
&dir->count,
|
||||
FIL_STANDARDL);
|
||||
#if defined(FIL_STANDARDL)
|
||||
FIL_STANDARDL
|
||||
#else
|
||||
FIL_STANDARD
|
||||
#endif
|
||||
);
|
||||
|
||||
if (rc != NO_ERROR) return -1;
|
||||
|
||||
|
@ -455,7 +455,11 @@ int qse_fio_init (
|
||||
APIRET ret;
|
||||
ULONG action_taken = 0;
|
||||
ULONG open_action, open_mode, open_attr;
|
||||
#if defined(FIL_STANDARDL)
|
||||
LONGLONG zero;
|
||||
#else
|
||||
ULONG zero;
|
||||
#endif
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
const qse_mchar_t* path_mb = path;
|
||||
@ -493,8 +497,12 @@ int qse_fio_init (
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FIL_STANDARDL)
|
||||
zero.ulLo = 0;
|
||||
zero.ulHi = 0;
|
||||
#else
|
||||
zero = 0;
|
||||
#endif
|
||||
|
||||
if (flags & QSE_FIO_APPEND)
|
||||
fio->status |= STATUS_APPEND;
|
||||
@ -549,7 +557,11 @@ int qse_fio_init (
|
||||
|
||||
open_attr = (mode & QSE_FIO_WUSR)? FILE_NORMAL: FILE_READONLY;
|
||||
|
||||
#if defined(FIL_STANDARDL)
|
||||
ret = DosOpenL (
|
||||
#else
|
||||
ret = DosOpen (
|
||||
#endif
|
||||
path_mb, /* file name */
|
||||
&handle, /* file handle */
|
||||
&action_taken, /* store action taken */
|
||||
@ -1015,6 +1027,8 @@ qse_fio_off_t qse_fio_seek (
|
||||
FILE_END
|
||||
};
|
||||
|
||||
#if defined(FIL_STANDARDL)
|
||||
|
||||
LONGLONG pos, newpos;
|
||||
APIRET ret;
|
||||
|
||||
@ -1030,7 +1044,22 @@ qse_fio_off_t qse_fio_seek (
|
||||
return (qse_fio_off_t)-1;
|
||||
}
|
||||
|
||||
return ((qse_fio_off_t)pos.ulHi << 32) | pos.ulLo;
|
||||
return ((qse_fio_off_t)newpos.ulHi << 32) | newpos.ulLo;
|
||||
|
||||
#else
|
||||
ULONG newpos;
|
||||
APIRET ret;
|
||||
|
||||
ret = DosSetFilePtr (fio->handle, offset, seek_map[origin], &newpos);
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
fio->errnum = syserr_to_errnum (ret);
|
||||
return (qse_fio_off_t)-1;
|
||||
}
|
||||
|
||||
return newpos;
|
||||
#endif
|
||||
|
||||
#elif defined(__DOS__)
|
||||
static int seek_map[] =
|
||||
{
|
||||
@ -1093,7 +1122,10 @@ int qse_fio_truncate (qse_fio_t* fio, qse_fio_off_t size)
|
||||
|
||||
return 0;
|
||||
#elif defined(__OS2__)
|
||||
|
||||
APIRET ret;
|
||||
|
||||
#if defined(FIL_STANDARDL)
|
||||
LONGLONG sz;
|
||||
/* the file must have the write access for it to succeed */
|
||||
|
||||
@ -1101,11 +1133,14 @@ int qse_fio_truncate (qse_fio_t* fio, qse_fio_off_t size)
|
||||
sz.ulHi = (ULONG)(size>>32);
|
||||
|
||||
ret = DosSetFileSizeL (fio->handle, sz);
|
||||
#else
|
||||
ret = DosSetFileSize (fio->handle, size);
|
||||
#endif
|
||||
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
fio->errnum = syserr_to_errnum (ret);
|
||||
return -1;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -1235,10 +1270,15 @@ qse_ssize_t qse_fio_write (qse_fio_t* fio, const void* data, qse_size_t size)
|
||||
if (fio->status & STATUS_APPEND)
|
||||
{
|
||||
/* i do this on a best-effort basis */
|
||||
#if defined(FIL_STANDARDL)
|
||||
LONGLONG pos, newpos;
|
||||
pos.ulLo = (ULONG)0;
|
||||
pos.ulHi = (ULONG)0;
|
||||
DosSetFilePtrL (fio->handle, pos, FILE_END, &newpos);
|
||||
#else
|
||||
ULONG newpos;
|
||||
DosSetFilePtr (fio->handle, 0, FILE_END, &newpos);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (size > (QSE_TYPE_MAX(qse_ssize_t) & QSE_TYPE_MAX(ULONG)))
|
||||
@ -1452,10 +1492,18 @@ int qse_fio_chmod (qse_fio_t* fio, int mode)
|
||||
|
||||
APIRET n;
|
||||
int flags = FILE_NORMAL;
|
||||
#if defined(FIL_STANDARDL)
|
||||
FILESTATUS3L stat;
|
||||
#else
|
||||
FILESTATUS3 stat;
|
||||
#endif
|
||||
ULONG size = QSE_SIZEOF(stat);
|
||||
|
||||
#if defined(FIL_STANDARDL)
|
||||
n = DosQueryFileInfo (fio->handle, FIL_STANDARDL, &stat, size);
|
||||
#else
|
||||
n = DosQueryFileInfo (fio->handle, FIL_STANDARD, &stat, size);
|
||||
#endif
|
||||
if (n != NO_ERROR)
|
||||
{
|
||||
fio->errnum = syserr_to_errnum (n);
|
||||
@ -1465,7 +1513,11 @@ int qse_fio_chmod (qse_fio_t* fio, int mode)
|
||||
if (!(mode & QSE_FIO_WUSR)) flags = FILE_READONLY;
|
||||
|
||||
stat.attrFile = flags;
|
||||
#if defined(FIL_STANDARDL)
|
||||
n = DosSetFileInfo (fio->handle, FIL_STANDARDL, &stat, size);
|
||||
#else
|
||||
n = DosSetFileInfo (fio->handle, FIL_STANDARD, &stat, size);
|
||||
#endif
|
||||
if (n != NO_ERROR)
|
||||
{
|
||||
fio->errnum = syserr_to_errnum (n);
|
||||
|
@ -89,6 +89,16 @@ struct qse_mux_t
|
||||
qse_size_t capa;
|
||||
} ee;
|
||||
|
||||
struct
|
||||
{
|
||||
qse_mux_evt_t** ptr;
|
||||
int ubound;
|
||||
} me;
|
||||
#elif defined(__OS2__)
|
||||
int fdarr;
|
||||
int rsize;
|
||||
int wsize;
|
||||
|
||||
struct
|
||||
{
|
||||
qse_mux_evt_t** ptr;
|
||||
@ -131,27 +141,27 @@ static qse_mux_errnum_t syserr_to_errnum (DWORD e)
|
||||
}
|
||||
}
|
||||
#elif defined(__OS2__)
|
||||
static qse_mux_errnum_t syserr_to_errnum (APIRET e)
|
||||
static qse_mux_errnum_t syserr_to_errnum (int e)
|
||||
{
|
||||
switch (e)
|
||||
{
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
case SOCENOMEM:
|
||||
return QSE_MUX_ENOMEM;
|
||||
|
||||
case ERROR_INVALID_PARAMETER:
|
||||
case ERROR_INVALID_HANDLE:
|
||||
case ERROR_INVALID_NAME:
|
||||
case SOCEINVAL:
|
||||
return QSE_MUX_EINVAL;
|
||||
|
||||
case ERROR_ACCESS_DENIED:
|
||||
case SOCEACCES:
|
||||
return QSE_MUX_EACCES;
|
||||
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
case SOCENOENT:
|
||||
return QSE_MUX_ENOENT;
|
||||
|
||||
case ERROR_ALREADY_EXISTS:
|
||||
case SOCEEXIST:
|
||||
return QSE_MUX_EEXIST;
|
||||
|
||||
case SOCEINTR:
|
||||
return QSE_MUX_EINTR;
|
||||
|
||||
default:
|
||||
return QSE_MUX_ESYSERR;
|
||||
@ -272,6 +282,11 @@ int qse_mux_init (qse_mux_t* mux, qse_mmgr_t* mmgr, qse_mux_evtfun_t evtfun, qse
|
||||
if (flag >= 0) fcntl (mux->fd, F_SETFD, flag | FD_CLOEXEC);
|
||||
}
|
||||
#endif
|
||||
#elif defined(__OS2__)
|
||||
|
||||
mux->errnum = QSE_MUX_ENOIMPL;
|
||||
return -1;
|
||||
|
||||
#else
|
||||
/* TODO: */
|
||||
mux->errnum = QSE_MUX_ENOIMPL;
|
||||
@ -458,6 +473,9 @@ int qse_mux_insert (qse_mux_t* mux, const qse_mux_evt_t* evt)
|
||||
*mux->me.ptr[evt->hnd] = *evt;
|
||||
mux->ee.len++;
|
||||
return 0;
|
||||
#elif defined(__OS2__)
|
||||
mux->errnum = QSE_MUX_ENOIMPL;
|
||||
return -1;
|
||||
#else
|
||||
/* TODO: */
|
||||
mux->errnum = QSE_MUX_ENOIMPL;
|
||||
@ -526,6 +544,12 @@ done:
|
||||
|
||||
mux->ee.len--;
|
||||
return 0;
|
||||
#elif defined(__OS2__)
|
||||
|
||||
/* TODO */
|
||||
mux->errnum = QSE_MUX_ENOIMPL;
|
||||
return -1;
|
||||
|
||||
#else
|
||||
/* TODO */
|
||||
mux->errnum = QSE_MUX_ENOIMPL;
|
||||
@ -550,6 +574,8 @@ int qse_mux_poll (qse_mux_t* mux, const qse_ntime_t* tmout)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
mux->errnum = syserr_to_errnum(WSAGetLastError());
|
||||
#elif defined(__OS2__)
|
||||
mux->errnum = syserr_to_errnum(sock_errno());
|
||||
#else
|
||||
mux->errnum = syserr_to_errnum(errno);
|
||||
#endif
|
||||
@ -614,6 +640,27 @@ int qse_mux_poll (qse_mux_t* mux, const qse_ntime_t* tmout)
|
||||
|
||||
return nfds;
|
||||
|
||||
#elif defined(__OS2__)
|
||||
|
||||
/*
|
||||
long tv;
|
||||
int n;
|
||||
|
||||
tv = QSE_SEC_TO_MSEC(nwio->tmout.r.sec) + QSE_NSEC_TO_MSEC (nwio->tmout.r.nsec);
|
||||
|
||||
n = os2_select (handle_array, read_count, write_count, 0, &tv);
|
||||
if (n < = 1)
|
||||
{
|
||||
mux->errnum = syserr_to_errnum(sock_errno());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return n;
|
||||
*/
|
||||
mux->errnum = QSE_MUX_ENOIMPL;
|
||||
return -1;
|
||||
|
||||
#else
|
||||
/* TODO */
|
||||
mux->errnum = QSE_MUX_ENOIMPL;
|
||||
|
@ -307,13 +307,15 @@ static int preset_tmout (qse_nwio_t* nwio)
|
||||
#if defined(SO_RCVTIMEO) && defined(SO_SNDTIMEO)
|
||||
#if defined(_WIN32)
|
||||
DWORD tv;
|
||||
#elif defined(__OS2__)
|
||||
long tv;
|
||||
#else
|
||||
struct timeval tv;
|
||||
#endif
|
||||
|
||||
if (TMOUT_ENABLED(nwio->tmout.r))
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) || defined(__OS2__)
|
||||
tv = QSE_SEC_TO_MSEC(nwio->tmout.r.sec) + QSE_NSEC_TO_MSEC (nwio->tmout.r.nsec);
|
||||
#else
|
||||
tv.tv_sec = nwio->tmout.r.sec;
|
||||
@ -322,6 +324,13 @@ static int preset_tmout (qse_nwio_t* nwio)
|
||||
|
||||
if (setsockopt (nwio->handle, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, QSE_SIZEOF(tv)) <= -1)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
nwio->errnum = syserr_to_errnum (WSAGetLastError());
|
||||
#elif defined(__OS2__)
|
||||
nwio->errnum = syserr_to_errnum (sock_errno());
|
||||
#else
|
||||
nwio->errnum = syserr_to_errnum (errno);
|
||||
#endif
|
||||
return -1; /* tried to set but failed */
|
||||
}
|
||||
|
||||
@ -330,7 +339,7 @@ static int preset_tmout (qse_nwio_t* nwio)
|
||||
|
||||
if (TMOUT_ENABLED(nwio->tmout.w))
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) || defined(__OS2__)
|
||||
tv = QSE_SEC_TO_MSEC(nwio->tmout.w.sec) + QSE_NSEC_TO_MSEC (nwio->tmout.w.nsec);
|
||||
#else
|
||||
tv.tv_sec = nwio->tmout.w.sec;
|
||||
@ -338,6 +347,13 @@ static int preset_tmout (qse_nwio_t* nwio)
|
||||
#endif
|
||||
if (setsockopt (nwio->handle, SOL_SOCKET, SO_SNDTIMEO, (void*)&tv, QSE_SIZEOF(tv)) <= -1)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
nwio->errnum = syserr_to_errnum (WSAGetLastError());
|
||||
#elif defined(__OS2__)
|
||||
nwio->errnum = syserr_to_errnum (sock_errno());
|
||||
#else
|
||||
nwio->errnum = syserr_to_errnum (errno);
|
||||
#endif
|
||||
return -1; /* tried to set but failed */
|
||||
}
|
||||
|
||||
|
27188
qse/lib/cmn/uni.c
Normal file
27188
qse/lib/cmn/uni.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -41,7 +41,16 @@
|
||||
# define EPOCH_DIFF_SECS ((qse_long_t)EPOCH_DIFF_DAYS*24*60*60)
|
||||
|
||||
#elif defined(__OS2__)
|
||||
/* TODO */
|
||||
# define INCL_DOSERRORS
|
||||
# define INCL_DOSFILEMGR
|
||||
# include <os2.h>
|
||||
# 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 */
|
||||
@ -236,7 +245,7 @@ static qse_httpd_errnum_t syserr_to_errnum (int e)
|
||||
|
||||
#define MAX_SEND_SIZE 4096
|
||||
|
||||
static qse_ssize_t send_file (
|
||||
static qse_ssize_t __send_file (
|
||||
int out_fd, qse_ubi_t in_fd, qse_foff_t* offset, qse_size_t count)
|
||||
{
|
||||
#if defined(HAVE_SENDFILE) && defined(HAVE_SENDFILE64)
|
||||
@ -325,7 +334,7 @@ on failure xfer != n.
|
||||
/* ------------------------------------------------------------------- */
|
||||
|
||||
#if defined(HAVE_SSL)
|
||||
static qse_ssize_t send_file_ssl (
|
||||
static qse_ssize_t __send_file_ssl (
|
||||
SSL* out, qse_ubi_t in_fd, qse_foff_t* offset, qse_size_t count)
|
||||
{
|
||||
qse_mchar_t buf[MAX_SEND_SIZE];
|
||||
@ -950,28 +959,43 @@ static int mux_poll (qse_httpd_t* httpd, void* vmux, const qse_ntime_t* tmout)
|
||||
|
||||
static int mux_readable (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t* tmout)
|
||||
{
|
||||
#if defined(__OS2__)
|
||||
long tv;
|
||||
|
||||
tv = tmout? QSE_SECNSEC_TO_MSEC (tmout->sec, tmout->nsec): -1;
|
||||
return os2_select (&handle.i, 1, 0, 0, tv);
|
||||
#else
|
||||
fd_set r;
|
||||
struct timeval tv, * tvp;
|
||||
|
||||
if (tmout)
|
||||
{
|
||||
tv.tv_sec = tmout->sec;
|
||||
tv.tv_usec = tmout->nsec;
|
||||
tvp = &tv;
|
||||
}
|
||||
else tvp = QSE_NULL;
|
||||
|
||||
FD_ZERO (&r);
|
||||
FD_SET (handle.i, &r);
|
||||
|
||||
if (tmout)
|
||||
{
|
||||
tv.tv_sec = tmout->sec;
|
||||
tv.tv_usec = tmout->nsec;
|
||||
tvp = &tv;
|
||||
}
|
||||
else tvp = QSE_NULL;
|
||||
|
||||
return select (handle.i + 1, &r, QSE_NULL, QSE_NULL, tvp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int mux_writable (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t* tmout)
|
||||
{
|
||||
#if defined(__OS2__)
|
||||
long tv;
|
||||
tv = tmout? QSE_SECNSEC_TO_MSEC (tmout->sec, tmout->nsec): -1;
|
||||
return os2_select (&handle.i, 0, 1, 0, tv);
|
||||
#else
|
||||
fd_set w;
|
||||
struct timeval tv, * tvp;
|
||||
|
||||
FD_ZERO (&w);
|
||||
FD_SET (handle.i, &w);
|
||||
|
||||
if (tmout)
|
||||
{
|
||||
tv.tv_sec = tmout->sec;
|
||||
@ -980,10 +1004,8 @@ static int mux_writable (qse_httpd_t* httpd, qse_ubi_t handle, const qse_ntime_t
|
||||
}
|
||||
else tvp = QSE_NULL;
|
||||
|
||||
FD_ZERO (&w);
|
||||
FD_SET (handle.i, &w);
|
||||
|
||||
return select (handle.i + 1, QSE_NULL, &w, QSE_NULL, tvp);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
@ -1034,17 +1056,19 @@ static int stat_file (
|
||||
|
||||
#elif defined(__OS2__)
|
||||
APIRET rc;
|
||||
HDIR h;
|
||||
FILEFINDBUF3L ffb;
|
||||
ULONG count;
|
||||
qse_btime_t bt;
|
||||
qse_ntime_t nt;
|
||||
|
||||
#if 0
|
||||
HDIR h;
|
||||
ULONG count;
|
||||
|
||||
/* fail if the path name contains a wilecard letter */
|
||||
if (qse_mbspbrk (path, QSE_MT("?*")) != QSE_NULL) return -1;
|
||||
|
||||
rc = DosFindFirst (
|
||||
mptr,
|
||||
path,
|
||||
&h,
|
||||
FILE_DIRECTORY | FILE_READONLY,
|
||||
&ffb,
|
||||
@ -1053,7 +1077,10 @@ static int stat_file (
|
||||
FIL_STANDARDL);
|
||||
if (rc != NO_ERROR) return -1;
|
||||
|
||||
DosFindClose (&h);
|
||||
DosFindClose (h);
|
||||
#endif
|
||||
rc = DosQueryPathInfo (path, FIL_STANDARDL, &ffb, QSE_SIZEOF(ffb));
|
||||
if (rc != NO_ERROR) return -1;
|
||||
|
||||
QSE_MEMSET (&bt, 0, QSE_SIZEOF(bt));
|
||||
bt.mday = ffb.fdateLastWrite.day;
|
||||
@ -1067,9 +1094,22 @@ static int stat_file (
|
||||
|
||||
QSE_MEMSET (hst, 0, QSE_SIZEOF(*hst));
|
||||
if (ffb.attrFile & FILE_DIRECTORY) hst->isdir = 1;
|
||||
hst->size = ffb.cbFile;
|
||||
hst->size = ((qse_foff_t)ffb.cbFile.ulHi << 32) | ffb.cbFile.ulLo;
|
||||
hst->mtime = nt;
|
||||
|
||||
if (path[0] != QSE_MT('\0') && path[1] == QSE_MT(':'))
|
||||
{
|
||||
if (path[0] >= QSE_MT('a') && path[0] <= QSE_MT('z'))
|
||||
hst->dev = path[0] - QSE_MT('a');
|
||||
else if (path[0] >= QSE_MT('A') && path[0] <= QSE_MT('Z'))
|
||||
hst->dev = path[0] - QSE_MT('A');
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG num, map;
|
||||
if (DosQueryCurrentDisk (&num, &map) == NO_ERROR) hst->dev = num - 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
#elif defined(__DOS__)
|
||||
@ -1372,14 +1412,14 @@ static qse_ssize_t client_sendfile (
|
||||
if (client->status & CLIENT_SECURE)
|
||||
{
|
||||
#if defined(HAVE_SSL)
|
||||
return send_file_ssl (client->handle2.ptr, handle, offset, count);
|
||||
return __send_file_ssl (client->handle2.ptr, handle, offset, count);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
return send_file (client->handle.i, handle, offset, count);
|
||||
return __send_file (client->handle.i, handle, offset, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,19 +223,23 @@ static qse_httpd_task_t* entask_status (
|
||||
const qse_mchar_t* extrapst = QSE_MT("");
|
||||
const qse_mchar_t* extraval = QSE_MT("");
|
||||
|
||||
qse_mchar_t text[1024] = QSE_MT(""); /* TODO: make this buffer dynamic or scalable */
|
||||
qse_mchar_t text[1024]; /* TODO: make this buffer dynamic or scalable */
|
||||
|
||||
msg = qse_httpstatustombs (code);
|
||||
if (code == 301 || code == 307)
|
||||
{
|
||||
status_reloc_t* reloc = (status_reloc_t*)extra;
|
||||
status_reloc_t* reloc;
|
||||
|
||||
reloc = (status_reloc_t*)extra;
|
||||
extrapre = QSE_MT("Location: ");
|
||||
extrapst = reloc->redir? QSE_MT("/\r\n"): QSE_MT("\r\n");
|
||||
extraval = reloc->dst;
|
||||
|
||||
text[0] = QSE_MT('\0');
|
||||
}
|
||||
else if (code == 304)
|
||||
{
|
||||
/* nothing to do */
|
||||
text[0] = QSE_MT('\0');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user