Remove: OS/2 port

This commit is contained in:
Owen Rudge 2023-06-16 13:23:55 +01:00
parent d4c2043294
commit 1a3d1bca59
39 changed files with 14 additions and 1693 deletions

View File

@ -174,9 +174,6 @@ See `src/3rdparty/squirrel/COPYRIGHT` for the complete license text.
The md5 implementation in `src/3rdparty/md5` is licensed under the Zlib license.
See the comments in the source files in `src/3rdparty/md5` for the complete license text.
The implementations of Posix `getaddrinfo` and `getnameinfo` for OS/2 in `src/3rdparty/os2` are distributed partly under the GNU Lesser General Public License 2.1, and partly under the (3-clause) BSD license.
The exact licensing terms can be found in `src/3rdparty/os2/getaddrinfo.c` resp. `src/3rdparty/os2/getnameinfo.c`.
The fmt implementation in `src/3rdparty/fmt` is licensed under the MIT license.
See `src/3rdparty/fmt/LICENSE.rst` for the complete license text.

View File

@ -1,8 +0,0 @@
rem
rem Building language files...
rem
cd ..
strgen\strgen
for %%f in (lang\*.txt) do strgen\strgen %%f
cd strgen

View File

@ -1 +0,0 @@
start /n /win openttd.exe -D %1 %2 %3 %4 %5 %6 %7 %8 %9

View File

@ -1,21 +0,0 @@
@echo off
if "%1" == "" goto err
if "%2" == "" goto err
echo Downloading NoSound...
%1\wget http://binaries.openttd.org/installer/nosound-NOSOUND_VERSION.7z -O %2/baseset/nosound.7z
echo Extracting NoSound...
%1\7za x -y -O%2/baseset %2/baseset/nosound.7z
del %1\baseset\nosound.7z /n
echo NoSound has been installed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
echo Please visit www.openttd.org for details on downloading NoSound.
:end

View File

@ -1,21 +0,0 @@
@echo off
if "%1" == "" goto err
if "%2" == "" goto err
echo Downloading OpenGFX...
%1\wget http://binaries.openttd.org/installer/opengfx-OPENGFX_VERSION.7z -O %2/baseset/opengfx.7z
echo Extracting OpenGFX...
%1\7za x -y -O%2/baseset %2/baseset/opengfx.7z
del %1\baseset\opengfx.7z /n
echo OpenGFX has been installed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
echo Please visit www.openttd.org for details on downloading OpenGFX.
:end

View File

@ -1,21 +0,0 @@
@echo off
if "%1" == "" goto err
if "%2" == "" goto err
echo Downloading OpenSFX...
%1\wget http://binaries.openttd.org/installer/opensfx-OPENSFX_VERSION.7z -O %2/baseset/opensfx.7z
echo Extracting OpenSFX...
%1\7za x -y -O%2/baseset %2/baseset/opensfx.7z
del %1\baseset\opensfx.7z /n
echo OpenSFX has been installed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
echo Please visit www.openttd.org for details on downloading OpenSFX.
:end

View File

@ -1,85 +0,0 @@
@echo off
set OPENTTD_VERSION=1.11.0
set OPENSFX_VERSION=0.8.0
set NOSOUND_VERSION=0.8.0
set OPENGFX_VERSION=1.2.0
echo To make the installer, you must have the WarpIN compiler (wic) installed and in
echo your path, as well as wget and unzip. This file will download the various DLLs
echo to be distributed with the installer. If you do not want to continue, please
echo press CTRL-C now.
echo.
pause
cd ..\..\..\bundle
if not exist SDL12.dll goto getsdl
if not exist FSLib.dll goto getsdl
goto libc
:getsdl
wget http://www.os2site.com/sw/dev/sdl/sdl-1.2.10-bin-20080804.zip -O dl.zip
unzip -j dl.zip SDL/FSLib.dll SDL/SDL12.dll
del dl.zip
:libc
if exist libc063.dll goto gcc
wget ftp://ftp.netlabs.org/pub/gcc/libc-0.6.3-csd3.zip -O dl.zip
unzip -j dl.zip libc063.dll
del dl.zip
:gcc
if exist gcc442.dll goto tools
wget http://www.owenrudge.net/various/gcc442.zip -O dl.zip
unzip -j dl.zip gcc442.dll
del dl.zip
:tools
cd ..\os\os2\installer
if exist tools goto opengfx
mkdir tools
cd tools
wget http://download.smedley.info/wget-1.11.4-os2-20090315.zip -O dl.zip
unzip -j dl.zip wget/bin/wget.exe
del dl.zip
wget ftp://ftp.os4.su/moveton/p7zip-9.04-bin-os2.zip -O dl.zip
unzip -j dl.zip bin/7za.exe dll/ilibca.dll
del dl.zip
cd ..
:opengfx
if exist opengfx goto opensfx
mkdir opengfx
sed s/OPENGFX_VERSION/%OPENGFX_VERSION%/ < download_opengfx.cmd > opengfx\download_opengfx.cmd
copy remove_opengfx.cmd opengfx
:opensfx
if exist opensfx goto nosound
mkdir opensfx
sed s/OPENSFX_VERSION/%OPENSFX_VERSION%/ < download_opensfx.cmd > opensfx\download_opensfx.cmd
copy remove_opensfx.cmd opensfx
:nosound
mkdir nosound
sed s/NOSOUND_VERSION/%NOSOUND_VERSION%/ < download_nosound.cmd > nosound\download_nosound.cmd
copy remove_nosound.cmd nosound
:end
if exist openttd-%OPENTTD_VERSION%-os2.exe del openttd-%OPENTTD_VERSION%-os2.exe
wic -a openttd-%OPENTTD_VERSION%-os2.exe 1 -c../../../bundle -r * 2 -ctools -r * 3 -copengfx -r * 4 -copensfx -r * 5 -cnosound -r * -U -s openttd.wis

View File

