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>
24 @interface vcsparsetest : NSObject
28 - (int)runWithArguments:(NSArray *)_args;
32 #include <NGiCal/NGVCard.h>
34 @implementation vcsparsetest
37 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 {
53 NSLog(@"cards: %@", _cards);
56 NSLog(@" subcomponents: %@", [_object subComponents]);
58 printf("%s", [[_object icalString] cString]);
64 - (int)runWithArguments:(NSArray *)_args {
68 args = [_args objectEnumerator];
69 [args nextObject]; // process name ...
71 while ((arg = [args nextObject])) {
72 NSAutoreleasePool *pool2;
74 if ([arg hasPrefix:@"-"]) { /* consume defaults */
79 pool2 = [[NSAutoreleasePool alloc] init];
84 cards = [self parseFile:arg];
90 NSLog(@"could not parse file: '%@'", arg);
92 [self printParsedObject:cards];
99 @end /* vcsparsetest */
101 int main(int argc, char **argv, char **env) {
102 NSAutoreleasePool *pool;
106 #if LIB_FOUNDATION_LIBRARY
107 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
110 pool = [[NSAutoreleasePool alloc] init];
112 if ((tool = [[vcsparsetest alloc] init])) {
114 rc = [tool runWithArguments:[[NSProcessInfo processInfo] arguments]];