PKUOS - Pintos
Pintos source browser for PKU Operating System course
Functions | Variables
insult.c File Reference
#include <ctype.h>
#include <debug.h>
#include <random.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syscall.h>
Include dependency graph for insult.c:

Go to the source code of this file.

Functions

static void init_grammar (void)
 
void expand (int num, char **grammar[], char *location[], int handle)
 
static void usage (int ret_code, const char *message,...) PRINTF_FORMAT(2
 
int main (int argc, char *argv[])
 

Variables

char * start []
 Insult.c. More...
 
char startLoc [] = { 3, 0, 4, 7, 16 }
 
char * adj [] = { "3", "4", "2", ",", "1" }
 
char adjLoc [] = { 3, 0, 1, 2, 5 }
 
char * adj3 [] = { "3", "4" }
 
char adj3Loc [] = { 2, 0, 1, 2 }
 
char * adj1 []
 
char adj1Loc []
 
char * adj2 []
 
char adj2Loc []
 
char * name []
 
char nameLoc [] = { 7, 0, 1, 6, 10, 16, 21, 23, 27 }
 
char * stuff []
 
char stuffLoc [] = { 14, 0, 1, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15, 17, 18 }
 
char * noun_and_prep []
 
char noun_and_prepLoc []
 
char * organics []
 
char organicsLoc []
 
char * body_parts []
 
char body_partsLoc [] = { 6, 0, 1, 2, 3, 4, 5, 6 }
 
char * noun []
 
char nounLoc [] = { 13, 0, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
 
char * animal []
 
char animalLoc [] = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
 
char * good_verb []
 
char good_verbLoc [] = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11 }
 
char * curse []
 
char curseLoc [] = { 4, 0, 3, 7, 13, 20 }
 
char * afflictors []
 
char afflictorsLoc [] = { 6, 0, 2, 4, 6, 8, 12, 16 }
 
char * quantity []
 
char quantityLoc [] = { 10, 0, 4, 8, 11, 14, 15, 18, 22, 26, 32, 33 }
 
char * numbers []
 
char numbersLoc [] = { 7, 0, 2, 4, 5, 7, 8, 10, 13 }
 
char * adv []
 
char advLoc [] = { 8, 0, 1, 2, 3, 4, 11, 12, 18, 19 }
 
char * metaphor []
 
char metaphorLoc [] = { 6, 0, 3, 5, 7, 9, 20, 23 }
 
char * force [] = { "force", "fury", "power", "rage" }
 
char forceLoc [] = { 4, 0, 1, 2, 3, 4 }
 
char * bad_action []
 
char bad_actionLoc []
 
char * beasties []
 
char beastiesLoc []
 
char * condition []
 
char conditionLoc [] = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
 
char * place []
 
char placeLoc [] = { 5, 0, 3, 7, 11, 17, 20 }
 
char * relation []
 
char relationLoc [] = { 6, 0, 1, 2, 3, 5, 7, 9 }
 
char * in_something []
 
char in_somethingLoc [] = { 8, 0, 1, 3, 4, 5, 6, 8, 9, 10 }
 
char * bad_place []
 
char bad_placeLoc [] = { 6, 0, 2, 3, 5, 7, 8, 9 }
 
char ** daGrammar [27]
 
char * daGLoc [27]
 

Function Documentation

◆ expand()

void expand ( int  num,
char **  grammar[],
char *  location[],
int  handle 
)

Definition at line 348 of file insult.c.

References atoi(), expand(), hprintf(), isdigit(), ispunct(), and random_ulong().

Referenced by expand(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_grammar()

static void init_grammar ( void  )
static

◆ main()

int main ( int argc   ,
char *  argv[] 
)

Definition at line 272 of file insult.c.

References atoi(), close(), create(), daGLoc, daGrammar, EXIT_FAILURE, EXIT_SUCCESS, expand(), hprintf(), init_grammar(), NULL, open(), printf(), random_init(), STDOUT_FILENO, strcmp(), and usage().

Here is the call graph for this function:

◆ usage()

static void static void usage ( int  ret_code,
const char *  message,
  ... 
)
static

Definition at line 249 of file insult.c.

References exit(), NULL, printf(), va_end, va_start, and vprintf().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ adj

char* adj[] = { "3", "4", "2", ",", "1" }

Definition at line 18 of file insult.c.

Referenced by init_grammar().

◆ adj1

char* adj1[]
Initial value:
=
{ "lame", "dried", "up", "par-broiled", "bloated", "half-baked", "spiteful",
"egotistical", "ungrateful", "stupid", "moronic", "fat", "ugly", "puny", "pitiful",
"insignificant", "blithering", "repulsive", "worthless", "blundering", "retarded",
"useless", "obnoxious", "low-budget", "assinine", "neurotic", "subhuman", "crochety",
"indescribable", "contemptible", "unspeakable", "sick", "lazy", "good-for-nothing",
"slutty", "mentally-deficient", "creepy", "sloppy", "dismal", "pompous", "pathetic",
"friendless", "revolting", "slovenly", "cantankerous", "uncultured", "insufferable",
"gross", "unkempt", "defective", "crumby"
}

Definition at line 22 of file insult.c.

Referenced by init_grammar().

◆ adj1Loc

char adj1Loc[]
Initial value:
=
{ 50, 0, 1, 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 }

Definition at line 32 of file insult.c.

Referenced by init_grammar().

◆ adj2

char* adj2[]
Initial value:
=
{ "putrefied", "festering", "funky", "moldy", "leprous", "curdled", "fetid",
"slimy", "crusty", "sweaty", "damp", "deranged", "smelly", "stenchy", "malignant",
"noxious", "grimy", "reeky", "nasty", "mutilated", "sloppy", "gruesome", "grisly",
"sloshy", "wormy", "mealy", "spoiled", "contaminated", "rancid", "musty",
"fly-covered", "moth-eaten", "decaying", "decomposed", "freeze-dried", "defective",
"petrified", "rotting", "scabrous", "hirsute"
}

Definition at line 36 of file insult.c.

Referenced by init_grammar().

◆ adj2Loc

char adj2Loc[]
Initial value:
=
{ 40, 0, 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 }

Definition at line 44 of file insult.c.

Referenced by init_grammar().

◆ adj3

char* adj3[] = { "3", "4" }

Definition at line 20 of file insult.c.

Referenced by init_grammar().

◆ adj3Loc

char adj3Loc[] = { 2, 0, 1, 2 }

Definition at line 21 of file insult.c.

Referenced by init_grammar().

◆ adjLoc

char adjLoc[] = { 3, 0, 1, 2, 5 }

Definition at line 19 of file insult.c.

Referenced by init_grammar().

◆ adv

char* adv[]
Initial value:
=
{ "viciously", "manicly", "merrily", "happily", ",", "with", "the", "19",
"of", "18", ",", "gleefully", ",", "with", "much", "ritualistic", "celebration", ",",
"franticly"
}

Definition at line 115 of file insult.c.

Referenced by init_grammar().

◆ advLoc

char advLoc[] = { 8, 0, 1, 2, 3, 4, 11, 12, 18, 19 }

Definition at line 120 of file insult.c.

Referenced by init_grammar().

◆ afflictors

char* afflictors[]
Initial value:
=
{ "15", "21", "15", "21", "15", "21", "15", "21", "a", "22", "Rush",
"Limbaugh", "the", "hosts", "of", "Hades"
}

Definition at line 99 of file insult.c.

Referenced by init_grammar().

◆ afflictorsLoc

char afflictorsLoc[] = { 6, 0, 2, 4, 6, 8, 12, 16 }

Definition at line 103 of file insult.c.

Referenced by init_grammar().

◆ animal

char* animal[]
Initial value:
=
{ "donkey", "llama", "dingo", "lizard", "gekko", "lemur", "moose", "camel",
"goat", "eel"
}

Definition at line 84 of file insult.c.

Referenced by init_grammar().

◆ animalLoc

char animalLoc[] = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }

Definition at line 88 of file insult.c.

Referenced by init_grammar().

◆ bad_action

char* bad_action[]
Initial value:
=
{ "spit", "shimmy", "slobber", "find", "refuge", "find", "shelter", "dance",
"retch", "vomit", "defecate", "erect", "a", "strip", "mall", "build", "a", "26", "have", "a",
"religious", "experience", "discharge", "bodily", "waste", "fart", "dance", "drool",
"lambada", "spill", "16", "rusty", "tacks", "bite", "you", "sneeze", "sing", "16",
"campfire", "songs", "smite", "you", "16", "times", "construct", "a", "new", "home", "throw",
"a", "party", "procreate"
}

Definition at line 129 of file insult.c.

Referenced by init_grammar().

◆ bad_actionLoc

char bad_actionLoc[]
Initial value:
=
{ 25, 0, 1, 2, 3, 5, 7, 8, 9, 10, 11, 15, 18, 22, 25, 26, 27, 28, 29, 33,
35, 36, 40, 44, 48, 51, 52 }

Definition at line 137 of file insult.c.

Referenced by init_grammar().

◆ bad_place

char* bad_place[]
Initial value:
=
{ "rat", "hole", "sewer", "toxic", "dump", "oil", "refinery", "landfill",
"porto-pottie"
}

Definition at line 168 of file insult.c.

Referenced by init_grammar().

◆ bad_placeLoc

char bad_placeLoc[] = { 6, 0, 2, 3, 5, 7, 8, 9 }

Definition at line 172 of file insult.c.

Referenced by init_grammar().

◆ beasties

char* beasties[]
Initial value:
=
{ "yaks", "22", "maggots", "22", "cockroaches", "stinging", "scorpions",
"fleas", "22", "weasels", "22", "gnats", "South", "American", "killer", "bees", "spiders",
"4", "monkeys", "22", "wiener-dogs", "22", "rats", "22", "wolverines", "4", ",", "22",
"pit-fiends"
}

Definition at line 140 of file insult.c.

Referenced by init_grammar().

◆ beastiesLoc

char beastiesLoc[]
Initial value:
=
{ 14, 0, 1, 3, 5, 7, 8, 10, 12, 16, 17, 19, 21, 23, 25, 29 }

Definition at line 146 of file insult.c.

Referenced by init_grammar().

◆ body_parts

char* body_parts[]
Initial value:
=
{ "kidneys", "genitals", "buttocks", "earlobes", "innards", "feet"
}

Definition at line 75 of file insult.c.

Referenced by init_grammar().

◆ body_partsLoc

char body_partsLoc[] = { 6, 0, 1, 2, 3, 4, 5, 6 }

Definition at line 78 of file insult.c.

Referenced by init_grammar().

◆ condition

char* condition[]
Initial value:
=
{ "frothing", "manic", "crazed", "plague-ridden", "disease-carrying",
"biting", "rabid", "blood-thirsty", "ravaging", "slavering"
}

Definition at line 148 of file insult.c.

Referenced by init_grammar().

◆ conditionLoc

char conditionLoc[] = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }

