Deleted Added
full compact
newseed.c (37304) newseed.c (59121)
1/* newseed.c: The opienewseed() library function.
2
3%%% copyright-cmetz-96
1/* newseed.c: The opienewseed() library function.
2
3%%% copyright-cmetz-96
4This software is Copyright 1996-1997 by Craig Metz, All Rights Reserved.
4This software is Copyright 1996-1998 by Craig Metz, All Rights Reserved.
5The Inner Net License Version 2 applies to this software.
6You should have received a copy of the license with this software. If
7you didn't get a copy, you may request one from <license@inner.net>.
8
9 History:
10
5The Inner Net License Version 2 applies to this software.
6You should have received a copy of the license with this software. If
7you didn't get a copy, you may request one from <license@inner.net>.
8
9 History:
10
11 Modified by cmetz for OPIE 2.32. Added syslog.h if DEBUG.
11 Modified by cmetz for OPIE 2.31. Added time.h.
12 Created by cmetz for OPIE 2.22.
12 Modified by cmetz for OPIE 2.31. Added time.h.
13 Created by cmetz for OPIE 2.22.
14
15$FreeBSD: head/contrib/opie/libopie/newseed.c 59121 2000-04-10 11:18:54Z kris $
13*/
14
15#include "opie_cfg.h"
16#if HAVE_TIME_H
17#include <time.h>
18#endif /* HAVE_TIME_H */
19#if HAVE_STRING_H
20#include <string.h>
21#endif /* HAVE_STRING_H */
22#include <ctype.h>
23#if HAVE_UNISTD_H
24#include <unistd.h>
25#endif /* HAVE_UNISTD_H */
26#if HAVE_SYS_UTSNAME_H
27#include <sys/utsname.h>
28#endif /* HAVE_SYS_UTSNAME_H */
29#include <errno.h>
16*/
17
18#include "opie_cfg.h"
19#if HAVE_TIME_H
20#include <time.h>
21#endif /* HAVE_TIME_H */
22#if HAVE_STRING_H
23#include <string.h>
24#endif /* HAVE_STRING_H */
25#include <ctype.h>
26#if HAVE_UNISTD_H
27#include <unistd.h>
28#endif /* HAVE_UNISTD_H */
29#if HAVE_SYS_UTSNAME_H
30#include <sys/utsname.h>
31#endif /* HAVE_SYS_UTSNAME_H */
32#include <errno.h>
33#if DEBUG
34#include <syslog.h>
35#endif /* DEBUG */
30#include "opie.h"
31
32int opienewseed FUNCTION((seed), char *seed)
33{
34 if (!seed)
35 return -1;
36
37 if (seed[0]) {

--- 44 unchanged lines hidden (view full) ---

82 time(&now);
83 srand(now);
84 }
85
86 {
87 struct utsname utsname;
88
89 if (uname(&utsname) < 0) {
36#include "opie.h"
37
38int opienewseed FUNCTION((seed), char *seed)
39{
40 if (!seed)
41 return -1;
42
43 if (seed[0]) {

--- 44 unchanged lines hidden (view full) ---

88 time(&now);
89 srand(now);
90 }
91
92 {
93 struct utsname utsname;
94
95 if (uname(&utsname) < 0) {
90#if 0
91 perror("uname");
92#endif /* 0 */
96#if DEBUG
97 syslog(LOG_DEBUG, "uname: %s(%d)", strerror(errno), errno);
98#endif /* DEBUG */
93 utsname.nodename[0] = 'k';
94 utsname.nodename[1] = 'e';
95 }
96 utsname.nodename[2] = 0;
97
98 sprintf(seed, "%s%04d", utsname.nodename, (rand() % 9999) + 1);
99 return 0;
100 }
101 }
102}
103
99 utsname.nodename[0] = 'k';
100 utsname.nodename[1] = 'e';
101 }
102 utsname.nodename[2] = 0;
103
104 sprintf(seed, "%s%04d", utsname.nodename, (rand() % 9999) + 1);
105 return 0;
106 }
107 }
108}
109