#include "fips181.h"
#include <string.h>
#define MAX_RETRIES (4 * pwlen + NUM_RULES)
struct FIPS181::unit FIPS181::rules[NUM_RULES] =
{
{ "a", VOWEL },
{ "b", NO_SPECIAL_RULE },
{ "c", NO_SPECIAL_RULE },
{ "d", NO_SPECIAL_RULE },
{ "e", NO_FINAL_SPLIT | VOWEL },
{ "f", NO_SPECIAL_RULE },
{ "g", NO_SPECIAL_RULE },
{ "h", NO_SPECIAL_RULE },
{ "i", VOWEL },
{ "j", NO_SPECIAL_RULE },
{ "k", NO_SPECIAL_RULE },
{ "l", NO_SPECIAL_RULE },
{ "m", NO_SPECIAL_RULE },
{ "n", NO_SPECIAL_RULE },
{ "o", VOWEL },
{ "p", NO_SPECIAL_RULE },
{ "r", NO_SPECIAL_RULE },
{ "s", NO_SPECIAL_RULE },
{ "t", NO_SPECIAL_RULE },
{ "u", VOWEL },
{ "v", NO_SPECIAL_RULE },
{ "w", NO_SPECIAL_RULE },
{ "x", NOT_BEGIN_SYLLABLE },
{ "y", ALTERNATE_VOWEL | VOWEL },
{ "z", NO_SPECIAL_RULE },
{ "ch", NO_SPECIAL_RULE },
{ "gh", NO_SPECIAL_RULE },
{ "ph", NO_SPECIAL_RULE },
{ "rh", NO_SPECIAL_RULE },
{ "sh", NO_SPECIAL_RULE },
{ "th", NO_SPECIAL_RULE },
{ "wh", NO_SPECIAL_RULE },
{ "qu", NO_SPECIAL_RULE },
{ "ck", NOT_BEGIN_SYLLABLE }
};
unsigned int FIPS181::digram[NUM_RULES][NUM_RULES] =
{
{
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
BREAK | NOT_END,
ANY_COMBINATION
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | SUFFIX | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
SUFFIX | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_END,
NOT_BEGIN | END,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | SUFFIX | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | NOT_END,
NOT_BEGIN | END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | NOT_END,
NOT_BEGIN | PREFIX,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_END,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
BREAK,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
BREAK | NOT_END,
ANY_COMBINATION
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | SUFFIX | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | NOT_END,
NOT_BEGIN,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
BEGIN | SUFFIX | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | NOT_END,
NOT_BEGIN | END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
BREAK,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
BREAK | NOT_END,
ANY_COMBINATION
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
SUFFIX | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | SUFFIX | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
SUFFIX | NOT_END,
NOT_BEGIN | END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
ILLEGAL_PAIR,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX
},
{
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
BREAK | NOT_END,
ANY_COMBINATION
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
SUFFIX | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_END,
NOT_BEGIN | END,
NOT_BEGIN | END,
NOT_BEGIN | END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
ILLEGAL_PAIR,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
ILLEGAL_PAIR,
NOT_BEGIN | PREFIX | NOT_END,
NOT_BEGIN | PREFIX
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
BEGIN | SUFFIX | NOT_END,
SUFFIX | NOT_END,
PREFIX | SUFFIX | NOT_END,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | NOT_END,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | SUFFIX | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | SUFFIX | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
SUFFIX | NOT_END,
NOT_BEGIN
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_END,
NOT_BEGIN | END,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | SUFFIX | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | END,
ILLEGAL_PAIR,
NOT_BEGIN | END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | BREAK,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
ILLEGAL_PAIR,
ANY_COMBINATION,
ANY_COMBINATION,
ILLEGAL_PAIR,
BREAK | NOT_END,
ANY_COMBINATION
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX | END,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX | END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX | SUFFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
BEGIN | SUFFIX | NOT_END,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | PREFIX,
ANY_COMBINATION,
NOT_BEGIN | PREFIX,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN
},
{
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN,
NOT_BEGIN | NOT_END,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | NOT_END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | NOT_END,
NOT_BEGIN | NOT_END,
NOT_BEGIN,
NOT_BEGIN | NOT_END,
NOT_BEGIN,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
SUFFIX | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
BEGIN | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
BEGIN | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | PREFIX,
NOT_BEGIN | PREFIX,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | PREFIX | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
BEGIN | SUFFIX | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_END,
NOT_BEGIN,
NOT_BEGIN,
ANY_COMBINATION,
NOT_BEGIN | NOT_END,
NOT_BEGIN | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
BEGIN | SUFFIX | NOT_END,
BEGIN | SUFFIX | NOT_END,
BEGIN | SUFFIX | NOT_END,
ANY_COMBINATION,
NOT_BEGIN,
BEGIN | SUFFIX | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
SUFFIX,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
SUFFIX | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_END,
NOT_BEGIN | END,
NOT_BEGIN | BREAK | NOT_END,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
SUFFIX | NOT_END,
ILLEGAL_PAIR,
ANY_COMBINATION,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
},
{
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
BEGIN | NOT_END,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR
},
{
ANY_COMBINATION,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ANY_COMBINATION,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ANY_COMBINATION,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ANY_COMBINATION,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR,
ILLEGAL_PAIR
},
{
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR,
NOT_BEGIN | BREAK | NOT_END,
ILLEGAL_PAIR
}
};
FIPS181::FIPS181(unsigned int (*randfunc)())
: saved_unit(0),
randfunc_(randfunc)
{
}
int FIPS181::randomword(std::string& word, std::string& hyphenated_word, unsigned int minlen, unsigned int maxlen)
{
if (minlen > maxlen)
return -1;
if (maxlen == 0)
{
word[0] = '\0';
hyphenated_word[0] = '\0';
return 0;
}
int pwlen = get_word(word, hyphenated_word, get_random(minlen, maxlen));
return pwlen;
}
int FIPS181::get_word(std::string& word, std::string& hyphenated_word, unsigned int pwlen)
{
unsigned int tries = 0;
unsigned int word_length = 0;
unsigned int word_size = 0;
unsigned int* word_units = new unsigned int[pwlen];
unsigned int* syllable_units = new unsigned int[pwlen];
std::string new_syllable;
while (word_length < pwlen)
{
unsigned int syllable_size;
get_syllable(new_syllable, pwlen - word_length, syllable_units, &syllable_size);
unsigned int syllable_length = new_syllable.size();
for (unsigned int word_place = 0; word_place <= syllable_size; word_place++)
{
word_units[word_size + word_place] = syllable_units[word_place];
}
word_size += syllable_size + 1;
if (improper_word(word_units, word_size) ||
((word_length == 0) &&
have_initial_y (syllable_units, syllable_size)) ||
((word_length + syllable_length == pwlen) &&
have_final_split (syllable_units, syllable_size)))
{
word_size -= syllable_size + 1;
}
else
{
if (word_length == 0)
{
word += new_syllable;
hyphenated_word += new_syllable;
}
else
{
word += new_syllable;
hyphenated_word += "-";
hyphenated_word += new_syllable;
}
word_length += syllable_length;
}
tries++;
if (tries > MAX_RETRIES)
{
word_length = 0;
word_size = 0;
tries = 0;
word = "";
hyphenated_word = "";
}
}
delete [] syllable_units;
delete [] word_units;
return word_length;
}
bool FIPS181::improper_word(unsigned int* units, unsigned int word_size)
{
bool failure = false;
for (unsigned int unit_count = 0; !failure && (unit_count < word_size);
unit_count++)
{
if ((unit_count != 0) &&
(digram[units[unit_count - 1]][units[unit_count]] & ILLEGAL_PAIR))
{
failure = true;
}
if (!failure && unit_count >= 2)
{
if ((((rules[units[unit_count - 2]].flags & VOWEL) &&
!(rules[units[unit_count - 2]].flags & ALTERNATE_VOWEL)) &&
(rules[units[unit_count - 1]].flags & VOWEL) &&
(rules[units[unit_count]].flags & VOWEL)) ||
(!(rules[units[unit_count - 2]].flags & VOWEL) &&
!(rules[units[unit_count - 1]].flags & VOWEL) &&
!(rules[units[unit_count]].flags & VOWEL)))
{
failure = true;
}
}
}
return failure;
}
bool FIPS181::have_initial_y(unsigned int* units, unsigned int unit_size)
{
unsigned int vowel_count = 0;
unsigned int normal_vowel_count = 0;
for (unsigned int unit_count = 0; unit_count <= unit_size; unit_count++)
{
if (rules[units[unit_count]].flags & VOWEL)
{
vowel_count++;
if (!(rules[units[unit_count]].flags & ALTERNATE_VOWEL) ||
(unit_count != 0))
{
normal_vowel_count++;
}
}
}
return (vowel_count <= 1) && (normal_vowel_count == 0);
}
bool FIPS181::have_final_split(unsigned int* units, unsigned int unit_size)
{
unsigned int vowel_count = 0;
for (unsigned int unit_count = 0; unit_count <= unit_size; unit_count++)
{
if (rules[units[unit_count]].flags & VOWEL)
vowel_count++;
}
return (vowel_count == 1) && (rules[units[unit_size]].flags & NO_FINAL_SPLIT);
}
void FIPS181::get_syllable(std::string& syllable, unsigned int pwlen, unsigned int* units_in_syllable, unsigned int* syllable_length)
{
bool rule_broken;
#define ALLOWED(flag) (digram[units_in_syllable[current_unit - 1]][unit] & (flag))
unsigned int hold_saved_unit = saved_unit;
do
{
unsigned int tries = 0;
saved_unit = hold_saved_unit;
syllable = "";
unsigned int vowel_count = 0;
int current_unit = 0;
int length_left = pwlen;
bool want_another_unit = true;
do
{
bool want_vowel = false;
unsigned int unit;
unsigned int last_unit = 0;
do
{
if (saved_unit != 0)
{
if (saved_unit == 2)
{
units_in_syllable[0] = saved_pair[1];
if (rules[saved_pair[1]].flags & VOWEL)
vowel_count++;
current_unit++;
syllable = rules[saved_pair[1]].unit_code;
length_left -= syllable.size();
}
unit = saved_pair[0];
saved_unit = 0;
}
else
{
if (want_vowel)
unit = random_unit(VOWEL);
else
unit = random_unit(NO_SPECIAL_RULE);
}
length_left -= strlen(rules[unit].unit_code);
if (length_left < 0)
rule_broken = true;
else
rule_broken = false;
if (current_unit == 0)
{
if (rules[unit].flags & NOT_BEGIN_SYLLABLE)
rule_broken = true;
else
{
if (length_left == 0)
{
if (rules[unit].flags & VOWEL)
want_another_unit = false;
else
rule_broken = true;
}
}
}
else
{
if ((ALLOWED (ILLEGAL_PAIR)) ||
(ALLOWED (BREAK) && (vowel_count == 0)) ||
(ALLOWED (END) && (vowel_count == 0) &&
!(rules[unit].flags & VOWEL)))
rule_broken = true;
if (current_unit == 1)
{
if (ALLOWED (NOT_BEGIN))
rule_broken = true;
}
else
{
last_unit = units_in_syllable[current_unit - 1];
if (((current_unit == 2) &&
(ALLOWED (BEGIN)) &&
(rules[units_in_syllable[0]].flags & ALTERNATE_VOWEL)) ||
(ALLOWED (NOT_END) &&
(length_left == 0)) ||
(ALLOWED (BREAK) &&
(digram[units_in_syllable[current_unit - 2]]
[last_unit] &
NOT_END)) ||
(ALLOWED (PREFIX) &&
!(rules[units_in_syllable
[current_unit - 2]].flags & VOWEL)))
rule_broken = true;
if (!rule_broken &&
(rules[unit].flags & VOWEL) &&
((length_left > 0) ||
!(rules[last_unit].flags & NO_FINAL_SPLIT)))
{
if ((vowel_count > 1) &&
(rules[last_unit].flags & VOWEL))
rule_broken = true;
else
{
if ((vowel_count != 0) &&
!(rules[last_unit].flags & VOWEL))
{
if (digram[units_in_syllable[current_unit - 2]]
[last_unit] & NOT_END)
rule_broken = true;
else
{
saved_unit = 1;
saved_pair[0] = unit;
want_another_unit = false;
}
}
}
}
}
if (!rule_broken && want_another_unit)
{
if (((vowel_count != 0) &&
(rules[unit].flags & NO_FINAL_SPLIT) &&
(length_left == 0) &&
!(current_unit > 1 && rules[last_unit].flags & VOWEL)) ||
(ALLOWED (END) || (length_left == 0)))
{
want_another_unit = false;
}
else
{
if ((vowel_count != 0) && (length_left > 0))
{
if (ALLOWED (BEGIN) &&
(current_unit > 1) &&
!((vowel_count == 1) &&
(rules[last_unit].flags & VOWEL)))
{
saved_unit = 2;
saved_pair[0] = unit;
saved_pair[1] = last_unit;
want_another_unit = false;
}
else if (ALLOWED (BREAK))
{
saved_unit = 1;
saved_pair[0] = unit;
want_another_unit = false;
}
}
else
{
if (ALLOWED (SUFFIX))
want_vowel = true;
}
}
}
}
tries++;
if (rule_broken)
length_left += strlen(rules[unit].unit_code);
}
while (rule_broken && (tries <= MAX_RETRIES));
if (tries <= MAX_RETRIES)
{
if ((rules[unit].flags & VOWEL) &&
((current_unit > 0) ||
!(rules[unit].flags & ALTERNATE_VOWEL)))
vowel_count++;
switch (saved_unit)
{
case 0:
units_in_syllable[current_unit] = unit;
syllable += rules[unit].unit_code;
break;
case 1:
current_unit--;
break;
case 2:
syllable.resize( syllable.size() - strlen(rules[last_unit].unit_code) );
length_left += strlen(rules[last_unit].unit_code);
current_unit -= 2;
break;
}
}
else
{
rule_broken = true;
}
*syllable_length = current_unit;
current_unit++;
}
while ((tries <= MAX_RETRIES) && want_another_unit);
}
while (rule_broken || illegal_placement(units_in_syllable, *syllable_length));
#undef ALLOWED
}
bool FIPS181::illegal_placement(unsigned int* units, unsigned int pwlen)
{
unsigned int vowel_count = 0;
bool failure = false;
for(unsigned int unit_count = 0; !failure && (unit_count <= pwlen);
unit_count++)
{
if (unit_count >= 1)
{
if ((!(rules[units[unit_count - 1]].flags & VOWEL) &&
(rules[units[unit_count]].flags & VOWEL) &&
!((rules[units[unit_count]].flags & NO_FINAL_SPLIT) && (unit_count == pwlen)) &&
(vowel_count != 0)) ||
((unit_count >= 2) &&
((!(rules[units[unit_count - 2]].flags & VOWEL) &&
!(rules[units[unit_count - 1]].flags & VOWEL) &&
!(rules[units[unit_count]].flags & VOWEL)) ||
(((rules[units[unit_count - 2]].flags & VOWEL) &&
!((rules[units[0]].flags & ALTERNATE_VOWEL) &&
(unit_count == 2))) &&
(rules[units[unit_count - 1]].flags & VOWEL) &&
(rules[units[unit_count]].flags & VOWEL)))))
failure = true;
}
if ((rules[units[unit_count]].flags & VOWEL) &&
!((rules[units[0]].flags & ALTERNATE_VOWEL) &&
(unit_count == 0) && (pwlen != 0)))
vowel_count++;
}
return failure;
}
unsigned int FIPS181::random_unit(unsigned int type)
{
static const unsigned int numbers[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
9, 9, 9, 9, 9, 9, 9, 9,
10, 10, 10, 10, 10, 10, 10, 10,
11, 11, 11, 11, 11, 11,
12, 12, 12, 12, 12, 12,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
15, 15, 15, 15, 15, 15,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 17,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
19, 19, 19, 19, 19, 19,
20, 20, 20, 20, 20, 20, 20, 20,
21, 21, 21, 21, 21, 21, 21, 21,
22,
23, 23, 23, 23, 23, 23, 23, 23,
24,
25,
26,
27,
28,
29, 29,
30,
31,
32,
33
};
static const unsigned int vowel_numbers[] = {
0, 0, 4, 4, 4, 8, 8, 14, 14, 19, 19, 23
};
if (type & VOWEL)
{
return vowel_numbers[get_random(0, sizeof(vowel_numbers) / sizeof(unsigned int) - 1)];
}
else
{
return numbers[get_random(0, sizeof(numbers) / sizeof(unsigned int) - 1)];
}
}
unsigned int FIPS181::get_random(unsigned int minlen, unsigned int maxlen)
{
return minlen + (unsigned int)(randfunc_() % (maxlen - minlen + 1));
}