-
Notifications
You must be signed in to change notification settings - Fork 3
/
cyberlaurent.c
387 lines (348 loc) · 17.7 KB
/
cyberlaurent.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
/*
* Copyright (c) 2002-2009 Frank DENIS <j at pureftpd dot org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
typedef enum Type_ {
T_WHAT = 1 << 0,
T_MALE = 1 << 1,
T_MALES = 1 << 2,
T_FEMALE = 1 << 3,
T_FEMALES = 1 << 4,
T_SUBJ = 1 << 5,
T_SUBJP = 1 << 6,
T_ACT = 1 << 7,
T_ACT1 = 1 << 8,
T_ACT1P = 1 << 9,
T_ACT2 = 1 << 10,
T_ACT2P = 1 << 11,
T_ADJ = 1 << 12,
T_LINK = 1 << 13,
T_VERB = 1 << 14,
T_SING = 1 << 15,
T_PLURAL = 1 << 16,
T_CC = 1 << 17,
T_CCBEG = 1 << 18,
T_CCFIN = 1 << 19,
T_OPTION = 1 << 31
} Type;
typedef struct Word_ {
const char *text;
const Type type;
int usage;
} Word;
typedef Type Grammar[64];
Word words[] = {
{ "l'iron", T_WHAT | T_SUBJ | T_MALE | T_SING, 0 },
{ "le firmware", T_WHAT | T_SUBJ | T_MALE | T_SING, 0 },
{ "les ports", T_SUBJ | T_MALES | T_PLURAL, 0 },
{ "des serveurs", T_SUBJP | T_MALES | T_PLURAL, 0 },
{ "sont passes en mode", T_ACT1 | T_MALES | T_PLURAL, 0 },
{ "a ete switche en mode", T_ACT1 | T_MALE | T_SING, 0 },
{ "testing", T_ACT1P | T_MALE | T_MALES | T_FEMALE | T_FEMALES, 0 },
{ "pooling", T_ACT1P | T_MALE | T_MALES | T_FEMALE | T_FEMALES, 0 },
{ "corporate", T_ACT1P | T_MALE | T_MALES | T_FEMALE | T_FEMALES, 0 },
{ "actif", T_ADJ | T_ACT1P | T_MALE, 0 },
{ "actives", T_ADJ | T_ACT1P | T_FEMALES, 0 },
{ "mais", T_LINK, 0 },
{ "donc", T_LINK, 0 },
{ "or", T_LINK, 0 },
{ "pourtant", T_LINK, 0 },
{ "cependant", T_LINK, 0 },
{ "pour couronner le tout", T_LINK, 0 },
{ "si bien que", T_LINK, 0 },
{ "a priori,", T_LINK, 0 },
{ "au passage,", T_LINK, 0 },
{ "d'ailleurs,", T_LINK, 0 },
{ "au fait,", T_LINK, 0 },
{ "et", T_LINK, 0 },
{ "c'est pour ca que", T_LINK, 0 },
{ "le serveur", T_WHAT | T_SUBJ | T_MALE | T_SING, 0 },
{ "ne renvoit pas", T_VERB | T_SING, 0 },
{ "n'envoient pas", T_VERB | T_PLURAL, 0 },
{ "les requetes", T_WHAT | T_SUBJ | T_FEMALES | T_PLURAL, 0 },
{ "rollback", T_ACT1P, 0 },
{ "un rollback", T_WHAT | T_SUBJ | T_MALE | T_SING, 0 },
{ "des warm restart", T_WHAT | T_SUBJ | T_MALES | T_PLURAL, 0 },
{ "de spare", T_ADJ | T_MALE | T_FEMALE | T_MALES | T_FEMALES, 0 },
{ "virtuel", T_ADJ | T_MALE, 0 },
{ "est toujours", T_ACT2 | T_SING | T_MALE | T_FEMALE, 0 },
{ "sont encore", T_ACT2 | T_PLURAL | T_MALES | T_FEMALES, 0 },
{ "down", T_ACT2P | T_MALE | T_FEMALE | T_MALES | T_FEMALES, 0 },
{ "up", T_ACT2P | T_MALE | T_FEMALE | T_MALES | T_FEMALES, 0 },
{ "off", T_ACT2P | T_MALE | T_FEMALE | T_MALES | T_FEMALES, 0 },
{ "du flapping", T_WHAT | T_MALE | T_SING, 0 },
{ "du pointcasting", T_WHAT | T_MALE | T_SING, 0 },
{ "un debriefing", T_SUBJ | T_MALE | T_SING, 0 },
{ "les logs", T_SUBJ | T_MALES | T_PLURAL, 0 },
{ "des logs", T_WHAT | T_MALES | T_PLURAL, 0 },
{ "le filer", T_SUBJ | T_WHAT | T_MALE | T_SING, 0 },
{ "le fw", T_SUBJ | T_WHAT | T_MALE | T_SING, 0 },
{ "le switch", T_SUBJ | T_WHAT | T_MALE | T_SING, 0 },
{ "le peering", T_SUBJ | T_WHAT | T_MALE | T_SING, 0 },
{ "la politique de routage", T_SUBJ | T_WHAT | T_FEMALE | T_SING, 0 },
{ "reboote", T_VERB | T_SING, 0 },
{ "le failovering", T_SUBJ | T_WHAT | T_MALE | T_SING, 0 },
{ "l'accounting", T_SUBJ | T_WHAT | T_MALE | T_SING, 0 },
{ "un test", T_SUBJ | T_WHAT | T_MALE | T_SING, 0 },
{ "mounté en raid5", T_ADJ | T_MALE, 0 },
{ "de /parisdata", T_ADJ | T_MALE | T_FEMALE | T_MALES | T_FEMALES, 0 },
{ "la todo list", T_SUBJ | T_WHAT | T_FEMALE | T_SING, 0 },
{ "la BDD", T_SUBJ | T_WHAT | T_FEMALE | T_SING, 0 },
{ "finale", T_ADJ | T_FEMALE, 0 },
{ "de backup", T_ADJ | T_MALE, 0 },
{ "une procedure d'urgence", T_SUBJ | T_WHAT | T_FEMALE | T_SING, 0 },
{ "nous a pete a la gueule", T_ACT | T_MALE | T_FEMALE | T_SING, 0 },
{ "commencent a merder", T_ACT | T_MALES | T_FEMALES | T_PLURAL, 0 },
{ "des service dependency definition", T_SUBJ | T_WHAT | T_MALES | T_PLURAL, 0 },
{ "mysql2", T_SUBJ | T_WHAT | T_FEMALE | T_SING, 0 },
{ "ping", T_VERB | T_SING, 0 },
{ "route", T_VERB | T_SING, 0 },
{ "routent", T_VERB | T_PLURAL, 0 },
{ "montre", T_VERB | T_SING, 0 },
{ "un broadcast", T_WHAT | T_MALE | T_SING, 0 },
{ "le mrtg", T_WHAT | T_MALE | T_SING, 0 },
{ "les altertes du mon", T_WHAT | T_FEMALES | T_PLURAL, 0 },
{ "remet", T_VERB | T_SING, 0 },
{ "resettent", T_VERB | T_SING, 0 },
{ "forwardent", T_VERB | T_PLURAL, 0 },
{ "les autres hosts", T_SUBJ | T_WHAT | T_MALES | T_PLURAL, 0 },
{ "des stats", T_SUBJ | T_WHAT | T_MALES | T_PLURAL, 0 },
{ "la gw", T_SUBJ | T_WHAT | T_FEMALE | T_SING, 0 },
{ "le hosting", T_SUBJ | T_WHAT | T_FEMALE | T_SING, 0 },
{ "la machine de William", T_SUBJ | T_WHAT | T_FEMALE | T_SING, 0 },
{ "une configuration foireuse", T_SUBJ | T_WHAT | T_FEMALE | T_SING, 0 },
{ "un truc bizarre", T_SUBJ | T_WHAT | T_MALE | T_SING, 0 },
{ "depuis quelques jours", T_CC | T_CCFIN, 0 },
{ "et ca se produit surtout sur la baie 13", T_CC | T_CCFIN, 0 },
{ "d'apres nos partenaires", T_CC | T_CCFIN, 0 },
{ "comme l'a dit Const", T_CC | T_CCFIN, 0 },
{ "j'ai remarque que", T_CC | T_CCBEG, 0 },
{ "dans les logs du c7206 on voit que", T_CC | T_CCBEG, 0 },
{ "je constate que", T_CC | T_CCBEG, 0 },
{ "il se passe un truc space:", T_CC | T_CCBEG, 0 },
{ "faut qu'on m'explique pourquoi", T_CC, 0 },
{ "tu me parles sur un autre ton, car", T_CC | T_CCBEG, 0 },
{ "le mec de Colt m'a dit que", T_CC | T_CCBEG, 0 },
{ "il se trouve que", T_CC | T_CCBEG, 0 },
{ "c'est bizarre:", T_CC | T_CCBEG, 0 },
{ "c'est pas normal...", T_CC | T_CCFIN, 0 },
{ "et je vais t'assigner une tache pour ca", T_CC | T_CCFIN, 0 },
{ NULL, (Type) -1, 0 },
};
const Grammar grammar[] = {
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALE, T_VERB | T_SING, T_WHAT, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALE, T_VERB | T_SING, T_WHAT, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALES, T_VERB | T_PLURAL, T_WHAT, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALES, T_VERB | T_PLURAL, T_WHAT, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALE, T_VERB | T_SING, T_WHAT | T_MALE, T_ADJ | T_MALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALE, T_VERB | T_SING, T_WHAT | T_MALES, T_ADJ | T_MALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALE, T_VERB | T_SING, T_WHAT | T_FEMALE, T_ADJ | T_FEMALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALE, T_VERB | T_SING, T_WHAT | T_FEMALES, T_ADJ | T_FEMALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALE, T_VERB | T_SING, T_WHAT | T_MALE, T_ADJ | T_MALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALE, T_VERB | T_SING, T_WHAT | T_MALES, T_ADJ | T_MALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALE, T_VERB | T_SING, T_WHAT | T_FEMALE, T_ADJ | T_FEMALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALE, T_VERB | T_SING, T_WHAT | T_FEMALES, T_ADJ | T_FEMALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALES, T_VERB | T_PLURAL, T_WHAT | T_MALE, T_ADJ | T_MALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALES, T_VERB | T_PLURAL, T_WHAT | T_MALES, T_ADJ | T_MALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALES, T_VERB | T_PLURAL, T_WHAT | T_FEMALE, T_ADJ | T_FEMALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALES, T_VERB | T_PLURAL, T_WHAT | T_FEMALES, T_ADJ | T_FEMALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALES, T_VERB | T_PLURAL, T_WHAT | T_MALE, T_ADJ | T_MALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALES, T_VERB | T_PLURAL, T_WHAT | T_MALES, T_ADJ | T_MALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALES, T_VERB | T_PLURAL, T_WHAT | T_FEMALE, T_ADJ | T_FEMALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALES, T_VERB | T_PLURAL, T_WHAT | T_FEMALES, T_ADJ | T_FEMALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
/* new style */
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALE, T_ACT1 | T_MALE | T_SING, T_ACT1P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALE, T_ACT1 | T_FEMALE | T_SING, T_ACT1P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALES, T_ACT1 | T_MALES | T_PLURAL, T_ACT1P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALES, T_ACT1 | T_FEMALES | T_PLURAL, T_ACT1P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
/* snip snip */
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALE, T_ACT1 | T_SING | T_MALE, T_ACT1P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALE, T_ACT1 | T_SING | T_FEMALE, T_ACT1P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALES, T_ACT1 | T_PLURAL | T_MALES, T_ACT1P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALES, T_ACT1 | T_PLURAL | T_FEMALES, T_ACT1P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
/* new style */
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALE, T_ACT2 | T_SING | T_MALE, T_ACT2P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALE, T_ACT2 | T_SING | T_FEMALE, T_ACT2P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALES, T_ACT2 | T_PLURAL | T_MALES , T_ACT2P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALES, T_ACT2 | T_PLURAL | T_FEMALES, T_ACT2P, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
/* new-new style */
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALE, T_ACT | T_SING | T_MALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALE | T_SING, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALE, T_ACT | T_SING | T_FEMALE, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_MALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_MALES, T_ACT | T_PLURAL | T_MALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ T_OPTION | T_CC | T_CCBEG, T_SUBJ | T_FEMALES | T_PLURAL, T_OPTION | T_SUBJP, T_OPTION | T_ADJ | T_FEMALES, T_ACT | T_PLURAL | T_FEMALES, T_OPTION | T_CC | T_CCFIN, (Type) -1 },
{ (Type) -1 },
};
size_t mystrlcat(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
size_t dlen;
while (n-- != 0 && *d != 0) {
d++;
}
dlen = d - dst;
n = siz - dlen;
if (n == 0) {
return dlen + strlen(s);
}
while (*s != 0) {
if (n != 1) {
*d++ = *s;
n--;
}
s++;
}
*d = 0;
return dlen + (s - src);
}
void reset(void)
{
Word *wordpnt = words;
do {
if (wordpnt->usage > 0) {
wordpnt->usage--;
}
wordpnt++;
} while (wordpnt->text != NULL);
}
int get(Type type, char * const buf, const size_t buflen, int * const initialp)
{
Word *wordpnt = &words[rand() % (sizeof words / sizeof words[0] - 1)];
const Word * const start = wordpnt;
if ((type & T_OPTION) != (Type) 0) {
if (rand() > rand()) {
return 1;
}
}
type &= ~T_OPTION;
do {
if ((wordpnt->type & type) == type && wordpnt->usage == 0) {
wordpnt->usage += 8;
if (*initialp != 0) {
char wi[strlen(wordpnt->text) + (size_t) 1U];
*initialp = 0;
strcpy(wi, wordpnt->text);
wi[0] = toupper(wi[0]);
mystrlcat(buf, wi, buflen);
} else {
mystrlcat(buf, wordpnt->text, buflen);
}
return 0;
}
wordpnt++;
if (wordpnt->text == NULL) {
wordpnt = words;
}
} while (wordpnt != start);
return -1;
}
void laurentize(char *buf)
{
const size_t s = strlen(buf);
int sw = s / 32;
int p;
int c;
do {
p = rand() % s;
if (isalpha(buf[p]) && !isupper(buf[p]) && isalpha(buf[p + 1])) {
c = buf[p];
buf[p] = buf[p + 1];
buf[p + 1] = c;
}
sw--;
} while (sw != 0);
}
void head(char * const buf, const size_t buflen)
{
(void) buf;
(void) buflen;
}
void sig(char * const buf, const size_t buflen)
{
mystrlcat(buf, "\n\nLL\n", buflen);
}
int main(void)
{
char buf[32768];
const Grammar *gpnt;
const Type *lpnt;
char *z;
char *bpb = buf;
size_t pointbreak = (size_t) 0U;
int initial = 1;
srand((unsigned int) time(NULL) % (unsigned int) getpid());
head(buf, sizeof buf);
do {
gpnt = &grammar[rand() % (sizeof grammar / sizeof grammar[0] - 1)];
lpnt = *gpnt;
reset();
bpb = buf + strlen(buf);
do {
switch (get(*lpnt, buf, sizeof buf, &initial)) {
case -1:
*bpb = 0;
goto skip;
case 1:
goto nxt;
}
mystrlcat(buf, " ", sizeof buf);
nxt:
lpnt++;
} while (*lpnt != (Type) -1);
z = buf + (strlen(buf) - (size_t) 1U);
while (z != buf && isspace(*z)) {
*z-- = 0;
}
if (rand() > rand()) {
if (rand() > rand()) {
mystrlcat(buf, ". ", sizeof buf);
} else {
mystrlcat(buf, ".\n\n", sizeof buf);
}
initial = 1;
if (rand() > rand()) {
pointbreak = (size_t) 0U;
} else {
pointbreak = strlen(buf);
get(T_LINK, buf, sizeof buf, &initial);
mystrlcat(buf, " ", sizeof buf);
}
} else {
pointbreak = strlen(buf);
if (rand() > rand()) {
mystrlcat(buf, ", ", sizeof buf);
} else {
mystrlcat(buf, " ", sizeof buf);
}
get(T_LINK, buf, sizeof buf, &initial);
mystrlcat(buf, " ", sizeof buf);
}
skip:
gpnt++;
} while (**gpnt != (Type) -1);
if (pointbreak > (size_t) 0U) {
buf[pointbreak] = 0;
}
laurentize(buf);
sig(buf, sizeof buf);
puts(buf);
return 0;
}