added some DOS stuffs

This commit is contained in:
2011-05-04 08:00:38 +00:00
parent fd0b3f9abd
commit 574f373cf0
11 changed files with 222 additions and 67 deletions

View File

@ -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

View File

@ -36,6 +36,9 @@
#elif defined(__OS2__)
# define INCL_DOSPROCESS
# include <os2.h>
#elif defined(__DOS__)
# include <dos.h>
# include <dosfunc.h>
#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 (&regs, &regs);
}
#else
QSE_KILL (QSE_GETPID(), SIGABRT);
QSE_EXIT (1);

View File

@ -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

View File

@ -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

View File

@ -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
}