int main( void ) { ThreadTo( Thread1, 0 ); ThreadTo( Thread2, 0 ); WakeableSleep( 120000 ); return 0; }
// command line option // time // output file... SaneWinMain( argc, argv ) { NetworkStart(); pcListen = ServeUDP( WIDE("0.0.0.0"), 514, LogRead, NULL ); while( pcListen ) WakeableSleep( SLEEP_FOREVER ); printf( WIDE("Failed to start.") ); return 1; }
static uintptr_t CPROC TestWake1( PTHREAD thread ) { while( 1 ) { lprintf( "sleeping 100" ); WakeableSleep( 100 ); lprintf( "woke 100" ); } }
SaneWinMain( argc, argv ) { int port = SackOpenComm( argv[1], 0, 0 ); SetSystemLog( SYSLOG_FILE, stdout ); SackSetReadCallback( port, callback, 0 ); while( 1 ) WakeableSleep( 100000 ); return 0; }
int main(void) { OpenServer(); xlprintf(LOG_ADVISORY)("Entering main."); while(1) { WakeableSleep(SLEEP_FOREVER); } return 1; }
uintptr_t CPROC ProcessDisplayMessages( PTHREAD thread ) { XEvent event; struct display_camera *camera; INDEX idx; struct display_camera *did_one; LoadOptions(); // loads camera config, and logging options... SACK_Vidlib_OpenCameras(); // create logical camera structures l.bThreadRunning = 1; while( !l.bExitThread ) { did_one = NULL; LIST_FORALL( l.cameras, idx, struct display_camera *, camera ) { //lprintf( "Checking Thread %Lx", GetThreadID( MakeThread() ) ); if( !camera->hVidCore ) continue; GLWindow *x11_gl_window = camera->hVidCore->x11_gl_window; if( !x11_gl_window && ( l.bottom ) ) { x11_gl_window = createGLWindow( camera ); // opens the physical device } //lprintf( "is it %Lx?", GetThreadID( thread ) ); if( x11_gl_window && x11_gl_window->dpy ) { did_one = camera; while( XPending( x11_gl_window->dpy ) > 0 ) { XNextEvent(x11_gl_window->dpy, &event); //if( l.flags.bLogMessageDispatch ) // lprintf( WIDE("(E)Got message:%d"), event.type ); HandleMessage( camera->hVidCore, x11_gl_window, &event ); //if( l.flags.bLogMessageDispatch ) // lprintf( WIDE("(X)Got message:%d"), event.type ); } //lprintf( "Draw GL..." ); //drawGLScene( camera, x11_gl_window ); // calls Update; moves the camera if it has a motion... // does a global tick then draws all cameras // returns if draw should be done; might step and draw one message // loop for each camera instead ProcessGLDraw( TRUE ); } } if( !did_one ) WakeableSleep( 1000 ); else Relinquish(); } return 1; }
SaneWinMain( argc, argv ) { lprintf( "Begin main..." ); l._100_sleep = ThreadTo( TestWake1, 0 ); l._10_sleep = ThreadTo( TestWake2, 0 ); while( 1 ) { WakeableSleep( 10000 ); } return 0; }
int ZFileSectorLoader::thread_func(void * Data) { ZFileSectorLoader * SectorLoader = (ZFileSectorLoader *) Data; while (SectorLoader->ThreadContinue) { SectorLoader->MakeTasks(); WakeableSleep( 20 ); //SDL_Delay(10); } return(0); }
int main( int argc, char **argv ) /*FOLD00*/ { if( argc < 2 ) { printf( WIDE("Usage: %s [scUu]\n"), argv[0] ); printf( WIDE(" s - server\n") ); printf( WIDE(" c - client\n") ); printf( WIDE(" s and c may be specified together to test single-process\n") ); return 0; } while( argc > 1 ) { char *p = argv[1]; while( p[0] ) { switch( p[0] ) { case 's': case 'S': l.flags.bServer = 1; break; case 'c': case 'C': l.flags.bClient = 1; break; } p++; } argv++; argc--; } if( l.flags.bServer ) { OpenServer(); } if( l.flags.bClient ) { OpenClient(); if( l.MsgBaseClient != INVALID_INDEX ) { // all tests are client based. Test1Byte(); // all tests are client based. Test1000Byte(); } } else if( l.flags.bServer ) // hang out here waiting for clients... WakeableSleep( SLEEP_FOREVER ); return 0; }
SaneWinMain( argc, argv ) { InitJSON(); NetworkWait( NULL, 1024, 1 ); gsg.server = WebSocketCreate( "0.0.0.0:27843/org.d3x0r/games/directory" , OnOpen , OnEvent , OnClose , Onerror , 0 ); while( 1 ) WakeableSleep( 10000 ); }
static uintptr_t CPROC TestWake2( PTHREAD thread ) { int n = 0; while( 1 ) { lprintf( "sleeping 10" ); WakeableSleep( 10 ); lprintf( "woke 10" ); if( n++ > 2 ) { WakeThread( l._100_sleep ); n = 0; } } }
int main( int argc, char** argv ) { SOCKADDR *sa; int n; if( argc < 2 ) { printf( "usage: %s <Telnet IP[:port]>\n", argv[0] ); return 0; } SystemLog( "Starting the network" ); NetworkStart(); SystemLog( "Started the network" ); sa = CreateSockAddress( argv[1], 23 ); //if( argc >= 3 ) port = atoi( argv[2] ); else port = 23; pc_user = OpenTCPClientAddrExx( sa, ReadComplete, Closed, NULL, Connected ); if( !pc_user ) { SystemLog( "Failed to open some port as telnet" ); printf( "failed to open %s%s\n", argv[1], strchr(argv[1],':')?"":":telnet[23]" ); return 0; } for( n = 0; n < 1000; n++ ) { if( (rand() & 3) != 0 ) { WakeableSleep( rand() %1000 ); } lprintf( "..." ); RemoveClient( pc_user ); pc_user = OpenTCPClientAddrExx( sa, ReadComplete, Closed, NULL, Connected ); lprintf( "..." ); if( (rand() &3) < 3 ) { fflush( stdout ); while( !connected ) Relinquish(); } if( connected ) { lprintf( "send." ); SendTCP( pc_user, "test", 4 ); } } return -1; }
int GetCh( void ) { int ch; //if( g.pCurrentPlayer && g.pCurrentPlayer->flags.bRemote ) // return 0; if( !pThreadInput ) pThreadInput = MakeThread(); if( !inputpipe ) { inputpipe = open( WIDE("stockmarket.pipe"), O_RDWR|O_CREAT|O_TRUNC, 0600 ); ThreadTo( InputThread, 0 ); } if( !save ) save = sack_fopen( 0, WIDE("stockmarket.save"), WIDE("wt") ); if( script ) { ch = fgetc( script ); if( ch == -1 ) { fclose( script ); script = NULL; } } if( !script ) { ch = 0; // clear upper bits. lprintf( WIDE("will read 1 TEXTCHAR") ); while( bEnque || ( read( inputpipe, &ch, 1 ) < 1 ) ) { lprintf( WIDE("Waiting for input event.") ); WakeableSleep( SLEEP_FOREVER ); lprintf( WIDE("Input event received.") ); } lprintf( WIDE("Read input.") ); } if( ch == '\r' ) fputc( '\n', save ); else fputc( ch, save ); fflush( save ); return ch; }
int main( int argc, char **argv ) { #undef atoi if( argc < 2 ) { printf( "%s {S|H|M} \n" " S - show\n" " H - hide\n" " M - requires 4 additional parameters < x y width height >\n", argv[0] ); return 0; } else if( argv[1][0] == 'S' || argv[1][0] == 's' ) SendShow(); else if( argv[1][0] == 'H' || argv[1][0] == 'h' ) SendHide(); else if( argv[1][0] == 'M' || argv[1][0] == 'm' ) SendPosition( atoi( argv[2] ), atoi( argv[3] ), atoi( argv[4] ), atoi( argv[5] ) ); WakeableSleep( 250 ); return 0; }
SaneWinMain( argc, argv ) { PSI_CONTROL frame; PSI_CONTROL clock; if( argc > 1 ) frame = NULL; else frame = CreateFrame( WIDE("blah"), 0, 0, 500, 500, BORDER_RESIZABLE|BORDER_NORMAL, NULL ); clock = MakeNamedControl( frame, WIDE("Basic Clock Widget"), 0, 0, 350, 350, -1 ); if( frame ) SetControlText( frame, WIDE("CLock Test Widet") ); SetControlText( clock, WIDE("CLock Test Widet") ); if( !frame ) SetCommonBorder( clock,BORDER_RESIZABLE|BORDER_NORMAL ); DisplayFrame( frame?frame:clock ); MakeClockAnalog( clock ); while( 1 ) WakeableSleep( 1000 ); }
int main( void ) { int32_t x, y; uint32_t w, h; PRENDERER renderer; l.pii = GetImageInterface(); l.pri = GetDisplayInterface(); SetSystemLog( SYSLOG_FILE, stdout ); GetDisplaySizeEx( 0, &x, &y, &w, &h ); renderer = OpenDisplaySizedAt( 0, w, h, x, y ); SetTouchHandler( renderer, touch_events, 0 ); UpdateDisplay( renderer ); while( 1 ) { WakeableSleep( 1000 ); } #if 0 HOOKPROC hkprcSysMsg; static HINSTANCE hinstDLL; static HHOOK hhookSysMsg; hinstDLL = LoadLibrary(TEXT("c:\\myapp\\sysmsg.dll")); hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL, "SysMessageProc"); hhookSysMsg = SetWindowsHookEx( WH_SYSMSGFILTER, hkprcSysMsg, hinstDLL, 0); SetWindowsHookEx( #endif return 0; }
int main( int argc, char **argv ) { l.world = OpenWorld( WIDE("") ); LoadWorldFromFile( l.world ); WakeableSleep( 500 ); // give the world time to load. { uint32_t w, h; PBODY body = EnterWorld( l.world ); PVIEW view ; GetDisplaySizeEx( 0, NULL,NULL,&w, &h ); //view = CreateViewEx( V_FORWARD, NULL, WIDE("blah"), h/3, h/3 ); //view = CreateViewEx( V_DOWN, NULL, WIDE("blah"), h/3, 0 ); //view = CreateViewEx( V_UP, NULL, WIDE("blah"), h/3, 2*h/2 ); //view = CreateViewEx( V_RIGHT, NULL, WIDE("blah"), 0, h/3 ); //view = CreateViewEx( V_LEFT, NULL, WIDE("blah"), 2*h/3, h/3 ); //view = CreateViewEx( V_BEHIND, NULL, WIDE("blah"), 3*h/3, h/3 ); //Equip( body ); //PlayWorld( world, body ); while( 1 ) Sleep( 1000 ); } return 0; }
SaneWinMain( argc, argv ) { int nowait = 0; int task_monitor = 0; int noinput = 0; if( argc < 2 ) { #ifdef WIN32 const TEXTCHAR * const args[] ={ WIDE("cmd.exe"), NULL }; #else const TEXTCHAR * const args[] ={ WIDE("/bin/sh"), NULL }; #endif if( !( task = LaunchPeerProgram( args[0], NULL, args, output, ended, 0 ) ) ) done = 1; } else { int delay = 0; int offset = 1; while( argv[offset] && argv[offset][0] == '-' ) { if( StrCaseCmp( argv[offset]+1, WIDE("nowait") ) == 0 ) nowait = 1; if( StrCaseCmp( argv[offset]+1, WIDE("taskmon") ) == 0 ) task_monitor = 1; if( StrCaseCmp( argv[offset]+1, WIDE("noin") ) == 0 ) noinput = 1; if( StrCaseCmp( argv[offset]+1, WIDE("local") ) == 0 ) { SetCurrentPath( OSALOT_GetEnvironmentVariable( WIDE("MY_LOAD_PATH") ) ); } if( StrCaseCmp( argv[offset]+1, WIDE("delay") ) == 0 ) { delay = atoi( argv[offset+1] ); offset++; // used an extra parameter } offset++; } if( delay ) WakeableSleep( delay ); if( offset < argc ) { if( !( task = LaunchPeerProgram( argv[offset], NULL, argv + offset, noinput?NULL:output, ended, 0 ) ) ) done = 1; } else { #ifdef WIN32 const TEXTCHAR * const args[] ={ WIDE("cmd.exe"), NULL }; #else const TEXTCHAR * const args[] ={ WIDE("/bin/sh"), NULL }; #endif if( !( task = LaunchPeerProgram( args[0], NULL, args, noinput?NULL:output, ended, 0 ) ) ) done = 1; } } main_thread = MakeThread(); while( !done ) { TEXTCHAR buf[256]; if( nowait ) WakeableSleep( 1000 ); else { if( !noinput ) { if( fgets( buf, 256, stdin ) ) { pprintf( task, WIDE("%s"), buf ); } } else nowait = 1; } } if( task_monitor ) SendMessage( FindWindow( WIDE("TaskMonClass"), WIDE("Task Completion Monitor") ), WM_USER+500, 0, 0 ); fprintf( stdout, WIDE("Shell Completed.") ); return 0; }
int CPROC MouseMethod( uintptr_t psv, int32_t x, int32_t y, uint32_t b ) { if( !g.flags.bSpinning ) { if( !b ) { g.ofs = -7; DrawReels(); } else if( b == 1 ) { if( g.ofs == -7 ) { int n; if( !g.flags.bBackgroundInitialized) { ClearImageTo( g.backgroundsurface, BASE_COLOR_BLACK ); BlotImage( g.backgroundsurface, g.background, 0, 0 ); g.flags.bBackgroundInitialized = 1; } for( n = 0; n < NUM_REELS; n++ ) { g.bReelSpinning[n] = 1; } g.flags.bSpinning = 1; if( 0 )//yucky. real cheesey. { int n, i; for( n = 0; n < g.nReels; n++ ) for( i = 0; i < NUM_PICS+2; i++ ) { g.reel[n][i] = g.images[rand()%10]; } } DrawSpinningReels(TRUE); } } } else { if( b ) { int reel = (x - REEL_OFSX) / REEL_STEPX; if( reel >= 0 && reel < NUM_REELS ) { if( g.bReelSpinning[reel] ) { g.bReelSpinning[reel] = 0; g.ofs = -32; // DrawReel(reel); UpdateDisplayPortion( g.render , REEL_OFSX , REEL_OFSY , REEL_STEPX*(reel) , REEL_WIDTH ); g.ofs = 7; // DrawReel(reel); UpdateDisplayPortion( g.render , REEL_OFSX , REEL_OFSY , REEL_STEPX*(reel) , REEL_WIDTH ); WakeableSleep( 100 ); g.ofs = 0; // DrawReel(reel); UpdateDisplayPortion( g.render , REEL_OFSX , REEL_OFSY , REEL_STEPX*(reel) , REEL_WIDTH ); { int n; for( n = 0; n < NUM_REELS; n++ ) if( g.bReelSpinning[n] ) break; if( n == NUM_REELS ) { g.flags.bSpinning = 0; SyncRender( g.render); // SetReelSpeedStep(); } } } } } } return 1; }
int main( int argc, char **argv ) { NetworkStart(); if( argc < 2 ) { printf( WIDE("Usage: %s [scUu]\n"), argv[0] ); printf( WIDE(" s - server\n") ); printf( WIDE(" c - client\n") ); printf( WIDE(" U - use a unix socket instead of tcp\n") ); printf( WIDE(" u - use a UDP socket instead of tcp\n") ); printf( WIDE(" s and c may be specified together to test single-process\n") ); return 0; } while( argc > 1 ) { char *p = argv[1]; while( p[0] ) { switch( p[0] ) { case 's': case 'S': l.flags.bServer = 1; break; case 'c': case 'C': l.flags.bClient = 1; break; case 'U': l.flags.bUnix = 1; l.flags.bUDP = 0; break; case 'u': l.flags.bUDP = 1; l.flags.bUnix = 0; break; } p++; } argv++; argc--; } if( l.flags.bServer ) { OpenServer(); } if( l.flags.bClient ) { OpenClient(); } if( l.flags.bClient ) { // all tests are client based. if( l.flags.bUDP ) { UDPTest1Byte(); } else TCPTest1Byte(); // all tests are client based. if( l.flags.bUDP ) { UDPTest1000Byte(); } else TCPTest1000Byte(); } else WakeableSleep( 10000 ); return 0; }
int main( void ) { uint32_t width, height; uint32_t imagecount = 0; uint32_t testimagesatinitialization = 0; Image blank; srand( time( NULL ) ); for(width=0; width< NUM_REELS; width++) { g.uiSpeedCounter[width] = 0; g.uiSpeedStep[width] = 2; g.idx[width]= 0; } g.pdi = GetDisplayInterface(); g.pii = GetImageInterface(); //SetSystemLog( SYSLOG_FILE, stdout ); SetSystemLoggingLevel( 1000 + LOG_NOISE); GetDisplaySize( &width, &height );; g.render = OpenDisplaySizedAt( 0, width, height, 0, 0 ); UpdateDisplay(g.render); g.surface = GetDisplayImage( g.render ); SetMouseHandler( g.render, MouseMethod, 0 ); // blank = LoadImageFile( WIDE("blankimage.jpg")); blank = MakeImageFile(96,96); ClearImageTo( blank, BASE_COLOR_CYAN ); g.playagain=LoadImageFile( WIDE("%images%/playagain.jpg")); g.playing =LoadImageFile( WIDE("%images%/playing.jpg")); g.background = LoadImageFile( WIDE("%images%/background.jpg") ); // g.background = blank; g.strip = LoadImageFile( WIDE("%images%/slot_strip.jpg") ); g.nReels = NUM_REELS; { Image icons[NUM_ICONS]; int n, m; INDEX idx; for( n = 0; n < NUM_ICONS; n++ ) { icons[n] = MakeSubImage( g.strip, 96 * n, 0, 96, 96 ); } n = width = imagecount = height = 0; while(imagecount < NUM_IMAGES ) { idx = rand()%NUM_ICONS; g.images[imagecount] = icons[idx]; if( testimagesatinitialization ) { BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 ); width++; if(!( width % 8 )) { width=0; height++; } } imagecount++; for( m = 0; m < (( rand()%2 ) ); m++) { g.images[imagecount] = blank; if( testimagesatinitialization ) { BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 ); width++; if(!( width % 8 )) { width=0; height++; } } imagecount++; } if( testimagesatinitialization ) { SyncRender( g.render); UpdateDisplay(g.render); } } if( !testimagesatinitialization ) { SyncRender( g.render); UpdateDisplay(g.render); } for( n = 0; n < NUM_BLURS; n++ ) { g.blurs[n] = MakeImageFile( 96, (NUM_PICS) * 96 ); g.dodges[n] = MakeImageFile( 96, (NUM_PICS) * 96 ); for( m = 0; m < NUM_IMAGES; m++ ) { idx = rand()%NUM_IMAGES; g.reel[0][m] = g.images[idx]; } Blur( g.blurs[n], g.reel[0] ); DodgeEx( g.dodges[n], g.reel[0] , 2); } for( n = 0; n < NUM_REELS; n++) { g.subsurface[n] = MakeSubImage( g.surface , REEL_OFSX + REEL_STEPX * n , REEL_OFSY , REEL_WIDTH, (96 * NUM_PICS_IN_WINDOW) ); g.testsurface[n] = MakeSubImage( g.surface, REEL_OFSX + REEL_STEPX * n + 480, REEL_OFSY , REEL_WIDTH, (96 * NUM_PICS) ); } g.statussurface = MakeSubImage( g.surface , 490, 10 , 140, 68 ); g.backgroundsurface = MakeSubImage( g.surface , 0, 0 , 640, 460 ); } g.flags.bBackgroundInitialized = 0; ThreadTo( ReadInput, 0 ); { uint32_t start = GetTickCount(); xlprintf(LOG_NOISE)("Started at %lu" , start); g.ofs = 0; while( 1 ) { if( g.flags.bSpinning ) { DrawSpinningReels(FALSE); } #ifndef __ARM__ // scale to approx unit speeds.. WakeableSleep( 250 ); //WakeableSleep( 33); #endif } } CloseDisplay( g.render ); UnmakeImageFile( g.strip ); return 0; }
SaneWinMain(argc, argv ) //int main( int argc, char **argv ) { int x = 0; int y = 0; uint32_t width, height; int w, h; g.pdi = GetDisplayInterface(); g.pii = GetImageInterface(); RegisterIcon( NULL ); GetDisplaySize( &width, &height ); w = width; h = height; y = x = 0; { int state = 0; int arg; g.fade_in = 500; g.show_time = 1000; for( arg = 1; arg < argc; arg++ ) { if( argv[arg][0] == '-' ) { if( argv[arg][1] == 'i' ) { g.flags.bShowInverted = 1; } else { switch( state ) { case 0: x = atoi( argv[arg]+1 ); break; case 1: y = atoi( argv[arg]+1 ); break; case 2: w = atoi( argv[arg]+1 ); break; case 3: h = atoi( argv[arg]+1 ); break; case 4: g.show_time = atoi( argv[arg]+1 ); break; case 5: g.fade_in = atoi( argv[arg]+1 ); break; } state++; } } else { Image x = LoadImageFile( argv[arg] ); if( x ) { g.nImages++; AddLink( &g.images, x ); } } } } if( g.nImages ) { g.displays[0] = OpenDisplaySizedAt( DISPLAY_ATTRIBUTE_LAYERED|DISPLAY_ATTRIBUTE_CHILD|DISPLAY_ATTRIBUTE_NO_MOUSE|DISPLAY_ATTRIBUTE_NO_AUTO_FOCUS , w //width , h //height , x //0 , y //0 ); g.displays[1] = OpenDisplaySizedAt( DISPLAY_ATTRIBUTE_LAYERED|DISPLAY_ATTRIBUTE_CHILD|DISPLAY_ATTRIBUTE_NO_MOUSE|DISPLAY_ATTRIBUTE_NO_AUTO_FOCUS , w //width , h //height , x //0 , y //0 ); SetRedrawHandler( g.displays[0], Output, 0 ); SetRedrawHandler( g.displays[1], Output, 1 ); if( g.nImages > 1 ) { target_in_start = GetTickCount(); AddTimer( 33, tick, 0 ); } else { //lprintf( "Show the first and only the first image." ); g.is_up[0] = 1; RestoreDisplay( g.displays[0] ); UpdateDisplay( g.displays[0] ); } while( 1 ) WakeableSleep( 10000 ); } else { } return 0; }
//---------------------------------------------------------------------------------------- // Timer for checking the timestamp static uintptr_t CPROC countDown( PTHREAD thread ) { TEXTCHAR buf[45]; uint8_t found = 0; uint32_t startTime; PODBC odbc; // Loop forever while( 1 ) { // Get Current time startTime = timeGetTime(); // Sleep to next timeout if( l.flags.bLogSleeps ) { long x = ( l.iIdleTime*(60)*(1000) ) - ( startTime - l.last_event_time ); lprintf( WIDE("Sleep for... %d:%02d.%03d"), x / 60000, (x / 1000 ) %60, x % 1000 ); } if( ( l.iIdleTime*(60)*(1000) ) > ( startTime - l.last_event_time ) ) WakeableSleep( ( l.iIdleTime*(60)*(1000) ) - ( startTime - l.last_event_time ) ); startTime = timeGetTime(); // sleep some more if we got a new event if( ( l.iIdleTime*(60)*(1000) ) > ( startTime - l.last_event_time ) ) continue; // Make connection to database odbc = SQLGetODBC( l.option_dsn ); if( l.flags.bLogSleeps ) lprintf( WIDE("woke up and user is %p (%d)"), HaveCurrentUser( odbc ), ( startTime - l.last_event_time ) ); // If there is current user, else there is no active logins or processes to kill if( HaveCurrentUser( odbc ) ) { uint32_t target_tick = startTime + ( l.iScreenSaverWaitTime * 1000 ); int32_t remaining = ( target_tick - startTime ); // Get time // Check last event, if timeout not hit go back to sleep until timeout will be hit if( remaining < 0 ) { if( l.flags.bLogSleeps ) lprintf( WIDE("Not enough time, go back and wait...") ); // Close Connection to database SQLDropODBC( odbc ); // not enough time has really passed... sleep more continue; } // Let hook know to update activity flag l.flags.countingDown = 1; // Start countdown do { // Update time to check against remaining = ( target_tick - startTime ); // Update Banner Message snprintf( buf, sizeof( buf ), WIDE(" The system will logout in %d.%03d seconds...") , remaining / 1000, remaining % 1000 ); BannerTopNoWait( buf ); // Don't eat to much cpu time IdleFor( 200 ); startTime = timeGetTime(); } while( l.flags.countingDown && ( target_tick > startTime ) ); // If countdown made it to 0 if( ( target_tick < startTime ) ) { uint32_t x; uint32_t y; // Logout users SQLCommandf( odbc , WIDE("update login_history set logout_whenstamp=now() where logout_whenstamp=11111111111111 and system_id=%d"), g.system_id ); // Get current process list if ( !EnumProcesses( l.pidList2, sizeof( l.pidList2 ), &l.pidListLength2 ) ) lprintf( WIDE(" Getting Process List 2 Failed!") ); // Kill Processes for( x = 0; x < l.pidListLength2; x++ ) { // Check if process existed originally for( y = 0; y < l.pidListLength1; y++ ) { if( l.pidList2[x] == l.pidList1[y] ) { found = 1; break; } } // If did not exist originally kill the process if( !found ) { TEXTCHAR cmd[25]; snprintf( cmd, sizeof( cmd ), WIDE("pskill %d"), l.pidList2[x] ); System( cmd, LogOutput, 0 ); } found = 0; } // Give extra time to see Banner IdleFor( 500 ); // Reset Data l.flags.countingDown = 0; } // Remove Banner RemoveBanner2Ex( NULL DBG_SRC ); } else { // fake an event, there was no user, so didn't do anything, just sleep more l.last_event_time = startTime; } // Close Connection to database SQLDropODBC( odbc ); } return 0; }
int main( int argc, char **argv ) { POINTER mem_lock; uintptr_t size = 0; TEXTCHAR *myname = StrDup( pathrchr( DupCharToText( argv[0] ) ) ); TEXTCHAR *endname; TEXTCHAR lockname[256]; if( myname ) myname++; else myname = DupCharToText( argv[0] ); // go to the .exe extension endname = (TEXTCHAR*)StrRChr( myname, '.' ); if( endname ) { // remove .exe extension endname[0] = 0; // go to the .stop extension endname = (TEXTCHAR*)StrRChr( myname, '.' ); } if( endname ) { // remove .stop extension endname[0] = 0; } else { // this would be an invalid name. return 0; } snprintf( lockname, sizeof( lockname ), WIDE( "%s.instance.lock" ), myname ); lprintf( WIDE( "Checking lock %s" ), lockname ); mem_lock = OpenSpace( lockname , NULL //, WIDE("memory.delete") , &size ); if( mem_lock ) { #ifdef WIN32 PRENDER_INTERFACE pri = GetDisplayInterface(); PVIDEO video = (PVIDEO)mem_lock; if( video->hWndOutput ) { ForceDisplayFocus( video ); keybd_event( VK_MENU, 56, 0, 0 ); keybd_event( VK_F4, 62, 0, 0 ); keybd_event( VK_F4, 62, KEYEVENTF_KEYUP, 0 ); keybd_event( VK_MENU, 56, KEYEVENTF_KEYUP, 0 ); #if 0 { int tick = timeGetTime(); while( ( tick + 15000 > timeGetTime() ) && IsWindow( video->hWndOutput ) ) WakeableSleep( 100 ); if( IsWindow( video->hWndOutput ) ) #define WM_EXIT_PLEASE 0xd1e if( !SendMessage( video->hWndOutput, WM_QUERYENDSESSION, 0, 0 ) ) printf( "Failed to post queyendsession." ); } #endif } else { // region found, but no content... } #endif } else lprintf( WIDE("lock region not found.") ); return 0; }