X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Ftool%2Ftool.c;h=b00e235eb739039f8d6d66a519689cb7d299308e;hp=1bb3ebe698b0a6f106e09f5d1b85fea51e9f654b;hb=c5da48368569383d064a2325ab3b99d10287a085;hpb=44926b7f9ff031c37be48b33c314e47e2f84ff9f diff --git a/src/tool/tool.c b/src/tool/tool.c index 1bb3ebe6..b00e235e 100644 --- a/src/tool/tool.c +++ b/src/tool/tool.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2010 Alexander Barton (alex@barton.de) + * Copyright (c)2001-2014 Alexander Barton (alex@barton.de) and Contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * Tool functions */ -#include "imp.h" #include #include #include @@ -31,7 +30,6 @@ #include #endif -#include "exp.h" #include "tool.h" @@ -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;