Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cat Code and Decoder Program

10 views
Skip to first unread message

Glenn Nelson

unread,
Sep 20, 1994, 12:19:59 PM9/20/94
to
This file contains both the cat code listing and a C program for
decoding the codes. The program is generic C and should be compilable
on most computer systems. I have not bothered to use shar, uuencode,
or any other fancy method for sending the code -- why bother, it's
just two simple files. Look for lines with lots of ======== that are
used to delimit the files (yes, I see that it's also used just below
for a different reason. Just use your brains).

I am not the author of the cat code and I am not the author of the
decoder program, but Laura says it's OK for me to distribute it.

Ace: DS O+Bto H 1.7 X L W++ C+ I+ T++ A E H++ S+ V++ F Q P++ B PA+ PL

Glenn Nelson, Megatest, San Jose
gne...@megatest.com
Phone: 408-441-3014

============================== The cat code file ==============================

CatCodes!
(for denizens of rec.pets.cats)

wd6...@netcom.com (Eric Williams)
October 1, 1993


======================================================================
= Physical Attributes =
= =
= These describe the physical appearance of the cat and must be =
= listed in the order shown here. =
======================================================================

Name:
Common or formal name followed by ':'.

Breed:

AB Abyssinian JB Japanese Bobtail
AC American Curl KT Korat
AL Americal Longhair MC Maine Coon
AS American Shorthair MX Manx
AW American Wirehair NB Nebelung
BA Balinese NF Norwegian Forest
BB American Bobtail OC Ocicat
BG Bengal OS Oriental Shorthair
BI Birman OL Oriental Longhair
BO Bombay PS Persian
BR Bristol RB Russian Blue
BS British Shorthair RD Ragdoll
BU Burmese SA Safari
CR Cornish Rex SF Scottish Fold
CX Chartreux SG Singapura
CY Cymric SI Siamese
DL Domestic longhair SN Snowshoe
DM Domestic mediumhair SO Somali
DR Devon Rex SP California Spangled
DS Domestic shorthair SR Selkirk Rex
EM Egyptian Mau SS Scottish Fold Longhair
ES Exotic Shorthair SX Sphynx
EU European Shorthair TA Turkish Angora
GR German Rex TF Tiffany
HB Havana Brown TO Tonkinese
HI Himalayan TV Turkish Van

Mixed breeds, if known, can be combined in descending order of
contribution (eg: MC+SI).

If a cat "looks like" a particular breed but parentage is unknown,
breed can be enclosed in quotation marks.

Color:
R Red (Orange)
W White
S Silver
B Black
O Brown
C Chocolate
L Lilac
D Ruddy
G Gold

Modifiers:
d Diluted (i.e.: Red->Cream, Black->Blue(Grey), etc.)
t Tabby (classic or mackeral pattern)
r Tortoiseshell
p Pointed
s Smoke
c Chinchilla
k Ticked
m Mink
o Spotted
h Shaded

Colors can be combined in descending order of area (eg: B+W)

Modifiers can be applied to individual colors by concatenation
(eg: W+Bd = white with grey patches), or groups of colors by use
of parenthesis (eg: (W+B+R)d = dilute calico,
(R+W)t+W = red tabby w/white).

Eye Color:
B Blue
A Aqua
G Green
H Hazel
C Copper
Y Gold (yellow)

Odd-eyed colors can be separated by '/', eg: B/G.
Colors can also be added for mixed colors, eg: G+Y = green-gold.

Age:
yy or yy.mm

Eg: 5 = five years old, 1.5 = 17 months, .10 = ten months.

Sex:
X Female, spayed, no interest.
X+ Female, spayed, but still interested.
X++ Female, intact, but not particularly excitable.
X+++ I am a kitten factory.
Y Male, neutered, no interest.
Y+ Male, neutered, but still interested.
Y++ Male, intact, but not particularly excitable.
Y+++ I would go through a burning building to get at a female in heat.

