Compare commits

..

1 Commits

Author SHA1 Message Date
(no author)
428ec0ae9d This commit was manufactured by cvs2svn to create tag 'Pre-XPCOM'.
git-svn-id: svn://10.0.0.236/tags/Pre-XPCOM@29612 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-28 00:34:31 +00:00
40 changed files with 1282 additions and 2974 deletions

View File

@@ -0,0 +1,5 @@
#
# This is a list of local files which get copied to the mozilla:dist directory
#
zipfile.h

View File

@@ -0,0 +1,36 @@
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
DEPTH = ../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = jar
LIBRARY_NAME = jar$(VERSION_NUMBER)
CPPSRCS = \
nsZipArchive.cpp \
$(NULL)
EXPORTS = zipfile.h
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

Binary file not shown.

View File

@@ -0,0 +1,2 @@
# target: libjarDebug.shlb
mozilla/modules/libjar/nsZipArchive.cpp

View File

@@ -0,0 +1,67 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/NPL/
#
# 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 Communicator client code,
# released March 31, 1998.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
# Contributors:
# Daniel Veditz <dveditz@netscape.com>
IGNORE_MANIFEST=1
DIRS=standalone
MODULE=jar
DEPTH=..\..
MAKE_OBJ_TYPE=DLL
DLLNAME=jar$(VERSION_NUMBER)
DLL=.\$(OBJDIR)\$(DLLNAME).dll
MAPFILE=$(DLLNAME).map
EXPORTS=zipfile.h
OBJS=.\$(OBJDIR)\nsZipArchive.obj
LINCS= \
-I$(XPDIST)\public\nspr \
-I$(XPDIST)\public\raptor \
-I$(XPDIST)\public\xpcom \
-I$(XPDIST)\public\zlib \
-I$(XPDIST)\public\network \
$(NULL)
LLIBS= \
$(LIBNSPR) \
$(DIST)\lib\plc3.lib \
$(DIST)\lib\zlib.lib \
$(DIST)\lib\xplib.lib \
$(NULL)
include <$(DEPTH)/config/rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber::
$(RM) $(OBJS)
$(RM) $(DIST)\bin\$(DLLNAME).dll
$(RM) $(DIST)\lib\$(DLLNAME).lib

View File

@@ -0,0 +1,795 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*
* Contributors:
* Daniel Veditz <dveditz@netscape.com>
*/
/*
* This module implements a simple archive extractor for the PKZIP format.
*/
#include <string.h>
#include "nscore.h"
#include "prmem.h"
#include "prio.h"
#include "plstr.h"
#include "prlog.h"
#include "xp_regexp.h"
#include "zlib.h"
#include "zipfile.h"
#include "zipstruct.h"
#include "nsZipArchive.h"
static PRUint16 xtoint(unsigned char *ii);
static PRUint32 xtolong(unsigned char *ll);
/*---------------------------------------------
* C API wrapper for nsZipArchive
*--------------------------------------------*/
/**
* ZIP_OpenArchive
*
* opens the named zip/jar archive and returns a handle that
* represents the archive in other ZIP_ calls.
*
* @param zipname archive filename
* @param hZip receives handle if archive opened OK
* @return status code
*/
PR_PUBLIC_API(PRInt32) ZIP_OpenArchive( const char * zipname, void** hZip )
{
PRInt32 status;
/*--- error check args ---*/
if ( hZip == NULL )
return ZIP_ERR_PARAM;
/*--- NULL output to prevent use by bozos who don't check errors ---*/
*hZip = NULL;
/*--- create and open the archive ---*/
nsZipArchive* zip = new nsZipArchive();
if ( zip == NULL )
return ZIP_ERR_MEMORY;
status = zip->OpenArchive(zipname);
if ( status == ZIP_OK )
*hZip = NS_STATIC_CAST(void*,zip);
else
delete zip;
return status;
}
/**
* ZIP_CloseArchive
*
* closes zip archive and frees memory
* @param hZip handle obtained from ZIP_OpenArchive
* @return status code
*/
PR_PUBLIC_API(PRInt32) ZIP_CloseArchive( void** hZip )
{
/*--- error check args ---*/
if ( hZip == NULL || *hZip == NULL )
return ZIP_ERR_PARAM;
nsZipArchive* zip = NS_STATIC_CAST(nsZipArchive*,*hZip);
if ( zip->kMagic != ZIP_MAGIC )
return ZIP_ERR_PARAM; /* whatever it is isn't one of ours! */
/*--- close the archive ---*/
*hZip = NULL;
delete zip;
return ZIP_OK;
}
/**
* ZIP_ExtractFile
*
* extracts named file from an opened archive
*
* @param hZip handle obtained from ZIP_OpenArchive
* @param filename name of file in archive
* @param outname filename to extract to
*/
PR_PUBLIC_API(PRInt32) ZIP_ExtractFile( void* hZip, const char * filename, const char * outname )
{
/*--- error check args ---*/
if ( hZip == NULL )
return ZIP_ERR_PARAM;
nsZipArchive* zip = NS_STATIC_CAST(nsZipArchive*,hZip);
if ( zip->kMagic != ZIP_MAGIC )
return ZIP_ERR_PARAM; /* whatever it is isn't one of ours! */
/*--- extract the file ---*/
return zip->ExtractFile( filename, outname );
}
/**
* ZIP_FindInit
*
* Initializes an enumeration of files in the archive
*
* @param hZip handle obtained from ZIP_OpenArchive
* @param pattern regexp to match files in archive, the usual shell expressions.
* NULL pattern also matches all files, faster than "*"
*/
PR_EXTERN(PRInt32) ZIP_FindInit( void* hZip, const char * pattern )
{
/*--- error check args ---*/
if ( hZip == NULL )
return ZIP_ERR_PARAM;
nsZipArchive* zip = NS_STATIC_CAST(nsZipArchive*,hZip);
if ( zip->kMagic != ZIP_MAGIC )
return ZIP_ERR_PARAM; /* whatever it is isn't one of ours! */
/*--- initialize the pattern search ---*/
return zip->FindInit( pattern );
}
/**
* ZIP_FindInit
*
* Puts the next name in the passed buffer. Returns ZIP_ERR_SMALLBUF when
* the name is too large for the buffer, and ZIP_ERR_FNF when there are no
* more files that match the pattern
*
* @param hZip handle obtained from ZIP_OpenArchive
* @param outbuf buffer to receive next filename
* @param bufsize size of allocated buffer
*/
PR_EXTERN(PRInt32) ZIP_FindNext( void* hZip, char * outbuf, PRUint16 bufsize )
{
/*--- error check args ---*/
if ( hZip == NULL )
return ZIP_ERR_PARAM;
nsZipArchive* zip = NS_STATIC_CAST(nsZipArchive*,hZip);
if ( zip->kMagic != ZIP_MAGIC )
return ZIP_ERR_PARAM; /* whatever it is isn't one of ours! */
/*--- return next filename file ---*/
return zip->FindNext( outbuf, bufsize );
}
//***********************************************************
// nsZipArchive -- public methods
//***********************************************************
//---------------------------------------------
// nsZipArchive::OpenArchive
//---------------------------------------------
PRInt32 nsZipArchive::OpenArchive( const char * aArchiveName )
{
//-- validate arguments
if ( aArchiveName == NULL || *aArchiveName == '\0')
return ZIP_ERR_PARAM;
//-- not allowed to do two opens on the same object!
if ( mFd != NULL )
return ZIP_ERR_GENERAL;
//-- open the physical file
mFd = PR_Open( aArchiveName, PR_RDONLY, 0 );
if ( mFd == NULL )
return ZIP_ERR_DISK;
//-- get table of contents for archive
return BuildFileList();
}
//---------------------------------------------
// nsZipArchive::ExtractFile
//---------------------------------------------
PRInt32 nsZipArchive::ExtractFile(const char* aFilename, const char* aOutname)
{
//-- sanity check arguments
if ( aFilename == NULL || aOutname == NULL )
return ZIP_ERR_PARAM;
//-- find file information
const nsZipItem* item = GetFileItem( aFilename );
if ( item == NULL )
return ZIP_ERR_FNF;
//-- extract the file using appropriate method
switch( item->compression )
{
case STORED:
return CopyItemToDisk( item, aOutname );
case DEFLATED:
return InflateItemToDisk( item, aOutname );
default:
//-- unsupported compression type
return ZIP_ERR_UNSUPPORTED;
}
}
//---------------------------------------------
// nsZipArchive::FindInit
//---------------------------------------------
PRInt32 nsZipArchive::FindInit( const char * aPattern )
{
// validate the pattern
if ( aPattern != NULL )
switch (XP_RegExpValid( (char*)aPattern ))
{
case INVALID_SXP:
return ZIP_ERR_PARAM;
case NON_SXP:
mPatternIsRegExp = PR_FALSE;
break;
case VALID_SXP:
mPatternIsRegExp = PR_TRUE;
break;
default:
// unexpected/undoc'ed return value
PR_ASSERT( PR_FALSE );
return ZIP_ERR_GENERAL;
}
// clear the old pattern
if ( mPattern != NULL )
{
PL_strfree( mPattern );
mPattern = NULL;
}
// re-initialize pattern state
mPatternSlot = 0;
mPatternItem = NULL;
if ( aPattern != NULL )
mPattern = PL_strdup( aPattern );
return ZIP_OK;
}
//---------------------------------------------
// nsZipArchive::FindNext
//---------------------------------------------
PRInt32 nsZipArchive::FindNext( char * aBuf, PRUint16 aSize )
{
PRInt32 status;
PRBool found = PR_FALSE;
PRUint32 slot = mPatternSlot;
nsZipItem* item = mPatternItem;
// we start from last match, look for next
while ( slot < ZIP_TABSIZE && !found )
{
if ( item != NULL )
item = item->next; // move to next in current chain
else
item = mFiles[slot]; // starting a new slot
if ( item == NULL )
{ // no more in this chain, move to next slot
++slot;
continue;
}
else if ( mPattern == NULL )
found = PR_TRUE; // always match
else if ( mPatternIsRegExp )
found = XP_RegExpMatch( item->name, mPattern, PR_FALSE );
else
found = ( PL_strcmp( item->name, mPattern ) == 0 );
}
if ( found )
{
if ( aSize > item->namelen )
{
PL_strcpy( aBuf, item->name );
status = ZIP_OK;
}
else
status = ZIP_ERR_SMALLBUF;
}
else
status = ZIP_ERR_FNF;
// save state for next Find. For 'smallbuf' we give user another chance
if ( status != ZIP_ERR_SMALLBUF )
{
mPatternSlot = slot;
mPatternItem = item;
}
return status;
}
//***********************************************************
// nsZipArchive -- private implementation
//***********************************************************
//---------------------------------------------
// nsZipArchive::BuildFileList
//---------------------------------------------
PRInt32 nsZipArchive::BuildFileList()
{
PRInt32 status = ZIP_OK;
PRUint32 sig = 0L;
PRUint32 namelen, extralen;
PRUint16 hash;
ZipLocal Local;
nsZipItem* item;
//-----------------------------------------------------------------------
// read the local file headers.
//
// What we *should* be doing is reading the central directory at the end,
// all in one place. We'll have to change this eventually since the local
// headers don't have the mode information we need for Unix files.
//-----------------------------------------------------------------------
PRInt32 pos = 0L;
while ( status == ZIP_OK )
{
if ( PR_Seek( mFd, pos, PR_SEEK_SET ) != (PRInt32)pos )
{
//-- couldn't seek to next position
status = ZIP_ERR_CORRUPT;
break;
}
if ( PR_Read( mFd, (char*)&Local, sizeof(ZipLocal) ) != sizeof(ZipLocal) )
{
//-- file ends prematurely
status = ZIP_ERR_CORRUPT;
break;
}
//-- make sure we're processing a local header
sig = xtolong( Local.signature );
if ( sig == CENTRALSIG )
{
// we're onto the next section
break;
}
else if ( sig != LOCALSIG )
{
//-- otherwise expected to find a local header
status = ZIP_ERR_CORRUPT;
break;
}
namelen = xtoint( Local.filename_len );
extralen = xtoint( Local.extrafield_len );
item = new nsZipItem();
if ( item != NULL )
{
item->name = new char[namelen+1];
if ( item->name != NULL )
{
if ( PR_Read( mFd, item->name, namelen ) == (PRInt32)namelen )
{
item->name[namelen] = 0;
item->namelen = namelen;
item->headerloc = pos;
item->offset = pos + sizeof(ZipLocal) + namelen + extralen;
item->compression = xtoint( Local.method );
item->size = xtolong( Local.size );
item->realsize = xtolong( Local.orglen );
item->crc32 = xtolong( Local.crc32 );
//-- add item to file table
hash = HashName( item->name );
item->next = mFiles[hash];
mFiles[hash] = item;
pos = item->offset + item->size;
}
else
{
//-- file is truncated
status = ZIP_ERR_CORRUPT;
delete item;
}
}
else
{
//-- couldn't allocate for the filename
status = ZIP_ERR_MEMORY;
delete item;
}
}
else
{
//-- couldn't create a nsZipItem
status = ZIP_ERR_MEMORY;
}
} /* while reading local headers */
//-------------------------------------------------------
// we don't care about the rest of the file (until we
// fix this to read the central directory instead)
//-------------------------------------------------------
return status;
}
//---------------------------------------------
// nsZipArchive::CopyItemToDisk
//---------------------------------------------
PRInt32 nsZipArchive::CopyItemToDisk( const nsZipItem* aItem, const char* aOutname )
{
PRInt32 status = ZIP_OK;
PRUint32 chunk, pos, size;
PRFileDesc* fOut = NULL;
PR_ASSERT( aItem != NULL && aOutname != NULL );
char* buf = (char*)PR_Malloc(ZIP_BUFLEN);
if ( buf == NULL )
return ZIP_ERR_MEMORY;
//-- find start of file in archive
if ( PR_Seek( mFd, aItem->offset, PR_SEEK_SET ) != (PRInt32)aItem->offset )
{
status = ZIP_ERR_CORRUPT;
goto cleanup;
}
//-- open output file
fOut = PR_Open( aOutname, PR_WRONLY | PR_CREATE_FILE, 0644);
if ( fOut == NULL )
{
status = ZIP_ERR_DISK;
goto cleanup;
}
//-- copy chunks until file is done
size = aItem->size;
for ( pos=0; pos < size; pos += chunk )
{
chunk = (pos+ZIP_BUFLEN <= size) ? ZIP_BUFLEN : size - pos;
if ( PR_Read( mFd, buf, chunk ) != (PRInt32)chunk )
{
//-- unexpected end of data in archive
status = ZIP_ERR_CORRUPT;
break;
}
if ( PR_Write( fOut, buf, chunk ) < (PRInt32)chunk )
{
//-- Couldn't write all the data (disk full?)
status = ZIP_ERR_DISK;
break;
}
}
cleanup:
if ( fOut != NULL )
PR_Close( fOut );
PR_FREEIF( buf );
return status;
}
//---------------------------------------------
// nsZipArchive::GetFileItem
//---------------------------------------------
const nsZipItem* nsZipArchive::GetFileItem( const char * aFilename )
{
PR_ASSERT( aFilename != NULL );
nsZipItem* item = mFiles[ HashName(aFilename) ];
for ( ; item != NULL; item = item->next )
{
if ( 0 == PL_strcmp( aFilename, item->name ) )
break; //-- found it
}
return item;
}
//---------------------------------------------
// nsZipArchive::HashName
//---------------------------------------------
PRUint16 nsZipArchive::HashName( const char* aName )
{
PRUint16 val = 0;
PRUint8* c;
PR_ASSERT( aName != NULL );
for ( c = (PRUint8*)aName; *c != 0; c++ ) {
val = val*37 + *c;
}
return (val % ZIP_TABSIZE);
}
//---------------------------------------------
// nsZipArchive::InflateItemToDisk
//---------------------------------------------
PRInt32 nsZipArchive::InflateItemToDisk( const nsZipItem* aItem, const char* aOutname )
{
PRInt32 status = ZIP_OK;
PRUint32 chunk, inpos, outpos, size;
PRFileDesc* fOut = NULL;
z_stream zs;
int zerr;
PRBool bInflating = PR_FALSE;
PR_ASSERT( aItem != NULL && aOutname != NULL );
//-- allocate deflation buffers
Bytef *inbuf = (Bytef*)PR_Malloc(ZIP_BUFLEN);
Bytef *outbuf = (Bytef*)PR_Malloc(ZIP_BUFLEN);
if ( inbuf == NULL || outbuf == NULL )
{
status = ZIP_ERR_MEMORY;
goto cleanup;
}
//-- find start of file in archive
if ( PR_Seek( mFd, aItem->offset, PR_SEEK_SET ) != (PRInt32)aItem->offset )
{
status = ZIP_ERR_CORRUPT;
goto cleanup;
}
//-- open output file
fOut = PR_Open( aOutname, PR_WRONLY | PR_CREATE_FILE, 0644);
if ( fOut == NULL )
{
status = ZIP_ERR_DISK;
goto cleanup;
}
//-- set up the inflate
memset( &zs, 0, sizeof(zs) );
zerr = inflateInit2( &zs, -MAX_WBITS );
if ( zerr != Z_OK )
{
status = ZIP_ERR_GENERAL;
goto cleanup;
}
bInflating = PR_TRUE;
//-- inflate loop
size = aItem->size;
outpos = inpos = 0;
zs.next_out = outbuf;
zs.avail_out = ZIP_BUFLEN;
while ( zerr == Z_OK )
{
if ( zs.avail_in == 0 && zs.total_in < size )
{
//-- no data to inflate yet still more in file:
//-- read another chunk of compressed data
inpos = zs.total_in; // input position
chunk = ( inpos + ZIP_BUFLEN <= size ) ? ZIP_BUFLEN : size - inpos;
if ( PR_Read( mFd, inbuf, chunk ) != (PRInt32)chunk )
{
//-- unexpected end of data
status = ZIP_ERR_CORRUPT;
break;
}
zs.next_in = inbuf;
zs.avail_in = ZIP_BUFLEN;
}
if ( zs.avail_out == 0 )
{
//-- write inflated buffer to disk and make space
if ( PR_Write( fOut, outbuf, ZIP_BUFLEN ) < ZIP_BUFLEN )
{
//-- Couldn't write all the data (disk full?)
status = ZIP_ERR_DISK;
break;
}
outpos = zs.total_out;
zs.next_out = outbuf;
zs.avail_out = chunk;
}
zerr = inflate( &zs, Z_PARTIAL_FLUSH );
} // while
//-- write last inflated bit to disk
if ( zerr == Z_STREAM_END && outpos < zs.total_out )
{
chunk = zs.total_out - outpos;
if ( PR_Write( fOut, outbuf, chunk ) < (PRInt32)chunk )
{
status = ZIP_ERR_DISK;
}
}
//-- convert zlib error to return value
if ( status == ZIP_OK && zerr != Z_OK && zerr != Z_STREAM_END )
{
status = (zerr == Z_MEM_ERROR) ? ZIP_ERR_MEMORY : ZIP_ERR_CORRUPT;
}
//-- if found no errors make sure we've converted the whole thing
PR_ASSERT( status != ZIP_OK || zs.total_in == aItem->size );
PR_ASSERT( status != ZIP_OK || zs.total_out == aItem->realsize );
cleanup:
if ( bInflating )
{
//-- free zlib internal state
inflateEnd( &zs );
}
if ( fOut != NULL )
PR_Close( fOut );
PR_FREEIF( inbuf );
PR_FREEIF( outbuf );
return status;
}
//------------------------------------------
// nsZipArchive constructor and destructor
//------------------------------------------
nsZipArchive::nsZipArchive()
: kMagic(ZIP_MAGIC), mFd(NULL), mPattern(NULL),
mPatternSlot(ZIP_TABSIZE), mPatternItem(NULL)
{
// initialize the table to NULL
for ( int i = 0; i < ZIP_TABSIZE; ++i) {
mFiles[i] = NULL;
}
}
nsZipArchive::~nsZipArchive()
{
// close the file if open
if ( mFd != NULL ) {
PR_Close(mFd);
}
// delete nsZipItems in table
nsZipItem* pItem;
for ( int i = 0; i < ZIP_TABSIZE; ++i)
{
pItem = mFiles[i];
while ( pItem != NULL )
{
mFiles[i] = pItem->next;
delete pItem;
pItem = mFiles[i];
}
}
if ( mPattern != NULL ) {
PL_strfree(mPattern);
}
}
//------------------------------------------
// nsZipItem constructor and destructor
//------------------------------------------
nsZipItem::nsZipItem() : name(NULL),next(NULL) {}
nsZipItem::~nsZipItem()
{
if (name != NULL )
delete [] name;
}
//------------------------------------------
// helper functions
//------------------------------------------
/*
* x t o i n t
*
* Converts a two byte ugly endianed integer
* to our platform's integer.
*/
static PRUint16 xtoint (unsigned char *ii)
{
return (PRUint16) (ii [0]) | ((PRUint16) ii [1] << 8);
}
/*
* x t o l o n g
*
* Converts a four byte ugly endianed integer
* to our platform's integer.
*/
static PRUint32 xtolong (unsigned char *ll)
{
PRUint32 ret;
ret = (
(((PRUint32) ll [0]) << 0) |
(((PRUint32) ll [1]) << 8) |
(((PRUint32) ll [2]) << 16) |
(((PRUint32) ll [3]) << 24)
);
return ret;
}

View File

@@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All Rights
* Reserved.
*
* Contributors:
* Daniel Veditz <dveditz@netscape.com>
*/
#include "prtypes.h"
#define ZIP_MAGIC 0x5F5A4950L /* "_ZIP" */
#define ZIP_TABSIZE 256
#define ZIP_BUFLEN 32767
/**
* nsZipItem -- a helper class for nsZipArchive
*
* each nsZipItem represents one file in the archive and all the
* information needed to manipulate it.
*/
class nsZipItem
{
public:
char* name;
PRUint32 namelen;
PRUint32 offset;
PRUint32 headerloc;
PRUint16 compression;
PRUint32 size;
PRUint32 realsize;
PRUint32 crc32;
nsZipItem* next;
nsZipItem();
~nsZipItem();
private:
//-- prevent copies and assignments
nsZipItem& operator=(const nsZipItem& rhs);
nsZipItem(const nsZipItem& rhs);
};
/**
* nsZipArchive -- a class for reading the PKZIP file format.
*
*/
class nsZipArchive
{
public:
/** cookie used to validate supposed objects passed from C code */
const PRInt32 kMagic;
/** constructing does not open the archive. See OpenArchive() */
nsZipArchive();
/** destructing the object closes the archive */
~nsZipArchive();
/**
* OpenArchive
*
* It's an error to call this more than once on the same nsZipArchive
* object. If we were allowed to use exceptions this would have been
* part of the constructor
*
* @param aArchiveName full pathname of archive
* @return status code
*/
PRInt32 OpenArchive( const char * aArchiveName );
/**
* ExtractFile
*
* @param aFilename name of file in archive to extract
* @param aOutname where to extract on disk
* @return status code
*/
PRInt32 ExtractFile( const char * aFilename, const char * aOutname );
PRInt32 FindInit( const char * aPattern );
PRInt32 FindNext( char * aBuf, PRUint16 aSize );
private:
//--- private members ---
PRFileDesc *mFd;
nsZipItem* mFiles[ZIP_TABSIZE];
char* mPattern;
PRUint16 mPatternSlot;
nsZipItem* mPatternItem;
PRBool mPatternIsRegExp;
//--- private methods ---
nsZipArchive& operator=(const nsZipArchive& rhs); // prevent assignments
nsZipArchive(const nsZipArchive& rhs); // prevent copies
PRInt32 BuildFileList();
PRInt32 CopyItemToDisk( const nsZipItem* aItem, const char* aOutname );
const nsZipItem* GetFileItem( const char * aFilename );
PRUint16 HashName( const char* aName );
PRInt32 InflateItemToDisk( const nsZipItem* aItem, const char* aOutname );
};

View File

@@ -0,0 +1,66 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/NPL/
#
# 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 Communicator client code,
# released March 31, 1998.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
# Contributors:
# Daniel Veditz <dveditz@netscape.com>
IGNORE_MANIFEST=1
MODULE=jar
DEPTH=..\..\..
MAKE_OBJ_TYPE=DLL
LIBRARY=$(OBJDIR)\jar_s.lib
OBJS=.\$(OBJDIR)\nsZipArchive.obj
LCFLAGS=-DSTANDALONE
LINCS= \
-I$(XPDIST)\public\nspr \
-I$(XPDIST)\public\raptor \
-I$(XPDIST)\public\xpcom \
-I$(XPDIST)\public\zlib \
$(NULL)
LLIBS= \
$(LIBNSPR) \
$(DIST)\lib\plc3.lib \
$(DIST)\lib\zlib.lib \
$(DIST)\lib\xplib.lib \
$(NULL)
include <$(DEPTH)/config/rules.mak>
docopy:
$(MAKE_INSTALL) ..\nsZip*.* .
$(MAKE_INSTALL) ..\zip*.* .
export:: docopy
install:: $(LIBRARY)
$(MAKE_INSTALL) .\$(OBJDIR)\jar_s.lib $(DIST)\lib
$(RM) *.h *.cpp
clobber::
$(RM) $(OBJS)
$(RM) $(DIST)\lib\jar_s.lib

View File

@@ -0,0 +1,85 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*
* Contributors:
* Daniel Veditz <dveditz@netscape.com>
*/
#ifndef _zipfile_h
#define _zipfile_h
/*
* This module implements a simple archive extractor for the PKZIP format.
*
* All functions return a status/error code, and have an opaque hZip argument
* that represents an open archive.
*
* Currently only compression mode 8 (or none) is supported.
*/
#include "prtypes.h"
#define ZIP_OK 0
#define ZIP_ERR_GENERAL -1
#define ZIP_ERR_MEMORY -2
#define ZIP_ERR_DISK -3
#define ZIP_ERR_CORRUPT -4
#define ZIP_ERR_PARAM -5
#define ZIP_ERR_FNF -6
#define ZIP_ERR_UNSUPPORTED -7
#define ZIP_ERR_SMALLBUF -8
PR_BEGIN_EXTERN_C
/* Open and close the archive
*
* If successful OpenArchive returns a handle in the hZip parameter
* that must be passed to all subsequent operations on the archive
*/
PR_EXTERN(PRInt32) ZIP_OpenArchive( const char * zipname, void** hZip );
PR_EXTERN(PRInt32) ZIP_CloseArchive( void** hZip );
/* Extract the named file in the archive to disk.
* This function will happily overwrite an existing Outfile if it can.
* It's up to the caller to detect or move it out of the way if it's important.
*/
PR_EXTERN(PRInt32) ZIP_ExtractFile( void* hZip, const char * filename, const char * outname );
/* Functions to list the files contained in the archive
*
* FindInit() initializes the search with the pattern, then FindNext() is
* called to get the matching filenames if any.
*
* a NULL pattern will find all the files in the archive, otherwise the
* pattern must be a shell regexp type pattern.
*
* if a matching filename is too small for the passed buffer FindNext()
* will return ZIP_ERR_SMALLBUF. When no more matches can be found in
* the archive it will return ZIP_ERR_FNF
*/
PR_EXTERN(PRInt32) ZIP_FindInit( void* hZip, const char * pattern );
PR_EXTERN(PRInt32) ZIP_FindNext( void* hZip, char * outbuf, PRUint16 bufsize );
PR_END_EXTERN_C
#endif /* _zipfile_h */

View File

