Argv stub
authorDuClare <akarinotengoku@gmail.com>
Tue, 19 May 2009 08:04:06 +0000 (11:04 +0300)
committerDuClare <akarinotengoku@gmail.com>
Tue, 19 May 2009 08:04:06 +0000 (11:04 +0300)
uzbl.c
uzbl.h

diff --git a/uzbl.c b/uzbl.c
index fc95530..41d8cff 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -252,34 +252,34 @@ download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) {
 
 /* scroll a bar in a given direction */
 static void
-scroll (GtkAdjustment* bar, const char *param) {
+scroll (GtkAdjustment* bar, GArray *argv) {
     gdouble amount;
     gchar *end;
 
-    amount = g_ascii_strtod(param, &end);
+    amount = g_ascii_strtod(g_array_index(argv, gchar*, 0), &end);
     if (*end == '%') amount = gtk_adjustment_get_page_size(bar) * amount * 0.01;
     gtk_adjustment_set_value (bar, gtk_adjustment_get_value(bar)+amount);
 }
 
-static void scroll_begin(WebKitWebView* page, const char *param) {
-    (void) page; (void) param;
+static void scroll_begin(WebKitWebView* page, GArray *argv) {
+    (void) page; (void) argv;
     gtk_adjustment_set_value (uzbl.gui.bar_v, gtk_adjustment_get_lower(uzbl.gui.bar_v));
 }
 
-static void scroll_end(WebKitWebView* page, const char *param) {
-    (void) page; (void) param;
+static void scroll_end(WebKitWebView* page, GArray *argv) {
+    (void) page; (void) argv;
     gtk_adjustment_set_value (uzbl.gui.bar_v, gtk_adjustment_get_upper(uzbl.gui.bar_v) -
                               gtk_adjustment_get_page_size(uzbl.gui.bar_v));
 }
 
-static void scroll_vert(WebKitWebView* page, const char *param) {
+static void scroll_vert(WebKitWebView* page, GArray *argv) {
     (void) page;
-    scroll(uzbl.gui.bar_v, param);
+    scroll(uzbl.gui.bar_v, argv);
 }
 
-static void scroll_horz(WebKitWebView* page, const char *param) {
+static void scroll_horz(WebKitWebView* page, GArray *argv) {
     (void) page;
-    scroll(uzbl.gui.bar_h, param);
+    scroll(uzbl.gui.bar_h, argv);
 }
 
 static void
@@ -890,9 +890,16 @@ static void
 parse_command(const char *cmd, const char *param) {
     Command c;
 
-    if ((c = g_hash_table_lookup(uzbl.behave.commands, cmd)))
-        c(uzbl.gui.web_view, param);
-    else
+    if ((c = g_hash_table_lookup(uzbl.behave.commands, cmd))) {
+        int i;
+        gchar **par = split_quoted(param, TRUE);
+        GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*));
+        for (i = 0; i < g_strv_length(par); i++)
+            sharg_append(a, par[i]);
+        c(uzbl.gui.web_view, a);
+        g_strfreev (par);
+        g_array_free (a, TRUE);
+    } else
         fprintf (stderr, "command \"%s\" not understood. ignoring.\n", cmd);
 }
 
diff --git a/uzbl.h b/uzbl.h
index 8d53c57..f2f907e 100644 (file)
--- a/uzbl.h
+++ b/uzbl.h
@@ -96,6 +96,7 @@ typedef struct {
     GRegex         *keycmd_regex;
     GRegex         *get_regex;
     GRegex         *bind_regex;
+    gchar          **sync_stdout;
 } Communication;
 
 
@@ -223,7 +224,7 @@ static gboolean
 download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data);
 
 static void
-toggle_status_cb (WebKitWebView* page, const char *param);
+toggle_status_cb (WebKitWebView* page, GArray *argv);
 
 static void
 link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data);
@@ -262,32 +263,32 @@ static bool
 file_exists (const char * filename);
 
 static void
-set_insert_mode(WebKitWebView *page, const gchar *param);
+set_insert_mode(WebKitWebView *page, GArray *argv);
 
 static void
-load_uri (WebKitWebView * web_view, const gchar *param);
+load_uri (WebKitWebView * web_view, GArray *argv);
 
 static void
 new_window_load_uri (const gchar * uri);
 
 static void
-close_uzbl (WebKitWebView *page, const char *param);
+close_uzbl (WebKitWebView *page, GArray *argv);
 
 static gboolean
 run_command(const gchar *command, const guint npre,
             const gchar **args, const gboolean sync, char **stdout);
 
 static void
-spawn(WebKitWebView *web_view, const char *param);
+spawn(WebKitWebView *web_view, GArray *argv);
 
 static void
-spawn_sh(WebKitWebView *web_view, const char *param);
+spawn_sh(WebKitWebView *web_view, GArray *argv);
 
 static void
 parse_command(const char *cmd, const char *param);
 
 static void
-runcmd(WebKitWebView *page, const char *param);
+runcmd(WebKitWebView *page, GArray *argv);
 
 static void
 parse_cmd_line(const char *ctl_line);
@@ -356,13 +357,13 @@ static void
 search_text (WebKitWebView *page, const char *param, const gboolean forward);
 
 static void
-search_forward_text (WebKitWebView *page, const char *param);
+search_forward_text (WebKitWebView *page, GArray *argv);
 
 static void
-search_reverse_text (WebKitWebView *page, const char *param);
+search_reverse_text (WebKitWebView *page, GArray *argv);
 
 static void
-run_js (WebKitWebView * web_view, const gchar *param);
+run_js (WebKitWebView * web_view, GArray *argv);
 
 static void handle_cookies (SoupSession *session,
                                                        SoupMessage *msg,