/* ============ idAASSettings::FromParser ============ */ bool idAASSettings::FromParser( idLexer& src ) { idToken token; if( !src.ExpectTokenString( "{" ) ) { return false; } // parse the file while( 1 ) { if( !src.ReadToken( &token ) ) { break; } if( token == "}" ) { break; } if( token == "bboxes" ) { if( !ParseBBoxes( src ) ) { return false; } } else if( token == "usePatches" ) { if( !ParseBool( src, usePatches ) ) { return false; } } else if( token == "writeBrushMap" ) { if( !ParseBool( src, writeBrushMap ) ) { return false; } } else if( token == "playerFlood" ) { if( !ParseBool( src, playerFlood ) ) { return false; } } else if( token == "allowSwimReachabilities" ) { if( !ParseBool( src, allowSwimReachabilities ) ) { return false; } } else if( token == "allowFlyReachabilities" ) { if( !ParseBool( src, allowFlyReachabilities ) ) { return false; } } else if( token == "fileExtension" ) { src.ExpectTokenString( "=" ); src.ExpectTokenType( TT_STRING, 0, &token ); fileExtension = token; } else if( token == "gravity" ) { ParseVector( src, gravity ); gravityDir = gravity; gravityValue = gravityDir.Normalize(); invGravityDir = -gravityDir; } else if( token == "maxStepHeight" ) { if( !ParseFloat( src, maxStepHeight ) ) { return false; } } else if( token == "maxBarrierHeight" ) { if( !ParseFloat( src, maxBarrierHeight ) ) { return false; } } else if( token == "maxWaterJumpHeight" ) { if( !ParseFloat( src, maxWaterJumpHeight ) ) { return false; } } else if( token == "maxFallHeight" ) { if( !ParseFloat( src, maxFallHeight ) ) { return false; } } else if( token == "minFloorCos" ) { if( !ParseFloat( src, minFloorCos ) ) { return false; } } else if( token == "tt_barrierJump" ) { if( !ParseInt( src, tt_barrierJump ) ) { return false; } } else if( token == "tt_startCrouching" ) { if( !ParseInt( src, tt_startCrouching ) ) { return false; } } else if( token == "tt_waterJump" ) { if( !ParseInt( src, tt_waterJump ) ) { return false; } } else if( token == "tt_startWalkOffLedge" ) { if( !ParseInt( src, tt_startWalkOffLedge ) ) { return false; } } else { src.Error( "invalid token '%s'", token.c_str() ); } } if( numBoundingBoxes <= 0 ) { src.Error( "no valid bounding box" ); } return true; }
void HandleStandardDaemonArgs(const Message & args) { TCHECKPOINT; #ifndef WIN32 if (args.HasName("disablestderr")) { LogTime(MUSCLE_LOG_INFO, "Suppressing all further output to stderr!\n"); close(STDERR_FILENO); } if (args.HasName("disablestdout")) { LogTime(MUSCLE_LOG_INFO, "Suppressing all further output to stdout!\n"); close(STDOUT_FILENO); } #endif // Do this first, so that the stuff below will affect the right process. const char * n; if (args.FindString("daemon", &n) == B_NO_ERROR) { LogTime(MUSCLE_LOG_INFO, "Spawning off a daemon-child...\n"); if (BecomeDaemonProcess(NULL, n[0] ? n : "/dev/null") != B_NO_ERROR) { LogTime(MUSCLE_LOG_CRITICALERROR, "Could not spawn daemon-child process!\n"); ExitWithoutCleanup(10); } } #ifdef WIN32 const String * consoleStr = args.GetStringPointer("console"); if (consoleStr) Win32AllocateStdioConsole(consoleStr->HasChars()?consoleStr->Cstr():NULL); #endif #ifdef MUSCLE_ENABLE_DEADLOCK_FINDER { const char * df = args.GetCstr("deadlockfinder"); if (df) _enableDeadlockFinderPrints = ParseBool(df, true); } #endif const char * value; if (args.FindString("displaylevel", &value) == B_NO_ERROR) { int ll = ParseLogLevelKeyword(value); if (ll >= 0) SetConsoleLogLevel(ll); else LogTime(MUSCLE_LOG_INFO, "Error, unknown display log level type [%s]\n", value); } if ((args.FindString("oldlogfilespattern", &value) == B_NO_ERROR)&&(*value != '\0')) SetOldLogFilesPattern(value); if ((args.FindString("maxlogfiles", &value) == B_NO_ERROR)||(args.FindString("maxnumlogfiles", &value) == B_NO_ERROR)) { uint32 maxNumFiles = atol(value); if (maxNumFiles > 0) SetMaxNumLogFiles(maxNumFiles); else LogTime(MUSCLE_LOG_ERROR, "Please specify a maxnumlogfiles value that is greater than zero.\n"); } if (args.FindString("logfile", &value) == B_NO_ERROR) { SetFileLogName(value); if (GetFileLogLevel() == MUSCLE_LOG_NONE) SetFileLogLevel(MUSCLE_LOG_INFO); // no sense specifying a name and then not logging anything! } if (args.FindString("filelevel", &value) == B_NO_ERROR) { int ll = ParseLogLevelKeyword(value); if (ll >= 0) SetFileLogLevel(ll); else LogTime(MUSCLE_LOG_INFO, "Error, unknown file log level type [%s]\n", value); } if (args.FindString("maxlogfilesize", &value) == B_NO_ERROR) { uint32 maxSizeKB = atol(value); if (maxSizeKB > 0) SetFileLogMaximumSize(maxSizeKB*1024); else LogTime(MUSCLE_LOG_ERROR, "Please specify a maxlogfilesize in kilobytes, that is greater than zero.\n"); } if ((args.HasName("compresslogfile"))||(args.HasName("compresslogfiles"))) SetFileLogCompressionEnabled(true); if (args.FindString("localhost", &value) == B_NO_ERROR) { ip_address ip = Inet_AtoN(value); if (ip != invalidIP) { char ipbuf[64]; Inet_NtoA(ip, ipbuf); LogTime(MUSCLE_LOG_INFO, "IP address [%s] will be used as the localhost address.\n", ipbuf); SetLocalHostIPOverride(ip); } else LogTime(MUSCLE_LOG_ERROR, "Error parsing localhost IP address [%s]!\n", value); } if (args.FindString("dnscache", &value) == B_NO_ERROR) { uint64 micros = ParseHumanReadableTimeIntervalString(value); if (micros > 0) { uint32 maxCacheSize = 1024; if (args.FindString("dnscachesize", &value) == B_NO_ERROR) maxCacheSize = atol(value); LogTime(MUSCLE_LOG_INFO, "Setting DNS cache parameters to " UINT32_FORMAT_SPEC " entries, expiration period is %s\n", maxCacheSize, GetHumanReadableTimeIntervalString(micros)()); SetHostNameCacheSettings(maxCacheSize, micros); } else LogTime(MUSCLE_LOG_ERROR, "Unable to parse time interval string [%s] for dnscache argument!\n", value); } if ((args.HasName("debugcrashes"))||(args.HasName("debugcrash"))) { #if defined(__linux__) || defined(__APPLE__) LogTime(MUSCLE_LOG_INFO, "Enabling stack-trace printing when a crash occurs.\n"); signal(SIGSEGV, CrashSignalHandler); signal(SIGBUS, CrashSignalHandler); signal(SIGILL, CrashSignalHandler); signal(SIGABRT, CrashSignalHandler); signal(SIGFPE, CrashSignalHandler); #elif MUSCLE_USE_MSVC_STACKWALKER # ifndef MUSCLE_INLINE_LOGGING LogTime(MUSCLE_LOG_INFO, "Enabling stack-trace printing when a crash occurs.\n"); SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) Win32FaultHandler); # endif #else LogTime(MUSCLE_LOG_ERROR, "Can't enable stack-trace printing when a crash occurs, that feature isn't supported on this platform!\n"); #endif } #if defined(__linux__) || defined(__APPLE__) { const char * niceStr = NULL; (void) args.FindString("nice", &niceStr); const char * meanStr = NULL; (void) args.FindString("mean", &meanStr); int32 niceLevel = niceStr ? ((strlen(niceStr) > 0) ? atoi(niceStr) : 5) : 0; int32 meanLevel = meanStr ? ((strlen(meanStr) > 0) ? atoi(meanStr) : 5) : 0; int32 effectiveLevel = niceLevel-meanLevel; if (effectiveLevel) { errno = 0; // the only reliable way to check for an error here :^P int ret = nice(effectiveLevel); // I'm only looking at the return value to shut gcc 4.4.3 up if (errno != 0) LogTime(MUSCLE_LOG_WARNING, "Could not change process execution priority to " INT32_FORMAT_SPEC " (ret=%i).\n", effectiveLevel, ret); else LogTime(MUSCLE_LOG_INFO, "Process is now %s (niceLevel=%i)\n", (effectiveLevel<0)?"mean":"nice", effectiveLevel); } } #endif #ifdef __linux__ const char * priStr; if (args.FindString("realtime", &priStr) == B_NO_ERROR) SetRealTimePriority(priStr, false); else if (args.FindString("realtime_rr", &priStr) == B_NO_ERROR) SetRealTimePriority(priStr, false); else if (args.FindString("realtime_fifo", &priStr) == B_NO_ERROR) SetRealTimePriority(priStr, true); #endif #ifdef MUSCLE_CATCH_SIGNALS_BY_DEFAULT # ifdef MUSCLE_AVOID_SIGNAL_HANDLING # error "MUSCLE_CATCH_SIGNALS_BY_DEFAULT and MUSCLE_AVOID_SIGNAL_HANDLING are mutually exclusive compiler flags... you can not specify both!" # endif if (args.HasName("dontcatchsignals")) { _mainReflectServerCatchSignals = false; LogTime(MUSCLE_LOG_DEBUG, "Controlled shutdowns (via Control-C) disabled in the main thread.\n"); } #else if (args.HasName("catchsignals")) { # ifdef MUSCLE_AVOID_SIGNAL_HANDLING LogTime(MUSCLE_LOG_ERROR, "Can not enable controlled shutdowns, MUSCLE_AVOID_SIGNAL_HANDLING was specified during compilation!\n"); # else _mainReflectServerCatchSignals = true; LogTime(MUSCLE_LOG_DEBUG, "Controlled shutdowns (via Control-C) enabled in the main thread.\n"); # endif } #endif }
int main (int argc, char *argv[]) { bool_tree_node *tree = NULL; TermList *term_list = NULL; int opt_type = 0; file_in = stdin; file_out = stdout; while (1) { int res = 0; int len = 0; /* get a line */ if (!prompt ("Please enter boolean expression...")) break; len = strlen (line) - 1; /* -1 => ignore the \n */ tree = ParseBool (line, len, &term_list, STEM_METHOD, &res); { int done = 0; while (!done) { if (!prompt ("Which type of optimisation 1 or 2 ?")) break; opt_type = atoi (line); done = (opt_type == 1 || opt_type == 2); } } if (!prompt ("Do you want to assign doc_counts to terms ?")) break; if (toupper (line[0]) == 'Y') { /* cycle thru terms asking for doc_counts */ int i; for (i = 0; i < term_list->num; i++) { char str[80]; TermEntry *te = &(term_list->TE[i]); sprintf (str, "Please enter doc count for term '%s'", str255_to_string (te->Word, NULL)); prompt (str); te->WE.doc_count = atoi (line); printf ("doc_count = %ld\n", te->WE.doc_count); } /*for */ } /*if */ if (res == 0) { fprintf (file_out, "\n***Parsed Expression***\n"); PrintBoolTree (tree, file_out); fputc ('\n', file_out); OptimiseBoolTree (tree, term_list, opt_type); fprintf (file_out, "\n***Optimised Expression ***\n"); PrintBoolTree (tree, file_out); fputc ('\n', file_out); } } exit(0); }
void mbCmdForEachDir::Execute(mbCommands& stack) { mbDirTraverser traverser; wxString idref; MB_CMD_GUARD_OPT; bool hidden = ParseBool(wxT("Hidden"), true, wxT("yes")); bool recurse = ParseBool(wxT("Recurse"), true); bool reverse = ParseBool(wxT("Reverse"), true); wxString id = ParseProp(wxT("Id"), true, wxT("ForEach")); wxString path = ParseProp(wxT("Path"), false); wxString flagstr; int flags = 0; if( hidden ) { flags |= wxDIR_HIDDEN; flagstr += wxT("Hidden "); } if( recurse ) { flags |= wxDIR_DIRS; flagstr += wxT("Recurse "); } if( reverse ) { flagstr += wxT("Reverse "); } wxFileName fname = wxFileName(path); wxString filespec = fname.GetFullName(); PrintExecute(stack, wxT("%s %s %s"), fname.GetPathWithSep().c_str(), filespec.c_str(), flagstr.c_str() ); traverser = mbDirTraverser::Init( fname.GetPathWithSep(), filespec, flags, reverse ); idref = id; // Optional parameter does not affect ForEachFile child elements so stop here MB_CMD_UNGUARD_OPT; for( mbDirTraverser ft=traverser; ft; ++ft ) { GmbVariables().PushLocal(GetDebugId(&stack), idref, ft.GetPath() ); for( mbCommands::iterator it=m_commands.begin(); it!=m_commands.end(); ++it ) { // Special Ignore elements if( wxString(wxT("Ignore")).IsSameAs((*it)->GetName()) ) { // Parse ignore mask, if matches current file then skip to next file if( wxMatchWild((*it)->ParseProp(wxT("Id"), false), ft.GetPath(), false) ) break; } else { // Execute other children elements normally mbCmd::StaticExecute(stack, *it); } } GmbVariables().PopLocal(GetDebugId(&stack)); } }
bool LegacyAvatarSerializer::ReadAttachment(AvatarAttachment& dest, const QDomDocument source, const EC_AvatarAppearance& appearance, const std::string& attachment_name) { QDomElement attachment_elem = source.firstChildElement("attachment"); if (attachment_elem.isNull()) { RexLogicModule::LogError("Attachment without attachment element"); return false; } dest.name_ = attachment_name; std::string meshname = appearance.GetMesh().name_; std::string basemeshname = appearance.GetProperty("basemesh"); bool found = false; QDomElement avatar_elem = attachment_elem.firstChildElement("avatar"); while (!avatar_elem.isNull()) { std::string name = avatar_elem.attribute("name").toStdString(); if ((name == meshname) || (name == basemeshname)) { found = true; break; } avatar_elem = avatar_elem.nextSiblingElement("avatar"); } if (!found) { RexLogicModule::LogError("No matching avatar mesh found in attachment. This attachment cannot be used for this avatar mesh"); return false; } QDomElement mesh_elem = attachment_elem.firstChildElement("mesh"); if (!mesh_elem.isNull()) { dest.mesh_.name_ = mesh_elem.attribute("name").toStdString(); dest.link_skeleton_ = ParseBool(mesh_elem.attribute("linkskeleton").toStdString()); } else { RexLogicModule::LogError("Attachment without mesh element"); return false; } QDomElement bone = avatar_elem.firstChildElement("bone"); if (!bone.isNull()) { dest.bone_name_ = bone.attribute("name").toStdString(); if (dest.bone_name_ == "None") dest.bone_name_ = std::string(); dest.transform_.position_ = ParseVector3(bone.attribute("offset").toStdString()); dest.transform_.orientation_ = ParseQuaternion(bone.attribute("rotation").toStdString()); dest.transform_.scale_ = ParseVector3(bone.attribute("scale").toStdString()); } QDomElement polygon = avatar_elem.firstChildElement("avatar_polygon"); while (!polygon.isNull()) { uint idx = ParseInt(polygon.attribute("idx").toStdString()); dest.vertices_to_hide_.push_back(idx); polygon = polygon.nextSiblingElement("avatar_polygon"); } QDomElement category_elem = attachment_elem.firstChildElement("category"); if (!category_elem.isNull()) { dest.category_ = category_elem.attribute("name").toStdString(); } return true; }
bool LegacyAvatarSerializer::ReadAttachment(AvatarAttachmentVector& dest, const QDomElement& elem) { AvatarAttachment attachment; QDomElement name = elem.firstChildElement("name"); if (!name.isNull()) { attachment.name_ = name.attribute("value").toStdString(); } else { RexLogicModule::LogError("Attachment without name element"); return false; } QDomElement category = elem.firstChildElement("category"); if (!category.isNull()) { attachment.category_ = category.attribute("name").toStdString(); } QDomElement mesh = elem.firstChildElement("mesh"); if (!mesh.isNull()) { attachment.mesh_.name_ = mesh.attribute("name").toStdString(); attachment.link_skeleton_ = ParseBool(mesh.attribute("linkskeleton").toStdString()); } else { RexLogicModule::LogError("Attachment without mesh element"); return false; } QDomElement avatar = elem.firstChildElement("avatar"); if (!avatar.isNull()) { QDomElement bone = avatar.firstChildElement("bone"); if (!bone.isNull()) { attachment.bone_name_ = bone.attribute("name").toStdString(); if (attachment.bone_name_ == "None") attachment.bone_name_ = std::string(); attachment.transform_.position_ = ParseVector3(bone.attribute("offset").toStdString()); attachment.transform_.orientation_ = ParseQuaternion(bone.attribute("rotation").toStdString()); attachment.transform_.scale_ = ParseVector3(bone.attribute("scale").toStdString()); } QDomElement polygon = avatar.firstChildElement("avatar_polygon"); while (!polygon.isNull()) { uint idx = ParseInt(polygon.attribute("idx").toStdString()); attachment.vertices_to_hide_.push_back(idx); polygon = polygon.nextSiblingElement("avatar_polygon"); } } else { RexLogicModule::LogError("Attachment without avatar element"); return false; } dest.push_back(attachment); return true; }