Definition at line 152 of file insult.c.

Referenced by init_grammar().

◆ curse

char* curse[]
Initial value:
=
{ "14", "20", "23", "14", "17", "20", "23", "14", "find", "your", "9",
"suddenly", "delectable", "14", "and", "14", "seek", "a", "battleground", "23"
}

Definition at line 94 of file insult.c.

Referenced by init_grammar().

◆ curseLoc

char curseLoc[] = { 4, 0, 3, 7, 13, 20 }

Definition at line 98 of file insult.c.

Referenced by init_grammar().

◆ daGLoc

char* daGLoc[27]

Definition at line 174 of file insult.c.

Referenced by init_grammar(), and main().

◆ daGrammar

char** daGrammar[27]

Definition at line 173 of file insult.c.

Referenced by init_grammar(), and main().

◆ force

char* force[] = { "force", "fury", "power", "rage" }

Definition at line 127 of file insult.c.

Referenced by init_grammar().

◆ forceLoc

char forceLoc[] = { 4, 0, 1, 2, 3, 4 }

Definition at line 128 of file insult.c.

Referenced by init_grammar().

◆ good_verb

char* good_verb[]
Initial value:
=
{ "love", "cuddle", "fondle", "adore", "smooch", "hug", "caress", "worship",
"look", "at", "touch"
}

