home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
AACD
/
Resources
/
System
/
BoingBag1
/
Contributions
/
Workbench
/
RexxArpLib3p6
/
src
/
whhtable.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-06-21
|
2KB
|
83 lines
/** Whhtable.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 = whhtable_index(name)
*
* int index the index of the function, -1 if not found.
* char *name name of function.
*
* Implement the Amiga environment access functions for rexxarplib.library.
*
* 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 <exec/types.h>
//#include "ralprotos.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
static int hash_table[] =
{
14, 2, 0, -1, 37, -1, -1, 17, 32, 3,
11, 24, -1, 21, 18, 29, -1, 39, -1, -1,
-1, -1, 5, 4, -1, -1, 15, -1, 27, 36,
-1, -1, -1, 28, 42, -1, -1, -1, -1, 16,
-1, 12, 8, 45, -1, -1, 26, 23, -1, -1,
-1, 38, -1, -1, 40, -1, 44, -1, 1, -1,
-1, 6, -1, 43, -1, -1, 34, 31, -1, -1,
-1, 33, 41, -1, -1, -1, 22, 20, -1, -1,
-1, -1, -1, -1, 7, -1, -1, -1, -1, 30,
-1, -1, 10, -1, -1, -1, -1, 13, 25, 9,
-1, -1, 19, -1, -1, -1, -1, -1, -1, 35,
-1, -1, -1,
};
int whhtable_index( char *s );
static int hash(unsigned char *);
int whhtable_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 * 110 + c ) & 0x7ff);
}
return(res % 113);
}