You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/03/23 21:33:22 UTC

[49/52] [partial] trafficserver git commit: TS-3419 Fix some enum's such that clang-format can handle it the way we want. Basically this means having a trailing , on short enum's. TS-3419 Run clang-format over most of the source

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/cmd/traffic_manager/StatType.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_manager/StatType.h b/cmd/traffic_manager/StatType.h
index 03e8f7a..3ab0367 100644
--- a/cmd/traffic_manager/StatType.h
+++ b/cmd/traffic_manager/StatType.h
@@ -31,23 +31,23 @@
  ****************************************************************************/
 
 #ifndef _STATTYPE_H_
-#define	_STATTYPE_H_
+#define _STATTYPE_H_
 
 #include "StatXML.h"
 #include "WebMgmtUtils.h"
 
-#define BYTES_TO_MBIT_SCALE (8/1000000.0)
+#define BYTES_TO_MBIT_SCALE (8 / 1000000.0)
 
 /* Structs used in Average Statistics calculations */
-struct StatDataSamples
-{
+struct StatDataSamples {
   ink_hrtime previous_time;
   ink_hrtime current_time;
   RecDataT data_type;
   RecData previous_value;
   RecData current_value;
 
-  RecData diff_value(const char *name)
+  RecData
+  diff_value(const char *name)
   {
     RecData tmp;
 
@@ -62,7 +62,8 @@ struct StatDataSamples
       return tmp;
     }
   }
-  ink_hrtime diff_time()
+  ink_hrtime
+  diff_time()
   {
     return (current_time - previous_time);
   }
@@ -73,8 +74,8 @@ struct StatDataSamples
 #define inline
 #endif
 
-#define MODULE      "StatPro"   // Statistics processor debug tag
-#define MODULE_INIT "StatProInit"       // Statistics processor debug tag
+#define MODULE "StatPro"          // Statistics processor debug tag
+#define MODULE_INIT "StatProInit" // Statistics processor debug tag
 
 /***************************************************************
  *                       StatExprToken
@@ -85,9 +86,7 @@ struct StatDataSamples
  ***************************************************************/
 class StatExprToken
 {
-
 public:
-
   char m_arith_symbol;
   char *m_token_name;
   RecDataT m_token_type;
@@ -107,10 +106,7 @@ public:
 
   LINK(StatExprToken, link);
   StatExprToken();
-  inline ~ StatExprToken()
-  {
-    clean();
-  };
+  inline ~StatExprToken() { clean(); };
   void clean();
 
   bool statVarSet(RecDataT, RecData);
@@ -123,14 +119,9 @@ public:
  **/
 class StatExprList
 {
-
 public:
-
   StatExprList();
-  inline ~ StatExprList()
-  {
-    clean();
-  };
+  inline ~StatExprList() { clean(); };
   void clean();
 
   void enqueue(StatExprToken *);
@@ -144,7 +135,6 @@ public:
   void print(const char *);
 
 private:
-
   size_t m_size;
   Queue<StatExprToken> m_tokenList;
 };
@@ -156,12 +146,10 @@ private:
  ***************************************************************/
 class StatObject
 {
-
 public:
-
   unsigned m_id;
   bool m_debug;
-  char *m_expr_string;          /* for debugging using only */
+  char *m_expr_string; /* for debugging using only */
   StatExprToken *m_node_dest;
   StatExprToken *m_cluster_dest;
   StatExprList *m_expression;
@@ -179,10 +167,7 @@ public:
   // Member functions
   StatObject();
   StatObject(unsigned);
-  inline ~ StatObject()
-  {
-    clean();
-  };
+  inline ~StatObject() { clean(); };
   void clean();
   void assignDst(const char *, bool, bool);
   void assignExpr(char *);
@@ -193,7 +178,6 @@ public:
   void setTokenValue(StatExprToken *, bool cluster = false);
 
 private:
-
   void infix2postfix();
 };
 
@@ -204,26 +188,20 @@ private:
  **/
 class StatObjectList
 {
-
 public:
-
   // Member functions
   StatObjectList();
-  inline ~ StatObjectList()
-  {
-    clean();
-  };
+  inline ~StatObjectList() { clean(); };
   void clean();
-  void enqueue(StatObject * object);
+  void enqueue(StatObject *object);
   StatObject *first();
-  StatObject *next(StatObject * current);
+  StatObject *next(StatObject *current);
   void print(const char *prefix = "");
-  short Eval();                 // return the number of statistics object processed
+  short Eval(); // return the number of statistics object processed
 
   size_t m_size;
 
 private:
-
   Queue<StatObject> m_statList;
 };
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/cmd/traffic_manager/StatXML.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_manager/StatXML.cc b/cmd/traffic_manager/StatXML.cc
index 277b84a..1d6a7ba 100644
--- a/cmd/traffic_manager/StatXML.cc
+++ b/cmd/traffic_manager/StatXML.cc
@@ -33,7 +33,6 @@
 unsigned short
 XML_extractContent(const char *name, char *content, size_t result_len)
 {
-
   char c;
   int contentIndex = 0;
 
@@ -55,7 +54,6 @@ XML_extractContent(const char *name, char *content, size_t result_len)
   }
 
   return (strlen(content));
-
 }
 
 
@@ -66,7 +64,6 @@ XML_extractContent(const char *name, char *content, size_t result_len)
 bool
 isOperator(char c)
 {
-
   switch (c) {
   case '+':
   case '-':
@@ -78,5 +75,4 @@ isOperator(char c)
   default:
     return false;
   }
-
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/cmd/traffic_manager/StatXML.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_manager/StatXML.h b/cmd/traffic_manager/StatXML.h
index b31063b..249be2f 100644
--- a/cmd/traffic_manager/StatXML.h
+++ b/cmd/traffic_manager/StatXML.h
@@ -23,18 +23,17 @@
 
 
 #ifndef _STATXML_H_
-#define	_STATXML_H_
+#define _STATXML_H_
 
 #include "WebMgmtUtils.h"
 #include "List.h"
 
-typedef enum
-{
+typedef enum {
   INVALID_TAG = -1,
   ROOT_TAG,
   STAT_TAG,
   DST_TAG,
-  EXPR_TAG
+  EXPR_TAG,
 } StatXMLTag;
 
 /***************************************************************

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/cmd/traffic_manager/traffic_manager.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_manager/traffic_manager.cc b/cmd/traffic_manager/traffic_manager.cc
index 6b099b7..5133c18 100644
--- a/cmd/traffic_manager/traffic_manager.cc
+++ b/cmd/traffic_manager/traffic_manager.cc
@@ -68,8 +68,8 @@ static void printUsage(void);
 extern "C" int getpwnam_r(const char *name, struct passwd *result, char *buffer, size_t buflen, struct passwd **resptr);
 #endif
 
-static StatProcessor *statProcessor;   // Statistics Processors
-static AppVersionInfo appVersionInfo;  // Build info for this application
+static StatProcessor *statProcessor;  // Statistics Processors
+static AppVersionInfo appVersionInfo; // Build info for this application
 
 static inkcoreapi DiagsConfig *diagsConfig;
 static char debug_tags[1024] = "";
@@ -86,8 +86,8 @@ static int fds_limit;
 // TODO: Use positive instead negative selection
 //       Thsis should just be #if defined(solaris)
 #if !defined(linux) && !defined(freebsd) && !defined(darwin)
-static void SignalHandler(int sig, siginfo_t * t, void *f);
-static void SignalAlrmHandler(int sig, siginfo_t * t, void *f);
+static void SignalHandler(int sig, siginfo_t *t, void *f);
+static void SignalAlrmHandler(int sig, siginfo_t *t, void *f);
 #else
 static void SignalHandler(int sig);
 static void SignalAlrmHandler(int sig);
@@ -129,11 +129,11 @@ check_lockfile()
   Lockfile server_lockfile(lockfile);
   err = server_lockfile.Open(&holding_pid);
   if (err == 1) {
-    server_lockfile.Close();    // no server running
+    server_lockfile.Close(); // no server running
   } else {
     char *reason = strerror(-err);
     if (err == 0) {
-      // TODO: Add PID_FMT_T instead duplicating code just for printing
+// TODO: Add PID_FMT_T instead duplicating code just for printing
 #if defined(solaris)
       fprintf(stderr, "FATAL: Lockfile '%s' says server already running as PID %d\n", lockfile, (int)holding_pid);
 #else
@@ -142,8 +142,7 @@ check_lockfile()
       mgmt_elog(stderr, 0, "FATAL: Lockfile '%s' says server already running as PID %d\n", lockfile, holding_pid);
     } else {
       fprintf(stderr, "FATAL: Can't open server lockfile '%s' (%s)\n", lockfile, (reason ? reason : "Unknown Reason"));
-      mgmt_elog(stderr, 0, "FATAL: Can't open server lockfile '%s' (%s)\n",
-                lockfile, (reason ? reason : "Unknown Reason"));
+      mgmt_elog(stderr, 0, "FATAL: Can't open server lockfile '%s' (%s)\n", lockfile, (reason ? reason : "Unknown Reason"));
     }
     exit(1);
   }
@@ -184,7 +183,7 @@ initSignalHandlers()
   struct sigaction sigHandler, sigChldHandler, sigAlrmHandler;
   sigset_t sigsToBlock;
 
-  // Set up the signal handler
+// Set up the signal handler
 #if !defined(linux) && !defined(freebsd) && !defined(darwin)
   sigHandler.sa_handler = NULL;
   sigHandler.sa_sigaction = SignalHandler;
@@ -202,9 +201,9 @@ initSignalHandlers()
   sigaction(SIGHUP, &sigHandler, NULL);
   sigaction(SIGUSR2, &sigHandler, NULL);
 
-  // Don't block the signal on entry to the signal
-  //   handler so we can reissue it and get a core
-  //   file in the appropriate circumstances
+// Don't block the signal on entry to the signal
+//   handler so we can reissue it and get a core
+//   file in the appropriate circumstances
 #if !defined(linux) && !defined(freebsd) && !defined(darwin)
   sigHandler.sa_flags = SA_RESETHAND | SA_SIGINFO;
 #else
@@ -282,7 +281,7 @@ init_dirs()
 static void
 chdir_root()
 {
-  const char * prefix = Layout::get()->prefix;
+  const char *prefix = Layout::get()->prefix;
 
   if (chdir(prefix) < 0) {
     mgmt_elog(0, "unable to change to root directory \"%s\" [%d '%s']\n", prefix, errno, strerror(errno));
@@ -319,26 +318,26 @@ set_process_limits(int fds_throttle)
 
     lim.rlim_cur = lim.rlim_max = static_cast<rlim_t>(maxfiles * file_max_pct);
     if (setrlimit(RLIMIT_NOFILE, &lim) == 0 && getrlimit(RLIMIT_NOFILE, &lim) == 0) {
-      fds_limit = (int) lim.rlim_cur;
-      syslog(LOG_NOTICE, "NOTE: RLIMIT_NOFILE(%d):cur(%d),max(%d)",RLIMIT_NOFILE, (int)lim.rlim_cur, (int)lim.rlim_max);
+      fds_limit = (int)lim.rlim_cur;
+      syslog(LOG_NOTICE, "NOTE: RLIMIT_NOFILE(%d):cur(%d),max(%d)", RLIMIT_NOFILE, (int)lim.rlim_cur, (int)lim.rlim_max);
     }
   }
 
   if (getrlimit(RLIMIT_NOFILE, &lim) == 0) {
-    if (fds_throttle > (int) (lim.rlim_cur + FD_THROTTLE_HEADROOM)) {
-      lim.rlim_cur = (lim.rlim_max = (rlim_t) fds_throttle);
+    if (fds_throttle > (int)(lim.rlim_cur + FD_THROTTLE_HEADROOM)) {
+      lim.rlim_cur = (lim.rlim_max = (rlim_t)fds_throttle);
       if (!setrlimit(RLIMIT_NOFILE, &lim) && !getrlimit(RLIMIT_NOFILE, &lim)) {
-        fds_limit = (int) lim.rlim_cur;
-	      syslog(LOG_NOTICE, "NOTE: RLIMIT_NOFILE(%d):cur(%d),max(%d)",RLIMIT_NOFILE, (int)lim.rlim_cur, (int)lim.rlim_max);
+        fds_limit = (int)lim.rlim_cur;
+        syslog(LOG_NOTICE, "NOTE: RLIMIT_NOFILE(%d):cur(%d),max(%d)", RLIMIT_NOFILE, (int)lim.rlim_cur, (int)lim.rlim_max);
       }
     }
   }
-
 }
 
 #if TS_HAS_WCCP
 static void
-Errata_Logger(ts::Errata const& err) {
+Errata_Logger(ts::Errata const &err)
+{
   size_t n;
   static size_t const SIZE = 4096;
   char buff[SIZE];
@@ -346,28 +345,33 @@ Errata_Logger(ts::Errata const& err) {
     ts::Errata::Code code = err.top().getCode();
     n = err.write(buff, SIZE, 1, 0, 2, "> ");
     // strip trailing newlines.
-    while (n && (buff[n-1] == '\n' || buff[n-1] == '\r'))
+    while (n && (buff[n - 1] == '\n' || buff[n - 1] == '\r'))
       buff[--n] = 0;
     // log it.
-    if (code > 1) mgmt_elog(0, "[WCCP]%s", buff);
-    else if (code > 0) mgmt_log("[WCCP]%s", buff);
-    else Debug("WCCP", "%s", buff);
+    if (code > 1)
+      mgmt_elog(0, "[WCCP]%s", buff);
+    else if (code > 0)
+      mgmt_log("[WCCP]%s", buff);
+    else
+      Debug("WCCP", "%s", buff);
   }
 }
 
 static void
-Init_Errata_Logging() {
+Init_Errata_Logging()
+{
   ts::Errata::registerSink(&Errata_Logger);
 }
 #endif
 
 static void
-millisleep(int ms) {
+millisleep(int ms)
+{
   struct timespec ts;
 
   ts.tv_sec = ms / 1000;
   ts.tv_nsec = (ms - ts.tv_sec * 1000) * 1000 * 1000;
-  nanosleep(&ts, NULL); //we use nanosleep instead of sleep because it does not interact with signals
+  nanosleep(&ts, NULL); // we use nanosleep instead of sleep because it does not interact with signals
 }
 
 int
@@ -396,7 +400,7 @@ main(int argc, char **argv)
   int cluster_mcport = -1, cluster_rsport = -1;
   // TODO: This seems completely incomplete, disabled for now
   //  int dump_config = 0, dump_process = 0, dump_node = 0, dump_cluster = 0, dump_local = 0;
-  char* proxy_port = 0;
+  char *proxy_port = 0;
   int proxy_backdoor = -1;
   char *envVar = NULL, *group_addr = NULL, *tsArgs = NULL;
   bool log_to_syslog = true;
@@ -406,8 +410,7 @@ main(int argc, char **argv)
   ink_thread webThrId;
 
   // Set up the application version info
-  appVersionInfo.setup(PACKAGE_NAME,"traffic_manager", PACKAGE_VERSION,
-                       __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
+  appVersionInfo.setup(PACKAGE_NAME, "traffic_manager", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
   initSignalHandlers();
 
   // Process Environment Variables
@@ -427,7 +430,7 @@ main(int argc, char **argv)
     group_addr = envVar;
   }
 
-  for (int i = 1; i < argc; i++) {      /* Process command line args */
+  for (int i = 1; i < argc; i++) { /* Process command line args */
 
     if (argv[i][0] == '-') {
       if ((strcmp(argv[i], "-version") == 0) || (strcmp(argv[i], "-V") == 0)) {
@@ -440,7 +443,6 @@ main(int argc, char **argv)
       } else {
         // The rest of the options require an argument in the form of -<Flag> <val>
         if ((i + 1) < argc) {
-
           if (strcmp(argv[i], "-aconfPort") == 0) {
             ++i;
             aconf_port_arg = atoi(argv[i]);
@@ -463,7 +465,7 @@ main(int argc, char **argv)
 #endif
           } else if (strcmp(argv[i], "-path") == 0) {
             ++i;
-            //bugfixed by YTS Team, yamsat(id-59703)
+            // bugfixed by YTS Team, yamsat(id-59703)
             if ((strlen(argv[i]) > PATH_NAME_MAX)) {
               fprintf(stderr, "\n   Path exceeded the maximum allowed characters.\n");
               exit(1);
@@ -478,7 +480,7 @@ main(int argc, char **argv)
           } else if (strcmp(argv[i], "-recordsConf") == 0) {
             ++i;
             recs_conf = argv[i];
-            // TODO: This seems completely incomplete, disabled for now
+// TODO: This seems completely incomplete, disabled for now
 #if 0
           } else if (strcmp(argv[i], "-printRecords") == 0) {
             ++i;
@@ -547,9 +549,10 @@ main(int argc, char **argv)
   RecLocalInit();
   LibRecordsConfigInit();
 
-  init_dirs();// setup critical directories, needs LibRecords
+  init_dirs(); // setup critical directories, needs LibRecords
 
-  if (RecGetRecordString("proxy.config.admin.user_id", userToRunAs, sizeof(userToRunAs)) != TS_ERR_OKAY || strlen(userToRunAs) == 0) {
+  if (RecGetRecordString("proxy.config.admin.user_id", userToRunAs, sizeof(userToRunAs)) != TS_ERR_OKAY ||
+      strlen(userToRunAs) == 0) {
     mgmt_fatal(stderr, 0, "proxy.config.admin.user_id is not set\n");
   }
 
@@ -605,8 +608,8 @@ main(int argc, char **argv)
   RecSetRecordString("proxy.node.version.manager.build_date", appVersionInfo.BldDateStr);
   RecSetRecordString("proxy.node.version.manager.build_machine", appVersionInfo.BldMachineStr);
   RecSetRecordString("proxy.node.version.manager.build_person", appVersionInfo.BldPersonStr);
-//    RecSetRecordString("proxy.node.version.manager.build_compile_flags",
-//                       appVersionInfo.BldCompileFlagsStr);
+  //    RecSetRecordString("proxy.node.version.manager.build_compile_flags",
+  //                       appVersionInfo.BldCompileFlagsStr);
 
   if (log_to_syslog) {
     char sys_var[] = "proxy.config.syslog_facility";
@@ -657,7 +660,7 @@ main(int argc, char **argv)
   RecLocalStart(configFiles);
 
   /* Update cmd line overrides/environmental overrides/etc */
-  if (tsArgs) {                 /* Passed command line args for proxy */
+  if (tsArgs) { /* Passed command line args for proxy */
     ats_free(lmgmt->proxy_options);
     lmgmt->proxy_options = tsArgs;
     mgmt_log(stderr, "[main] Traffic Server Args: '%s'\n", lmgmt->proxy_options);
@@ -690,14 +693,14 @@ main(int argc, char **argv)
   in_addr_t group_addr_ip = inet_network(group_addr);
 
   if (!(min_ip < group_addr_ip && group_addr_ip < max_ip)) {
-    mgmt_fatal(0, "[TrafficManager] Multi-Cast group addr '%s' is not in the permitted range of %s\n",
-               group_addr, "224.0.1.0 - 239.255.255.255");
+    mgmt_fatal(0, "[TrafficManager] Multi-Cast group addr '%s' is not in the permitted range of %s\n", group_addr,
+               "224.0.1.0 - 239.255.255.255");
   }
 
   /* TODO: Do we really need to init cluster communication? */
-  lmgmt->initCCom(appVersionInfo, configFiles, cluster_mcport, group_addr, cluster_rsport);       /* Setup cluster communication */
+  lmgmt->initCCom(appVersionInfo, configFiles, cluster_mcport, group_addr, cluster_rsport); /* Setup cluster communication */
 
-  lmgmt->initMgmtProcessServer();       /* Setup p-to-p process server */
+  lmgmt->initMgmtProcessServer(); /* Setup p-to-p process server */
 
   // Now that we know our cluster ip address, add the
   //   UI record for this machine
@@ -711,8 +714,8 @@ main(int argc, char **argv)
   // can keep a consistent euid when create mgmtapi/eventapi unix
   // sockets in webIntr_main thread.
   //
-  webThrId = ink_thread_create(webIntr_main, NULL);     /* Spin web agent thread */
-  Debug("lm", "Created Web Agent thread (%"  PRId64 ")", (int64_t)webThrId);
+  webThrId = ink_thread_create(webIntr_main, NULL); /* Spin web agent thread */
+  Debug("lm", "Created Web Agent thread (%" PRId64 ")", (int64_t)webThrId);
 
   ticker = time(NULL);
   mgmt_log("[TrafficManager] Setup complete\n");
@@ -726,7 +729,7 @@ main(int argc, char **argv)
   RecRegisterStatInt(RECT_NODE, "proxy.node.config.restart_required.manager", 0, RECP_NON_PERSISTENT);
   RecRegisterStatInt(RECT_NODE, "proxy.node.config.restart_required.cop", 0, RECP_NON_PERSISTENT);
 
-  int sleep_time = 0; //sleep_time given in sec
+  int sleep_time = 0; // sleep_time given in sec
 
   for (;;) {
     lmgmt->processEventQueue();
@@ -746,7 +749,7 @@ main(int argc, char **argv)
       lmgmt->ccom->sendSharedData();
       lmgmt->virt_map->lt_runGambit();
     } else {
-      if (!lmgmt->run_proxy) {  /* Down if we are not going to start another immed. */
+      if (!lmgmt->run_proxy) { /* Down if we are not going to start another immed. */
         /* Proxy is not up, so no addrs should be */
         lmgmt->virt_map->downOurAddrs();
       }
@@ -793,7 +796,7 @@ main(int argc, char **argv)
     if (lmgmt->run_proxy && !lmgmt->processRunning()) { /* Make sure we still have a proxy up */
       if (sleep_time) {
         mgmt_log(stderr, "Relaunching proxy after %d sec...", sleep_time);
-        millisleep(1000 * sleep_time); //we use millisleep instead of sleep because it doesnt interfere with signals
+        millisleep(1000 * sleep_time); // we use millisleep instead of sleep because it doesnt interfere with signals
         sleep_time = (sleep_time > 30) ? 60 : sleep_time * 2;
       } else {
         sleep_time = 1;
@@ -804,7 +807,7 @@ main(int argc, char **argv)
       } else {
         just_started++;
       }
-    } else {                    /* Give the proxy a chance to fire up */
+    } else { /* Give the proxy a chance to fire up */
       just_started++;
     }
 
@@ -821,37 +824,37 @@ main(int argc, char **argv)
 #ifdef NEED_PSIGNAL
           mgmt_log(stderr, "[main] Proxy terminated due to Sig %d. Relaunching after %d sec...\n", sig, sleep_time);
 #else
-          mgmt_log(stderr, "[main] Proxy terminated due to Sig %d: %s. Relaunching after %d sec...\n", sig, strsignal(sig), sleep_time);
+          mgmt_log(stderr, "[main] Proxy terminated due to Sig %d: %s. Relaunching after %d sec...\n", sig, strsignal(sig),
+                   sleep_time);
 #endif /* NEED_PSIGNAL */
         }
       }
       mgmt_log(stderr, "[main] Proxy launch failed, retrying after %d sec...\n", sleep_time);
     }
-
   }
 
   if (statProcessor) {
-    delete(statProcessor);
+    delete (statProcessor);
   }
 
 #ifndef MGMT_SERVICE
   return 0;
 #endif
 
-}                               /* End main */
+} /* End main */
 
 #if !defined(linux) && !defined(freebsd) && !defined(darwin)
 static void
-SignalAlrmHandler(int /* sig ATS_UNUSED */, siginfo_t * t, void * /* c ATS_UNUSED */)
+SignalAlrmHandler(int /* sig ATS_UNUSED */, siginfo_t *t, void * /* c ATS_UNUSED */)
 #else
 static void
 SignalAlrmHandler(int /* sig ATS_UNUSED */)
 #endif
 {
-  /*
-     fprintf(stderr, "[TrafficManager] ==> SIGALRM received\n");
-     mgmt_elog(stderr, 0, "[TrafficManager] ==> SIGALRM received\n");
-   */
+/*
+   fprintf(stderr, "[TrafficManager] ==> SIGALRM received\n");
+   mgmt_elog(stderr, 0, "[TrafficManager] ==> SIGALRM received\n");
+ */
 #if !defined(linux) && !defined(freebsd) && !defined(darwin)
   if (t) {
     if (t->si_code <= 0) {
@@ -873,7 +876,7 @@ SignalAlrmHandler(int /* sig ATS_UNUSED */)
 
 #if !defined(linux) && !defined(freebsd) && !defined(darwin)
 static void
-SignalHandler(int sig, siginfo_t * t, void *c)
+SignalHandler(int sig, siginfo_t *t, void *c)
 #else
 static void
 SignalHandler(int sig)
@@ -909,7 +912,6 @@ SignalHandler(int sig)
   if (lmgmt && !clean) {
     clean = 1;
     if (lmgmt->watched_process_pid != -1) {
-
       if (sig == SIGTERM || sig == SIGINT) {
         kill(lmgmt->watched_process_pid, sig);
         waitpid(lmgmt->watched_process_pid, &status, 0);
@@ -940,7 +942,7 @@ SignalHandler(int sig)
   fprintf(stderr, "[TrafficManager] ==> signal2 #%d\n", sig);
   mgmt_elog(stderr, 0, "[TrafficManager] ==> signal2 #%d\n", sig);
   _exit(sig);
-}                               /* End SignalHandler */
+} /* End SignalHandler */
 
 // void SigChldHandler(int sig)
 //
@@ -995,7 +997,7 @@ printUsage()
   fprintf(stderr, "   [...] can be one+ of: [config process node cluster local all]\n");
   fprintf(stderr, "----------------------------------------------------------------------------\n");
   exit(0);
-}                               /* End printUsage */
+} /* End printUsage */
 
 void
 fileUpdated(char *fname, bool incVersion)
@@ -1071,10 +1073,9 @@ fileUpdated(char *fname, bool incVersion)
     lmgmt->signalFileChange("proxy.config.prefetch.config_file");
   } else {
     mgmt_elog(stderr, 0, "[fileUpdated] Unknown config file updated '%s'\n", fname);
-
   }
   return;
-}                               /* End fileUpdate */
+} /* End fileUpdate */
 
 #if TS_USE_POSIX_CAP
 /** Restore capabilities after user id change.
@@ -1096,16 +1097,17 @@ fileUpdated(char *fname, bool incVersion)
  */
 
 int
-restoreCapabilities() {
-  int zret = 0; // return value.
+restoreCapabilities()
+{
+  int zret = 0;                   // return value.
   cap_t cap_set = cap_get_proc(); // current capabilities
   // Make a list of the capabilities we want turned on.
   cap_value_t cap_list[] = {
-    CAP_NET_ADMIN, ///< Set socket transparency.
+    CAP_NET_ADMIN,        ///< Set socket transparency.
     CAP_NET_BIND_SERVICE, ///< Low port (e.g. 80) binding.
-    CAP_IPC_LOCK ///< Lock IPC objects.
+    CAP_IPC_LOCK          ///< Lock IPC objects.
   };
-  static int const CAP_COUNT = sizeof(cap_list)/sizeof(*cap_list);
+  static int const CAP_COUNT = sizeof(cap_list) / sizeof(*cap_list);
 
   cap_set_flag(cap_set, CAP_EFFECTIVE, CAP_COUNT, cap_list, CAP_SET);
   zret = cap_set_proc(cap_set);
@@ -1122,7 +1124,7 @@ restoreCapabilities() {
 //  If we are not root, do nothing
 //
 void
-runAsUser(const char * userName)
+runAsUser(const char *userName)
 {
   if (getuid() == 0 || geteuid() == 0) {
     ImpersonateUser(userName, IMPERSONATE_EFFECTIVE);
@@ -1132,6 +1134,5 @@ runAsUser(const char * userName)
       mgmt_elog(stderr, 0, "[runAsUser] Error: Failed to restore capabilities after switch to user %s.\n", userName);
     }
 #endif
-
   }
-}                               /* End runAsUser() */
+} /* End runAsUser() */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/cmd/traffic_top/stats.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/stats.h b/cmd/traffic_top/stats.h
index 714781b..4b48bde 100644
--- a/cmd/traffic_top/stats.h
+++ b/cmd/traffic_top/stats.h
@@ -33,8 +33,10 @@
 using namespace std;
 
 struct LookupItem {
-  LookupItem(const char *s, const char *n, const int t): pretty(s), name(n), type(t) {}
-  LookupItem(const char *s, const char *n, const char *d, const int t): pretty(s), name(n), numerator(n), denominator(d), type(t) {}
+  LookupItem(const char *s, const char *n, const int t) : pretty(s), name(n), type(t) {}
+  LookupItem(const char *s, const char *n, const char *d, const int t) : pretty(s), name(n), numerator(n), denominator(d), type(t)
+  {
+  }
   const char *pretty;
   const char *name;
   const char *numerator;
@@ -45,19 +47,21 @@ extern size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream);
 extern char curl_error[CURL_ERROR_SIZE];
 extern string response;
 
-namespace constant {
-  const char global[] = "\"global\": {\n";
-  const char start[] = "\"proxy.process.";
-  const char seperator[] = "\": \"";
-  const char end[] = "\",\n";
+namespace constant
+{
+const char global[] = "\"global\": {\n";
+const char start[] = "\"proxy.process.";
+const char seperator[] = "\": \"";
+const char end[] = "\",\n";
 };
 
 
 //----------------------------------------------------------------------------
-class Stats {
+class Stats
+{
 public:
-  Stats(const string &url): _url(url) {
-
+  Stats(const string &url) : _url(url)
+  {
     if (url != "") {
       if (_url.substr(0, 4) != "http") {
         // looks like it is a host using it the old way
@@ -104,7 +108,8 @@ public:
     lookup_table.insert(make_pair("client_conn", LookupItem("New Conn", "proxy.process.http.total_client_connections", 2)));
     lookup_table.insert(make_pair("client_req_conn", LookupItem("Req/Conn", "client_req", "client_conn", 3)));
     lookup_table.insert(make_pair("client_curr_conn", LookupItem("Curr Conn", "proxy.process.http.current_client_connections", 1)));
-    lookup_table.insert(make_pair("client_actv_conn", LookupItem("Active Con", "proxy.process.http.current_active_client_connections", 1)));
+    lookup_table.insert(
+      make_pair("client_actv_conn", LookupItem("Active Con", "proxy.process.http.current_active_client_connections", 1)));
 
     lookup_table.insert(make_pair("server_req", LookupItem("Requests", "proxy.process.http.outgoing_requests", 2)));
     lookup_table.insert(make_pair("server_conn", LookupItem("New Conn", "proxy.process.http.total_server_connections", 2)));
@@ -112,10 +117,14 @@ public:
     lookup_table.insert(make_pair("server_curr_conn", LookupItem("Curr Conn", "proxy.process.http.current_server_connections", 1)));
 
 
-    lookup_table.insert(make_pair("client_head", LookupItem("Head Bytes", "proxy.process.http.user_agent_response_header_total_size", 2)));
-    lookup_table.insert(make_pair("client_body", LookupItem("Body Bytes", "proxy.process.http.user_agent_response_document_total_size", 2)));
-    lookup_table.insert(make_pair("server_head", LookupItem("Head Bytes", "proxy.process.http.origin_server_response_header_total_size", 2)));
-    lookup_table.insert(make_pair("server_body", LookupItem("Body Bytes", "proxy.process.http.origin_server_response_document_total_size", 2)));
+    lookup_table.insert(
+      make_pair("client_head", LookupItem("Head Bytes", "proxy.process.http.user_agent_response_header_total_size", 2)));
+    lookup_table.insert(
+      make_pair("client_body", LookupItem("Body Bytes", "proxy.process.http.user_agent_response_document_total_size", 2)));
+    lookup_table.insert(
+      make_pair("server_head", LookupItem("Head Bytes", "proxy.process.http.origin_server_response_header_total_size", 2)));
+    lookup_table.insert(
+      make_pair("server_body", LookupItem("Body Bytes", "proxy.process.http.origin_server_response_document_total_size", 2)));
 
     // not used directly
     lookup_table.insert(make_pair("ram_hit", LookupItem("Ram Hit", "proxy.process.cache.ram_cache.hits", 2)));
@@ -127,7 +136,8 @@ public:
     lookup_table.insert(make_pair("client_abort", LookupItem("Clnt Abort", "proxy.process.http.err_client_abort_count_stat", 2)));
     lookup_table.insert(make_pair("conn_fail", LookupItem("Conn Fail", "proxy.process.http.err_connect_fail_count_stat", 2)));
     lookup_table.insert(make_pair("abort", LookupItem("Abort", "proxy.process.http.transaction_counts.errors.aborts", 2)));
-    lookup_table.insert(make_pair("t_conn_fail", LookupItem("Conn Fail", "proxy.process.http.transaction_counts.errors.connect_failed", 2)));
+    lookup_table.insert(
+      make_pair("t_conn_fail", LookupItem("Conn Fail", "proxy.process.http.transaction_counts.errors.connect_failed", 2)));
     lookup_table.insert(make_pair("other_err", LookupItem("Other Err", "proxy.process.http.transaction_counts.errors.other", 2)));
 
     // percentage
@@ -142,12 +152,18 @@ public:
     lookup_table.insert(make_pair("not", LookupItem("Not Cache", "proxy.process.http.transaction_counts.miss_not_cacheable", 5)));
     lookup_table.insert(make_pair("no", LookupItem("No Cache", "proxy.process.http.transaction_counts.miss_client_no_cache", 5)));
 
-    lookup_table.insert(make_pair("fresh_time", LookupItem("Fresh (ms)", "proxy.process.http.transaction_totaltime.hit_fresh", "fresh", 8)));
-    lookup_table.insert(make_pair("reval_time", LookupItem("Reval (ms)", "proxy.process.http.transaction_totaltime.hit_revalidated", "reval", 8)));
-    lookup_table.insert(make_pair("cold_time", LookupItem("Cold (ms)", "proxy.process.http.transaction_totaltime.miss_cold", "cold", 8)));
-    lookup_table.insert(make_pair("changed_time", LookupItem("Chang (ms)", "proxy.process.http.transaction_totaltime.miss_changed", "changed", 8)));
-    lookup_table.insert(make_pair("not_time", LookupItem("Not (ms)", "proxy.process.http.transaction_totaltime.miss_not_cacheable", "not", 8)));
-    lookup_table.insert(make_pair("no_time", LookupItem("No (ms)", "proxy.process.http.transaction_totaltime.miss_client_no_cache", "no", 8)));
+    lookup_table.insert(
+      make_pair("fresh_time", LookupItem("Fresh (ms)", "proxy.process.http.transaction_totaltime.hit_fresh", "fresh", 8)));
+    lookup_table.insert(
+      make_pair("reval_time", LookupItem("Reval (ms)", "proxy.process.http.transaction_totaltime.hit_revalidated", "reval", 8)));
+    lookup_table.insert(
+      make_pair("cold_time", LookupItem("Cold (ms)", "proxy.process.http.transaction_totaltime.miss_cold", "cold", 8)));
+    lookup_table.insert(
+      make_pair("changed_time", LookupItem("Chang (ms)", "proxy.process.http.transaction_totaltime.miss_changed", "changed", 8)));
+    lookup_table.insert(
+      make_pair("not_time", LookupItem("Not (ms)", "proxy.process.http.transaction_totaltime.miss_not_cacheable", "not", 8)));
+    lookup_table.insert(
+      make_pair("no_time", LookupItem("No (ms)", "proxy.process.http.transaction_totaltime.miss_client_no_cache", "no", 8)));
 
     lookup_table.insert(make_pair("get", LookupItem("GET", "proxy.process.http.get_requests", 5)));
     lookup_table.insert(make_pair("head", LookupItem("HEAD", "proxy.process.http.head_requests", 5)));
@@ -225,8 +241,9 @@ public:
     lookup_table.insert(make_pair("client_dyn_ka", LookupItem("Dynamic KA", "ka_total", "ka_count", 3)));
   }
 
-  void getStats() {
-
+  void
+  getStats()
+  {
     if (_url == "") {
       int64_t value = 0;
       if (_old_stats != NULL) {
@@ -239,8 +256,7 @@ public:
       gettimeofday(&_time, NULL);
       double now = _time.tv_sec + (double)_time.tv_usec / 1000000;
 
-      for (map<string, LookupItem>::const_iterator lookup_it = lookup_table.begin();
-           lookup_it != lookup_table.end(); ++lookup_it) {
+      for (map<string, LookupItem>::const_iterator lookup_it = lookup_table.begin(); lookup_it != lookup_table.end(); ++lookup_it) {
         const LookupItem &item = lookup_it->second;
 
         if (item.type == 1 || item.type == 2 || item.type == 5 || item.type == 8) {
@@ -252,8 +268,8 @@ public:
             (*_stats)[key] = strValue;
           } else {
             if (TSRecordGetInt(item.name, &value) != TS_ERR_OKAY) {
-              fprintf(stderr, "Error getting stat: %s when calling TSRecordGetInt() failed: file \"%s\", line %d\n\n",
-                  item.name, __FILE__, __LINE__);
+              fprintf(stderr, "Error getting stat: %s when calling TSRecordGetInt() failed: file \"%s\", line %d\n\n", item.name,
+                      __FILE__, __LINE__);
               abort();
             }
             string key = item.name;
@@ -310,7 +326,9 @@ public:
     }
   }
 
-  int64_t getValue(const string &key, const map<string, string> *stats) const {
+  int64_t
+  getValue(const string &key, const map<string, string> *stats) const
+  {
     map<string, string>::const_iterator stats_it = stats->find(key);
     if (stats_it == stats->end())
       return 0;
@@ -318,14 +336,18 @@ public:
     return value;
   }
 
-  void getStat(const string &key, double &value, int overrideType = 0) {
+  void
+  getStat(const string &key, double &value, int overrideType = 0)
+  {
     string strtmp;
     int typetmp;
     getStat(key, value, strtmp, typetmp, overrideType);
   }
 
 
-  void getStat(const string &key, string &value) {
+  void
+  getStat(const string &key, string &value)
+  {
     map<string, LookupItem>::const_iterator lookup_it = lookup_table.find(key);
     assert(lookup_it != lookup_table.end());
     const LookupItem &item = lookup_it->second;
@@ -337,7 +359,9 @@ public:
       value = stats_it->second.c_str();
   }
 
-  void getStat(const string &key, double &value, string &prettyName, int &type, int overrideType = 0) {
+  void
+  getStat(const string &key, double &value, string &prettyName, int &type, int overrideType = 0)
+  {
     map<string, LookupItem>::const_iterator lookup_it = lookup_table.find(key);
     assert(lookup_it != lookup_table.end());
     const LookupItem &item = lookup_it->second;
@@ -401,7 +425,9 @@ public:
     }
   }
 
-  bool toggleAbsolute() {
+  bool
+  toggleAbsolute()
+  {
     if (_absolute == true)
       _absolute = false;
     else
@@ -410,7 +436,9 @@ public:
     return _absolute;
   }
 
-  void parseResponse(const string &response) {
+  void
+  parseResponse(const string &response)
+  {
     // move past global
     size_t pos = response.find(constant::global);
     pos += sizeof(constant::global) - 1;
@@ -424,23 +452,29 @@ public:
       if (start == string::npos || seperator == string::npos || end == string::npos)
         return;
 
-      //cout << constant::start << " " << start << endl;
-      //cout << constant::seperator << " " << seperator << endl;
-      //cout << constant::end << " " << end << endl;
+      // cout << constant::start << " " << start << endl;
+      // cout << constant::seperator << " " << seperator << endl;
+      // cout << constant::end << " " << end << endl;
 
       string key = response.substr(start + 1, seperator - start - 1);
-      string value = response.substr(seperator + sizeof(constant::seperator) - 1, end - seperator - sizeof(constant::seperator) + 1);
+      string value =
+        response.substr(seperator + sizeof(constant::seperator) - 1, end - seperator - sizeof(constant::seperator) + 1);
 
       (*_stats)[key] = value;
-      //cout << "key " << key << " " << "value " << value << endl;
+      // cout << "key " << key << " " << "value " << value << endl;
       pos = end + sizeof(constant::end) - 1;
-      //cout << "pos: " << pos << endl;
+      // cout << "pos: " << pos << endl;
     }
   }
 
-  const string& getHost() const { return _host; }
+  const string &
+  getHost() const
+  {
+    return _host;
+  }
 
-  ~Stats() {
+  ~Stats()
+  {
     if (_stats != NULL) {
       delete _stats;
     }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/cmd/traffic_top/traffic_top.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/traffic_top.cc b/cmd/traffic_top/traffic_top.cc
index 71d8729..2f34c5a 100644
--- a/cmd/traffic_top/traffic_top.cc
+++ b/cmd/traffic_top/traffic_top.cc
@@ -38,17 +38,17 @@
 #define NCURSES_NOMACROS 1
 
 #if defined HAVE_NCURSESW_CURSES_H
-#  include <ncursesw/curses.h>
+#include <ncursesw/curses.h>
 #elif defined HAVE_NCURSESW_H
-#  include <ncursesw.h>
+#include <ncursesw.h>
 #elif defined HAVE_NCURSES_CURSES_H
-#  include <ncurses/curses.h>
+#include <ncurses/curses.h>
 #elif defined HAVE_NCURSES_H
-#  include <ncurses.h>
+#include <ncurses.h>
 #elif defined HAVE_CURSES_H
-#  include <curses.h>
+#include <curses.h>
 #else
-#  error "SysV or X/Open-compatible Curses header file required"
+#error "SysV or X/Open-compatible Curses header file required"
 #endif
 
 #include "stats.h"
@@ -57,19 +57,22 @@ using namespace std;
 char curl_error[CURL_ERROR_SIZE];
 string response;
 
-namespace colorPair {
-  const short red = 1;
-  const short yellow = 2;
-  const short green = 3;
-  const short blue = 4;
-  //  const short black = 5;
-  const short grey = 6;
-  const short cyan = 7;
-  const short border = 8;
+namespace colorPair
+{
+const short red = 1;
+const short yellow = 2;
+const short green = 3;
+const short blue = 4;
+//  const short black = 5;
+const short grey = 6;
+const short cyan = 7;
+const short border = 8;
 };
 
 //----------------------------------------------------------------------------
-static void prettyPrint(const int x, const int y, const double number, const int type) {
+static void
+prettyPrint(const int x, const int y, const double number, const int type)
+{
   char buffer[32];
   char exp = ' ';
   double my_number = number;
@@ -119,7 +122,9 @@ static void prettyPrint(const int x, const int y, const double number, const int
 }
 
 //----------------------------------------------------------------------------
-static void makeTable(const int x, const int y, const list<string> &items, Stats &stats) {
+static void
+makeTable(const int x, const int y, const list<string> &items, Stats &stats)
+{
   int my_y = y;
 
   for (list<string>::const_iterator it = items.begin(); it != items.end(); ++it) {
@@ -134,16 +139,19 @@ static void makeTable(const int x, const int y, const list<string> &items, Stats
 }
 
 //----------------------------------------------------------------------------
-size_t write_data(void *ptr, size_t size, size_t nmemb, void * /* stream */)
+size_t
+write_data(void *ptr, size_t size, size_t nmemb, void * /* stream */)
 {
-  response.append((char*)ptr, size * nmemb);
-  //cout << "appending: " << size * nmemb << endl;
-  //int written = fwrite(ptr, size, nmemb, (FILE *)stream);
+  response.append((char *)ptr, size * nmemb);
+  // cout << "appending: " << size * nmemb << endl;
+  // int written = fwrite(ptr, size, nmemb, (FILE *)stream);
   return size * nmemb;
 }
 
 //----------------------------------------------------------------------------
-static void response_code_page(Stats &stats) {
+static void
+response_code_page(Stats &stats)
+{
   attron(COLOR_PAIR(colorPair::border));
   attron(A_BOLD);
   mvprintw(0, 0, "                              RESPONSE CODES                                   ");
@@ -205,27 +213,34 @@ static void response_code_page(Stats &stats) {
 }
 
 //----------------------------------------------------------------------------
-static void help(const string &host, const string &version) {
+static void
+help(const string &host, const string &version)
+{
   timeout(1000);
 
-  while(1) {
+  while (1) {
     clear();
     time_t now = time(NULL);
     struct tm *nowtm = localtime(&now);
     char timeBuf[32];
     strftime(timeBuf, sizeof(timeBuf), "%H:%M:%S", nowtm);
 
-    //clear();
-    attron(A_BOLD); mvprintw(0, 0, "Overview:"); attroff(A_BOLD);
-    mvprintw(1, 0,
+    // clear();
+    attron(A_BOLD);
+    mvprintw(0, 0, "Overview:");
+    attroff(A_BOLD);
+    mvprintw(
+      1, 0,
       "traffic_top is a top like program for Apache Traffic Server (ATS). "
       "There is a lot of statistical information gathered by ATS. "
       "This program tries to show some of the more important stats and gives a good overview of what the proxy server is doing. "
       "Hopefully this can be used as a tool for diagnosing the proxy server if there are problems.");
 
-    attron(A_BOLD); mvprintw(7, 0, "Definitions:"); attroff(A_BOLD);
-    mvprintw(8,  0, "Fresh      => Requests that were servered by fresh entries in cache");
-    mvprintw(9,  0, "Revalidate => Requests that contacted the origin to verify if still valid");
+    attron(A_BOLD);
+    mvprintw(7, 0, "Definitions:");
+    attroff(A_BOLD);
+    mvprintw(8, 0, "Fresh      => Requests that were servered by fresh entries in cache");
+    mvprintw(9, 0, "Revalidate => Requests that contacted the origin to verify if still valid");
     mvprintw(10, 0, "Cold       => Requests that were not in cache at all");
     mvprintw(11, 0, "Changed    => Requests that required entries in cache to be updated");
     mvprintw(12, 0, "Changed    => Requests that can't be cached for some reason");
@@ -243,14 +258,16 @@ static void help(const string &host, const string &version) {
   }
 }
 
-static void usage()
+static void
+usage()
 {
   fprintf(stderr, "Usage: traffic_top [-s seconds] [URL|hostname|hostname:port]\n");
   exit(1);
 }
 
 //----------------------------------------------------------------------------
-void main_stats_page(Stats &stats)
+void
+main_stats_page(Stats &stats)
 {
   attron(COLOR_PAIR(colorPair::border));
   attron(A_BOLD);
@@ -364,13 +381,14 @@ void main_stats_page(Stats &stats)
 }
 
 //----------------------------------------------------------------------------
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
 {
   int sleep_time = 5000;
   bool absolute = false;
   int opt;
   while ((opt = getopt(argc, argv, "s:")) != -1) {
-    switch(opt) {
+    switch (opt) {
     case 's':
       sleep_time = atoi(optarg) * 1000;
       break;
@@ -395,7 +413,7 @@ int main(int argc, char **argv)
   initscr();
   curs_set(0);
 
-  start_color();			/* Start color functionality	*/
+  start_color(); /* Start color functionality	*/
 
   init_pair(colorPair::red, COLOR_RED, COLOR_BLACK);
   init_pair(colorPair::yellow, COLOR_YELLOW, COLOR_BLACK);
@@ -407,11 +425,14 @@ int main(int argc, char **argv)
   //  mvchgat(0, 0, -1, A_BLINK, 1, NULL);
 
 
-  enum Page {MAIN_PAGE, RESPONSE_PAGE};
+  enum Page {
+    MAIN_PAGE,
+    RESPONSE_PAGE,
+  };
   Page page = MAIN_PAGE;
   string page_alt = "(r)esponse";
 
-  while(1) {
+  while (1) {
     attron(COLOR_PAIR(colorPair::border));
     attron(A_BOLD);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/cmd/traffic_via/traffic_via.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_via/traffic_via.cc b/cmd/traffic_via/traffic_via.cc
index 46b0fc7..7426d1b 100644
--- a/cmd/traffic_via/traffic_via.cc
+++ b/cmd/traffic_via/traffic_via.cc
@@ -39,179 +39,176 @@
 #include <pcre.h>
 #endif
 
-#define SUBSTRING_VECTOR_COUNT 30 //Should be multiple of 3
+#define SUBSTRING_VECTOR_COUNT 30 // Should be multiple of 3
 
 static AppVersionInfo appVersionInfo;
 
-struct VIA
-{
-  VIA(const char * t) : title(t), next(NULL) { memset(viaData, 0, sizeof(viaData)); }
+struct VIA {
+  VIA(const char *t) : title(t), next(NULL) { memset(viaData, 0, sizeof(viaData)); }
 
-  ~VIA() {
-    delete next;
-  }
+  ~VIA() { delete next; }
 
-  const char * title;
-  const char * viaData[128];
-  VIA * next;
+  const char *title;
+  const char *viaData[128];
+  VIA *next;
 };
 
-//Function to get via header table for every field/category in the via header
+// Function to get via header table for every field/category in the via header
 static VIA *
 detailViaLookup(char flag)
 {
-  VIA * viaTable;
+  VIA *viaTable;
 
-  //Detailed via codes after ":"
+  // Detailed via codes after ":"
   switch (flag) {
   case 't':
     viaTable = new VIA("Tunnel info");
-    viaTable->viaData[(unsigned char) ' '] = "no tunneling";
-    viaTable->viaData[(unsigned char) 'U'] = "tunneling because of url (url suggests dynamic content)";
-    viaTable->viaData[(unsigned char) 'M'] = "tunneling due to a method (e.g. CONNECT)";
-    viaTable->viaData[(unsigned char) 'O'] = "tunneling because cache is turned off";
-    viaTable->viaData[(unsigned char) 'F'] = "tunneling due to a header field (such as presence of If-Range header)";
-    viaTable->viaData[(unsigned char) 'N'] = "tunneling due to no forward";
-    viaTable->viaData[(unsigned char) 'A'] = "tunnel authorization";
+    viaTable->viaData[(unsigned char)' '] = "no tunneling";
+    viaTable->viaData[(unsigned char)'U'] = "tunneling because of url (url suggests dynamic content)";
+    viaTable->viaData[(unsigned char)'M'] = "tunneling due to a method (e.g. CONNECT)";
+    viaTable->viaData[(unsigned char)'O'] = "tunneling because cache is turned off";
+    viaTable->viaData[(unsigned char)'F'] = "tunneling due to a header field (such as presence of If-Range header)";
+    viaTable->viaData[(unsigned char)'N'] = "tunneling due to no forward";
+    viaTable->viaData[(unsigned char)'A'] = "tunnel authorization";
     break;
   case 'c':
-    //Cache type
-    viaTable = new VIA( "Cache Type");
-    viaTable->viaData[(unsigned char) 'C'] = "cache";
-    viaTable->viaData[(unsigned char) 'L'] = "cluster, (not used)";
-    viaTable->viaData[(unsigned char) 'I'] = "icp";
-    viaTable->viaData[(unsigned char) 'P'] = "parent";
-    viaTable->viaData[(unsigned char) 'S'] = "server";
-    viaTable->viaData[(unsigned char) ' '] = "unknown";
-
-    //Cache Lookup Result
+    // Cache type
+    viaTable = new VIA("Cache Type");
+    viaTable->viaData[(unsigned char)'C'] = "cache";
+    viaTable->viaData[(unsigned char)'L'] = "cluster, (not used)";
+    viaTable->viaData[(unsigned char)'I'] = "icp";
+    viaTable->viaData[(unsigned char)'P'] = "parent";
+    viaTable->viaData[(unsigned char)'S'] = "server";
+    viaTable->viaData[(unsigned char)' '] = "unknown";
+
+    // Cache Lookup Result
     viaTable->next = new VIA("Cache Lookup Result");
-    viaTable->next->viaData[(unsigned char) 'C'] = "cache hit but config forces revalidate";
-    viaTable->next->viaData[(unsigned char) 'I'] = "conditional miss (client sent conditional, fresh in cache, returned 412)";
-    viaTable->next->viaData[(unsigned char) ' '] = "cache miss or no cache lookup";
-    viaTable->next->viaData[(unsigned char) 'U'] = "cache hit, but client forces revalidate (e.g. Pragma: no-cache)";
-    viaTable->next->viaData[(unsigned char) 'D'] = "cache hit, but method forces revalidated (e.g. ftp, not anonymous)";
-    viaTable->next->viaData[(unsigned char) 'M'] = "cache miss (url not in cache)";
-    viaTable->next->viaData[(unsigned char) 'N'] = "conditional hit (client sent conditional, doc fresh in cache, returned 304)";
-    viaTable->next->viaData[(unsigned char) 'H'] = "cache hit";
-    viaTable->next->viaData[(unsigned char) 'S'] = "cache hit, but expired";
-    viaTable->next->viaData[(unsigned char) 'K'] = "cookie miss";
+    viaTable->next->viaData[(unsigned char)'C'] = "cache hit but config forces revalidate";
+    viaTable->next->viaData[(unsigned char)'I'] = "conditional miss (client sent conditional, fresh in cache, returned 412)";
+    viaTable->next->viaData[(unsigned char)' '] = "cache miss or no cache lookup";
+    viaTable->next->viaData[(unsigned char)'U'] = "cache hit, but client forces revalidate (e.g. Pragma: no-cache)";
+    viaTable->next->viaData[(unsigned char)'D'] = "cache hit, but method forces revalidated (e.g. ftp, not anonymous)";
+    viaTable->next->viaData[(unsigned char)'M'] = "cache miss (url not in cache)";
+    viaTable->next->viaData[(unsigned char)'N'] = "conditional hit (client sent conditional, doc fresh in cache, returned 304)";
+    viaTable->next->viaData[(unsigned char)'H'] = "cache hit";
+    viaTable->next->viaData[(unsigned char)'S'] = "cache hit, but expired";
+    viaTable->next->viaData[(unsigned char)'K'] = "cookie miss";
     break;
   case 'i':
     viaTable = new VIA("ICP status");
-    viaTable->viaData[(unsigned char) ' '] = "no icp";
-    viaTable->viaData[(unsigned char) 'S'] = "connection opened successfully";
-    viaTable->viaData[(unsigned char) 'F'] = "connection open failed";
+    viaTable->viaData[(unsigned char)' '] = "no icp";
+    viaTable->viaData[(unsigned char)'S'] = "connection opened successfully";
+    viaTable->viaData[(unsigned char)'F'] = "connection open failed";
     break;
   case 'p':
     viaTable = new VIA("Parent proxy connection status");
-    viaTable->viaData[(unsigned char) ' '] = "no parent proxy or unknown";
-    viaTable->viaData[(unsigned char) 'S'] = "connection opened successfully";
-    viaTable->viaData[(unsigned char) 'F'] = "connection open failed";
+    viaTable->viaData[(unsigned char)' '] = "no parent proxy or unknown";
+    viaTable->viaData[(unsigned char)'S'] = "connection opened successfully";
+    viaTable->viaData[(unsigned char)'F'] = "connection open failed";
     break;
   case 's':
     viaTable = new VIA("Origin server connection status");
-    viaTable->viaData[(unsigned char) ' '] = "no server connection needed";
-    viaTable->viaData[(unsigned char) 'S'] = "connection opened successfully";
-    viaTable->viaData[(unsigned char) 'F'] = "connection open failed";
+    viaTable->viaData[(unsigned char)' '] = "no server connection needed";
+    viaTable->viaData[(unsigned char)'S'] = "connection opened successfully";
+    viaTable->viaData[(unsigned char)'F'] = "connection open failed";
     break;
   default:
     viaTable = NULL;
-    fprintf(stderr, "%s: %s: %c\n", appVersionInfo.AppStr, "Invalid VIA header character",flag);
+    fprintf(stderr, "%s: %s: %c\n", appVersionInfo.AppStr, "Invalid VIA header character", flag);
     break;
   }
 
   return viaTable;
 }
 
-//Function to get via header table for every field/category in the via header
+// Function to get via header table for every field/category in the via header
 static VIA *
 standardViaLookup(char flag)
 {
-  VIA * viaTable;
+  VIA *viaTable;
 
-  //Via codes before ":"
+  // Via codes before ":"
   switch (flag) {
-    case 'u':
-      viaTable = new VIA("Request headers received from client");
-      viaTable->viaData[(unsigned char) 'C'] = "cookie";
-      viaTable->viaData[(unsigned char) 'E'] = "error in request";
-      viaTable->viaData[(unsigned char) 'S'] = "simple request (not conditional)";
-      viaTable->viaData[(unsigned char) 'N'] = "no-cache";
-      viaTable->viaData[(unsigned char) 'I'] = "IMS";
-      viaTable->viaData[(unsigned char) ' '] = "unknown";
-      break;
-    case 'c':
-      viaTable = new VIA( "Result of Traffic Server cache lookup for URL");
-      viaTable->viaData[(unsigned char) 'A'] = "in cache, not acceptable (a cache \"MISS\")";
-      viaTable->viaData[(unsigned char) 'H'] = "in cache, fresh (a cache \"HIT\")";
-      viaTable->viaData[(unsigned char) 'S'] = "in cache, stale (a cache \"MISS\")";
-      viaTable->viaData[(unsigned char) 'R'] = "in cache, fresh Ram hit (a cache \"HIT\")";
-      viaTable->viaData[(unsigned char) 'M'] = "miss (a cache \"MISS\")";
-      viaTable->viaData[(unsigned char) ' '] = "no cache lookup";
-      break;
-    case 's':
-      viaTable = new VIA("Response information received from origin server");
-      viaTable->viaData[(unsigned char) 'E'] = "error in response";
-      viaTable->viaData[(unsigned char) 'S'] = "connection opened successfully";
-      viaTable->viaData[(unsigned char) 'N'] = "not-modified";
-      viaTable->viaData[(unsigned char) ' '] = "no server connection needed";
-      break;
-    case 'f':
-      viaTable = new VIA("Result of document write-to-cache:");
-      viaTable->viaData[(unsigned char) 'U'] = "updated old cache copy";
-      viaTable->viaData[(unsigned char) 'D'] = "cached copy deleted";
-      viaTable->viaData[(unsigned char) 'W'] = "written into cache (new copy)";
-      viaTable->viaData[(unsigned char) ' '] = "no cache write performed";
-      break;
-    case 'p':
-      viaTable = new VIA("Proxy operation result");
-      viaTable->viaData[(unsigned char) 'R'] = "origin server revalidated";
-      viaTable->viaData[(unsigned char) ' '] = "unknown";
-      viaTable->viaData[(unsigned char) 'S'] = "served or connection opened successfully";
-      viaTable->viaData[(unsigned char) 'N'] = "not-modified";
-      break;
-    case 'e':
-      viaTable = new VIA("Error codes (if any)");
-      viaTable->viaData[(unsigned char) 'A'] = "authorization failure";
-      viaTable->viaData[(unsigned char) 'H'] = "header syntax unacceptable";
-      viaTable->viaData[(unsigned char) 'C'] = "connection to server failed";
-      viaTable->viaData[(unsigned char) 'T'] = "connection timed out";
-      viaTable->viaData[(unsigned char) 'S'] = "server related error";
-      viaTable->viaData[(unsigned char) 'D'] = "dns failure";
-      viaTable->viaData[(unsigned char) 'N'] = "no error";
-      viaTable->viaData[(unsigned char) 'F'] = "request forbidden";
-      viaTable->viaData[(unsigned char) 'R'] = "cache read error";
-      viaTable->viaData[(unsigned char) ' '] = "unknown";
-      break;
-    default:
-      viaTable = NULL;
-      fprintf(stderr, "%s: %s: %c\n", appVersionInfo.AppStr, "Invalid VIA header character",flag);
-      break;
+  case 'u':
+    viaTable = new VIA("Request headers received from client");
+    viaTable->viaData[(unsigned char)'C'] = "cookie";
+    viaTable->viaData[(unsigned char)'E'] = "error in request";
+    viaTable->viaData[(unsigned char)'S'] = "simple request (not conditional)";
+    viaTable->viaData[(unsigned char)'N'] = "no-cache";
+    viaTable->viaData[(unsigned char)'I'] = "IMS";
+    viaTable->viaData[(unsigned char)' '] = "unknown";
+    break;
+  case 'c':
+    viaTable = new VIA("Result of Traffic Server cache lookup for URL");
+    viaTable->viaData[(unsigned char)'A'] = "in cache, not acceptable (a cache \"MISS\")";
+    viaTable->viaData[(unsigned char)'H'] = "in cache, fresh (a cache \"HIT\")";
+    viaTable->viaData[(unsigned char)'S'] = "in cache, stale (a cache \"MISS\")";
+    viaTable->viaData[(unsigned char)'R'] = "in cache, fresh Ram hit (a cache \"HIT\")";
+    viaTable->viaData[(unsigned char)'M'] = "miss (a cache \"MISS\")";
+    viaTable->viaData[(unsigned char)' '] = "no cache lookup";
+    break;
+  case 's':
+    viaTable = new VIA("Response information received from origin server");
+    viaTable->viaData[(unsigned char)'E'] = "error in response";
+    viaTable->viaData[(unsigned char)'S'] = "connection opened successfully";
+    viaTable->viaData[(unsigned char)'N'] = "not-modified";
+    viaTable->viaData[(unsigned char)' '] = "no server connection needed";
+    break;
+  case 'f':
+    viaTable = new VIA("Result of document write-to-cache:");
+    viaTable->viaData[(unsigned char)'U'] = "updated old cache copy";
+    viaTable->viaData[(unsigned char)'D'] = "cached copy deleted";
+    viaTable->viaData[(unsigned char)'W'] = "written into cache (new copy)";
+    viaTable->viaData[(unsigned char)' '] = "no cache write performed";
+    break;
+  case 'p':
+    viaTable = new VIA("Proxy operation result");
+    viaTable->viaData[(unsigned char)'R'] = "origin server revalidated";
+    viaTable->viaData[(unsigned char)' '] = "unknown";
+    viaTable->viaData[(unsigned char)'S'] = "served or connection opened successfully";
+    viaTable->viaData[(unsigned char)'N'] = "not-modified";
+    break;
+  case 'e':
+    viaTable = new VIA("Error codes (if any)");
+    viaTable->viaData[(unsigned char)'A'] = "authorization failure";
+    viaTable->viaData[(unsigned char)'H'] = "header syntax unacceptable";
+    viaTable->viaData[(unsigned char)'C'] = "connection to server failed";
+    viaTable->viaData[(unsigned char)'T'] = "connection timed out";
+    viaTable->viaData[(unsigned char)'S'] = "server related error";
+    viaTable->viaData[(unsigned char)'D'] = "dns failure";
+    viaTable->viaData[(unsigned char)'N'] = "no error";
+    viaTable->viaData[(unsigned char)'F'] = "request forbidden";
+    viaTable->viaData[(unsigned char)'R'] = "cache read error";
+    viaTable->viaData[(unsigned char)' '] = "unknown";
+    break;
+  default:
+    viaTable = NULL;
+    fprintf(stderr, "%s: %s: %c\n", appVersionInfo.AppStr, "Invalid VIA header character", flag);
+    break;
   }
 
   return viaTable;
 }
 
-//Function to print via header
+// Function to print via header
 static void
-printViaHeader(const char * header)
+printViaHeader(const char *header)
 {
-  VIA * viaTable = NULL;
-  VIA * viaEntry = NULL;
+  VIA *viaTable = NULL;
+  VIA *viaEntry = NULL;
   bool isDetail = false;
 
   printf("Via Header Details:\n");
 
-  //Loop through input via header flags
-  for (const char * c = header; *c; ++c) {
+  // Loop through input via header flags
+  for (const char *c = header; *c; ++c) {
     if (*c == ':') {
       isDetail = true;
       continue;
     }
 
     if (islower(*c)) {
-      //Get the via header table
+      // Get the via header table
       delete viaTable;
       viaEntry = viaTable = isDetail ? detailViaLookup(*c) : standardViaLookup(*c);
     } else {
@@ -226,41 +223,43 @@ printViaHeader(const char * header)
   delete viaTable;
 }
 
-//Check validity of via header and then decode it
+// Check validity of via header and then decode it
 static TSMgmtError
-decodeViaHeader(const char * str)
+decodeViaHeader(const char *str)
 {
   size_t viaHdrLength = strlen(str);
   char tmp[viaHdrLength + 2];
-  char * Via = tmp;
+  char *Via = tmp;
 
   strncpy(Via, str, viaHdrLength + 1); // Safe to call strcpy.
   printf("Via header is %s, Length is %zu\n", Via, viaHdrLength);
 
-  //Via header inside square brackets
-  if (Via[0] == '[' && Via[viaHdrLength-1] == ']') {
+  // Via header inside square brackets
+  if (Via[0] == '[' && Via[viaHdrLength - 1] == ']') {
     viaHdrLength = viaHdrLength - 2;
     Via++;
-    Via[viaHdrLength] = '\0'; //null terminate the string after trimming
+    Via[viaHdrLength] = '\0'; // null terminate the string after trimming
   }
 
   if (viaHdrLength == 5) {
-    Via = strcat(Via, " ");  //Add one space character before decoding via header
+    Via = strcat(Via, " "); // Add one space character before decoding via header
     ++viaHdrLength;
   }
 
   if (viaHdrLength == 24 || viaHdrLength == 6) {
-    //Decode via header
+    // Decode via header
     printViaHeader(Via);
     return TS_ERR_OKAY;
   }
-  //Invalid header size, come out.
+  // Invalid header size, come out.
   printf("\nInvalid VIA header. VIA header length should be 6 or 24 characters\n");
-  printf("Valid via header format is [u<client-stuff>c<cache-lookup-stuff>s<server-stuff>f<cache-fill-stuff>p<proxy-stuff>]e<error-codes>:t<tunneling-info>c<cache type><cache-lookup-result>i<icp-conn-info>p<parent-proxy-conn-info>s<server-conn-info>]");
+  printf("Valid via header format is "
+         "[u<client-stuff>c<cache-lookup-stuff>s<server-stuff>f<cache-fill-stuff>p<proxy-stuff>]e<error-codes>:t<tunneling-info>c<"
+         "cache type><cache-lookup-result>i<icp-conn-info>p<parent-proxy-conn-info>s<server-conn-info>]");
   return TS_ERR_FAIL;
 }
 
-//Read user input from stdin
+// Read user input from stdin
 static TSMgmtError
 filterViaHeader()
 {
@@ -271,11 +270,12 @@ filterViaHeader()
   int errOffset;
   int pcreExecCode;
   int i;
-  const char *viaPattern = "\\[([ucsfpe]+[^\\]]+)\\]"; //Regex to match via header with in [] which can start with character class ucsfpe
+  const char *viaPattern =
+    "\\[([ucsfpe]+[^\\]]+)\\]"; // Regex to match via header with in [] which can start with character class ucsfpe
   char *viaHeaderString;
   char viaHeader[1024];
 
-  //Compile PCRE via header pattern
+  // Compile PCRE via header pattern
   compiledReg = pcre_compile(viaPattern, 0, &err, &errOffset, NULL);
 
   if (compiledReg == NULL) {
@@ -283,34 +283,36 @@ filterViaHeader()
     return TS_ERR_FAIL;
   }
 
-  //Read all lines from stdin
+  // Read all lines from stdin
   while (fgets(viaHeader, sizeof(viaHeader), stdin)) {
-    //Trim new line character and null terminate it
-    char* newLinePtr = strchr(viaHeader, '\n');
+    // Trim new line character and null terminate it
+    char *newLinePtr = strchr(viaHeader, '\n');
     if (newLinePtr) {
       *newLinePtr = '\0';
     }
-    //Match for via header pattern
-    pcreExecCode = pcre_exec(compiledReg, extraReg, viaHeader, (int)sizeof(viaHeader), 0, 0, subStringVector, SUBSTRING_VECTOR_COUNT);
+    // Match for via header pattern
+    pcreExecCode =
+      pcre_exec(compiledReg, extraReg, viaHeader, (int)sizeof(viaHeader), 0, 0, subStringVector, SUBSTRING_VECTOR_COUNT);
 
-    //Match failed, don't worry. Continue to next line.
-    if (pcreExecCode < 0) continue;
+    // Match failed, don't worry. Continue to next line.
+    if (pcreExecCode < 0)
+      continue;
 
-    //Match successful, but too many substrings
+    // Match successful, but too many substrings
     if (pcreExecCode == 0) {
-      pcreExecCode = SUBSTRING_VECTOR_COUNT/3;
+      pcreExecCode = SUBSTRING_VECTOR_COUNT / 3;
       printf("Too many substrings were found. %d substrings couldn't fit into subStringVector\n", pcreExecCode - 1);
     }
 
-    //Loop based on number of matches found
+    // Loop based on number of matches found
     for (i = 1; i < pcreExecCode; i++) {
-      //Point to beginning of matched substring
-      char *subStringBegin = viaHeader + subStringVector[2*i];
-      //Get length of matched substring
-      int subStringLen = subStringVector[2*i+1] - subStringVector[2*i];
+      // Point to beginning of matched substring
+      char *subStringBegin = viaHeader + subStringVector[2 * i];
+      // Get length of matched substring
+      int subStringLen = subStringVector[2 * i + 1] - subStringVector[2 * i];
       viaHeaderString = subStringBegin;
       sprintf(viaHeaderString, "%.*s", subStringLen, subStringBegin);
-      //Decode matched substring
+      // Decode matched substring
       decodeViaHeader(viaHeaderString);
     }
   }
@@ -327,8 +329,7 @@ main(int /* argc ATS_UNUSED */, const char **argv)
 
   /* see 'ink_args.h' for meanings of the various fields */
   ArgumentDescription argument_descriptions[] = {
-    VERSION_ARGUMENT_DESCRIPTION(),
-    HELP_ARGUMENT_DESCRIPTION(),
+    VERSION_ARGUMENT_DESCRIPTION(), HELP_ARGUMENT_DESCRIPTION(),
   };
 
   process_args(&appVersionInfo, argument_descriptions, countof(argument_descriptions), argv);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/cmd/traffic_wccp/wccp_client.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_wccp/wccp_client.cc b/cmd/traffic_wccp/wccp_client.cc
index 4e28032..7d08fcb 100644
--- a/cmd/traffic_wccp/wccp_client.cc
+++ b/cmd/traffic_wccp/wccp_client.cc
@@ -47,28 +47,26 @@
 bool do_debug = false;
 bool do_daemon = false;
 
-static char const USAGE_TEXT[] =
-  "%s\n"
-  "--address IP address to bind.\n"
-  "--router Booststrap IP address for routers.\n"
-  "--service Path to service group definitions.\n"
-  "--debug Print debugging information.\n"
-  "--daemon Run as daemon.\n"
-  "--help Print usage and exit.\n"
-  ;
+static char const USAGE_TEXT[] = "%s\n"
+                                 "--address IP address to bind.\n"
+                                 "--router Booststrap IP address for routers.\n"
+                                 "--service Path to service group definitions.\n"
+                                 "--debug Print debugging information.\n"
+                                 "--daemon Run as daemon.\n"
+                                 "--help Print usage and exit.\n";
 
 static void
-PrintErrata(ts::Errata const& err) 
+PrintErrata(ts::Errata const &err)
 {
   size_t n;
   static size_t const SIZE = 4096;
   char buff[SIZE];
   if (err.size()) {
     ts::Errata::Code code = err.top().getCode();
-    if (do_debug || code >=  wccp::LVL_WARN) {
+    if (do_debug || code >= wccp::LVL_WARN) {
       n = err.write(buff, SIZE, 1, 0, 2, "> ");
       // strip trailing newlines.
-      while (n && (buff[n-1] == '\n' || buff[n-1] == '\r'))
+      while (n && (buff[n - 1] == '\n' || buff[n - 1] == '\r'))
         buff[--n] = 0;
       printf("%s\n", buff);
     }
@@ -76,7 +74,7 @@ PrintErrata(ts::Errata const& err)
 }
 
 static void
-Init_Errata_Logging() 
+Init_Errata_Logging()
 {
   ts::Errata::registerSink(&PrintErrata);
 }
@@ -112,35 +110,36 @@ check_lockfile()
 }
 
 int
-main(int argc, char** argv) {
+main(int argc, char **argv)
+{
   wccp::Cache wcp;
 
   // getopt return values. Selected to avoid collisions with
   // short arguments.
   static int const OPT_ADDRESS = 257; ///< Bind to IP address option.
-  static int const OPT_HELP = 258; ///< Print help message.
-  static int const OPT_ROUTER = 259; ///< Seeded router IP address.
+  static int const OPT_HELP = 258;    ///< Print help message.
+  static int const OPT_ROUTER = 259;  ///< Seeded router IP address.
   static int const OPT_SERVICE = 260; ///< Service group definition.
-  static int const OPT_DEBUG = 261; ///< Enable debug printing
-  static int const OPT_DAEMON = 262; ///< Disconnect and run as daemon
+  static int const OPT_DEBUG = 261;   ///< Enable debug printing
+  static int const OPT_DAEMON = 262;  ///< Disconnect and run as daemon
 
   static option OPTIONS[] = {
-    { "address", 1, 0, OPT_ADDRESS },
-    { "router", 1, 0, OPT_ROUTER },
-    { "service", 1, 0, OPT_SERVICE },
-    { "debug", 0, 0, OPT_DEBUG },
-    { "daemon", 0, 0, OPT_DAEMON },
-    { "help", 0, 0, OPT_HELP },
-    { 0, 0, 0, 0 } // required terminator.
+    {"address", 1, 0, OPT_ADDRESS},
+    {"router", 1, 0, OPT_ROUTER},
+    {"service", 1, 0, OPT_SERVICE},
+    {"debug", 0, 0, OPT_DEBUG},
+    {"daemon", 0, 0, OPT_DAEMON},
+    {"help", 0, 0, OPT_HELP},
+    {0, 0, 0, 0} // required terminator.
   };
 
-  in_addr ip_addr = { INADDR_ANY };
-  in_addr router_addr = { INADDR_ANY };
+  in_addr ip_addr = {INADDR_ANY};
+  in_addr router_addr = {INADDR_ANY};
 
   int zret; // getopt return.
   int zidx; // option index.
   bool fail = false;
-  char const* FAIL_MSG = "";
+  char const *FAIL_MSG = "";
 
   while (-1 != (zret = getopt_long_only(argc, argv, "", OPTIONS, &zidx))) {
     switch (zret) {
@@ -166,13 +165,14 @@ main(int argc, char** argv) {
       break;
     case OPT_SERVICE: {
       ts::Errata status = wcp.loadServicesFromFile(optarg);
-      if (!status) fail = true;
+      if (!status)
+        fail = true;
       break;
     }
-    case OPT_DEBUG: 
+    case OPT_DEBUG:
       do_debug = true;
       break;
-    case OPT_DAEMON: 
+    case OPT_DAEMON:
       do_daemon = true;
       break;
     }
@@ -182,7 +182,7 @@ main(int argc, char** argv) {
     printf(USAGE_TEXT, FAIL_MSG);
     return 1;
   }
- 
+
   if (0 > wcp.open(ip_addr.s_addr)) {
     fprintf(stderr, "Failed to open or bind socket.\n");
     return 2;
@@ -211,7 +211,7 @@ main(int argc, char** argv) {
   wcp.housekeeping();
 
   while (true) {
-    int n = poll(pfa, POLL_FD_COUNT,  1000);
+    int n = poll(pfa, POLL_FD_COUNT, 1000);
     if (n < 0) { // error
       perror("General polling failure");
       return 5;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/add-header/add-header.c
----------------------------------------------------------------------
diff --git a/example/add-header/add-header.c b/example/add-header/add-header.c
index 7bd1e15..7583028 100644
--- a/example/add-header/add-header.c
+++ b/example/add-header/add-header.c
@@ -65,7 +65,6 @@ add_header(TSHttpTxn txnp, TSCont contp ATS_UNUSED)
 
   /* Loop on our header containing fields to add */
   while (field_loc) {
-
     /* First create a new field in the client request header */
     if (TSMimeHdrFieldCreate(req_bufp, req_loc, &new_field_loc) != TS_SUCCESS) {
       TSError("[add_header] Error while creating new field");
@@ -108,7 +107,7 @@ done:
 static int
 add_header_plugin(TSCont contp, TSEvent event, void *edata)
 {
-  TSHttpTxn txnp = (TSHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn)edata;
 
   switch (event) {
   case TS_EVENT_HTTP_READ_REQUEST_HDR:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/append-transform/append-transform.c
----------------------------------------------------------------------
diff --git a/example/append-transform/append-transform.c b/example/append-transform/append-transform.c
index 77ba97f..7ff3848 100644
--- a/example/append-transform/append-transform.c
+++ b/example/append-transform/append-transform.c
@@ -43,10 +43,9 @@
 #include "ts/ts.h"
 #include "ink_defs.h"
 
-#define ASSERT_SUCCESS(_x) TSAssert ((_x) == TS_SUCCESS)
+#define ASSERT_SUCCESS(_x) TSAssert((_x) == TS_SUCCESS)
 
-typedef struct
-{
+typedef struct {
   TSVIO output_vio;
   TSIOBuffer output_buffer;
   TSIOBufferReader output_reader;
@@ -62,7 +61,7 @@ my_data_alloc()
 {
   MyData *data;
 
-  data = (MyData *) TSmalloc(sizeof(MyData));
+  data = (MyData *)TSmalloc(sizeof(MyData));
   TSReleaseAssert(data);
 
   data->output_vio = NULL;
@@ -74,7 +73,7 @@ my_data_alloc()
 }
 
 static void
-my_data_destroy(MyData * data)
+my_data_destroy(MyData *data)
 {
   if (data) {
     if (data->output_buffer)
@@ -208,20 +207,18 @@ append_transform(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
     return 0;
   } else {
     switch (event) {
-    case TS_EVENT_ERROR:
-      {
-        TSVIO write_vio;
-
-        /* Get the write VIO for the write operation that was
-           performed on ourself. This VIO contains the continuation of
-           our parent transformation. */
-        write_vio = TSVConnWriteVIOGet(contp);
-
-        /* Call back the write VIO continuation to let it know that we
-           have completed the write operation. */
-        TSContCall(TSVIOContGet(write_vio), TS_EVENT_ERROR, write_vio);
-      }
-      break;
+    case TS_EVENT_ERROR: {
+      TSVIO write_vio;
+
+      /* Get the write VIO for the write operation that was
+         performed on ourself. This VIO contains the continuation of
+         our parent transformation. */
+      write_vio = TSVConnWriteVIOGet(contp);
+
+      /* Call back the write VIO continuation to let it know that we
+         have completed the write operation. */
+      TSContCall(TSVIOContGet(write_vio), TS_EVENT_ERROR, write_vio);
+    } break;
     case TS_EVENT_VCONN_WRITE_COMPLETE:
       /* When our output connection says that it has finished
          reading all the data we've written to it then we should
@@ -259,7 +256,6 @@ transformable(TSHttpTxn txnp)
    */
 
   if (TS_HTTP_STATUS_OK == (resp_status = TSHttpHdrStatusGet(bufp, hdr_loc))) {
-
     /* We only want to do the transformation on documents that have a
        content type of "text/html". */
     field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, "Content-Type", 12);
@@ -281,7 +277,7 @@ transformable(TSHttpTxn txnp)
     }
   }
 
-  return 0;                     /* not a 200 */
+  return 0; /* not a 200 */
 }
 
 static void
@@ -296,7 +292,7 @@ transform_add(TSHttpTxn txnp)
 static int
 transform_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
 {
-  TSHttpTxn txnp = (TSHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn)edata;
 
   switch (event) {
   case TS_EVENT_HTTP_READ_RESPONSE_HDR:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/basic-auth/basic-auth.c
----------------------------------------------------------------------
diff --git a/example/basic-auth/basic-auth.c b/example/basic-auth/basic-auth.c
index 963b78e..7baceec 100644
--- a/example/basic-auth/basic-auth.c
+++ b/example/basic-auth/basic-auth.c
@@ -37,15 +37,16 @@ static char base64_codes[256];
 static char *
 base64_decode(const char *input)
 {
-#define decode(A) ((unsigned int) base64_codes[(int) input[A]])
+#define decode(A) ((unsigned int)base64_codes[(int)input[A]])
 
   char *output;
   char *obuf;
   int len;
 
-  for (len = 0; (input[len] != '\0') && (input[len] != '='); len++);
+  for (len = 0; (input[len] != '\0') && (input[len] != '='); len++)
+    ;
 
-  output = obuf = (char *) TSmalloc((len * 6) / 8 + 3);
+  output = obuf = (char *)TSmalloc((len * 6) / 8 + 3);
 
   while (len > 0) {
     *output++ = decode(0) << 2 | decode(1) >> 4;
@@ -174,13 +175,12 @@ handle_response(TSHttpTxn txnp)
   }
 
   TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED);
-  TSHttpHdrReasonSet(bufp, hdr_loc,
-                      TSHttpHdrReasonLookup(TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED),
-                      strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED)));
+  TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED),
+                     strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED)));
 
   TSMimeHdrFieldCreate(bufp, hdr_loc, &field_loc); // Probably should check for errors
   TSMimeHdrFieldNameSet(bufp, hdr_loc, field_loc, TS_MIME_FIELD_PROXY_AUTHENTICATE, TS_MIME_LEN_PROXY_AUTHENTICATE);
-  TSMimeHdrFieldValueStringInsert(bufp, hdr_loc, field_loc, -1,  insert, len);
+  TSMimeHdrFieldValueStringInsert(bufp, hdr_loc, field_loc, -1, insert, len);
   TSMimeHdrFieldAppend(bufp, hdr_loc, field_loc);
 
   TSHandleMLocRelease(bufp, hdr_loc, field_loc);
@@ -193,7 +193,7 @@ done:
 static int
 auth_plugin(TSCont contp, TSEvent event, void *edata)
 {
-  TSHttpTxn txnp = (TSHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn)edata;
 
   switch (event) {
   case TS_EVENT_HTTP_OS_DNS:
@@ -241,4 +241,3 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 
   TSHttpHookAdd(TS_HTTP_OS_DNS_HOOK, TSContCreate(auth_plugin, NULL));
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/blacklist-0/blacklist-0.c
----------------------------------------------------------------------
diff --git a/example/blacklist-0/blacklist-0.c b/example/blacklist-0/blacklist-0.c
index 9038b8f..c48e735 100644
--- a/example/blacklist-0/blacklist-0.c
+++ b/example/blacklist-0/blacklist-0.c
@@ -98,9 +98,8 @@ handle_response(TSHttpTxn txnp)
   }
 
   TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_FORBIDDEN);
-  TSHttpHdrReasonSet(bufp, hdr_loc,
-                      TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN),
-                      strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN)));
+  TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN),
+                     strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN)));
 
   if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
     TSError("couldn't retrieve client request header\n");
@@ -131,7 +130,7 @@ done:
 static int
 blacklist_plugin(TSCont contp, TSEvent event, void *edata)
 {
-  TSHttpTxn txnp = (TSHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn)edata;
 
   switch (event) {
   case TS_EVENT_HTTP_OS_DNS:
@@ -158,12 +157,11 @@ TSPluginInit(int argc, const char *argv[])
 
   if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
     TSError("Plugin registration failed.\n");
-
   }
 
   nsites = argc - 1;
   if (nsites > 0) {
-    sites = (char **) TSmalloc(sizeof(char *) * nsites);
+    sites = (char **)TSmalloc(sizeof(char *) * nsites);
 
     for (i = 0; i < nsites; i++) {
       sites[i] = TSstrdup(argv[i + 1]);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/blacklist-1/blacklist-1.c
----------------------------------------------------------------------
diff --git a/example/blacklist-1/blacklist-1.c b/example/blacklist-1/blacklist-1.c
index c7b0797..322df1c 100644
--- a/example/blacklist-1/blacklist-1.c
+++ b/example/blacklist-1/blacklist-1.c
@@ -38,14 +38,11 @@ static TSCont global_contp;
 
 static void handle_txn_start(TSCont contp, TSHttpTxn txnp);
 
-typedef struct contp_data
-{
-
-  enum calling_func
-  {
+typedef struct contp_data {
+  enum calling_func {
     HANDLE_DNS,
     HANDLE_RESPONSE,
-    READ_BLACKLIST
+    READ_BLACKLIST,
   } cf;
 
   TSHttpTxn txnp;
@@ -57,7 +54,7 @@ destroy_continuation(TSHttpTxn txnp, TSCont contp)
 {
   cdata *cd = NULL;
 
-  cd = (cdata *) TSContDataGet(contp);
+  cd = (cdata *)TSContDataGet(contp);
   if (cd != NULL) {
     TSfree(cd);
   }
@@ -146,9 +143,8 @@ handle_response(TSHttpTxn txnp, TSCont contp ATS_UNUSED)
   }
 
   TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_FORBIDDEN);
-  TSHttpHdrReasonSet(bufp, hdr_loc,
-                      TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN),
-                      strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN)));
+  TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN),
+                     strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN)));
 
   if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
     TSError("couldn't retrieve client request header\n");
@@ -162,7 +158,7 @@ handle_response(TSHttpTxn txnp, TSCont contp ATS_UNUSED)
     goto done;
   }
 
-  buf = (char *) TSmalloc(4096);
+  buf = (char *)TSmalloc(4096);
 
   url_str = TSUrlStringGet(bufp, url_loc, &url_length);
   sprintf(buf, "You are forbidden from accessing \"%s\"\n", url_str);
@@ -223,7 +219,6 @@ read_blacklist(TSCont contp)
   }
 
   TSMutexUnlock(sites_mutex);
-
 }
 
 static int
@@ -234,12 +229,12 @@ blacklist_plugin(TSCont contp, TSEvent event, void *edata)
 
   switch (event) {
   case TS_EVENT_HTTP_TXN_START:
-    txnp = (TSHttpTxn) edata;
+    txnp = (TSHttpTxn)edata;
     handle_txn_start(contp, txnp);
     return 0;
   case TS_EVENT_HTTP_OS_DNS:
     if (contp != global_contp) {
-      cd = (cdata *) TSContDataGet(contp);
+      cd = (cdata *)TSContDataGet(contp);
       cd->cf = HANDLE_DNS;
       handle_dns(cd->txnp, contp);
       return 0;
@@ -247,14 +242,14 @@ blacklist_plugin(TSCont contp, TSEvent event, void *edata)
       break;
     }
   case TS_EVENT_HTTP_TXN_CLOSE:
-    txnp = (TSHttpTxn) edata;
+    txnp = (TSHttpTxn)edata;
     if (contp != global_contp) {
       destroy_continuation(txnp, contp);
     }
     break;
   case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
     if (contp != global_contp) {
-      cd = (cdata *) TSContDataGet(contp);
+      cd = (cdata *)TSContDataGet(contp);
       cd->cf = HANDLE_RESPONSE;
       handle_response(cd->txnp, contp);
       return 0;
@@ -267,7 +262,7 @@ blacklist_plugin(TSCont contp, TSEvent event, void *edata)
        edata. We need to decide, in which function did the MutexLock
        failed and call that function again */
     if (contp != global_contp) {
-      cd = (cdata *) TSContDataGet(contp);
+      cd = (cdata *)TSContDataGet(contp);
       switch (cd->cf) {
       case HANDLE_DNS:
         handle_dns(cd->txnp, contp);
@@ -276,7 +271,7 @@ blacklist_plugin(TSCont contp, TSEvent event, void *edata)
         handle_response(cd->txnp, contp);
         return 0;
       default:
-	TSDebug("blacklist_plugin", "This event was unexpected: %d\n", event);
+        TSDebug("blacklist_plugin", "This event was unexpected: %d\n", event);
         break;
       }
     } else {
@@ -295,9 +290,9 @@ handle_txn_start(TSCont contp ATS_UNUSED, TSHttpTxn txnp)
   TSCont txn_contp;
   cdata *cd;
 
-  txn_contp = TSContCreate((TSEventFunc) blacklist_plugin, TSMutexCreate());
+  txn_contp = TSContCreate((TSEventFunc)blacklist_plugin, TSMutexCreate());
   /* create the data that'll be associated with the continuation */
-  cd = (cdata *) TSmalloc(sizeof(cdata));
+  cd = (cdata *)TSmalloc(sizeof(cdata));
   TSContDataSet(txn_contp, cd);
 
   cd->txnp = txnp;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/bnull-transform/bnull-transform.c
----------------------------------------------------------------------
diff --git a/example/bnull-transform/bnull-transform.c b/example/bnull-transform/bnull-transform.c
index 03acb26..40f4ae6 100644
--- a/example/bnull-transform/bnull-transform.c
+++ b/example/bnull-transform/bnull-transform.c
@@ -39,12 +39,11 @@
 #include "ts/ts.h"
 #include "ink_defs.h"
 
-#define TS_NULL_MUTEX      NULL
-#define STATE_BUFFER_DATA   0
-#define STATE_OUTPUT_DATA   1
+#define TS_NULL_MUTEX NULL
+#define STATE_BUFFER_DATA 0
+#define STATE_OUTPUT_DATA 1
 
-typedef struct
-{
+typedef struct {
   int state;
   TSVIO output_vio;
   TSIOBuffer output_buffer;
@@ -56,7 +55,7 @@ my_data_alloc()
 {
   MyData *data;
 
-  data = (MyData *) TSmalloc(sizeof(MyData));
+  data = (MyData *)TSmalloc(sizeof(MyData));
   data->state = STATE_BUFFER_DATA;
   data->output_vio = NULL;
   data->output_buffer = NULL;
@@ -66,7 +65,7 @@ my_data_alloc()
 }
 
 static void
-my_data_destroy(MyData * data)
+my_data_destroy(MyData *data)
 {
   if (data) {
     if (data->output_buffer) {
@@ -77,7 +76,7 @@ my_data_destroy(MyData * data)
 }
 
 static int
-handle_buffering(TSCont contp, MyData * data)
+handle_buffering(TSCont contp, MyData *data)
 {
   TSVIO write_vio;
   int towrite;
@@ -160,7 +159,7 @@ handle_buffering(TSCont contp, MyData * data)
 }
 
 static int
-handle_output(TSCont contp, MyData * data)
+handle_output(TSCont contp, MyData *data)
 {
   /* Check to see if we need to initiate the output operation. */
   if (!data->output_vio) {
@@ -169,8 +168,7 @@ handle_output(TSCont contp, MyData * data)
     /* Get the output connection where we'll write data to. */
     output_conn = TSTransformOutputVConnGet(contp);
 
-    data->output_vio =
-      TSVConnWrite(output_conn, contp, data->output_reader, TSIOBufferReaderAvail(data->output_reader));
+    data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, TSIOBufferReaderAvail(data->output_reader));
 
     TSAssert(data->output_vio);
   }
@@ -220,19 +218,19 @@ bnull_transform(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
     TSContDestroy(contp);
   } else {
     switch (event) {
-    case TS_EVENT_ERROR:{
-        TSVIO write_vio;
+    case TS_EVENT_ERROR: {
+      TSVIO write_vio;
 
-        /* Get the write VIO for the write operation that was
-           performed on ourself. This VIO contains the continuation of
-           our parent transformation. */
-        write_vio = TSVConnWriteVIOGet(contp);
+      /* Get the write VIO for the write operation that was
+         performed on ourself. This VIO contains the continuation of
+         our parent transformation. */
+      write_vio = TSVConnWriteVIOGet(contp);
 
-        /* Call back the write VIO continuation to let it know that we
-           have completed the write operation. */
-        TSContCall(TSVIOContGet(write_vio), TS_EVENT_ERROR, write_vio);
-        break;
-      }
+      /* Call back the write VIO continuation to let it know that we
+         have completed the write operation. */
+      TSContCall(TSVIOContGet(write_vio), TS_EVENT_ERROR, write_vio);
+      break;
+    }
 
     case TS_EVENT_VCONN_WRITE_COMPLETE:
       /* When our output connection says that it has finished
@@ -271,7 +269,8 @@ transformable(TSHttpTxn txnp)
   retv = (resp_status == TS_HTTP_STATUS_OK);
 
   if (TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc) == TS_ERROR) {
-    TSError("[bnull-transform] Error releasing MLOC while checking " "header status\n");
+    TSError("[bnull-transform] Error releasing MLOC while checking "
+            "header status\n");
   }
 
   return retv;
@@ -290,7 +289,7 @@ transform_add(TSHttpTxn txnp)
 static int
 transform_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
 {
-  TSHttpTxn txnp = (TSHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn)edata;
 
   switch (event) {
   case TS_EVENT_HTTP_READ_RESPONSE_HDR: