#include #include #include #include "gscal.h" BOOL printWholeYear = NO; int month, year; NSString *infile, *outfile; void get_opts(int count, char *args[]) { int i; if(strcmp(args[1],"-y")==0) { printWholeYear = YES; i=2; } else { i=1; } infile = [[NSString alloc] initWithCString:args[i++]]; outfile = [[NSString alloc] initWithCString:args[i]]; } void printTheWholeYear(id cal, int year) { int i; for(i=JANUARY;i<=DECEMBER;i++) { [cal writeTitle:outfile month:i year:year]; [cal drawWeeks:outfile month:i year:year]; } [cal printReferenceTable:outfile month:i year:year]; } int main(int argc, char *argv[]) { NSAutoreleasePool *pool; GSCalendar *cal; struct tm *timest; time_t t; if(argc<3) { printf("usage: gscal [-y] \n"); return 0; } get_opts(argc,argv); pool = [[NSAutoreleasePool alloc] init]; cal = [[GSCalendar alloc] initWithFile:infile]; t = time(NULL); timest = localtime(&t); month = timest->tm_mon; year = timest->tm_year + 1900; if(printWholeYear) { printTheWholeYear(cal,year); } else { [cal drawCalendar:outfile month:month year:year]; } [cal release]; [pool release]; return 0; }