Reland bug 121341.
[wine-gecko.git] / modules / libreg / src / reg.h
blob056aecc800b52e64dde82d51243e0e9fe34d69ac
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is Mozilla Communicator client code, released
17 * March 31, 1998.
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1998
22 * the Initial Developer. All Rights Reserved.
24 * Contributor(s):
25 * Daniel Veditz <dveditz@netscape.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either the GNU General Public License Version 2 or later (the "GPL"), or
29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
40 /* reg.h
41 * XP Registry functions (prototype)
44 #ifndef _REG_H_
45 #define _REG_H_
47 #include "vr_stubs.h"
49 #ifndef STANDALONE_REGISTRY
50 #include "prlock.h"
51 #endif
53 /* --------------------------------------------------------------------
54 * Miscellaneous Definitions
55 * --------------------------------------------------------------------
57 #define MAGIC_NUMBER 0x76644441L
58 #define MAJOR_VERSION 1 /* major version for incompatible changes */
59 #define MINOR_VERSION 2 /* minor ver for new (compatible) features */
60 #define PATHDEL '/'
61 #define HDRRESERVE 128 /* number of bytes reserved for hdr */
62 #define INTSIZE 4
63 #define DOUBLESIZE 8
65 #define PACKBUFFERSIZE 2048
68 /* Node types */
69 #define REGTYPE_KEY (1)
70 #define REGTYPE_DELETED (0x0080)
72 /* Private standard keys */
73 #define ROOTKEY (0x20)
74 #define ROOTKEY_VERSIONS (0x21)
76 /* strings for standard keys */
77 #define ROOTKEY_STR "/"
78 #define ROOTKEY_VERSIONS_STR "Version Registry"
79 #define ROOTKEY_USERS_STR "Users"
80 #define ROOTKEY_COMMON_STR "Common"
81 #define ROOTKEY_PRIVATE_STR "Private Arenas"
83 #define OLD_VERSIONS_STR "ROOTKEY_VERSIONS"
84 #define OLD_USERS_STR "ROOTKEY_USERS"
85 #define OLD_COMMON_STR "ROOTKEY_COMMON"
87 /* needs to be kept in sync with PE. see ns/cmd/winfe/profile.h */
88 /* and ns/cmd/macfe/central/profile.cp */
89 #define ASW_MAGIC_PROFILE_NAME "User1"
91 /* macros */
92 #define COPYDESC(dest,src) memcpy((dest),(src),sizeof(REGDESC))
94 #define VALID_FILEHANDLE(fh) ((fh) != NULL)
96 #define INVALID_NAME_CHAR(p) ( ((unsigned char)(p) < 0x20) )
98 #define TYPE_IS_ENTRY(type) ( (type) & REGTYPE_ENTRY )
99 #define TYPE_IS_KEY(type) ( !((type) & REGTYPE_ENTRY) )
101 #define VERIFY_HREG(h)\
102 ( ((h) == NULL) ? REGERR_PARAM : \
103 ( (((REGHANDLE*)(h))->magic == MAGIC_NUMBER) ? REGERR_OK : REGERR_BADMAGIC ) )
107 /* --------------------------------------------------------------------
108 * Types and Objects
109 * --------------------------------------------------------------------
111 #undef REGOFF
112 typedef int32 REGOFF; /* offset into registry file */
114 typedef struct _desc
116 REGOFF location; /* this object's offset (for verification) */
117 REGOFF name; /* name string */
118 uint16 namelen; /* length of name string (including terminator) */
119 uint16 type; /* node type (key, or entry style) */
120 REGOFF left; /* next object at this level (0 if none) */
121 REGOFF down; /* KEY: first subkey VALUE: 0 */
122 REGOFF value; /* KEY: first entry object VALUE: value string */
123 uint32 valuelen; /* KEY: 0 VALUE: length of value data */
124 uint32 valuebuf; /* KEY: 0 VALUE: length available */
125 REGOFF parent; /* the node on the immediate level above */
126 } REGDESC;
128 /* offsets into structure on disk */
129 #define DESC_LOCATION 0
130 #define DESC_NAME 4
131 #define DESC_NAMELEN 8
132 #define DESC_TYPE 10
133 #define DESC_LEFT 12
134 #define DESC_DOWN 16
135 #define DESC_VALUE 20
136 #define DESC_VALUELEN 24
137 #define DESC_VALUEBUF 16 /* stored in place of "down" for entries */
138 #define DESC_PARENT 28
140 #define DESC_SIZE 32 /* size of desc on disk */
142 typedef struct _hdr
144 uint32 magic; /* must equal MAGIC_NUMBER */
145 uint16 verMajor; /* major version number */
146 uint16 verMinor; /* minor version number */
147 REGOFF avail; /* next available offset */
148 REGOFF root; /* root object */
149 } REGHDR;
151 /* offsets into structure on disk*/
152 #define HDR_MAGIC 0
153 #define HDR_VERMAJOR 4
154 #define HDR_VERMINOR 6
155 #define HDR_AVAIL 8
156 #define HDR_ROOT 12
158 typedef XP_File FILEHANDLE; /* platform-specific file reference */
160 typedef struct _stdnodes {
161 REGOFF versions;
162 REGOFF users;
163 REGOFF common;
164 REGOFF current_user;
165 REGOFF privarea;
166 } STDNODES;
168 typedef struct _regfile
170 FILEHANDLE fh;
171 REGHDR hdr;
172 int refCount;
173 int hdrDirty;
174 int inInit;
175 int readOnly;
176 char * filename;
177 STDNODES rkeys;
178 struct _regfile *next;
179 struct _regfile *prev;
180 #ifndef STANDALONE_REGISTRY
181 PRLock *lock;
182 PRUint64 uniqkey;
183 #endif
184 } REGFILE;
186 typedef struct _reghandle
188 uint32 magic; /* for validating reg handles */
189 REGFILE *pReg; /* the real registry file object */
190 } REGHANDLE;
193 #endif /* _REG_H_ */
195 /* EOF: reg.h */