int main(int argc, char** argv) { DBusConnection* bus = NULL; DBusMessage* msg = NULL; DBusError error; DBusPendingCall* pending; dbus_error_init(&error); printf("Connecting to Session D-Bus\n"); bus = dbus_bus_get(DBUS_BUS_SESSION, &error); terminateOnError("Failed to open Session bus\n", &error); assert(bus != NULL); printf("Creating a message object\n"); msg = dbus_message_new_method_call( NOTIFY_TARGET, NOTIFY_OBJ_PATH, NOTIFY_INTERFACE, NOTIFY_METHOD); assert(msg != NULL); printf("Appending arguments to the message\n"); fillArgs(msg); #ifndef WAIT_FOR_REPLY dbus_message_set_no_reply(msg, TRUE); printf("Adding message to client send-queue\n"); dbus_connection_send(bus, msg, NULL); printf("Waiting for send-queue to be send out\n"); dbus_connection_flush(bus); printf("Cleaning up message\n"); dbus_message_unref(msg); #else printf("Adding message to client send-queue\n"); dbus_connection_send_with_reply(bus, msg, &pending, -1); printf("Waiting for send-queue to be send out\n"); dbus_connection_flush(bus); printf("Cleaning up message\n"); dbus_message_unref(msg); recvReply(pending); #endif printf("Cleaning up connection\n"); dbus_connection_unref(bus); return 0; }
CnfExp* CnfPass::produceDisjunction(Solver& solver, Edge e) { Edge largestEdge; CnfExp* accum = fillArgs(e, true, largestEdge); if (accum == NULL) accum = new CnfExp(false); // This is necessary to check to make sure that we don't start out // with an accumulator that is "too large". /// @todo Strictly speaking, introProxy doesn't *need* to free /// memory, then this wouldn't have to reallocate CnfExp /// @todo When this call to introProxy is made, the semantic /// negation pointer will have been destroyed. Thus, it will not /// be possible to use the correct proxy. That should be fixed. // at this point, we will either have NULL, or a destructible expression if (accum->clauseSize() > CLAUSE_MAX) accum = new CnfExp(introProxy(solver, largestEdge, accum, largestEdge.isNeg())); int i = _args.size(); while (i != 0) { Edge arg(_args[--i]); if (arg.isVar()) { accum->disjoin(atomLit(arg)); } else { CnfExp* argExp = (CnfExp*) arg->ptrAnnot(arg.isNeg()); assert(argExp != NULL); bool destroy = (--arg->intAnnot(arg.isNeg()) == 0); if (isProxy(argExp)) { // variable has been introduced accum->disjoin(getProxy(argExp)); } else if (argExp->litSize() == 0) { accum->disjoin(argExp, destroy); } else { // check to see if we should introduce a proxy int aL = accum->litSize(); // lits in accum int eL = argExp->litSize(); // lits in argument int aC = accum->clauseSize(); // clauses in accum int eC = argExp->clauseSize(); // clauses in argument if (eC > CLAUSE_MAX || (eL * aC + aL * eC > eL + aC + aL + aC)) { accum->disjoin(introProxy(solver, arg, argExp, arg.isNeg())); } else { accum->disjoin(argExp, destroy); if (destroy) arg->ptrAnnot(arg.isNeg()) = NULL; } } } } return accum; }
/*++ ******************************************************************************** FUNCTION: DESCRIPTION: ARGUMENTS: RETURNS: ******************************************************************************** --*/ int fExecute(char *execPath, char *paramList) { int err = 0; pid_t pid = fork(); if (pid==0) { char *args[100]; args[0] = execPath; fillArgs(args,paramList); err = execv(args[0], args); // Launch external process } else { waitpid(pid,0,0); /* wait for child to exit */ } return err; }