Manager::~Manager() { shutDown(); }
cAudioManager::~cAudioManager() { shutDown(); }
/* reboot handler */ static void sigintHandler(int signum) { termReset(); shutDown(getNoKill(), 1, 0); }
WorkerObject::~WorkerObject() { shutDown(); delete d; }
App::~App(void) { shutDown(); }
int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer initMSP430(); while (1) { if (packetIndex > 40) { _disable_interrupt(); while(packetData[i] != 2 && i < 80){ i++; } for(j = 0; j < 31; j++){ i++; irPacket += packetData[i]; irPacket <<= 1; } if(irPacket == CH_UP){ initRobot(); moveForward(50); newPacket = TRUE; } if(irPacket == CH_DW){ initRobot(); moveBackward(50); newPacket = TRUE; } if(irPacket == VOL_UP){ initRobot(); turnRight(50); newPacket = TRUE; } if(irPacket == VOL_DW){ initRobot(); turnLeft(50); newPacket = TRUE; } if(irPacket == ONE){ newPacket = TRUE; } if(irPacket == TWO){ newPacket = TRUE; } if(irPacket == THR){ newPacket = TRUE; } if(irPacket == PWR){ newPacket = TRUE; shutDown(); } if(newPacket == TRUE){ initMSP430(); newPacket = FALSE; } i = 0; packetIndex = 0; _enable_interrupt(); } // end if new IR packet arrived } }
ExtraRfbServers::~ExtraRfbServers() { try { shutDown(); } catch (...) { } }
/* Name DirectInput::getDevices Syntax directInputObj.getDevices() Return Bool - Returns false is fails to get input device Brief Creates the keyboard and mouse input devices */ bool DirectInput::getDevices() { shutDown(); if (FAILED(DirectInput8Create(GetModuleHandle(0), 0x0800, IID_IDirectInput8, (void**)&diObject_, 0))) { return false; } //////////////////////// // Keyboard //////////////////////// // Create keyboard device if (FAILED(diObject_->CreateDevice(GUID_SysKeyboard, &keyboardDevice_, 0))) { return false; } // Set the Data format (c_dfDIKeyboard is standard Dirx Global) if (FAILED(keyboardDevice_->SetDataFormat(&c_dfDIKeyboard))) { shutDown(); return false; } // How the app handles control of keyboard when switching window etc. if (FAILED(keyboardDevice_->SetCooperativeLevel(0, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))) { shutDown(); return false; } // The header DIPROPDWORD dipdw; dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; // The data dipdw.dwData = KEYBOARD_BUFFER_SIZE; // Aquiring the keyboard now everything is set up if (FAILED(keyboardDevice_->Acquire())) { shutDown(); return false; } //////////////////////// // Mouse //////////////////////// // Create mouse device if (FAILED(diObject_->CreateDevice(GUID_SysMouse, &mouseDevice_, 0))) { return false; } if (FAILED(mouseDevice_->SetCooperativeLevel(0, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))) { shutDown(); return false; } // c_dfDIMouse is a standard Dirx Global if (FAILED(mouseDevice_->SetDataFormat(&c_dfDIMouse2))) { shutDown(); return false; } // Aquiring the mouse now everything is set up if (FAILED(mouseDevice_->Acquire())) { shutDown(); return false; } return true; }
/* Name DirectInput::~DirectInput Syntax ~DirectInput() Brief DirectInput destructor calls shutDown */ DirectInput::~DirectInput() { shutDown(); }
static KWBoolean master( const char recvGrade, const KWBoolean overrideGrade, const KWBoolean runUUXQT ) { CONN_STATE m_state = CONN_INITSTAT; CONN_STATE old_state = CONN_EXIT; char sendGrade = ALL_GRADES; KWBoolean contacted = KWFalse; KWBoolean needUUXQT = KWFalse; /*--------------------------------------------------------------------*/ /* Validate the system to call */ /*--------------------------------------------------------------------*/ if ( !equal( Rmtname, "any" ) && !equal( Rmtname, "all" )) { if ( checkreal( Rmtname ) == NULL ) { printmsg(0,"%s is not \"any\", \"all\", or a valid system to call", Rmtname); printmsg(0,"Run UUNAME for a list of callable systems"); panic(); } } if ((fsys = FOPEN(E_systems, "r",TEXT_MODE)) == nil(FILE)) { printerr(E_systems); panic(); } setvbuf( fsys, NULL, _IONBF, 0); while (m_state != CONN_EXIT ) { printmsg(old_state == m_state ? 10 : 4 , "M state = %c", m_state); old_state = m_state; switch (m_state) { case CONN_INITSTAT: HostStatus(); m_state = CONN_INITIALIZE; break; case CONN_INITIALIZE: setTitle("Determining system to call"); hostp = NULL; if ( locked ) UnlockSystem(); m_state = getsystem(recvGrade); if ( hostp != NULL ) remote_stats.hstatus = hostp->status.hstatus; break; case CONN_CHECKTIME: sendGrade = checktime(flds[FLD_CCTIME]); if ( (overrideGrade && sendGrade) || callnow ) sendGrade = recvGrade; if ( !CallWindow( sendGrade )) m_state = CONN_INITIALIZE; else if ( LockSystem( hostp->hostname , B_UUCICO)) { dialed = KWTrue; time(&hostp->status.ltime); /* Save time of last attempt to call */ hostp->status.hstatus = HS_AUTODIAL; m_state = CONN_MODEM; } else m_state = CONN_INITIALIZE; break; case CONN_NOGRADE: CallWindow( 0 ); /* Simply to update last time called */ m_state = CONN_INITIALIZE; break; case CONN_MODEM: if (getmodem(flds[FLD_TYPE])) m_state = CONN_DIALOUT; else { hostp->status.hstatus = HS_INVALID_DEVICE; m_state = CONN_INITIALIZE; } break; case CONN_DIALOUT: if ( !IsNetwork() ) { setTitle( "Allocating modem on %s", M_device); if (suspend_other(KWTrue, M_device ) < 0 ) { hostp->status.hstatus = HS_NODEVICE; suspend_other(KWFalse, M_device ); /* Resume modem */ m_state = CONN_INITIALIZE; /* Try next system */ break; } } /* if */ setTitle( "Calling %s on %s", rmtname, M_device ); m_state = callup( ); break; case CONN_PROTOCOL: m_state = startup_server( (char) (bflag[F_SYMMETRICGRADES] ? sendGrade : recvGrade) ); break; case CONN_SERVER: if (bflag[F_MULTITASK]) dcupdate(); setTitle("%s connected to %s", securep->myname, hostp->via ); m_state = process( POLL_ACTIVE, sendGrade ); contacted = KWTrue; break; case CONN_TERMINATE: m_state = sysend(); if ( hostp != NULL ) { if (hostp->status.hstatus == HS_INPROGRESS) hostp->status.hstatus = HS_CALL_FAILED; dcstats(); needUUXQT = KWTrue; } break; case CONN_TIMESET: contacted = KWTrue; m_state = CONN_DROPLINE; break; case CONN_DROPLINE: setTitle("Closing port %s", M_device); shutDown(); UnlockSystem(); setTitle("Not connected"); m_state = CONN_CLEANUP; break; case CONN_CLEANUP: if ( runUUXQT && needUUXQT ) m_state = CONN_UUXQT; else m_state = CONN_INITIALIZE; break; case CONN_UUXQT: { char buf[100]; sprintf( buf, "-s %s -x %d", rmtname, debuglevel ); copylog(); execute( "uuxqt", buf, NULL, NULL, KWFalse, KWFalse ); openlog(NULL); } needUUXQT = KWFalse; m_state = CONN_INITIALIZE; break; case CONN_EXIT: break; default: printmsg(0,"dcpmain: Unknown master state = %c",m_state ); panic(); break; } /* switch */ if ( terminate_processing ) m_state = CONN_EXIT; } /* while */ setTitle("Exiting"); fclose(fsys); return contacted; } /* master */
static KWBoolean client( const time_t exitTime, const char *hotUser, const BPS hotBPS, const int hotHandle, const KWBoolean runUUXQT ) { CONN_STATE s_state = CONN_INITIALIZE; CONN_STATE old_state = CONN_EXIT; KWBoolean contacted = KWFalse; KWBoolean needUUXQT = KWFalse; char sendGrade = ALL_GRADES; /*--------------------------------------------------------------------*/ /* Trap missing modem entry */ /*--------------------------------------------------------------------*/ if ( E_inmodem == NULL ) { printmsg(0,"No modem specified in configuration file or command line"); panic(); } if (!getmodem(E_inmodem)) /* Initialize modem configuration */ panic(); /* Avoid loop if bad modem name */ if ( ! IsNetwork() && ( hotUser == NULL ) && (hotHandle == -1 ) && ! suspend_init(M_device)) { #ifdef WIN32 if (!isWinNT()) { printmsg(0,"Unable to set up pipe for suspending; " "may be unsupported in this environment (use NT for modem sharing)."); } else #endif /* else under WIN32, otherwise unconditional */ { printmsg(0,"Unable to set up pipe for suspending; " "is another UUCICO running?" ); panic(); } } while (s_state != CONN_EXIT ) { printmsg(s_state == old_state ? 10 : 4 , "S state = %c", s_state); old_state = s_state; switch (s_state) { case CONN_INITIALIZE: if (( hotUser == NULL ) && (hotHandle == -1 )) s_state = CONN_ANSWER; else s_state = CONN_HOTMODEM; break; case CONN_WAIT: #if !defined(__TURBOC__) || defined(BIT32ENV) setTitle("Port %s suspended", M_device); s_state = suspend_wait(); #else panic(); /* Why are we here?! */ #endif break; case CONN_ANSWER: setTitle("Monitoring port %s", M_device); s_state = callin( exitTime ); break; case CONN_HOTMODEM: s_state = callhot( hotBPS, hotHandle ); break; case CONN_HOTLOGIN: if ( hotUser == NULL ) /* User specified to login? */ s_state = CONN_LOGIN; /* No --> Process normally */ else if ( loginbypass( hotUser ) ) s_state = CONN_INITSTAT; else s_state = CONN_DROPLINE; break; case CONN_LOGIN: setTitle("Processing login on %s", M_device ); if ( login( ) ) s_state = CONN_INITSTAT; else s_state = CONN_DROPLINE; break; case CONN_INITSTAT: HostStatus(); s_state = CONN_PROTOCOL; break; case CONN_PROTOCOL: setTitle("Establishing connection on %s", M_device); s_state = startup_client(&sendGrade); break; case CONN_CLIENT: contacted = KWTrue; if (bflag[F_MULTITASK]) dcupdate(); setTitle("%s connected to %s", securep->myname, hostp->via, M_device); s_state = process( POLL_PASSIVE, sendGrade ); break; case CONN_TERMINATE: s_state = sysend(); if ( hostp != NULL ) { dcstats(); needUUXQT = KWTrue; } break; case CONN_DROPLINE: shutDown(); if ( locked ) /* Cause could get here w/o locking */ UnlockSystem(); s_state = CONN_CLEANUP; break; case CONN_CLEANUP: if ( runUUXQT && needUUXQT ) s_state = CONN_UUXQT; else s_state = CONN_EXIT; break; case CONN_UUXQT: { char buf[100]; sprintf( buf, "-s %s -x %d", rmtname, debuglevel ); copylog(); execute( "uuxqt", buf, NULL, NULL, KWFalse, KWFalse ); openlog(NULL); } needUUXQT = KWFalse; s_state = CONN_EXIT; break; case CONN_EXIT: break; default: printmsg(0,"dcpmain: Unknown slave state = %c",s_state ); panic(); break; } /* switch */ if ( terminate_processing ) s_state = CONN_EXIT; } /* while */ return contacted; } /* client */
Terrain::~Terrain() { shutDown(); }
AudioSystem& AudioSystem::operator=(AudioSystem &&other) { shutDown(); move(std::move(other)); return *this; }
AudioSystem::~AudioSystem() { shutDown(); }
KSlovar::KSlovar() : KMainWindow( 0, "KSlovar" ), m_dictionarydlg(0), m_recievedPackages(0) { KSlovar::m_instance=this; m_configDialog=new KSConfigDialog(this, "settings", Configuration::self()); new KStatusBar(this); statusBar()->insertItem(i18n("Ready."), 0); if(!QFile::exists(locateLocal("config", "kslovarrc", false))) { slotFirstRunWizard(); } else { if(Configuration::autoUpdateLanguage()) { slotDownloadLanguage(); } else { loadLanguages(); } } m_welcomeMessage=i18n("<h1>Welcome to KSlovar</h1> <p>This is an editor and viewer that is capable of creating, editing and showing diferent kinds of dictionaries.</p><p>If you encounter any bugs, please send a bug report to [email protected].</p>"); registerButtons(); addMenu(); addToolbar(); QHBox * horiz = new QHBox(this); m_split = new QSplitter(horiz); QVBox * vert = new QVBox(m_split); vert->setMaximumWidth(200); vert->setMinimumWidth(200); m_search = new KSSearchLine(vert); m_list = new KSListView( vert ); m_list->addColumn("name"); m_list->setColumnWidth(0, 193); m_list->setFullWidth(true); m_search->setList(m_list); KSData::instance()->setMainList(m_list); m_browser=new KHTMLPart(m_split); m_browser->setEncoding("utf-8", true); m_browser->view()->viewport()->installEventFilter(this); //For searching with middle click slotClose(); connect( m_browser->browserExtension(), SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ), this, SLOT( slotShowBrowser(const KURL &, const KParts::URLArgs &) ) ); connect(m_list, SIGNAL( selectionChanged(QListViewItem *)), this, SLOT( slotShowList(QListViewItem *) ) ); connect(m_list, SIGNAL(doubleClicked( QListViewItem *)), this, SLOT(slotEditPhrase())); connect(kapp, SIGNAL(shutDown()), this, SLOT(slotClose())); connect(m_list, SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint&)), this, SLOT(showPopup( KListView*, QListViewItem*, const QPoint& ))); connect(m_list, SIGNAL(recievedPackage(bool, bool)), this, SLOT(slotCountPackages(bool, bool))); setCentralWidget(horiz); }
int main (int argc, char * argv[]) { char * config_file_name = "vrpn.cfg"; char * client_name = NULL; int client_port; bool bail_on_error = true; int auto_quit = 0; int realparams = 0; int i; int port = vrpn_DEFAULT_LISTEN_PORT_NO; #ifdef _WIN32 // On Windows, the millisleep with 0 option frees up the CPU time slice for other jobs // but does not sleep for a specific time. On Unix, this returns immediately and does // not do anything but waste cycles. int milli_sleep_time = 5; // How long to sleep each iteration (default: free the timeslice but be runnable again immediately) #else int milli_sleep_time = 1; // How long to sleep each iteration (default: 1ms) #endif #ifdef _WIN32 WSADATA wsaData; int status; if ((status = WSAStartup(MAKEWORD(1,1), &wsaData)) != 0) { fprintf(stderr, "WSAStartup failed with %d\n", status); return(1); } // This handles all kinds of signals. SetConsoleCtrlHandler(handleConsoleSignalsWin, TRUE); #else #ifdef sgi sigset( SIGINT, sighandler ); sigset( SIGKILL, sighandler ); sigset( SIGTERM, sighandler ); sigset( SIGPIPE, sighandler ); #else signal( SIGINT, sighandler ); signal( SIGKILL, sighandler ); signal( SIGTERM, sighandler ); signal( SIGPIPE, sighandler ); #endif // not sgi #endif // not WIN32 // Parse the command line i = 1; while (i < argc) { if (!strcmp(argv[i], "-f")) { // Specify config-file name if (++i > argc) { Usage(argv[0]); } config_file_name = argv[i]; } else if (!strcmp(argv[i], "-millisleep")) { // How long to sleep each loop? if (++i > argc) { Usage(argv[0]); } milli_sleep_time = atoi(argv[i]); } else if (!strcmp(argv[i], "-warn")) {// Don't bail on errors bail_on_error = false; } else if (!strcmp(argv[i], "-v")) { // Verbose verbose = true; } else if (!strcmp(argv[i], "-q")) { // quit on dropped last con auto_quit = 1; } else if (!strcmp(argv[i], "-client")) { // specify a waiting client if (++i > argc) { Usage(argv[0]); } client_name = argv[i]; if (++i > argc) { Usage(argv[0]); } client_port = atoi(argv[i]); } else if (!strcmp(argv[i], "-NIC")) { // specify a network interface if (++i > argc) { Usage(argv[0]); } if (verbose) { fprintf(stderr, "Listening on network interface card %s.\n", argv[i]); } g_NICname = argv[i]; } else if (!strcmp(argv[i], "-li")) { // specify server-side logging if (++i > argc) { Usage(argv[0]); } if (verbose) { fprintf(stderr, "Incoming logfile name %s.\n", argv[i]); } g_inLogName = argv[i]; } else if (!strcmp(argv[i], "-lo")) { // specify server-side logging g_outLogName = argv[i]; if (++i > argc) { Usage(argv[0]); } if (verbose) { fprintf(stderr, "Outgoing logfile name %s.\n", argv[i]); } } else if (argv[i][0] == '-') { // Unknown flag Usage(argv[0]); } else switch (realparams) { // Non-flag parameters case 0: port = atoi(argv[i]); realparams++; break; default: Usage(argv[0]); } i++; } // Need to have a global pointer to it so we can shut it down // in the signal handler (so we can close any open logfiles.) //vrpn_Synchronized_Connection connection; connection = new vrpn_Connection (port, g_inLogName, g_outLogName, g_NICname); // Create the generic server object and make sure it is doing okay. generic_server = new vrpn_Generic_Server_Object(connection, config_file_name, port, verbose, bail_on_error); if ( (generic_server == NULL) || !generic_server->doing_okay() ) { fprintf(stderr,"Could not start generic server, exiting\n"); shutDown(); } // Open the Forwarder Server forwarderServer = new vrpn_Forwarder_Server (connection); // If we're set to auto-quit, then register a handler for the last connection // dropped that will cause a callback which will exit. if (auto_quit) { int dlc_m_id = connection->register_message_type( vrpn_dropped_last_connection); connection->register_handler(dlc_m_id, handle_dlc, NULL); } if (client_name) { if (verbose) { fprintf(stderr, "vrpn_serv: connecting to client: %s:%d\n", client_name, client_port); } if (connection->connect_to_client(client_name, client_port)) { fprintf(stderr, "server: could not connect to client %s:%d\n", client_name, client_port); shutDown(); } } // ******************************************************************** // ** ** // ** MAIN LOOP ** // ** ** // ******************************************************************** while (!done) { // Let the generic object server do its thing. if (generic_server) { generic_server->mainloop(); } // Send and receive all messages connection->mainloop(); if (!connection->doing_okay()) { shutDown(); } // Handle forwarding requests; send messages // on auxiliary connections forwarderServer->mainloop(); // Sleep so we don't eat the CPU #if defined(_WIN32) if (milli_sleep_time >= 0) { #else if (milli_sleep_time > 0) { #endif vrpn_SleepMsecs(milli_sleep_time); } } shutDown(); return 0; }
void GBaseEngine::OnStateStackEmpty() { GTRACE(1, "the state stack is empty... shutting down..."); shutDown(); }
int VRPN_CALLBACK handle_dlc (void *, vrpn_HANDLERPARAM p) { shutDown(); return 0; }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { WNDCLASSEX winClass; MSG uMsg; memset(&uMsg,0,sizeof(uMsg)); winClass.lpszClassName = "MY_WINDOWS_CLASS"; winClass.cbSize = sizeof(WNDCLASSEX); winClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; winClass.lpfnWndProc = WindowProc; winClass.hInstance = hInstance; winClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); winClass.hCursor = LoadCursor(NULL, IDC_ARROW); winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winClass.lpszMenuName = NULL; winClass.cbClsExtra = 0; winClass.cbWndExtra = 0; if( !RegisterClassEx(&winClass) ) return E_FAIL; hWnd = CreateWindowEx( 0,"MY_WINDOWS_CLASS", "D1_C3", WS_OVERLAPPEDWINDOW, 0, 0, (DWORD)screenWidth, (DWORD)screenHeight, 0, 0, hInstance, 0 );//WS_POPUP | WS_VISIBLE,<<<----fullscreen if( hWnd == NULL ) return E_FAIL; ShowWindow( hWnd, nCmdShow ); UpdateWindow( hWnd ); Init(); Dot3shader(); while( uMsg.message != WM_QUIT ) { if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &uMsg ); DispatchMessage( &uMsg ); } else if(over == true) { break; } else { ProcessKeyboard(); render(); } } shutDown(); UnregisterClass( "MY_WINDOWS_CLASS", hInstance ); return uMsg.wParam; }
void CWinMain::quazaaShutdown() { CDialogSplash* dlgSplash = new CDialogSplash(); dlgSplash->show(); dlgSplash->updateProgress( 95, tr( "Saving UI..." ) ); qApp->processEvents(); quazaaSettings.WinMain.MainToolbar = saveState(); pageHome->saveWidget(); pageLibrary->saveWidget(); pageMedia->saveWidget(); pageSearch->saveWidget(); pageTransfers->saveWidget(); pageSecurity->saveWidget(); pageActivity->saveWidget(); pageIrcMain->saveWidget(); pageHostCache->saveWidget(); pageDiscovery->saveWidget(); pageScheduler->saveWidget(); pageGraph->saveWidget(); pagePacketDump->saveWidget(); pageSearchMonitor->saveWidget(); pageHitMonitor->saveWidget(); quazaaSettings.saveWindowSettings( this ); emit shutDown(); dlgSplash->updateProgress( 90, tr( "Saving Settings..." ) ); qApp->processEvents(); quazaaSettings.saveSettings(); dlgSplash->updateProgress( 85, tr( "Closing Networks..." ) ); qApp->processEvents(); neighboursRefresher->stop(); delete neighboursRefresher; neighboursRefresher = 0; networkG2.stop(); shareManager.stop(); dlgSplash->updateProgress( 65, tr( "Saving Security Manager..." ) ); qApp->processEvents(); securityManager.stop(); // Prepare Security Manager for shutdown (this includes saving the security rules to disk) dlgSplash->updateProgress( 55, tr( "Saving Discovery Manager..." ) ); qApp->processEvents(); discoveryManager.stop(); dlgSplash->updateProgress( 50, tr( "Saving Host Cache..." ) ); qApp->processEvents(); hostCache.stop(); dlgSplash->updateProgress( 30, tr( "Removing Tray Icon..." ) ); qApp->processEvents(); trayIcon->hide(); trayIcon->deleteLater(); dlgSplash->updateProgress( 15, tr( "Stopping transfers..." ) ); qApp->processEvents(); transfers.stop(); qApp->processEvents(); dlgSplash->close(); delete this; }
void update() { maple_device_t *cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); if (cont) { cont_state_t *state = (cont_state_t *) maple_dev_status(cont); if (!state) return; if (state->buttons & CONT_DPAD_UP || state->buttons & CONT_DPAD2_UP) { //dbglog(DBG_DEBUG, "\nDPad UP Pressed\n"); if (stateM == statePaused) { dbglog(DBG_DEBUG, "\n*** RESUME RENDERING PVR ***\n\n"); stateM = stateMenu; } else if (stateM != statePaused) { dbglog(DBG_DEBUG, "\n*** PAUSE RENDERING PVR ***\n"); stateM = statePaused; } usleep(400000); } if (state->buttons & CONT_DPAD_DOWN || state->buttons & CONT_DPAD2_DOWN) { dbglog(DBG_DEBUG, "~ Settings ~\n"); settingDBRead("/hd/settings.conf"); usleep(400000); } if (state->buttons & CONT_DPAD_LEFT || state->buttons & CONT_DPAD2_LEFT) { usleep(400000); } if (state->buttons & CONT_DPAD_RIGHT || state->buttons & CONT_DPAD2_RIGHT) { } if (state->buttons & CONT_Y) { //dbglog(DBG_DEBUG, "\nButton Y Pressed\n"); if (writeRTF()) dbglog(DBG_DEBUG, "** FS WRITE FAILED!\n"); if (settingDBWrite("/hd/settings.conf", "CYRUS", "HelloWorld", 1)) dbglog(DBG_DEBUG, "** Settings Save Failed!\n"); usleep(400000); } if (state->buttons & CONT_A) { dbglog(DBG_DEBUG, "\nBooting romdisk binary...\n"); if (executeSub("/rd/SUB.ECS")) dbglog(DBG_DEBUG, "** EXEC FAILED!\n"); usleep(400000); } if (state->buttons & CONT_X) { //dbglog(DBG_DEBUG, "\nButton X Pressed\n"); if (mountState) { mountCTL("/hd", 0); mountState = 0; } else if (!mountState) { mountCTL("/hd", 1); mountState = 1; } usleep(400000); } if (state->buttons & CONT_B) { //dbglog(DBG_DEBUG, "\nButton B Pressed\n"); bCount += 1; if (bCount == 2) { bCount = 0; stateM = stateMenu; dbglog(DBG_DEBUG, "~ STATEMACHINE set to Menu\n"); } else if (mountState) { stateM = statePrintDIR; dbglog(DBG_DEBUG, "~ STATEMACHINE set to PrintDIR\n"); } usleep(400000); } if (state->buttons & CONT_START) { dbglog(DBG_DEBUG, "\nStart Pressed\n\n"); shutDown("/hd"); } } }
int playbackFileInit (char *file) { #if DEBUG_LEVEL & DBG_PLBK logMsg (DBG_PLBK, "Playback routines using file: %s, ", file); #endif if (playbackSetMode (NULL) == RECORD_MODE) { logMsg (DBG_PLBK, "mode: 'RECORD_MODE'\n"); } else { logMsg (DBG_PLBK, "mode: 'PLAY_MODE'\n"); } switch (playbackSetMode (NULL)) { case PLAY_MODE: if ((stream = fopen (file, "r")) == NULL) { logMsg (DBG_GEN, "Uh Oh! Couldn't open playback file: %s\n", strerror (errno)); shutDown (); } /* Lead the header into memory */ if (fread (&header, sizeof (struct playback_h), 1, stream) == 0) { logMsg (DBG_GEN, "Error reading in playback header: %s\n", strerror (errno)); return 0; } break; case RECORD_MODE: if ((stream = fopen (file, "w")) == NULL) { logMsg (DBG_GEN, "Uh Oh! Couldn't create recoding file: %s\n", strerror (errno)); shutdown (); } memset (&header, 0, sizeof (struct playback_h)); header.major_ver = PLAYBACK_MAJOR_VER; header.minor_ver = PLAYBACK_MINOR_VER; header.max_events = MAX_PLAYBACK_EVENTS; /* Our initial start position can be found right after * the header */ header.start_pos = sizeof (struct playback_h); gettimeofday (&header.start_t, NULL); /* Initialize the file with the header. Note that end_t is initially * left at zero */ if (fwrite (&header, sizeof (struct playback_h), 1, stream) == 0) { logMsg (DBG_GEN, "Error initializing file with playback header: %s\n", strerror (errno)); return 0; } /* Flush out the header */ fflush (stream); break; default: logMsg (DBG_DEF, "Uh Oh! peepd asked to use invalid mode for playback. Please specify: {PLAY_MODE, RECORD_MODE}\n"); shutdown (); } #if DEBUG_LEVEL & DBG_PLBK logMsg (DBG_PLBK, "The playback header is:\n"); logMsg (DBG_PLBK, "\tmajor ver: [%d]\n", header.major_ver); logMsg (DBG_PLBK, "\tminor ver: [%d]\n", header.minor_ver); logMsg (DBG_PLBK, "\tmax events: [%d]\n", header.max_events); logMsg (DBG_PLBK, "\tevents written: [%d]\n", header.written); logMsg (DBG_PLBK, "\tstart pos: [%d]\n", header.start_pos); logMsg (DBG_PLBK, "\tstart time: [%lf]\n", TP_IN_FP_SECS (header.start_t)); logMsg (DBG_PLBK, "\tend time: [%lf]\n", TP_IN_FP_SECS (header.end_t)); #endif return 1; }
Service::~Service() { shutDown(); exit(); }
int main(int argc, char **argv) { pid_t installpid, childpid; int waitStatus; int fd = -1; int doReboot = 0; int doShutdown =0; int isSerial = 0; char * console = NULL; int noKill = 0; char * argvc[15]; char ** argvp = argvc; char twelve = 12; struct serial_struct si; int i, disable_keys; if (!strncmp(basename(argv[0]), "poweroff", 8)) { printf("Running poweroff...\n"); fd = getInitPid(); if (fd > 0) kill(fd, SIGUSR2); exit(0); } else if (!strncmp(basename(argv[0]), "halt", 4)) { printf("Running halt...\n"); fd = getInitPid(); if (fd > 0) kill(fd, SIGUSR1); exit(0); } else if (!strncmp(basename(argv[0]), "reboot", 6)) { printf("Running reboot...\n"); fd = getInitPid(); if (fd > 0) kill(fd, SIGINT); exit(0); } #if !defined(__s390__) && !defined(__s390x__) testing = (getppid() != 0) && (getppid() != 1); #endif if (!testing) { /* turn off screen blanking */ printstr("\033[9;0]"); printstr("\033[8]"); } else { printstr("(running in test mode).\n"); sleep(2); } umask(022); printstr("\nGreetings.\n"); printf("Redoop installer init version %s starting\n", VERSION); printf("mounting /proc filesystem... "); if (!testing) { if (mount("/proc", "/proc", "proc", 0, NULL)) fatal_error(1); } printf("done\n"); printf("creating /dev filesystem... "); if (!testing) { if (mount("/dev", "/dev", "tmpfs", 0, NULL)) fatal_error(1); createDevices(); printf("done\n"); printf("starting udev..."); if (fork() == 0) { execl("/sbin/udevd", "/sbin/udevd","--daemon",NULL); exit(1); } } printf("done\n"); printf("populating /dev filesystem... "); if (fork() == 0) { execl("/sbin/udevadm", "/sbin/udevadm","trigger", "--action=add", NULL); exit(1); } printf("done\n"); printf("mounting /dev/pts (unix98 pty) filesystem... "); if (!testing) { if (mount("/dev/pts", "/dev/pts", "devpts", 0, NULL)) fatal_error(1); } printf("done\n"); printf("mounting /sys filesystem... "); if (!testing) { if (mount("/sys", "/sys", "sysfs", 0, NULL)) fatal_error(1); } printf("done\n"); /* these args are only for testing from commandline */ for (i = 1; i < argc; i++) { if (!strcmp (argv[i], "serial")) { isSerial = 1; break; } } noKill = getNoKill(); #if !defined(__s390__) && !defined(__s390x__) static struct termios orig_cmode; struct termios cmode, mode; int cfd; cfd = open("/dev/console", O_RDONLY); tcgetattr(cfd,&orig_cmode); close(cfd); cmode = orig_cmode; cmode.c_lflag &= (~ECHO); cfd = open("/dev/console", O_WRONLY); tcsetattr(cfd,TCSANOW,&cmode); close(cfd); /* handle weird consoles */ #if defined(__powerpc__) char * consoles[] = { "/dev/hvc0", /* hvc for JS20 */ "/dev/hvsi0", "/dev/hvsi1", "/dev/hvsi2", /* hvsi for POWER5 */ NULL }; #elif defined (__ia64__) char * consoles[] = { "/dev/ttySG0", "/dev/xvc0", "/dev/hvc0", NULL }; #elif defined (__i386__) || defined (__x86_64__) char * consoles[] = { "/dev/xvc0", "/dev/hvc0", NULL }; #else char * consoles[] = { NULL }; #endif for (i = 0; consoles[i] != NULL; i++) { if ((fd = open(consoles[i], O_RDWR)) >= 0 && !tcgetattr(fd, &mode) && !termcmp(&cmode, &mode)) { printf("Redoop installer init version %s using %s as console\n", VERSION, consoles[i]); isSerial = 3; console = strdup(consoles[i]); break; } close(fd); } cfd = open("/dev/console", O_WRONLY); tcsetattr(cfd,TCSANOW,&orig_cmode); close(cfd); if ((fd < 0) && (ioctl (0, TIOCLINUX, &twelve) < 0)) { isSerial = 2; if (ioctl(0, TIOCGSERIAL, &si) == -1) { isSerial = 0; } } if (isSerial && (isSerial != 3)) { char *device = "/dev/ttyS0"; printf("anaconda installer init version %s using a serial console\n", VERSION); if (isSerial == 2) device = "/dev/console"; fd = open(device, O_RDWR, 0); if (fd < 0) device = "/dev/tts/0"; if (fd < 0) { printf("failed to open %s\n", device); fatal_error(1); } setupTerminal(fd); } else if (isSerial == 3) { setupTerminal(fd); } else if (fd < 0) { fd = open("/dev/tty1", O_RDWR, 0); if (fd < 0) fd = open("/dev/vc/1", O_RDWR, 0); if (fd < 0) { printf("failed to open /dev/tty1 and /dev/vc/1"); fatal_error(1); } } if (testing) exit(0); setsid(); if (ioctl(0, TIOCSCTTY, NULL)) { printf("could not set new controlling tty\n"); } dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); if (fd > 2) close(fd); #else dup2(0, 1); dup2(0, 2); #endif /* disable Ctrl+Z, Ctrl+C, etc ... but not in rescue mode */ disable_keys = 1; if (argc > 1) if (strstr(argv[1], "rescue")) disable_keys = 0; if (disable_keys) { tcgetattr(0, &ts); ts.c_iflag &= ~BRKINT; ts.c_iflag |= IGNBRK; ts.c_iflag &= ~ISIG; tcsetattr(0, TCSANOW, &ts); } if (!testing) { int ret; ret = sethostname("localhost.localdomain", 21); /* the default domainname (as of 2.0.35) is "(none)", which confuses glibc */ ret = setdomainname("", 0); } printf("trying to remount root filesystem read write... "); if (mount("/", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, NULL)) { fatal_error(1); } printf("done\n"); /* we want our /tmp to be ramfs, but we also want to let people hack * their initrds to add things like a ks.cfg, so this has to be a little * tricky */ if (!testing) { rename("/tmp", "/oldtmp"); mkdir("/tmp", 0755); printf("mounting /tmp as ramfs... "); if (mount("none", "/tmp", "ramfs", 0, NULL)) fatal_error(1); printf("done\n"); copyDirectory("/oldtmp", "/tmp", copyErrorFn, copyErrorFn); unlink("/oldtmp"); } /* Now we have some /tmp space set up, and /etc and /dev point to it. We should be in pretty good shape. */ if (!testing) doklog("/dev/tty4"); /* write out a pid file */ if ((fd = open("/var/run/init.pid", O_WRONLY|O_CREAT, 0644)) > 0) { char * buf = malloc(10); int ret; snprintf(buf, 9, "%d", getpid()); ret = write(fd, buf, strlen(buf)); close(fd); free(buf); } else { printf("unable to write init.pid (%d): %m\n", errno); sleep(2); } /* D-Bus */ if (!testing) { if (fork() == 0) { execl("/sbin/dbus-uuidgen", "/sbin/dbus-uuidgen", "--ensure", NULL); perror("launching /sbin/dbus-uuidgen"); exit(1); } if (fork() == 0) { execl("/sbin/dbus-daemon", "/sbin/dbus-daemon", "--system", NULL); perror("launching /sbin/dbus-daemon"); exit(1); } sleep(3); } /* Go into normal init mode - keep going, and then do a orderly shutdown when: 1) /bin/install exits 2) we receive a SIGHUP */ printf("running install...\n"); setsid(); if (!(installpid = fork())) { /* * comment out this lines for loader * debuging, and comment in the following * loader line. */ //printf("running bash for early testing\n"); //*argvp++ = "/bin/bash"; *argvp++ = "/sbin/loader"; if (isSerial == 3) { *argvp++ = "--virtpconsole"; *argvp++ = console; } *argvp++ = NULL; printf("running %s\n", argvc[0]); execve(argvc[0], argvc, env); shutDown(1, 0, 0); } /* signal handlers for halt/poweroff */ signal(SIGUSR1, sigUsr1Handler); signal(SIGUSR2, sigUsr2Handler); /* set up the ctrl+alt+delete handler to kill our pid, not pid 1 */ signal(SIGINT, sigintHandler); if ((fd = open("/proc/sys/kernel/cad_pid", O_WRONLY)) != -1) { char buf[7]; size_t count; sprintf(buf, "%d", getpid()); count = write(fd, buf, strlen(buf)); close(fd); /* if we succeeded in writing our pid, turn off the hard reboot ctrl-alt-del handler */ if (count == strlen(buf) && (fd = open("/proc/sys/kernel/ctrl-alt-del", O_WRONLY)) != -1) { int ret; ret = write(fd, "0", 1); close(fd); } } while (!doShutdown) { childpid = waitpid(-1, &waitStatus, 0); if (childpid == installpid) doShutdown = 1; } if (!WIFEXITED(waitStatus) || (WIFEXITED(waitStatus) && WEXITSTATUS(waitStatus))) { printf("install exited abnormally [%d/%d] ", WIFEXITED(waitStatus), WEXITSTATUS(waitStatus)); if (WIFSIGNALED(waitStatus)) { printf("-- received signal %d", WTERMSIG(waitStatus)); } printf("\n"); } else { doReboot = 1; } if (testing) exit(0); shutDown(noKill, doReboot, 0); return 0; }
void LCDServer::parseTokens(const QStringList &tokens, QTcpSocket *socket) { // // parse commands coming in from the socket // if (tokens[0] == "HALT" || tokens[0] == "QUIT" || tokens[0] == "SHUTDOWN") { shutDown(); } else if (tokens[0] == "HELLO") { sendConnected(socket); } else if (tokens[0] == "SWITCH_TO_TIME") { switchToTime(socket); } else if (tokens[0] == "SWITCH_TO_MUSIC") { switchToMusic(tokens, socket); } else if (tokens[0] == "SWITCH_TO_VOLUME") { switchToVolume(tokens, socket); } else if (tokens[0] == "SWITCH_TO_GENERIC") { switchToGeneric(tokens, socket); } else if (tokens[0] == "SWITCH_TO_MENU") { switchToMenu(tokens, socket); } else if (tokens[0] == "SWITCH_TO_CHANNEL") { switchToChannel(tokens, socket); } else if (tokens[0] == "SWITCH_TO_NOTHING") { switchToNothing(socket); } else if (tokens[0] == "SET_VOLUME_LEVEL") { setVolumeLevel(tokens, socket); } else if (tokens[0] == "SET_GENERIC_PROGRESS") { setGenericProgress(tokens, socket); } else if (tokens[0] == "SET_MUSIC_PROGRESS") { setMusicProgress(tokens, socket); } else if (tokens[0] == "SET_MUSIC_PLAYER_PROP") { setMusicProp(tokens, socket); } else if (tokens[0] == "SET_CHANNEL_PROGRESS") { setChannelProgress(tokens, socket); } else if (tokens[0] == "UPDATE_LEDS") { updateLEDs(tokens, socket); } else if (tokens[0] == "STOP_ALL") { if (m_lcd) m_lcd->stopAll(); } else if (tokens[0] == "RESET") { // reset lcd & reload settings if (m_lcd) m_lcd->reset(); } else { QString did_not_parse = tokens.join(" "); if (debug_level > 0) LOG(VB_GENERAL, LOG_ERR, "LCDServer::failed to parse this: " + did_not_parse); sendMessage(socket, "HUH?"); } }
void Game::injectJoinRefuse(NetworkMessage::JoinRefuse *message){ shutDown(); }
/**************************************************************************//*** * @brief Executes a shutdown operation on the device. * * @return None. *******************************************************************************/ void DoShutdown(double* param, char paramNo) // "shutdown!" command { shutDown(); CONSOLE_Print("Device entered in shutdown mode.\r\n"); }
void ZScriptMainDialog::onCompile() { shutDown(); compileZScript(); }
/* poweroff handler */ static void sigUsr2Handler(int signum) { termReset(); shutDown(getNoKill(), 0, 1); }
DXTest::~DXTest() { shutDown(); }