]> git.street.me.uk Git - andy/viking.git/blobdiff - src/util.c
Create the geonames search as an VikXmlSearchTool
[andy/viking.git] / src / util.c
index 079ccc9c9e61fb4509b3aeeef5b9af6cfd9b9d1c..5c9823b8c35a0ccd5964a7d63ed1d610b7b729b2 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include <glib/gi18n.h>
 #endif
 
 #include <glib/gi18n.h>
+#include <glib/gprintf.h>
 
 #include "dialog.h"
 
 
 #include "dialog.h"
 
@@ -42,6 +43,7 @@ static gboolean spawn_command_line_async(const gchar * cmd,
 
   g_free(cmdline);
  
 
   g_free(cmdline);
  
+  return status;
 }
 
 void open_url(GtkWindow *parent, const gchar * url)
 }
 
 void open_url(GtkWindow *parent, const gchar * url)
@@ -87,3 +89,25 @@ void new_email(GtkWindow *parent, const gchar * address)
   g_free(uri);
   uri = NULL;
 }
   g_free(uri);
   uri = NULL;
 }
+
+gchar *uri_escape(gchar *str)
+{
+  gchar *esc_str = g_malloc(3*strlen(str));
+  gchar *dst = esc_str;
+  gchar *src;
+
+  for (src = str; *src; src++) {
+    if (*src == ' ')
+     *dst++ = '+';
+    else if (g_ascii_isalnum(*src))
+     *dst++ = *src;
+    else {
+      g_sprintf(dst, "%%%02X", *src);
+      dst += 3;
+    }
+  }
+  *dst = '\0';
+
+  return(esc_str);
+}
+