+2004-09-05 Helge Hess <helge.hess@opengroupware.org>
+
+ * WOResourceRequestHandler.m: added some debug logging, send a 404
+ instead of a 500 if a resource could not be found (v4.3.25)
+
2004-09-02 Helge Hess <helge.hess@opengroupware.org>
* wo*.make: when copying bundles to the install location, ensure that
# version file
-SUBMINOR_VERSION:=24
+SUBMINOR_VERSION:=25
# v4.2.413 requires libSaxObjC v4.2.33
# v4.2.341 requires libNGExtensions v4.2.77
/*
- Copyright (C) 2000-2003 SKYRIX Software AG
+ Copyright (C) 2000-2004 SKYRIX Software AG
- This file is part of OGo
+ This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include <NGObjWeb/WORequestHandler.h>
@implementation WOResourceRequestHandler
+static BOOL debugOn = NO;
+
+ (int)version {
return [super version] + 0 /* v2 */;
}
NSString *resourcePath;
NSData *data;
+ if (debugOn) [self logWithFormat:@"handle WS request: %@", _request];
+
if (_request == nil) return nil;
*(&app) = [WOApplication application];
/* check for WebServerResources requests ... */
- if ([handlerPath count] < 1)
+ if ([handlerPath count] < 1) {
+ if (debugOn) [self logWithFormat:@"path to short: '%@'", handlerPath];
return nil;
+ }
+ if (debugOn) [self logWithFormat:@" check path: '%@'", handlerPath];
/* ok, found a resource request */
pathForResourceNamed:resourceName
inFramework:nil
languages:languages];
+ if (debugOn) [self logWithFormat:@" resource path: '%@'", resourcePath];
- data = resourcePath
+ data = (resourcePath != nil)
? [NSData dataWithContentsOfFile:resourcePath]
: nil;
if (data == nil) {
response = [WOResponse responseWithRequest:_request];
[response setStatus:404]; /* not found */
- return nil;
+ [response setHeader:@"text/html" forKey:@"content-type"];
+ [response appendContentString:@"<h3>Resource not found</h3><pre>"];
+ [response appendContentHTMLString:@"Name: "];
+ [response appendContentHTMLString:resourceName];
+ [response appendContentHTMLString:@"\nLanguages: "];
+ [response appendContentHTMLString:[languages description]];
+ [response appendContentHTMLString:@"\nResourceManager: "];
+ [response appendContentHTMLString:[[app resourceManager] description]];
+ [response appendContentString:@"</pre>"];
+ return response;
}
//NSLog(@"shall deliver %@", resourcePath);
- (WOResponse *)handleRequest:(WORequest *)_request {
NSArray *handlerPath = nil;
+ if (debugOn) [self logWithFormat:@"handle request: %@", _request];
+
if ([[_request requestHandlerKey] isEqualToString:@"WebServerResources"])
return [self _handleWebServerResourcesRequest:_request];
#include <unistd.h>
#include <sys/stat.h>
-#if LIB_FOUNDATION_LIBRARY
-# import <Foundation/exceptions/GeneralExceptions.h>
-#endif
-
#if NeXT_Foundation_LIBRARY
# include <NGExtensions/NGObjectMacros.h>
# include <NGExtensions/NSString+Ext.h>
+2004-09-05 Helge Hess <helge.hess@opengroupware.org>
+
+ * v4.3.112
+
+ * NGBundleManager.m: code cleanups, added -setBundleSearchPaths: and
+ -bundleSearchPaths to allow bundle path modifications from code
+
+ * NGHashMap.m: removed libFoundation specific exception handling, the
+ same exceptions are now thrown for all runtimes
+
2004-08-30 Helge Hess <helge.hess@opengroupware.org>
* NGBundleManager.m: fixed yet another bug in NGBundleManager path
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id: NGBundleManager.m 4 2004-08-20 17:04:31Z helge $
#include "NGBundleManager.h"
#include "common.h"
# include <NGExtensions/NGPropertyListParser.h>
#endif
+#if LIB_FOUNDATION_LIBRARY
+@interface NSBundle(UsedPrivates)
++ (BOOL)isFlattenedDirLayout;
+@end
+#endif
+
#if NeXT_RUNTIME || APPLE_RUNTIME
#include <objc/objc-runtime.h>
bundle = [manager bundleForClassNamed:[NSString stringWithCString:_name]];
if (bundle) {
- //NSLog(@"%s: found bundle %@", __PRETTY_FUNCTION__, [bundle bundlePath]);
+#if 0
+ NSLog(@"%s: found bundle %@", __PRETTY_FUNCTION__, [bundle bundlePath]);
+#endif
if ([manager loadBundle:bundle]) {
Class clazz;
static NGBundleManager *defaultManager = nil;
static BOOL debugOn = NO;
+#if defined(__MINGW32__)
+static NSString *NGEnvVarPathSeparator = @";";
+#else
+static NSString *NGEnvVarPathSeparator = @":";
+#endif
+
+ (void)initialize {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
return defaultManager;
}
-- (void)_setupBundleSearchPathes {
- NSProcessInfo *pi;
- NSUserDefaults *ud;
- id paths;
- NSString *path;
+/* setup bundle search path */
- pi = [NSProcessInfo processInfo];
+- (void)_addMainBundlePathToPathArray:(NSMutableArray *)_paths {
+ NSProcessInfo *pi;
+ NSString *path;
- /* setup bundle search path */
-
- self->bundleSearchPaths = [[NSMutableArray alloc] init];
-
- // first add main-bundle path
+ pi = [NSProcessInfo processInfo];
+ path = [[pi arguments] objectAtIndex:0];
+ path = [path stringByDeletingLastPathComponent];
- path = [[[pi arguments] objectAtIndex:0] stringByDeletingLastPathComponent];
if ([path isEqual:@""])
- path = @".";
+ path = @".";
#if WITH_GNUSTEP
else {
- /* The path is the complete path to the executable, including the
- processor, the OS and the library combo. Strip these directories
- from the main bundle's path. */
- path = [[[path stringByDeletingLastPathComponent]
- stringByDeletingLastPathComponent]
- stringByDeletingLastPathComponent];
+ // TODO: to be correct this would need to read the bundle-info
+ // NSExecutable?!
+ /*
+ The path is the complete path to the executable, including the
+ processor, the OS and the library combo. Strip these directories
+ from the main bundle's path.
+ */
+#if LIB_FOUNDATION_LIBRARY
+ if (![NSBundle isFlattenedDirLayout])
+#endif
+ path = [[[path stringByDeletingLastPathComponent]
+ stringByDeletingLastPathComponent]
+ stringByDeletingLastPathComponent];
}
#endif
- [self->bundleSearchPaths addObject:path];
-
- // look into NGBundlePath default
-
+ [_paths addObject:path];
+}
+
+- (void)_addBundlePathDefaultToPathArray:(NSMutableArray *)_paths {
+ NSUserDefaults *ud;
+ id paths;
+
if ((ud = [NSUserDefaults standardUserDefaults]) == nil) {
// got this with gstep-base during the port, apparently it happens
// if the bundle manager is created inside the setup process of
abort();
#endif
}
-
- paths = [ud arrayForKey:@"NGBundlePath"];
- if (paths == nil) {
- paths = [ud stringForKey:@"NGBundlePath"];
- if (paths) {
-#if defined(__MINGW32__)
- paths = [paths componentsSeparatedByString:@";"];
-#else
- paths = [paths componentsSeparatedByString:@":"];
-#endif
- }
+
+ if ((paths = [ud arrayForKey:@"NGBundlePath"]) == nil) {
+ if ((paths = [ud stringForKey:@"NGBundlePath"]) != nil)
+ paths = [paths componentsSeparatedByString:NGEnvVarPathSeparator];
}
- if (paths)
- [self->bundleSearchPaths addObjectsFromArray:paths];
+ if (paths != nil)
+ [_paths addObjectsFromArray:paths];
else if (debugOn)
NSLog(@"Note: NGBundlePath default is not configured.");
-
- /* look into environment */
+}
+- (void)_addEnvironmentPathToPathArray:(NSMutableArray *)_paths {
+ NSProcessInfo *pi;
+ id paths;
+
+ pi = [NSProcessInfo processInfo];
paths = [[pi environment] objectForKey:@"NGBundlePath"];
- if (paths) {
-#if defined(__MINGW32__)
- paths = [paths componentsSeparatedByString:@";"];
-#else
- paths = [paths componentsSeparatedByString:@":"];
-#endif
- }
- if (paths) [self->bundleSearchPaths addObjectsFromArray:paths];
+ if (paths)
+ paths = [paths componentsSeparatedByString:NGEnvVarPathSeparator];
+ if (paths) [_paths addObjectsFromArray:paths];
+}
- /* add standard bundle paths */
- {
+- (void)_addGNUstepPathsToPathArray:(NSMutableArray *)_paths {
#if !GNUSTEP
#else
- // TODO: whats that supposed to do?
- // TODO: replace with proper path locator function!
- NSDictionary *env;
- NSString *p;
- unsigned i, count;
- id tmp;
+ // TODO: whats that supposed to do?
+ // TODO: replace with proper path locator function!
+ NSDictionary *env;
+ NSString *p;
+ unsigned i, count;
+ id tmp;
- env = [[NSProcessInfo processInfo] environment];
+ env = [[NSProcessInfo processInfo] environment];
- if ((tmp = [env objectForKey:@"GNUSTEP_PATHPREFIX_LIST"]) == nil)
- tmp = [env objectForKey:@"GNUSTEP_PATHLIST"];
- tmp = [tmp componentsSeparatedByString:@":"];
+ if ((tmp = [env objectForKey:@"GNUSTEP_PATHPREFIX_LIST"]) == nil)
+ tmp = [env objectForKey:@"GNUSTEP_PATHLIST"];
+ tmp = [tmp componentsSeparatedByString:@":"];
- for (i = 0, count = [tmp count]; i < count; i++) {
- p = [tmp objectAtIndex:i];
- p = [p stringByAppendingPathComponent:@"Library"];
- p = [p stringByAppendingPathComponent:@"Bundles"];
- if ([self->bundleSearchPaths containsObject:p]) continue;
+ for (i = 0, count = [tmp count]; i < count; i++) {
+ p = [tmp objectAtIndex:i];
+ p = [p stringByAppendingPathComponent:@"Library"];
+ p = [p stringByAppendingPathComponent:@"Bundles"];
+ if ([self->bundleSearchPaths containsObject:p]) continue;
- if (p) [self->bundleSearchPaths addObject:p];
- }
-#endif
+ if (p) [self->bundleSearchPaths addObject:p];
}
+#endif
+}
+
+- (void)_setupBundleSearchPathes {
+ NSProcessInfo *pi;
+
+ pi = [NSProcessInfo processInfo];
+
+ /* setup bundle search path */
+
+ self->bundleSearchPaths = [[NSMutableArray alloc] initWithCapacity:16];
+
+ [self _addMainBundlePathToPathArray:self->bundleSearchPaths];
+ [self _addBundlePathDefaultToPathArray:self->bundleSearchPaths];
+ [self _addEnvironmentPathToPathArray:self->bundleSearchPaths];
+ [self _addGNUstepPathsToPathArray:self->bundleSearchPaths];
#if DEBUG && NeXT_Foundation_LIBRARY && 0
NSLog(@"%s: bundle search pathes:\n%@", __PRETTY_FUNCTION__,
[super dealloc];
}
+/* accessors */
+
+- (void)setBundleSearchPaths:(NSArray *)_paths {
+ ASSIGNCOPY(self->bundleSearchPaths, _paths);
+}
+- (NSArray *)bundleSearchPaths {
+ return self->bundleSearchPaths;
+}
+
/* registering bundles */
- (void)registerBundle:(NSBundle *)_bundle
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#ifndef __NGExtensions_NGBundleManager_H__
#define __NGExtensions_NGBundleManager_H__
+ (id)defaultBundleManager;
-/*
- * bundle access
- */
+/* accessors */
+
+- (void)setBundleSearchPaths:(NSArray *)_paths;
+- (NSArray *)bundleSearchPaths;
+
+/* bundle access */
- (NSBundle *)bundleWithName:(NSString *)name type:(NSString *)_type;
- (NSBundle *)bundleWithName:(NSString *)name; // type=='bundle'
- (NSBundle *)bundleForClass:(Class)aClass;
- (NSBundle *)bundleWithPath:(NSString *)path;
-/*
- * dependencies
- */
+/* dependencies */
/* returns the names of the bundles required by the bundle */
- (NSArray *)bundlesRequiredByBundle:(NSBundle *)_bundle;
/* returns the names of the classes required by the bundle */
- (NSArray *)classesRequiredByBundle:(NSBundle *)_bundle;
-/*
- * loading
- */
+/* loading */
- (id)loadBundle:(NSBundle *)_bundle;
-/*
- * bundle manager object
- */
+/* bundle manager object */
- (id)principalObjectOfBundle:(NSBundle *)_bundle;
-/*
- * resources
- */
+/* resources */
- (NSDictionary *)configForResource:(id)_resource ofType:(NSString *)_type
providedByBundle:(NSBundle *)_bundle;
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: NGHashMap.m 4 2004-08-20 17:04:31Z helge $
#include "NGHashMap.h"
#include "common.h"
-#if LIB_FOUNDATION_LIBRARY
-# import <extensions/exceptions/GeneralExceptions.h>
-#endif
-
#if !LIB_FOUNDATION_LIBRARY
@interface NSException(SetUI) /* allowed on Jaguar ? */
- (void)setUserInfo:(NSDictionary *)_ui;
return nil;
if ((_index < list->count) == 0) {
-#if LIB_FOUNDATION_LIBRARY
- NSException *exc = [[IndexOutOfRangeException alloc]
- initForSize:list->count index:_index];
- [exc setUserInfo:
- [NSDictionary dictionaryWithObject:self forKey:@"object"]];
- [exc raise];
-#else
[NSException raise:NSRangeException
format:@"index %d out of range for key %@ of length %d",
_index, _key, list->count];
-#endif
+ return nil;
}
while (_index--)
checkForAddErrorMessage(self, _objects[0],_key);
if ((root = [self __structForKey:_key]) == NULL) {
if (_index > 0) {
-#if LIB_FOUNDATION_LIBRARY
- NSException *exc = [[IndexOutOfRangeException alloc]
- initForSize:0 index:_index];
- [exc setUserInfo:[NSDictionary dictionaryWithObject:self forKey:@"map"]];
- [exc raise];
-#else
[NSException raise:NSRangeException
format:@"index %d out of range in map 0x%08X",
_index, self];
-#endif
+ return;
}
root = initLListElement(_objects[0], NULL);
}
else {
if (!(_index < root->count)) {
-#if LIB_FOUNDATION_LIBRARY
- NSException *exc = [[IndexOutOfRangeException alloc]
- initForSize:root->count index:_index];
- [exc setUserInfo:[NSDictionary dictionaryWithObject:self forKey:@"map"]];
- [exc raise];
-#else
[NSException raise:NSRangeException
format:@"index %d out of range in map 0x%08X length %d",
_index, self, root->count];
-#endif
+ return;
}
root->count += _count;
-# $Id$
+# version
-SUBMINOR_VERSION:=111
+SUBMINOR_VERSION:=112
# v4.2.72 requires libEOControl v4.2.39
/*
- Copyright (C) 2000-2003 SKYRIX Software AG
+ Copyright (C) 2000-2004 SKYRIX Software AG
- This file is part of OGo
+ This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#ifndef __NGExtensions_common_h__
#define __NGExtensions_common_h__
# import <objc/objc.h>
# import <objc/encoding.h>
# import <extensions/objc-runtime.h>
-# import <extensions/exceptions/GeneralExceptions.h>
#endif
#ifndef ASSIGN