home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
AACD
/
Resources
/
System
/
BoingBag1
/
Contributions
/
Workbench
/
RexxArpLib3p6
/
src
/
rxhtable.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-06-21
|
1KB
|
73 lines
/** Rxhtable.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' by W.G.J. Langeveld.
*
* SYNOPSIS:
* =========
*
* index = rxhtable_index(name)
*
* int index the index of the function, -1 if not found.
* char *name name of function.
*
* AUTHOR/DATE: W.G.J. Langeveld, November 1987.
* ============
*
* CURRENT VERSION:
*
* This version has been converted to SAS C 6.5 format. It has been modified
* for modern definition sequences for ANSI compilation. This no longer works
* with OS versions prior to 2.04.
*
* AUTHOR/DATE: Joanne Dow, jdow@bix.com, June 1998.
* ============
*
**/
#include <string.h>
#include <ctype.h>
static int hash_table[] =
{
-1, -1, 8, -1, 17, -1, 18, 7, -1, 9,
6, 15, 10, -1, 0, -1, 11, -1, -1, -1,
5, 12, 16, 14, 19, 13, -1, -1, -1, 4,
1, 2, -1, -1, 3, -1, -1,
};
int rxhtable_index(char *);
static int hash(unsigned char *);
int rxhtable_index( char *s )
{
return(hash_table[hash(s)]);
}
static int hash( 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 * 23 + c ) & 0x7ff);
}
return(res % 37);
}