1*b30d1939SAndy Fiddaman /*********************************************************************** 2*b30d1939SAndy Fiddaman * * 3*b30d1939SAndy Fiddaman * This software is part of the ast package * 4*b30d1939SAndy Fiddaman * Copyright (c) 1985-2012 AT&T Intellectual Property * 5*b30d1939SAndy Fiddaman * and is licensed under the * 6*b30d1939SAndy Fiddaman * Eclipse Public License, Version 1.0 * 7*b30d1939SAndy Fiddaman * by AT&T Intellectual Property * 8*b30d1939SAndy Fiddaman * * 9*b30d1939SAndy Fiddaman * A copy of the License is available at * 10*b30d1939SAndy Fiddaman * http://www.eclipse.org/org/documents/epl-v10.html * 11*b30d1939SAndy Fiddaman * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 12*b30d1939SAndy Fiddaman * * 13*b30d1939SAndy Fiddaman * Information and Software Systems Research * 14*b30d1939SAndy Fiddaman * AT&T Research * 15*b30d1939SAndy Fiddaman * Florham Park NJ * 16*b30d1939SAndy Fiddaman * * 17*b30d1939SAndy Fiddaman * Glenn Fowler <gsf@research.att.com> * 18*b30d1939SAndy Fiddaman * David Korn <dgk@research.att.com> * 19*b30d1939SAndy Fiddaman * Phong Vo <kpv@research.att.com> * 20*b30d1939SAndy Fiddaman * * 21*b30d1939SAndy Fiddaman ***********************************************************************/ 22*b30d1939SAndy Fiddaman /* 23*b30d1939SAndy Fiddaman * Glenn Fowler 24*b30d1939SAndy Fiddaman * AT&T Research 25*b30d1939SAndy Fiddaman * 26*b30d1939SAndy Fiddaman * 1-6 char lower-case keyword -> long hash 27*b30d1939SAndy Fiddaman * digit args passed as HASHKEYN('2') 28*b30d1939SAndy Fiddaman */ 29*b30d1939SAndy Fiddaman 30*b30d1939SAndy Fiddaman #ifndef _HASHKEY_H 31*b30d1939SAndy Fiddaman #define _HASHKEY_H 1 32*b30d1939SAndy Fiddaman 33*b30d1939SAndy Fiddaman #define HASHKEYMAX 6 34*b30d1939SAndy Fiddaman #define HASHKEYBIT 5 35*b30d1939SAndy Fiddaman #define HASHKEYOFF ('a'-1) 36*b30d1939SAndy Fiddaman #define HASHKEYPART(h,c) (((h)<<HASHKEYBIT)+HASHKEY1(c)) 37*b30d1939SAndy Fiddaman 38*b30d1939SAndy Fiddaman #define HASHKEYN(n) ((n)-'0'+'z'+1) 39*b30d1939SAndy Fiddaman 40*b30d1939SAndy Fiddaman #define HASHKEY1(c1) ((c1)-HASHKEYOFF) 41*b30d1939SAndy Fiddaman #define HASHKEY2(c1,c2) HASHKEYPART(HASHKEY1(c1),c2) 42*b30d1939SAndy Fiddaman #define HASHKEY3(c1,c2,c3) HASHKEYPART(HASHKEY2(c1,c2),c3) 43*b30d1939SAndy Fiddaman #define HASHKEY4(c1,c2,c3,c4) HASHKEYPART(HASHKEY3(c1,c2,c3),c4) 44*b30d1939SAndy Fiddaman #define HASHKEY5(c1,c2,c3,c4,c5) HASHKEYPART(HASHKEY4(c1,c2,c3,c4),c5) 45*b30d1939SAndy Fiddaman #define HASHKEY6(c1,c2,c3,c4,c5,c6) HASHKEYPART(HASHKEY5(c1,c2,c3,c4,c5),c6) 46*b30d1939SAndy Fiddaman 47*b30d1939SAndy Fiddaman #define HASHNKEY1(n,c1) HASHKEY2((n)+HASHKEYOFF,c1) 48*b30d1939SAndy Fiddaman #define HASHNKEY2(n,c2,c1) HASHKEY3((n)+HASHKEYOFF,c2,c1) 49*b30d1939SAndy Fiddaman #define HASHNKEY3(n,c3,c2,c1) HASHKEY4((n)+HASHKEYOFF,c3,c2,c1) 50*b30d1939SAndy Fiddaman #define HASHNKEY4(n,c4,c3,c2,c1) HASHKEY5((n)+'a',c4,c3,c2,c1) 51*b30d1939SAndy Fiddaman #define HASHNKEY5(n,c5,c4,c3,c2,c1) HASHKEY6((n)+'a',c5,c4,c3,c2,c1) 52*b30d1939SAndy Fiddaman 53*b30d1939SAndy Fiddaman #if _BLD_ast && defined(__EXPORT__) 54*b30d1939SAndy Fiddaman #define extern __EXPORT__ 55*b30d1939SAndy Fiddaman #endif 56*b30d1939SAndy Fiddaman 57*b30d1939SAndy Fiddaman extern long strkey(const char*); 58*b30d1939SAndy Fiddaman 59*b30d1939SAndy Fiddaman #undef extern 60*b30d1939SAndy Fiddaman 61*b30d1939SAndy Fiddaman #endif 62