Size ("largeness"):
L--- I fit easily into your shirt pocket.
L-- I can curl up in two cupped hands.
L- I'm somewhere between kitten-sized and average.
L I'm average cat size, just right for your lap.
L+ I'm starting to slip off the side of your lap.
L++ I'm large enough to make a German Shepard think twice.
L+++ People sometimes mistake me for a mountain lion.

Weight:
W-- I'm so thin that you can count my bones.
W- I'm slim, but healthy.
W I'm an average cat, not too thin and not too fat.
W+ I'm a heavy cat, but it's all muscle.
W++ I need to go on a diet.

Claws:
C--- I've been declawed front and back
C-- I've been declawed in front
C- I have claws, but they're covered with "Soft Paws" (tm).
C+ I have claws, but they're clipped regularly.
C++ My claws are unclipped, but they're kindof dull.
C+++ I have ten razor-sharp implements of death.
(Comments about the "correct" number of claws to /dev/null.)

Note: "C*" can be substituted for "C" for a polydactyl.

======================================================================
= Behavioral Traits =
= =
= These are optional fields that describe behavioral, as opposed =
= to physical, traits. Consider omitting the corresponding code if =
= your cat is "normal" (whatever that means for a cat!) or near- =
= normal for the sake of brevity. =
======================================================================

I/O:
I+++ You mean there's a world *outside* of the house?!
I++ I live indoors most of the time, but will sneak out sometimes.
I+ I prefer to live indoors, but go outside when I feel like it.
I I drift between indoors and outdoors at will.
I- I come indoors to sleep and eat, but not much else.
I-- I'm allowed inside once in a while, but I eat and sleep outdoors.
I--- Why would anyone want to live inside those big ugly boxes?

Tempermant:
T+++ I am a furry ball of affection and love everybody.
T++ I like meeting new people and am affectionate with most.
T+ I'm shy about meeting new people, but am affectionate
with those that I know well.
T I have a few special humans I really like, the rest I tolerate.
T- People are OK for feeding and playing, but not much else
T-- I'm annoyed by human contact and will avoid it if possible.
T--- DON'T TOUCH ME OR I'LL SHRED YOU!!

Note: Many cats appear to be split-personalities, eg: T++/---

Activity level:
A+++ All the photos of me are blurred.
A++ I am always getting into, under or on top of things and am
hardly ever still.
A+ If you don't play with me, I'll find a way to play by myself.
A It's easy to get me to play, but I like to sleep, too.
A- I work very hard at sleeping, but like to chase the occasional toy.
A-- I may show signs of life in the presence of an excellent toy.
A--- They thought I was dead, until they started the can opener.

Eating:
E+++ Nothing even remotely edible is safe when I'm around.
E++ I'm always hungry. What are you having?
E+ I would rather eat than play with a toy.
E I enjoy good food, but sometimes the stuff I get is fit only
for my litter box.
E- I'll wait until the others have eaten.
E-- I would rather play with a toy than eat.
E--- I eat just enough to get by.

Hunting:
H Food comes in a box, right?
H+ I chase anything that moves, but am not quite sure what to
do with it if I catch it.
H++ I kill an occasional small rodent, bird or lizard, but
would never eat one. (Well, *hardly* ever.)
H+++ I regularly kill and eat small prey but expect to be fed, too.
H++++ If I didn't kill it then I don't want to eat it.

Smurgling:
S I wouldn't be caught dead doing it!
S+ I sneak an occasional smurgle.
S++ When I'm in the mood, I can smurgle with the best of them.
S+++ Everybody leaves my house moistened with kitty-drool.

Note: "smurgling" is defined as kneading some part of a person's body
or clothing while simultaneously nuzzling, licking or sucking.

Vocalization:
V+++ Everyone in the neighborhood deserves the benefit of hearing
my magnificent voice.
V++ I have long, meaningful conversations with people.
V+ I have a small but useful vocabulary of important words, like:
"Food!", "Play!", and: "Clean the box!"
V I'll let you know when it's dinner time, don't expect to
hear from me until then.
V- I know how to say "Feed me!", but must be very hungry to do so.
V-- Well, talking is a learned experience, I'm trying...
V--- If you are killing me, I might squeek a little.

