PageRenderTime 39ms CodeModel.GetById 14ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 1ms

/Tools/squid-orgs.m

http://eeframework.googlecode.com/
Objective C | 69 lines | 55 code | 12 blank | 2 comment | 9 complexity | 99037d7ea9e4883974c3b0a9eb65a768 MD5 | raw file
 1// -*- objc -*-
 2// -*- coding: koi8-r -*-
 3
 4#import <Foundation/Foundation.h>
 5#import "SquidAggregator/SquidAggregator.h"
 6#import <GNUstepBase/GSLocale.h>
 7#include <stdio.h>
 8#include <time.h>
 9
10void usage()
11{
12      printf("SQUID Organizations Populating utility v.0.1.0\n");
13      printf("This tool is intended to store the links between organizations and users.\n");
14      printf("\n  --help\n\tthis help.\n");
15      printf("\n  --populate <file>\n\tthe file with the orgs and users table.\n");
16      printf("\n  --restore\n\trestore the orgs and users table.\n");
17      printf("\n  --store\n\tstore the orgs and users table.\n");
18      printf("\n  --dump\n\tdumps the organization list to the standard output.\n");
19      printf("\n");
20      exit(EXIT_SUCCESS);  
21}
22
23int
24main(int argc, char** argv, char** env)
25{
26  CREATE_AUTORELEASE_POOL(pool);
27  SquidAggregator *sa = [SquidAggregator new]; //the current month
28  NSProcessInfo	 *pInfo = [NSProcessInfo processInfo];
29  BOOL help = YES;
30
31
32  if ([[pInfo arguments] containsObject: @"--populate"] == YES)
33    {
34      NSString *file = [[pInfo arguments] 
35			  objectAtIndex:[[pInfo arguments] 
36					  indexOfObject:@"--populate"] + 1];
37
38      [sa populateOrgsAndPersonsWithPath:file];
39    }
40
41  if ([[pInfo arguments] containsObject: @"--restore"] == YES)
42    {
43      [sa restoreOrgsAndPersons];
44      help = NO;
45    }
46
47  if ([[pInfo arguments] containsObject: @"--store"] == YES)
48    {
49      [sa storeOrgsAndPersons];
50      help = NO;
51    }
52
53  if ([[pInfo arguments] containsObject: @"--dump"] == YES)
54    {
55      [sa dumpOrgs];
56      [sa dumpPersons];
57      help = NO;
58    }
59
60  RELEASE(sa);
61  RELEASE(pool);
62
63  if(help)
64    {
65      usage();
66    }
67
68  return 0;
69}