1998-11-23 21:40:54 +00:00
|
|
|
/* This tool builds a cache of service specifications like the
|
|
|
|
NeXTstep/ OPENSTEP 'make_services' tool. In addition it builds a list of
|
|
|
|
applications and services-bundles found in the standard directories.
|
|
|
|
|
1998-11-23 15:03:41 +00:00
|
|
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Created: November 1998
|
|
|
|
|
1999-02-04 13:06:58 +00:00
|
|
|
This file is part of the GNUstep Project
|
1998-11-23 15:03:41 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
1999-02-04 13:06:58 +00:00
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1998-11-23 15:03:41 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Foundation/NSArray.h>
|
1999-05-06 08:46:03 +00:00
|
|
|
#include <Foundation/NSBundle.h>
|
1998-11-23 15:03:41 +00:00
|
|
|
#include <Foundation/NSDictionary.h>
|
|
|
|
#include <Foundation/NSFileManager.h>
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
#include <Foundation/NSProcessInfo.h>
|
|
|
|
#include <Foundation/NSData.h>
|
|
|
|
#include <Foundation/NSDebug.h>
|
1998-12-01 20:54:23 +00:00
|
|
|
#include <Foundation/NSDistributedLock.h>
|
1998-11-23 15:03:41 +00:00
|
|
|
#include <Foundation/NSAutoreleasePool.h>
|
|
|
|
#include <Foundation/NSSerialization.h>
|
|
|
|
|
|
|
|
static void scanDirectory(NSMutableDictionary *services, NSString *path);
|
1998-12-01 20:54:23 +00:00
|
|
|
static void scanDynamic(NSMutableDictionary *services, NSString *path);
|
1998-11-23 15:03:41 +00:00
|
|
|
static NSMutableArray *validateEntry(id svcs, NSString* path);
|
|
|
|
static NSMutableDictionary *validateService(NSDictionary *service, NSString* path, unsigned i);
|
|
|
|
|
1998-12-01 20:54:23 +00:00
|
|
|
static NSString *appsName = @".GNUstepAppList";
|
1998-11-23 15:03:41 +00:00
|
|
|
static NSString *cacheName = @".GNUstepServices";
|
|
|
|
|
|
|
|
static BOOL verbose = NO;
|
|
|
|
static NSMutableDictionary *serviceMap;
|
|
|
|
static NSMutableDictionary *filterMap;
|
|
|
|
static NSMutableDictionary *printMap;
|
|
|
|
static NSMutableDictionary *spellMap;
|
1998-11-23 21:40:54 +00:00
|
|
|
static NSMutableDictionary *applicationMap;
|
1999-01-07 13:04:21 +00:00
|
|
|
static NSMutableDictionary *extensionsMap;
|
|
|
|
|
|
|
|
static Class aClass;
|
|
|
|
static Class dClass;
|
|
|
|
static Class sClass;
|
1998-11-23 15:03:41 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
NSData *data;
|
|
|
|
NSProcessInfo *proc;
|
|
|
|
NSFileManager *mgr;
|
|
|
|
NSDictionary *env;
|
|
|
|
NSMutableDictionary *services;
|
|
|
|
NSMutableArray *roots;
|
|
|
|
NSArray *args;
|
|
|
|
NSArray *locations;
|
|
|
|
NSString *usrRoot;
|
|
|
|
NSString *str;
|
|
|
|
unsigned index;
|
|
|
|
BOOL isDir;
|
1999-06-02 07:14:45 +00:00
|
|
|
BOOL usedPrefixes = NO;
|
1998-11-23 15:03:41 +00:00
|
|
|
NSMutableDictionary *fullMap;
|
1998-12-01 20:54:23 +00:00
|
|
|
NSDictionary *oldMap;
|
1998-11-23 15:03:41 +00:00
|
|
|
|
|
|
|
pool = [NSAutoreleasePool new];
|
|
|
|
|
1999-01-07 13:04:21 +00:00
|
|
|
aClass = [NSArray class];
|
|
|
|
dClass = [NSDictionary class];
|
|
|
|
sClass = [NSString class];
|
|
|
|
|
1998-11-23 15:03:41 +00:00
|
|
|
proc = [NSProcessInfo processInfo];
|
|
|
|
if (proc == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"unable to get process information!\n");
|
|
|
|
[pool release];
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
1998-12-07 11:58:44 +00:00
|
|
|
[NSSerializer shouldBeCompact: YES];
|
|
|
|
|
1998-11-23 15:03:41 +00:00
|
|
|
serviceMap = [NSMutableDictionary dictionaryWithCapacity: 64];
|
|
|
|
filterMap = [NSMutableDictionary dictionaryWithCapacity: 66];
|
|
|
|
printMap = [NSMutableDictionary dictionaryWithCapacity: 8];
|
|
|
|
spellMap = [NSMutableDictionary dictionaryWithCapacity: 8];
|
1998-11-23 21:40:54 +00:00
|
|
|
applicationMap = [NSMutableDictionary dictionaryWithCapacity: 64];
|
1999-01-07 13:04:21 +00:00
|
|
|
extensionsMap = [NSMutableDictionary dictionaryWithCapacity: 64];
|
1998-11-23 15:03:41 +00:00
|
|
|
|
|
|
|
env = [proc environment];
|
|
|
|
args = [proc arguments];
|
|
|
|
|
1999-02-17 09:36:25 +00:00
|
|
|
for (index = 1; index < [args count]; index++)
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
|
|
|
if ([[args objectAtIndex: index] isEqual: @"--verbose"])
|
|
|
|
verbose = YES;
|
|
|
|
if ([[args objectAtIndex: index] isEqual: @"--help"])
|
|
|
|
{
|
|
|
|
printf(
|
|
|
|
"make_services builds a validated cache of service information for use by\n"
|
|
|
|
"programs that want to use the OpenStep services facility.\n"
|
|
|
|
"This cache is stored in '%s' in the users GNUstep directory.\n"
|
|
|
|
"\n"
|
|
|
|
"You may use 'make_services --test filename' to test that the property list\n"
|
|
|
|
"in 'filename' contains a valid services definition.\n", [cacheName cString]);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
if ([[args objectAtIndex: index] isEqual: @"--test"])
|
|
|
|
{
|
|
|
|
verbose = YES;
|
|
|
|
while (++index < [args count])
|
|
|
|
{
|
|
|
|
NSString *file = [args objectAtIndex: index];
|
|
|
|
NSDictionary *info;
|
|
|
|
|
|
|
|
info = [NSDictionary dictionaryWithContentsOfFile: file];
|
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
id svcs = [info objectForKey: @"NSServices"];
|
|
|
|
|
|
|
|
if (svcs)
|
|
|
|
{
|
|
|
|
validateEntry(svcs, file);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"bad info - %@\n", file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"bad info - %@\n", file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
roots = [NSMutableArray arrayWithCapacity: 3];
|
1999-06-02 07:14:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up an array of root paths from the prefix list if possible.
|
|
|
|
* If we managed to get any paths, we set a flag so we know not to
|
|
|
|
* get and add default values later.
|
|
|
|
*/
|
|
|
|
str = [env objectForKey: @"GNUSTEP_PATHPREFIX_LIST"];
|
|
|
|
if (str != nil && [str isEqualToString: @""] == NO)
|
|
|
|
{
|
|
|
|
NSArray *a = [str componentsSeparatedByString: @":"];
|
|
|
|
unsigned index;
|
|
|
|
|
|
|
|
for (index = 0; index < [a count]; index++)
|
|
|
|
{
|
|
|
|
str = [a objectAtIndex: index];
|
|
|
|
if ([str isEqualToString: @""] == NO)
|
|
|
|
{
|
|
|
|
if ([roots containsObject: str] == NO)
|
|
|
|
{
|
|
|
|
[roots addObject: str];
|
|
|
|
usedPrefixes = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-01 20:54:23 +00:00
|
|
|
services = [NSMutableDictionary dictionaryWithCapacity: 200];
|
1998-11-23 15:03:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Build a list of 'root' directories to search for applications.
|
|
|
|
* Order is important - later duplicates of services are ignored.
|
1998-12-01 20:54:23 +00:00
|
|
|
*
|
|
|
|
* Make sure that the users 'GNUstep/Services' directory exists.
|
1998-11-23 15:03:41 +00:00
|
|
|
*/
|
|
|
|
str = [env objectForKey: @"GNUSTEP_USER_ROOT"];
|
|
|
|
if (str != nil)
|
|
|
|
usrRoot = str;
|
|
|
|
else
|
1999-01-07 13:04:21 +00:00
|
|
|
usrRoot = [sClass stringWithFormat: @"%@/GNUstep", NSHomeDirectory()];
|
1998-12-01 20:54:23 +00:00
|
|
|
|
|
|
|
mgr = [NSFileManager defaultManager];
|
|
|
|
if (([mgr fileExistsAtPath: usrRoot isDirectory: &isDir] && isDir) == 0)
|
|
|
|
{
|
|
|
|
if ([mgr createDirectoryAtPath: usrRoot attributes: nil] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"couldn't create %@\n", usrRoot);
|
|
|
|
[pool release];
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
1998-11-23 15:03:41 +00:00
|
|
|
|
1999-06-02 07:14:45 +00:00
|
|
|
str = usrRoot; /* Record for adding into roots array */
|
|
|
|
|
|
|
|
usrRoot = [str stringByAppendingPathComponent: @"Services"];
|
1998-12-01 20:54:23 +00:00
|
|
|
if (([mgr fileExistsAtPath: usrRoot isDirectory: &isDir] && isDir) == 0)
|
|
|
|
{
|
|
|
|
if ([mgr createDirectoryAtPath: usrRoot attributes: nil] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"couldn't create %@\n", usrRoot);
|
|
|
|
[pool release];
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-02 07:14:45 +00:00
|
|
|
if (usedPrefixes == NO)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Ensure that the user root (or default user root) is in the path.
|
|
|
|
*/
|
|
|
|
if ([roots containsObject: str] == NO)
|
|
|
|
[roots addObject: str];
|
1998-11-23 15:03:41 +00:00
|
|
|
|
1999-06-02 07:14:45 +00:00
|
|
|
/*
|
|
|
|
* Ensure that the local root (or default local root) is in the path.
|
|
|
|
*/
|
|
|
|
str = [env objectForKey: @"GNUSTEP_LOCAL_ROOT"];
|
|
|
|
if (str == nil)
|
|
|
|
str = @"/usr/GNUstep/Local";
|
|
|
|
if ([roots containsObject: str] == NO)
|
|
|
|
[roots addObject: str];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure that the system root (or default system root) is in the path.
|
|
|
|
*/
|
|
|
|
str = [env objectForKey: @"GNUSTEP_SYSTEM_ROOT"];
|
|
|
|
if (str == nil)
|
|
|
|
str = @"/usr/GNUstep";
|
|
|
|
if ([roots containsObject: str] == NO)
|
|
|
|
[roots addObject: str];
|
|
|
|
}
|
1998-11-23 15:03:41 +00:00
|
|
|
|
1998-12-01 20:54:23 +00:00
|
|
|
/*
|
|
|
|
* Before doing the main scan, we examine the 'Services' directory to
|
|
|
|
* see if any application has registered dynamic services - these take
|
|
|
|
* precedence over any listed in an applications Info_gnustep.plist.
|
|
|
|
*/
|
|
|
|
scanDynamic(services, usrRoot);
|
|
|
|
|
1998-11-23 15:03:41 +00:00
|
|
|
/*
|
|
|
|
* List of directory names to search within each root directory
|
|
|
|
* when looking for applications providing services.
|
|
|
|
*/
|
|
|
|
locations = [NSArray arrayWithObjects: @"Apps", @"Library/Services", nil];
|
|
|
|
|
|
|
|
for (index = 0; index < [roots count]; index++)
|
|
|
|
{
|
|
|
|
NSString *root = [roots objectAtIndex: index];
|
|
|
|
unsigned dirIndex;
|
|
|
|
|
|
|
|
for (dirIndex = 0; dirIndex < [locations count]; dirIndex++)
|
|
|
|
{
|
|
|
|
NSString *loc = [locations objectAtIndex: dirIndex];
|
|
|
|
NSString *path = [root stringByAppendingPathComponent: loc];
|
|
|
|
|
|
|
|
scanDirectory(services, path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fullMap = [NSMutableDictionary dictionaryWithCapacity: 5];
|
|
|
|
[fullMap setObject: services forKey: @"ByPath"];
|
|
|
|
[fullMap setObject: serviceMap forKey: @"ByService"];
|
|
|
|
[fullMap setObject: filterMap forKey: @"ByFilter"];
|
|
|
|
[fullMap setObject: printMap forKey: @"ByPrint"];
|
|
|
|
[fullMap setObject: spellMap forKey: @"BySpell"];
|
|
|
|
|
|
|
|
str = [usrRoot stringByAppendingPathComponent: cacheName];
|
1998-12-01 20:54:23 +00:00
|
|
|
if ([mgr fileExistsAtPath: str])
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
1998-12-01 20:54:23 +00:00
|
|
|
data = [NSData dataWithContentsOfFile: str];
|
|
|
|
oldMap = [NSDeserializer deserializePropertyListFromData: data
|
|
|
|
mutableContainers: NO];
|
1998-11-23 15:03:41 +00:00
|
|
|
}
|
1998-12-01 20:54:23 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
oldMap = nil;
|
|
|
|
}
|
|
|
|
if ([fullMap isEqual: oldMap] == NO)
|
|
|
|
{
|
|
|
|
data = [NSSerializer serializePropertyList: fullMap];
|
|
|
|
if ([data writeToFile: str atomically: YES] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"couldn't write %@\n", str);
|
|
|
|
[pool release];
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
str = [usrRoot stringByAppendingPathComponent: appsName];
|
|
|
|
if ([mgr fileExistsAtPath: str])
|
|
|
|
{
|
|
|
|
data = [NSData dataWithContentsOfFile: str];
|
|
|
|
oldMap = [NSDeserializer deserializePropertyListFromData: data
|
|
|
|
mutableContainers: NO];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oldMap = nil;
|
|
|
|
}
|
1999-01-07 13:04:21 +00:00
|
|
|
[applicationMap setObject: extensionsMap forKey: @"GSExtensionsMap"];
|
1998-12-01 20:54:23 +00:00
|
|
|
if ([applicationMap isEqual: oldMap] == NO)
|
|
|
|
{
|
|
|
|
data = [NSSerializer serializePropertyList: applicationMap];
|
|
|
|
if ([data writeToFile: str atomically: YES] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"couldn't write %@\n", str);
|
|
|
|
[pool release];
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-23 15:03:41 +00:00
|
|
|
[pool release];
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
1999-01-07 13:04:21 +00:00
|
|
|
/*
|
|
|
|
* Load information about the types of files that an application supports.
|
1999-04-28 11:17:11 +00:00
|
|
|
* For each extension found, produce a dictionary, keyed by app name, that
|
|
|
|
* contains dictionaries giving type info for that extension.
|
|
|
|
* NB. in order to make extensions case-insensiteve - we always convert
|
|
|
|
* to lowercase.
|
1999-01-07 13:04:21 +00:00
|
|
|
*/
|
|
|
|
static void addExtensionsForApplication(NSDictionary *info, NSString *app)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
id o0;
|
|
|
|
NSArray *a0;
|
|
|
|
|
|
|
|
|
|
|
|
o0 = [info objectForKey: @"NSTypes"];
|
|
|
|
if (o0)
|
|
|
|
{
|
|
|
|
if ([o0 isKindOfClass: aClass] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"bad app NSTypes (not an array) - %@\n", app);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
a0 = (NSArray*)o0;
|
|
|
|
i = [a0 count];
|
|
|
|
while (i-- > 0)
|
|
|
|
{
|
|
|
|
NSDictionary *t;
|
|
|
|
NSString *s;
|
|
|
|
NSArray *a1;
|
|
|
|
id o1 = [a0 objectAtIndex: i];
|
|
|
|
unsigned int j;
|
|
|
|
|
|
|
|
if ([o1 isKindOfClass: dClass] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"bad app NSTypes (type not a dictionary) - %@\n", app);
|
|
|
|
return;
|
|
|
|
}
|
1999-05-14 18:21:59 +00:00
|
|
|
/*
|
|
|
|
* Set 't' to the dictionary defining a particular file type.
|
|
|
|
*/
|
1999-01-07 13:04:21 +00:00
|
|
|
t = (NSDictionary*)o1;
|
|
|
|
o1 = [t objectForKey: @"NSUnixExtensions"];
|
|
|
|
if (o1 == nil)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ([o1 isKindOfClass: aClass] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"bad app NSType (extensions not an array) - %@\n", app);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
a1 = (NSArray*)o1;
|
|
|
|
j = [a1 count];
|
|
|
|
while (j-- > 0)
|
|
|
|
{
|
1999-04-28 11:17:11 +00:00
|
|
|
NSString *e;
|
|
|
|
NSMutableDictionary *d;
|
1999-01-07 13:04:21 +00:00
|
|
|
|
1999-04-28 11:17:11 +00:00
|
|
|
e = [[a1 objectAtIndex: j] lowercaseString];
|
|
|
|
d = [extensionsMap objectForKey: e];
|
|
|
|
if (d == nil)
|
1999-01-07 13:04:21 +00:00
|
|
|
{
|
1999-04-28 11:17:11 +00:00
|
|
|
d = [NSMutableDictionary dictionaryWithCapacity: 1];
|
|
|
|
[extensionsMap setObject: d forKey: e];
|
1999-01-07 13:04:21 +00:00
|
|
|
}
|
1999-04-28 11:17:11 +00:00
|
|
|
if ([d objectForKey: app] == NO)
|
1999-01-07 13:04:21 +00:00
|
|
|
{
|
1999-05-14 18:21:59 +00:00
|
|
|
[d setObject: t forKey: app];
|
1999-01-07 13:04:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If we have an old format list of extensions
|
|
|
|
* handled by this application - ensure that
|
|
|
|
* the name of the application is listed in
|
1999-04-28 11:17:11 +00:00
|
|
|
* the dictionary of applications handling each of
|
1999-01-07 13:04:21 +00:00
|
|
|
* the extensions.
|
|
|
|
*/
|
|
|
|
o0 = [info objectForKey: @"NSExtensions"];
|
|
|
|
if (o0 == nil)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ([o0 isKindOfClass: aClass] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"bad app NSExtensions (not an array) - %@\n", app);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
a0 = (NSArray*)o0;
|
|
|
|
i = [a0 count];
|
|
|
|
while (i-- > 0)
|
|
|
|
{
|
1999-04-28 11:17:11 +00:00
|
|
|
NSString *e;
|
|
|
|
NSMutableDictionary *d;
|
1999-01-07 13:04:21 +00:00
|
|
|
|
1999-04-28 11:17:11 +00:00
|
|
|
e = [[a0 objectAtIndex: i] lowercaseString];
|
|
|
|
d = [extensionsMap objectForKey: e];
|
|
|
|
if (d == nil)
|
1999-01-07 13:04:21 +00:00
|
|
|
{
|
1999-04-28 11:17:11 +00:00
|
|
|
d = [NSMutableDictionary dictionaryWithCapacity: 1];
|
|
|
|
[extensionsMap setObject: d forKey: e];
|
1999-01-07 13:04:21 +00:00
|
|
|
}
|
1999-04-28 11:17:11 +00:00
|
|
|
if ([d objectForKey: app] == nil)
|
1999-01-07 13:04:21 +00:00
|
|
|
{
|
1999-04-28 11:17:11 +00:00
|
|
|
NSDictionary *info;
|
|
|
|
|
|
|
|
info = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
nil];
|
|
|
|
[d setObject: info forKey: app];
|
1999-01-07 13:04:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-23 15:03:41 +00:00
|
|
|
static void
|
|
|
|
scanDirectory(NSMutableDictionary *services, NSString *path)
|
|
|
|
{
|
|
|
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
|
|
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
|
|
|
NSArray *contents = [mgr directoryContentsAtPath: path];
|
|
|
|
unsigned index;
|
|
|
|
|
|
|
|
for (index = 0; index < [contents count]; index++)
|
|
|
|
{
|
|
|
|
NSString *name = [contents objectAtIndex: index];
|
|
|
|
NSString *ext = [name pathExtension];
|
|
|
|
NSString *newPath;
|
|
|
|
BOOL isDir;
|
|
|
|
|
|
|
|
if (ext != nil &&
|
1999-04-28 11:17:11 +00:00
|
|
|
([ext isEqualToString: @"app"] || [ext isEqualToString: @"debug"]
|
|
|
|
|| [ext isEqualToString: @"profile"]))
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
|
|
|
newPath = [path stringByAppendingPathComponent: name];
|
|
|
|
if ([mgr fileExistsAtPath: newPath isDirectory: &isDir] && isDir)
|
|
|
|
{
|
1999-05-06 08:46:03 +00:00
|
|
|
NSString *oldPath;
|
|
|
|
NSString *infPath;
|
|
|
|
NSBundle *bundle;
|
|
|
|
NSDictionary *info;
|
1998-11-23 15:03:41 +00:00
|
|
|
|
1998-11-23 21:40:54 +00:00
|
|
|
/*
|
1999-01-07 13:04:21 +00:00
|
|
|
* All application paths are noted by name
|
1998-11-23 21:40:54 +00:00
|
|
|
* in the 'applicationMap' dictionary.
|
|
|
|
*/
|
1999-01-07 13:04:21 +00:00
|
|
|
if ((oldPath = [applicationMap objectForKey: name]) == nil)
|
|
|
|
{
|
|
|
|
[applicationMap setObject: newPath forKey: name];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If we already have an entry for an application with
|
|
|
|
* this name, we skip this one - the first one takes
|
|
|
|
* precedence.
|
|
|
|
*/
|
|
|
|
NSLog(@"duplicate app (%@) at '%@' and '%@'\n",
|
|
|
|
name, oldPath, newPath);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1999-05-06 08:46:03 +00:00
|
|
|
bundle = [NSBundle bundleWithPath: newPath];
|
|
|
|
info = [bundle infoDictionary];
|
|
|
|
if (info)
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
1999-05-06 08:46:03 +00:00
|
|
|
id obj;
|
1998-11-23 15:03:41 +00:00
|
|
|
|
1999-05-06 08:46:03 +00:00
|
|
|
/*
|
|
|
|
* Load and validate any services definitions.
|
|
|
|
*/
|
|
|
|
obj = [info objectForKey: @"NSServices"];
|
|
|
|
if (obj)
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
1999-05-06 08:46:03 +00:00
|
|
|
NSMutableArray *entry;
|
1998-11-23 15:03:41 +00:00
|
|
|
|
1999-05-06 08:46:03 +00:00
|
|
|
entry = validateEntry(obj, newPath);
|
|
|
|
if (entry)
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
1999-05-06 08:46:03 +00:00
|
|
|
[services setObject: entry forKey: newPath];
|
1998-11-23 15:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
1999-05-06 08:46:03 +00:00
|
|
|
|
|
|
|
addExtensionsForApplication(info, name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"bad app info - %@\n", newPath);
|
1998-11-23 15:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"bad application - %@\n", newPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ext != nil && [ext isEqualToString: @"service"])
|
|
|
|
{
|
|
|
|
newPath = [path stringByAppendingPathComponent: name];
|
|
|
|
if ([mgr fileExistsAtPath: newPath isDirectory: &isDir] && isDir)
|
|
|
|
{
|
1999-05-06 08:46:03 +00:00
|
|
|
NSBundle *bundle;
|
|
|
|
NSDictionary *info;
|
|
|
|
|
|
|
|
bundle = [NSBundle bundleWithPath: newPath];
|
|
|
|
info = [bundle infoDictionary];
|
|
|
|
if (info)
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
1999-05-06 08:46:03 +00:00
|
|
|
id svcs = [info objectForKey: @"NSServices"];
|
1998-11-23 15:03:41 +00:00
|
|
|
|
1999-05-06 08:46:03 +00:00
|
|
|
if (svcs)
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
1999-05-06 08:46:03 +00:00
|
|
|
NSMutableArray *entry;
|
1998-11-23 15:03:41 +00:00
|
|
|
|
1999-05-06 08:46:03 +00:00
|
|
|
entry = validateEntry(svcs, newPath);
|
|
|
|
if (entry)
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
1999-05-06 08:46:03 +00:00
|
|
|
[services setObject: entry forKey: newPath];
|
1998-11-23 15:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-05-06 08:46:03 +00:00
|
|
|
NSLog(@"missing info - %@\n", newPath);
|
1998-11-23 15:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
1999-05-06 08:46:03 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"bad service info - %@\n", newPath);
|
|
|
|
}
|
1998-11-23 15:03:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"bad services bundle - %@\n", newPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newPath = [path stringByAppendingPathComponent: name];
|
|
|
|
if ([mgr fileExistsAtPath: newPath isDirectory: &isDir] && isDir)
|
|
|
|
{
|
|
|
|
scanDirectory(services, newPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[arp release];
|
|
|
|
}
|
|
|
|
|
1998-12-01 20:54:23 +00:00
|
|
|
static void
|
|
|
|
scanDynamic(NSMutableDictionary *services, NSString *path)
|
|
|
|
{
|
|
|
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
|
|
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
|
|
|
NSArray *contents = [mgr directoryContentsAtPath: path];
|
|
|
|
unsigned index;
|
|
|
|
|
|
|
|
for (index = 0; index < [contents count]; index++)
|
|
|
|
{
|
|
|
|
NSString *name = [contents objectAtIndex: index];
|
|
|
|
NSString *infPath;
|
|
|
|
NSDictionary *info;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ignore anything with a leading dot.
|
|
|
|
*/
|
|
|
|
if ([name hasPrefix: @"."])
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
infPath = [path stringByAppendingPathComponent: name];
|
|
|
|
|
|
|
|
info = [NSDictionary dictionaryWithContentsOfFile: infPath];
|
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
id svcs = [info objectForKey: @"NSServices"];
|
|
|
|
|
|
|
|
if (svcs)
|
|
|
|
{
|
|
|
|
NSMutableArray *entry;
|
|
|
|
|
|
|
|
entry = validateEntry(svcs, infPath);
|
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
[services setObject: entry forKey: infPath];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"bad app info - %@\n", infPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[arp release];
|
|
|
|
}
|
|
|
|
|
1998-11-23 15:03:41 +00:00
|
|
|
static NSMutableArray*
|
|
|
|
validateEntry(id svcs, NSString *path)
|
|
|
|
{
|
|
|
|
NSMutableArray *newServices;
|
|
|
|
NSArray *services;
|
|
|
|
unsigned pos;
|
|
|
|
|
1999-01-07 13:04:21 +00:00
|
|
|
if ([svcs isKindOfClass: aClass] == NO)
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry not an array - %@\n", path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
services = (NSArray*)svcs;
|
|
|
|
newServices = [NSMutableArray arrayWithCapacity: [services count]];
|
|
|
|
for (pos = 0; pos < [services count]; pos++)
|
|
|
|
{
|
|
|
|
id svc;
|
|
|
|
|
|
|
|
svc = [services objectAtIndex: pos];
|
1999-01-07 13:04:21 +00:00
|
|
|
if ([svc isKindOfClass: dClass])
|
1998-11-23 15:03:41 +00:00
|
|
|
{
|
|
|
|
NSDictionary *service = (NSDictionary*)svc;
|
|
|
|
NSMutableDictionary *newService;
|
|
|
|
|
|
|
|
newService = validateService(service, path, pos);
|
|
|
|
if (newService)
|
|
|
|
{
|
|
|
|
[newServices addObject: newService];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u not a dictionary - %@\n",
|
|
|
|
pos, path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return newServices;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NSMutableDictionary*
|
|
|
|
validateService(NSDictionary *service, NSString *path, unsigned pos)
|
|
|
|
{
|
|
|
|
static NSDictionary *fields = nil;
|
|
|
|
NSEnumerator *e;
|
|
|
|
NSMutableDictionary *result;
|
|
|
|
NSString *k;
|
|
|
|
id obj;
|
|
|
|
|
|
|
|
if (fields == nil)
|
|
|
|
{
|
|
|
|
fields = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
@"string", @"NSMessage",
|
|
|
|
@"string", @"NSPortName",
|
|
|
|
@"array", @"NSSendTypes",
|
|
|
|
@"array", @"NSReturnTypes",
|
|
|
|
@"dictionary", @"NSMenuItem",
|
|
|
|
@"dictionary", @"NSKeyEquivalent",
|
|
|
|
@"string", @"NSUserData",
|
|
|
|
@"string", @"NSTimeout",
|
|
|
|
@"string", @"NSHost",
|
|
|
|
@"string", @"NSExecutable",
|
|
|
|
@"string", @"NSFilter",
|
|
|
|
@"string", @"NSInputMechanism",
|
|
|
|
@"string", @"NSPrintFilter",
|
|
|
|
@"string", @"NSDeviceDependent",
|
|
|
|
@"array", @"NSLanguages",
|
|
|
|
@"string", @"NSSpellChecker",
|
|
|
|
nil];
|
|
|
|
[fields retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
result = [NSMutableDictionary dictionaryWithCapacity: [service count]];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Step through and check that each field is a known one and of the
|
|
|
|
* correct type.
|
|
|
|
*/
|
|
|
|
e = [service keyEnumerator];
|
|
|
|
while ((k = [e nextObject]) != nil)
|
|
|
|
{
|
|
|
|
NSString *type = [fields objectForKey: k];
|
|
|
|
|
|
|
|
if (type == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u spurious field (%@)- %@\n", pos, k, path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
obj = [service objectForKey: k];
|
|
|
|
if ([type isEqualToString: @"string"])
|
|
|
|
{
|
|
|
|
if ([obj isKindOfClass: sClass] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u field %@ is not a string - %@\n", pos, k, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
[result setObject: obj forKey: k];
|
|
|
|
}
|
|
|
|
else if ([type isEqualToString: @"array"])
|
|
|
|
{
|
|
|
|
NSArray *a;
|
|
|
|
|
|
|
|
if ([obj isKindOfClass: aClass] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u field %@ is not an array - %@\n", pos, k, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
a = (NSArray*)obj;
|
|
|
|
if ([a count] == 0)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u field %@ is an empty array - %@\n", pos, k, path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < [a count]; i++)
|
|
|
|
{
|
|
|
|
if ([[a objectAtIndex: i] isKindOfClass: sClass] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u field %@ element %u is not a string - %@\n", pos, k, i, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[result setObject: a forKey: k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ([type isEqualToString: @"dictionary"])
|
|
|
|
{
|
|
|
|
NSDictionary *d;
|
|
|
|
|
|
|
|
if ([obj isKindOfClass: dClass] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u field %@ is not a dictionary - %@\n", pos, k, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
d = (NSDictionary*)obj;
|
|
|
|
if ([d objectForKey: @"default"] == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u field %@ has no default value - %@\n", pos, k, path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSEnumerator *e = [d objectEnumerator];
|
|
|
|
|
|
|
|
while ((obj = [e nextObject]) != nil)
|
|
|
|
{
|
|
|
|
if ([obj isKindOfClass: sClass] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u field %@ contains non-string value - %@\n", pos, k, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[result setObject: d forKey: k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Record in this service dictionary where it is to be found.
|
|
|
|
*/
|
|
|
|
[result setObject: path forKey: @"ServicePath"];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now check that we have the required fields for the service.
|
|
|
|
*/
|
|
|
|
if ((obj = [result objectForKey: @"NSMessage"]) != nil)
|
|
|
|
{
|
|
|
|
NSDictionary *item;
|
|
|
|
NSEnumerator *e;
|
|
|
|
NSString *k;
|
|
|
|
BOOL used = NO;
|
|
|
|
|
|
|
|
if ([result objectForKey: @"NSPortName"] == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u NSPortName missing - %@\n", pos, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
if ([result objectForKey: @"NSSendTypes"] == nil &&
|
|
|
|
[result objectForKey: @"NSReturnTypes"] == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u types missing - %@\n", pos, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
if ((item = [result objectForKey: @"NSMenuItem"]) == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u NSMenuItem missing - %@\n", pos, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For each language, check to see if we already have a service
|
|
|
|
* by this name - if so - we ignore this one.
|
|
|
|
*/
|
|
|
|
e = [item keyEnumerator];
|
|
|
|
while ((k = [e nextObject]) != nil)
|
|
|
|
{
|
|
|
|
NSString *name = [item objectForKey: k];
|
|
|
|
NSMutableDictionary *names;
|
|
|
|
|
|
|
|
names = [serviceMap objectForKey: k];
|
|
|
|
if (names == nil)
|
|
|
|
{
|
|
|
|
names = [NSMutableDictionary dictionaryWithCapacity: 1];
|
|
|
|
[serviceMap setObject: names forKey: k];
|
|
|
|
}
|
|
|
|
if ([names objectForKey: name] == nil)
|
|
|
|
{
|
|
|
|
[names setObject: result forKey: name];
|
|
|
|
used = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (used == NO)
|
|
|
|
{
|
|
|
|
if (verbose)
|
|
|
|
NSLog(@"Ignoring entry %u in %@ -\n%@\n", pos, path, result);
|
|
|
|
return nil; /* Ignore - already got service with this name */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((obj = [result objectForKey: @"NSFilter"]) != nil)
|
|
|
|
{
|
|
|
|
NSString *str;
|
|
|
|
NSArray *snd;
|
|
|
|
NSArray *ret;
|
|
|
|
unsigned spos;
|
|
|
|
BOOL used = NO;
|
|
|
|
|
|
|
|
str = [result objectForKey: @"NSInputMechanism"];
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
if ([str isEqualToString: @"NSUnixStdio"] == NO &&
|
|
|
|
[str isEqualToString: @"NSMapFile"] == NO &&
|
|
|
|
[str isEqualToString: @"NSIdentity"] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u bad input mechanism - %@\n", pos, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
snd = [result objectForKey: @"NSSendTypes"];
|
|
|
|
ret = [result objectForKey: @"NSReturnTypes"];
|
|
|
|
if (snd == nil || ret == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u types missing - %@\n", pos, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For each send-type/return-type combination, see if we
|
|
|
|
* already have a filter - if so - ignore this one.
|
|
|
|
*/
|
|
|
|
spos = [snd count];
|
|
|
|
while (spos-- > 0)
|
|
|
|
{
|
|
|
|
NSString *stype = [snd objectAtIndex: spos];
|
|
|
|
NSMutableDictionary *sdict = [filterMap objectForKey: stype];
|
|
|
|
unsigned rpos;
|
|
|
|
|
|
|
|
if (sdict == nil)
|
|
|
|
{
|
|
|
|
sdict = [NSMutableDictionary dictionaryWithCapacity: [snd count]];
|
|
|
|
[filterMap setObject: sdict forKey: stype];
|
|
|
|
}
|
|
|
|
rpos = [ret count];
|
|
|
|
while (rpos-- > 0)
|
|
|
|
{
|
|
|
|
NSString *rtype = [ret objectAtIndex: rpos];
|
|
|
|
|
|
|
|
if ([sdict objectForKey: rtype] == nil)
|
|
|
|
{
|
|
|
|
[sdict setObject: result forKey: rtype];
|
|
|
|
used = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (used == NO)
|
|
|
|
{
|
|
|
|
if (verbose)
|
|
|
|
NSLog(@"Ignoring entry %u in %@ -\n%@\n", pos, path, result);
|
|
|
|
return nil; /* Ignore - already got filter for types. */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((obj = [result objectForKey: @"NSPrintFilter"]) != nil)
|
|
|
|
{
|
|
|
|
NSDictionary *item;
|
|
|
|
NSEnumerator *e;
|
|
|
|
NSString *k;
|
|
|
|
BOOL used = NO;
|
|
|
|
|
|
|
|
if ((item = [result objectForKey: @"NSMenuItem"]) == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u NSMenuItem missing - %@\n", pos, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* For each language, check to see if we already have a print
|
|
|
|
* filter by this name - if so - we ignore this one.
|
|
|
|
*/
|
|
|
|
e = [item keyEnumerator];
|
|
|
|
while ((k = [e nextObject]) != nil)
|
|
|
|
{
|
|
|
|
NSString *name = [item objectForKey: k];
|
|
|
|
NSMutableDictionary *names;
|
|
|
|
|
|
|
|
names = [printMap objectForKey: k];
|
|
|
|
if (names == nil)
|
|
|
|
{
|
|
|
|
names = [NSMutableDictionary dictionaryWithCapacity: 1];
|
|
|
|
[printMap setObject: names forKey: k];
|
|
|
|
}
|
|
|
|
if ([names objectForKey: name] == nil)
|
|
|
|
{
|
|
|
|
[names setObject: result forKey: name];
|
|
|
|
used = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (used == NO)
|
|
|
|
{
|
|
|
|
if (verbose)
|
|
|
|
NSLog(@"Ignoring entry %u in %@ -\n%@\n", pos, path, result);
|
|
|
|
return nil; /* Ignore - already got filter with this name */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((obj = [result objectForKey: @"NSSpellChecker"]) != nil)
|
|
|
|
{
|
|
|
|
NSArray *item;
|
|
|
|
unsigned pos;
|
|
|
|
BOOL used = NO;
|
|
|
|
|
|
|
|
if ((item = [result objectForKey: @"NSLanguages"]) == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u NSLanguages missing - %@\n", pos, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* For each language, check to see if we already have a spell
|
|
|
|
* checker by this name - if so - we ignore this one.
|
|
|
|
*/
|
|
|
|
pos = [item count];
|
|
|
|
while (pos-- > 0)
|
|
|
|
{
|
|
|
|
NSString *lang = [item objectAtIndex: pos];
|
|
|
|
|
|
|
|
if ([spellMap objectForKey: lang] == nil)
|
|
|
|
{
|
|
|
|
[spellMap setObject: result forKey: lang];
|
|
|
|
used = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (used == NO)
|
|
|
|
{
|
|
|
|
if (verbose)
|
|
|
|
NSLog(@"Ignoring entry %u in %@ -\n%@\n", pos, path, result);
|
|
|
|
return nil; /* Ignore - already got speller with language. */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"NSServices entry %u unknown service/filter - %@\n", pos, path);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|