[pisa-src] r1872 - in trunk/pairing: accept.c common.c common.h libconfig_wrapper.c management.c packet_handler.c send.c

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Fri, 27 Nov 2009 15:07:42 +0100

Author: biurrun
Date: Fri Nov 27 15:07:42 2009
New Revision: 1872

Log:
Rename DEBUG macro to DEBUG_PRINT. The former is much too generic.

Modified:
   trunk/pairing/accept.c
   trunk/pairing/common.c
   trunk/pairing/common.h
   trunk/pairing/libconfig_wrapper.c
   trunk/pairing/management.c
   trunk/pairing/packet_handler.c
   trunk/pairing/send.c

Modified: trunk/pairing/accept.c
==============================================================================
--- trunk/pairing/accept.c      Fri Nov 27 14:58:46 2009        (r1871)
+++ trunk/pairing/accept.c      Fri Nov 27 15:07:42 2009        (r1872)
@@ -79,7 +79,7 @@
     const char *name;
 
     changes = 0;
-    DEBUG("Checking expiration dates...");
+    DEBUG_PRINT("Checking expiration dates...");
 
     hitlist_allowed_hosts = pisa_hitlist_build("allowed_hosts");
 
@@ -100,13 +100,13 @@
             config_setting_t *parent= config_setting_parent(g);
             name = config_setting_get_string(config_setting_get_member(g, 
"hit"));
 
-            DEBUG("HIT: %s",name);
-            DEBUG("With expiration date: %s expired.",buffer);
-            DEBUG("Removing HIT.");
+            DEBUG_PRINT("HIT: %s",name);
+            DEBUG_PRINT("With expiration date: %s expired.",buffer);
+            DEBUG_PRINT("Removing HIT.");
 
             if(config_setting_remove_elem(parent,config_setting_index(g)) != 
CONFIG_TRUE)
             {
-                DEBUG("Error removing HIT");
+                DEBUG_PRINT("Error removing HIT");
             }
             changes = 1;
         }
@@ -115,7 +115,7 @@
     // Save changes
     if (changes)
     {
-        DEBUG("Saving changes to authorized hosts file.");
+        DEBUG_PRINT("Saving changes to authorized hosts file.");
         pisa_cfg_write_authorized_hosts_file();
     }
 
@@ -136,7 +136,7 @@
 
     if (!open_socket_accept())
     {
-        DEBUG("Socket could not be created. Leaving program.\n");
+        DEBUG_PRINT("Socket could not be created. Leaving program.\n");
         return 1;
     }
 
@@ -146,7 +146,7 @@
 
     if (signal(SIGALRM, check_expiration_dates) == SIG_ERR)
     {
-        DEBUG("Cannot register signal handler");
+        DEBUG_PRINT("Cannot register signal handler");
     }
     check_expiration_dates(SIGALRM);
 
@@ -166,7 +166,7 @@
 
             // Get peer address, determine if it's a HIT
             inet_ntop(AF_INET6, &peer_addr.sin6_addr, address_string, 
sizeof(address_string));
-            DEBUG("Address of sender is %s", address_string);
+            DEBUG_PRINT("Address of sender is %s", address_string);
             if (!pisa_ipv6_addr_is_hit(&peer_addr.sin6_addr))
                 DEBUG_HIGH("Address is IPv6.");
             else

Modified: trunk/pairing/common.c
==============================================================================
--- trunk/pairing/common.c      Fri Nov 27 14:58:46 2009        (r1871)
+++ trunk/pairing/common.c      Fri Nov 27 15:07:42 2009        (r1872)
@@ -107,13 +107,13 @@
                               CONFIG_TYPE_INT, &default_expiration_int, 0);
     if (temp == 0)  // Something failed in reading, debug printed by 