@@ -0,0 +1,100 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All Rights
* Reserved.
*
* Contributors:
* Daniel Veditz <dveditz@netscape.com>
*/
#ifndef _zipstruct_h
#define _zipstruct_h
/*
* Certain constants and structures for
* the Phil Katz ZIP archive format.
*
*/
typedef struct ZipLocal_
{
unsigned char signature [4];
unsigned char word [2];
unsigned char bitflag [2];
unsigned char method [2];
unsigned char time [2];
unsigned char date [2];
unsigned char crc32 [4];
unsigned char size [4];
unsigned char orglen [4];
unsigned char filename_len [2];
unsigned char extrafield_len [2];
} ZipLocal;
typedef struct ZipCentral_
{
char signature [4];
char version_made_by [2];
char version [2];
char bitflag [2];
char method [2];
char time [2];
char date [2];
char crc32 [4];
char size [4];
char orglen [4];
char filename_len [2];
char extrafield_len [2];
char commentfield_len [2];
char diskstart_number [2];
char internal_attributes [2];
char external_attributes [4];
char localhdr_offset [4];
} ZipCentral;
typedef struct ZipEnd_
{
char signature [4];
char disk_nr [2];
char start_central_dir [2];
char total_entries_disk [2];
char total_entries_archive [2];
char central_dir_size [4];
char offset_central_dir [4];
char commentfield_len [2];
} ZipEnd;
/* signatures */
#define LOCALSIG 0x04034B50l
#define CENTRALSIG 0x02014B50l
#define ENDSIG 0x06054B50l
/* compression methods */
#define STORED 0
#define SHRUNK 1
#define REDUCED1 2
#define REDUCED2 3
#define REDUCED3 4
#define REDUCED4 5
#define IMPLODED 6
#define TOKENIZED 7
#define DEFLATED 8
#endif /* _zipstruct_h */

View File

@@ -1,9 +0,0 @@
libjar50.so
libjsdom.so
libmozjs.so
libnspr3.so
libplc3.so
libplds3.so
libxpcom.so
libxpinstall.so
libxpistub.so

View File

@@ -1,352 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape 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
* http://www.mozilla.org/NPL/
*
* 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 Communicator client code, released March
* 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#include "INSTALL.h"
static xpistub_t gstub;
int
main(int argc, char **argv)
{
int err = XI_OK;
xpi_t *pkglist;
ERR_CHECK( init() );
ERR_CHECK( build_list(&pkglist) );
ERR_CHECK( install_all(pkglist) );
ERR_CHECK( shutdown(pkglist) );
return err;
}
int
init()
{
nsresult rv = NS_OK;
char progdir[512];
int err = XI_OK;
DUMP("initialize");
err = extract_core();
if (err != XI_OK)
{
PRINT_ERR(err);
shutdown(NULL);
return err;
}
err = load_stub();
if (err != XI_OK)
{
PRINT_ERR(err);
shutdown(NULL);
return err;
}
getcwd(progdir, 512);
rv = gstub.fn_init(progdir, progress_callback);
if (NS_FAILED(rv))
{
PRINT_ERR(rv);
shutdown(NULL);
return XI_XPI_FAIL;
}
DUMP("XPI_Init called");
return err;
}
int
extract_core()
{
char cmd[256];
int i;
int err = XI_OK;
DUMP("extract_core");
for (i = 0; i < CORE_LIB_COUNT*2; i++)
{
strcpy(cmd, "unzip -j "); /* -j = junk paths; install here */
strcat(cmd, CORE_ARCHIVE); /* relative path to install.xpi */
strcat(cmd, " -d . "); /* -d = destination root */
strcat(cmd, core_libs[i]); /* archive subdir */
strcat(cmd, core_libs[++i]);/* lib file name */
strcat(cmd, "\0");
DUMP(cmd);
system(cmd);
}
return err;
}
int
load_stub()
{
char libpath[512];
char *dlerr;
int err = XI_OK;
DUMP("load_stub");
/* get the working dir and tack on lib name */
getcwd(libpath, 512);
strncat(libpath, "/", 1);
strncat(libpath, XPISTUB, strlen(XPISTUB));
DUMP(libpath);
/* open the library */
gstub.handle = NULL;
gstub.handle = dlopen(libpath, RTLD_NOW);
if (!gstub.handle)
{
dlerr = dlerror();
DUMP(dlerr);
return XI_LIB_OPEN;
}
DUMP("xpistub opened");
/* read and store symbol addresses */
gstub.fn_init = (pfnXPI_Init) dlsym(gstub.handle, FN_INIT);
gstub.fn_install = (pfnXPI_Install) dlsym(gstub.handle, FN_INSTALL);
gstub.fn_exit = (pfnXPI_Exit) dlsym(gstub.handle, FN_EXIT);
if (!gstub.fn_init || !gstub.fn_install || !gstub.fn_exit)
{
dlerr = dlerror();
DUMP(dlerr);
return XI_LIB_SYM;
}
return err;
}
void
progress_callback(const char* msg, PRInt32 max, PRInt32 val)
{
DUMP("progress_callback");
if (max == 0)
{
if (val > 0)
printf("Preparing item %d ...\n", val);
}
else
printf("Installing item %d of %d ...\n", val, max);
}
int
build_list(xpi_t **listhead)
{
xpi_t *currxpi = NULL, *lastxpi = NULL;
char mfpath[512];
char *buf = NULL, *pcurr, curr[32];
fpos_t mfeof;
FILE *fdmf;
size_t rd = 0;
int len = 0, total, head;
int err = XI_OK;
DUMP("build_list");
if (!listhead)
return XI_NULL_PTR;
*listhead = NULL;
/* XXX optionally set mf path in cmd line args */
strcpy(mfpath, MANIFEST);
/* open manifest file */
fdmf = NULL;
fdmf = fopen(mfpath, "r");
if (!fdmf)
{
err = XI_NO_MANIFEST;
goto bail;
}
DUMP("opened manifest");
/* read the file into a buffer */
if (fseek(fdmf, 0, SEEK_END) != 0)
{
err = XI_NO_MANIFEST;
goto bail;
}
if (fgetpos(fdmf, &mfeof) != 0)
{
err = XI_NO_MANIFEST;
goto bail;
}
DUMP("eof manifest found");
buf = (char*) malloc(mfeof * sizeof(char));
if (!buf)
{
err = XI_OUT_OF_MEM;
goto bail;
}
DUMP("malloc'd manifest buf");
if (fseek(fdmf, 0, SEEK_SET) != 0)
{
err = XI_NO_MANIFEST;
goto bail;
}
rd = fread( (void*)buf, 1, mfeof, fdmf);
if (!rd)
{
err = XI_NO_MANIFEST;
goto bail;
}
DUMP(buf);
/* loop over each line reading in a .xpi module
* name unless commented with ';'
*/
head = 1;
for (pcurr = buf, total = 0; total < mfeof; pcurr = strchr(pcurr, '\n')+1)
{
len = strchr(pcurr, '\n') - pcurr;
total += len + 1;
strncpy(curr, pcurr, len);
curr[ (len>32?32:len) ] = '\0';
/* malloc a new xpi structure */
currxpi = (xpi_t *) malloc(sizeof(xpi_t));
if (!currxpi)
{
err = XI_OUT_OF_MEM;
goto bail;
}
currxpi->next = NULL;
if (head)
{
*listhead = currxpi;
lastxpi = currxpi;
}
strncpy(currxpi->name, curr, (len>32?32:len));
/* link to xpi list */
if (!head && *listhead)
{
lastxpi->next = currxpi;
lastxpi = currxpi;
}
else
head = 0;
}
/* close manifest file */
fclose(fdmf);
return err;
bail:
if (buf)
free(buf);
shutdown(*listhead);
return err;
}
int
install_all(xpi_t *listhead)
{
xpi_t *curr = listhead;
int err = XI_OK;
DUMP("install_all");
if (!listhead)
return XI_NULL_PTR;
while (curr)
{
install_one(curr);
curr = curr->next;
}
return err;
}
int
install_one(xpi_t *pkg)
{
nsresult rv = NS_OK;
char xpipath[512];
int err = XI_OK;
DUMP("install_one");
getcwd(xpipath, 512);
strncat(xpipath, "/modules/", 9);
strncat(xpipath, pkg->name, strlen(pkg->name));
DUMP("--------- installing xpi package: ");
DUMP(xpipath);
DUMP("---------\n");
/* XXX check if file exists: if not skip it with status */
rv = gstub.fn_install(xpipath, "", 0);
if (NS_FAILED(rv))
{
err = XI_XPI_FAIL;
printf("ERROR %d: Installation of %s failed.\n", rv, pkg->name);
}
else
printf("Installed %s successfully.\n", pkg->name);
return err;
}
int
shutdown(xpi_t *list)
{
xpi_t *curr = list;
int i;
int err = XI_OK;
DUMP("shutdown");
/* release XPCOM and XPInstall */
if (gstub.fn_exit)
{
gstub.fn_exit();
DUMP("XPI_Exit called");
}
/* close xpistub library */
if (gstub.handle)
{
dlclose(gstub.handle);
DUMP("xpistub closed");
}
while (curr)
{
list = curr->next;
free(curr);
curr = list;
}
/* clean up extracted core libs */
for (i=1; i<CORE_LIB_COUNT*2; i+=2)
{
unlink(core_libs[i]);
}
return err;
}

View File

@@ -1,136 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape 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
* http://www.mozilla.org/NPL/
*
* 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 Communicator client code, released March
* 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _INSTALL_H_
#define _INSTALL_H_
#include "xpistub.h"
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
/*_____________________________________________ func ptrs __*/
typedef nsresult (*pfnXPI_Init) (const char *aProgramDir, pfnXPIProgress progressCB);
typedef nsresult (*pfnXPI_Install) (const char *file, const char *args, long flags);
typedef void (*pfnXPI_Exit) ();
/*________________________________________________ arrays __*/
#define CORE_LIB_COUNT 10
static char core_libs[CORE_LIB_COUNT*2][32] =
{
/* Archive Subdir File */
/* -------------- ---- */
"bin/", "libjsdom.so",
"bin/", "libmozjs.so",
"bin/", "libnspr3.so",
"bin/", "libplc3.so",
"bin/", "libplds3.so",
"bin/", "libxpcom.so",
"bin/", "libxpistub.so",
"bin/components/", "libxpinstall.so",
"bin/components/", "libjar50.so",
"bin/", "component.reg"
};
/*_______________________________________________ structs __*/
typedef struct _xpistub_t
{
const char *name;
void *handle;
pfnXPI_Init fn_init;
pfnXPI_Install fn_install;
pfnXPI_Exit fn_exit;
} xpistub_t;
typedef struct _xpi_t
{
char name[32];
struct _xpi_t *next;
} xpi_t;
/*_________________________________________________ funcs __*/
int main(int argc, char **argv);
int init();
int extract_core();
int load_stub();
void progress_callback(const char *msg, PRInt32 max, PRInt32 val);
int build_list(xpi_t **listhead);
int install_all(xpi_t *listhead);
int install_one(xpi_t *pkg);
int shutdown(xpi_t *list);
/*________________________________________________ macros __*/
#ifdef DEBUG_sgehani___
#define DUMP(_msg) \
printf("%s %d: ", __FILE__, __LINE__); \
printf(_msg); \
printf("\n");
#else
#define DUMP(_msg)
#endif
#define XPISTUB "libxpistub.so"
#define FN_INIT "XPI_Init"
#define FN_INSTALL "XPI_Install"
#define FN_EXIT "XPI_Exit"
#ifndef RTLD_NOW
#define RTLD_NOW 0
#endif
#ifndef NULL
#define NULL 0
#endif
#define CORE_ARCHIVE "modules/install.xpi"
#define MANIFEST "modules/MANIFEST"
#define ERR_CHECK(_func) \
{ \
int ret_err = XI_OK; \
ret_err = _func; \
if (ret_err != XI_OK) \
{ \
PRINT_ERR(ret_err); \
return ret_err; \
} \
}
#ifdef DEBUG_sgehani
#define PRINT_ERR(_err) \
printf("%s %d: err = %d \n", __FILE__, __LINE__, _err);
#endif
/*________________________________________________ errors __*/
#define XI_OK 0
#define XI_NULL_PTR -1
#define XI_OUT_OF_MEM -2
#define XI_FAIL -3
#define XI_LIB_OPEN -4
#define XI_LIB_SYM -5
#define XI_XPI_FAIL -6
#define XI_NO_MANIFEST -7
#endif /* _INSTALL_H_ */

View File

@@ -1,47 +0,0 @@
#
# The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
#
# 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 Communicator client code,
# released March 31, 1998.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Samir Gehani <sgehani@netscape.com>
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
PROGRAM = MozInstaller
CPPSRCS = \
nsXInstallerDlg.cpp \
nsComponent.cpp \
nsSetupType.cpp \
nsComponentList.cpp \
nsLicenseDlg.cpp \
nsWelcomeDlg.cpp \
nsSetupTypeDlg.cpp \
nsComponentsDlg.cpp \
nsInstallDlg.cpp \
nsXInstaller.cpp \
nsINIParser.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -1,51 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _XI_ERRORS_H_
#define _XI_ERRORS_H_
/*------------------------------------------------------------------*
* X Installer Errors
*------------------------------------------------------------------*/
enum
{
OK = 0,
E_MEM = -601, /* out of memory */
E_PARAM = -602, /* invalid param */
E_NO_MEMBER = -603 /* invalid member variable */
};
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#endif /* _XI_ERRORS_H_ */

View File

@@ -1,32 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _XILIMITS_H_
#define _XILIMITS_H_
#define MAX_COMPONENTS 64
#define MAX_SETUP_TYPES 32
#endif /* _XILIMITS_H_ */

View File

@@ -1,17 +0,0 @@
[section1]
key1=value_of_key1_of_section1
key2=value_of_key2_of_section1
[section2]
key1=value_of_key1_of_section2
; key2=commentvalue_of_key2_of_section2
key2=realvalue_of_key2_of_section2
; dhdks
; kjdsakjdas
[SetupType0]
Short Description=Browser
Long Description=This is the browser component.
Size=9090

View File

@@ -1,32 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef NULL
#define NULL 0
#endif
int
main(int arc, char **argv)
{
char *ftphost = "sweetlou";
char *file = "/products/server/README";
char *basename = "./README";
char *user = "test";
char *localhost = "test.com";
char *ftpcmds = malloc(1024);
sprintf(ftpcmds, "\
\
ftp -n %s <<EndFTP\n\
binary\n\
user anonymous %s@%s\n\
get %s %s\n\
EndFTP\n\
\
", ftphost, user, localhost, file, basename);
printf(ftpcmds);
system(ftpcmds);
return 0;
}

View File

@@ -1,240 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsComponent.h"
nsComponent::nsComponent() :
mDescShort(NULL),
mDescLong(NULL),
mArchive(NULL),
mSize(0),
mDependencies(NULL),
mAttributes(NO_ATTR)
{
}
nsComponent::~nsComponent()
{
if (mDescShort)
free (mDescShort);
if (mDescLong)
free (mDescLong);
if (mArchive)
free (mArchive);
if (mDependencies)
delete mDependencies;
}
int
nsComponent::SetDescShort(char *aDescShort)
{
if (!aDescShort)
return E_PARAM;
mDescShort = aDescShort;
return OK;
}
char *
nsComponent::GetDescShort()
{
if (mDescShort)
return mDescShort;
return NULL;
}
int
nsComponent::SetDescLong(char *aDescLong)
{
if (!aDescLong)
return E_PARAM;
mDescLong = aDescLong;
return OK;
}
char *
nsComponent::GetDescLong()
{
if (mDescLong)
return mDescLong;
return NULL;
}
int
nsComponent::SetArchive(char *aArchive)
{
if (!aArchive)
return E_PARAM;
mArchive = aArchive;
return OK;
}
char *
nsComponent::GetArchive()
{
if (mArchive)
return mArchive;
return NULL;
}
int
nsComponent::SetSize(int aSize)
{
mSize = aSize;
return OK;
}
int
nsComponent::GetSize()
{
if (mSize >= 0)
return mSize;
return 0;
}
int
nsComponent::AddDependency(nsComponent *aDependent)
{
if (!aDependent)
return E_PARAM;
if (!mDependencies)
mDependencies = new nsComponentList();
if (!mDependencies)
return E_MEM;
return mDependencies->AddComponent(aDependent);
}
int
nsComponent::RemoveDependency(nsComponent *aIndependent)
{
if (!aIndependent)
return E_PARAM;
if (!mDependencies)
return E_NO_MEMBER;
return mDependencies->RemoveComponent(aIndependent);
}
nsComponentList *
nsComponent::GetDependencies()
{
if (mDependencies)
return mDependencies;
return NULL;
}
int
nsComponent::SetSelected()
{
mAttributes |= nsComponent::SELECTED;
return OK;
}
int
nsComponent::SetUnselected()
{
if (IsSelected())
mAttributes &= ~nsComponent::SELECTED;
return OK;
}
int
nsComponent::IsSelected()
{
if (mAttributes & nsComponent::SELECTED)
return TRUE;
return FALSE;
}
int
nsComponent::SetInvisible()
{
mAttributes |= nsComponent::INVISIBLE;
return OK;
}
int
nsComponent::SetVisible()
{
if (IsInvisible())
mAttributes &= ~nsComponent::INVISIBLE;
return OK;
}
int
nsComponent::IsInvisible()
{
if (mAttributes & nsComponent::INVISIBLE)
return TRUE;
return FALSE;
}
int
nsComponent::SetNext(nsComponent *aComponent)
{
if (!aComponent)
return E_PARAM;
mNext = aComponent;
return OK;
}
int
nsComponent::InitNext()
{
mNext = NULL;
return OK;
}
nsComponent *
nsComponent::GetNext()
{
if (mNext)
return mNext;
return NULL;
}

View File

@@ -1,84 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_COMPONENT_H_
#define _NS_COMPONENT_H_
#include "XILimits.h"
#include "XIErrors.h"
#include <malloc.h>
#include "nsComponentList.h"
class nsComponent
{
public:
nsComponent();
~nsComponent();
/*--------------------------------------------------------------*
* Accessors/Mutators
*--------------------------------------------------------------*/
int SetDescShort(char *aDescShort);
char * GetDescShort();
int SetDescLong(char *aDescLong);
char * GetDescLong();
int SetArchive(char *aAcrhive);
char * GetArchive();
int SetSize(int aSize);
int GetSize();
int AddDependency(nsComponent *aDependent);
int RemoveDependency(nsComponent *aIndependent);
nsComponentList *GetDependencies();
int SetSelected();
int SetUnselected();
int IsSelected();
int SetInvisible();
int SetVisible();
int IsInvisible();
int SetNext(nsComponent *aComponent);
int InitNext();
nsComponent *GetNext();
/*---------------------------------------------------------------*
* Attributes
*---------------------------------------------------------------*/
enum
{
NO_ATTR = 0x00000000,
SELECTED = 0x00000001,
INVISIBLE = 0x00000010
};
private:
char *mDescShort;
char *mDescLong;
char *mArchive;
int mSize;
nsComponentList *mDependencies;
int mAttributes;
nsComponent *mNext;
};
#endif /* _NS_COMPONENT_H_ */

