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

Contents of /trunk/Src/wptRegistry.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 262 - (show annotations)
Sat Sep 30 10:24:34 2006 UTC (18 years, 5 months ago) by twoaday
File size: 18070 byte(s)


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26