add $(GN_LIBINTL) to Makefile.am (fixes 0005902)
[oweals/gnunet.git] / src / regex / gnunet-daemon-regexprofiler.c
index 24919aebe79139862f1ba27f28f804aae8b167f7..fb061acc1897b53d5ab917dad74991c0713ff932 100644 (file)
@@ -2,21 +2,21 @@
      This file is part of GNUnet.
      Copyright (C) 2012, 2013 Christian Grothoff
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet 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.
+     Affero General Public License for more details.
 
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
-*/
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
 
 /**
  * @file regex/gnunet-daemon-regexprofiler.c
@@ -62,7 +62,7 @@ static struct REGEX_INTERNAL_Announcement *announce_handle;
 /**
  * Periodically reannounce regex.
  */
-static struct GNUNET_SCHEDULER_Task * reannounce_task;
+static struct GNUNET_SCHEDULER_Task *reannounce_task;
 
 /**
  * What's the maximum reannounce period.
@@ -78,12 +78,12 @@ static unsigned long long max_path_compression;
  * Name of the file containing policies that this peer should announce. One
  * policy per line.
  */
-static char * policy_filename;
+static char *policy_filename;
 
 /**
  * Prefix to add before every regex we're announcing.
  */
-static char * regex_prefix;
+static char *regex_prefix;
 
 /**
  * Regex with prefix.
@@ -101,7 +101,6 @@ static unsigned int rounds = 3;
 static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
 
 
-
 /**
  * Task run during shutdown.
  *
@@ -157,16 +156,17 @@ reannounce_regex (void *cls)
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing regex: %s\n", regex);
   GNUNET_STATISTICS_update (stats_handle, "# regexes announced", 1, GNUNET_NO);
-  if (NULL == announce_handle && NULL != regex)
+  if ((NULL == announce_handle) && (NULL != regex))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "First time, creating regex: %s\n",
                 regex);
     announce_handle = REGEX_INTERNAL_announce (dht_handle,
-                                              my_private_key,
-                                              regex,
-                                              (unsigned int) max_path_compression,
-                                              stats_handle);
+                                               my_private_key,
+                                               regex,
+                                               (unsigned
+                                                int) max_path_compression,
+                                               stats_handle);
   }
   else
   {
@@ -195,7 +195,7 @@ announce_regex (const char *regex)
 {
   char *copy;
 
-  if (NULL == regex || 0 == strlen (regex))
+  if ((NULL == regex) || (0 == strlen (regex)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot announce empty regex\n");
     return;
@@ -207,7 +207,7 @@ announce_regex (const char *regex)
   GNUNET_assert (NULL == reannounce_task);
   copy = GNUNET_strdup (regex);
   reannounce_task = GNUNET_SCHEDULER_add_now (&reannounce_regex,
-                                             (void *) copy);
+                                              (void *) copy);
 }
 
 
@@ -264,7 +264,8 @@ run (void *cls, char *const *args GNUNET_UNUSED,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 _
-                ("%s service is lacking key configuration settings (%s).  Exiting.\n"),
+                (
+                  "%s service is lacking key configuration settings (%s).  Exiting.\n"),
                 "regexprofiler", "max_path_compression");
     global_ret = GNUNET_SYSERR;
     GNUNET_SCHEDULER_shutdown ();
@@ -274,7 +275,8 @@ run (void *cls, char *const *args GNUNET_UNUSED,
       GNUNET_CONFIGURATION_get_value_string (cfg, "REGEXPROFILER",
                                              "POLICY_DIR", &policy_dir))
   {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "REGEXPROFILER", "POLICY_DIR");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "REGEXPROFILER",
+                               "POLICY_DIR");
     global_ret = GNUNET_SYSERR;
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -294,7 +296,8 @@ run (void *cls, char *const *args GNUNET_UNUSED,
       GNUNET_CONFIGURATION_get_value_string (cfg, "REGEXPROFILER",
                                              "REGEX_PREFIX", &regex_prefix))
   {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "REGEXPROFILER", "REGEX_PREFIX");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "REGEXPROFILER",
+                               "REGEX_PREFIX");
     global_ret = GNUNET_SYSERR;
     GNUNET_free (policy_dir);
     GNUNET_SCHEDULER_shutdown ();
@@ -345,16 +348,16 @@ run (void *cls, char *const *args GNUNET_UNUSED,
 
   /* Announcing regexes from policy_filename */
   GNUNET_asprintf (&rx_with_pfx,
-                  "%s(%s)(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)*",
-                  regex_prefix,
-                  regex);
+                   "%s(%s)(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)*",
+                   regex_prefix,
+                   regex);
   announce_regex (rx_with_pfx);
   GNUNET_free (regex);
   GNUNET_free (rx_with_pfx);
 
   /* Scheduled the task to clean up when shutdown is called */
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                NULL);
+                                 NULL);
 }
 
 
@@ -377,7 +380,8 @@ main (int argc, char *const *argv)
   return (GNUNET_OK ==
           GNUNET_PROGRAM_run (argc, argv, "regexprofiler",
                               gettext_noop
-                              ("Daemon to announce regular expressions for the peer using cadet."),
+                              (
+                                "Daemon to announce regular expressions for the peer using cadet."),
                               options, &run, NULL)) ? global_ret : 1;
 }
 
@@ -388,12 +392,15 @@ main (int argc, char *const *argv)
 /**
  * MINIMIZE heap size (way below 128k) since this process doesn't need much.
  */
-void __attribute__ ((constructor)) GNUNET_ARM_memory_init ()
+void __attribute__ ((constructor))
+GNUNET_ARM_memory_init ()
 {
   mallopt (M_TRIM_THRESHOLD, 4 * 1024);
   mallopt (M_TOP_PAD, 1 * 1024);
   malloc_trim (0);
 }
+
+
 #endif