mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Further config enhancements ... fix a couple of static declarations,
use GNUstep.conf in defaults system, and allow external defaults to be disabled. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22518 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a531412909
commit
0d2f432fab
7 changed files with 91 additions and 26 deletions
|
@ -1,3 +1,10 @@
|
|||
2006-02-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSPathUtilities.m: Make config functions public.
|
||||
* Headers/Foundation/NSPathUtilities.h: Declare config functions.
|
||||
* Source/NSUserDefaults.m: Use config functions and add support
|
||||
for new option to turn off external config file.
|
||||
|
||||
2006-02-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSFileManager.m: Fix bug dereferencing nul pointer under
|
||||
|
|
|
@ -516,7 +516,10 @@ notice and this notice are preserved.
|
|||
Relative to the user's home directory.<br />
|
||||
On mswindows this may be set to be ':REGISTRY:' to have defaults
|
||||
stored in the windows registry rather than in the standard file
|
||||
format.
|
||||
format.<br />
|
||||
On any system this may be set to ':INTERNAL:' to use only
|
||||
internal defaults domains (NSArgumentDomain, NSRegistrationDomain,
|
||||
and GSConfigDomain).
|
||||
</desc>
|
||||
</deflist>
|
||||
<p>
|
||||
|
@ -672,7 +675,10 @@ notice and this notice are preserved.
|
|||
<code>GNUstep/Defaults</code> subdirectory).
|
||||
On mswindows this may be set to be ':REGISTRY:' to have defaults
|
||||
stored in the windows registry rather than in the standard file
|
||||
format.
|
||||
format.<br />
|
||||
On any system this may be set to ':INTERNAL:' to use only
|
||||
internal defaults domains (NSArgumentDomain, NSRegistrationDomain,
|
||||
and GSConfigDomain).
|
||||
</p>
|
||||
</subsect>
|
||||
</section>
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
AutogsdocSource: NSPathUtilities.m
|
||||
*/
|
||||
|
@ -29,6 +30,8 @@
|
|||
#include <Foundation/NSString.h>
|
||||
|
||||
#ifndef NO_GNUSTEP
|
||||
@class NSDictionary;
|
||||
@class NSMutableDictionary;
|
||||
/**
|
||||
* This extension permits a change of username from that specified in the
|
||||
* LOGNAME environment variable. Using it will almost certainly cause
|
||||
|
@ -38,9 +41,34 @@
|
|||
* [NSUserDefaults +resetUserDefaults] extension to reset the defaults system
|
||||
* to use the defaults belonging to the new user.
|
||||
*/
|
||||
GS_EXPORT void GSSetUserName(NSString *aName);
|
||||
GS_EXPORT void
|
||||
GSSetUserName(NSString *aName);
|
||||
|
||||
GS_EXPORT NSString *GSDefaultsRootForUser(NSString *userName);
|
||||
/**
|
||||
* Returns a mutable copy of the system-wide configuration used to
|
||||
* determine paths to locate files etc.<br />
|
||||
* If the newConfig argument is non-nil it is used to set the config
|
||||
* overriding any other version. You should not change the config
|
||||
* after the user defaults system has been initialised as the new
|
||||
* config will not be picked up by the defaults system.
|
||||
*/
|
||||
GS_EXPORT NSMutableDictionary*
|
||||
GNUstepConfig(NSDictionary *newConfig);
|
||||
|
||||
/**
|
||||
* Returns the location of the defaults database for the specified user.
|
||||
*/
|
||||
GS_EXPORT NSString*
|
||||
GSDefaultRootForUser(NSString *username);
|
||||
|
||||
/**
|
||||
* The config dictiuonary passed to this function should be a
|
||||
* system-wiude config as provided by GNUstepConfig() ... and
|
||||
* this function merges in user specific configuration file
|
||||
* information if such a file exists and is owned by the user.
|
||||
*/
|
||||
GS_EXPORT void
|
||||
GNUstepUserConfig(NSMutableDictionary *config, NSString *userName);
|
||||
|
||||
#endif
|
||||
GS_EXPORT NSString *NSUserName(void);
|
||||
|
|
|
@ -55,6 +55,13 @@ GS_EXPORT NSString* const NSGlobalDomain;
|
|||
*/
|
||||
GS_EXPORT NSString* const NSRegistrationDomain;
|
||||
|
||||
#ifndef NO_GNUSTEP
|
||||
/**
|
||||
* User defaults domain for GNUstep config file.
|
||||
*/
|
||||
GS_EXPORT NSString* const GSConfigDomain;
|
||||
#endif
|
||||
|
||||
|
||||
/* Public notification */
|
||||
|
||||
|
|
|
@ -82,6 +82,11 @@
|
|||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
NSMutableDictionary* GNUstepConfig(NSDictionary *newConfig);
|
||||
|
||||
void GNUstepUserConfig(NSMutableDictionary *config, NSString *userName);
|
||||
|
||||
|
||||
/* The global configuration file. The real value is read from config.h */
|
||||
#ifndef GNUSTEP_TARGET_CONFIG_FILE
|
||||
# define GNUSTEP_TARGET_CONFIG_FILE "/etc/GNUstep/GNUstep.conf"
|
||||
|
@ -155,14 +160,6 @@ static NSString *localResources = nil;
|
|||
static NSString *localApps = nil;
|
||||
static NSString *localLibs = nil;
|
||||
|
||||
/* ============================= */
|
||||
/* Internal function prototypes. */
|
||||
/* ============================= */
|
||||
|
||||
static NSMutableDictionary* GNUstepConfig(NSDictionary *newConfig);
|
||||
|
||||
static void UserConfig(NSMutableDictionary *config, NSString *userName);
|
||||
|
||||
static BOOL ParseConfigurationFile(NSString *name, NSMutableDictionary *dict,
|
||||
NSString *userName);
|
||||
|
||||
|
@ -363,7 +360,7 @@ static void ExtractValuesFromConfig(NSDictionary *config)
|
|||
}
|
||||
}
|
||||
|
||||
static NSMutableDictionary*
|
||||
NSMutableDictionary*
|
||||
GNUstepConfig(NSDictionary *newConfig)
|
||||
{
|
||||
static NSDictionary *config = nil;
|
||||
|
@ -510,8 +507,8 @@ GNUstepConfig(NSDictionary *newConfig)
|
|||
return AUTORELEASE([config mutableCopy]);
|
||||
}
|
||||
|
||||
static void
|
||||
UserConfig(NSMutableDictionary *config, NSString *userName)
|
||||
void
|
||||
GNUstepUserConfig(NSMutableDictionary *config, NSString *userName)
|
||||
{
|
||||
#ifdef HAVE_GETEUID
|
||||
if (userName != nil)
|
||||
|
@ -568,7 +565,7 @@ static void InitialisePathUtilities(void)
|
|||
[gnustep_global_lock lock];
|
||||
userName = NSUserName();
|
||||
config = GNUstepConfig(nil);
|
||||
UserConfig(config, userName);
|
||||
GNUstepUserConfig(config, userName);
|
||||
ASSIGNCOPY(gnustepUserHome, NSHomeDirectoryForUser(userName));
|
||||
ExtractValuesFromConfig(config);
|
||||
|
||||
|
@ -1154,7 +1151,7 @@ GSDefaultsRootForUser(NSString *userName)
|
|||
NSMutableDictionary *config;
|
||||
|
||||
config = GNUstepConfig(nil);
|
||||
UserConfig(config, userName);
|
||||
GNUstepUserConfig(config, userName);
|
||||
defaultsDir = [config objectForKey: @"GNUSTEP_USER_DEFAULTS_DIR"];
|
||||
if (defaultsDir == nil)
|
||||
{
|
||||
|
|
|
@ -189,6 +189,13 @@ static void updateCache(NSUserDefaults *self)
|
|||
* Constants that help with localization to the users's
|
||||
* language.
|
||||
* </desc>
|
||||
* <term><code>GSConfigDomain</code> ... volatile</term>
|
||||
* <desc>
|
||||
* Information retrieved from the GNUstep configuration system.
|
||||
* Usually the system wide and user specific GNUstep.conf files,
|
||||
* or from information cimplied in when the base library was
|
||||
* built.
|
||||
* </desc>
|
||||
* <term><code>NSRegistrationDomain</code> ... volatile</term>
|
||||
* <desc>
|
||||
* Temporary defaults set up by the application.
|
||||
|
@ -474,6 +481,7 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
|
|||
[sharedDefaults->_searchList addObject: NSArgumentDomain];
|
||||
[sharedDefaults->_searchList addObject: processName];
|
||||
[sharedDefaults->_searchList addObject: NSGlobalDomain];
|
||||
[sharedDefaults->_searchList addObject: GSConfigDomain];
|
||||
[sharedDefaults->_searchList addObject: NSRegistrationDomain];
|
||||
|
||||
/*
|
||||
|
@ -707,14 +715,19 @@ static NSString *
|
|||
pathForUser(NSString *user)
|
||||
{
|
||||
NSString *database = @".GNUstepDefaults";
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSFileManager *mgr;
|
||||
NSString *path;
|
||||
unsigned desired;
|
||||
NSDictionary *attr;
|
||||
BOOL isDir;
|
||||
|
||||
path = GSDefaultsRootForUser(user);
|
||||
if (path == nil || [path rangeOfString: @":INTERNAL:"].length > 0)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
mgr = [NSFileManager defaultManager];
|
||||
#if !(defined(S_IRUSR) && defined(S_IWUSR) && defined(S_IXUSR) \
|
||||
&& defined(S_IRGRP) && defined(S_IXGRP) \
|
||||
&& defined(S_IROTH) && defined(S_IXOTH))
|
||||
|
@ -770,6 +783,7 @@ pathForUser(NSString *user)
|
|||
- (id) initWithContentsOfFile: (NSString*)path
|
||||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSRange r;
|
||||
BOOL flag;
|
||||
|
||||
self = [super init];
|
||||
|
@ -787,12 +801,17 @@ pathForUser(NSString *user)
|
|||
path = pathForUser(NSUserName());
|
||||
}
|
||||
|
||||
r = [path rangeOfString: @":INTERNAL:"];
|
||||
if (r.length > 0)
|
||||
{
|
||||
goto skipPathChecks;
|
||||
}
|
||||
#if defined(__MINGW32__)
|
||||
{
|
||||
NSRange r = [path rangeOfString: @":REGISTRY:"];
|
||||
if (r.length > 0)
|
||||
goto skipPathChecks;
|
||||
}
|
||||
r = [path rangeOfString: @":REGISTRY:"];
|
||||
if (r.length > 0)
|
||||
{
|
||||
goto skipPathChecks;
|
||||
}
|
||||
#endif
|
||||
|
||||
path = [path stringByStandardizingPath];
|
||||
|
@ -826,9 +845,7 @@ pathForUser(NSString *user)
|
|||
[_defaultsDatabase stringByAppendingPathExtension: @"lck"]];
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
skipPathChecks:
|
||||
#endif
|
||||
|
||||
_lock = [GSLazyRecursiveLock new];
|
||||
|
||||
|
@ -866,6 +883,7 @@ skipPathChecks:
|
|||
[_tempDomains
|
||||
setObject: [NSMutableDictionaryClass dictionaryWithCapacity: 10]
|
||||
forKey: NSRegistrationDomain];
|
||||
[_tempDomains setObject: GNUstepConfig(nil) forKey: GSConfigDomain];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||
selector: @selector(synchronize)
|
||||
|
|
|
@ -133,6 +133,8 @@ NSString *NSGlobalDomain = @"NSGlobalDomain";
|
|||
|
||||
NSString *NSRegistrationDomain = @"NSRegistrationDomain";
|
||||
|
||||
NSString *GSConfigDomain = @"GSConfigDomain";
|
||||
|
||||
|
||||
/* Public notification */
|
||||
NSString *NSUserDefaultsDidChangeNotification = @"NSUserDefaultsDidChangeNotification";
|
||||
|
|
Loading…
Reference in a new issue