@ -1,106 +0,0 @@
<WARPIN>
<HEAD>
<TITLE>OpenTTD</TITLE>
<!-- Please remember to increment the build number for each package
when releasing a new stable version, particularly if there are
also release candidates sharing the major/minor versions:
e.g., 0\7\1\16279 for 0.7.1-RC1,
0\7\1\16365 for 0.7.1-RC2,
0\7\1\16540 for 0.7.1 final
-->
<PCK INDEX="1"
PACKAGEID="OpenTTD\OpenTTD\OpenTTD\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="OpenTTD"
LONGFILENAMES
BASE
>OpenTTD is an open source transport simulation game</PCK>
<PCK INDEX="2"
PACKAGEID="OpenTTD\OpenTTD\Downloader\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="Download tools"
REQUIRES=1
FIXED
>Tools required for downloading the OpenGFX/SFX packs</PCK>
<PCK INDEX="3"
PACKAGEID="OpenTTD\OpenTTD\OpenGFX\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="OpenGFX"
LONGFILENAMES
REQUIRES=2
EXECUTE="$(3)\download_opengfx.cmd | $(1) $(/1)"
DEEXECUTE="$(3)\remove_opengfx.cmd | $(1) $(/1)"
FIXED
>Downloads the OpenGFX graphics pack for OpenTTD</PCK>
<PCK INDEX="4"
PACKAGEID="OpenTTD\OpenTTD\OpenSFX\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="OpenSFX"
LONGFILENAMES
REQUIRES=2
EXECUTE="$(4)\download_opensfx.cmd | $(1) $(/1)"
DEEXECUTE="$(4)\remove_opensfx.cmd | $(1) $(/1)"
FIXED
>Downloads the OpenSFX sound effects pack for OpenTTD</PCK>
<PCK INDEX="5"
PACKAGEID="OpenTTD\OpenTTD\NoSound\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="NoSound"
LONGFILENAMES
REQUIRES=2
EXECUTE="$(5)\download_nosound.cmd | $(1) $(/1)"
DEEXECUTE="$(5)\remove_nosound.cmd | $(1) $(/1)"
FIXED
>Downloads the NoSound pack for OpenTTD, to disable sound effects</PCK>
</HEAD>
<BODY>
<!-- page 1: introductory page -->
<PAGE INDEX="1" TYPE="README">
<NEXTBUTTON TARGET=2>~Next</NEXTBUTTON>
<README EXTRACTFROMPCK="1">README.md</README>
<TEXT>Welcome to the OpenTTD installer. This program will install OpenTTD 1.0 on your system. Before we begin the installation process, please take a moment to read the following document.
Select "Next" to continue, or "Cancel" to abort installation.</TEXT>
</PAGE>
<!-- page 2: licence page -->
<PAGE INDEX="2" TYPE="README">
<NEXTBUTTON TARGET=3>~Next</NEXTBUTTON>
<README EXTRACTFROMPCK="1">COPYING.md</README>
<TEXT>OpenTTD is licenced under the GNU General Public License. The text of the licence is below.
Select "Next" if you agree to this licence.
Select "Cancel" to abort installation.</TEXT>
</PAGE>
<!-- The TYPE=CONTAINER will list the packages which can be installed. -->
<PAGE INDEX="3" TYPE="CONTAINER">
<NEXTBUTTON TARGET="4">~Next</NEXTBUTTON>
<TEXT>On this page, you may choose which components to install. If you don't own Transport Tycoon Deluxe, you will need to download OpenGFX (3MiB) and OpenSFX (10MiB).</TEXT>
</PAGE>
<!-- Display another TEXT page to inform the user
that installation will begin. We use the TARGET=0
with the NEXTBUTTON tag which starts installation. -->
<PAGE INDEX="4" TYPE="TEXT">
<NEXTBUTTON TARGET="0">I~nstall</NEXTBUTTON>
<TEXT>
Press "Install" to begin installing OpenTTD.</TEXT>
</PAGE>
</BODY>
</WARPIN>

View File

@ -1,15 +0,0 @@
@echo off
if "%1" == "" goto err
echo Removing NoSound...
del %1\baseset\nosound\*.* /n
rmdir %1\baseset\nosound
echo NoSound has been removed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
:end

View File

@ -1,15 +0,0 @@
@echo off
if "%1" == "" goto err
echo Removing OpenGFX...
del %1\baseset\opengfx\*.* /n
rmdir %1\baseset\opengfx
echo OpenGFX has been removed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
:end

View File

@ -1,15 +0,0 @@
@echo off
if "%1" == "" goto err
echo Removing OpenSFX...
del %1\baseset\opensfx\*.* /n
rmdir %1\baseset\opensfx
echo OpenSFX has been removed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
:end

View File

@ -1,64 +0,0 @@
40
projectIdent
0
VpeMain
1
WRect
0
0
10304
10020
2
MProject
3
MCommand
15
svn_version.cmd
4
MCommand
0
2
5
WFileName
17
..\..\openttd.tgt
6
WFileName
23
..\..\strgen\strgen.tgt
7
WVList
2
8
VComponent
9
WRect
0
0
5696
4240
0
0
10
WFileName
17
..\..\openttd.tgt
0
0
11
VComponent
12
WRect
688
680
5696
4240
0
0
13
WFileName
23
..\..\strgen\strgen.tgt
0
1
8

View File

