Get rid of some unused code. Fix error in debug logs for unicode defaults key.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21965 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-11-07 07:46:44 +00:00
parent c9c6734169
commit 4a5190d98e
8 changed files with 54 additions and 383 deletions

View file

@ -1,3 +1,14 @@
2005-11-07 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Additions/GNUstepBase/Win32Support.h: removed
* Headers/Additions/GNUstepBase/Win32_Utilities.h: removed
* Source/NSPathUtilities.m: Don't include unused files.
* Source/win32/GNUmakefile: Don't build removed files.
* Source/win32/NSUserDefaultsWin32.m: fix '%s' to '%S'
* Source/win32/Win32Support.m: removed
* Source/win32/Win32_Utilities.m: removed
Cleanup ... remove some unused win32 cruft.
2005-11-06 Richard Frith-Macdonald <rfm@gnu.org>
* Documentation/Base.ispell: words from base reference documentation

View file

@ -1,37 +0,0 @@
/* Useful support functions for GNUstep under MS-Windows
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Sheldon Gill <address@hidden>
Created: Dec 2003
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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.
*/
#ifndef __Win32Support_h_GNUSTEP_BASE_INCLUDE
#define __Win32Support_h_GNUSTEP_BASE_INCLUDE
#if defined(__WIN32__)
void Win32Initialise(void);
void Win32Finalise(void);
#else
#define Win32Initialise()
#define Win32Finalise()
#endif /* defined(__WIN32__) else */
#endif /* __WIN32Support_h_GNUSTEP_BASE_INCLUDE */

View file

@ -1,61 +0,0 @@
/** Win32 Utility support functions for GNUStep
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Sheldon Gill <address@hidden>
Date: 2004
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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.
AutogsdocSource: Win32_Utilities.m
*/
#ifndef __Win32_Utilities_h_GNUSTEP_BASE_INCLUDE
#define __Win32_Utilities_h_GNUSTEP_BASE_INCLUDE
#include <Foundation/NSString.h>
/* TODO:
- Win32GetUserProfileDirectory()
Find profile directory for non-current user.
- Win32FindDirectory()
NOT IMPLEMENTED YET!
-Win32NSNumberFromRegistry()
NOT IMPLEMENTED YET!
-Win32NSDataFromRegistry()
NOT IMPLEMENTED YET!
*/
#if defined(__WIN32__)
/* ---- Init Functions ---- */
void Win32_Utilities_init(void);
void Win32_Utilities_fini(void);
/* ---- Environment Functions ---- */
NSString *Win32NSStringFromEnvironmentVariable(NSString *envVar);
/* ---- Registry Functions ---- */
HKEY Win32OpenRegistry(HKEY hive, NSString *key);
NSString *Win32NSStringFromRegistry(HKEY regkey, NSString *regValue);
// NSNumber *Win32NSNumberFromRegistry(HKEY regkey, NSString *regValue);
// NSData *Win32NSDataFromRegistry(HKEY regkey, NSString *regValue);
/* ---- Path Functions ---- */
NSString *Win32GetUserProfileDirectory(NSString *userName);
NSString *Win32FindDirectory(DWORD DirCLSID);
#endif /* defined(__WIN32__) */
#endif /* */

View file

@ -70,12 +70,8 @@
#include "Foundation/NSLock.h"
#include "Foundation/NSUserDefaults.h"
#include "GNUstepBase/GSCategories.h"
#if defined(__WIN32__)
#include "GNUstepBase/Win32_Utilities.h"
#endif
#include "GSPrivate.h"
#include "GNUstepBase/Win32Support.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h> // for getuid()
@ -552,9 +548,6 @@ static void ShutdownPathUtilities(void)
#endif /* OPTION_PLATFORM SUPPORT */
DESTROY(tempDir);
/* Shutdown Win32 support */
Win32Finalise();
}
/**
@ -969,7 +962,44 @@ NSHomeDirectoryForUser(NSString *loginName)
}
[gnustep_global_lock unlock];
#else
s = Win32GetUserProfileDirectory(loginName);
if ([loginName isEqual: NSUserName()] == YES)
{
NSDictionary *e = [[NSProcessInfo processInfo] environment];
/*
* The environment variable HOMEPATH holds the home directory
* for the user on Windows NT;
* For OPENSTEP compatibility (and because USERPROFILE is usually
* unusable because it contains spaces), we use HOMEPATH in
* preference to USERPROFILE.
*/
s = [e objectForKey: @"HOMEPATH"];
if (s != nil && ([s length] < 2 || [s characterAtIndex: 1] != ':'))
{
s = [[e objectForKey: @"HOMEDRIVE"] stringByAppendingString: s];
}
if (s == nil)
{
s = [e objectForKey: @"USERPROFILE"];
}
if (s == nil)
{
; // FIXME: Talk to the NET API and get the profile path
}
}
else
{
s = nil;
NSLog(@"Trying to get home for '%@' when user is '%@'",
loginName, NSUserName());
NSLog(@"Can't determine other user home directories in Win32.");
}
if ([s length] == 0 && [loginName length] != 1)
{
s = nil;
NSLog(@"NSHomeDirectoryForUser(%@) failed", loginName);
}
#endif
return s;
}

