2 Copyright (C) 2005 Helge Hess
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import <Foundation/Foundation.h>
23 #import <NGCards/NGVCard.h>
25 @interface vcsparsetest : NSObject
29 - (int)runWithArguments:(NSArray *)_args;
33 @implementation vcsparsetest
36 if ((self = [super init])) {
47 - (id)parseFile:(NSString *)_path {
48 if ([_path length] == 0) return nil;
49 return [NGVCard parseVCardsFromSource:[NSURL fileURLWithPath:_path]];
52 - (void)printParsedObject: (NSArray *)_cards
54 NSEnumerator *cardObjects;
57 cardObjects = [_cards objectEnumerator];
58 card = [cardObjects nextObject];
61 NSLog (@"-------s\n%@\ne-------", [card versitString]);
62 card = [cardObjects nextObject];
66 NSLog(@" subcomponents: %@", [_object subComponents]);
68 printf("%s", [[_object icalString] cString]);
74 - (int)runWithArguments:(NSArray *)_args {
78 args = [_args objectEnumerator];
79 [args nextObject]; // process name ...
81 while ((arg = [args nextObject])) {
82 NSAutoreleasePool *pool2;
84 if ([arg hasPrefix:@"-"]) { /* consume defaults */
89 pool2 = [[NSAutoreleasePool alloc] init];
94 cards = [self parseFile:arg];
100 NSLog(@"could not parse file: '%@'", arg);
102 [self printParsedObject:cards];
109 @end /* vcsparsetest */
111 int main(int argc, char **argv, char **env) {
112 NSAutoreleasePool *pool;
116 pool = [[NSAutoreleasePool alloc] init];
117 #if LIB_FOUNDATION_LIBRARY
118 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
121 if ((tool = [[vcsparsetest alloc] init]) != nil) {
123 rc = [tool runWithArguments:[[NSProcessInfo processInfo] arguments]];