home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libreg / src / reg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.4 KB  |  176 lines

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