View file

@ -35,8 +35,7 @@ win32_OBJC_FILES =\
NSMessagePortWin32.m \
NSRunLoopWin32.m \
NSUserDefaultsWin32.m \
Win32Support.m \
Win32_Utilities.m
-include Makefile.preamble

View file

@ -231,13 +231,11 @@ struct NSUserDefaultsWin32_DomainInfo
v = [NSString stringWithCString: data
encoding: NSASCIIStringEncoding];
v = [v propertyList];
k = AUTORELEASE([[NSString alloc] initWithBytes: name
length: namelen * sizeof(unichar)
encoding: NSUnicodeStringEncoding]);
k = [NSString stringWithCharacters: name length: namelen];
[domainDict setObject: v forKey: k];
}
NS_HANDLER
NSLog(@"Bad registry value for '%s'", name);
NSLog(@"Bad registry value for '%S'", name);
NS_ENDHANDLER
}
else if (rc == ERROR_MORE_DATA)
@ -299,13 +297,11 @@ struct NSUserDefaultsWin32_DomainInfo
v = [NSString stringWithCString: data
encoding: NSASCIIStringEncoding];
v = [v propertyList];
k = AUTORELEASE([[NSString alloc] initWithBytes: name
length: namelen * sizeof(unichar)
encoding: NSUnicodeStringEncoding]);
k = [NSString stringWithCharacters: name length: namelen];
[domainDict setObject: v forKey: k];
}
NS_HANDLER
NSLog(@"Bad registry value for '%s'", name);
NSLog(@"Bad registry value for '%S'", name);
NS_ENDHANDLER
}
else if (rc == ERROR_MORE_DATA)

View file

@ -1,48 +0,0 @@
/* Useful support functions for GNUstep under MS-Windows
Copyright (C) 2004-2005 Free Software Foundation, Inc.
Written by: Sheldon Gill <address@hidden>
Created: Dec 2003
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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.
*/
#include "GNUstepBase/Win32_Utilities.h"
//#include "GNUstepBase/Win32_FileManagement.h"
/*
* Perform any and all necessary initialisation for supporting Win32
* Called after first part of library initialisation so some Obj-C is okay
*/
void
Win32Initialise(void)
{
/* We call the initialisation routines of all support modules in turn */
Win32_Utilities_init();
// Win32_FileManagement_init();
}
/*
* Free and finalise all things for supporting Win32
*/
void
Win32Finalise(void)
{
/* We call the finalisation routines of all support modules in turn */
Win32_Utilities_fini();
// Win32_FileManagement_fini();
}

View file

