2 * fake - make up random lines resembling history-file entries, reproducibly
12 #define MAXSTR 500 /* For sizing strings -- DON'T use BUFSIZ! */
13 #define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
15 int midonly
= 0; /* just message ids, rest not realistic */
16 int tag
= 0; /* tag lines with random digit for later use */
17 int expired
= -1; /* percentage of lines to be expired */
22 char *inname
; /* filename for messages etc. */
23 long lineno
; /* line number for messages etc. */
30 - main - parse arguments and handle options
50 while ((c
= getopt(argc
, argv
, "ms:te:d")) != EOF
)
52 case 'm': /* message-ids only */
58 case 't': /* tag lines with a random digit */
61 case 'e': /* percentage to be expired */
62 expired
= atoi(optarg
);
64 case 'd': /* Debugging. */
72 if (errflg
|| optind
!= argc
- 1) {
73 fprintf(stderr
, "usage: %s ", progname
);
74 fprintf(stderr
, "[-m] [-s seed] length\n");
78 for (no
= atol(argv
[optind
]); no
> 0; no
--) {
89 - doline - generate random history pseudo-line
97 (void) strcpy(buf
, "<");
98 addchars(buf
, range(4, 20));
99 (void) strcat(buf
, "@");
100 addchars(buf
, range(8, 20));
102 (void) strcat(buf
, ">\tx");
105 tagch
[0] = "1234567890"[range(0,9)];
107 (void) strcat(buf
, ">\t");
108 (void) strcat(buf
, tagch
);
109 (void) strcat(buf
, "00000000~-");
111 (void) strcat(buf
, ">\t1234567890~-");
113 if (range(1, 100) > expired
) {
115 (void) strcat(buf
, "\tx");
117 (void) strcat(buf
, "\t");
118 addchars(buf
, range(10, 30));
124 - addchars - generate n random characters suitable for history file
132 register char *p
= buf
+ strlen(buf
);
133 static char vocab
[] = "1234567890.abcde.fghij.klmno.pqrst.uvwxyz.\
134 1234567890.ABCDE.FGHIJ.KLMNO.PQRST.UVWXYZ.1234567890.\
135 1234567890.abcde.fghij.klmno.pqrst.uvwxyz.1234567890";
137 for (i
= len
; i
> 0; i
--)
138 *p
++ = vocab
[range(0, sizeof(vocab
)-2)];