Fetching:
F- Why did you throw that thing?
F I'll chase it if you throw it, but forget about bringing it back.
F+ I can be coaxed into fetching a favorite object when I'm in the mood.
F++ I like to fetch and will often ask my human to throw things for me.
F+++ I will fetch anything, anywhere, anytime. [Are you sure you don't
have a dog?]

Intelligence ("IQ"):
Q--- Every time I blink, I discover a whole new world.
Q-- The principals of gravity still escape me.
Q- I'm a little slow, but I'm trying!
Q I'm an average cat: cunning, but no real reasoning.
Q+ I'm pretty quick-witted for a cat.
Q++ I display near-human reasoning sometimes, such as double-takes
and abstract reasoning.
Q+++ I'm working on my PhD thesis.

Lap affinity:
P- I'd rather lie on a hard rock than in a person's lap.
P I'll use your lap if you're in the right room and I'm in the mood.
P+ I prefer laps to any other type of resting place, but they
have to belong to people I like.
P++ I am a total lap fungus. (Hurry up and sit down so
I can demonstrate!)

Belly sensitivity:
B-- Touching my belly is just cause for my taking your arm off
at the elbow.
B- I like to lay on my back and show my belly, but you'd better
not touch it.
B Well, OK, you can rub my belly...but not too much!
B+ Please rub my belly. Oh, yes! Do it some more!!
B++ I like to have my belly "drummed".
--
Eric Williams | Vincent: MC (B+S)t G+Y 1.1 Y L++ C+ T+ I+++ H+ S++ V+ F++
wd6...@netcom.com | Murphy: DS W+(B+R)t+R Y 1.2 Y L C+ T- I+++ H+ A+ F+ B--
WD6CMU@WD6CMU.#NOCAL.CA.USA.NA


============================= README file =============================

The catdecode program decodes Eric Williams' cat codes into a more human
readable format.

This is a C program. Included are this README file,
the catdecode.c source file, and the tables.h file, which
contains the catcodes and their interpretations.

This program has been compiled and run on SGIs (IRIX 4.0.5), Suns
(SunOS 4.1.3), and a Convex (ConvexOS 10.1). It's very generic C, and
should compile on almost any Unix platform with no modifications.
[NOTE: MS-DOG too]

To run the program, simply type "catdecode" if you want to enter input from
the keyboard, or "catdecode filename" if you wish it to read catcode lines
from a file. There should be one cat code per line. The first 4
fields (name, color, eyes, and age) *must* be in order - the rest of
the fields can be in any order, and other than the first four, none of the
fields are required. The name field must be terminated with a ':'.
Any field the program doesn't understand will be untranslated, and
echoed back with a '?'

When reading keyboard input, <ctrl-d> terminates the program.

Send any suggestions, bug fixes, etc., to lg...@nosc.mil.

Enjoy!

Laura

Taj: SI Bp B 4 Y+++ L W- C+ I+++ T+ A++ E-- H+ S++ V+ F Q P+ B PA PL
Tasha: SI Bp B 4 X+++ L W C+ I+++ T++ A E+ H+ S+ V++ F Q P++ B PA++ PL++
Panda: SI Bp B 8 X+++ L+ W++ C+ I+++ T++ A E+ H+ S V+ F Q+ P++ B PA++ PL++


========================== File tables.h ================================
/*
* tables.h - define the cat code tables - keys and data strings.
*/

struct tbl {
char key[6];
char data[140];
};