@ -1,30 +0,0 @@
@echo off
echo Running SVN version detection script...
rem
rem Requires subversion (`svnversion') to be installed
rem
cd ..\..
if not "%RELEASE%"=="" goto forcerelease
if not exist .svn goto nosvn
svnversion -n . > os\os2\svnver.tmp
if not "%ERRORLEVEL%"=="0" goto nosvn
copy os\os2\svnver1.c+os\os2\svnver.tmp+os\os2\svnver2.c rev.c /a /y > nul 2> nul
goto end
:forcerelease
echo Forcing release string "%RELEASE%"...
echo const char _openttd_revision[] = "%RELEASE%"; > rev.c
echo const int _revision_number = 0; >> rev.c
goto end
:nosvn
echo Error executing `svnversion' or no SVN data detected
echo const char _openttd_revision[] = "norev000"; > rev.c
echo const int _revision_number = 0; >> rev.c
goto end
:end
cd os\os2
del svnver.tmp > nul 2> nul
rem end

View File

@ -1,3 +0,0 @@
/* rev.c part #1 for OS/2 - ensure no newline at end of file! */
const char _openttd_revision[] = "r

View File

@ -1,4 +0,0 @@
";
const int _revision_number = 0;
/* rev.c part 2 for OS/2 - ensure no newline at start of file! */

View File

@ -4,4 +4,3 @@ add_subdirectory(icu)
add_subdirectory(md5)
add_subdirectory(squirrel)
add_subdirectory(opengl)
add_subdirectory(os2)

View File

@ -1,7 +0,0 @@
add_files(
getaddrinfo.c
getaddrinfo.h
getnameinfo.c
getnameinfo.h
CONDITION OPTION_OS2
)

View File

@ -1,299 +0,0 @@
/*
* This file is part of libESMTP, a library for submission of RFC 2822
* formatted electronic mail messages using the SMTP protocol described
* in RFC 2821.
*
* Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* An emulation of the RFC 2553 / Posix getaddrinfo resolver interface.
*/
#if !HAVE_GETADDRINFO
/* Need to turn off Posix features in glibc to build this */
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#include "getaddrinfo.h"
//#include "compat/inet_pton.h"
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
static struct addrinfo *
dup_addrinfo (struct addrinfo *info, void *addr, size_t addrlen) {
struct addrinfo *ret;
ret = malloc (sizeof (struct addrinfo));
if (ret == NULL)
return NULL;
memcpy (ret, info, sizeof (struct addrinfo));
ret->ai_addr = malloc (addrlen);
if (ret->ai_addr == NULL) {
free (ret);
return NULL;
}
memcpy (ret->ai_addr, addr, addrlen);
ret->ai_addrlen = addrlen;
return ret;
}
int
getaddrinfo (const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res)
{
struct hostent *hp;
struct servent *servent;
const char *socktype;
int port;
struct addrinfo hint, result;
struct addrinfo *ai, *sai, *eai;
char **addrs;
if (servname == NULL && nodename == NULL)
return EAI_NONAME;
memset (&result, 0, sizeof result);
/* default for hints */
if (hints == NULL) {
memset (&hint, 0, sizeof hint);
hint.ai_family = PF_UNSPEC;
hints = &hint;
}
if (servname == NULL)
port = 0;
else {
/* check for tcp or udp sockets only */
if (hints->ai_socktype == SOCK_STREAM)
socktype = "tcp";
else if (hints->ai_socktype == SOCK_DGRAM)
socktype = "udp";
else
return EAI_SERVICE;
result.ai_socktype = hints->ai_socktype;
/* Note: maintain port in host byte order to make debugging easier */
if (isdigit (*servname))
port = strtol (servname, NULL, 10);
else if ((servent = getservbyname (servname, socktype)) != NULL)
port = ntohs (servent->s_port);
else
return EAI_NONAME;
}
/* if nodename == NULL refer to the local host for a client or any
for a server */
if (nodename == NULL) {
struct sockaddr_in sin;
/* check protocol family is PF_UNSPEC or PF_INET - could try harder
for IPv6 but that's more code than I'm prepared to write */
if (hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET)
result.ai_family = AF_INET;
else
return EAI_FAMILY;
sin.sin_family = result.ai_family;
sin.sin_port = htons (port);
if (hints->ai_flags & AI_PASSIVE)
sin.sin_addr.s_addr = htonl (INADDR_ANY);
else
sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
/* Duplicate result and addr and return */
*res = dup_addrinfo (&result, &sin, sizeof sin);
return (*res == NULL) ? EAI_MEMORY : 0;
}
/* If AI_NUMERIC is specified, use inet_pton to translate numbers and
dots notation. */
if (hints->ai_flags & AI_NUMERICHOST) {
struct sockaddr_in sin;
/* check protocol family is PF_UNSPEC or PF_INET */
if (hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET)
result.ai_family = AF_INET;
else
return EAI_FAMILY;
sin.sin_family = result.ai_family;
sin.sin_port = htons (port);
if (inet_pton(result.ai_family, nodename, &sin.sin_addr)==0)
return EAI_NONAME;
sin.sin_addr.s_addr = inet_addr (nodename);
/* Duplicate result and addr and return */
*res = dup_addrinfo (&result, &sin, sizeof sin);
return (*res == NULL) ? EAI_MEMORY : 0;
}
#if HAVE_H_ERRNO
h_errno = 0;
#endif
errno = 0;
hp = gethostbyname(nodename);
if (hp == NULL) {
#ifdef EAI_SYSTEM
if (errno != 0) {
return EAI_SYSTEM;
}
#endif
switch (h_errno) {
case HOST_NOT_FOUND:
return EAI_NODATA;
case NO_DATA:
return EAI_NODATA;
#if defined(NO_ADDRESS) && NO_ADDRESS != NO_DATA
case NO_ADDRESS:
return EAI_NODATA;
#endif
case NO_RECOVERY:
return EAI_FAIL;
case TRY_AGAIN:
return EAI_AGAIN;
default:
return EAI_FAIL;
}
return EAI_FAIL;
}
/* Check that the address family is acceptable.
*/
switch (hp->h_addrtype) {
case AF_INET:
if (!(hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET))
return EAI_FAMILY;
break;
#ifndef __OS2__
case AF_INET6:
if (!(hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET6))
return EAI_FAMILY;
break;
#endif
default:
return EAI_FAMILY;
}
/* For each element pointed to by hp, create an element in the
result linked list. */
sai = eai = NULL;
for (addrs = hp->h_addr_list; *addrs != NULL; addrs++) {
struct sockaddr sa;
size_t addrlen;
if (hp->h_length < 1)
continue;
sa.sa_family = hp->h_addrtype;
switch (hp->h_addrtype) {
case AF_INET:
((struct sockaddr_in *) &sa)->sin_port = htons (port);
memcpy (&((struct sockaddr_in *) &sa)->sin_addr,
*addrs, hp->h_length);
addrlen = sizeof (struct sockaddr_in);
break;
#ifndef __OS2__
case AF_INET6:
#if SIN6_LEN
((struct sockaddr_in6 *) &sa)->sin6_len = hp->h_length;
#endif
((struct sockaddr_in6 *) &sa)->sin6_port = htons (port);
memcpy (&((struct sockaddr_in6 *) &sa)->sin6_addr,
*addrs, hp->h_length);
addrlen = sizeof (struct sockaddr_in6);
break;
#endif
default:
continue;
}
result.ai_family = hp->h_addrtype;
ai = dup_addrinfo (&result, &sa, addrlen);
if (ai == NULL) {
freeaddrinfo (sai);
return EAI_MEMORY;
}
if (sai == NULL)
sai = ai;
else
eai->ai_next = ai;
eai = ai;
}
if (sai == NULL) {
return EAI_NODATA;
}
if (hints->ai_flags & AI_CANONNAME) {
sai->ai_canonname = malloc (strlen (hp->h_name) + 1);
if (sai->ai_canonname == NULL) {
freeaddrinfo (sai);
return EAI_MEMORY;
}
strcpy (sai->ai_canonname, hp->h_name);
}
*res = sai;
return 0;
}
void
freeaddrinfo (struct addrinfo *ai)
{
struct addrinfo *next;
while (ai != NULL) {
next = ai->ai_next;
if (ai->ai_canonname != NULL)
free (ai->ai_canonname);
if (ai->ai_addr != NULL)
free (ai->ai_addr);
free (ai);
ai = next;
}
}
const char *
gai_strerror (int ecode)
{
static const char *eai_descr[] = {
"no error",
"address family for nodename not supported", /* EAI_ADDRFAMILY */
"temporary failure in name resolution", /* EAI_AGAIN */
"invalid value for ai_flags", /* EAI_BADFLAGS */
"non-recoverable failure in name resolution", /* EAI_FAIL */
"ai_family not supported", /* EAI_FAMILY */
"memory allocation failure", /* EAI_MEMORY */
"no address associated with nodename", /* EAI_NODATA */
"nodename nor servname provided, or not known", /* EAI_NONAME */
"servname not supported for ai_socktype", /* EAI_SERVICE */
"ai_socktype not supported", /* EAI_SOCKTYPE */
"system error returned in errno", /* EAI_SYSTEM */
"argument buffer overflow", /* EAI_OVERFLOW */
};
if (ecode < 0 || ecode > (int) (sizeof eai_descr/ sizeof eai_descr[0]))
return "unknown error";
return eai_descr[ecode];
}
#endif /* HAVE_GETADDRINFO */

View File

@ -1,101 +0,0 @@
#ifndef _getaddrinfo_h
#define _getaddrinfo_h
/*
* Shamelessly duplicated from the fetchmail public sources
* for use by the Squid Project under GNU Public License.
*
* Update/Maintenance History:
*
* 15-Aug-2007 : Copied from fetchmail 6.3.8
* - added protection around libray headers
*
* 16-Aug-2007 : Altered configure checks
* Un-hacked slightly to use system gethostbyname()
*
* Original License and code follows.
*/
/*
* This file is part of libESMTP, a library for submission of RFC 2822
* formatted electronic mail messages using the SMTP protocol described
* in RFC 2821.
*
* Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Structure and prototypes taken from RFC 2553 */
/* SG 23/09/2007:
On Windows the following definitions are already available, may be that
this could be needed on some other platform */
typedef int socklen_t;
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
socklen_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for nodename */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
/* Supposed to be defined in <netdb.h> */
#define AI_ADDRCONFIG 0
#define AI_PASSIVE 1 /* Socket address is intended for `bind'. */
#define AI_CANONNAME 2 /* Request for canonical name. */
#define AI_NUMERICHOST 4 /* Don't use name resolution. */
/* Supposed to be defined in <netdb.h> */
#define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
#define EAI_AGAIN 2 /* temporary failure in name resolution */
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /* ai_family not supported */
#define EAI_MEMORY 6 /* memory allocation failure */
#define EAI_NODATA 7 /* no address associated with nodename */
#define EAI_NONAME 8 /* nodename nor servname provided, or not known */
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
#ifndef EAI_SYSTEM
/* Not defined on mingw32. */
#define EAI_SYSTEM 11 /* System error returned in `errno'. */
#endif
#ifndef EAI_OVERFLOW
/* Not defined on mingw32. */
#define EAI_OVERFLOW 12 /* Argument buffer overflow. */
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* RFC 2553 / Posix resolver */
int getaddrinfo (const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res);
/* Free addrinfo structure and associated storage */
void freeaddrinfo (struct addrinfo *ai);
/* Convert error return from getaddrinfo() to string */
const char *gai_strerror (int code);
#ifdef __cplusplus
}
#endif
#endif /* _getaddrinfo_h */