Definition at line 89 of file insult.c.

Referenced by init_grammar().

◆ good_verbLoc

char good_verbLoc[] = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11 }

Definition at line 93 of file insult.c.

Referenced by init_grammar().

◆ in_something

char* in_something[]
Initial value:
=
{ "entrails", "anal", "cavity", "shoes", "house", "pantry", "general",
"direction", "pants", "bed"
}

Definition at line 163 of file insult.c.

Referenced by init_grammar().

◆ in_somethingLoc

char in_somethingLoc[] = { 8, 0, 1, 3, 4, 5, 6, 8, 9, 10 }

Definition at line 167 of file insult.c.

Referenced by init_grammar().

◆ metaphor

char* metaphor[]
Initial value:
=
{ "an", "irate", "manticore", "Thor's", "belch", "Alah's", "fist", "16",
"titans", "a", "particularly", "vicious", "she-bear", "in", "the", "midst", "of", "her",
"menstrual", "cycle", "a", "pissed-off", "Jabberwock"
}

Definition at line 121 of file insult.c.

Referenced by init_grammar().

◆ metaphorLoc

char metaphorLoc[] = { 6, 0, 3, 5, 7, 9, 20, 23 }

Definition at line 126 of file insult.c.

Referenced by init_grammar().

◆ name

