/*
Copyright (C) 1992 by R. Franklin Buchanan
Permission is granted to any individual or institution to use, copy, or
redistribute this software so long as all of the original files are included
unmodified, that it is not sold for profit, and that this copyright notice
is retained.
---------------------------------------------------------------------
CHANGE HISTORY:
1.0 8 August 1992 - RFB - Initial Release
---------------------------------------------------------------------
*/
#include
#include
#define VERSION "1.0"
/*********************************************************************
* ELEMENTAL TABLES
*
* DESCRIPTION: the Enochian Elemental Tablets
*
* NOTES:
*
*********************************************************************/
static char *ltable[] = {
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
};
static char *rtable[] = {
"rZilafAytlpaeTaOAdvptDnim",
"ardZaidpaLam aabcooromebb",
"czonsaroYavbxTogconxmalGm",
"ToiTtzoPacoCanhodDialeaoc",
"SigasomrbznhrpatAxioVsPsN",
"fmondaTdiaripSaaixaarVroi",
"oroibAhaozpi mpharslgaiol",
"tNabrVixgasdhMamgloinLirx",
"OiiitTpalOai olaaDngaTapa",
"AbamoooaCucaCpaLcoidxPacn",
"NaocOTtnproiondazNziVaasa",
"ocanmagotroimiidPonsdAspi",
"ShialrapmzoxaxrinhtarndiL",
"motib aTnan nanta bitom",
"bOaZaRophaRaadonpaTdanVaa",
"uNnaxoPSondn oloaGeoobaua",
"aigranoomaggmOPamnoVGmdnm",
"orpmningbealoaplsTedecaop",
"rsOnizirlemvCscmioonAmlox",
"izinrCzlaMhlhVarsGdLbriap",
"MordialhCtGa oipteaapDoce",
"OcanchiasomtpPsuacNrZirZa",
"Arbizmiilpiz Siodaoinrzfm",
"OpanalamSmaPrdaltTdnadire",
"dOloPinianbaadixomonsiosp",
"rxpaocsizixpxOoDpziApanli",
"axtirVastrimergoannpACrar"
};
/*********************************************************************
* DATA DEFINITIONS
*
* DESCRIPTION: data definitions used by the extraction code
*
* NOTES:
*
*********************************************************************/
/* maximum filename length */
#define NAMELEN 64
/* maximum buffer size */
#define BFRSIZ 64
typedef enum
{ FALSE,
TRUE,
} boolean;
typedef enum
{ ABS,
REL,
} ORIG;
typedef struct option {
char *keyword;
char *opt;
short match_len;
short copy_len;
boolean requires_parameter;
boolean present;
} OPTION;
typedef struct coord_struct {
short row;
short column;
} COORD;
typedef struct label_struct {
char *name;
char *element;
char *planet;
} LABEL;
typedef struct rule_struct {
COORD *coord;
LABEL *label;
ORIG *origin;
} RULE;
/*********************************************************************
* OPTIONS
*
* DESCRIPTION: command-line options
*
* NOTES:
*
*********************************************************************/
static char filename[NAMELEN+1];
typedef enum
{ TABLE_OPT,
TITLE_OPT,
ALL_OPT,
HOLY_OPT,
KING_OPT,
SENIOR_OPT,
INVOKE_OPT,
COMMAND_OPT,
LESSER_OPT,
ARCH_OPT,
KERUB_OPT,
REVI_OPT,
REVC_OPT,
CAC_OPT,
GREAT_OPT,
AIR_OPT,
WATER_OPT,
EARTH_OPT,
FIRE_OPT,
LOAD_OPT,
HELP_OPT,
LAST_OPT
} COMMAND_ARG;
static OPTION table_option = {"-table", NULL, 3, 0, FALSE, FALSE };
static OPTION title_option = {"-title", NULL, 3, 0, FALSE, FALSE };
static OPTION all_option = {"-all", NULL, 3, 0, FALSE, FALSE };
static OPTION holy_option = {"-holy", NULL, 3, 0, FALSE, FALSE };
static OPTION king_option = {"-king", NULL, 3, 0, FALSE, FALSE };
static OPTION senior_option = {"-senior", NULL, 3, 0, FALSE, FALSE };
static OPTION invoke_option = {"-invoke", NULL, 3, 0, FALSE, FALSE };
static OPTION command_option = {"-command", NULL, 3, 0, FALSE, FALSE };
static OPTION lesser_option = {"-lesser", NULL, 3, 0, FALSE, FALSE };
static OPTION arch_option = {"-arch", NULL, 3, 0, FALSE, FALSE };
static OPTION kerub_option = {"-kerub", NULL, 3, 0, FALSE, FALSE };
static OPTION revi_option = {"-rinvoke", NULL, 3, 0, FALSE, FALSE };
static OPTION revc_option = {"-rcommand", NULL, 3, 0, FALSE, FALSE };
static OPTION cac_option = {"-cacodaemon", NULL, 3, 0, FALSE, FALSE };
static OPTION great_option = {"-great", NULL, 3, 0, FALSE, FALSE };
static OPTION air_option = {"-air", NULL, 3, 0, FALSE, FALSE };
static OPTION water_option = {"-water", NULL, 3, 0, FALSE, FALSE };
static OPTION earth_option = {"-earth", NULL, 3, 0, FALSE, FALSE };
static OPTION fire_option = {"-fire", NULL, 3, 0, FALSE, FALSE };
static OPTION load_option = {"-load", filename, 3, NAMELEN, TRUE, FALSE };
static OPTION help_option = {"-help", NULL, 2, 0, FALSE, FALSE };
static OPTION nul_option = {NULL, NULL, 0, 0, FALSE, FALSE };
static OPTION *parameter_array[] = {
&table_option,
&title_option,
&all_option,
&holy_option,
&king_option,
&senior_option,
&invoke_option,
&command_option,
&lesser_option,
&arch_option,
&kerub_option,
&revi_option,
&revc_option,
&cac_option,
&great_option,
&air_option,
&water_option,
&earth_option,
&fire_option,
&load_option,
&help_option,
&nul_option
};
/*********************************************************************
* RULES
*
* DESCRIPTION: Extraction rules for Enochian Angelic Names
*
* NOTES:
*
*********************************************************************/
COORD sub_tablet[] = {0,0, 0,13, 14,0, 14,13, -1,-1};
LABEL element_name[] = {"Air ",NULL,NULL, "Water",NULL,NULL, "Earth",NULL,NULL, "Fire ",NULL,NULL,};
RULE tablets = {sub_tablet, element_name, NULL};
COORD cnog3[] = {6,0, 6,1, 6,2, -1,-1};
LABEL lnog3[] = {"3 Letter Name",NULL,NULL};
RULE nog_3 = {cnog3, lnog3, NULL};
COORD cnog4[] = {6,3, 6,4, 6,5, 6,6, -1,-1};
LABEL lnog4[] = {"4 Letter Name",NULL,NULL};
RULE nog_4 = {cnog4, lnog4, NULL};
COORD cnog5[] = {6,7, 6,8, 6,9, 6,10, 6,11, -1,-1};
LABEL lnog5[] = {"5 Letter Name",NULL,NULL};
RULE nog_5 = {cnog5, lnog5, NULL};
COORD cking[] = {6,4, 5,5, 5,6, 6,7, 7,6, 7,5, 6,5, 6,6, -1,-1};
LABEL lking[] = {"Elemental King",NULL,NULL};
RULE king = {cking, lking, NULL};
COORD csen1[] = {6,6, 6,5, 6,4, 6,3, 6,2, 6,1, 6,0, -1,-1};
LABEL lsen1[] = {"Senior",NULL,"Mars "};
RULE sen_1 = {csen1, lsen1, NULL};
COORD csen2[] = {6,5, 5,5, 4,5, 3,5, 2,5, 1,5, 0,5, -1,-1};
LABEL lsen2[] = {"Senior",NULL,"Jupiter"};
RULE sen_2 = {csen2, lsen2, NULL};
COORD csen3[] = {6,6, 5,6, 4,6, 3,6, 2,6, 1,6, 0,6, -1,-1};
LABEL lsen3[] = {"Senior",NULL,"Moon "};
RULE sen_3 = {csen3, lsen3, NULL};
COORD csen4[] = {6,5, 6,6, 6,7, 6,8, 6,9, 6,10, 6,11, -1,-1};
LABEL lsen4[] = {"Senior",NULL,"Venus "};
RULE sen_4 = {csen4, lsen4, NULL};
COORD csen5[] = {6,6, 7,6, 8,6, 9,6, 10,6, 11,6, 12,6, -1,-1};
LABEL lsen5[] = {"Senior",NULL,"Saturn "};
RULE sen_5 = {csen5, lsen5, NULL};
COORD csen6[] = {6,5, 7,5, 8,5, 9,5, 10,5, 11,5, 12,5, -1,-1};
LABEL lsen6[] = {"Senior",NULL,"Mercury"};
RULE sen_6 = {csen6, lsen6, NULL};
COORD cinva[] = {0,2, 1,2, 2,2, 3,2, 4,2, 5,2, -1,-1};
LABEL linva[] = {"Invoking Angelic Name","Air ",NULL};
RULE inv_a = {cinva, linva, NULL};
COORD cinvw[] = {0,9, 1,9, 2,9, 3,9, 4,9, 5,9, -1,-1};
LABEL linvw[] = {"Invoking Angelic Name","Water",NULL};
RULE inv_w = {cinvw, linvw, NULL};
COORD cinve[] = {7,2, 8,2, 9,2, 10,2, 11,2, 12,2, -1,-1};
LABEL linve[] = {"Invoking Angelic Name","Earth",NULL};
RULE inv_e = {cinve, linve, NULL};
COORD cinvf[] = {7,9, 8,9, 9,9, 10,9, 11,9, 12,9, -1,-1};
LABEL linvf[] = {"Invoking Angelic Name","Fire ",NULL};
RULE inv_f = {cinvf, linvf, NULL};
COORD ccoma[] = {1,0, 1,1, 1,2, 1,3, 1,4, -1,-1};
LABEL lcoma[] = {"Commanding Angelic Name","Air ",NULL};
RULE com_a = {ccoma, lcoma, NULL};
COORD ccomw[] = {1,7, 1,8, 1,9, 1,10, 1,11, -1,-1};
LABEL lcomw[] = {"Commanding Angelic Name","Water",NULL};
RULE com_w = {ccomw, lcomw, NULL};
COORD ccome[] = {8,0, 8,1, 8,2, 8,3, 8,4, -1,-1};
LABEL lcome[] = {"Commanding Angelic Name","Earth",NULL};
RULE com_e = {ccome, lcome, NULL};
COORD ccomf[] = {8,7, 8,8, 8,9, 8,10, 8,11, -1,-1};
LABEL lcomf[] = {"Commanding Angelic Name","Fire ",NULL};
RULE com_f = {ccomf, lcomf, NULL};
COORD crina[] = {5,2, 4,2, 3,2, 2,2, 1,2, 0,2, -1,-1};
LABEL lrina[] = {"Reversed Invoking Angelic Name","Air ",NULL};
RULE rin_a = {crina, lrina, NULL};
COORD crinw[] = {5,9, 4,9, 3,9, 2,9, 1,9, 0,9, -1,-1};
LABEL lrinw[] = {"Reversed Invoking Angelic Name","Water",NULL};
RULE rin_w = {crinw, lrinw, NULL};
COORD crine[] = {12,2, 11,2, 10,2, 9,2, 8,2, 7,2, -1,-1};
LABEL lrine[] = {"Reversed Invoking Angelic Name","Earth",NULL};
RULE rin_e = {crine, lrine, NULL};
COORD crinf[] = {12,9, 11,9, 10,9, 9,9, 8,9, 7,9, -1,-1};
LABEL lrinf[] = {"Reversed Invoking Angelic Name","Fire ",NULL};
RULE rin_f = {crinf, lrinf, NULL};
COORD crcoa[] = {1,4, 1,3, 1,2, 1,1, 1,0, -1,-1};
LABEL lrcoa[] = {"Reversed Commanding Angelic Name","Air ",NULL};
RULE rco_a = {crcoa, lrcoa, NULL};
COORD crcow[] = {1,11, 1,10, 1,9, 1,8, 1,7, -1,-1};
LABEL lrcow[] = {"Reversed Commanding Angelic Name","Water",NULL};
RULE rco_w = {crcow, lrcow, NULL};
COORD crcoe[] = {8,4, 8,3, 8,2, 8,1, 8,0, -1,-1};
LABEL lrcoe[] = {"Reversed Commanding Angelic Name","Earth",NULL};
RULE rco_e = {crcoe, lrcoe, NULL};
COORD crcof[] = {8,11, 8,10, 8,9, 8,8, 8,7, -1,-1};
LABEL lrcof[] = {"Reversed Commanding Angelic Name","Fire ",NULL};
RULE rco_f = {crcof, lrcof, NULL};
COORD carca[] = {0,12, 0,0, 0,1, 0,3, 0,4, -1,-1};
LABEL larca[] = {"Archangel","Air ",NULL};
ORIG oarca[] = {ABS, REL, REL, REL, REL};
RULE arc_a = {carca, larca, oarca};
COORD carcw[] = {0,12, 0,7, 0,8, 0,10, 0,11, -1,-1};
LABEL larcw[] = {"Archangel","Water",NULL};
ORIG oarcw[] = {ABS, REL, REL, REL, REL};
RULE arc_w = {carcw, larcw, oarcw};
COORD carce[] = {7,12, 7,0, 7,1, 7,3, 7,4, -1,-1};
LABEL larce[] = {"Archangel","Earth",NULL};
ORIG oarce[] = {ABS, REL, REL, REL, REL};
RULE arc_e = {carce, larce, oarce};
COORD carcf[] = {7,12, 7,7, 7,8, 7,10, 7,11, -1,-1};
LABEL larcf[] = {"Archangel","Fire",NULL};
ORIG oarcf[] = {ABS, REL, REL, REL, REL};
RULE arc_f = {carcf, larcf, oarcf};
COORD ckera1[] = {0,0, 0,1, 0,3, 0,4, -1,-1};
LABEL lkera1[] = {"Kerubic Angel","Air ",NULL};
RULE ker_a1 = {ckera1, lkera1, NULL};
COORD ckera2[] = {0,1, 0,3, 0,4, 0,0, -1,-1};
LABEL lkera2[] = {"Kerubic Angel","Air ",NULL};
RULE ker_a2 = {ckera2, lkera2, NULL};
COORD ckera3[] = {0,3, 0,4, 0,0, 0,1, -1,-1};
LABEL lkera3[] = {"Kerubic Angel","Air ",NULL};
RULE ker_a3 = {ckera3, lkera3, NULL};
COORD ckera4[] = {0,4, 0,0, 0,1, 0,3, -1,-1};
LABEL lkera4[] = {"Kerubic Angel","Air ",NULL};
RULE ker_a4 = {ckera4, lkera4, NULL};
COORD ckerw1[] = {0,7, 0,8, 0,10, 0,11, -1,-1};
LABEL lkerw1[] = {"Kerubic Angel","Water",NULL};
RULE ker_w1 = {ckerw1, lkerw1, NULL};
COORD ckerw2[] = {0,8, 0,10, 0,11, 0,7, -1,-1};
LABEL lkerw2[] = {"Kerubic Angel","Water",NULL};
RULE ker_w2 = {ckerw2, lkerw2, NULL};
COORD ckerw3[] = {0,10, 0,11, 0,7, 0,8, -1,-1};
LABEL lkerw3[] = {"Kerubic Angel","Water",NULL};
RULE ker_w3 = {ckerw3, lkerw3, NULL};
COORD ckerw4[] = {0,11, 0,7, 0,8, 0,10, -1,-1};
LABEL lkerw4[] = {"Kerubic Angel","Water",NULL};
RULE ker_w4 = {ckerw4, lkerw4, NULL};
COORD ckere1[] = {7,0, 7,1, 7,3, 7,4, -1,-1};
LABEL lkere1[] = {"Kerubic Angel","Earth",NULL};
RULE ker_e1 = {ckere1, lkere1, NULL};
COORD ckere2[] = {7,1, 7,3, 7,4, 7,0, -1,-1};
LABEL lkere2[] = {"Kerubic Angel","Earth",NULL};
RULE ker_e2 = {ckere2, lkere2, NULL};
COORD ckere3[] = {7,3, 7,4, 7,0, 7,1, -1,-1};
LABEL lkere3[] = {"Kerubic Angel","Earth",NULL};
RULE ker_e3 = {ckere3, lkere3, NULL};
COORD ckere4[] = {7,4, 7,0, 7,1, 7,3, -1,-1};
LABEL lkere4[] = {"Kerubic Angel","Earth",NULL};
RULE ker_e4 = {ckere4, lkere4, NULL};
COORD ckerf1[] = {7,7, 7,8, 7,10, 7,11, -1,-1};
LABEL lkerf1[] = {"Kerubic Angel","Fire ",NULL};
RULE ker_f1 = {ckerf1, lkerf1, NULL};
COORD ckerf2[] = {7,8, 7,10, 7,11, 7,7, -1,-1};
LABEL lkerf2[] = {"Kerubic Angel","Fire ",NULL};
RULE ker_f2 = {ckerf2, lkerf2, NULL};
COORD ckerf3[] = {7,10, 7,11, 7,7, 7,8, -1,-1};
LABEL lkerf3[] = {"Kerubic Angel","Fire ",NULL};
RULE ker_f3 = {ckerf3, lkerf3, NULL};
COORD ckerf4[] = {7,11, 7,7, 7,8, 7,10, -1,-1};
LABEL lkerf4[] = {"Kerubic Angel","Fire ",NULL};
RULE ker_f4 = {ckerf4, lkerf4, NULL};
COORD cle1a[] = {2,0, 2,1, 2,3, 2,4, -1,-1};
LABEL lle1a[] = {"Lesser Angel","Air ",NULL};
RULE le1_a = {cle1a, lle1a, NULL};
COORD cle2a[] = {3,0, 3,1, 3,3, 3,4, -1,-1};
LABEL lle2a[] = {"Lesser Angel","Air ",NULL};
RULE le2_a = {cle2a, lle2a, NULL};
COORD cle3a[] = {4,0, 4,1, 4,3, 4,4, -1,-1};
LABEL lle3a[] = {"Lesser Angel","Air ",NULL};
RULE le3_a = {cle3a, lle3a, NULL};
COORD cle4a[] = {5,0, 5,1, 5,3, 5,4, -1,-1};
LABEL lle4a[] = {"Lesser Angel","Air ",NULL};
RULE le4_a = {cle4a, lle4a, NULL};
COORD cle1w[] = {2,7, 2,8, 2,10, 2,11, -1,-1};
LABEL lle1w[] = {"Lesser Angel","Water",NULL};
RULE le1_w = {cle1w, lle1w, NULL};
COORD cle2w[] = {3,7, 3,8, 3,10, 3,11, -1,-1};
LABEL lle2w[] = {"Lesser Angel","Water",NULL};
RULE le2_w = {cle2w, lle2w, NULL};
COORD cle3w[] = {4,7, 4,8, 4,10, 4,11, -1,-1};
LABEL lle3w[] = {"Lesser Angel","Water",NULL};
RULE le3_w = {cle3w, lle3w, NULL};
COORD cle4w[] = {5,7, 5,8, 5,10, 5,11, -1,-1};
LABEL lle4w[] = {"Lesser Angel","Water",NULL};
RULE le4_w = {cle4w, lle4w, NULL};
COORD cle1e[] = {9,0, 9,1, 9,3, 9,4, -1,-1};
LABEL lle1e[] = {"Lesser Angel","Earth",NULL};
RULE le1_e = {cle1e, lle1e, NULL};
COORD cle2e[] = {10,0, 10,1, 10,3, 10,4, -1,-1};
LABEL lle2e[] = {"Lesser Angel","Earth",NULL};
RULE le2_e = {cle2e, lle2e, NULL};
COORD cle3e[] = {11,0, 11,1, 11,3, 11,4, -1,-1};
LABEL lle3e[] = {"Lesser Angel","Earth",NULL};
RULE le3_e = {cle3e, lle3e, NULL};
COORD cle4e[] = {12,0, 12,1, 12,3, 12,4, -1,-1};
LABEL lle4e[] = {"Lesser Angel","Earth",NULL};
RULE le4_e = {cle4e, lle4e, NULL};
COORD cle1f[] = {9,7, 9,8, 9,10, 9,11, -1,-1};
LABEL lle1f[] = {"Lesser Angel","Fire ",NULL};
RULE le1_f = {cle1f, lle1f, NULL};
COORD cle2f[] = {10,7, 10,8, 10,10, 10,11, -1,-1};
LABEL lle2f[] = {"Lesser Angel","Fire ",NULL};
RULE le2_f = {cle2f, lle2f, NULL};
COORD cle3f[] = {11,7, 11,8, 11,10, 11,11, -1,-1};
LABEL lle3f[] = {"Lesser Angel","Fire ",NULL};
RULE le3_f = {cle3f, lle3f, NULL};
COORD cle4f[] = {12,7, 12,8, 12,10, 12,11, -1,-1};
LABEL lle4f[] = {"Lesser Angel","Fire ",NULL};
RULE le4_f = {cle4f, lle4f, NULL};
COORD cca1a[] = {2,12, 2,0, 2,1, -1,-1};
LABEL lca1a[] = {"Cacodaemon","Air ",NULL};
ORIG oca1a[] = {ABS, REL, REL};
RULE ca1_a = {cca1a, lca1a, oca1a};
COORD cca2a[] = {3,12, 3,0, 3,1, -1,-1};
LABEL lca2a[] = {"Cacodaemon","Air ",NULL};
ORIG oca2a[] = {ABS, REL, REL};
RULE ca2_a = {cca2a, lca2a, oca2a};
COORD cca3a[] = {4,12, 4,0, 4,1, -1,-1};
LABEL lca3a[] = {"Cacodaemon","Air ",NULL};
ORIG oca3a[] = {ABS, REL, REL};
RULE ca3_a = {cca3a, lca3a, oca3a};
COORD cca4a[] = {5,12, 5,0, 5,1, -1,-1};
LABEL lca4a[] = {"Cacodaemon","Air ",NULL};
ORIG oca4a[] = {ABS, REL, REL};
RULE ca4_a = {cca4a, lca4a, oca4a};
COORD cca1w[] = {2,12, 2,7, 2,8, -1,-1};
LABEL lca1w[] = {"Cacodaemon","Water",NULL};
ORIG oca1w[] = {ABS, REL, REL};
RULE ca1_w = {cca1w, lca1w, oca1w};
COORD cca2w[] = {3,12, 3,7, 3,8, -1,-1};
LABEL lca2w[] = {"Cacodaemon","Water",NULL};
ORIG oca2w[] = {ABS, REL, REL};
RULE ca2_w = {cca2w, lca2w, oca2w};
COORD cca3w[] = {4,12, 4,7, 4,8, -1,-1};
LABEL lca3w[] = {"Cacodaemon","Water",NULL};
ORIG oca3w[] = {ABS, REL, REL};
RULE ca3_w = {cca3w, lca3w, oca3w};
COORD cca4w[] = {5,12, 5,7, 5,8, -1,-1};
LABEL lca4w[] = {"Cacodaemon","Water",NULL};
ORIG oca4w[] = {ABS, REL, REL};
RULE ca4_w = {cca4w, lca4w, oca4w};
COORD cca1e[] = {9,12, 9,0, 9,1, -1,-1};
LABEL lca1e[] = {"Cacodaemon","Earth",NULL};
ORIG oca1e[] = {ABS, REL, REL};
RULE ca1_e = {cca1e, lca1e, oca1e};
COORD cca2e[] = {10,12, 10,0, 10,1, -1,-1};
LABEL lca2e[] = {"Cacodaemon","Earth",NULL};
ORIG oca2e[] = {ABS, REL, REL};
RULE ca2_e = {cca2e, lca2e, oca2e};
COORD cca3e[] = {11,12, 11,0, 11,1, -1,-1};
LABEL lca3e[] = {"Cacodaemon","Earth",NULL};
ORIG oca3e[] = {ABS, REL, REL};
RULE ca3_e = {cca3e, lca3e, oca3e};
COORD cca4e[] = {12,12, 12,0, 12,1, -1,-1};
LABEL lca4e[] = {"Cacodaemon","Earth",NULL};
ORIG oca4e[] = {ABS, REL, REL};
RULE ca4_e = {cca4e, lca4e, oca4e};
COORD cca1f[] = {9,12, 9,7, 9,8, -1,-1};
LABEL lca1f[] = {"Cacodaemon","Fire ",NULL};
ORIG oca1f[] = {ABS, REL, REL};
RULE ca1_f = {cca1f, lca1f, oca1f};
COORD cca2f[] = {10,12, 10,7, 10,8, -1,-1};
LABEL lca2f[] = {"Cacodaemon","Fire ",NULL};
ORIG oca2f[] = {ABS, REL, REL};
RULE ca2_f = {cca2f, lca2f, oca2f};
COORD cca3f[] = {11,12, 11,7, 11,8, -1,-1};
LABEL lca3f[] = {"Cacodaemon","Fire ",NULL};
ORIG oca3f[] = {ABS, REL, REL};
RULE ca3_f = {cca3f, lca3f, oca3f};
COORD cca4f[] = {12,12, 12,7, 12,8, -1,-1};
LABEL lca4f[] = {"Cacodaemon","Fire ",NULL};
ORIG oca4f[] = {ABS, REL, REL};
RULE ca4_f = {cca4f, lca4f, oca4f};
/*********************************************************************
* MAPS
*
* DESCRIPTION: arrays of pointers to extraction rules for Enochian
* Angelic names
*
* NOTES:
*
*********************************************************************/
RULE *nog_map[] = { /* 3,4 & 5-fold Secret Holy Names */
&nog_3,
&nog_4,
&nog_5,
NULL
};
RULE *kin_map[] = { /* Elemental King */
&king,
NULL
};
RULE *sen_map[] = { /* Seniors */
&sen_1,
&sen_2,
&sen_3,
&sen_4,
&sen_5,
&sen_6,
NULL
};
RULE *inv_map[] = { /* Invoking Names */
&inv_a,
&inv_w,
&inv_e,
&inv_f,
NULL
};
RULE *com_map[] = { /* Commanding Names */
&com_a,
&com_w,
&com_e,
&com_f,
NULL
};
RULE *rin_map[] = { /* Reversed Invoking Names */
&rin_a,
&rin_w,
&rin_e,
&rin_f,
NULL
};
RULE *rco_map[] = { /* Reversed Commanding Names */
&rco_a,
&rco_w,
&rco_e,
&rco_f,
NULL
};
RULE *les_map[] = { /* Lesser Angelic Names */
&le1_a,
&le2_a,
&le3_a,
&le4_a,
&le1_w,
&le2_w,
&le3_w,
&le4_w,
&le1_e,
&le2_e,
&le3_e,
&le4_e,
&le1_f,
&le2_f,
&le3_f,
&le4_f,
NULL
};
RULE *arc_map[] = { /* Archangelic Names */
&arc_a,
&arc_w,
&arc_e,
&arc_f,
NULL
};
RULE *ker_map[] = { /* Kerubic Angelic Names */
&ker_a1,
&ker_a2,
&ker_a3,
&ker_a4,
&ker_w1,
&ker_w2,
&ker_w3,
&ker_w4,
&ker_e1,
&ker_e2,
&ker_e3,
&ker_e4,
&ker_f1,
&ker_f2,
&ker_f3,
&ker_f4,
NULL
};
RULE *cac_map[] = { /* Cacodaemon Names */
&ca1_a,
&ca2_a,
&ca3_a,
&ca4_a,
&ca1_w,
&ca2_w,
&ca3_w,
&ca4_w,
&ca1_e,
&ca2_e,
&ca3_e,
&ca4_e,
&ca1_f,
&ca2_f,
&ca3_f,
&ca4_f,
NULL
};
/*********************************************************************
* GETOPTS
*
* DESCRIPTION: acquires and stores command-line options
*
* NOTES:
*
*********************************************************************/
static short getopts(int argc, char **argv)
{
short optind, a, args;
for (args = 0, optind = 1;(optind < argc) && (argv[optind][0] == '-');optind++)
{ for (a = 0;parameter_array[a]->keyword;a++)
{ if (!strncmp(parameter_array[a]->keyword, argv[optind], parameter_array[a]->match_len) &&
(parameter_array[a]->present == FALSE) )
{ if (parameter_array[a]->requires_parameter)
{ strncpy(parameter_array[a]->opt, argv[optind + 1], parameter_array[a]->copy_len);
++optind;
}
parameter_array[a]->present = TRUE;
++args;
break;
}
}
}
return(args);
}
/*********************************************************************
* GET ARG
*
* DESCRIPTION: returns a pointer to the specified option block
*
* NOTES:
*
*********************************************************************/
static OPTION *get_arg(COMMAND_ARG arg)
{
return(parameter_array[arg]);
}
/*********************************************************************
* STRPAD
*
* DESCRIPTION: pads or truncates a string to the specified length
*
* NOTES:
*
*********************************************************************/
static char *strpad(char *wrk, short newlen)
{
short len;
if ((len = strlen(wrk)) == newlen)
return (wrk);
else
{ if (len > newlen)
len = newlen;
else
{ while (len < newlen)
wrk[len++] = ' ';
}
}
wrk[len] = 0x00;
return (wrk);
}
/*********************************************************************
* STRUPPER
*
* DESCRIPTION: uppercases a string
*
* NOTES:
*
*********************************************************************/
static char *strupper(char *wrk)
{
char* str;
str = wrk;
while(*str)
{ *str = toupper(*str);
++str;
}
return(wrk);
}
/*********************************************************************
* EXTRACT NAME
*
* DESCRIPTION: extracts a name from the 'table' using the specified
* map, map entry index, and table index, and copies it
* to bfr
*
* NOTES:
*
*********************************************************************/
static char *extract_name(short tabndx, RULE **map, short map_entry, char *bfr, char **table)
{
short j, column_offset;
for (j = 0;map[map_entry]->coord[j].row > -1;j++)
{ column_offset = tablets.coord[tabndx].column;
if (map[map_entry]->origin)
{ if (map[map_entry]->origin[j] == ABS)
column_offset = 0;
}
bfr[j] = table[map[map_entry]->coord[j].row + tablets.coord[tabndx].row][map[map_entry]->coord[j].column + column_offset];
}
bfr[j] = 0;
return(bfr);
}
/*********************************************************************
* PRINT NAMES
*
* DESCRIPTION: prints, and optionally describes, all names associated
* with the specified map and table index
*
* NOTES:
*
*********************************************************************/
static void print_names(boolean title, short tabndx, RULE **map, char **table)
{
short map_entry;
char bfr[17];
for (map_entry = 0;map[map_entry];map_entry++)
{ strpad(extract_name(tabndx, map, map_entry, bfr, table), 10);
if (title)
{ if (map[map_entry]->label->element)
{ printf("%s%s, %s of %s\n", bfr, map[map_entry]->label->name, map[map_entry]->label->element, tablets.label[tabndx].name);
}
else
{ if (map[map_entry]->label->planet)
printf("%s%s %s of %s\n", bfr, map[map_entry]->label->planet, map[map_entry]->label->name, tablets.label[tabndx].name);
else
printf("%s%s of %s\n", bfr, map[map_entry]->label->name, tablets.label[tabndx].name);
}
}
else
printf("%s\n", bfr);
}
}
/*********************************************************************
* PRINT TABLE
*
* DESCRIPTION: prints the elemental table given by tabndx
*
* NOTES:
*
*********************************************************************/
static void print_table(short tabndx, char **table)
{
short i, j;
char bfr[32];
sprintf(bfr, "\nTablet of %s\n", tablets.label[tabndx].name);
puts(strupper(bfr));
for (i = tablets.coord[tabndx].row;i < (tablets.coord[tabndx].row+13);i++)
{ for (j = tablets.coord[tabndx].column;j < (tablets.coord[tabndx].column + 12);j++)
{ putchar(table[i][j]);
}
putchar('\n');
}
putchar('\n');
}
/*********************************************************************
* EXTRACT
*
* DESCRIPTION: performs specified name extractions on the elemental
* table given by tabndx
*
* NOTES:
*
*********************************************************************/
static void extract(short tabndx, char **table)
{
boolean all, title;
if (get_arg(TABLE_OPT)->present)
print_table(tabndx, table);
all = get_arg(ALL_OPT)->present;
title = get_arg(TITLE_OPT)->present;
if (all || get_arg(HOLY_OPT)->present)
print_names(title, tabndx, nog_map, table);
if (all || get_arg(KING_OPT)->present)
print_names(title, tabndx, kin_map, table);
if (all || get_arg(SENIOR_OPT)->present)
print_names(title, tabndx, sen_map, table);
if (all || get_arg(INVOKE_OPT)->present)
print_names(title, tabndx, inv_map, table);
if (all || get_arg(COMMAND_OPT)->present)
print_names(title, tabndx, com_map, table);
if (all || get_arg(LESSER_OPT)->present)
print_names(title, tabndx, les_map, table);
if (all || get_arg(ARCH_OPT)->present)
print_names(title, tabndx, arc_map, table);
if (all || get_arg(KERUB_OPT)->present)
print_names(title, tabndx, ker_map, table);
if (all || get_arg(REVI_OPT)->present)
print_names(title, tabndx, rin_map, table);
if (all || get_arg(REVC_OPT)->present)
print_names(title, tabndx, rco_map, table);
if (all || get_arg(CAC_OPT)->present)
print_names(title, tabndx, cac_map, table);
}
/*********************************************************************
* LOAD TABLE
*
* DESCRIPTION: loads the reference Enochian Table from disk
*
* NOTES:
*
*********************************************************************/
static boolean load_table(void)
{
short i;
FILE *fd;
char *fn, bfr[BFRSIZ+1];
boolean status;
status = FALSE;
if ((fd = fopen((fn = get_arg(LOAD_OPT)->opt), "r")) != NULL)
{ status = TRUE;
for (i = 0;i < 27;i++)
{ fgets(bfr, BFRSIZ, fd);
strpad(bfr, 25);
strncpy(ltable[i], bfr, 25);
}
fclose(fd);
fprintf(stderr, "*** Loaded Enochian Tablets from %s ***\n", fn);
}
else
fprintf(stderr, "*** Unable to Load Enochian Tablets from %s ***\n", fn);
return(status);
}
/*********************************************************************
* MAIN
*
* DESCRIPTION: program main entry point
*
* NOTES:
*
*********************************************************************/
main(int argc, char **argv)
{
boolean status, great;
char **table;
short tabndx;
fprintf(stderr, "%s - Release %s\n", argv[0], VERSION);
getopts(argc, argv);
if (!get_arg(HELP_OPT)->present)
{ if (get_arg(LOAD_OPT)->present)
{ if (load_table() == TRUE)
table = ltable;
else
table = NULL;
}
else
table = NULL;
if (!table)
{ table = rtable;
fprintf(stderr, "*** Using the Tabula Recensa ***\n");
}
great = get_arg(GREAT_OPT)->present;
for (tabndx = 0;tablets.coord[tabndx].row > -1;tabndx++)
{ switch (tabndx)
{ case 0:
if (great || get_arg(AIR_OPT)->present)
extract(tabndx, table);
break;
case 1:
if (great || get_arg(WATER_OPT)->present)
extract(tabndx, table);
break;
case 2:
if (great || get_arg(EARTH_OPT)->present)
extract(tabndx, table);
break;
case 3:
if (great || get_arg(FIRE_OPT)->present)
extract(tabndx, table);
break;
default:
break;
}
}
}
else
{ fprintf(stderr, "Usage: %s [options...]\n", argv[0]);
fprintf(stderr, "Options: -ta[ble] - prints the selected Tablet\n");
fprintf(stderr, "Options: -ti[tle] - prints titles of extracted Names\n");
fprintf(stderr, "Options: -al[l] - extracts all Names\n");
fprintf(stderr, "Options: -ho[ly] - extracts 3/4/5 letter Names\n");
fprintf(stderr, "Options: -ki[ng] - extracts Elemental King Names\n");
fprintf(stderr, "Options: -se[nior] - extracts Elemental Senior Names\n");
fprintf(stderr, "Options: -in[voke] - extracts Invoking Angelic Names\n");
fprintf(stderr, "Options: -co[mmand] - extracts Commanding Angelic Names\n");
fprintf(stderr, "Options: -le[sser] - extracts Lesser Angelic Names\n");
fprintf(stderr, "Options: -ke[rub] - extracts Kerubic Angelic Names\n");
fprintf(stderr, "Options: -ri[nvoke] - extracts Reversed Invoking Names\n");
fprintf(stderr, "Options: -rc[ommand] - extracts Reversed Commanding Names\n");
fprintf(stderr, "Options: -ca[codaemon] - extracts Cacodaemonic Names\n");
fprintf(stderr, "Options: -gr[eat] - extracts Names from all Tablets\n");
fprintf(stderr, "Options: -ai[r] - extracts Names from the Air Tablet\n");
fprintf(stderr, "Options: -wa[ter] - extracts Names from the Water Tablet\n");
fprintf(stderr, "Options: -ea[rth] - extracts Names from the Earth Tablet\n");
fprintf(stderr, "Options: -fi[re] - extracts Names from the Fire Tablet\n");
fprintf(stderr, "Options: -lo[ad] {file} - load Tablets from file\n");
fprintf(stderr, "Options: -h[elp] - prints this message\n");
fprintf(stderr, "Example: %s -load wombat -air -seniors\n", argv[0]);
}
return(0);
}