View File

@ -1,367 +0,0 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Issues to be discussed:
* - RFC2553 says that we should raise error on short buffer. X/Open says
* we need to truncate the result. We obey RFC2553 (and X/Open should be
* modified). ipngwg rough consensus seems to follow RFC2553. RFC3493 says
* nothing about it, but defines a new error code EAI_OVERFLOW which seems
* to be intended the code for this case.
* - What is "local" in NI_NOFQDN? (see comments in the code)
* - NI_NAMEREQD and NI_NUMERICHOST conflict with each other.
* - (KAME extension) always attach textual scopeid (fe80::1%lo0), if
* sin6_scope_id is filled - standardization status?
* - what should we do if we should do getservbyport("sctp")?
*/
/*
* Considerations about thread-safeness
* The code in this file is thread-safe, and so the thread-safeness of
* getnameinfo() depends on the property of backend functions.
* - getservbyport() is not thread safe for most systems we are targeting.
* - getipnodebyaddr() is thread safe. However, many resolver libraries
* used in the function are not thread safe.
* - gethostbyaddr() is usually not thread safe.
*/
#if !HAVE_GETNAMEINFO
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <netdb.h>
#include <resolv.h>
#include <string.h>
#include <stddef.h>
#include <errno.h>
#include <inttypes.h>
#include "getaddrinfo.h"
#include "getnameinfo.h"
static const struct afd {
int a_af;
int a_addrlen;
int a_socklen;
int a_off;
int a_portoff;
} afdl [] = {
#if INET6
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
offsetof(struct sockaddr_in6, sin6_addr),
offsetof(struct sockaddr_in6, sin6_port)},
#endif
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
offsetof(struct sockaddr_in, sin_addr),
offsetof(struct sockaddr_in, sin_port)},
{0, 0, 0, 0, 0},
};
#if INET6
static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
size_t, int));
static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int));
#endif
int
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
const struct sockaddr *sa;
socklen_t salen;
char *host;
size_t hostlen;
char *serv;
size_t servlen;
int flags;
{
const struct afd *afd;
struct servent *sp;
struct hostent *hp;
unsigned short port;
int family, i;
const char *addr;
uint32_t v4a;
char numserv[512];
if (sa == NULL)
return EAI_FAIL;
#if HAVE_SA_LEN /*XXX*/
if (sa->sa_len != salen)
return EAI_FAIL;
#endif
family = sa->sa_family;
for (i = 0; afdl[i].a_af; i++)
if (afdl[i].a_af == family) {
afd = &afdl[i];
goto found;
}
return EAI_FAMILY;
found:
if (salen != afd->a_socklen)
return EAI_FAIL;
/* network byte order */
memcpy(&port, (const char *)sa + afd->a_portoff, sizeof(port));
addr = (const char *)sa + afd->a_off;
if (serv == NULL || servlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC3493 says that serv == NULL OR servlen == 0
* means that the caller does not want the result.
*/
} else {
if (flags & NI_NUMERICSERV)
sp = NULL;
else {
sp = getservbyport(port,
(flags & NI_DGRAM) ? "udp" : "tcp");
}
if (sp) {
if (strlen(sp->s_name) + 1 > servlen)
return EAI_OVERFLOW;
strncpy(serv, sp->s_name, servlen);
} else {
snprintf(numserv, sizeof(numserv), "%u", ntohs(port));
if (strlen(numserv) + 1 > servlen)
return EAI_OVERFLOW;
strncpy(serv, numserv, servlen);
}
}
switch (sa->sa_family) {
case AF_INET:
v4a = (uint32_t)
ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
flags |= NI_NUMERICHOST;
v4a >>= IN_CLASSA_NSHIFT;
if (v4a == 0)
flags |= NI_NUMERICHOST;
break;
#if INET6
case AF_INET6: {
const struct sockaddr_in6 *sin6;
sin6 = (const struct sockaddr_in6 *)sa;
switch (sin6->sin6_addr.s6_addr[0]) {
case 0x00:
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
;
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
;
else
flags |= NI_NUMERICHOST;
break;
default:
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
break;
}
}
break;
#endif
}
if (host == NULL || hostlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC3493 says that host == NULL or hostlen == 0
* means that the caller does not want the result.
*/
} else if (flags & NI_NUMERICHOST) {
/* NUMERICHOST and NAMEREQD conflicts with each other */
if (flags & NI_NAMEREQD)
return EAI_NONAME;
goto numeric;
} else {
#if USE_GETIPNODEBY
int h_error = 0;
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
#else
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
#if 0 // getnameinfo.c:161:9: error: variable 'h_error' set but not used
#if HAVE_H_ERRNO
h_error = h_errno;
#else
h_error = EINVAL;
#endif
#endif /* 0 */
#endif
if (hp) {
#if 0
if (flags & NI_NOFQDN) {
/*
* According to RFC3493 section 6.2, NI_NOFQDN
* means "node name portion of the FQDN shall
* be returned for local hosts." The following
* code tries to implement it by returning the
* first label (the part before the first
* period) of the FQDN. However, it is not
* clear if this always makes sense, since the
* given address may be outside of "local
* hosts." Due to the unclear description, we
* disable the code in this implementation.
*/
char *p;
p = strchr(hp->h_name, '.');
if (p)
*p = '\0';
}
#endif
if (strlen(hp->h_name) + 1 > hostlen) {
#if USE_GETIPNODEBY
freehostent(hp);
#endif
return EAI_OVERFLOW;
}
strncpy(host, hp->h_name, hostlen);
#if USE_GETIPNODEBY
freehostent(hp);
#endif
} else {
if (flags & NI_NAMEREQD)
return EAI_NONAME;
numeric:
switch (afd->a_af) {
#if INET6
case AF_INET6: {
int error;
if ((error = ip6_parsenumeric(sa, addr, host,
hostlen,
flags)) != 0)
return(error);
break;
}
#endif
default:
if (inet_ntop(afd->a_af, addr, host,
hostlen) == NULL)
return EAI_SYSTEM;
break;
}
}
}
return(0);
}
#if INET6
static int
ip6_parsenumeric(sa, addr, host, hostlen, flags)
const struct sockaddr *sa;
const char *addr;
char *host;
size_t hostlen;
int flags;
{
int numaddrlen;
char numaddr[512];
if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
return EAI_SYSTEM;
numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
return EAI_OVERFLOW;
strncpy(host, numaddr, hostlen);
if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
char zonebuf[SQUIDHOSTNAMELEN];
int zonelen;
zonelen = ip6_sa2str(
(const struct sockaddr_in6 *)(const void *)sa,
zonebuf, sizeof(zonebuf), flags);
if (zonelen < 0)
return EAI_OVERFLOW;
if (zonelen + 1 + numaddrlen + 1 > hostlen)
return EAI_OVERFLOW;
/* construct <numeric-addr><delim><zoneid> */
memcpy(host + numaddrlen + 1, zonebuf,
(size_t)zonelen);
host[numaddrlen] = SCOPE_DELIMITER;
host[numaddrlen + 1 + zonelen] = '\0';
}
return 0;
}
/* ARGSUSED */
static int
ip6_sa2str(sa6, buf, bufsiz, flags)
const struct sockaddr_in6 *sa6;
char *buf;
size_t bufsiz;
int flags;
{
unsigned int ifindex;
const struct in6_addr *a6;
int n;
ifindex = (unsigned int)sa6->sin6_scope_id;
a6 = &sa6->sin6_addr;
#if NI_NUMERICSCOPE
if ((flags & NI_NUMERICSCOPE) != 0) {
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
if (n < 0 || n >= bufsiz)
return -1;
else
return n;
}
#endif
/* if_indextoname() does not take buffer size. not a good api... */
if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6) ||
IN6_IS_ADDR_MC_NODELOCAL(a6)) && bufsiz >= IF_NAMESIZE) {
char *p = if_indextoname(ifindex, buf);
if (p)
return (strlen(p));
}
/* last resort */
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
if (n < 0 || n >= bufsiz)
return -1;
else
return n;
}
#endif /* INET6 */
#endif

View File

@ -1,29 +0,0 @@
#ifndef _getnameinfo_h
#define _getnameinfo_h
/*
* Reconstructed from KAME getnameinfo.c (in lib/)
*/
/* getnameinfo flags */
#define NI_NOFQDN 0x0001
#define NI_NUMERICHOST 0x0002 /* return numeric form of address */
#define NI_NAMEREQD 0x0004 /* request DNS name */
#define NI_NUMERICSERV 0x0008
#define NI_DGRAM 0x0010
#ifdef __cplusplus
extern "C" {
#endif
/* RFC 2553 / Posix resolver */
int getnameinfo(const struct sockaddr *sa,
socklen_t salen,
char *host,
size_t hostlen,
char *serv,
size_t servlen,
int flags );
#ifdef __cplusplus
}
#endif
#endif /* _getnameinfo_h */

View File

@ -32,13 +32,6 @@ uint64 ottd_rdtsc()
#define RDTSC_AVAILABLE
#endif
/* rdtsc for OS/2. Hopefully this works, who knows */
#if defined (__WATCOMC__) && !defined(RDTSC_AVAILABLE)
unsigned __int64 ottd_rdtsc();
# pragma aux ottd_rdtsc = 0x0F 0x31 value [edx eax] parm nomemory modify exact [edx eax] nomemory;
# define RDTSC_AVAILABLE
#endif
/* rdtsc for all other *nix-en (hopefully). Use GCC syntax */
#if (defined(__i386__) || defined(__x86_64__)) && !defined(RDTSC_AVAILABLE)
uint64 ottd_rdtsc()

View File

@ -88,8 +88,6 @@ void CrashLog::LogCompiler(std::back_insert_iterator<std::string> &output_iterat
"ICC {}", __ICC
#elif defined(__GNUC__)
"GCC {}.{}.{}", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
#elif defined(__WATCOMC__)
"WatcomC {}", __WATCOMC__
#else
"<unknown>"
#endif

View File

@ -347,8 +347,6 @@ void FioCreateDirectory(const std::string &name)
* of the time they are 'directory already exists' errors anyhow. */
#if defined(_WIN32)
CreateDirectory(OTTD2FS(name).c_str(), nullptr);
#elif defined(OS2) && !defined(__INNOTEK_LIBC__)
mkdir(OTTD2FS(name).c_str());
#else
mkdir(OTTD2FS(name).c_str(), 0755);
#endif
@ -724,7 +722,7 @@ bool ExtractTar(const std::string &tar_filename, Subdirectory subdir)
/**
* Determine the base (personal dir and game data dir) paths
* @param exe the path from the current path to the executable
* @note defined in the OS related files (os2.cpp, win32.cpp, unix.cpp etc)
* @note defined in the OS related files (win32.cpp, unix.cpp etc)
*/
extern void DetermineBasePaths(const char *exe);
#else /* defined(_WIN32) */
@ -846,7 +844,7 @@ void DetermineBasePaths(const char *exe)
}
#endif
#if defined(OS2) || !defined(WITH_PERSONAL_DIR)
#if !defined(WITH_PERSONAL_DIR)
_searchpaths[SP_PERSONAL_DIR].clear();
#else
if (!homedir.empty()) {

View File

@ -34,7 +34,7 @@
static std::string *_fios_path = nullptr;
SortingBits _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
/* OS-specific functions are taken from their respective files (win32/unix/os2 .c) */
/* OS-specific functions are taken from their respective files (win32/unix .c) */
extern bool FiosIsRoot(const std::string &path);
extern bool FiosIsValidFile(const std::string &path, const struct dirent *ent, struct stat *sb);
extern bool FiosIsHiddenFile(const struct dirent *ent);
@ -143,7 +143,7 @@ bool FiosBrowseTo(const FiosItem *item)
{
switch (item->type) {
case FIOS_TYPE_DRIVE:
#if defined(_WIN32) || defined(__OS2__)
#if defined(_WIN32)
assert(_fios_path != nullptr);
*_fios_path = std::string{ item->title, 0, 1 } + ":" PATHSEP;
#endif

View File

@ -36,12 +36,6 @@ if(NOT OPTION_DEDICATED)
bemidi.h
CONDITION HAIKU
)
add_files(
os2_m.cpp
os2_m.h
CONDITION OPTION_OS2
)
endif()
add_files(

View File

@ -1,86 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD 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, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file os2_m.cpp Music playback on OS/2. */
#include "../stdafx.h"
#include "../openttd.h"
#include "os2_m.h"
#include "midifile.hpp"
#include "../base_media_base.h"
#include "../3rdparty/fmt/format.h"
#define INCL_DOS
#define INCL_OS2MM
#define INCL_WIN
#include <os2.h>
#include <os2me.h>
#include "../safeguards.h"
/**********************
* OS/2 MIDI PLAYER
**********************/
/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API,
* eh? Anyone would think they both came from the same place originally! ;)
*/
/**
* Send a midi command.
* @param cmd The command to send.
* @return The result of sending it.
*/
static long CDECL MidiSendCommand(const std::string_view cmd)
{
return mciSendString(cmd.data(), nullptr, 0, nullptr, 0);
}
/** OS/2's music player's factory. */
static FMusicDriver_OS2 iFMusicDriver_OS2;
void MusicDriver_OS2::PlaySong(const MusicSongInfo &song)
{
std::string filename = MidiFile::GetSMFFile(song);
MidiSendCommand("close all");
if (filename.empty()) return;
if (MidiSendCommand(fmt::format("open {} type sequencer alias song", filename)) != 0) {
return;
}
MidiSendCommand("play song from 0");
}
void MusicDriver_OS2::StopSong()
{
MidiSendCommand("close all");
}
void MusicDriver_OS2::SetVolume(byte vol)
{
MidiSendCommand("set song audio volume %d", ((vol/127)*100));
}
bool MusicDriver_OS2::IsSongPlaying()
{
char buf[16];
mciSendString("status song mode", buf, sizeof(buf), nullptr, 0);
return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
}
const char *MusicDriver_OS2::Start(const StringList &parm)
{
return 0;
}
void MusicDriver_OS2::Stop()
{
MidiSendCommand("close all");
}

View File

@ -1,39 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD 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, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file os2_m.h Base for OS2 music playback. */
#ifndef MUSIC_OS2_H
#define MUSIC_OS2_H
#include "music_driver.hpp"
/** OS/2's music player. */
class MusicDriver_OS2 : public MusicDriver {
public:
const char *Start(const StringList &param) override;
void Stop() override;
void PlaySong(const MusicSongInfo &song) override;
void StopSong() override;
bool IsSongPlaying() override;
void SetVolume(byte vol) override;
const char *GetName() const override { return "os2"; }
};
/** Factory for OS/2's music player. */
class FMusicDriver_OS2 : public DriverFactoryBase {
public:
FMusicDriver_OS2() : DriverFactoryBase(Driver::DT_MUSIC, 10, "os2", "OS/2 Music Driver") {}
Driver *CreateInstance() const override { return new MusicDriver_OS2(); }
};
#endif /* MUSIC_OS2_H */

View File

@ -316,13 +316,11 @@ static SOCKET ListenLoopProc(addrinfo *runp)
Debug(net, 0, "Setting reuse-address mode failed: {}", NetworkError::GetLast().AsString());
}
#ifndef __OS2__
int on = 1;
if (runp->ai_family == AF_INET6 &&
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&on, sizeof(on)) == -1) {
Debug(net, 3, "Could not disable IPv4 over IPv6: {}", NetworkError::GetLast().AsString());
}
#endif
if (bind(sock, runp->ai_addr, (int)runp->ai_addrlen) != 0) {
Debug(net, 0, "Could not bind socket on {}: {}", address, NetworkError::GetLast().AsString());

View File

@ -118,8 +118,6 @@ bool NetworkError::HasError() const
{
#if defined(_WIN32)
return NetworkError(WSAGetLastError());
#elif defined(__OS2__)
return NetworkError(sock_errno());
#else
return NetworkError(errno);
#endif

View File

@ -60,7 +60,7 @@ typedef unsigned long in_addr_t;
#endif /* _WIN32 */
/* UNIX stuff */
#if defined(UNIX) && !defined(__OS2__)
#if defined(UNIX)
# if defined(OPENBSD) || defined(__NetBSD__)
# define AI_ADDRCONFIG 0
# endif
@ -79,7 +79,7 @@ typedef unsigned long in_addr_t;
# include <arpa/inet.h>
# include <net/if.h>
/* According to glibc/NEWS, <ifaddrs.h> appeared in glibc-2.3. */
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__INNOTEK_LIBC__) \
# if !defined(__sgi__) && !defined(SUNOS) \
&& !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX)
/* If for any reason ifaddrs.h does not exist on your system, comment out
* the following two lines and an alternative way will be used to fetch
@ -117,60 +117,6 @@ typedef unsigned long in_addr_t;
#endif /* UNIX */
/* OS/2 stuff */
#if defined(__OS2__)
# define SOCKET int
# define INVALID_SOCKET -1
# define closesocket close
/* Includes needed for OS/2 systems */
# include <types.h>
# include <unistd.h>
# include <sys/ioctl.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <arpa/inet.h>
# include <net/if.h>
# include <errno.h>
# include <sys/time.h>
# include <netdb.h>
# include <nerrno.h>
# define INADDR_NONE 0xffffffff
# include "../../3rdparty/os2/getaddrinfo.h"
# include "../../3rdparty/os2/getnameinfo.h"
#define IPV6_V6ONLY 27
/*
* IPv6 address
*/
struct in6_addr {
union {
uint8_t __u6_addr8[16];
uint16_t __u6_addr16[8];
uint32_t __u6_addr32[4];
} __u6_addr; /* 128-bit IP6 address */
};
#define s6_addr __u6_addr.__u6_addr8
struct sockaddr_in6 {
uint8_t sin6_len; /* length of this struct */
sa_family_t sin6_family; /* AF_INET6 */
in_port_t sin6_port; /* Transport layer port # */
uint32_t sin6_flowinfo; /* IP6 flow information */
struct in6_addr sin6_addr; /* IP6 address */
uint32_t sin6_scope_id; /* scope zone index */
};
typedef int socklen_t;
#if !defined(__INNOTEK_LIBC__)
typedef unsigned long in_addr_t;
#endif /* __INNOTEK_LIBC__ */
#endif /* OS/2 */
#ifdef __EMSCRIPTEN__
/**
* Emscripten doesn't set 'addrlen' for accept(), getsockname(), getpeername()

View File

@ -1,4 +1,3 @@
add_subdirectory(macosx)
add_subdirectory(os2)
add_subdirectory(unix)
add_subdirectory(windows)

View File

@ -1,8 +0,0 @@
add_files(
os2.cpp
CONDITION OPTION_OS2
)
if(OPTION_OS2)
target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/os2_main.cpp)
endif()

View File

@ -1,187 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD 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, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file os2.cpp OS2 related OS support. */
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../gui.h"
#include "../../fileio_func.h"
#include "../../fios.h"
#include "../../string_func.h"
#include "../../textbuf_gui.h"
#include "../../thread.h"
#include "table/strings.h"
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <time.h>
#ifndef __INNOTEK_LIBC__
# include <dos.h>
#endif
#include "../../safeguards.h"
#define INCL_WIN
#define INCL_WINCLIPBOARD
#include <os2.h>
#ifndef __INNOTEK_LIBC__
# include <i86.h>
#endif
bool FiosIsRoot(const std::string &file)
{
return file.size() == 3; // C:\...
}
void FiosGetDrives(FileList &file_list)
{
uint disk, disk2, save, total;
#ifndef __INNOTEK_LIBC__
_dos_getdrive(&save); // save original drive
#else
save = _getdrive(); // save original drive
char wd[MAX_PATH];
getcwd(wd, MAX_PATH);
total = 'z';
#endif
/* get an available drive letter */
#ifndef __INNOTEK_LIBC__
for (disk = 1;; disk++) {
_dos_setdrive(disk, &total);
#else
for (disk = 'A';; disk++) {
_chdrive(disk);
#endif
if (disk >= total) break;
#ifndef __INNOTEK_LIBC__
_dos_getdrive(&disk2);
#else
disk2 = _getdrive();
#endif
if (disk == disk2) {
FiosItem *fios = file_list.Append();
fios->type = FIOS_TYPE_DRIVE;
fios->mtime = 0;
#ifndef __INNOTEK_LIBC__
fios->name += 'A' + disk - 1;
#else
fios->name += (char)disk;
#endif
fios->name += ':';
fios->title = fios->name;
}
}
/* Restore the original drive */
#ifndef __INNOTEK_LIBC__
_dos_setdrive(save, &total);
#else
chdir(wd);
#endif
}
std::optional<uint64_t> FiosGetDiskFreeSpace(const std::string &path)
{
#ifndef __INNOTEK_LIBC__
struct diskfree_t free;
char drive = path[0] - 'A' + 1;
if (_getdiskfree(drive, &free) == 0) {
return free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector;
}
#elif defined(HAS_STATVFS)
struct statvfs s;
if (statvfs(path.c_str(), &s) == 0) return static_cast<uint64_t>(s.f_frsize) * s.f_bavail;
#endif
return std::nullopt;
}
bool FiosIsValidFile(const std::string &path, const struct dirent *ent, struct stat *sb)
{
std::string filename = fmt::format("{}" PATHSEP "{}", path, ent->d_name);
return stat(filename.c_str(), sb) == 0;
}
bool FiosIsHiddenFile(const struct dirent *ent)
{
return ent->d_name[0] == '.';
}
void ShowInfoI(const std::string &str)
{
HAB hab;
HMQ hmq;
ULONG rc;
/* init PM env. */
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
/* display the box */
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)str.c_str(), (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_INFORMATION);
/* terminate PM env. */
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
}
void ShowOSErrorBox(const char *buf, bool system)
{
HAB hab;
HMQ hmq;
ULONG rc;
/* init PM env. */
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
/* display the box */
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)buf, (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_ERROR);
/* terminate PM env. */
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
}
std::optional<std::string> GetClipboardContents()
{
/* XXX -- Currently no clipboard support implemented with GCC */
#ifndef __INNOTEK_LIBC__
HAB hab = 0;
if (WinOpenClipbrd(hab)) {
const char *text = (const char *)WinQueryClipbrdData(hab, CF_TEXT);
if (text != nullptr) {
std::string result = text;
WinCloseClipbrd(hab);
return result;
}
WinCloseClipbrd(hab);
}
#endif
return std::nullopt;
}
void OSOpenBrowser(const char *url)
{
// stub only
Debug(misc, 0, "Failed to open url: {}", url);
}
void SetCurrentThreadName(const char *)
{
}

