if (uzbl.behave.download_handler) {
const gchar* uri = webkit_download_get_uri ((WebKitDownload*)download);
printf("Download -> %s\n",uri);
- run_command_async(uzbl.behave.download_handler, uri);
+ run_command(uzbl.behave.download_handler, uri, FALSE, NULL);
}
return (FALSE);
}
(void) frame;
(void) data;
if (uzbl.behave.load_finish_handler) {
- run_command_async(uzbl.behave.load_finish_handler, NULL);
+ run_command(uzbl.behave.load_finish_handler, NULL, FALSE, NULL);
}
}
strftime (date, 80, "%Y-%m-%d %H:%M:%S", timeinfo);
GString* args = g_string_new ("");
g_string_printf (args, "'%s'", date);
- run_command_async(uzbl.behave.history_handler, args->str);
+ run_command(uzbl.behave.history_handler, args->str, FALSE, NULL);
g_string_free (args, TRUE);
}
}
// make sure to put '' around args, so that if there is whitespace we can still keep arguments together.
static gboolean
-run_command_async(const char *command, const char *args) {
+run_command (const char *command, const char *args, const gboolean sync, char **stdout) {
//command <uzbl conf> <uzbl pid> <uzbl win id> <uzbl fifo file> <uzbl socket file> [args]
GString* to_execute = g_string_new ("");
gboolean result;
(int) uzbl.xwin, uzbl.comm.fifo_path, uzbl.comm.socket_path);
g_string_append_printf (to_execute, " '%s' '%s'",
uzbl.state.uri, "TODO title here");
- if(args) {
- g_string_append_printf (to_execute, " %s", args);
- }
- result = g_spawn_command_line_async (to_execute->str, NULL);
- printf("Called %s. Result: %s\n", to_execute->str, (result ? "TRUE" : "FALSE" ));
- g_string_free (to_execute, TRUE);
- return result;
-}
+ if(args) g_string_append_printf (to_execute, " %s", args);
-static gboolean
-run_command_sync(const char *command, const char *args, char **stdout) {
- //command <uzbl conf> <uzbl pid> <uzbl win id> <uzbl fifo file> <uzbl socket file> [args]
- GString* to_execute = g_string_new ("");
- gboolean result;
- g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s' '%s'", command, uzbl.state.config_file, (int) getpid() , (int) uzbl.xwin, uzbl.comm.fifo_path, uzbl.comm.socket_path);
- g_string_append_printf (to_execute, " '%s' '%s'", uzbl.state.uri, "TODO title here");
- if(args) {
- g_string_append_printf (to_execute, " %s", args);
- }
- result = g_spawn_command_line_sync (to_execute->str, stdout, NULL, NULL, NULL);
+ if (sync) {
+ result = g_spawn_command_line_sync (to_execute->str, stdout, NULL, NULL, NULL);
+ } else result = g_spawn_command_line_async (to_execute->str, NULL);
printf("Called %s. Result: %s\n", to_execute->str, (result ? "TRUE" : "FALSE" ));
g_string_free (to_execute, TRUE);
return result;
static void
spawn(WebKitWebView *web_view, const char *param) {
(void)web_view;
- run_command_async(param, NULL);
+ run_command(param, NULL, FALSE, NULL);
}
static void
GString* args = g_string_new ("");
SoupURI * soup_uri = soup_message_get_uri(msg);
g_string_printf (args, "GET %s %s", soup_uri->host, soup_uri->path);
- run_command_sync(uzbl.behave.cookie_handler, args->str, &stdout);
+ run_command(uzbl.behave.cookie_handler, args->str, TRUE, &stdout);
if(stdout) {
soup_message_headers_replace (msg->request_headers, "Cookie", stdout);
}
GString* args = g_string_new ("");
SoupURI * soup_uri = soup_message_get_uri(msg);
g_string_printf (args, "PUT %s %s \"%s\"", soup_uri->host, soup_uri->path, cookie);
- run_command_async(uzbl.behave.cookie_handler, args->str);
+ run_command(uzbl.behave.cookie_handler, args->str, FALSE, NULL);
g_string_free(args, TRUE);
free(cookie);
}