14
9
#include <sys/types.h>
15
11
#include <sys/stat.h>
17
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD)
21
#if defined(HAVE_INT_32)
22
typedef unsigned int UINT32;
23
#elif defined(HAVE_LONG_32)
24
typedef unsigned long UINT32;
25
#elif defined(HAVE_SHORT_32)
26
typedef unsigned short UINT32;
29
#define TAUS_MAX 4294967295UL
31
static UINT32 taus_state[3];
33
static UINT32 taus_get ()
36
#define TAUSWORTHE(s,a,b,c,d) ((s &c) <<d) ^ (((s <<a) ^s) >>b)
37
taus_state[0] = TAUSWORTHE (taus_state[0], 13, 19, 4294967294UL, 12);
38
taus_state[1] = TAUSWORTHE (taus_state[1], 2, 25, 4294967288UL, 4);
39
taus_state[2] = TAUSWORTHE (taus_state[2], 3, 11, 4294967280UL, 17);
40
return (taus_state[0] ^ taus_state[1] ^ taus_state[2]);
43
static void taus_seed ()
45
unsigned char buf[12];
46
unsigned char buf2[12];
47
unsigned char buf3[12];
49
size_t nbytes = sizeof(buf);
52
struct timeval t1, t2;
56
int fd = open ("/dev/urandom", O_RDONLY);
60
gettimeofday(&t1, NULL);
62
memcpy(&buf[0], &delta, 4);
63
gettimeofday(&t1, NULL);
65
memcpy(&buf[4], &delta, 4);
66
gettimeofday(&t1, NULL);
68
memcpy(&buf[8], &delta, 4);
73
count = read(fd, &buf[where], nbytes);
74
if (count == -1 && errno == EINTR)
78
} while (count == -1 && errno == EINTR);
83
for (i = 0; i < 12; ++i)
85
gettimeofday(&t1, NULL);
89
gettimeofday(&t2, NULL);
90
delta = t2.tv_usec - t1.tv_usec;
91
buf2[i] = (unsigned char) delta;
94
for (i = 0; i < 12; ++i)
96
gettimeofday(&t1, NULL);
97
for (j = 0; j < 32768; ++j)
102
gettimeofday(&t2, NULL);
103
delta = t2.tv_usec - t1.tv_usec;
104
buf3[i] ^= (unsigned char) delta;
107
memcpy(&taus_state[0], &buf3[0], 4);
108
memcpy(&taus_state[1], &buf3[4], 4);
109
memcpy(&taus_state[2], &buf3[8], 4);
111
taus_state[0] ^= k[0];
112
taus_state[1] ^= k[1];
113
taus_state[2] ^= k[2];
115
memcpy(&k[0], &buf2[0], 4);
116
memcpy(&k[1], &buf2[4], 4);
117
memcpy(&k[2], &buf2[8], 4);
119
taus_state[0] ^= k[0];
120
taus_state[1] ^= k[1];
121
taus_state[2] ^= k[2];
123
memcpy(&k[0], &buf[0], 4);
124
memcpy(&k[1], &buf[4], 4);
125
memcpy(&k[2], &buf[8], 4);
127
taus_state[0] ^= k[0];
128
taus_state[1] ^= k[1];
129
taus_state[2] ^= k[2];
131
taus_state[0] |= (UINT32) 0x03;
132
taus_state[1] |= (UINT32) 0x09;
133
taus_state[2] |= (UINT32) 0x17;
21
char * globber(char * string);
137
char * globber(const char * string);
22
138
#define _(string) globber(string)
23
139
#define N_(string) string
206
323
oldf = open(argv[1], O_RDONLY);
208
newn = (char *) malloc (strlen(argv[1])+strlen(argv[2])+2);
209
strcpy(newn, argv[1]);
211
strcat(newn, argv[2]);
325
nlen = strlen(argv[1])+strlen(argv[2])+2;
326
newn = (char *) malloc (nlen);
327
strncpy(newn, argv[1], nlen); newn[nlen-1] = '\0';
328
strncat(newn, ".", nlen); newn[nlen-1] = '\0';
329
strncat(newn, argv[2], nlen); newn[nlen-1] = '\0';
212
330
newf = open(newn, O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU);
216
334
fprintf(stdout, _("ERROR Cannot open input file %s.\n"), argv[1]);
222
340
fprintf(stdout, _("ERROR Cannot open output file %s.\n"), newn);
227
345
/* ---- scan file -----