View File

@ -1,27 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD 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, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file os2_main.cpp Main entry for OS/2. */
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../core/random_func.hpp"
#include "../../string_func.h"
#include <time.h>
#include "../../safeguards.h"
int CDECL main(int argc, char *argv[])
{
SetRandomSeed(time(nullptr));
/* Make sure our arguments contain only valid UTF-8 characters. */
for (int i = 0; i < argc; i++) StrMakeValidInPlace(argv[i]);
return openttd_main(argc, argv);
}

View File

@ -1,12 +1,12 @@
add_files(
crashlog_unix.cpp
survey_unix.cpp
CONDITION UNIX AND NOT APPLE AND NOT OPTION_OS2
CONDITION UNIX AND NOT APPLE
)
add_files(
unix.cpp
CONDITION UNIX AND NOT OPTION_OS2
CONDITION UNIX
)
add_files(
@ -14,6 +14,6 @@ add_files(
CONDITION Fontconfig_FOUND
)
if(UNIX AND NOT APPLE AND NOT OPTION_OS2)
if(UNIX AND NOT APPLE)
target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/unix_main.cpp)
endif()

View File

@ -121,14 +121,6 @@
# define NODISCARD [[nodiscard]]
#endif
#if defined(__WATCOMC__)
# define NORETURN
# define CDECL
# define FINAL
# define FALLTHROUGH
# include <malloc.h>
#endif /* __WATCOMC__ */
#if defined(_WIN32)
# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif
@ -236,7 +228,7 @@
# endif /* _WIN32 or WITH_ICONV */
#endif /* STRGEN || SETTINGSGEN */
#if defined(_WIN32) || defined(__OS2__) && !defined(__INNOTEK_LIBC__)
#if defined(_WIN32)
# define PATHSEP "\\"
# define PATHSEPCHAR '\\'
#else
@ -244,7 +236,7 @@
# define PATHSEPCHAR '/'
#endif
#if defined(_MSC_VER) || defined(__WATCOMC__)
#if defined(_MSC_VER)
# define PACK_N(type_dec, n) __pragma(pack(push, n)) type_dec; __pragma(pack(pop))
#elif defined(__MINGW32__)
# define PRAGMA(x) _Pragma(#x)