View File

@@ -1,149 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsComponentList.h"
#include "nsComponent.h"
nsComponentList::nsComponentList() :
mHead(NULL),
mTail(NULL),
mNext(NULL),
mLength(0)
{
}
nsComponentList::~nsComponentList()
{
nsComponent *curr = mHead;
nsComponent *next = NULL;
while (curr)
{
next = NULL;
next = curr->GetNext();
delete curr;
curr = next;
}
mHead = NULL;
mTail = NULL;
mLength = 0;
}
nsComponent *
nsComponentList::GetHead()
{
if (mHead)
{
mNext = mHead->GetNext();
return mHead;
}
return NULL;
}
nsComponent *
nsComponentList::GetNext()
{
nsComponent *curr = mNext;
if (mNext)
{
mNext = mNext->GetNext();
return curr;
}
return NULL;
}
nsComponent *
nsComponentList::GetTail()
{
if (mTail)
return mTail;
return NULL;
}
int
nsComponentList::AddComponent(nsComponent *aComponent)
{
if (!aComponent)
return E_PARAM;
// empty list: head and tail are the same -- the new comp
if (!mHead)
{
mHead = aComponent;
mHead->InitNext();
mTail = mHead;
return OK;
}
// non-empty list: the new comp is tacked on and tail is updated
mTail->SetNext(aComponent);
mTail = aComponent;
mTail->InitNext();
return OK;
}
int
nsComponentList::RemoveComponent(nsComponent *aComponent)
{
nsComponent *curr = GetHead();
nsComponent *last = NULL;
if (!aComponent)
return E_PARAM;
while (curr)
{
if (aComponent == curr)
{
// remove and link last to next while deleting current
if (last)
{
last->SetNext(curr->GetNext());
}
else
{
mHead = curr->GetNext();
if (mTail == curr)
mTail = NULL;
}
delete aComponent;
return OK;
}
else
{
// move on to next
last = curr;
curr = GetNext();
}
}
}

View File

@@ -1,96 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_COMPONENTLIST_H_
#define _NS_COMPONENTLIST_H_
#include "XIErrors.h"
class nsComponent;
class nsComponentList
{
public:
nsComponentList();
~nsComponentList();
/**
* GetHead
*
* Initializes the next ptr to the second item and
* returns the head item.
*
* @return mHead the head of the singly-linked list
*/
nsComponent * GetHead();
/**
* GetNext
*
* Returns the next available item. GetFirst() has to have
* been called prior calling this and after the last time
* the entire list was iterated over.
*
* @return mNext the next available component
*/
nsComponent * GetNext();
/**
* GetTail
*
* Returns the tail item of the list.
*
* @return mTail the tail item of the list
*/
nsComponent * GetTail();
/**
* AddComponent
*
* Adds the supplied component to the list's tail.
*
* @param aComponent the component to add
* @return err integer err code (zero means OK)
*/
int AddComponent(nsComponent *aComponent);
/**
* RemoveComponent
*
* Searches the list and removes the first component that
* matches the supplied component.
*
* @param aComponent the component to remove
* @return err integer error code (zero means OK)
*/
int RemoveComponent(nsComponent *aComponent);
private:
nsComponent *mHead;
nsComponent *mTail;
nsComponent *mNext;
int mLength;
};
#endif /* _NS_COMPONENTLIST_H_ */

View File

@@ -1,92 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsComponentsDlg.h"
nsComponentsDlg::nsComponentsDlg() :
mMsg0(NULL),
mCompList(NULL)
{
}
nsComponentsDlg::~nsComponentsDlg()
{
if (mMsg0)
free (mMsg0);
if (mCompList)
delete mCompList;
}
int
nsComponentsDlg::Back()
{
return OK;
}
int
nsComponentsDlg::Next()
{
return OK;
}
int
nsComponentsDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsComponentsDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}
int
nsComponentsDlg::SetCompList(nsComponentList *aCompList)
{
if (!aCompList)
return E_PARAM;
mCompList = aCompList;
return OK;
}
nsComponentList *
nsComponentsDlg::GetCompList()
{
if (mCompList)
return mCompList;
return NULL;
}

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_COMPONENTSDLG_H_
#define _NS_COMPONENTSDLG_H_
#include "XIErrors.h"
#include "nsXInstallerDlg.h"
#include "nsComponentList.h"
class nsComponentsDlg : public nsXInstallerDlg
{
public:
nsComponentsDlg();
~nsComponentsDlg();
/*--------------------------------------------------------------------*
* Navigation
*--------------------------------------------------------------------*/
int Back();
int Next();
/*--------------------------------------------------------------------*
* INI Properties
*--------------------------------------------------------------------*/
int SetMsg0(char *aMsg);
char *GetMsg0();
int SetCompList(nsComponentList *aCompList);
nsComponentList *GetCompList();
private:
char *mMsg0;
nsComponentList *mCompList;
};
#endif /* _NS_COMPONENTSDLG_H_ */

View File

@@ -1,265 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsINIParser.h"
nsINIParser::nsINIParser(char *aFilename)
{
FILE *fd = NULL;
fpos_t eofpos = (fpos_t) NULL;
int rd = 0;
mFileBuf = NULL;
mFileBufSize = 0;
mError = OK;
DUMP("nsINIParser");
/* param check */
if (!aFilename)
{
mError = E_PARAM;
return;
}
/* open the file */
fd = fopen(aFilename, "r");
if (!fd)
goto bail;
/* get file size */
if (fseek(fd, 0, SEEK_END) != 0)
goto bail;
if (fgetpos(fd, &eofpos) != 0)
goto bail;
/* malloc an internal buf the size of the file */
mFileBuf = (char *) malloc(eofpos * sizeof(char));
if (!mFileBuf)
{
mError = E_MEM;
return;
}
mFileBufSize = eofpos;
/* read the file in one swoop */
if (fseek(fd, 0, SEEK_SET) != 0)
goto bail;
rd = fread((void *)mFileBuf, 1, eofpos, fd);
if (!rd)
goto bail;
/* close file */
fclose(fd);
return;
bail:
mError = E_READ;
return;
}
nsINIParser::~nsINIParser()
{
DUMP("~nsINIParser");
}
int
nsINIParser::GetString( char *aSection, char *aKey,
char *aValBuf, int *aIOValBufSize )
{
char *secPtr = NULL;
mError = OK;
DUMP("GetString");
/* param check */
if ( !aSection || !aKey || !aValBuf ||
!aIOValBufSize || (*aIOValBufSize <= 0) )
return E_PARAM;
/* find the section if it exists */
mError = FindSection(aSection, &secPtr);
if (mError != OK)
return mError;
/* find the key if it exists in the valid section we found */
mError = FindKey(secPtr, aKey, aValBuf, aIOValBufSize);
return mError;
}
int
nsINIParser::GetStringAlloc( char *aSection, char *aKey,
char **aOutBuf, int *aOutBufSize )
{
char buf[MAX_VAL_SIZE];
int bufsize = MAX_VAL_SIZE;
mError = OK;
DUMP("GetStringAlloc");
mError = GetString(aSection, aKey, buf, &bufsize);
if (mError != OK)
return mError;
*aOutBuf = (char *) malloc(bufsize + 1);
strncpy(*aOutBuf, buf, bufsize);
strcat(*aOutBuf, "\0");
*aOutBufSize = bufsize + 1;
return mError;
}
int
nsINIParser::GetError()
{
DUMP("GetError");
return mError;
}
int
nsINIParser::FindSection(char *aSection, char **aOutSecPtr)
{
char *currChar = mFileBuf;
char *nextSec = NULL;
char *secClose = NULL;
char *nextNL = NULL;
mError = E_NO_SEC;
DUMP("FindSection");
// param check
if (!aSection || !aOutSecPtr)
{
mError = E_PARAM;
return mError;
}
while (currChar < (mFileBuf + mFileBufSize))
{
// look for first '['
nextSec = NULL;
nextSec = strchr(currChar, '[');
if (!nextSec)
break;
currChar = nextSec + 1;
// extract section name till first ']'
secClose = NULL; nextNL = NULL;
secClose = strchr(currChar, ']');
nextNL = strchr(currChar, NL);
if ((!nextNL) || (nextNL < secClose))
{
currChar = nextNL;
continue;
}
// if section name matches we succeeded
if (strncmp(aSection, currChar, secClose - currChar) == 0)
{
*aOutSecPtr = secClose + 1;
mError = OK;
break;
}
}
return mError;
}
int
nsINIParser::FindKey(char *aSecPtr, char *aKey, char *aVal, int *aIOValSize)
{
char *nextNL = NULL;
char *secEnd = NULL;
char *currLine = aSecPtr;
char *nextEq = NULL;
mError = E_NO_KEY;
DUMP("FindKey");
// param check
if (!aSecPtr || !aKey || !aVal || !aIOValSize || (*aIOValSize <= 0))
{
mError = E_PARAM;
return mError;
}
// determine the section end
secEnd = strchr(aSecPtr, '['); // search for next sec start
if (!secEnd)
{
secEnd = strchr(aSecPtr, '\0'); // else search for file end
if (!secEnd)
{
mError = E_SEC_CORRUPT; // else this data is corrupt
return mError;
}
}
while (currLine < secEnd)
{
nextNL = NULL;
nextNL = strchr(currLine, NL);
if (!nextNL)
nextNL = mFileBuf + mFileBufSize;
// ignore commented lines (starting with ;)
if (currLine == strchr(currLine, ';'))
{
currLine = nextNL + 1;
continue;
}
// extract key before '='
nextEq = NULL;
nextEq = strchr(currLine, '=');
if (!nextEq || nextEq > nextNL)
{
currLine = nextNL + 1;
continue;
}
// if key matches we succeeded
if (strncmp(currLine, aKey, nextEq - currLine) == 0)
{
// extract the value and return
if (*aIOValSize < nextNL - nextEq)
{
mError = E_SMALL_BUF;
*aVal = "\0";
*aIOValSize = 0;
return mError;
}
*aIOValSize = nextNL - nextEq;
strncpy(aVal, (nextEq + 1), *aIOValSize);
mError = OK;
return mError;
}
else
{
currLine = nextNL + 1;
}
}
return mError;
}

