ap_regkey.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @file ap_regkey.h
  18. * @brief APR-style Win32 Registry Manipulation
  19. */
  20. #ifndef AP_REGKEY_H
  21. #define AP_REGKEY_H
  22. #if defined(WIN32) || defined(DOXYGEN)
  23. #include "apr.h"
  24. #include "apr_pools.h"
  25. #include "ap_config.h" /* Just for AP_DECLARE */
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. typedef struct ap_regkey_t ap_regkey_t;
  30. /* Used to recover AP_REGKEY_* constants
  31. */
  32. AP_DECLARE(const ap_regkey_t *) ap_regkey_const(int i);
  33. /**
  34. * Win32 Only: Constants for ap_regkey_open()
  35. */
  36. #define AP_REGKEY_CLASSES_ROOT ap_regkey_const(0)
  37. #define AP_REGKEY_CURRENT_CONFIG ap_regkey_const(1)
  38. #define AP_REGKEY_CURRENT_USER ap_regkey_const(2)
  39. #define AP_REGKEY_LOCAL_MACHINE ap_regkey_const(3)
  40. #define AP_REGKEY_USERS ap_regkey_const(4)
  41. #define AP_REGKEY_PERFORMANCE_DATA ap_regkey_const(5)
  42. #define AP_REGKEY_DYN_DATA ap_regkey_const(6)
  43. /**
  44. * Win32 Only: Flags for ap_regkey_value_set()
  45. */
  46. #define AP_REGKEY_EXPAND 0x0001
  47. /**
  48. * Win32 Only: Open the specified registry key.
  49. * @param newkey The opened registry key
  50. * @param parentkey The open registry key of the parent, or one of
  51. * <PRE>
  52. * AP_REGKEY_CLASSES_ROOT
  53. * AP_REGKEY_CURRENT_CONFIG
  54. * AP_REGKEY_CURRENT_USER
  55. * AP_REGKEY_LOCAL_MACHINE
  56. * AP_REGKEY_USERS
  57. * AP_REGKEY_PERFORMANCE_DATA
  58. * AP_REGKEY_DYN_DATA
  59. * </PRE>
  60. * @param keyname The path of the key relative to the parent key
  61. * @param flags Or'ed value of:
  62. * <PRE>
  63. * APR_READ open key for reading
  64. * APR_WRITE open key for writing
  65. * APR_CREATE create the key if it doesn't exist
  66. * APR_EXCL return error if APR_CREATE and key exists
  67. * </PRE>
  68. * @param pool The pool in which newkey is allocated
  69. */
  70. AP_DECLARE(apr_status_t) ap_regkey_open(ap_regkey_t **newkey,
  71. const ap_regkey_t *parentkey,
  72. const char *keyname,
  73. apr_int32_t flags,
  74. apr_pool_t *pool);
  75. /**
  76. * Win32 Only: Close the registry key opened or created by ap_regkey_open().
  77. * @param key The registry key to close
  78. */
  79. AP_DECLARE(apr_status_t) ap_regkey_close(ap_regkey_t *key);
  80. /**
  81. * Win32 Only: Remove the given registry key.
  82. * @param parent The open registry key of the parent, or one of
  83. * <PRE>
  84. * AP_REGKEY_CLASSES_ROOT
  85. * AP_REGKEY_CURRENT_CONFIG
  86. * AP_REGKEY_CURRENT_USER
  87. * AP_REGKEY_LOCAL_MACHINE
  88. * AP_REGKEY_USERS
  89. * AP_REGKEY_PERFORMANCE_DATA
  90. * AP_REGKEY_DYN_DATA
  91. * </PRE>
  92. * @param keyname The path of the key relative to the parent key
  93. * @param pool The pool used for temp allocations
  94. * @remark ap_regkey_remove() is not recursive, although it removes
  95. * all values within the given keyname, it will not remove a key
  96. * containing subkeys.
  97. */
  98. AP_DECLARE(apr_status_t) ap_regkey_remove(const ap_regkey_t *parent,
  99. const char *keyname,
  100. apr_pool_t *pool);
  101. /**
  102. * Win32 Only: Retrieve a registry value string from an open key.
  103. * @param result The string value retrieved
  104. * @param key The registry key to retrieve the value from
  105. * @param valuename The named value to retrieve (pass "" for the default)
  106. * @param pool The pool used to store the result
  107. * @remark There is no toggle to prevent environment variable expansion
  108. * if the registry value is set with AP_REG_EXPAND (REG_EXPAND_SZ), such
  109. * expansions are always performed.
  110. */
  111. AP_DECLARE(apr_status_t) ap_regkey_value_get(char **result,
  112. ap_regkey_t *key,
  113. const char *valuename,
  114. apr_pool_t *pool);
  115. /**
  116. * Win32 Only: Store a registry value string into an open key.
  117. * @param key The registry key to store the value into
  118. * @param valuename The named value to store (pass "" for the default)
  119. * @param value The string to store for the named value
  120. * @param flags The option AP_REGKEY_EXPAND or 0, where AP_REGKEY_EXPAND
  121. * values will find all %foo% variables expanded from the environment.
  122. * @param pool The pool used for temp allocations
  123. */
  124. AP_DECLARE(apr_status_t) ap_regkey_value_set(ap_regkey_t *key,
  125. const char *valuename,
  126. const char *value,
  127. apr_int32_t flags,
  128. apr_pool_t *pool);
  129. /**
  130. * Win32 Only: Retrieve a raw byte value from an open key.
  131. * @param result The raw bytes value retrieved
  132. * @param resultsize Pointer to a variable to store the number raw bytes retrieved
  133. * @param resulttype Pointer to a variable to store the registry type of the value retrieved
  134. * @param key The registry key to retrieve the value from
  135. * @param valuename The named value to retrieve (pass "" for the default)
  136. * @param pool The pool used to store the result
  137. */
  138. AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result,
  139. apr_size_t *resultsize,
  140. apr_int32_t *resulttype,
  141. ap_regkey_t *key,
  142. const char *valuename,
  143. apr_pool_t *pool);
  144. /**
  145. * Win32 Only: Store a raw bytes value into an open key.
  146. * @param key The registry key to store the value into
  147. * @param valuename The named value to store (pass "" for the default)
  148. * @param value The bytes to store for the named value
  149. * @param valuesize The number of bytes for value
  150. * @param valuetype The
  151. * values will find all %foo% variables expanded from the environment.
  152. * @param pool The pool used for temp allocations
  153. */
  154. AP_DECLARE(apr_status_t) ap_regkey_value_raw_set(ap_regkey_t *key,
  155. const char *valuename,
  156. const void *value,
  157. apr_size_t valuesize,
  158. apr_int32_t valuetype,
  159. apr_pool_t *pool);
  160. /**
  161. * Win32 Only: Retrieve a registry value string from an open key.
  162. * @param result The string elements retrieved from a REG_MULTI_SZ string array
  163. * @param key The registry key to retrieve the value from
  164. * @param valuename The named value to retrieve (pass "" for the default)
  165. * @param pool The pool used to store the result
  166. */
  167. AP_DECLARE(apr_status_t) ap_regkey_value_array_get(apr_array_header_t **result,
  168. ap_regkey_t *key,
  169. const char *valuename,
  170. apr_pool_t *pool);
  171. /**
  172. * Win32 Only: Store a registry value string array into an open key.
  173. * @param key The registry key to store the value into
  174. * @param valuename The named value to store (pass "" for the default)
  175. * @param nelts The string elements to store in a REG_MULTI_SZ string array
  176. * @param elts The number of elements in the elts string array
  177. * @param pool The pool used for temp allocations
  178. */
  179. AP_DECLARE(apr_status_t) ap_regkey_value_array_set(ap_regkey_t *key,
  180. const char *valuename,
  181. int nelts,
  182. const char * const * elts,
  183. apr_pool_t *pool);
  184. /**
  185. * Win32 Only: Remove a registry value from an open key.
  186. * @param key The registry key to remove the value from
  187. * @param valuename The named value to remove (pass "" for the default)
  188. * @param pool The pool used for temp allocations
  189. */
  190. AP_DECLARE(apr_status_t) ap_regkey_value_remove(const ap_regkey_t *key,
  191. const char *valuename,
  192. apr_pool_t *pool);
  193. #ifdef __cplusplus
  194. }
  195. #endif
  196. #endif /* def WIN32 || def DOXYGEN */
  197. #endif /* AP_REGKEY_H */