mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-29 08:42:28 +00:00
Added Parameter to LaunchBrowser to set path (#158)
This commit is contained in:
parent
af59806a42
commit
6215c91e90
1 changed files with 9 additions and 4 deletions
|
@ -2003,7 +2003,7 @@ static char *GetBasicAuthorization(size_t *z) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LaunchBrowser() {
|
static void LaunchBrowser(const char *path) {
|
||||||
char openbrowsercommand[255];
|
char openbrowsercommand[255];
|
||||||
char *prog;
|
char *prog;
|
||||||
if (IsWindows()) {
|
if (IsWindows()) {
|
||||||
|
@ -2015,8 +2015,12 @@ static void LaunchBrowser() {
|
||||||
}
|
}
|
||||||
struct in_addr addr = serveraddr.sin_addr;
|
struct in_addr addr = serveraddr.sin_addr;
|
||||||
if (addr.s_addr == INADDR_ANY) addr.s_addr = htonl(INADDR_LOOPBACK);
|
if (addr.s_addr == INADDR_ANY) addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||||
snprintf(openbrowsercommand, sizeof(openbrowsercommand), "%s http://%s:%d",
|
const char *pathname = path;
|
||||||
prog, inet_ntoa(addr), ntohs(serveraddr.sin_port));
|
if (path == NULL) {
|
||||||
|
pathname = "/";
|
||||||
|
}
|
||||||
|
snprintf(openbrowsercommand, sizeof(openbrowsercommand), "%s http://%s:%d%s",
|
||||||
|
prog, inet_ntoa(addr), ntohs(serveraddr.sin_port), pathname);
|
||||||
DEBUGF("Opening browser with command %s\n", openbrowsercommand);
|
DEBUGF("Opening browser with command %s\n", openbrowsercommand);
|
||||||
system(openbrowsercommand);
|
system(openbrowsercommand);
|
||||||
}
|
}
|
||||||
|
@ -3551,7 +3555,8 @@ static void LuaSetIntField(lua_State *L, const char *k, lua_Integer v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int LuaLaunchBrowser(lua_State *L) {
|
static int LuaLaunchBrowser(lua_State *L) {
|
||||||
LaunchBrowser();
|
const char *p = luaL_optstring(L, 1, "/");
|
||||||
|
LaunchBrowser(p);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue