uint32_t TDNFCliParseRepoListArgs( PTDNF_CMD_ARGS pCmdArgs, TDNF_REPOLISTFILTER* pnFilter ) { uint32_t dwError = 0; TDNF_REPOLISTFILTER nFilter = REPOLISTFILTER_ENABLED; if(!pCmdArgs) { dwError = ERROR_TDNF_INVALID_PARAMETER; BAIL_ON_CLI_ERROR(dwError); } //Could have filter argument (tdnf repolist <filter>) //assume REPOLISTFILTER_ENABLED if not specified. if(pCmdArgs->nCmdCount > 1) { dwError = ParseFilter(pCmdArgs->ppszCmds[1], &nFilter); BAIL_ON_CLI_ERROR(dwError); } *pnFilter = nFilter; cleanup: return dwError; error: if(pnFilter) { *pnFilter = REPOLISTFILTER_ENABLED; } goto cleanup; }
/* ================ sdDeclDamageFilter::Parse ================ */ bool sdDeclDamageFilter::Parse( const char *text, const int textLength ) { idToken token; idParser src; src.SetFlags( DECL_LEXER_FLAGS ); //src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); sdDeclParseHelper declHelper( this, text, textLength, src ); src.SkipUntilString( "{", &token ); while( true ) { if( !src.ReadToken( &token ) ) { return false; } if( !token.Icmp( "type" ) ) { damageFilter_t& filter = filters.Alloc(); filter.target = NULL; filter.damage = 0.f; filter.mode = DFM_NORMAL; filter.noScale = false; if ( !ParseFilter( filter, src ) ) { src.Error( "sdDeclDamageFilter::Parse Error Parsing Filter %i", filters.Num() ); return false; } } else if( !token.Cmp( "}" ) ) { break; } else { src.Error( "sdDeclDamageFilter::Parse Invalid Token '%s'", token.c_str() ); return false; } } return true; }
/////////////////////////////////////////////////////////////////////////////// /// \brief /// Returns unmanaged data /// MgByteReader* MgUnmanagedDataManager::EnumerateUnmanagedData(CREFSTRING path, bool recursive, CREFSTRING type, CREFSTRING filter) { Ptr<MgByteReader> byteReader; MG_TRY() ACE_TRACE("MgUnmanagedDataManager::EnumerateUnmanagedData"); Ptr<MgPropertyCollection> unmanagedDataMappings = GetUnmanagedDataMappings(); if (NULL != unmanagedDataMappings.p) { // this XML follows the ResourceList-1.0.0.xsd schema string list = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; list += "<UnmanagedDataList xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"UnmanagedDataList-1.0.0.xsd\">\n"; // check arguments... // pull out the mapping name from the path // path must be in the form of: // "" // "[alias1]" // "[alias1]subfolder1" // "[alias1]subfolder1/" // "[alias1]subfolder1/subfolder2/" STRING mappingName = L"", subfolder = L""; if (!MgUnmanagedDataManager::ParsePath(path, mappingName, subfolder)) { MgStringCollection arguments; arguments.Add(L"1"); arguments.Add(path); throw new MgInvalidArgumentException(L"MgUnmanagedDataManager.EnumerateUnmanagedData", __LINE__, __WFILE__, &arguments, L"", NULL); } // type must be: // "FOLDERS" // "FILES" // "BOTH" bool storeFolders = ACE_OS::strcasecmp(type.c_str(), MgResourceUnmanagedDataType::Folders.c_str()) == 0 || ACE_OS::strcasecmp(type.c_str(), MgResourceUnmanagedDataType::Both.c_str()) == 0; bool storeFiles = ACE_OS::strcasecmp(type.c_str(), MgResourceUnmanagedDataType::Files.c_str()) == 0 || ACE_OS::strcasecmp(type.c_str(), MgResourceUnmanagedDataType::Both.c_str()) == 0; ACE_ASSERT(storeFolders || storeFiles); // filter is ignored if type = "FOLDERS" // filter can be: // "" // ".sdf" // ".sdf;.pdf;.shp" // "sdf" // "sdf;dwf;png" MgStringCollection filters; if (storeFiles) ParseFilter(filter, &filters); // are we looking in a specific path? if (!mappingName.empty()) { Ptr<MgStringProperty> stringProp = dynamic_cast<MgStringProperty*>(unmanagedDataMappings->FindItem(mappingName)); if (stringProp != NULL) { // we have a match! STRING mappingDir = stringProp->GetValue(); // get the files and/or folders from that folder and subfolder (recursive) GetFilesAndFolders(list, mappingName, mappingDir, subfolder, &filters, storeFolders, storeFiles, recursive); } else { MgStringCollection arguments; arguments.Add(L"1"); arguments.Add(path); throw new MgInvalidArgumentException(L"MgUnmanagedDataManager.EnumerateUnmanagedData", __LINE__, __WFILE__, &arguments, L"", NULL); } } else { // getting files starting from virtual root (all mappings) // iterate thru mappings for (int i = 0; i < unmanagedDataMappings->GetCount(); i++) { Ptr<MgStringProperty> stringProp = dynamic_cast<MgStringProperty*>(unmanagedDataMappings->GetItem(i)); STRING mapName = stringProp->GetName(); STRING mapDir = stringProp->GetValue(); if (MgFileUtil::IsDirectory(mapDir)) { if (storeFolders) { MgDateTime createdDate = MgFileUtil::GetFileCreationTime(mapDir); MgDateTime modifiedDate = MgFileUtil::GetFileModificationTime(mapDir); INT32 numFolders = 0; INT32 numFiles = 0; GetNumberOfFilesAndSubfolders(mapDir, numFolders, numFiles); // add top-level mappings AddFolder(list, mapName, L"", L"", numFolders, numFiles, createdDate, modifiedDate); } if (recursive) GetFilesAndFolders(list, mapName, mapDir, L"", &filters, storeFolders, storeFiles, recursive); } } } list += "</UnmanagedDataList>"; Ptr<MgByteSource> byteSource = new MgByteSource( (unsigned char*)list.c_str(), (INT32)list.length()); byteSource->SetMimeType(MgMimeType::Xml); byteReader = byteSource->GetReader(); } MG_CATCH_AND_THROW(L"MgUnmanagedDataManager.EnumerateUnmanagedData") return byteReader.Detach(); }
int FileDialog::ShowModal() { HWND hWnd = 0; if (m_parent) hWnd = (HWND) m_parent->GetHWND(); if (!hWnd && wxTheApp->GetTopWindow()) hWnd = (HWND) wxTheApp->GetTopWindow()->GetHWND(); static wxChar fileNameBuffer [ wxMAXPATH ]; // the file-name wxChar titleBuffer [ wxMAXFILE+1+wxMAXEXT ]; // the file-name, without path *fileNameBuffer = wxT('\0'); *titleBuffer = wxT('\0'); #if WXWIN_COMPATIBILITY_2_4 long msw_flags = 0; if ( (m_dialogStyle & wxHIDE_READONLY) || (m_dialogStyle & wxSAVE) ) msw_flags |= OFN_HIDEREADONLY; #else long msw_flags = OFN_HIDEREADONLY; #endif if ( m_dialogStyle & wxFILE_MUST_EXIST ) msw_flags |= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; /* If the window has been moved the programmer is probably trying to center or position it. Thus we set the callback or hook function so that we can actually adjust the position. Without moving or centering the dlg, it will just stay in the upper left of the frame, it does not center automatically.. One additional note, when the hook is enabled, the PLACES BAR in the dlg (shown on later versions of windows (2000 and XP) will automatically be turned off according to the MSDN docs. This is normal. If the programmer needs the PLACES BAR (left side of dlg) they just shouldn't move or center the dlg. */ if (m_bMovedWindow) // we need these flags. { msw_flags |= OFN_EXPLORER|OFN_ENABLEHOOK; #ifndef __WXWINCE__ msw_flags |= OFN_ENABLESIZING; #endif } if (m_dialogStyle & wxMULTIPLE ) { // OFN_EXPLORER must always be specified with OFN_ALLOWMULTISELECT msw_flags |= OFN_EXPLORER | OFN_ALLOWMULTISELECT; } // if wxCHANGE_DIR flag is not given we shouldn't change the CWD which the // standard dialog does by default (notice that under NT it does it anyhow, // OFN_NOCHANGEDIR or not, see below) if ( !(m_dialogStyle & wxCHANGE_DIR) ) { msw_flags |= OFN_NOCHANGEDIR; } if ( m_dialogStyle & wxOVERWRITE_PROMPT ) { msw_flags |= OFN_OVERWRITEPROMPT; } if ( m_dialogStyle & wxRESIZE_BORDER ) { msw_flags |= OFN_ENABLESIZING; } if ( m_callback != NULL ) { msw_flags |= OFN_SHOWHELP | OFN_EXPLORER | OFN_ENABLEHOOK; } // We always need EXPLORER and ENABLEHOOK to use our filtering code msw_flags |= OFN_EXPLORER | OFN_ENABLEHOOK; OPENFILENAME of; wxZeroMemory(of); // Allow Places bar to show on supported platforms if ( wxGetOsVersion() == wxWINDOWS_NT ) { of.lStructSize = sizeof(OPENFILENAME); } else { of.lStructSize = OPENFILENAME_SIZE_VERSION_400; } of.hwndOwner = hWnd; of.lpstrTitle = WXSTRINGCAST m_message; of.lpstrFileTitle = titleBuffer; of.nMaxFileTitle = wxMAXFILE + 1 + wxMAXEXT; // Windows 3.0 and 3.1 of.lCustData = (LPARAM) this; // Convert forward slashes to backslashes (file selector doesn't like // forward slashes) and also squeeze multiple consecutive slashes into one // as it doesn't like two backslashes in a row neither wxString dir; size_t i, len = m_dir.length(); dir.reserve(len); for ( i = 0; i < len; i++ ) { wxChar ch = m_dir[i]; switch ( ch ) { case _T('/'): // convert to backslash ch = _T('\\'); // fall through case _T('\\'): while ( i < len - 1 ) { wxChar chNext = m_dir[i + 1]; if ( chNext != _T('\\') && chNext != _T('/') ) break; // ignore the next one, unless it is at the start of a UNC path if (i > 0) i++; else break; } // fall through default: // normal char dir += ch; } } of.lpstrInitialDir = dir.c_str(); of.Flags = msw_flags; of.lpfnHook = FileDialogHookFunction; wxArrayString wildDescriptions; size_t items = wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, m_FilterGroups); wxASSERT_MSG( items > 0 , _T("empty wildcard list") ); wxString filterBuffer; for (i = 0; i < items ; i++) { filterBuffer += wildDescriptions[i]; filterBuffer += wxT("|"); filterBuffer += wxT("*.*"); filterBuffer += wxT("|"); } // Replace | with \0 for (i = 0; i < filterBuffer.Len(); i++ ) { if ( filterBuffer.GetChar(i) == wxT('|') ) { filterBuffer[i] = wxT('\0'); } } of.lpstrFilter = (LPTSTR)filterBuffer.c_str(); of.nFilterIndex = m_filterIndex + 1; ParseFilter(of.nFilterIndex); //=== Setting defaultFileName >>========================================= wxStrncpy( fileNameBuffer, (const wxChar *)m_fileName, wxMAXPATH-1 ); fileNameBuffer[ wxMAXPATH-1 ] = wxT('\0'); of.lpstrFile = fileNameBuffer; // holds returned filename of.nMaxFile = wxMAXPATH; // we must set the default extension because otherwise Windows would check // for the existing of a wrong file with wxOVERWRITE_PROMPT (i.e. if the // user types "foo" and the default extension is ".bar" we should force it // to check for "foo.bar" existence and not "foo") wxString defextBuffer; // we need it to be alive until GetSaveFileName()! if (m_dialogStyle & wxSAVE && m_dialogStyle & wxOVERWRITE_PROMPT) { const wxChar* extension = filterBuffer; int maxFilter = (int)(of.nFilterIndex*2L) - 1; for( int i = 0; i < maxFilter; i++ ) // get extension extension = extension + wxStrlen( extension ) + 1; // use dummy name a to avoid assert in AppendExtension defextBuffer = AppendExtension(wxT("a"), extension); if (defextBuffer.StartsWith(wxT("a."))) { defextBuffer.Mid(2); of.lpstrDefExt = defextBuffer.c_str(); } } // store off before the standard windows dialog can possibly change it const wxString cwdOrig = wxGetCwd(); //== Execute FileDialog >>================================================= bool success = (m_dialogStyle & wxSAVE ? GetSaveFileName(&of) : GetOpenFileName(&of)) != 0; #ifdef __WXWINCE__ DWORD errCode = GetLastError(); #else DWORD errCode = CommDlgExtendedError(); // GetOpenFileName will always change the current working directory on // (according to MSDN) "Windows NT 4.0/2000/XP" because the flag // OFN_NOCHANGEDIR has no effect. If the user did not specify wxCHANGE_DIR // let's restore the current working directory to what it was before the // dialog was shown (assuming this behavior extends to Windows Server 2003 // seems safe). if ( success && (msw_flags & OFN_NOCHANGEDIR) && wxGetOsVersion() == wxWINDOWS_NT ) { wxSetWorkingDirectory(cwdOrig); } #ifdef __WIN32__ if (!success && (errCode == CDERR_STRUCTSIZE)) { // The struct size has changed so try a smaller or bigger size int oldStructSize = of.lStructSize; of.lStructSize = oldStructSize - (sizeof(void *) + 2*sizeof(DWORD)); success = (m_dialogStyle & wxSAVE) ? (GetSaveFileName(&of) != 0) : (GetOpenFileName(&of) != 0); errCode = CommDlgExtendedError(); if (!success && (errCode == CDERR_STRUCTSIZE)) { of.lStructSize = oldStructSize + (sizeof(void *) + 2*sizeof(DWORD)); success = (m_dialogStyle & wxSAVE) ? (GetSaveFileName(&of) != 0) : (GetOpenFileName(&of) != 0); } } #endif // __WIN32__ #endif // __WXWINCE__ if ( success ) { m_fileNames.Empty(); if ( ( m_dialogStyle & wxMULTIPLE ) && #if defined(OFN_EXPLORER) ( fileNameBuffer[of.nFileOffset-1] == wxT('\0') ) #else ( fileNameBuffer[of.nFileOffset-1] == wxT(' ') ) #endif // OFN_EXPLORER ) { #if defined(OFN_EXPLORER) m_dir = fileNameBuffer; i = of.nFileOffset; m_fileName = &fileNameBuffer[i]; m_fileNames.Add(m_fileName); i += m_fileName.Len() + 1; while (fileNameBuffer[i] != wxT('\0')) { m_fileNames.Add(&fileNameBuffer[i]); i += wxStrlen(&fileNameBuffer[i]) + 1; } #else wxStringTokenizer toke(fileNameBuffer, _T(" \t\r\n")); m_dir = toke.GetNextToken(); m_fileName = toke.GetNextToken(); m_fileNames.Add(m_fileName); while (toke.HasMoreTokens()) m_fileNames.Add(toke.GetNextToken()); #endif // OFN_EXPLORER wxString dir(m_dir); if ( m_dir.Last() != _T('\\') ) dir += _T('\\'); m_path = dir + m_fileName; m_filterIndex = (int)of.nFilterIndex - 1; } else { //=== Adding the correct extension >>================================= m_filterIndex = (int)of.nFilterIndex - 1; #if 0 // LLL: Removed to prevent adding extension during Export // processing. if ( !of.nFileExtension || (of.nFileExtension && fileNameBuffer[of.nFileExtension] == wxT('\0')) ) { // User has typed a filename without an extension: const wxChar* extension = filterBuffer; int maxFilter = (int)(of.nFilterIndex*2L) - 1; for( int i = 0; i < maxFilter; i++ ) // get extension extension = extension + wxStrlen( extension ) + 1; m_fileName = AppendExtension(fileNameBuffer, extension); wxStrncpy(fileNameBuffer, m_fileName.c_str(), wxMin(m_fileName.Len(), wxMAXPATH-1)); fileNameBuffer[wxMin(m_fileName.Len(), wxMAXPATH-1)] = wxT('\0'); } #endif m_path = fileNameBuffer; m_fileName = wxFileNameFromPath(fileNameBuffer); m_fileNames.Add(m_fileName); m_dir = wxPathOnly(fileNameBuffer); } } else { // common dialog failed - why? #ifdef __WXDEBUG__ #ifdef __WXWINCE__ if (errCode == 0) { // OK, user cancelled the dialog } else if (errCode == ERROR_INVALID_PARAMETER) { wxLogError(wxT("Invalid parameter passed to file dialog function.")); } else if (errCode == ERROR_OUTOFMEMORY) { wxLogError(wxT("Out of memory when calling file dialog function.")); } else if (errCode == ERROR_CALL_NOT_IMPLEMENTED) { wxLogError(wxT("Call not implemented when calling file dialog function.")); } else { wxLogError(wxT("Unknown error %d when calling file dialog function."), errCode); } #else DWORD dwErr = CommDlgExtendedError(); if ( dwErr != 0 ) { // this msg is only for developers wxLogError(wxT("Common dialog failed with error code %0lx."), dwErr); } //else: it was just cancelled #endif #endif } return success ? wxID_OK : wxID_CANCEL; }
int VmDirPerformSearch( PVDIR_OPERATION pOperation ) { ber_len_t size = 0; SearchReq * sr = &(pOperation->request.searchReq); int retVal = LDAP_SUCCESS; BerValue* pLberBerv = NULL; PSTR pszLocalErrorMsg = NULL; BOOLEAN bResultAlreadySent = FALSE; PVDIR_LDAP_RESULT pResult = &(pOperation->ldapResult); // Parse base object, scope, deref alias, sizeLimit, timeLimit and typesOnly search parameters. if ( ber_scanf( pOperation->ber, "{miiiib", &(pOperation->reqDn.lberbv), &sr->scope, &sr->derefAlias, &sr->sizeLimit, &sr->timeLimit, &sr->attrsOnly ) == LBER_ERROR ) { VMDIR_LOG_ERROR( LDAP_DEBUG_ARGS, "PerformSearch: Decoding baseDN, ... attrsOnly error." ); pResult->errCode = LDAP_PROTOCOL_ERROR; retVal = LDAP_NOTICE_OF_DISCONNECT; BAIL_ON_VMDIR_ERROR_WITH_MSG( retVal, (pszLocalErrorMsg), "Decoding error while parsing baseDN, ... attrsOnly."); } VMDIR_LOG_VERBOSE( LDAP_DEBUG_ARGS, "Search Request: base: \"%s\", scope: %d, deref: %d, sizeLimit: %d, timeLimit: %d," "attrsOnly: %d", pOperation->reqDn.lberbv.bv_val, sr->scope, sr->derefAlias, sr->sizeLimit, sr->timeLimit, sr->attrsOnly); if (sr->scope != LDAP_SCOPE_BASE && sr->scope != LDAP_SCOPE_ONELEVEL && sr->scope != LDAP_SCOPE_SUBTREE) { pResult->errCode = retVal = LDAP_PROTOCOL_ERROR; BAIL_ON_VMDIR_ERROR_WITH_MSG( retVal, (pszLocalErrorMsg), "Invalid scope" ); } if (sr->sizeLimit < 0 || sr->sizeLimit > LDAP_MAXINT) { pResult->errCode = retVal = LDAP_PROTOCOL_ERROR; BAIL_ON_VMDIR_ERROR_WITH_MSG( retVal, (pszLocalErrorMsg), "Invalid size limit: %d", sr->sizeLimit ); } if (sr->timeLimit < 0 || sr->timeLimit > LDAP_MAXINT) { pResult->errCode = retVal = LDAP_PROTOCOL_ERROR; BAIL_ON_VMDIR_ERROR_WITH_MSG( retVal, (pszLocalErrorMsg), "Invalid time limit: %d", sr->timeLimit ); } if (sr->derefAlias != LDAP_DEREF_NEVER && sr->derefAlias != LDAP_DEREF_SEARCHING && sr->derefAlias != LDAP_DEREF_FINDING && sr->derefAlias != LDAP_DEREF_ALWAYS) { pResult->errCode = retVal = LDAP_PROTOCOL_ERROR; BAIL_ON_VMDIR_ERROR_WITH_MSG( retVal, (pszLocalErrorMsg), "Invalid dereference alias parameter"); } // Parse filter retVal = ParseFilter( pOperation, &sr->filter, pResult ); BAIL_ON_VMDIR_ERROR(retVal); // Log String filter, if desired. if (VmDirLogGetLevel() >= VMDIR_LOG_VERBOSE && VmDirLogGetMask() & LDAP_DEBUG_ARGS) { VDIR_BERVALUE strFilter = VDIR_BERVALUE_INIT; FilterToStrFilter( sr->filter, &strFilter ); VMDIR_LOG_VERBOSE( LDAP_DEBUG_ARGS, " Filter: %s", strFilter.lberbv.bv_val ); VmDirFreeBervalContent(&strFilter); } // Parse attributes. 'M' => attribute names point within (in-place) the ber. size = sizeof( BerValue ); // Size of the structure is passed-in, and number of attributes are returned back in // the same parameter. if ( ber_scanf( pOperation->ber, "{M}}", &pLberBerv, &size, 0 ) == LBER_ERROR ) { pResult->errCode = LDAP_PROTOCOL_ERROR; retVal = LDAP_NOTICE_OF_DISCONNECT; BAIL_ON_VMDIR_ERROR_WITH_MSG( retVal, (pszLocalErrorMsg), "Decoding error while parsing required attributes."); } // copy pLberBerv content into sr->attrs if (pLberBerv && size > 0) { int iCnt = 0; if (VmDirAllocateMemory(sizeof(VDIR_BERVALUE) * (size+1), (PVOID*)&sr->attrs) != 0) { pResult->errCode = retVal = LDAP_OPERATIONS_ERROR; BAIL_ON_VMDIR_ERROR_WITH_MSG( retVal, (pszLocalErrorMsg), "no memory"); } for (iCnt = 0; iCnt < size; iCnt++) { sr->attrs[iCnt].lberbv.bv_val = pLberBerv[iCnt].bv_val; sr->attrs[iCnt].lberbv.bv_len = pLberBerv[iCnt].bv_len; } } // Log list of the required attributes, if desired. if (( VmDirLogGetMask() & LDAP_DEBUG_ARGS) && size > 0) { if (VmDirLogSearchRequest(sr, size) != 0) { pResult->errCode = retVal = LDAP_OPERATIONS_ERROR; BAIL_ON_VMDIR_ERROR_WITH_MSG(retVal, (pszLocalErrorMsg), "Error while logging search request"); } } // Parse LDAP controls present (if any) in the request. retVal = ParseRequestControls(pOperation, pResult); // ldapResult.errCode set inside BAIL_ON_VMDIR_ERROR( retVal ); retVal = pResult->errCode = VmDirMLSearch( pOperation ); bResultAlreadySent = TRUE; BAIL_ON_VMDIR_ERROR(retVal); cleanup: VMDIR_SAFE_FREE_MEMORY(pLberBerv); VMDIR_SAFE_FREE_MEMORY(pszLocalErrorMsg); return retVal; error: VMDIR_APPEND_ERROR_MSG(pResult->pszErrMsg, pszLocalErrorMsg); if (retVal != LDAP_NOTICE_OF_DISCONNECT && bResultAlreadySent == FALSE) { VmDirSendLdapResult( pOperation ); } goto cleanup; }