home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
tass.lzh
/
sigs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-24
|
2KB
|
80 lines
#include <stdio.h>
#include "tass.h"
#ifdef APPEND_SIG
#ifdef RAND_SIG
static void
random_signature (buf, fpo, cnt)
char *buf;
FILE *fpo;
int cnt;
{
static int first = 1;
FILE *fp;
char inp[130];
int n;
sprintf (buf, "%s/.randsig", homedir);
if (! (fp = fopen (buf, "r")))
return;
if (first) {
srandom (time (0));
first = 0;
}
n = _gs_size (fileno (fp));
n = random () %
((n > (1 << 9)) ?
(n >> 7) :
((n > (1 << 5)) ?
(n >> 3) :
10));
while (n-- > 0) {
while (fgets (inp, 128, fp))
if (! strcmp (inp, "%%\n"))
break;
if (feof (fp)) {
clearerr (fp);
cleareof (fp);
rewind (fp);
continue;
}
}
while (fgets (inp, 128, fp) && (cnt-- > 0))
if (strcmp (inp, "%%\n"))
fputs (inp, fpo);
else
break;
fclose (fp);
}
#endif /* RAND_SIG */
void
add_signature (fp)
FILE *fp;
{
extern char *malloc ();
static char *fn = NULL;
FILE *fpi;
int cnt;
if (!fn) {
if (!(fn = malloc (250)))
return;
}
sprintf (fn, "%s/.signature", homedir);
cnt = 4 * 400;
if (fpi = fopen (fn, "r")) {
putc ('\n', fp);
while (fgets (fn, 200, fpi) && (cnt-- > 0))
fputs (fn, fp);
fclose (fpi);
}
#ifdef RAND_SIG
if (cnt > 0)
random_signature (fn, fp, cnt);
#endif /* RAND_SIG */
}
#endif /* APPEND_SIG */