54 |
{ |
{ |
55 |
free_if_alloc (reg_prefs.backup.path); |
free_if_alloc (reg_prefs.backup.path); |
56 |
free_if_alloc (reg_prefs.kserv_conf); |
free_if_alloc (reg_prefs.kserv_conf); |
57 |
|
free_if_alloc (reg_prefs.homedir); |
58 |
memset (®_prefs, 0, sizeof reg_prefs); |
memset (®_prefs, 0, sizeof reg_prefs); |
59 |
} /* free_reg_prefs */ |
} /* free_reg_prefs */ |
60 |
|
|
61 |
|
|
62 |
/* |
/* Register the given WinPT filetype. */ |
|
* Register the given WinPT filetype. |
|
|
*/ |
|
63 |
static int |
static int |
64 |
regist_single_filetype (gpg_filetype *gfile) |
regist_single_filetype (gpg_filetype *gfile) |
65 |
{ |
{ |
72 |
} /* regist_single_filetype */ |
} /* regist_single_filetype */ |
73 |
|
|
74 |
|
|
75 |
/* |
/* Install the GPG related into the W32 resgistry, if the entry already |
76 |
* Install the GPG related into the W32 resgistry, if the entry already |
exists the function returns immediately. */ |
|
* exists< the function returns immediately. |
|
|
*/ |
|
77 |
int |
int |
78 |
regist_inst_gnupg( int create_mokey ) |
regist_inst_gnupg (int create_mokey) |
79 |
{ |
{ |
80 |
int rc; |
int rc; |
81 |
HKEY reg; |
HKEY reg; |
105 |
} /* regist_inst_gpg */ |
} /* regist_inst_gpg */ |
106 |
|
|
107 |
|
|
108 |
/* |
/* Install WinPT into the W32 registry, if the entry already |
109 |
* Install WinPT into the W32 registry, if the entry already |
exists the function returns immediately.*/ |
|
* exists the function returns immediately. |
|
|
*/ |
|
110 |
int |
int |
111 |
regist_inst_winpt( int with_ext, int * created ) |
regist_inst_winpt (int with_ext, int * created) |
112 |
{ |
{ |
113 |
HKEY reg; |
HKEY reg; |
114 |
char * p = NULL; |
char * p = NULL; |
117 |
if( created ) |
if( created ) |
118 |
*created = 0; |
*created = 0; |
119 |
|
|
120 |
p = get_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions" ); |
p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions"); |
121 |
if( p && *p == '1' ) |
if (p && *p == '1') |
122 |
with_ext = 0; |
with_ext = 0; |
123 |
free_if_alloc( p ); |
free_if_alloc( p ); |
124 |
|
|
178 |
} /* regist_inst_winpt */ |
} /* regist_inst_winpt */ |
179 |
|
|
180 |
|
|
181 |
/* |
/* Create a new filetype in the W32 registry. |
182 |
* Create a new filetype in the W32 registry. |
We should really care of errors! Otherwise we can damage the registry! */ |
|
* We should really care of errors! Otherwise we can damage the registry! |
|
|
*/ |
|
183 |
int |
int |
184 |
create_file_type( const char *exefile, const char *ext, const char *extname, char *iconfile ) |
create_file_type( const char *exefile, const char *ext, const char *extname, char *iconfile ) |
185 |
{ |
{ |
234 |
} /* create_file_type */ |
} /* create_file_type */ |
235 |
|
|
236 |
|
|
237 |
|
/* Expand a string with %foo% entries so that %foo% will |
238 |
|
be replaced with its actual value. */ |
239 |
static char * |
static char * |
240 |
expand_path( const char *path ) |
expand_path (const char *path) |
241 |
{ |
{ |
242 |
DWORD len; |
DWORD len; |
243 |
char *p; |
char *p; |
244 |
|
|
245 |
len = ExpandEnvironmentStrings( path, NULL, 0 ); |
len = ExpandEnvironmentStrings (path, NULL, 0); |
246 |
if( !len ) |
if (!len) |
247 |
return NULL; |
return NULL; |
248 |
len += 1; |
len += 1; |
249 |
p = new char[len]; |
p = new char[len+1]; |
250 |
if( !p ) |
if( !p ) |
251 |
return NULL; |
return NULL; |
252 |
len = ExpandEnvironmentStrings( path, p, len ); |
len = ExpandEnvironmentStrings (path, p, len); |
253 |
if( !len ) { |
if (!len) { |
254 |
free_if_alloc( p ); |
free_if_alloc (p); |
255 |
return NULL; |
return NULL; |
256 |
} |
} |
257 |
return p; |
return p; |
258 |
} /* expand_path */ |
} /* expand_path */ |
259 |
|
|
260 |
|
|
261 |
char * |
/* Retrieve a registry entry with the directory given in @dir |
262 |
get_reg_entry( HKEY root_key, const char * dir, const char * key ) |
and the key given in @key. |
263 |
|
Return value is the value or NULL otherwise. */ |
264 |
|
char* |
265 |
|
get_reg_entry (HKEY root_key, const char * dir, const char * key) |
266 |
{ |
{ |
267 |
int rc; |
int rc; |
268 |
char text[384] = {0}; |
char text[384] = {0}; |
270 |
HKEY reg_key = NULL; |
HKEY reg_key = NULL; |
271 |
char * p = NULL, * tmp = NULL; |
char * p = NULL, * tmp = NULL; |
272 |
|
|
273 |
rc = RegOpenKeyEx( root_key, dir, 0, KEY_QUERY_VALUE, ®_key ); |
rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, ®_key); |
274 |
if( !rc_ok( rc ) ) |
if( !rc_ok( rc ) ) |
275 |
goto leave; |
goto leave; |
276 |
nbytes = sizeof text - 1; |
nbytes = sizeof (text) - 1; |
277 |
type = REG_SZ; |
type = REG_SZ; |
278 |
|
|
279 |
rc = RegQueryValueEx (reg_key, key, 0, &type, (BYTE *)&text, &nbytes); |
rc = RegQueryValueEx (reg_key, key, 0, &type, (BYTE *)&text, &nbytes); |
294 |
if (reg_key) |
if (reg_key) |
295 |
RegCloseKey (reg_key); |
RegCloseKey (reg_key); |
296 |
return p; |
return p; |
297 |
} /* get_reg_entry */ |
} |
298 |
|
|
299 |
|
|
300 |
|
/* XXX: use REG_EXPAND_SZ to support multi user environments. |
301 |
|
keep this type and do not overwrite it with REG_SZ. */ |
302 |
|
|
303 |
|
/* Set a registry entry. */ |
304 |
int |
int |
305 |
set_reg_entry( HKEY root_key, const char * dir, const char * key, |
set_reg_entry (HKEY root_key, const char *dir, const char *key, |
306 |
const char * value ) |
const char *value) |
307 |
{ |
{ |
308 |
int rc = 0; |
int rc = 0; |
309 |
HKEY reg_key; |
HKEY reg_key; |
348 |
|
|
349 |
|
|
350 |
int |
int |
351 |
set_reg_entry_gpg( const char * key, const char * value ) |
set_reg_entry_gpg (const char * key, const char * value) |
352 |
{ |
{ |
353 |
return set_reg_entry( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key, value ); |
return set_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key, value); |
354 |
} /* set_reg_entry_gpg */ |
} |
355 |
|
|
356 |
|
|
357 |
int |
int |
358 |
set_reg_entry_mo( const char * value ) |
set_reg_entry_mo (const char * value) |
359 |
{ |
{ |
360 |
return set_reg_entry( HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS", "MODir", value ); |
return set_reg_entry (HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS", |
361 |
} /* set_reg_entry_mo */ |
"MODir", value); |
362 |
|
} |
363 |
|
|
364 |
|
|
365 |
char * |
char * |
366 |
get_reg_entry_gpg( const char *key ) |
get_reg_entry_gpg (const char *key) |
367 |
{ |
{ |
368 |
return get_reg_entry( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key ); |
return get_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key); |
369 |
} /* get_reg_entry_gpg */ |
} |
370 |
|
|
371 |
|
|
372 |
char * |
char * |
373 |
get_reg_entry_mo( void ) |
get_reg_entry_mo(void) |
374 |
{ |
{ |
375 |
return get_reg_entry( HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS", "MODir" ); |
return get_reg_entry(HKEY_CURRENT_USER, |
376 |
} /* get_reg_entry_mo */ |
"Control Panel\\Mingw32\\NLS", "MODir"); |
377 |
|
} |
378 |
|
|
379 |
|
|
380 |
|
/* All valid configuration commands. */ |
381 |
static const char * cfg [] = { |
static const char * cfg [] = { |
382 |
NULL, |
NULL, |
383 |
"CacheTime", |
"CacheTime", |
424 |
} |
} |
425 |
|
|
426 |
|
|
427 |
|
/* Saves the winpt preferences in the registry. */ |
428 |
int |
int |
429 |
set_reg_winpt_prefs (winpt_reg_prefs_s * opt) |
set_reg_winpt_prefs (winpt_reg_prefs_s * opt) |
430 |
{ |
{ |
508 |
return rc; |
return rc; |
509 |
} |
} |
510 |
return 0; |
return 0; |
511 |
} /* set_reg_winpt_prefs */ |
} |
512 |
|
|
513 |
|
|
514 |
int |
int |
534 |
} /* get_reg_winpt_flag */ |
} /* get_reg_winpt_flag */ |
535 |
|
|
536 |
|
|
537 |
|
/* Retrieve the winpt preferences from the registry. */ |
538 |
int |
int |
539 |
get_reg_winpt_prefs (winpt_reg_prefs_s * opt) |
get_reg_winpt_prefs (winpt_reg_prefs_s * opt) |
540 |
{ |
{ |
621 |
} /* get_reg_winpt_prefs */ |
} /* get_reg_winpt_prefs */ |
622 |
|
|
623 |
|
|
624 |
char * |
char* |
625 |
get_reg_entry_keyserver (const char *name) |
get_reg_entry_keyserver (const char *name) |
626 |
{ |
{ |
627 |
char * p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name); |
char * p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name); |
630 |
return NULL; |
return NULL; |
631 |
} |
} |
632 |
return p; |
return p; |
633 |
} /* get_reg_entry_keyserver */ |
} |
634 |
|
|
635 |
|
|
636 |
void |
void |