386BSD 0.1 development
[unix-history] / usr / othersrc / public / ghostscript-2.4.1 / name.h
CommitLineData
882dbf12
WJ
1/* Copyright (C) 1989, 1992 Aladdin Enterprises. All rights reserved.
2 Distributed by Free Software Foundation, Inc.
3
4This file is part of Ghostscript.
5
6Ghostscript is distributed in the hope that it will be useful, but
7WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
8to anyone for the consequences of using it or for whether it serves any
9particular purpose or works at all, unless he says so in writing. Refer
10to the Ghostscript General Public License for full details.
11
12Everyone is granted permission to copy, modify and redistribute
13Ghostscript, but only under the conditions described in the Ghostscript
14General Public License. A copy of this license is supposed to have been
15given to you along with Ghostscript so you can know your rights and
16responsibilities. It should be in a file named COPYING. Among other
17things, the copyright notice and this notice must be preserved on all
18copies. */
19
20/* name.h */
21/* Name table entry structure for Ghostscript */
22
23/* Name structure. The name table is a simple chained hash table. */
24/* There is an optimization to avoid lookup for operator and other */
25/* global names. */
26struct name_s {
27 ushort next_index; /* next name in chain or 0 */
28 ushort index;
29/* In order to pack names into 16 bytes, we use a non-standard */
30/* representation for the string, omitting the type_attrs field. */
31 ushort string_size;
32 const byte *string_bytes;
33/* pvalue specifies the definition status of the name: */
34/* pvalue == pv_no_defn: no definitions */
35#define pv_no_defn ((ref *)0)
36/* pvalue == pv_other: other status */
37#define pv_other ((ref *)1)
38#define pv_valid(pvalue) ((unsigned long)(pvalue) > 1)
39/* pvalue != pv_no_defn, pvalue != pv_other: pvalue is valid */
40 ref *pvalue; /* if only defined in systemdict */
41 /* or userdict, this points to */
42 /* the value */
43};
44/*typedef struct name_s name;*/ /* in ghost.h */
45
46/* Procedures for the name table. */
47
48/* The size argument for name_ref should be a ushort, */
49/* but this gets the Apollo compiler confused. */
50/* enterflag=-1 means don't enter (return an error if missing); */
51/* enterflag=0 means enter if missing, don't copy the string; */
52/* enterflag=1 means enter if missing, copy the string. */
53extern int name_ref(P4(const byte *ptr, uint size, ref *pnref, int enterflag));
54extern void name_string_ref(P2(const ref *pnref, ref *psref));
55extern void name_enter(P2(const char *str, ref *pnref));
56/* name_from_string essentially implements cvn. */
57/* It always enters the name, and copies the executable attribute. */
58extern int name_from_string(P2(const ref *psref, ref *pnref));
59
60/* Conversion between names and indices. */
61#define name_index(pnref) ((pnref)->value.pname->index)
62extern void name_index_ref(P2(uint index /* should be ushort */,
63 ref *pnref));
64extern uint name_count(P0());
65extern int name_is_since_count(P2(ref *, uint));
66
67/* Clean up the name table before a restore. */
68extern void name_restore(P1(uint old_count));