From: helge Date: Thu, 18 Aug 2005 15:08:50 +0000 (+0000) Subject: started ngcal tool X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebb12bdf8b91166b3cdfcd535948da6875c3a4a8;p=sope started ngcal tool git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1050 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-core/samples/ChangeLog b/sope-core/samples/ChangeLog index 5ffca0a8..7bfb072c 100644 --- a/sope-core/samples/ChangeLog +++ b/sope-core/samples/ChangeLog @@ -1,3 +1,8 @@ +2005-08-18 Helge Hess + + * prepared new ngcal tool for testing calendar calculations + (unfinished) + 2005-08-10 Helge Hess * EOQualTool.m: fixed gcc 4.0 warnings diff --git a/sope-core/samples/GNUmakefile b/sope-core/samples/GNUmakefile index a6e2bd84..07114da4 100644 --- a/sope-core/samples/GNUmakefile +++ b/sope-core/samples/GNUmakefile @@ -13,7 +13,8 @@ TOOL_NAME = \ httpu_notify \ parserule \ testurl \ - sope-rsrclookup + sope-rsrclookup \ + ngcal ifneq ($(OBJC_RUNTIME_LIB),apple) TOOL_NAME += subclassing @@ -30,6 +31,7 @@ parserule_OBJC_FILES = parserule.m httpu_notify_OBJC_FILES = httpu_notify.m testurl_OBJC_FILES = testurl.m sope-rsrclookup_OBJC_FILES = sope-rsrclookup.m +ngcal_OBJC_FILES = ngcal.m -include GNUmakefile.preamble include $(GNUSTEP_MAKEFILES)/tool.make diff --git a/sope-core/samples/ngcal.m b/sope-core/samples/ngcal.m new file mode 100644 index 00000000..e08781f1 --- /dev/null +++ b/sope-core/samples/ngcal.m @@ -0,0 +1,66 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE 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. + + SOPE 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 SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#include "common.h" + +static void usage(NSArray *args) { + printf("Usage: %s [[[month] year] startday]\n\n" + "Arguments:\n" + " month - month as a decimal (1-12)\n" + " year - year as a decimal (1976-2030)\n" + " startday - first column in matrix (Sunday=0...Saturday=6)\n" + , [[args objectAtIndex:0] cString]); +} + +static int doCalArgs(NSArray *args) { + NSCalendarDate *now; + unsigned startDayOfWeek, month, year; + + if ([args containsObject:@"--help"] || [args containsObject:@"-h"]) { + usage(args); + return 0; + } + + now = [NSCalendarDate date]; + startDayOfWeek = 1 /* Monday */; + month = [now monthOfYear]; + year = [now yearOfCommonEra]; + + return 0; +} + +int main(int argc, char **argv, char **env) { + NSAutoreleasePool *pool; + int res; + + pool = [[NSAutoreleasePool alloc] init]; +#if LIB_FOUNDATION_LIBRARY + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; +#endif + + res = doCalArgs([[NSProcessInfo processInfo] argumentsWithoutDefaults]); + + [pool release]; + exit(0); + /* static linking */ + [NGExtensions class]; + return 0; +}