-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgarble.c
53 lines (47 loc) · 1.16 KB
/
garble.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
#include "garble.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* GARBLE simulates the mispronunciation and blending of syllables
* than young children might possess. Feel free to modify garble as
* you see fit!
*/
void garble(char* message)
{
int sflag = rand() % 4;
switch (sflag) {
/* Add a random lower case letter */
case 0:
{
int n = strlen(message);
int k = rand() % n;
message[k] = 'a' + (rand() % 26);
break;
}
/* Add a random upper case letter */
case 1:
{
int n = strlen(message);
int k = rand() % n;
message[k] = 'A' + (rand() % 26);
break;
}
/* Add a random "blegh" */
case 2:
{
int n = strlen(message);
if (n > 5)
memcpy(message + (rand() % (n-5)), "blegh", 5);
break;
}
/* Add a random "gargh" */
case 3:
{
int n = strlen(message);
if (n > 5)
memcpy(message + (rand() % (n-5)), "gargh", 5);
break;
}
}
}