Fix byte order confusion which broke on big endian platforms
[umurmur.git] / src / main.c
index 6d48f6e4656fd01544a6cb725c612e582237ca23..a4c1c12b3182045174f8af9e8ee0c106d6e8bcc9 100644 (file)
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/utsname.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <sched.h>
 #include <errno.h>
+#include <string.h>
+#include <stdlib.h>
 
 #include "server.h"
 #include "ssl.h"
@@ -47,6 +50,8 @@
 #include "conf.h"
 #include "version.h"
 
+char system_string[64], version_string[64];
+
 void lockfile(const char *pidfile)
 {
        int lfp;
@@ -134,6 +139,7 @@ int main(int argc, char **argv)
        bool_t realtime = false;
        char *conffile = NULL, *pidfile = NULL;
        int c;
+       struct utsname utsbuf;
        
        /* Arguments */
        while ((c = getopt(argc, argv, "drp:c:h")) != EOF) {
@@ -178,11 +184,22 @@ int main(int argc, char **argv)
        signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
        signal(SIGTTOU, SIG_IGN);
        signal(SIGTTIN, SIG_IGN);
+       signal(SIGPIPE, SIG_IGN);
        signal(SIGHUP, signal_handler); /* catch hangup signal */
        signal(SIGTERM, signal_handler); /* catch kill signal */
-
+       
+       /* Build system string */
+       if (uname(&utsbuf) == 0) {
+               snprintf(system_string, 64, "%s %s", utsbuf.sysname, utsbuf.machine);
+               snprintf(version_string, 64, "%s", utsbuf.release);
+       }
+       else {
+               snprintf(system_string, 64, "unknown unknown");
+               snprintf(version_string, 64, "unknown");
+       }
+       
        /* Initializing */
-       SSL_init();
+       SSLi_init();
        Chan_init();
        Client_init();
 
@@ -191,7 +208,7 @@ int main(int argc, char **argv)
        
        Server_run();
        
-       SSL_deinit();
+       SSLi_deinit();
        Chan_free();
        Log_free();
        Conf_deinit();