char* name[]
Initial value:
=
{ "10", ",", "bad", "excuse", "for", "6", ",", "6", "for", "brains", ",",
"4", "11", "8", "for", "brains", "offspring", "of", "a", "motherless", "10", "7", "6",
"7", "4", "11", "8"
}

Definition at line 47 of file insult.c.

Referenced by block_get_by_name(), block_register(), dir_add(), dir_lookup(), dir_readdir(), dir_remove(), do_remove(), filesys_create(), filesys_open(), filesys_remove(), found_partition(), fsutil_ls(), getcwd(), init_grammar(), init_pool(), init_thread(), intr_register_ext(), intr_register_int(), list_dir(), lookup(), main(), parse_options(), readdir(), register_handler(), run_actions(), run_test(), test_main(), test_mlfqs_fair(), test_sleep(), thread_create(), and wrap_open().

◆ nameLoc

char nameLoc[] = { 7, 0, 1, 6, 10, 16, 21, 23, 27 }

Definition at line 52 of file insult.c.

Referenced by init_grammar().

◆ noun

char* noun[]
Initial value:
=
{ "pop", "tart", "warthog", "twinkie", "barnacle", "fondue", "pot",
"cretin", "fuckwad", "moron", "ass", "neanderthal", "nincompoop", "simpleton", "11"
}

Definition at line 79 of file insult.c.

Referenced by init_grammar().

◆ noun_and_prep

char* noun_and_prep[]
Initial value:
=
{ "bit", "of", "piece", "of", "vat", "of", "lump", "of", "crock", "of",
"ball", "of", "tub", "of", "load", "of", "bucket", "of", "mound", "of", "glob", "of", "bag",
"of", "heap", "of", "mountain", "of", "load", "of", "barrel", "of", "sack", "of", "blob", "of",
"pile", "of", "truckload", "of", "vat", "of"
}

Definition at line 59 of file insult.c.

Referenced by init_grammar().

◆ noun_and_prepLoc

char noun_and_prepLoc[]
Initial value:
=
{ 21, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36,
38, 40, 42 }

Definition at line 65 of file insult.c.

Referenced by init_grammar().

◆ nounLoc

char nounLoc[] = { 13, 0, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15 }

Definition at line 83 of file insult.c.

Referenced by init_grammar().

◆ numbers

