PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/libreg/src/reg.h

http://github.com/zpao/v8monkey
C++ Header | 196 lines | 105 code | 32 blank | 59 comment | 3 complexity | 9072e4606fa6dc8e6617246af3c82c6d MD5 | raw file
  1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2 *
  3 * ***** BEGIN LICENSE BLOCK *****
  4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5 *
  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/
 10 *
 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.
 15 *
 16 * The Original Code is Mozilla Communicator client code, released
 17 * March 31, 1998.
 18 *
 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.
 23 *
 24 * Contributor(s):
 25 *   Daniel Veditz <dveditz@netscape.com>
 26 *
 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.
 38 *
 39 * ***** END LICENSE BLOCK ***** */
 40/* reg.h
 41 * XP Registry functions (prototype)
 42 */
 43
 44#ifndef _REG_H_
 45#define _REG_H_
 46
 47#include "vr_stubs.h"
 48
 49#ifndef STANDALONE_REGISTRY
 50#include "prlock.h"
 51#endif
 52
 53/* --------------------------------------------------------------------
 54 * Miscellaneous Definitions
 55 * --------------------------------------------------------------------
 56 */
 57#define MAGIC_NUMBER    0x76644441L
 58#define MAJOR_VERSION   2          /* 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
 64
 65#define PACKBUFFERSIZE  2048
 66
 67
 68/* Node types */
 69#define REGTYPE_KEY                   (1)
 70#define REGTYPE_DELETED               (0x0080)
 71
 72/* Private standard keys */
 73#define ROOTKEY                       (0x20)
 74#define ROOTKEY_VERSIONS              (0x21)
 75
 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"
 82
 83#define OLD_VERSIONS_STR        "ROOTKEY_VERSIONS"
 84#define OLD_USERS_STR           "ROOTKEY_USERS"
 85#define OLD_COMMON_STR          "ROOTKEY_COMMON"
 86
 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"
 90
 91/* macros */
 92#define COPYDESC(dest,src)  memcpy((dest),(src),sizeof(REGDESC))
 93
 94#define VALID_FILEHANDLE(fh)    ((fh) != NULL)
 95
 96#define INVALID_NAME_CHAR(p)    ( ((unsigned char)(p) < 0x20) )
 97
 98#define TYPE_IS_ENTRY(type)       ( (type) & REGTYPE_ENTRY )
 99#define TYPE_IS_KEY(type)         ( !((type) & REGTYPE_ENTRY) )
100
101#define VERIFY_HREG(h)\
102    ( ((h) == NULL) ? REGERR_PARAM : \
103    ( (((REGHANDLE*)(h))->magic == MAGIC_NUMBER) ? REGERR_OK : REGERR_BADMAGIC ) )
104
105
106
107/* --------------------------------------------------------------------
108 * Types and Objects
109 * --------------------------------------------------------------------
110 */
111#undef REGOFF
112typedef int32 REGOFF;   /* offset into registry file */
113
114typedef struct _desc
115{
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;
127
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
139
140#define DESC_SIZE       32    /* size of desc on disk */
141
142typedef struct _hdr
143{
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;
150
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
157
158typedef XP_File FILEHANDLE; /* platform-specific file reference */
159
160typedef struct _stdnodes {
161    REGOFF          versions;
162    REGOFF          users;
163    REGOFF          common;
164    REGOFF          current_user;
165    REGOFF          privarea;
166} STDNODES;
167
168typedef struct _regfile
169{
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;
185
186typedef struct _reghandle
187{
188    uint32          magic;     /* for validating reg handles */
189    REGFILE         *pReg;     /* the real registry file object */
190} REGHANDLE;
191
192
193#endif  /* _REG_H_ */
194
195/* EOF: reg.h */
196