~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/modules/libreg/src/reg.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

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