gecko-dev/modules/libreg/src/reg.h

197 строки
6.3 KiB
C
Исходник Обычный вид История

2001-09-20 04:02:59 +04:00
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
1998-03-28 05:44:41 +03:00
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Daniel Veditz <dveditz@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
1998-03-28 05:44:41 +03:00
/* reg.h
* XP Registry functions (prototype)
*/
#ifndef _REG_H_
#define _REG_H_
#include "vr_stubs.h"
1998-05-23 01:56:30 +04:00
#ifndef STANDALONE_REGISTRY
#include "prlock.h"
1998-03-28 05:44:41 +03:00
#endif
/* --------------------------------------------------------------------
* Miscellaneous Definitions
* --------------------------------------------------------------------
*/
#define MAGIC_NUMBER 0x76644441L
#define MAJOR_VERSION 2 /* major version for incompatible changes */
1998-03-28 05:44:41 +03:00
#define MINOR_VERSION 2 /* minor ver for new (compatible) features */
#define PATHDEL '/'
1999-04-15 09:40:37 +04:00
#define HDRRESERVE 128 /* number of bytes reserved for hdr */
1998-03-28 05:44:41 +03:00
#define INTSIZE 4
#define DOUBLESIZE 8
#define PACKBUFFERSIZE 2048
/* Node types */
#define REGTYPE_KEY (1)
#define REGTYPE_DELETED (0x0080)
/* Private standard keys */
#define ROOTKEY (0x20)
#define ROOTKEY_VERSIONS (0x21)
/* strings for standard keys */
#define ROOTKEY_STR "/"
#define ROOTKEY_VERSIONS_STR "Version Registry"
#define ROOTKEY_USERS_STR "Users"
#define ROOTKEY_COMMON_STR "Common"
#define ROOTKEY_PRIVATE_STR "Private Arenas"
#define OLD_VERSIONS_STR "ROOTKEY_VERSIONS"
#define OLD_USERS_STR "ROOTKEY_USERS"
#define OLD_COMMON_STR "ROOTKEY_COMMON"
/* needs to be kept in sync with PE. see ns/cmd/winfe/profile.h */
/* and ns/cmd/macfe/central/profile.cp */
#define ASW_MAGIC_PROFILE_NAME "User1"
/* macros */
#define COPYDESC(dest,src) memcpy((dest),(src),sizeof(REGDESC))
#define VALID_FILEHANDLE(fh) ((fh) != NULL)
#define INVALID_NAME_CHAR(p) ( ((unsigned char)(p) < 0x20) )
1998-03-28 05:44:41 +03:00
#define TYPE_IS_ENTRY(type) ( (type) & REGTYPE_ENTRY )
#define TYPE_IS_KEY(type) ( !((type) & REGTYPE_ENTRY) )
#define VERIFY_HREG(h)\
( ((h) == NULL) ? REGERR_PARAM : \
( (((REGHANDLE*)(h))->magic == MAGIC_NUMBER) ? REGERR_OK : REGERR_BADMAGIC ) )
/* --------------------------------------------------------------------
* Types and Objects
* --------------------------------------------------------------------
*/
1998-10-21 00:53:56 +04:00
#undef REGOFF
1998-03-28 05:44:41 +03:00
typedef int32 REGOFF; /* offset into registry file */
typedef struct _desc
{
1999-04-15 09:40:37 +04:00
REGOFF location; /* this object's offset (for verification) */
REGOFF name; /* name string */
uint16 namelen; /* length of name string (including terminator) */
uint16 type; /* node type (key, or entry style) */
REGOFF left; /* next object at this level (0 if none) */
REGOFF down; /* KEY: first subkey VALUE: 0 */
REGOFF value; /* KEY: first entry object VALUE: value string */
uint32 valuelen; /* KEY: 0 VALUE: length of value data */
uint32 valuebuf; /* KEY: 0 VALUE: length available */
1998-03-28 05:44:41 +03:00
REGOFF parent; /* the node on the immediate level above */
} REGDESC;
/* offsets into structure on disk */
#define DESC_LOCATION 0
#define DESC_NAME 4
#define DESC_NAMELEN 8
#define DESC_TYPE 10
#define DESC_LEFT 12
#define DESC_DOWN 16
#define DESC_VALUE 20
#define DESC_VALUELEN 24
#define DESC_VALUEBUF 16 /* stored in place of "down" for entries */
#define DESC_PARENT 28
#define DESC_SIZE 32 /* size of desc on disk */
typedef struct _hdr
{
1999-04-15 09:40:37 +04:00
uint32 magic; /* must equal MAGIC_NUMBER */
uint16 verMajor; /* major version number */
uint16 verMinor; /* minor version number */
REGOFF avail; /* next available offset */
REGOFF root; /* root object */
1998-03-28 05:44:41 +03:00
} REGHDR;
/* offsets into structure on disk*/
#define HDR_MAGIC 0
#define HDR_VERMAJOR 4
#define HDR_VERMINOR 6
#define HDR_AVAIL 8
#define HDR_ROOT 12
1999-04-15 09:40:37 +04:00
typedef XP_File FILEHANDLE; /* platform-specific file reference */
1998-03-28 05:44:41 +03:00
typedef struct _stdnodes {
REGOFF versions;
REGOFF users;
REGOFF common;
REGOFF current_user;
REGOFF privarea;
} STDNODES;
typedef struct _regfile
{
1999-04-15 09:40:37 +04:00
FILEHANDLE fh;
REGHDR hdr;
1998-03-28 05:44:41 +03:00
int refCount;
1999-04-15 09:40:37 +04:00
int hdrDirty;
1998-03-28 05:44:41 +03:00
int inInit;
int readOnly;
char * filename;
STDNODES rkeys;
struct _regfile *next;
struct _regfile *prev;
#ifndef STANDALONE_REGISTRY
PRLock *lock;
1999-10-18 16:06:19 +04:00
PRUint64 uniqkey;
1998-03-28 05:44:41 +03:00
#endif
} REGFILE;
typedef struct _reghandle
{
uint32 magic; /* for validating reg handles */
REGFILE *pReg; /* the real registry file object */
} REGHANDLE;
#endif /* _REG_H_ */
/* EOF: reg.h */