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

Diff of /trunk/Src/wptGPG.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 255 by twoaday, Tue Aug 1 16:37:23 2006 UTC revision 270 by twoaday, Sat Oct 21 18:08:57 2006 UTC
# Line 97  get_gnupg_path (void) Line 97  get_gnupg_path (void)
97      if (path && dir_exist_check (path) == 0)      if (path && dir_exist_check (path) == 0)
98          return path;          return path;
99      free_if_alloc (path);      free_if_alloc (path);
100      path = multi_gnupg_path (1);      return multi_gnupg_path (1);
     return path;  
101  }  }
102    
103    
# Line 108  char* Line 107  char*
107  get_gnupg_cfgfile (void)  get_gnupg_cfgfile (void)
108  {  {
109      char *optfile = NULL;      char *optfile = NULL;
110      char *path = NULL;      char *path;
111      size_t nlen = 0;      size_t nlen;
112    
113      path = get_gnupg_path ();      path = get_gnupg_path ();
114      if (!path)      if (!path)
# Line 117  get_gnupg_cfgfile (void) Line 116  get_gnupg_cfgfile (void)
116      nlen = strlen (path) + 64;      nlen = strlen (path) + 64;
117      optfile = new char[nlen + 1];      optfile = new char[nlen + 1];
118      if (!optfile)      if (!optfile)
119          BUG (NULL);              BUG (NULL);
120      _snprintf (optfile, nlen, "%s\\"GPG_CONF, path);      _snprintf (optfile, nlen, "%s\\"GPG_CONF, path);
121    
122      free_if_alloc (path);      free_if_alloc (path);
# Line 173  get_gnupg_prog (void) Line 172  get_gnupg_prog (void)
172      if (!path)      if (!path)
173          return NULL;              return NULL;    
174      pgm = make_filename (path, "gpg", "exe");      pgm = make_filename (path, "gpg", "exe");
175      free_if_alloc (path);          free_if_alloc (path);
176      return pgm;      return pgm;
177  }  }
178    
# Line 213  int Line 212  int
212  gnupg_load_config (void)  gnupg_load_config (void)
213  {      {    
214      gpg_optfile_t opt;      gpg_optfile_t opt;
     gpg_option_t o;  
215      char *conf;      char *conf;
216            
217      conf = get_gnupg_cfgfile ();      conf = get_gnupg_cfgfile ();
218      if (!conf)      if (!conf)
219          return -1;          return -1;
220      if (parse_gpg_options (conf, &opt)) {      if (parse_config (conf, &opt)) {
221          free_if_alloc (conf);          free_if_alloc (conf);
222          return -1;          return -1;
223      }      }
224      o = find_option (opt, "ask-cert-level");      if (find_option (opt, "ask-cert-level"))
     if (o)  
225          reg_prefs.gpg.ask_cert_level = 1;          reg_prefs.gpg.ask_cert_level = 1;
226      o = find_option (opt, "ask-cert-expire");      if (find_option (opt, "ask-cert-expire"))
     if (o)  
227          reg_prefs.gpg.ask_cert_expire = 1;          reg_prefs.gpg.ask_cert_expire = 1;
228      release_gpg_options (opt);      release_config (opt);
229      free_if_alloc (conf);      free_if_alloc (conf);
230      return 0;      return 0;
231  }  }
# Line 264  get_gnupg_default_key (void) Line 260  get_gnupg_default_key (void)
260      optfile = get_gnupg_cfgfile ();      optfile = get_gnupg_cfgfile ();
261      if (!optfile)      if (!optfile)
262          return default_key_from_cache (&no_usable);          return default_key_from_cache (&no_usable);
263      if (parse_gpg_options (optfile, &opt)) {      if (parse_config (optfile, &opt)) {
264          free_if_alloc (optfile);          free_if_alloc (optfile);
265          return default_key_from_cache (&no_usable);          return default_key_from_cache (&no_usable);
266      }      }
# Line 275  get_gnupg_default_key (void) Line 271  get_gnupg_default_key (void)
271          keyid = extract_keyid (e->val);          keyid = extract_keyid (e->val);
272    
273      free_if_alloc (optfile);      free_if_alloc (optfile);
274      release_gpg_options (opt);      release_config (opt);
275      if (!keyid)      if (!keyid)
276          keyid = default_key_from_cache (&no_usable);          keyid = default_key_from_cache (&no_usable);
277      return keyid;      return keyid;
# Line 404  cfgfile_count_keyrings (const char *fnam Line 400  cfgfile_count_keyrings (const char *fnam
400      *r_secrings = 0;      *r_secrings = 0;
401      *r_pubrings = 0;      *r_pubrings = 0;
402    
403      if (parse_gpg_options (fname, &opt))      if (parse_config (fname, &opt))
404          return WPTERR_FILE_OPEN;          return WPTERR_FILE_OPEN;
405      for (e = opt->list; e; e = e->next) {      for (e = opt->list; e; e = e->next) {
406          if (!strcmp( e->name, "secret-keyring")) {          if (!strcmp (e->name, "secret-keyring")) {
407              if (!file_exist_check (e->val))              if (!file_exist_check (e->val))
408                  r_secrings[0]++;                  r_secrings[0]++;
409          }          }
# Line 416  cfgfile_count_keyrings (const char *fnam Line 412  cfgfile_count_keyrings (const char *fnam
412                  r_pubrings[0]++;                  r_pubrings[0]++;
413          }          }
414      }      }
415      release_gpg_options (opt);      release_config (opt);
416      return 0;      return 0;
417  }  }
418    
# Line 562  set_gnupg_default_key (const char *key) Line 558  set_gnupg_default_key (const char *key)
558      optfile = get_gnupg_cfgfile ();      optfile = get_gnupg_cfgfile ();
559      if (!optfile)      if (!optfile)
560          return WPTERR_FILE_OPEN;          return WPTERR_FILE_OPEN;
561      rc = parse_gpg_options (optfile, &opt);      rc = parse_config (optfile, &opt);
562      if (rc) {      if (rc) {
563          free_if_alloc (optfile);          free_if_alloc (optfile);
564          return WPTERR_GENERAL;          return WPTERR_GENERAL;
# Line 577  set_gnupg_default_key (const char *key) Line 573  set_gnupg_default_key (const char *key)
573      }      }
574      else if (key)      else if (key)
575          add_entry (opt, ENTRY_MULTI, "default-key", key);          add_entry (opt, ENTRY_MULTI, "default-key", key);
576      rc = commit_gpg_options (optfile, opt);      rc = commit_config (optfile, opt);
577    
578      free_if_alloc (optfile);      free_if_alloc (optfile);
579      release_gpg_options (opt);      release_config (opt);
   
580      return rc;      return rc;
581  }  }
582    
# Line 795  get_gnupg_keyring_from_options (const ch Line 790  get_gnupg_keyring_from_options (const ch
790      char *kring = NULL;      char *kring = NULL;
791      int rc;      int rc;
792    
793      rc = parse_gpg_options (fname, &opt);      rc = parse_config (fname, &opt);
794      if (rc)      if (rc)
795          return NULL;          return NULL;
796      if (pub)      if (pub)
# Line 804  get_gnupg_keyring_from_options (const ch Line 799  get_gnupg_keyring_from_options (const ch
799          e = find_option (opt, "secret-keyring");          e = find_option (opt, "secret-keyring");
800      if (e)      if (e)
801          kring = m_strdup (e->val);          kring = m_strdup (e->val);
802      release_gpg_options (opt);      release_config (opt);
803    
804      return kring;      return kring;
805  }  }

Legend:
Removed from v.255  
changed lines
  Added in v.270

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26