/[winpt]/trunk/Src/wptRegistry.cpp
ViewVC logotype

Contents of /trunk/Src/wptRegistry.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 76 - (show annotations)
Thu Nov 10 14:07:06 2005 UTC (19 years, 3 months ago) by twoaday
File size: 17840 byte(s)
2005-11-09  Timo Schulz  <ts@g10code.com>
 
        * wptNLS.c (get_gettext_langid): Map user language id to
        printable gettext language strings.
        * wptRegistry.cpp (get_reg_entry_mo): Support for the
        gettext environment.
        * wptFileManager.cpp (fm_encrypt): Close all files before
        the wipe procedure is called.
        * wptVerlist.cpp (verlist_add_sig): Handle the case the
        issuer is not valid but the signature is.
        (verlist_add_sig_log): Likewise. Thanks to the folks on
        winpt-users.


1 /* wptRegistry.cpp - W32 Registry access
2 * Copyright (C) 2000-2005 Timo Schulz
3 *
4 * This file is part of WinPT.
5 *
6 * WinPT is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * WinPT is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with WinPT; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24
25 #include <windows.h>
26 #include <stdio.h>
27
28 #include "wptErrors.h"
29 #include "wptW32API.h"
30 #include "wptGPG.h"
31 #include "wptRegistry.h"
32 #include "wptKeyserver.h"
33 #include "wptTypes.h"
34 #include "wptNLS.h"
35 #include "wptVersion.h"
36
37 #define rc_ok(rc) ((rc) == ERROR_SUCCESS)
38
39 static gpg_filetype gpg_filetypes[] = {
40 {"GPG Detached Signature", ".sig", 1},
41 {"GPG Encrypted Data", ".gpg", 2},
42 {"GPG Armored Data", ".asc", 2},
43 {0}
44 };
45
46 struct reg_hotkey_s reg_hotkeys[] = {
47 {"ClipEncrypt", "", 0},
48 {"ClipDecrypt", "", 0},
49 {"ClipSign", "", 0},
50 {"ClipSignEnc", "", 0},
51 {"CwsEncrypt", "", 0},
52 {"CwsDecrypt", "", 0},
53 {"CwsSign", "", 0},
54 {"CwsSignEnc", "", 0},
55 {NULL, "", 0}
56 };
57
58 winpt_reg_prefs_s reg_prefs;
59
60 #define WINPT_REG "Software\\WinPT"
61
62
63 void
64 free_reg_prefs (void)
65 {
66 free_if_alloc (reg_prefs.backup.path);
67 free_if_alloc (reg_prefs.kserv_conf);
68 free_if_alloc (reg_prefs.homedir);
69 memset (&reg_prefs, 0, sizeof reg_prefs);
70 } /* free_reg_prefs */
71
72
73 /* Register the given WinPT filetype. */
74 static int
75 regist_single_filetype (gpg_filetype *gfile)
76 {
77 char icon[256], prog[256];
78
79 memset (&icon, 0, sizeof (icon));
80 GetModuleFileName (glob_hinst, prog, sizeof (prog)-1);
81 _snprintf (icon, sizeof (icon) -1, "%s,%d", prog, gfile->nicon);
82 return create_file_type (prog, gfile->ext, gfile->descr, icon);
83 } /* regist_single_filetype */
84
85
86 /* Install the GPG related into the W32 resgistry, if the entry already
87 exists the function returns immediately. */
88 int
89 regist_inst_gnupg (int create_mokey)
90 {
91 int rc;
92 HKEY reg;
93
94 rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", 0, KEY_READ, &reg );
95 if( rc_ok( rc ) ) {
96 RegCloseKey( reg );
97 return 0;
98 }
99 rc = RegCreateKey( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", &reg );
100 if( !rc_ok( rc ) )
101 return WPTERR_REGISTRY;
102 RegCloseKey( reg );
103 if( create_mokey ) {
104 rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Control Panel\\MingW32\\NLS", 0, KEY_READ, &reg );
105 if( rc_ok( rc ) ) {
106 RegCloseKey( reg );
107 return 0;
108 }
109 rc = RegCreateKey( HKEY_CURRENT_USER, "Control Panel\\MingW32\\NLS", &reg );
110 if( !rc_ok( rc ) )
111 return WPTERR_REGISTRY;
112 RegCloseKey( reg );
113 }
114
115 return 0;
116 } /* regist_inst_gpg */
117
118
119 /* Install WinPT into the W32 registry, if the entry already
120 exists the function returns immediately.*/
121 int
122 regist_inst_winpt (int with_ext, int * created)
123 {
124 HKEY reg;
125 char * p = NULL;
126 int rc, i, id, n = 0;
127
128 if( created )
129 *created = 0;
130
131 p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions");
132 if (p && *p == '1')
133 with_ext = 0;
134 free_if_alloc( p );
135
136 if( with_ext ) {
137 id = msg_box( NULL, _("WinPT can register some GPG file types for you so they can "
138 "be processed with a double click in the explorer.\n"
139 "Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO );
140 if( id == IDNO ) {
141 set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" );
142 goto start;
143 }
144 for( i = 0; gpg_filetypes[i].ext; i++ ) {
145 rc = RegOpenKeyEx( HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, &reg );
146 if( rc_ok( rc ) ) {
147 RegCloseKey( reg );
148 id = log_box( _("WinPT WARNING"), MB_YESNO|MB_INFO,
149 _("It seems there was already a '%s' file type registered by another application.\n"
150 "Do you want to overwrite it?"), gpg_filetypes[i].ext );
151 if( id == IDNO )
152 continue;
153 }
154 regist_single_filetype( &gpg_filetypes[i] );
155 n++;
156 }
157 }
158
159 start:
160 rc = RegOpenKeyEx( HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, &reg );
161 if( rc_ok( rc ) ) {
162 RegCloseKey( reg );
163 rc = RegOpenKeyEx( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, &reg );
164 if( !rc_ok( rc ) ) {
165 RegCreateKey( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", &reg );
166 RegCloseKey( reg );
167 }
168 p = get_reg_entry_keyserver ("Default");
169 if (!p) {
170 char buf[16];
171 sprintf (buf, "%d", HKP_PORT);
172 set_reg_entry_keyserver ("Default_Port", buf);
173 set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER);
174 }
175 free_if_alloc( p );
176 if( n )
177 set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" );
178 return 0;
179 }
180 rc = RegCreateKey( HKEY_CURRENT_USER, WINPT_REG, &reg );
181 if( !rc_ok( rc ) )
182 return WPTERR_REGISTRY;
183 if( created )
184 *created = 1;
185 RegCloseKey( reg );
186 if( n )
187 set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" );
188 return 0;
189 } /* regist_inst_winpt */
190
191
192 /* Create a new filetype in the W32 registry.
193 We should really care of errors! Otherwise we can damage the registry! */
194 int
195 create_file_type( const char *exefile, const char *ext, const char *extname, char *iconfile )
196 {
197 int rc;
198 HKEY reg = NULL;
199 char deficon[256], defexec[256], p_exefile[256];
200
201
202 rc = RegCreateKey( HKEY_CLASSES_ROOT, ext, &reg );
203 if( rc_ok( rc ) )
204 rc = RegSetValueEx( reg, NULL, 0, REG_SZ, (byte *)extname, strlen( extname ) );
205 if( rc_ok( rc ) )
206 rc = RegCloseKey( reg );
207 if( rc_ok( rc ) )
208 rc = RegCreateKey( HKEY_CLASSES_ROOT, extname, &reg );
209 if( rc_ok( rc ) )
210 rc = RegSetValueEx( reg, NULL, 0, REG_SZ, (byte *) extname, strlen( extname ) );
211 if( rc_ok( rc ) )
212 rc = RegCloseKey( reg );
213 if( !rc_ok( rc ) ) {
214 rc = WPTERR_REGISTRY;
215 goto leave;
216 }
217
218 memset( &deficon, 0, sizeof deficon );
219 _snprintf( deficon, sizeof deficon - 1, "%s\\DefaultIcon", extname );
220 memset( &defexec, 0, sizeof defexec );
221 _snprintf( defexec, sizeof defexec - 1, "%s\\shell\\open\\command", extname );
222 memset( &p_exefile, 0, sizeof p_exefile );
223 _snprintf( p_exefile, sizeof p_exefile - 1, "%s %%1", exefile );
224
225 rc = RegCreateKey( HKEY_CLASSES_ROOT, deficon, &reg );
226 if( rc_ok( rc ) )
227 rc = RegSetValueEx(reg, NULL, 0, REG_SZ, (byte *)iconfile, strlen( iconfile ) );
228 if( rc_ok( rc ) )
229 rc = RegCloseKey( reg );
230 if( rc_ok( rc ) )
231 rc = RegCreateKey( HKEY_CLASSES_ROOT, defexec, &reg );
232 if( rc_ok( rc ) )
233 rc = RegSetValueEx( reg, NULL, 0, REG_SZ, (byte *)p_exefile, strlen( exefile ) );
234 if( rc_ok( rc ) )
235 rc = RegCloseKey( reg );
236 if( !rc_ok( rc ) ) {
237 rc = WPTERR_REGISTRY;
238 goto leave;
239 }
240
241 leave:
242 if( reg )
243 RegCloseKey( reg );
244 return rc;
245 } /* create_file_type */
246
247
248 /* Expand a string with %foo% entries so that %foo% will
249 be replaced with its actual value. */
250 static char *
251 expand_path (const char *path)
252 {
253 DWORD len;
254 char *p;
255
256 len = ExpandEnvironmentStrings (path, NULL, 0);
257 if (!len)
258 return NULL;
259 len += 1;
260 p = new char[len+1];
261 if( !p )
262 return NULL;
263 len = ExpandEnvironmentStrings (path, p, len);
264 if (!len) {
265 free_if_alloc (p);
266 return NULL;
267 }
268 return p;
269 } /* expand_path */
270
271
272 /* Retrieve a registry entry with the directory given in @dir
273 and the key given in @key.
274 Return value is the value or NULL otherwise. */
275 char*
276 get_reg_entry (HKEY root_key, const char * dir, const char * key)
277 {
278 int rc;
279 char text[384] = {0};
280 DWORD nbytes, type;
281 HKEY reg_key = NULL;
282 char *p = NULL;
283
284 rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, &reg_key);
285 if( !rc_ok( rc ) )
286 goto leave;
287 nbytes = sizeof (text) - 1;
288 type = REG_SZ;
289
290 rc = RegQueryValueEx (reg_key, key, 0, &type, (BYTE *)&text, &nbytes);
291 if (!rc_ok (rc) || !nbytes)
292 goto leave;
293
294 if (type == REG_EXPAND_SZ && strchr (text, '%'))
295 p = expand_path (text);
296 else {
297 p = new char[nbytes + 1];
298 if (!p)
299 BUG (0);
300 memcpy (p, text, nbytes);
301 p[nbytes] = '\0';
302 }
303
304 leave:
305 if (reg_key)
306 RegCloseKey (reg_key);
307 return p;
308 }
309
310
311 /* XXX: use REG_EXPAND_SZ to support multi user environments.
312 keep this type and do not overwrite it with REG_SZ. */
313
314 /* Set a registry entry. */
315 int
316 set_reg_entry (HKEY root_key, const char *dir, const char *key,
317 const char *value)
318 {
319 int rc = 0;
320 HKEY reg_key;
321
322 rc = RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, &reg_key );
323 if( !rc_ok( rc ) )
324 return WPTERR_REGISTRY;
325 rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) );
326 if( !rc_ok( rc ) )
327 rc = WPTERR_REGISTRY;
328 RegCloseKey( reg_key );
329 return rc;
330 } /* set_reg_entry */
331
332
333 int
334 set_reg_key( HKEY root_key, const char * dir, const char * key,
335 const char * value )
336 {
337 int rc = 0;
338 HKEY reg_key;
339
340 rc = RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, &reg_key );
341 if( !rc_ok( rc ) )
342 return WPTERR_REGISTRY;
343
344 rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) );
345 if( !rc_ok( rc ) ) {
346 if ( RegCreateKey( root_key, key, &reg_key ) != ERROR_SUCCESS ) {
347 rc = WPTERR_REGISTRY;
348 goto leave;
349 }
350 rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) );
351 if ( !rc_ok( rc ) )
352 rc = WPTERR_REGISTRY;
353 }
354
355 leave:
356 RegCloseKey( reg_key );
357 return rc;
358 } /* set_reg_key */
359
360
361 int
362 set_reg_entry_gpg (const char * key, const char * value)
363 {
364 return set_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key, value);
365 }
366
367
368 int
369 set_reg_entry_mo (const char * value)
370 {
371 return set_reg_entry (HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS",
372 "MODir", value);
373 }
374
375
376 char *
377 get_reg_entry_gpg (const char *key)
378 {
379 return get_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key);
380 }
381
382
383 /* Return if possible the GPG4Win installation directory concatenated
384 with the string in @path if given. */
385 char*
386 get_reg_entry_gpg4win (const char *path)
387 {
388 char *p, *pp;
389 p = get_reg_entry (HKEY_LOCAL_MACHINE,
390 "Software\\GNU\\GnuPG", "Install Directory");
391 if (!p)
392 return NULL;
393 if (!path)
394 return p;
395 pp = new char[strlen (p) + strlen (path) + 4];
396 if (!pp)
397 BUG (NULL);
398 sprintf (pp, "%s\\%s", p, path);
399 free_if_alloc (p);
400 return pp;
401 }
402
403
404 char*
405 get_reg_entry_mo (void)
406 {
407 char *p, *pp;
408 const char *lang;
409
410 p = get_reg_entry (HKEY_CURRENT_USER,
411 "Control Panel\\Mingw32\\NLS", "MODir");
412 if (p)
413 return p;
414
415 lang = get_gettext_langid ();
416 if (!lang)
417 return NULL;
418 pp = new char[strlen ("share\\xxxxx\\locale\\LC_MESSAGES")+8];
419 if (!pp)
420 BUG (NULL);
421 sprintf (pp, "share\\locale\\%s\\LC_MESSAGES", lang);
422 p = get_reg_entry_gpg4win (pp);
423 free_if_alloc (pp);
424 return p;
425 }
426
427
428 /* All valid configuration commands. */
429 static const char * cfg [] = {
430 NULL,
431 "CacheTime",
432 "WordWrap",
433 "FastMode",
434 "Viewer",
435 "KeylistMode",
436 "WipeMode",
437 "AlwaysTrust",
438 "AutoBackup",
439 "BackupMode",
440 "DisableHotkeys",
441 "NoCompressMultiMedia",
442 "Expert",
443 "FMProgressBar",
444 };
445
446
447 int
448 set_reg_winpt_single (int id, int val)
449 {
450 char buf[64];
451 int rc;
452
453 sprintf (buf, "%d", val);
454 rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id], buf);
455 return rc;
456 }
457
458
459 int
460 get_reg_winpt_single (int id)
461 {
462 char * buf = NULL;
463 int val = 0;
464
465 buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]);
466 if (buf && *buf != ' ')
467 val = 1;
468 else if (!buf)
469 val = -1;
470 free_if_alloc (buf);
471 return val;
472 }
473
474
475 /* Saves the winpt preferences in the registry. */
476 int
477 set_reg_winpt_prefs (winpt_reg_prefs_s * opt)
478 {
479 char buf[128];
480 size_t i;
481 int rc = 0;
482
483 for (i=1; i < DIM (cfg); i++) {
484 switch (i) {
485 case CFG_CACHETIME:
486 sprintf (buf, "%d", opt->cache_time);
487 break;
488 case CFG_WORDWRAP:
489 sprintf (buf, "%d", opt->word_wrap);
490 break;
491 case CFG_WIPEMODE:
492 sprintf (buf, "%d", opt->wipe_mode);
493 break;
494 case CFG_FASTMODE:
495 sprintf (buf, "%d", opt->use_tmpfiles);
496 break;
497 case CFG_NOZIP_MMEDIA:
498 sprintf (buf, "%d", opt->no_zip_mmedia);
499 break;
500 case CFG_VIEWER:
501 sprintf (buf, "%d", opt->use_viewer);
502 break;
503 case CFG_KEYLISTMODE:
504 sprintf (buf, "%d", opt->keylist_mode);
505 break;
506 case CFG_ALWAYSTRUST:
507 sprintf (buf, "%d", opt->always_trust);
508 break;
509 case CFG_AUTOBACKUP:
510 sprintf (buf, "%d", opt->auto_backup);
511 break;
512 case CFG_AUTOBAKMODE:
513 sprintf (buf, "%d", opt->backup.mode);
514 break;
515 case CFG_DISHOTKEYS:
516 sprintf (buf, "%d", opt->no_hotkeys);
517 break;
518 case CFG_EXPERT:
519 sprintf (buf, "%d", opt->expert);
520 break;
521
522 case CFG_FM_PROGRESS:
523 sprintf (buf, "%d", opt->fm.progress);
524 break;
525 }
526 rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[i], buf);
527 if (rc)
528 goto leave;
529 }
530
531 if (opt->backup.path) {
532 rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "BackupPath",
533 opt->backup.path);
534 if (rc)
535 goto leave;
536 }
537 if (opt->kserv_conf) {
538 rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "KeyserverConfig",
539 opt->kserv_conf);
540 if (rc)
541 goto leave;
542 }
543
544 for (i=0; reg_hotkeys[i].reg_entry; i++) {
545 strcpy (buf, " ");
546 if (reg_hotkeys[i].enabled)
547 strcpy (buf, reg_hotkeys[i].key);
548 rc = set_reg_key (HKEY_CURRENT_USER, WINPT_REG,
549 reg_hotkeys[i].reg_entry, buf);
550 if (rc)
551 break;
552 }
553
554 leave:
555 if (rc) {
556 msg_box (NULL, _("Could not write to Registry."), _("Preferences"), MB_ERR);
557 return rc;
558 }
559 return 0;
560 }
561
562
563 int
564 set_reg_winpt_flag (const char * name, int val)
565 {
566 return set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, name, val? "1" : "0");
567 } /* set_reg_winpt_flag */
568
569
570 int
571 get_reg_winpt_flag (const char * name)
572 {
573 char * buf;
574 int flag = 0;
575
576 buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, name);
577 if (buf && buf[0] == '1')
578 flag = 1;
579 else if (!buf || buf && buf[0] != '0')
580 flag = -1;
581 free_if_alloc (buf);
582 return flag;
583 } /* get_reg_winpt_flag */
584
585
586 /* Retrieve the winpt preferences from the registry. */
587 int
588 get_reg_winpt_prefs (winpt_reg_prefs_s * opt)
589 {
590 char * val = NULL;
591 size_t i;
592
593 for (i=1; i < DIM (cfg); i++) {
594 val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[i]);
595 if (!val || *val == ' ') {
596 free_if_alloc (val);
597 continue;
598 }
599 switch (i) {
600 case CFG_CACHETIME:
601 opt->cache_time = atol (val);
602 /* We do NOT support passphrase caching for more than an hour.
603 * Perhaps we should allow it, but for now we silently drop this.
604 */
605 if (opt->cache_time > 3600)
606 opt->cache_time = 3600;
607 break;
608 case CFG_WORDWRAP:
609 opt->word_wrap = atol (val);
610 break;
611 case CFG_FASTMODE:
612 opt->use_tmpfiles = atol (val);
613 break;
614 case CFG_NOZIP_MMEDIA:
615 opt->no_zip_mmedia = atol (val);
616 break;
617 case CFG_VIEWER:
618 opt->use_viewer = atol (val);
619 break;
620 case CFG_KEYLISTMODE:
621 opt->keylist_mode = atol (val);
622 break;
623 case CFG_WIPEMODE:
624 opt->wipe_mode = atol (val);
625 break;
626 case CFG_DISHOTKEYS:
627 opt->no_hotkeys = atol (val);
628 break;
629 case CFG_ALWAYSTRUST:
630 opt->always_trust = atol (val);
631 break;
632 case CFG_AUTOBACKUP:
633 opt->auto_backup = atol (val);
634 break;
635 case CFG_AUTOBAKMODE:
636 opt->backup.mode = atol (val);
637 break;
638 case CFG_EXPERT:
639 opt->expert = atol (val);
640 break;
641
642 case CFG_FM_PROGRESS:
643 opt->fm.progress = atol (val);
644 break;
645 }
646 free_if_alloc (val);
647 }
648
649 val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "BackupPath");
650 if (val && val[0] != ' ')
651 opt->backup.path = m_strdup (val);
652 free_if_alloc (val);
653
654 val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "KeyserverConfig");
655 if (val && val[0] != ' ')
656 opt->kserv_conf = m_strdup (val);
657 free_if_alloc (val);
658
659 for (i=0; reg_hotkeys[i].reg_entry; i++) {
660 val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, reg_hotkeys[i].reg_entry);
661 if (val && val[0] != ' ') {
662 reg_hotkeys[i].key[0] = *val;
663 reg_hotkeys[i].enabled = 1;
664 }
665 else
666 reg_hotkeys[i].enabled = 0;
667 free_if_alloc (val);
668 }
669 return 0;
670 } /* get_reg_winpt_prefs */
671
672
673 char*
674 get_reg_entry_keyserver (const char *name)
675 {
676 char * p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name);
677 if (p && !strcmp (p, "")) {
678 free_if_alloc (p);
679 return NULL;
680 }
681 return p;
682 }
683
684
685 void
686 get_reg_proxy_prefs (char ** host, int * port, char ** user, char ** pass)
687 {
688 if (host)
689 *host = get_reg_entry_keyserver ("Host");
690 if (user)
691 *user = get_reg_entry_keyserver ("User");
692 if (pass)
693 *pass = get_reg_entry_keyserver ("Pass");
694 if (port) {
695 char * p = get_reg_entry_keyserver ("Port");
696 if (p) {
697 *port = atol (p);
698 free_if_alloc (p);
699 }
700 }
701 } /* get_reg_proxy_prefs */
702
703
704 int
705 set_reg_entry_keyserver( const char * name, const char * val )
706 {
707 return set_reg_entry( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name, val );
708 } /* set_reg_entry_keyserver */
709
710
711 int
712 set_reg_proxy_prefs( const char * host, int port, const char * user, const char * pass )
713 {
714 int rc;
715
716 rc = set_reg_entry_keyserver( "Host", host? host : "" );
717 if( !rc ) {
718 char buf[32];
719 sprintf( buf, "%d", port );
720 rc = set_reg_entry_keyserver( "Port", buf );
721 }
722 if( !rc )
723 rc = set_reg_entry_keyserver( "User", user? user : "" );
724 if( !rc )
725 rc = set_reg_entry_keyserver( "Pass", pass? pass : "" );
726 return rc;
727 } /* set_reg_proxy_prefs */

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26