Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
xptiManifest.cpp File Reference
#include "xptiprivate.h"
#include "nsManifestLineReader.h"
#include "nsString.h"

Go to the source code of this file.

Functions

static PRBool GetCurrentAppDirString (xptiInterfaceInfoManager *aMgr, nsACString &aStr)
static PRBool CurrentAppDirMatchesPersistentDescriptor (xptiInterfaceInfoManager *aMgr, const char *inStr)
 xpti_InterfaceWriter (PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 number, void *arg)
static char * ReadManifestIntoMemory (xptiInterfaceInfoManager *aMgr, PRUint32 *pLength)
static PRBool ReadSectionHeader (nsManifestLineReader &reader, const char *token, int minCount, int *count)

Variables

static const char g_Disclaimer [] = "# Generated file. ** DO NOT EDIT! **"
static const char g_TOKEN_Files [] = "Files"
static const char g_TOKEN_ArchiveItems [] = "ArchiveItems"
static const char g_TOKEN_Interfaces [] = "Interfaces"
static const char g_TOKEN_Header [] = "Header"
static const char g_TOKEN_Version [] = "Version"
static const char g_TOKEN_AppDir [] = "AppDir"
static const char g_TOKEN_Directories [] = "Directories"
static const int g_VERSION_MAJOR = 2
static const int g_VERSION_MINOR = 0

Function Documentation

static PRBool CurrentAppDirMatchesPersistentDescriptor ( xptiInterfaceInfoManager aMgr,
const char *  inStr 
) [static]

Definition at line 72 of file xptiManifest.cpp.

{
    nsCOMPtr<nsILocalFile> appDir;
    aMgr->GetApplicationDir(getter_AddRefs(appDir));

    nsCOMPtr<nsILocalFile> descDir;
    nsresult rv = NS_NewNativeLocalFile(EmptyCString(), PR_FALSE, getter_AddRefs(descDir));
    if(NS_FAILED(rv))
        return PR_FALSE;

    rv = descDir->SetPersistentDescriptor(nsDependentCString(inStr));
    if(NS_FAILED(rv))
        return PR_FALSE;
    
    PRBool matches;
    rv = appDir->Equals(descDir, &matches);
    return NS_SUCCEEDED(rv) && matches;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool GetCurrentAppDirString ( xptiInterfaceInfoManager aMgr,
nsACString &  aStr 
) [static]

Definition at line 62 of file xptiManifest.cpp.

{
    nsCOMPtr<nsILocalFile> appDir;
    aMgr->GetApplicationDir(getter_AddRefs(appDir));
    if(appDir)
        return NS_SUCCEEDED(appDir->GetPersistentDescriptor(aStr));
    return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static char* ReadManifestIntoMemory ( xptiInterfaceInfoManager aMgr,
PRUint32 pLength 
) [static]

Definition at line 288 of file xptiManifest.cpp.

{
    PRFileDesc* fd = nsnull;
    PRInt32 flen;
    PRInt64 fileSize;
    char* whole = nsnull;
    PRBool success = PR_FALSE;

    nsCOMPtr<nsILocalFile> aFile;
    if(!aMgr->GetCloneOfManifestLocation(getter_AddRefs(aFile)) || !aFile)
        return nsnull;

#ifdef DEBUG
    {
        static PRBool shown = PR_FALSE;
        
        nsCAutoString path;
        if(!shown && NS_SUCCEEDED(aFile->GetNativePath(path)) && !path.IsEmpty())
        {
            printf("Type Manifest File: %s\n", path.get());
            shown = PR_TRUE;        
        } 
    }            
#endif

    if(NS_FAILED(aFile->GetFileSize(&fileSize)) || !(flen = nsInt64(fileSize)))
        return nsnull;

    whole = new char[flen];
    if (!whole)
        return nsnull;

    // All exits from on here should be via 'goto out' 

    if(NS_FAILED(aFile->OpenNSPRFileDesc(PR_RDONLY, 0444, &fd)) || !fd)
        goto out;

    if(flen > PR_Read(fd, whole, flen))
        goto out;

    success = PR_TRUE;

 out:
    if(fd)
        PR_Close(fd);

    if(!success)     
    {
        delete [] whole;
        return nsnull;
    }

    *pLength = flen;
    return whole;    
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool ReadSectionHeader ( nsManifestLineReader reader,
const char *  token,
int  minCount,
int count 
) [static]

Definition at line 346 of file xptiManifest.cpp.

{
    while(1)
    {
        if(!reader.NextLine())
            break;
        if(*reader.LinePtr() == '[')
        {
            char* p = reader.LinePtr() + (reader.LineLength() - 1);
            if(*p != ']')
                break;
            *p = 0;

            char* values[2];
            int lengths[2];
            if(2 != reader.ParseLine(values, lengths, 2))
                break;

            // ignore the leading '['
            if(0 != PL_strcmp(values[0]+1, token))
                break;

            if((*count = atoi(values[1])) < minCount)
                break;
            
            return PR_TRUE;
        }
    }
    return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

xpti_InterfaceWriter ( PLDHashTable table,
PLDHashEntryHdr hdr,
PRUint32  number,
void arg 
)

Definition at line 93 of file xptiManifest.cpp.

{
    xptiInterfaceEntry* entry = ((xptiHashEntry*)hdr)->value;
    PRFileDesc* fd = (PRFileDesc*)  arg;

    char* iidStr = entry->GetTheIID()->ToString();
    if(!iidStr)
        return PL_DHASH_STOP;

    const xptiTypelib& typelib = entry->GetTypelibRecord();

    PRBool success =  PR_fprintf(fd, "%d,%s,%s,%d,%d,%d\n",
                                 (int) number,
                                 entry->GetTheName(),
                                 iidStr,
                                 (int) typelib.GetFileIndex(),
                                 (int) (typelib.IsZip() ? 
                                 typelib.GetZipItemIndex() : -1),
                                 (int) entry->GetScriptableFlag());

    nsCRT::free(iidStr);

    return success ? PL_DHASH_NEXT : PL_DHASH_STOP;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const char g_Disclaimer[] = "# Generated file. ** DO NOT EDIT! **" [static]

Definition at line 46 of file xptiManifest.cpp.

const char g_TOKEN_AppDir[] = "AppDir" [static]

Definition at line 53 of file xptiManifest.cpp.

const char g_TOKEN_ArchiveItems[] = "ArchiveItems" [static]

Definition at line 49 of file xptiManifest.cpp.

const char g_TOKEN_Directories[] = "Directories" [static]

Definition at line 54 of file xptiManifest.cpp.

const char g_TOKEN_Files[] = "Files" [static]

Definition at line 48 of file xptiManifest.cpp.

const char g_TOKEN_Header[] = "Header" [static]

Definition at line 51 of file xptiManifest.cpp.

const char g_TOKEN_Interfaces[] = "Interfaces" [static]

Definition at line 50 of file xptiManifest.cpp.

const char g_TOKEN_Version[] = "Version" [static]

Definition at line 52 of file xptiManifest.cpp.

const int g_VERSION_MAJOR = 2 [static]

Definition at line 56 of file xptiManifest.cpp.

const int g_VERSION_MINOR = 0 [static]

Definition at line 57 of file xptiManifest.cpp.