/** htable.c
*
*   DESCRIPTION:
*   ===========
*
*	This function finds the index associated with the function
*	name given in the argument string.
*	
*	It uses a hashing function that was found using the program
*	hash that I wrote for the purpose...
*
*   SYNOPSIS:
*   =========
*
*	index = get_index(name)
*
*	int index	the index of the function, -1 if not found.
*       name            name of function.
*
*
*   AUTHOR/DATE:  W.G.J. Langeveld, November 1987.
*   ============
*
**/



int hash_table[] = {
     -1,  27,  16,   5,  14,  -1,  21,  11,  -1,  -1,
     -1,  -1,  -1,   1,  -1,  -1,  -1,  24,  -1,  -1,
     -1,  -1,  -1,  -1,  20,  -1,  -1,   9,  13,  -1,
     29,  -1,  30,  -1,  -1,  17,  -1,  -1,  -1,   3,
     -1,  25,  10,  -1,  -1,  -1,   7,  26,  -1,  -1,
      2,  12,  18,  28,  -1,  31,   4,  -1,  -1,  -1,
     -1,  15,  -1,  -1,  -1,  -1,  -1,  -1,  22,  19,
      8,  -1,   0,  -1,  -1,   6,  23,  };


int get_index(s)
char *s;
{
   return(hash_table[hash(s)]);
}


static int hash(s)
unsigned char *s;
{
    register int res;
    register unsigned char *sp;
    register unsigned int c;

    res = strlen(s);

    for(sp = s; *sp; sp++ ) {
        c = toupper(*sp);
        res = ((res * 166 + c ) & 0x7ff);
    }
    return(res % 77);
}
