mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-08 14:58:14 +03:00
Merge pull request #39 from kichikuou/openweb
Use SDL_OpenURL for system.OpenWeb
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include <libgen.h>
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
@@ -328,14 +327,6 @@ static void config_init_with_ain(const char *ain_path)
|
||||
config_init();
|
||||
}
|
||||
|
||||
#if (!defined(_WIN32) && !defined(__WIN32__))
|
||||
#include <sys/wait.h>
|
||||
void cleanup(possibly_unused int signal)
|
||||
{
|
||||
while (waitpid((pid_t)-1, 0, WNOHANG) > 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void ain_audit(FILE *f, struct ain *ain)
|
||||
{
|
||||
link_libraries();
|
||||
@@ -491,10 +482,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
ainfile = gamedir_path(config.ain_filename);
|
||||
|
||||
#if (!defined(_WIN32) && !defined(__WIN32__))
|
||||
signal(SIGCHLD, cleanup);
|
||||
#endif
|
||||
|
||||
read_user_config();
|
||||
|
||||
// NOTE: some command line options are handled here so that they
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <setjmp.h>
|
||||
#include <assert.h>
|
||||
#include <SDL.h> // for system.MsgBox
|
||||
@@ -41,12 +40,6 @@
|
||||
#include "vm/page.h"
|
||||
#include "xsystem4.h"
|
||||
|
||||
#if (!defined(_WIN32) && !defined(__WIN32__))
|
||||
#include <spawn.h>
|
||||
#endif
|
||||
|
||||
extern char **environ;
|
||||
|
||||
static inline int32_t lint_clamp(int64_t n)
|
||||
{
|
||||
if (n < 0)
|
||||
@@ -484,20 +477,12 @@ static void system_call(enum syscall_code code)
|
||||
break;
|
||||
}
|
||||
case SYS_OPEN_WEB: {
|
||||
#if (defined(_WIN32) || defined(__WIN32__))
|
||||
WARNING("system.OpenWeb not implemented on Windows");
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 14)
|
||||
WARNING("SDL_OpenURL not available");
|
||||
#else
|
||||
struct string *url = stack_peek_string(0);
|
||||
char *browser = getenv("BROWSER");
|
||||
if (!browser || !*browser) {
|
||||
WARNING("$BROWSER not set, assuming Firefox");
|
||||
browser = "firefox";
|
||||
}
|
||||
int err;
|
||||
pid_t child;
|
||||
char *argv[] = { browser, url->text, NULL };
|
||||
if ((err = posix_spawnp(&child, browser, NULL, NULL, argv, environ))) {
|
||||
WARNING("posix_spawn failed: %s", strerror(err));
|
||||
if (SDL_OpenURL(url->text) < 0) {
|
||||
WARNING("SDL_OpenURL failed: %s", SDL_GetError());
|
||||
}
|
||||
#endif
|
||||
heap_unref(stack_pop().i);
|
||||
|
||||
Reference in New Issue
Block a user