]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/tool/tool.c
Remove imp.h and exp.h header files
[ngircd-alex.git] / src / tool / tool.c
index eb6c131e428462e81d3aad67075c721b429edd00..8fe6e05e9fa74d84b7675a29b7d9b3d0a3cba058 100644 (file)
@@ -16,7 +16,6 @@
  * Tool functions
  */
 
-#include "imp.h"
 #include <assert.h>
 #include <ctype.h>
 #include <stdio.h>
@@ -31,7 +30,6 @@
 #include <syslog.h>
 #endif
 
-#include "exp.h"
 #include "tool.h"
 
 
@@ -84,7 +82,7 @@ ngt_UpperStr(char *String)
 
        ptr = String;
        while(*ptr) {
-               *ptr = toupper(*ptr);
+               *ptr = toupper((int)*ptr);
                ptr++;
        }
        return String;
@@ -103,7 +101,7 @@ ngt_LowerStr(char *String)
 
        ptr = String;
        while(*ptr) {
-               *ptr = tolower(*ptr);
+               *ptr = tolower((int)*ptr);
                ptr++;
        }
        return String;
@@ -144,11 +142,16 @@ ngt_RandomStr(char *String, const size_t len)
        assert(String != NULL);
 
        gettimeofday(&t, NULL);
+#ifndef HAVE_ARC4RANDOM
        srand((unsigned)(t.tv_usec * t.tv_sec));
 
        for (i = 0; i < len; ++i) {
                String[i] = chars[rand() % (sizeof(chars) - 1)];
        }
+#else
+       for (i = 0; i < len; ++i)
+               String[i] = chars[arc4random() % (sizeof(chars) - 1)];
+#endif
        String[len] = '\0';
 
        return String;