home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume36
/
formes
/
part01
/
form.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-01
|
2KB
|
119 lines
/*
* Copyright (C) 1992-1993 Jeffrey Chilton
*
* Permission is granted to anyone to make or distribute copies of
* this program, in any medium, provided that the copyright notice
* and permission notice are preserved, and that the distributor
* grants the recipient permission for further redistribution as
* permitted by this notice.
*
* Author's E-mail address: 172-9221@mcimail.com
*
*/
static char *whatstring = "@(#)form.c 2.2 JWC";
#include <stdio.h>
#include <malloc.h>
#include "class.h"
#include "form.h"
char *formNames[N_OF_PERSON][N_OF_PLURAL][N_OF_GENDER] =
{
"1SM", "1SF", "1PM", "1PF",
"2SM", "2SF", "2PM", "2PF",
"3SM", "3SF", "3PM", "3PF",
};
Form *
Form_new(person, plurality, gender)
int person;
int plurality;
int gender;
{
Form *self;
self = (Form *)malloc(sizeof (Form));
if (!self)
{
fprintf(stderr, "Form_new: malloc fails\n");
goto out;
}
self->gender = gender;
self->plurality = plurality;
self->person = person;
out:
return self;
}
Form *
Form_newFromImage(image)
char *image;
{
int person;
int plurality;
int gender;
char *name;
Form *self;
self = (Form *)malloc(sizeof (Form));
if (!self)
{
fprintf(stderr, "Form_newFromImage: malloc fails\n");
goto out;
}
for (person = 0; person < N_OF_PERSON; person++)
{
for (plurality = 0; plurality < N_OF_PLURAL; plurality++)
{
for (gender = 0; gender < N_OF_GENDER; gender++)
{
name = formNames[person][plurality][gender];
if (0 == strncmp(image, name, strlen(image)))
{
self->gender = gender;
self->plurality = plurality;
self->person = person;
goto out;
}
}
}
}
self = (Form *)(0);
out:
return self;
}
int
Form_isEquivalent(self, x)
Form *self;
Form *x;
{
return self->person == x->person && self->plurality == x->plurality;
}
char *
Form_image(self)
Form *self;
{
return formNames[self->person][self->plurality][self->gender];
}
void
Form_destroy(self)
Form *self;
{
free(self);
}