View File

@@ -1,128 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_INIPARSER_H_
#define _NS_INIPARSER_H_
#include <stdio.h>
#include <malloc.h>
#include <string.h>
class nsINIParser
{
public:
/**
* nsINIParser
*
* Construct a new INI parser for the file specified.
*
* @param aFilename path to INI file
*/
nsINIParser(char *aFilename);
~nsINIParser();
/**
* GetString
*
* Gets the value of the specified key in the specified section
* of the INI file represented by this instance. The value is stored
* in the supplied buffer. The buffer size is provided as input and
* the actual bytes used by the value is set in the in/out size param.
*
* @param aSection section name
* @param aKey key name
* @param aValBuf user supplied buffer
* @param aIOValBufSize buf size on input; actual buf used on output
*
* @return mError operation success code
*/
int GetString( char *aSection, char *aKey,
char *aValBuf, int *aIOValBufSize );
/**
* GetStringAlloc
*
* Same as GetString() except the buffer is allocated to the exact
* size of the value. Useful when the buffer is allocated everytime
* rather than reusing the same buffer when calling this function
* multiple times.
*
* @param aSection section name
* @param aKey key name
* @param aOutBuf buffer to be allocated
* @param aOutBufSize size of newly allocated buffer
*
* @return mError operation success code
*/
int GetStringAlloc( char *aSection, char *aKey,
char **aOutBuf, int *aOutBufSize );
/**
* GetError
*
* Exposes the last error on this instance. Useful for checking
* teh state of the object after construtcion since the INI file
* is parsed once at object-allocation time.
*
* @return mError last error on ops on this object
*/
int GetError();
/*--------------------------------------------------------------------*
* Errors
*--------------------------------------------------------------------*/
enum
{
OK = 0,
E_READ = -701,
E_MEM = -702,
E_PARAM = -703,
E_NO_SEC = -704,
E_NO_KEY = -705,
E_SEC_CORRUPT = -706,
E_SMALL_BUF = -707
};
private:
int FindSection(char *aSection, char **aOutSecPtr);
int FindKey(char *aSecPtr, char *aKey, char *aVal, int *aIOValSize);
char *mFileBuf;
int mFileBufSize;
int mError;
};
#define NL '\n'
#define MAX_VAL_SIZE 512
#ifdef DEBUG_druidd
#define DUMP(_msg) printf("%s %d: %s \n", __FILE__, __LINE__, _msg);
#else
#define DUMP(_msg)
#endif
#endif /*_NS_INIPARSER_H_ */

View File

@@ -1,68 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsInstallDlg.h"
nsInstallDlg::nsInstallDlg() :
mMsg0(NULL)
{
}
nsInstallDlg::~nsInstallDlg()
{
if (mMsg0)
free (mMsg0);
}
int
nsInstallDlg::Back()
{
return OK;
}
int
nsInstallDlg::Next()
{
return OK;
}
int
nsInstallDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsInstallDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}

View File

@@ -1,53 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_INSTALLDLG_H_
#define _NS_INSTALLDLG_H_
#include "nsXInstallerDlg.h"
#include "XIErrors.h"
class nsInstallDlg : public nsXInstallerDlg
{
public:
nsInstallDlg();
~nsInstallDlg();
/*------------------------------------------------------------------*
* Navigation
*------------------------------------------------------------------*/
int Back();
int Next();
/*------------------------------------------------------------------*
* INI Properties
*------------------------------------------------------------------*/
int SetMsg0(char *aMsg);
char *GetMsg0();
private:
char *mMsg0;
};
#endif /* _NS_INSTALLDLG_H_ */

View File

@@ -1,114 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsLicenseDlg.h"
nsLicenseDlg::nsLicenseDlg() :
mLicenseFile(NULL),
mMsg0(NULL),
mMsg1(NULL)
{
}
nsLicenseDlg::~nsLicenseDlg()
{
if (mLicenseFile)
free (mLicenseFile);
if (mMsg0)
free (mMsg0);
if (mMsg1)
free (mMsg1);
}
int
nsLicenseDlg::Back()
{
return OK;
}
int
nsLicenseDlg::Next()
{
return OK;
}
int
nsLicenseDlg::SetLicenseFile(char *aLicenseFile)
{
if (!aLicenseFile)
return E_PARAM;
aLicenseFile = mLicenseFile;
return OK;
}
char *
nsLicenseDlg::GetLicenseFile()
{
if (mLicenseFile)
return mLicenseFile;
return NULL;
}
int
nsLicenseDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsLicenseDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}
int
nsLicenseDlg::SetMsg1(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg1 = aMsg;
return OK;
}
char *
nsLicenseDlg::GetMsg1()
{
if (mMsg1)
return mMsg1;
return NULL;
}

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_LICENSEDLG_H_
#define _NS_LICENSEDLG_H_
#include "nsXInstallerDlg.h"
#include "XIErrors.h"
class nsLicenseDlg : public nsXInstallerDlg
{
public:
nsLicenseDlg();
~nsLicenseDlg();
/*-------------------------------------------------------------------*
* Navigation
*-------------------------------------------------------------------*/
int Back();
int Next();
/*-------------------------------------------------------------------*
* INI Properties
*-------------------------------------------------------------------*/
int SetLicenseFile(char *aLicenseFile);
char * GetLicenseFile();
int SetMsg0(char *aMsg);
char * GetMsg0();
int SetMsg1(char *aMsg);
char * GetMsg1();
private:
char *mLicenseFile;
char *mMsg0;
char *mMsg1;
};
#endif /* _NS_LICENSEDLG_H_ */

View File

@@ -1,139 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsSetupType.h"
nsSetupType::nsSetupType() :
mDescShort(NULL),
mDescLong(NULL),
mComponents(NULL),
mNext(NULL)
{
}
nsSetupType::~nsSetupType()
{
if (mDescShort)
free (mDescShort);
if (mDescLong)
free (mDescLong);
if (mComponents)
delete mComponents;
}
int
nsSetupType::SetDescShort(char *aDescShort)
{
if (!aDescShort)
return E_PARAM;
mDescShort = aDescShort;
return OK;
}
char *
nsSetupType::GetDescShort()
{
if (mDescShort)
return mDescShort;
return NULL;
}
int
nsSetupType::SetDescLong(char *aDescLong)
{
if (!aDescLong)
return E_PARAM;
mDescLong = aDescLong;
return OK;
}
char *
nsSetupType::GetDescLong()
{
if (mDescLong)
return mDescLong;
return NULL;
}
int
nsSetupType::SetComponent(nsComponent *aComponent)
{
if (!aComponent)
return E_PARAM;
if (!mComponents)
mComponents = new nsComponentList();
if (!mComponents)
return E_MEM;
return mComponents->AddComponent(aComponent);
}
int
nsSetupType::UnsetComponent(nsComponent *aComponent)
{
if (!aComponent)
return E_PARAM;
if (!mComponents)
return OK;
return mComponents->RemoveComponent(aComponent);
}
nsComponentList *
nsSetupType::GetComponents()
{
if (mComponents)
return mComponents;
return NULL;
}
int
nsSetupType::SetNext(nsSetupType *aSetupType)
{
if (!aSetupType)
return E_PARAM;
mNext = aSetupType;
return OK;
}
nsSetupType *
nsSetupType::GetNext()
{
if (mNext)
return mNext;
return NULL;
}

View File

@@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_SETUPTYPE_H_
#define _NS_SETUPTYPE_H_
#include "XILimits.h"
#include "XIErrors.h"
#include "nsComponent.h"
class nsComponentList;
class nsSetupType
{
public:
nsSetupType();
~nsSetupType();
/*--------------------------------------------------------------*
* Accessors/Mutators
*--------------------------------------------------------------*/
int SetDescShort(char *aDescShort);
char * GetDescShort();
int SetDescLong(char *aDescLong);
char * GetDescLong();
int SetComponent(nsComponent *aComponent);
int UnsetComponent(nsComponent *aComponent);
nsComponentList *GetComponents();
int SetNext(nsSetupType *aSetupType);
nsSetupType * GetNext();
private:
char *mDescShort;
char *mDescLong;
nsComponentList *mComponents;
nsSetupType *mNext;
};
#endif /* _NS_SETUPTYPE_H_ */

