URI: 
       Adding reverse lookup to log entries. Thanks to James Penketh <tamber@furryhelix.co.uk>! - geomyidae - A small C-based gopherd.
  HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit a0495a999191b84a00f2586b7089c99947d0de93
   DIR parent cb73df5b7e3746edcb70fd57b462161efec5385a
  HTML Author: Christoph Lohmann <20h@r-36.net>
       Date:   Sun, 27 Feb 2011 12:32:54 +0100
       
       Adding reverse lookup to log entries. Thanks to James Penketh
       <tamber@furryhelix.co.uk>!
       
       Diffstat:
         M ind.c                               |      25 +++++++++++++++++++++++++
         M ind.h                               |       1 +
         M main.c                              |      13 ++++++-------
       
       3 files changed, 32 insertions(+), 7 deletions(-)
       ---
   DIR diff --git a/ind.c b/ind.c
       @@ -10,6 +10,10 @@
        #include <fcntl.h>
        #include <stdio.h>
        #include <stdlib.h>
       +#include <netdb.h>
       +#include <sys/socket.h>
       +#include <arpa/inet.h>
       +
        #include "ind.h"
        #include "handlr.h"
        
       @@ -285,3 +289,24 @@ smprintf(char *fmt, ...)
                return ret;
        }
        
       +char *
       +reverselookup(char *host)
       +{
       +        struct in_addr hoststr;
       +        struct hostent *client;
       +        char *rethost;
       +
       +        rethost = NULL;
       +
       +        if(inet_pton(AF_INET, host, &hoststr)) {
       +                client = gethostbyaddr(&hoststr, sizeof(hoststr), AF_INET);
       +                if(client != NULL)
       +                        rethost = strdup(client->h_name);
       +        }
       +
       +        if(rethost == NULL)
       +                rethost = strdup(host);
       +
       +        return rethost;
       +}
       +
   DIR diff --git a/ind.h b/ind.h
       @@ -43,6 +43,7 @@ void tprintf(int fd, char *fmt, ...);
        int initlogging(char *logf);
        void stoplogging(int fd);
        char *smprintf(char *fmt, ...);
       +char *reverselookup(char *host);
        
        #endif
        
   DIR diff --git a/main.c b/main.c
       @@ -19,6 +19,7 @@
        #include <time.h>
        #include <pwd.h>
        #include <grp.h>
       +
        #include "ind.h"
        #include "handlr.h"
        #include "arg.h"
       @@ -102,17 +103,19 @@ logentry(char *host, char *port, char *qry, char *status)
        {
                time_t tim;
                struct tm *ptr;
       -        char timstr[128];
       +        char timstr[128], *ahost;
        
                if(glfd >= 0) {
                        tim = time(0);
                        ptr = localtime(&tim);
        
       +                ahost = reverselookup(host);
                        strftime(timstr, sizeof(timstr), "%a %b %d %H:%M:%S %Z %Y",
                                                ptr);
        
                        tprintf(glfd, "[%s|%s:%s] %s (%s)\n",
       -                        timstr, host, port, qry, status);
       +                        timstr, ahost, port, qry, status);
       +                free(ahost);
                }
        
                return;
       @@ -364,11 +367,7 @@ main(int argc, char *argv[])
                        return 1;
                }
        
       -        if(dofork) {
       -                signal(SIGINT, SIG_IGN);
       -                signal(SIGQUIT, SIG_IGN);
       -        }
       -        signal(SIGCHLD, hndlsigchld);
       +        initsignals();
        
                cltlen = sizeof(clt);
                while(running) {