1 /******************************************************************************
2   Copyright (c) 1995, 1996 Xerox Corporation.  All rights reserved.
3   Portions of this code were written by Stephen White, aka ghond.
4   Use and copying of this software and preparation of derivative works based
5   upon this software are permitted.  Any distribution of this software or
6   derivative works must comply with all applicable United States export
7   control laws.  This software is made available AS IS, and Xerox Corporation
8   makes no warranty about the software, its performance or its conformity to
9   any specification.  Any person obtaining a copy of this software is requested
10   to send their name and post office or electronic mail address to:
11     Pavel Curtis
12     Xerox PARC
13     3333 Coyote Hill Rd.
14     Palo Alto, CA 94304
15     Pavel@Xerox.Com
16  *****************************************************************************/
17 
18 /*****************************************************************************
19  * Private interface for internal communication in the DB implementation
20  *****************************************************************************/
21 
22 #include "config.h"
23 #include "exceptions.h"
24 #include "program.h"
25 #include "structures.h"
26 
27 typedef struct Verbdef Verbdef;
28 
29 struct Verbdef {
30     const char *name;
31     Program *program;
32     Objid owner;
33     short perms;
34     short prep;
35     Verbdef *next;
36 };
37 
38 typedef struct Proplist Proplist;
39 typedef struct Propdef Propdef;
40 
41 struct Propdef {
42     const char *name;
43     int hash;
44 };
45 
46 struct Proplist {
47     int max_length;
48     int cur_length;
49     Propdef *l;
50 };
51 
52 typedef struct Pval {
53     Var var;
54     Objid owner;
55     short perms;
56 } Pval;
57 
58 typedef struct Object {
59     Objid id;
60     Objid owner;
61     Objid location;
62     Objid contents;
63     Objid next;
64 
65     Objid parent;
66     Objid child;
67     Objid sibling;
68 
69 
70     const char *name;
71     int flags;
72 
73     Verbdef *verbdefs;
74     Proplist propdefs;
75     Pval *propval;
76 } Object;
77 
78 /*********** Verb cache support ***********/
79 
80 #define VERB_CACHE 1
81 
82 #ifdef VERB_CACHE
83 
84 /* Whenever anything is modified that could influence callable verb
85  * lookup, this function must be called.
86  */
87 
88 #ifdef RONG
89 #define db_priv_affected_callable_verb_lookup() (db_verb_generation++)
90                                  /* The choice of a new generation. */
91 extern unsigned int db_verb_generation;
92 #endif
93 
94 extern void db_priv_affected_callable_verb_lookup(void);
95 
96 #else /* no cache */
97 #define db_priv_affected_callable_verb_lookup()
98 #endif
99 
100 /*********** Objects ***********/
101 
102 extern void dbpriv_set_all_users(Var);
103 				/* Initialize the list returned by
104 				 * db_all_users().
105 				 */
106 
107 extern Object *dbpriv_new_object(void);
108 				/* Creates a new object, assigning it a number,
109 				 * but doesn't fill in any of the fields other
110 				 * than `id'.
111 				 */
112 
113 extern void dbpriv_new_recycled_object(void);
114 				/* Does the equivalent of creating and
115 				 * destroying an object, with the net effect of
116 				 * using up the next available object number.
117 				 */
118 
119 extern Object *dbpriv_find_object(Objid);
120 				/* Returns 0 if given object is not valid.
121 				 */
122 
123 /*********** Properties ***********/
124 
125 extern Propdef dbpriv_new_propdef(const char *name);
126 
127 extern int dbpriv_count_properties(Objid);
128 
129 extern int dbpriv_check_properties_for_chparent(Objid oid,
130 						Objid new_parent);
131 				/* Return true iff NEW_PARENT defines no
132 				 * properties that are also defined by either
133 				 * OID or any of OID's descendants.
134 				 */
135 
136 extern void dbpriv_fix_properties_after_chparent(Objid oid,
137 						 Objid old_parent);
138 				/* OID has just had its parent changed away
139 				 * from OLD_PARENT.  Fix up the properties of
140 				 * OID and its descendants, removing obsolete
141 				 * ones and adding clear new ones, as
142 				 * appropriate for its new parent.
143 				 */
144 
145 /*********** Verbs ***********/
146 
147 extern void dbpriv_build_prep_table(void);
148 				/* Should be called once near the beginning of
149 				 * the world, to initialize the
150 				 * prepositional-phrase matching table.
151 				 */
152 
153 /*********** DBIO ***********/
154 
155 extern Exception dbpriv_dbio_failed;
156 				/* Raised by DBIO in case of failure (e.g.,
157 				 * running out of disk space for the dump).
158 				 */
159 
160 extern void dbpriv_set_dbio_input(FILE *);
161 extern void dbpriv_set_dbio_output(FILE *);
162 
163 /*
164  * $Log: db_private.h,v $
165  * Revision 1.4  1998/12/14 13:17:37  nop
166  * Merge UNSAFE_OPTS (ref fixups); fix Log tag placement to fit CVS whims
167  *
168  * Revision 1.3  1997/07/07 03:24:53  nop
169  * Merge UNSAFE_OPTS (r5) after extensive testing.
170  *
171  * Revision 1.2  1997/03/03 04:18:30  nop
172  * GNU Indent normalization
173  *
174  * Revision 1.1.1.1  1997/03/03 03:45:02  nop
175  * LambdaMOO 1.8.0p5
176  *
177  * Revision 2.3  1996/02/08  06:27:28  pavel
178  * Updated copyright notice for 1996.  Release 1.8.0beta1.
179  *
180  * Revision 2.2  1995/12/31  03:18:05  pavel
181  * Removed a few more uses of `unsigned'.  Release 1.8.0alpha4.
182  *
183  * Revision 2.1  1995/12/28  00:57:51  pavel
184  * Added dbpriv_build_prep_table().  Release 1.8.0alpha3.
185  *
186  * Revision 2.0  1995/11/30  05:05:53  pavel
187  * New baseline version, corresponding to release 1.8.0alpha1.
188  *
189  * Revision 1.1  1995/11/30  05:05:38  pavel
190  * Initial revision
191  */
192