char* numbers[]
Initial value:
=
{ "a", "thousand", "three", "million", "ninty-nine", "nine-hundred,",
"ninty-nine", "forty-two", "a", "gazillion", "sixty-eight", "times", "thirty-three"
}

Definition at line 110 of file insult.c.

Referenced by init_grammar().

◆ numbersLoc

char numbersLoc[] = { 7, 0, 2, 4, 5, 7, 8, 10, 13 }

Definition at line 114 of file insult.c.

Referenced by init_grammar().

◆ organics

char* organics[]
Initial value:
=
{ "droppings", "mung", "zits", "puckies", "tumors", "cysts", "tumors",
"livers", "froth", "parts", "scabs", "guts", "entrails", "blubber", "carcuses", "gizards",
"9"
}

Definition at line 68 of file insult.c.

Referenced by init_grammar().

◆ organicsLoc

char organicsLoc[]
Initial value:
=
{ 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }

Definition at line 73 of file insult.c.

Referenced by init_grammar().

◆ place

char* place[]
Initial value:
=
{ "in", "24", "25", "upon", "your", "mother's", "grave", "on", "24", "best",
"rug", "in", "the", "26", "you", "call", "home", "upon", "your", "heinie"
}

Definition at line 153 of file insult.c.

Referenced by init_grammar().

◆ placeLoc

char placeLoc[] = { 5, 0, 3, 7, 11, 17, 20 }

Definition at line 157 of file insult.c.

Referenced by init_grammar().

◆ quantity

char* quantity[]
Initial value:
=
{ "a", "4", "hoard", "of", "a", "4", "pack", "of", "a", "truckload", "of",
"a", "swarm", "of", "many", "an", "army", "of", "a", "4", "heard", "of", "a", "4",
"platoon", "of", "a", "4", "and", "4", "group", "of", "16"
}

Definition at line 104 of file insult.c.

Referenced by init_grammar().

◆ quantityLoc

char quantityLoc[] = { 10, 0, 4, 8, 11, 14, 15, 18, 22, 26, 32, 33 }

Definition at line 109 of file insult.c.

Referenced by init_grammar().

◆ relation

char* relation[]
Initial value:
=
{ "your", "your", "your", "your", "father's", "your", "mother's", "your",
"grandma's"
}

Definition at line 158 of file insult.c.

Referenced by init_grammar().

◆ relationLoc

char relationLoc[] = { 6, 0, 1, 2, 3, 5, 7, 9 }

Definition at line 162 of file insult.c.

Referenced by init_grammar().

◆ start

char* start[]
Initial value:
=
{ "You", "1", "5", ".", "May", "13", ".", "With", "the", "19", "of", "18",
",", "may", "13", "."
}

Insult.c.

This is a version of the famous CS 107 random sentence generator. I wrote a program that reads a grammar definition file and writes a C file containing that grammar as hard code static C strings. Thus the majority of the code below in machine generated and totally unreadable. The arrays created are specially designed to make generating the sentences as easy as possible.

Originally by Greg Hutchins, March 1998. Modified by Ben Pfaff for Pintos, Sept 2004.

Definition at line 13 of file insult.c.

Referenced by bitmap_all(), bitmap_any(), bitmap_contains(), bitmap_count(), bitmap_none(), bitmap_scan(), bitmap_scan_and_flip(), bitmap_set_multiple(), found_partition(), hex_dump(), init_grammar(), test_main(), timer_sleep(), and too_many_loops().

◆ startLoc

char startLoc[] = { 3, 0, 4, 7, 16 }

Definition at line 17 of file insult.c.

Referenced by init_grammar().

◆ stuff

char* stuff[]
Initial value:
=
{ "shit", "toe", "jam", "filth", "puss", "earwax", "leaf", "clippings",
"bat", "guano", "mucus", "fungus", "mung", "refuse", "earwax", "spittoon", "spittle",
"phlegm"
}

Definition at line 53 of file insult.c.

Referenced by init_grammar().

◆ stuffLoc

char stuffLoc[] = { 14, 0, 1, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15, 17, 18 }

Definition at line 58 of file insult.c.

Referenced by init_grammar().