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

Contents of /trunk/Src/wptRegistry.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 222 - (show annotations)
Thu Jun 1 08:30:46 2006 UTC (18 years, 9 months ago) by twoaday
File size: 18067 byte(s)
Applied some more patches.


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 int rc;
315 char text[384] = {0};
316 DWORD nbytes, type;
317 HKEY reg_key = NULL;
318 char * p = NULL;
319
320 rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, &reg_key);
321 if( !rc_ok( rc ) )
322 goto leave;
323 nbytes = sizeof (text) - 1;
324 type = REG_SZ;
325
326 rc = RegQueryValueEx (reg_key, key, 0, &type, (BYTE *)&text, &nbytes);
327 if (!rc_ok (rc) || !nbytes)
328 goto leave;
329
330 if (type == REG_EXPAND_SZ && strchr (text, '%'))
331 p = expand_path (text);
332 else {
333 p = new char[nbytes + 1];
334 if (!p)
335 BUG (0);
336 memcpy (p, text, nbytes);
337 p[nbytes] = '\0';
338 }
339
340 leave:
341 if (reg_key)
342 RegCloseKey (reg_key);
343 return p;
344 }
345
346
347 /* XXX: use REG_EXPAND_SZ to support multi user environments.
348 keep this type and do not overwrite it with REG_SZ. */
349
350 /* Set a registry entry. */
351 int
352 set_reg_entry (HKEY root_key, const char *dir, const char *key,
353 const char *value)
354 {
355 int rc = 0;
356 HKEY reg_key;
357
358 rc = RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, &reg_key );
359 if( !rc_ok( rc ) )
360 return WPTERR_REGISTRY;
361 rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) );
362 if( !rc_ok( rc ) )
363 rc = WPTERR_REGISTRY;
364 RegCloseKey( reg_key );
365 return rc;
366 }
367
368
369 int
370 set_reg_key( HKEY root_key, const char * dir, const char * key,
371 const char * value )
372 {
373 int rc = 0;
374 HKEY reg_key;
375
376 rc = RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, &reg_key );
377 if( !rc_ok( rc ) )
378 return WPTERR_REGISTRY;
379
380 rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) );
381 if( !rc_ok( rc ) ) {
382 if ( RegCreateKey( root_key, key, &reg_key ) != ERROR_SUCCESS ) {
383 rc = WPTERR_REGISTRY;
384 goto leave;
385 }
386 rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) );
387 if ( !rc_ok( rc ) )
388 rc = WPTERR_REGISTRY;
389 }
390
391 leave:
392 RegCloseKey( reg_key );
393 return rc;
394 }
395
396
397 int
398 set_reg_entry_gpg (const char * key, const char * value)
399 {
400 return set_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key, value);
401 }
402
403
404 int
405 set_reg_entry_mo (const char * value)
406 {
407 return set_reg_entry (HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS",
408 "MODir", value);
409 }
410
411
412 char*
413 get_reg_entry_gpg (const char *key)
414 {
415 char *p;
416 p = get_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key);
417 if (!p || strlen (p) == 0) {
418 free_if_alloc (p);
419 return NULL;
420 }
421 return p;
422 }
423
424
425 /* Return if possible the GPG4Win installation directory concatenated
426 with the string in @path if given. */
427 char*
428 get_reg_entry_gpg4win (const char *path)
429 {
430 char *p, *pp;
431 p = get_reg_entry (HKEY_LOCAL_MACHINE,
432 "Software\\GNU\\GnuPG", "Install Directory");
433 if (!p)
434 return NULL;
435 if (!path)
436 return p;
437 pp = new char[strlen (p) + strlen (path) + 4];
438 if (!pp)
439 BUG (NULL);
440 sprintf (pp, "%s\\%s", p, path);
441 free_if_alloc (p);
442 return pp;
443 }
444
445
446 char*
447 get_reg_entry_mo (void)
448 {
449 char *p, *pp;
450 const char *lang;
451
452 p = get_reg_entry (HKEY_CURRENT_USER,
453 "Control Panel\\Mingw32\\NLS", "MODir");
454 if (p)
455 return p;
456
457 lang = get_gettext_langid ();
458 if (!lang)
459 return NULL;
460 pp = new char[strlen ("share\\xxxxx\\locale\\LC_MESSAGES")+8];
461 if (!pp)
462 BUG (NULL);
463 sprintf (pp, "share\\locale\\%s\\LC_MESSAGES", lang);
464 p = get_reg_entry_gpg4win (pp);
465 free_if_alloc (pp);
466 return p;
467 }
468
469
470 /* All valid configuration commands. */
471 static const char *cfg [] = {
472 NULL,
473 "CacheTime",
474 "WordWrap",
475 "DefaultExt",
476 "Viewer",
477 "WipeMode",
478 "AlwaysTrust",
479 "AutoBackup",
480 "BackupMode",
481 "DisableHotkeys",
482 "NoCompressMultiMedia",
483 "Expert",
484 "FMProgressBar",
485 "BackupSecring"
486 };
487
488
489 int
490 set_reg_winpt_single (int id, int val)
491 {
492 char buf[64];
493 int rc;
494
495 sprintf (buf, "%d", val);
496 rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id], buf);
497 return rc;
498 }
499
500
501 int
502 get_reg_winpt_single (int id)
503 {
504 char *buf;
505 int val = 0;
506
507 buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]);
508 if (buf && *buf != ' ')
509 val = 1;
510 else if (!buf)
511 val = -1;
512 free_if_alloc (buf);
513 return val;
514 }
515
516
517 /* Saves the winpt preferences in the registry. */
518 int
519 set_reg_winpt_prefs (winpt_reg_prefs_s * opt)
520 {
521 char buf[128];
522 size_t i;
523 int rc = 0;
524
525 for (i=1; i < DIM (cfg); i++) {
526 switch (i) {
527 case CFG_CACHETIME:
528 sprintf (buf, "%d", opt->cache_time);
529 break;
530 case CFG_WORDWRAP:
531 sprintf (buf, "%d", opt->word_wrap);
532 break;
533 case CFG_WIPEMODE:
534 sprintf (buf, "%d", opt->wipe_mode);
535 break;
536 case CFG_FILEEXT:
537 sprintf (buf, "%d", opt->default_ext);
538 break;
539 case CFG_NOZIP_MMEDIA:
540 sprintf (buf, "%d", opt->no_zip_mmedia);
541 break;
542 case CFG_VIEWER:
543 sprintf (buf, "%d", opt->use_viewer);
544 break;
545 case CFG_ALWAYSTRUST:
546 sprintf (buf, "%d", opt->always_trust);
547 break;
548 case CFG_AUTOBACKUP:
549 sprintf (buf, "%d", opt->auto_backup);
550 break;
551 case CFG_AUTOBAKMODE:
552 sprintf (buf, "%d", opt->backup.mode);
553 break;
554 case CFG_DISHOTKEYS:
555 sprintf (buf, "%d", opt->no_hotkeys);
556 break;
557 case CFG_EXPERT:
558 sprintf (buf, "%d", opt->expert);
559 break;
560
561 case CFG_FM_PROGRESS:
562 sprintf (buf, "%d", opt->fm.progress);
563 break;
564
565 case CFG_BACKUP_INC_SKR:
566 sprintf (buf, "%d", opt->backup.include_secr);
567 break;
568 }
569 rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[i], buf);
570 if (rc)
571 goto leave;
572 }
573
574 if (opt->backup.path) {
575 rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "BackupPath",
576 opt->backup.path);
577 if (rc)
578 goto leave;
579 }
580
581 for (i=0; wpt_hotkeys[i].name; i++) {
582 if (wpt_hotkeys[i].enabled) {
583 buf[0] = wpt_hotkeys[i].key;
584 buf[1] = 0;
585 }
586 else
587 strcpy (buf, " ");
588 rc = set_reg_key (HKEY_CURRENT_USER, WINPT_REG,
589 wpt_hotkeys[i].name, buf);
590 if (rc)
591 break;
592 }
593
594 leave:
595 if (rc) {
596 msg_box (NULL, _("Could not write to Registry."), _("Preferences"), MB_ERR);
597 return rc;
598 }
599 return 0;
600 }
601
602
603 int
604 set_reg_winpt_flag (const char * name, int val)
605 {
606 return set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, name, val? "1" : "0");
607 }
608
609
610 int
611 get_reg_winpt_flag (const char * name)
612 {
613 char * buf;
614 int flag = 0;
615
616 buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, name);
617 if (buf && buf[0] == '1')
618 flag = 1;
619 else if (!buf || buf && buf[0] != '0')
620 flag = -1;
621 free_if_alloc (buf);
622 return flag;
623 }
624
625
626 /* Retrieve the winpt preferences from the registry. */
627 int
628 get_reg_winpt_prefs (winpt_reg_prefs_s * opt)
629 {
630 char *val = NULL;
631 size_t i;
632
633 for (i=1; i < DIM (cfg); i++) {
634 val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[i]);
635 if (!val || *val == ' ') {
636 free_if_alloc (val);
637 continue;
638 }
639 switch (i) {
640 case CFG_CACHETIME:
641 opt->cache_time = atol (val);
642 break;
643 case CFG_WORDWRAP:
644 opt->word_wrap = atol (val);
645 break;
646 case CFG_FILEEXT:
647 opt->default_ext = atol (val);
648 break;
649 case CFG_NOZIP_MMEDIA:
650 opt->no_zip_mmedia = atol (val);
651 break;
652 case CFG_VIEWER:
653 opt->use_viewer = atol (val);
654 break;
655 case CFG_WIPEMODE:
656 opt->wipe_mode = atol (val);
657 break;
658 case CFG_DISHOTKEYS:
659 opt->no_hotkeys = atol (val);
660 break;
661 case CFG_ALWAYSTRUST:
662 opt->always_trust = atol (val);
663 break;
664 case CFG_AUTOBACKUP:
665 opt->auto_backup = atol (val);
666 break;
667 case CFG_AUTOBAKMODE:
668 opt->backup.mode = atol (val);
669 break;
670 case CFG_EXPERT:
671 opt->expert = atol (val);
672 break;
673 case CFG_FM_PROGRESS:
674 opt->fm.progress = atol (val);
675 break;
676
677 case CFG_BACKUP_INC_SKR:
678 opt->backup.include_secr = atol (val);
679 break;
680 }
681 free_if_alloc (val);
682 }
683
684 val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "BackupPath");
685 if (val && val[0] != ' ')
686 opt->backup.path = m_strdup (val);
687 free_if_alloc (val);
688
689 for (i=0; wpt_hotkeys[i].name; i++) {
690 wpt_hotkeys[i].enabled = 0;
691 val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, wpt_hotkeys[i].name);
692 if (val && val[0] != ' ') {
693 wpt_hotkeys[i].key = *val;
694 wpt_hotkeys[i].enabled = 1;
695 }
696 free_if_alloc (val);
697 }
698 return 0;
699 }
700
701
702 char*
703 get_reg_entry_keyserver (const char *name)
704 {
705 char *p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name);
706 if (p && (!strcmp (p, "") || strlen (p) == 0)) {
707 free_if_alloc (p);
708 return NULL;
709 }
710 return p;
711 }
712
713
714 int
715 set_reg_entry_keyserver (const char * name, const char * val)
716 {
717 return set_reg_entry( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name, val );
718 }
719
720 static int
721 get_reg_entry_keyserver_int (const char *key)
722 {
723 char *p;
724 int val = 0;
725
726 p = get_reg_entry_keyserver (key);
727 if (p && *p)
728 val = atoi (p);
729 free_if_alloc (p);
730 return val;
731 }
732
733
734 void
735 get_reg_proxy_prefs (keyserver_proxy_t prox)
736 {
737 if (!prox)
738 return;
739
740 free_if_alloc (prox->host);
741 prox->host = get_reg_entry_keyserver ("Host");
742 free_if_alloc (prox->user);
743 prox->user = get_reg_entry_keyserver ("User");
744 free_if_alloc (prox->pass);
745 prox->pass = get_reg_entry_keyserver ("Pass");
746 prox->port = get_reg_entry_keyserver_int ("Port");
747 }
748
749
750 static int
751 set_reg_entry_keyserver_int (const char *key, int val)
752 {
753 char buf[32];
754
755 sprintf (buf, "%d", val);
756 return set_reg_entry_keyserver (key, buf);
757 }
758
759
760 int
761 set_reg_proxy_prefs (keyserver_proxy_t prox)
762 {
763 int rc;
764
765 rc = set_reg_entry_keyserver_int ("Proto", prox->proto);
766 if (!rc)
767 rc = set_reg_entry_keyserver ("Host", prox->host? prox->host : "");
768 if (!rc)
769 rc = set_reg_entry_keyserver_int ("Port", prox->port);
770 if (!rc)
771 rc = set_reg_entry_keyserver ("User", prox->user? prox->user : "");
772 if (!rc)
773 rc = set_reg_entry_keyserver ("Pass", prox->pass? prox->pass : "");
774 return rc;
775 }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26