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

Diff of /trunk/Src/wptRegistry.cpp

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

revision 13 by twoaday, Mon Apr 25 07:15:30 2005 UTC revision 23 by twoaday, Fri Sep 30 10:10:16 2005 UTC
# Line 59  free_reg_prefs (void) Line 59  free_reg_prefs (void)
59  } /* free_reg_prefs */  } /* free_reg_prefs */
60    
61    
62  /*  /* Register the given WinPT filetype. */
  * Register the given WinPT filetype.  
  */  
63  static int  static int
64  regist_single_filetype (gpg_filetype *gfile)  regist_single_filetype (gpg_filetype *gfile)
65  {  {
# Line 74  regist_single_filetype (gpg_filetype *gf Line 72  regist_single_filetype (gpg_filetype *gf
72  } /* regist_single_filetype */  } /* regist_single_filetype */
73    
74    
75  /*  /* Install the GPG related into the W32 resgistry, if the entry already
76   * Install the GPG related into the W32 resgistry, if the entry already     exists the function returns immediately. */
  * exists< the function returns immediately.  
  */  
77  int  int
78  regist_inst_gnupg (int create_mokey)  regist_inst_gnupg (int create_mokey)
79  {  {
# Line 109  regist_inst_gnupg (int create_mokey) Line 105  regist_inst_gnupg (int create_mokey)
105  } /* regist_inst_gpg */  } /* regist_inst_gpg */
106    
107    
108  /*  /* Install WinPT into the W32 registry, if the entry already
109   * Install WinPT into the W32 registry, if the entry already     exists the function returns immediately.*/
  * exists the function returns immediately.  
  */  
110  int  int
111  regist_inst_winpt (int with_ext, int * created)  regist_inst_winpt (int with_ext, int * created)
112  {  {
# Line 184  start: Line 178  start:
178  } /* regist_inst_winpt */  } /* regist_inst_winpt */
179    
180    
181  /*  /* Create a new filetype in the W32 registry.
182   * Create a new filetype in the W32 registry.     We should really care of errors! Otherwise we can damage the registry! */
  * We should really care of errors! Otherwise we can damage the registry!  
  */  
