1 /*
2 Copyright (C) 2015-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4wreg8.ctr
12 */
13 
14 #ifndef DK4WREG8_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4WREG8_H_INCLUDED 1
17 
18 
19 /**	@file
20 	Access Windows registry, use
21 	8 bit character names.
22 
23 	CRT on Windows: Optional.
24 */
25 
26 #ifndef DK4CONF_H_INCLUDED
27 #if DK4_BUILDING_DKTOOLS4
28 #include "dk4conf.h"
29 #else
30 #include <dktools-4/dk4conf.h>
31 #endif
32 #endif
33 
34 #ifndef DK4TYPES_H_INCLUDED
35 #if DK4_BUILDING_DKTOOLS4
36 #include <libdk4base/dk4types.h>
37 #else
38 #include <dktools-4/dk4types.h>
39 #endif
40 #endif
41 
42 #ifndef DK4ERROR_H_INCLUDED
43 #if DK4_BUILDING_DKTOOLS4
44 #include <libdk4base/dk4error.h>
45 #else
46 #include <dktools-4/dk4error.h>
47 #endif
48 #endif
49 
50 #ifndef DK4WREGK_H_INCLUDED
51 #if DK4_BUILDING_DKTOOLS4
52 #include <libdk4c/dk4wregk.h>
53 #else
54 #include <dktools-4/dk4wregk.h>
55 #endif
56 #endif
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /**	Open a registry key.
63 	@param	pk	Parent key identifier.
64 	@param	keyname	Name of registry key to open.
65 	@param	wr	Flag: Open for write access too.
66 	@param	erp	Error report, may be NULL.
67 	@return	Pointer to key handle structure on success, NULL on error.
68 
69 	Error codes:
70 	- DK4_E_NOT_SUPPORTED<br>
71 	  if the function is run on a non-Windows system,
72 	- DK4_E_INVALID_ARGUMENTS<br>
73 	  if pk or keyname is invalid,
74 	- DK4_E_NOT_FOUND<br>
75 	  if opening or creating the registry key failed,
76 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
77 	  if memory allocation for the key handle structure failed.
78 */
79 void *
80 dk4wreg_open_key_c8(int pk, const char *keyname, int wr, dk4_er_t *erp);
81 
82 /**	Set a string value.
83 	@param	kptr	Key handle structure.
84 	@param	name	Entry name.
85 	@param	val	Entry value.
86 	@param	expand	Flag: Use REG_EXPAND_SZ (1) or REG_SZ (0).
87 	@param	erp	Error report, may be NULL.
88 	@return	1 on success, 0 on error.
89 
90 	Error codes:
91 	- DK4_E_NOT_SUPPORTED<br>
92 	  when called on non-Windows systems,
93 	- DK4_E_INVALID_ARGUMENTS<br>
94 	  if kptr or val is NULL,
95 	- DK4_E_MATH_OVERFLOW<br>
96 	  if the name is too long,
97 	- DK4_E_SYSTEM<br>
98 	  if RegSetValueExA() failed.
99 */
100 int
101 dk4wreg_set_string_c8(
102   void *kptr, const char *name, const char *val, int expand, dk4_er_t *erp
103 );
104 
105 /**	Get string value.
106 	@param	kptr	Key handle structure.
107 	@param	name	Entry name.
108 	@param	bptr	Buffer for result string.
109 	@param	sz	Result buffer length.
110 	@param	expand	Pointer to expand flag output variable.
111 			This variable is set to 1 if the string found
112 			is of type REG_EXPAND_SZ. The variable is left
113 			unchanged for REG_SZ.
114 	@param	erp	Error report, may be NULL.
115 	@return	1 on success, 0 on error.
116 
117 	Error codes:
118 	- DK4_E_NOT_SUPPORTED<br>
119 	  when called on non-Windows systems,
120 	- DK4_E_INVALID_ARGUMENTS<br>
121 	  if kptr, name, or bptr is NULL or sz is 0,
122 	- DK4_E_NOT_FOUND<br>
123 	  if the entry is not found or has 0 length,
124 	- DK4_E_SYNTAX<br>
125 	  if the entry is not a string type.
126 */
127 int
128 dk4wreg_get_string_c8(
129   void		*kptr,
130   const char	*name,
131   char		*bptr,
132   size_t	 sz,
133   int		*expand,
134   dk4_er_t	*erp
135 );
136 
137 /**	Set DWORD registry entry.
138 	@param	kptr	Key handle structure.
139 	@param	name	Entry name.
140 	@param	val	Value.
141 	@param	erp	Error report, may be NULL.
142 	@return	1 on success, 0 on error.
143 
144 	Error codes:
145 	- DK4_E_NOT_SUPPORTED<br>
146 	  when called on a non-Windows system,
147 	- DK4_E_INVALID_ARGUMENTS<br>
148 	  if kptr is NULL,
149 	- DK4_E_SYSTEM<br>
150 	  if RegSetValueExA() failed.
151 */
152 int
153 dk4wreg_set_dword_c8(
154   void *kptr, const char *name, dk4_dword_t val, dk4_er_t *erp
155 );
156 
157 /**	Retrieve DWORD value from registry.
158 	@param	kptr	Key handle structure.
159 	@param	name	Entry name.
160 	@param	vptr	Pointer to result variable.
161 	@param	erp	Error report, may be NULL.
162 	@return	1 on success, 0 on error.
163 */
164 int
165 dk4wreg_get_dword_c8(
166   void		*kptr,
167   const char	*name,
168   dk4_dword_t	*vptr,
169   dk4_er_t	*erp
170 );
171 
172 /**	Get string value.
173 	@param	kptr	Key handle structure.
174 	@param	name	Entry name.
175 	@param	dptr	Buffer for result string.
176 	@param	dsz	Result buffer length.
177 	@param	b1	First buffer, used for result from RegQueryValue().
178 			Should have same size as dptr.
179 	@param	b1sz	Size of b1.
180 	@param	b2	Second buffer, used for result from ExpandEnvironmentStrings.
181 			Should be 2 characters larger than dptr.
182 	@param	b2sz	Size of b2.
183 	@param	erp	Error report, may be NULL.
184 	@return	1 on success, 0 on error.
185 
186 	Error codes:
187 	- DK4_E_NOT_SUPPORTED<br>
188 	  when called on non-Windows systems,
189 	- DK4_E_INVALID_ARGUMENTS<br>
190 	  if kptr, name, dptr, b1 or b2 is NULL or
191 	  dsz, b1sz or b2sz is 0 or out of range,
192 	- DK4_E_BUFFER_TOO_SMALL<br>
193 	  if one of the buffers is too small,
194 	- DK4_E_NOT_FOUND<br>
195 	  if the entry is not found or has 0 length,
196 	- DK4_E_SYNTAX<br>
197 	  if the entry is not a string type.
198 */
199 int
200 dk4wreg_get_expanded_string_c8(
201   void		*kptr,
202   const char	*name,
203   char		*dptr,
204   size_t	 dsz,
205   char		*b1,
206   size_t	 b1sz,
207   char		*b2,
208   size_t	 b2sz,
209   dk4_er_t	*erp
210 );
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 
217 #endif
218