mirror of
https://github.com/holub/mame
synced 2025-04-25 09:50:04 +03:00
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:
parent
3853306c85
commit
509b39374d
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user