From 5f9ac5eeab62e58063c2a760f6d5fdd2513b476f Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Wed, 6 Nov 2019 10:19:07 +0100 Subject: [PATCH] Remove code ifdefed for OS/2 Cleanup before replacing SDL1.2 with SDL2. OS/2 support was introduced in DOSBox in March 2006. OS/2 reached EOL in December 2006. As of 2019, OS/2 is being continued by proprietary 32-bit only ArcaOS, although there is no official SDL2 support, despite pledges from SDL2 maintainers. --- README | 2 +- configure.ac | 29 +--- include/cross.h | 2 +- src/dos/Makefile.am | 2 +- src/dos/cdrom.cpp | 2 +- src/dos/cdrom.h | 2 +- src/dos/cdrom_image.cpp | 6 +- src/dos/cdrom_ioctl_os2.cpp | 152 ----------------- src/dos/dos_mscdex.cpp | 4 +- src/dos/dos_programs.cpp | 47 +----- src/dos/drive_cache.cpp | 28 +--- src/dos/drive_overlay.cpp | 7 +- src/gui/sdl_mapper.cpp | 21 +-- src/gui/sdlmain.cpp | 13 -- src/hardware/serialport/libserial.cpp | 229 -------------------------- src/hardware/serialport/misc_util.cpp | 4 - src/hardware/serialport/misc_util.h | 2 +- src/misc/cross.cpp | 4 +- src/shell/shell.cpp | 2 +- 19 files changed, 29 insertions(+), 529 deletions(-) delete mode 100644 src/dos/cdrom_ioctl_os2.cpp diff --git a/README b/README index 5323229f..eb49726f 100644 --- a/README +++ b/README @@ -459,7 +459,7 @@ Note: If a name/command/configfilelocation/languagefilelocation contains a space, put the whole name/command/configfilelocation/languagefilelocation between quotes ("command or file name"). If you need to use quotes within quotes (most likely with -c and mount): - Windows and OS/2 users can use single quotes inside the double quotes. + Windows users can use single quotes inside the double quotes. Other people should be able to use escaped double quotes inside the double quotes. Windows: -c "mount c 'c:\My folder with DOS games\'" diff --git a/configure.ac b/configure.ac index 06fe76b2..adb1ab7f 100644 --- a/configure.ac +++ b/configure.ac @@ -20,13 +20,6 @@ AC_PROG_CXX AC_PROG_INSTALL AC_PROG_RANLIB -dnl Some needed libaries for OS2 -dnl perharps join this with the other target depended checks. move them upwards -if test x$host = xi386-pc-os2-emx ; then - CXXFLAGS="$CXXFLAGS -Zmt" - LDFLAGS="$LDFLAGS -Zomf -Zmt" -fi - dnl Check for SDL SDL_VERSION=1.2.0 AM_PATH_SDL($SDL_VERSION, @@ -463,17 +456,7 @@ AH_TEMPLATE(C_MODEM,[Define to 1 to enable internal modem support, requires SDL_ AH_TEMPLATE(C_IPX,[Define to 1 to enable IPX over Internet networking, requires SDL_net]) AC_CHECK_HEADER(SDL_net.h,have_sdl_net_h=yes,) -if test x$host = xi386-pc-os2-emx ; then - AC_MSG_CHECKING(for SDLNet_Init in SDL_net); - LIBS_BACKUP=$LIBS; - LIBS="$LIBS -lSDL_Net"; - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]],[[ - SDLNet_Init (); - ]])], [AC_MSG_RESULT(yes); have_sdl_net_lib=yes], AC_MSG_RESULT(no)) - LIBS=$LIBS_BACKUP -else AC_CHECK_LIB(SDL_net, SDLNet_Init, have_sdl_net_lib=yes, , ) -fi if test x$have_sdl_net_lib = xyes -a x$have_sdl_net_h = xyes ; then LIBS="$LIBS -lSDL_net" AC_DEFINE(C_MODEM,1) @@ -576,7 +559,7 @@ case "$host" in LIBS="$LIBS -lwinmm" AC_DEFINE(WIN32, 1, [Compiling on Windows]) AC_DEFINE(NOMINMAX, 1, [Prevent from clobbering std::min and std::max]) - AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2 only).]) + AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32 and Posix).]) if test x$have_sdl_net_lib = xyes -a x$have_sdl_net_h = xyes ; then LIBS="$LIBS -lws2_32" fi @@ -587,11 +570,11 @@ case "$host" in dnl to do more to distinguish them. dnl For now I am lazy and do not add proper detection code. AC_DEFINE(MACOSX, 1, [Compiling on Mac OS X]) - AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2).]) + AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32 and Posix).]) ;; *-*-linux*) AC_DEFINE(LINUX, 1, [Compiling on GNU/Linux]) - AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2).]) + AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32 and Posix).]) ;; *-*-freebsd* | *-*-dragonfly* | *-*-netbsd* | *-*-openbsd*) dnl Disabled directserial for now. It doesn't do anything without @@ -600,11 +583,7 @@ case "$host" in dnl functions and headers. I currently do not know dnl which ones are needed for BSD AC_DEFINE(BSD, 1, [Compiling on BSD]) - AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2).]) - ;; - *-*-os2-emx*) - AC_DEFINE(OS2, 1, [Compiling on OS/2 EMX]) - AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2).]) + AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32 and Posix).]) ;; esac diff --git a/include/cross.h b/include/cross.h index 90b65315..5699cd40 100644 --- a/include/cross.h +++ b/include/cross.h @@ -44,7 +44,7 @@ #define CROSS_LEN 512 /* Maximum filename size */ -#if defined (WIN32) || defined (OS2) /* Win 32 & OS/2*/ +#if defined (WIN32) #define CROSS_FILENAME(blah) #define CROSS_FILESPLIT '\\' #define F_OK 0 diff --git a/src/dos/Makefile.am b/src/dos/Makefile.am index 36a2d99b..bb538d46 100644 --- a/src/dos/Makefile.am +++ b/src/dos/Makefile.am @@ -7,4 +7,4 @@ libdos_a_SOURCES = dos.cpp dos_devices.cpp dos_execute.cpp dos_files.cpp dos_ioc drives.cpp drives.h drive_virtual.cpp drive_local.cpp drive_cache.cpp drive_fat.cpp \ drive_iso.cpp dev_con.h dos_mscdex.cpp dos_keyboard_layout.cpp \ cdrom.h cdrom.cpp cdrom_ioctl_win32.cpp cdrom_aspi_win32.cpp cdrom_ioctl_linux.cpp cdrom_image.cpp \ - cdrom_ioctl_os2.cpp drive_overlay.cpp + drive_overlay.cpp diff --git a/src/dos/cdrom.cpp b/src/dos/cdrom.cpp index 76847af5..826bbadd 100644 --- a/src/dos/cdrom.cpp +++ b/src/dos/cdrom.cpp @@ -153,7 +153,7 @@ int CDROM_GetMountType(char* path, int forceCD) { const char* cdName; char buffer[512]; strcpy(buffer,path); -#if defined (WIN32) || defined(OS2) +#if defined (WIN32) upcase(buffer); #endif diff --git a/src/dos/cdrom.h b/src/dos/cdrom.h index d2cddac2..75df0654 100644 --- a/src/dos/cdrom.h +++ b/src/dos/cdrom.h @@ -415,7 +415,7 @@ private: #endif /* WIN 32 */ -#if defined (LINUX) || defined(OS2) +#if defined (LINUX) class CDROM_Interface_Ioctl : public CDROM_Interface_SDL { diff --git a/src/dos/cdrom_image.cpp b/src/dos/cdrom_image.cpp index 4bf4b3c7..6c9c147c 100644 --- a/src/dos/cdrom_image.cpp +++ b/src/dos/cdrom_image.cpp @@ -1159,9 +1159,8 @@ bool CDROM_Interface_Image::GetRealFileName(string &filename, string &pathname) return true; } } -#if defined (WIN32) || defined(OS2) - //Nothing -#else + +#if !defined (WIN32) //Consider the possibility that the filename has a windows directory seperator (inside the CUE file) //which is common for some commercial rereleases of DOS games using DOSBox @@ -1181,7 +1180,6 @@ bool CDROM_Interface_Image::GetRealFileName(string &filename, string &pathname) filename = tmpstr; return true; } - #endif return false; } diff --git a/src/dos/cdrom_ioctl_os2.cpp b/src/dos/cdrom_ioctl_os2.cpp deleted file mode 100644 index 926a85a3..00000000 --- a/src/dos/cdrom_ioctl_os2.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2002-2019 The DOSBox Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include -#include "dosbox.h" -#include "cdrom.h" - -#if defined (OS2) -#define INCL_DOSFILEMGR -#define INCL_DOSERRORS -#define INCL_DOSDEVICES -#define INCL_DOSDEVIOCTL -#include "os2.h" - -// Ripped from linux/cdrom.h -#define CD_FRAMESIZE_RAW 2352 -#define CD_FRAMESIZE 2048 - -CDROM_Interface_Ioctl::CDROM_Interface_Ioctl(void) : CDROM_Interface_SDL(){ - strcpy(device_name, ""); -} - -bool CDROM_Interface_Ioctl::GetUPC(unsigned char& attr, char* upc){ - HFILE cdrom_fd = 0; - ULONG ulAction = 0; - APIRET rc = DosOpen((unsigned char*)device_name, &cdrom_fd, &ulAction, 0L, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, - OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L); - if (rc != NO_ERROR) { - return false; - } - char data[50]; - ULONG len = sizeof(data); - char sig[] = {'C', 'D', '0', '1'}; - ULONG sigsize = 4; - rc = DosDevIOCtl(cdrom_fd, IOCTL_CDROMDISK, CDROMDISK_GETUPC, sig, sigsize, &sigsize, - data, len, &len); - if (rc != NO_ERROR) { - return false; - } - rc = DosClose(cdrom_fd); - return rc == NO_ERROR; -} - -bool CDROM_Interface_Ioctl::ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num){ - HFILE cdrom_fd = 0; - ULONG ulAction = 0; - APIRET rc = DosOpen((unsigned char*)device_name, &cdrom_fd, &ulAction, 0L, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, - OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L); - if (rc != NO_ERROR) { - return false; - } - - Bitu buflen = raw ? num * CD_FRAMESIZE_RAW : num * CD_FRAMESIZE; - Bit8u* buf = new Bit8u[buflen]; - int ret = NO_ERROR; - - if (raw) { - struct paramseek { - UCHAR sig[4]; - UCHAR mode; - ULONG sec; - - paramseek(ULONG sector) - { - sig[0] = 'C'; sig[1] = 'D'; sig[2] = '0'; sig[3] = '1'; - sec = sector; - } - } param_seek(sector); - ULONG paramsize = sizeof (paramseek); - rc = DosDevIOCtl(cdrom_fd, IOCTL_CDROMDISK, CDROMDISK_SEEK, ¶m_seek, paramsize, ¶msize, - 0, 0, 0); - if (rc != NO_ERROR) { - return false; - } - - struct paramread { - UCHAR sig[4]; - UCHAR mode; - USHORT number; - BYTE sec; - BYTE reserved; - BYTE interleave; - - paramread(USHORT num) - { - sig[0] = 'C'; sig[1] = 'D'; sig[2] = '0'; sig[3] = '1'; - mode = 0; number = num; - sec = interleave = 0; - } - } param_read(num); - paramsize = sizeof (paramread); - ULONG len = buflen; - rc = DosDevIOCtl(cdrom_fd, IOCTL_CDROMDISK, CDROMDISK_READLONG, ¶m_read, paramsize, ¶msize, - buf, len, &len); - if (rc != NO_ERROR) { - return false; - } - } else { - ULONG pos = 0; - rc = DosSetFilePtr(cdrom_fd, sector * CD_FRAMESIZE, FILE_BEGIN, &pos); - if (rc != NO_ERROR) { - return false; - } - ULONG read = 0; - rc = DosRead(cdrom_fd, buf, buflen, &read); - if (rc != NO_ERROR || read != buflen) { - return false; - } - } - rc = DosClose(cdrom_fd); - MEM_BlockWrite(buffer, buf, buflen); - delete[] buf; - - return (ret == NO_ERROR); -} - -bool CDROM_Interface_Ioctl::SetDevice(char* path, int forceCD) { - bool success = CDROM_Interface_SDL::SetDevice(path, forceCD); - - if (success) { - char temp[3] = {0, 0, 0}; - if (path[1] == ':') { - temp[0] = path[0]; - temp[1] = path[1]; - temp[2] = 0; - } - strncpy(device_name, temp, 512); - } else { - strcpy(device_name, ""); - success = false; - } - - return success; -} - -#endif diff --git a/src/dos/dos_mscdex.cpp b/src/dos/dos_mscdex.cpp index 027a0a2e..43af4b4a 100644 --- a/src/dos/dos_mscdex.cpp +++ b/src/dos/dos_mscdex.cpp @@ -285,8 +285,8 @@ int CMscdex::AddDrive(Bit16u _drive, char* physicalPath, Bit8u& subUnit) break; } #endif -#if defined (LINUX) || defined(OS2) - // Always use IOCTL in Linux or OS/2 +#if defined (LINUX) + // Always use IOCTL in Linux cdrom[numDrives] = new CDROM_Interface_Ioctl(); LOG(LOG_MISC,LOG_NORMAL)("MSCDEX: IOCTL Interface."); #else diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index e373dd14..2c7e0bf4 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -40,11 +40,6 @@ #include "dma.h" -#if defined(OS2) -#define INCL DOSFILEMGR -#define INCL_DOSERRORS -#include "os2.h" -#endif #if defined(WIN32) #ifndef S_ISDIR @@ -302,35 +297,12 @@ public: } struct stat test; //Win32 : strip tailing backslashes - //os2: some special drive check //rest: substitute ~ for home bool failed = false; -#if defined (WIN32) || defined(OS2) +#if defined (WIN32) /* Removing trailing backslash if not root dir so stat will succeed */ if(temp_line.size() > 3 && temp_line[temp_line.size()-1]=='\\') temp_line.erase(temp_line.size()-1,1); if (stat(temp_line.c_str(),&test)) { -#endif -#if defined(WIN32) -// Nothing to do here. -#elif defined (OS2) - if (temp_line.size() <= 2) // Seems to be a drive. - { - failed = true; - HFILE cdrom_fd = 0; - ULONG ulAction = 0; - - APIRET rc = DosOpen((unsigned char*)temp_line.c_str(), &cdrom_fd, &ulAction, 0L, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, - OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L); - DosClose(cdrom_fd); - if (rc != NO_ERROR && rc != ERROR_NOT_READY) - { - failed = true; - } else { - failed = false; - } - } - } - if (failed) { #else if (stat(temp_line.c_str(),&test)) { failed = true; @@ -345,22 +317,9 @@ public: } /* Not a switch so a normal directory/file */ if (!S_ISDIR(test.st_mode)) { -#ifdef OS2 - HFILE cdrom_fd = 0; - ULONG ulAction = 0; - - APIRET rc = DosOpen((unsigned char*)temp_line.c_str(), &cdrom_fd, &ulAction, 0L, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, - OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L); - DosClose(cdrom_fd); - if (rc != NO_ERROR && rc != ERROR_NOT_READY) { WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_2"),temp_line.c_str()); return; } -#else - WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_2"),temp_line.c_str()); - return; -#endif - } if (temp_line[temp_line.size()-1]!=CROSS_FILESPLIT) temp_line+=CROSS_FILESPLIT; Bit8u bit8size=(Bit8u) sizes[1]; @@ -413,7 +372,7 @@ public: } } else { /* Give a warning when mount c:\ or the / */ -#if defined (WIN32) || defined(OS2) +#if defined (WIN32) if( (temp_line == "c:\\") || (temp_line == "C:\\") || (temp_line == "c:/") || (temp_line == "C:/") ) WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_WIN")); @@ -484,7 +443,7 @@ public: if(type == "floppy") incrementFDD(); return; showusage: -#if defined (WIN32) || defined(OS2) +#if defined (WIN32) WriteOut(MSG_Get("PROGRAM_MOUNT_USAGE"),"d:\\dosprogs","d:\\dosprogs"); #else WriteOut(MSG_Get("PROGRAM_MOUNT_USAGE"),"~/dosprogs","~/dosprogs"); diff --git a/src/dos/drive_cache.cpp b/src/dos/drive_cache.cpp index 9dbe1215..fd11f142 100644 --- a/src/dos/drive_cache.cpp +++ b/src/dos/drive_cache.cpp @@ -33,11 +33,6 @@ #include #endif -#if defined (OS2) -#define INCL_DOSERRORS -#define INCL_DOSFILEMGR -#include -#endif int fileInfoCounter = 0; @@ -159,25 +154,14 @@ void DOS_Drive_Cache::SetBaseDir(const char* baseDir) { ReadDir(id,result); }; // Get Volume Label -#if defined (WIN32) || defined (OS2) +#if defined (WIN32) bool cdrom = false; char labellocal[256]={ 0 }; char drive[4] = "C:\\"; drive[0] = basePath[0]; -#if defined (WIN32) if (GetVolumeInformation(drive,labellocal,256,NULL,NULL,NULL,NULL,0)) { UINT test = GetDriveType(drive); if(test == DRIVE_CDROM) cdrom = true; -#else // OS2 - //TODO determine wether cdrom or not! - FSINFO fsinfo; - ULONG drivenumber = drive[0]; - if (drivenumber > 26) { // drive letter was lowercase - drivenumber = drive[0] - 'a' + 1; - } - APIRET rc = DosQueryFSInfo(drivenumber, FSIL_VOLSER, &fsinfo, sizeof(FSINFO)); - if (rc == NO_ERROR) { -#endif /* Set label and allow being updated */ SetLabel(labellocal,cdrom,true); } @@ -209,12 +193,11 @@ char* DOS_Drive_Cache::GetExpandName(const char* path) { if (*work) { size_t len = strlen(work); -#if defined (WIN32) - //What about OS/2 +#if defined (WIN32) if((work[len-1] == CROSS_FILESPLIT ) && (len >= 2) && (work[len-2] != ':')) { #else if((len > 1) && (work[len-1] == CROSS_FILESPLIT )) { -#endif +#endif work[len-1] = 0; // Remove trailing slashes except when in root } } @@ -263,8 +246,7 @@ void DOS_Drive_Cache::AddEntryDirOverlay(const char* path, bool checkExists) { char* post = strrchr(dironly,CROSS_FILESPLIT); if (post) { -#if defined (WIN32) - //OS2 ? +#if defined (WIN32) if (post > dironly && *(post - 1) == ':' && (post - dironly) == 2) post++; //move away from X: as need to end up with x:\ . #else @@ -392,7 +374,7 @@ bool DOS_Drive_Cache::GetShortName(const char* fullname, char* shortname) { // The orgname part of the list is not sorted (shortname is)! So we can only walk through it. for(Bitu i = 0; i < filelist_size; i++) { -#if defined (WIN32) || defined (OS2) /* Win 32 & OS/2*/ +#if defined (WIN32) if (strcasecmp(pos,curDir->longNameList[i]->orgname) == 0) { #else if (strcmp(pos,curDir->longNameList[i]->orgname) == 0) { diff --git a/src/dos/drive_overlay.cpp b/src/dos/drive_overlay.cpp index 0da3d9e2..c146fb28 100644 --- a/src/dos/drive_overlay.cpp +++ b/src/dos/drive_overlay.cpp @@ -37,10 +37,10 @@ bool logoverlay = false; using namespace std; -#if defined (WIN32) || defined (OS2) /* Win 32 & OS/2*/ -#define CROSS_DOSFILENAME(blah) +#if defined (WIN32) +#define CROSS_DOSFILENAME(blah) #else -//Convert back to DOS PATH +//Convert back to DOS PATH #define CROSS_DOSFILENAME(blah) strreplace(blah,'/','\\') #endif @@ -345,7 +345,6 @@ void Overlay_Drive::convert_overlay_to_DOSname_in_base(char* dirname ) if (strlen(overlaydir) >= strlen(basedir) ) { //Needs to be longer at least. #if defined (WIN32) -//OS2 ? if (strncasecmp(overlaydir,basedir,strlen(basedir)) == 0) { #else if (strncmp(overlaydir,basedir,strlen(basedir)) == 0) { diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index 471777ca..821b6a85 100644 --- a/src/gui/sdl_mapper.cpp +++ b/src/gui/sdl_mapper.cpp @@ -433,7 +433,7 @@ Bitu GetKeyCode(SDL_keysym keysym) { /* try to retrieve key from symbolic key as scancode is zero */ if (keysym.sym Linux & BSDs */ bool evdev_input = false; #ifdef SDL_VIDEO_DRIVER_X11 diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 34ca3f57..d39a10a4 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -121,11 +121,6 @@ struct private_hwdata { #define PRIO_TOTAL (PRIO_MAX-PRIO_MIN) #endif -#ifdef OS2 -#define INCL_DOS -#define INCL_WIN -#include -#endif enum SCREEN_TYPES { SCREEN_SURFACE, @@ -2038,14 +2033,6 @@ int main(int argc, char* argv[]) { SetConsoleCtrlHandler((PHANDLER_ROUTINE) ConsoleEventHandler,TRUE); #endif -#ifdef OS2 - PPIB pib; - PTIB tib; - DosGetInfoBlocks(&tib, &pib); - if (pib->pib_ultype == 2) pib->pib_ultype = 3; - setbuf(stdout, NULL); - setbuf(stderr, NULL); -#endif /* Display Welcometext in the console */ LOG_MSG("DOSBox version %s",VERSION); diff --git a/src/hardware/serialport/libserial.cpp b/src/hardware/serialport/libserial.cpp index b7f524f2..4b487475 100644 --- a/src/hardware/serialport/libserial.cpp +++ b/src/hardware/serialport/libserial.cpp @@ -478,232 +478,3 @@ void SERIAL_setRTS(COMPORT port, bool value) { } #endif -#ifdef OS2 -// OS/2 related headers -#define INCL_DOSFILEMGR -#define INCL_DOSERRORS -#define INCL_DOSDEVICES -#define INCL_DOSDEVIOCTL -#define INCL_DOSPROCESS -#include -#include -#include -#include - -struct _COMPORT { - HFILE porthandle; - DCBINFO orig_dcb; -}; -// TODO: THIS IS INCOMPLETE and UNTESTED. - -bool SERIAL_open(const char* portname, COMPORT* port) { - // allocate COMPORT structure - COMPORT cp = (_COMPORT*)malloc(sizeof(_COMPORT)); - if(cp == NULL) return false; - cp->porthandle=0; - - USHORT errors = 0; - ULONG ulAction = 0; - ULONG ulParmLen = sizeof(DCBINFO); - APIRET rc = DosOpen((PSZ)portname, &cp->porthandle, - &ulAction, 0L, FILE_NORMAL, FILE_OPEN, - OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | OPEN_FLAGS_SEQUENTIAL, 0L); - if (rc != NO_ERROR) { - goto cleanup_error; - } - - rc = DosDevIOCtl(cp->porthandle, IOCTL_ASYNC, ASYNC_GETDCBINFO, - 0, 0, 0, &cp->orig_dcb, ulParmLen, &ulParmLen); - if ( rc != NO_ERROR) { - goto cleanup_error; - } - // configure the port for polling - DCBINFO newdcb; - memcpy(&newdcb,&cp->orig_dcb,sizeof(DCBINFO)); - - newdcb.usWriteTimeout = 0; - newdcb.usReadTimeout = 0; //65535; - newdcb.fbCtlHndShake = cp->orig_dcb.fbFlowReplace = 0; - newdcb.fbTimeout = 6; - - rc = DosDevIOCtl(cp->porthandle, IOCTL_ASYNC, ASYNC_SETDCBINFO, - &newdcb, ulParmLen, &ulParmLen, 0, 0, 0); - if ( rc != NO_ERROR) { - goto cleanup_error; - } - - ulParmLen = sizeof(errors); - rc = DosDevIOCtl(cp->porthandle, IOCTL_ASYNC, ASYNC_GETCOMMERROR, - 0, 0, 0, &errors, ulParmLen, &ulParmLen); - if ( rc != NO_ERROR) { - goto cleanup_error; - } - - *port = cp; - return true; - -cleanup_error: - // TODO error string - rc value - if (cp->porthandle != 0) DosClose(cp->porthandle); - free(cp); - return false; -} - -void SERIAL_getErrorString(char* buffer, size_t length) { - sprintf(buffer, "TODO: error handling is not fun"); -} -void SERIAL_close(COMPORT port) { - ULONG ulParmLen = sizeof(DCBINFO); - // restore original DCB, close handle, free the COMPORT struct - if (port->porthandle != 0) { - DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_SETDCBINFO, - &port->orig_dcb, ulParmLen, &ulParmLen, 0, 0, 0); - DosClose (port->porthandle); - } - free(port); -} -bool SERIAL_sendchar(COMPORT port, char data) { - ULONG bytesWritten = 0; - - APIRET rc = DosWrite(port->porthandle, &data, 1, &bytesWritten); - if (rc == NO_ERROR && bytesWritten > 0) return true; - else return false; -} - -void SERIAL_setBREAK(COMPORT port, bool value) { - USHORT error; - ULONG ulParmLen = sizeof(error); - DosDevIOCtl(port->porthandle, IOCTL_ASYNC, - value ? ASYNC_SETBREAKON : ASYNC_SETBREAKOFF, - 0,0,0, &error, ulParmLen, &ulParmLen); -} - -int SERIAL_getextchar(COMPORT port) { - ULONG dwRead = 0; // Number of chars read - char chRead; - - int retval = 0; - // receive a byte; TODO communicate failure - if (DosRead(port->porthandle, &chRead, 1, &dwRead) == NO_ERROR) { - if (dwRead) { - // check for errors; will OS/2 clear the error on reading its data? - // if yes then this is in wrong order - USHORT errors = 0, event = 0; - ULONG ulParmLen = sizeof(errors); - DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_GETCOMMEVENT, - 0, 0, 0, &event, ulParmLen, &ulParmLen); - if (event & (64 + 128) ) { // Break (Bit 6) or Frame or Parity (Bit 7) error - Bit8u errreg = 0; - if (event & 64) retval |= SERIAL_BREAK_ERR; - if (event & 128) { - DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_GETCOMMERROR, - 0, 0, 0, &errors, ulParmLen, &ulParmLen); - if (errors & 8) retval |= SERIAL_FRAMING_ERR; - if (errors & 4) retval |= SERIAL_PARITY_ERR; - } - } - retval |= (chRead & 0xff); - retval |= 0x10000; - } - } - return retval; -} - - -int SERIAL_getmodemstatus(COMPORT port) { - UCHAR dptr = 0; - ULONG ulParmLen = sizeof(dptr); - DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_GETMODEMINPUT, - 0, 0, 0, &dptr, ulParmLen, &ulParmLen); - // bits are the same as return value - return (int)dptr; -} -void SERIAL_setDTR(COMPORT port, bool value) { - UCHAR masks[2]; - ULONG ulParmLen = sizeof(masks); - if(value) { - masks[0]=0x01; - masks[1]=0xFF; - } else { - masks[0]=0x00; - masks[1]=0xFE; - } - DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_SETMODEMCTRL, - 0,0,0, &masks, ulParmLen, &ulParmLen); -} - -void SERIAL_setRTS(COMPORT port, bool value) { - UCHAR masks[2]; - ULONG ulParmLen = sizeof(masks); - if(value) { - masks[0]=0x02; - masks[1]=0xFF; - } else { - masks[0]=0x00; - masks[1]=0xFD; - } - DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_SETMODEMCTRL, - 0,0,0, &masks, ulParmLen, &ulParmLen); -} - - - -bool SERIAL_setCommParameters(COMPORT port, - int baudrate, char parity, int stopbits, int length) { - // baud - struct { - ULONG baud; - BYTE fraction; - } setbaud; - - setbaud.baud = baudrate; - setbaud.fraction = 0; - ULONG ulParmLen = sizeof(setbaud); - APIRET rc = DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_EXTSETBAUDRATE, - &setbaud, ulParmLen, &ulParmLen, 0, 0, 0); - if (rc != NO_ERROR) { - return false; - } - - struct { - UCHAR data; - UCHAR parity; - UCHAR stop; - } paramline; - - // byte length - if(length > 8 || length < 5) { - // TODO SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - paramline.data = length; - - // parity - switch (parity) { - case 'n': paramline.parity = 0; break; - case 'o': paramline.parity = 1; break; - case 'e': paramline.parity = 2; break; - case 'm': paramline.parity = 3; break; - case 's': paramline.parity = 4; break; - default: - // TODO SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - // stopbits - switch(stopbits) { - case SERIAL_1STOP: paramline.stop = 0; break; - case SERIAL_2STOP: paramline.stop = 2; break; - case SERIAL_15STOP: paramline.stop = 1; break; - default: - // TODO SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - // set it - ulParmLen = sizeof(paramline); - rc = DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_SETLINECTRL, - ¶mline, ulParmLen, &ulParmLen, 0, 0, 0); - if ( rc != NO_ERROR) - return false; - return true; -} -#endif diff --git a/src/hardware/serialport/misc_util.cpp b/src/hardware/serialport/misc_util.cpp index b0eed831..0a01e277 100644 --- a/src/hardware/serialport/misc_util.cpp +++ b/src/hardware/serialport/misc_util.cpp @@ -64,11 +64,7 @@ TCPClientSocket::TCPClientSocket(int platformsocket) { ((struct _TCPsocketX*)nativetcpstruct)->sflag=0; ((struct _TCPsocketX*)nativetcpstruct)->channel=(SOCKET) platformsocket; sockaddr_in sa; -#ifdef OS2 - int sz; -#else socklen_t sz; -#endif sz=sizeof(sa); if(getpeername(platformsocket, (sockaddr *)(&sa), &sz)==0) { ((struct _TCPsocketX*)nativetcpstruct)-> diff --git a/src/hardware/serialport/misc_util.h b/src/hardware/serialport/misc_util.h index a15c6937..b6cab9eb 100644 --- a/src/hardware/serialport/misc_util.h +++ b/src/hardware/serialport/misc_util.h @@ -40,7 +40,7 @@ #include //for socklen_t //typedef int socklen_t; -//Tests for BSD/OS2/LINUX +//Tests for BSD/LINUX #elif defined HAVE_STDLIB_H && defined HAVE_SYS_TYPES_H && defined HAVE_SYS_SOCKET_H && defined HAVE_NETINET_IN_H #define NATIVESOCKETS #define SOCKET int diff --git a/src/misc/cross.cpp b/src/misc/cross.cpp index 6ecba051..5ad17333 100644 --- a/src/misc/cross.cpp +++ b/src/misc/cross.cpp @@ -124,7 +124,7 @@ void Cross::CreateDir(std::string const& in) { bool Cross::IsPathAbsolute(std::string const& in) { // Absolute paths -#if defined (WIN32) || defined(OS2) +#if defined (WIN32) // drive letter if (in.size() > 2 && in[1] == ':' ) return true; // UNC path @@ -247,7 +247,7 @@ void close_directory(dir_information* dirp) { #endif FILE *fopen_wrap(const char *path, const char *mode) { -#if defined(WIN32) || defined(OS2) +#if defined(WIN32) ; #elif defined (MACOSX) ; diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index 2281a505..39264221 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -409,7 +409,7 @@ public: /* Maximum of extra commands: 10 */ Bitu i = 1; while (control->cmdline->FindString("-c",line,true) && (i <= 11)) { -#if defined (WIN32) || defined (OS2) +#if defined (WIN32) //replace single with double quotes so that mount commands can contain spaces for(Bitu temp = 0;temp < line.size();++temp) if(line[temp] == '\'') line[temp]='\"'; #endif //Linux users can simply use \" in their shell