2012-02-19 11:59:22 +00:00
|
|
|
|
2012-02-19 12:53:41 +00:00
|
|
|
/** Enterprise Control Configuration and Logging
|
2012-02-19 11:59:22 +00:00
|
|
|
|
2012-02-19 12:53:41 +00:00
|
|
|
Copyright (C) 2012 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
|
|
|
Date: Febrary 2010
|
|
|
|
Originally developed from 1996 to 2012 by Brainstorm, and donated to
|
|
|
|
the FSF.
|
|
|
|
|
|
|
|
This file is part of the GNUstep project.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 3 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
2013-09-03 10:55:21 +00:00
|
|
|
#if !defined(EC_DEFAULTS_PREFIX)
|
|
|
|
#define EC_DEFAULTS_PREFIX nil
|
|
|
|
#endif
|
|
|
|
#if !defined(EC_DEFAULTS_STRICT)
|
|
|
|
#define EC_DEFAULTS_STRICT NO
|
|
|
|
#endif
|
|
|
|
#if !defined(EC_EFFECTIVE_USER)
|
|
|
|
#define EC_EFFECTIVE_USER nil
|
|
|
|
#endif
|
|
|
|
|
2012-02-19 12:53:41 +00:00
|
|
|
#import "EcProcess.h"
|
2013-08-05 10:45:52 +00:00
|
|
|
#import "EcUserDefaults.h"
|
|
|
|
|
2012-02-19 11:59:22 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
CREATE_AUTORELEASE_POOL(arp);
|
2013-08-05 10:45:52 +00:00
|
|
|
NSUserDefaults *defs;
|
|
|
|
NSString *pref;
|
2012-02-19 11:59:22 +00:00
|
|
|
NSString *host;
|
|
|
|
NSString *name;
|
|
|
|
id proxy;
|
2013-08-05 10:45:52 +00:00
|
|
|
BOOL any = NO;
|
2012-02-19 11:59:22 +00:00
|
|
|
|
2013-08-05 10:45:52 +00:00
|
|
|
pref = EC_DEFAULTS_PREFIX;
|
|
|
|
if (nil == pref)
|
2012-02-19 11:59:22 +00:00
|
|
|
{
|
2013-08-05 10:45:52 +00:00
|
|
|
pref = @"";
|
2012-02-19 11:59:22 +00:00
|
|
|
}
|
2013-08-05 10:45:52 +00:00
|
|
|
defs = [NSUserDefaults userDefaultsWithPrefix: pref
|
|
|
|
strict: EC_DEFAULTS_STRICT];
|
2012-02-19 11:59:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Shut down the local command server.
|
|
|
|
*/
|
2013-08-05 10:45:52 +00:00
|
|
|
name = [defs stringForKey: @"CommandName"];
|
2012-02-19 11:59:22 +00:00
|
|
|
if (name == nil)
|
|
|
|
{
|
2013-08-05 10:45:52 +00:00
|
|
|
name = @"Command";
|
|
|
|
}
|
|
|
|
|
|
|
|
host = [defs stringForKey: @"CommandHost"];
|
|
|
|
if ([host length] == 0)
|
|
|
|
{
|
|
|
|
any = YES;
|
|
|
|
host = [[NSHost currentHost] name];
|
2012-02-19 11:59:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proxy = [NSConnection rootProxyForConnectionWithRegisteredName: name
|
|
|
|
host: host
|
|
|
|
usingNameServer: [NSSocketPortNameServer sharedInstance]];
|
|
|
|
|
2013-08-05 10:45:52 +00:00
|
|
|
if (nil == proxy && YES == any)
|
|
|
|
{
|
|
|
|
host = @"*";
|
|
|
|
proxy = [NSConnection rootProxyForConnectionWithRegisteredName: name
|
|
|
|
host: host
|
|
|
|
usingNameServer: [NSSocketPortNameServer sharedInstance]];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nil == proxy)
|
|
|
|
{
|
|
|
|
NSLog(@"Unable to contact %@ on %@", name, host);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[(id<Command>)proxy terminate];
|
|
|
|
}
|
2012-02-19 11:59:22 +00:00
|
|
|
RELEASE(arp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|