1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 1990 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
29 /*	  All Rights Reserved  	*/
30 
31 #ifndef	_HASH_H
32 #define	_HASH_H
33 
34 #ifdef	SCHILY_INCLUDES
35 #include <schily/mconfig.h>
36 #endif
37 
38 #if defined(sun)
39 #pragma ident	"@(#)hash.h	1.8	05/09/13 SMI"
40 #endif
41 
42 /*
43  * Copyright 2008-2017 J. Schilling
44  *
45  * @(#)hash.h	1.10 17/11/22 2008-2017 J. Schilling
46  */
47 
48 /*
49  *	UNIX shell
50  */
51 #ifdef	__cplusplus
52 extern "C" {
53 #endif
54 
55 #define		HASHZAP		0x23FF	/* Mask all but BUILTIN / FUNCTION */
56 #define		CDMARK		0x8000	/* Mark outdated "::" based entries */
57 
58 #define		NOTFOUND	0x0000	/* Cannot exec, reason in low 8 bits */
59 #define		BUILTIN		0x0100	/* Builtin, builtin # in low 8 bits */
60 #define		FUNCTION	0x0200	/* Data value for all functions */
61 #define		COMMAND		0x0400	/* Command, PATH index in low 8 bits */
62 #define		REL_COMMAND	0x0800	/* Relative command from "::" in PATH */
63 #define		PATH_COMMAND	0x1000	/* Command with PATH= in local env */
64 #define		SPC_BUILTIN	0x2000	/* Special builtin command */
65 #define		DOT_COMMAND	0x8800	/* CDMARK | REL_COMMAND */
66 
67 #define		hashtype(x)	(x & 0x1F00)
68 #define		hashdata(x)	(x & 0x00FF)
69 
70 
71 typedef struct entry
72 {
73 	unsigned char	*key;		/* Hash key string (command name) */
74 	short		data;		/* Hash data, see flags above */
75 	unsigned char	hits;		/* # of hash hits % 256 */
76 	unsigned char	cost;		/* cost: # of PATH entries to search */
77 	struct entry	*next;
78 } ENTRY;
79 
80 extern ENTRY	*hfind	__PR((unsigned char *));
81 extern ENTRY	*henter	__PR((ENTRY));
82 extern void	hcreate	__PR((void));
83 extern void	hscan	__PR((void (*uscan)(ENTRY *)));
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif /* !_HASH_H */
90