14 {
"You",
"1",
"5",
".",
"May",
"13",
".",
"With",
"the",
"19",
"of",
"18",
18char *
adj[] = {
"3",
"4",
"2",
",",
"1" };
20char *
adj3[] = {
"3",
"4" };
23 {
"lame",
"dried",
"up",
"par-broiled",
"bloated",
"half-baked",
"spiteful",
24"egotistical",
"ungrateful",
"stupid",
"moronic",
"fat",
"ugly",
"puny",
"pitiful",
25"insignificant",
"blithering",
"repulsive",
"worthless",
"blundering",
"retarded",
26"useless",
"obnoxious",
"low-budget",
"assinine",
"neurotic",
"subhuman",
"crochety",
27"indescribable",
"contemptible",
"unspeakable",
"sick",
"lazy",
"good-for-nothing",
28"slutty",
"mentally-deficient",
"creepy",
"sloppy",
"dismal",
"pompous",
"pathetic",
29"friendless",
"revolting",
"slovenly",
"cantankerous",
"uncultured",
"insufferable",
30"gross",
"unkempt",
"defective",
"crumby"
33 { 50, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
3421, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
3543, 44, 45, 46, 47, 48, 49, 50, 51 };
37 {
"putrefied",
"festering",
"funky",
"moldy",
"leprous",
"curdled",
"fetid",
38"slimy",
"crusty",
"sweaty",
"damp",
"deranged",
"smelly",
"stenchy",
"malignant",
39"noxious",
"grimy",
"reeky",
"nasty",
"mutilated",
"sloppy",
"gruesome",
"grisly",
40"sloshy",
"wormy",
"mealy",
"spoiled",
"contaminated",
"rancid",
"musty",
41"fly-covered",
"moth-eaten",
"decaying",
"decomposed",
"freeze-dried",
"defective",
42"petrified",
"rotting",
"scabrous",
"hirsute"
45 { 40, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
4620, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 };
48 {
"10",
",",
"bad",
"excuse",
"for",
"6",
",",
"6",
"for",
"brains",
",",
49"4",
"11",
"8",
"for",
"brains",
"offspring",
"of",
"a",
"motherless",
"10",
"7",
"6",
52char nameLoc[] = { 7, 0, 1, 6, 10, 16, 21, 23, 27 };
54 {
"shit",
"toe",
"jam",
"filth",
"puss",
"earwax",
"leaf",
"clippings",
55"bat",
"guano",
"mucus",
"fungus",
"mung",
"refuse",
"earwax",
"spittoon",
"spittle",
58char stuffLoc[] = { 14, 0, 1, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15, 17, 18 };
60 {
"bit",
"of",
"piece",
"of",
"vat",
"of",
"lump",
"of",
"crock",
"of",
61"ball",
"of",
"tub",
"of",
"load",
"of",
"bucket",
"of",
"mound",
"of",
"glob",
"of",
"bag",
62"of",
"heap",
"of",
"mountain",
"of",
"load",
"of",
"barrel",
"of",
"sack",
"of",
"blob",
"of",
63"pile",
"of",
"truckload",
"of",
"vat",
"of"
66 { 21, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36,
69 {
"droppings",
"mung",
"zits",
"puckies",
"tumors",
"cysts",
"tumors",
70"livers",
"froth",
"parts",
"scabs",
"guts",
"entrails",
"blubber",
"carcuses",
"gizards",
74 { 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 };
76 {
"kidneys",
"genitals",
"buttocks",
"earlobes",
"innards",
"feet"
80 {
"pop",
"tart",
"warthog",
"twinkie",
"barnacle",
"fondue",
"pot",
81"cretin",
"fuckwad",
"moron",
"ass",
"neanderthal",
"nincompoop",
"simpleton",
"11"
83char nounLoc[] = { 13, 0, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
85 {
"donkey",
"llama",
"dingo",
"lizard",
"gekko",
"lemur",
"moose",
"camel",
88char animalLoc[] = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
90 {
"love",
"cuddle",
"fondle",
"adore",
"smooch",
"hug",
"caress",
"worship",
93char good_verbLoc[] = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11 };
95 {
"14",
"20",
"23",
"14",
"17",
"20",
"23",
"14",
"find",
"your",
"9",
96"suddenly",
"delectable",
"14",
"and",
"14",
"seek",
"a",
"battleground",
"23"
100 {
"15",
"21",
"15",
"21",
"15",
"21",
"15",
"21",
"a",
"22",
"Rush",
101"Limbaugh",
"the",
"hosts",
"of",
"Hades"
105 {
"a",
"4",
"hoard",
"of",
"a",
"4",
"pack",
"of",
"a",
"truckload",
"of",
106"a",
"swarm",
"of",
"many",
"an",
"army",
"of",
"a",
"4",
"heard",
"of",
"a",
"4",
107"platoon",
"of",
"a",
"4",
"and",
"4",
"group",
"of",
"16"
109char quantityLoc[] = { 10, 0, 4, 8, 11, 14, 15, 18, 22, 26, 32, 33 };
111 {
"a",
"thousand",
"three",
"million",
"ninty-nine",
"nine-hundred,",
112"ninty-nine",
"forty-two",
"a",
"gazillion",
"sixty-eight",
"times",
"thirty-three"
116 {
"viciously",
"manicly",
"merrily",
"happily",
",",
"with",
"the",
"19",
117"of",
"18",
",",
"gleefully",
",",
"with",
"much",
"ritualistic",
"celebration",
",",
120char advLoc[] = { 8, 0, 1, 2, 3, 4, 11, 12, 18, 19 };
122 {
"an",
"irate",
"manticore",
"Thor's",
"belch",
"Alah's",
"fist",
"16",
123"titans",
"a",
"particularly",
"vicious",
"she-bear",
"in",
"the",
"midst",
"of",
"her",
124"menstrual",
"cycle",
"a",
"pissed-off",
"Jabberwock"
127char *
force[] = {
"force",
"fury",
"power",
"rage" };
130 {
"spit",
"shimmy",
"slobber",
"find",
"refuge",
"find",
"shelter",
"dance",
131"retch",
"vomit",
"defecate",
"erect",
"a",
"strip",
"mall",
"build",
"a",
"26",
"have",
"a",
132"religious",
"experience",
"discharge",
"bodily",
"waste",
"fart",
"dance",
"drool",
133"lambada",
"spill",
"16",
"rusty",
"tacks",
"bite",
"you",
"sneeze",
"sing",
"16",
134"campfire",
"songs",
"smite",
"you",
"16",
"times",
"construct",
"a",
"new",
"home",
"throw",
135"a",
"party",
"procreate"
138 { 25, 0, 1, 2, 3, 5, 7, 8, 9, 10, 11, 15, 18, 22, 25, 26, 27, 28, 29, 33,
13935, 36, 40, 44, 48, 51, 52 };
141 {
"yaks",
"22",
"maggots",
"22",
"cockroaches",
"stinging",
"scorpions",
142"fleas",
"22",
"weasels",
"22",
"gnats",
"South",
"American",
"killer",
"bees",
"spiders",
143"4",
"monkeys",
"22",
"wiener-dogs",
"22",
"rats",
"22",
"wolverines",
"4",
",",
"22",
147 { 14, 0, 1, 3, 5, 7, 8, 10, 12, 16, 17, 19, 21, 23, 25, 29 };
149 {
"frothing",
"manic",
"crazed",
"plague-ridden",
"disease-carrying",
150"biting",
"rabid",
"blood-thirsty",
"ravaging",
"slavering"
152char conditionLoc[] = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
154 {
"in",
"24",
"25",
"upon",
"your",
"mother's",
"grave",
"on",
"24",
"best",
155"rug",
"in",
"the",
"26",
"you",
"call",
"home",
"upon",
"your",
"heinie"
159 {
"your",
"your",
"your",
"your",
"father's",
"your",
"mother's",
"your",
164 {
"entrails",
"anal",
"cavity",
"shoes",
"house",
"pantry",
"general",
165"direction",
"pants",
"bed"
169 {
"rat",
"hole",
"sewer",
"toxic",
"dump",
"oil",
"refinery",
"landfill",
243void expand (
int num,
char **grammar[],
char *location[],
int handle);
249usage (
int ret_code, const
char *message, ...)
261 "Usage: insult [OPTION]...\n"
262 "Prints random insults to screen.\n\n"
263 " -h: this help message\n"
264 " -s <integer>: set the random seed (default 4951)\n"
265 " -n <integer>: choose number of insults (default 4)\n"
266 " -f <file>: redirect output to <file>\n");
274 int sentence_cnt, new_seed, i, file_flag, sent_flag, seed_flag;
284 for (i = 1; i < argc; i++)
286 if (
strcmp (argv[1],
"-h") == 0)
288 else if (
strcmp (argv[i],
"-s") == 0)
291 usage (-1,
"Can't have more than one seed");
293 usage (-1,
"Missing value for -s");
294 new_seed =
atoi (argv[i]);
296 else if (
strcmp (argv[i],
"-n") == 0)
299 usage (-1,
"Can't have more than one sentence option");
301 usage (-1,
"Missing value for -n");
302 sentence_cnt =
atoi (argv[i]);
303 if (sentence_cnt < 1)
304 usage (-1,
"Must have at least one sentence");
306 else if (
strcmp (argv[i],
"-f") == 0)
309 usage (-1,
"Can't have more than one output file");
311 usage (-1,
"Missing value for -f");
318 handle =
open (argv[i]);
321 printf (
"%s: open failed\n", argv[i]);
326 usage (-1,
"Unrecognized flag");
334 for (i = 0; i < sentence_cnt; i++)
348expand (
int num,
char **grammar[],
char *location[],
int handle)
351 int i, which, listStart, listEnd;
354 listStart = location[num][which];
355 listEnd = location[num][which + 1];
356 for (i = listStart; i < listEnd; i++)
358 word = grammar[num][i];
366 expand (
atoi (word), grammar, location, handle);
static int ispunct(int c)
static int isdigit(int c)
#define PRINTF_FORMAT(FMT, FIRST)
int main(int argc, char *argv[])
void expand(int num, char **grammar[], char *location[], int handle)
static void usage(int ret_code, const char *message,...) PRINTF_FORMAT(2
static void init_grammar(void)
int vprintf(const char *format, va_list args)
The standard vprintf() function, which is like printf() but uses a va_list.
int printf(const char *format,...)
Writes formatted output to the console.
int atoi(const char *s)
Converts a string representation of a signed decimal integer in S into an ‘int’, which is returned.
bool create(const char *file, unsigned initial_size)
int open(const char *file)
#define EXIT_SUCCESS
Typical return values from main() and arguments to exit().
#define EXIT_FAILURE
Unsuccessful execution.
unsigned long random_ulong(void)
Returns a pseudo-random unsigned long.
void random_init(unsigned seed)
Initializes or reinitializes the PRNG with the given SEED.
#define va_start(LIST, ARG)
__builtin_va_list va_list
GCC has <stdarg.h> functionality as built-ins, so all we need is to use it.
int strcmp(const char *a_, const char *b_)
Finds the first differing characters in strings A and B.
int hprintf(int handle, const char *format,...)
Like printf(), but writes output to the given HANDLE.