/** * Gets the base domain name from a hostname where the base domain name is the * effective second level domain name, e.g. for www.example.com it will be * example.com, for www.example.co.uk it will be example.co.uk. * * @name domainFromHost * @memberOf net * @function * * @param {String} hostname A hostname * * @returns {String} * The effective second level domain * * */ static JSValueRef net_domain_from_host(JSContextRef ctx, JSObjectRef f, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exc) { if (argc < 1) { js_make_exception(ctx, exc, EXCEPTION("domainFromHost: missing argument.")); return JSValueMakeBoolean(ctx, false); } char *host = js_value_to_char(ctx, argv[0], -1, exc); const char *domain = domain_get_base_for_host(host); if (domain == NULL) return NIL; JSValueRef ret = js_char_to_value(ctx, domain); g_free(host); return ret; }/*}}}*//*}}}*/
GSList * domain_get_cookie_domains(WebKitWebView *wv) { GSList *ret = NULL; WebKitWebFrame *frame = webkit_web_view_get_main_frame(wv); WebKitWebDataSource *data = webkit_web_frame_get_data_source(frame); if (data == NULL) return NULL; WebKitNetworkRequest *request = webkit_web_data_source_get_request(data); if (request == NULL) return NULL; SoupMessage *msg = webkit_network_request_get_message(request); if (msg == NULL) return NULL; SoupURI *uri = soup_message_get_uri(msg); if (uri == NULL) return NULL; const char *host = soup_uri_get_host(uri); char *base_host = g_strconcat(".", host, NULL); const char *base_domain = domain_get_base_for_host(base_host); char *cur = base_host; char *nextdot; while (cur != base_domain) { nextdot = strchr(cur, '.'); ret = g_slist_append(ret, nextdot); cur = nextdot+1; ret = g_slist_append(ret, cur); } return ret; }