@ -1,219 +0,0 @@
/* Useful support functions for GNUstep under MS-Windows
Copyright (C) 2004-2005 Free Software Foundation, Inc.
Written by: Sheldon Gill <address@hidden>
Created: Dec 2003
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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.
*/
#include <Foundation/NSString.h>
#include <Foundation/NSException.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSProcessInfo.h>
#include "GNUstepBase/Win32_Utilities.h"
#define UNISTR(X) \
((const unichar*)[(X) cStringUsingEncoding: NSUnicodeStringEncoding])
/* ------------------ */
/* Internal Variables */
/* ------------------ */
/* ------+---------+---------+---------+---------+---------+---------+---------+
#pragma mark -
#pragma mark -<Registry functions>-
---------+---------+---------+---------+---------+---------+---------+------- */
/**
* Returns a hive key or 0 if unable.
*/
HKEY
Win32OpenRegistryW(HKEY hive, NSString *key)
{
HKEY regkey;
if (RegOpenKeyExW(hive, UNISTR(key), 0, KEY_READ, &regkey) == ERROR_SUCCESS)
{
return regkey;
}
return 0;
}
/**
* Returns an NSString as read from a registry STRING value.
*/
NSString *
Win32NSStringFromRegistry(HKEY regkey, NSString *regValue)
{
unichar buf[MAX_PATH];
DWORD bufsize = MAX_PATH;
DWORD type;
if (RegQueryValueExW(regkey, UNISTR(regValue), 0, &type, (unsigned char*)buf,
&bufsize) == ERROR_SUCCESS)
{
// FIXME check type is correct
return [NSString stringWithCharacters: buf
length: bufsize / sizeof(unichar)];
}
return nil;
}
// NSNumber *Win32NSNumberFromRegistry(HKEY regkey, NSString *regValue);
// NSData *Win32NSDataFromRegistry(HKEY regkey, NSString *regValue);
/* ------+---------+---------+---------+---------+---------+---------+---------+
#pragma mark -
#pragma mark -<Environment functions>-
---------+---------+---------+---------+---------+---------+---------+------- */
/**
* Obtains an NSString for the environment variable named envVar.
*/
NSString *
Win32NSStringFromEnvironmentVariable(NSString *envVar)
{
unichar buf[1024], *nb;
DWORD n;
NSString *s = nil;
[gnustep_global_lock lock];
n = GetEnvironmentVariableW(UNISTR(envVar), buf, 1024);
if (n > 1024)
{
/* Buffer not big enough, so dynamically allocate it */
nb = (unichar *)NSZoneMalloc(NSDefaultMallocZone(),
sizeof(unichar)*(n + 1));
if (nb != NULL)
{
n = GetEnvironmentVariableW(UNISTR(envVar), nb, n + 1);
s = [NSString stringWithCharacters: nb length: n];
NSZoneFree(NSDefaultMallocZone(), nb);
}
}
else if (n > 0)
{
s = [NSString stringWithCharacters: buf length: n];
}
[gnustep_global_lock unlock];
return s;
}
/* ------+---------+---------+---------+---------+---------+---------+---------+
#pragma mark -
#pragma mark -<Path functions>-
---------+---------+---------+---------+---------+---------+---------+------- */
/**
* Locates the users profile directory, roughly equivalent to ~/ on unix
*/
NSString *
Win32GetUserProfileDirectory(NSString *loginName)
{
NSString *s;
if ([loginName isEqual: NSUserName()] == YES)
{
[gnustep_global_lock lock];
/*
* The environment variable HOMEPATH holds the home directory
* for the user on Windows NT;
* For OPENSTEP compatibility (and because USERPROFILE is usually
* unusable because it contains spaces), we use HOMEPATH in
* preference to USERPROFILE.
*/
s = Win32NSStringFromEnvironmentVariable(@"HOMEPATH");
if (s != nil && ([s length] < 2 || [s characterAtIndex: 1] != ':'))
{
s = [Win32NSStringFromEnvironmentVariable(@"HOMEDRIVE")
stringByAppendingString: s];
}
if (s == nil)
{
s = Win32NSStringFromEnvironmentVariable(@"USERPROFILE");
}
if (s == nil)
{
; // FIXME: Talk to the NET API and get the profile path
}
[gnustep_global_lock unlock];
}
else
{
s = nil;
NSLog(@"Trying to get home for '%@' when user is '%@'",
loginName, NSUserName());
NSLog(@"Can't determine other user home directories in Win32.");
}
if ([s length] == 0 && [loginName length] != 1)
{
s = nil;
NSLog(@"NSHomeDirectoryForUser(%@) failed", loginName);
}
return s;
}
/**
* Locates specified directory on Win32 systems
*/
NSString *
Win32FindDirectory(DWORD DirCSIDL)
{
[NSException raise: NSInternalInconsistencyException
format: @"Not implemented! Can't find directories in Win32."];
return nil;
}
/**
* Initialises resources required by utilities
*/
void
Win32_Utilities_init(void)
{
/*
* Initialise the COM sub-system for this application
*/
//CoCreateInstance();
/*
* Look for the libraries we need
*/
// GetDLLVersion
/*
* Get pointers to the Explorer Shell memory functions
*/
// IShellMalloc, IShellFree
// SHGetFolder
}
/**
* Closes down and releases resources
*/
void
Win32_Utilities_fini(void)
{
/*
* Release the pointers for Explorer Shell functions
*/
}