mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-12-25 02:29:49 +00:00
Unicode friendly!
This commit is contained in:
parent
47e95ba2e6
commit
a6a46a2697
@ -50,11 +50,11 @@ typedef struct _PACKET {
|
|||||||
|
|
||||||
|
|
||||||
BOOLEAN StartPacketDriver(
|
BOOLEAN StartPacketDriver(
|
||||||
LPTSTR ServiceName
|
LPCTSTR ServiceName
|
||||||
);
|
);
|
||||||
|
|
||||||
LPADAPTER PacketOpenAdapter(
|
LPADAPTER PacketOpenAdapter(
|
||||||
LPCSTR AdapterName,
|
LPCTSTR AdapterName,
|
||||||
int16 mode
|
int16 mode
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -95,8 +95,7 @@ BOOLEAN PacketGetMAC( LPADAPTER AdapterObject, LPBYTE address, BOOL permanent );
|
|||||||
BOOLEAN PacketAddMulticast( LPADAPTER AdapterObject, LPBYTE address );
|
BOOLEAN PacketAddMulticast( LPADAPTER AdapterObject, LPBYTE address );
|
||||||
BOOLEAN PacketDelMulticast( LPADAPTER AdapterObject, LPBYTE address );
|
BOOLEAN PacketDelMulticast( LPADAPTER AdapterObject, LPBYTE address );
|
||||||
|
|
||||||
ULONG PacketGetAdapterNames( LPADAPTER lpAdapter, PTSTR pStr, PULONG BufferSize );
|
ULONG PacketGetAdapterNames( LPADAPTER lpAdapter, LPTSTR pStr, PULONG BufferSize );
|
||||||
ULONG PacketSelectAdapterByName( LPADAPTER AdapterObject, LPCSTR name );
|
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
void recycle_write_packet( LPPACKET Packet );
|
void recycle_write_packet( LPPACKET Packet );
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include <windows.h>
|
#include "main.h"
|
||||||
|
#include "util_windows.h"
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
#include "cpu_emulation.h"
|
#include "cpu_emulation.h"
|
||||||
@ -73,26 +74,18 @@ extern "C" {
|
|||||||
#define MAX_MULTICAST 100
|
#define MAX_MULTICAST 100
|
||||||
#define MAX_MULTICAST_SZ (20*ETH_802_3_ADDRESS_LENGTH)
|
#define MAX_MULTICAST_SZ (20*ETH_802_3_ADDRESS_LENGTH)
|
||||||
|
|
||||||
static int os = VER_PLATFORM_WIN32_WINDOWS;
|
|
||||||
|
|
||||||
static ULONG packet_filter = 0;
|
static ULONG packet_filter = 0;
|
||||||
|
|
||||||
|
|
||||||
LPADAPTER PacketOpenAdapter( LPCSTR AdapterName, int16 mode )
|
LPADAPTER PacketOpenAdapter( LPCTSTR AdapterName, int16 mode )
|
||||||
{
|
{
|
||||||
LPADAPTER lpAdapter;
|
LPADAPTER lpAdapter;
|
||||||
BOOLEAN Result = TRUE;
|
BOOLEAN Result = TRUE;
|
||||||
OSVERSIONINFO osv;
|
|
||||||
|
|
||||||
D(bug("Packet32: PacketOpenAdapter\n"));
|
D(bug("Packet32: PacketOpenAdapter\n"));
|
||||||
|
|
||||||
osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
||||||
if(GetVersionEx( &osv )) os = osv.dwPlatformId;
|
|
||||||
|
|
||||||
if(os == VER_PLATFORM_WIN32_NT) {
|
|
||||||
// May fail if user is not an Administrator.
|
// May fail if user is not an Administrator.
|
||||||
StartPacketDriver( "B2ether" );
|
StartPacketDriver( TEXT("B2ether") );
|
||||||
}
|
|
||||||
|
|
||||||
lpAdapter = (LPADAPTER)GlobalAllocPtr( GMEM_MOVEABLE|GMEM_ZEROINIT, sizeof(ADAPTER) );
|
lpAdapter = (LPADAPTER)GlobalAllocPtr( GMEM_MOVEABLE|GMEM_ZEROINIT, sizeof(ADAPTER) );
|
||||||
if (lpAdapter==NULL) {
|
if (lpAdapter==NULL) {
|
||||||
@ -100,10 +93,9 @@ LPADAPTER PacketOpenAdapter( LPCSTR AdapterName, int16 mode )
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(os == VER_PLATFORM_WIN32_NT) {
|
TCHAR device_name[256];
|
||||||
char device_name[256];
|
_sntprintf(lpAdapter->SymbolicLink, lengthof(lpAdapter->SymbolicLink), TEXT("\\\\.\\B2ether_%s"), AdapterName );
|
||||||
wsprintf( lpAdapter->SymbolicLink, "\\\\.\\B2ether_%s", AdapterName );
|
_sntprintf(device_name, lengthof(device_name), TEXT("\\Device\\B2ether_%s"), AdapterName );
|
||||||
wsprintf( device_name, "\\Device\\B2ether_%s", AdapterName );
|
|
||||||
|
|
||||||
// Work around one subtle NT4 bug.
|
// Work around one subtle NT4 bug.
|
||||||
DefineDosDevice(
|
DefineDosDevice(
|
||||||
@ -116,9 +108,6 @@ LPADAPTER PacketOpenAdapter( LPCSTR AdapterName, int16 mode )
|
|||||||
&lpAdapter->SymbolicLink[4],
|
&lpAdapter->SymbolicLink[4],
|
||||||
device_name
|
device_name
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
wsprintf( lpAdapter->SymbolicLink, "\\\\.\\B2ether" );
|
|
||||||
}
|
|
||||||
|
|
||||||
packet_filter = NDIS_PACKET_TYPE_DIRECTED |
|
packet_filter = NDIS_PACKET_TYPE_DIRECTED |
|
||||||
NDIS_PACKET_TYPE_MULTICAST |
|
NDIS_PACKET_TYPE_MULTICAST |
|
||||||
@ -138,10 +127,7 @@ LPADAPTER PacketOpenAdapter( LPCSTR AdapterName, int16 mode )
|
|||||||
0
|
0
|
||||||
);
|
);
|
||||||
if (lpAdapter->hFile != INVALID_HANDLE_VALUE) {
|
if (lpAdapter->hFile != INVALID_HANDLE_VALUE) {
|
||||||
if(*AdapterName && strcmp(AdapterName,"<None>") != 0) {
|
if(*AdapterName && _tcscmp(AdapterName,TEXT("<None>")) != 0) {
|
||||||
if(os == VER_PLATFORM_WIN32_WINDOWS) {
|
|
||||||
PacketSelectAdapterByName( lpAdapter, AdapterName );
|
|
||||||
}
|
|
||||||
PacketSetFilter( lpAdapter, packet_filter );
|
PacketSetFilter( lpAdapter, packet_filter );
|
||||||
}
|
}
|
||||||
return lpAdapter;
|
return lpAdapter;
|
||||||
@ -282,7 +268,6 @@ BOOLEAN PacketSendPacket(
|
|||||||
D(bug("Packet32: PacketSendPacket bytes=%d, sync=%d\n",lpPacket->Length,Sync));
|
D(bug("Packet32: PacketSendPacket bytes=%d, sync=%d\n",lpPacket->Length,Sync));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(os == VER_PLATFORM_WIN32_NT) {
|
|
||||||
lpPacket->OverLapped.Offset = 0;
|
lpPacket->OverLapped.Offset = 0;
|
||||||
lpPacket->OverLapped.OffsetHigh = 0;
|
lpPacket->OverLapped.OffsetHigh = 0;
|
||||||
lpPacket->bIoComplete = FALSE;
|
lpPacket->bIoComplete = FALSE;
|
||||||
@ -326,15 +311,6 @@ BOOLEAN PacketSendPacket(
|
|||||||
recycle_write_packet(lpPacket);
|
recycle_write_packet(lpPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Now: make writes always synchronous under Win9x
|
|
||||||
Sync = TRUE;
|
|
||||||
Result = PacketDeviceIoControl( AdapterObject,
|
|
||||||
lpPacket,
|
|
||||||
IOCTL_PROTOCOL_WRITE,
|
|
||||||
Sync );
|
|
||||||
if(RecyclingAllowed) recycle_write_packet(lpPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
@ -347,7 +323,6 @@ BOOLEAN PacketReceivePacket(
|
|||||||
{
|
{
|
||||||
BOOLEAN Result;
|
BOOLEAN Result;
|
||||||
|
|
||||||
if(os == VER_PLATFORM_WIN32_NT) {
|
|
||||||
lpPacket->OverLapped.Offset=0;
|
lpPacket->OverLapped.Offset=0;
|
||||||
lpPacket->OverLapped.OffsetHigh=0;
|
lpPacket->OverLapped.OffsetHigh=0;
|
||||||
lpPacket->bIoComplete = FALSE;
|
lpPacket->bIoComplete = FALSE;
|
||||||
@ -387,17 +362,6 @@ BOOLEAN PacketReceivePacket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!Result) lpPacket->BytesReceived = 0;
|
if(!Result) lpPacket->BytesReceived = 0;
|
||||||
} else {
|
|
||||||
Result = PacketDeviceIoControl( AdapterObject,
|
|
||||||
lpPacket,
|
|
||||||
IOCTL_PROTOCOL_READ,
|
|
||||||
Sync );
|
|
||||||
if( !Result && !Sync ) {
|
|
||||||
if (GetLastError() == ERROR_IO_PENDING) {
|
|
||||||
Result = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG_PACKETS
|
#if DEBUG_PACKETS
|
||||||
D(bug("Packet32: PacketReceivePacket got %d bytes, result=%d\n",lpPacket->BytesReceived,(int)Result));
|
D(bug("Packet32: PacketReceivePacket got %d bytes, result=%d\n",lpPacket->BytesReceived,(int)Result));
|
||||||
@ -641,7 +605,7 @@ BOOLEAN PacketSetFilter( LPADAPTER AdapterObject, ULONG Filter )
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN StartPacketDriver( LPTSTR ServiceName )
|
BOOLEAN StartPacketDriver( LPCTSTR ServiceName )
|
||||||
{
|
{
|
||||||
BOOLEAN Status = FALSE;
|
BOOLEAN Status = FALSE;
|
||||||
|
|
||||||
@ -658,7 +622,7 @@ BOOLEAN StartPacketDriver( LPTSTR ServiceName )
|
|||||||
} else {
|
} else {
|
||||||
SCServiceHandle = OpenService(SCManagerHandle,ServiceName,SERVICE_START);
|
SCServiceHandle = OpenService(SCManagerHandle,ServiceName,SERVICE_START);
|
||||||
if (SCServiceHandle == NULL) {
|
if (SCServiceHandle == NULL) {
|
||||||
D(bug("Could not open service %s\r\n",ServiceName));
|
D(bug(TEXT("Could not open service %s\r\n"),ServiceName));
|
||||||
} else {
|
} else {
|
||||||
Status = StartService( SCServiceHandle, 0, NULL );
|
Status = StartService( SCServiceHandle, 0, NULL );
|
||||||
if(!Status) {
|
if(!Status) {
|
||||||
@ -694,23 +658,22 @@ BOOLEAN StartPacketDriver( LPTSTR ServiceName )
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG PacketGetAdapterNames( LPADAPTER lpAdapter, PTSTR pStr, PULONG BufferSize )
|
ULONG PacketGetAdapterNames( LPADAPTER lpAdapter, LPTSTR pStr, PULONG BufferSize )
|
||||||
{
|
{
|
||||||
LONG Status;
|
LONG Status;
|
||||||
|
|
||||||
if(os == VER_PLATFORM_WIN32_NT) {
|
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD RegType;
|
DWORD RegType;
|
||||||
|
|
||||||
Status = RegOpenKey(
|
Status = RegOpenKey(
|
||||||
HKEY_LOCAL_MACHINE,
|
HKEY_LOCAL_MACHINE,
|
||||||
"SYSTEM\\CurrentControlSet\\Services\\B2Ether\\Linkage",
|
TEXT("SYSTEM\\CurrentControlSet\\Services\\B2Ether\\Linkage"),
|
||||||
&hKey
|
&hKey
|
||||||
);
|
);
|
||||||
if( Status == ERROR_SUCCESS ) {
|
if( Status == ERROR_SUCCESS ) {
|
||||||
Status = RegQueryValueEx(
|
Status = RegQueryValueEx(
|
||||||
hKey,
|
hKey,
|
||||||
"Export",
|
TEXT("Export"),
|
||||||
NULL,
|
NULL,
|
||||||
&RegType,
|
&RegType,
|
||||||
(LPBYTE)pStr,
|
(LPBYTE)pStr,
|
||||||
@ -718,67 +681,10 @@ ULONG PacketGetAdapterNames( LPADAPTER lpAdapter, PTSTR pStr, PULONG BufferSize
|
|||||||
);
|
);
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (lpAdapter && lpAdapter->hFile != INVALID_HANDLE_VALUE) {
|
|
||||||
LPPACKET Packet = PacketAllocatePacket( lpAdapter, *BufferSize );
|
|
||||||
if(Packet) {
|
|
||||||
memset( pStr, 0, *BufferSize );
|
|
||||||
Packet->Buffer = (PVOID)pStr;
|
|
||||||
Packet->Length = *BufferSize;
|
|
||||||
Status = PacketDeviceIoControl(
|
|
||||||
lpAdapter,
|
|
||||||
Packet,
|
|
||||||
(ULONG)IOCTL_PROTOCOL_MACNAME,
|
|
||||||
TRUE
|
|
||||||
);
|
|
||||||
if(Status) {
|
|
||||||
while(*pStr) {
|
|
||||||
if(*pStr == '|' || *pStr == ' ') *pStr = 0;
|
|
||||||
pStr++;
|
|
||||||
}
|
|
||||||
*(++pStr) = 0;
|
|
||||||
Status = ERROR_SUCCESS;
|
|
||||||
} else {
|
|
||||||
Status = ERROR_ACCESS_DENIED;
|
|
||||||
}
|
|
||||||
*BufferSize = Packet->BytesReceived;
|
|
||||||
PacketFreePacket(Packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ULONG PacketSelectAdapterByName( LPADAPTER lpAdapter, LPCSTR name )
|
|
||||||
{
|
|
||||||
ULONG Status = 0;
|
|
||||||
|
|
||||||
if(os == VER_PLATFORM_WIN32_WINDOWS) {
|
|
||||||
int len = strlen(name) + 1;
|
|
||||||
LPPACKET Packet = PacketAllocatePacket( lpAdapter, len );
|
|
||||||
if(Packet) {
|
|
||||||
Packet->Buffer = (PVOID)name;
|
|
||||||
Packet->Length = len;
|
|
||||||
Status = PacketDeviceIoControl(
|
|
||||||
lpAdapter,
|
|
||||||
Packet,
|
|
||||||
(ULONG)IOCTL_PROTOCOL_SELECT_BY_NAME,
|
|
||||||
TRUE
|
|
||||||
);
|
|
||||||
if(Status) {
|
|
||||||
Status = ERROR_SUCCESS;
|
|
||||||
} else {
|
|
||||||
Status = ERROR_ACCESS_DENIED;
|
|
||||||
}
|
|
||||||
PacketFreePacket(Packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,9 +29,9 @@ extern "C" {
|
|||||||
#include "ntcd.h"
|
#include "ntcd.h"
|
||||||
#include "cdenable.h"
|
#include "cdenable.h"
|
||||||
|
|
||||||
static char *sDriverShort = "cdenable";
|
static LPCTSTR sDriverShort = TEXT("cdenable");
|
||||||
static char *sDriverLong = "System32\\Drivers\\cdenable.sys";
|
static LPCTSTR sDriverLong = TEXT("System32\\Drivers\\cdenable.sys");
|
||||||
static char *sCompleteName = "\\\\.\\cdenable";
|
static LPCTSTR sCompleteName = TEXT("\\\\.\\cdenable");
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -168,7 +168,7 @@ static HANDLE int_sig2 = 0;
|
|||||||
static HANDLE int_send_now = 0;
|
static HANDLE int_send_now = 0;
|
||||||
|
|
||||||
// Prototypes
|
// Prototypes
|
||||||
static LPADAPTER tap_open_adapter(const char *dev_name);
|
static LPADAPTER tap_open_adapter(LPCTSTR dev_name);
|
||||||
static void tap_close_adapter(LPADAPTER fd);
|
static void tap_close_adapter(LPADAPTER fd);
|
||||||
static bool tap_check_version(LPADAPTER fd);
|
static bool tap_check_version(LPADAPTER fd);
|
||||||
static bool tap_set_status(LPADAPTER fd, ULONG status);
|
static bool tap_set_status(LPADAPTER fd, ULONG status);
|
||||||
@ -218,7 +218,7 @@ static NetProtocol *find_protocol(uint16 type)
|
|||||||
|
|
||||||
bool ether_init(void)
|
bool ether_init(void)
|
||||||
{
|
{
|
||||||
char str[256];
|
TCHAR buf[256];
|
||||||
|
|
||||||
// Do nothing if no Ethernet device specified
|
// Do nothing if no Ethernet device specified
|
||||||
const char *name = PrefsFindString("ether");
|
const char *name = PrefsFindString("ether");
|
||||||
@ -248,22 +248,21 @@ bool ether_init(void)
|
|||||||
// Initialize slirp library
|
// Initialize slirp library
|
||||||
if (net_if_type == NET_IF_SLIRP) {
|
if (net_if_type == NET_IF_SLIRP) {
|
||||||
if (slirp_init() < 0) {
|
if (slirp_init() < 0) {
|
||||||
sprintf(str, GetString(STR_SLIRP_NO_DNS_FOUND_WARN));
|
WarningAlert(GetString(STR_SLIRP_NO_DNS_FOUND_WARN));
|
||||||
WarningAlert(str);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open ethernet device
|
// Open ethernet device
|
||||||
const char *dev_name;
|
decltype(tstr(std::declval<const char*>())) dev_name;
|
||||||
switch (net_if_type) {
|
switch (net_if_type) {
|
||||||
case NET_IF_B2ETHER:
|
case NET_IF_B2ETHER:
|
||||||
dev_name = PrefsFindString("etherguid");
|
dev_name = tstr(PrefsFindString("etherguid"));
|
||||||
if (dev_name == NULL || strcmp(name, "b2ether") != 0)
|
if (dev_name == NULL || strcmp(name, "b2ether") != 0)
|
||||||
dev_name = name;
|
dev_name = tstr(name);
|
||||||
break;
|
break;
|
||||||
case NET_IF_TAP:
|
case NET_IF_TAP:
|
||||||
dev_name = PrefsFindString("etherguid");
|
dev_name = tstr(PrefsFindString("etherguid"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (net_if_type == NET_IF_B2ETHER) {
|
if (net_if_type == NET_IF_B2ETHER) {
|
||||||
@ -272,17 +271,17 @@ bool ether_init(void)
|
|||||||
goto open_error;
|
goto open_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = PacketOpenAdapter( dev_name, ether_multi_mode );
|
fd = PacketOpenAdapter( dev_name.get(), ether_multi_mode );
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
sprintf(str, "Could not open ethernet adapter %s.", dev_name);
|
_sntprintf(buf, lengthof(buf), TEXT("Could not open ethernet adapter %s."), dev_name.get());
|
||||||
WarningAlert(str);
|
WarningAlert(buf);
|
||||||
goto open_error;
|
goto open_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Ethernet address
|
// Get Ethernet address
|
||||||
if(!PacketGetMAC(fd,ether_addr,ether_use_permanent)) {
|
if(!PacketGetMAC(fd,ether_addr,ether_use_permanent)) {
|
||||||
sprintf(str, "Could not get hardware address of device %s. Ethernet is not available.", dev_name);
|
_sntprintf(buf, lengthof(buf), TEXT("Could not get hardware address of device %s. Ethernet is not available."), dev_name.get());
|
||||||
WarningAlert(str);
|
WarningAlert(buf);
|
||||||
goto open_error;
|
goto open_error;
|
||||||
}
|
}
|
||||||
D(bug("Real ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
|
D(bug("Real ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
|
||||||
@ -306,28 +305,27 @@ bool ether_init(void)
|
|||||||
goto open_error;
|
goto open_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = tap_open_adapter(dev_name);
|
fd = tap_open_adapter(dev_name.get());
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
sprintf(str, "Could not open ethernet adapter %s.", dev_name);
|
_sntprintf(buf, lengthof(buf), TEXT("Could not open ethernet adapter %s."), dev_name.get());
|
||||||
WarningAlert(str);
|
WarningAlert(buf);
|
||||||
goto open_error;
|
goto open_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tap_check_version(fd)) {
|
if (!tap_check_version(fd)) {
|
||||||
sprintf(str, "Minimal TAP-Win32 version supported is %d.%d.", TAP_VERSION_MIN_MAJOR, TAP_VERSION_MIN_MINOR);
|
_sntprintf(buf, lengthof(buf), TEXT("Minimal TAP-Win32 version supported is %d.%d."), TAP_VERSION_MIN_MAJOR, TAP_VERSION_MIN_MINOR);
|
||||||
WarningAlert(str);
|
WarningAlert(buf);
|
||||||
goto open_error;
|
goto open_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tap_set_status(fd, true)) {
|
if (!tap_set_status(fd, true)) {
|
||||||
sprintf(str, "Could not set media status to connected.");
|
WarningAlert("Could not set media status to connected.");
|
||||||
WarningAlert(str);
|
|
||||||
goto open_error;
|
goto open_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tap_get_mac(fd, ether_addr)) {
|
if (!tap_get_mac(fd, ether_addr)) {
|
||||||
sprintf(str, "Could not get hardware address of device %s. Ethernet is not available.", dev_name);
|
_sntprintf(buf, lengthof(buf), TEXT("Could not get hardware address of device %s. Ethernet is not available."), dev_name.get());
|
||||||
WarningAlert(str);
|
WarningAlert(buf);
|
||||||
goto open_error;
|
goto open_error;
|
||||||
}
|
}
|
||||||
D(bug("Real ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
|
D(bug("Real ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
|
||||||
@ -1168,15 +1166,15 @@ static bool set_wait_request(void)
|
|||||||
* TAP-Win32 glue
|
* TAP-Win32 glue
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static LPADAPTER tap_open_adapter(const char *dev_name)
|
static LPADAPTER tap_open_adapter(LPCTSTR dev_name)
|
||||||
{
|
{
|
||||||
fd = (LPADAPTER)GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(*fd));
|
fd = (LPADAPTER)GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(*fd));
|
||||||
if (fd == NULL)
|
if (fd == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char dev_path[MAX_PATH];
|
TCHAR dev_path[MAX_PATH];
|
||||||
snprintf(dev_path, sizeof(dev_path),
|
_sntprintf(dev_path, lengthof(dev_path),
|
||||||
"\\\\.\\Global\\%s.tap", dev_name);
|
TEXT("\\\\.\\Global\\%s.tap"), dev_name);
|
||||||
|
|
||||||
HANDLE handle = CreateFile(
|
HANDLE handle = CreateFile(
|
||||||
dev_path,
|
dev_path,
|
||||||
|
@ -18,17 +18,18 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "extfs.h"
|
||||||
|
#include "extfs_defs.h"
|
||||||
|
#include "posix_emu.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "sysdeps.h"
|
|
||||||
#include "extfs.h"
|
|
||||||
#include "extfs_defs.h"
|
|
||||||
#include "posix_emu.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@ -127,8 +128,13 @@ static int open_helper(const char *path, const char *add, int flag)
|
|||||||
char helper_path[MAX_PATH_LENGTH];
|
char helper_path[MAX_PATH_LENGTH];
|
||||||
make_helper_path(path, helper_path, add);
|
make_helper_path(path, helper_path, add);
|
||||||
|
|
||||||
if ((flag & O_ACCMODE) == O_RDWR || (flag & O_ACCMODE) == O_WRONLY)
|
switch (flag & (_O_RDONLY | _O_WRONLY | _O_RDWR)) {
|
||||||
|
case _O_WRONLY:
|
||||||
|
case _O_RDWR:
|
||||||
flag |= O_CREAT;
|
flag |= O_CREAT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int fd = open(helper_path, flag, 0666);
|
int fd = open(helper_path, flag, 0666);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (/*errno == ENOENT &&*/ (flag & O_CREAT)) {
|
if (/*errno == ENOENT &&*/ (flag & O_CREAT)) {
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <SDL_thread.h>
|
#include <SDL_thread.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
using std::string;
|
typedef std::basic_string<TCHAR> tstring;
|
||||||
|
|
||||||
#include "cpu_emulation.h"
|
#include "cpu_emulation.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
@ -63,7 +63,7 @@ extern void flush_icache_range(uint8 *start, uint32 size); // from compemu_suppo
|
|||||||
|
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const char ROM_FILE_NAME[] = "ROM";
|
const TCHAR ROM_FILE_NAME[] = TEXT("ROM");
|
||||||
const int SCRATCH_MEM_SIZE = 0x10000; // Size of scratch memory area
|
const int SCRATCH_MEM_SIZE = 0x10000; // Size of scratch memory area
|
||||||
|
|
||||||
|
|
||||||
@ -235,8 +235,8 @@ int main(int argc, char **argv)
|
|||||||
} else if (strcmp(argv[i], "--config") == 0) {
|
} else if (strcmp(argv[i], "--config") == 0) {
|
||||||
argv[i++] = NULL;
|
argv[i++] = NULL;
|
||||||
if (i < argc) {
|
if (i < argc) {
|
||||||
extern string UserPrefsPath; // from prefs_windows.cpp
|
extern tstring UserPrefsPath; // from prefs_windows.cpp
|
||||||
UserPrefsPath = argv[i];
|
UserPrefsPath = to_tstring(argv[i]);
|
||||||
argv[i] = NULL;
|
argv[i] = NULL;
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "--rominfo") == 0) {
|
} else if (strcmp(argv[i], "--rominfo") == 0) {
|
||||||
@ -277,9 +277,11 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// Check that drivers are installed
|
// Check that drivers are installed
|
||||||
if (!check_drivers())
|
if (!check_drivers())
|
||||||
QuitEmulator();
|
QuitEmulator();
|
||||||
|
#endif
|
||||||
|
|
||||||
// FIXME: default to DIB driver
|
// FIXME: default to DIB driver
|
||||||
if (getenv("SDL_VIDEODRIVER") == NULL)
|
if (getenv("SDL_VIDEODRIVER") == NULL)
|
||||||
@ -359,10 +361,10 @@ int main(int argc, char **argv)
|
|||||||
D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac));
|
D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac));
|
||||||
|
|
||||||
// Get rom file path from preferences
|
// Get rom file path from preferences
|
||||||
const char *rom_path = PrefsFindString("rom");
|
auto rom_path = tstr(PrefsFindString("rom"));
|
||||||
|
|
||||||
// Load Mac ROM
|
// Load Mac ROM
|
||||||
HANDLE rom_fh = CreateFile(rom_path ? rom_path : ROM_FILE_NAME,
|
HANDLE rom_fh = CreateFile(rom_path ? rom_path.get() : ROM_FILE_NAME,
|
||||||
GENERIC_READ,
|
GENERIC_READ,
|
||||||
FILE_SHARE_READ, NULL,
|
FILE_SHARE_READ, NULL,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
@ -639,7 +641,12 @@ HWND GetMainWindowHandle(void)
|
|||||||
static void display_alert(int title_id, const char *text, int flags)
|
static void display_alert(int title_id, const char *text, int flags)
|
||||||
{
|
{
|
||||||
HWND hMainWnd = GetMainWindowHandle();
|
HWND hMainWnd = GetMainWindowHandle();
|
||||||
MessageBox(hMainWnd, text, GetString(title_id), MB_OK | flags);
|
MessageBoxA(hMainWnd, text, GetString(title_id), MB_OK | flags);
|
||||||
|
}
|
||||||
|
static void display_alert(int title_id, const wchar_t *text, int flags)
|
||||||
|
{
|
||||||
|
HWND hMainWnd = GetMainWindowHandle();
|
||||||
|
MessageBoxW(hMainWnd, text, GetStringW(title_id).get(), MB_OK | flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -655,6 +662,14 @@ void ErrorAlert(const char *text)
|
|||||||
VideoQuitFullScreen();
|
VideoQuitFullScreen();
|
||||||
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP);
|
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP);
|
||||||
}
|
}
|
||||||
|
void ErrorAlert(const wchar_t *text)
|
||||||
|
{
|
||||||
|
if (PrefsFindBool("nogui"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
VideoQuitFullScreen();
|
||||||
|
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -668,6 +683,13 @@ void WarningAlert(const char *text)
|
|||||||
|
|
||||||
display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONINFORMATION);
|
display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
|
void WarningAlert(const wchar_t *text)
|
||||||
|
{
|
||||||
|
if (PrefsFindBool("nogui"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONINFORMATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -114,12 +114,12 @@ int my_errno = 0;
|
|||||||
|
|
||||||
#define VIRTUAL_ROOT_ID ((HANDLE)0xFFFFFFFE)
|
#define VIRTUAL_ROOT_ID ((HANDLE)0xFFFFFFFE)
|
||||||
|
|
||||||
static const char *desktop_name = "Virtual Desktop";
|
static LPCTSTR desktop_name = TEXT("Virtual Desktop");
|
||||||
static const char *custom_icon_name = "Icon\r";
|
static const char *custom_icon_name = "Icon\r";
|
||||||
#define my_computer GetString(STR_EXTFS_VOLUME_NAME)
|
#define my_computer GetString(STR_EXTFS_VOLUME_NAME)
|
||||||
|
|
||||||
static char lb1[MAX_PATH_LENGTH];
|
static TCHAR lb1[MAX_PATH_LENGTH];
|
||||||
static char lb2[MAX_PATH_LENGTH];
|
static TCHAR lb2[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
#define MRP(path) translate(path,lb1)
|
#define MRP(path) translate(path,lb1)
|
||||||
#define MRP2(path) translate(path,lb2)
|
#define MRP2(path) translate(path,lb2)
|
||||||
@ -127,8 +127,8 @@ static char lb2[MAX_PATH_LENGTH];
|
|||||||
#define DISABLE_ERRORS UINT prevmode = SetErrorMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS)
|
#define DISABLE_ERRORS UINT prevmode = SetErrorMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS)
|
||||||
#define RESTORE_ERRORS SetErrorMode(prevmode);
|
#define RESTORE_ERRORS SetErrorMode(prevmode);
|
||||||
|
|
||||||
static char host_drive_list[512];
|
static TCHAR host_drive_list[512];
|
||||||
static char virtual_root[248]; // Not _MAX_PATH
|
static TCHAR virtual_root[248]; // Not _MAX_PATH
|
||||||
|
|
||||||
const uint8 my_comp_icon[2670] = {
|
const uint8 my_comp_icon[2670] = {
|
||||||
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0xD8, 0x00, 0x00, 0x08, 0xD8, 0x00, 0x00, 0x00, 0x96,
|
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0xD8, 0x00, 0x00, 0x08, 0xD8, 0x00, 0x00, 0x00, 0x96,
|
||||||
@ -302,12 +302,12 @@ const uint8 my_comp_icon[2670] = {
|
|||||||
|
|
||||||
static bool use_streams[ 'Z'-'A'+1 ];
|
static bool use_streams[ 'Z'-'A'+1 ];
|
||||||
|
|
||||||
static bool is_ntfs_volume( char *rootdir )
|
static bool is_ntfs_volume(LPCTSTR rootdir)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
char tst_file[_MAX_PATH], tst_stream[_MAX_PATH];
|
TCHAR tst_file[_MAX_PATH], tst_stream[_MAX_PATH];
|
||||||
sprintf( tst_file, "%sb2query.tmp", rootdir );
|
_sntprintf( tst_file, lengthof(tst_file), TEXT("%sb2query.tmp"), rootdir );
|
||||||
sprintf( tst_stream, "%s:AFP_AfpInfo", tst_file );
|
_sntprintf( tst_stream, lengthof(tst_stream), TEXT("%s:AFP_AfpInfo"), tst_file );
|
||||||
if(!exists(tst_file)) {
|
if(!exists(tst_file)) {
|
||||||
if(create_file( tst_file, 0 )) {
|
if(create_file( tst_file, 0 )) {
|
||||||
if(create_file( tst_stream, 0 )) {
|
if(create_file( tst_stream, 0 )) {
|
||||||
@ -353,12 +353,11 @@ void init_posix_emu(void)
|
|||||||
const char *extdrives = PrefsFindString("extdrives");
|
const char *extdrives = PrefsFindString("extdrives");
|
||||||
|
|
||||||
// Set up drive list.
|
// Set up drive list.
|
||||||
int outinx = 0;
|
size_t outinx = 0;
|
||||||
for( char letter = 'A'; letter <= 'Z'; letter++ ) {
|
for( TCHAR letter = TEXT('A'); letter <= TEXT('Z'); letter++ ) {
|
||||||
if(extdrives && !strchr(extdrives,letter)) continue;
|
if(extdrives && !strchr(extdrives,letter)) continue;
|
||||||
int i = (int)( letter - 'A' );
|
TCHAR rootdir[20];
|
||||||
char rootdir[20];
|
_sntprintf( rootdir, lengthof(rootdir), TEXT("%c:\\"), letter );
|
||||||
wsprintf( rootdir, "%c:\\", letter );
|
|
||||||
use_streams[ letter - 'A' ] = false;
|
use_streams[ letter - 'A' ] = false;
|
||||||
switch(GetDriveType(rootdir)) {
|
switch(GetDriveType(rootdir)) {
|
||||||
case DRIVE_FIXED:
|
case DRIVE_FIXED:
|
||||||
@ -368,7 +367,7 @@ void init_posix_emu(void)
|
|||||||
// fall
|
// fall
|
||||||
case DRIVE_REMOVABLE:
|
case DRIVE_REMOVABLE:
|
||||||
case DRIVE_CDROM:
|
case DRIVE_CDROM:
|
||||||
if(outinx < sizeof(host_drive_list)) {
|
if(outinx < lengthof(host_drive_list)) {
|
||||||
host_drive_list[outinx] = letter;
|
host_drive_list[outinx] = letter;
|
||||||
outinx += 2;
|
outinx += 2;
|
||||||
}
|
}
|
||||||
@ -377,14 +376,13 @@ void init_posix_emu(void)
|
|||||||
|
|
||||||
// Set up virtual desktop root.
|
// Set up virtual desktop root.
|
||||||
// TODO: this should be customizable.
|
// TODO: this should be customizable.
|
||||||
GetModuleFileName( NULL, virtual_root, sizeof(virtual_root) );
|
GetModuleFileName( NULL, virtual_root, lengthof(virtual_root) );
|
||||||
char *p = strrchr( virtual_root, '\\' );
|
TCHAR *p = _tcsrchr( virtual_root, TEXT('\\') );
|
||||||
if(p) {
|
if(p) {
|
||||||
*(++p) = 0;
|
_tcscpy( ++p, desktop_name );
|
||||||
strcat( virtual_root, desktop_name );
|
|
||||||
} else {
|
} else {
|
||||||
// should never happen
|
// should never happen
|
||||||
sprintf( virtual_root, "C:\\%s", desktop_name );
|
_sntprintf( virtual_root, lengthof(virtual_root), TEXT("C:\\%s"), desktop_name );
|
||||||
}
|
}
|
||||||
CreateDirectory( virtual_root, 0 );
|
CreateDirectory( virtual_root, 0 );
|
||||||
|
|
||||||
@ -433,14 +431,14 @@ static void charset_host2mac( char *s )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void charset_mac2host( char *s )
|
static void charset_mac2host( LPTSTR s )
|
||||||
{
|
{
|
||||||
int i, convert, len = strlen(s);
|
size_t len = _tcslen(s);
|
||||||
|
|
||||||
D(bug("charset_mac2host(%s)...\n", s));
|
D(bug(TEXT("charset_mac2host(%s)...\n"), s));
|
||||||
|
|
||||||
for( i=len-1; i>=0; i-- ) {
|
for( size_t i=len; i-->0; ) {
|
||||||
convert = 0;
|
bool convert = false;
|
||||||
switch( (unsigned char)s[i] ) {
|
switch( (unsigned char)s[i] ) {
|
||||||
// case '\r': // handled by "default"
|
// case '\r': // handled by "default"
|
||||||
// case '\n':
|
// case '\n':
|
||||||
@ -455,61 +453,61 @@ static void charset_mac2host( char *s )
|
|||||||
case '>':
|
case '>':
|
||||||
case '|':
|
case '|':
|
||||||
case '%':
|
case '%':
|
||||||
convert = 1;
|
convert = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if((unsigned char)s[i] < ' ') convert = 1;
|
if((unsigned char)s[i] < ' ') convert = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(convert) {
|
if(convert) {
|
||||||
char sml[10];
|
TCHAR sml[10];
|
||||||
sprintf( sml, "%%%02X", s[i] );
|
_sntprintf( sml, lengthof(sml), TEXT("%%%02X"), s[i] );
|
||||||
memmove( &s[i+2], &s[i], strlen(&s[i])+1 );
|
memmove( &s[i+2], &s[i], (_tcslen(&s[i])+1) * sizeof(TCHAR) );
|
||||||
memmove( &s[i], sml, 3 );
|
memmove( &s[i], sml, 3 * sizeof(TCHAR) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
D(bug("charset_mac2host = %s\n", s));
|
D(bug(TEXT("charset_mac2host = %s\n"), s));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void make_mask(
|
static void make_mask(
|
||||||
char *mask,
|
TCHAR *mask,
|
||||||
const char *dir,
|
LPCTSTR dir,
|
||||||
const char *a1,
|
LPCTSTR a1,
|
||||||
const char *a2
|
LPCTSTR a2
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
strcpy( mask, dir );
|
_tcscpy( mask, dir );
|
||||||
|
|
||||||
int len = strlen(mask);
|
size_t len = _tcslen(mask);
|
||||||
if( len && mask[len-1] != '\\' ) strcat( mask, "\\" );
|
if( len && mask[len-1] != '\\' ) _tcscat( mask, TEXT("\\") );
|
||||||
|
|
||||||
if( a1 ) strcat( mask, a1 );
|
if( a1 ) _tcscat( mask, a1 );
|
||||||
if( a2 ) strcat( mask, a2 );
|
if( a2 ) _tcscat( mask, a2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// !!UNC
|
// !!UNC
|
||||||
static char *translate( const char *path, char *buffer )
|
static LPTSTR translate( LPCTSTR path, TCHAR *buffer )
|
||||||
{
|
{
|
||||||
char *l = host_drive_list;
|
TCHAR *l = host_drive_list;
|
||||||
char *p = (char *)path;
|
const TCHAR *p = path;
|
||||||
|
|
||||||
while(*l) {
|
while(*l) {
|
||||||
if(toupper(p[1]) == toupper(*l)) break;
|
if(_totupper(p[1]) == _totupper(*l)) break;
|
||||||
l += strlen(l) + 1;
|
l += _tcslen(l) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p[0] == '\\' && *l && (p[2] == 0 || p[2] == ':' || p[2] == '\\')) {
|
if(p[0] == TEXT('\\') && *l && (p[2] == 0 || p[2] == TEXT(':') || p[2] == TEXT('\\'))) {
|
||||||
p += 2;
|
p += 2;
|
||||||
if(*p == ':') p++;
|
if(*p == TEXT(':')) p++;
|
||||||
if(*p == '\\') p++;
|
if(*p == TEXT('\\')) p++;
|
||||||
sprintf( buffer, "%c:\\%s", *l, p );
|
_sntprintf( buffer, MAX_PATH_LENGTH, TEXT("%c:\\%s"), *l, p );
|
||||||
} else {
|
} else {
|
||||||
if(*path == '\\') {
|
if(*path == TEXT('\\')) {
|
||||||
sprintf( buffer, "%s%s", virtual_root, path );
|
_sntprintf( buffer, MAX_PATH_LENGTH, TEXT("%s%s"), virtual_root, path );
|
||||||
} else {
|
} else {
|
||||||
int len = strlen(path);
|
int len = _tcslen(path);
|
||||||
if(len == 0 || path[len-1] == '\\') {
|
if(len == 0 || path[len-1] == TEXT('\\')) {
|
||||||
make_mask( buffer, virtual_root, path, my_computer );
|
make_mask( buffer, virtual_root, path, tstr(my_computer).get() );
|
||||||
} else {
|
} else {
|
||||||
make_mask( buffer, virtual_root, path, 0 );
|
make_mask( buffer, virtual_root, path, 0 );
|
||||||
}
|
}
|
||||||
@ -521,10 +519,10 @@ static char *translate( const char *path, char *buffer )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
static void strip_trailing_bs( char *path )
|
static void strip_trailing_bs( LPTSTR path )
|
||||||
{
|
{
|
||||||
int len = strlen(path);
|
size_t len = _tcslen(path);
|
||||||
if(len > 0 && path[len-1] == '\\') path[len-1] = 0;
|
if(len > 0 && path[len-1] == TEXT('\\')) path[len-1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* defined is util_windows.cpp */
|
#if 0 /* defined is util_windows.cpp */
|
||||||
@ -546,7 +544,7 @@ static int exists( const char *p )
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int is_dir( char *p )
|
static int is_dir( LPCTSTR p )
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA fdata;
|
WIN32_FIND_DATA fdata;
|
||||||
|
|
||||||
@ -560,31 +558,31 @@ static int is_dir( char *p )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int myRemoveDirectory( const char *source )
|
static int myRemoveDirectory( LPCTSTR source )
|
||||||
{
|
{
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
WIN32_FIND_DATA FindFileData;
|
WIN32_FIND_DATA FindFileData;
|
||||||
int ok, result = 1;
|
int ok, result = 1;
|
||||||
char mask[_MAX_PATH];
|
TCHAR mask[_MAX_PATH];
|
||||||
|
|
||||||
D(bug("removing folder %s\n", source));
|
D(bug(TEXT("removing folder %s\n"), source));
|
||||||
|
|
||||||
make_mask( mask, source, "*.*", 0 );
|
make_mask( mask, source, TEXT("*.*"), 0 );
|
||||||
|
|
||||||
fh = FindFirstFile( mask, &FindFileData );
|
fh = FindFirstFile( mask, &FindFileData );
|
||||||
ok = fh != INVALID_HANDLE_VALUE;
|
ok = fh != INVALID_HANDLE_VALUE;
|
||||||
while(ok) {
|
while(ok) {
|
||||||
make_mask( mask, source, FindFileData.cFileName, 0 );
|
make_mask( mask, source, FindFileData.cFileName, 0 );
|
||||||
D(bug("removing item %s\n", mask));
|
D(bug(TEXT("removing item %s\n"), mask));
|
||||||
int isdir = (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
int isdir = (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
if(isdir) {
|
if(isdir) {
|
||||||
// must delete ".finf", ".rsrc" but not ".", ".."
|
// must delete ".finf", ".rsrc" but not ".", ".."
|
||||||
if(strcmp(FindFileData.cFileName,".") && strcmp(FindFileData.cFileName,"..")) {
|
if(_tcscmp(FindFileData.cFileName,TEXT(".")) && _tcscmp(FindFileData.cFileName,TEXT(".."))) {
|
||||||
result = myRemoveDirectory( mask );
|
result = myRemoveDirectory( mask );
|
||||||
if(!result) break;
|
if(!result) break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
D(bug("DeleteFile %s\n", mask));
|
D(bug(TEXT("DeleteFile %s\n"), mask));
|
||||||
result = DeleteFile( mask );
|
result = DeleteFile( mask );
|
||||||
if(!result) break;
|
if(!result) break;
|
||||||
}
|
}
|
||||||
@ -592,41 +590,41 @@ static int myRemoveDirectory( const char *source )
|
|||||||
}
|
}
|
||||||
if(fh != INVALID_HANDLE_VALUE) FindClose( fh );
|
if(fh != INVALID_HANDLE_VALUE) FindClose( fh );
|
||||||
if(result) {
|
if(result) {
|
||||||
D(bug("RemoveDirectory %s\n", source));
|
D(bug(TEXT("RemoveDirectory %s\n"), source));
|
||||||
result = RemoveDirectory( source );
|
result = RemoveDirectory( source );
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void make_folders( char *path )
|
static void make_folders( LPCTSTR path )
|
||||||
{
|
{
|
||||||
char local_path[_MAX_PATH], *p;
|
TCHAR local_path[_MAX_PATH], *p;
|
||||||
strcpy( local_path, path );
|
_tcscpy( local_path, path );
|
||||||
p = strrchr( local_path, '\\' );
|
p = _tcsrchr( local_path, TEXT('\\') );
|
||||||
if(p) {
|
if(p) {
|
||||||
*p = 0;
|
*p = 0;
|
||||||
if(strlen(local_path) > 3) {
|
if(_tcslen(local_path) > 3) {
|
||||||
make_folders(local_path);
|
make_folders(local_path);
|
||||||
mkdir(local_path);
|
_tmkdir(local_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// !!UNC
|
// !!UNC
|
||||||
static bool is_same_drive( char *p1, char *p2 )
|
static bool is_same_drive( LPCTSTR p1, LPCTSTR p2 )
|
||||||
{
|
{
|
||||||
return toupper(*p1) == toupper(*p2);
|
return _totupper(*p1) == _totupper(*p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used when the drives are known to be different.
|
// Used when the drives are known to be different.
|
||||||
// Can't use MoveFileEx() etc because of the Win9x limitations.
|
// Can't use MoveFileEx() etc because of the Win9x limitations.
|
||||||
// It would simulate CopyFile*() -- DeleteFile*() anyway
|
// It would simulate CopyFile*() -- DeleteFile*() anyway
|
||||||
int file_move_copy( char *src, char *dst, bool delete_old )
|
static int file_move_copy( LPCTSTR src, LPCTSTR dst, bool delete_old )
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
my_errno = 0;
|
my_errno = 0;
|
||||||
|
|
||||||
D(bug("file_copy %s -> %s\n", src, dst));
|
D(bug(TEXT("file_copy %s -> %s\n"), src, dst));
|
||||||
|
|
||||||
// Fail if exists -- it's up to MacOS to move things to Trash
|
// Fail if exists -- it's up to MacOS to move things to Trash
|
||||||
if(CopyFile(src,dst,TRUE)) {
|
if(CopyFile(src,dst,TRUE)) {
|
||||||
@ -644,24 +642,24 @@ int file_move_copy( char *src, char *dst, bool delete_old )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_move( char *src, char *dst )
|
static int file_move( LPCTSTR src, LPCTSTR dst )
|
||||||
{
|
{
|
||||||
return file_move_copy( src, dst, true );
|
return file_move_copy( src, dst, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_copy( char *src, char *dst )
|
static int file_copy( LPCTSTR src, LPCTSTR dst )
|
||||||
{
|
{
|
||||||
return file_move_copy( src, dst, false );
|
return file_move_copy( src, dst, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
int folder_copy( char *folder_src, char *folder_dst )
|
static int folder_copy( LPCTSTR folder_src, LPCTSTR folder_dst )
|
||||||
{
|
{
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
WIN32_FIND_DATA FindFileData;
|
WIN32_FIND_DATA FindFileData;
|
||||||
int ok, result = 0;
|
int ok, result = 0;
|
||||||
char mask[_MAX_PATH];
|
TCHAR mask[_MAX_PATH];
|
||||||
|
|
||||||
D(bug("copying folder %s -> \n", folder_src, folder_dst));
|
D(bug(TEXT("copying folder %s -> \n"), folder_src, folder_dst));
|
||||||
|
|
||||||
my_errno = 0;
|
my_errno = 0;
|
||||||
|
|
||||||
@ -670,18 +668,18 @@ int folder_copy( char *folder_src, char *folder_dst )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
make_mask( mask, folder_src, "*.*", 0 );
|
make_mask( mask, folder_src, TEXT("*.*"), 0 );
|
||||||
|
|
||||||
fh = FindFirstFile( mask, &FindFileData );
|
fh = FindFirstFile( mask, &FindFileData );
|
||||||
ok = fh != INVALID_HANDLE_VALUE;
|
ok = fh != INVALID_HANDLE_VALUE;
|
||||||
while(ok) {
|
while(ok) {
|
||||||
make_mask( mask, folder_src, FindFileData.cFileName, 0 );
|
make_mask( mask, folder_src, FindFileData.cFileName, 0 );
|
||||||
int isdir = (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
int isdir = (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
char target[_MAX_PATH];
|
TCHAR target[_MAX_PATH];
|
||||||
make_mask( target, folder_dst, FindFileData.cFileName, 0 );
|
make_mask( target, folder_dst, FindFileData.cFileName, 0 );
|
||||||
D(bug("copying item %s -> %s\n", mask, target));
|
D(bug(TEXT("copying item %s -> %s\n"), mask, target));
|
||||||
if(isdir) {
|
if(isdir) {
|
||||||
if(strcmp(FindFileData.cFileName,".") && strcmp(FindFileData.cFileName,"..")) {
|
if(_tcscmp(FindFileData.cFileName,TEXT(".")) && _tcscmp(FindFileData.cFileName,TEXT(".."))) {
|
||||||
result = folder_copy( mask, target );
|
result = folder_copy( mask, target );
|
||||||
if(result < 0) break;
|
if(result < 0) break;
|
||||||
}
|
}
|
||||||
@ -715,12 +713,11 @@ static int make_dentry( struct DIR *d )
|
|||||||
memset( &d->de, 0, sizeof(d->de) );
|
memset( &d->de, 0, sizeof(d->de) );
|
||||||
if(d->h != INVALID_HANDLE_VALUE) {
|
if(d->h != INVALID_HANDLE_VALUE) {
|
||||||
if( (d->FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 &&
|
if( (d->FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 &&
|
||||||
*d->FindFileData.cFileName == '.')
|
*d->FindFileData.cFileName == TEXT('.'))
|
||||||
{
|
{
|
||||||
ok = 0;
|
ok = 0;
|
||||||
} else {
|
} else {
|
||||||
strncpy( d->de.d_name, d->FindFileData.cFileName, sizeof(d->de.d_name)-1 );
|
strlcpy( d->de.d_name, d->FindFileData.cFileName, lengthof(d->de.d_name) );
|
||||||
d->de.d_name[sizeof(d->de.d_name)-1] = 0;
|
|
||||||
charset_host2mac( d->de.d_name );
|
charset_host2mac( d->de.d_name );
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
@ -739,14 +736,14 @@ struct dirent *readdir( struct DIR *d )
|
|||||||
if(d->h == VIRTUAL_ROOT_ID) {
|
if(d->h == VIRTUAL_ROOT_ID) {
|
||||||
make_dentry(d);
|
make_dentry(d);
|
||||||
de = &d->de;
|
de = &d->de;
|
||||||
d->vname_list += strlen(d->vname_list) + 1;
|
d->vname_list += _tcslen(d->vname_list) + 1;
|
||||||
if(*d->vname_list) {
|
if(*d->vname_list) {
|
||||||
strcpy( d->FindFileData.cFileName, d->vname_list );
|
_tcscpy( d->FindFileData.cFileName, d->vname_list );
|
||||||
d->FindFileData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
d->FindFileData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
||||||
} else {
|
} else {
|
||||||
// Out of static drive entries. Continue with other stuff.
|
// Out of static drive entries. Continue with other stuff.
|
||||||
char mask[MAX_PATH_LENGTH];
|
TCHAR mask[MAX_PATH_LENGTH];
|
||||||
make_mask( mask, virtual_root, "*.*", 0 );
|
make_mask( mask, virtual_root, TEXT("*.*"), 0 );
|
||||||
d->h = FindFirstFile( mask, &d->FindFileData );
|
d->h = FindFirstFile( mask, &d->FindFileData );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -778,23 +775,24 @@ struct dirent *readdir( struct DIR *d )
|
|||||||
struct DIR *opendir( const char *path )
|
struct DIR *opendir( const char *path )
|
||||||
{
|
{
|
||||||
DISABLE_ERRORS;
|
DISABLE_ERRORS;
|
||||||
|
auto tpath = tstr(path);
|
||||||
DIR *d = new DIR;
|
DIR *d = new DIR;
|
||||||
if(d) {
|
if(d) {
|
||||||
memset( d, 0, sizeof(DIR) );
|
memset( d, 0, sizeof(DIR) );
|
||||||
if(*path == 0) {
|
if(*tpath.get() == 0) {
|
||||||
d->vname_list = host_drive_list;
|
d->vname_list = host_drive_list;
|
||||||
if(d->vname_list) {
|
if(d->vname_list) {
|
||||||
d->h = VIRTUAL_ROOT_ID;
|
d->h = VIRTUAL_ROOT_ID;
|
||||||
strcpy( d->FindFileData.cFileName, d->vname_list );
|
_tcscpy( d->FindFileData.cFileName, d->vname_list );
|
||||||
d->FindFileData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
d->FindFileData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
||||||
} else {
|
} else {
|
||||||
d->h = INVALID_HANDLE_VALUE;
|
d->h = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char mask[MAX_PATH_LENGTH];
|
TCHAR mask[MAX_PATH_LENGTH];
|
||||||
make_mask( mask, MRP(path), "*.*", 0 );
|
make_mask( mask, MRP(tpath.get()), TEXT("*.*"), 0 );
|
||||||
|
|
||||||
D(bug("opendir path=%s, mask=%s\n", path, mask));
|
D(bug(TEXT("opendir path=%s, mask=%s\n"), tpath.get(), mask));
|
||||||
|
|
||||||
d->h = FindFirstFile( mask, &d->FindFileData );
|
d->h = FindFirstFile( mask, &d->FindFileData );
|
||||||
if(d->h == INVALID_HANDLE_VALUE) {
|
if(d->h == INVALID_HANDLE_VALUE) {
|
||||||
@ -804,7 +802,7 @@ struct DIR *opendir( const char *path )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
D(bug("opendir(%s,%s) = %08x\n", path, MRP(path), d));
|
D(bug(TEXT("opendir(%s,%s) = %08x\n"), tpath.get(), MRP(tpath.get()), d));
|
||||||
|
|
||||||
RESTORE_ERRORS;
|
RESTORE_ERRORS;
|
||||||
|
|
||||||
@ -823,16 +821,17 @@ int my_stat( const char *path, struct my_stat *st )
|
|||||||
{
|
{
|
||||||
DISABLE_ERRORS;
|
DISABLE_ERRORS;
|
||||||
|
|
||||||
|
auto tpath = tstr(path);
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if(*path == 0) {
|
if(*tpath.get() == 0) {
|
||||||
/// virtual root
|
/// virtual root
|
||||||
memset( st, 0, sizeof(struct my_stat) );
|
memset( st, 0, sizeof(struct my_stat) );
|
||||||
st->st_mode = _S_IFDIR;
|
st->st_mode = _S_IFDIR;
|
||||||
result = 0;
|
result = 0;
|
||||||
my_errno = 0;
|
my_errno = 0;
|
||||||
} else {
|
} else {
|
||||||
result = stat( MRP(path), (struct stat *)st );
|
result = _tstat( MRP(tpath.get()), (struct _stat *)st );
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
my_errno = errno;
|
my_errno = errno;
|
||||||
} else {
|
} else {
|
||||||
@ -840,7 +839,7 @@ int my_stat( const char *path, struct my_stat *st )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
D(bug("stat(%s,%s) = %d\n", path, MRP(path), result));
|
D(bug(TEXT("stat(%s,%s) = %d\n"), tpath.get(), MRP(tpath.get()), result));
|
||||||
if(result >= 0) dump_stat( st );
|
if(result >= 0) dump_stat( st );
|
||||||
RESTORE_ERRORS;
|
RESTORE_ERRORS;
|
||||||
return result;
|
return result;
|
||||||
@ -849,7 +848,7 @@ int my_stat( const char *path, struct my_stat *st )
|
|||||||
int my_fstat( int fd, struct my_stat *st )
|
int my_fstat( int fd, struct my_stat *st )
|
||||||
{
|
{
|
||||||
DISABLE_ERRORS;
|
DISABLE_ERRORS;
|
||||||
int result = fstat( fd, (struct stat *)st );
|
int result = _fstat( fd, (struct _stat *)st );
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
my_errno = errno;
|
my_errno = errno;
|
||||||
} else {
|
} else {
|
||||||
@ -865,24 +864,25 @@ int my_open( const char *path, int mode, ... )
|
|||||||
{
|
{
|
||||||
DISABLE_ERRORS;
|
DISABLE_ERRORS;
|
||||||
int result;
|
int result;
|
||||||
char *p = MRP(path);
|
auto tpath = tstr(path);
|
||||||
|
LPCTSTR p = MRP(tpath.get());
|
||||||
|
|
||||||
// Windows "open" does not handle _O_CREAT and _O_BINARY as it should
|
// Windows "open" does not handle _O_CREAT and _O_BINARY as it should
|
||||||
if(mode & _O_CREAT) {
|
if(mode & _O_CREAT) {
|
||||||
if(exists(p)) {
|
if(exists(p)) {
|
||||||
result = open( p, mode & ~_O_CREAT );
|
result = _topen( p, mode & ~_O_CREAT );
|
||||||
D(bug("open-nocreat(%s,%s,%d) = %d\n", path, p, mode, result));
|
D(bug(TEXT("open-nocreat(%s,%s,%d) = %d\n"), tpath.get(), p, mode, result));
|
||||||
} else {
|
} else {
|
||||||
result = creat( p, _S_IWRITE|_S_IREAD );
|
result = _tcreat( p, _S_IWRITE|_S_IREAD );
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
make_folders(p);
|
make_folders(p);
|
||||||
result = creat( p, _S_IWRITE|_S_IREAD );
|
result = _tcreat( p, _S_IWRITE|_S_IREAD );
|
||||||
}
|
}
|
||||||
D(bug("open-creat(%s,%s,%d) = %d\n", path, p, mode, result));
|
D(bug(TEXT("open-creat(%s,%s,%d) = %d\n"), tpath.get(), p, mode, result));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = open( p, mode );
|
result = _topen( p, mode );
|
||||||
D(bug("open(%s,%s,%d) = %d\n", path, p, mode, result));
|
D(bug(TEXT("open(%s,%s,%d) = %d\n"), tpath.get(), p, mode, result));
|
||||||
}
|
}
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
my_errno = errno;
|
my_errno = errno;
|
||||||
@ -898,15 +898,17 @@ int my_rename( const char *old_path, const char *new_path )
|
|||||||
{
|
{
|
||||||
DISABLE_ERRORS;
|
DISABLE_ERRORS;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
char *p_old = MRP(old_path);
|
auto told_path = tstr(old_path);
|
||||||
char *p_new = MRP2(new_path);
|
auto tnew_path = tstr(new_path);
|
||||||
|
LPCTSTR p_old = MRP(told_path.get());
|
||||||
|
LPCTSTR p_new = MRP2(tnew_path.get());
|
||||||
|
|
||||||
result = my_access(old_path,0);
|
result = my_access(old_path,0);
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
// my_errno already set
|
// my_errno already set
|
||||||
} else {
|
} else {
|
||||||
if(is_same_drive(p_old,p_new)) {
|
if(is_same_drive(p_old,p_new)) {
|
||||||
result = rename( p_old, p_new );
|
result = _trename( p_old, p_new );
|
||||||
if(result != 0) { // by definition, rename may also return a positive value to indicate an error
|
if(result != 0) { // by definition, rename may also return a positive value to indicate an error
|
||||||
my_errno = errno;
|
my_errno = errno;
|
||||||
} else {
|
} else {
|
||||||
@ -932,7 +934,7 @@ int my_rename( const char *old_path, const char *new_path )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
D(bug("rename(%s,%s,%s,%s) = %d\n", old_path, p_old, new_path, p_new, result));
|
D(bug(TEXT("rename(%s,%s,%s,%s) = %d\n"), told_path.get(), p_old, tnew_path.get(), p_new, result));
|
||||||
RESTORE_ERRORS;
|
RESTORE_ERRORS;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -940,7 +942,8 @@ int my_rename( const char *old_path, const char *new_path )
|
|||||||
int my_access( const char *path, int mode )
|
int my_access( const char *path, int mode )
|
||||||
{
|
{
|
||||||
DISABLE_ERRORS;
|
DISABLE_ERRORS;
|
||||||
char *p = MRP(path);
|
auto tpath = tstr(path);
|
||||||
|
LPCTSTR p = MRP(tpath.get());
|
||||||
WIN32_FIND_DATA fdata;
|
WIN32_FIND_DATA fdata;
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
@ -968,7 +971,7 @@ int my_access( const char *path, int mode )
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// W_OK, F_OK are ok.
|
// W_OK, F_OK are ok.
|
||||||
result = access(p,mode);
|
result = _taccess(p,mode);
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
my_errno = errno;
|
my_errno = errno;
|
||||||
} else {
|
} else {
|
||||||
@ -976,7 +979,7 @@ int my_access( const char *path, int mode )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
D(bug("access(%s,%s,%d) = %d\n", path, MRP(path), mode, result));
|
D(bug(TEXT("access(%s,%s,%d) = %d\n"), tpath.get(), p, mode, result));
|
||||||
RESTORE_ERRORS;
|
RESTORE_ERRORS;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -984,19 +987,20 @@ int my_access( const char *path, int mode )
|
|||||||
int my_mkdir( const char *path, int mode )
|
int my_mkdir( const char *path, int mode )
|
||||||
{
|
{
|
||||||
DISABLE_ERRORS;
|
DISABLE_ERRORS;
|
||||||
char *p = MRP(path);
|
auto tpath = tstr(path);
|
||||||
|
LPTSTR p = MRP(tpath.get());
|
||||||
strip_trailing_bs(p);
|
strip_trailing_bs(p);
|
||||||
int result = mkdir( p );
|
int result = _tmkdir( p );
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
make_folders(p);
|
make_folders(p);
|
||||||
result = mkdir( p );
|
result = _tmkdir( p );
|
||||||
}
|
}
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
my_errno = errno;
|
my_errno = errno;
|
||||||
} else {
|
} else {
|
||||||
my_errno = 0;
|
my_errno = 0;
|
||||||
}
|
}
|
||||||
D(bug("mkdir(%s,%s,%d) = %d\n", path, p, mode, result));
|
D(bug(TEXT("mkdir(%s,%s,%d) = %d\n"), tpath.get(), p, mode, result));
|
||||||
RESTORE_ERRORS;
|
RESTORE_ERRORS;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1004,13 +1008,14 @@ int my_mkdir( const char *path, int mode )
|
|||||||
int my_remove( const char *path )
|
int my_remove( const char *path )
|
||||||
{
|
{
|
||||||
DISABLE_ERRORS;
|
DISABLE_ERRORS;
|
||||||
char *p = MRP(path);
|
auto tpath = tstr(path);
|
||||||
|
LPTSTR p = MRP(tpath.get());
|
||||||
strip_trailing_bs(p);
|
strip_trailing_bs(p);
|
||||||
int result;
|
int result;
|
||||||
if(is_dir(p)) {
|
if(is_dir(p)) {
|
||||||
result = myRemoveDirectory( p );
|
result = myRemoveDirectory( p );
|
||||||
} else {
|
} else {
|
||||||
D(bug("DeleteFile %s\n", p));
|
D(bug(TEXT("DeleteFile %s\n"), p));
|
||||||
result = DeleteFile( p );
|
result = DeleteFile( p );
|
||||||
}
|
}
|
||||||
if(result) {
|
if(result) {
|
||||||
@ -1024,7 +1029,7 @@ int my_remove( const char *path )
|
|||||||
my_errno = ENOENT;
|
my_errno = ENOENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
D(bug("remove(%s,%s) = %d\n", path, p, result));
|
D(bug(TEXT("remove(%s,%s) = %d\n"), tpath.get(), p, result));
|
||||||
RESTORE_ERRORS;
|
RESTORE_ERRORS;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1032,11 +1037,12 @@ int my_remove( const char *path )
|
|||||||
int my_creat( const char *path, int mode )
|
int my_creat( const char *path, int mode )
|
||||||
{
|
{
|
||||||
DISABLE_ERRORS;
|
DISABLE_ERRORS;
|
||||||
char *p = MRP(path);
|
auto tpath = tstr(path);
|
||||||
int result = creat( p, _S_IWRITE|_S_IREAD ); // note mode
|
LPCTSTR p = MRP(tpath.get());
|
||||||
|
int result = _tcreat( p, _S_IWRITE|_S_IREAD ); // note mode
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
make_folders(p);
|
make_folders(p);
|
||||||
result = creat( p, _S_IWRITE|_S_IREAD ); // note mode
|
result = _tcreat( p, _S_IWRITE|_S_IREAD ); // note mode
|
||||||
}
|
}
|
||||||
if(result < 0) {
|
if(result < 0) {
|
||||||
my_errno = errno;
|
my_errno = errno;
|
||||||
@ -1044,7 +1050,7 @@ int my_creat( const char *path, int mode )
|
|||||||
setmode(result, _O_BINARY);
|
setmode(result, _O_BINARY);
|
||||||
my_errno = 0;
|
my_errno = 0;
|
||||||
}
|
}
|
||||||
D(bug("creat(%s,%s,%d) = %d\n", path, p, mode,result));
|
D(bug(TEXT("creat(%s,%s,%d) = %d\n"), tpath.get(), p, mode,result));
|
||||||
RESTORE_ERRORS;
|
RESTORE_ERRORS;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ typedef struct DIR {
|
|||||||
HANDLE h;
|
HANDLE h;
|
||||||
WIN32_FIND_DATA FindFileData;
|
WIN32_FIND_DATA FindFileData;
|
||||||
dirent de;
|
dirent de;
|
||||||
char *vname_list;
|
TCHAR *vname_list;
|
||||||
} DIR;
|
} DIR;
|
||||||
|
|
||||||
// emulated
|
// emulated
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
using std::string;
|
typedef std::basic_string<TCHAR> tstring;
|
||||||
|
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
|
|
||||||
@ -58,9 +58,9 @@ prefs_desc platform_prefs_items[] = {
|
|||||||
|
|
||||||
|
|
||||||
// Prefs file name and path
|
// Prefs file name and path
|
||||||
const char PREFS_FILE_NAME[] = "BasiliskII_prefs";
|
const TCHAR PREFS_FILE_NAME[] = TEXT("BasiliskII_prefs");
|
||||||
string UserPrefsPath;
|
tstring UserPrefsPath;
|
||||||
static string prefs_path;
|
static tstring prefs_path;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -72,16 +72,15 @@ void LoadPrefs(const char *vmdir)
|
|||||||
// Construct prefs path
|
// Construct prefs path
|
||||||
if (UserPrefsPath.empty()) {
|
if (UserPrefsPath.empty()) {
|
||||||
int pwd_len = GetCurrentDirectory(0, NULL);
|
int pwd_len = GetCurrentDirectory(0, NULL);
|
||||||
char *pwd = new char[pwd_len];
|
prefs_path.resize(pwd_len);
|
||||||
if (GetCurrentDirectory(pwd_len, pwd) == pwd_len - 1)
|
pwd_len = GetCurrentDirectory(pwd_len, &prefs_path.front());
|
||||||
prefs_path = string(pwd) + '\\';
|
prefs_path[pwd_len] = TEXT('\\');
|
||||||
delete[] pwd;
|
|
||||||
prefs_path += PREFS_FILE_NAME;
|
prefs_path += PREFS_FILE_NAME;
|
||||||
} else
|
} else
|
||||||
prefs_path = UserPrefsPath;
|
prefs_path = UserPrefsPath;
|
||||||
|
|
||||||
// Read preferences from settings file
|
// Read preferences from settings file
|
||||||
FILE *f = fopen(prefs_path.c_str(), "r");
|
FILE *f = _tfopen(prefs_path.c_str(), TEXT("r"));
|
||||||
if (f != NULL) {
|
if (f != NULL) {
|
||||||
|
|
||||||
// Prefs file found, load settings
|
// Prefs file found, load settings
|
||||||
@ -103,7 +102,7 @@ void LoadPrefs(const char *vmdir)
|
|||||||
void SavePrefs(void)
|
void SavePrefs(void)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
if ((f = fopen(prefs_path.c_str(), "w")) != NULL) {
|
if ((f = _tfopen(prefs_path.c_str(), TEXT("w"))) != NULL) {
|
||||||
SavePrefsToStream(f);
|
SavePrefsToStream(f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "cpu_emulation.h"
|
#include "cpu_emulation.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "ether_windows.h"
|
#include "ether_windows.h"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "dump.h"
|
#include "dump.h"
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "dynsockets.h"
|
#include "dynsockets.h"
|
||||||
#include "dump.h"
|
#include "dump.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@ -40,7 +41,7 @@
|
|||||||
Win95 b2 users who can't (or won't) upgrade.
|
Win95 b2 users who can't (or won't) upgrade.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char *wslib = "WS2_32.DLL";
|
static LPCTSTR wslib = TEXT("WS2_32.DLL");
|
||||||
|
|
||||||
static HMODULE hWinsock32 = 0;
|
static HMODULE hWinsock32 = 0;
|
||||||
static WSADATA WSAData;
|
static WSADATA WSAData;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "dump.h"
|
#include "dump.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "cpu_emulation.h"
|
#include "cpu_emulation.h"
|
||||||
#include "ws2tcpip.h"
|
#include "ws2tcpip.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "cpu_emulation.h"
|
#include "cpu_emulation.h"
|
||||||
#include "ether_windows.h"
|
#include "ether_windows.h"
|
||||||
#include "ether.h"
|
#include "ether.h"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "cpu_emulation.h"
|
#include "cpu_emulation.h"
|
||||||
#include "ws2tcpip.h"
|
#include "ws2tcpip.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
#include "../dump.h"
|
#include "../dump.h"
|
||||||
#include "mibaccess.h"
|
#include "mibaccess.h"
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "mibaccess.h"
|
#include "mibaccess.h"
|
||||||
#include "../dynsockets.h"
|
#include "../dynsockets.h"
|
||||||
#include "../dump.h"
|
#include "../dump.h"
|
||||||
@ -71,9 +72,8 @@
|
|||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
MibExtLoad::MibExtLoad( LPSTR MibDllName, LPSTR SnmpDllName )
|
MibExtLoad::MibExtLoad( LPCTSTR MibDllName, LPCTSTR SnmpDllName )
|
||||||
{
|
{
|
||||||
|
|
||||||
m_Init = NULL;
|
m_Init = NULL;
|
||||||
|
|
||||||
m_InitEx = NULL;
|
m_InitEx = NULL;
|
||||||
@ -88,10 +88,10 @@ MibExtLoad::MibExtLoad( LPSTR MibDllName, LPSTR SnmpDllName )
|
|||||||
|
|
||||||
m_hInst = LoadLibrary( MibDllName );
|
m_hInst = LoadLibrary( MibDllName );
|
||||||
if(!m_hInst) {
|
if(!m_hInst) {
|
||||||
D(bug("MIB: library %s could not be loaded.\r\n", MibDllName));
|
D(bug(TEXT("MIB: library %s could not be loaded.\r\n"), MibDllName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
D(bug("MIB: library %s loaded ok.\r\n", MibDllName));
|
D(bug(TEXT("MIB: library %s loaded ok.\r\n"), MibDllName));
|
||||||
|
|
||||||
m_Init = (pSnmpExtensionInit)GetProcAddress(m_hInst ,"SnmpExtensionInit");
|
m_Init = (pSnmpExtensionInit)GetProcAddress(m_hInst ,"SnmpExtensionInit");
|
||||||
m_InitEx= (pSnmpExtensionInitEx)GetProcAddress(m_hInst ,"SnmpExtensionInitEx");
|
m_InitEx= (pSnmpExtensionInitEx)GetProcAddress(m_hInst ,"SnmpExtensionInitEx");
|
||||||
@ -100,19 +100,19 @@ MibExtLoad::MibExtLoad( LPSTR MibDllName, LPSTR SnmpDllName )
|
|||||||
|
|
||||||
if( !m_Init || !m_InitEx || !m_Query || !m_Trap )
|
if( !m_Init || !m_InitEx || !m_Query || !m_Trap )
|
||||||
{
|
{
|
||||||
D(bug("MIB: required entry points not found in library %s.\r\n", MibDllName));
|
D(bug(TEXT("MIB: required entry points not found in library %s.\r\n"), MibDllName));
|
||||||
FreeLibrary( m_hInst );
|
FreeLibrary( m_hInst );
|
||||||
m_hInst = NULL;
|
m_hInst = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hInst_snmputil = LoadLibrary( SnmpDllName );
|
m_hInst_snmputil = LoadLibrary( SnmpDllName );
|
||||||
if(!m_hInst_snmputil){
|
if(!m_hInst_snmputil){
|
||||||
D(bug("MIB: library %s could not be loaded.\r\n", SnmpDllName));
|
D(bug(TEXT("MIB: library %s could not be loaded.\r\n"), SnmpDllName));
|
||||||
FreeLibrary( m_hInst );
|
FreeLibrary( m_hInst );
|
||||||
m_hInst = NULL;
|
m_hInst = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
D(bug("MIB: library %s loaded ok.\r\n", SnmpDllName));
|
D(bug(TEXT("MIB: library %s loaded ok.\r\n"), SnmpDllName));
|
||||||
|
|
||||||
m_SnmpUtilVarBindFree = (VOID (SNMP_FUNC_TYPE *)(SnmpVarBind *))GetProcAddress( m_hInst_snmputil, "SnmpUtilVarBindFree" );
|
m_SnmpUtilVarBindFree = (VOID (SNMP_FUNC_TYPE *)(SnmpVarBind *))GetProcAddress( m_hInst_snmputil, "SnmpUtilVarBindFree" );
|
||||||
m_SnmpUtilOidNCmp = (SNMPAPI (SNMP_FUNC_TYPE *)(AsnObjectIdentifier *, AsnObjectIdentifier *, UINT))GetProcAddress( m_hInst_snmputil, "SnmpUtilOidNCmp" );
|
m_SnmpUtilOidNCmp = (SNMPAPI (SNMP_FUNC_TYPE *)(AsnObjectIdentifier *, AsnObjectIdentifier *, UINT))GetProcAddress( m_hInst_snmputil, "SnmpUtilOidNCmp" );
|
||||||
@ -120,7 +120,7 @@ MibExtLoad::MibExtLoad( LPSTR MibDllName, LPSTR SnmpDllName )
|
|||||||
|
|
||||||
if( !m_SnmpUtilVarBindFree || !m_SnmpUtilOidNCmp || !m_SnmpUtilOidCpy )
|
if( !m_SnmpUtilVarBindFree || !m_SnmpUtilOidNCmp || !m_SnmpUtilOidCpy )
|
||||||
{
|
{
|
||||||
D(bug("MIB: required entry points not found in library %s.\r\n", SnmpDllName));
|
D(bug(TEXT("MIB: required entry points not found in library %s.\r\n"), SnmpDllName));
|
||||||
FreeLibrary( m_hInst );
|
FreeLibrary( m_hInst );
|
||||||
FreeLibrary( m_hInst_snmputil );
|
FreeLibrary( m_hInst_snmputil );
|
||||||
m_hInst = NULL;
|
m_hInst = NULL;
|
||||||
@ -181,7 +181,7 @@ BOOL MibExtLoad::Trap(AsnObjectIdentifier *enterprise, AsnInteger *genericTrap,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MibII::MibII( bool load_winsock ):MibExtLoad("inetmib1.dll","snmpapi.dll")
|
MibII::MibII(bool load_winsock) : MibExtLoad(TEXT("inetmib1.dll"), TEXT("snmpapi.dll"))
|
||||||
{
|
{
|
||||||
WSADATA wsa;
|
WSADATA wsa;
|
||||||
m_load_winsock = load_winsock;
|
m_load_winsock = load_winsock;
|
||||||
|
@ -38,7 +38,7 @@ typedef BOOL (WINAPI *pSnmpExtensionInitEx)(OUT AsnObjectIdentifier *supportedVi
|
|||||||
class MibExtLoad
|
class MibExtLoad
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MibExtLoad( LPSTR MibDllName, LPSTR SnmpDllName );
|
MibExtLoad( LPCTSTR MibDllName, LPCTSTR SnmpDllName );
|
||||||
~MibExtLoad();
|
~MibExtLoad();
|
||||||
BOOL Init(DWORD dwTimeZeroReference,HANDLE *hPollForTrapEvent,AsnObjectIdentifier *supportedView);
|
BOOL Init(DWORD dwTimeZeroReference,HANDLE *hPollForTrapEvent,AsnObjectIdentifier *supportedView);
|
||||||
BOOL InitEx(AsnObjectIdentifier *supportedView);
|
BOOL InitEx(AsnObjectIdentifier *supportedView);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "cpu_emulation.h"
|
#include "cpu_emulation.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "ether_windows.h"
|
#include "ether_windows.h"
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "util_windows.h"
|
||||||
#include "macos_util.h"
|
#include "macos_util.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
@ -38,7 +39,7 @@
|
|||||||
#undef OutputDebugString
|
#undef OutputDebugString
|
||||||
#define OutputDebugString serial_log_write
|
#define OutputDebugString serial_log_write
|
||||||
static void serial_log_write( char *s );
|
static void serial_log_write( char *s );
|
||||||
#define SERIAL_LOG_FILE_NAME "serial.log"
|
#define SERIAL_LOG_FILE_NAME TEXT("serial.log")
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#undef D
|
#undef D
|
||||||
#define D(x) if(debug_serial != DB_SERIAL_NONE) (x);
|
#define D(x) if(debug_serial != DB_SERIAL_NONE) (x);
|
||||||
@ -54,7 +55,7 @@ static int16 debug_serial = DB_SERIAL_NONE;
|
|||||||
|
|
||||||
static HANDLE serial_log_file = INVALID_HANDLE_VALUE;
|
static HANDLE serial_log_file = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
static void serial_log_open( char *path )
|
static void serial_log_open( LPCTSTR path )
|
||||||
{
|
{
|
||||||
if(debug_serial == DB_SERIAL_NONE) return;
|
if(debug_serial == DB_SERIAL_NONE) return;
|
||||||
|
|
||||||
@ -108,28 +109,27 @@ static void serial_log_write( char *s )
|
|||||||
// Driver private variables
|
// Driver private variables
|
||||||
class XSERDPort : public SERDPort {
|
class XSERDPort : public SERDPort {
|
||||||
public:
|
public:
|
||||||
XSERDPort(const char *dev, const char *suffix)
|
XSERDPort(LPCTSTR dev, LPCTSTR suffix)
|
||||||
{
|
{
|
||||||
D(bug("XSERDPort constructor %s\r\n", dev));
|
D(bug(TEXT("XSERDPort constructor %s\r\n"), dev));
|
||||||
// device_name = (char *)dev;
|
|
||||||
|
|
||||||
read_pending = write_pending = false;
|
read_pending = write_pending = false;
|
||||||
|
|
||||||
if(dev)
|
if(dev)
|
||||||
strcpy( device_name, (char *)dev );
|
_tcscpy( device_name, dev );
|
||||||
else
|
else
|
||||||
*device_name = 0;
|
*device_name = 0;
|
||||||
strupr(device_name);
|
_tcsupr(device_name);
|
||||||
is_parallel = (strncmp(device_name,"LPT",3) == 0);
|
is_parallel = (_tcsncmp(device_name, TEXT("LPT"), 3) == 0);
|
||||||
is_file = (strncmp(device_name,"FILE",4) == 0);
|
is_file = (_tcsncmp(device_name, TEXT("FILE"), 4) == 0);
|
||||||
if(is_file) {
|
if(is_file) {
|
||||||
char entry_name[20];
|
char entry_name[20];
|
||||||
wsprintf( entry_name, "portfile%s", suffix );
|
_snprintf( entry_name, lengthof(entry_name), "portfile%s", str(suffix).get() );
|
||||||
const char *path = PrefsFindString(entry_name);
|
const char *path = PrefsFindString(entry_name);
|
||||||
if(path) {
|
if(path) {
|
||||||
strcpy( output_file_name, path );
|
_tcscpy( output_file_name, tstr(path).get() );
|
||||||
} else {
|
} else {
|
||||||
strcpy( output_file_name, "C:\\B2TEMP.OUT" );
|
_tcscpy( output_file_name, TEXT("C:\\B2TEMP.OUT") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ private:
|
|||||||
static int acknowledge_error(HANDLE h, bool is_read);
|
static int acknowledge_error(HANDLE h, bool is_read);
|
||||||
bool set_timeouts(int bauds, int parity_bits, int stop_bits);
|
bool set_timeouts(int bauds, int parity_bits, int stop_bits);
|
||||||
|
|
||||||
char device_name[256];
|
TCHAR device_name[256];
|
||||||
HANDLE fd;
|
HANDLE fd;
|
||||||
|
|
||||||
bool io_killed; // Flag: KillIO called, I/O threads must not call deferred tasks
|
bool io_killed; // Flag: KillIO called, I/O threads must not call deferred tasks
|
||||||
@ -193,7 +193,7 @@ private:
|
|||||||
bool is_parallel; // true if LPTx
|
bool is_parallel; // true if LPTx
|
||||||
|
|
||||||
bool is_file; // true if FILE
|
bool is_file; // true if FILE
|
||||||
char output_file_name[256];
|
TCHAR output_file_name[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -214,13 +214,13 @@ void SerialInit(void)
|
|||||||
if(port) {
|
if(port) {
|
||||||
D(bug("SerialInit seriala=%s\r\n",port));
|
D(bug("SerialInit seriala=%s\r\n",port));
|
||||||
}
|
}
|
||||||
the_serd_port[0] = new XSERDPort(port,"0");
|
the_serd_port[0] = new XSERDPort(tstr(port).get(), TEXT("0"));
|
||||||
|
|
||||||
port = PrefsFindString("serialb");
|
port = PrefsFindString("serialb");
|
||||||
if(port) {
|
if(port) {
|
||||||
D(bug("SerialInit serialb=%s\r\n",port));
|
D(bug("SerialInit serialb=%s\r\n",port));
|
||||||
}
|
}
|
||||||
the_serd_port[1] = new XSERDPort(port,"1");
|
the_serd_port[1] = new XSERDPort(tstr(port).get(), TEXT("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ int16 XSERDPort::open(uint16 config)
|
|||||||
if (!device_name || !*device_name)
|
if (!device_name || !*device_name)
|
||||||
return openErr;
|
return openErr;
|
||||||
|
|
||||||
D(bug("XSERDPort::open device=%s,config=0x%X\r\n",device_name,(int)config));
|
D(bug(TEXT("XSERDPort::open device=%s,config=0x%X\r\n"),device_name,(int)config));
|
||||||
|
|
||||||
// Init variables
|
// Init variables
|
||||||
io_killed = false;
|
io_killed = false;
|
||||||
@ -268,7 +268,7 @@ int16 XSERDPort::open(uint16 config)
|
|||||||
}
|
}
|
||||||
if(fd == INVALID_HANDLE_VALUE) {
|
if(fd == INVALID_HANDLE_VALUE) {
|
||||||
goto open_error;
|
goto open_error;
|
||||||
D(bug("XSERDPort::open failed to open port %s\r\n",device_name));
|
D(bug(TEXT("XSERDPort::open failed to open port %s\r\n"),device_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_serial) {
|
if(is_serial) {
|
||||||
@ -1046,7 +1046,7 @@ unsigned int XSERDPort::input_func(void *arg)
|
|||||||
set_desktop();
|
set_desktop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
D(bug("XSERDPort::input_func started for device %s\r\n",s->device_name));
|
D(bug(TEXT("XSERDPort::input_func started for device %s\r\n"),s->device_name));
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
@ -1131,7 +1131,7 @@ unsigned int XSERDPort::output_func(void *arg)
|
|||||||
set_desktop();
|
set_desktop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
D(bug("XSERDPort::output_func started for device %s\r\n",s->device_name));
|
D(bug(TEXT("XSERDPort::output_func started for device %s\r\n"),s->device_name));
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
|
@ -23,12 +23,13 @@
|
|||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
using std::string;
|
typedef std::basic_string<TCHAR> tstring;
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using std::min;
|
using std::min;
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "util_windows.h"
|
||||||
#include "macos_util.h"
|
#include "macos_util.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "user_strings.h"
|
#include "user_strings.h"
|
||||||
@ -45,7 +46,7 @@ using std::min;
|
|||||||
|
|
||||||
// File handles are pointers to these structures
|
// File handles are pointers to these structures
|
||||||
struct file_handle {
|
struct file_handle {
|
||||||
char *name; // Copy of device/file name
|
TCHAR *name; // Copy of device/file name
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
bool is_file; // Flag: plain file or physical device?
|
bool is_file; // Flag: plain file or physical device?
|
||||||
bool is_floppy; // Flag: floppy device
|
bool is_floppy; // Flag: floppy device
|
||||||
@ -149,8 +150,8 @@ void mount_removable_media(int media)
|
|||||||
CloseHandle(fh->fh);
|
CloseHandle(fh->fh);
|
||||||
|
|
||||||
// Re-open device
|
// Re-open device
|
||||||
char device_name[MAX_PATH];
|
TCHAR device_name[MAX_PATH];
|
||||||
sprintf(device_name, "\\\\.\\%c:", fh->name[0]);
|
_sntprintf(device_name, lengthof(device_name), TEXT("\\\\.\\%c:"), fh->name[0]);
|
||||||
fh->fh = CreateFile(
|
fh->fh = CreateFile(
|
||||||
device_name,
|
device_name,
|
||||||
GENERIC_READ,
|
GENERIC_READ,
|
||||||
@ -230,11 +231,10 @@ void SysAddCDROMPrefs(void)
|
|||||||
if (PrefsFindBool("nocdrom"))
|
if (PrefsFindBool("nocdrom"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (char letter = 'C'; letter <= 'Z'; letter++) {
|
char rootdir[] = "C:\\";
|
||||||
int i = (int)(letter - 'A');
|
for (; rootdir[0] <= 'Z'; rootdir[0]++) {
|
||||||
string rootdir = letter + ":\\";
|
if (GetDriveTypeA(rootdir) == DRIVE_CDROM)
|
||||||
if (GetDriveType(rootdir.c_str()) == DRIVE_CDROM)
|
PrefsAddString("cdrom", rootdir);
|
||||||
PrefsAddString("cdrom", rootdir.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,9 +395,9 @@ static bool is_cdrom_readable(file_handle *fh)
|
|||||||
* Check if NAME represents a read-only file
|
* Check if NAME represents a read-only file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static bool is_read_only_path(const char *name)
|
static bool is_read_only_path(const TCHAR *name)
|
||||||
{
|
{
|
||||||
DWORD attrib = GetFileAttributes((char *)name);
|
DWORD attrib = GetFileAttributes(name);
|
||||||
return (attrib != INVALID_FILE_ATTRIBUTES && ((attrib & FILE_ATTRIBUTE_READONLY) != 0));
|
return (attrib != INVALID_FILE_ATTRIBUTES && ((attrib & FILE_ATTRIBUTE_READONLY) != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,25 +411,25 @@ void *Sys_open(const char *path_name, bool read_only)
|
|||||||
file_handle * fh = NULL;
|
file_handle * fh = NULL;
|
||||||
|
|
||||||
// Parse path name and options
|
// Parse path name and options
|
||||||
char name[MAX_PATH];
|
TCHAR name[MAX_PATH];
|
||||||
strcpy(name, path_name);
|
tcslcpy(name, path_name, lengthof(name));
|
||||||
|
|
||||||
// Normalize floppy / cd path
|
// Normalize floppy / cd path
|
||||||
int name_len = strlen(name);
|
int name_len = _tcslen(name);
|
||||||
if (name_len == 1 && isalpha(name[0]))
|
if (name_len == 1 && _istalpha(name[0]))
|
||||||
strcat(name, ":\\");
|
_tcscat(name, TEXT(":\\"));
|
||||||
if (name_len > 0 && name[name_len - 1] == ':')
|
if (name_len > 0 && name[name_len - 1] == TEXT(':'))
|
||||||
strcat(name, "\\");
|
_tcscat(name, TEXT("\\"));
|
||||||
name_len = strlen(name);
|
name_len = _tcslen(name);
|
||||||
|
|
||||||
D(bug("Sys_open(%s, %s)\n", name, read_only ? "read-only" : "read/write"));
|
D(bug(TEXT("Sys_open(%s, %s)\n"), name, read_only ? TEXT("read-only") : TEXT("read/write")));
|
||||||
if (name_len > 0 && name[name_len - 1] == '\\') {
|
if (name_len > 0 && name[name_len - 1] == TEXT('\\')) {
|
||||||
int type = GetDriveType(name);
|
int type = GetDriveType(name);
|
||||||
|
|
||||||
if (type == DRIVE_CDROM) {
|
if (type == DRIVE_CDROM) {
|
||||||
read_only = true;
|
read_only = true;
|
||||||
char device_name[MAX_PATH];
|
TCHAR device_name[MAX_PATH];
|
||||||
sprintf(device_name, "\\\\.\\%c:", name[0]);
|
_sntprintf(device_name, lengthof(device_name), TEXT("\\\\.\\%c:"), name[0]);
|
||||||
|
|
||||||
// Open device
|
// Open device
|
||||||
HANDLE h = CreateFile(
|
HANDLE h = CreateFile(
|
||||||
@ -439,7 +439,7 @@ void *Sys_open(const char *path_name, bool read_only)
|
|||||||
|
|
||||||
if (h != INVALID_HANDLE_VALUE) {
|
if (h != INVALID_HANDLE_VALUE) {
|
||||||
fh = new file_handle;
|
fh = new file_handle;
|
||||||
fh->name = strdup(name);
|
fh->name = _tcsdup(name);
|
||||||
fh->fh = h;
|
fh->fh = h;
|
||||||
fh->is_file = false;
|
fh->is_file = false;
|
||||||
fh->read_only = read_only;
|
fh->read_only = read_only;
|
||||||
@ -478,7 +478,7 @@ void *Sys_open(const char *path_name, bool read_only)
|
|||||||
|
|
||||||
if (h != INVALID_HANDLE_VALUE) {
|
if (h != INVALID_HANDLE_VALUE) {
|
||||||
fh = new file_handle;
|
fh = new file_handle;
|
||||||
fh->name = strdup(name);
|
fh->name = _tcsdup(name);
|
||||||
fh->fh = h;
|
fh->fh = h;
|
||||||
fh->is_file = true;
|
fh->is_file = true;
|
||||||
fh->read_only = read_only;
|
fh->read_only = read_only;
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <tchar.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -88,7 +88,7 @@ static const char *get_volume_name(void)
|
|||||||
// Try Windows 2000 key first
|
// Try Windows 2000 key first
|
||||||
if (ERROR_SUCCESS == RegOpenKey(
|
if (ERROR_SUCCESS == RegOpenKey(
|
||||||
HKEY_CURRENT_USER,
|
HKEY_CURRENT_USER,
|
||||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}",
|
TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}"),
|
||||||
&hHelpKey))
|
&hHelpKey))
|
||||||
{
|
{
|
||||||
cbData = sizeof(volume);
|
cbData = sizeof(volume);
|
||||||
@ -99,7 +99,7 @@ static const char *get_volume_name(void)
|
|||||||
if (volume[0] == 0 &&
|
if (volume[0] == 0 &&
|
||||||
ERROR_SUCCESS == RegOpenKey(
|
ERROR_SUCCESS == RegOpenKey(
|
||||||
HKEY_CURRENT_USER,
|
HKEY_CURRENT_USER,
|
||||||
"Software\\Classes\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}",
|
TEXT("Software\\Classes\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}"),
|
||||||
&hHelpKey))
|
&hHelpKey))
|
||||||
{
|
{
|
||||||
cbData = sizeof(volume);
|
cbData = sizeof(volume);
|
||||||
@ -110,7 +110,7 @@ static const char *get_volume_name(void)
|
|||||||
if (volume[0] == 0 &&
|
if (volume[0] == 0 &&
|
||||||
ERROR_SUCCESS == RegOpenKey(
|
ERROR_SUCCESS == RegOpenKey(
|
||||||
HKEY_CLASSES_ROOT,
|
HKEY_CLASSES_ROOT,
|
||||||
"CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}",
|
TEXT("CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}"),
|
||||||
&hHelpKey))
|
&hHelpKey))
|
||||||
{
|
{
|
||||||
cbData = sizeof(volume);
|
cbData = sizeof(volume);
|
||||||
@ -119,7 +119,7 @@ static const char *get_volume_name(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fix the error that some "tweak" apps do.
|
// Fix the error that some "tweak" apps do.
|
||||||
if (stricmp(volume, "%USERNAME% on %COMPUTER%") == 0)
|
if (_stricmp(volume, "%USERNAME% on %COMPUTER%") == 0)
|
||||||
volume[0] = '\0';
|
volume[0] = '\0';
|
||||||
|
|
||||||
// No volume name found, default to "My Computer"
|
// No volume name found, default to "My Computer"
|
||||||
@ -159,3 +159,21 @@ const char *GetString(int num)
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert text to wide string, given the string number
|
||||||
|
*/
|
||||||
|
std::unique_ptr<wchar_t[]> GetStringW(int num)
|
||||||
|
{
|
||||||
|
auto str = GetString(num);
|
||||||
|
if (str == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto length = MultiByteToWideChar(CP_ACP, 0, str, -1, nullptr, 0);
|
||||||
|
if (length == 0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto p = std::unique_ptr<wchar_t[]>(new wchar_t[length]);
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, str, -1, p.get(), length);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* user_strings_unix.h - Unix-specific localizable strings
|
* user_strings_windows.h - Windows-specific localizable strings
|
||||||
*
|
*
|
||||||
* Basilisk II (C) 1997-2008 Christian Bauer
|
* Basilisk II (C) 1997-2008 Christian Bauer
|
||||||
*
|
*
|
||||||
@ -18,8 +18,17 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef USER_STRINGS_UNIX_H
|
#ifndef USER_STRINGS_WINDOWS_H
|
||||||
#define USER_STRINGS_UNIX_H
|
#define USER_STRINGS_WINDOWS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus >= 201103L || _MSC_VER >= 1600
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
// Convert text to wide string, given the string number
|
||||||
|
extern std::unique_ptr<wchar_t[]> GetStringW(int num);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
STR_NO_XVISUAL_ERR = 10000,
|
STR_NO_XVISUAL_ERR = 10000,
|
||||||
|
@ -31,13 +31,143 @@ using std::list;
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
using std::string;
|
using std::string;
|
||||||
|
using std::wstring;
|
||||||
|
typedef std::basic_string<TCHAR> tstring;
|
||||||
|
|
||||||
BOOL exists( const char *path )
|
std::unique_ptr<char[]> str(const wchar_t* s)
|
||||||
|
{
|
||||||
|
auto length = WideCharToMultiByte(CP_ACP, 0, s, -1, nullptr, 0, nullptr, nullptr);
|
||||||
|
if (length == -1)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
std::unique_ptr<char[]> p(new char[length]);
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, s, -1, p.get(), length, nullptr, nullptr);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<wchar_t[]> wstr(const char* s)
|
||||||
|
{
|
||||||
|
auto length = MultiByteToWideChar(CP_ACP, 0, s, -1, nullptr, 0);
|
||||||
|
if (length == -1)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
std::unique_ptr<wchar_t[]> p(new wchar_t[length]);
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, s, -1, p.get(), length);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
string to_string(const wchar_t* s)
|
||||||
|
{
|
||||||
|
auto wlen = wcslen(s); // length without null terminator
|
||||||
|
auto len = WideCharToMultiByte(CP_ACP, 0, s, wlen, nullptr, 0, nullptr, nullptr);
|
||||||
|
if (len == -1)
|
||||||
|
return string();
|
||||||
|
|
||||||
|
string str(len, '\0');
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, s, wlen, &str.front(), len, nullptr, nullptr);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
wstring to_wstring(const char* s)
|
||||||
|
{
|
||||||
|
auto len = strlen(s); // length without null terminator
|
||||||
|
auto wlen = MultiByteToWideChar(CP_ACP, 0, s, len, nullptr, 0);
|
||||||
|
if (len == -1)
|
||||||
|
return wstring();
|
||||||
|
|
||||||
|
wstring str(wlen, L'\0');
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, s, len, &str.front(), wlen);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t strlcpy(char* dst, const char* src, size_t size)
|
||||||
|
{
|
||||||
|
size_t length = strlen(src);
|
||||||
|
if (size-- > 0) {
|
||||||
|
if (length < size)
|
||||||
|
size = length;
|
||||||
|
memcpy(dst, src, size);
|
||||||
|
dst[size] = '\0';
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t strlcpy(char* dst, const wchar_t* src, size_t size)
|
||||||
|
{
|
||||||
|
size_t length = WideCharToMultiByte(CP_ACP, 0, src, -1, dst, size, nullptr, nullptr);
|
||||||
|
if (size > 0) {
|
||||||
|
if (length == 0)
|
||||||
|
return strlcpy(dst, str(src).get(), size);
|
||||||
|
--length;
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t strlcat(char* dst, const char* src, size_t size)
|
||||||
|
{
|
||||||
|
char* end = static_cast<char*>(memchr(dst, '\0', size));
|
||||||
|
if (end == nullptr)
|
||||||
|
return size;
|
||||||
|
size_t length = end - dst;
|
||||||
|
return length + strlcpy(end, src, size - length);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t strlcat(char* dst, const wchar_t* src, size_t size)
|
||||||
|
{
|
||||||
|
char* end = static_cast<char*>(memchr(dst, '\0', size));
|
||||||
|
if (end == nullptr)
|
||||||
|
return size;
|
||||||
|
size_t length = end - dst;
|
||||||
|
return length + strlcpy(end, src, size - length);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t size)
|
||||||
|
{
|
||||||
|
size_t length = wcslen(src);
|
||||||
|
if (size-- > 0) {
|
||||||
|
if (length < size)
|
||||||
|
size = length;
|
||||||
|
wmemcpy(dst, src, size);
|
||||||
|
dst[size] = '\0';
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wcslcpy(wchar_t* dst, const char* src, size_t size)
|
||||||
|
{
|
||||||
|
size_t length = MultiByteToWideChar(CP_ACP, 0, src, -1, dst, size);
|
||||||
|
if (size > 0) {
|
||||||
|
if (length == 0)
|
||||||
|
return wcslcpy(dst, wstr(src).get(), size);
|
||||||
|
--length;
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wcslcat(wchar_t* dst, const wchar_t* src, size_t size)
|
||||||
|
{
|
||||||
|
wchar_t* end = wmemchr(dst, L'\0', size);
|
||||||
|
if (end == nullptr)
|
||||||
|
return size;
|
||||||
|
size_t length = end - dst;
|
||||||
|
return length + wcslcpy(end, src, size - length);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wcslcat(wchar_t* dst, const char* src, size_t size)
|
||||||
|
{
|
||||||
|
wchar_t* end = wmemchr(dst, L'\0', size);
|
||||||
|
if (end == nullptr)
|
||||||
|
return size;
|
||||||
|
size_t length = end - dst;
|
||||||
|
return length + wcslcpy(end, src, size - length);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL exists( const TCHAR *path )
|
||||||
{
|
{
|
||||||
HFILE h;
|
HFILE h;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
h = _open( path, _O_RDONLY | _O_BINARY );
|
h = _topen( path, _O_RDONLY | _O_BINARY );
|
||||||
if(h != -1) {
|
if(h != -1) {
|
||||||
ret = true;
|
ret = true;
|
||||||
_close(h);
|
_close(h);
|
||||||
@ -45,7 +175,7 @@ BOOL exists( const char *path )
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL create_file( const char *path, DWORD size )
|
BOOL create_file( const TCHAR *path, DWORD size )
|
||||||
{
|
{
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
@ -80,7 +210,7 @@ BOOL create_file( const char *path, DWORD size )
|
|||||||
return(ok);
|
return(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 get_file_size( const char *path )
|
int32 get_file_size( const TCHAR *path )
|
||||||
{
|
{
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
DWORD size = 0;
|
DWORD size = 0;
|
||||||
@ -125,22 +255,22 @@ void kill_thread(HANDLE thread)
|
|||||||
|
|
||||||
bool check_drivers(void)
|
bool check_drivers(void)
|
||||||
{
|
{
|
||||||
char path[_MAX_PATH];
|
TCHAR path[_MAX_PATH];
|
||||||
GetSystemDirectory(path, sizeof(path));
|
GetSystemDirectory(path, lengthof(path));
|
||||||
strcat(path, "\\drivers\\cdenable.sys");
|
_tcscat(path, TEXT("\\drivers\\cdenable.sys"));
|
||||||
|
|
||||||
if (exists(path)) {
|
if (exists(path)) {
|
||||||
int32 size = get_file_size(path);
|
int32 size = get_file_size(path);
|
||||||
if (size != 6112) {
|
if (size != 6112) {
|
||||||
char str[256];
|
TCHAR str[256];
|
||||||
sprintf(str, "The CD-ROM driver file \"%s\" is too old or corrupted.", path);
|
_sntprintf(str, lengthof(str), TEXT("The CD-ROM driver file \"%s\" is too old or corrupted."), path);
|
||||||
ErrorAlert(str);
|
ErrorAlert(str);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char str[256];
|
TCHAR str[256];
|
||||||
sprintf(str, "The CD-ROM driver file \"%s\" is missing.", path);
|
_sntprintf(str, lengthof(str), TEXT("The CD-ROM driver file \"%s\" is missing."), path);
|
||||||
WarningAlert(str);
|
WarningAlert(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,15 +283,15 @@ bool check_drivers(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct panel_reg {
|
struct panel_reg {
|
||||||
string name;
|
tstring name;
|
||||||
string guid;
|
tstring guid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static list<panel_reg> network_registry;
|
static list<panel_reg> network_registry;
|
||||||
typedef list<panel_reg>::const_iterator network_registry_iterator;
|
typedef list<panel_reg>::const_iterator network_registry_iterator;
|
||||||
|
|
||||||
#define NETWORK_CONNECTIONS_KEY \
|
#define NETWORK_CONNECTIONS_KEY \
|
||||||
"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
|
TEXT("SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}")
|
||||||
|
|
||||||
static void get_network_registry(void)
|
static void get_network_registry(void)
|
||||||
{
|
{
|
||||||
@ -184,14 +314,14 @@ static void get_network_registry(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
char enum_name[256];
|
TCHAR enum_name[256];
|
||||||
char connection_string[256];
|
TCHAR connection_string[256];
|
||||||
HKEY connection_key;
|
HKEY connection_key;
|
||||||
char name_data[256];
|
TCHAR name_data[256];
|
||||||
DWORD name_type;
|
DWORD name_type;
|
||||||
const char name_string[] = "Name";
|
const TCHAR name_string[] = TEXT("Name");
|
||||||
|
|
||||||
len = sizeof (enum_name);
|
len = lengthof(enum_name);
|
||||||
status = RegEnumKeyEx(
|
status = RegEnumKeyEx(
|
||||||
network_connections_key,
|
network_connections_key,
|
||||||
i,
|
i,
|
||||||
@ -204,8 +334,8 @@ static void get_network_registry(void)
|
|||||||
if (status != ERROR_SUCCESS)
|
if (status != ERROR_SUCCESS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
snprintf (connection_string, sizeof(connection_string),
|
_sntprintf (connection_string, lengthof(connection_string),
|
||||||
"%s\\%s\\Connection",
|
TEXT("%s\\%s\\Connection"),
|
||||||
NETWORK_CONNECTIONS_KEY, enum_name);
|
NETWORK_CONNECTIONS_KEY, enum_name);
|
||||||
|
|
||||||
status = RegOpenKeyEx(
|
status = RegOpenKeyEx(
|
||||||
@ -216,7 +346,7 @@ static void get_network_registry(void)
|
|||||||
&connection_key);
|
&connection_key);
|
||||||
|
|
||||||
if (status == ERROR_SUCCESS) {
|
if (status == ERROR_SUCCESS) {
|
||||||
len = sizeof (name_data);
|
len = lengthof(name_data);
|
||||||
status = RegQueryValueEx(
|
status = RegQueryValueEx(
|
||||||
connection_key,
|
connection_key,
|
||||||
name_string,
|
name_string,
|
||||||
@ -239,24 +369,24 @@ static void get_network_registry(void)
|
|||||||
RegCloseKey (network_connections_key);
|
RegCloseKey (network_connections_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ether_name_to_guid(const char *name)
|
const TCHAR *ether_name_to_guid(const TCHAR *name)
|
||||||
{
|
{
|
||||||
get_network_registry();
|
get_network_registry();
|
||||||
|
|
||||||
for (network_registry_iterator it = network_registry.begin(); it != network_registry.end(); it++) {
|
for (network_registry_iterator it = network_registry.begin(); it != network_registry.end(); it++) {
|
||||||
if (strcmp((*it).name.c_str(), name) == 0)
|
if (_tcscmp((*it).name.c_str(), name) == 0)
|
||||||
return (*it).guid.c_str();
|
return (*it).guid.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ether_guid_to_name(const char *guid)
|
const TCHAR *ether_guid_to_name(const TCHAR *guid)
|
||||||
{
|
{
|
||||||
get_network_registry();
|
get_network_registry();
|
||||||
|
|
||||||
for (network_registry_iterator it = network_registry.begin(); it != network_registry.end(); it++) {
|
for (network_registry_iterator it = network_registry.begin(); it != network_registry.end(); it++) {
|
||||||
if (strcmp((*it).guid.c_str(), guid) == 0)
|
if (_tcscmp((*it).guid.c_str(), guid) == 0)
|
||||||
return (*it).name.c_str();
|
return (*it).name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,11 +398,11 @@ const char *ether_guid_to_name(const char *guid)
|
|||||||
* Get TAP-Win32 adapters
|
* Get TAP-Win32 adapters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
|
#define ADAPTER_KEY TEXT("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}")
|
||||||
|
|
||||||
#define TAP_COMPONENT_ID "tap0801"
|
#define TAP_COMPONENT_ID TEXT("tap0801")
|
||||||
|
|
||||||
const char *ether_tap_devices(void)
|
const TCHAR *ether_tap_devices(void)
|
||||||
{
|
{
|
||||||
HKEY adapter_key;
|
HKEY adapter_key;
|
||||||
LONG status;
|
LONG status;
|
||||||
@ -289,19 +419,19 @@ const char *ether_tap_devices(void)
|
|||||||
if (status != ERROR_SUCCESS)
|
if (status != ERROR_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
list<string> devices;
|
list<tstring> devices;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
char enum_name[256];
|
TCHAR enum_name[256];
|
||||||
char unit_string[256];
|
TCHAR unit_string[256];
|
||||||
HKEY unit_key;
|
HKEY unit_key;
|
||||||
char component_id_string[] = "ComponentId";
|
TCHAR component_id_string[] = TEXT("ComponentId");
|
||||||
char component_id[256];
|
TCHAR component_id[256];
|
||||||
char net_cfg_instance_id_string[] = "NetCfgInstanceId";
|
TCHAR net_cfg_instance_id_string[] = TEXT("NetCfgInstanceId");
|
||||||
char net_cfg_instance_id[256];
|
TCHAR net_cfg_instance_id[256];
|
||||||
DWORD data_type;
|
DWORD data_type;
|
||||||
|
|
||||||
len = sizeof (enum_name);
|
len = lengthof(enum_name);
|
||||||
status = RegEnumKeyEx(
|
status = RegEnumKeyEx(
|
||||||
adapter_key,
|
adapter_key,
|
||||||
i,
|
i,
|
||||||
@ -314,7 +444,7 @@ const char *ether_tap_devices(void)
|
|||||||
if (status != ERROR_SUCCESS)
|
if (status != ERROR_SUCCESS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
snprintf (unit_string, sizeof(unit_string), "%s\\%s",
|
_sntprintf (unit_string, lengthof(unit_string), TEXT("%s\\%s"),
|
||||||
ADAPTER_KEY, enum_name);
|
ADAPTER_KEY, enum_name);
|
||||||
|
|
||||||
status = RegOpenKeyEx(
|
status = RegOpenKeyEx(
|
||||||
@ -325,7 +455,7 @@ const char *ether_tap_devices(void)
|
|||||||
&unit_key);
|
&unit_key);
|
||||||
|
|
||||||
if (status == ERROR_SUCCESS) {
|
if (status == ERROR_SUCCESS) {
|
||||||
len = sizeof (component_id);
|
len = lengthof(component_id);
|
||||||
status = RegQueryValueEx(
|
status = RegQueryValueEx(
|
||||||
unit_key,
|
unit_key,
|
||||||
component_id_string,
|
component_id_string,
|
||||||
@ -335,7 +465,7 @@ const char *ether_tap_devices(void)
|
|||||||
&len);
|
&len);
|
||||||
|
|
||||||
if (status == ERROR_SUCCESS && data_type == REG_SZ) {
|
if (status == ERROR_SUCCESS && data_type == REG_SZ) {
|
||||||
len = sizeof (net_cfg_instance_id);
|
len = lengthof(net_cfg_instance_id);
|
||||||
status = RegQueryValueEx(
|
status = RegQueryValueEx(
|
||||||
unit_key,
|
unit_key,
|
||||||
net_cfg_instance_id_string,
|
net_cfg_instance_id_string,
|
||||||
@ -345,7 +475,7 @@ const char *ether_tap_devices(void)
|
|||||||
&len);
|
&len);
|
||||||
|
|
||||||
if (status == ERROR_SUCCESS && data_type == REG_SZ) {
|
if (status == ERROR_SUCCESS && data_type == REG_SZ) {
|
||||||
if (!strcmp (component_id, TAP_COMPONENT_ID))
|
if (!_tcscmp (component_id, TAP_COMPONENT_ID))
|
||||||
devices.push_back(net_cfg_instance_id);
|
devices.push_back(net_cfg_instance_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,17 +490,17 @@ const char *ether_tap_devices(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// The result is a '\0' separated list of strings
|
// The result is a '\0' separated list of strings
|
||||||
list<string>::const_iterator it;
|
list<tstring>::const_iterator it;
|
||||||
len = 0;
|
len = 0;
|
||||||
for (it = devices.begin(); it != devices.end(); it++)
|
for (it = devices.begin(); it != devices.end(); it++)
|
||||||
len += (*it).length() + 1;
|
len += (*it).length() + 1;
|
||||||
|
|
||||||
char *names = (char *)malloc(len);
|
TCHAR *names = (TCHAR *)malloc(len * sizeof(TCHAR));
|
||||||
if (names) {
|
if (names) {
|
||||||
char *p = names;
|
TCHAR *p = names;
|
||||||
for (it = devices.begin(); it != devices.end(); it++) {
|
for (it = devices.begin(); it != devices.end(); it++) {
|
||||||
len = (*it).length();
|
len = (*it).length();
|
||||||
strcpy(p, (*it).c_str());
|
_tcscpy(p, (*it).c_str());
|
||||||
p[len] = '\0';
|
p[len] = '\0';
|
||||||
p += len + 1;
|
p += len + 1;
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,12 @@
|
|||||||
#ifndef _UTIL_WINDOWS_H
|
#ifndef _UTIL_WINDOWS_H
|
||||||
#define _UTIL_WINDOWS_H
|
#define _UTIL_WINDOWS_H
|
||||||
|
|
||||||
BOOL exists( const char *path );
|
#include <memory>
|
||||||
int32 get_file_size( const char *path );
|
#include <string>
|
||||||
BOOL create_file( const char *path, DWORD size );
|
|
||||||
|
BOOL exists( const TCHAR *path );
|
||||||
|
int32 get_file_size( const TCHAR *path );
|
||||||
|
BOOL create_file( const TCHAR *path, DWORD size );
|
||||||
bool check_drivers(void);
|
bool check_drivers(void);
|
||||||
|
|
||||||
// Thread wrappers
|
// Thread wrappers
|
||||||
@ -44,10 +47,79 @@ class mutex_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Network control panel helpers
|
// Network control panel helpers
|
||||||
extern const char *ether_name_to_guid(const char *name);
|
extern const TCHAR *ether_name_to_guid(const TCHAR *name);
|
||||||
extern const char *ether_guid_to_name(const char *guid);
|
extern const TCHAR *ether_guid_to_name(const TCHAR *guid);
|
||||||
|
|
||||||
// Get TAP-Win32 devices (caller free()s returned buffer)
|
// Get TAP-Win32 devices (caller free()s returned buffer)
|
||||||
extern const char *ether_tap_devices(void);
|
extern const TCHAR *ether_tap_devices(void);
|
||||||
|
|
||||||
|
// Wide string versions of commonly used functions
|
||||||
|
extern void ErrorAlert(const wchar_t *text);
|
||||||
|
extern void WarningAlert(const wchar_t *text);
|
||||||
|
|
||||||
|
// ----------------- String conversion functions -----------------
|
||||||
|
|
||||||
|
// Null deleter -- does nothing. Allows returning a non-owning
|
||||||
|
// unique_ptr. This should go away if observer_ptr makes it into
|
||||||
|
// the standard.
|
||||||
|
template <class T> struct null_delete {
|
||||||
|
constexpr null_delete() noexcept = default;
|
||||||
|
template <class U> null_delete(const null_delete<U>&) noexcept { }
|
||||||
|
void operator ()(T*) const noexcept { }
|
||||||
|
};
|
||||||
|
template <class T> struct null_delete<T[]> {
|
||||||
|
constexpr null_delete() noexcept = default;
|
||||||
|
void operator ()(T*) const noexcept { }
|
||||||
|
template <class U> void operator ()(U*) const = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Functions returning null-terminated C strings
|
||||||
|
std::unique_ptr<char[]> str(const wchar_t* s);
|
||||||
|
std::unique_ptr<wchar_t[]> wstr(const char* s);
|
||||||
|
|
||||||
|
inline std::unique_ptr<const char[], null_delete<const char[]>> str(const char* s)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<const char[], null_delete<const char[]>>(s);
|
||||||
|
}
|
||||||
|
inline std::unique_ptr<const wchar_t[], null_delete<const wchar_t[]>> wstr(const wchar_t* s)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<const wchar_t[], null_delete<const wchar_t[]>>(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
#define tstr wstr
|
||||||
|
#else
|
||||||
|
#define tstr str
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Functions returning std::strings
|
||||||
|
std::string to_string(const wchar_t* s);
|
||||||
|
std::wstring to_wstring(const char* s);
|
||||||
|
inline std::string to_string(const char* s) { return std::string(s); }
|
||||||
|
inline std::wstring to_wstring(const wchar_t* s) { return std::wstring(s); }
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
#define to_tstring to_wstring
|
||||||
|
#else
|
||||||
|
#define to_tstring to_string
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// BSD strlcpy/strlcat with overloads for converting between wide and narrow strings
|
||||||
|
size_t strlcpy(char* dst, const char* src, size_t size);
|
||||||
|
size_t strlcpy(char* dst, const wchar_t* src, size_t size);
|
||||||
|
size_t strlcat(char* dst, const char* src, size_t size);
|
||||||
|
size_t strlcat(char* dst, const wchar_t* src, size_t size);
|
||||||
|
size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t size);
|
||||||
|
size_t wcslcpy(wchar_t* dst, const char* src, size_t size);
|
||||||
|
size_t wcslcat(wchar_t* dst, const wchar_t* src, size_t size);
|
||||||
|
size_t wcslcat(wchar_t* dst, const char* src, size_t size);
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
#define tcslcpy wcslcpy
|
||||||
|
#define tcslcat wcslcat
|
||||||
|
#else
|
||||||
|
#define tcslcpy strlcpy
|
||||||
|
#define tcslcat strlcat
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // _UTIL_WINDOWS_H
|
#endif // _UTIL_WINDOWS_H
|
||||||
|
@ -21,18 +21,18 @@
|
|||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
using std::string;
|
typedef std::basic_string<TCHAR> tstring;
|
||||||
|
|
||||||
#include "xpram.h"
|
#include "xpram.h"
|
||||||
|
|
||||||
|
|
||||||
// XPRAM file name and path
|
// XPRAM file name and path
|
||||||
#if POWERPC_ROM
|
#if POWERPC_ROM
|
||||||
const char XPRAM_FILE_NAME[] = "SheepShaver_nvram.dat";
|
const TCHAR XPRAM_FILE_NAME[] = TEXT("SheepShaver_nvram.dat");
|
||||||
#else
|
#else
|
||||||
const char XPRAM_FILE_NAME[] = "BasiliskII_xpram.dat";
|
const TCHAR XPRAM_FILE_NAME[] = TEXT("BasiliskII_xpram.dat");
|
||||||
#endif
|
#endif
|
||||||
static string xpram_path;
|
static tstring xpram_path;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -43,9 +43,9 @@ static void build_xpram_path(void)
|
|||||||
{
|
{
|
||||||
xpram_path.clear();
|
xpram_path.clear();
|
||||||
int pwd_len = GetCurrentDirectory(0, NULL);
|
int pwd_len = GetCurrentDirectory(0, NULL);
|
||||||
char *pwd = new char[pwd_len];
|
TCHAR *pwd = new TCHAR[pwd_len];
|
||||||
if (GetCurrentDirectory(pwd_len, pwd) == pwd_len - 1)
|
if (GetCurrentDirectory(pwd_len, pwd) == pwd_len - 1)
|
||||||
xpram_path = string(pwd) + '\\';
|
xpram_path = tstring(pwd) + TEXT('\\');
|
||||||
delete[] pwd;
|
delete[] pwd;
|
||||||
xpram_path += XPRAM_FILE_NAME;
|
xpram_path += XPRAM_FILE_NAME;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
#include "main.h"
|
||||||
#include "scsi.h"
|
#include "scsi.h"
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
|
@ -30,24 +30,62 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
|
||||||
static void _cdecl inline winbug( char *s, ...)
|
static inline void _cdecl vwinbug(const char *s, va_list vargs)
|
||||||
{
|
{
|
||||||
va_list vargs;
|
|
||||||
char msg[1024], date[50], hours[50];
|
char msg[1024], date[50], hours[50];
|
||||||
struct _timeb tstruct;
|
struct _timeb tstruct;
|
||||||
|
|
||||||
_ftime( &tstruct );
|
_ftime( &tstruct );
|
||||||
_strtime( hours );
|
_strtime( hours );
|
||||||
_strdate( date );
|
_strdate( date );
|
||||||
sprintf( msg, "B2: %s %s:%03u ", date, hours, tstruct.millitm );
|
_snprintf( msg, lengthof(msg), "B2: %s %s:%03u ", date, hours, tstruct.millitm );
|
||||||
|
|
||||||
va_start( vargs, s );
|
char *rest = &msg[strlen(msg)];
|
||||||
vsprintf( &msg[strlen(msg)], s, vargs );
|
_vsnprintf( rest, lengthof(msg) - (rest - msg), s, vargs );
|
||||||
va_end( vargs );
|
|
||||||
|
|
||||||
OutputDebugString(msg);
|
OutputDebugStringA(msg);
|
||||||
}
|
}
|
||||||
|
static inline void _cdecl vwwinbug( const wchar_t *s, va_list vargs)
|
||||||
|
{
|
||||||
|
wchar_t msg[1024], date[50], hours[50];
|
||||||
|
struct _timeb tstruct;
|
||||||
|
|
||||||
|
_ftime( &tstruct );
|
||||||
|
_wstrtime( hours );
|
||||||
|
_wstrdate( date );
|
||||||
|
_snwprintf( msg, lengthof(msg), L"B2: %s %s:%03u ", date, hours, tstruct.millitm );
|
||||||
|
|
||||||
|
wchar_t *rest = &msg[wcslen(msg)];
|
||||||
|
_vsnwprintf( rest, lengthof(msg) - (rest - msg), s, vargs );
|
||||||
|
|
||||||
|
OutputDebugStringW(msg);
|
||||||
|
}
|
||||||
|
static inline void _cdecl winbug( const char *s, ...)
|
||||||
|
{
|
||||||
|
va_list vargs;
|
||||||
|
va_start(vargs, s);
|
||||||
|
vwinbug(s, vargs);
|
||||||
|
va_end(vargs);
|
||||||
|
}
|
||||||
|
static inline void _cdecl wwinbug(const wchar_t *s, ...)
|
||||||
|
{
|
||||||
|
va_list vargs;
|
||||||
|
va_start(vargs, s);
|
||||||
|
vwwinbug(s, vargs);
|
||||||
|
va_end(vargs);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
static inline void _cdecl winbug(wchar_t *s, ...)
|
||||||
|
{
|
||||||
|
va_list vargs;
|
||||||
|
va_start(vargs, s);
|
||||||
|
vwwinbug(s, vargs);
|
||||||
|
va_end(vargs);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#define bug winbug
|
#define bug winbug
|
||||||
|
#define wbug wwinbug
|
||||||
|
|
||||||
#elif defined(AMIGA)
|
#elif defined(AMIGA)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user