예제 #1
0
IO_METHOD(IoObject, shellExecute)
{
	LPCTSTR operation;
	LPCTSTR file;
	LPCTSTR parameters;
	LPCTSTR directory;
	int displayFlag;
	int result;

	operation = CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 0));
	file = CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 1));
	parameters = IoMessage_argCount(m) > 2 ? CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 2)) : NULL;
	directory = IoMessage_argCount(m) > 3 ? CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 3)) : NULL;
	displayFlag = IoMessage_argCount(m) > 4 ? IoMessage_locals_intArgAt_(m, locals, 4) : SW_SHOWNORMAL;

	result = (int)ShellExecute(NULL, operation, file, parameters, directory, displayFlag);

	if(result > 32)
	{
		return self;
	}
	else
	{
		return (IoObject *)IoError_newWithMessageFormat_(IOSTATE, "ShellExecute Error %i", result);
	}
}
예제 #2
0
IoObject *IoEventManager_listenUntilEvent(IoEventManager *self, IoObject *locals, IoMessage *m)
{
	int hadEvents = event_base_loop(DATA(self)->eventBase, EVLOOP_ONCE);

	if (hadEvents == -1)
	{
		return IoError_newWithMessageFormat_(IOSTATE, "EventManager: error in event_base_loop");
	}

	return self;
}
예제 #3
0
IoObject *IoEventManager_addEvent(IoEventManager *self, IoObject *locals, IoMessage *m)
{
	IoEvent *event = IoMessage_locals_eventArgAt_(m, locals, 0);
	struct event *ev = IoEvent_rawEvent(event);

	int fd = IoMessage_locals_intArgAt_(m, locals, 1);

	int eventType = IoMessage_locals_intArgAt_(m, locals, 2);

	double timeout = IoMessage_locals_doubleArgAt_(m, locals, 3);
	struct timeval tv = timevalFromDouble(timeout);

	//printf("IoEventManager_addEvent type:%i descriptor:%i\n", eventType, fd);
	//printf("fcntl(fd, F_GETFL, NULL) = %i\n", fcntl(fd, F_GETFL, NULL));

	if (eventType != 0 && !RawDescriptor_isValid(fd))
	{
		return IoError_newWithMessageFormat_(IOSTATE, "IoEventManager_addEvent: attempt to add bad file descriptor %i", fd);
	}

	List_append_(DATA(self)->activeEvents, IOREF(event));

	event_set(ev, fd, eventType, IoEvent_handleEvent, event);
	event_base_set(DATA(self)->eventBase, ev);

	if (timeout < 0)
	{
		event_add(ev, NULL); // no timeout
	}
	else
	{
		event_add(ev, &tv);
	}

	return self;
}