]> err.no Git - scalable-opengroupware.org/blob - Main/sogod.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1245 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / Main / sogod.m
1 /*
2   Copyright (C) 2004-2005 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #import <unistd.h>
23
24 #import <Foundation/NSAutoreleasePool.h>
25 #import <Foundation/NSString.h>
26 #import <Foundation/NSTimeZone.h>
27 #import <Foundation/NSUserDefaults.h>
28
29 #import <NGObjWeb/SoApplication.h>
30
31 int
32 main (int argc, char **argv, char **env)
33 {
34   NSString *tzName;
35   NSUserDefaults *ud;
36   NSAutoreleasePool *pool;
37   int rc;
38
39   pool = [NSAutoreleasePool new];
40
41   rc = -1;
42
43   if (getuid() > 0)
44     {
45 #if LIB_FOUNDATION_LIBRARY
46       [NSProcessInfo initializeWithArguments: argv
47                      count: argc environment: env];
48 #endif
49       ud = [NSUserDefaults standardUserDefaults];
50       rc = 0;
51       tzName = [ud stringForKey: @"SOGoServerTimeZone"];
52       if (!tzName)
53         tzName = @"UTC";
54       [NSTimeZone setDefaultTimeZone:
55                     [NSTimeZone timeZoneWithName: tzName]];
56       WOWatchDogApplicationMain (@"SOGo", argc, (void *) argv);
57     }
58   else
59     NSLog (@"Don't run SOGo as root!");
60
61   [pool release];
62
63   return rc;
64 }