1 /* newseed.c: The opienewseed() library function.
4 This software is Copyright 1996-1997 by Craig Metz, All Rights Reserved.
5 The Inner Net License Version 2 applies to this software.
6 You should have received a copy of the license with this software. If
7 you didn't get a copy, you may request one from <license@inner.net>.
11 Modified by cmetz for OPIE 2.31. Added time.h.
12 Created by cmetz for OPIE 2.22.
18 #endif /* HAVE_TIME_H */
21 #endif /* HAVE_STRING_H */
25 #endif /* HAVE_UNISTD_H */
26 #if HAVE_SYS_UTSNAME_H
27 #include <sys/utsname.h>
28 #endif /* HAVE_SYS_UTSNAME_H */
32 int opienewseed FUNCTION((seed), char *seed)
40 if ((i = strlen(seed)) >= OPIE_SEED_MIN) {
44 if (i > OPIE_SEED_MAX)
57 if (j = strtol(c, (char **)0, 10)) {
58 char buf[OPIE_SEED_MAX];
63 if (errno == ERANGE) {
66 int k = 1, l = OPIE_SEED_MAX - strlen(buf);
73 sprintf(seed, "%s%04ld", buf, j);
87 struct utsname utsname;
89 if (uname(&utsname) < 0) {
93 utsname.nodename[0] = 'k';
94 utsname.nodename[1] = 'e';
96 utsname.nodename[2] = 0;
98 sprintf(seed, "%s%04d", utsname.nodename, (rand() % 9999) + 1);