/*ARGSUSED*/ void OptionCallback(Widget w, XtPointer pointer, XtPointer junk) { ManpageGlobals * man_globals = (ManpageGlobals *) pointer; String params; Cardinal num_params = 1; if ( w == man_globals->search_entry ) PopupSearch(XtParent(w), NULL, NULL, NULL); else if (w == man_globals->dir_entry) { /* Put Up Directory */ params = "Directory"; GotoPage(XtParent(w), NULL, ¶ms, &num_params); } else if (w == man_globals->manpage_entry ) { /* Put Up Man Page */ params = "ManualPage"; GotoPage(XtParent(w), NULL, ¶ms, &num_params); } else if ( w == man_globals->help_entry ) /* Help */ PopupHelp(XtParent(w), NULL, NULL, NULL); else if ( w == man_globals->both_screens_entry ) /*Toggle Both_Shown State.*/ ToggleBothShownState(man_globals); else if ( w == man_globals->remove_entry) /* Kill the manpage */ RemoveThisManpage(XtParent(w), NULL, NULL, NULL); else if ( w == man_globals->open_entry) /* Open new manpage */ CreateNewManpage(XtParent(w), NULL, NULL, NULL); else if ( w == man_globals->version_entry) /* Get version */ ShowVersion(XtParent(w), NULL, NULL, NULL); else if ( w == man_globals->quit_entry) /* Quit. */ Quit(XtParent(w), NULL, NULL, NULL); }
/** * Prints the program syntax. * * @returns 1 * @param argv0 The program name. */ static int ShowSyntax(const char *argv0) { ShowVersion(); printf("syntax: %s [options] <files>\n" "\n", argv0); return 1; }
__declspec(dllexport) void main() { Init(); __try { switch ( *(DWORD *)(0x00DDDC00) ) { /*case 0x508B018B : // 1.7.7.0 (2012) { break; } */ case 0x5FFFF2DD : // 1.8.151.0 (2012) { break; } default : { ShowVersion(); return; } } if(!EasySteam::Interface::GetInstance() || !EasySteam::Interface::GetInstance()->GetUser()->IsLoggedOn()) { Debug::ShowMessageBox("Unable to retrieve steam."); return; } Skyrim::RegisterOnlineScript(); srand((unsigned int)time(NULL)); PrintNote("To play Skyrim Online, press F3"); while(!Skyrim::TheGameWorld) { if(GetKeyPressed(VK_F3)) { NewInstance(); Skyrim::TheGameWorld->Setup(); break; } Wait(0); } if(Skyrim::TheGameWorld) Skyrim::TheGameWorld->Run(); } __except(GenerateDump(GetExceptionInformation())) { } }
// Check only arguments needing action before GUI is shown. // Rest of the arguments are handled in MainWindow::HandleCLIParams() static bool CheckArgs(const QStringList &args) { if (args.contains("-h") || args.contains("--help")) { ShowUsage(); return false; } if (args.contains("-v") || args.contains("--version")) { ShowVersion(); return false; } return true; }
int main(int argc, char *argv[]) { #if HAVE_SETBUF setbuf(stdin, NULL); #endif OpenLogFile("Amy.log"); InitMoves(); InitAll(); HashInit(); /* * Process rc file first, then command line options. This way command * line options can override rc file settings. */ ProcessRCFile(); ProcessOptions(argc, argv); ShowVersion(); AllocateHT(); InitEGTB(EGTBPath); RecogInit(); DoBookLearning(); Print(0, "\n"); strcpy(AutoSaveFileName, GetTmpFileName()); /* Ensure true random behavior. */ InitRandom(GetTime()); StateMachine(); return 0; }
int main(int argc, char *argv[]) { int error = 0; if ((argc == 2) && (strcmp(argv[1], "-v") == 0)) { ShowVersion(); return 0; } if ((InitClient()) || (ConnectToMiranda()) || (GetKnownCommands()) || (LoadLangPackModule())) { lpprintf("Could not create connection with Miranda or could not retrieve list of known commands.\n"); error = MIMRES_NOMIRANDA; } else{ if ((argc <= 1) || (argc > MAX_ARGUMENTS)) { PrintUsage(); } else{ PReply reply = ParseCommand(argv, argc); if (reply) { error = reply->code; lpprintf("%s\n", reply->message); } else{ lpprintf(Translate("Unknown command '%s'.\n"), argv[1]); } DestroyKnownCommands(); DisconnectFromMiranda(); DestroyClient(); } } return error; }
void main(void) { /* * Power On Reset initialization */ PIC_Init(); LCD_Init(); /* Display application and version */ ShowVersion(); /* Show what is in the character generator RAM */ LCD_SetDDRamAddr(LINE_TWO); LCD_WriteConstString("\010\011\012\013\014\015\016\017"); /* octal byte constants in a string */ LCD_WriteConstString(" 18JUL21"); /* * Main application loop */ for(;;) { } }
/* ---------------------------------------------------------------------------- * Private method to display help info * ---------------------------------------------------------------------------- */ void DynMat::help() { ShowVersion(); printf("\nUsage:\n phana [options] [file]\n\n"); printf("Available options:\n"); printf(" -r To reset the dynamical matrix at the gamma point by a 4th order\n"); printf(" polynomial interpolation along the [100] direction; this might be\n"); printf(" useful for systems with charges. As for charged system, the dynamical\n"); printf(" matrix at Gamma is far from accurate because of the long range nature\n"); printf(" of Coulombic interaction. By reset it by interpolation, will partially\n"); printf(" elliminate the unwanted behavior, but the result is still inaccurate.\n"); printf(" By default, this is not set; and not expected for uncharged systems.\n\n"); printf(" -s This will reset the dynamical matrix at the gamma point, too, but it\n"); printf(" will also inform the code to skip all q-points that is in the vicinity\n"); printf(" of the gamma point when evaluating phonon DOS and/or phonon dispersion.\n\n"); printf(" By default, this is not set; and not expected for uncharged systems.\n\n"); printf(" -h To print out this help info.\n\n"); printf(" file To define the filename that carries the binary dynamical matrice generated\n"); printf(" by fix-phonon. If not provided, the code will ask for it.\n"); printf("\n\n"); exit(0); }
void InitConfig(int argc, char *argv[], std::string& configFile) { while(true) { int option_index = 0; int c = getopt_long(argc, argv, option_format, long_options, &option_index); if (c == -1) break; switch(c) { case 0: // long option, not need process break; case 'f': configFile.assign(optarg); break; case 'v': ShowVersion(); exit(0); case 'h': ShowUsage(argv[0]); exit(0); } } }
int main(int argc, char *argv[]) { uldat err = 1, id, index_list, len; tslist TSL; tsfield TSF; uldat n, v_id; udat type_id, max_list; byte verbose = FALSE, recursive = FALSE, isvec; TwMergeHyphensArgv(argc, argv); argv0 = argv[0]; argc--; argv++; while (argc--) { if (!strcmp(*argv, "-h") || !strcmp(*argv, "-help")) { Usage(); return 0; } else if (!strcmp(*argv, "-V") || !strcmp(*argv, "-version")) { ShowVersion(); return 0; } else if (!strcmp(*argv, "-r") || !strcmp(*argv, "-recursive")) { recursive = TRUE; } else if (!strcmp(*argv, "-v") || !strcmp(*argv, "-verbose")) { verbose = TRUE; } else if ((id = strtoul(*argv, NULL, 0)) != TW_NOID) { err = 0; } argv++; } max_list = recursive ? lsobj_max_list1 : lsobj_max_list0; if (TwCheckMagic(lsobj_magic) && TwOpen(NULL)) do { if (err == 1) { id = TwGetAll(); if (TwErrno == TW_ESERVER_NO_FUNCTION) { TwErrno = 0; id = TwFirstScreen(); } } TSL = TwStatA(id, max_list, field_list); if (TSL) { for (id = 0, TSF = TSL->TSF; id < TSL->N; id++, TSF++) { for (index_list = 0; index_list < max_list; index_list++) { if (field_list[index_list] == TSF->hash) break; } if (index_list < max_list) { printf("%s", name_list[index_list]); len = strlen(name_list[index_list]); } else { len = 13; printf("unknown_field"); } while (len < 32) len++, putchar(' '); isvec = TSF->type >= TWS_vec && (TSF->type & ~TWS_vec) <= TWS_last; if (isvec) type_id = TSF->type & ~TWS_vec; else type_id = TSF->type; if (type_id == TWS_tobj) type_id = TWS_highest; else if (type_id > TWS_tobj) /* unknown */ type_id = TWS_highest + 1; if (isvec) { len += 4 + strlen(type_list[type_id]); v_id = TSF->type & ~TWS_vec; if (v_id == TWS_tobj) v_id = TWS_uldat; if (v_id < TWS_highest) { n = v_id = TSF->TWS_field_vecL / lsobj_magic[v_id]; do len++; while (v_id /= 10); printf("= (%s[%d])", type_list[type_id], (int)n); } else printf("= (%s[])", type_list[type_id]); } else { len += 2 + strlen(type_list[type_id]); printf("= (%s)", type_list[type_id]); } while (len < 44) len++, putchar(' '); if (isvec) { if (TSF->TWS_field_vecL && TSF->TWS_field_vecV) { if (type_id == TWS_highest) human_print_tobjs(TSF->TWS_field_vecV, TSF->TWS_field_vecL, !verbose); else human_print(TSF->TWS_field_vecV, TSF->TWS_field_vecL, !verbose); } else printf(" (NULL)\n"); } else { err = TSF->TWS_field_scalar; printf("% -11ld # 0x%lx\n", (long)err, (long)err); } } TwDeleteStat(TSL); } } while (0); if ((err = TwErrno)) { fprintf(stderr, "%s: libTw error: %s%s\n", argv0, TwStrError(err), TwStrErrorDetail(err, TwErrnoDetail)); return 1; } return 0; }
int EView::ExecCommand(int Command, ExState &State) { switch (Command) { case ExSwitchTo: return SwitchTo(State); case ExFilePrev: return FilePrev(); case ExFileNext: return FileNext(); case ExFileLast: return FileLast(); case ExFileOpen: return FileOpen(State); case ExFileOpenInMode: return FileOpenInMode(State); case ExFileSaveAll: return FileSaveAll(); case ExListRoutines: return ViewRoutines(State); case ExDirOpen: return DirOpen(State); case ExViewMessages: return ViewMessages(State); case ExCompile: return Compile(State); case ExRunCompiler: return RunCompiler(State); case ExCompilePrevError: return CompilePrevError(State); case ExCompileNextError: return CompileNextError(State); case ExCvs: return Cvs(State); case ExRunCvs: return RunCvs(State); case ExViewCvs: return ViewCvs(State); case ExClearCvsMessages: return ClearCvsMessages(State); case ExCvsDiff: return CvsDiff(State); case ExRunCvsDiff: return RunCvsDiff(State); case ExViewCvsDiff: return ViewCvsDiff(State); case ExCvsCommit: return CvsCommit(State); case ExRunCvsCommit: return RunCvsCommit(State); case ExViewCvsLog: return ViewCvsLog(State); case ExSvn: return Svn(State); case ExRunSvn: return RunSvn(State); case ExViewSvn: return ViewSvn(State); case ExClearSvnMessages: return ClearSvnMessages(State); case ExSvnDiff: return SvnDiff(State); case ExRunSvnDiff: return RunSvnDiff(State); case ExViewSvnDiff: return ViewSvnDiff(State); case ExSvnCommit: return SvnCommit(State); case ExRunSvnCommit: return RunSvnCommit(State); case ExViewSvnLog: return ViewSvnLog(State); case ExViewBuffers: return ViewBuffers(State); case ExShowKey: return ShowKey(State); case ExToggleSysClipboard: return ToggleSysClipboard(State); case ExSetPrintDevice: return SetPrintDevice(State); case ExShowVersion: return ShowVersion(); case ExViewModeMap: return ViewModeMap(State); case ExClearMessages: return ClearMessages(); case ExTagNext: return TagNext(this); case ExTagPrev: return TagPrev(this); case ExTagPop: return TagPop(this); case ExTagClear: TagClear(); return 1; case ExTagLoad: return TagLoad(State); case ExShowHelp: return SysShowHelp(State, 0); case ExConfigRecompile: return ConfigRecompile(State); case ExRemoveGlobalBookmark: return RemoveGlobalBookmark(State); case ExGotoGlobalBookmark: return GotoGlobalBookmark(State); case ExPopGlobalBookmark: return PopGlobalBookmark(); } return Model ? Model->ExecCommand(Command, State) : 0; }
int main(int argc, char **argv) { int rcRet = 0; /* * Parse arguments. */ int fArgsDone = 0; for (int i = 1; i < argc; i++) { const char *psz = argv[i]; if (!fArgsDone && psz[0] == '-' && psz[1]) { /* convert long option to short. */ if (*++psz == '-') { psz++; if (!*psz) /* -- */ { fArgsDone = 1; continue; } if (!strcmp(psz, "line-numbers")) psz = "l"; else if (!strcmp(psz, "no-line-numbers")) psz = "L"; else if (!strcmp(psz, "global-syms") || !strcmp(psz, "public-syms")) psz = "g"; else if (!strcmp(psz, "no-global-syms") || !strcmp(psz, "no-public-syms")) psz = "G"; else if (!strcmp(psz, "privat-syms") || !strcmp(psz, "local-syms")) psz = "p"; else if (!strcmp(psz, "no-privat-syms") || !strcmp(psz, "no-local-syms")) psz = "P"; else if (!strcmp(psz, "version")) psz = "v"; else if (!strcmp(psz, "help")) psz = "h"; else { fprintf(stderr, "%s: syntax error: unknown option '--%s'\n", argv[0], psz); return 1; } } /* eat short options. */ while (*psz) switch (*psz++) { case 'l': g_fLineNumbers = 1; break; case 'L': g_fLineNumbers = 0; break; case 'p': g_fPrivateSyms = 1; break; case 'P': g_fPrivateSyms = 0; break; case 'g': g_fGlobalSyms = 1; break; case 'G': g_fGlobalSyms = 0; break; case '?': case 'H': case 'h': return ShowSyntax(argv[0]); case 'v': return ShowVersion(); default: fprintf(stderr, "%s: syntax error: unknown option '-%c'.\n", argv[0], psz[-1]); return 1; } } else { /* Dump does it's own bitching if something goes wrong. */ int rc = DumpFile(psz); if (rc && !rcRet) rc = rcRet; } } return rcRet; }
__myevic__ void DrawScreen() { if ( Screen == 2 && FireDuration && FireDuration != CurrentFD ) { CurrentFD = FireDuration; ScreenDuration = 1; ShowFDTimer = 0; gFlags.refresh_display = 1; } if ( gFlags.refresh_display ) { gFlags.refresh_display = 0; ClearScreenBuffer(); switch ( Screen ) { case 0: // Black break; case 1: // Main view case 3: // Main view (?) case 4: // (unused?) ShowMainView(); break; case 2: // Firing if ( !dfStealthOn ) { ShowMainView(); } break; case 5: // Black w/ Battery ShowBatCharging(); break; case 20: // No Atomizer Found ShowNoAtoFound(); break; case 21: // Atomizer Short ShowAtoShort(); break; case 22: // Atomizer Low ShowAtoLow(); break; case 23: // 10s Protection Show10sProtec(); break; case 24: // Battery Low ShowBatLow(); break; case 25: // Battery Low Lock ShowBatLowLock(); break; case 28: // Key Lock ShowKeyLock(); break; case 29: // Device too hot ShowDevTooHot(); break; case 31: // Key UnLock ShowKeyUnLock(); break; case 37: // Board Temp ShowBoardTemp(); break; case 40: // Stealth ON/OFF ShowStealthMode(); break; case 41: // Ti ON/OFF ShowTiOnOff(); break; case 50: // FW Version ShowVersion(); break; case 51: // New Coil ShowNewCoil(); break; case 54: // Battery Voltage ShowBattVolts(); break; case 59: // TCR Set Menu ShowTCRSet(); break; case 82: // LOGO Menu ShowLOGOMenu(); break; case 83: // Game Menu ShowGameMenu(); break; case 100: ShowInfos(); break; case 101: ShowContrast(); break; case 102: ShowMenus(); break; case 103: ShowRTCSpeed(); break; case 104: ShowRTCAdjust(); break; default: break; } if ( myDbgFlag & 1 ) { int nd = (Screen<100?Screen<10?1:2:3); DrawValue( 64-6*nd, 120, Screen, 0, 0x01, nd ); DrawValue( 0, 120, ScreenDuration, 0, 0x01, 0 ); } DisplayRefresh(); } if (( gFlags.firing ) && ISMODETC(dfMode)) { ShowFDTimer += 5; } else { ShowFDTimer += 1; } if ( ShowFDTimer < 10 ) return; ShowFDTimer = 0; if ( ScreenDuration && --ScreenDuration ) return; switch ( Screen ) { case 0: // Black if ( dfStatus.off ) { SleepTimer = 0; } break; case 2: // Firing if ( dfStealthOn ) { gFlags.refresh_display = 1; if ( !(gFlags.battery_charging) ) { Screen = 0; SleepTimer = 18000; } else { Screen = 5; } } else { MainView(); } break; case 5: // Black w/ Battery break; case 20: // No Atomizer Found case 21: // Atomizer Short MainView(); break; case 22: // Atomizer Low case 23: // 10s Protection case 24: // Battery Low case 25: // Battery Low Lock break; case 29: // Device too hot MainView(); break; case 101: // Contrast Menu case 102: // Menus case 103: // RTC Speed gFlags.edit_capture_evt = 0; // NOBREAK case 59: // TCR Set Menu case 82: // LOGO Menu case 83: // Game Menu UpdateDataFlash(); // NOBREAK case 1: // Main view case 28: // Key Lock case 31: // Key UnLock case 37: // Board Temp case 40: // Stealth ON/OFF case 41: // Ti ON/OFF case 54: // Battery Voltage case 100: // Ferox's page case 104: // Adjust Clock if ( !dfScreenSave ) { if ( Screen != 1 ) MainView(); break; } if ( !(gFlags.battery_charging) ) { gFlags.refresh_display = 1; Screen = 0; SleepTimer = 18000; } else { Screen = 5; } break; case 50: // FW Version break; case 51: // New Coil MainView(); break; default: break; } return; }
// to intialize the class DynMat::DynMat(int narg, char **arg) { attyp = NULL; memory = NULL; M_inv_sqrt = NULL; interpolate = NULL; DM_q = DM_all = NULL; binfile = funit = dmfile = NULL; attyp = NULL; basis = NULL; flag_reset_gamma = flag_skip = 0; // analyze the command line options int iarg = 1; while (narg > iarg){ if (strcmp(arg[iarg], "-s") == 0){ flag_reset_gamma = flag_skip = 1; } else if (strcmp(arg[iarg], "-r") == 0){ flag_reset_gamma = 1; } else if (strcmp(arg[iarg], "-h") == 0){ help(); } else { if (binfile) delete []binfile; int n = strlen(arg[iarg]) + 1; binfile = new char[n]; strcpy(binfile, arg[iarg]); } iarg++; } ShowVersion(); // get the binary file name from user input if not found in command line char str[MAXLINE]; if (binfile == NULL) { char *ptr = NULL; printf("\n"); do { printf("Please input the binary file name from fix_phonon: "); fgets(str,MAXLINE,stdin); ptr = strtok(str, " \n\t\r\f"); } while (ptr == NULL); int n = strlen(ptr) + 1; binfile = new char[n]; strcpy(binfile, ptr); } // open the binary file FILE *fp = fopen(binfile, "rb"); if (fp == NULL) { printf("\nFile %s not found! Programe terminated.\n", binfile); help(); } // read header info from the binary file if ( fread(&sysdim, sizeof(int), 1, fp) != 1) {printf("\nError while reading sysdim from file: %s\n", binfile); fclose(fp); exit(2);} if ( fread(&nx, sizeof(int), 1, fp) != 1) {printf("\nError while reading nx from file: %s\n", binfile); fclose(fp); exit(2);} if ( fread(&ny, sizeof(int), 1, fp) != 1) {printf("\nError while reading ny from file: %s\n", binfile); fclose(fp); exit(2);} if ( fread(&nz, sizeof(int), 1, fp) != 1) {printf("\nError while reading nz from file: %s\n", binfile); fclose(fp); exit(2);} if ( fread(&nucell, sizeof(int), 1, fp) != 1) {printf("\nError while reading nucell from file: %s\n", binfile); fclose(fp); exit(2);} if ( fread(&boltz, sizeof(double), 1, fp) != 1) {printf("\nError while reading boltz from file: %s\n", binfile); fclose(fp); exit(2);} fftdim = sysdim*nucell; fftdim2 = fftdim*fftdim; npt = nx*ny*nz; // display info related to the read file printf("\n"); for (int i = 0; i < 80; ++i) printf("="); printf("\n"); printf("Dynamical matrix is read from file: %s\n", binfile); printf("The system size in three dimension: %d x %d x %d\n", nx, ny, nz); printf("Number of atoms per unit cell : %d\n", nucell); printf("System dimension : %d\n", sysdim); printf("Boltzmann constant in used units : %g\n", boltz); for (int i = 0; i < 80; ++i) printf("="); printf("\n"); if (sysdim < 1||sysdim > 3||nx < 1||ny < 1||nz < 1||nucell < 1){ printf("Wrong values read from header of file: %s, please check the binary file!\n", binfile); fclose(fp); exit(3); } funit = new char[4]; strcpy(funit, "THz"); if (boltz == 1.){eml2f = 1.; delete funit; funit = new char[27]; strcpy(funit,"sqrt(epsilon/(m.sigma^2))");} else if (boltz == 0.0019872067) eml2f = 3.256576161; else if (boltz == 8.617343e-5) eml2f = 15.63312493; else if (boltz == 1.3806504e-23) eml2f = 1.; else if (boltz == 1.3806504e-16) eml2f = 1.591549431e-14; else { printf("WARNING: Because of float precision, I cannot get the factor to convert sqrt(E/ML^2)\n"); printf("into THz, instead, I set it to be 1; you should check the unit used by LAMMPS.\n"); eml2f = 1.; } // now to allocate memory for DM memory = new Memory(); memory->create(DM_all, npt, fftdim2, "DynMat:DM_all"); memory->create(DM_q, fftdim,fftdim,"DynMat:DM_q"); // read all dynamical matrix info into DM_all if ( fread(DM_all[0], sizeof(doublecomplex), npt*fftdim2, fp) != size_t(npt*fftdim2)){ printf("\nError while reading the DM from file: %s\n", binfile); fclose(fp); exit(1); } // now try to read unit cell info from the binary file memory->create(basis, nucell, sysdim, "DynMat:basis"); memory->create(attyp, nucell, "DynMat:attyp"); memory->create(M_inv_sqrt, nucell, "DynMat:M_inv_sqrt"); if ( fread(&Tmeasure, sizeof(double), 1, fp) != 1 ){printf("\nError while reading temperature from file: %s\n", binfile); fclose(fp); exit(3);} if ( fread(&basevec[0], sizeof(double), 9, fp) != 9 ){printf("\nError while reading lattice info from file: %s\n", binfile); fclose(fp); exit(3);} if ( fread(basis[0], sizeof(double), fftdim, fp) != fftdim){printf("\nError while reading basis info from file: %s\n", binfile); fclose(fp); exit(3);} if ( fread(&attyp[0], sizeof(int), nucell, fp) != nucell){printf("\nError while reading atom types from file: %s\n", binfile); fclose(fp); exit(3);} if ( fread(&M_inv_sqrt[0], sizeof(double), nucell, fp) != nucell){printf("\nError while reading atomic masses from file: %s\n", binfile); fclose(fp); exit(3);} fclose(fp); car2dir(); real2rec(); // initialize interpolation interpolate = new Interpolate(nx,ny,nz,fftdim2,DM_all); if (flag_reset_gamma) interpolate->reset_gamma(); // Enforcing Austic Sum Rule EnforceASR(); // get the dynamical matrix from force constant matrix: D = 1/M x Phi for (int idq = 0; idq < npt; ++idq){ int ndim =0; for (int idim = 0; idim < fftdim; ++idim) for (int jdim = 0; jdim < fftdim; ++jdim){ double inv_mass = M_inv_sqrt[idim/sysdim]*M_inv_sqrt[jdim/sysdim]; DM_all[idq][ndim].r *= inv_mass; DM_all[idq][ndim].i *= inv_mass; ndim++; } } // ask for the interpolation method interpolate->set_method(); return; }
/** Main entrypoint for DumpDynPcd shell application. @param[in] ImageHandle The image handle. @param[in] SystemTable The system table. @retval EFI_SUCCESS Command completed successfully. @retval EFI_INVALID_PARAMETER Command usage error. @retval EFI_OUT_OF_RESOURCES Not enough resources were available to run the command. @retval EFI_ABORTED Aborted by user. @retval EFI_NOT_FOUND The specified PCD is not found. @retval Others Error status returned from gBS->LocateProtocol. **/ EFI_STATUS EFIAPI DumpDynPcdMain ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; CHAR16 *InputPcdName; InputPcdName = NULL; Status = gBS->LocateProtocol(&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID **) &mUnicodeCollation); if (EFI_ERROR (Status)) { mUnicodeCollation = NULL; } Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); if (EFI_ERROR (Status)) { Print (L"DumpDynPcd: %EError. %NPI PCD protocol is not present.\n"); return Status; } Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **) &mPiPcdInfo); if (EFI_ERROR (Status)) { Print (L"DumpDynPcd: %EError. %NPI PCD info protocol is not present.\n"); return Status; } Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **) &mPcd); if (EFI_ERROR (Status)) { Print (L"DumpDynPcd: %EError. %NPCD protocol is not present.\n"); return Status; } Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **) &mPcdInfo); if (EFI_ERROR (Status)) { Print (L"DumpDynPcd: %EError. %NPCD info protocol is not present.\n"); return Status; } // // get the command line arguments // Status = GetArg(); if (EFI_ERROR(Status)){ Print (L"DumpDynPcd: %EError. %NThe input parameters are not recognized.\n"); Status = EFI_INVALID_PARAMETER; return Status; } if (Argc > 2){ Print (L"DumpDynPcd: %EError. %NToo many arguments specified.\n"); Status = EFI_INVALID_PARAMETER; return Status; } if (Argc == 1){ Status = ProcessPcd (InputPcdName); goto Done; } if ((StrCmp(Argv[1], L"-?") == 0)||(StrCmp(Argv[1], L"-h") == 0)||(StrCmp(Argv[1], L"-H") == 0)){ ShowHelp (); goto Done; } else { if ((StrCmp(Argv[1], L"-v") == 0)||(StrCmp(Argv[1], L"-V") == 0)){ ShowVersion (); goto Done; } else { if (StrStr(Argv[1], L"-") != NULL){ Print (L"DumpDynPcd: %EError. %NThe argument '%B%s%N' is invalid.\n", Argv[1]); goto Done; } } } InputPcdName = Argv[1]; Status = ProcessPcd (InputPcdName); Done: if (mTempPcdNameBuffer != NULL) { FreePool (mTempPcdNameBuffer); } return Status; }
void InputCmd () /************************************************************************* * * This is the main user command interface driver. * *************************************************************************/ { const char *color[2] = { "White", "Black" }; int suffix; int i; leaf *ptr; int ncmds; char *x,*trim; CLEAR (flags, THINK); memset(userinput,0,sizeof(userinput)); memset(cmd,0,sizeof(cmd)); #ifndef HAVE_LIBREADLINE /* Why is this necessary anyway? */ memset(inputstr,0,sizeof(inputstr)); #endif #ifdef HAVE_LIBREADLINE if (isatty(STDIN_FILENO)) { sprintf(s,"%s (%d) %c ", color[board.side], (GameCnt+1)/2 + 1, prompt); inputstr = readline(s); if (inputstr == NULL) return; if (*inputstr) { add_history(inputstr); } if (strlen(inputstr) > INPUT_SIZE-1) { printf("Warning: Input line truncated to %d characters.\n", INPUT_SIZE -1 ); inputstr[INPUT_SIZE-1] = '\000'; } } else { inputstr = malloc(INPUT_SIZE); if (inputstr == NULL) { perror("InputCmd"); exit(EXIT_FAILURE); } fgets(inputstr, INPUT_SIZE, stdin); if (inputstr[0]) { inputstr[strlen(inputstr)-1] = 0; } } #else /* !HAVE_LIBREADLINE */ if (!(flags & XBOARD)) { printf ("%s (%d) %c ", color[board.side], (GameCnt+1)/2 + 1, prompt); fflush(stdout); } fgets (inputstr, INPUT_SIZE, stdin) ; #endif /* HAVE_LIBREADLINE */ cmd[0] = '\n'; strcpy(userinput,inputstr); sscanf (inputstr, "%s %[^\n]", cmd, inputstr); if (cmd[0] == '\n') goto done; cmd[0] = subcmd[0] = setting[0] = subsetting[0] = '\0'; ncmds = sscanf (userinput,"%s %s %s %[^\n]", cmd,subcmd,setting,subsetting); /* Put options after command back in inputstr - messy */ sprintf(inputstr,"%s %s %s",subcmd,setting,subsetting); trim = inputstr + strlen(inputstr) - 1; while ( trim>=inputstr && *trim==' ') *trim--='\0'; if (strcmp (cmd, "quit") == 0 || strcmp (cmd, "exit") == 0) SET (flags, QUIT); else if (strcmp (cmd, "help") == 0) ShowHelp (inputstr); else if (strcmp (cmd, "show") == 0) ShowCmd (inputstr); else if (strncmp (cmd, "book", 4) == 0) { if (strncmp(inputstr, "add",3) == 0) { sscanf (inputstr, "add %s", file); if (access(file,F_OK) < 0) { printf("The syntax to add a new book is:\n\n\tbook add file.pgn\n"); } else { BookPGNReadFromFile (file); } } else if (strncmp (inputstr, "on", 2) == 0 || strncmp (inputstr, "prefer", 6) == 0) { bookmode = BOOKPREFER; printf("book now on.\n"); } else if (strncmp (inputstr, "off", 3) == 0) { bookmode = BOOKOFF; printf("book now off.\n"); } else if (strncmp (inputstr, "best", 4) == 0) { bookmode = BOOKBEST; printf("book now best.\n"); } else if (strncmp (inputstr, "worst", 5) == 0) { bookmode = BOOKWORST; printf("book now worst.\n"); } else if (strncmp (inputstr, "random", 6) == 0) { bookmode = BOOKRAND; printf("book now random.\n"); } } else if (strcmp (cmd, "test") == 0) TestCmd (inputstr); else if (strcmp (cmd, "version") == 0) ShowVersion (); else if (strcmp (cmd, "pgnsave") == 0) { if ( strlen(inputstr) > 0 && strlen(inputstr) < INPUT_SIZE ) PGNSaveToFile (inputstr,""); else printf("Invalid filename.\n"); } else if (strcmp (cmd, "pgnload") == 0) PGNReadFromFile (inputstr); else if (strcmp (cmd, "manual") == 0) SET (flags, MANUAL); else if (strcmp (cmd, "debug") == 0) { SET (flags, DEBUGG); Debugmvl = 0; if (strcmp (inputstr, "debug") == 0) { while (strcmp (inputstr, s)) { sscanf (inputstr, "%s %[^\n]", s, inputstr); ptr = ValidateMove (s); Debugmv[Debugmvl++] = ptr->move; MakeMove (board.side, &ptr->move); } i = Debugmvl; while (i) { UnmakeMove (board.side, &Debugmv[--i]); } } } else if (strcmp (cmd, "force") == 0) SET (flags, MANUAL); else if (strcmp (cmd, "white") == 0) ; else if (strcmp (cmd, "black") == 0) ; else if (strcmp (cmd, "hard") == 0) ; else if (strcmp (cmd, "easy") == 0) ; else if (strcmp (cmd, "list") == 0) { if (inputstr[0] == '?') { printf("name - list known players alphabetically\n"); printf("score - list by GNU best result first \n"); printf("reverse - list by GNU worst result first\n"); } else { sscanf (inputstr, "%s %[^\n]", cmd, inputstr); if (inputstr == '\000') DBListPlayer("rscore"); else DBListPlayer(inputstr); } } else if (strcmp (cmd, "post") == 0) SET (flags, POST); else if (strcmp (cmd, "nopost") == 0) CLEAR (flags, POST); else if (strcmp (cmd, "name") == 0) { strcpy(name, inputstr); x = name; while (*x != '\000') { if (*x == ' ') { *x = '\000'; break; } x++; } suffix = 0; for (;;) { sprintf(logfile,"log.%03d",suffix); sprintf(gamefile,"game.%03d",suffix); if (access(logfile,F_OK) < 0) { ofp = fopen(logfile,"w"); break; } else suffix++; } } else if (strcmp (cmd, "result") == 0) { if (ofp != stdout) { fprintf(ofp, "result: %s\n",inputstr); fclose(ofp); ofp = stdout; printf("Save to %s\n",gamefile); PGNSaveToFile (gamefile, inputstr); DBUpdatePlayer (name, inputstr); } } else if (strcmp (cmd, "rating") == 0) { sscanf(inputstr,"%d %d",&myrating,&opprating); fprintf(ofp,"my rating = %d, opponent rating = %d\n",myrating,opprating); /* Change randomness of book based on opponent rating. */ /* Basically we play narrower book the higher the opponent */ if (opprating >= 1700) bookfirstlast = 2; else if (opprating >= 1700) bookfirstlast = 2; else bookfirstlast = 2; } else if (strcmp (cmd, "activate") == 0) { CLEAR (flags, TIMEOUT); CLEAR (flags, ENDED); } else if (strcmp (cmd, "new") == 0) { InitVars (); NewPosition (); CLEAR (flags, MANUAL); CLEAR (flags, THINK); myrating = opprating = 0; } else if (strcmp (cmd, "time") == 0) { sscanf (inputstr, "%s %[^\n]", s, inputstr); TimeLimit[1^board.side] = atoi(s) / 100.0f ; } else if (strcmp (cmd, "otim") == 0) ; else if (strcmp (cmd, "random") == 0) ; else if (strcmp (cmd, "hash") == 0) { sscanf (inputstr, "%s %[^\n]", cmd, inputstr); if (strcmp (cmd, "off") == 0) CLEAR (flags, USEHASH); else if (strcmp (cmd, "on") == 0) SET (flags, USEHASH); printf ("Hashing %s\n", flags & USEHASH ? "on" : "off"); } else if (strcmp (cmd, "hashsize") == 0) { if (inputstr[0] == 0) { printf("Current HashSize is %u slots\n", HashSize); } else { i = atoi (inputstr); TTHashMask = 0; while ((i >>= 1) > 0) { TTHashMask <<= 1; TTHashMask |= 1; } HashSize = TTHashMask + 1; printf ("Adjusting HashSize to %u slots\n", HashSize); InitHashTable (); } } else if (strcmp (cmd, "null") == 0)