sdlsocket: workaround for a problem in the detection of tcp/ip socket address [Michael Zapf]

out of whatsnew
remark 1- this is for MESS only to my knowledge, let me know if I should credit the change in MESS instead
remark 2 (mainly for Arbee) - sorry if I touched the SDL side of the source, but mizapf was eager to fix the ti99 issues 
            and since tlinder approved the change and you did not object on the MESS list, I think it was time to commit it ;)
This commit is contained in:
Fabio Priuli 2011-06-08 19:49:12 +00:00
parent 3853306c85
commit 509b39374d
3 changed files with 19 additions and 3 deletions

View File

@ -122,7 +122,7 @@ file_error osd_open(const char *path, UINT32 openflags, osd_file **file, UINT64
goto error;
}
if (strlen(sdlfile_socket_identifier) > 0 && strncmp(path, sdlfile_socket_identifier, strlen(sdlfile_socket_identifier)) == 0)
if (sdl_check_socket_path(path))
{
(*file)->type = SDLFILE_SOCKET;
filerr = sdl_open_socket(path, openflags, file, filesize);

View File

@ -37,6 +37,7 @@ struct _osd_file
// PROTOTYPES
//============================================================
bool sdl_check_socket_path(const char *path);
file_error sdl_open_socket(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize);
file_error sdl_read_socket(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual);
file_error sdl_write_socket(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual);

View File

@ -26,7 +26,22 @@
#include "emu.h"
#include "sdlfile.h"
const char *sdlfile_socket_identifier = "/dev/socket";
const char *sdlfile_socket_identifier = "socket.";
/*
Checks whether the path is a socket specification. A valid socket
specification has the format "socket." host ":" port. Host may be simple
or fully qualified. Port must be between 1 and 65535.
*/
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)
{
@ -37,7 +52,7 @@ file_error sdl_open_socket(const char *path, UINT32 openflags, osd_file **file,
int flag = 1;
int port;
sscanf( path+strlen(sdlfile_socket_identifier), ":%255[^:]:%d", hostname, &port );
sscanf( path+strlen(sdlfile_socket_identifier), "%255[^:]:%d", hostname, &port );
printf("Connecting to server '%s' on port '%d'\n", hostname, port);