Back to index

lightning-sunbird  0.9+nobinonly
reg.h
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Mozilla Communicator client code, released
00017  * March 31, 1998.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1998
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Daniel Veditz <dveditz@netscape.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 /* reg.h
00041  * XP Registry functions (prototype)
00042  */
00043 
00044 #ifndef _REG_H_
00045 #define _REG_H_
00046 
00047 #include "vr_stubs.h"
00048 
00049 #ifndef STANDALONE_REGISTRY
00050 #include "prlock.h"
00051 #endif
00052 
00053 /* --------------------------------------------------------------------
00054  * Miscellaneous Definitions
00055  * --------------------------------------------------------------------
00056  */
00057 #define MAGIC_NUMBER    0x76644441L
00058 #define MAJOR_VERSION   1          /* major version for incompatible changes */
00059 #define MINOR_VERSION   2          /* minor ver for new (compatible) features */
00060 #define PATHDEL         '/'
00061 #define HDRRESERVE      128        /* number of bytes reserved for hdr */
00062 #define INTSIZE         4
00063 #define DOUBLESIZE      8
00064 
00065 #define PACKBUFFERSIZE  2048
00066 
00067 
00068 /* Node types */
00069 #define REGTYPE_KEY                   (1)
00070 #define REGTYPE_DELETED               (0x0080)
00071 
00072 /* Private standard keys */
00073 #define ROOTKEY                       (0x20)
00074 #define ROOTKEY_VERSIONS              (0x21)
00075 
00076 /* strings for standard keys */
00077 #define ROOTKEY_STR             "/"
00078 #define ROOTKEY_VERSIONS_STR    "Version Registry"
00079 #define ROOTKEY_USERS_STR       "Users"
00080 #define ROOTKEY_COMMON_STR      "Common"
00081 #define ROOTKEY_PRIVATE_STR     "Private Arenas"
00082 
00083 #define OLD_VERSIONS_STR        "ROOTKEY_VERSIONS"
00084 #define OLD_USERS_STR           "ROOTKEY_USERS"
00085 #define OLD_COMMON_STR          "ROOTKEY_COMMON"
00086 
00087 /* needs to be kept in sync with PE. see ns/cmd/winfe/profile.h */
00088 /* and ns/cmd/macfe/central/profile.cp */
00089 #define ASW_MAGIC_PROFILE_NAME "User1"
00090 
00091 /* macros */
00092 #define COPYDESC(dest,src)  memcpy((dest),(src),sizeof(REGDESC))
00093 
00094 #define VALID_FILEHANDLE(fh)    ((fh) != NULL)
00095 
00096 #define INVALID_NAME_CHAR(p)    ( ((unsigned char)(p) < 0x20) )
00097 
00098 #define TYPE_IS_ENTRY(type)       ( (type) & REGTYPE_ENTRY )
00099 #define TYPE_IS_KEY(type)         ( !((type) & REGTYPE_ENTRY) )
00100 
00101 #define VERIFY_HREG(h)\
00102     ( ((h) == NULL) ? REGERR_PARAM : \
00103     ( (((REGHANDLE*)(h))->magic == MAGIC_NUMBER) ? REGERR_OK : REGERR_BADMAGIC ) )
00104 
00105 
00106 
00107 /* --------------------------------------------------------------------
00108  * Types and Objects
00109  * --------------------------------------------------------------------
00110  */
00111 #undef REGOFF
00112 typedef int32 REGOFF;   /* offset into registry file */
00113 
00114 typedef struct _desc
00115 {
00116     REGOFF  location;   /* this object's offset (for verification) */
00117     REGOFF  name;       /* name string */
00118     uint16  namelen;    /* length of name string (including terminator) */
00119     uint16  type;       /* node type (key, or entry style) */
00120     REGOFF  left;       /* next object at this level (0 if none) */
00121     REGOFF  down;       /* KEY: first subkey        VALUE: 0 */
00122     REGOFF  value;      /* KEY: first entry object  VALUE: value string */
00123     uint32  valuelen;   /* KEY: 0  VALUE: length of value data */
00124     uint32  valuebuf;   /* KEY: 0  VALUE: length available */
00125     REGOFF  parent;     /* the node on the immediate level above */
00126 } REGDESC;
00127 
00128 /* offsets into structure on disk */
00129 #define DESC_LOCATION   0
00130 #define DESC_NAME       4
00131 #define DESC_NAMELEN    8
00132 #define DESC_TYPE       10
00133 #define DESC_LEFT       12
00134 #define DESC_DOWN       16
00135 #define DESC_VALUE      20
00136 #define DESC_VALUELEN   24
00137 #define DESC_VALUEBUF   16    /* stored in place of "down" for entries */
00138 #define DESC_PARENT     28
00139 
00140 #define DESC_SIZE       32    /* size of desc on disk */
00141 
00142 typedef struct _hdr
00143 {
00144     uint32  magic;      /* must equal MAGIC_NUMBER */
00145     uint16  verMajor;   /* major version number */
00146     uint16  verMinor;   /* minor version number */
00147     REGOFF  avail;      /* next available offset */
00148     REGOFF  root;       /* root object */
00149 } REGHDR;
00150 
00151 /* offsets into structure on disk*/
00152 #define HDR_MAGIC       0
00153 #define HDR_VERMAJOR    4
00154 #define HDR_VERMINOR    6
00155 #define HDR_AVAIL       8
00156 #define HDR_ROOT        12
00157 
00158 typedef XP_File FILEHANDLE; /* platform-specific file reference */
00159 
00160 typedef struct _stdnodes {
00161     REGOFF          versions;
00162     REGOFF          users;
00163     REGOFF          common;
00164     REGOFF          current_user;
00165     REGOFF          privarea;
00166 } STDNODES;
00167 
00168 typedef struct _regfile
00169 {
00170     FILEHANDLE      fh;
00171     REGHDR          hdr;
00172     int             refCount;
00173     int             hdrDirty;
00174     int             inInit;
00175     int             readOnly;
00176     char *          filename;
00177     STDNODES        rkeys;
00178     struct _regfile *next;
00179     struct _regfile *prev;
00180 #ifndef STANDALONE_REGISTRY
00181     PRLock          *lock;
00182     PRUint64        uniqkey;
00183 #endif
00184 } REGFILE;
00185 
00186 typedef struct _reghandle
00187 {
00188     uint32          magic;     /* for validating reg handles */
00189     REGFILE         *pReg;     /* the real registry file object */
00190 } REGHANDLE;
00191 
00192 
00193 #endif  /* _REG_H_ */
00194 
00195 /* EOF: reg.h */
00196