struct tbl breed[] = {

"AB", "Abyssinian",
"AC", "American Curl",
"AL", "American Longhair",
"AS", "American Shorthair",
"AW", "American Wirehair",
"BA", "Balinese",
"BB", "American Bobtail",
"BG", "Bengal",
"BI", "Birman",
"BO", "Bombay",
"BR", "Bristol",
"BS", "British Shorthair",
"BU", "Burmese",
"CR", "Cornish Rex",
"CX", "Chartreux",
"CY", "Cymric",
"DL", "Domestic Longhair",
"DM", "Domestic Mediumhair",
"DR", "Devon Rex",
"DS", "Domestic Shorthair",
"EM", "Egyptian Mau",
"ES", "Exotic Shorthair",
"EU", "European Shorthair",
"GR", "German Rex",
"HB", "Havana Brown",
"HI", "Himalayan",
"JB", "Japanese Bobtail",
"KT", "Korat",
"MC", "Maine Coon",
"MX", "Manx",
"NB", "Nebelung",
"NF", "Norwegian Forest",
"OC", "Ocicat",
"OS", "Oriental Shorthair",
"OL", "Oriental Longhair",
"PS", "Persian",
"RB", "Russian Blue",
"RD", "Ragdoll",
"SA", "Safari",
"SF", "Scottish Fold",
"SG", "Singapura",
"SI", "Siamese",
"SN", "Snowshoe",
"SO", "Somali",
"SP", "California Spangled",
"SR", "Selkirk Rex",
"SS", "Scottish Fold Longhair",
"SX", "Sphynx",
"TA", "Turkish Angora",
"TF", "Tiffany",
"TO", "Tonkinese",
"TV", "Turkish Van",
"", ""
};


struct tbl colors[] = {
"R", "red (orange)",
"W", "white",
"S", "silver",
"B", "black",
"O", "brown",
"C", "chocolate",
"L", "lilac",
"D", "ruddy",
"G", "gold",
"d", "dilute",
"t", "tabby",
"r", "tortoiseshell",
"p", "pointed",
"s", "smoke",
"c", "chinchilla",
"k", "ticked",
"m", "mink",
"o", "spotted",
"h", "shaded",
"", ""
};

struct tbl eyes[] = {
"B", "blue",
"A", "aqua",
"G", "green",
"H", "hazel",
"C", "copper",
"Y", "gold/yellow",
"", ""
};

struct tbl sex[] = {
"X", "female, spayed, no interest.",
"X+", "female, spayed, but still interested.",
"X++", "female, intact, but not particularly excitable.",
"X+++", "kitten factory.",
"Y", "male, neutered, no interest.",
"Y+", "male, neutered, but still interested.",
"Y++", "male, intact, but not particularly excitable.",
"Y+++", "male who would go through a burning building to get at a \n\tfemale in heat.",
"", ""
};

struct tbl size[] = {
"L---", "I fit easily into your shirt pocket.",
"L--", "I can curl up in two cupped hands.",
"L-", "I\'m somewhere between kitten-sized and average.",
"L", "I\'m average cat size, just right for your lap.",
"L+", "I\'m starting to slip off the side of your lap.",
"L++", "I\'m large enough to make a German Shepherd think twice.",
"L+++", "People sometimes mistake me for a mountain lion.",
"", ""
};

struct tbl weight[] = {
"W--", "I\'m so thin that you can count my bones.",
"W-", "I\'m slim, but healthy.",
"W", "I\'m an average cat, not too thin and not too fat.",
"W+", "I\'m a heavy cat, but it\'s all muscle.",
"W++", "I need to go on a diet.",
"", ""
};

struct tbl claws[] = {
"C---", "I\'ve been declawed front and back",
"C--", "I\'ve been declawed in front",
"C-", "I have claws, but they\'re covered with \"Soft Paws\" (tm).",
"C+", "I have claws, but they\'re clipped regularly.",
"C++", "My claws are unclipped, but they\'re kind of dull.",
"C+++", "I have ten razor-sharp implements of death.",
"C*---", "I'm a polydactyl, and I\'ve been declawed front and back",
"C*--", "I'm a polydactyl, and I\'ve been declawed in front",
"C*-", "I'm a polydactyl, and I have claws, but they\'re covered with \"Soft Paws\" (tm).",
"C*+", "I'm a polydactyl, and I have claws, but they\'re clipped regularly.",
"C*++", "I'm a polydactyl, and my claws are unclipped, but they\'re \n\tkind of dull.",
"C*+++", "I'm a polydactyl, and I have more than ten razor-sharp \n\timplements of death.",
"", ""
};

