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