X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fmagic.c;h=8e08e47ef5bb0ed528fe3fcfb269069e596af8f4;hb=5191399f5266bb595f03f5c4fee13153092e2baf;hp=2e0426c5c6af9839469c7568206541a6977a1138;hpb=f53a48eb9d74db3c71938e114b7f489c339bc003;p=ppp.git diff --git a/pppd/magic.c b/pppd/magic.c index 2e0426c..8e08e47 100644 --- a/pppd/magic.c +++ b/pppd/magic.c @@ -40,9 +40,8 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: magic.c,v 1.10 2002/12/04 23:03:32 paulus Exp $" - #include +#include #include #include #include @@ -50,10 +49,9 @@ #include "pppd.h" #include "magic.h" -static const char rcsid[] = RCSID; -extern long mrand48 __P((void)); -extern void srand48 __P((long)); +extern long mrand48 (void); +extern void srand48 (long); /* * magic_init - Initialize the magic number generator. @@ -63,7 +61,7 @@ extern void srand48 __P((long)); * and current time, currently. */ void -magic_init() +magic_init(void) { long seed; struct timeval t; @@ -77,11 +75,23 @@ magic_init() * magic - Returns the next magic number. */ u_int32_t -magic() +magic(void) { return (u_int32_t) mrand48(); } +/* + * random_bytes - Fill a buffer with random bytes. + */ +void +random_bytes(unsigned char *buf, int len) +{ + int i; + + for (i = 0; i < len; ++i) + buf[i] = mrand48() >> 24; +} + #ifdef NO_DRAND48 /* * Substitute procedures for those systems which don't have @@ -89,20 +99,19 @@ magic() */ double -drand48() +drand48(void) { return (double)random() / (double)0x7fffffffL; /* 2**31-1 */ } long -mrand48() +mrand48(void) { return random(); } void -srand48(seedval) -long seedval; +srand48(long seedval) { srandom((int)seedval); }