home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libreg / include / NSReg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.7 KB  |  220 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. /* NSReg.h
  19.  */
  20. #ifndef _NSREG_H_
  21. #define _NSREG_H_
  22.  
  23. typedef int32   REGERR;
  24. typedef int32   RKEY;
  25. typedef uint32  REGENUM;
  26. typedef void *  HREG;
  27.  
  28. typedef struct _reginfo
  29. {
  30.    uint16  size;        /* must be initialized to sizeof(REGINFO) */
  31.    uint16  entryType;
  32.    uint32  entryLength;
  33. } REGINFO;
  34.  
  35. #define REGERR_OK           (0)
  36. #define REGERR_FAIL         (1)
  37. #define REGERR_NOMORE       (2)
  38. #define REGERR_NOFIND       (3)
  39. #define REGERR_BADREAD      (4)
  40. #define REGERR_BADLOCN      (5)
  41. #define REGERR_PARAM        (6)
  42. #define REGERR_BADMAGIC     (7)
  43. #define REGERR_BADCHECK     (8)
  44. #define REGERR_NOFILE       (9)
  45. #define REGERR_MEMORY       (10)
  46. #define REGERR_BUFTOOSMALL  (11)
  47. #define REGERR_NAMETOOLONG  (12)
  48. #define REGERR_REGVERSION   (13)
  49. #define REGERR_DELETED      (14)
  50. #define REGERR_BADTYPE      (15)
  51. #define REGERR_NOPATH       (16)
  52. #define REGERR_BADNAME      (17)
  53. #define REGERR_READONLY     (18)
  54.  
  55. /* Total path length */
  56. #define MAXREGPATHLEN   (2048)
  57. /* Name on the path (including null terminator) */
  58. #define MAXREGNAMELEN   (512)
  59. /* Value of an entry */
  60. #define MAXREGVALUELEN  (0x7FFF)
  61.  
  62. /* Standard keys */
  63. #define ROOTKEY_USERS                   (0x01)
  64. #define ROOTKEY_COMMON                  (0x02)
  65. #define ROOTKEY_CURRENT_USER            (0x03)
  66. #define ROOTKEY_PRIVATE                 (0x04)
  67.  
  68. /* enumeration styles */
  69. #define REGENUM_NORMAL                  (0x00)
  70. #define REGENUM_DESCEND                 (0x01)
  71.  
  72. /* entry data types */
  73. #define REGTYPE_ENTRY                 (0x0010)
  74. #define REGTYPE_ENTRY_STRING_UTF      (REGTYPE_ENTRY + 1)
  75. #define REGTYPE_ENTRY_INT32_ARRAY     (REGTYPE_ENTRY + 2)
  76. #define REGTYPE_ENTRY_BYTES           (REGTYPE_ENTRY + 3)
  77.  
  78. #define REG_DELETE_LIST_KEY  "Netscape/Communicator/SoftwareUpdate/Delete List"
  79. #define REG_REPLACE_LIST_KEY "Netscape/Communicator/SoftwareUpdate/Replace List"
  80.  
  81. #define UNIX_GLOBAL_FLAG     "MOZILLA_SHARED_REGISTRY"
  82.  
  83. /* Platform-dependent declspec for library interface */
  84. #if defined(STANDALONE_REGISTRY) && defined(XP_PC)
  85.  #if defined(WIN32)
  86.  #define VR_INTERFACE(type)     __declspec(dllexport) type __stdcall
  87.  #elif defined(XP_OS2)
  88.  #define VR_INTERFACE(type)     type _Optlink
  89.  #else
  90.  #define VR_INTERFACE(type)     type _far _pascal _export
  91.  #endif
  92. #else
  93.  #define VR_INTERFACE(type)     type
  94. #endif /* STANDALONE_REGISTRY and XP_PC */
  95.  
  96.  
  97. XP_BEGIN_PROTOS
  98. /* ---------------------------------------------------------------------
  99.  * Registry API -- General
  100.  * ---------------------------------------------------------------------
  101.  */
  102.  
  103. VR_INTERFACE(REGERR) NR_RegOpen(
  104.          char *filename,   /* reg. file to open (NULL == standard registry) */
  105.          HREG *hReg        /* OUT: handle to opened registry */
  106.        );
  107.  
  108. VR_INTERFACE(REGERR) NR_RegClose(
  109.          HREG hReg         /* handle of open registry to close */
  110.        );
  111.  
  112. VR_INTERFACE(REGERR) NR_RegPack(
  113.          HREG hReg         /* handle of open registry to pack */
  114.        );
  115.  
  116. /* ---------------------------------------------------------------------
  117.  * Registry API -- Key Management functions
  118.  * ---------------------------------------------------------------------
  119.  */
  120.  
  121. VR_INTERFACE(REGERR) NR_RegAddKey(
  122.          HREG hReg,        /* handle of open registry */
  123.          RKEY key,         /* root key */
  124.          char *path,       /* relative path of subkey to add */
  125.          RKEY *newKey      /* if not null returns newly created key */
  126.        );
  127.  
  128. VR_INTERFACE(REGERR) NR_RegDeleteKey(
  129.          HREG hReg,        /* handle of open registry */
  130.          RKEY key,         /* root key */
  131.          char *path        /* relative path of subkey to delete */
  132.        );
  133.  
  134. VR_INTERFACE(REGERR) NR_RegGetKey(
  135.          HREG hReg,        /* handle of open registry */
  136.          RKEY key,         /* root key */
  137.          char *path,       /* relative path of subkey to find */
  138.          RKEY *result      /* returns RKEY of specified sub-key */
  139.        );
  140.  
  141. VR_INTERFACE(REGERR) NR_RegEnumSubkeys(
  142.          HREG    hReg,        /* handle of open registry */
  143.          RKEY    key,         /* containing key */
  144.          REGENUM *state,      /* enum state, must be NULL to start */
  145.          char    *buffer,     /* buffer for entry names */
  146.          uint32  bufsize,     /* size of buffer */
  147.          uint32  style        /* 0: children only; REGENUM_DESCEND: sub-tree */
  148.        );
  149.  
  150. /* ---------------------------------------------------------------------
  151.  * Registry API -- Entry Management functions
  152.  * ---------------------------------------------------------------------
  153.  */
  154.  
  155. VR_INTERFACE(REGERR) NR_RegGetEntryInfo(
  156.          HREG    hReg,     /* handle of open registry */
  157.          RKEY    key,      /* containing key */
  158.          char    *name,    /* entry name */
  159.          REGINFO *info     /* returned entry info */
  160.        );
  161.  
  162. VR_INTERFACE(REGERR) NR_RegGetEntryString(
  163.          HREG   hReg,      /* handle of open registry */
  164.          RKEY   key,       /* containing key */
  165.          char   *name,     /* entry name */
  166.          char   *buffer,   /* buffer to hold value (UTF String) */
  167.          uint32 bufsize    /* length of buffer */
  168.        );
  169.  
  170. VR_INTERFACE(REGERR) NR_RegGetEntry(
  171.          HREG   hReg,      /* handle of open registry */
  172.          RKEY   key,       /* containing key */
  173.          char   *name,     /* entry name */
  174.          void   *buffer,   /* buffer to hold value */
  175.          uint32 *size      /* in:length of buffer */
  176.        );                  /* out: data length, >>includes<< null terminator*/
  177.  
  178. VR_INTERFACE(REGERR) NR_RegSetEntryString(
  179.          HREG hReg,        /* handle of open registry */
  180.          RKEY key,         /* containing key */
  181.          char *name,       /* entry name */
  182.          char *buffer      /* UTF String value */
  183.        );
  184.  
  185. VR_INTERFACE(REGERR) NR_RegSetEntry(
  186.          HREG   hReg,        /* handle of open registry */
  187.          RKEY   key,         /* containing key */
  188.          char   *name,       /* entry name */
  189.          uint16 type,        /* type of value data */
  190.          void   *buffer,     /* data buffer */
  191.          uint32 size         /* data length in bytes; incl. null term for strings */
  192.        );
  193.  
  194. VR_INTERFACE(REGERR) NR_RegDeleteEntry(
  195.          HREG hReg,        /* handle of open registry */
  196.          RKEY key,         /* containing key */
  197.          char *name        /* value name */
  198.        );
  199.  
  200. VR_INTERFACE(REGERR) NR_RegEnumEntries(
  201.          HREG    hReg,        /* handle of open registry */
  202.          RKEY    key,         /* containing key */
  203.          REGENUM *state,      /* enum state, must be NULL to start */
  204.          char    *buffer,     /* buffer for entry names */
  205.          uint32  bufsize,     /* size of buffer */
  206.          REGINFO *info        /* optional; returns info about entry */
  207.        );
  208.  
  209. #ifndef STANDALONE_REGISTRY
  210. void NR_ShutdownRegistry(void);
  211. void NR_StartupRegistry(void);
  212. #endif /* STANDALONE_REGISTRY */
  213.  
  214. XP_END_PROTOS
  215.  
  216. #endif   /* _NSREG_H_ */
  217.  
  218. /* EOF: NSReg.h */
  219.  
  220.