: nply/fiche2

commit 7e33e463bbd38a3029bdd3f82cc2fdb5a344ddd8
parent f7926b75fc36c189f47de8e7db47f1bd36f2d1d6
Author: Björn Ketelaars <bjorn.ketelaars@hydroxide.nl>
Date: Sat, 19 Sep 2015 17:29:40 +0200

remove info(), instead used printf's. Check for DAEMON at some stages
2 files changed, 20 insertions(+), 21 deletions(-)
M
fiche.c
|
40
++++++++++++++++++++--------------------
M
fiche.h
|
1
-
diff --git a/fiche.c b/fiche.c
@@ -170,7 +170,7 @@ struct client_data get_client_address(struct sockaddr_in client_address)
     hostp = gethostbyaddr((const char *)&client_address.sin_addr.s_addr, sizeof(client_address.sin_addr.s_addr), AF_INET);
     if (hostp == NULL)
     {
-        info("WARNING: Couldn't obtain client's hostname\n");
+        printf("WARNING: Couldn't obtain client's hostname\n");
         data.hostname = "n/a";
     }
     else

@@ -179,7 +179,7 @@ struct client_data get_client_address(struct sockaddr_in client_address)
     hostaddrp = inet_ntoa(client_address.sin_addr);
     if (hostaddrp == NULL)
     {
-        info("WARNING: Couldn't obtain client's address\n");
+        printf("WARNING: Couldn't obtain client's address\n");
         data.ip_address = "n/a";
     }
     else

@@ -208,12 +208,17 @@ void save_log(char *slug, char *hostaddrp, char *h_name)
 
 void display_info(struct client_data data, char *slug, char *message)
 {
+    if (DAEMON)
+        return;
+
     if (slug == NULL)
-        info("%s\n", message);
-    else info("Saved to: %s\n", slug);
-    info("%s\n", get_date());
-    info("Client: %s (%s)\n", data.ip_address, data.hostname);
-    info("====================================\n");
+        printf("%s\n", message);
+    else
+        printf("Saved to: %s\n", slug);
+
+    printf("%s\n", get_date());
+    printf("Client: %s (%s)\n", data.ip_address, data.hostname);
+    printf("====================================\n");
 }
 
 char *check_banlist(char *ip_address)

@@ -372,22 +377,17 @@ void set_basedir()
 
 void startup_message()
 {
-    info("====================================\n");
-    info("Domain name: %s\n", DOMAIN);
-    info("Saving files to: %s\n", BASEDIR);
-    info("Fiche started listening on port %d.\n", PORT);
-    info("Buffer size set to: %d.\n", BUFSIZE);
-    info("Slug size set to: %d.\n", SLUG_SIZE);
-    info("Log file: %s\n", LOG);
-    info("====================================\n");
-}
-
-void info(char *buffer, ...)
-{
     if (DAEMON)
         return;
 
-    printf(buffer);
+    printf("====================================\n");
+    printf("Domain name: %s\n", DOMAIN);
+    printf("Saving files to: %s\n", BASEDIR);
+    printf("Fiche started listening on port %d.\n", PORT);
+    printf("Buffer size set to: %d.\n", BUFSIZE);
+    printf("Slug size set to: %d.\n", SLUG_SIZE);
+    printf("Log file: %s\n", LOG);
+    printf("====================================\n");
 }
 
 void parse_parameters(int argc, char **argv)
diff --git a/fiche.h b/fiche.h
@@ -92,7 +92,6 @@ void parse_parameters(int argc, char **argv);
 void save_log(char *slug, char *hostaddrp, char *h_name);
 void change_owner(char *directory);
 void set_uid_gid();
-void info(char *buffer, ...);
 
 char *check_banlist(char *ip_address);
 char *check_whitelist(char *ip_address);