void drawDirectory() { CreateDirs(); Menu_Loop(); drawMain(); }
int main(int argc,char * argv[]) { if(argc<2) { printf("Usage: %s <path> \n",argv[0]); return 0; } CreateDirs(argv[1],strlen(argv[1])); return 0; }
bool WcxArchive::pExtract( const char *lpDestPath ) { int nProcessed = 0; int nResult = 0; m_files.clear(); while ( nResult == 0 ) { tHeaderData HeaderData; memset (&HeaderData, 0, sizeof (HeaderData)); nResult = m_pModule->m_pfnReadHeader (m_hArchive, &HeaderData); if( nResult!=0 ) continue; char szDestPath[MAX_PATH] = {0}; strcpy(szDestPath, lpDestPath); PathAppendA(szDestPath, HeaderData.FileName); int nProcessResult = 0; if ( (HeaderData.FileAttr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) { CreateDirEx (szDestPath); nProcessResult = m_pModule->m_pfnProcessFile (m_hArchive, PK_SKIP, NULL, NULL); ATLASSERT(FALSE); } else { CreateDirs( szDestPath ); SetFileApisToANSI(); nProcessResult = m_pModule->m_pfnProcessFile (m_hArchive, PK_EXTRACT, NULL, szDestPath); SetFileApisToOEM(); if(!nProcessResult) m_files.push_back( szDestPath ); } if ( !nProcessResult ) nProcessed++; } return nProcessed!=0; }
/** * Function Name : TestFtw3 * Description : Tests the behaviour of ftw */ TInt CTestftw::TestFtw3() { int ret=KErrNone; if(CreateDirs() == -1) { INFO_PRINTF1(_L("Failed to create directory tree")); return KErrGeneral; } if(ftw("c:\\ftwtest", &action, 3) != 0) { INFO_PRINTF2(_L("FTW failed with errno %d"), errno); ret = KErrGeneral; } rmdir("c:\\ftwtest\\test"); rmdir("c:\\ftwtest"); return ret; }
/* * User pressed the install button. Make it go. */ void CBINDInstallDlg::OnInstall() { BOOL success = FALSE; int oldlen; if (CheckBINDService()) StopBINDService(); InstallTags(); UpdateData(); /* * Check that the Passwords entered match. */ if (m_accountPassword != m_accountPasswordConfirm) { MsgBox(IDS_ERR_PASSWORD); return; } /* * Check that there is not leading / trailing whitespace. * This is for compatability with the standard password dialog. * Passwords really should be treated as opaque blobs. */ oldlen = m_accountPassword.GetLength(); m_accountPassword.TrimLeft(); m_accountPassword.TrimRight(); if (m_accountPassword.GetLength() != oldlen) { MsgBox(IDS_ERR_WHITESPACE); return; } /* * Check the entered account name. */ if (ValidateServiceAccount() == FALSE) return; /* * For Registration we need to know if account was changed. */ if (m_accountName != m_currentAccount) m_accountUsed = FALSE; if (m_accountUsed == FALSE && m_serviceExists == FALSE) { /* * Check that the Password is not null. */ if (m_accountPassword.GetLength() == 0) { MsgBox(IDS_ERR_NULLPASSWORD); return; } } /* Directories */ m_etcDir = m_targetDir + "\\etc"; m_binDir = m_targetDir + "\\bin"; if (m_defaultDir != m_targetDir) { if (GetFileAttributes(m_targetDir) != 0xFFFFFFFF) { int install = MsgBox(IDS_DIREXIST, MB_YESNO | MB_ICONQUESTION, m_targetDir); if (install == IDNO) return; } else { int createDir = MsgBox(IDS_CREATEDIR, MB_YESNO | MB_ICONQUESTION, m_targetDir); if (createDir == IDNO) return; } } if (m_accountExists == FALSE) { success = CreateServiceAccount(m_accountName.GetBuffer(30), m_accountPassword.GetBuffer(30)); if (success == FALSE) { MsgBox(IDS_CREATEACCOUNT_FAILED); return; } m_accountExists = TRUE; } ProgramGroup(FALSE); try { CreateDirs(); CopyFiles(); RegisterService(); RegisterMessages(); HKEY hKey; /* Create a new key for named */ SetCurrent(IDS_CREATE_KEY); if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_SUBKEY, &hKey) == ERROR_SUCCESS) { // Get the install directory RegSetValueEx(hKey, "InstallDir", 0, REG_SZ, (LPBYTE)(LPCTSTR)m_targetDir, m_targetDir.GetLength()); RegCloseKey(hKey); } SetCurrent(IDS_ADD_REMOVE); if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_UNINSTALL_SUBKEY, &hKey) == ERROR_SUCCESS) { CString buf(BIND_DISPLAY_NAME); RegSetValueEx(hKey, "DisplayName", 0, REG_SZ, (LPBYTE)(LPCTSTR)buf, buf.GetLength()); buf.Format("%s\\BINDInstall.exe", m_binDir); RegSetValueEx(hKey, "UninstallString", 0, REG_SZ, (LPBYTE)(LPCTSTR)buf, buf.GetLength()); RegCloseKey(hKey); } ProgramGroup(FALSE); if (m_startOnInstall) StartBINDService(); } catch(Exception e) { MessageBox(e.resString); SetCurrent(IDS_CLEANUP); FailedInstall(); MsgBox(IDS_FAIL); return; } catch(DWORD dw) { CString msg; msg.Format("A fatal error occured\n(%s)", GetErrMessage(dw)); MessageBox(msg); SetCurrent(IDS_CLEANUP); FailedInstall(); MsgBox(IDS_FAIL); return; } SetCurrent(IDS_INSTALL_DONE); MsgBox(IDS_SUCCESS); }
int main(int argc,char *argv[]) { char *t; if(timeBeginPeriod(1)!=TIMERR_NOERROR) { AddLogText("Error setting timer granularity to 1ms.",1); } if(!FCEUI_Initialize()) goto doexito; srand(GetTickCount()); // rand() is used for some GUI sillyness. fceu_hInstance=GetModuleHandle(0); GetBaseDirectory(); sprintf(TempArray,"%s\\fceu98.cfg",BaseDirectory); LoadConfig(TempArray); t=ParseArgies(argc,argv); /* Bleh, need to find a better place for this. */ { palyo&=1; FCEUI_SetVidSystem(palyo); genie&=1; FCEUI_SetGameGenie(genie); fullscreen&=1; soundo&=1; FCEUI_SetSoundVolume(soundvolume); FCEUI_SetSoundQuality(soundquality); } ParseGIInput(NULL); /* Since a game doesn't have to be loaded before the GUI can be used, make sure the temporary input type variables are set. */ CreateDirs(); SetDirs(); DoVideoConfigFix(); DoTimingConfigFix(); if(eoptions&EO_CPALETTE) FCEUI_SetPaletteArray(cpalette); if(!t) fullscreen=0; CreateMainWindow(); if(!InitDInput()) goto doexito; if(!DriverInitialize()) goto doexito; InitSpeedThrottle(); UpdateMenu(); if(t) ALoad(t); else if(eoptions&EO_FOAFTERSTART) LoadNewGamey(hAppWnd, 0); doloopy: UpdateFCEUWindow(); if(GI) { while(GI) { uint8 *gfx; int32 *sound; int32 ssize; FCEUI_Emulate(&gfx, &sound, &ssize, 0); xbsave = gfx; FCEUD_Update(gfx, sound, ssize); } xbsave = NULL; RedrawWindow(hAppWnd,0,0,RDW_ERASE|RDW_INVALIDATE); StopSound(); } Sleep(50); if(!exiting) goto doloopy; doexito: DriverKill(); timeEndPeriod(1); FCEUI_Kill(); return(0); }
// returns a config structure with default options // also creates config base directory (ie: /home/user/.fceux as well as subdirs Config* InitConfig() { std::string dir, prefix; Config *config; GetBaseDirectory(dir); FCEUI_SetBaseDirectory(dir.c_str()); CreateDirs(dir); config = new Config(dir); // TODO: tsone: network play is disabled #if 0 // network play options - netplay is broken config->addOption("server", "SDL.NetworkIsServer", 0); config->addOption('n', "net", "SDL.NetworkIP", ""); config->addOption('u', "user", "SDL.NetworkUsername", ""); config->addOption('w', "pass", "SDL.NetworkPassword", ""); config->addOption('k', "netkey", "SDL.NetworkGameKey", ""); config->addOption("port", "SDL.NetworkPort", 4046); config->addOption("players", "SDL.NetworkPlayers", 1); #endif // TODO: tsone: fc extension port peripherals support #if PERI // PowerPad 0 - 1 for(unsigned int i = 0; i < POWERPAD_NUM_DEVICES; i++) { char buf[64]; snprintf(buf, 20, "SDL.Input.PowerPad.%d.", i); prefix = buf; config->addOption(prefix + "DeviceType", DefaultPowerPadDevice[i]); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < POWERPAD_NUM_BUTTONS; j++) { config->addOption(prefix +PowerPadNames[j], DefaultPowerPad[i][j]); } } // QuizKing prefix = "SDL.Input.QuizKing."; config->addOption(prefix + "DeviceType", DefaultQuizKingDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < QUIZKING_NUM_BUTTONS; j++) { config->addOption(prefix + QuizKingNames[j], DefaultQuizKing[j]); } // HyperShot prefix = "SDL.Input.HyperShot."; config->addOption(prefix + "DeviceType", DefaultHyperShotDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < HYPERSHOT_NUM_BUTTONS; j++) { config->addOption(prefix + HyperShotNames[j], DefaultHyperShot[j]); } // Mahjong prefix = "SDL.Input.Mahjong."; config->addOption(prefix + "DeviceType", DefaultMahjongDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < MAHJONG_NUM_BUTTONS; j++) { config->addOption(prefix + MahjongNames[j], DefaultMahjong[j]); } // TopRider prefix = "SDL.Input.TopRider."; config->addOption(prefix + "DeviceType", DefaultTopRiderDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < TOPRIDER_NUM_BUTTONS; j++) { config->addOption(prefix + TopRiderNames[j], DefaultTopRider[j]); } // FTrainer prefix = "SDL.Input.FTrainer."; config->addOption(prefix + "DeviceType", DefaultFTrainerDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < FTRAINER_NUM_BUTTONS; j++) { config->addOption(prefix + FTrainerNames[j], DefaultFTrainer[j]); } // FamilyKeyBoard prefix = "SDL.Input.FamilyKeyBoard."; config->addOption(prefix + "DeviceType", DefaultFamilyKeyBoardDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < FAMILYKEYBOARD_NUM_BUTTONS; j++) { config->addOption(prefix + FamilyKeyBoardNames[j], DefaultFamilyKeyBoard[j]); } // All mouse devices config->addOption("SDL.OekaKids.0.DeviceType", "Mouse"); config->addOption("SDL.OekaKids.0.DeviceNum", 0); config->addOption("SDL.Arkanoid.0.DeviceType", "Mouse"); config->addOption("SDL.Arkanoid.0.DeviceNum", 0); config->addOption("SDL.Shadow.0.DeviceType", "Mouse"); config->addOption("SDL.Shadow.0.DeviceNum", 0); config->addOption("SDL.Zapper.0.DeviceType", "Mouse"); config->addOption("SDL.Zapper.0.DeviceNum", 0); #endif return config; }
HRESULT __stdcall CArchiveExtractCallback::GetStream ( unsigned int index, ISequentialOutStream **outStream, int askExtractMode ) { CPropVariant value; IInArchive *archive = m_pArchive->m_pArchive; if ( askExtractMode == 0 ) //extract { if ( archive->GetProperty (index, kpidPath, &value) != S_OK ) return S_OK; //!!! to return error char szArcFileName[MAX_PATH]; char szFullName[MAX_PATH]; if ( value.vt == VT_BSTR ) WideCharToMultiByte (CP_OEMCP, 0, value.bstrVal, -1, szArcFileName, MAX_PATH, NULL, NULL); else { //strcpy (szArcFileName, FSF.PointToName (m_pArchive->m_lpFileName)); //CutTo (szArcFileName, '.', true); ATLASSERT(FALSE); } strcpy (szFullName, m_lpDestPath.c_str()); PathAppendA(szFullName, szArcFileName); if ( (int)m_nLastProcessed == -1 ) m_nLastProcessed = 0; FILETIME ftCreationTime, ftLastAccessTime, ftLastWriteTime; DWORD dwFileAttributes = 0; memset (&ftCreationTime, 0, sizeof (FILETIME)); memset (&ftLastAccessTime, 0, sizeof (FILETIME)); memset (&ftLastWriteTime, 0, sizeof (FILETIME)); if ( archive->GetProperty (index, kpidAttrib, &value) == S_OK ) { if ( value.vt == VT_UI4 ) dwFileAttributes = value.ulVal; } if ( archive->GetProperty (index, kpidCTime, &value) == S_OK ) { if ( value.vt == VT_FILETIME ) memcpy (&ftCreationTime, &value.filetime, sizeof (FILETIME)); } if ( archive->GetProperty (index, kpidATime, &value) == S_OK ) { if ( value.vt == VT_FILETIME ) memcpy (&ftLastAccessTime, &value.filetime, sizeof (FILETIME)); } if ( archive->GetProperty (index, kpidMTime, &value) == S_OK ) { if ( value.vt == VT_FILETIME ) memcpy (&ftLastWriteTime, &value.filetime, sizeof (FILETIME)); } bool bIsFolder = false; if ( archive->GetProperty (index, kpidIsDir, &value) == S_OK ) { if (value.vt == VT_BOOL) bIsFolder = (value.boolVal == VARIANT_TRUE); } if ( bIsFolder || dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY ) { *outStream = NULL; CreateDirEx (szFullName, dwFileAttributes); } else { CreateDirs (szFullName); COutFile *file = new COutFile (szFullName); if ( file->Open () ) { file->SetAttributes (dwFileAttributes); file->SetTime (&ftCreationTime, &ftLastAccessTime, &ftLastWriteTime); *outStream = file; m_files.push_back( szFullName ); } else delete file; } } else *outStream = NULL; return S_OK; }
void PanguAppendStore::Init(bool iscreate) { mFileSystemHelper = FileSystemHelper::GetInstance(); if (iscreate) { CreateDirs(mRoot); } uint32_t binmajor = mMeta.storemajor; uint32_t binminor = mMeta.storeminor; if (ReadMetaInfo()) { if (! mMeta.check(binmajor, binminor)) { THROW_EXCEPTION(AppendStoreMisMatchedVerException, "meta version is not matched"); } mCompressionType = mMeta.compressionFlag; } else { if (iscreate) { WriteMetaInfo(mRoot, mMeta); } else { THROW_EXCEPTION(AppendStoreNotExistException, "store not exist (.meta_)" + mRoot); } } std::string compressAlgo(LzoCodec::mName); if (mCompressionType == (uint32_t)NO_COMPRESSION) { compressAlgo = NoneCodec::mName; } else if (mCompressionType != (uint32_t)COMPRESSOR_LZO) { THROW_EXCEPTION(AppendStoreCodecException, "unknown compression type"); } // directory exist if (!CheckDirs(mRoot)) { THROW_EXCEPTION(AppendStoreNotExistException, "store not exist (3 dirs)" + mRoot); } mMaxChunkId = Chunk::GetMaxChunkID(mRoot); if (mAppend) { LOG4CXX_DEBUG(logger_, "mMaxChunkSize : " << mMeta.maxChunkSize << " & mBlockIndexInterval : " << mMeta.blockIndexInterval); // Currently, append at the last chunk // set mMaxChunkId: chunks are in [0, mMaxChunkId] inclusive mAppendChunkId = mMaxChunkId; mCodec.reset(CompressionCodec::getCodec(compressAlgo.c_str(), 1024, true)); } else { mCodec.reset(CompressionCodec::getCodec(compressAlgo.c_str(), 1024, false)); } mCache.reset(new Cache()); }
int main(int argc, char **argv, char **envp) { struct rx_service *tservice; afs_int32 code; struct afsconf_dir *tdir; int noAuth = 0; int i; char namebuf[AFSDIR_PATH_MAX]; int rxMaxMTU = -1; afs_uint32 host = htonl(INADDR_ANY); char *auditFileName = NULL; struct rx_securityClass **securityClasses; afs_int32 numClasses; int DoPeerRPCStats = 0; int DoProcessRPCStats = 0; #ifndef AFS_NT40_ENV int nofork = 0; struct stat sb; #endif #ifdef AFS_AIX32_ENV struct sigaction nsa; /* for some reason, this permits user-mode RX to run a lot faster. * we do it here in the bosserver, so we don't have to do it * individually in each server. */ tweak_config(); /* * The following signal action for AIX is necessary so that in case of a * crash (i.e. core is generated) we can include the user's data section * in the core dump. Unfortunately, by default, only a partial core is * generated which, in many cases, isn't too useful. */ sigemptyset(&nsa.sa_mask); nsa.sa_handler = SIG_DFL; nsa.sa_flags = SA_FULLDUMP; sigaction(SIGSEGV, &nsa, NULL); sigaction(SIGABRT, &nsa, NULL); #endif osi_audit_init(); signal(SIGFPE, bozo_insecureme); #ifdef AFS_NT40_ENV /* Initialize winsock */ if (afs_winsockInit() < 0) { ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0); fprintf(stderr, "%s: Couldn't initialize winsock.\n", argv[0]); exit(2); } #endif /* Initialize dirpaths */ if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) { #ifdef AFS_NT40_ENV ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0); #endif fprintf(stderr, "%s: Unable to obtain AFS server directory.\n", argv[0]); exit(2); } /* some path inits */ bozo_fileName = AFSDIR_SERVER_BOZCONF_FILEPATH; DoCore = AFSDIR_SERVER_LOGS_DIRPATH; /* initialize the list of dirpaths that the bosserver has * an interest in monitoring */ initBosEntryStats(); #if defined(AFS_SGI_ENV) /* offer some protection if AFS isn't loaded */ if (syscall(AFS_SYSCALL, AFSOP_ENDLOG) < 0 && errno == ENOPKG) { printf("bosserver: AFS doesn't appear to be configured in O.S..\n"); exit(1); } #endif #ifndef AFS_NT40_ENV /* save args for restart */ bozo_argc = argc; bozo_argv = malloc((argc+1) * sizeof(char*)); if (!bozo_argv) { fprintf(stderr, "%s: Failed to allocate argument list.\n", argv[0]); exit(1); } bozo_argv[0] = (char*)AFSDIR_SERVER_BOSVR_FILEPATH; /* expected path */ bozo_argv[bozo_argc] = NULL; /* null terminate list */ #endif /* AFS_NT40_ENV */ /* parse cmd line */ for (code = 1; code < argc; code++) { #ifndef AFS_NT40_ENV bozo_argv[code] = argv[code]; #endif /* AFS_NT40_ENV */ if (strcmp(argv[code], "-noauth") == 0) { /* set noauth flag */ noAuth = 1; } else if (strcmp(argv[code], "-log") == 0) { /* set extra logging flag */ DoLogging = 1; } #ifndef AFS_NT40_ENV else if (strcmp(argv[code], "-syslog") == 0) { /* set syslog logging flag */ DoSyslog = 1; } else if (strncmp(argv[code], "-syslog=", 8) == 0) { DoSyslog = 1; DoSyslogFacility = atoi(argv[code] + 8); } else if (strncmp(argv[code], "-cores=", 7) == 0) { if (strcmp((argv[code]+7), "none") == 0) DoCore = 0; else DoCore = (argv[code]+7); } else if (strcmp(argv[code], "-nofork") == 0) { nofork = 1; } #endif else if (strcmp(argv[code], "-enable_peer_stats") == 0) { DoPeerRPCStats = 1; } else if (strcmp(argv[code], "-enable_process_stats") == 0) { DoProcessRPCStats = 1; } else if (strcmp(argv[code], "-restricted") == 0) { bozo_isrestricted = 1; } else if (strcmp(argv[code], "-rxbind") == 0) { rxBind = 1; } else if (strcmp(argv[code], "-allow-dotted-principals") == 0) { rxkadDisableDotCheck = 1; } else if (!strcmp(argv[code], "-rxmaxmtu")) { if ((code + 1) >= argc) { fprintf(stderr, "missing argument for -rxmaxmtu\n"); exit(1); } rxMaxMTU = atoi(argv[++code]); } else if (strcmp(argv[code], "-auditlog") == 0) { auditFileName = argv[++code]; } else if (strcmp(argv[code], "-audit-interface") == 0) { char *interface = argv[++code]; if (osi_audit_interface(interface)) { printf("Invalid audit interface '%s'\n", interface); exit(1); } } else if (strncmp(argv[code], "-pidfiles=", 10) == 0) { DoPidFiles = (argv[code]+10); } else if (strncmp(argv[code], "-pidfiles", 9) == 0) { DoPidFiles = AFSDIR_BOSCONFIG_DIR; } else { /* hack to support help flag */ #ifndef AFS_NT40_ENV printf("Usage: bosserver [-noauth] [-log] " "[-auditlog <log path>] " "[-audit-interface <file|sysvmq> (default is file)] " "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] " "[-syslog[=FACILITY]] " "[-restricted] " "[-enable_peer_stats] [-enable_process_stats] " "[-cores=<none|path>] \n" "[-pidfiles[=path]] " "[-nofork] " "[-help]\n"); #else printf("Usage: bosserver [-noauth] [-log] " "[-auditlog <log path>] " "[-audit-interface <file|sysvmq> (default is file)] " "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] " "[-restricted] " "[-enable_peer_stats] [-enable_process_stats] " "[-cores=<none|path>] \n" "[-pidfiles[=path]] " "[-help]\n"); #endif fflush(stdout); exit(0); } } if (auditFileName) { osi_audit_file(auditFileName); } #ifndef AFS_NT40_ENV if (geteuid() != 0) { printf("bosserver: must be run as root.\n"); exit(1); } #endif if ((!DoSyslog) #ifndef AFS_NT40_ENV && ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) && !(S_ISFIFO(sb.st_mode))) #endif ) { strcpy(namebuf, AFSDIR_BOZLOG_FILE); strcat(namebuf, ".old"); rk_rename(AFSDIR_BOZLOG_FILE, namebuf); /* try rename first */ bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a"); if (!bozo_logFile) { printf("bosserver: can't initialize log file (%s).\n", AFSDIR_SERVER_BOZLOG_FILEPATH); exit(1); } /* keep log closed normally, so can be removed */ fclose(bozo_logFile); } else { #ifndef AFS_NT40_ENV openlog("bosserver", LOG_PID, DoSyslogFacility); #endif } /* * go into the background and remove our controlling tty, close open * file desriptors */ #ifndef AFS_NT40_ENV if (!nofork) daemon(1, 0); #endif /* ! AFS_NT40_ENV */ /* create useful dirs */ CreateDirs(DoCore); /* Write current state of directory permissions to log file */ DirAccessOK(); /* chdir to AFS log directory */ if (DoCore) chdir(DoCore); else chdir(AFSDIR_SERVER_LOGS_DIRPATH); /* try to read the key from the config file */ tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); if (!tdir) { /* try to create local cell config file */ struct afsconf_cell tcell; strcpy(tcell.name, "localcell"); tcell.numServers = 1; code = gethostname(tcell.hostName[0], MAXHOSTCHARS); if (code) { bozo_Log("failed to get hostname, code %d\n", errno); exit(1); } if (tcell.hostName[0][0] == 0) { bozo_Log("host name not set, can't start\n"); bozo_Log("try the 'hostname' command\n"); exit(1); } memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */ code = afsconf_SetCellInfo(NULL, AFSDIR_SERVER_ETC_DIRPATH, &tcell); if (code) { bozo_Log ("could not create cell database in '%s' (code %d), quitting\n", AFSDIR_SERVER_ETC_DIRPATH, code); exit(1); } tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); if (!tdir) { bozo_Log ("failed to open newly-created cell database, quitting\n"); exit(1); } } /* opened the cell databse */ bozo_confdir = tdir; code = bnode_Init(); if (code) { printf("bosserver: could not init bnode package, code %d\n", code); exit(1); } bnode_Register("fs", &fsbnode_ops, 3); bnode_Register("dafs", &dafsbnode_ops, 4); bnode_Register("simple", &ezbnode_ops, 1); bnode_Register("cron", &cronbnode_ops, 2); #if defined(RLIMIT_CORE) && defined(HAVE_GETRLIMIT) { struct rlimit rlp; getrlimit(RLIMIT_CORE, &rlp); if (!DoCore) rlp.rlim_cur = 0; else rlp.rlim_max = rlp.rlim_cur = RLIM_INFINITY; setrlimit(RLIMIT_CORE, &rlp); getrlimit(RLIMIT_CORE, &rlp); bozo_Log("Core limits now %d %d\n",(int)rlp.rlim_cur,(int)rlp.rlim_max); } #endif /* Read init file, starting up programs. Also starts watcher threads. */ if ((code = ReadBozoFile(0))) { bozo_Log ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n", code, AFSDIR_SERVER_BOZCONF_FILEPATH); exit(code); } if (rxBind) { afs_int32 ccode; if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) { char reason[1024]; ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL, ADDRSPERSITE, reason, AFSDIR_SERVER_NETINFO_FILEPATH, AFSDIR_SERVER_NETRESTRICT_FILEPATH); } else { ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE); } if (ccode == 1) host = SHostAddrs[0]; } for (i = 0; i < 10; i++) { if (rxBind) { code = rx_InitHost(host, htons(AFSCONF_NANNYPORT)); } else { code = rx_Init(htons(AFSCONF_NANNYPORT)); } if (code) { bozo_Log("can't initialize rx: code=%d\n", code); sleep(3); } else break; } if (i >= 10) { bozo_Log("Bos giving up, can't initialize rx\n"); exit(code); } /* Set some rx config */ if (DoPeerRPCStats) rx_enablePeerRPCStats(); if (DoProcessRPCStats) rx_enableProcessRPCStats(); /* Disable jumbograms */ rx_SetNoJumbo(); if (rxMaxMTU != -1) { if (rx_SetMaxMTU(rxMaxMTU) != 0) { bozo_Log("bosserver: rxMaxMTU %d is invalid\n", rxMaxMTU); exit(1); } } code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1, /* param */ NULL , "bozo-the-clown", &bozo_pid); if (code) { bozo_Log("Failed to create daemon thread\n"); exit(1); } /* initialize audit user check */ osi_audit_set_user_check(bozo_confdir, bozo_IsLocalRealmMatch); bozo_CreateRxBindFile(host); /* for local scripts */ /* allow super users to manage RX statistics */ rx_SetRxStatUserOk(bozo_rxstat_userok); afsconf_SetNoAuthFlag(tdir, noAuth); afsconf_BuildServerSecurityObjects(tdir, &securityClasses, &numClasses); if (DoPidFiles) { bozo_CreatePidFile("bosserver", NULL, getpid()); } tservice = rx_NewServiceHost(host, 0, /* service id */ 1, "bozo", securityClasses, numClasses, BOZO_ExecuteRequest); rx_SetMinProcs(tservice, 2); rx_SetMaxProcs(tservice, 4); rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE); /* so gethostbyname works (in cell stuff) */ if (rxkadDisableDotCheck) { rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS, (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK); } tservice = rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats", securityClasses, numClasses, RXSTATS_ExecuteRequest); rx_SetMinProcs(tservice, 2); rx_SetMaxProcs(tservice, 4); rx_StartServer(1); /* donate this process */ return 0; }
Config * InitConfig() { std::string dir, prefix; Config *config; GetBaseDirectory(dir); FCEUI_SetBaseDirectory(dir.c_str()); CreateDirs(dir); config = new Config(dir); // sound options config->addOption('s', "sound", "SDL.Sound", 1); config->addOption("volume", "SDL.Sound.Volume", 150); config->addOption("trianglevol", "SDL.Sound.TriangleVolume", 256); config->addOption("square1vol", "SDL.Sound.Square1Volume", 256); config->addOption("square2vol", "SDL.Sound.Square2Volume", 256); config->addOption("noisevol", "SDL.Sound.NoiseVolume", 256); config->addOption("pcmvol", "SDL.Sound.PCMVolume", 256); config->addOption("soundrate", "SDL.Sound.Rate", 44100); config->addOption("soundq", "SDL.Sound.Quality", 1); config->addOption("soundrecord", "SDL.Sound.RecordFile", ""); config->addOption("soundbufsize", "SDL.Sound.BufSize", 128); config->addOption("lowpass", "SDL.Sound.LowPass", 0); config->addOption('g', "gamegenie", "SDL.GameGenie", 0); config->addOption("pal", "SDL.PAL", 0); config->addOption("frameskip", "SDL.Frameskip", 0); config->addOption("clipsides", "SDL.ClipSides", 0); config->addOption("nospritelim", "SDL.DisableSpriteLimit", 1); // color control config->addOption('p', "palette", "SDL.Palette", ""); config->addOption("tint", "SDL.Tint", 56); config->addOption("hue", "SDL.Hue", 72); config->addOption("ntsccolor", "SDL.NTSCpalette", 0); // scanline settings config->addOption("slstart", "SDL.ScanLineStart", 0); config->addOption("slend", "SDL.ScanLineEnd", 239); // video controls config->addOption('x', "xres", "SDL.XResolution", 512); config->addOption('y', "yres", "SDL.YResolution", 448); config->addOption('f', "fullscreen", "SDL.Fullscreen", 0); config->addOption('b', "bpp", "SDL.BitsPerPixel", 32); config->addOption("doublebuf", "SDL.DoubleBuffering", 0); config->addOption("autoscale", "SDL.AutoScale", 1); config->addOption("keepratio", "SDL.KeepRatio", 1); config->addOption("xscale", "SDL.XScale", 1.0); config->addOption("yscale", "SDL.YScale", 1.0); config->addOption("xstretch", "SDL.XStretch", 0); config->addOption("ystretch", "SDL.YStretch", 0); config->addOption("noframe", "SDL.NoFrame", 0); config->addOption("special", "SDL.SpecialFilter", 0); // OpenGL options config->addOption("opengl", "SDL.OpenGL", 0); config->addOption("openglip", "SDL.OpenGLip", 0); config->addOption("SDL.SpecialFilter", 0); config->addOption("SDL.SpecialFX", 0); // network play options - netplay is broken config->addOption("server", "SDL.NetworkIsServer", 0); config->addOption('n', "net", "SDL.NetworkIP", ""); config->addOption('u', "user", "SDL.NetworkUsername", ""); config->addOption('w', "pass", "SDL.NetworkPassword", ""); config->addOption('k', "netkey", "SDL.NetworkGameKey", ""); config->addOption("port", "SDL.NetworkPort", 4046); config->addOption("players", "SDL.NetworkPlayers", 1); // input configuration options config->addOption("input1", "SDL.Input.0", "GamePad.0"); config->addOption("input2", "SDL.Input.1", "GamePad.1"); config->addOption("input3", "SDL.Input.2", "Gamepad.2"); config->addOption("input4", "SDL.Input.3", "Gamepad.3"); // allow for input configuration config->addOption('i', "inputcfg", "SDL.InputCfg", InputCfg); // display input config->addOption("inputdisplay", "SDL.InputDisplay", 0); // pause movie playback at frame x config->addOption("pauseframe", "SDL.PauseFrame", 0); config->addOption("moviemsg", "SDL.MovieMsg", 1); // overwrite the config file? config->addOption("no-config", "SDL.NoConfig", 0); // video playback config->addOption("playmov", "SDL.Movie", ""); config->addOption("subtitles", "SDL.SubtitleDisplay", 1); config->addOption("fourscore", "SDL.FourScore", 0); #ifdef _S9XLUA_H // load lua script config->addOption("loadlua", "SDL.LuaScript", ""); #endif #ifdef CREATE_AVI config->addOption("videolog", "SDL.VideoLog", ""); config->addOption("mute", "SDL.MuteCapture", 0); #endif #ifdef _GTK char* home_dir = getenv("HOME"); // prefixed with _ because they are internal (not cli options) config->addOption("_lastopenfile", "SDL.LastOpenFile", home_dir); config->addOption("_laststatefrom", "SDL.LastLoadStateFrom", home_dir); config->addOption("_lastopennsf", "SDL.LastOpenNSF", home_dir); config->addOption("_lastsavestateas", "SDL.LastSaveStateAs", home_dir); // option to disable gui (broken??) config->addOption("nogui", "SDL.NoGUI", 0); #endif // fcm -> fm2 conversion config->addOption("fcmconvert", "SDL.FCMConvert", ""); // fm2 -> srt conversion config->addOption("ripsubs", "SDL.RipSubs", ""); // enable new PPU core config->addOption("newppu", "SDL.NewPPU", 0); // GamePad 0 - 3 for(unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++) { char buf[64]; snprintf(buf, 20, "SDL.Input.GamePad.%d.", i); prefix = buf; config->addOption(prefix + "DeviceType", DefaultGamePadDevice[i]); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < GAMEPAD_NUM_BUTTONS; j++) { config->addOption(prefix + GamePadNames[j], DefaultGamePad[i][j]); } } // PowerPad 0 - 1 for(unsigned int i = 0; i < POWERPAD_NUM_DEVICES; i++) { char buf[64]; snprintf(buf, 20, "SDL.Input.PowerPad.%d.", i); prefix = buf; config->addOption(prefix + "DeviceType", DefaultPowerPadDevice[i]); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < POWERPAD_NUM_BUTTONS; j++) { config->addOption(prefix +PowerPadNames[j], DefaultPowerPad[i][j]); } } // QuizKing prefix = "SDL.Input.QuizKing."; config->addOption(prefix + "DeviceType", DefaultQuizKingDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < QUIZKING_NUM_BUTTONS; j++) { config->addOption(prefix + QuizKingNames[j], DefaultQuizKing[j]); } // HyperShot prefix = "SDL.Input.HyperShot."; config->addOption(prefix + "DeviceType", DefaultHyperShotDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < HYPERSHOT_NUM_BUTTONS; j++) { config->addOption(prefix + HyperShotNames[j], DefaultHyperShot[j]); } // Mahjong prefix = "SDL.Input.Mahjong."; config->addOption(prefix + "DeviceType", DefaultMahjongDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < MAHJONG_NUM_BUTTONS; j++) { config->addOption(prefix + MahjongNames[j], DefaultMahjong[j]); } // TopRider prefix = "SDL.Input.TopRider."; config->addOption(prefix + "DeviceType", DefaultTopRiderDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < TOPRIDER_NUM_BUTTONS; j++) { config->addOption(prefix + TopRiderNames[j], DefaultTopRider[j]); } // FTrainer prefix = "SDL.Input.FTrainer."; config->addOption(prefix + "DeviceType", DefaultFTrainerDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < FTRAINER_NUM_BUTTONS; j++) { config->addOption(prefix + FTrainerNames[j], DefaultFTrainer[j]); } // FamilyKeyBoard prefix = "SDL.Input.FamilyKeyBoard."; config->addOption(prefix + "DeviceType", DefaultFamilyKeyBoardDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < FAMILYKEYBOARD_NUM_BUTTONS; j++) { config->addOption(prefix + FamilyKeyBoardNames[j], DefaultFamilyKeyBoard[j]); } // for FAMICOM microphone in pad 2 pad 1 didn't have it // Takeshi no Chousenjou uses it for example. prefix = "SDL.Input.FamicomPad2."; config->addOption("rp2mic", prefix + "EnableMic", 0); const int Hotkeys[HK_MAX] = { SDLK_F1, // cheat menu SDLK_F2, // bind state SDLK_F3, // load lua SDLK_F4, // toggleBG SDLK_F5, // save state SDLK_F6, // fds select SDLK_F7, // load state SDLK_F8, // fds eject SDLK_F6, // VS insert coin SDLK_F8, // VS toggle dipswitch SDLK_PERIOD, // toggle frame display SDLK_F10, // toggle subtitle SDLK_F11, // reset SDLK_F12, // screenshot SDLK_PAUSE, // pause SDLK_MINUS, // speed++ SDLK_EQUALS, // speed-- SDLK_BACKSLASH, //frame advnace SDLK_TAB, // turbo SDLK_COMMA, // toggle input display SDLK_q, // toggle movie RW SDLK_QUOTE, // toggle mute capture //SDLK_ESCAPE, // quit SDLK_DELETE, // frame advance lag skip SDLK_SLASH, // lag counter display SDLK_0, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9 }; prefix = "SDL.Hotkeys."; for(int i=0; i < HK_MAX; i++) config->addOption(prefix + HotkeyStrings[i], Hotkeys[i]); /* config->addOption(prefix + "Pause", SDLK_PAUSE); config->addOption(prefix + "DecreaseSpeed", SDLK_MINUS); config->addOption(prefix + "IncreaseSpeed", SDLK_EQUALS); config->addOption(prefix + "FrameAdvance", SDLK_BACKSLASH); config->addOption(prefix + "FastForward", SDLK_TAB); config->addOption(prefix + "InputDisplay", SDLK_i); config->addOption(prefix + "MovieToggleReadWrite", SDLK_q); #ifdef CREATE_AVI config->addOption(prefix + "MuteCapture", SDLK_DELETE); #endif config->addOption(prefix + "Quit", SDLK_ESCAPE); //config->addOption(prefix + "Power", 0); config->addOption(prefix + "SelectState0", SDLK_0); config->addOption(prefix + "SelectState1", SDLK_1); config->addOption(prefix + "SelectState2", SDLK_2); config->addOption(prefix + "SelectState3", SDLK_3); config->addOption(prefix + "SelectState4", SDLK_4); config->addOption(prefix + "SelectState5", SDLK_5); config->addOption(prefix + "SelectState6", SDLK_6); config->addOption(prefix + "SelectState7", SDLK_7); config->addOption(prefix + "SelectState8", SDLK_8); config->addOption(prefix + "SelectState9", SDLK_9); */ // All mouse devices config->addOption("SDL.OekaKids.0.DeviceType", "Mouse"); config->addOption("SDL.OekaKids.0.DeviceNum", 0); config->addOption("SDL.Arkanoid.0.DeviceType", "Mouse"); config->addOption("SDL.Arkanoid.0.DeviceNum", 0); config->addOption("SDL.Shadow.0.DeviceType", "Mouse"); config->addOption("SDL.Shadow.0.DeviceNum", 0); config->addOption("SDL.Zapper.0.DeviceType", "Mouse"); config->addOption("SDL.Zapper.0.DeviceNum", 0); return config; }
Config * InitConfig() { std::string dir, prefix; Config *config; GetBaseDirectory(dir); FCEUI_SetBaseDirectory(dir.c_str()); CreateDirs(dir); config = new Config(dir); // sound options config->addOption('s', "sound", "SDL.Sound", 1); config->addOption("volume", "SDL.Sound.Volume", 256); config->addOption("trianglevol", "SDL.Sound.TriangleVolume", 256); config->addOption("square1vol", "SDL.Sound.Square1Volume", 256); config->addOption("square2vol", "SDL.Sound.Square2Volume", 256); config->addOption("noisevol", "SDL.Sound.NoiseVolume", 256); config->addOption("pcmvol", "SDL.Sound.PCMVolume", 256); config->addOption("soundrate", "SDL.Sound.Rate", 32000); config->addOption("soundq", "SDL.Sound.Quality", 0); config->addOption("soundrecord", "SDL.Sound.RecordFile", ""); config->addOption("soundbufsize", "SDL.Sound.BufSize", 30); config->addOption("lowpass", "SDL.Sound.LowPass", 0); config->addOption('g', "gamegenie", "SDL.GameGenie", 0); config->addOption("pal", "SDL.PAL", 0); config->addOption("frameskip", "SDL.Frameskip", 0); config->addOption("clipsides", "SDL.ClipSides", 0); config->addOption("nospritelim", "SDL.DisableSpriteLimit", 1); // color control config->addOption('p', "palette", "SDL.Palette", ""); config->addOption("tint", "SDL.Tint", 56); config->addOption("hue", "SDL.Hue", 72); config->addOption("ntsccolor", "SDL.NTSCpalette", 0); // scanline settings config->addOption("slstart", "SDL.ScanLineStart", 0); config->addOption("slend", "SDL.ScanLineEnd", 239); // video controls config->addOption('x', "xres", "SDL.XResolution", 320); config->addOption('y', "yres", "SDL.YResolution", 240); config->addOption('f', "fullscreen", "SDL.Fullscreen", 0); config->addOption('b', "bpp", "SDL.BitsPerPixel", 8); config->addOption("doublebuf", "SDL.DoubleBuffering", 0); config->addOption("autoscale", "SDL.AutoScale", 1); config->addOption("keepratio", "SDL.KeepRatio", 1); config->addOption("xscale", "SDL.XScale", 1.0); config->addOption("yscale", "SDL.YScale", 1.0); config->addOption("xstretch", "SDL.XStretch", 0); config->addOption("ystretch", "SDL.YStretch", 0); config->addOption("noframe", "SDL.NoFrame", 0); config->addOption("special", "SDL.SpecialFilter", 0); // NOT SUPPORTED // OpenGL options //config->addOption("opengl", "SDL.OpenGL", 0); //config->addOption("openglip", "SDL.OpenGLip", 0); //config->addOption("SDL.SpecialFilter", 0); //config->addOption("SDL.SpecialFX", 0); // network play options - netplay is broken //config->addOption("server", "SDL.NetworkIsServer", 0); //config->addOption('n', "net", "SDL.NetworkIP", ""); //config->addOption('u', "user", "SDL.NetworkUsername", ""); //config->addOption('w', "pass", "SDL.NetworkPassword", ""); //config->addOption('k', "netkey", "SDL.NetworkGameKey", ""); //config->addOption("port", "SDL.NetworkPort", 4046); //config->addOption("players", "SDL.NetworkPlayers", 1); config->addOption("mousespeed", "SDL.MouseSpeed", 3); config->addOption("showmouse", "SDL.ShowMouseCursor", 0); config->addOption("fpsthottle", "SDL.FPSThrottle", 0); config->addOption("showfps", "SDL.ShowFPS", 0); // input configuration options config->addOption("input1", "SDL.Input.0", "GamePad.0"); config->addOption("input2", "SDL.Input.1", "GamePad.1"); config->addOption("input3", "SDL.Input.2", "Gamepad.2"); config->addOption("input4", "SDL.Input.3", "Gamepad.3"); // allow for input configuration // NOT SUPPORTED // config->addOption('i', "inputcfg", "SDL.InputCfg", InputCfg); // display input config->addOption("inputdisplay", "SDL.InputDisplay", 0); // pause movie playback at frame x config->addOption("pauseframe", "SDL.PauseFrame", 0); config->addOption("moviemsg", "SDL.MovieMsg", 1); // overwrite the config file? config->addOption("no-config", "SDL.NoConfig", 0); // video playback config->addOption("playmov", "SDL.Movie", ""); config->addOption("subtitles", "SDL.SubtitleDisplay", 1); config->addOption("fourscore", "SDL.FourScore", 0); #ifdef _S9XLUA_H // load lua script config->addOption("loadlua", "SDL.LuaScript", ""); #endif #ifdef CREATE_AVI config->addOption("videolog", "SDL.VideoLog", ""); config->addOption("mute", "SDL.MuteCapture", 0); #endif // fcm -> fm2 conversion config->addOption("fcmconvert", "SDL.FCMConvert", ""); // fm2 -> srt conversion config->addOption("ripsubs", "SDL.RipSubs", ""); // enable new PPU core config->addOption("newppu", "SDL.NewPPU", 0); // GamePad 0 - 3 for (unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++) { char buf[64]; snprintf(buf, 20, "SDL.Input.GamePad.%d.", i); prefix = buf; config->addOption(prefix + "DeviceType", DefaultGamePadDevice[i]); config->addOption(prefix + "DeviceNum", 0); for (unsigned int j = 0; j < GAMEPAD_NUM_BUTTONS; j++) { config->addOption(prefix + GamePadNames[j], DefaultGamePad[i][j]); } } #if 0 // PowerPad 0 - 1 for(unsigned int i = 0; i < POWERPAD_NUM_DEVICES; i++) { char buf[64]; snprintf(buf, 20, "SDL.Input.PowerPad.%d.", i); prefix = buf; config->addOption(prefix + "DeviceType", DefaultPowerPadDevice[i]); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < POWERPAD_NUM_BUTTONS; j++) { config->addOption(prefix +PowerPadNames[j], DefaultPowerPad[i][j]); } } #endif // QuizKing prefix = "SDL.Input.QuizKing."; config->addOption(prefix + "DeviceType", DefaultQuizKingDevice); config->addOption(prefix + "DeviceNum", 0); for (unsigned int j = 0; j < QUIZKING_NUM_BUTTONS; j++) { config->addOption(prefix + QuizKingNames[j], DefaultQuizKing[j]); } // HyperShot prefix = "SDL.Input.HyperShot."; config->addOption(prefix + "DeviceType", DefaultHyperShotDevice); config->addOption(prefix + "DeviceNum", 0); for (unsigned int j = 0; j < HYPERSHOT_NUM_BUTTONS; j++) { config->addOption(prefix + HyperShotNames[j], DefaultHyperShot[j]); } #if 0 // Mahjong prefix = "SDL.Input.Mahjong."; config->addOption(prefix + "DeviceType", DefaultMahjongDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < MAHJONG_NUM_BUTTONS; j++) { config->addOption(prefix + MahjongNames[j], DefaultMahjong[j]); } #endif // TopRider prefix = "SDL.Input.TopRider."; config->addOption(prefix + "DeviceType", DefaultTopRiderDevice); config->addOption(prefix + "DeviceNum", 0); for (unsigned int j = 0; j < TOPRIDER_NUM_BUTTONS; j++) { config->addOption(prefix + TopRiderNames[j], DefaultTopRider[j]); } #if 0 // FTrainer prefix = "SDL.Input.FTrainer."; config->addOption(prefix + "DeviceType", DefaultFTrainerDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < FTRAINER_NUM_BUTTONS; j++) { config->addOption(prefix + FTrainerNames[j], DefaultFTrainer[j]); } // FamilyKeyBoard prefix = "SDL.Input.FamilyKeyBoard."; config->addOption(prefix + "DeviceType", DefaultFamilyKeyBoardDevice); config->addOption(prefix + "DeviceNum", 0); for(unsigned int j = 0; j < FAMILYKEYBOARD_NUM_BUTTONS; j++) { config->addOption(prefix + FamilyKeyBoardNames[j], DefaultFamilyKeyBoard[j]); } #endif // Will use R + Button combo for hotkeys on dingoo // So only 11 hotkeys available // L trigger will be saved for GUI const int Hotkeys[HK_MAX] = { -1, // cheat menu -1, // bind state -1, // load lua -1, // toggleBG 0, // save state 2, // fds flip disk -1, // fds select 1, // load state -1, // fds eject 5, // VS insert coin -1, // VS toggle dipswitch 6, // toggle frame display 27, // toggle subtitle -1, // reset 17, // screenshot 16, // pause -1, // speed++ -1, // speed-- 18, //frame advance -1, // turbo -1, // toggle input display -1, // toggle movie RW -1, // toggle mute capture 29, // quit -1, // frame advance lag skip -1, // lag counter display -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; prefix = "SDL.Hotkeys."; for (int i = 0; i < HK_MAX; i++) config->addOption(prefix + HotkeyStrings[i], Hotkeys[i]); // TODO - Are these necessary? /* config->addOption(prefix + "Pause", SDLK_PAUSE); config->addOption(prefix + "DecreaseSpeed", SDLK_MINUS); config->addOption(prefix + "IncreaseSpeed", SDLK_EQUALS); config->addOption(prefix + "FrameAdvance", SDLK_BACKSLASH); config->addOption(prefix + "FastForward", SDLK_TAB); config->addOption(prefix + "InputDisplay", SDLK_i); config->addOption(prefix + "MovieToggleReadWrite", SDLK_q); #ifdef CREATE_AVI config->addOption(prefix + "MuteCapture", SDLK_DELETE); #endif config->addOption(prefix + "Quit", SDLK_ESCAPE); //config->addOption(prefix + "Power", 0); */ /* NOT SUPPORTED config->addOption(prefix + "SelectState0", SDLK_0); config->addOption(prefix + "SelectState1", SDLK_1); config->addOption(prefix + "SelectState2", SDLK_2); config->addOption(prefix + "SelectState3", SDLK_3); config->addOption(prefix + "SelectState4", SDLK_4); config->addOption(prefix + "SelectState5", SDLK_5); config->addOption(prefix + "SelectState6", SDLK_6); config->addOption(prefix + "SelectState7", SDLK_7); config->addOption(prefix + "SelectState8", SDLK_8); config->addOption(prefix + "SelectState9", SDLK_9); */ // All mouse devices config->addOption("SDL.OekaKids.0.DeviceType", "Mouse"); config->addOption("SDL.OekaKids.0.DeviceNum", 0); config->addOption("SDL.Arkanoid.0.DeviceType", "Mouse"); config->addOption("SDL.Arkanoid.0.DeviceNum", 0); config->addOption("SDL.Shadow.0.DeviceType", "Mouse"); config->addOption("SDL.Shadow.0.DeviceNum", 0); config->addOption("SDL.Zapper.0.DeviceType", "Mouse"); config->addOption("SDL.Zapper.0.DeviceNum", 0); return config; }
/* * User pressed the install button. Make it go. */ void CBINDInstallDlg::OnInstall() { #if _MSC_VER >= 1400 char Vcredist_x86[MAX_PATH]; #endif BOOL success = FALSE; int oldlen; if (CheckBINDService()) StopBINDService(); InstallTags(); UpdateData(); if (!m_toolsOnly && m_accountName != LOCAL_SERVICE) { /* * Check that the Passwords entered match. */ if (m_accountPassword != m_accountPasswordConfirm) { MsgBox(IDS_ERR_PASSWORD); return; } /* * Check that there is not leading / trailing whitespace. * This is for compatibility with the standard password dialog. * Passwords really should be treated as opaque blobs. */ oldlen = m_accountPassword.GetLength(); m_accountPassword.TrimLeft(); m_accountPassword.TrimRight(); if (m_accountPassword.GetLength() != oldlen) { MsgBox(IDS_ERR_WHITESPACE); return; } /* * Check the entered account name. */ if (ValidateServiceAccount() == FALSE) return; /* * For Registration we need to know if account was changed. */ if (m_accountName != m_currentAccount) m_accountUsed = FALSE; if (m_accountUsed == FALSE && m_serviceExists == FALSE) { /* * Check that the Password is not null. */ if (m_accountPassword.GetLength() == 0) { MsgBox(IDS_ERR_NULLPASSWORD); return; } } } else if (m_accountName == LOCAL_SERVICE) { /* The LocalService always exists. */ m_accountExists = TRUE; if (m_accountName != m_currentAccount) m_accountUsed = FALSE; } /* Directories */ m_etcDir = m_targetDir + "\\etc"; m_binDir = m_targetDir + "\\bin"; if (m_defaultDir != m_targetDir) { if (GetFileAttributes(m_targetDir) != 0xFFFFFFFF) { int install = MsgBox(IDS_DIREXIST, MB_YESNO | MB_ICONQUESTION, m_targetDir); if (install == IDNO) return; } else { int createDir = MsgBox(IDS_CREATEDIR, MB_YESNO | MB_ICONQUESTION, m_targetDir); if (createDir == IDNO) return; } } if (!m_toolsOnly) { if (m_accountExists == FALSE) { success = CreateServiceAccount(m_accountName.GetBuffer(30), m_accountPassword.GetBuffer(30)); if (success == FALSE) { MsgBox(IDS_CREATEACCOUNT_FAILED); return; } m_accountExists = TRUE; } } ProgramGroup(FALSE); #if _MSC_VER >= 1400 /* * Install Visual Studio libraries. As per: * http://blogs.msdn.com/astebner/archive/2006/08/23/715755.aspx * * Vcredist_x86.exe /q:a /c:"msiexec /i vcredist.msi /qn /l*v %temp%\vcredist_x86.log" */ /*system(".\\Vcredist_x86.exe /q:a /c:\"msiexec /i vcredist.msi /qn /l*v %temp%\vcredist_x86.log\"");*/ /* * Enclose full path to Vcredist_x86.exe in quotes as * m_currentDir may contain spaces. */ sprintf(Vcredist_x86, "\"%s\\Vcredist_x86.exe\"", (LPCTSTR) m_currentDir); system(Vcredist_x86); #endif try { CreateDirs(); CopyFiles(); if (!m_toolsOnly) RegisterService(); RegisterMessages(); HKEY hKey; /* Create a new key for named */ SetCurrent(IDS_CREATE_KEY); if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_SUBKEY, &hKey) == ERROR_SUCCESS) { // Get the install directory RegSetValueEx(hKey, "InstallDir", 0, REG_SZ, (LPBYTE)(LPCTSTR)m_targetDir, m_targetDir.GetLength()); RegCloseKey(hKey); } SetCurrent(IDS_ADD_REMOVE); if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_UNINSTALL_SUBKEY, &hKey) == ERROR_SUCCESS) { CString buf(BIND_DISPLAY_NAME); RegSetValueEx(hKey, "DisplayName", 0, REG_SZ, (LPBYTE)(LPCTSTR)buf, buf.GetLength()); buf.Format("%s\\BINDInstall.exe", m_binDir); RegSetValueEx(hKey, "UninstallString", 0, REG_SZ, (LPBYTE)(LPCTSTR)buf, buf.GetLength()); RegCloseKey(hKey); } ProgramGroup(FALSE); if (m_startOnInstall) StartBINDService(); } catch(Exception e) { MessageBox(e.resString); SetCurrent(IDS_CLEANUP); FailedInstall(); MsgBox(IDS_FAIL); return; } catch(DWORD dw) { CString msg; msg.Format("A fatal error occured\n(%s)", GetErrMessage(dw)); MessageBox(msg); SetCurrent(IDS_CLEANUP); FailedInstall(); MsgBox(IDS_FAIL); return; } SetCurrent(IDS_INSTALL_DONE); MsgBox(IDS_SUCCESS); }
int CUserPatcher::_Patch( LPCTSTR szfile, const T_UserPatchInfo &unpkinfo, const char *, CString &strLogfile ) { USES_CONVERSION; TCHAR szTempPath[MAX_PATH]; #if 1 TCHAR szTempName[MAX_PATH]; GetTempPath(MAX_PATH, szTempName); GetTempFileName(szTempName, _T("BK.UPK"), 0, szTempPath); DeleteFile( szTempPath ); #else strcpy(szTempPath, "c:\\office.unpack\\"); #endif INT err = KPATCHER_ERR_GENERAL; do { strings files; if(!m_objUpk->Extract(szfile, szTempPath, files)) { err = KPATCHER_ERR_EXTRACT; break; } typedef std::pair<std::string, std::string> stringPair; typedef std::vector< stringPair > stringPairs; stringPairs ps; for(int i=0; i<unpkinfo.files.GetSize(); ++i) { // const T_UserPatchInfo::PatchFileInfo &pi = unpkinfo.files[i]; std::string strfromfilename; _GetFilename( CT2CA(pi.strFilenameFrom), strfromfilename); for(strings::iterator it2=files.begin(); it2!=files.end(); ++it2) { std::string strfilename2; _GetFilename( it2->c_str(), strfilename2 ); if(stricmp(strfromfilename.c_str(), strfilename2.c_str())==0) { std::string sto = CT2CA(pi.strFilenameTo); ps.push_back( stringPair(*it2, sto) ); break; } } } if( ps.size()< unpkinfo.files.GetSize() ) { err = KPATCHER_ERR_FILENOTMATCH; break; } // 2. check file is not used BOOL bFileIsUsing = FALSE; for(unsigned int i=0; i<ps.size(); ++i) { CString strFilename = CA2CT(ps[i].second.c_str()); if( PathFileExists(strFilename) && IsFileUsing( strFilename ) ) { bFileIsUsing = TRUE; break; } } if(bFileIsUsing) { err = KPATCHER_ERR_FILEBUSY; break; } // 3. replace files struct T_ReplaceInfo { std::string strTo, strTmpBackup, strTmp; LARGE_INTEGER llfrom, llto; bool skipReplace; }; bool hasError = false; std::vector<T_ReplaceInfo> tmpfiles; // copy all files into target path for( unsigned int i=0; i<ps.size() && !hasError; ++i) { // BAKCUP in local DIR std::string strfrom, strto, strtmp, strbackup; strfrom = ps[i].first; strto = ps[i].second; strtmp = strto + "_TMP"; strbackup = ps[i].second + "_TMPBK"; T_ReplaceInfo r; r.strTo = strto; r.strTmpBackup = strbackup; r.strTmp = strtmp; if( GetFileVersion( CA2CT(strfrom.c_str()), r.llfrom) && GetFileVersion( CA2CT(strto.c_str()), r.llto) && r.llfrom.QuadPart==r.llto.QuadPart ) { r.skipReplace = true; } else { CreateDirs( strto.c_str() ); BOOL b1 = true, b2 = true; if( IsFileExist( CA2CT(strto.c_str()) ) ) b1 = MyMoveFileA( strto.c_str(), strbackup.c_str()); b2 = MyMoveFileA(strfrom.c_str(), strtmp.c_str()); if( !b1 || !b2 ) { #ifdef _DEBUG DWORD dwErr = GetLastError(); CStringA strA; strA.Format("MOVE FILE ERROR %d\r\n%d %s -> %s\r\n%d %s -> %s \r\n", dwErr, b1, strto.c_str(), strbackup.c_str(), b2, strfrom.c_str(), strtmp.c_str() ); MessageBoxA(NULL, strA, NULL, MB_OK); #endif hasError = true; } r.skipReplace = false; } tmpfiles.push_back( r ); } // 4. rollback or commit replace operation if( hasError ) { for( unsigned int i=0; i<tmpfiles.size(); ++i) { T_ReplaceInfo &r = tmpfiles[i]; if( r.skipReplace ) continue; MyMoveFileA( r.strTmpBackup.c_str(), r.strTo.c_str() ); } err = KPATCHER_ERR_REPLACE; } else { // Assume all move operation success CStringA slog; CStringA strProductKey = CT2CA(unpkinfo.strProductKey), strPatchKey = CT2CA(unpkinfo.strPatchKey); slog.AppendFormat("REG:%s\t%s\r\n", strProductKey, strPatchKey); for( unsigned int i=0; i<tmpfiles.size(); ++i) { T_ReplaceInfo &r = tmpfiles[i]; std::string strbackup = r.strTo + "_bk"; CString strVfrom, strVto; CStringA strVfromA, strVtoA; GenVersionStr( r.llfrom, strVfrom); GenVersionStr( r.llto, strVto); strVfromA = CT2CA( strVfrom ); strVtoA = CT2CA( strVto ); slog.AppendFormat("VER:%s\t%s\r\n", strVfromA, strVtoA); slog.AppendFormat("FILE:%d\t%s\t%s\r\n", r.skipReplace, strbackup.c_str(), r.strTo.c_str() ); if( r.skipReplace ) continue; // if( IsFileExist( CA2CT(r.strTmpBackup.c_str()) ) ) MyMoveFileA(r.strTmpBackup.c_str(), strbackup.c_str()); MyMoveFileA(r.strTmp.c_str(), r.strTo.c_str()); } std::string dir; _GetFileDir( ps[0].second.c_str(), dir ); char logfilename[MAX_PATH]; sprintf(logfilename, "$NTUninstKB%d$.log", unpkinfo.nKBID); dir += '\\'; dir += logfilename; strLogfile = CA2CT(dir.c_str()); file_put_contents( strLogfile, (BYTE*)(LPCSTR)slog, slog.GetLength()); err = KPATCHER_OK; } }while(FALSE); #ifndef _DEBUG { TCHAR szPath[MAX_PATH] = {0}; _tcscpy(szPath, szTempPath); SHFILEOPSTRUCT shfileopstruct = {0}; shfileopstruct.wFunc = FO_DELETE; shfileopstruct.pFrom = szPath; shfileopstruct.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI; SHFileOperation(&shfileopstruct); } #endif return err; }