xptiManifest.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mike McCabe <mccabe@netscape.com>
* John Bandhauer <jband@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Implementation of xptiManifest. */
#include "xptiprivate.h"
#include "nsManifestLineReader.h"
#include "nsString.h"
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;
/***************************************************************************/
static PRBool
{
if(appDir)
return PR_FALSE;
}
static PRBool
const char *inStr)
{
return PR_FALSE;
return PR_FALSE;
}
{
if(!iidStr)
return PL_DHASH_STOP;
(int) number,
entry->GetTheName(),
(int) typelib.GetFileIndex(),
(int) entry->GetScriptableFlag());
}
// static
{
PRUint32 i;
PRIntn interfaceCount = 0;
return PR_FALSE;
// All exits via "goto out;" from here on...
{
goto out;
}
// write file header comments
goto out;
// write the [Header] block, version number, and appdir.
goto out;
goto out;
if(appDirString.IsEmpty())
goto out;
goto out;
// write Directories list
(int) aWorkingSet->GetDirectoryCount()))
goto out;
for(i = 0; i < aWorkingSet->GetDirectoryCount(); i++)
{
if(!dir)
goto out;
goto out;
goto out;
}
// write Files list
(int) aWorkingSet->GetFileCount()))
goto out;
for(i = 0; i < aWorkingSet->GetFileCount(); i++)
{
(int) i,
(int) file.GetDirectory(),
goto out;
}
// write ArchiveItems list
(int) aWorkingSet->GetZipItemCount()))
goto out;
for(i = 0; i < aWorkingSet->GetZipItemCount(); i++)
{
(int) i,
goto out;
}
// write the Interfaces list
(int) interfaceCount))
goto out;
if(interfaceCount != (PRIntn)
goto out;
{
}
out:
if(fd)
if(succeeded)
{
// delete the old file and rename this
return PR_FALSE;
return PR_FALSE;
return PR_FALSE;
// MoveTo means rename.
return PR_FALSE;
}
return succeeded;
}
/***************************************************************************/
/***************************************************************************/
static char*
{
return nsnull;
#ifdef DEBUG
{
{
}
}
#endif
return nsnull;
if (!whole)
return nsnull;
// All exits from on here should be via 'goto out'
goto out;
goto out;
out:
if(fd)
if(!success)
{
delete [] whole;
return nsnull;
}
return whole;
}
static
{
while(1)
{
break;
{
if(*p != ']')
break;
*p = 0;
char* values[2];
int lengths[2];
break;
// ignore the leading '['
break;
break;
return PR_TRUE;
}
}
return PR_FALSE;
}
// static
{
int i;
int headerCount = 0;
int dirCount = 0;
int fileCount = 0;
int zipItemCount = -1;
int interfaceCount = 0;
int dir;
int flags;
int lengths[6];
if(!whole)
return PR_FALSE;
// All exits from here on should be via 'goto out'
// Look for "Header" section
// This version accepts only version 1,0. We also freak if the header
// has more than one entry. The rationale is that we want to force an
// autoreg if the xpti.dat file was written by *any* other version of
// the software. Future versions may wish to support updating older
// manifests in some interesting way.
goto out;
if(headerCount != 2)
goto out;
// Verify the version number
goto out;
// index,VersionLiteral,major,minor
goto out;
// index
goto out;
// VersionLiteral
goto out;
// major
goto out;
// minor
goto out;
// Verify the application directory
goto out;
// index,AppDirLiteral,directoryname
goto out;
// index
goto out;
// AppDirLiteral
goto out;
goto out;
// Look for "Directories" section
goto out;
else
{
// To validate that the directory list matches the current search path
// we first confirm that the list lengths match.
if(dirCount != (int) searchPathCount)
goto out;
}
// Read the directory records
for(i = 0; i < dirCount; ++i)
{
goto out;
// index,directoryname
goto out;
// index
goto out;
// directoryname
goto out;
}
// Look for "Files" section
goto out;
// Alloc room in the WorkingSet for the filearray.
goto out;
// Read the file records
for(i = 0; i < fileCount; ++i)
{
goto out;
// index,filename,dirIndex,dilesSize,filesDate
goto out;
// index
goto out;
// filename
if(!*values[1])
goto out;
// dirIndex
goto out;
// fileSize
if(size32 <= 0)
goto out;
// fileDate
if(LL_IS_ZERO(date))
goto out;
// Append a new file record to the array.
}
// Look for "ZipItems" section
goto out;
// Alloc room in the WorkingSet for the zipItemarray.
if(zipItemCount)
goto out;
// Read the zipItem records
for(i = 0; i < zipItemCount; ++i)
{
goto out;
// index,filename
goto out;
// index
goto out;
// filename
if(!*values[1])
goto out;
// Append a new zipItem record to the array.
}
// Look for "Interfaces" section
goto out;
// Read the interface records
for(i = 0; i < interfaceCount; ++i)
{
int fileIndex;
int zipItemIndex;
goto out;
// index,interfaceName,iid,fileIndex,zipIndex,flags
goto out;
// index
goto out;
// interfaceName
if(!*values[1])
goto out;
// iid
goto out;
// fileIndex
goto out;
// zipIndex (NOTE: -1 is a valid value)
goto out;
// flags
goto out;
// Build an InterfaceInfo and hook it in.
if(zipItemIndex == -1)
else
if(!entry)
goto out;
// Add our entry to the iid hashtable.
hashEntry = (xptiHashEntry*)
if(hashEntry)
// Add our entry to the name hashtable.
hashEntry = (xptiHashEntry*)
if(hashEntry)
}
// success!
out:
if(whole)
delete [] whole;
if(!succeeded)
{
// Cleanup the WorkingSet on failure.
}
return succeeded;
}
// static
{
return PR_FALSE;
return PR_FALSE;
return PR_FALSE;
return PR_TRUE;
}