mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-13 01:38:19 +03:00
Implement system.OpenWeb
This commit is contained in:
+1
-1
@@ -47,7 +47,7 @@ const struct syscall syscalls[NR_SYSCALLS] = {
|
||||
SYS ( SYS_RESUME_SAVE, ResumeSave ),
|
||||
SYS ( SYS_RESUME_LOAD, ResumeLoad ),
|
||||
SYS ( SYS_EXISTS_FILE, ExistsFile ),
|
||||
TODO ( SYS_OPEN_WEB, OpenWeb ),
|
||||
SYS ( SYS_OPEN_WEB, OpenWeb ),
|
||||
SYS ( SYS_GET_SAVE_FOLDER_NAME, GetSaveFolderName ),
|
||||
SYS ( SYS_GET_TIME, GetTime ),
|
||||
TODO ( SYS_GET_GAME_NAME, GetGameName ),
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <libgen.h>
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include "debugger.h"
|
||||
#include "file.h"
|
||||
#include "ini.h"
|
||||
@@ -195,6 +197,11 @@ static void config_init(void)
|
||||
mkdir_p(new_save_dir);
|
||||
}
|
||||
|
||||
void cleanup(int signal)
|
||||
{
|
||||
while (waitpid((pid_t)-1, 0, WNOHANG) > 0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
initialize_instructions();
|
||||
@@ -226,6 +233,8 @@ int main(int argc, char *argv[])
|
||||
ERROR("Not an AIN/INI file: %s", &argv[1][len - 4]);
|
||||
}
|
||||
|
||||
signal(SIGCHLD, cleanup);
|
||||
|
||||
config_init();
|
||||
|
||||
if (!(ain = ain_open(ainfile, &err))) {
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <spawn.h>
|
||||
#include <SDL.h> // for system.MsgBox
|
||||
|
||||
#include "debugger.h"
|
||||
@@ -35,6 +37,8 @@
|
||||
#include "vm/heap.h"
|
||||
#include "vm/page.h"
|
||||
|
||||
extern char **environ;
|
||||
|
||||
static inline int32_t lint_clamp(int64_t n)
|
||||
{
|
||||
if (n < 0)
|
||||
@@ -397,6 +401,22 @@ static void system_call(enum syscall_code code)
|
||||
free(path);
|
||||
break;
|
||||
}
|
||||
case SYS_OPEN_WEB: {
|
||||
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));
|
||||
}
|
||||
heap_unref(stack_pop().i);
|
||||
break;
|
||||
};
|
||||
case SYS_GET_SAVE_FOLDER_NAME: {// system.GetSaveFolderName(void)
|
||||
if (config.save_dir) {
|
||||
char *sjis = utf2sjis(config.save_dir, strlen(config.save_dir));
|
||||
|
||||
Reference in New Issue
Block a user