diff options
author | 2016-03-13 13:54:57 +1100 | |
---|---|---|
committer | 2016-03-14 18:55:00 +1100 | |
commit | 42fbb9c3967fcda37f2d9ae17d5796a79cf027b9 (patch) | |
tree | a43047ee00431e5e22bfc5f8f612ff775586e415 /src/osd/sdl/sdlptty_unix.cpp | |
parent | 5fc27747031b6ed6f6c0582502098ebfb960be67 (diff) |
Make osd_file a polymorphic class that's held with smart pointers
Make avi_file a class that's held with smart pointers, encapsulate various AVI I/O structures
Make zip_file and _7z_file classes rather than having free functions everywhere
Hide zip/7z class implementation behind an interface, no longer need to call close() to send back to the cache
Don't dump as much crap in global namespace
Add solaris PTY implementation
Improve variable expansion for SDL OSD - supports ~/$FOO/${BAR} syntax
Rearrange stuff so the same things are in file module for all OSDs
Move file stuff into its own module
7z/zip open and destruct are still not thread-safe due to lack of interlocks around cache access
Directory functions still need to be moved to file module
SDL OSD may not initialise WinSock on Windows
Diffstat (limited to 'src/osd/sdl/sdlptty_unix.cpp')
-rw-r--r-- | src/osd/sdl/sdlptty_unix.cpp | 161 |
1 files changed, 0 insertions, 161 deletions
diff --git a/src/osd/sdl/sdlptty_unix.cpp b/src/osd/sdl/sdlptty_unix.cpp deleted file mode 100644 index 063b999b75d..00000000000 --- a/src/osd/sdl/sdlptty_unix.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert, R. Belmont -//============================================================ -// -// sdlptty_unix.c - SDL pseudo tty access functions -// -// SDLMAME by Olivier Galibert and R. Belmont -// -//============================================================ - -#if (!defined(SDLMAME_SOLARIS)) - -#include <sys/types.h> -#include <sys/uio.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#if defined(SDLMAME_FREEBSD) || defined(SDLMAME_DRAGONFLY) -# include <termios.h> -# include <libutil.h> -#elif defined(SDLMAME_NETBSD) || defined(SDLMAME_MACOSX) -# include <termios.h> -# include <util.h> -#elif defined(SDLMAME_OPENBSD) -# include <termios.h> -# include <util.h> -#elif defined(SDLMAME_LINUX) || defined(SDLMAME_EMSCRIPTEN) -# include <pty.h> -#elif defined(SDLMAME_HAIKU) -# include <bsd/pty.h> -#endif -#include <stdlib.h> - -#include "sdlfile.h" - -#if defined(SDLMAME_MACOSX) -const char *sdlfile_ptty_identifier = "/dev/pty"; -#else -const char *sdlfile_ptty_identifier = "/dev/pts"; -#endif - -file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize) -{ - int master; - int aslave; - struct termios tios; - int oldflags; - - memset(&tios , 0 , sizeof(tios)); - cfmakeraw(&tios); - - if (openpty(&master, &aslave, NULL, &tios, NULL) >= 0) - { - oldflags = fcntl(master, F_GETFL, 0); - if (oldflags == -1) { - close(master); - return FILERR_FAILURE; - } - - fcntl(master, F_SETFL, oldflags | O_NONBLOCK); - close(aslave); - (*file)->handle = master; - *filesize = 0; - } - else - { - return FILERR_ACCESS_DENIED; - } - - return FILERR_NONE; -} - -file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) -{ - ssize_t result; - - result = read(file->handle, buffer, count); - - if (result < 0) - { - return error_to_file_error(errno); - } - - if (actual != NULL ) - { - *actual = result; - } - - return FILERR_NONE; -} - -file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) -{ - ssize_t result; - result = write(file->handle, buffer, count); - - if (result < 0) - { - return error_to_file_error(errno); - } - - if (actual != NULL ) - { - *actual = result; - } - - return FILERR_NONE; -} - -file_error sdl_close_ptty(osd_file *file) -{ - close(file->handle); - osd_free(file); - - return FILERR_NONE; -} - -file_error sdl_slave_name_ptty(osd_file *file , char *name , size_t name_len) -{ - const char *slave_name = ptsname(file->handle); - - if (slave_name == NULL || strlen(slave_name) >= name_len) { - return FILERR_INVALID_ACCESS; - } - - strcpy(name , slave_name); - - return FILERR_NONE; -} - -#else -#include "sdlfile.h" - -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; -} - -file_error sdl_slave_name_ptty(osd_file *file) -{ - return FILERR_ACCESS_DENIED; -} - -#endif |