/* ep.c - Code for EP, the Electronic Poet... V1.00 - Baseline. [Rob Seace, 12-Aug-94] */ #include #include #include #include #include #include #ifdef __USAGE V1.00 %C [-p <#>] [-l] EP, the Electronic Poet... -p <#> The number of poems to write. (Default = 1) -l Print separator lines between poems. #endif typedef char *string; typedef int bool; #define IS == #define ISNT != #define AND && #define OR || #define NOT ! #define TRUE 1 #define FALSE 0 #define SUCCESS 0 #define ERROR -1 #define streq(s1,s2) (!strcmp((s1),(s2))) static string people[] = { "Rob", "Agrajag", "The Pope", "Dan Quayle", "John Wayne", "Fred Flintstone", "Barney Rubble", "Dan Akroyd", "John Belushi", "Jed Clampett", "Benji", "Elvis Presley", "Madonna", "Michael Jackson", "Lars Ulrich", "Prince", "Cindy Crawford", "Jessica Tandy", "Jessica Rabbit", "Barbara Walters", "Harrison Ford", "Henry Ford", "Ford Prefect", "G.I. Joe", "Barbie", "Samuel Adams", "Abraham Lincoln", "George Washington", "Jack Nickolson", "Mr. Spock", "Captain Kirk", "Trent Reznor", "Bill Gates", "Cher", "George Bush", "Barbara Bush", "Ronald Reagan", "Bill Clinton", NULL }; static string people_wants[] = { "to have a lot of money", "to have sex", "world peace", "world war", "life", "death", "love", "hate", "pleasure", "pain", "freedom", "torture", "censorship", "naziism", "liberalism", "conservativism", "to have a real life", "sex, drugs, and rock & roll", "to worship Satan", NULL }; static string people_descs[] = { "angry", "happy", "sad", "lonely", "horny", "insane", "stupid", "dumb", "ugly", "depressed", "suicidal", "mean", "nice", "hyperactive", "crazy", "lustful", "hateful", "gripless", "bored", "boring", "unstable", "special", "smart", "strong", "retarded", "brain-dead", "satanic", "naked", "loud", NULL }; static string people_verbs[] = { "kill", "fuck", "make love to", "beat the shit out of", "ride", "carry", "shove", "push", "kick", "kiss", "hug", "smack", "spit on", "eat lunch with", "rip the clothes off", "punish", "reward", "piss on", "lick whipped cream off", "live with", "cannabalize", NULL }; static string weapons[] = { "a knife", "a stake", "a dull butter knife", "a spoon", "a fork", "a sharpened pencil", "a screwdriver", "an ice pick", "an axe", "a rusted chunk of sheet metal", "a shard of broken glass", "an iron spike", "a large wooden plank", "a lobster claw", "a thumb-tack", "a baseball bat", "a pretzel rod", NULL }; static string weapon_verbs[] = { "shove", "thrust", "drive", "plunge", "ram", "throw", "hurl", "jam", NULL }; static string weapon_body_parts[] = { "through my heart", "into my chest", "into your chest", "up my ass", "up your ass", "through your skull", "into your skull", "into my eye", "into your eye", "through my skull", "into my skull", "through your heart", "into your neck", "into my neck", "into your genitals", "into my genitals", "into your mouth", "into my mouth", NULL }; static string puncts[] = { ".", "?", "!", "...", "??", "!!", "?!?", "!!!!", ";", "", NULL }; void usage (progname) string progname; { printf ("V1.00\n\n"); printf ("%s [-p <#>] [-l]\n\n", progname); printf ("EP, the Electronic Poet...\n\n"); printf ("-p <#> The number of poems to write. (Default = 1)\n"); printf ("-l Print separator lines between poems.\n\n"); } string rand_str (); string *rand_array (); void main (argc, argv) int argc; char *argv[]; { int format; int lines; int i; int num_poems; int c; bool print_sep_line; string title_str; char buf[81]; if ((argc > 1) AND streq (argv[1], "?")) { usage (argv[0]); exit (0); } num_poems = 1; print_sep_line = FALSE; #ifdef YOU_HAVE_GETOPT while ((c = getopt (argc, argv, "p:l")) ISNT -1) { switch (c) { case 'p': num_poems = atoi (optarg); break; case 'l': print_sep_line = TRUE; break; default: usage (argv[0]); exit (-1); } } #else for (i = 1; i < argc; i++) { if (streq (argv[i], "-l")) { print_sep_line = TRUE; } else if (streq (argv[i], "-p")) { i++; num_poems = atoi (argv[i]); } else { printf ("Unknown switch (%s).\n\n", argv[i]); usage (argv[0]); exit (-1); } } #endif srand (time (NULL)); for (i = 0; i < num_poems; i++) { lines = (rand() % 7) + 4; /* 4 to 10 lines */ title_str = rand_str (rand_array()); printf (" %s\n", title_str); memset (buf, '-', strlen(title_str)); buf[strlen(title_str)] = '\0'; printf (" %s\n \n", buf); while (lines--) { format = rand() % 8; switch (format) { case 0: printf (" %s wants %s%s\n", rand_str(people), rand_str(people_wants), rand_str(puncts)); break; case 1: printf (" I want %s%s\n", rand_str(people_wants), rand_str(puncts)); break; case 2: printf (" I will %s %s%s\n", rand_str(people_verbs), rand_str(people), rand_str(puncts)); break; case 3: printf (" I am %s%s\n", rand_str(people_descs), rand_str(puncts)); break; case 4: printf (" %s is %s%s\n", rand_str(people), rand_str(people_descs), rand_str(puncts)); break; case 5: printf (" I will %s %s %s%s\n", rand_str(weapon_verbs), rand_str(weapons), rand_str(weapon_body_parts), rand_str(puncts)); break; case 6: printf (" %s will %s %s %s%s\n", rand_str(people), rand_str(weapon_verbs), rand_str(weapons), rand_str(weapon_body_parts), rand_str(puncts)); break; case 7: printf (" %s%s\n", rand_str(rand_array()), rand_str(puncts)); break; default: printf (" The impossible just happened... format = %d...\n", format); break; } } printf (" \n"); if (print_sep_line) printf (" ======================================================================\n \n"); } exit (0); } string rand_str (strs) string strs[]; { int num; int i; for (num = 0; strs[num]; num++) ; i = rand() % num; return (strs[i]); } string *rand_array () { int i; i = rand() % 8; switch (i) { case 0: return (people); case 1: return (people_wants); case 2: return (people_descs); case 3: return (people_verbs); case 4: return (weapons); case 5: return (weapon_verbs); case 6: return (weapon_body_parts); case 7: default: return (puncts); } }