2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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
11 SOPE 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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include <EOControl/EOControl.h>
23 #include <NGLdap/NGLdapFileManager.h>
26 int main(int argc, char **argv, char **env) {
27 NSAutoreleasePool *pool;
34 pool = [[NSAutoreleasePool alloc] init];
35 #if LIB_FOUNDATION_LIBRARY
36 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
39 args = [[NSProcessInfo processInfo] arguments];
40 if ([args count] < 1) {
41 NSLog(@"usage: %@ <files>", [args objectAtIndex:0]);
44 else if ([args count] == 1)
45 args = [args arrayByAddingObject:@"."];
47 ud = [NSUserDefaults standardUserDefaults];
49 fm = [[NGLdapFileManager alloc]
50 initWithHostName:[ud stringForKey:@"LDAPHost"]
51 port:[ud integerForKey:@"LDAPPort"]
52 bindDN:[ud stringForKey:@"LDAPBindDN"]
53 credentials:[ud stringForKey:@"LDAPPassword"]
54 rootDN:[ud stringForKey:@"LDAPRootDN"]];
55 fm = [fm autorelease];
58 NSLog(@"could not open LDAP connection (got no filemanager).");
62 // NSLog(@"LDAP: %@", fm);
64 for (i = 1; i < [args count]; i++) {
68 path = [args objectAtIndex:i];
70 if ([path hasPrefix:@"-r"]) {
75 if ([path hasPrefix:@"-"]) {
80 if (![fm fileExistsAtPath:path isDirectory:&isDir]) {
81 NSLog(@"file/directory does not exist: %@", path);
91 ? [fm subpathsAtPath:path]
92 : [fm directoryContentsAtPath:path];
94 for (i = 0, count = [dirContents count]; i < count; i++) {
95 NSString *cpath, *apath;
100 cpath = [dirContents objectAtIndex:i];
101 apath = [path stringByAppendingPathComponent:cpath];
103 info = [fm fileAttributesAtPath:apath
106 mid = [[info objectForKey:@"NSFileIdentifier"] description];
107 if ([mid length] > 39) {
108 mid = [mid substringToIndex:37];
109 mid = [mid stringByAppendingString:@"..."];
112 owner = [info objectForKey:NSFileOwnerAccountName];
113 date = [[info objectForKey:NSFileModificationDate] description];
120 /* id uid date name */
121 printf("%-34s %20s %-32s %s",
127 if ([[info objectForKey:NSFileType]
128 isEqualToString:NSFileTypeDirectory])
139 if ((contents = [fm contentsAtPath:path]) == nil) {
140 NSLog(@"could not get content of record: '%@'", path);
143 s = [[NSString alloc] initWithData:contents
144 encoding:[NSString defaultCStringEncoding]];
145 printf("%s\n", [s cString]);