183  int  int
184  create_file_type( const char *exefile, const char *ext, const char *extname, char *iconfile )  create_file_type( const char *exefile, const char *ext, const char *extname, char *iconfile )
185  {  {
# Line 242  leave: Line 234  leave:
234  } /* create_file_type */  } /* create_file_type */
235    
236    
237    /* Expand a string with %foo% entries so that %foo% will
238       be replaced with its actual value. */
239  static char *  static char *
240  expand_path( const char *path )  expand_path (const char *path)
241  {  {
242      DWORD len;      DWORD len;
243      char *p;      char *p;
244    
245      len = ExpandEnvironmentStrings( path, NULL, 0 );      len = ExpandEnvironmentStrings (path, NULL, 0);
246      if( !len )      if (!len)
247          return NULL;          return NULL;
248      len += 1;      len += 1;
249      p = new char[len];          p = new char[len+1];
250      if( !p )      if( !p )
251          return NULL;          return NULL;
252      len = ExpandEnvironmentStrings( path, p, len );      len = ExpandEnvironmentStrings (path, p, len);
253      if( !len ) {      if (!len) {
254          free_if_alloc( p );          free_if_alloc (p);
255          return NULL;          return NULL;
256      }      }
257      return p;      return p;
258  } /* expand_path */  } /* expand_path */
259    
260    
261  char *  /* Retrieve a registry entry with the directory given in @dir
262       and the key given in @key.
263       Return value is the value or NULL otherwise. */
264    char*
265  get_reg_entry (HKEY root_key, const char * dir, const char * key)  get_reg_entry (HKEY root_key, const char * dir, const char * key)
266  {  {
267      int rc;      int rc;
# Line 276  get_reg_entry (HKEY root_key, const char Line 273  get_reg_entry (HKEY root_key, const char
273      rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, &reg_key);      rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, &reg_key);
274      if( !rc_ok( rc ) )      if( !rc_ok( rc ) )
275          goto leave;          goto leave;
276      nbytes = sizeof text - 1;      nbytes = sizeof (text) - 1;
277      type = REG_SZ;      type = REG_SZ;
278            
279      rc = RegQueryValueEx (reg_key, key, 0, &type, (BYTE *)&text, &nbytes);      rc = RegQueryValueEx (reg_key, key, 0, &type, (BYTE *)&text, &nbytes);
# Line 297  leave: Line 294  leave:
294      if (reg_key)      if (reg_key)
295          RegCloseKey (reg_key);          RegCloseKey (reg_key);
296      return p;      return p;
297  } /* get_reg_entry */  }
298    
299    
300    /* XXX: use REG_EXPAND_SZ to support multi user environments.
301            keep this type and do not overwrite it with REG_SZ. */
302    
303    /* Set a registry entry. */
304  int  int
305  set_reg_entry( HKEY root_key, const char * dir, const char * key,  set_reg_entry (HKEY root_key, const char *dir, const char *key,
306                 const char * value )                 const char *value)
307  {  {
308      int rc = 0;      int rc = 0;
309      HKEY reg_key;      HKEY reg_key;
# Line 347  leave: Line 348  leave:
348    
349    
350  int  int
351  set_reg_entry_gpg( const char * key, const char * value )  set_reg_entry_gpg (const char * key, const char * value)
352  {        {      
353      return set_reg_entry( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key, value );      return set_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key, value);
354  } /* set_reg_entry_gpg */  }
355    
356    
357  int  int
358  set_reg_entry_mo( const char * value )  set_reg_entry_mo (const char * value)
359  {        {      
360      return set_reg_entry( HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS", "MODir", value );      return set_reg_entry (HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS",
361  } /* set_reg_entry_mo */                            "MODir", value);
362    }
363    
364    
365  char *  char *
366  get_reg_entry_gpg( const char *key )  get_reg_entry_gpg (const char *key)
367  {  {
368      return get_reg_entry( HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key );      return get_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key);
369  } /* get_reg_entry_gpg */  }
370    
371    
372  char *  char *
373  get_reg_entry_mo( void )  get_reg_entry_mo(void)
374  {        {      
375      return get_reg_entry( HKEY_CURRENT_USER, "Control Panel\\Mingw32\\NLS", "MODir" );      return get_reg_entry(HKEY_CURRENT_USER,
376  } /* get_reg_entry_mo */                           "Control Panel\\Mingw32\\NLS", "MODir");
377    }
378    
379    
380    /* All valid configuration commands. */
381  static const char * cfg [] = {  static const char * cfg [] = {
382          NULL,          NULL,
383          "CacheTime",          "CacheTime",
# Line 420  get_reg_winpt_single (int id) Line 424  get_reg_winpt_single (int id)
424  }  }
425    
426    
427    /* Saves the winpt preferences in the registry. */
428  int  int
429  set_reg_winpt_prefs (winpt_reg_prefs_s * opt)  set_reg_winpt_prefs (winpt_reg_prefs_s * opt)
430  {  {
# Line 503  leave: Line 508  leave:
508          return rc;          return rc;
509      }      }
510      return 0;      return 0;
511  } /* set_reg_winpt_prefs */  }
512    
513    
514  int  int
# Line 529  get_reg_winpt_flag (const char * name) Line 534  get_reg_winpt_flag (const char * name)
534  } /* get_reg_winpt_flag */  } /* get_reg_winpt_flag */
535    
536    
537    /* Retrieve the winpt preferences from the registry. */
538  int  int
539  get_reg_winpt_prefs (winpt_reg_prefs_s * opt)  get_reg_winpt_prefs (winpt_reg_prefs_s * opt)
540  {  {
# Line 615  get_reg_winpt_prefs (winpt_reg_prefs_s * Line 621  get_reg_winpt_prefs (winpt_reg_prefs_s *
621  } /* get_reg_winpt_prefs */  } /* get_reg_winpt_prefs */
622    
623    
624  char *  char*
625  get_reg_entry_keyserver (const char *name)  get_reg_entry_keyserver (const char *name)
626  {  {
627      char * p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name);      char * p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name);
# Line 624  get_reg_entry_keyserver (const char *nam Line 630  get_reg_entry_keyserver (const char *nam
630          return NULL;          return NULL;
631      }      }
632      return p;      return p;
633  } /* get_reg_entry_keyserver */  }
634    
635    
636  void  void

Legend:
Removed from v.13  
changed lines
  Added in v.23

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26