/[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 12 by twoaday, Thu Apr 14 12:56:25 2005 UTC revision 22 by twoaday, Wed Aug 10 11:33:35 2005 UTC
# Line 67  multi_gnupg_path (void) Line 67  multi_gnupg_path (void)
67      strcat (buf, "\\gnupg");      strcat (buf, "\\gnupg");
68      if (access (buf, 00))      if (access (buf, 00))
69          return NULL;          return NULL;
70      return buf;      return m_strdup (buf);
71  }  }
72    
73  /*  /*
# Line 77  multi_gnupg_path (void) Line 77  multi_gnupg_path (void)
77  char*  char*
78  get_gnupg_path (void)  get_gnupg_path (void)
79  {  {
80      char *p = NULL, *path = NULL;          char *p = NULL, *path = NULL;
81            
82      p = get_reg_entry_gpg ("HomeDir");      p = get_reg_entry_gpg ("HomeDir");
83      if (p) {      if (p) {
# Line 85  get_gnupg_path (void) Line 85  get_gnupg_path (void)
85          free_if_alloc (p);          free_if_alloc (p);
86          return path;          return path;
87      }      }
88      else {      else
89          p = multi_gnupg_path ();          return multi_gnupg_path ();
         if (p)  
             return m_strdup (p);  
     }  
90      return m_strdup ("c:\\gnupg");      return m_strdup ("c:\\gnupg");
91  } /* get_gnupg_path */  } /* get_gnupg_path */
92    
# Line 438  fail: Line 435  fail:
435   * Return the contents of the options file as a char buf.   * Return the contents of the options file as a char buf.
436   */   */
437  char *  char *
438  get_gnupg_config( void )  get_gnupg_config (void)
439  {  {
440      FILE * fp;      FILE * fp;
441      char * p = NULL, * optfile = NULL;      char * p = NULL, * optfile = NULL;
442      int fsize, rc = 0;      int fsize, rc = 0;
443                    
444      optfile = get_gnupg_cfgfile( );      optfile = get_gnupg_cfgfile ();
445      if( optfile == NULL )      if( optfile == NULL )
446          return NULL;          return NULL;
447      fsize = get_file_size( optfile );      fsize = get_file_size( optfile );
# Line 981  check_keyring (char ** r_path) Line 978  check_keyring (char ** r_path)
978  }  }
979    
980    
981    static char*
982    get_backup_name (const char *templ)
983    {
984        struct tm *tm;
985        char *p;
986    
987        time_t t = time (NULL);
988        tm = localtime (&t);
989        p = new char [strlen (templ) + 8 + 1];
990        if (!p)
991            BUG (0);
992        sprintf (p, "%s-%d", templ, tm->tm_wday % 3);
993        return p;
994    }
995    
996    
997  void  void
998  gnupg_backup_keyrings (void)  gnupg_backup_keyrings (void)
999  {  {
1000      char * srcpath = NULL, * dstpath = NULL;      char *srcpath = NULL, *dstpath = NULL;
1001        char *name=NULL;
1002      int rc, bakmode=0;      int rc, bakmode=0;
1003    
1004      if (!reg_prefs.auto_backup)      if (!reg_prefs.auto_backup)
# Line 992  gnupg_backup_keyrings (void) Line 1006  gnupg_backup_keyrings (void)
1006      bakmode = reg_prefs.backup.mode;      bakmode = reg_prefs.backup.mode;
1007      srcpath =  get_gnupg_path ();      srcpath =  get_gnupg_path ();
1008      check_keyring (&srcpath);      check_keyring (&srcpath);
1009      if (bakmode == 1)      if (bakmode == 1) {
     {  
1010          dstpath = get_gnupg_path ();          dstpath = get_gnupg_path ();
1011          check_keyring (&dstpath);          check_keyring (&dstpath);
1012      }      }
1013      else if (bakmode == 2)      else if (bakmode == 2) {
     {  
1014          char * tmpfile;          char * tmpfile;
1015          FILE * fp;          FILE * fp;
1016    
# Line 1010  gnupg_backup_keyrings (void) Line 1022  gnupg_backup_keyrings (void)
1022          if (!fp)          if (!fp)
1023              rc = log_box (_("Backup"), MB_WARN|MB_RETRYCANCEL, _("The backup drive '%s' does not seems to accessable.\n"              rc = log_box (_("Backup"), MB_WARN|MB_RETRYCANCEL, _("The backup drive '%s' does not seems to accessable.\n"
1024                                                                   "Please insert/check the drive to continue."), dstpath);                                                                   "Please insert/check the drive to continue."), dstpath);
1025          else          else {
         {  
1026              rc = 0;              rc = 0;
1027              fclose (fp);              fclose (fp);
1028              unlink (tmpfile);              unlink (tmpfile);
# Line 1020  gnupg_backup_keyrings (void) Line 1031  gnupg_backup_keyrings (void)
1031          if (!fp || rc == IDCANCEL)          if (!fp || rc == IDCANCEL)
1032              return;              return;
1033      }      }
1034      else      else {
     {  
1035          log_box (_("Backup"), MB_ERR, _("Invalid backup mode %d"), bakmode);          log_box (_("Backup"), MB_ERR, _("Invalid backup mode %d"), bakmode);
1036          return;          return;
1037      }      }
1038      rc = backup_one_file (srcpath, "pubring", dstpath, "pubring-bak");      name = get_backup_name ("pubring-bak");
1039        rc = backup_one_file (srcpath, "pubring", dstpath, name);
1040      if (!rc)      if (!rc)
1041          rc = backup_one_file (srcpath, "secring", dstpath, "secring-bak");          rc = backup_one_file (srcpath, "secring", dstpath, "secring-bak");
1042        free_if_alloc (name);
1043      free_if_alloc (srcpath);      free_if_alloc (srcpath);
1044      free_if_alloc (dstpath);      free_if_alloc (dstpath);
1045  } /* gnupg_backup_keyrings */  } /* gnupg_backup_keyrings */

Legend:
Removed from v.12  
changed lines
  Added in v.22

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26