/[winpt]/trunk/MyGPGME/w32-util.c
ViewVC logotype

Diff of /trunk/MyGPGME/w32-util.c

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

revision 6 by twoaday, Mon Jan 31 11:02:21 2005 UTC revision 7 by twoaday, Mon Apr 4 07:01:43 2005 UTC
# Line 1  Line 1 
1  /* w32-util.c - Utility functions for the W32 API  /* w32-util.c - Utility functions for the W32 API
2   *      Copyright (C) 1999 Free Software Foundation, Inc   *      Copyright (C) 1999 Free Software Foundation, Inc
3   *      Copyright (C) 2001 Werner Koch (dd9jn)   *      Copyright (C) 2001 Werner Koch (dd9jn)
4   *      Copyright (C) 2002 Timo Schulz   *      Copyright (C) 2002, 2005 Timo Schulz
5   *   *
6   * This file is part of MyGPGME.   * This file is part of MyGPGME.
7   *   *
# Line 84  leave: Line 84  leave:
84    
85    
86  const char *  const char *
87  _gpgme_get_gpg_path (void)  _gpgme_get_gpg_path (int cleanup)
88  {  {
89      static char *gpg_program = NULL;      static char *gpg_program = NULL;
90            
91        if (cleanup) {
92            if (gpg_program) {
93                free (gpg_program);
94                gpg_program = NULL;
95            }
96            return NULL;
97        }
98    
99      if (!gpg_program) {      if (!gpg_program) {
100          gpg_program = read_w32_registry_string ( NULL,          gpg_program = read_w32_registry_string (NULL,
101                                                   "Software\\GNU\\GnuPG", "gpgProgram" );                                                  "Software\\GNU\\GnuPG", "gpgProgram");
102          if (gpg_program) {          if (gpg_program) {
103              int i;              int i;
104                            
# Line 100  _gpgme_get_gpg_path (void) Line 108  _gpgme_get_gpg_path (void)
108                      gpg_program[i] = '\\';                      gpg_program[i] = '\\';
109              }              }
110          }          }
111          else {          else
112              gpg_program = "C:\\GNUPG\\GPG.EXE";              gpg_program = strdup ("C:\\GNUPG\\GPG.EXE");
         }  
113      }      }
114            
115      return gpg_program;      return gpg_program;
116  }  }
117    
118  char *  
119  _gpgme_get_gpg_optfile( void )  const char *
120  {  _gpgme_get_gpg_optfile (int cleanup)
121      FILE *fp;  {    
122      char *gpg_optfile = NULL;      static char *gpg_optfile = NULL;
123            
124      gpg_optfile = read_w32_registry_string(      if (cleanup) {
125          NULL, "Software\\GNU\\GnuPG", "OptFile" );          if (gpg_optfile) {
126      if( gpg_optfile ) {              free (gpg_optfile);
127          int i;              gpg_optfile = NULL;
128          for( i = 0; gpg_optfile[i]; i++ ) {          }
129              if( gpg_optfile[i] == '/' )          return NULL;
130                  gpg_optfile[i] = '\\';      }
131          }  
132          if( !strcmp(gpg_optfile, "") )      if (!gpg_optfile) {
133              return NULL; /* Then ignore the file */          FILE *fp;
134          fp = fopen( gpg_optfile, "r" );          gpg_optfile = read_w32_registry_string(
135          if( fp == NULL )                              NULL, "Software\\GNU\\GnuPG", "OptFile" );
136              return NULL;          if (gpg_optfile) {
137          fclose( fp );              int i;
138                for (i = 0; gpg_optfile[i]; i++) {
139                    if (gpg_optfile[i] == '/')
140                        gpg_optfile[i] = '\\';
141                }
142                if (!strcmp(gpg_optfile, ""))
143                    return NULL; /* Then ignore the file */
144                fp = fopen (gpg_optfile, "r");
145                if (fp == NULL)
146                    return NULL;
147                fclose (fp);
148            }
149      }      }
150    
151      return gpg_optfile;      return gpg_optfile;
152  } /* _gpgme_get_gpg_optfile */  } /* _gpgme_get_gpg_optfile */
153    
154  const char *  
155  _gpgme_get_gpg_keyring( const char *keyring )  void
156    util_cleanup (void)
157  {  {
     static char gpg_keyring[2048] = {0};  
     char *homedir;  
       
     homedir = read_w32_registry_string(NULL, "Software\\GNU\\GnuPG",  
                                        "HomeDir");  
     if( homedir ) {  
         _snprintf( gpg_keyring, sizeof gpg_keyring -1, "%s\\%s",  
                    homedir, keyring );  
         free( homedir );  
     }  
       
     return gpg_keyring;  
 } /* _gpgme_get_gpg_keyring */  
158        _gpgme_get_gpg_optfile (1);
159        _gpgme_get_gpg_path (1);
160    }

Legend:
Removed from v.6  
changed lines
  Added in v.7

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26