diff options
Diffstat (limited to 'src/uzbl-core.c')
-rw-r--r-- | src/uzbl-core.c | 59 |
1 files changed, 16 insertions, 43 deletions
diff --git a/src/uzbl-core.c b/src/uzbl-core.c index c960936..1110b02 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -415,36 +415,6 @@ find_existing_file(gchar* path_list) { return NULL; } - -/* Returns a new string with environment $variables expanded */ -gchar* -parseenv (gchar* string) { - extern char** environ; - gchar* tmpstr = NULL, * out; - int i = 0; - - if(!string) - return NULL; - - out = g_strdup(string); - while (environ[i] != NULL) { - gchar** env = g_strsplit (environ[i], "=", 2); - gchar* envname = g_strconcat ("$", env[0], NULL); - - if (g_strrstr (string, envname) != NULL) { - tmpstr = out; - out = str_replace(envname, env[1], out); - g_free (tmpstr); - } - - g_free (envname); - g_strfreev (env); // somebody said this breaks uzbl - i++; - } - - return out; -} - void clean_up(void) { if(uzbl.info.pid_str) { @@ -696,9 +666,8 @@ set_var(WebKitWebView *page, GArray *argv, GString *result) { gchar **split = g_strsplit(argv_idx(argv, 0), "=", 2); if (split[0] != NULL) { - gchar *value = parseenv(split[1] ? g_strchug(split[1]) : " "); + gchar *value = split[1] ? g_strchug(split[1]) : " "; set_var_value(g_strstrip(split[0]), value); - g_free(value); } g_strfreev(split); } @@ -928,14 +897,12 @@ void include(WebKitWebView *page, GArray *argv, GString *result) { (void) page; (void) result; - gchar *pe = NULL, - *path = NULL; + gchar *path = argv_idx(argv, 0); - if(!argv_idx(argv, 0)) + if(!path) return; - pe = parseenv(argv_idx(argv, 0)); - if((path = find_existing_file(pe))) { + if((path = find_existing_file(path))) { if(!for_each_line_in_file(path, parse_cmd_line_cb, NULL)) { gchar *tmp = g_strdup_printf("File %s can not be read.", path); send_event(COMMAND_ERROR, tmp, NULL); @@ -945,7 +912,6 @@ include(WebKitWebView *page, GArray *argv, GString *result) { send_event(FILE_INCLUDED, path, NULL); g_free(path); } - g_free(pe); } void @@ -1614,8 +1580,9 @@ init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */ if (g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, NULL)) { if (uzbl.state.verbose) printf ("init_fifo: created successfully as %s\n", path); - send_event(FIFO_SET, path, NULL); + send_event(FIFO_SET, path, NULL); uzbl.comm.fifo_path = path; + g_setenv("UZBL_FIFO", uzbl.comm.fifo_path, TRUE); return dir; } else g_warning ("init_fifo: could not add watch on %s\n", path); } else g_warning ("init_fifo: can't open: %s\n", error->message); @@ -1809,6 +1776,7 @@ init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL * g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_socket, chan); uzbl.comm.socket_path = path; send_event(SOCKET_SET, path, NULL); + g_setenv("UZBL_SOCKET", uzbl.comm.socket_path, TRUE); return dir; } } else g_warning ("init_socket: could not open in %s: %s\n", path, strerror(errno)); @@ -2076,6 +2044,7 @@ settings_init () { send_event(COMMAND_ERROR, tmp, NULL); g_free(tmp); } + g_setenv("UZBL_CONFIG", s->config_file, TRUE); } else if (uzbl.state.verbose) printf ("No configuration file loaded.\n"); @@ -2358,12 +2327,16 @@ main (int argc, char* argv[]) { "signal::changed", (GCallback)scroll_horiz_cb, NULL, NULL); + gchar *xwin = g_strdup_printf("%d", (int)uzbl.xwin); + g_setenv("UZBL_XID", xwin, TRUE); + if(!uzbl.state.instance_name) - uzbl.state.instance_name = itos((int)uzbl.xwin); + uzbl.state.instance_name = g_strdup(xwin); - GString *tmp = g_string_new(""); - g_string_printf(tmp, "%d", getpid()); - uzbl.info.pid_str = g_string_free(tmp, FALSE); + g_free(xwin); + + uzbl.info.pid_str = g_strdup_printf("%d", getpid()); + g_setenv("UZBL_PID", uzbl.info.pid_str, TRUE); send_event(INSTANCE_START, uzbl.info.pid_str, NULL); if(uzbl.state.plug_mode) { |