]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Source Format: tools
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 23 Sep 2008 14:15:36 +0000 (02:15 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 23 Sep 2008 14:15:36 +0000 (02:15 +1200)
tools/cachemgr.cc
tools/squidclient.cc

index 04e226e58f5d7243574b810381a9a07dd6cd4851..2009e029c5cf73582728eb3160af3cbcf596bbb3 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
@@ -140,8 +140,7 @@ extern "C"
 #define DEFAULT_CACHEMGR_CONFIG "/etc/squid/cachemgr.conf"
 #endif
 
-typedef struct
-{
+typedef struct {
     char *server;
     char *hostname;
     int port;
@@ -153,7 +152,7 @@ typedef struct
 
 /*
  * Debugging macros (info goes to error_log on your web server)
- * Note: do not run cache manager with non zero debugging level 
+ * Note: do not run cache manager with non zero debugging level
  *       if you do not debug, it may write a lot of [sensitive]
  *       information to your error log.
  */
@@ -589,13 +588,13 @@ munge_action_line(const char *_buf, cachemgr_request * req)
     char *p;
 
     if ((p = strchr(x, '\n')))
-       *p = '\0';
+        *p = '\0';
     action = xstrtok(&x, '\t');
     description = xstrtok(&x, '\t');
     if (!description)
-       description = action;
+        description = action;
     if (!action)
-       return "";
+        return "";
     snprintf(html, sizeof(html), " <a href=\"%s\">%s</a>", menu_url(req, action), description);
     return html;
 }
@@ -881,8 +880,7 @@ process_request(cachemgr_request * req)
 }
 
 int
-main(int argc, char *argv[])
-{
+main(int argc, char *argv[]) {
     char *s;
     cachemgr_request *req;
 
@@ -914,8 +912,7 @@ main(int argc, char *argv[])
 }
 
 static char *
-read_post_request(void)
-{
+read_post_request(void) {
     char *s;
     char *buf;
     int len;
@@ -942,8 +939,7 @@ read_post_request(void)
 }
 
 static char *
-read_get_request(void)
-{
+read_get_request(void) {
     char *s;
 
     if ((s = getenv("QUERY_STRING")) == NULL)
@@ -953,8 +949,7 @@ read_get_request(void)
 }
 
 static cachemgr_request *
-read_request(void)
-{
+read_request(void) {
     char *buf;
 
     cachemgr_request *req;
@@ -1029,12 +1024,11 @@ read_request(void)
 /* Routines to support authentication */
 
 /*
- * Encodes auth info into a "public" form. 
+ * Encodes auth info into a "public" form.
  * Currently no powerful encryption is used.
  */
 static void
-make_pub_auth(cachemgr_request * req)
-{
+make_pub_auth(cachemgr_request * req) {
     static char buf[1024];
     safe_free(req->pub_auth);
     debug(3) fprintf(stderr, "cmgr: encoding for pub...\n");
@@ -1057,8 +1051,7 @@ make_pub_auth(cachemgr_request * req)
 }
 
 static void
-decode_pub_auth(cachemgr_request * req)
-{
+decode_pub_auth(cachemgr_request * req) {
     char *buf;
     const char *host_name;
     const char *time_str;
@@ -1116,15 +1109,13 @@ decode_pub_auth(cachemgr_request * req)
 }
 
 static void
-reset_auth(cachemgr_request * req)
-{
+reset_auth(cachemgr_request * req) {
     safe_free(req->passwd);
     safe_free(req->pub_auth);
 }
 
 static const char *
-make_auth_header(const cachemgr_request * req)
-{
+make_auth_header(const cachemgr_request * req) {
     static char buf[1024];
     size_t stringLength = 0;
     const char *str64;
@@ -1149,8 +1140,7 @@ make_auth_header(const cachemgr_request * req)
 }
 
 static int
-check_target_acl(const char *hostname, int port)
-{
+check_target_acl(const char *hostname, int port) {
     char config_line[BUFSIZ];
     FILE *fp = NULL;
     int ret = 0;
index e64dbb7cc165f76dc41a3e2526b15c2543f408b1..d7ff21dad9deec9ede4c106266fe27d84f1ead71 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
@@ -132,29 +132,29 @@ static void
 usage(const char *progname)
 {
     fprintf(stderr,
-       "Version: %s\n"
-       "Usage: %s [-arsv] [-i IMS] [-h remote host] [-l local host] [-p port] [-m method] [-t count] [-I ping-interval] [-H 'strings'] [-T timeout] url\n"
-       "Options:\n"
-       "    -P file      PUT request.\n"
-       "    -a           Do NOT include Accept: header.\n"
-       "    -r           Force cache to reload URL.\n"
-       "    -s           Silent.  Do not print data to stdout.\n"
-       "    -v           Verbose. Print outgoing message to stderr.\n"
-       "    -i IMS       If-Modified-Since time (in Epoch seconds).\n"
-       "    -h host      Retrieve URL from cache on hostname.  Default is localhost.\n"
-       "    -l host      Specify a local IP address to bind to.  Default is none.\n"
-       "    -p port      Port number of cache.  Default is %d.\n"
-       "    -m method    Request method, default is GET.\n"
-       "    -t count     Trace count cache-hops\n"
-       "    -g count     Ping mode, \"count\" iterations (0 to loop until interrupted).\n"
-       "    -I interval  Ping interval in seconds (default 1 second).\n"
-       "    -H 'string'  Extra headers to send. Use '\\n' for new lines.\n"
-       "    -T timeout   Timeout value (seconds) for read/write operations.\n"
-       "    -u user      Proxy authentication username\n"
-       "    -w password  Proxy authentication password\n"
-       "    -U user      WWW authentication username\n"
-       "    -W password  WWW authentication password\n",
-       VERSION, progname, CACHE_HTTP_PORT);
+            "Version: %s\n"
+            "Usage: %s [-arsv] [-i IMS] [-h remote host] [-l local host] [-p port] [-m method] [-t count] [-I ping-interval] [-H 'strings'] [-T timeout] url\n"
+            "Options:\n"
+            "    -P file      PUT request.\n"
+            "    -a           Do NOT include Accept: header.\n"
+            "    -r           Force cache to reload URL.\n"
+            "    -s           Silent.  Do not print data to stdout.\n"
+            "    -v           Verbose. Print outgoing message to stderr.\n"
+            "    -i IMS       If-Modified-Since time (in Epoch seconds).\n"
+            "    -h host      Retrieve URL from cache on hostname.  Default is localhost.\n"
+            "    -l host      Specify a local IP address to bind to.  Default is none.\n"
+            "    -p port      Port number of cache.  Default is %d.\n"
+            "    -m method    Request method, default is GET.\n"
+            "    -t count     Trace count cache-hops\n"
+            "    -g count     Ping mode, \"count\" iterations (0 to loop until interrupted).\n"
+            "    -I interval  Ping interval in seconds (default 1 second).\n"
+            "    -H 'string'  Extra headers to send. Use '\\n' for new lines.\n"
+            "    -T timeout   Timeout value (seconds) for read/write operations.\n"
+            "    -u user      Proxy authentication username\n"
+            "    -w password  Proxy authentication password\n"
+            "    -U user      WWW authentication username\n"
+            "    -W password  WWW authentication password\n",
+            VERSION, progname, CACHE_HTTP_PORT);
     exit(1);
 }
 
@@ -198,254 +198,254 @@ main(int argc, char *argv[])
     ping_int = 1 * 1000;
 
     if (argc < 2) {
-       usage(argv[0]);         /* need URL */
+        usage(argv[0]);                /* need URL */
     } else if (argc >= 2) {
-       strncpy(url, argv[argc - 1], BUFSIZ);
-       url[BUFSIZ - 1] = '\0';
+        strncpy(url, argv[argc - 1], BUFSIZ);
+        url[BUFSIZ - 1] = '\0';
 
-       if (url[0] == '-')
-           usage(argv[0]);
+        if (url[0] == '-')
+            usage(argv[0]);
 
-       while ((c = getopt(argc, argv, "ah:l:P:i:km:p:rsvt:g:p:I:H:T:u:U:w:W:?")) != -1)
-           switch (c) {
+        while ((c = getopt(argc, argv, "ah:l:P:i:km:p:rsvt:g:p:I:H:T:u:U:w:W:?")) != -1)
+            switch (c) {
 
-           case 'a':
-               opt_noaccept = 1;
-               break;
+            case 'a':
+                opt_noaccept = 1;
+                break;
 
-           case 'h':           /* remote host */
+            case 'h':          /* remote host */
 
-               if (optarg != NULL)
-                   hostname = optarg;
+                if (optarg != NULL)
+                    hostname = optarg;
 
-               break;
+                break;
 
-           case 'l':           /* local host */
-               if (optarg != NULL)
-                   localhost = optarg;
+            case 'l':          /* local host */
+                if (optarg != NULL)
+                    localhost = optarg;
 
-               break;
+                break;
 
-           case 's':           /* silent */
-               to_stdout = 0;
+            case 's':          /* silent */
+                to_stdout = 0;
 
-               break;
+                break;
 
-           case 'k':           /* backward compat */
-               keep_alive = 1;
+            case 'k':          /* backward compat */
+                keep_alive = 1;
 
-               break;
+                break;
 
-           case 'r':           /* reload */
-               reload = 1;
+            case 'r':          /* reload */
+                reload = 1;
 
-               break;
+                break;
 
-           case 'p':           /* port number */
-               sscanf(optarg, "%d", &port);
+            case 'p':          /* port number */
+                sscanf(optarg, "%d", &port);
 
-               if (port < 1)
-                   port = CACHE_HTTP_PORT;     /* default */
+                if (port < 1)
+                    port = CACHE_HTTP_PORT;    /* default */
 
-               break;
+                break;
 
-           case 'P':
-               put_file = xstrdup(optarg);
+            case 'P':
+                put_file = xstrdup(optarg);
 
-               break;
+                break;
 
-           case 'i':           /* IMS */
-               ims = (time_t) atoi(optarg);
+            case 'i':          /* IMS */
+                ims = (time_t) atoi(optarg);
 
-               break;
+                break;
 
-           case 'm':
-               method = xstrdup(optarg);
+            case 'm':
+                method = xstrdup(optarg);
 
-               break;
+                break;
 
-           case 't':
-               method = xstrdup("TRACE");
+            case 't':
+                method = xstrdup("TRACE");
 
-               max_forwards = atoi(optarg);
+                max_forwards = atoi(optarg);
 
-               break;
+                break;
 
-           case 'g':
-               ping = 1;
+            case 'g':
+                ping = 1;
 
-               pcount = atoi(optarg);
+                pcount = atoi(optarg);
 
-               to_stdout = 0;
+                to_stdout = 0;
 
-               break;
+                break;
 
-           case 'I':
-               if ((ping_int = atoi(optarg) * 1000) <= 0)
-                   usage(argv[0]);
+            case 'I':
+                if ((ping_int = atoi(optarg) * 1000) <= 0)
+                    usage(argv[0]);
 
-               break;
+                break;
 
-           case 'H':
-               if (strlen(optarg)) {
-                   char *t;
-                   strncpy(extra_hdrs, optarg, sizeof(extra_hdrs));
+            case 'H':
+                if (strlen(optarg)) {
+                    char *t;
+                    strncpy(extra_hdrs, optarg, sizeof(extra_hdrs));
 
-                   while ((t = strstr(extra_hdrs, "\\n")))
-                       *t = '\r', *(t + 1) = '\n';
-               }
-               break;
+                    while ((t = strstr(extra_hdrs, "\\n")))
+                        *t = '\r', *(t + 1) = '\n';
+                }
+                break;
 
-           case 'T':
-               io_timeout = atoi(optarg);
-               break;
+            case 'T':
+                io_timeout = atoi(optarg);
+                break;
 
-           case 'u':
-               proxy_user = optarg;
-               break;
+            case 'u':
+                proxy_user = optarg;
+                break;
 
-           case 'w':
-               proxy_password = optarg;
-               break;
+            case 'w':
+                proxy_password = optarg;
+                break;
 
-           case 'U':
-               www_user = optarg;
-               break;
+            case 'U':
+                www_user = optarg;
+                break;
 
-           case 'W':
-               www_password = optarg;
-               break;
+            case 'W':
+                www_password = optarg;
+                break;
 
-           case 'v':
-               /* undocumented: may increase verb-level by giving more -v's */
-               opt_verbose++;
-               break;
+            case 'v':
+                /* undocumented: may increase verb-level by giving more -v's */
+                opt_verbose++;
+                break;
 
-           case '?':           /* usage */
+            case '?':          /* usage */
 
-           default:
-               usage(argv[0]);
-               break;
-           }
+            default:
+                usage(argv[0]);
+                break;
+            }
     }
 #ifdef _SQUID_MSWIN_
     {
-       WSADATA wsaData;
-       WSAStartup(2, &wsaData);
-       atexit(Win32SockCleanup);
+        WSADATA wsaData;
+        WSAStartup(2, &wsaData);
+        atexit(Win32SockCleanup);
     }
 #endif
     /* Build the HTTP request */
     if (strncmp(url, "mgr:", 4) == 0) {
-       char *t = xstrdup(url + 4);
-       snprintf(url, BUFSIZ, "cache_object://%s/%s", hostname, t);
-       xfree(t);
+        char *t = xstrdup(url + 4);
+        snprintf(url, BUFSIZ, "cache_object://%s/%s", hostname, t);
+        xfree(t);
     }
     if (put_file) {
-       put_fd = open(put_file, O_RDONLY);
-       set_our_signal();
-
-       if (put_fd < 0) {
-           fprintf(stderr, "%s: can't open file (%s)\n", argv[0],
-               xstrerror());
-           exit(-1);
-       }
+        put_fd = open(put_file, O_RDONLY);
+        set_our_signal();
+
+        if (put_fd < 0) {
+            fprintf(stderr, "%s: can't open file (%s)\n", argv[0],
+                    xstrerror());
+            exit(-1);
+        }
 #ifdef _SQUID_WIN32_
-       setmode(put_fd, O_BINARY);
+        setmode(put_fd, O_BINARY);
 
 #endif
 
-       fstat(put_fd, &sb);
+        fstat(put_fd, &sb);
     }
     snprintf(msg, BUFSIZ, "%s %s HTTP/1.0\r\n", method, url);
 
     if (reload) {
-       snprintf(buf, BUFSIZ, "Pragma: no-cache\r\n");
-       strcat(msg, buf);
+        snprintf(buf, BUFSIZ, "Pragma: no-cache\r\n");
+        strcat(msg, buf);
     }
     if (put_fd > 0) {
-       snprintf(buf, BUFSIZ, "Content-length: %d\r\n", (int) sb.st_size);
-       strcat(msg, buf);
+        snprintf(buf, BUFSIZ, "Content-length: %d\r\n", (int) sb.st_size);
+        strcat(msg, buf);
     }
     if (opt_noaccept == 0) {
-       snprintf(buf, BUFSIZ, "Accept: */*\r\n");
-       strcat(msg, buf);
+        snprintf(buf, BUFSIZ, "Accept: */*\r\n");
+        strcat(msg, buf);
     }
     if (ims) {
-       snprintf(buf, BUFSIZ, "If-Modified-Since: %s\r\n", mkrfc1123(ims));
-       strcat(msg, buf);
+        snprintf(buf, BUFSIZ, "If-Modified-Since: %s\r\n", mkrfc1123(ims));
+        strcat(msg, buf);
     }
     if (max_forwards > -1) {
-       snprintf(buf, BUFSIZ, "Max-Forwards: %d\r\n", max_forwards);
-       strcat(msg, buf);
+        snprintf(buf, BUFSIZ, "Max-Forwards: %d\r\n", max_forwards);
+        strcat(msg, buf);
     }
     if (proxy_user) {
-       char *user = proxy_user;
-       char *password = proxy_password;
+        char *user = proxy_user;
+        char *password = proxy_password;
 #if HAVE_GETPASS
 
-       if (!password)
-           password = getpass("Proxy password: ");
+        if (!password)
+            password = getpass("Proxy password: ");
 
 #endif
 
-       if (!password) {
-           fprintf(stderr, "ERROR: Proxy password missing\n");
-           exit(1);
-       }
-       snprintf(buf, BUFSIZ, "%s:%s", user, password);
-       snprintf(buf, BUFSIZ, "Proxy-Authorization: Basic %s\r\n", base64_encode(buf));
-       strcat(msg, buf);
+        if (!password) {
+            fprintf(stderr, "ERROR: Proxy password missing\n");
+            exit(1);
+        }
+        snprintf(buf, BUFSIZ, "%s:%s", user, password);
+        snprintf(buf, BUFSIZ, "Proxy-Authorization: Basic %s\r\n", base64_encode(buf));
+        strcat(msg, buf);
     }
     if (www_user) {
-       char *user = www_user;
-       char *password = www_password;
+        char *user = www_user;
+        char *password = www_password;
 #if HAVE_GETPASS
 
-       if (!password)
-           password = getpass("WWW password: ");
+        if (!password)
+            password = getpass("WWW password: ");
 
 #endif
 
-       if (!password) {
-           fprintf(stderr, "ERROR: WWW password missing\n");
-           exit(1);
-       }
-       snprintf(buf, BUFSIZ, "%s:%s", user, password);
-       snprintf(buf, BUFSIZ, "Authorization: Basic %s\r\n", base64_encode(buf));
-       strcat(msg, buf);
+        if (!password) {
+            fprintf(stderr, "ERROR: WWW password missing\n");
+            exit(1);
+        }
+        snprintf(buf, BUFSIZ, "%s:%s", user, password);
+        snprintf(buf, BUFSIZ, "Authorization: Basic %s\r\n", base64_encode(buf));
+        strcat(msg, buf);
     }
     if (keep_alive) {
-       if (port != 80)
-           snprintf(buf, BUFSIZ, "Proxy-Connection: keep-alive\r\n");
-       else
-           snprintf(buf, BUFSIZ, "Connection: keep-alive\r\n");
+        if (port != 80)
+            snprintf(buf, BUFSIZ, "Proxy-Connection: keep-alive\r\n");
+        else
+            snprintf(buf, BUFSIZ, "Connection: keep-alive\r\n");
 
-       strcat(msg, buf);
+        strcat(msg, buf);
     }
     strcat(msg, extra_hdrs);
     snprintf(buf, BUFSIZ, "\r\n");
     strcat(msg, buf);
 
     if (opt_verbose)
-       fprintf(stderr, "headers: '%s'\n", msg);
+        fprintf(stderr, "headers: '%s'\n", msg);
 
     if (ping) {
 #if HAVE_SIGACTION
 
-       struct sigaction sa, osa;
+        struct sigaction sa, osa;
 
-       if (sigaction(SIGINT, NULL, &osa) == 0 && osa.sa_handler == SIG_DFL) {
-           sa.sa_handler = catchSignal;
-           sa.sa_flags = 0;
-           sigemptyset(&sa.sa_mask);
-           (void) sigaction(SIGINT, &sa, NULL);
-       }
+        if (sigaction(SIGINT, NULL, &osa) == 0 && osa.sa_handler == SIG_DFL) {
+            sa.sa_handler = catchSignal;
+            sa.sa_flags = 0;
+            sigemptyset(&sa.sa_mask);
+            (void) sigaction(SIGINT, &sa, NULL);
+        }
 #else
-       void (*osig) (int);
+        void (*osig) (int);
 
-       if ((osig = signal(SIGINT, catchSignal)) != SIG_DFL)
-           (void) signal(SIGINT, osig);
+        if ((osig = signal(SIGINT, catchSignal)) != SIG_DFL)
+            (void) signal(SIGINT, osig);
 
 #endif
 
@@ -453,21 +453,20 @@ main(int argc, char *argv[])
     loops = ping ? pcount : 1;
 
     for (i = 0; loops == 0 || i < loops; i++) {
-       int fsize = 0;
+        int fsize = 0;
         struct addrinfo *AI = NULL;
 
-       /* Connect to the server */
+        /* Connect to the server */
 
-        if(localhost) {
-            if( !iaddr.GetHostByName(localhost) ) {
+        if (localhost) {
+            if ( !iaddr.GetHostByName(localhost) ) {
                 fprintf(stderr, "client: ERROR: Cannot resolve %s: Host unknown.\n", localhost);
                 exit(1);
             }
-        }
-        else {
+        } else {
             /* Process the remote host name to locate the Protocol required
                in case we are being asked to link to another version of squid */
-            if( !iaddr.GetHostByName(hostname) ) {
+            if ( !iaddr.GetHostByName(hostname) ) {
                 fprintf(stderr, "client: ERROR: Cannot resolve %s: Host unknown.\n", hostname);
                 exit(1);
             }
@@ -487,7 +486,7 @@ main(int argc, char *argv[])
         }
 
         iaddr.SetEmpty();
-         if( !iaddr.GetHostByName(hostname) ) {
+        if ( !iaddr.GetHostByName(hostname) ) {
             fprintf(stderr, "client: ERROR: Cannot resolve %s: Host unknown.\n", hostname);
             exit(1);
         }
@@ -507,105 +506,105 @@ main(int argc, char *argv[])
             exit(1);
         }
 
-       /* Send the HTTP request */
-       bytesWritten = mywrite(conn, msg, strlen(msg));
+        /* Send the HTTP request */
+        bytesWritten = mywrite(conn, msg, strlen(msg));
 
-       if (bytesWritten < 0) {
-           perror("client: ERROR: write");
-           exit(1);
-       } else if ((unsigned) bytesWritten != strlen(msg)) {
-           fprintf(stderr, "client: ERROR: Cannot send request?: %s\n", msg);
-           exit(1);
-       }
+        if (bytesWritten < 0) {
+            perror("client: ERROR: write");
+            exit(1);
+        } else if ((unsigned) bytesWritten != strlen(msg)) {
+            fprintf(stderr, "client: ERROR: Cannot send request?: %s\n", msg);
+            exit(1);
+        }
 
-       if (put_file) {
-           int x;
-           lseek(put_fd, 0, SEEK_SET);
+        if (put_file) {
+            int x;
+            lseek(put_fd, 0, SEEK_SET);
 #ifdef _SQUID_MSWIN_
 
-           while ((x = read(put_fd, buf, sizeof(buf))) > 0) {
+            while ((x = read(put_fd, buf, sizeof(buf))) > 0) {
 #else
 
-           while ((x = myread(put_fd, buf, sizeof(buf))) > 0) {
+            while ((x = myread(put_fd, buf, sizeof(buf))) > 0) {
 #endif
-               x = mywrite(conn, buf, x);
+                x = mywrite(conn, buf, x);
 
-               total_bytes += x;
+                total_bytes += x;
 
-               if (x <= 0)
-                   break;
-           }
+                if (x <= 0)
+                    break;
+            }
 
-           if (x != 0)
-               fprintf(stderr, "client: ERROR: Cannot send file.\n");
-       }
-       /* Read the data */
+            if (x != 0)
+                fprintf(stderr, "client: ERROR: Cannot send file.\n");
+        }
+        /* Read the data */
 
 #ifdef _SQUID_MSWIN_
-       setmode(1, O_BINARY);
+        setmode(1, O_BINARY);
 
 #endif
 
-       while ((len = myread(conn, buf, sizeof(buf))) > 0) {
-           fsize += len;
+        while ((len = myread(conn, buf, sizeof(buf))) > 0) {
+            fsize += len;
 
-           if (to_stdout)
-               fwrite(buf, len, 1, stdout);
-       }
+            if (to_stdout)
+                fwrite(buf, len, 1, stdout);
+        }
 
 #ifdef _SQUID_MSWIN_
-       setmode(1, O_TEXT);
+        setmode(1, O_TEXT);
 
 #endif
 
-       (void) close(conn);     /* done with socket */
+        (void) close(conn);    /* done with socket */
 
-       if (interrupted)
-           break;
+        if (interrupted)
+            break;
 
-       if (ping) {
+        if (ping) {
 
-           struct tm *tmp;
-           time_t t2s;
-           long elapsed_msec;
+            struct tm *tmp;
+            time_t t2s;
+            long elapsed_msec;
 
-           (void) Now(&tv2);
-           elapsed_msec = tvSubMsec(tv1, tv2);
-           t2s = tv2.tv_sec;
-           tmp = localtime(&t2s);
-           fprintf(stderr, "%d-%02d-%02d %02d:%02d:%02d [%d]: %ld.%03ld secs, %f KB/s\n",
-               tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
-               tmp->tm_hour, tmp->tm_min, tmp->tm_sec, i + 1,
-               elapsed_msec / 1000, elapsed_msec % 1000,
-               elapsed_msec ? (double) fsize / elapsed_msec : -1.0);
+            (void) Now(&tv2);
+            elapsed_msec = tvSubMsec(tv1, tv2);
+            t2s = tv2.tv_sec;
+            tmp = localtime(&t2s);
+            fprintf(stderr, "%d-%02d-%02d %02d:%02d:%02d [%d]: %ld.%03ld secs, %f KB/s\n",
+                    tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
+                    tmp->tm_hour, tmp->tm_min, tmp->tm_sec, i + 1,
+                    elapsed_msec / 1000, elapsed_msec % 1000,
+                    elapsed_msec ? (double) fsize / elapsed_msec : -1.0);
 
-           if (i == 0 || elapsed_msec < ping_min)
-               ping_min = elapsed_msec;
+            if (i == 0 || elapsed_msec < ping_min)
+                ping_min = elapsed_msec;
 
-           if (i == 0 || elapsed_msec > ping_max)
-               ping_max = elapsed_msec;
+            if (i == 0 || elapsed_msec > ping_max)
+                ping_max = elapsed_msec;
 
-           ping_sum += elapsed_msec;
+            ping_sum += elapsed_msec;
 
-           /* Delay until next "ping_int" boundary */
-           if ((loops == 0 || i + 1 < loops) && elapsed_msec < ping_int) {
+            /* Delay until next "ping_int" boundary */
+            if ((loops == 0 || i + 1 < loops) && elapsed_msec < ping_int) {
 
-               struct timeval tvs;
-               long msec_left = ping_int - elapsed_msec;
+                struct timeval tvs;
+                long msec_left = ping_int - elapsed_msec;
 
-               tvs.tv_sec = msec_left / 1000;
-               tvs.tv_usec = (msec_left % 1000) * 1000;
-               select(0, NULL, NULL, NULL, &tvs);
-           }
-       }
+                tvs.tv_sec = msec_left / 1000;
+                tvs.tv_usec = (msec_left % 1000) * 1000;
+                select(0, NULL, NULL, NULL, &tvs);
+            }
+        }
     }
 
     if (ping && i) {
-       ping_mean = ping_sum / i;
-       fprintf(stderr, "%d requests, round-trip (secs) min/avg/max = "
-           "%ld.%03ld/%ld.%03ld/%ld.%03ld\n", i,
-           ping_min / 1000, ping_min % 1000, ping_mean / 1000, ping_mean % 1000,
-           ping_max / 1000, ping_max % 1000);
+        ping_mean = ping_sum / i;
+        fprintf(stderr, "%d requests, round-trip (secs) min/avg/max = "
+                "%ld.%03ld/%ld.%03ld/%ld.%03ld\n", i,
+                ping_min / 1000, ping_min % 1000, ping_mean / 1000, ping_mean % 1000,
+                ping_max / 1000, ping_max % 1000);
     }
     exit(0);
     /*NOTREACHED */
@@ -613,8 +612,7 @@ main(int argc, char *argv[])
 }
 
 static int
-client_comm_bind(int sock, const IPAddress &addr)
-{
+client_comm_bind(int sock, const IPAddress &addr) {
 
     int res;
 
@@ -632,8 +630,7 @@ client_comm_bind(int sock, const IPAddress &addr)
 }
 
 static int
-client_comm_connect(int sock, const IPAddress &addr, struct timeval *tvp)
-{
+client_comm_connect(int sock, const IPAddress &addr, struct timeval *tvp) {
     int res;
     static struct addrinfo *AI = NULL;
 
@@ -652,8 +649,7 @@ client_comm_connect(int sock, const IPAddress &addr, struct timeval *tvp)
 }
 
 static int
-Now(struct timeval *tp)
-{
+Now(struct timeval *tp) {
 #if GETTIMEOFDAY_NO_TZP
     return gettimeofday(tp);
 #else
@@ -663,21 +659,18 @@ Now(struct timeval *tp)
 }                              /* ARGSUSED */
 
 static void
-catchSignal(int sig)
-{
+catchSignal(int sig) {
     interrupted = 1;
     fprintf(stderr, "Interrupted.\n");
 }
 
 static void
-pipe_handler(int sig)
-{
+pipe_handler(int sig) {
     fprintf(stderr, "SIGPIPE received.\n");
 }
 
 static void
-set_our_signal(void)
-{
+set_our_signal(void) {
 #if HAVE_SIGACTION
 
     struct sigaction sa;
@@ -686,8 +679,8 @@ set_our_signal(void)
     sigemptyset(&sa.sa_mask);
 
     if (sigaction(SIGPIPE, &sa, NULL) < 0) {
-       fprintf(stderr, "Cannot set PIPE signal.\n");
-       exit(-1);
+        fprintf(stderr, "Cannot set PIPE signal.\n");
+        exit(-1);
     }
 #else
     signal(SIGPIPE, pipe_handler);
@@ -697,8 +690,7 @@ set_our_signal(void)
 }
 
 static ssize_t
-myread(int fd, void *buf, size_t len)
-{
+myread(int fd, void *buf, size_t len) {
 #ifndef _SQUID_MSWIN_
     alarm(io_timeout);
     return read(fd, buf, len);
@@ -709,8 +701,7 @@ myread(int fd, void *buf, size_t len)
 }
 
 static ssize_t
-mywrite(int fd, void *buf, size_t len)
-{
+mywrite(int fd, void *buf, size_t len) {
 #ifndef _SQUID_MSWIN_
     alarm(io_timeout);
     return write(fd, buf, len);