get_config_setting
     {
-        DEBUG("User not remembered.");
+        DEBUG_PRINT("User not remembered.");
         return 0;
     }
     if (default_expiration_int == 0)
     {
-        DEBUG("Could not read setting 
\'connection_settings.default_connection_expiration\' in file %s", filename);
-        DEBUG("User not remembered.");
+        DEBUG_PRINT("Could not read setting 
\'connection_settings.default_connection_expiration\' in file %s", filename);
+        DEBUG_PRINT("User not remembered.");
         return 0;
     }
 
@@ -140,7 +140,7 @@
     c = strptime(expiration_date, EXPIRATION_DATE_FORMAT, tm_expiration);
     if ((c == NULL) || (*c != 0))    // If c does not point to the terminating 
character of the string
     {               // then strptime did not make it all of the way through 
the string.
-        DEBUG("Could not parse time-and-date string.");
+        DEBUG_PRINT("Could not parse time-and-date string.");
         return 0;
     }else
     {

Modified: trunk/pairing/common.h
==============================================================================
--- trunk/pairing/common.h      Fri Nov 27 14:58:46 2009        (r1871)
+++ trunk/pairing/common.h      Fri Nov 27 15:07:42 2009        (r1872)
@@ -70,31 +70,31 @@
 
 /* Use the line below in the DEBUG macro to make the filename, function name, 
and line # appear in debug output */
 /*     printf("Debug: %s:%s:%d:\t" fmt "\n",__FILE__, __FUNCTION__ , __LINE__ 
, ## args) */
-#define DEBUG(fmt, args...) \
+#define DEBUG_PRINT(fmt, args...) \
        printf("Debug: " fmt "\n", ## args)
 
 #define CHECK_FOR_NULL_HDR(hdr) \
-       if (hdr == NULL) { DEBUG("Header could not be created. Exiting."); 
return 0; }
+       if (hdr == NULL) { DEBUG_PRINT("Header could not be created. 
Exiting."); return 0; }
 
 #define DEBUG_EMPTY do { } while(0)
 
 
 #if DEBUG_LEVEL >= DEBUG_LEVEL_HIGH
-       #define DEBUG_HIGH(fmt, args...) DEBUG(fmt, ## args)
+       #define DEBUG_HIGH(fmt, args...) DEBUG_PRINT(fmt, ## args)
 #else
        #define DEBUG_HIGH(fmt, args...) DEBUG_EMPTY
 #endif
 
 
 #if DEBUG_LEVEL >= DEBUG_LEVEL_MED
-       #define DEBUG_MED(fmt, args...) DEBUG(fmt, ## args)
+       #define DEBUG_MED(fmt, args...) DEBUG_PRINT(fmt, ## args)
 #else
        #define DEBUG_MED(fmt, args...) DEBUG_EMPTY
 #endif
 
 
 #if DEBUG_LEVEL >= DEBUG_LEVEL_LOW
-       #define DEBUG_LOW(fmt, args...) DEBUG(fmt, ## args)
+       #define DEBUG_LOW(fmt, args...) DEBUG_PRINT(fmt, ## args)
 #else
        #define DEBUG_LOW(fmt, args...) DEBUG_EMPTY
 #endif

Modified: trunk/pairing/libconfig_wrapper.c
==============================================================================
--- trunk/pairing/libconfig_wrapper.c   Fri Nov 27 14:58:46 2009        (r1871)
+++ trunk/pairing/libconfig_wrapper.c   Fri Nov 27 15:07:42 2009        (r1872)
@@ -100,7 +100,7 @@
 
     if (!valid_addr(info))
     {
-        DEBUG("Tried to add invalid HIT \'%s\'. HIT not written. Exiting 
function.", info);
+        DEBUG_PRINT("Tried to add invalid HIT \'%s\'. HIT not written. Exiting 
function.", info);
         return 0;
     }
 
@@ -111,19 +111,19 @@
     {
         hit_existed = 1;
         current_expiration = config_setting_get_member(con->group, "expires");
-        DEBUG("HIT found.");
+        DEBUG_PRINT("HIT found.");
     }
 
 
     if (hit_existed == 1)      // Update old entry
     {
-        DEBUG("Update expiration date for HIT");
+        DEBUG_PRINT("Update expiration date for HIT");
         config_setting_set_string(current_expiration, expiration);
     }
     else                       // Create new entry
     {
-        DEBUG("HIT not found");
-        DEBUG("Adding new entry to config");
+        DEBUG_PRINT("HIT not found");
+        DEBUG_PRINT("Adding new entry to config");
 
         allowed_hosts = check_list("allowed_hosts");
 
@@ -161,12 +161,12 @@
         parent= config_setting_parent(g);
         name = config_setting_get_string(config_setting_get_member(g, "hit"));
 
-        DEBUG("HIT: %s",name);
-        DEBUG("Removing HIT.");
+        DEBUG_PRINT("HIT: %s",name);
+        DEBUG_PRINT("Removing HIT.");
 
         if(config_setting_remove_elem(parent,config_setting_index(g)) != 
CONFIG_TRUE)
         {
-            DEBUG("Error removing HIT");
+            DEBUG_PRINT("Error removing HIT");
         }
 
         if(!pisa_cfg_write_authorized_hosts_file())
@@ -220,7 +220,7 @@
         }
     default:
         {
-            DEBUG("Invalid information type.");
+            DEBUG_PRINT("Invalid information type.");
             return 0;
         }
     }
@@ -258,7 +258,7 @@
        config_init(&cfg);
        if (!config_read_file(&cfg, filename))
        {
-               DEBUG("Could not read file \'%s\'.", filename);
+               DEBUG_PRINT("Could not read file \'%s\'.", filename);
                return 0;
        }
 
@@ -279,7 +279,7 @@
                        success = config_lookup_string(&cfg, path, &temp);
                        if (success != CONFIG_TRUE || temp == NULL)
                        {
-                               DEBUG("Problem getting setting at path \'%s\' 
from file \'%s\'.", path, filename);
+                               DEBUG_PRINT("Problem getting setting at path 
\'%s\' from file \'%s\'.", path, filename);
                                return 0;
                        }
                        strncpy(*(char **)return_val, temp, len);

Modified: trunk/pairing/management.c
==============================================================================
--- trunk/pairing/management.c  Fri Nov 27 14:58:46 2009        (r1871)
+++ trunk/pairing/management.c  Fri Nov 27 15:07:42 2009        (r1872)
@@ -912,7 +912,7 @@
     {
         if (new_entry->active != 2)
         {
-            DEBUG("Changed active status.");
+            DEBUG_PRINT("Changed active status.");
             config_setting_set_bool(current_active, new_entry->active);
 
             // Add or Remove HIT from authorized_hosts.cfg because active 
changed
@@ -1006,7 +1006,7 @@
 
     if (config_setting_remove_elem(parent, config_setting_index(group)) != 
CONFIG_TRUE)
     {
-        DEBUG("Error removing HIT");
+        DEBUG_PRINT("Error removing HIT");
         return 0;
     }
 

Modified: trunk/pairing/packet_handler.c
==============================================================================
--- trunk/pairing/packet_handler.c      Fri Nov 27 14:58:46 2009        (r1871)
+++ trunk/pairing/packet_handler.c      Fri Nov 27 15:07:42 2009        (r1872)
@@ -51,7 +51,7 @@
 {
        if (error_string == NULL)
        {
-               DEBUG("No error string given. Error structure was not 
created.");
+               DEBUG_PRINT("No error string given. Error structure was not 
created.");
                return NULL;
        }
 
@@ -89,7 +89,7 @@
         config_init(&cfg);
         if (!config_read_file(&cfg, FILE_SERVER_CONFIG))
         {
-                DEBUG("Error reading %s on line %d: %s\n", FILE_SERVER_CONFIG, 
cfg.error_line, cfg.error_text);
+                DEBUG_PRINT("Error reading %s on line %d: %s\n", 
FILE_SERVER_CONFIG, cfg.error_line, cfg.error_text);
                 return NULL;
         }
 
@@ -186,7 +186,7 @@
         // Open file
         if ((file = fopen(FILE_PWD, "r")) == NULL)
         {
-                DEBUG("Cannot open password file.\n");
+                DEBUG_PRINT("Cannot open password file.\n");
                 return 0;
         }
 
@@ -202,7 +202,7 @@
 
         // Close file
         if (fclose(file))
-                DEBUG("File close error.\n");
+                DEBUG_PRINT("File close error.\n");
 
         return (result == 0) ? 1 : 0 ;
 
@@ -367,7 +367,7 @@
 
         if (!config_read_file(&cfg, FILE_SERVER_CONFIG))
         {
-            DEBUG("Could not read file \'%s\'.", FILE_SERVER_CONFIG);
+            DEBUG_PRINT("Could not read file \'%s\'.", FILE_SERVER_CONFIG);
             return 0;
         }
 
@@ -375,7 +375,7 @@
         unknown_user_count_setting = config_lookup(&cfg, 
"pwd_request_settings.unknown_user_count");
         if (!unknown_user_count_setting)
         {
-            DEBUG("Error reading unknown user count setting from file %s.", 
FILE_SERVER_CONFIG);
+            DEBUG_PRINT("Error reading unknown user count setting from file 
%s.", FILE_SERVER_CONFIG);
             return 0;
         }
 
@@ -389,7 +389,7 @@
         unknown_user_count_int++;
         if (config_setting_set_int(unknown_user_count_setting, 
unknown_user_count_int) != CONFIG_TRUE)
         {
-            DEBUG("Error setting unknown user count.");
+            DEBUG_PRINT("Error setting unknown user count.");
             return 0;
         }
 
@@ -397,7 +397,7 @@
 
         if (config_write_file(&cfg, FILE_SERVER_CONFIG) == CONFIG_FALSE)
         {
-            DEBUG("Error writing to file %s.", FILE_SERVER_CONFIG);
+            DEBUG_PRINT("Error writing to file %s.", FILE_SERVER_CONFIG);
             return 0;
         }
         config_destroy(&cfg);
@@ -505,7 +505,7 @@
 
         if (!config_read_file(&cfg, FILE_KNOWN_RELAYS))
         {
-                DEBUG("Could not read file \'%s\'.", FILE_KNOWN_RELAYS);
+                DEBUG_PRINT("Could not read file \'%s\'.", FILE_KNOWN_RELAYS);
                 return 0;
         }
 
@@ -577,7 +577,7 @@
                 this_relay = config_setting_add(root, new_nickname, 
CONFIG_TYPE_GROUP);
                 if (this_relay == NULL)
                 {
-                        DEBUG("Setting could not be created. Exiting 
function.");
+                        DEBUG_PRINT("Setting could not be created. Exiting 
function.");
                         return 0;
                 }
 
@@ -587,27 +587,27 @@
                 new_ipv6_addr = config_setting_add(this_relay, "ipv6_addr", 
CONFIG_TYPE_STRING);
         }
 
-        DEBUG("Writing new relay information.");
+        DEBUG_PRINT("Writing new relay information.");
 
         // Write relay information
         // Write HIT
         if (new_hit)
                 config_setting_set_string(new_hit, hit);
         else
-                DEBUG("Error writing HIT.");
+                DEBUG_PRINT("Error writing HIT.");
         // Write IPv4 address
         if (new_ipv4_addr)
                 config_setting_set_string(new_ipv4_addr, ipv4_addr);
         else
-                DEBUG("Error writing IPv4 address.");
+                DEBUG_PRINT("Error writing IPv4 address.");
         // Write IPv6 address
         if (new_ipv6_addr)
                 config_setting_set_string(new_ipv6_addr, ipv6_addr);
         else
-                DEBUG("Error writing IPv6 address.");
+                DEBUG_PRINT("Error writing IPv6 address.");
 
         // Write the configuration back to the file
-        DEBUG("Write file");
+        DEBUG_PRINT("Write file");
         config_write_file(&cfg, FILE_KNOWN_RELAYS);
         config_destroy(&cfg);
 
@@ -740,7 +740,7 @@
                        DEBUG_MED("Received an error packet.");
                        temp = handle_packet_error(socket_addr, 
&(gen_hdr->msg.header_error));
                        break;
-               default: DEBUG("Packet format unrecognized. Packet ignored.");
+               default: DEBUG_PRINT("Packet format unrecognized. Packet 
ignored.");
                        return 0;
        }
 

Modified: trunk/pairing/send.c
==============================================================================
--- trunk/pairing/send.c        Fri Nov 27 14:58:46 2009        (r1871)
+++ trunk/pairing/send.c        Fri Nov 27 15:07:42 2009        (r1872)
@@ -277,7 +277,7 @@
                // Read config file
                if (!config_read_file(&cfg, FILE_KNOWN_RELAYS))
                {
-                       DEBUG("Could not read file \'%s\'.", FILE_KNOWN_RELAYS);
+                       DEBUG_PRINT("Could not read file \'%s\'.", 
FILE_KNOWN_RELAYS);
                        return 0;
                }
 
@@ -295,11 +295,11 @@
                        success = config_lookup_string(&cfg, path, (const char 
**)&temp);
                        if (success != CONFIG_TRUE || temp == NULL)
                        {
-                               DEBUG("No HIT found for relay %s.", nickname);
+                               DEBUG_PRINT("No HIT found for relay %s.", 
nickname);
                                return 0;
                        }
                        strncpy(hit, temp, INET6_ADDRSTRLEN);
-                       DEBUG("Using HIT for relay %s: %s", nickname, hit);
+                       DEBUG_PRINT("Using HIT for relay %s: %s", nickname, 
hit);
 
                        // Look up the IPv6 address
                        strcpy(path, nickname);         // Construct the path
@@ -307,11 +307,11 @@
                        success = config_lookup_string(&cfg, path, (const char 
**)&temp);
                        if (success != CONFIG_TRUE || temp == NULL)
                        {
-                               DEBUG("No IPv6 address found for relay %s.", 
nickname);
+                               DEBUG_PRINT("No IPv6 address found for relay 
%s.", nickname);
                                return 0;
                        }
                        strncpy(ipv6_addr, temp, INET6_ADDRSTRLEN);
-                       DEBUG("Using IPv6 address for relay %s: %s", nickname, 
ipv6_addr);
+                       DEBUG_PRINT("Using IPv6 address for relay %s: %s", 
nickname, ipv6_addr);
                }
                else            // Give an error
                {
@@ -364,7 +364,7 @@
 
        if ((hit == NULL) || (ipv6_addr == NULL))
        {
-               DEBUG("Missing essential information (HIT or IPv6 address). 
Socket was not opened.");
+               DEBUG_PRINT("Missing essential information (HIT or IPv6 
address). Socket was not opened.");
                return NULL;
        }
 
@@ -424,7 +424,7 @@
 {
         if (password == NULL)
         {
-                DEBUG("No password given. Password structure was not 
created.");
+                DEBUG_PRINT("No password given. Password structure was not 
created.");
                 return NULL;
         }
 

Other related posts:

  • » [pisa-src] r1872 - in trunk/pairing: accept.c common.c common.h libconfig_wrapper.c management.c packet_handler.c send.c - Diego Biurrun