void WriteLine( const std::string& line, int type ) { if( myLogErrors && type >= CLog::LT_Warning ) AddToErrorBuffer( line, type ); if( line.empty() ) { GetPrefix( type ); return; } std::ofstream myLog; myLog.open( myFilename.c_str(), std::ios::app ); myLog << GetPrefix( type ); if ( myIndent <= 0 ) { myIndent = 0; } else { std::string tmp_string; for ( int i = 0; i < myIndent; i++ ) tmp_string.append( myIndentString ); myLog << tmp_string; } myLog << line; myLog.close(); }
bool ASSISTANT::Document::SaveAs(LPCTSTR filename) { // store temporarily old document name CString documentPrefix = m_csDocumentName; GetPrefix(documentPrefix); // update document name m_csDocumentName = filename; ASSISTANT::GetName(m_csDocumentName); // update document path m_csDocumentPath = filename; ASSISTANT::GetPath(m_csDocumentPath); if (containerName == documentPrefix) { bool changeTitle = false; if (containerName == scorm.GetTitle()) changeTitle = true; containerName = m_csDocumentName; ASSISTANT::GetPrefix(containerName); if (changeTitle) scorm.SetTitle(containerName); } bool success = WriteLSD(filename); if (success) { SetChanged(false); lastSavedDocument = filename; } return success; }
void RPCProxy::HOOK_Fini(FRT_RPCRequest *req) { if (++GetSession(req)->finiCnt == 2) { fprintf(stdout, "%s FINI\n", GetPrefix(req)); delete GetSession(req); } }
CustomPrefixMode(Module* parent, const std::string& Name, char Letter, char Prefix, ConfigTag* Tag) : PrefixMode(parent, Name, Letter, 0, Prefix) , tag(Tag) { unsigned long rank = tag->getUInt("rank", 0, 0, UINT_MAX); unsigned long setrank = tag->getUInt("ranktoset", prefixrank, rank, UINT_MAX); unsigned long unsetrank = tag->getUInt("ranktounset", setrank, setrank, UINT_MAX); bool depriv = tag->getBool("depriv", true); this->Update(rank, setrank, unsetrank, depriv); ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Created the %s prefix: letter=%c prefix=%c rank=%u ranktoset=%u ranktounset=%i depriv=%d", name.c_str(), GetModeChar(), GetPrefix(), GetPrefixRank(), GetLevelRequired(true), GetLevelRequired(false), CanSelfRemove()); }
void FdoSmLpGrdPropertyMappingSingle::SetupOverrides( const FdoSmLpPropertyMappingSingle* pBase, FdoSmLpObjectPropertyDefinition* pParent, FdoRdbmsOvPropertyMappingSingle* pOverrides, bool bInherit ) { FdoSmPhMgrP mgr = GetLogicalPhysicalSchema()->GetPhysicalSchema(); FdoStringP prefix = GetPrefix(); // Extract the physical overrides. if ( pOverrides ) { prefix = pOverrides->GetPrefix(); if ( prefix.GetLength() > 0 ) { if ( prefix != mgr->CensorDbObjectName(prefix) ) AddPrefixCharError(prefix); if ( prefix.GetLength() > mgr->DbObjectNameMaxLen() ) AddPrefixLengthError(prefix, mgr->DbObjectNameMaxLen()); } } if ( prefix.GetLength() == 0 ) { if ( pBase ) { // Get them from base definition if this one is copied or inherited. prefix = pBase->GetPrefix(); } // Generate default column prefix from object property name. if ( prefix.GetLength() == 0 ) { prefix = mgr->CensorDbObjectName(pParent->GetName()).Mid(0,25); } if ( (pParent->GetElementState() == FdoSchemaElementState_Added) && !bInherit ) { FdoSmLpObjectPropertyClass* pParentClass = dynamic_cast<FdoSmLpObjectPropertyClass*>( (FdoSmLpSchemaElement*)(pParent->GetParent()) ); // Pre-pend base property prefix to keep prefix as unique as possible. if ( pParentClass ) { const FdoSmLpPropertyMappingSingle* pParentMapping = FdoSmLpGrdPropertyMappingSingle::Cast( pParentClass->RefObjectProperty()->RefMappingDefinition() ); if ( pParentMapping ) { prefix = FdoStringP(pParentMapping->GetPrefix()) + L"_" + prefix; } } } } SetPrefix( prefix ); }
/* virtual */ OP_STATUS CSS_NamespaceRule::GetCssText(CSS* stylesheet, TempBuffer* buf, unsigned indent_level) { RETURN_IF_ERROR(buf->Append("@namespace ")); const uni_char* prefix = GetPrefix(); if (prefix && *prefix) { RETURN_IF_ERROR(buf->Append(prefix)); RETURN_IF_ERROR(buf->Append(" ")); } RETURN_IF_ERROR(buf->Append("url(")); RETURN_IF_ERROR(buf->Append(GetURI())); return buf->Append(");"); }
// Process a line of input int ClassAdCronJob::ProcessOutput( const char *line ) { if ( NULL == m_output_ad ) { m_output_ad = new ClassAd( ); } // NULL line means end of list if ( NULL == line ) { // Publish it if ( m_output_ad_count != 0 ) { // Insert the 'LastUpdate' field const char *lu_prefix = GetPrefix( ); if ( lu_prefix ) { MyString Update; Update.formatstr( "%sLastUpdate = %ld", lu_prefix, (long) time(NULL) ); const char *UpdateStr = Update.Value( ); // Add it in if ( ! m_output_ad->Insert( UpdateStr ) ) { dprintf( D_ALWAYS, "Can't insert '%s' into '%s' ClassAd\n", UpdateStr, GetName() ); // TodoWrite( ); } } // Replace the old ClassAd now Publish( GetName( ), m_output_ad ); // I've handed it off; forget about it! m_output_ad = NULL; m_output_ad_count = 0; } } else { // Process this line! if ( ! m_output_ad->Insert( line ) ) { dprintf( D_ALWAYS, "Can't insert '%s' into '%s' ClassAd\n", line, GetName() ); // TodoWrite( ); } else { m_output_ad_count++; } } return m_output_ad_count; }
int StartdCronJob::Publish( const char *ad_name, ClassAd *ad ) { // first, update the ad in the ResMgr, so we have the new // values. we only want to do the (somewhat expensive) // operation of reportind a diff if we care about that. bool report_diff = false; CronAutoPublish_t auto_publish = cron_job_mgr->getAutoPublishValue(); if( auto_publish == CAP_IF_CHANGED ) { report_diff = true; } int rval = resmgr->adlist_replace( ad_name, GetPrefix(), ad, report_diff ); // now, figure out if we need to update the collector based on // the startd_cron_autopublish stuff and if the ad changed... bool wants_update = false; switch( auto_publish ) { case CAP_NEVER: return rval; break; case CAP_ALWAYS: wants_update = true; dprintf( D_FULLDEBUG, "StartdCronJob::Publish() updating collector " "[STARTD_CRON_AUTOPUBLISH=\"Always\"]\n" ); break; case CAP_IF_CHANGED: if( rval == 1 ) { dprintf( D_FULLDEBUG, "StartdCronJob::Publish() has new data, " "updating collector\n" ); wants_update = true; } else { dprintf( D_FULLDEBUG, "StartdCronJob::Publish() has no new data, " "skipping collector update\n" ); } break; default: EXCEPT( "PROGRAMMER ERROR: unknown value of auto_publish (%d)", (int)auto_publish ); break; } if( wants_update ) { resmgr->update_all(); } return rval; }
void ASSISTANT::Document::SetDocumentFilename(LPCTSTR filename) { CString documentPrefix = m_csDocumentName; GetPrefix(documentPrefix); m_csDocumentName = filename; ASSISTANT::GetName(m_csDocumentName); m_csDocumentPath = filename; ASSISTANT::GetPath(m_csDocumentPath); if (containerName == documentPrefix) { containerName = m_csDocumentName; ASSISTANT::GetPrefix(containerName); } }
bool IsNodeAlias( const char * nameSpace, const char * name, XMP_ExpandedXPath & exPath ) { spIUTF8String qualName = IUTF8String_I::CreateUTF8String(); auto defaultMap = INameSpacePrefixMap::GetDefaultNameSpacePrefixMap(); spcIUTF8String prefixStr = defaultMap->GetPrefix( nameSpace, AdobeXMPCommon::npos ); if ( !prefixStr ) { return false; } qualName->append( prefixStr )->append( ":", AdobeXMPCommon::npos )->append( name, AdobeXMPCommon::npos ); bool aliasFound = sRegisteredAliasMap->count( qualName->c_str() ) > 0; if ( aliasFound ) { exPath = ( *sRegisteredAliasMap )[ qualName->c_str() ]; return aliasFound; } return aliasFound; }
bool FdoSmLpGrdPropertyMappingSingle::AddSchemaMappings( FdoPhysicalPropertyMappingP propMapping, bool bIncludeDefaults ) const { FdoRdbmsOvObjectPropertyDefinition* grdPropMapping = dynamic_cast<FdoRdbmsOvObjectPropertyDefinition*>((FdoPhysicalPropertyMapping*)propMapping); bool bHasMappings = false; // Add the schema mappings for the particular type of mapping definition. if ( grdPropMapping) { FdoRdbmsOvPropertyMappingSingleP singleMapping = grdPropMapping->CreateSingleMapping( true ); if ( singleMapping ) { singleMapping->SetPrefix( GetPrefix() ); bHasMappings = true; } } return bHasMappings; }
/** * @brief Internal function for writing the messages. * @param [in] level Message's level. * @param [in] pszFormat Message's format specifier. * @param [in] arglist Message argumets to format string. */ void CLogFile::WriteV(UINT level, LPCTSTR pszFormat, va_list arglist) { CString msg; msg.FormatV(pszFormat, arglist); msg.Insert(0, GetPrefix(level)); if (level & LOSERROR) { TCHAR cause[5120]; CInternetException(GetLastError()).GetErrorMessage(cause, countof(cause)); msg += cause; } msg.TrimRight(_T("\r\n")); msg += _T("\n"); WriteRaw(msg); if (level & LDEBUG) { OutputDebugString(msg); } }
const char* MakePath( PathID id, char buf[MAX_PATH_SIZE]) { const PathEntry* ent = &_entries[id]; /* Copy prefix */ if (Strlcpy(buf, GetPrefix(), MAX_PATH_SIZE) >= MAX_PATH_SIZE) return NULL; /* If running from source directory */ if (_runningFromSourceDirectory && id == ID_PLUGIN_LIBDIR) return buf; /* Copy the LHS */ { const char* p; /* Skip over "${prefix}" or "${exec_prefix}" */ { p = ent->lhs; if (p[0] == '$' && p[1] == '{') { for (p += 2; *p && *p != '}'; p++) ; if (*p == '}') p++; } } if (Strlcat(buf, p, MAX_PATH_SIZE) >= MAX_PATH_SIZE) return NULL; } /* Copy the RHS */ if (ent->rhs && Strlcat(buf, ent->rhs, MAX_PATH_SIZE) >= MAX_PATH_SIZE) return NULL; return buf; }
void RPCProxy::HOOK_Init(FRT_RPCRequest *req) { if (req->GetConnection()->IsClient()) { return; } Session *session = new Session(_currID++); session->client = req->GetConnection(); session->server = _supervisor.Get2WayTarget(_spec, FNET_Context((void *) session)); session->client->SetContext(FNET_Context((void *) session)); if (session->server->GetConnection() == nullptr || session->server->GetConnection()->GetState() > FNET_Connection::FNET_CONNECTED) { session->finiCnt = 1; session->client->Owner()->Close(session->client); } fprintf(stdout, "%s INIT\n", GetPrefix(req)); }
rbToken* rbBytecode::AddToken( rbToken* t ) { GetStack()->AddChild(t); wxLogMessage( wxString::Format(wxT("%sADD %s"),GetPrefix(),PF_SAFESTR(t->ToString()))); return t; }
char* VSIArchiveFilesystemHandler::SplitFilename(const char *pszFilename, CPLString &osFileInArchive, int bCheckMainFileExists) { int i = 0; if (strcmp(pszFilename, GetPrefix()) == 0) return NULL; /* Allow natural chaining of VSI drivers without requiring double slash */ CPLString osDoubleVsi(GetPrefix()); osDoubleVsi += "/vsi"; if (strncmp(pszFilename, osDoubleVsi.c_str(), osDoubleVsi.size()) == 0) pszFilename += strlen(GetPrefix()); else pszFilename += strlen(GetPrefix()) + 1; while(pszFilename[i]) { std::vector<CPLString> oExtensions = GetExtensions(); std::vector<CPLString>::const_iterator iter; int nToSkip = 0; for( iter = oExtensions.begin(); iter != oExtensions.end(); ++iter ) { const CPLString& osExtension = *iter; if (EQUALN(pszFilename + i, osExtension.c_str(), strlen(osExtension.c_str()))) { nToSkip = strlen(osExtension.c_str()); break; } } if (nToSkip != 0) { VSIStatBufL statBuf; char* archiveFilename = CPLStrdup(pszFilename); int bArchiveFileExists = FALSE; if (archiveFilename[i + nToSkip] == '/' || archiveFilename[i + nToSkip] == '\\') { archiveFilename[i + nToSkip] = 0; } if (!bCheckMainFileExists) { bArchiveFileExists = TRUE; } else { CPLMutexHolder oHolder( &hMutex ); if (oFileList.find(archiveFilename) != oFileList.end() ) { bArchiveFileExists = TRUE; } } if (!bArchiveFileExists) { VSIFilesystemHandler *poFSHandler = VSIFileManager::GetHandler( archiveFilename ); if (poFSHandler->Stat(archiveFilename, &statBuf, VSI_STAT_EXISTS_FLAG | VSI_STAT_NATURE_FLAG) == 0 && !VSI_ISDIR(statBuf.st_mode)) { bArchiveFileExists = TRUE; } } if (bArchiveFileExists) { if (pszFilename[i + nToSkip] == '/' || pszFilename[i + nToSkip] == '\\') { char* pszArchiveInFileName = CPLStrdup(pszFilename + i + nToSkip + 1); /* Replace a/../b by b and foo/a/../b by foo/b */ while(TRUE) { char* pszPrevDir = strstr(pszArchiveInFileName, "/../"); if (pszPrevDir == NULL || pszPrevDir == pszArchiveInFileName) break; char* pszPrevSlash = pszPrevDir - 1; while(pszPrevSlash != pszArchiveInFileName && *pszPrevSlash != '/') pszPrevSlash --; if (pszPrevSlash == pszArchiveInFileName) memmove(pszArchiveInFileName, pszPrevDir + nToSkip, strlen(pszPrevDir + nToSkip) + 1); else memmove(pszPrevSlash + 1, pszPrevDir + nToSkip, strlen(pszPrevDir + nToSkip) + 1); } osFileInArchive = pszArchiveInFileName; CPLFree(pszArchiveInFileName); } else osFileInArchive = ""; /* Remove trailing slash */ if (osFileInArchive.size()) { char lastC = osFileInArchive[strlen(osFileInArchive) - 1]; if (lastC == '\\' || lastC == '/') osFileInArchive.resize(strlen(osFileInArchive) - 1); } return archiveFilename; } CPLFree(archiveFilename); } i++; } return NULL; }
VSIArchiveReader* VSIArchiveFilesystemHandler::OpenArchiveFile(const char* archiveFilename, const char* fileInArchiveName) { VSIArchiveReader* poReader = CreateReader(archiveFilename); if (poReader == NULL) { return NULL; } if (fileInArchiveName == NULL || strlen(fileInArchiveName) == 0) { if (poReader->GotoFirstFile() == FALSE) { delete(poReader); return NULL; } /* Skip optionnal leading subdir */ CPLString osFileName = poReader->GetFileName(); const char* fileName = osFileName.c_str(); if (fileName[strlen(fileName)-1] == '/' || fileName[strlen(fileName)-1] == '\\') { if (poReader->GotoNextFile() == FALSE) { delete(poReader); return NULL; } } if (poReader->GotoNextFile()) { CPLString msg; msg.Printf("Support only 1 file in archive file %s when no explicit in-archive filename is specified", archiveFilename); const VSIArchiveContent* content = GetContentOfArchive(archiveFilename, poReader); if (content) { int i; msg += "\nYou could try one of the following :\n"; for(i=0;i<content->nEntries;i++) { msg += CPLString().Printf(" %s/%s/%s\n", GetPrefix(), archiveFilename, content->entries[i].fileName); } } CPLError(CE_Failure, CPLE_NotSupported, "%s", msg.c_str()); delete(poReader); return NULL; } } else { const VSIArchiveEntry* archiveEntry = NULL; if (FindFileInArchive(archiveFilename, fileInArchiveName, &archiveEntry) == FALSE || archiveEntry->bIsDir) { delete(poReader); return NULL; } if (!poReader->GotoFileOffset(archiveEntry->file_pos)) { delete poReader; return NULL; } } return poReader; }
void RPCProxy::PrintMethod(FRT_RPCRequest *req, const char *desc) { fprintf(stdout, "%s %s: %s\n", GetPrefix(req), desc, req->GetMethodName()); }
int StartdCronJob::Publish( const char *ad_name, const char *args, ClassAd *ad ) { // first, update the ad in the ResMgr, so we have the new // values. we only want to do the (somewhat expensive) // operation of reportind a diff if we care about that. CronAutoPublish_t auto_publish = cron_job_mgr->getAutoPublishValue(); bool wants_update = false; // if args isn't NULL, then we may have a uniqueness tag for the ad and/or publication arguments MyString tagged_name; if (args) { StringList arglist(args); arglist.rewind(); const char * arg = arglist.next(); // the first token may be a uniqueness tag for the ad, but not if it contains a : if (arg && ! strchr(arg, ':')) { tagged_name.formatstr("%s.%s", ad_name, arg); ad_name = tagged_name.c_str(); } else { // if first arg had a : it's not a tag, so we want to re-parse it as an argument. arglist.rewind(); } while ((arg = arglist.next())) { const char * pcolon = NULL; if (is_arg_colon_prefix(arg, "update", &pcolon, -1)) { wants_update = true; // update without arg means true if ( ! pcolon || string_is_boolean_param(pcolon+1, wants_update, ad)) { auto_publish = CAP_NEVER; // No point in checking for differences } } } } // can't use adlist_replace here because it can't easily insert // new ads that point back to this class // so we replicate the relevent bits of adlist_replace here. int rval = 0; // set to 1 to indicate the ad has changed. StartdNamedClassAd * sad = resmgr->adlist_find( ad_name ); if ( ! sad ) { sad = new StartdNamedClassAd( ad_name, *this, ad ); // maybe we should be inserting this after the base ad for this cron job? dprintf( D_FULLDEBUG, "Adding '%s' to the 'extra' ClassAd list\n", ad_name ); resmgr->adlist_register( sad ); rval = 1; // a new ad is a changed ad } else { // found the ad, now we want to update it, and possbly check for changes in the update dprintf( D_FULLDEBUG, "Replacing ClassAd for '%s'\n", ad_name ); if (CAP_IF_CHANGED == auto_publish) { ClassAd* oldAd = sad->GetAd(); if ( ! oldAd) { rval = 1; // a new ad is a changed ad } else { MyString ignore(GetPrefix()); ignore += "LastUpdate"; StringList ignore_list(ignore.c_str()); rval = ! ClassAdsAreSame(ad, oldAd, &ignore_list); } } sad->ReplaceAd(ad); } // now, figure out if we need to update the collector based on // the startd_cron_autopublish stuff and if the ad changed... switch( auto_publish ) { case CAP_NEVER: // wants_update will be already be set to false unless set to true by the script itself. if (wants_update) { dprintf( D_FULLDEBUG, "StartdCronJob::Publish() updating collector " "[script '%s' requested update]\n", ad_name ); } break; case CAP_ALWAYS: wants_update = true; dprintf( D_FULLDEBUG, "StartdCronJob::Publish() updating collector " "[STARTD_CRON_AUTOPUBLISH=\"Always\"]\n" ); break; case CAP_IF_CHANGED: if( rval == 1 ) { dprintf( D_FULLDEBUG, "StartdCronJob::Publish() has new data, " "updating collector\n" ); wants_update = true; } else { dprintf( D_FULLDEBUG, "StartdCronJob::Publish() has no new data, " "skipping collector update\n" ); } break; default: EXCEPT( "PROGRAMMER ERROR: unknown value of auto_publish (%d)", (int)auto_publish ); break; } if( wants_update ) { resmgr->update_all(); } // Update our internal (policy) ads immediately. Otherwise, this cron // job's output won't effect anything until the next UPDATE_INTERVAL. // The flag argument must be at least A_PUBLIC | A_UPDATE to pass the // check in ResMgr::adlist_publish(), which is the (only) update we // actually want. (We can't call it directly, because we need to // update the internal ad for each Resource.) resmgr->walk( &Resource::refresh_classad, A_PUBLIC | A_UPDATE ); return rval; }
HRESULT ASSISTANT::Document::Load(CProgressDialogA *pProgress) { HRESULT hr = S_OK; CString csProgressText; csProgressText.Format(IDS_LOADING_DOCUMENT, m_csDocumentName); if (pProgress != NULL) { pProgress->SetRange(0, 100); pProgress->SetLabel(csProgressText); } CString csFilename = m_csDocumentPath; csFilename += _T("\\"); csFilename += m_csDocumentName; int iPageCount = 0; ASSISTANT::SGMLTree *pSgmlTree = new ASSISTANT::SGMLTree(csFilename); if (pSgmlTree == NULL || pSgmlTree->Buildtree(iPageCount, pProgress) < 0) return E_FAIL; containerName.Empty(); ASSISTANT::SGMLElement *pRoot = pSgmlTree->root; if (pRoot == NULL || ((pRoot->Name != _T("ASSISTANT")) && (pRoot->Name != _T("MLB")))) { delete pSgmlTree; return E_FAIL; } SetName(pRoot->GetAttribute("name")); LPTSTR tszAttribute; tszAttribute = pRoot->GetAttribute("author"); if (tszAttribute != NULL) scorm.SetAuthor(tszAttribute); else scorm.SetAuthor(_T("")); tszAttribute = pRoot->GetAttribute("creator"); if (tszAttribute != NULL) scorm.SetCreator(tszAttribute); else scorm.SetCreator(_T("")); tszAttribute = pRoot->GetAttribute("keywords"); if (tszAttribute) scorm.SetKeywords(tszAttribute); else scorm.SetKeywords(_T("")); tszAttribute = pRoot->GetAttribute("codepage"); if (tszAttribute) { unsigned int iCodePage = _ttoi(tszAttribute); SetCodepage(iCodePage); unsigned int iActualCodepage = GetACP(); if (iActualCodepage != iCodePage) { CString csMessage; csMessage.Format(IDS_WARNING_CODEPAGE, iCodePage, iActualCodepage); CString csCaption; csCaption.LoadString(IDS_WARNING); MessageBox(NULL, csMessage, csCaption, MB_OK | MB_ICONWARNING | MB_TOPMOST); } } float fProgressTab = (float)50 / iPageCount; int iCount = 0; int iContainerNumber = 0; // If the document is selected the loaded objects are inserted at the begin // -> wrong order, this flag is only necessary for draeg&drop m_bSelected = false; ASSISTANT::SGMLElement *pTag = pRoot->son; while (pTag != NULL) { // 50% for Buildtree, 50% for page creation int iActualProgressValue = (int)(50 + iCount * fProgressTab); if (pProgress) pProgress->SetPos(iActualProgressValue); if (pTag->Name == _T("FOLDER")) { ++iContainerNumber; _TCHAR tszTmpFolderNumber[256]; _stprintf(tszTmpFolderNumber, _T("%d") ,iContainerNumber); ASSISTANT::Folder *pFolder = new ASSISTANT::Folder(Project::active->GetObjectID(), tszTmpFolderNumber, this, pTag); InsertContainerCurrent(pFolder); pFolder->SetCodepage(GetCodepage()); } else if (pTag->Name == _T("PAGE")) { ++iContainerNumber; _TCHAR tszTmpPageNumber[256]; _stprintf(tszTmpPageNumber, _T("%d"), iContainerNumber); ASSISTANT::Page *pPage = new ASSISTANT::Page(Project::active->GetObjectID(), tszTmpPageNumber, this, pTag); InsertContainerCurrent(pPage); pPage->SetCodepage(GetCodepage()); ++iCount; } else { CString csError; csError.Format(IDS_SGML_TYPE_ERROR, pTag->Name); MessageBox(NULL, csError, NULL, MB_OK | MB_TOPMOST); } pTag = pTag->next; } current = subContainer.GetSize() > 0 ? 0 : -1; delete pSgmlTree; CString metadataName = csFilename; GetPrefix(metadataName); metadataName += _T(".lmd"); MetadataMerger metadataMerger; metadataMerger.DoMerge(this, metadataName); //if ((50 - lastValue) > 0) // GUI::Progress::IncreaseProgress(50-lastValue); m_bIsLoaded = true; return hr; }
// Create consistent units bool UnitsController::SetConsistentUnits(char *len,char *ms,char *tm) { if(unitsType != LEGACY_UNITS) return false; unitsType = CONSISTENT_UNITS; // length if(strcmp(len,"km")==0) lengthExp = 3; else if(strcmp(len,"m")==0) lengthExp = 0; else if(strcmp(len,"dm")==0) lengthExp = -1; else if(strcmp(len,"cm")==0) lengthExp = -2; else if(strcmp(len,"mm")==0) lengthExp = -3; else if(strcmp(len,"um")==0) lengthExp = -6; else if(strcmp(len,"microns")==0) { strcpy(len,"um"); lengthExp = -6; } else if(strcmp(len,"nm")==0) lengthExp = -9; else if(strcmp(len,"L")==0) { lengthExp = 0; unitsType = USER_UNITS; } else return false; strcpy(length,len); // mass if(strcmp(ms,"kg")==0) massExp = 0; else if(strcmp(ms,"g")==0) massExp = -3; else if(strcmp(ms,"mg")==0) massExp = -6; else if(strcmp(ms,"ug")==0) massExp = -9; else if(strcmp(ms,"M")==0) { massExp = 0; unitsType = USER_UNITS; } else return false; strcpy(mass,ms); // time if(strcmp(tm,"s")==0) timeExp = 0; else if(strcmp(tm,"sec")==0) { tm[1]=0; timeExp = 0; } else if(strcmp(tm,"ms")==0) timeExp = -3; else if(strcmp(tm,"msec")==0) { tm[2]=0; timeExp = -3; } else if(strcmp(tm,"us")==0) timeExp = -6; else if(strcmp(ms,"T")==0) { timeExp = 0; unitsType = USER_UNITS; } else return false; strcpy(timeu,tm); // build labels // density strcpy(density,mass); strcat(density,"/"); strcat(density,length); strcat(density,"^3"); // velocity strcpy(velocity,len); strcat(velocity,"/"); strcat(velocity,timeu); // force int fexp = massExp+lengthExp-2*timeExp; if(unitsType==USER_UNITS) strcpy(force,"F"); else { GetPrefix(fexp,"N",force); if(strlen(force)==0) { GetPrefix(fexp+5,"dyne",force); if(strlen(force)==0) sprintf(force,"10^%dN",fexp); } } // pressure int pexp = fexp-2*lengthExp; if(unitsType==USER_UNITS) strcpy(pressure,"F/L^2"); else { GetPrefix(pexp,"Pa",pressure); if(strlen(pressure)==0) { GetPrefix(pexp+1,"Ba",pressure); if(strlen(pressure)==0) sprintf(pressure,"10^%dPa",pexp); } } // energy int enerexp = fexp+lengthExp; if(unitsType==USER_UNITS) strcpy(energy,"F-L"); else { GetPrefix(enerexp,"J",energy); if(strlen(energy)==0) { GetPrefix(enerexp+7,"erg",energy); if(strlen(energy)==0) sprintf(energy,"10^%dJ",enerexp); } } // energy release rate strcpy(errRate,energy); strcat(errRate,"/"); strcat(errRate,length); strcat(errRate,"^2"); // stress intensity strcpy(stressIntensity,pressure); strcat(stressIntensity,"-sqrt("); strcat(stressIntensity,length); strcat(stressIntensity,")"); // traction slope strcpy(tractionSlope,pressure); strcat(tractionSlope,"/"); strcat(tractionSlope,length); // viscosity int vexp = pexp+timeExp; if(unitsType==USER_UNITS) strcpy(viscosity,"F-T/L^2"); else { GetPrefix(vexp,"Pa-s",viscosity); if(strlen(viscosity)==0) { GetPrefix(vexp+1,"P",viscosity); if(strlen(viscosity)==0) sprintf(viscosity,"10^%dPa-s",vexp); } } // heat capacity strcpy(heatCapacity,energy); strcat(heatCapacity,"/("); strcat(heatCapacity,mass); strcat(heatCapacity,"-K)"); // power int powerexp = enerexp-timeExp; if(unitsType==USER_UNITS) strcpy(power,"F-L/T"); else { GetPrefix(powerexp,"W",power); if(strlen(power)==0) { GetPrefix(powerexp+7,"(erg/s)",power); if(strlen(power)==0) sprintf(power,"10^%dW",powerexp); } } // conductivity if(unitsType==USER_UNITS) strcpy(conductivity,"F-L/(m-s-K)"); else { strcpy(conductivity,power); strcat(conductivity,"/("); strcat(conductivity,length); strcat(conductivity,"-K)"); } // convection if(unitsType==USER_UNITS) strcpy(convection,"F-L/(m^2-s-K)"); else { strcpy(convection,power); strcat(convection,"/("); strcat(convection,length); strcat(convection,"^2-K)"); } // heat flux if(unitsType==USER_UNITS) strcpy(heatFlux,"F-L/(m^2-s)"); else { strcpy(heatFlux,power); strcat(heatFlux,"/"); strcat(heatFlux,length); strcat(heatFlux,"^2"); } // bcarg strcpy(bcarg,timeu); strcat(bcarg,"/"); strcat(bcarg,timeu); strcat(bcarg,"^-1"); // concentration flux strcpy(concFlux,mass); strcat(concFlux,"/("); strcat(concFlux,length); strcat(concFlux,"^-2-"); strcat(concFlux,timeu); strcat(concFlux,")"); return true; }
int StartdBenchJob::Publish( const char *ad_name, ClassAd *ad ) { resmgr->adlist_replace( ad_name, GetPrefix(), ad, false ); return 0; }
// // Initialize // bool wxApp::Initialize(int& argc, wxChar **argv) { if ( !wxAppBase::Initialize(argc, argv) ) return false; #if defined(wxUSE_CONSOLEDEBUG) #if wxUSE_CONSOLEDEBUG /***********************************************/ /* Code for using stdout debug */ /* To use it you mast link app as "Window" - EK*/ /***********************************************/ { PPIB pib; PTIB tib; printf("In console\n"); DosGetInfoBlocks(&tib, &pib); /* Try morphing into a PM application. */ // if(pib->pib_ultype == 2) /* VIO */ pib->pib_ultype = 3; } /**********************************************/ /**********************************************/ #endif //wxUSE_CONSOLEDEBUG #endif // // OS2 has to have an anchorblock // vHabmain = WinInitialize(0); wxFileName GetPrefix(argv[0]); GetPrefix.MakeAbsolute(); wxStandardPaths::SetInstallPrefix(GetPrefix.GetPath()); if (!vHabmain) { // TODO: at least give some error message here... wxAppBase::CleanUp(); return false; } wxBuffer = new wxChar[1500]; // FIXME; why? // Some people may wish to use this, but // probably it shouldn't be here by default. #ifdef __WXDEBUG__ // wxRedirectIOToConsole(); #endif wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100); // This is to foil optimizations in Visual C++ that throw out dummy.obj. // PLEASE DO NOT ALTER THIS. #if !defined(WXMAKINGDLL) && defined(__VISAGECPP__) extern char wxDummyChar; if (wxDummyChar) wxDummyChar++; #endif // wxSetKeyboardHook(TRUE); RegisterWindowClasses(vHabmain); return true; } // end of wxApp::Initialize
std::string PrefixFilter::FilterLine(const std::string &line) const { return GetPrefix() + line; }