Index: src/plugins/mozjs.c =================================================================== --- src/plugins/mozjs.c (revision 199) +++ src/plugins/mozjs.c (working copy) @@ -33,16 +33,16 @@ #include "pacutils.h" static JSBool dnsResolve(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { - // Get hostname argument + /* Get hostname argument */ char *tmp = px_strdup(JS_GetStringBytes(JS_ValueToString(cx, argv[0]))); - // Look it up + /* Look it up */ struct addrinfo *info; if (getaddrinfo(tmp, NULL, NULL, &info)) goto error; px_free(tmp); - // Try for IPv4 + /* Try for IPv4 */ tmp = px_malloc0(INET_ADDRSTRLEN+1); if (inet_ntop(info->ai_family, &((struct sockaddr_in *) info->ai_addr)->sin_addr, @@ -53,7 +53,7 @@ return true; } - // Try for IPv6 + /* Try for IPv6 */ px_free(tmp); tmp = px_malloc0(INET6_ADDRSTRLEN+1); if (inet_ntop(info->ai_family, @@ -91,12 +91,12 @@ jsval rval; char *answer = NULL; - // Make sure we have the pac file and url + /* Make sure we have the pac file and url */ if (!pac) return NULL; if (!url) return NULL; if (!px_pac_to_string(pac) && !px_pac_reload(pac)) return NULL; - // Setup Javascript global class + /* Setup Javascript global class */ JSClass *global_class = px_malloc0(sizeof(JSClass)); global_class->name = "global"; global_class->flags = 0; @@ -109,24 +109,24 @@ global_class->convert = JS_ConvertStub; global_class->finalize = JS_FinalizeStub; - // Initialize Javascript runtime environment + /* Initialize Javascript runtime environment */ if (!(runtime = JS_NewRuntime(1024 * 1024))) goto out; if (!(context = JS_NewContext(runtime, 1024 * 1024))) goto out; if (!(global = JS_NewObject(context, global_class, NULL, NULL))) goto out; JS_InitStandardClasses(context, global); - // Define Javascript functions + /* Define Javascript functions */ JS_DefineFunction(context, global, "dnsResolve", dnsResolve, 1, 0); JS_DefineFunction(context, global, "myIpAddress", myIpAddress, 0, 0); JS_EvaluateScript(context, global, JAVASCRIPT_ROUTINES, strlen(JAVASCRIPT_ROUTINES), "pacutils.js", 0, &rval); - // Add PAC to the environment + /* Add PAC to the environment */ JS_EvaluateScript(context, JS_GetGlobalObject(context), px_pac_to_string(pac), strlen(px_pac_to_string(pac)), px_url_to_string((pxURL *) px_pac_get_url(pac)), 0, &rval); - // Build arguments to the FindProxyForURL() function + /* Build arguments to the FindProxyForURL() function */ char *tmpurl = px_strdup(px_url_to_string(url)); char *tmphost = px_strdup(px_url_get_host(url)); jsval val[2] = { @@ -134,7 +134,7 @@ STRING_TO_JSVAL(JS_NewString(context, tmphost, strlen(tmphost))) }; - // Find the proxy (call FindProxyForURL()) + /* Find the proxy (call FindProxyForURL()) */ JSBool result = JS_CallFunctionName(context, JS_GetGlobalObject(context), "FindProxyForURL", 2, val, &rval); if (!result) goto out; Index: src/plugins/xhasclient.c =================================================================== --- src/plugins/xhasclient.c (revision 199) +++ src/plugins/xhasclient.c (working copy) @@ -43,40 +43,40 @@ { va_list ap; - // Open display + /* Open display */ Display *display = XOpenDisplay(NULL); if (!display) return false; - // For each screen... + /* For each screen... */ for (int i=0; i < ScreenCount(display); i++) { Window dummy, *children = NULL; unsigned int nchildren = 0; - // Get the root window's children + /* Get the root window's children */ if (!XQueryTree(display, RootWindow(display, i), &dummy, &dummy, &children, &nchildren)) continue; - // For each child on the screen... + /* For each child on the screen... */ for (int j=0; j < nchildren; j++) { - // If we can get their client info... + /* If we can get their client info... */ Window client; if ((client = XmuClientWindow(display, children[j])) != None) { int argc; char **argv; - // ... and if we can find out their command ... + /* ... and if we can find out their command ... */ if (!XGetCommand (display, client, &argv, &argc) || argc == 0) continue; - // ... check the commands against our list + /* ... check the commands against our list */ va_start(ap, prog); for (char *s = prog ; s ; s = va_arg(ap, char *)) { - // We've found a match, return... + /* We've found a match, return... */ if (!strcmp(argv[0], s)) { va_end(ap); @@ -89,7 +89,7 @@ } } - // Close the display + /* Close the display */ XCloseDisplay(display); return false; } Index: src/plugins/kde.c =================================================================== --- src/plugins/kde.c (revision 199) +++ src/plugins/kde.c (working copy) @@ -28,17 +28,17 @@ #include #include -// From xhasclient.c +/* From xhasclient.c */ bool x_has_client(char *prog, ...); pxConfig * kde_config_cb(pxProxyFactory *self) { - // TODO: make ignores work w/ KDE + /* TODO: make ignores work w/ KDE */ char *url = NULL, *ignore = NULL, *tmp = getenv("HOME"); if (!tmp) return NULL; - // Open the config file + /* Open the config file */ pxConfigFile *cf = px_proxy_factory_misc_get(self, "kde"); if (!cf || px_config_file_is_stale(cf)) { @@ -50,19 +50,19 @@ } if (!cf) goto out; - // Read the config file to find out what type of proxy to use + /* Read the config file to find out what type of proxy to use */ tmp = px_config_file_get_value(cf, "Proxy Settings", "ProxyType"); if (!tmp) { px_config_file_free(cf); goto out; } - // Don't use any proxy + /* Don't use any proxy */ if (!strcmp(tmp, "0")) url = px_strdup("direct://"); - // Use a manual proxy + /* Use a manual proxy */ else if (!strcmp(tmp, "1")) url = px_config_file_get_value(cf, "Proxy Settings", "httpProxy"); - // Use a manual PAC + /* Use a manual PAC */ else if (!strcmp(tmp, "2")) { px_free(tmp); @@ -71,15 +71,15 @@ else url = px_strdup("wpad://"); } - // Use WPAD + /* Use WPAD */ else if (!strcmp(tmp, "3")) url = px_strdup("wpad://"); - // Use envvar + /* Use envvar $HOME */ else if (!strcmp(tmp, "4")) - url = NULL; // We'll bypass this config plugin and let the envvar plugin work + url = NULL; /* We'll bypass this config plugin and let the envvar plugin work */ - // Cleanup + /* Cleanup */ px_free(tmp); px_config_file_free(cf); @@ -90,7 +90,7 @@ bool on_proxy_factory_instantiate(pxProxyFactory *self) { - // If we are running in KDE, then make sure this plugin is registered. + /* If we are running in KDE, then make sure this plugin is registered. */ if (x_has_client("kicker", NULL)) return px_proxy_factory_config_add(self, "kde", PX_CONFIG_CATEGORY_SESSION, (pxProxyFactoryPtrCallback) kde_config_cb); Index: src/plugins/networkmanager.c =================================================================== --- src/plugins/networkmanager.c (revision 199) +++ src/plugins/networkmanager.c (working copy) @@ -30,12 +30,11 @@ void nm_on_get_proxy(pxProxyFactory *self) { - // Make sure we have a valid connection with a proper match + /* Make sure we have a valid connection with a proper match */ DBusConnection *conn = px_proxy_factory_misc_get(self, "networkmanager"); if (!conn || !dbus_connection_get_is_connected(conn)) { - // If the connection was disconnected, - // close it an clear the queue + /* If the connection was disconnected, close it an clear the queue */ if (conn) { dbus_connection_close(conn); @@ -43,32 +42,30 @@ for (DBusMessage *msg=NULL ; (msg = dbus_connection_pop_message(conn)) ; dbus_message_unref(msg)); } - // Create a new connections + /* Create a new connection */ conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, NULL); if (!conn) return; - // If connection was successful, set it up + /* If connection was successful, set it up */ dbus_connection_set_exit_on_disconnect(conn, false); dbus_bus_add_match(conn, "type='signal',interface='" NM_DBUS_INTERFACE "',member='StateChange'", NULL); dbus_connection_flush(conn); px_proxy_factory_misc_set(self, "networkmanager", conn); } - // We are guaranteed a connection, - // so check for incoming messages + /* We are guaranteed a connection, so check for incoming messages */ bool changed = false; while (true) { DBusMessage *msg = NULL; uint32_t state; - // Pull messages off the queue + /* Pull messages off the queue */ dbus_connection_read_write(conn, 0); if (!(msg = dbus_connection_pop_message(conn))) break; - // If a message is the right type and value, - // we'll reset the network + /* If a message is the right type and value, we'll reset the network */ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID)) if (state == NM_STATE_CONNECTED) changed = true; @@ -76,7 +73,7 @@ dbus_message_unref(msg); } - // Reset the network if ready + /* Reset the network if ready */ if (changed) px_proxy_factory_network_changed(self); } Index: src/plugins/gnome.c =================================================================== --- src/plugins/gnome.c (revision 199) +++ src/plugins/gnome.c (working copy) @@ -25,34 +25,34 @@ #include -// From xhasclient.c +/* From xhasclient.c */ bool x_has_client(char *prog, ...); pxConfig * gconf_config_cb(pxProxyFactory *self) { - // Get the GConf client + /* Get the GConf client */ GConfClient *client = px_proxy_factory_misc_get(self, "gnome"); if (!client) { - // Create a new instance if not found + /* Create a new instance if not found */ client = gconf_client_get_default(); if (!client) return NULL; px_proxy_factory_misc_set(self, "gnome", client); } g_object_ref(client); - // Get the mode + /* Get the mode */ char *mode = gconf_client_get_string(client, "/system/proxy/mode", NULL); if (!mode) { g_object_unref(client); return NULL; } char *url = NULL, *ignore = NULL; - // Mode is direct:// + /* Mode is direct:// */ if (!strcmp(mode, "none")) url = px_strdup("direct://"); - // Mode is wpad:// or pac+http://... + /* Mode is wpad:// or pac+http://... */ else if (!strcmp(mode, "auto")) { char *tmp = gconf_client_get_string(client, "/system/proxy/autoconfig_url", NULL); @@ -63,7 +63,7 @@ px_free(tmp); } - // Mode is http://... or socks://... + /* Mode is http://... or socks://... */ else if (!strcmp(mode, "manual")) { char *type = px_strdup("http"); @@ -71,7 +71,7 @@ int port = gconf_client_get_int (client, "/system/http_proxy/port", NULL); if (port < 0 || port > 65535) port = 0; - // If http proxy is not set, try socks + /* If http proxy is not set, try socks */ if (!host || !strcmp(host, "") || !port) { if (type) px_free(type); @@ -83,7 +83,7 @@ if (port < 0 || port > 65535) port = 0; } - // If host and port were found, build config url + /* If host and port were found, build config url */ if (host && strcmp(host, "") && port) url = g_strdup_printf("%s://%s:%d", type, host, port); @@ -122,7 +122,7 @@ bool on_proxy_factory_instantiate(pxProxyFactory *self) { - // If we are running in GNOME, then make sure this plugin is registered. + /* If we are running in GNOME, then make sure this plugin is registered. */ if (x_has_client("gnome-session", "gnome-panel", NULL)) { g_type_init(); @@ -137,7 +137,7 @@ { px_proxy_factory_config_del(self, "gnome"); - // Close the GConf connection, if present + /* Close the GConf connection, if present */ if (px_proxy_factory_misc_get(self, "gnome")) { g_object_unref(px_proxy_factory_misc_get(self, "gnome")); Index: src/lib/wpad_dns.c =================================================================== --- src/lib/wpad_dns.c (revision 199) +++ src/lib/wpad_dns.c (working copy) @@ -34,13 +34,13 @@ char *domain; }; -// The top-level domain blacklist +/* The top-level domain blacklist */ static char *tld[] = { - // General top-level domains + /* General top-level domains */ "arpa", "root", "aero", "biz", "cat", "com", "coop", "edu", "gov", "info", "int", "jobs", "mil", "mobi", "museum", "name", "net", "org", "pro", "travel", - // Country codes + /* Country codes */ "ac", "ad", "ae", "af", "ag", "ai", "al", "am", "an", "ao", "aq", "ar", "as", "at", "au", "aw", "ax", "az", "ba", "bb", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bm", "bn", "bo", "br", "bs", "bt", "bv", "bw", "by", @@ -63,23 +63,23 @@ "uy", "uz", "va", "vc", "ve", "vg", "vi", "vn", "vu", "wf", "ws", "ye", "yt", "yu", "za", "zm", "zw", - // Other domains to blacklist + /* Other domains to blacklist */ "co.uk", "com.au", - // Terminator + /* Terminator */ NULL }; static char * get_domain_name() { - // Get the hostname + /* Get the hostname */ char *hostname = px_malloc0(128); for (int i = 0 ; gethostname(hostname, (i + 1) * 128) && errno == ENAMETOOLONG ; ) hostname = px_malloc0((++i + 1) * 128); - // Lookup the hostname - // TODO: Make this whole process not suck + /* Lookup the hostname */ + /* TODO: Make this whole process not suck */ struct hostent *host_info = gethostbyname(hostname); if (host_info) { @@ -87,7 +87,7 @@ hostname = px_strdup(host_info->h_name); } - // Get domain portion + /* Get domain portion */ if (!strchr(hostname, '.')) return NULL; if (!strcmp(".", strchr(hostname, '.'))) return NULL; char *tmp = px_strdup(strchr(hostname, '.') + 1); @@ -107,29 +107,29 @@ return urls; } - // Split up the domain + /* Split up the domain */ char **domainv = px_strsplit(domain, "."); if (!domainv) return NULL; - // Count the number of domain blocks + /* Count the number of domain blocks */ int count = 0; for (int i=0 ; *(domainv + i) ; i++) count++; - // Allocate our URL array + /* Allocate our URL array */ urls = px_malloc0(sizeof(pxURL *) * (count + 2)); - // Create the URLs + /* Create the URLs */ urls[0] = px_url_new("http://wpad/wpad.dat"); char *url = px_malloc0(strlen("http://wpad./wpad.dat") + strlen(domain) + 1); for (int i=0, j=1 ; domainv[i] ; i++) { - // Check the domain against the blacklist + /* Check the domain against the blacklist */ char *tmp = px_strjoin((const char **) (domainv + i), "."); for (int k=0; tld[k] ; k++) if (!strcmp(tmp, tld[k])) { px_free(tmp); tmp = NULL; break; } if (!tmp) continue; - // Create the URL + /* Create the URL */ sprintf(url, "http://wpad.%s/wpad.dat", tmp); px_free(tmp); tmp = NULL; urls[j] = px_url_new(url); @@ -176,25 +176,25 @@ if (!self->urls) { char *domain; - // Reset the counter + /* Reset the counter */ self->next = 0; - // Get the domain name + /* Get the domain name */ if (self->domain) domain = px_strdup(self->domain); else domain = get_domain_name(); - // Get the URLs + /* Get the URLs */ self->urls = get_urls(domain); px_free(domain); - // Make sure we have more than one URL + /* Make sure we have more than one URL */ if (!self->urls || !self->urls[0]) return NULL; } - // Try to find a PAC at each URL + /* Try to find a PAC at each URL */ for (pxPAC *pac = NULL ; self->urls[self->next] ; ) if ((pac = px_pac_new(self->urls[self->next++]))) return pac; Index: src/lib/misc.h =================================================================== --- src/lib/misc.h (revision 199) +++ src/lib/misc.h (working copy) @@ -20,7 +20,7 @@ #ifndef MISC_H_ #define MISC_H_ -#include // For type size_t +#include /* For type size_t */ /** * Allocates memory and always returns valid memory. Index: src/lib/url.c =================================================================== --- src/lib/url.c (revision 199) +++ src/lib/url.c (working copy) @@ -87,10 +87,10 @@ char *joined_headers = NULL; int sock = -1; - // DNS lookup of host + /* DNS lookup of host */ if (!px_url_get_ips(self)) goto error; - // Iterate through each pxIP trying to make a connection + /* Iterate through each pxIP trying to make a connection */ for (int i = 0 ; self->ips && self->ips[i] && sock < 0 ; i++) { sock = socket(self->ips[i]->sa_family, SOCK_STREAM, 0); @@ -108,7 +108,7 @@ } if (sock < 0) goto error; - // Merge optional headers + /* Merge optional headers */ if (headers) { joined_headers = px_strjoin(headers, "\r\n"); @@ -117,17 +117,17 @@ else joined_headers = px_strdup(""); - // Create request header + /* Create request header */ request = px_strcat("GET ", px_url_get_path(self), " HTTP/1.1\r\nHost: ", px_url_get_host(self), "\r\n", joined_headers, "\r\n\r\n", NULL); px_free(joined_headers); - // Send HTTP request + /* Send HTTP request */ if (send(sock, request, strlen(request), 0) != strlen(request)) goto error; px_free(request); request = NULL; - // Return the socket, which is ready for reading the response + /* Return the socket, which is ready for reading the response */ return sock; error: @@ -166,12 +166,12 @@ { if (!self) return NULL; - // Check the cache + /* Check the cache */ if (self->ips && self->ips[0]) return (const struct sockaddr *) self->ips[0]; px_free(self->ips); - // Try for IPv4 first + /* Try for IPv4 first */ struct sockaddr *ip = px_malloc0(sizeof(struct sockaddr_in)); if (inet_pton(AF_INET, px_url_get_host(self), &((struct sockaddr_in *) ip)->sin_addr) > 0) { @@ -182,7 +182,7 @@ } px_free(ip); - // Try for IPv6 next + /* Try for IPv6 next */ ip = px_malloc0(sizeof(struct sockaddr_in6)); if (inet_pton(AF_INET6, px_url_get_host(self), &((struct sockaddr_in6 *) ip)->sin6_addr) > 0) { @@ -193,7 +193,7 @@ } px_free(ip); - // The hostname was not an IP address + /* The hostname was not an IP address */ return NULL; } @@ -206,24 +206,24 @@ { if (!self) return NULL; - // Check the cache + /* Check the cache */ if (self->ips) return (const struct sockaddr **) self->ips; - // Check without DNS first + /* Check without DNS first */ if (px_url_get_ip_no_dns(self)) return (const struct sockaddr **) self->ips; - // Check DNS for IPs + /* Check DNS for IPs */ struct addrinfo *info; if (!getaddrinfo(px_url_get_host(self), NULL, NULL, &info)) { struct addrinfo *first = info; int count; - // Count how many IPs we got back + /* Count how many IPs we got back */ for (count=0 ; info ; info = info->ai_next) count++; - // Copy the sockaddr's into self->ips + /* Copy the sockaddr's into self->ips */ info = first; self->ips = px_malloc0(sizeof(struct sockaddr *) * ++count); for (int i=0 ; info ; info = info->ai_next) @@ -246,7 +246,7 @@ return (const struct sockaddr **) self->ips; } - // No addresses found + /* No addresses found */ return NULL; } @@ -287,24 +287,24 @@ pxURL * px_url_new(const char *url) { - // Allocate pxURL + /* Allocate pxURL */ pxURL *self = px_malloc0(sizeof(pxURL)); - // Get scheme + /* Get scheme */ if (!strstr(url, "://")) goto error; self->scheme = px_strndup(url, strstr(url, "://") - url); - // Get host + /* Get host */ self->host = px_strdup(strstr(url, "://") + strlen("://")); - // Get path + /* Get path */ self->path = px_strdup(strchr(self->host, '/')); if (self->path) self->host[strlen(self->host) - strlen(self->path)] = 0; else self->path = px_strdup(""); - // Get the port + /* Get the port */ bool port_specified = false; if (strchr(self->host, ':')) { if (!atoi(strchr(self->host, ':')+1)) goto error; @@ -315,10 +315,10 @@ else self->port = px_url_get_default_port(self); - // Make sure we have a real host + /* Make sure we have a real host */ if (!strcmp(self->host, "")) goto error; - // Verify by re-assembly + /* Verify by re-assembly */ self->url = px_malloc0(strlen(url) + 1); if (!port_specified) snprintf(self->url, strlen(url) + 1, "%s://%s%s", self->scheme, self->host, self->path); Index: src/lib/pac.c =================================================================== --- src/lib/pac.c (revision 199) +++ src/lib/pac.c (working copy) @@ -70,13 +70,13 @@ { if (!url) return NULL; - // Allocate the object + /* Allocate the object */ pxPAC *self = px_malloc0(sizeof(pxPAC)); - // Copy the given URL - self->url = px_url_new(px_url_to_string(url)); // Always returns valid value + /* Copy the given URL */ + self->url = px_url_new(px_url_to_string(url)); /* Always returns valid value */ - // Make sure we have a real pxPAC + /* Make sure we have a real pxPAC */ if (!px_pac_reload(self)) { px_pac_free(self); return NULL; } return self; @@ -90,13 +90,13 @@ pxPAC * px_pac_new_from_string(char *url) { - // Create temporary URL + /* Create temporary URL */ pxURL *tmpurl = px_url_new(url); if (!tmpurl) return NULL; - // Create pac + /* Create pac */ pxPAC *self = px_pac_new(tmpurl); - px_url_free(tmpurl); // Free no longer used URL + px_url_free(tmpurl); /* Free no longer used URL */ if (!self) return NULL; return self; } @@ -124,33 +124,33 @@ bool correct_mime_type; unsigned long int content_length = 0; - // Get the pxPAC + /* Get the pxPAC */ sock = px_url_get(self->url, headers); if (sock < 0) return false; - // Verify status line + /* Verify status line */ line = px_readline(sock); if (!line) goto error; - if (strncmp(line, "HTTP", strlen("HTTP"))) goto error; // Check valid HTTP response - if (!strchr(line, ' ') || atoi(strchr(line, ' ') + 1) != 200) goto error; // Check status code + if (strncmp(line, "HTTP", strlen("HTTP"))) goto error; /* Check valid HTTP response */ + if (!strchr(line, ' ') || atoi(strchr(line, ' ') + 1) != 200) goto error; /* Check status code */ - // Check for correct mime type and content length + /* Check for correct mime type and content length */ while (strcmp(line, "\r")) { - // Check for content type + /* Check for content type */ if (strstr(line, "Content-Type: ") == line && strstr(line, PAC_MIME_TYPE)) correct_mime_type = true; - // Check for content length + /* Check for content length */ else if (strstr(line, "Content-Length: ") == line) content_length = atoi(line + strlen("Content-Length: ")); - // Get new line + /* Get new line */ px_free(line); line = px_readline(sock); if (!line) goto error; } - // Get content + /* Get content */ if (!content_length || !correct_mime_type) goto error; px_free(line); line = NULL; px_free(self->cache); @@ -158,7 +158,7 @@ for (int recvd=0 ; recvd != content_length ; ) recvd += recv(sock, self->cache + recvd, content_length - recvd, 0); - // Clean up + /* Clean up */ close(sock); return true; Index: src/lib/config_file.c =================================================================== --- src/lib/config_file.c (revision 199) +++ src/lib/config_file.c (working copy) @@ -36,36 +36,36 @@ pxConfigFile * px_config_file_new(char *filename) { - // Open the file and stat it + /* Open the file and stat it */ struct stat st; int fd = open(filename, O_RDONLY); if (fd < 0) return NULL; fstat(fd, &st); - // Allocate our structure; get mtime and filename + /* Allocate our structure; get mtime and filename */ pxConfigFile *self = px_malloc0(sizeof(pxConfigFile)); self->filename = px_strdup(filename); self->mtime = st.st_mtime; self->sections = px_strdict_new((void *) px_strdict_free); - // Add one section (PX_CONFIG_FILE_DEFAULT_SECTION) + /* Add one section (PX_CONFIG_FILE_DEFAULT_SECTION) */ px_strdict_set(self->sections, PX_CONFIG_FILE_DEFAULT_SECTION, px_strdict_new(free)); pxStrDict *current = (pxStrDict *) px_strdict_get(self->sections, PX_CONFIG_FILE_DEFAULT_SECTION); - // Parse our file + /* Parse our file */ for (char *line=NULL ; (line = px_readline(fd)) ; px_free(line)) { - // Strip + /* Strip */ char *tmp = px_strstrip(line); px_free(line); line = tmp; - // Check for comment and/or empty line + /* Check for comment and/or empty line */ if (*line == '#' || !strcmp(line, "")) continue; - // If we have a new section + /* If we have a new section */ if (*line == '[' || line[strlen(line)-1] == ']') { - // Get just the section name + /* Get just the section name */ memmove(line, line+1, strlen(line)-1); line[strlen(line)-2] = '\0'; @@ -75,7 +75,7 @@ px_strdict_set(self->sections, line, px_strdict_new(free)); } - // If this is a key/val line, get the key/val. + /* If this is a key/val line, get the key/val. */ else if ((tmp = strchr(line, '=')) && tmp[1]) { *tmp = '\0'; Index: src/lib/url.h =================================================================== --- src/lib/url.h (revision 199) +++ src/lib/url.h (working copy) @@ -20,7 +20,7 @@ #ifndef URL_H_ #define URL_H_ -#include "stdbool.h" // For type bool +#include "stdbool.h" /* For type bool */ /** * WPAD object. All fields are private. Index: src/lib/proxy_factory.c =================================================================== --- src/lib/proxy_factory.c (revision 199) +++ src/lib/proxy_factory.c (working copy) @@ -58,7 +58,7 @@ pxConfigFile *cf; }; -// Convert the PAC formatted response into our proxy URL array response +/* Convert the PAC formatted response into our proxy URL array response */ static char ** _format_pac_response(char *response) { @@ -107,7 +107,7 @@ if (ip_a->sa_family != ip_b->sa_family) return false; if (nm && ip_a->sa_family != nm->sa_family) return false; - // Setup the arrays + /* Setup the arrays */ uint8_t bytes = 0, *a_data = NULL, *b_data = NULL, *nm_data = NULL; if (ip_a->sa_family == AF_INET) { @@ -142,26 +142,26 @@ if (!ip) return NULL; struct sockaddr *result = NULL; - // Copy the string + /* Copy the string */ if (len >= 0) ip = px_strndup(ip, len); else ip = px_strdup(ip); - // Try to parse IPv4 + /* Try to parse IPv4 */ result = px_malloc0(sizeof(struct sockaddr_in)); result->sa_family = AF_INET; if (inet_pton(AF_INET, ip, &((struct sockaddr_in *) result)->sin_addr) > 0) goto out; - // Try to parse IPv6 + /* Try to parse IPv6 */ px_free(result); result = px_malloc0(sizeof(struct sockaddr_in6)); result->sa_family = AF_INET6; if (inet_pton(AF_INET6, ip, &((struct sockaddr_in6 *) result)->sin6_addr) > 0) goto out; - // No address found + /* No address found */ px_free(result); result = NULL; out: @@ -172,7 +172,7 @@ static struct sockaddr * _sockaddr_from_cidr(int af, int cidr) { - // TODO: Support CIDR notation + /* TODO: Support CIDR notation */ return NULL; } @@ -186,21 +186,25 @@ const struct sockaddr *dst_ip = px_url_get_ip_no_dns(url); struct sockaddr *ign_ip = NULL, *net_ip = NULL; - // IPv4 - // IPv6 + /* + * IPv4 + * IPv6 + */ if ((ign_ip = _sockaddr_from_string(ignore, -1))) goto out; - // IPv4/CIDR - // IPv4/IPv4 - // IPv6/CIDR - // IPv6/IPv6 + /* + * IPv4/CIDR + * IPv4/IPv4 + * IPv6/CIDR + * IPv6/IPv6 + */ if (strchr(ignore, '/')) { ign_ip = _sockaddr_from_string(ignore, strchr(ignore, '/') - ignore); net_ip = _sockaddr_from_string(strchr(ignore, '/') + 1, -1); - // If CIDR notation was used, get the netmask + /* If CIDR notation was used, get the netmask */ if (ign_ip && !net_ip) { uint32_t cidr = 0; @@ -217,13 +221,15 @@ net_ip = NULL; } - // IPv4:port - // [IPv6]:port + /* + * IPv4:port + * [IPv6]:port + */ if (strrchr(ignore, ':') && sscanf(strrchr(ignore, ':'), ":%u", &port) == 1 && port > 0) { ign_ip = _sockaddr_from_string(ignore, strrchr(ignore, ':') - ignore); - // Make sure this really is just a port and not just an IPv6 address + /* Make sure this really is just a port and not just an IPv6 address */ if (ign_ip && (ign_ip->sa_family != AF_INET6 || ignore[0] == '[')) goto out; @@ -245,11 +251,11 @@ if (!url || !ignore) return false; - // Get our URL's hostname and port + /* Get our URL's hostname and port */ char *host = px_strdup(px_url_get_host(url)); int port = px_url_get_port(url); - // Get our ignore pattern's hostname and port + /* Get our ignore pattern's hostname and port */ char *ihost = px_strdup(ignore); int iport = 0; if (strchr(ihost, ':')) @@ -261,27 +267,27 @@ iport = 0; } - // Hostname match (domain.com or domain.com:80) + /* Hostname match (domain.com or domain.com:80) */ if (!strcmp(host, ihost)) if (!iport || port == iport) goto match; - // Endswith (.domain.com or .domain.com:80) + /* Endswith (.domain.com or .domain.com:80) */ if (ihost[0] == '.' && _endswith(host, ihost)) if (!iport || port == iport) goto match; - // Glob (*.domain.com or *.domain.com:80) + /* Glob (*.domain.com or *.domain.com:80) */ if (ihost[0] == '*' && _endswith(host, ihost+1)) if (!iport || port == iport) goto match; - // No match was found + /* No match was found */ px_free(host); px_free(ihost); return false; - // A match was found + /* A match was found */ match: px_free(host); px_free(ihost); @@ -291,7 +297,7 @@ static void destantiate_plugins(void *item, void *self) { - // Call the destantiation hook + /* Call the destantiation hook */ pxProxyFactoryVoidCallback destantiate; destantiate = dlsym(item, "on_proxy_factory_destantiate"); if (destantiate) @@ -318,22 +324,22 @@ self->misc = px_strdict_new(NULL); self->on_get_proxies = px_array_new(NULL, NULL, true, false); - // Open the plugin dir + /* Open the plugin dir */ DIR *plugindir = opendir(PLUGINDIR); if (!plugindir) return self; - // For each plugin... + /* For each plugin... */ struct dirent *ent; for (int i=0 ; (ent = readdir(plugindir)) ; i++) { - // Load the plugin + /* Load the plugin */ char *tmp = px_strcat(PLUGINDIR, "/", ent->d_name, NULL); void *plugin = dlopen(tmp, RTLD_LOCAL); px_free(tmp); if (!plugin) continue; - // Call the instantiation hook + /* Call the instantiation hook */ pxProxyFactoryBoolCallback instantiate; instantiate = dlsym(plugin, "on_proxy_factory_instantiate"); if (instantiate && !instantiate(self)) @@ -352,27 +358,29 @@ int count; pxProxyFactoryConfig **tmp; - // Verify some basic stuff + /* Verify some basic stuff */ if (!self) return false; if (!callback) return false; if (!name || !strcmp(name, "")) return false; - // Allocate an empty config array if there is none + /* Allocate an empty config array if there is none */ if (!self->configs) self->configs = px_malloc0(sizeof(pxProxyFactoryConfig *)); - // Make sure that 'name' is unique - // Also, get a count of how many configs we have + /* + * Make sure that 'name' is unique + * Also, get a count of how many configs we have + */ for (count=0 ; self->configs[count] ; count++) if (!strcmp(self->configs[count]->name, name)) return false; - // Allocate new array, copy old values into it and free old array + /* Allocate new array, copy old values into it and free old array */ tmp = px_malloc0(sizeof(pxProxyFactoryConfig *) * (count + 2)); memcpy(tmp, self->configs, sizeof(pxProxyFactoryConfig *) * count); px_free(self->configs); self->configs = tmp; - // Add the new callback to the end + /* Add the new callback to the end */ self->configs[count] = px_malloc0(sizeof(pxProxyFactoryConfig)); self->configs[count]->category = category; self->configs[count]->name = px_strdup(name); @@ -386,12 +394,12 @@ { int i,j; - // Verify some basic stuff + /* Verify some basic stuff */ if (!self) return false; if (!name || !strcmp(name, "")) return false; if (!self->configs) return false; - // Remove and shift all configs down (if found) + /* Remove and shift all configs down (if found) */ for (i=0,j=0 ; self->configs[j]; i++,j++) { if (i != j) @@ -403,7 +411,7 @@ } } - // If we have an empty array, free it + /* If we have an empty array, free it */ if (!self->configs[0]) { px_free(self->configs); @@ -416,7 +424,7 @@ bool px_proxy_factory_misc_set(pxProxyFactory *self, const char *key, const void *value) { - // Verify some basic stuff + /* Verify some basic stuff */ if (!self) return false; if (!key || !strcmp(key, "")) return false; @@ -426,7 +434,7 @@ void * px_proxy_factory_misc_get(pxProxyFactory *self, const char *key) { - // Verify some basic stuff + /* Verify some basic stuff */ if (!self) return NULL; if (!key || !strcmp(key, "")) return NULL; @@ -454,47 +462,47 @@ char **response = px_strsplit("direct://", ";"); char *tmp = NULL, *order = NULL, **orderv = NULL; - // Verify some basic stuff + /* Verify some basic stuff */ if (!self) goto do_return; if (!url || !strcmp(url, "")) goto do_return; if (!realurl) goto do_return; - // Lock mutex + /* Lock mutex */ pthread_mutex_lock(&self->mutex); - // Call the events + /* Call the events */ px_array_foreach(self->on_get_proxies, call_on_proxy_factory_get_proxies, self); - // If our config file is stale, close it + /* If our config file is stale, close it */ if (self->cf && px_config_file_is_stale(self->cf)) { px_config_file_free(self->cf); self->cf = NULL; } - // Try to open our config file if we don't have one + /* Try to open our config file if we don't have one */ if (!self->cf) self->cf = px_config_file_new(SYSCONFDIR "/proxy.conf"); - // If we have a config file, load the order from it + /* If we have a config file, load the order from it */ if (self->cf) tmp = px_config_file_get_value(self->cf, PX_CONFIG_FILE_DEFAULT_SECTION, "config_order"); - // Attempt to get info from the environment + /* Attempt to get info from the environment */ order = getenv("PX_CONFIG_ORDER"); - // Create the config order + /* Create the config order */ order = px_strcat(tmp ? tmp : "", ",", order ? order : "", ",", DEFAULT_CONFIG_ORDER, NULL); px_free(tmp); tmp = NULL; - // Create the config plugin order vector + /* Create the config plugin order vector */ orderv = px_strsplit(order, ","); px_free(order); - // Get the config by searching the config order + /* Get the config by searching the config order */ for (int i=0 ; orderv[i] && !config ; i++) { - // Get the category (if applicable) + /* Get the category (if applicable) */ pxConfigCategory category; if (!strcmp(orderv[i], "USER")) category = PX_CONFIG_CATEGORY_USER; @@ -515,11 +523,11 @@ } px_strfreev(orderv); - // No config was found via search order, call all plugins + /* No config was found via search order, call all plugins */ for (int i=0 ; self->configs && self->configs[i] && !config ; i++) config = self->configs[i]->callback(self); - // No plugin returned a valid config, fall back to 'wpad://' + /* No plugin returned a valid config, fall back to 'wpad://' */ if (!config) { fprintf(stderr, "*** Unable to locate valid config! Falling back to auto-detection...\n"); @@ -528,7 +536,7 @@ config->ignore = px_strdup(""); } - // If the config plugin returned an invalid config type or malformed URL, fall back to 'wpad://' + /* If the config plugin returned an invalid config type or malformed URL, fall back to 'wpad://' */ if (!(!strncmp(config->url, "http://", 7) || !strncmp(config->url, "socks://", 8) || !strncmp(config->url, "pac+", 4) || @@ -553,7 +561,7 @@ config->url = px_strdup("wpad://"); } - // Check our ignore patterns + /* Check our ignore patterns */ char **ignores = px_strsplit(config->ignore, ","); for (int i=0 ; ignores[i] ; i++) { @@ -565,10 +573,10 @@ } px_strfreev(ignores); - // If we have a wpad config + /* If we have a wpad config */ if (!strcmp(config->url, "wpad://")) { - // Get the WPAD object if needed + /* Get the WPAD object if needed */ if (!self->wpad) { if (self->pac) px_pac_free(self->pac); @@ -581,45 +589,46 @@ } } - // If we have no PAC, get one - // If getting the PAC fails, but the WPAD cycle worked, restart the cycle + /* + * If we have no PAC, get one + * If getting the PAC fails, but the WPAD cycle worked, restart the cycle + */ if (!self->pac && !(self->pac = px_wpad_next(self->wpad)) && px_wpad_pac_found(self->wpad)) { px_wpad_rewind(self->wpad); self->pac = px_wpad_next(self->wpad); } - // If the WPAD cycle failed, fall back to direct + /* If the WPAD cycle failed, fall back to direct */ if (!self->pac) { fprintf(stderr, "*** Unable to locate PAC! Falling back to direct...\n"); goto do_return; } - // Run the PAC + /* Run the PAC */ if (self->pac_runner) { px_strfreev(response); response = _format_pac_response(self->pac_runner(self, self->pac, realurl)); } - // No PAC runner found, fall back to direct + /* No PAC runner found, fall back to direct */ else fprintf(stderr, "*** PAC found, but no active PAC runner! Falling back to direct...\n"); } - // If we have a PAC config + /* If we have a PAC config */ else if (!strncmp(config->url, "pac+", 4)) { - // Clear WPAD to indicate that this is a non-WPAD PAC + /* Clear WPAD to indicate that this is a non-WPAD PAC */ if (self->wpad) { px_wpad_free(self->wpad); self->wpad = NULL; } - // If a PAC alread exists, but comes from a different URL than the one - // specified, remove it + /* If a PAC already exists, but came from a different URL than the one specified, remove it */ if (self->pac) { pxURL *urltmp = px_url_new(config->url + 4); @@ -636,14 +645,14 @@ px_url_free(urltmp); } - // Try to load the PAC if it is not already loaded + /* Try to load the PAC if it is not already loaded */ if (!self->pac && !(self->pac = px_pac_new_from_string(config->url + 4))) { fprintf(stderr, "*** Invalid PAC URL! Falling back to direct...\n"); goto do_return; } - // Run the PAC + /* Run the PAC */ if (self->pac_runner) { px_strfreev(response); @@ -653,7 +662,7 @@ fprintf(stderr, "*** PAC found, but no active PAC runner! Falling back to direct...\n"); } - // If we have a manual config (http://..., socks://...) + /* If we have a manual config (http://..., socks://...) */ else if (!strncmp(config->url, "http://", 7) || !strncmp(config->url, "socks://", 8)) { if (self->wpad) { px_wpad_free(self->wpad); self->wpad = NULL; } @@ -662,7 +671,7 @@ response = px_strsplit(config->url, ";"); } - // Actually return, freeing misc stuff + /* Actually return, freeing misc stuff */ do_return: if (config) { px_free(config->url); px_free(config->ignore); px_free(config); } if (realurl) px_url_free(realurl); @@ -710,14 +719,14 @@ pthread_mutex_lock(&self->mutex); - // Free the plugins + /* Free the plugins */ px_array_foreach(self->plugins, destantiate_plugins, self); px_array_free(self->plugins); - // Free misc + /* Free misc */ px_strdict_free(self->misc); - // Free everything else + /* Free everything else */ px_pac_free(self->pac); px_wpad_free(self->wpad); px_config_file_free(self->cf); Index: src/lib/strdict.c =================================================================== --- src/lib/strdict.c (revision 199) +++ src/lib/strdict.c (working copy) @@ -78,7 +78,7 @@ { if (!self || !key) return false; - // We are unseting the value + /* We are unseting the value */ if (!value) { void *item[3] = { (void *) key, value, self->free }; Index: src/lib/proxy_factory.h =================================================================== --- src/lib/proxy_factory.h (revision 199) +++ src/lib/proxy_factory.h (working copy) @@ -35,13 +35,15 @@ }; typedef enum _pxConfigCategory pxConfigCategory; -// URLs look like this: -// http://host:port -// socks://host:port -// pac+http://pac_host:port/path/to/pac -// wpad:// -// direct:// -// TODO: ignore syntax TBD +/* + * URLs look like this: + * http://host:port + * socks://host:port + * pac+http://pac_host:port/path/to/pac + * wpad:// + * direct:// + */ + /* TODO: ignore syntax TBD */ struct _pxConfig { char *url; char *ignore; Index: src/lib/array.c =================================================================== --- src/lib/array.c (revision 199) +++ src/lib/array.c (working copy) @@ -60,11 +60,10 @@ bool px_array_add(pxArray *self, void *item) { - // Verify some basic stuff + /* Verify some basic stuff */ if (!self || !item) return false; - // If we are a unique array and a dup is found, - // either bail or replace the item + /* If we are a unique array and a dup is found, either bail or replace the item */ if (self->unique && px_array_find(self, item) >= 0) { if (!self->replace) @@ -90,7 +89,7 @@ unsigned int index = px_array_find(self, item); if (index < 0) return false; - // Free the old one and shift elements down + /* Free the old one and shift elements down */ self->free(self->data[index]); memmove(self->data+index, self->data+index+1, Index: src/lib/wpad.c =================================================================== --- src/lib/wpad.c (revision 199) +++ src/lib/wpad.c (working copy) @@ -71,7 +71,7 @@ { if (!self) return NULL; - // Check all the detectors for a PAC + /* Check all the detectors for a PAC */ pxPAC *pac = NULL; if (!(pac = px_dhcp_next(self->dhcp))) if (!(pac = px_slp_next(self->slp))) Index: src/lib/misc.c =================================================================== --- src/lib/misc.c (revision 199) +++ src/lib/misc.c (working copy) @@ -110,13 +110,13 @@ { va_list args; - // Count the number of characters to concatentate + /* Count the number of characters to concatentate */ va_start(args, s); int count = strlen(s); for (char *tmp = NULL ; (tmp = va_arg(args, char *)) ; count += strlen(tmp)); va_end(args); - // Build our output string + /* Build our output string */ char *output = px_malloc0(count + 1); strcat(output, s); va_start(args, s); @@ -139,13 +139,13 @@ if (!strv) return NULL; if (!delimiter) return NULL; - // Count up the length we need + /* Count up the length we need */ size_t length = 0; for (int i=0 ; strv[i]; i++) length += strlen(strv[i]) + strlen(delimiter); if (!length) return NULL; - // Do the join + /* Do the join */ char *str = px_malloc0(length); for (int i=0 ; strv[i]; i++) { @@ -164,15 +164,15 @@ char ** px_strsplit(const char *string, const char *delimiter) { - // Count how many times the delimiter appears + /* Count how many times the delimiter appears */ int count = 1; for (const char *tmp = string ; (tmp = strstr(tmp, delimiter)) ; tmp += strlen(delimiter)) count++; - // Allocate the vector + /* Allocate the vector */ char **strv = px_malloc0(sizeof(char *) * (count + 1)); - // Fill the vector + /* Fill the vector */ const char *last = string; for (int i=0 ; i < count ; i++) { @@ -210,20 +210,20 @@ char * px_readline(int fd) { - // Verify we have an open socket + /* Verify we have an open socket */ if (fd < 0) return NULL; - // For each character received add it to the buffer unless it is a newline + /* For each character received add it to the buffer unless it is a newline */ char *buffer = NULL; for (int i=1; i > 0 ; i++) { char c; - // Receive a single character, check for newline or EOF + /* Receive a single character, check for newline or EOF */ if (read(fd, &c, 1) != 1) return buffer; if (c == '\n') return buffer ? buffer : px_strdup(""); - // Allocate new buffer if we need + /* Allocate new buffer if we need */ if (i % 1024 == 1) { char *tmp = buffer; @@ -231,7 +231,7 @@ if (tmp) { strcpy(buffer, tmp); px_free(tmp); } } - // Add new character + /* Add new character */ buffer[i-1] = c; } return buffer; Index: src/bin/proxy.c =================================================================== --- src/bin/proxy.c (revision 199) +++ src/bin/proxy.c (working copy) @@ -23,7 +23,7 @@ #include #include -// Import libproxy API +/* Import libproxy API */ #include #define STDIN fileno(stdin) @@ -45,20 +45,20 @@ static char * readline(int fd) { - // Verify we have an open socket + /* Verify we have an open socket */ if (fd < 0) return NULL; - // For each character received add it to the buffer unless it is a newline + /* For each character received add it to the buffer unless it is a newline */ char *buffer = NULL; for (int i=1; i > 0 ; i++) { char c; - // Receive a single character, check for newline or EOF + /* Receive a single character, check for newline or EOF */ if (read(fd, &c, 1) != 1) return buffer; if (c == '\n') return buffer ? buffer : strdup(""); - // Allocate new buffer if we need + /* Allocate new buffer if we need */ if (i % 1024 == 1) { char *tmp = buffer; @@ -67,7 +67,7 @@ if (tmp) { strcpy(buffer, tmp); free(tmp); } } - // Add new character + /* Add new character */ buffer[i-1] = c; } return buffer; @@ -76,7 +76,7 @@ int main(int argc, char **argv) { - // Create the proxy factory object + /* Create the proxy factory object */ pxProxyFactory *pf = px_proxy_factory_new(); if (!pf) { @@ -84,12 +84,14 @@ return 1; } - // For each URL we read on STDIN, get the proxies to use + /* For each URL we read on STDIN, get the proxies to use */ for (char *url = NULL ; url = readline(STDIN) ; free(url)) { - // Get an array of proxies to use. These should be used - // in the order returned. Only move on to the next proxy - // if the first one fails (etc). + /* + * Get an array of proxies to use. These should be used + * in the order returned. Only move on to the next proxy + * if the first one fails (etc). + */ char **proxies = px_proxy_factory_get_proxies(pf, url); for (int i = 0 ; proxies[i] ; i++) { @@ -103,7 +105,7 @@ free(proxies); } - // Destantiate the proxy factory object + /* Destantiate the proxy factory object */ px_proxy_factory_free(pf); return 0; }