Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

static int kldrDyldFindGetDefaults ( KLDRDYLDSEARCH penmSearch,
const char **  ppszPrefix,
const char **  ppszSuffix,
const char *  pszName,
KU32  fFlags 
) [static]

Resolve default search method, prefix and suffix.

Returns:
0 on success, KERR_INVALID_PARAMETER on failure.
Parameters:
penmSearch The search method. In/Out.
ppszPrefix The prefix. In/Out.
ppszSuffix The suffix. In/Out.
pszName The name. In.
fFlags The load/search flags.

Todo:
*penmSearch = KLDRDYLD_SEARCH_DARWIN;

Definition at line 807 of file kLdrDyldFind.c.

References KERR_INVALID_PARAMETER, KLDRDYLD_LOAD_FLAGS_EXECUTABLE, KLDRDYLD_SEARCH_HOST, KLDRDYLD_SEARCH_KLDR, KLDRDYLD_SEARCH_OS2, KLDRDYLD_SEARCH_UNIX_COMMON, KLDRDYLD_SEARCH_WINDOWS, KLDRDYLD_SEARCH_WINDOWS_ALTERED, kLdrDyldDefPrefix, kLdrDyldDefSuffix, KLDRDYLDFIND_ASSERT, KSIZE, and NULL.

Referenced by kldrDyldFindDoDllSearch(), kldrDyldFindDoExeSearch(), and kldrDyldFindExistingModule().

{
    unsigned fCaseSensitive;

    /*
     * Fixup search method alias.
     */
    if (*penmSearch == KLDRDYLD_SEARCH_HOST)
#if K_OS == K_OS_DARWIN
        /** @todo *penmSearch = KLDRDYLD_SEARCH_DARWIN; */
        *penmSearch = KLDRDYLD_SEARCH_UNIX_COMMON;
#elif K_OS == K_OS_FREEBSD \
   || K_OS == K_OS_LINUX \
   || K_OS == K_OS_NETBSD \
   || K_OS == K_OS_OPENBSD \
   || K_OS == K_OS_SOLARIS
        *penmSearch = KLDRDYLD_SEARCH_UNIX_COMMON;
#elif K_OS == K_OS_OS2
        *penmSearch = KLDRDYLD_SEARCH_OS2;
#elif K_OS == K_OS_WINDOWS
        *penmSearch = KLDRDYLD_SEARCH_WINDOWS;
#else
# error "Port me"
#endif

    /*
     * Apply search method specific prefix/suffix.
     */
    switch (*penmSearch)
    {
        case KLDRDYLD_SEARCH_KLDR:
            if (!*ppszPrefix && kLdrDyldDefPrefix[0])
                *ppszPrefix = kLdrDyldDefPrefix;
            if (!*ppszSuffix && kLdrDyldDefSuffix[0])
                *ppszSuffix = kLdrDyldDefSuffix;
            fCaseSensitive = 1;
            break;

        case KLDRDYLD_SEARCH_OS2:
            if (!*ppszSuffix)
                *ppszSuffix = !(fFlags & KLDRDYLD_LOAD_FLAGS_EXECUTABLE) ? ".dll" : ".exe";
            fCaseSensitive = 0;
            break;

        case KLDRDYLD_SEARCH_WINDOWS:
        case KLDRDYLD_SEARCH_WINDOWS_ALTERED:
            if (!*ppszSuffix)
                *ppszSuffix = !(fFlags & KLDRDYLD_LOAD_FLAGS_EXECUTABLE) ? ".dll" : ".exe";
            fCaseSensitive = 0;
            break;

        case KLDRDYLD_SEARCH_UNIX_COMMON:
            fCaseSensitive = 1;
            break;

        default:
            KLDRDYLDFIND_ASSERT(!"invalid search method");
            return KERR_INVALID_PARAMETER;
    }

    /*
     * Drop the suffix if it's already included in the name.
     */
    if (*ppszSuffix)
    {
        const KSIZE cchName = kHlpStrLen(pszName);
        const KSIZE cchSuffix = kHlpStrLen(*ppszSuffix);
        if (    cchName > cchSuffix
            &&  (   fCaseSensitive
                 ?  !kHlpMemComp(pszName + cchName - cchSuffix, *ppszSuffix, cchSuffix)
                 :  !kHlpMemICompAscii(pszName + cchName - cchSuffix, *ppszSuffix, cchSuffix))
           )
            *ppszSuffix = NULL;
    }

    return 0;
}


Generated by  Doxygen 1.6.0   Back to index