From 574f373cf0d10e10a70070188282ea10219204ff Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 4 May 2011 08:00:38 +0000 Subject: [PATCH] added some DOS stuffs --- qse/include/qse/Makefile.am | 4 +- qse/include/qse/Makefile.in | 10 +-- qse/include/qse/conf_dos.h | 82 ++++++++++++++++++++++++ qse/include/qse/conf_os2.h | 2 +- qse/include/qse/types.h | 4 +- qse/lib/awk/std.c | 4 +- qse/lib/cmn/assert.c | 16 ++++- qse/lib/cmn/chr_cnv.c | 4 +- qse/lib/cmn/fio.c | 37 ++++++++++- qse/lib/cmn/misc.c | 6 +- qse/watcom/qse.wpj | 120 +++++++++++++++++++++--------------- 11 files changed, 222 insertions(+), 67 deletions(-) create mode 100644 qse/include/qse/conf_dos.h diff --git a/qse/include/qse/Makefile.am b/qse/include/qse/Makefile.am index 26ccacbc..18a03cd8 100644 --- a/qse/include/qse/Makefile.am +++ b/qse/include/qse/Makefile.am @@ -2,7 +2,9 @@ SUBDIRS = cmn awk cut sed scm http pkgincludedir = $(includedir)/qse -pkginclude_HEADERS = conf_msw.h conf_vms.h types.h macros.h pack1.h unpack.h +pkginclude_HEADERS = \ + conf_msw.h conf_os2.h conf_dos.h conf_vms.h \ + types.h macros.h pack1.h unpack.h if ENABLE_CXX pkginclude_HEADERS += Types.hpp diff --git a/qse/include/qse/Makefile.in b/qse/include/qse/Makefile.in index 65fa35d5..088d6fb0 100644 --- a/qse/include/qse/Makefile.in +++ b/qse/include/qse/Makefile.in @@ -57,8 +57,9 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive -am__pkginclude_HEADERS_DIST = conf_msw.h conf_vms.h types.h macros.h \ - pack1.h unpack.h Types.hpp +am__pkginclude_HEADERS_DIST = \ + conf_msw.h conf_os2.h conf_dos.h conf_vms.h \ + types.h macros.h pack1.h unpack.h Types.hpp am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -255,8 +256,9 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = cmn awk cut sed scm http -pkginclude_HEADERS = conf_msw.h conf_vms.h types.h macros.h pack1.h \ - unpack.h $(am__append_1) +pkginclude_HEADERS = \ + conf_msw.h conf_os2.h conf_dos.h conf_vms.h \ + types.h macros.h pack1.h unpack.h $(am__append_1) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive diff --git a/qse/include/qse/conf_dos.h b/qse/include/qse/conf_dos.h new file mode 100644 index 00000000..ad718e7d --- /dev/null +++ b/qse/include/qse/conf_dos.h @@ -0,0 +1,82 @@ +/* + * $Id$ + * + Copyright 2006-2011 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 . + */ + +/* DOS for other platforms than x86? + * If so, the endian should be defined selectively + */ +#define QSE_ENDIAN_LITTLE + +/* + * You must define which character type to use as a default character here. + * + * #define QSE_CHAR_IS_WCHAR + * #define QSE_CHAR_IS_MCHAR + */ + +#if defined(__WATCOMC__) && defined(__386__) +# define QSE_SIZEOF_CHAR 1 +# define QSE_SIZEOF_SHORT 2 +# define QSE_SIZEOF_INT 4 +# define QSE_SIZEOF_LONG 4 +# define QSE_SIZEOF_LONG_LONG 8 +# +# define QSE_SIZEOF_VOID_P 4 +# define QSE_SIZEOF_FLOAT 4 +# define QSE_SIZEOF_DOUBLE 8 +# define QSE_SIZEOF_LONG_DOUBLE 8 +# define QSE_SIZEOF_WCHAR_T 2 +# +# define QSE_SIZEOF___INT8 1 +# define QSE_SIZEOF___INT16 2 +# define QSE_SIZEOF___INT32 4 +# define QSE_SIZEOF___INT64 8 +# define QSE_SIZEOF___INT128 0 +# +# define QSE_SIZEOF_OFF64_T 0 +# define QSE_SIZEOF_OFF_T 4 +# +# define QSE_CHAR_IS_WCHAR +#elif defined(__WATCOMC__) && !defined(__386__) +# define QSE_SIZEOF_CHAR 1 +# define QSE_SIZEOF_SHORT 2 +# define QSE_SIZEOF_INT 2 +# define QSE_SIZEOF_LONG 4 +# define QSE_SIZEOF_LONG_LONG 8 +# +# define QSE_SIZEOF_VOID_P 4 +# define QSE_SIZEOF_FLOAT 4 +# define QSE_SIZEOF_DOUBLE 8 +# define QSE_SIZEOF_LONG_DOUBLE 8 +# define QSE_SIZEOF_WCHAR_T 2 +# +# define QSE_SIZEOF___INT8 1 +# define QSE_SIZEOF___INT16 2 +# define QSE_SIZEOF___INT32 4 +# define QSE_SIZEOF___INT64 8 +# define QSE_SIZEOF___INT128 0 +# +# define QSE_SIZEOF_OFF64_T 0 +# define QSE_SIZEOF_OFF_T 4 +# +# define QSE_CHAR_IS_WCHAR +#else +# error Define the size of various data types. +#endif + diff --git a/qse/include/qse/conf_os2.h b/qse/include/qse/conf_os2.h index 6460fcb4..c9e95388 100644 --- a/qse/include/qse/conf_os2.h +++ b/qse/include/qse/conf_os2.h @@ -1,5 +1,5 @@ /* - * $Id: conf_msw.h 287 2009-09-15 10:01:02Z hyunghwan.chung $ + * $Id$ * Copyright 2006-2011 Chung, Hyung-Hwan. This file is part of QSE. diff --git a/qse/include/qse/types.h b/qse/include/qse/types.h index 9a2549af..0c87f240 100644 --- a/qse/include/qse/types.h +++ b/qse/include/qse/types.h @@ -1,5 +1,5 @@ /* - * $Id: types.h 450 2011-05-03 07:48:42Z hyunghwan.chung $ + * $Id: types.h 451 2011-05-03 14:00:38Z hyunghwan.chung $ * Copyright 2006-2011 Chung, Hyung-Hwan. This file is part of QSE. @@ -36,6 +36,8 @@ # include #elif defined(__OS2__) # include +#elif defined(__DOS__) +# include #elif defined(vms) || defined(__vms) # include #else diff --git a/qse/lib/awk/std.c b/qse/lib/awk/std.c index 63555e09..76cd318f 100644 --- a/qse/lib/awk/std.c +++ b/qse/lib/awk/std.c @@ -1,5 +1,5 @@ /* - * $Id: std.c 447 2011-05-01 13:28:51Z hyunghwan.chung $ + * $Id: std.c 451 2011-05-03 14:00:38Z hyunghwan.chung $ * Copyright 2006-2011 Chung, Hyung-Hwan. This file is part of QSE. @@ -37,7 +37,7 @@ #endif #ifndef QSE_HAVE_CONFIG_H -# if defined(__OS2__) || defined(_WIN32) || defined(__DOS__) +# if defined(_WIN32) || defined(__OS2__) || defined(__DOS__) # define HAVE_POW # define HAVE_SIN # define HAVE_COS diff --git a/qse/lib/cmn/assert.c b/qse/lib/cmn/assert.c index 66a6f8c7..c37d8e79 100644 --- a/qse/lib/cmn/assert.c +++ b/qse/lib/cmn/assert.c @@ -36,6 +36,9 @@ #elif defined(__OS2__) # define INCL_DOSPROCESS # include +#elif defined(__DOS__) +# include +# include #else # include "syscall.h" #endif @@ -86,9 +89,11 @@ void qse_assert_failed ( void *btarray[128]; qse_size_t btsize, i; char **btsyms; + #ifdef QSE_CHAR_IS_WCHAR qse_wchar_t wcs[256]; #endif + #endif qse_sio_puts (QSE_SIO_ERR, QSE_T("=[ASSERTION FAILURE]============================================================\n")); @@ -151,9 +156,16 @@ void qse_assert_failed ( qse_sio_flush (QSE_SIO_ERR); #if defined(_WIN32) - ExitProcess (1); + ExitProcess (249); #elif defined(__OS2__) - DosExit (EXIT_PROCESS, 1); + DosExit (EXIT_PROCESS, 249); +#elif defined(__DOS__) + { + union REGS regs; + regs.h.ah = DOS_EXIT; + regs.h.al = 249; + intdos (®s, ®s); + } #else QSE_KILL (QSE_GETPID(), SIGABRT); QSE_EXIT (1); diff --git a/qse/lib/cmn/chr_cnv.c b/qse/lib/cmn/chr_cnv.c index d4cf1cb0..e8ab646b 100644 --- a/qse/lib/cmn/chr_cnv.c +++ b/qse/lib/cmn/chr_cnv.c @@ -1,5 +1,5 @@ /* - * $Id: chr_cnv.c 441 2011-04-22 14:28:43Z hyunghwan.chung $ + * $Id: chr_cnv.c 451 2011-05-03 14:00:38Z hyunghwan.chung $ * Copyright 2006-2011 Chung, Hyung-Hwan. This file is part of QSE. @@ -22,7 +22,7 @@ #include "mem.h" #if !defined(QSE_HAVE_CONFIG_H) -# if defined(_WIN32) || defined(__OS2__) +# if defined(_WIN32) || defined(__OS2__) || defined(__DOS__) # define HAVE_WCHAR_H # define HAVE_STDLIB_H # define HAVE_MBRLEN diff --git a/qse/lib/cmn/fio.c b/qse/lib/cmn/fio.c index 7e3d7579..a81a0e8c 100644 --- a/qse/lib/cmn/fio.c +++ b/qse/lib/cmn/fio.c @@ -1,5 +1,5 @@ /* - * $Id: fio.c 441 2011-04-22 14:28:43Z hyunghwan.chung $ + * $Id: fio.c 451 2011-05-03 14:00:38Z hyunghwan.chung $ * Copyright 2006-2011 Chung, Hyung-Hwan. This file is part of QSE. @@ -252,6 +252,9 @@ qse_fio_t* qse_fio_init ( if (ret != NO_ERROR) return QSE_NULL; } +#elif defined(__DOS__) + /* UNSUPPORTED */ + return QSE_NULL; #else if (flags & QSE_FIO_HANDLE) @@ -328,6 +331,9 @@ qse_fio_t* qse_fio_init ( CloseHandle (handle); #elif defined(__OS2__) DosClose (handle); + #elif defined(__DOS__) + /* UNSUPPORTED */ + ; #else QSE_CLOSE (handle); #endif @@ -349,6 +355,9 @@ void qse_fio_fini (qse_fio_t* fio) CloseHandle (fio->handle); #elif defined(__OS2__) DosClose (fio->handle); +#elif defined(__DOS__) + /* UNSUPPORTED */ + ; #else QSE_CLOSE (fio->handle); #endif @@ -417,6 +426,11 @@ qse_fio_off_t qse_fio_seek ( if (ret != NO_ERROR) return (qse_fio_off_t)-1; return ((qse_fio_off_t)pos.ulHi << 32) | pos.ulLo; +#elif defined(__DOS__) + + /* UNSUPPORTED */ + return -1; + #else static int seek_map[] = { @@ -468,6 +482,11 @@ int qse_fio_truncate (qse_fio_t* fio, qse_fio_off_t size) ret = DosSetFileSizeL (fio->handle, sz); return (ret == NO_ERROR)? 0: -1; + +#elif defined(__DOS__) + /* UNSUPPORTED */ + return -1; + #else return QSE_FTRUNCATE (fio->handle, size); #endif @@ -485,6 +504,10 @@ static qse_ssize_t fio_read (qse_fio_t* fio, void* buf, qse_size_t size) if (size > QSE_TYPE_MAX(ULONG)) size = QSE_TYPE_MAX(ULONG); if (DosRead (fio->handle, buf, (ULONG)size, &count) != NO_ERROR) return -1; return (qse_ssize_t)count; + +#elif defined(__DOS__) + /* UNSUPPORTED */ + return -1; #else if (size > QSE_TYPE_MAX(size_t)) size = QSE_TYPE_MAX(size_t); return QSE_READ (fio->handle, buf, size); @@ -511,6 +534,10 @@ static qse_ssize_t fio_write (qse_fio_t* fio, const void* data, qse_size_t size) if (size > QSE_TYPE_MAX(ULONG)) size = QSE_TYPE_MAX(ULONG); if (DosWrite(fio->handle, (PVOID)data, (ULONG)size, &count) != NO_ERROR) return -1; return (qse_ssize_t)count; + +#elif defined(__DOS__) + /* UNSUPPORTED */ + return -1; #else if (size > QSE_TYPE_MAX(size_t)) size = QSE_TYPE_MAX(size_t); return QSE_WRITE (fio->handle, data, size); @@ -662,6 +689,10 @@ int qse_fio_chmod (qse_fio_t* fio, int mode) stat.attrFile = flags; return (DosSetFileInfo (fio->handle, FIL_STANDARDL, &stat, size) != NO_ERROR)? -1: 0; + +#elif defined(__DOS__) + /* UNSUPPORTED */ + return -1; #else return QSE_FCHMOD (fio->handle, mode); #endif @@ -673,6 +704,10 @@ int qse_fio_sync (qse_fio_t* fio) return (FlushFileBuffers (fio->handle) == FALSE)? -1: 0; #elif defined(__OS2__) return (DosResetBuffer (fio->handle) == NO_ERROR)? 0: -1; + +#elif defined(__DOS__) + /* UNSUPPORTED */ + return -1; #else return QSE_FSYNC (fio->handle); #endif diff --git a/qse/lib/cmn/misc.c b/qse/lib/cmn/misc.c index 74c9892c..3ab99a14 100644 --- a/qse/lib/cmn/misc.c +++ b/qse/lib/cmn/misc.c @@ -1,5 +1,5 @@ /* - * $Id: misc.c 450 2011-05-03 07:48:42Z hyunghwan.chung $ + * $Id: misc.c 451 2011-05-03 14:00:38Z hyunghwan.chung $ * Copyright 2006-2011 Chung, Hyung-Hwan. This file is part of QSE. @@ -28,7 +28,7 @@ const qse_mchar_t* qse_mbsbasename (const qse_mchar_t* path) for (p = path; *p != QSE_MT('\0'); p++) { if (*p == QSE_MT('/')) last = p; - #if defined(__OS2__) || defined(_WIN32) || defined(__DOS__) + #if defined(_WIN32) || defined(__OS2__) || defined(__DOS__) else if (*p == QSE_MT('\\')) last = p; #endif } @@ -43,7 +43,7 @@ const qse_wchar_t* qse_wcsbasename (const qse_wchar_t* path) for (p = path; *p != QSE_WT('\0'); p++) { if (*p == QSE_WT('/')) last = p; - #if defined(__OS2__) || defined(_WIN32) || defined(__DOS__) + #if defined(_WIN32) || defined(__OS2__) || defined(__DOS__) else if (*p == QSE_WT('\\')) last = p; #endif } diff --git a/qse/watcom/qse.wpj b/qse/watcom/qse.wpj index 3e578a94..e44baa36 100755 --- a/qse/watcom/qse.wpj +++ b/qse/watcom/qse.wpj @@ -16,7 +16,7 @@ MCommand 4 MCommand 0 -14 +15 5 WFileName 30 @@ -74,11 +74,15 @@ WFileName 28 debug/os2/cmd/awk/qseawk.tgt 19 -WVList -14 +WFileName +30 +debug/dos32/lib/cmn/qsecmn.tgt 20 -VComponent +WVList +15 21 +VComponent +22 WRect 410 1880 @@ -86,15 +90,15 @@ WRect 4240 1 0 -22 +23 WFileName 30 release/os2/lib/cmn/qsecmn.tgt 28 29 -23 -VComponent 24 +VComponent +25 WRect 90 1240 @@ -102,15 +106,15 @@ WRect 4240 1 0 -25 +26 WFileName 30 release/os2/lib/sed/qsesed.tgt 0 0 -26 -VComponent 27 +VComponent +28 WRect 2100 1400 @@ -118,15 +122,15 @@ WRect 4240 1 0 -28 +29 WFileName 30 release/os2/cmd/sed/qsesed.tgt 0 1 -29 -VComponent 30 +VComponent +31 WRect 590 1080 @@ -134,31 +138,31 @@ WRect 4240 1 0 -31 +32 WFileName 30 release/os2/lib/scm/qsescm.tgt 0 0 -32 -VComponent 33 +VComponent +34 WRect -380 -0 +3100 +1440 5700 4240 -1 0 -34 +0 +35 WFileName 28 debug/os2/lib/cmn/qsecmn.tgt -29 -32 -35 -VComponent +0 +0 36 +VComponent +37 WRect 1050 2360 @@ -166,15 +170,15 @@ WRect 4240 1 0 -37 +38 WFileName 28 debug/os2/lib/sed/qsesed.tgt 0 5 -38 -VComponent 39 +VComponent +40 WRect 2360 1280 @@ -182,15 +186,15 @@ WRect 4240 1 0 -40 +41 WFileName 28 debug/os2/lib/scm/qsescm.tgt 0 0 -41 -VComponent 42 +VComponent +43 WRect 2460 2400 @@ -198,15 +202,15 @@ WRect 4240 1 0 -43 +44 WFileName 28 debug/os2/cmd/scm/qsescm.tgt 0 1 -44 -VComponent 45 +VComponent +46 WRect 980 1080 @@ -214,15 +218,15 @@ WRect 4240 1 0 -46 +47 WFileName 30 debug/win32/lib/cmn/qsecmn.tgt 29 30 -47 -VComponent 48 +VComponent +49 WRect 200 1240 @@ -230,15 +234,15 @@ WRect 4240 1 0 -49 +50 WFileName 30 debug/win32/lib/scm/qsescm.tgt 0 0 -50 -VComponent 51 +VComponent +52 WRect 3280 40 @@ -246,15 +250,15 @@ WRect 4240 1 0 -52 +53 WFileName 30 debug/win32/cmd/scm/qsescm.tgt 0 0 -53 -VComponent 54 +VComponent +55 WRect 240 80 @@ -262,15 +266,15 @@ WRect 4240 0 0 -55 +56 WFileName 28 debug/os2/lib/awk/qseawk.tgt 8 12 -56 -VComponent 57 +VComponent +58 WRect 830 2720 @@ -278,15 +282,15 @@ WRect 4240 1 0 -58 +59 WFileName 30 debug/win32/lib/awk/qseawk.tgt 8 9 -59 -VComponent 60 +VComponent +61 WRect 2920 880 @@ -294,10 +298,26 @@ WRect 4240 0 0 -61 +62 WFileName 28 debug/os2/cmd/awk/qseawk.tgt 0 1 -59 +63 +VComponent +64 +WRect +430 +2480 +5700 +4240 +0 +0 +65 +WFileName +30 +debug/dos32/lib/cmn/qsecmn.tgt +0 +3 +63