mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Mingw update
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6666 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
62f719eb99
commit
93f1bc859a
24 changed files with 155 additions and 577 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
||||||
|
2000-06-11 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Headers/gnustep/base/preface.h.in: Define MINGW if MINW32.
|
||||||
|
* Headers/gnustep/base/TcpPort.h: Change WIN32 to MINGW since
|
||||||
|
CYGWIN has unix-like services.
|
||||||
|
* Headers/gnustep/base/UdpPort.h: Likewise.
|
||||||
|
* Source/GSTcpPort.m, Source/NSData.m, Source/NSDate.m,
|
||||||
|
Source/NSFileManager.m, Source/NSHost.m, Source/NSLog.m,
|
||||||
|
Source/NSPage.m, Source/NSProcessInfo.m, Source/NSString.m,
|
||||||
|
Source/NSThread.m, Source/NSUser.m, Source/UdpPort.m,
|
||||||
|
Source/UnixFileHandle.m, : Likewise.
|
||||||
|
|
||||||
|
* Source/Makefile.postamble: touch generated h files so they aren'y
|
||||||
|
re-copied every compile.
|
||||||
|
|
||||||
|
* Source/NSBundle.m (_absolutePathOfExecutable:): New method.
|
||||||
|
(mainBundle): Use it.
|
||||||
|
* Source/NSTask.m (launch): Likewise.
|
||||||
|
* Source/find_exec.m: Removed.
|
||||||
|
|
||||||
2000-06-09 Richard Frith-Macdonald <rfm@gnu.org>
|
2000-06-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSeq.h: Reverted bogus change.
|
* Source/GSeq.h: Reverted bogus change.
|
||||||
|
|
|
@ -89,6 +89,7 @@ extern NSString* NSLoadedClasses;
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
@interface NSBundle (GNUstep)
|
@interface NSBundle (GNUstep)
|
||||||
|
|
||||||
|
+ (NSString *) _absolutePathOfExecutable: (NSString *)path;
|
||||||
+ (NSString*) _gnustep_target_cpu;
|
+ (NSString*) _gnustep_target_cpu;
|
||||||
+ (NSString*) _gnustep_target_dir;
|
+ (NSString*) _gnustep_target_dir;
|
||||||
+ (NSString*) _gnustep_target_os;
|
+ (NSString*) _gnustep_target_os;
|
||||||
|
|
|
@ -27,11 +27,13 @@
|
||||||
#include <base/preface.h>
|
#include <base/preface.h>
|
||||||
#include <base/Port.h>
|
#include <base/Port.h>
|
||||||
#include <base/RunLoop.h>
|
#include <base/RunLoop.h>
|
||||||
#if !defined(__WIN32__) || defined(__CYGWIN__)
|
#ifdef __MINGW__
|
||||||
|
# include <winsock.h>
|
||||||
|
#else
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif /* !__WIN32__ */
|
#endif
|
||||||
#include <Foundation/NSMapTable.h>
|
#include <Foundation/NSMapTable.h>
|
||||||
|
|
||||||
/* A concrete implementation of a Port object implemented on top of
|
/* A concrete implementation of a Port object implemented on top of
|
||||||
|
|
|
@ -27,12 +27,12 @@
|
||||||
#include <base/preface.h>
|
#include <base/preface.h>
|
||||||
#include <base/Port.h>
|
#include <base/Port.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef __WIN32__
|
#ifdef __MINGW__
|
||||||
# include <winsock.h>
|
# include <winsock.h>
|
||||||
#else
|
#else
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
#endif /* !WIN32 */
|
#endif
|
||||||
|
|
||||||
@interface UdpInPort : InPort
|
@interface UdpInPort : InPort
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,12 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#ifndef __MINGW__
|
||||||
|
#define __MINGW__
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define GNUSTEP_BASE_SOCKET_MESSAGE (WM_USER + 1)
|
#define GNUSTEP_BASE_SOCKET_MESSAGE (WM_USER + 1)
|
||||||
|
|
|
@ -335,7 +335,6 @@ NSValue.m \
|
||||||
NSZone.m \
|
NSZone.m \
|
||||||
externs.m \
|
externs.m \
|
||||||
objc-load.m \
|
objc-load.m \
|
||||||
find_exec.m \
|
|
||||||
NSURL.m \
|
NSURL.m \
|
||||||
NSURLHandle.m
|
NSURLHandle.m
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#if !defined(__WIN32__) || defined(__CYGWIN__)
|
#ifndef __MINGW__
|
||||||
#include <unistd.h> /* for gethostname() */
|
#include <unistd.h> /* for gethostname() */
|
||||||
#include <netinet/in.h> /* for inet_ntoa() */
|
#include <netinet/in.h> /* for inet_ntoa() */
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -63,14 +63,14 @@ extern int errno;
|
||||||
#define NBLK_OPT FNDELAY
|
#define NBLK_OPT FNDELAY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !__WIN32__ */
|
#endif /* !__MINGW__ */
|
||||||
#include <string.h> /* for memset() and strchr() */
|
#include <string.h> /* for memset() and strchr() */
|
||||||
#if !defined(__WIN32__) || defined(__CYGWIN__)
|
#ifndef __MINGW__
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif /* !__WIN32__ */
|
#endif /* !__MINGW__ */
|
||||||
|
|
||||||
#ifndef INADDR_NONE
|
#ifndef INADDR_NONE
|
||||||
#define INADDR_NONE -1
|
#define INADDR_NONE -1
|
||||||
|
|
|
@ -153,14 +153,17 @@ $(GNUSTEP_OBJ_DIR)/preface${OEXT}: Foundation/preface.h
|
||||||
$(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/config.h: ../config.status
|
$(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/config.h: ../config.status
|
||||||
$(MKDIRS) $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
$(MKDIRS) $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
||||||
-mv Foundation/config.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
-mv Foundation/config.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
||||||
|
-touch $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/config.h
|
||||||
|
|
||||||
$(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/GSConfig.h: ../config.status
|
$(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/GSConfig.h: ../config.status
|
||||||
$(MKDIRS) $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
$(MKDIRS) $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
||||||
-mv Foundation/GSConfig.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
-mv Foundation/GSConfig.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
||||||
|
-touch $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/GSConfig.h
|
||||||
|
|
||||||
$(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/mframe.h: mframe/config.status
|
$(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/mframe.h: mframe/config.status
|
||||||
$(MKDIRS) $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
$(MKDIRS) $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
||||||
-mv mframe/mframe.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
-mv mframe/mframe.h $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
|
||||||
|
-touch $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/mframe.h
|
||||||
|
|
||||||
Foundation/o_%_bas.h: Foundation/o_x_bas.h.in
|
Foundation/o_%_bas.h: Foundation/o_x_bas.h.in
|
||||||
sed -e "s/@XX@/$*/g" $< > $@
|
sed -e "s/@XX@/$*/g" $< > $@
|
||||||
|
|
|
@ -96,9 +96,6 @@ static NSString* library_combo =
|
||||||
nil;
|
nil;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Declaration from find_exec.c */
|
|
||||||
extern char *objc_find_executable(const char *name);
|
|
||||||
|
|
||||||
/* This function is provided for objc-load.c, although I'm not sure it
|
/* This function is provided for objc-load.c, although I'm not sure it
|
||||||
really needs it (So far only needed if using GNU dld library) */
|
really needs it (So far only needed if using GNU dld library) */
|
||||||
const char *
|
const char *
|
||||||
|
@ -237,7 +234,6 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
||||||
{
|
{
|
||||||
NSMutableString *system;
|
NSMutableString *system;
|
||||||
NSString *str;
|
NSString *str;
|
||||||
char *output;
|
|
||||||
|
|
||||||
if ((str = [env objectForKey: @"GNUSTEP_TARGET_DIR"]) != nil)
|
if ((str = [env objectForKey: @"GNUSTEP_TARGET_DIR"]) != nil)
|
||||||
gnustep_target_dir = RETAIN(str);
|
gnustep_target_dir = RETAIN(str);
|
||||||
|
@ -270,10 +266,9 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
||||||
{
|
{
|
||||||
_executable_path =
|
_executable_path =
|
||||||
[[[NSProcessInfo processInfo] arguments] objectAtIndex: 0];
|
[[[NSProcessInfo processInfo] arguments] objectAtIndex: 0];
|
||||||
output = objc_find_executable([_executable_path cString]);
|
_executable_path =
|
||||||
NSAssert(output, NSInternalInconsistencyException);
|
[NSBundle _absolutePathOfExecutable: _executable_path];
|
||||||
_executable_path = [NSString stringWithCString: output];
|
NSAssert(_executable_path, NSInternalInconsistencyException);
|
||||||
OBJC_FREE(output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RETAIN(_executable_path);
|
RETAIN(_executable_path);
|
||||||
|
@ -308,6 +303,53 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
||||||
return [self notImplemented: _cmd];
|
return [self notImplemented: _cmd];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (NSString *) _absolutePathOfExecutable: (NSString *)path
|
||||||
|
{
|
||||||
|
NSFileManager *mgr;
|
||||||
|
NSDictionary *env;
|
||||||
|
NSString *pathlist, *prefix;
|
||||||
|
id patharr;
|
||||||
|
|
||||||
|
path = [path stringByStandardizingPath];
|
||||||
|
if ([path isAbsolutePath])
|
||||||
|
return path;
|
||||||
|
|
||||||
|
mgr = [NSFileManager defaultManager];
|
||||||
|
env = [[NSProcessInfo processInfo] environment];
|
||||||
|
pathlist = [env objectForKey:@"PATH"];
|
||||||
|
#if defined(__MINGW__)
|
||||||
|
patharr = [pathlist componentsSeparatedByString:@";"];
|
||||||
|
#else
|
||||||
|
patharr = [pathlist componentsSeparatedByString:@":"];
|
||||||
|
#endif
|
||||||
|
patharr = [patharr objectEnumerator];
|
||||||
|
while ((prefix = [patharr nextObject]))
|
||||||
|
{
|
||||||
|
if ([prefix isEqual:@"."])
|
||||||
|
prefix = [mgr currentDirectoryPath];
|
||||||
|
prefix = [prefix stringByAppendingPathComponent: path];
|
||||||
|
if ([mgr isExecutableFileAtPath: prefix])
|
||||||
|
return [prefix stringByStandardizingPath];
|
||||||
|
#if defined(__WIN32__)
|
||||||
|
/* Also add common executable extensions on windows */
|
||||||
|
if ([path pathExtension] == nil)
|
||||||
|
{
|
||||||
|
NSString *wpath;
|
||||||
|
wpath = [prefix stringByAppendingPathExtension: @"exe"];
|
||||||
|
if ([mgr isExecutableFileAtPath: wpath])
|
||||||
|
return [wpath stringByStandardizingPath];
|
||||||
|
wpath = [prefix stringByAppendingPathExtension: @"com"];
|
||||||
|
if ([mgr isExecutableFileAtPath: wpath])
|
||||||
|
return [wpath stringByStandardizingPath];
|
||||||
|
wpath = [prefix stringByAppendingPathExtension: @"cmd"];
|
||||||
|
if ([mgr isExecutableFileAtPath: wpath])
|
||||||
|
return [wpath stringByStandardizingPath];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
+ (NSBundle *)mainBundle
|
+ (NSBundle *)mainBundle
|
||||||
{
|
{
|
||||||
[load_lock lock];
|
[load_lock lock];
|
||||||
|
|
|
@ -120,17 +120,17 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len, NSZone* zone)
|
||||||
void *tmp = 0;
|
void *tmp = 0;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
#if defined(__MINGW__)
|
||||||
|
return NO;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ([path getFileSystemRepresentation: thePath
|
if ([path getFileSystemRepresentation: thePath
|
||||||
maxLength: sizeof(thePath)-1] == NO)
|
maxLength: sizeof(thePath)-1] == NO)
|
||||||
{
|
{
|
||||||
NSDebugLog(@"Open (%s) attempt failed - bad path", thePath);
|
NSDebugLog(@"Open (%s) attempt failed - bad path", thePath);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
#if defined(__WIN32__)
|
|
||||||
theFile = fopen(thePath, "rb");
|
theFile = fopen(thePath, "rb");
|
||||||
#else
|
|
||||||
theFile = fopen(thePath, "r");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (theFile == NULL) /* We failed to open the file. */
|
if (theFile == NULL) /* We failed to open the file. */
|
||||||
{
|
{
|
||||||
|
@ -541,6 +541,10 @@ failure:
|
||||||
FILE *theFile;
|
FILE *theFile;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
#if defined(__MINGW__)
|
||||||
|
return NO;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ([path getFileSystemRepresentation: theRealPath
|
if ([path getFileSystemRepresentation: theRealPath
|
||||||
maxLength: sizeof(theRealPath)-1] == NO)
|
maxLength: sizeof(theRealPath)-1] == NO)
|
||||||
{
|
{
|
||||||
|
@ -568,11 +572,7 @@ failure:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(thePath, theRealPath);
|
strcpy(thePath, theRealPath);
|
||||||
#if defined(__WIN32__)
|
|
||||||
theFile = fopen(thePath, "wb");
|
theFile = fopen(thePath, "wb");
|
||||||
#else
|
|
||||||
theFile = fopen(thePath, "w");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (useAuxiliaryFile)
|
if (useAuxiliaryFile)
|
||||||
|
@ -594,11 +594,7 @@ failure:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the file (whether temp or real) for writing. */
|
/* Open the file (whether temp or real) for writing. */
|
||||||
#if defined(__WIN32__)
|
|
||||||
theFile = fopen(thePath, "wb");
|
theFile = fopen(thePath, "wb");
|
||||||
#else
|
|
||||||
theFile = fopen(thePath, "w");
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (theFile == NULL) /* Something went wrong; we weren't
|
if (theFile == NULL) /* Something went wrong; we weren't
|
||||||
|
|
|
@ -108,7 +108,7 @@ otherTime(NSDate* other)
|
||||||
NSTimeInterval
|
NSTimeInterval
|
||||||
GSTimeNow()
|
GSTimeNow()
|
||||||
{
|
{
|
||||||
#if !defined(__WIN32__)
|
#if !defined(__MINGW__)
|
||||||
volatile NSTimeInterval interval;
|
volatile NSTimeInterval interval;
|
||||||
struct timeval tp;
|
struct timeval tp;
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ GSTimeNow()
|
||||||
t = otherTime(d);
|
t = otherTime(d);
|
||||||
RELEASE(d);
|
RELEASE(d);
|
||||||
return t + sys_time.wMilliseconds / 1000.0;
|
return t + sys_time.wMilliseconds / 1000.0;
|
||||||
#endif /* __WIN32__ */
|
#endif /* __MINGW__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The implementation of NSDate. */
|
/* The implementation of NSDate. */
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
|
|
||||||
#define DIR_enum_state DIR
|
#define DIR_enum_state DIR
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
#define WIN32ERR ((DWORD)0xFFFFFFFF)
|
#define WIN32ERR ((DWORD)0xFFFFFFFF)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
# include <limits.h> /* for PATH_MAX */
|
# include <limits.h> /* for PATH_MAX */
|
||||||
# include <utime.h>
|
# include <utime.h>
|
||||||
#else
|
#else
|
||||||
#ifdef __WIN32__
|
#ifdef __MINGW__
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
# include <sys/utime.h>
|
# include <sys/utime.h>
|
||||||
#else
|
#else
|
||||||
|
@ -206,8 +206,8 @@ static NSFileManager* defaultManager = nil;
|
||||||
{
|
{
|
||||||
const char* cpath = [self fileSystemRepresentationWithPath: path];
|
const char* cpath = [self fileSystemRepresentationWithPath: path];
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
return SetCurrentDirectory(cpath);
|
return SetCurrentDirectory(cpath) == TRUE ? YES : NO;
|
||||||
#else
|
#else
|
||||||
return (chdir(cpath) == 0);
|
return (chdir(cpath) == 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -216,7 +216,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
- (BOOL) createDirectoryAtPath: (NSString*)path
|
- (BOOL) createDirectoryAtPath: (NSString*)path
|
||||||
attributes: (NSDictionary*)attributes
|
attributes: (NSDictionary*)attributes
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
BOOL ok;
|
BOOL ok;
|
||||||
|
|
||||||
ok = CreateDirectory([self fileSystemRepresentationWithPath: path], NULL);
|
ok = CreateDirectory([self fileSystemRepresentationWithPath: path], NULL);
|
||||||
|
@ -321,14 +321,14 @@ static NSFileManager* defaultManager = nil;
|
||||||
while (cur < len);
|
while (cur < len);
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
#endif /* WIN32 */
|
#endif /* !MINGW */
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) currentDirectoryPath
|
- (NSString*) currentDirectoryPath
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
if (GetCurrentDirectory(PATH_MAX, path) > PATH_MAX)
|
if (GetCurrentDirectory(PATH_MAX, path) > PATH_MAX)
|
||||||
return nil;
|
return nil;
|
||||||
#else
|
#else
|
||||||
|
@ -339,7 +339,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
if (getwd(path) == NULL)
|
if (getwd(path) == NULL)
|
||||||
return nil;
|
return nil;
|
||||||
#endif /* HAVE_GETCWD */
|
#endif /* HAVE_GETCWD */
|
||||||
#endif /* WIN32 */
|
#endif /* !MINGW */
|
||||||
|
|
||||||
return [self stringWithFileSystemRepresentation: path length: strlen(path)];
|
return [self stringWithFileSystemRepresentation: path length: strlen(path)];
|
||||||
}
|
}
|
||||||
|
@ -716,7 +716,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
DWORD res;
|
DWORD res;
|
||||||
|
|
||||||
res = GetFileAttributes(cpath);
|
res = GetFileAttributes(cpath);
|
||||||
|
@ -743,7 +743,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
#endif /* WIN32 */
|
#endif /* MINGW */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,7 +755,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
return NO;
|
return NO;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
DWORD res= GetFileAttributes(cpath);
|
DWORD res= GetFileAttributes(cpath);
|
||||||
|
|
||||||
if (res == WIN32ERR)
|
if (res == WIN32ERR)
|
||||||
|
@ -775,7 +775,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
return NO;
|
return NO;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
DWORD res= GetFileAttributes(cpath);
|
DWORD res= GetFileAttributes(cpath);
|
||||||
|
|
||||||
if (res == WIN32ERR)
|
if (res == WIN32ERR)
|
||||||
|
@ -795,7 +795,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
return NO;
|
return NO;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
DWORD res= GetFileAttributes(cpath);
|
DWORD res= GetFileAttributes(cpath);
|
||||||
int len = strlen(cpath);
|
int len = strlen(cpath);
|
||||||
|
|
||||||
|
@ -839,7 +839,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
|
|
||||||
- (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path
|
- (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
long long totalsize, freesize;
|
long long totalsize, freesize;
|
||||||
id values[5];
|
id values[5];
|
||||||
id keys[5] = {
|
id keys[5] = {
|
||||||
|
@ -912,7 +912,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
#else
|
#else
|
||||||
return nil;
|
return nil;
|
||||||
#endif
|
#endif
|
||||||
#endif /* WIN32 */
|
#endif /* MINGW */
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) changeFileAttributes: (NSDictionary*)attributes atPath: (NSString*)path
|
- (BOOL) changeFileAttributes: (NSDictionary*)attributes atPath: (NSString*)path
|
||||||
|
@ -923,7 +923,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
NSDate *date;
|
NSDate *date;
|
||||||
BOOL allOk = YES;
|
BOOL allOk = YES;
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __MINGW__
|
||||||
num = [attributes objectForKey: NSFileOwnerAccountNumber];
|
num = [attributes objectForKey: NSFileOwnerAccountNumber];
|
||||||
if (num)
|
if (num)
|
||||||
{
|
{
|
||||||
|
@ -990,7 +990,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
ASSIGN(_lastError, str);
|
ASSIGN(_lastError, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* __WIN32__ */
|
#endif /* __MINGW__ */
|
||||||
|
|
||||||
num = [attributes objectForKey: NSFilePosixPermissions];
|
num = [attributes objectForKey: NSFilePosixPermissions];
|
||||||
if (num)
|
if (num)
|
||||||
|
@ -1123,7 +1123,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
const char* lpath = [self fileSystemRepresentationWithPath: path];
|
const char* lpath = [self fileSystemRepresentationWithPath: path];
|
||||||
const char* npath = [self fileSystemRepresentationWithPath: otherPath];
|
const char* npath = [self fileSystemRepresentationWithPath: otherPath];
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __MINGW__
|
||||||
return NO;
|
return NO;
|
||||||
#else
|
#else
|
||||||
return (symlink(lpath, npath) == 0);
|
return (symlink(lpath, npath) == 0);
|
||||||
|
@ -1146,7 +1146,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
|
|
||||||
- (const char*) fileSystemRepresentationWithPath: (NSString*)path
|
- (const char*) fileSystemRepresentationWithPath: (NSString*)path
|
||||||
{
|
{
|
||||||
#if 0 && defined(__WIN32__)
|
#if 0 && defined(__MINGW__)
|
||||||
unsigned len = [path length];
|
unsigned len = [path length];
|
||||||
NSMutableData *d = [NSMutableData dataWithLength: len + 5];
|
NSMutableData *d = [NSMutableData dataWithLength: len + 5];
|
||||||
char *fspath = (char*)[d mutableBytes];
|
char *fspath = (char*)[d mutableBytes];
|
||||||
|
|
|
@ -34,15 +34,15 @@
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
/* #include <libc.h>*/
|
/* #include <libc.h>*/
|
||||||
|
|
||||||
#if defined(__WIN32__) && !defined(__CYGWIN__)
|
#if defined(__MINGW__)
|
||||||
#include <Windows32/Sockets.h>
|
#include <winsock.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif /* __WIN32__*/
|
#endif /* !__MINGW__*/
|
||||||
|
|
||||||
#ifndef INADDR_NONE
|
#ifndef INADDR_NONE
|
||||||
#define INADDR_NONE -1
|
#define INADDR_NONE -1
|
||||||
|
|
|
@ -97,7 +97,7 @@ NSLogv (NSString* format, va_list args)
|
||||||
if (_NSLog_printf_handler == NULL)
|
if (_NSLog_printf_handler == NULL)
|
||||||
_NSLog_printf_handler = *_NSLog_standard_printf_handler;
|
_NSLog_printf_handler = *_NSLog_standard_printf_handler;
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
pid = (int)GetCurrentProcessId(),
|
pid = (int)GetCurrentProcessId(),
|
||||||
#else
|
#else
|
||||||
pid = (int)getpid();
|
pid = (int)getpid();
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <base/preface.h>
|
#include <base/preface.h>
|
||||||
#include <Foundation/NSZone.h>
|
#include <Foundation/NSZone.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef __WIN32__
|
#ifndef __MINGW__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
#include <linux/sys.h>
|
#include <linux/sys.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __MINGW__
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
static size_t
|
static size_t
|
||||||
getpagesize(void)
|
getpagesize(void)
|
||||||
|
|
|
@ -184,7 +184,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
|
||||||
i = 0;
|
i = 0;
|
||||||
while (env[i])
|
while (env[i])
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char *cp;
|
char *cp;
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
@ -486,7 +486,7 @@ extern char** _environ;
|
||||||
#undef main
|
#undef main
|
||||||
int main(int argc, char *argv[], char *env[])
|
int main(int argc, char *argv[], char *env[])
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__) && !defined(__CYGWIN__)
|
#if defined(__MINGW__)
|
||||||
WSADATA lpWSAData;
|
WSADATA lpWSAData;
|
||||||
|
|
||||||
// Initialize Windows Sockets
|
// Initialize Windows Sockets
|
||||||
|
@ -495,7 +495,7 @@ int main(int argc, char *argv[], char *env[])
|
||||||
printf("Could not startup Windows Sockets\n");
|
printf("Could not startup Windows Sockets\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif /* __WIN32__ */
|
#endif /* __MINGW__ */
|
||||||
|
|
||||||
#ifdef __MS_WIN32__
|
#ifdef __MS_WIN32__
|
||||||
_MB_init_runtime();
|
_MB_init_runtime();
|
||||||
|
@ -566,7 +566,7 @@ int main(int argc, char *argv[], char *env[])
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
pid = (int)GetCurrentProcessId();
|
pid = (int)GetCurrentProcessId();
|
||||||
#else
|
#else
|
||||||
pid = (int)getpid();
|
pid = (int)getpid();
|
||||||
|
|
|
@ -117,7 +117,7 @@ static Class NSString_class; /* For speed */
|
||||||
#define GSPLUNI 1
|
#define GSPLUNI 1
|
||||||
#include "propList.h"
|
#include "propList.h"
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
static unichar pathSepChar = (unichar)'\\';
|
static unichar pathSepChar = (unichar)'\\';
|
||||||
static NSString *pathSepString = @"\\";
|
static NSString *pathSepString = @"\\";
|
||||||
static NSString *rootPath = @"C:\\";
|
static NSString *rootPath = @"C:\\";
|
||||||
|
@ -138,7 +138,7 @@ pathSeps()
|
||||||
{
|
{
|
||||||
if (myPathSeps == nil)
|
if (myPathSeps == nil)
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/\\"];
|
myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/\\"];
|
||||||
#else
|
#else
|
||||||
myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/"];
|
myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/"];
|
||||||
|
@ -2121,7 +2121,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
|
|
||||||
- (NSString*) stringByResolvingSymlinksInPath
|
- (NSString*) stringByResolvingSymlinksInPath
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
return self;
|
return self;
|
||||||
#else
|
#else
|
||||||
const int MAX_PATH = 1024;
|
const int MAX_PATH = 1024;
|
||||||
|
@ -2268,7 +2268,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
strcpy(new_buf, &new_buf[8]);
|
strcpy(new_buf, &new_buf[8]);
|
||||||
}
|
}
|
||||||
return [NSString stringWithCString: new_buf];
|
return [NSString stringWithCString: new_buf];
|
||||||
#endif /* (__WIN32__) */
|
#endif /* (__MINGW__) */
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) stringByStandardizingPath
|
- (NSString*) stringByStandardizingPath
|
||||||
|
@ -2317,10 +2317,10 @@ handle_printf_atsign (FILE *stream,
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For absolute paths, we must resolve symbolic links or (on win32)
|
* For absolute paths, we must resolve symbolic links or (on MINGW)
|
||||||
* remove '/../' sequences and their matching parent directories.
|
* remove '/../' sequences and their matching parent directories.
|
||||||
*/
|
*/
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
/* Condense `/../' */
|
/* Condense `/../' */
|
||||||
r = NSMakeRange(0, [s length]);
|
r = NSMakeRange(0, [s length]);
|
||||||
while ((r = [s rangeOfCharacterFromSet: pathSeps()
|
while ((r = [s rangeOfCharacterFromSet: pathSeps()
|
||||||
|
@ -2400,7 +2400,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
if ([self length] == 0)
|
if ([self length] == 0)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
if ([self indexOfString: @":"] != NSNotFound)
|
if ([self indexOfString: @":"] != NSNotFound)
|
||||||
return YES;
|
return YES;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -361,9 +361,6 @@ GSCheckTasks()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Declaration from find_exec.c */
|
|
||||||
extern char *objc_find_executable(const char *name);
|
|
||||||
|
|
||||||
- (void) launch
|
- (void) launch
|
||||||
{
|
{
|
||||||
NSMutableArray *toClose;
|
NSMutableArray *toClose;
|
||||||
|
@ -427,29 +424,21 @@ extern char *objc_find_executable(const char *name);
|
||||||
lpath = [base_path stringByAppendingPathComponent: prog];
|
lpath = [base_path stringByAppendingPathComponent: prog];
|
||||||
if ([mgr isExecutableFileAtPath: lpath] == NO)
|
if ([mgr isExecutableFileAtPath: lpath] == NO)
|
||||||
{
|
{
|
||||||
const char *cpath = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Last resort - if the launch path was simply a program name
|
* Last resort - if the launch path was simply a program name
|
||||||
* get objc_find_executable() to try using the PATH environment
|
* get NSBundle to try using the PATH environment
|
||||||
* variable to find the executable.
|
* variable to find the executable.
|
||||||
*/
|
*/
|
||||||
if ([base_path isEqualToString: @""] == YES)
|
if ([base_path isEqualToString: @""] == YES)
|
||||||
{
|
{
|
||||||
|
lpath = [NSBundle _absolutePathOfExecutable: prog];
|
||||||
cpath = objc_find_executable([prog cString]);
|
|
||||||
}
|
}
|
||||||
if (cpath == 0)
|
if (lpath == nil)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"NSTask - launch path (%@) is not valid",
|
format: @"NSTask - launch path (%@) not valid",
|
||||||
_launchPath];
|
_launchPath];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
lpath = [NSString stringWithCString: cpath];
|
|
||||||
OBJC_FREE((void*)cpath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,7 +541,7 @@ extern char *objc_find_executable(const char *name);
|
||||||
setpgrp(getpid(), getpid());
|
setpgrp(getpid(), getpid());
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
pid = (int)GetCurrentProcessId(),
|
pid = (int)GetCurrentProcessId(),
|
||||||
#else
|
#else
|
||||||
pid = (int)getpid();
|
pid = (int)getpid();
|
||||||
|
|
|
@ -254,7 +254,7 @@ gnustep_base_thread_callback()
|
||||||
#ifdef HAVE_USLEEP
|
#ifdef HAVE_USLEEP
|
||||||
usleep (30*60*1000000);
|
usleep (30*60*1000000);
|
||||||
#else
|
#else
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
Sleep (30*60*1000);
|
Sleep (30*60*1000);
|
||||||
#else
|
#else
|
||||||
sleep (30*60);
|
sleep (30*60);
|
||||||
|
@ -269,7 +269,7 @@ gnustep_base_thread_callback()
|
||||||
#ifdef HAVE_USLEEP
|
#ifdef HAVE_USLEEP
|
||||||
usleep ((int)(delay*1000000));
|
usleep ((int)(delay*1000000));
|
||||||
#else
|
#else
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
Sleep (delay*1000);
|
Sleep (delay*1000);
|
||||||
#else
|
#else
|
||||||
sleep ((int)delay);
|
sleep ((int)delay);
|
||||||
|
|
|
@ -115,7 +115,7 @@ NSHomeDirectory(void)
|
||||||
NSString *
|
NSString *
|
||||||
NSHomeDirectoryForUser(NSString *login_name)
|
NSHomeDirectoryForUser(NSString *login_name)
|
||||||
{
|
{
|
||||||
#if !defined(__WIN32__)
|
#if !defined(__MINGW__)
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
[gnustep_global_lock lock];
|
[gnustep_global_lock lock];
|
||||||
|
@ -140,12 +140,14 @@ NSHomeDirectoryForUser(NSString *login_name)
|
||||||
s = [NSString stringWithCString: nb];
|
s = [NSString stringWithCString: nb];
|
||||||
NSZoneFree(NSDefaultMallocZone(), nb);
|
NSZoneFree(NSDefaultMallocZone(), nb);
|
||||||
}
|
}
|
||||||
else
|
else if (n > 0)
|
||||||
{
|
{
|
||||||
/* null terminate it and return the string */
|
/* null terminate it and return the string */
|
||||||
buf[n] = '\0';
|
buf[n] = '\0';
|
||||||
s = [NSString stringWithCString: buf];
|
s = [NSString stringWithCString: buf];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
s = NSOpenStepRootDirectory();
|
||||||
[gnustep_global_lock unlock];
|
[gnustep_global_lock unlock];
|
||||||
return s;
|
return s;
|
||||||
#endif
|
#endif
|
||||||
|
@ -289,7 +291,7 @@ NSOpenStepRootDirectory(void)
|
||||||
objectForKey: @"GNUSTEP_ROOT"];
|
objectForKey: @"GNUSTEP_ROOT"];
|
||||||
|
|
||||||
if (root == nil)
|
if (root == nil)
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
root = @"C:\\";
|
root = @"C:\\";
|
||||||
#else
|
#else
|
||||||
root = @"/";
|
root = @"/";
|
||||||
|
|
|
@ -37,14 +37,14 @@
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif /* _AIX */
|
#endif /* _AIX */
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __MINGW__
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif /* !__WIN32__ */
|
#endif /* !__MINGW__ */
|
||||||
|
|
||||||
/* For IRIX machines, which don't define this */
|
/* For IRIX machines, which don't define this */
|
||||||
#ifndef IPPORT_USERRESERVED
|
#ifndef IPPORT_USERRESERVED
|
||||||
|
@ -262,11 +262,11 @@ static NSMapTable *port_number_2_in_port = NULL;
|
||||||
{
|
{
|
||||||
if (_is_valid)
|
if (_is_valid)
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__MINGW__)
|
||||||
closesocket (_port_socket);
|
closesocket (_port_socket);
|
||||||
#else
|
#else
|
||||||
close (_port_socket);
|
close (_port_socket);
|
||||||
#endif /* __WIN32__ */
|
#endif /* __MINGW__ */
|
||||||
[super invalidate];
|
[super invalidate];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
#include <Foundation/NSHost.h>
|
#include <Foundation/NSHost.h>
|
||||||
#include <Foundation/NSByteOrder.h>
|
#include <Foundation/NSByteOrder.h>
|
||||||
|
|
||||||
#if defined(__WIN32__) && !defined(__CYGWIN__)
|
#if defined(__MINGW__)
|
||||||
#include <Windows32/Sockets.h>
|
#include <winsock.h>
|
||||||
#else
|
#else
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#endif /* __WIN32__ */
|
#endif /* __MINGW__ */
|
||||||
|
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
|
@ -1,241 +0,0 @@
|
||||||
/*
|
|
||||||
find_exec.c - routine to find the executable path
|
|
||||||
|
|
||||||
From the dld distribution -- copyrighted below.
|
|
||||||
Modified by Adam Fedor - traverse links
|
|
||||||
|
|
||||||
Given a filename, objc_find_executable searches the directories listed in
|
|
||||||
environment variable PATH for a file with that filename.
|
|
||||||
A new copy of the complete path name of that file is returned. This new
|
|
||||||
string may be disposed by free() later on.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This file is part of DLD, a dynamic link/unlink editor for C.
|
|
||||||
|
|
||||||
Copyright (C) 1990 by W. Wilson Ho.
|
|
||||||
|
|
||||||
The author can be reached electronically by how@cs.ucdavis.edu or
|
|
||||||
through physical mail at:
|
|
||||||
|
|
||||||
W. Wilson Ho
|
|
||||||
Division of Computer Science
|
|
||||||
University of California at Davis
|
|
||||||
Davis, CA 95616
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This program is free software; you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation; either version 1, or (at your option) any
|
|
||||||
later version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
#include <limits.h>
|
|
||||||
#define S_IFLNK 0120000
|
|
||||||
int readlink(char *path, char *buf, int bufsiz) { return (-1); }
|
|
||||||
int lstat(char *path, struct stat *buf) { return (-1); }
|
|
||||||
#define MAXPATHLEN 255
|
|
||||||
#else
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif /* __WIN32__ */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define DEFAULT_PATH ".:~/bin::/usr/local/bin:/usr/new:/usr/ucb:/usr/bin:/bin:/usr/hosts"
|
|
||||||
|
|
||||||
#if defined(__WIN32__) || defined(_WIN32)
|
|
||||||
#define PATH_SEPARATOR ';'
|
|
||||||
#define PATH_COMPONENT "\\"
|
|
||||||
#else
|
|
||||||
#define PATH_SEPARATOR ':'
|
|
||||||
#define PATH_COMPONENT "/"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ABSOLUTE_FILENAME_P (fname): True if fname is an absolute filename */
|
|
||||||
#if defined(atarist) || defined(__WIN32__) || defined(_WIN32)
|
|
||||||
#define ABSOLUTE_FILENAME_P(fname) ((fname[0] == '/') || \
|
|
||||||
(fname[0] && (fname[1] == ':')))
|
|
||||||
#else
|
|
||||||
#define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/')
|
|
||||||
#endif /* atarist */
|
|
||||||
|
|
||||||
static char *
|
|
||||||
copy_of (s)
|
|
||||||
register char *s;
|
|
||||||
{
|
|
||||||
register char *p = (char *) malloc (strlen(s)+1);
|
|
||||||
|
|
||||||
if (!p) return 0;
|
|
||||||
|
|
||||||
*p = 0;
|
|
||||||
strcpy (p, s);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
find_full_path(char *path)
|
|
||||||
{
|
|
||||||
struct stat statbuf;
|
|
||||||
|
|
||||||
if ( stat(path, &statbuf) != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if ( (lstat(path, &statbuf) == 0)
|
|
||||||
&& (statbuf.st_mode & S_IFLNK) == S_IFLNK) {
|
|
||||||
char link[MAXPATHLEN+1];
|
|
||||||
int cc;
|
|
||||||
cc = readlink(path, link, MAXPATHLEN);
|
|
||||||
if (cc == -1)
|
|
||||||
return -1;
|
|
||||||
link[cc] = '\0';
|
|
||||||
if (ABSOLUTE_FILENAME_P(link)) {
|
|
||||||
strcpy(path, link);
|
|
||||||
} else if (strlen(path)+strlen(link) < MAXPATHLEN) {
|
|
||||||
char *p;
|
|
||||||
p = strrchr(path, '/');
|
|
||||||
if (p)
|
|
||||||
*(p+1) = '\0';
|
|
||||||
strcat(path, link);
|
|
||||||
} else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
objc_find_executable (const char *file)
|
|
||||||
{
|
|
||||||
char *search;
|
|
||||||
register char *p;
|
|
||||||
int cwd_in_path = 0;
|
|
||||||
|
|
||||||
if (ABSOLUTE_FILENAME_P(file)) {
|
|
||||||
search = copy_of(file);
|
|
||||||
find_full_path(search);
|
|
||||||
return search;
|
|
||||||
/*
|
|
||||||
return copy_of (file);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((search = (char *) getenv("PATH")) == 0)
|
|
||||||
search = DEFAULT_PATH;
|
|
||||||
|
|
||||||
p = search;
|
|
||||||
|
|
||||||
while (*p) {
|
|
||||||
char name[MAXPATHLEN];
|
|
||||||
register char *next;
|
|
||||||
|
|
||||||
next = name;
|
|
||||||
|
|
||||||
/* copy directory name into [name] */
|
|
||||||
while (*p && *p != PATH_SEPARATOR) *next++ = *p++;
|
|
||||||
*next = 0;
|
|
||||||
if (*p) p++;
|
|
||||||
|
|
||||||
if (name[0] == '.' && name[1] == 0) {
|
|
||||||
#ifdef HAVE_GETCWD
|
|
||||||
getcwd (name, MAXPATHLEN);
|
|
||||||
#else
|
|
||||||
getwd (name);
|
|
||||||
#endif
|
|
||||||
cwd_in_path = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcat (name, PATH_COMPONENT);
|
|
||||||
strcat (name, file);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (access (name, X_OK) == 0)
|
|
||||||
*/
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
|
|
||||||
/* Also add common executable extensions on windows */
|
|
||||||
#if defined(__WIN32__) || defined(_WIN32)
|
|
||||||
{
|
|
||||||
int fl = strlen(name);
|
|
||||||
|
|
||||||
strcat (name, ".com");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".exe");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".bat");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".cmd");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
If '.' not in PATH, check this too
|
|
||||||
*/
|
|
||||||
if (!cwd_in_path) {
|
|
||||||
char name[MAXPATHLEN];
|
|
||||||
|
|
||||||
#ifdef HAVE_GETCWD
|
|
||||||
getcwd (name, MAXPATHLEN);
|
|
||||||
#else
|
|
||||||
getwd (name);
|
|
||||||
#endif
|
|
||||||
strcat (name, PATH_COMPONENT);
|
|
||||||
strcat (name, file);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (access (name, X_OK) == 0)
|
|
||||||
*/
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
|
|
||||||
/* Also add common executable extensions on windows */
|
|
||||||
#if defined(__WIN32__) || defined(_WIN32)
|
|
||||||
{
|
|
||||||
int fl = strlen(name);
|
|
||||||
|
|
||||||
strcat (name, ".com");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".exe");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".bat");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".cmd");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,241 +0,0 @@
|
||||||
/*
|
|
||||||
find_exec.c - routine to find the executable path
|
|
||||||
|
|
||||||
From the dld distribution -- copyrighted below.
|
|
||||||
Modified by Adam Fedor - traverse links
|
|
||||||
|
|
||||||
Given a filename, objc_find_executable searches the directories listed in
|
|
||||||
environment variable PATH for a file with that filename.
|
|
||||||
A new copy of the complete path name of that file is returned. This new
|
|
||||||
string may be disposed by free() later on.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This file is part of DLD, a dynamic link/unlink editor for C.
|
|
||||||
|
|
||||||
Copyright (C) 1990 by W. Wilson Ho.
|
|
||||||
|
|
||||||
The author can be reached electronically by how@cs.ucdavis.edu or
|
|
||||||
through physical mail at:
|
|
||||||
|
|
||||||
W. Wilson Ho
|
|
||||||
Division of Computer Science
|
|
||||||
University of California at Davis
|
|
||||||
Davis, CA 95616
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This program is free software; you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation; either version 1, or (at your option) any
|
|
||||||
later version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
#include <limits.h>
|
|
||||||
#define S_IFLNK 0120000
|
|
||||||
int readlink(char *path, char *buf, int bufsiz) { return (-1); }
|
|
||||||
int lstat(char *path, struct stat *buf) { return (-1); }
|
|
||||||
#define MAXPATHLEN 255
|
|
||||||
#else
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif /* __WIN32__ */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define DEFAULT_PATH ".:~/bin::/usr/local/bin:/usr/new:/usr/ucb:/usr/bin:/bin:/usr/hosts"
|
|
||||||
|
|
||||||
#if defined(__WIN32__) || defined(_WIN32)
|
|
||||||
#define PATH_SEPARATOR ';'
|
|
||||||
#define PATH_COMPONENT "\\"
|
|
||||||
#else
|
|
||||||
#define PATH_SEPARATOR ':'
|
|
||||||
#define PATH_COMPONENT "/"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ABSOLUTE_FILENAME_P (fname): True if fname is an absolute filename */
|
|
||||||
#if defined(atarist) || defined(__WIN32__) || defined(_WIN32)
|
|
||||||
#define ABSOLUTE_FILENAME_P(fname) ((fname[0] == '/') || \
|
|
||||||
(fname[0] && (fname[1] == ':')))
|
|
||||||
#else
|
|
||||||
#define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/')
|
|
||||||
#endif /* atarist */
|
|
||||||
|
|
||||||
static char *
|
|
||||||
copy_of (s)
|
|
||||||
register char *s;
|
|
||||||
{
|
|
||||||
register char *p = (char *) malloc (strlen(s)+1);
|
|
||||||
|
|
||||||
if (!p) return 0;
|
|
||||||
|
|
||||||
*p = 0;
|
|
||||||
strcpy (p, s);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
find_full_path(char *path)
|
|
||||||
{
|
|
||||||
struct stat statbuf;
|
|
||||||
|
|
||||||
if ( stat(path, &statbuf) != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if ( (lstat(path, &statbuf) == 0)
|
|
||||||
&& (statbuf.st_mode & S_IFLNK) == S_IFLNK) {
|
|
||||||
char link[MAXPATHLEN+1];
|
|
||||||
int cc;
|
|
||||||
cc = readlink(path, link, MAXPATHLEN);
|
|
||||||
if (cc == -1)
|
|
||||||
return -1;
|
|
||||||
link[cc] = '\0';
|
|
||||||
if (ABSOLUTE_FILENAME_P(link)) {
|
|
||||||
strcpy(path, link);
|
|
||||||
} else if (strlen(path)+strlen(link) < MAXPATHLEN) {
|
|
||||||
char *p;
|
|
||||||
p = strrchr(path, '/');
|
|
||||||
if (p)
|
|
||||||
*(p+1) = '\0';
|
|
||||||
strcat(path, link);
|
|
||||||
} else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
objc_find_executable (const char *file)
|
|
||||||
{
|
|
||||||
char *search;
|
|
||||||
register char *p;
|
|
||||||
int cwd_in_path = 0;
|
|
||||||
|
|
||||||
if (ABSOLUTE_FILENAME_P(file)) {
|
|
||||||
search = copy_of(file);
|
|
||||||
find_full_path(search);
|
|
||||||
return search;
|
|
||||||
/*
|
|
||||||
return copy_of (file);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((search = (char *) getenv("PATH")) == 0)
|
|
||||||
search = DEFAULT_PATH;
|
|
||||||
|
|
||||||
p = search;
|
|
||||||
|
|
||||||
while (*p) {
|
|
||||||
char name[MAXPATHLEN];
|
|
||||||
register char *next;
|
|
||||||
|
|
||||||
next = name;
|
|
||||||
|
|
||||||
/* copy directory name into [name] */
|
|
||||||
while (*p && *p != PATH_SEPARATOR) *next++ = *p++;
|
|
||||||
*next = 0;
|
|
||||||
if (*p) p++;
|
|
||||||
|
|
||||||
if (name[0] == '.' && name[1] == 0) {
|
|
||||||
#ifdef HAVE_GETCWD
|
|
||||||
getcwd (name, MAXPATHLEN);
|
|
||||||
#else
|
|
||||||
getwd (name);
|
|
||||||
#endif
|
|
||||||
cwd_in_path = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcat (name, PATH_COMPONENT);
|
|
||||||
strcat (name, file);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (access (name, X_OK) == 0)
|
|
||||||
*/
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
|
|
||||||
/* Also add common executable extensions on windows */
|
|
||||||
#if defined(__WIN32__) || defined(_WIN32)
|
|
||||||
{
|
|
||||||
int fl = strlen(name);
|
|
||||||
|
|
||||||
strcat (name, ".com");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".exe");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".bat");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".cmd");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
If '.' not in PATH, check this too
|
|
||||||
*/
|
|
||||||
if (!cwd_in_path) {
|
|
||||||
char name[MAXPATHLEN];
|
|
||||||
|
|
||||||
#ifdef HAVE_GETCWD
|
|
||||||
getcwd (name, MAXPATHLEN);
|
|
||||||
#else
|
|
||||||
getwd (name);
|
|
||||||
#endif
|
|
||||||
strcat (name, PATH_COMPONENT);
|
|
||||||
strcat (name, file);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (access (name, X_OK) == 0)
|
|
||||||
*/
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
|
|
||||||
/* Also add common executable extensions on windows */
|
|
||||||
#if defined(__WIN32__) || defined(_WIN32)
|
|
||||||
{
|
|
||||||
int fl = strlen(name);
|
|
||||||
|
|
||||||
strcat (name, ".com");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".exe");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".bat");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
|
|
||||||
strcat (name, ".cmd");
|
|
||||||
if (find_full_path (name) == 0)
|
|
||||||
return copy_of (name);
|
|
||||||
name[fl] = '\0';
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue