#include "scutil.h"
#include "session.h"
#include "notify.h"
void
do_open(int argc, char **argv)
{
if (store) {
CFRelease(store);
CFRelease(watchedKeys);
CFRelease(watchedPatterns);
}
store = SCDynamicStoreCreate(NULL, CFSTR("scutil"), storeCallback, NULL);
if (!store) {
SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
return;
}
watchedKeys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
watchedPatterns = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
return;
}
void
do_close(int argc, char **argv)
{
if (notifyRls) {
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), notifyRls, kCFRunLoopDefaultMode);
CFRelease(notifyRls);
notifyRls = NULL;
}
if (notifyRl) {
CFRunLoopStop(notifyRl);
notifyRl = NULL;
}
if (store) {
CFRelease(store);
store = NULL;
CFRelease(watchedKeys);
watchedKeys = NULL;
CFRelease(watchedPatterns);
watchedPatterns = NULL;
}
return;
}
void
do_lock(int argc, char **argv)
{
if (!SCDynamicStoreLock(store)) {
SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
}
return;
}
void
do_unlock(int argc, char **argv)
{
if (!SCDynamicStoreUnlock(store)) {
SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
}
return;
}