+char *
+buildpath(const char *path) {
+ char *apath, *p;
+ FILE *f;
+
+ /* creating directory */
+ if(path[0] == '/')
+ apath = g_strdup(path);
+ else
+ apath = g_strconcat(g_get_home_dir(), "/", path, NULL);
+ if((p = strrchr(apath, '/'))) {
+ *p = '\0';
+ g_mkdir_with_parents(apath, 0755);
+ *p = '/';
+ }
+ /* creating file (gives error when apath ends with "/") */
+ if((f = g_fopen(apath, "a")))
+ fclose(f);
+ return apath;
+}
+
+void
+changecookie(SoupCookieJar *j, SoupCookie *oc, SoupCookie *c, gpointer p) {
+ SoupDate *e;
+ SoupCookieJar *jar;
+
+ if(lockcookie)
+ return;
+ if(c && c->expires == NULL) {
+ e = soup_date_new_from_time_t(time(NULL) + sessiontime);
+ c = soup_cookie_copy(c);
+ soup_cookie_set_expires(c, e);
+ }
+
+ jar = soup_cookie_jar_text_new(cookiefile, FALSE);
+ if(c)
+ soup_cookie_jar_add_cookie(jar, soup_cookie_copy(c));
+ else
+ soup_cookie_jar_delete_cookie(jar, oc);
+ g_object_unref(jar);
+}
+