int main(int argc, char* argv[]) { // setup signal handlers setHandler(SIGINT, signalHandler, 0); setHandler(SIGHUP, signalHandler, 1); //initialize port and counts serverPort = 2000; clientCount = 0; killCount = 0; // check arg count and scan in arg if (argc != 2){ fprintf(stderr, "Error: Too few or too many arguments to %s.\n", argv[0]); cleanup(); exit(0); } strncpy(configPath, argv[1], strlen(argv[1])); // open the log files serverlog = fopen(getenv("PROCNANNYSERVERINFO"), "w"); logfile = fopen(getenv("PROCNANNYLOGS"), "w"); readFile(); /* read in the config file */ killPrevious("procnanny.server", getpid()); /* kill previous instances of procnanny server */ // server loops forever until it is sent SIGINT serverLoop(); /* shouldn't get here */ return (EXIT_SUCCESS); }
uint8_t startMenu() { selectedMenuItem = (menuItem*)&m_s1i1; dispMenu(0); setHandler(MSG_KEY_PRESS, &menuKey); setHandler(MSG_DISP_REFRESH, &dispMenu); return (0); }
void I2C_Init(void) { I2CM=1;//ведущий i2c_st.GLOBAL_STATE=I2C_RESTART; setHandler(I2C_IS_WRITE_MSG , &I2C_Is_Write); setHandler(I2C_IS_READ_MSG , &I2C_Is_Read); return; }
//--------------------------------------------------- unsigned char startMenu() { selectedMenuItem = (menuItem*)&m_s1i1; //printf("ERROR"); // dispMenu(0); setHandler(MSG_KEY_PRESS, &menuKey); setHandler(MSG_DISP_REFRESH, &dispMenu); setTimer(MSG_DISP_REFRESH, 0, 250); // setHandler(MSG_MENU_SELECT, &selectMenu); return (0); }
HTTPTransaction* HTTPUpstreamSession::newTransaction(HTTPTransaction::Handler* handler, int8_t priority) { CHECK_NOTNULL(handler); if (!supportsMoreTransactions() || draining_) { // This session doesn't support any more parallel transactions return nullptr; } if (!started_) { startNow(); } auto txn = createTransaction(codec_->createStream(), 0, priority); if (txn) { DestructorGuard dg(this); auto txnID = txn->getID(); txn->setHandler(handler); setNewTransactionPauseState(txnID); } return txn; }
TEST(EventLoop, invoke) { auto loop = std::make_shared<capnqml::EventLoop>(); bool invoked = false; bool handler_called = false; loop->setHandler([&](auto m) -> decltype (auto) { handler_called = true; return nullptr; }); loop->invoke([&]() { invoked = true; capnqml::Message msg; loop->push(std::move(msg)); }); ASSERT_EQ(loop->state(), capnqml::EventLoop::State::Startup); // NOLINT std::thread th([=] { loop->run(); // NOLINT }); th.detach(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); ASSERT_EQ(loop->state(), capnqml::EventLoop::State::Idle); // NOLINT loop->cancel(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); ASSERT_EQ(loop->state(), capnqml::EventLoop::State::Canceled); ASSERT_TRUE(invoked); ASSERT_TRUE(handler_called); }
void editText() { setHandler(); edit_text_interrupt = 0; free(text); text = (unsigned char*)calloc(1, sizeof(unsigned char)); text[0] = 0; size = 1; system("clear"); // trash input fgetc(stdin); while( ! edit_text_interrupt ) { char tmp = (unsigned char)fgetc(stdin); if( edit_text_interrupt == 1 || tmp == EOF || feof(stdin) ) break; text = (unsigned char*)realloc(text, ++size * sizeof(unsigned char)); text[size - 2] = tmp; text[size - 1] = 0; } // cut last \n text[size - 2] = 0; text[size - 1] = 0; size -= 1; unsetHandler(); }
void pfGUIControlMod::read(hsStream* S, plResManager* mgr) { plSingleModifier::read(S, mgr); fTagID = S->readInt(); fVisible = S->readBool(); setHandler(pfGUICtrlProcWriteableObject::Read(S)); if (S->readBool()) { fDynTextLayer = mgr->readKey(S); fDynTextMap = mgr->readKey(S); } if (S->readBool()) { setColorScheme(new pfGUIColorScheme()); fColorScheme->read(S); } else { setColorScheme(NULL); } fSoundIndices.resize(S->readByte()); for (size_t i=0; i<fSoundIndices.size(); i++) fSoundIndices[i] = S->readInt(); if (fFlags[kHasProxy]) fProxy = mgr->readKey(S); fSkin = mgr->readKey(S); }
MouseDriver::MouseDriver() : Driver("Mouse", "ps") { uint8_t status; Wait(1); io_outb(0x64, 0xA8); Wait(1); io_outb(0x64, 0x20); Wait(0); status = (io_inb(0x60) | 2); Wait(1); io_outb(0x64, 0x60); Wait(1); io_outb(0x60, status); // Valori di default MouseWrite(0xF6); MouseRead(); // Abilita lo sacmbio dati MouseWrite(0xF4); MouseRead(); // Scaling 1:1 MouseWrite(0xE6); MouseRead(); // Imposta l'handler setHandler(MouseDriver::IRQ, &MouseCallback); }
WaveShaperNode::WaveShaperNode(AbstractAudioContext& context) : AudioNode(context) { setHandler(AudioBasicProcessorHandler::create(AudioHandler::NodeTypeWaveShaper, *this, context.sampleRate(), adoptPtr(new WaveShaperProcessor(context.sampleRate(), 1)))); handler().initialize(); }
// ---------------------------------------------------------------- AudioBufferSourceNode::AudioBufferSourceNode(AbstractAudioContext& context, float sampleRate) : AudioScheduledSourceNode(context) , m_playbackRate(AudioParam::create(context, 1.0)) , m_detune(AudioParam::create(context, 0.0)) { setHandler(AudioBufferSourceHandler::create(*this, sampleRate, m_playbackRate->handler(), m_detune->handler())); }
PingServer::PingServer() : DatagramServiceThread("PingServer") { //setLockName("PingServerLock"); setHandler(this); setLogging(false); }
ExpatWrapper::ExpatWrapper(bool createParser) : XmlParserBase() { if (createParser) { expatParser = ::XML_ParserCreate(0); setHandler(); } }
void xmlrpc_server_abyss_set_handler3( xmlrpc_env * const envP, TServer * const srvP, const xmlrpc_server_abyss_handler_parms * const parmsP, unsigned int const parmSize) { struct uriHandlerXmlrpc * uriHandlerXmlrpcP; size_t xmlProcessorMaxStackSize; MALLOCVAR_NOFAIL(uriHandlerXmlrpcP); if (!envP->fault_occurred) { if (parmSize >= XMLRPC_AHPSIZE(xml_processor)) uriHandlerXmlrpcP->xmlProcessor = parmsP->xml_processor; else xmlrpc_faultf(envP, "Parameter too short to contain the required " "'xml_processor' member"); } if (!envP->fault_occurred) { if (parmSize >= XMLRPC_AHPSIZE(xml_processor_arg)) uriHandlerXmlrpcP->xmlProcessorArg = parmsP->xml_processor_arg; else xmlrpc_faultf(envP, "Parameter too short to contain the required " "'xml_processor_arg' member"); } if (!envP->fault_occurred) { if (parmSize >= XMLRPC_AHPSIZE(xml_processor_max_stack)) xmlProcessorMaxStackSize = parmsP->xml_processor_max_stack; else xmlrpc_faultf(envP, "Parameter too short to contain the required " "'xml_processor_max_stack' member"); } if (!envP->fault_occurred) { if (parmSize >= XMLRPC_AHPSIZE(uri_path) && parmsP->uri_path) uriHandlerXmlrpcP->uriPath = xmlrpc_strdupsol(parmsP->uri_path); else uriHandlerXmlrpcP->uriPath = xmlrpc_strdupsol("/RPC2"); if (parmSize >= XMLRPC_AHPSIZE(chunk_response) && parmsP->chunk_response) uriHandlerXmlrpcP->chunkResponse = parmsP->chunk_response; else uriHandlerXmlrpcP->chunkResponse = false; interpretHttpAccessControl(parmsP, parmSize, &uriHandlerXmlrpcP->accessControl); if (envP->fault_occurred) xmlrpc_termAccessControl(&uriHandlerXmlrpcP->accessControl); } if (!envP->fault_occurred) setHandler(envP, srvP, uriHandlerXmlrpcP, xmlProcessorMaxStackSize); if (envP->fault_occurred) free(uriHandlerXmlrpcP); }
ScriptProcessorNode::ScriptProcessorNode(BaseAudioContext& context, float sampleRate, size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfOutputChannels) : AudioNode(context), ActiveScriptWrappable(this) { setHandler(ScriptProcessorHandler::create(*this, sampleRate, bufferSize, numberOfInputChannels, numberOfOutputChannels)); }
KHCWidget::KHCWidget(QWidget* parent, const char* name, WFlags fl) : KHCWidgetBase(parent, name, fl) { m_isEnable = true; setLayout(); setHandler(); txtOrgKey->installEventFilter(this); txtMapKey->installEventFilter(this); }
options* initProgram(int argc, char** argv) { // init, get options and init SMC if(setHandler(sigintHandler, SIGINT)) FILE_ERR("Can't set sigint handler"); options* opt = getOptions(argc, argv); CHECK_ERROR_WHEN_NULL( opt ); smcInit(); printOptions(opt); return opt; }
// ---------------------------------------------------------------- AudioBufferSourceNode::AudioBufferSourceNode(AbstractAudioContext& context) : AudioScheduledSourceNode(context) , m_playbackRate(AudioParam::create(context, ParamTypeAudioBufferSourcePlaybackRate, 1.0)) , m_detune(AudioParam::create(context, ParamTypeAudioBufferSourceDetune, 0.0)) { setHandler(AudioBufferSourceHandler::create( *this, context.sampleRate(), m_playbackRate->handler(), m_detune->handler())); }
void pfGUIControlMod::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "ControlParams") { fTagID = tag->getParam("TagID", "0").toUint(); fVisible = tag->getParam("Visible", "true").toBool(); } else if (tag->getName() == "Handler") { if (tag->hasChildren()) setHandler(pfGUICtrlProcWriteableObject::PrcParse(tag->getFirstChild())); else setHandler(NULL); } else if (tag->getName() == "DynTextLayer") { if (tag->hasChildren()) fDynTextLayer = mgr->prcParseKey(tag->getFirstChild()); } else if (tag->getName() == "DynTextMap") { if (tag->hasChildren()) fDynTextMap = mgr->prcParseKey(tag->getFirstChild()); } else if (tag->getName() == "pfGUIColorScheme") { if (tag->getParam("NULL", "false")) { setColorScheme(NULL); } else { setColorScheme(new pfGUIColorScheme()); fColorScheme->prcParse(tag); } } else if (tag->getName() == "SoundIndices") { fSoundIndices.resize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fSoundIndices.size(); i++) { if (child->getName() != "SoundIndex") throw pfPrcTagException(__FILE__, __LINE__, child->getName()); fSoundIndices[i] = child->getParam("value", "0").toInt(); child = child->getNextSibling(); } } else if (tag->getName() == "Proxy") { if (tag->hasChildren()) fProxy = mgr->prcParseKey(tag->getFirstChild()); } else if (tag->getName() == "Skin") { if (tag->hasChildren()) fSkin = mgr->prcParseKey(tag->getFirstChild()); } else { plSingleModifier::IPrcParse(tag, mgr); } }
DelayNode::DelayNode(AbstractAudioContext& context, double maxDelayTime) : AudioNode(context) , m_delayTime(AudioParam::create(context, ParamTypeDelayDelayTime, 0.0, 0.0, maxDelayTime)) { setHandler(AudioBasicProcessorHandler::create( AudioHandler::NodeTypeDelay, *this, context.sampleRate(), wrapUnique(new DelayProcessor( context.sampleRate(), 1, m_delayTime->handler(), maxDelayTime)))); }
ManagerFilter::ManagerFilter() { // Initialize structures: streams, vars, mutexes, etc. this->sOut = getOutputHandler("out"); this->sWorkRequest = getOutputHandler("workRequest"); this->sNewWork = getInputHandler("newWork"); this->sNeedMore = getInputHandler("needMore"); this->currVal = 0; this->msgId = 1; this->hasRequest = false; pthread_mutex_init(&mWorkQueue, NULL); pthread_mutex_init(&mStatus, NULL); pthread_mutex_init(&mLog, NULL); // Open Log File log.open("manager.log", std::fstream::out); // Create initial work buildInitialWork(); // Set event handlers setHandler( sNewWork, &ManagerFilter::handleNewWork ); setHandler( sNeedMore, &ManagerFilter::handleNeedMore ); }
void startServer() { int timer; fd_set rdfs; blockGroup* block_group; struct timeval tval; tval.tv_sec = PING_TIMER; tval.tv_usec = 0; block_group = newBlockGroup(); block_group->server_socket = initServer(); block_group->max_socket = block_group->server_socket; printf("[IMPORTANT] : Press Enter to Stop the Boss\n"); for ( ;; ) { FD_ZERO(&rdfs); setHandler(block_group, &rdfs); if( (timer = select(block_group->max_socket + 1, &rdfs, NULL, NULL, &tval)) == -1) { QUIT_MSG("Can't select : "); } if ( timer == 0 ) { tval.tv_sec = handlerPresence(block_group); } #ifdef linux if( FD_ISSET(STDIN_FILENO, &rdfs) ) { break; } else #endif if( FD_ISSET(block_group->server_socket, &rdfs) ) { handleNewClient(block_group); } else { handlerClient(block_group, &rdfs); } } printf("[BYE] Server stop\n\n"); closeServer(block_group); return; }
void IRGenerator::accept(Handler& handler) { FNTRACE(); setHandler(getHandler(handler.name())); setInsertPoint(createBlock("EntryPoint")); this->handler()->setEntryPoint(getInsertPoint()); for (Symbol* symbol: *handler.scope()) { codegen(symbol); } codegen(handler.body()); createRet(get(false)); }
IIRFilterNode::IIRFilterNode(BaseAudioContext& context, const Vector<double> feedforwardCoef, const Vector<double> feedbackCoef) : AudioNode(context) { setHandler(AudioBasicProcessorHandler::create( AudioHandler::NodeTypeIIRFilter, *this, context.sampleRate(), wrapUnique(new IIRProcessor(context.sampleRate(), 1, feedforwardCoef, feedbackCoef)))); // Histogram of the IIRFilter order. createIIRFilter ensures that the length // of |feedbackCoef| is in the range [1, IIRFilter::kMaxOrder + 1]. The order // is one less than the length of this vector. DEFINE_STATIC_LOCAL(SparseHistogram, filterOrderHistogram, ("WebAudio.IIRFilterNode.Order")); filterOrderHistogram.sample(feedbackCoef.size() - 1); }
void IRGenerator::accept(Handler& handlerSym) { FNTRACE(); assert(handlerStack_.empty()); setHandler(getHandler(handlerSym.name())); setInsertPoint(createBlock("EntryPoint")); codegenInline(handlerSym); createRet(get(false)); handler()->verify(); assert(handlerStack_.empty()); }
DynamicsCompressorNode::DynamicsCompressorNode(AbstractAudioContext& context) : AudioNode(context) , m_threshold(AudioParam::create(context, ParamTypeDynamicsCompressorThreshold, -24, -100, 0)) , m_knee(AudioParam::create(context, ParamTypeDynamicsCompressorKnee, 30, 0, 40)) , m_ratio(AudioParam::create(context, ParamTypeDynamicsCompressorRatio, 12, 1, 20)) , m_attack(AudioParam::create(context, ParamTypeDynamicsCompressorAttack, 0.003, 0, 1)) , m_release(AudioParam::create(context, ParamTypeDynamicsCompressorRelease, 0.250, 0, 1)) { setHandler(DynamicsCompressorHandler::create( *this, context.sampleRate(), m_threshold->handler(), m_knee->handler(), m_ratio->handler(), m_attack->handler(), m_release->handler())); }
QuillImageFilterGenerator::QuillImageFilterGenerator(const QString &name) : priv(new QuillImageFilterGeneratorPrivate) { priv->m_result = 0; priv->m_resultingFilterPassed = 0; setValid(true); QuillImageFilterInterface *plugin = PluginLoader::instance(name); QuillImageFilterImplementation *handler = 0; QuillImageFilterImplementation *impl = 0; if (plugin) { impl = plugin->create(name); handler = dynamic_cast<QuillImageFilterGeneratorImplementation*>(impl); } if (!handler) { delete impl; handler = new QuillImageFilterGeneratorImplementation; setValid(false); } setHandler(handler); }
void CLI_Configure(void) { #ifdef _USE_CLI_ P4SEL |= BIT5 + BIT4; /* P4.4,5 = USCI_A1 TXD/RXD */ UCA1CTL1 |= UCSWRST; /* Put state machine in reset */ UCA1CTL0 = 0x00; UCA1CTL1 = UCSSEL__SMCLK + UCSWRST; /* Use SMCLK, keep RESET */ UCA1BR0 = 0xD9; /* 25MHz/115200= 217.01 =0xD9 (see User's Guide) */ UCA1BR1 = 0x0; /* 25MHz/9600= 2604 =0xA2C (see User's Guide) */ UCA1MCTL = UCBRS_3 + UCBRF_0; /* Modulation UCBRSx=3, UCBRFx=0 */ UCA1CTL1 &= ~UCSWRST; /* Initialize USCI state machine */ /* Disable RX Interrupt on UART */ UCA1IFG &= ~ (UCRXIFG | UCRXIFG); UCA1IE &= ~UCRXIE; RTOS_MUTEX_CREATE(&g_printLock); setHandler(&CLI_Put); #endif }
ScriptProcessorNode::ScriptProcessorNode(AbstractAudioContext& context, float sampleRate, size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfOutputChannels) : AudioNode(context) { setHandler(ScriptProcessorHandler::create(*this, sampleRate, bufferSize, numberOfInputChannels, numberOfOutputChannels)); }
StereoPannerNode::StereoPannerNode(AbstractAudioContext& context, float sampleRate) : AudioNode(context) , m_pan(AudioParam::create(context, 0)) { setHandler(StereoPannerHandler::create(*this, sampleRate, m_pan->handler())); }