modified code for the first successful dos/4gw build omitting unsupported features

This commit is contained in:
2011-05-10 10:11:13 +00:00
parent fab23e8575
commit 3ae34f8acc
24 changed files with 1295 additions and 381 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: pio.c 454 2011-05-06 15:28:27Z hyunghwan.chung $
* $Id: pio.c 455 2011-05-09 16:11:13Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -105,8 +105,8 @@ qse_pio_t* qse_pio_init (
qse_char_t* dup = QSE_NULL;
HANDLE windevnul = INVALID_HANDLE_VALUE;
BOOL x;
#elif defined(__OS2__)
/* TODO: implmenet this for os/2 */
APIRET rc;
ULONG pipe_size = 4096;
UCHAR load_error[CCHMAXPATH];
@ -118,8 +118,11 @@ qse_pio_t* qse_pio_init (
qse_mchar_t* cmd_line = QSE_NULL;
qse_mchar_t* cmd_file;
HFILE os2devnul = (HFILE)-1;
#elif defined(__DOS__)
# error UNSUPPORTED
/* TODO: implmenet this for dos
unsupported yet */
#else
qse_pio_pid_t pid;
#endif
@ -527,7 +530,11 @@ qse_pio_t* qse_pio_init (
if (rc != NO_ERROR) goto oops;
pio->child = child_rc.codeTerminate;
#elif defined(__DOS__)
/* TODO: implement this */
#else
if (oflags & QSE_PIO_WRITEIN)
@ -854,9 +861,11 @@ qse_pio_t* qse_pio_init (
return pio;
oops:
#if defined(_WIN32)
if (windevnul != INVALID_HANDLE_VALUE) CloseHandle (windevnul);
if (dup) QSE_MMGR_FREE (mmgr, dup);
#elif defined(__OS2__)
if (cmd_line) QSE_MMGR_FREE (mmgr, cmd_line);
if (old_in != QSE_PIO_HND_NIL)
@ -889,6 +898,11 @@ oops:
{
if (handle[i] != QSE_PIO_HND_NIL) DosClose (handle[i]);
}
#elif defined(__DOS__)
for (i = minidx; i < maxidx; i++)
{
if (handle[i] != QSE_PIO_HND_NIL) close (handle[i]);
}
#else
for (i = minidx; i < maxidx; i++)
{
@ -962,6 +976,8 @@ static qse_ssize_t pio_read (
#elif defined(__OS2__)
ULONG count;
APIRET rc;
#elif defined(__DOS__)
int n;
#else
qse_ssize_t n;
#endif
@ -984,6 +1000,7 @@ static qse_ssize_t pio_read (
return -1;
}
return (qse_ssize_t)count;
#elif defined(__OS2__)
if (size > QSE_TYPE_MAX(ULONG)) size = QSE_TYPE_MAX(ULONG);
rc = DosRead (hnd, buf, (ULONG)size, &count);
@ -994,6 +1011,16 @@ static qse_ssize_t pio_read (
return -1;
}
return (qse_ssize_t)count;
#elif defined(__DOS__)
/* TODO: verify this */
if (size > QSE_TYPE_MAX(unsigned int))
size = QSE_TYPE_MAX(unsigned int);
n = read (hnd, buf, size);
if (n == -1) pio->errnum = QSE_PIO_ESUBSYS;
return n;
#else
if (size > QSE_TYPE_MAX(size_t)) size = QSE_TYPE_MAX(size_t);
@ -1039,6 +1066,8 @@ static qse_ssize_t pio_write (
#elif defined(__OS2__)
ULONG count;
APIRET rc;
#elif defined(__DOS__)
int n;
#else
qse_ssize_t n;
#endif
@ -1073,6 +1102,14 @@ static qse_ssize_t pio_write (
}
return (qse_ssize_t)count;
#elif defined(__DOS__)
if (size > QSE_TYPE_MAX(unsigned int))
size = QSE_TYPE_MAX(unsigned int);
n = write (hnd, data, size);
if (n == -1) pio->errnum = QSE_PIO_ESUBSYS;
return n;
#else
if (size > QSE_TYPE_MAX(size_t)) size = QSE_TYPE_MAX(size_t);
@ -1131,6 +1168,8 @@ void qse_pio_end (qse_pio_t* pio, qse_pio_hid_t hid)
CloseHandle (pio->pin[hid].handle);
#elif defined(__OS2__)
DosClose (pio->pin[hid].handle);
#elif defined(__DOS__)
close (pio->pin[hid].handle);
#else
QSE_CLOSE (pio->pin[hid].handle);
#endif
@ -1231,6 +1270,10 @@ int qse_pio_wait (qse_pio_t* pio)
return (child_rc.codeTerminate == TC_EXIT)?
child_rc.codeResult: (255 + 1 + child_rc.codeTerminate);
#elif defined(__DOS__)
/* TOOD: implement this */
return -1;
#else
int opt = 0;
@ -1315,6 +1358,8 @@ int qse_pio_kill (qse_pio_t* pio)
DWORD n;
#elif defined(__OS2__)
APIRET rc;
#elif defined(__DOS__)
/* TODO: implement this */
#else
int n;
#endif
@ -1334,6 +1379,7 @@ int qse_pio_kill (qse_pio_t* pio)
return -1;
}
return 0;
#elif defined(__OS2__)
/*TODO: must use DKP_PROCESS? */
rc = DosKillProcess (pio->child, DKP_PROCESSTREE);
@ -1343,6 +1389,11 @@ int qse_pio_kill (qse_pio_t* pio)
return -1;
}
return 0;
#elif defined(__DOS__)
/* TODO: implement this*/
return -1;
#else
n = QSE_KILL (pio->child, SIGKILL);
if (n <= -1) pio->errnum = QSE_PIO_ESUBSYS;

View File

@ -339,7 +339,7 @@ QSE_FILE* qse_fopen (const qse_char_t* path, const qse_char_t* mode)
{
#if defined(QSE_CHAR_IS_MCHAR)
return fopen (path, mode);
#elif defined(_WIN32)
#elif defined(_WIN32) || defined(__OS2__)
return _wfopen (path, mode);
#else
@ -362,13 +362,21 @@ QSE_FILE* qse_fopen (const qse_char_t* path, const qse_char_t* mode)
QSE_FILE* qse_popen (const qse_char_t* cmd, const qse_char_t* mode)
{
#if defined(QSE_CHAR_IS_MCHAR)
#if defined(__OS2__)
#if defined(__OS2__)
return _popen (cmd, mode);
#else
#elif defined(__DOS__)
return QSE_NULL;
#else
return popen (cmd, mode);
#endif
#elif defined(_WIN32) || defined(__OS2__)
#endif
#elif defined(_WIN32) || defined(__OS2__)
return _wpopen (cmd, mode);
#elif defined(__DOS__)
return QSE_NULL;
#else
char cmd_mb[PATH_MAX + 1];
char mode_mb[32];

View File

@ -1,5 +1,5 @@
/*
* $Id: time.c 441 2011-04-22 14:28:43Z hyunghwan.chung $
* $Id: time.c 455 2011-05-09 16:11:13Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -27,6 +27,8 @@
# define INCL_DOSDATETIME
# define INCL_DOSERRORS
# include <os2.h>
#elif defined(__DOS__)
# include <dos.h>
#else
# include "syscall.h"
# include <sys/time.h>
@ -119,6 +121,27 @@ int qse_gettime (qse_ntime_t* t)
if (qse_timelocal (&bt, t) <= -1) return -1;
return 0;
#elif defined(__DOS__)
struct dostime_t dt;
struct dosdate_t dd;
qse_btime_t bt;
_dos_gettime (&dt);
_dos_getdate (&dd);
bt.year = dd.year - 1900;
bt.mon = dd.month - 1;
bt.mday = dd.day;
bt.hour = dt.hour;
bt.min = dt.minute;
bt.sec = dt.second;
bt.msec = dt.hsecond * 10;
bt.isdst = -1;
if (qse_timelocal (&bt, t) <= -1) return -1;
return 0;
#else
struct timeval tv;
int n;
@ -142,6 +165,7 @@ int qse_settime (qse_ntime_t t)
if (FileTimeToSystemTime (&ft, &st) == FALSE) return -1;
if (SetSystemTime(&st) == FALSE) return -1;
return 0;
#elif defined(__OS2__)
APIRET rc;
@ -161,6 +185,28 @@ int qse_settime (qse_ntime_t t)
rc = DosSetDateTime (&dt);
return (rc != NO_ERROR)? -1: 0;
#elif defined(__DOS__)
struct dostime_t dt;
struct dosdate_t dd;
qse_btime_t bt;
if (qse_localtime (t, &bt) <= -1) return -1;
dd.year = bt.year + 1900;
dd.month = bt.mon + 1;
dd.day = bt.mday;
dt.hour = bt.hour;
dt.minute = bt.min;
dt.second = bt.sec;
dt.hsecond = bt.msec / 10;
if (_dos_settime (&dt) != 0) return -1;
if (_dos_setdate (&dd) != 0) return -1;
return 0;
#else
struct timeval tv;
int n;
@ -275,6 +321,13 @@ int qse_localtime (qse_ntime_t nt, qse_btime_t* bt)
# else
# error Please support other compilers that I didn't try.
# endif
#elif defined(__DOS__)
# if defined(__WATCOMC__)
struct tm btm;
tm = _localtime (&t, &btm);
# else
# error Please support other compilers that I didn't try.
# endif
#else
struct tm btm;
tm = localtime_r (&t, &btm);
@ -322,6 +375,8 @@ int qse_timegm (const qse_btime_t* bt, qse_ntime_t* nt)
return 0;
#elif defined(__OS2__)
# error NOT IMPLEMENTED YET
#elif defined(__DOS__)
# error NOT IMPLEMENTED YET
#else
/* TODO: qse_timegm - remove dependency on timegm */