]> err.no Git - scalable-opengroupware.org/blob - SoObjects/SOGo/agenor_shares4uid.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1163 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / SoObjects / SOGo / agenor_shares4uid.m
1 /*
2   Copyright (C) 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 #include "AgenorUserManager.h"
23 #include "common.h"
24
25 static void usage(NSArray *args) {
26   fprintf(stderr, "usage: %s <uid1> <uid2> <uid3>\n",
27           [[args objectAtIndex:0] cString]);
28 }
29
30 static void handleUID(NSString *uid, AgenorUserManager *userManager) {
31   NSArray  *shares;
32   unsigned i, count;
33   
34   shares = [userManager getSharedMailboxAccountStringsForUID:uid];
35   
36   printf("%s:", [uid cString]);
37   
38   if ((count = [shares count]) == 0) {
39     printf(" <no shares>\n");
40     return;
41   }
42   
43   puts("");
44   for (i = 0; i < count; i++)
45     printf("  %s\n", [[shares objectAtIndex:i] cString]);
46 }
47
48 static void doIt(NSArray *args) {
49   AgenorUserManager *userManager;
50   NSEnumerator *e;
51   NSString     *uid;
52   
53   if ([args count] < 2) {
54     usage(args);
55     return;
56   }
57   
58   userManager = [AgenorUserManager sharedUserManager];
59   
60   e = [args objectEnumerator];
61   [e nextObject]; /* consume the command name */
62   
63   while ((uid = [e nextObject]) != nil)
64     handleUID(uid, userManager);
65 }
66
67 int main(int argc, char **argv, char **env) {
68   NSAutoreleasePool *pool;
69   
70   pool = [[NSAutoreleasePool alloc] init];
71 #if LIB_FOUNDATION_LIBRARY
72   [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
73 #endif
74   
75   doIt([[NSProcessInfo processInfo] argumentsWithoutDefaults]);
76   
77   [pool release];
78   return 0;
79 }