View File

@ -25,33 +25,6 @@
#include "../window_func.h"
#include "dedicated_v.h"
#ifdef __OS2__
# include <sys/time.h> /* gettimeofday */
# include <sys/types.h>
# include <unistd.h>
# include <conio.h>
# define INCL_DOS
# include <os2.h>
# define STDIN 0 /* file descriptor for standard input */
/**
* Switches OpenTTD to a console app at run-time, instead of a PM app
* Necessary to see stdout, etc.
*/
static void OS2_SwitchToConsoleMode()
{
PPIB pib;
PTIB tib;
DosGetInfoBlocks(&tib, &pib);
/* Change flag from PM to VIO */
pib->pib_ultype = 3;
}
#endif
#if defined(UNIX)
# include <sys/time.h> /* gettimeofday */
# include <sys/types.h>
@ -160,11 +133,6 @@ const char *VideoDriver_Dedicated::Start(const StringList &parm)
_set_error_mode(_OUT_TO_STDERR);
#endif
#ifdef __OS2__
/* For OS/2 we also need to switch to console mode instead of PM mode */
OS2_SwitchToConsoleMode();
#endif
Debug(driver, 1, "Loading dedicated server");
return nullptr;
}
@ -181,7 +149,7 @@ void VideoDriver_Dedicated::MakeDirty(int left, int top, int width, int height)
bool VideoDriver_Dedicated::ChangeResolution(int w, int h) { return false; }
bool VideoDriver_Dedicated::ToggleFullscreen(bool fs) { return false; }
#if defined(UNIX) || defined(__OS2__)
#if defined(UNIX)
static bool InputWaiting()
{
struct timeval tv;
@ -214,7 +182,7 @@ static void DedicatedHandleKeyInput()
if (_exit_game) return;
#if defined(UNIX) || defined(__OS2__)
#if defined(UNIX)
if (fgets(input_line, lengthof(input_line), stdin) == nullptr) return;
#else
/* Handle console input, and signal console thread, it can accept input again */

View File

@ -446,7 +446,7 @@ static uint ConvertSdlKeyIntoMy(SDL_keysym *sym, WChar *character)
}
/* check scancode for BACKQUOTE key, because we want the key left of "1", not anything else (on non-US keyboards) */
#if defined(_WIN32) || defined(__OS2__)
#if defined(_WIN32)
if (sym->scancode == 41) key = WKC_BACKQUOTE;
#elif defined(__APPLE__)
if (sym->scancode == 10) key = WKC_BACKQUOTE;