struct tbl indoors[] = {
"I+++", "You mean there\'s a world *outside* of the house?!",
"I++", "I live indoors most of the time, but will sneak out sometimes.",
"I+", "I prefer to live indoors, but go outside when I feel like it.",
"I", "I drift between indoors and outdoors at will.",
"I-", "I come indoors to sleep and eat, but not much else.",
"I--", "I\'m allowed inside once in a while, but I eat and sleep outdoors.",
"I---", "I wonder why would anyone want to live inside those big ugly boxes?",
"", ""
};

struct tbl temper[] = {
"T+++", "I am a furry ball of affection and love everybody.",
"T++", "I like meeting new people and am affectionate with most.",
"T+", "I\'m shy about meeting new people, but am affectionate with \n\tthose that I know well.",
"T", "I have a few special humans I really like, the rest I tolerate.",
"T-", "People are OK for feeding and playing, but not much else",
"T--", "I\'m annoyed by human contact and will avoid it if possible.",
"T---", "DON\'T TOUCH ME OR I\'LL SHRED YOU!!",
"", ""
};

struct tbl active[] = {
"A+++", "All the photos of me are blurred.",
"A++", "I am always getting into, under or on top of things and am \n\thardly ever still.",
"A+", "If you don\'t play with me, I\'ll find a way to play by myself.",
"A", "It\'s easy to get me to play, but I like to sleep, too.",
"A-", "I work very hard at sleeping, but like to chase the occasional toy.",
"A--", "I may show signs of life in the presence of an excellent toy.",
"A---", "They thought I was dead, until they started the can opener.",
"", ""
};

struct tbl eat[] = {
"E+++", "Nothing even remotely edible is safe when I\'m around.",
"E++", "I\'m always hungry. What are you having?",
"E+", "I would rather eat than play with a toy.",
"E", "I enjoy good food, but sometimes the stuff I get is fit only\n\tfor my litter box.",
"E-", "I\'ll wait until the others have eaten.",
"E--", "I would rather play with a toy than eat.",
"E---", "I eat just enough to get by.",
"", ""
};

struct tbl hunt[] = {
"H", "Food comes in a box, right?",
"H+", "I chase anything that moves, but am not quite sure what to \n\tdo with it if I catch it.",
"H++", "I kill an occasional small rodent, bird or lizard, but would \n\tnever eat one. (Well, *hardly* ever.)",
"H+++", "I regularly kill and eat small prey but expect to be fed, too.",
"H++++", "If I didn\'t kill it then I don\'t want to eat it.",
"", ""
};

struct tbl smurgle[] = {
"S", "Smurgling...I wouldn\'t be caught dead doing it!",
"S+", "I sneak an occasional smurgle.",
"S++", "When I\'m in the mood, I can smurgle with the best of them.",
"S+++", "Everybody leaves my house moistened with kitty-drool.",
"", ""
};

struct tbl voice[] = {
"V+++", "Everyone in the neighborhood deserves the benefit of hearing \n\tmy magnificent voice.",
"V++", "I have long, meaningful conversations with people.",
"V+", "I have a small but useful vocabulary of important words, like: \n\t\"Food!\", \"Play!\", and: \"Clean the box!\"",
"V", "I\'ll let you know when it\'s dinner time, don\'t expect to \n\thear from me until then.",
"V-", "I know how to say \"Feed me!\", but must be very hungry to do so.",
"V--", "Well, talking is a learned experience, I\'m trying...",
"V---", "If you are killing me, I might squeak a little.",
"", ""
};

struct tbl fetch[] = {
"F-", "Why did you throw that thing?",
"F", "I\'ll chase it if you throw it, but forget about bringing it back.",
"F+", "I can be coaxed into fetching a favorite object when I\'m in the mood.",
"F++", "I like to fetch and will often ask my human to throw things for me.",
"F+++", "I will fetch anything, anywhere, anytime. [Are you sure you \n\tdon\'t have a dog?]",
"", ""
};

