CComponentIDToolApp::~CComponentIDToolApp() { if (IsOptionSet(eInputFile) && m_Opts.input_stream != NULL) fclose(m_Opts.input_stream); if (IsOptionSet(eOutputFile) && m_Opts.output_stream != NULL) fclose(m_Opts.output_stream); }
int _tmain(int argc, _TCHAR * argv[]) { int a; _tprintf (_T("ReactOS Project Statistics\n")); _tprintf (_T("==========================\n\n")); if (argc < 2 || argc > 2 + MAX_OPTIONS) { _tprintf(_T("Usage: stats [-e] [-s] directory\n")); _tprintf(_T(" -e: don't count empty lines\n")); _tprintf(_T(" -s: be silent, don't print directories while processing\n")); return 1; } Initialize(); AddExtension (_T("c\0\0"), _T("Ansi C Source files")); AddExtension (_T("cpp\0cxx\0\0"), _T("C++ Source files")); AddExtension (_T("h\0\0"), _T("Header files")); for(a = 1; a < argc - 1; a++) { Options[a - 1] = argv[a]; } SkipEmptyLines = IsOptionSet(_T("-e")); BeSilent = IsOptionSet(_T("-s")); Execute (argv[argc - 1]); Cleanup(); return 0; }
int CSocketItems::ApplySocketOptions(LPOBJ lpObj) { int OptionCount = 0; BYTE btSocketOption = 0; BYTE btOption = 0; BYTE btLevel = 0; _SOCKET_SPHERE_OPTION tmpSphere; for(int i = 0; i < INVETORY_WEAR_SIZE; i++) { if( IsSocketItem(&lpObj->pInventory[i]) == FALSE ) continue; for(int n = 0; n < MAX_SOCKET_COUNT; n++) { btSocketOption = lpObj->pInventory[i].m_SocketOption[n]; if( btSocketOption == 0xFF || btSocketOption == 0xFE ) continue; btOption = btSocketOption%50; btLevel = (btSocketOption-btOption)/50+1; if( IsOptionSet(&tmpSphere,btOption,btLevel) == FALSE ) continue; SetSocketOption(lpObj,TRUE,btOption,tmpSphere.btIncType,tmpSphere.wSphereValue); OptionCount++; } } return OptionCount; }
int CGridCommandLineInterfaceApp::PrintNetScheduleStats() { if (IsOptionSet(eJobGroupInfo)) PrintNetScheduleStats_Generic(eNetScheduleStatJobGroups); else if (IsOptionSet(eClientInfo)) PrintNetScheduleStats_Generic(eNetScheduleStatClients); else if (IsOptionSet(eNotificationInfo)) PrintNetScheduleStats_Generic(eNetScheduleStatNotifications); else if (IsOptionSet(eAffinityInfo)) PrintNetScheduleStats_Generic(eNetScheduleStatAffinities); else if (IsOptionSet(eJobsByAffinity)) { CNetScheduleAdmin::TAffinityMap affinity_map; m_NetScheduleAdmin.AffinitySnapshot(affinity_map); const char* format; const char* format_cont; string human_readable_format_buf; if (m_Opts.output_format == eHumanReadable) { size_t max_affinity_token_len = sizeof("Affinity"); ITERATE(CNetScheduleAdmin::TAffinityMap, it, affinity_map) { if (max_affinity_token_len < it->first.length()) max_affinity_token_len = it->first.length(); } string sep(max_affinity_token_len + 47, '-'); printf("%-*s Pending Running Dedicated Tentative\n" "%-*s job count job count workers workers\n" "%s\n", int(max_affinity_token_len), "Affinity", int(max_affinity_token_len), "token", sep.c_str()); human_readable_format_buf = "%-" + NStr::NumericToString(max_affinity_token_len); human_readable_format_buf.append("s%11u %11u %11u %11u\n"); format_cont = format = human_readable_format_buf.c_str(); } else if (m_Opts.output_format == eRaw)
void CSocketItems::SetSocketOption(CItem* lpItem) { if( lpItem == NULL ) return; if( lpItem->IsItem() == FALSE || IsSocketItem(lpItem) == FALSE ) return; BYTE btOption = 0; BYTE btLevel = 0; BYTE btSocketOpt = 0; _SOCKET_SPHERE_OPTION tmpSphere; int _IncValue = 0; for(int i = 0; i < MAX_SOCKET_COUNT; i++) { if( lpItem->m_SocketOption[i] == 0xFF || lpItem->m_SocketOption[i] == 0xFE ) continue; btSocketOpt = lpItem->m_SocketOption[i]; btOption = btSocketOpt % 50; btLevel = ((btSocketOpt - btOption)/50)+1; if( IsOptionSet(&tmpSphere,btOption,btLevel) == FALSE ) continue; if( btOption == 38 ) { _IncValue = GetResultValue(lpItem->m_HJOpStrength,tmpSphere.wSphereValue,tmpSphere.btIncType); lpItem->m_HJOpStrength += _IncValue; } else if(btOption == 39 ) { _IncValue = GetResultValue(lpItem->m_HJOpDexterity,tmpSphere.wSphereValue,tmpSphere.btIncType); lpItem->m_HJOpDexterity += _IncValue; } else if(btOption == 20 ) { lpItem->m_BonusDurability += tmpSphere.wSphereValue; } } }
void SetUp_NetCacheCmd() { SetUp_NetCacheCmd(IsOptionSet(eCache)); }
int CComponentIDToolApp::Run() { const SCommandDefinition* cmd_def; const int* cmd_opt; { CCommandLineParser clparser(GRID_APP_NAME, GRID_APP_VERSION_INFO, "Generate and decode identifiers in CompoundID format."); const SOptionDefinition* opt_def = s_OptionDefinitions; int opt_id = 0; do { #ifdef _DEBUG _ASSERT(opt_def->opt_id == opt_id && "EOption order must match positions in s_OptionDefinitions."); #endif clparser.AddOption(opt_def->type, opt_id, opt_def->name_variants, opt_def->description ? opt_def->description : kEmptyStr); ++opt_def; } while (++opt_id < eNumberOfOptions); cmd_def = s_CommandDefinitions; for (int i = 0; i < TOTAL_NUMBER_OF_COMMANDS; ++i, ++cmd_def) { clparser.AddCommand(i, cmd_def->name_variants, cmd_def->synopsis, cmd_def->usage); for (cmd_opt = cmd_def->options; *cmd_opt >= 0; ++cmd_opt) clparser.AddAssociation(i, *cmd_opt); } try { int cmd_id = clparser.Parse(m_ArgC, m_ArgV); if (cmd_id < 0) return 0; cmd_def = s_CommandDefinitions + cmd_id; } catch (exception& e) { NcbiCerr << e.what(); return 1; } for (cmd_opt = cmd_def->options; *cmd_opt >= 0; ++cmd_opt) MarkOptionAsAccepted(*cmd_opt); const char* opt_value; while (clparser.NextOption(&opt_id, &opt_value)) { MarkOptionAsExplicitlySet(opt_id); switch (EOption(opt_id)) { case eCID: m_Opts.cid = opt_value; break; case eInputFile: if ((m_Opts.input_stream = fopen(opt_value, "rb")) == NULL) { fprintf(stderr, "%s: %s\n", opt_value, strerror(errno)); return 2; } break; case eOutputFile: if ((m_Opts.output_stream = fopen(opt_value, "wb")) == NULL) { fprintf(stderr, "%s: %s\n", opt_value, strerror(errno)); return 2; } break; default: // Just to silence the compiler. break; } } opt_id = eNumberOfOptions - 1; do if (IsOptionSet(opt_id)) for (const int* required_opt = s_OptionDefinitions[opt_id].required_options; *required_opt != -1; ++required_opt) if (!IsOptionSet(*required_opt)) { fprintf(stderr, GRID_APP_NAME ": option '--%s' requires option '--%s'.\n", s_OptionDefinitions[opt_id].name_variants, s_OptionDefinitions[ *required_opt].name_variants); return 2; } while (--opt_id >= 0); if (IsOptionAcceptedButNotSet(eInputFile)) { m_Opts.input_stream = stdin; } if (IsOptionAcceptedButNotSet(eOutputFile)) { m_Opts.output_stream = stdout; } } try { return (this->*cmd_def->cmd_proc)(); } catch (CConfigException& e) { fprintf(stderr, "%s\n", e.GetMsg().c_str()); return 2; } catch (CArgException& e) { fprintf(stderr, GRID_APP_NAME " %s: %s\n", cmd_def->name_variants, e.GetMsg().c_str()); return 2; } catch (CException& e) { fprintf(stderr, "%s\n", e.what()); return 3; } catch (string& s) { fprintf(stderr, "%s\n", s.c_str()); return 4; } }