SDL: fall through to the baseline Win32 implementations for file, socket, and pty/named pipe I/O. [R. Belmont]

nw: This fixes laserdisc games and enables socket and named pipe I/O in SDL Windows builds.
This commit is contained in:
R. Belmont 2014-08-31 20:55:48 +00:00
parent a436203ce8
commit ada89eb11d
4 changed files with 31 additions and 39 deletions

View File

@ -2,13 +2,17 @@
//
// sdldir.c - SDL core directory access functions
//
// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
// Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
// SDLMAME by Olivier Galibert and R. Belmont
//
//============================================================
#ifdef SDLMAME_WIN32
#include "../windows/windir.c"
#else
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
@ -230,3 +234,5 @@ void osd_closedir(osd_directory *dir)
osd_free(dir->path);
osd_free(dir);
}
#endif

View File

@ -1,14 +1,19 @@
//============================================================
//
// fileio.c - SDL file access functions
// sdlfile.c - SDL file access functions
//
// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
// Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
// SDLMAME by Olivier Galibert and R. Belmont
//
//============================================================
#ifdef SDLMAME_WIN32
#include "../windows/winfile.c"
#include "../windows/winutil.c"
#else
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
@ -16,6 +21,11 @@
#ifdef SDLMAME_LINUX
#define __USE_LARGEFILE64
#endif
#ifdef SDLMAME_WIN32
#define _FILE_OFFSET_BITS 64
#endif
#ifndef SDLMAME_BSD
#ifdef _XOPEN_SOURCE
#undef _XOPEN_SOURCE
@ -254,6 +264,7 @@ file_error osd_open(const char *path, UINT32 openflags, osd_file **file, UINT64
*filesize = (UINT64)st.st_size;
fprintf(stderr, "SDL: opened file %s, size %I64d\n", tmpstr, *filesize);
error:
// cleanup
@ -500,3 +511,4 @@ int osd_is_absolute_path(const char *path)
return result;
}
#endif

View File

@ -1,35 +1,14 @@
//============================================================
//
// sdlptty_win32 - SDL psuedo tty access functions
// (Win32 has no pttys - maybe named pipes?)
// (passthrough to Windows OSD version)
//
// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
// Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
// SDLMAME by Olivier Galibert and R. Belmont
//
//============================================================
#include "sdlfile.h"
#include "../windows/winptty.c"
const char *sdlfile_ptty_identifier = "";
file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize)
{
return FILERR_ACCESS_DENIED;
}
file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual)
{
return FILERR_ACCESS_DENIED;
}
file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual)
{
return FILERR_ACCESS_DENIED;
}
file_error sdl_close_ptty(osd_file *file)
{
return FILERR_ACCESS_DENIED;
}

View File

@ -2,25 +2,27 @@
//
// sdlsocket.c - SDL socket (inet) access functions
//
// Copyright (c) 1996-2013, Nicola Salmoria and the MAME Team.
// Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
// SDLMAME by Olivier Galibert and R. Belmont
//
//============================================================
#ifdef SDLMAME_WIN32
#include "../windows/winsocket.c"
#else
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#ifndef SDLMAME_WIN32
#include <sys/select.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#endif
#include <errno.h>
#define NO_MEM_TRACKING
@ -36,17 +38,14 @@ const char *sdlfile_socket_identifier = "socket.";
*/
bool sdl_check_socket_path(const char *path)
{
#ifndef SDLMAME_WIN32
if (strlen(sdlfile_socket_identifier) > 0 &&
strncmp(path, sdlfile_socket_identifier, strlen(sdlfile_socket_identifier)) == 0 &&
strchr(path, ':') != NULL) return true;
#endif
return false;
}
file_error sdl_open_socket(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize)
{
#ifndef SDLMAME_WIN32
char hostname[256];
struct hostent *localhost;
struct sockaddr_in sai;
@ -103,13 +102,12 @@ file_error sdl_open_socket(const char *path, UINT32 openflags, osd_file **file,
*filesize = 0;
(*file)->handle = -1;
#endif
return FILERR_NONE;
}
file_error sdl_read_socket(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual)
{
#if (!defined(SDLMAME_WIN32)) && (!defined(SDLMAME_EMSCRIPTEN))
#if (!defined(SDLMAME_EMSCRIPTEN))
ssize_t result;
char line[80];
struct timeval timeout;
@ -172,7 +170,6 @@ file_error sdl_read_socket(osd_file *file, void *buffer, UINT64 offset, UINT32 c
file_error sdl_write_socket(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual)
{
#ifndef SDLMAME_WIN32
ssize_t result;
result = write(file->socket, buffer, count);
@ -186,15 +183,13 @@ file_error sdl_write_socket(osd_file *file, const void *buffer, UINT64 offset, U
{
*actual = result;
}
#endif
return FILERR_NONE;
}
file_error sdl_close_socket(osd_file *file)
{
#ifndef SDLMAME_WIN32
close(file->socket);
osd_free(file);
#endif
return FILERR_NONE;
}
#endif