mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-05 16:35:10 +00:00
See ChangeLog
Monotone-Parent: 8d42e44b72c2c9e6431e77f6b5c590736449f7d7 Monotone-Revision: bafccbe12139895411068d388269aca400af46ec Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2009-04-01T13:49:24 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -5,7 +5,6 @@ include $(GNUSTEP_MAKEFILES)/common.make
|
||||
include ./Version
|
||||
|
||||
LIBRARY_NAME = libOGoContentStore
|
||||
TOOL_NAME = test_quick_extract
|
||||
|
||||
TYPEMODELS_DIR = $(SOGO_TYPEMODELS)
|
||||
|
||||
@@ -26,9 +25,6 @@ libOGoContentStore_TYPEMODELS += \
|
||||
appointment-oracle.ocs \
|
||||
contact-oracle.ocs
|
||||
|
||||
test_quick_extract_OBJC_FILES += \
|
||||
test_quick_extract.m
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
ifneq ($(FHS_INSTALL_ROOT),)
|
||||
GNUSTEP_HEADERS=$(DESTDIR)$(FHS_INSTALL_ROOT)/include
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2005 SKYRIX Software AG
|
||||
|
||||
This file is part of SOGo.
|
||||
|
||||
SOGo 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; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with SOGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGExtensions/NSProcessInfo+misc.h>
|
||||
|
||||
#import <GDLContentStore/GCSFieldExtractor.h>
|
||||
|
||||
@interface TestQuickExtract : NSObject
|
||||
|
||||
- (int)runWithArguments:(NSArray *)_args;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TestQuickExtract
|
||||
|
||||
- (int)usage:(NSArray *)_args {
|
||||
fprintf(stderr, "usage: %s <ExtractorClassName> <file1> <file2>\n",
|
||||
[[_args objectAtIndex:0] cString]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (void)extractQuickInfoFromFileAtPath:(NSString *)_path
|
||||
usingExtractorClass:(Class)_clazz
|
||||
{
|
||||
GCSFieldExtractor *extractor;
|
||||
NSString *content;
|
||||
NSDictionary *quickInfo;
|
||||
|
||||
if ((content = [NSString stringWithContentsOfFile:_path]) == nil) {
|
||||
fprintf(stderr, "ERROR: could not open file: %s\n", [_path cString]);
|
||||
return;
|
||||
}
|
||||
|
||||
extractor = [[_clazz alloc] init];
|
||||
quickInfo = [[extractor extractQuickFieldsFromContent:content] retain];
|
||||
[extractor release]; extractor = nil;
|
||||
|
||||
if ([quickInfo count] == 0) {
|
||||
fprintf(stderr, "ERROR: could not extract quickfields from file: %s\n",
|
||||
[_path cString]);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("File: %s\n", [_path cString]);
|
||||
printf("**************************************************\n");
|
||||
printf("%s\n", [[quickInfo description] cString]);
|
||||
|
||||
[quickInfo release];
|
||||
}
|
||||
|
||||
- (void)extractQuickInfoFromFiles:(NSEnumerator *)_pathes
|
||||
usingExtractorClass:(Class)_clazz
|
||||
{
|
||||
NSString *path;
|
||||
|
||||
while ((path = [_pathes nextObject]) != nil)
|
||||
[self extractQuickInfoFromFileAtPath:path usingExtractorClass:_clazz];
|
||||
}
|
||||
|
||||
- (int)runWithArguments:(NSArray *)_args {
|
||||
NSEnumerator *e;
|
||||
Class clazz;
|
||||
|
||||
if ([_args count] < 3)
|
||||
return [self usage:_args];
|
||||
|
||||
if ((clazz = NSClassFromString([_args objectAtIndex:1])) == Nil) {
|
||||
fprintf(stderr, "ERROR: did not find extractor class: %s\n",
|
||||
[[_args objectAtIndex:1] cString]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
e = [_args objectEnumerator];
|
||||
[e nextObject]; // skip toolname
|
||||
[e nextObject]; // skip classname
|
||||
|
||||
[self extractQuickInfoFromFiles:e usingExtractorClass:clazz];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@end /* TestQuickExtract */
|
||||
|
||||
|
||||
int main(int argc, char **argv, char **env) {
|
||||
NSAutoreleasePool *pool;
|
||||
TestQuickExtract *tool;
|
||||
int rc;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
#if LIB_FOUNDATION_LIBRARY
|
||||
[NSProcessInfo initializeWithArguments:argv count:argc environment:env];
|
||||
#endif
|
||||
|
||||
tool = [[TestQuickExtract alloc] init];
|
||||
rc = [tool runWithArguments:
|
||||
[[NSProcessInfo processInfo] argumentsWithoutDefaults]];
|
||||
[tool release];
|
||||
[pool release];
|
||||
return rc;
|
||||
}
|
||||
Reference in New Issue
Block a user