struct tbl iq[] = {
"Q---", "Every time I blink, I discover a whole new world.",
"Q--", "The principles of gravity still escape me.",
"Q-", "I\'m a little slow, but I\'m trying!",
"Q", "I\'m an average cat: cunning, but no real reasoning.",
"Q+", "I\'m pretty quick-witted for a cat.",
"Q++", "I display near-human reasoning sometimes, such as double-takes \n\tand abstract reasoning.",
"Q+++", "I\'m working on my PhD dissertation.",
"", ""
};

struct tbl lap[] = {
"P-", "I\'d rather lie on a hard rock than in a person\'s lap.",
"P", "I\'ll use your lap if you\'re in the right room and I\'m in the mood.",
"P+", "I prefer laps to any other type of resting place, but they \n\thave to belong to people I like.",
"P++", "I am a total lap fungus. (Hurry up and sit down so I can \n\tdemonstrate!)",
"PA--", "Me purr? Never!",
"PA-", "I\'ll think about purring if you pat or feed me enough.",
"PA", "I purr to show my appreciation when patted or fed.",
"PA+", "Pat me and I'll rumble.",
"PA++", "I\'ll purr as soon as you enter the room/yard.",
"PL---", "There\'s something wrong with my purr voice.",
"PL--", "You\'ll have to put your ear against my tummy to hear me purr.",
"PL-", "When I purr, I\'m a little on the quiet side.",
"PL", "I\'m an average purrer.",
"PL+", "When I purr, I\'m a little louder than the average cat.",
"PL++", "I\'m a real power purrer!",
"PL+++", "When I purr, I\'ve been known to set off car alarms.",
"", ""
};

struct tbl belly[] = {
"B--", "Touching my belly is just cause for my taking your arm off at the elbow.",
"B-", "I like to lay on my back and show my belly, but you\'d better \n\tnot touch it.",
"B", "Well, OK, you can rub my belly...but not too much!",
"B+", "Please rub my belly. Oh, yes! Do it some more!!",
"B++", "I like to have my belly \"drummed\".",
"", ""
};


============================= File catdecode.c ==============================

/*
Copyright (c) 1994 by Laura Gilbreath

Permission to use, copy, modify, and distribute this material
for any purpose and without fee is hereby granted, provided
that the above copyright notice and this permission notice
appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.

Send bug reports, fixes, comments, etc., to lg...@nosc.mil
*/

/*
* catdecode - Decode Eric Williams' cat codes into a more human readable
* form.
*/

#include <stdio.h>
#include <ctype.h>
#include <string.h>

/* cat code tables */
#include "tables.h"

char *lookup();
char *getfield();

#define LINELEN 140 /* Maximum length of line to be decoded */

char prompt[]="Enter cat code (ctrl-D to quit):\n";

main(argc, argv)
int argc;
char **argv;

