23 using namespace basis;
36 #ifdef DEBUG_REGISTRY_CONFIGURATOR
37 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
54 const astring ®istry_configurator::reg_str_fake_default()
56 static astring _hidden =
"bogus_never_should_see";
93 for (
int i = 0; i < to_return.
length(); i++) {
94 if (to_return[i] ==
'/')
106 else if (!section.
length())
return false;
111 to_unicode_temp(section), 0, KEY_WRITE, &key);
112 if (ret != ERROR_SUCCESS) {
113 LOG(
"failed to open the key, trying to create it.");
116 to_unicode_temp(section), 0,
NULL_POINTER, REG_OPTION_NON_VOLATILE,
118 if (ret != ERROR_SUCCESS) {
119 LOG(
"failed to create the key!!");
124 bool to_return =
true;
125 ret = RegSetValueEx(key, to_unicode_temp(entry), 0, REG_SZ,
126 (
byte *)to_store.
s(), to_store.
length() + 1);
127 if (ret != ERROR_SUCCESS) {
144 if (!section_in)
return false;
150 to_unicode_temp(section), 0, KEY_QUERY_VALUE, &key);
151 if (ret != ERROR_SUCCESS) {
152 LOG(
"failed to open the key!");
159 ret = RegQueryValueEx(key, to_unicode_temp(entry), 0, &type_seen, data_seen,
161 if (ret != ERROR_SUCCESS) {
166 if (type_seen != REG_SZ) {
167 LOG(
astring(
"entry found was not of string type!"));
174 found =
astring((
char *)data_seen);
190 if (!section_in.
length())
return false;
195 to_unicode_temp(section), 0, KEY_QUERY_VALUE, &key);
196 if (ret != ERROR_SUCCESS) {
197 LOG(
"failed to open the key!");
205 for (
DWORD index = 0;
true; index++) {
208 LONG ret = RegEnumValue(key, index, name_seen, &name_length, 0,
209 &type_seen, data_seen, &length);
210 if (ret != ERROR_SUCCESS)
break;
211 if (type_seen == REG_SZ) {
213 astring name = from_unicode_temp(name_seen);
215 info.
add(name, content);
233 if (!section_in.
length())
return false;
238 to_unicode_temp(section), 0, KEY_QUERY_VALUE, &key);
239 if (ret != ERROR_SUCCESS) {
240 LOG(
"failed to open the key!");
253 if (!section_in.
length())
return false;
258 to_unicode_temp(section));
259 if (ret != ERROR_SUCCESS) {
260 LOG(
"failed to delete the key!");
273 if (!section_in.
length())
return false;
280 to_unicode_temp(section), 0, KEY_SET_VALUE, &key);
281 if (ret != ERROR_SUCCESS) {
282 LOG(
"failed to open the key!");
286 bool to_return =
true;
287 ret = RegDeleteValue(key, to_unicode_temp(entry));
288 if (ret != ERROR_SUCCESS) {
303 if (!section_in)
return false;
305 bool failures =
false;
306 for (
int i = 0; i < info.
symbols(); i++) {
307 bool worked =
put(section, info.
name(i), info[i]);
308 if (!worked) failures =
true;
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
int length() const
Returns the current length of the string.
Provides a base class for configuration repositories.
virtual bool put_section(const basis::astring §ion, const structures::string_table &info)
writes a table called "info" into the "section" in the INI file.
basis::astring fix_section(const basis::astring §ion)
repairs malformed section names.
virtual ~registry_configurator()
virtual bool put(const basis::astring §ion, const basis::astring &entry, const basis::astring &to_store)
implements the configurator storage function.
virtual bool section_exists(const basis::astring §ion)
returns true if the "section" was found in the file.
void * translate_hive(registry_hives hive)
translates from our enum to the windows specific type for hives.
virtual bool get_section(const basis::astring §ion, structures::string_table &info)
reads the entire "section" into a table called "info".
virtual bool delete_entry(const basis::astring §ion, const basis::astring &entry)
removes the entry specified by the "section" and "entry" name.
registry_hives
the hives are major partitions of the registry.
virtual bool delete_section(const basis::astring §ion)
removes the entire "section" specified.
virtual bool get(const basis::astring §ion, const basis::astring &entry, basis::astring &found)
implements the configurator retrieval function.
Provides a symbol_table that holds strings as the content.
const basis::astring & name(int index) const
returns the name held at the "index".
basis::outcome add(const basis::astring &name, const contents &storage)
Enters a symbol name into the table along with some contents.
int symbols() const
returns the number of symbols listed in the table.
#define NULL_POINTER
The value representing a pointer to nothing.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
The guards collection helps in testing preconditions and reporting errors.
const int KILOBYTE
Number of bytes in a kilobyte.
void * HKEY_LOCAL_MACHINE
void * HKEY_CURRENT_CONFIG
const int MAXIMUM_NAME_SIZE
const int MAXIMUM_ENTRY_SIZE
A platform independent way to obtain the timestamp of a file.
A dynamic container class that holds any kind of object via pointers.
Support for unicode builds.
Aids in achievement of platform independence.