+static void sigchld(int unused);
+static void source(Client *c, const Arg *arg);
+static void spawn(Client *c, const Arg *arg);
+static void eval(Client *c, const Arg *arg);
+static void stop(Client *c, const Arg *arg);
+static void titlechange(WebKitWebView *v, WebKitWebFrame* frame, const char* title, Client *c);
+static void toggle(Client *c, const Arg *arg);
+static void gettogglestat(Client *c);
+static void update(Client *c);
+static void updatewinid(Client *c);
+static void usage(void);
+static void windowobjectcleared(GtkWidget *w, WebKitWebFrame *frame, JSContextRef js, JSObjectRef win, Client *c);
+static void zoom(Client *c, const Arg *arg);
+
+/* configuration, allows nested code to access above variables */
+#include "config.h"
+
+char *
+buildpath(const char *path) {
+ char *apath, *p;
+ FILE *f;
+
+ /* creating directory */
+ if(path[0] == '/') {
+ apath = g_strdup(path);
+ } else if(path[0] == '~') {
+ if(path[1] == '/') {
+ apath = g_strconcat(g_get_home_dir(), &path[1], NULL);
+ } else {
+ apath = g_strconcat(g_get_home_dir(), "/",
+ &path[1], NULL);
+ }
+ } else {
+ apath = g_strconcat(g_get_current_dir(), "/", path, NULL);
+ }
+
+ if((p = strrchr(apath, '/'))) {
+ *p = '\0';
+ g_mkdir_with_parents(apath, 0700);
+ g_chmod(apath, 0700); /* in case it existed */
+ *p = '/';
+ }
+ /* creating file (gives error when apath ends with "/") */
+ if((f = fopen(apath, "a"))) {
+ g_chmod(apath, 0600); /* always */
+ fclose(f);
+ }
+
+ return apath;
+}
+
+static gboolean
+buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl) {
+ WebKitHitTestResultContext context;
+ WebKitHitTestResult *result = webkit_web_view_get_hit_test_result(web, e);
+ Arg arg;
+
+ g_object_get(result, "context", &context, NULL);
+ if(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) {
+ if(e->button == 2) {
+ g_object_get(result, "link-uri", &arg.v, NULL);
+ newwindow(NULL, &arg, e->state & GDK_CONTROL_MASK);
+ return true;
+ }
+ }
+ return false;
+}