{
FILE *fp;
char line[LINELEN], *pt, *name, *bname, *color, *age, *eye, *misc;
char longname[LINELEN];
char *pos, tstr[4];
int prob, numbreeds, odd;


/* takes an input file containing lines to be decoded, or reads stdin */
if(argc > 1)
{
if((fp = fopen(argv[1], "r")) == (FILE *)NULL)
{
fprintf(stderr, "error opening input file %s\n",
argv[1]);
exit(1);
}
prompt[0] = '\0'; /* file input, so no prompt string */
}
else
fp = stdin;

while(1)
{
printf("%s", prompt);
if(fgets(line, LINELEN, fp) == NULL)
break;

line[strlen(line)-1] = '\0'; /* strip off newline */
if(strchr(line, ':') == NULL)
{
printf("Line: %s,\nparsing error - no \":\"\n", line);
continue;
}
longname[0] = '\0';
while((name = getfield(line)) != NULL)
{
strcat(longname, " ");
strcat(longname, name);
if((pt = strrchr(longname, ':')) != NULL)
{
*pt = '\0';
break;
}
}

printf("My name is%s.\n", longname);
if((bname = getfield(line)) == NULL)
continue;
if(strlen(bname) > 2) /* sort out mixed breeds */
{
prob = 0;
pos = bname;
numbreeds = 0;
printf("I am");
while(*pos != NULL) /* parse breed codes */
{
switch(*pos)
{
case '"':
if(prob == 0)
printf(" probably a");
prob++;
break;
case '(':
case ')':
break;
case '+':
printf(",");
break;
default:
if(isalpha(*pos))
{
strncpy(tstr, pos, 2);
tstr[2] = '\0';
numbreeds++;
printf(" %s", lookup(breed, tstr));
pos++;
}
}
pos++;
}
if(numbreeds > 1)
printf(" mix.\n");
else
printf(".\n");

}
else /* the straightforward case */
printf("I am a %s.\n", lookup(breed, bname));

if((color = getfield(line)) == NULL)
continue;
pos = color;
printf("I am");
while(*pos != NULL) /* parse color */
{
switch(*pos)
{
case '(':
break;
case ')':
printf(",");
break;
case '+':
printf(" with");
break;
default:
if(isalpha(*pos))
{
tstr[0] = *pos;
tstr[1] = '\0';
printf(" %s", lookup(colors, tstr));
}
}
pos++;
}
printf(".\n");

if((eye = getfield(line)) == NULL)
continue;
pos = eye;
odd = 0;
if(strchr(pos, '/') != NULL)
{
odd++; /* cat has odd eye color */
printf("I have one ");
}
else
printf("My eyes are ");
while(*pos != NULL)
{
switch(*pos)
{
case '/':
printf(" eye and one ");
break;
case '+':
printf("-");
break;
default:
if(isalpha(*pos))
{
tstr[0] = *pos;
tstr[1] = '\0';
printf("%s", lookup(eyes, tstr));
}
}
pos++;
}
if(odd)
printf(" eye");
printf(".\n");

if((age = getfield(line)) == NULL)
continue;
printf("In people years, I am %s.\n", age);

printf("Some of my traits are:\n");
while((misc = getfield(line)) != NULL)
{
switch(*misc)
{
case 'A':
printf("\t%s\n", lookup(active, misc));
break;
case 'B':
printf("\t%s\n", lookup(belly, misc));
break;
case 'C':
printf("\t%s\n", lookup(claws, misc));
break;
case 'E':
printf("\t%s\n", lookup(eat, misc));
break;
case 'F':
printf("\t%s\n", lookup(fetch, misc));
break;
case 'H':
printf("\t%s\n", lookup(hunt, misc));
break;
case 'I':
printf("\t%s\n", lookup(indoors, misc));
break;
case 'L':
printf("\t%s\n", lookup(size, misc));
break;
case 'P':
printf("\t%s\n", lookup(lap, misc));
break;
case 'Q':
printf("\t%s\n", lookup(iq, misc));
break;
case 'S':
printf("\t%s\n", lookup(smurgle, misc));
break;
case 'T':
printf("\t%s\n", lookup(temper, misc));
break;
case 'V':
printf("\t%s\n", lookup(voice, misc));
break;
case 'W':
printf("\t%s\n", lookup(weight, misc));
break;
case 'X':
case 'Y':
printf("\tI am a %s\n", lookup(sex, misc));
break;
}
}

}
}


/* return the next field of the input line. The field starts with a
* non-space character and is null-terminated. */
char *getfield(line)
char *line;
{
static char *bpos=NULL, *epos;

/* start at beginning of line */
if(bpos == NULL)
{
bpos = line;
while(isspace(*bpos))
bpos++;
}
else
{
if(*epos == '\0') /* at end of line */
{
bpos = NULL;
return(NULL);
}
bpos = epos; /* new begin pos is last end pos */
}

if((epos = strpbrk(bpos, " \t")) != NULL) /* find end of next field */
{
*epos++ = '\0';
while(isspace(*epos))
epos++;
}
else
epos = strrchr(bpos, '\0');
return(bpos);
}

/* search one of the tables on the input key parameter, and return a pointer
* to the string associated with the key. Return a ? if key is not found
* in the table.
*/
char *lookup(table, key)
struct tbl *table;
char *key;
{
int ii;
char retstr[12];

while(table->key[0] != '\0')
{
if(strcmp(key, table->key) == 0)
return(table->data);
table++;
}
sprintf(retstr, " \"%s\"?", key);
return(retstr);
}

0 new messages