/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. #ifndef _REG_H_
  44. #define _REG_H_
  45. #include "vr_stubs.h"
  46. #ifndef STANDALONE_REGISTRY
  47. #include "prlock.h"
  48. #endif
  49. /* --------------------------------------------------------------------
  50. * Miscellaneous Definitions
  51. * --------------------------------------------------------------------
  52. */
  53. #define MAGIC_NUMBER 0x76644441L
  54. #define MAJOR_VERSION 2 /* major version for incompatible changes */
  55. #define MINOR_VERSION 2 /* minor ver for new (compatible) features */
  56. #define PATHDEL '/'
  57. #define HDRRESERVE 128 /* number of bytes reserved for hdr */
  58. #define INTSIZE 4
  59. #define DOUBLESIZE 8
  60. #define PACKBUFFERSIZE 2048
  61. /* Node types */
  62. #define REGTYPE_KEY (1)
  63. #define REGTYPE_DELETED (0x0080)
  64. /* Private standard keys */
  65. #define ROOTKEY (0x20)
  66. #define ROOTKEY_VERSIONS (0x21)
  67. /* strings for standard keys */
  68. #define ROOTKEY_STR "/"
  69. #define ROOTKEY_VERSIONS_STR "Version Registry"
  70. #define ROOTKEY_USERS_STR "Users"
  71. #define ROOTKEY_COMMON_STR "Common"
  72. #define ROOTKEY_PRIVATE_STR "Private Arenas"
  73. #define OLD_VERSIONS_STR "ROOTKEY_VERSIONS"
  74. #define OLD_USERS_STR "ROOTKEY_USERS"
  75. #define OLD_COMMON_STR "ROOTKEY_COMMON"
  76. /* needs to be kept in sync with PE. see ns/cmd/winfe/profile.h */
  77. /* and ns/cmd/macfe/central/profile.cp */
  78. #define ASW_MAGIC_PROFILE_NAME "User1"
  79. /* macros */
  80. #define COPYDESC(dest,src) memcpy((dest),(src),sizeof(REGDESC))
  81. #define VALID_FILEHANDLE(fh) ((fh) != NULL)
  82. #define INVALID_NAME_CHAR(p) ( ((unsigned char)(p) < 0x20) )
  83. #define TYPE_IS_ENTRY(type) ( (type) & REGTYPE_ENTRY )
  84. #define TYPE_IS_KEY(type) ( !((type) & REGTYPE_ENTRY) )
  85. #define VERIFY_HREG(h)\
  86. ( ((h) == NULL) ? REGERR_PARAM : \
  87. ( (((REGHANDLE*)(h))->magic == MAGIC_NUMBER) ? REGERR_OK : REGERR_BADMAGIC ) )
  88. /* --------------------------------------------------------------------
  89. * Types and Objects
  90. * --------------------------------------------------------------------
  91. */
  92. #undef REGOFF
  93. typedef int32 REGOFF; /* offset into registry file */
  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. /* offsets into structure on disk */
  108. #define DESC_LOCATION 0
  109. #define DESC_NAME 4
  110. #define DESC_NAMELEN 8
  111. #define DESC_TYPE 10
  112. #define DESC_LEFT 12
  113. #define DESC_DOWN 16
  114. #define DESC_VALUE 20
  115. #define DESC_VALUELEN 24
  116. #define DESC_VALUEBUF 16 /* stored in place of "down" for entries */
  117. #define DESC_PARENT 28
  118. #define DESC_SIZE 32 /* size of desc on disk */
  119. typedef struct _hdr
  120. {
  121. uint32 magic; /* must equal MAGIC_NUMBER */
  122. uint16 verMajor; /* major version number */
  123. uint16 verMinor; /* minor version number */
  124. REGOFF avail; /* next available offset */
  125. REGOFF root; /* root object */
  126. } REGHDR;
  127. /* offsets into structure on disk*/
  128. #define HDR_MAGIC 0
  129. #define HDR_VERMAJOR 4
  130. #define HDR_VERMINOR 6
  131. #define HDR_AVAIL 8
  132. #define HDR_ROOT 12
  133. typedef XP_File FILEHANDLE; /* platform-specific file reference */
  134. typedef struct _stdnodes {
  135. REGOFF versions;
  136. REGOFF users;
  137. REGOFF common;
  138. REGOFF current_user;
  139. REGOFF privarea;
  140. } STDNODES;
  141. typedef struct _regfile
  142. {
  143. FILEHANDLE fh;
  144. REGHDR hdr;
  145. int refCount;
  146. int hdrDirty;
  147. int inInit;
  148. int readOnly;
  149. char * filename;
  150. STDNODES rkeys;
  151. struct _regfile *next;
  152. struct _regfile *prev;
  153. #ifndef STANDALONE_REGISTRY
  154. PRLock *lock;
  155. PRUint64 uniqkey;
  156. #endif
  157. } REGFILE;
  158. typedef struct _reghandle
  159. {
  160. uint32 magic; /* for validating reg handles */
  161. REGFILE *pReg; /* the real registry file object */
  162. } REGHANDLE;
  163. #endif /* _REG_H_ */
  164. /* EOF: reg.h */