2 Copyright (C) 2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo 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 OGo 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 OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import <Foundation/NSObject.h>
24 @class NSUserDefaults, NSArray;
25 @class GCSFolderManager;
27 @interface Tool : NSObject
32 + (int)runWithArgs:(NSArray *)_args;
37 #include <GDLContentStore/GCSFolderType.h>
43 if ((self = [super init])) {
44 self->ud = [[NSUserDefaults standardUserDefaults] retain];
55 - (int)runOnTable:(NSString *)_tableName typeName:(NSString *)_typeName {
56 GCSFolderType *folderType;
58 if ((folderType = [GCSFolderType folderTypeWithName:_typeName]) != nil) {
61 s = [folderType sqlQuickCreateWithTableName:_tableName];
63 fwrite([s cString], 1, [s cStringLength], stdout);
67 fprintf(stderr, "ERROR: did not find GCS type: '%s'\n",
76 NSString *tableName, *typeName;
78 e = [[[NSProcessInfo processInfo] argumentsWithoutDefaults]
80 [e nextObject]; // skip tool name
82 while ((tableName = [e nextObject]) != nil) {
83 typeName = [e nextObject];
84 if (typeName == nil) {
85 [self logWithFormat:@"got tablename '%@' but no type?!", tableName];
89 [self runOnTable:tableName typeName:typeName];
94 + (int)runWithArgs:(NSArray *)_args {
95 return [(Tool *)[[[self alloc] init] autorelease] run];
100 int main(int argc, char **argv, char **env) {
101 NSAutoreleasePool *pool;
104 pool = [[NSAutoreleasePool alloc] init];
105 #if LIB_FOUNDATION_LIBRARY
106 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
109 rc = [Tool runWithArgs:
110 [[NSProcessInfo processInfo] argumentsWithoutDefaults]];