View File

@@ -1,103 +0,0 @@
#include "nsSetupTypeDlg.h"
nsSetupTypeDlg::nsSetupTypeDlg() :
mMsg0(NULL),
mSetupTypeList(NULL)
{
}
nsSetupTypeDlg::~nsSetupTypeDlg()
{
FreeSetupTypeList();
if (mMsg0)
free (mMsg0);
}
int
nsSetupTypeDlg::Back()
{
return OK;
}
int
nsSetupTypeDlg::Next()
{
return OK;
}
int
nsSetupTypeDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsSetupTypeDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}
int
nsSetupTypeDlg::AddSetupType(nsSetupType *aSetupType)
{
if (!aSetupType)
return E_PARAM;
if (!mSetupTypeList)
{
mSetupTypeList = aSetupType;
return OK;
}
nsSetupType *curr = mSetupTypeList;
nsSetupType *next;
while (curr)
{
next = NULL;
next = curr->GetNext();
if (!next)
{
return curr->SetNext(aSetupType);
}
curr = next;
}
return OK;
}
nsSetupType *
nsSetupTypeDlg::GetSetupTypeList()
{
if (mSetupTypeList)
return mSetupTypeList;
return NULL;
}
void
nsSetupTypeDlg::FreeSetupTypeList()
{
nsSetupType *curr = mSetupTypeList;
nsSetupType *prev;
while (curr)
{
prev = curr;
curr = curr->GetNext();
if (prev)
delete prev;
}
}

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_SETUPTYPEDLG_H_
#define _NS_SETUPTYPEDLG_H_
#include "nsXInstallerDlg.h"
#include "nsSetupType.h"
class nsSetupTypeDlg : public nsXInstallerDlg
{
public:
nsSetupTypeDlg();
~nsSetupTypeDlg();
/*---------------------------------------------------------------------*
* Navigation
*---------------------------------------------------------------------*/
int Back();
int Next();
/*---------------------------------------------------------------------*
* INI Properties
*---------------------------------------------------------------------*/
int SetMsg0(char *aMsg);
char *GetMsg0();
int AddSetupType(nsSetupType *aSetupType);
nsSetupType *GetSetupTypeList();
private:
void FreeSetupTypeList();
char *mMsg0;
nsSetupType *mSetupTypeList;
};
#endif /* _NS_SETUPTYPEDLG_H_ */

View File

@@ -1,137 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsWelcomeDlg.h"
nsWelcomeDlg::nsWelcomeDlg() :
mReadmeFile(NULL),
mMsg0(NULL),
mMsg1(NULL),
mMsg2(NULL)
{
}
nsWelcomeDlg::~nsWelcomeDlg()
{
if (mReadmeFile)
free (mReadmeFile);
if (mMsg0)
free (mMsg0);
if (mMsg1)
free (mMsg1);
if (mMsg2)
free (mMsg2);
}
int
nsWelcomeDlg::Back()
{
return OK;
}
int
nsWelcomeDlg::Next()
{
return OK;
}
int
nsWelcomeDlg::SetReadmeFile(char *aReadmeFile)
{
if (!aReadmeFile)
return E_PARAM;
mReadmeFile = aReadmeFile;
return OK;
}
char *
nsWelcomeDlg::GetReadmeFile()
{
if (mReadmeFile)
return mReadmeFile;
return NULL;
}
int
nsWelcomeDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsWelcomeDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}
int
nsWelcomeDlg::SetMsg1(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg1 = aMsg;
return OK;
}
char *
nsWelcomeDlg::GetMsg1()
{
if (mMsg1)
return mMsg1;
return NULL;
}
int
nsWelcomeDlg::SetMsg2(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg2 = aMsg;
return OK;
}
char *
nsWelcomeDlg::GetMsg2()
{
if (mMsg2)
return mMsg2;
return NULL;
}

View File

@@ -1,62 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_WELCOMEDLG_H_
#define _NS_WELCOMEDLG_H_
#include "nsXInstallerDlg.h"
#include "XIErrors.h"
class nsWelcomeDlg : public nsXInstallerDlg
{
public:
nsWelcomeDlg();
~nsWelcomeDlg();
/*--------------------------------------------------------------------*
* Navigation
*--------------------------------------------------------------------*/
int Back();
int Next();
/*--------------------------------------------------------------------*
* INI Properties
*--------------------------------------------------------------------*/
int SetReadmeFile(char *aReadmeFile);
char *GetReadmeFile();
int SetMsg0(char *aMsg);
char *GetMsg0();
int SetMsg1(char *aMsg);
char *GetMsg1();
int SetMsg2(char *aMsg);
char *GetMsg2();
private:
char *mReadmeFile;
char *mMsg0;
char *mMsg1;
char *mMsg2;
};
#endif /* _NS_WELCOMEDLG_H_ */

View File

@@ -1,126 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsXInstaller.h"
#include "nsINIParser.h"
#include "XIErrors.h"
nsXInstaller::nsXInstaller()
{
}
nsXInstaller::~nsXInstaller()
{
}
int
nsXInstaller::ParseConfig()
{
int err = OK;
nsINIParser *parser = new nsINIParser( CONFIG_INI );
char *bufalloc = NULL;
char buf[512];
int bufsize = 0;
if (!parser)
return E_MEM;
err = parser->GetError();
if (err != nsINIParser::OK)
return err;
bufsize = 512;
// err = parser->GetString("section2", "key2", buf, &bufsize);
err = parser->GetStringAlloc("section2", "key2", &bufalloc, &bufsize);
if ( (err == nsINIParser::OK) && (bufalloc) && (bufsize > 0) )
{
DUMP("section2 key2 = ");
DUMP(bufalloc);
}
return err;
}
int
nsXInstaller::Run()
{
int err = OK;
if ( (err = StartWizard()) != OK)
goto au_revoir;
if ( (err = Download()) != OK)
goto au_revoir;
if ( (err = Extract()) != OK)
goto au_revoir;
if ( (err = Install()) != OK)
goto au_revoir;
au_revoir:
return err;
}
int
nsXInstaller::StartWizard()
{
return OK;
}
int
nsXInstaller::Download()
{
return OK;
}
int
nsXInstaller::Extract()
{
return OK;
}
int
nsXInstaller::Install()
{
return OK;
}
int
main(int argc, char **argv)
{
nsXInstaller *installer = new nsXInstaller();
int err = OK;
if (installer)
{
if ( (err = installer->ParseConfig()) == OK)
err = installer->Run();
}
exit(err);
}

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_XINSTALLER_H_
#define _NS_XINSTALLER_H_
#include <stdio.h>
#include "XIErrors.h"
class nsXInstaller
{
public:
nsXInstaller();
~nsXInstaller();
int ParseConfig();
int Run();
private:
int StartWizard();
int Download();
int Extract();
int Install();
};
int main(int argc, char **argv);
#define CONFIG_INI "config.ini"
#ifdef DEBUG_druidd
#define DUMP(_msg) printf("%s %d: %s \n", __FILE__, __LINE__, _msg);
#else
#define DUMP(_msg)
#endif
#endif /*_NS_XINSTALLER_H_ */

View File

@@ -1,75 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsXInstallerDlg.h"
nsXInstallerDlg::nsXInstallerDlg() :
mShowDlg(nsXInstallerDlg::SHOW_DLG),
mTitle(NULL)
{
}
nsXInstallerDlg::~nsXInstallerDlg()
{
if (mTitle)
free (mTitle);
}
int
nsXInstallerDlg::SetShowDlg(int aShowDlg)
{
if ( aShowDlg != nsXInstallerDlg::SHOW_DLG &&
aShowDlg != nsXInstallerDlg::SKIP_DLG )
return E_PARAM;
mShowDlg = aShowDlg;
return OK;
}
int
nsXInstallerDlg::GetShowDlg()
{
return mShowDlg;
}
int
nsXInstallerDlg::SetTitle(char *aTitle)
{
if (!aTitle)
return E_PARAM;
mTitle = aTitle;
return OK;
}
char *
nsXInstallerDlg::GetTitle()
{
if (mTitle)
return mTitle;
return NULL;
}

View File

@@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_XINSTALLERDLG_H_
#define _NS_XINSTALLERDLG_H_
#include <malloc.h>
#include "XIErrors.h"
/**
* nsXInstallerDlg
*
* The interface for all installer dialogs. Helps maintain
* uniform navigation mechanism and UI widgets.
*/
class nsXInstallerDlg
{
public:
nsXInstallerDlg();
virtual ~nsXInstallerDlg();
/*-------------------------------------------------------------------*
* Navigation
*-------------------------------------------------------------------*/
virtual int Back() = 0;
virtual int Next() = 0;
/*-------------------------------------------------------------------*
* INI Properties
*-------------------------------------------------------------------*/
int SetShowDlg(int aShowDlg);
int GetShowDlg();
int SetTitle(char *aTitle);
char *GetTitle();
// TO DO
enum
{
SKIP_DLG = 0,
SHOW_DLG = 1
};
protected:
int mShowDlg;
char *mTitle;
};
#endif /* _NS_INSTALLERDLG_H_ */