Compare commits
14 Commits
feature_te
...
OJI_BRANCH
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a7fa35b7d | ||
|
|
a38f7d654e | ||
|
|
0bef9759d0 | ||
|
|
94e08348c8 | ||
|
|
be4eb6fdf9 | ||
|
|
5c55a671ab | ||
|
|
8aeee171a4 | ||
|
|
77f0906a43 | ||
|
|
9ad74acb71 | ||
|
|
ec80eb087b | ||
|
|
9b0fcb4228 | ||
|
|
362f4d14d6 | ||
|
|
bc4b919b8e | ||
|
|
3465460a1b |
248
CVSROOT/modules
248
CVSROOT/modules
@@ -1,248 +0,0 @@
|
||||
# Three different line formats are valid:
|
||||
# key -a aliases...
|
||||
# key [options] directory
|
||||
# key [options] directory files...
|
||||
#
|
||||
# Where "options" are composed of:
|
||||
# -i prog Run "prog" on "cvs commit" from top-level of module.
|
||||
# -o prog Run "prog" on "cvs checkout" of module.
|
||||
# -e prog Run "prog" on "cvs export" of module.
|
||||
# -t prog Run "prog" on "cvs rtag" of module.
|
||||
# -u prog Run "prog" on "cvs update" of module.
|
||||
# -d dir Place module in directory "dir" instead of module name.
|
||||
# -l Top-level directory only -- do not recurse.
|
||||
#
|
||||
# NOTE: If you change any of the "Run" options above, you'll have to
|
||||
# release and re-checkout any working directories of these modules.
|
||||
#
|
||||
# And "directory" is a path to a directory relative to $CVSROOT.
|
||||
#
|
||||
# The "-a" option specifies an alias. An alias is interpreted as if
|
||||
# everything on the right of the "-a" had been typed on the command line.
|
||||
#
|
||||
# You can encode a module within a module by using the special '&'
|
||||
# character to interpose another module into the current module. This
|
||||
# can be useful for creating a module that consists of many directories
|
||||
# spread out over the entire source repository.
|
||||
|
||||
ClientSourceProduct -a \
|
||||
ClientSourceProductWin \
|
||||
ClientSourceProductMac \
|
||||
ClientSourceProductUnix \
|
||||
|
||||
ClientSourceProductWin -a MozillaCommon MozillaWinOnly
|
||||
|
||||
ClientSourceProductMac -a MozillaCommon MozillaMacOnly
|
||||
|
||||
ClientSourceProductUnix -a MozillaCommon MozillaUnixOnly
|
||||
|
||||
MozillaCommon -a \
|
||||
ns/LEGAL \
|
||||
ns/LICENSE \
|
||||
ns/build \
|
||||
ns/include \
|
||||
ns/jpeg \
|
||||
ns/js \
|
||||
ns/lib/htmldlgs \
|
||||
ns/lib/layout \
|
||||
ns/lib/libcnv \
|
||||
ns/lib/libi18n \
|
||||
ns/lib/liblayer \
|
||||
ns/lib/libmisc \
|
||||
ns/lib/libmime \
|
||||
ns/lib/libmocha \
|
||||
ns/lib/libnet \
|
||||
ns/lib/libparse \
|
||||
ns/lib/libpics \
|
||||
ns/lib/libpwcac \
|
||||
ns/lib/libstyle \
|
||||
ns/lib/plugin \
|
||||
ns/lib/xlate \
|
||||
ns/lib/xp \
|
||||
ns/modules/edtplug/src \
|
||||
ns/modules/edtplug/include \
|
||||
ns/modules/libfont/classes \
|
||||
ns/modules/libfont/public \
|
||||
ns/modules/libfont/src \
|
||||
ns/modules/libhook \
|
||||
ns/modules/libimg \
|
||||
ns/modules/libpref \
|
||||
ns/modules/libreg \
|
||||
ns/modules/libutil \
|
||||
ns/modules/progress/src \
|
||||
ns/modules/rdf \
|
||||
ns/modules/schedulr \
|
||||
ns/modules/security/freenav \
|
||||
ns/modules/zlib/src \
|
||||
ns/nav-java/stubs \
|
||||
ns/nsprpub \
|
||||
ns/xpcom \
|
||||
ns/l10n \
|
||||
ns/nsprpub \
|
||||
ns/dbm \
|
||||
ns/modules/schedulr
|
||||
|
||||
MozillaWinOnly -a \
|
||||
ns/client.mak \
|
||||
ns/cmd/makefile.win \
|
||||
ns/cmd/wincom \
|
||||
ns/cmd/winfe \
|
||||
ns/config \
|
||||
ns/lib/makefile.win \
|
||||
ns/modules/coreincl \
|
||||
ns/modules/edtplug/makefile.win \
|
||||
ns/makefile.win \
|
||||
ns/modules/libfont/jmcgen \
|
||||
ns/modules/libfont/makefile.win \
|
||||
ns/modules/libfont/producers/makefile.win \
|
||||
ns/modules/libfont/producers/win \
|
||||
ns/modules/libfont/producers/win/classes \
|
||||
ns/modules/libfont/producers/win/classes/netscape \
|
||||
ns/modules/libfont/producers/win/classes/netscape/fonts \
|
||||
ns/modules/libfont/producers/win/src \
|
||||
ns/modules/makefile.win \
|
||||
ns/modules/progress/makefile.win \
|
||||
ns/modules/progress/public \
|
||||
ns/modules/security/makefile.win \
|
||||
ns/modules/zlib/makefile.win \
|
||||
ns/nav-java/makefile.win \
|
||||
JavaStubWin
|
||||
|
||||
|
||||
MozillaUnixOnly -a \
|
||||
ns/cmd/Makefile \
|
||||
ns/cmd/stubfe \
|
||||
ns/cmd/xfe \
|
||||
ns/config/.cvsignore \
|
||||
ns/config/AIX.mk \
|
||||
ns/config/BSD_OS.mk \
|
||||
ns/config/bsdecho.c \
|
||||
ns/config/bsdecho.c \
|
||||
ns/config/clobber_miss.pl \
|
||||
ns/config/clobber_miss.pl \
|
||||
ns/config/common.mk \
|
||||
ns/config/common.mk \
|
||||
ns/config/config.guess \
|
||||
ns/config/config.mk \
|
||||
ns/config/coreconf.mk \
|
||||
ns/config/coreconf.mk \
|
||||
ns/config/cvsco.pl \
|
||||
ns/config/cvsco.pl \
|
||||
ns/config/fastcwd.pl \
|
||||
ns/config/fastcwd.pl \
|
||||
ns/config/FreeBSD.mk \
|
||||
ns/config/gtscc.c \
|
||||
ns/config/HP-UX.mk \
|
||||
ns/config/IRIX.mk \
|
||||
ns/config/Linux.mk \
|
||||
ns/config/makecopy.c \
|
||||
ns/config/makecopy.c \
|
||||
ns/config/Makefile \
|
||||
ns/config/Makefile \
|
||||
ns/config/mangle.c \
|
||||
ns/config/mangle.c \
|
||||
ns/config/mantomak.c \
|
||||
ns/config/mantomak.c \
|
||||
ns/config/mkdepend \
|
||||
ns/config/NCR.mk \
|
||||
ns/config/NEC.mk \
|
||||
ns/config/NEWS-OS.mk \
|
||||
ns/config/NEXTSTEP.mk \
|
||||
ns/config/nfspwd.pl \
|
||||
ns/config/nfspwd.pl \
|
||||
ns/config/nodl.pl \
|
||||
ns/config/nodl.pl \
|
||||
ns/config/nsinstall.c \
|
||||
ns/config/nsinstall.c \
|
||||
ns/config/OSF1.mk \
|
||||
ns/config/outofdate.pl \
|
||||
ns/config/outofdate.pl \
|
||||
ns/config/pathsub.c \
|
||||
ns/config/pathsub.c \
|
||||
ns/config/pathsub.h \
|
||||
ns/config/pathsub.h \
|
||||
ns/config/pkg2dpth.pl \
|
||||
ns/config/pkg2dpth.pl \
|
||||
ns/config/ports \
|
||||
ns/config/revdepth.pl \
|
||||
ns/config/revdepth.pl \
|
||||
ns/config/Rhapsody.mk \
|
||||
ns/config/rules.mk \
|
||||
ns/config/SCOOS.mk \
|
||||
ns/config/SINIX.mk \
|
||||
ns/config/sj.pl \
|
||||
ns/config/sj.pl \
|
||||
ns/config/SunOS.mk \
|
||||
ns/config/SunOS4.mk \
|
||||
ns/config/SunOS5.mk \
|
||||
ns/config/UNIXWARE.mk \
|
||||
ns/config/xmversion.sh \
|
||||
ns/lib/Makefile \
|
||||
ns/Makefile \
|
||||
ns/modules/edtplug/Makefile \
|
||||
ns/modules/libfont/jmcgen \
|
||||
ns/modules/libfont/Makefile \
|
||||
ns/modules/libfont/producers/Makefile \
|
||||
ns/modules/Makefile \
|
||||
ns/modules/progress/Makefile \
|
||||
ns/modules/progress/public \
|
||||
ns/modules/security/Makefile \
|
||||
ns/modules/softupdt/Makefile \
|
||||
ns/modules/zlib/Makefile \
|
||||
ns/nav-java/Makefile \
|
||||
ns/lib/mariner \
|
||||
JavaStubUnix
|
||||
|
||||
|
||||
MozillaMacOnly -a \
|
||||
ns/cmd/macfe \
|
||||
ns/lib/mac/AutoAdmin \
|
||||
ns/lib/mac/Includes \
|
||||
ns/lib/mac/MacMemoryAllocator \
|
||||
ns/lib/mac/Misc \
|
||||
ns/lib/mac/MoreFiles \
|
||||
ns/lib/mac/NSRuntime \
|
||||
ns/lib/mac/NSStdLib \
|
||||
ns/lib/mac/patches \
|
||||
ns/lib/mac/PowerPlant \
|
||||
ns/lib/mac/UserInterface \
|
||||
ns/modules/coreincl \
|
||||
ns/modules/edtplug/classes \
|
||||
ns/modules/edtplug/macbuild \
|
||||
ns/modules/libfont/jmcgen/include \
|
||||
ns/modules/libfont/jmcgen/src \
|
||||
ns/modules/libfont/macbuild \
|
||||
ns/modules/progress/macbuild \
|
||||
ns/modules/progress/public \
|
||||
ns/modules/zlib/macbuild \
|
||||
ns/lib/mariner \
|
||||
JavaStubMac
|
||||
|
||||
JavaStubAll -a \
|
||||
JavaStubWin \
|
||||
JavaStubMac \
|
||||
JavaStubUnix
|
||||
|
||||
JavaStubCore -a \
|
||||
ns/sun-java/stubs/include \
|
||||
ns/sun-java/stubs/src
|
||||
|
||||
JavaStubMac -a \
|
||||
JavaStubCore \
|
||||
ns/sun-java/stubs/macbuild \
|
||||
ns/sun-java/stubs/macjri
|
||||
|
||||
JavaStubUnix -a \
|
||||
JavaStubCore \
|
||||
ns/sun-java/Makefile \
|
||||
ns/sun-java/stubs/jri \
|
||||
ns/sun-java/stubs/Makefile
|
||||
|
||||
JavaStubWin -a \
|
||||
JavaStubCore \
|
||||
ns/sun-java/makefile.win \
|
||||
ns/sun-java/stubs/jri \
|
||||
ns/sun-java/stubs/makefile.win
|
||||
|
||||
|
||||
|
||||
2516
mozilla/CHANGES.html
Normal file
2516
mozilla/CHANGES.html
Normal file
File diff suppressed because it is too large
Load Diff
50
mozilla/cmd/macfe/central/CSecureAttachment.cp
Normal file
50
mozilla/cmd/macfe/central/CSecureAttachment.cp
Normal file
@@ -0,0 +1,50 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
|
||||
// CSecureAttachment.cp
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CSecureAttachment.h"
|
||||
#include "xp_core.h"
|
||||
#include "secnav.h"
|
||||
#include "secrng.h"
|
||||
|
||||
CSecureAttachment::CSecureAttachment()
|
||||
: LAttachment(msg_Event)
|
||||
{
|
||||
mTickCounter = 0;
|
||||
}
|
||||
|
||||
|
||||
void CSecureAttachment::ExecuteSelf(
|
||||
MessageT inMessage,
|
||||
void *ioParam)
|
||||
{
|
||||
if (mTickCounter < 500)
|
||||
{
|
||||
EventRecord* theEvent = (EventRecord*)ioParam;
|
||||
RNG_RandomUpdate(theEvent, sizeof(EventRecord));
|
||||
long ticks = ::TickCount();
|
||||
RNG_RandomUpdate(&ticks, sizeof(long));
|
||||
mTickCounter++;
|
||||
}
|
||||
else
|
||||
delete this;
|
||||
}
|
||||
|
||||
4266
mozilla/cmd/macfe/central/uapp.cp
Normal file
4266
mozilla/cmd/macfe/central/uapp.cp
Normal file
File diff suppressed because it is too large
Load Diff
3875
mozilla/cmd/winfe/fegui.cpp
Executable file
3875
mozilla/cmd/winfe/fegui.cpp
Executable file
File diff suppressed because it is too large
Load Diff
2031
mozilla/cmd/winfe/nsapp.cpp
Normal file
2031
mozilla/cmd/winfe/nsapp.cpp
Normal file
File diff suppressed because it is too large
Load Diff
123
mozilla/cmd/winfe/stdafx.h
Normal file
123
mozilla/cmd/winfe/stdafx.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
|
||||
#ifndef STDAFX_PCH
|
||||
#define STDAFX_PCH
|
||||
|
||||
#define OEMRESOURCE
|
||||
|
||||
#if defined(DEBUG_blythe)
|
||||
// Set up a flag specific to WFE developers in the client
|
||||
#define DEBUG_WFE
|
||||
#endif
|
||||
|
||||
/* Very windows specific includes.
|
||||
*/
|
||||
/* MFC, KFC, RUN DMC, whatever */
|
||||
#include <afxwin.h>
|
||||
#include <afxext.h>
|
||||
#include <afxpriv.h>
|
||||
#include <afxole.h>
|
||||
#include <afxdisp.h>
|
||||
#include <afxodlgs.h>
|
||||
#ifdef _WIN32
|
||||
#include <afxcmn.h>
|
||||
#endif
|
||||
|
||||
/* More XP than anything */
|
||||
#include "xp.h"
|
||||
#include "fe_proto.h"
|
||||
#include "fe_rgn.h"
|
||||
#include "libi18n.h"
|
||||
#include "xlate.h"
|
||||
#include "ntypes.h"
|
||||
#ifdef EDITOR
|
||||
#include "edttypes.h"
|
||||
#endif
|
||||
#include "xpassert.h"
|
||||
#include "lo_ele.h"
|
||||
#include "layers.h"
|
||||
|
||||
/* Standard C includes */
|
||||
#ifndef _WIN32
|
||||
#include <dos.h>
|
||||
#endif
|
||||
#include <malloc.h>
|
||||
#include <direct.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#ifdef DEBUG
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* Very windows specific includes.
|
||||
*/
|
||||
/* WFE needs a layout file */
|
||||
extern "C" {
|
||||
#include "layout.h"
|
||||
}
|
||||
|
||||
/* Some common defines. */
|
||||
#ifndef _AFXDLL
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/* All front end forward declarations needed to compile. */
|
||||
#include "forward.h"
|
||||
|
||||
/* Front end Casting macros. */
|
||||
#include "cast.h"
|
||||
|
||||
/* General purpose utilities. */
|
||||
#include "feutil.h"
|
||||
|
||||
/* afxData/sysInfo */
|
||||
#include "sysinfo.h"
|
||||
|
||||
/* Some defines we like everywhere. */
|
||||
#include "resource.h"
|
||||
#include "defaults.h"
|
||||
|
||||
/* The application include and
|
||||
* Commonly used, rarely changed headers */
|
||||
#include "ncapiurl.h"
|
||||
#include "genedit.h"
|
||||
#include "genframe.h"
|
||||
#include "genview.h"
|
||||
#include "gendoc.h"
|
||||
#include "intlwin.h"
|
||||
#include "mozilla.h"
|
||||
#include "cxwin.h"
|
||||
#include "winproto.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert(x) ASSERT(x)
|
||||
#endif
|
||||
|
||||
#endif /* STDAFX_PCH */
|
||||
3284
mozilla/cmd/xfe/icons.c
Normal file
3284
mozilla/cmd/xfe/icons.c
Normal file
File diff suppressed because it is too large
Load Diff
5212
mozilla/cmd/xfe/mozilla.c
Normal file
5212
mozilla/cmd/xfe/mozilla.c
Normal file
File diff suppressed because it is too large
Load Diff
2654
mozilla/cmd/xfe/pref_helpers.c
Normal file
2654
mozilla/cmd/xfe/pref_helpers.c
Normal file
File diff suppressed because it is too large
Load Diff
874
mozilla/cmd/xfe/prefdialogs.c
Normal file
874
mozilla/cmd/xfe/prefdialogs.c
Normal file
@@ -0,0 +1,874 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
dialogs.c --- Preference dialogs.
|
||||
Created: Spence Murray <spence@netscape.com>, 30-Sep-95.
|
||||
*/
|
||||
|
||||
|
||||
#define PREFS_NET
|
||||
#define PREFS_SOCKS
|
||||
#define PREFS_DISK_CACHE
|
||||
#define PREFS_VERIFY
|
||||
#define PREFS_CLEAR_CACHE_BUTTONS
|
||||
#define PREFS_SIG
|
||||
#define PREFS_NEWS_MAX
|
||||
#define PREFS_8BIT
|
||||
/* #define PREFS_EMPTY_TRASH */
|
||||
/* #define PREFS_QUEUED_DELIVERY */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mozilla.h"
|
||||
#include "xlate.h"
|
||||
#include "xfe.h"
|
||||
#include "felocale.h"
|
||||
#include "nslocks.h"
|
||||
#include "secnav.h"
|
||||
#include "cert.h"
|
||||
#include "mozjava.h"
|
||||
#include "prnetdb.h"
|
||||
#include "e_kit.h"
|
||||
#include "pref_helpers.h"
|
||||
|
||||
#include "libmocha.h"
|
||||
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/CascadeBG.h>
|
||||
#include <Xm/PanedW.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
|
||||
#include <Xm/ArrowBG.h>
|
||||
|
||||
#ifndef _STDC_
|
||||
#define _STDC_ 1
|
||||
#define HACKED_STDC 1
|
||||
#endif
|
||||
|
||||
#include <XmL/Folder.h>
|
||||
|
||||
#ifdef HACKED_STDC
|
||||
#undef HACKED_STDC
|
||||
#undef _STDC_
|
||||
#endif
|
||||
|
||||
#include "msgcom.h"
|
||||
|
||||
#include "libimg.h" /* Image Library public API. */
|
||||
|
||||
|
||||
/* For sys_errlist and sys_nerr */
|
||||
#include <sys/errno.h>
|
||||
#if !defined(__FreeBSD__) && !defined(LINUX_GLIBC_2)
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
#endif
|
||||
|
||||
#include "prprf.h"
|
||||
#include "libi18n.h"
|
||||
#include "fonts.h"
|
||||
|
||||
|
||||
/* for XP_GetString() */
|
||||
#include <xpgetstr.h>
|
||||
extern int XFE_UNKNOWN_ERROR;
|
||||
|
||||
extern int XFE_FILE_DOES_NOT_EXIST;
|
||||
extern int XFE_FTP_PROXY_HOST;
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
extern int XFE_GLOBAL_MAILCAP_FILE;
|
||||
extern int XFE_GLOBAL_MIME_FILE;
|
||||
#endif
|
||||
extern int XFE_GOPHER_PROXY_HOST;
|
||||
extern int XFE_HOST_IS_UNKNOWN;
|
||||
extern int XFE_HTTPS_PROXY_HOST;
|
||||
extern int XFE_HTTP_PROXY_HOST;
|
||||
extern int XFE_NO_PORT_NUMBER;
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
extern int XFE_MAIL_HOST;
|
||||
extern int XFE_NEWS_HOST;
|
||||
extern int XFE_NEWS_RC_DIRECTORY;
|
||||
extern int XFE_PRIVATE_MAILCAP_FILE;
|
||||
extern int XFE_PRIVATE_MIME_FILE;
|
||||
#endif
|
||||
extern int XFE_SOCKS_HOST;
|
||||
extern int XFE_TEMP_DIRECTORY;
|
||||
extern int XFE_WAIS_PROXY_HOST;
|
||||
extern int XFE_WARNING;
|
||||
extern int XFE_ERROR_SAVING_OPTIONS;
|
||||
extern int XFE_GENERAL;
|
||||
extern int XFE_PASSWORDS;
|
||||
extern int XFE_PERSONAL_CERTIFICATES;
|
||||
extern int XFE_SITE_CERTIFICATES;
|
||||
extern int XFE_APPEARANCE;
|
||||
extern int XFE_BOOKMARKS;
|
||||
extern int XFE_COLORS;
|
||||
extern int XFE_FONTS;
|
||||
extern int XFE_APPLICATIONS;
|
||||
extern int XFE_HELPERS;
|
||||
extern int XFE_IMAGES;
|
||||
extern int XFE_LANGUAGES;
|
||||
extern int XFE_CACHE;
|
||||
extern int XFE_CONNECTIONS;
|
||||
extern int XFE_PROXIES;
|
||||
extern int XFE_PROTOCOLS;
|
||||
extern int XFE_LANG;
|
||||
extern int XFE_APPEARANCE;
|
||||
extern int XFE_COMPOSE_DLG;
|
||||
extern int XFE_SERVERS;
|
||||
extern int XFE_IDENTITY;
|
||||
extern int XFE_ORGANIZATION;
|
||||
extern int XFE_CHANGE_PASSWORD;
|
||||
extern int XFE_SET_PASSWORD;
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
extern int XFE_PRIVATE_MIMETYPE_RELOAD;
|
||||
extern int XFE_PRIVATE_MAILCAP_RELOAD;
|
||||
extern int XFE_PRIVATE_RELOADED_MIMETYPE;
|
||||
extern int XFE_PRIVATE_RELOADED_MAILCAP;
|
||||
#endif
|
||||
|
||||
extern void fe_installGeneralAppearance(void);
|
||||
extern void fe_installGeneralFonts(void);
|
||||
extern void fe_installGeneralColors(void);
|
||||
extern void fe_installGeneralAdvanced(void);
|
||||
extern void fe_installGeneralPasswd(void);
|
||||
extern void fe_installGeneralCache(void);
|
||||
extern void fe_installGeneralProxies(void);
|
||||
extern void fe_installBrowser(void);
|
||||
extern void fe_installBrowserAppl(void);
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
extern void fe_installMailNews(void);
|
||||
extern void fe_installMailNewsIdentity(void);
|
||||
extern void fe_installMailNewsComposition(void);
|
||||
extern void fe_installMailNewsMserver(void);
|
||||
extern void fe_installMailNewsNserver(void);
|
||||
extern void fe_installMailNewsAddrBook(void);
|
||||
extern void fe_installOfflineNews(void);
|
||||
extern void fe_installMserverMore(void);
|
||||
#endif
|
||||
extern void fe_installProxiesView(void);
|
||||
extern void fe_installDiskMore(void);
|
||||
extern void fe_installSslConfig(void);
|
||||
extern void fe_installOffline(void);
|
||||
extern void fe_installDiskSpace(void);
|
||||
|
||||
/* Preferences
|
||||
*/
|
||||
|
||||
struct fe_prefs_data
|
||||
{
|
||||
MWContext *context;
|
||||
|
||||
Widget shell, form;
|
||||
Widget promptDialog;
|
||||
|
||||
/*=== General prefs folder ===*/
|
||||
Widget general_form;
|
||||
|
||||
/* Appearance page */
|
||||
Widget styles1_selector, styles1_page;
|
||||
Widget icons_p, text_p, both_p, tips_p;
|
||||
Widget browser_p, mail_p, news_p;
|
||||
Widget blank_p, home_p, home_text;
|
||||
Widget underline_p;
|
||||
Widget expire_days_p, expire_days_text, never_expire_p;
|
||||
|
||||
/* Applications page */
|
||||
Widget apps_selector, apps_page;
|
||||
Widget tmp_text;
|
||||
Widget telnet_text, tn3270_text, rlogin_text, rlogin_user_text;
|
||||
|
||||
#if 0
|
||||
/* Bookmarks page */
|
||||
Widget bookmarks_selector, bookmarks_page;
|
||||
Widget book_text;
|
||||
#endif
|
||||
|
||||
/* Colors page */
|
||||
Widget colors_selector, colors_page;
|
||||
|
||||
/* Fonts page */
|
||||
Widget fonts_selector, fonts_page;
|
||||
Widget prop_family_pulldown, fixed_family_pulldown;
|
||||
Widget prop_family_option, fixed_family_option;
|
||||
Widget prop_size_pulldown, fixed_size_pulldown;
|
||||
Widget prop_size_option, fixed_size_option;
|
||||
Widget prop_size_field, fixed_size_field;
|
||||
Widget prop_size_toggle, fixed_size_toggle;
|
||||
int fonts_changed;
|
||||
|
||||
/* Helpers page */
|
||||
Widget helpers_selector, helpers_page;
|
||||
int helpers_changed;
|
||||
|
||||
struct fe_prefs_helpers_data *helpers;
|
||||
|
||||
/* Images page */
|
||||
Widget images_selector, images_page;
|
||||
Widget auto_p, dither_p, closest_p;
|
||||
Widget while_loading_p, after_loading_p;
|
||||
|
||||
/* Languages page */
|
||||
Widget languages_selector, languages_page;
|
||||
Widget lang_reg_avail, lang_reg_pref, lang_reg_text;
|
||||
Widget tmpDefaultButton;
|
||||
|
||||
/*=== Mail/News prefs folder ===*/
|
||||
Widget mailnews_form;
|
||||
|
||||
/* Appearance page */
|
||||
Widget appearance_selector, appearance_page;
|
||||
Widget fixed_message_font_p, var_message_font_p;
|
||||
Widget cite_plain_p, cite_bold_p, cite_italic_p, cite_bold_italic_p;
|
||||
Widget cite_normal_p, cite_bigger_p, cite_smaller_p;
|
||||
Widget cite_color_text;
|
||||
Widget mail_horiz_p, mail_vert_p, mail_stack_p;
|
||||
Widget news_horiz_p, news_vert_p, news_stack_p;
|
||||
Widget msgwin_use_mailwin_p, msgwin_use_new_p, msgwin_use_existing_p;
|
||||
|
||||
/* Compose page */
|
||||
Widget compose_selector, compose_page;
|
||||
Widget eightbit_toggle, qp_toggle;
|
||||
Widget deliverAuto_toggle, deliverQ_toggle;
|
||||
Widget mMailOutSelf_toggle, mMailOutOther_text;
|
||||
Widget nMailOutSelf_toggle, nMailOutOther_text;
|
||||
Widget mCopyOut_text;
|
||||
Widget nCopyOut_text;
|
||||
Widget autoquote_toggle;
|
||||
|
||||
/* Servers page */
|
||||
Widget dirs_selector, dirs_page;
|
||||
Widget srvr_text, user_text;
|
||||
Widget pop_toggle;
|
||||
Widget movemail_text;
|
||||
Widget external_toggle, builtin_toggle;
|
||||
Widget no_limit, msg_limit, limit_text;
|
||||
Widget msg_remove, msg_leave;
|
||||
Widget check_every, check_never, check_text;
|
||||
Widget smtp_text, maildir_text;
|
||||
Widget newshost_text, newsrc_text, newsmax_text;
|
||||
|
||||
/* Identity page */
|
||||
Widget identity_selector, identity_page;
|
||||
Widget user_name_text, user_mail_text, user_org_text, user_sig_text;
|
||||
|
||||
/* Organization page */
|
||||
Widget organization_selector, organization_page;
|
||||
Widget emptyTrash_toggle, rememberPswd_toggle;
|
||||
Widget threadmail_toggle, threadnews_toggle;
|
||||
Widget mdate_toggle, mnum_toggle, msubject_toggle, msender_toggle;
|
||||
Widget ndate_toggle, nnum_toggle, nsubject_toggle, nsender_toggle;
|
||||
|
||||
/*=== Network prefs folder ===*/
|
||||
Widget network_form;
|
||||
|
||||
/* Cache page */
|
||||
Widget cache_selector, cache_page;
|
||||
Widget memory_text, memory_clear;
|
||||
Widget disk_text, disk_dir, disk_clear;
|
||||
Widget verify_label, once_p, every_p, expired_p;
|
||||
Widget cache_ssl_p;
|
||||
|
||||
/* Nework page */
|
||||
Widget network_selector, network_page;
|
||||
Widget buf_label, buf_text;
|
||||
Widget conn_label, conn_text;
|
||||
|
||||
/* Proxies page */
|
||||
Widget proxies_selector, proxies_page;
|
||||
Widget no_proxies_p, manual_p, manual_browse;
|
||||
Widget auto_proxies_p, proxy_label, proxy_text;
|
||||
Widget proxy_reload;
|
||||
|
||||
Widget ftp_text, ftp_port;
|
||||
Widget gopher_text, gopher_port;
|
||||
Widget http_text, http_port;
|
||||
Widget https_text, https_port;
|
||||
Widget wais_text, wais_port;
|
||||
Widget no_text;
|
||||
Widget socks_text, socks_port;
|
||||
|
||||
/* Protocols page */
|
||||
Widget protocols_selector, protocols_page;
|
||||
Widget cookie_p; /* Show alert before accepting a cookie */
|
||||
Widget anon_ftp_p; /* Use email address for anon ftp */
|
||||
Widget email_form_p; /* Show alert before submiting a form by email */
|
||||
|
||||
/* Languages page */
|
||||
Widget lang_selector, lang_page;
|
||||
#ifdef JAVA
|
||||
Widget java_toggle;
|
||||
#endif
|
||||
|
||||
Widget javascript_toggle;
|
||||
|
||||
/*=== Security prefs folder ===*/
|
||||
Widget security_form;
|
||||
|
||||
/* General Security page */
|
||||
Widget sec_general_selector, sec_general_page;
|
||||
Widget enter_toggle, leave_toggle, mixed_toggle, submit_toggle;
|
||||
Widget ssl2_toggle, ssl3_toggle;
|
||||
|
||||
/* Security Passwords page */
|
||||
Widget sec_passwords_selector, sec_passwords_page;
|
||||
Widget once_toggle, every_toggle, periodic_toggle;
|
||||
Widget periodic_text, change_password;
|
||||
#ifdef FORTEZZA
|
||||
Widget fortezza_toggle, fortezza_timeout;
|
||||
#endif
|
||||
|
||||
/* Personal Certificates page */
|
||||
Widget personal_selector, personal_page;
|
||||
Widget pers_list, pers_info, pers_delete_cert, pers_new_cert;
|
||||
Widget site_default, pers_label;
|
||||
Widget pers_cert_menu;
|
||||
char *deleted_user_cert;
|
||||
|
||||
/* Site Certificates page */
|
||||
Widget site_selector, site_page;
|
||||
Widget all_list, all_edit_cert, all_delete_cert;
|
||||
Widget all_label;
|
||||
char *deleted_site_cert;
|
||||
};
|
||||
|
||||
void
|
||||
FE_SetPasswordAskPrefs(MWContext *context, int askPW, int timeout)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FE_SetPasswordEnabled(MWContext *context, PRBool usePW)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fe_MarkHelpersModified(MWContext *context)
|
||||
{
|
||||
/* Mark that the helpers have been modified. We need this
|
||||
* to detect if we need to save/reload all these helpers.
|
||||
* For doing this, the condition we adopt is
|
||||
* (1) User clicked on 'OK' button for the Edit Helpers Dialog
|
||||
* This also covers the "New" case as the same Dialog
|
||||
* is shown for the "New" and "Edit".
|
||||
* (2) User deleted a mime/type and confirmed it.
|
||||
*/
|
||||
if (context && CONTEXT_DATA(context)->fep)
|
||||
CONTEXT_DATA(context)->fep->helpers_changed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
const char *multiline_continuator = "\t\t\n";
|
||||
/*
|
||||
* This belongs in a utility module
|
||||
*
|
||||
* Convert an array of strings
|
||||
* to multiline string (embedded new-lines)
|
||||
*
|
||||
* returns a string built up from the array
|
||||
*
|
||||
* The caller must free the array
|
||||
*/
|
||||
char *
|
||||
array_to_multiline_str(char **array, int cnt)
|
||||
{
|
||||
char *mstring, *p;
|
||||
int i, str_len;
|
||||
|
||||
/*
|
||||
* Handle an empty array
|
||||
*/
|
||||
if (cnt == 0) {
|
||||
/* always allocate an array so the caller can free it */
|
||||
mstring = strdup("\n");
|
||||
return mstring;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the length of the multiline string
|
||||
*/
|
||||
str_len = 0;
|
||||
for (i=0; i<cnt; i++) {
|
||||
if (i != 0)
|
||||
str_len += strlen(multiline_continuator);
|
||||
str_len += strlen(array[i]);
|
||||
}
|
||||
str_len += 2; /* space for new-line and terminator */
|
||||
mstring = (char *)XP_ALLOC(str_len);
|
||||
|
||||
for (p=mstring, i=0; i<cnt; i++) {
|
||||
if (i != 0) {
|
||||
strcpy(p, multiline_continuator);
|
||||
p += strlen(multiline_continuator);
|
||||
}
|
||||
strcpy(p, array[i]);
|
||||
p += strlen(array[i]);
|
||||
}
|
||||
/*
|
||||
* Note: don't add a final line-feed for multiline
|
||||
* as the prefs_write_string() function handles it funny
|
||||
*/
|
||||
return mstring;
|
||||
}
|
||||
|
||||
/*
|
||||
* This belongs in a utility module
|
||||
*
|
||||
* Convert an array of strings
|
||||
* to multiline preference (embedded new-lines)
|
||||
*
|
||||
* returns a preference value string built up from the array
|
||||
*
|
||||
* The caller must free the array
|
||||
*/
|
||||
char *
|
||||
array_to_multiline_pref(char **array, int cnt)
|
||||
{
|
||||
char *string;
|
||||
string = array_to_multiline_str(array, cnt);
|
||||
return string;
|
||||
}
|
||||
|
||||
/*
|
||||
* This belongs in a utility module
|
||||
*
|
||||
* Convert a multiline string (embedded new-lines)
|
||||
* to an array of strings
|
||||
* create the array
|
||||
* copies the lines into the array
|
||||
* returns length of the array
|
||||
*
|
||||
* To free the array:
|
||||
* for (i=0; i<cnt; i++)
|
||||
* XP_FREE(array[i]);
|
||||
* XP_FREE(array);
|
||||
*/
|
||||
int
|
||||
multiline_str_to_array(const char *string, char ***array_p)
|
||||
{
|
||||
char *p, *q, **array;
|
||||
int i, cnt, len;
|
||||
Boolean at_start_of_line;
|
||||
|
||||
/* handle null string */
|
||||
if (string == NULL) {
|
||||
/* always allocate an array so the caller can free it */
|
||||
array = (char **)XP_ALLOC(sizeof(char *));
|
||||
array[0] = NULL;
|
||||
*array_p = array;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* count the number of lines
|
||||
* (count beginnings so we will count any last line without a '\n')
|
||||
* This supports multibyte text only because '\n' is less than 0x40
|
||||
*/
|
||||
cnt = 0;
|
||||
at_start_of_line = True;
|
||||
for (p=(char *)string; *p; p++) {
|
||||
if (at_start_of_line) {
|
||||
cnt += 1;
|
||||
at_start_of_line = False;
|
||||
}
|
||||
if (*p == '\n') {
|
||||
at_start_of_line = True;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy lines into the array */
|
||||
array = (char **)XP_ALLOC((cnt+1) * sizeof(char *));
|
||||
i = 0;
|
||||
len = 0;
|
||||
for (p=q=(char *)string; *p; p++) {
|
||||
if (*p == '\n') {
|
||||
array[i] = (char *)XP_ALLOC(len+1);
|
||||
strncpy(array[i], q, len);
|
||||
/* add a string terminator */
|
||||
array[i][len] = '\0';
|
||||
i += 1;
|
||||
len = 0;
|
||||
q = p + 1;
|
||||
}
|
||||
else
|
||||
len += 1;
|
||||
}
|
||||
if (len) { /* include ending chars with no newline */
|
||||
array[i] = (char *)XP_ALLOC(len+1);
|
||||
strncpy(array[i], q, len);
|
||||
/* add a string terminator */
|
||||
array[i][len] = '\0';
|
||||
}
|
||||
|
||||
*array_p = array;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/*
|
||||
* This belongs in a utility module
|
||||
*
|
||||
* Convert a multiline preference (embedded new-lines)
|
||||
* to an array of strings
|
||||
* create the array
|
||||
* copies the lines into the array
|
||||
* remove leading/trailing white space
|
||||
* remove blank lines
|
||||
* returns length of the array
|
||||
*
|
||||
* To free the array:
|
||||
* for (i=0; i<cnt; i++)
|
||||
* XP_FREE(array[i]);
|
||||
* XP_FREE(array);
|
||||
*/
|
||||
int
|
||||
multiline_pref_to_array(const char *string, char ***array_p)
|
||||
{
|
||||
int i, j, cnt;
|
||||
char **array;
|
||||
|
||||
/*
|
||||
* Convert the multiline string to an array
|
||||
* (with leading/trailing white space and blank lines)
|
||||
*/
|
||||
cnt = multiline_str_to_array(string, array_p);
|
||||
|
||||
/*
|
||||
* trim any leading/training white space
|
||||
*/
|
||||
array = *array_p;
|
||||
for (i=0; i<cnt; i++) {
|
||||
char *tmp;
|
||||
tmp = XP_StripLine(array[i]);
|
||||
/* we can't lose the malloc address else free will fail */
|
||||
/* so if there was white space at the beginning we make a copy */
|
||||
if (tmp != array[i]) {
|
||||
char *tmp2 = array[i];
|
||||
array[i] = strdup(tmp);
|
||||
XP_FREE(tmp2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* remove any blank lines
|
||||
*/
|
||||
for (i=0; i<cnt; i++) {
|
||||
if (array[i][0] == '\0') {
|
||||
XP_FREE(array[i]);
|
||||
for (j=i+1; j<cnt; j++)
|
||||
array[j-1] = array[j];
|
||||
cnt -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
IL_DitherMode
|
||||
fe_pref_string_to_dither_mode (char *s)
|
||||
{
|
||||
if (!XP_STRCASECMP(s, "True") || !XP_STRCASECMP(s, "Dither"))
|
||||
return IL_Dither;
|
||||
else if (!XP_STRCASECMP(s, "False") || !XP_STRCASECMP(s, "ClosestColor"))
|
||||
return IL_ClosestColor;
|
||||
|
||||
/* In the absence of a reasonable value, dithering is auto-selected */
|
||||
return IL_Auto;
|
||||
}
|
||||
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
void
|
||||
fe_SetMailNewsSortBehavior(MWContext* context, XP_Bool thread, int sortcode)
|
||||
{
|
||||
XP_ASSERT(context->type == MWContextMail || context->type == MWContextNews);
|
||||
if (context->type == MWContextMail || context->type == MWContextNews) {
|
||||
if (thread) {
|
||||
MSG_SetToggleStatus(ACTIVE_MAILTAB(context)->threadpane, MSG_SortByThread, NULL, 0,
|
||||
thread ? MSG_Checked : MSG_Unchecked);
|
||||
} else {
|
||||
switch (sortcode) {
|
||||
case 0:
|
||||
MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortByDate, NULL, 0);
|
||||
break;
|
||||
case 1:
|
||||
MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortByMessageNumber, NULL, 0);
|
||||
break;
|
||||
case 2:
|
||||
MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortBySubject, NULL, 0);
|
||||
break;
|
||||
case 3:
|
||||
MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortBySender, NULL, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
fe_InstallPreferences (MWContext *context)
|
||||
{
|
||||
/* This function is called from main() */
|
||||
|
||||
fe_installGeneralAppearance();
|
||||
fe_installGeneralFonts();
|
||||
fe_installGeneralColors();
|
||||
fe_installGeneralAdvanced();
|
||||
fe_installGeneralPasswd();
|
||||
fe_installGeneralCache();
|
||||
fe_installGeneralProxies();
|
||||
fe_installDiskSpace();
|
||||
|
||||
fe_installBrowser();
|
||||
fe_installBrowserAppl();
|
||||
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
fe_installMailNews();
|
||||
fe_installMailNewsIdentity();
|
||||
fe_installMailNewsComposition();
|
||||
fe_installMailNewsMserver();
|
||||
fe_installMailNewsNserver();
|
||||
fe_installMailNewsAddrBook();
|
||||
#endif
|
||||
|
||||
fe_installOffline();
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
fe_installOfflineNews();
|
||||
fe_installMserverMore();
|
||||
#endif
|
||||
|
||||
fe_installProxiesView();
|
||||
fe_installSslConfig();
|
||||
fe_installDiskMore();
|
||||
|
||||
/* CACHE
|
||||
*/
|
||||
|
||||
/* spider begin */
|
||||
FE_SARCacheDir = fe_globalPrefs.sar_cache_dir ;
|
||||
/* spider end */
|
||||
NET_DontDiskCacheSSL(!fe_globalPrefs.cache_ssl_p);
|
||||
|
||||
/* bookmark_file
|
||||
*/
|
||||
|
||||
FE_GlobalHist = fe_globalPrefs.history_file;
|
||||
|
||||
/* NETWORK
|
||||
*/
|
||||
|
||||
NET_ChangeMaxNumberOfConnections (50);
|
||||
NET_ChangeMaxNumberOfConnectionsPerContext (fe_globalPrefs.max_connections);
|
||||
/* The unit for tcp buffer size is changed from kbyes to btyes */
|
||||
NET_ChangeSocketBufferSize (fe_globalPrefs.network_buffer_size);
|
||||
|
||||
/* NEWS
|
||||
*/
|
||||
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
NET_SetNumberOfNewsArticlesInListing (fe_globalPrefs.news_max_articles);
|
||||
NET_SetCacheXOVER (fe_globalPrefs.news_cache_xover);
|
||||
#endif
|
||||
|
||||
/* PROTOCOLS
|
||||
*/
|
||||
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
NET_WarnOnMailtoPost(fe_globalPrefs.email_submit);
|
||||
#endif
|
||||
|
||||
#ifdef FORTEZZA
|
||||
if (fe_globalPrefs.fortezza_toggle) {
|
||||
int timeout = fe_globalPrefs.fortezza_timeout;
|
||||
/* '0' minute timeout because 1 minute... still pretty darn fast */
|
||||
FortezzaSetTimeout(timeout ? timeout : 1);
|
||||
} else {
|
||||
FortezzaSetTimeout(0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
fe_GeneralPrefsDialog (MWContext *context)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
fe_MailNewsPrefsDialog (MWContext *context)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
fe_NetworkPrefsDialog (MWContext *context)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
fe_SecurityPrefsDialog (MWContext *context)
|
||||
{
|
||||
}
|
||||
|
||||
/* spider begin */
|
||||
void
|
||||
fe_VerifyDiskCache (MWContext *context)
|
||||
{
|
||||
|
||||
#ifdef PREFS_DISK_CACHE
|
||||
|
||||
static Boolean done = False;
|
||||
if (done) return;
|
||||
done = True;
|
||||
|
||||
if (fe_globalPrefs.disk_cache_size <= 0)
|
||||
return;
|
||||
|
||||
fe_VerifyDiskCacheExistence(context, fe_globalPrefs.cache_dir) ;
|
||||
|
||||
#endif /* PREFS_DISK_CACHE */
|
||||
|
||||
#ifdef PREFS_OLD_WAY
|
||||
#ifdef PREFS_DISK_CACHE
|
||||
struct stat st;
|
||||
char file [1024];
|
||||
char message [4000];
|
||||
static Boolean done = False;
|
||||
if (done) return;
|
||||
done = True;
|
||||
|
||||
if (fe_globalPrefs.disk_cache_size <= 0)
|
||||
return;
|
||||
|
||||
strcpy (file, fe_globalPrefs.cache_dir);
|
||||
if (file [strlen (file) - 1] == '/')
|
||||
file [strlen (file) - 1] = 0;
|
||||
|
||||
if (stat (file, &st))
|
||||
{
|
||||
/* Doesn't exist - try to create it. */
|
||||
if (mkdir (file, 0700))
|
||||
{
|
||||
/* Failed. */
|
||||
char *error = ((errno >= 0 && errno < sys_nerr)
|
||||
? sys_errlist [errno]
|
||||
: XP_GetString( XFE_UNKNOWN_ERROR));
|
||||
PR_snprintf (message, sizeof (message),
|
||||
fe_globalData.create_cache_dir_message,
|
||||
file, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Suceeded. */
|
||||
PR_snprintf (message, sizeof (message),
|
||||
fe_globalData.created_cache_dir_message, file);
|
||||
}
|
||||
}
|
||||
else if (! (st.st_mode & S_IFDIR))
|
||||
{
|
||||
/* Exists but isn't a directory. */
|
||||
PR_snprintf (message, sizeof (message),
|
||||
fe_globalData.cache_not_dir_message, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The disk cache is ok! */
|
||||
*message = 0;
|
||||
}
|
||||
|
||||
if (*message)
|
||||
{
|
||||
PR_snprintf(message + strlen (message), sizeof (message),
|
||||
fe_globalData.cache_suffix_message,
|
||||
fe_globalPrefs.disk_cache_size, fe_progclass);
|
||||
FE_Alert (context, message);
|
||||
}
|
||||
#endif /* PREFS_DISK_CACHE */
|
||||
#endif /* PREFS_OLD_WAY */
|
||||
}
|
||||
|
||||
void
|
||||
fe_VerifySARDiskCache (MWContext *context)
|
||||
{
|
||||
|
||||
#ifdef PREFS_DISK_CACHE
|
||||
|
||||
fe_VerifyDiskCacheExistence(context, fe_globalPrefs.sar_cache_dir) ;
|
||||
|
||||
#endif /* PREFS_DISK_CACHE */
|
||||
}
|
||||
|
||||
void
|
||||
fe_VerifyDiskCacheExistence (MWContext *context, char * cache_directory)
|
||||
{
|
||||
|
||||
#ifdef PREFS_DISK_CACHE
|
||||
struct stat st;
|
||||
char file [1024];
|
||||
char message [4000];
|
||||
|
||||
if (!cache_directory)
|
||||
return ;
|
||||
|
||||
strcpy (file, cache_directory);
|
||||
if (file [strlen (file) - 1] == '/')
|
||||
file [strlen (file) - 1] = 0;
|
||||
|
||||
if (stat (file, &st))
|
||||
{
|
||||
/* Doesn't exist - try to create it. */
|
||||
if (mkdir (file, 0700))
|
||||
{
|
||||
/* Failed. */
|
||||
char *error = ((errno >= 0 && errno < sys_nerr)
|
||||
? sys_errlist [errno]
|
||||
: XP_GetString( XFE_UNKNOWN_ERROR));
|
||||
PR_snprintf (message, sizeof (message),
|
||||
fe_globalData.create_cache_dir_message,
|
||||
file, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Suceeded. */
|
||||
PR_snprintf (message, sizeof (message),
|
||||
fe_globalData.created_cache_dir_message, file);
|
||||
}
|
||||
}
|
||||
else if (! (st.st_mode & S_IFDIR))
|
||||
{
|
||||
/* Exists but isn't a directory. */
|
||||
PR_snprintf (message, sizeof (message),
|
||||
fe_globalData.cache_not_dir_message, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The disk cache is ok! */
|
||||
*message = 0;
|
||||
}
|
||||
|
||||
if (*message)
|
||||
{
|
||||
PR_snprintf(message + strlen (message), sizeof (message),
|
||||
fe_globalData.cache_suffix_message,
|
||||
fe_globalPrefs.disk_cache_size, fe_progclass);
|
||||
FE_Alert (context, message);
|
||||
}
|
||||
#endif /* PREFS_DISK_CACHE */
|
||||
}
|
||||
|
||||
/* spider end */
|
||||
|
||||
@@ -382,6 +382,12 @@ MOZILLA_CLIENT = 1
|
||||
DEFINES += -DMOZILLA_CLIENT
|
||||
endif
|
||||
|
||||
ifdef MOZ_JAVA
|
||||
ifdef NO_SECURITY
|
||||
DEFINES += -DNO_SECURITY
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_LITE
|
||||
NO_EDITOR = 1
|
||||
NO_UNIX_LDAP = 1
|
||||
|
||||
@@ -284,6 +284,7 @@ int buffer_to_output(char *pBuffer, FILE *pOutput)
|
||||
slash_convert(pMacros, "JBOOTDIRS");
|
||||
slash_convert(pMacros, "JDIRS");
|
||||
slash_convert(pMacros, "DEPTH");
|
||||
slash_convert(pMacros, "PRIV_DEPTH");
|
||||
slash_convert(pMacros, "PACKAGE");
|
||||
slash_convert(pMacros, "JMC_GEN_DIR");
|
||||
slash_convert(pMacros, "DIST_PUBLIC");
|
||||
|
||||
Binary file not shown.
@@ -48,6 +48,7 @@ foreach $filename (@ARGV) {
|
||||
# remained the same. This was confusing outofdate.pl
|
||||
#
|
||||
$classfilename =~ s/sun\/io\/extended.\//sun\/io\//;
|
||||
$classfilename =~ s/\.\.\/\.\.\/sun-java\/classsrc\///;
|
||||
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,
|
||||
$ctime,$blksize,$blocks) = stat($filename);
|
||||
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$classmtime,
|
||||
|
||||
2104
mozilla/include/net.h
Normal file
2104
mozilla/include/net.h
Normal file
File diff suppressed because it is too large
Load Diff
129
mozilla/include/shistele.h
Normal file
129
mozilla/include/shistele.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SHISTELE_H
|
||||
#define SHISTELE_H
|
||||
|
||||
#include "xp_list.h"
|
||||
|
||||
/*
|
||||
** This structure holds pointer so all saved data in the history. It is
|
||||
** also used by URL_Structs and is ultimately fed to layout.
|
||||
**
|
||||
** Warning: Don't change the names of the fields because they're used by
|
||||
** macros.
|
||||
*/
|
||||
typedef struct SHIST_SavedData {
|
||||
void* FormList; /* layout data to recreate forms */
|
||||
void* EmbedList; /* layout data to recreate embeds and applets */
|
||||
void* Grid; /* layout data to recreate grids */
|
||||
#ifdef MOCHA
|
||||
void* Window; /* window object for grid being resized */
|
||||
|
||||
/* XXX none of this would be necessary if frameset docs were reparsed */
|
||||
void* OnLoad; /* JavaScript onload event handler source */
|
||||
void* OnUnload; /* JavaScript onunload event handler source */
|
||||
void* OnFocus; /* JavaScript onfocus event handler source */
|
||||
void* OnBlur; /* JavaScript onblur event handler source */
|
||||
void* OnHelp; /* JavaScript onhelp event handler source */
|
||||
void* OnMouseOver; /* JavaScript onmouseover event handler source */
|
||||
void* OnMouseOut; /* JavaScript onmouseout event handler source */
|
||||
void* OnDragDrop; /* JavaScript ondragdrop event handler source */
|
||||
void* OnMove; /* JavaScript onmove event handler source */
|
||||
void* OnResize; /* JavaScript onresize event handler source */
|
||||
void* style_stack; /* JSSS style stack info */
|
||||
#endif
|
||||
} SHIST_SavedData;
|
||||
|
||||
/*
|
||||
This structure encapsulates all of the information needed for the
|
||||
session history. It should contain stuff like a list of all of the
|
||||
documents in the current history and a pointer to where the currently
|
||||
viewed document sits in the chain.
|
||||
|
||||
WARNING!! Some slots of this structure are shared with URL_Struct and
|
||||
net_CacheObject. If you add a slot, decide whether it needs to be
|
||||
shared as well.
|
||||
*/
|
||||
|
||||
struct _History_entry {
|
||||
char * title; /* title for this entry */
|
||||
char * address; /* URL address string */
|
||||
char * content_name; /* Server-provided "real name", used for
|
||||
default file name when saving. */
|
||||
int method; /* method of acessing URL */
|
||||
char * referer; /* What document points to this url */
|
||||
char * post_data; /* post data */
|
||||
int32 post_data_size; /* post data size */
|
||||
Bool post_data_is_file; /* is the post data a filename? */
|
||||
char * post_headers; /* content type for posted data */
|
||||
int32 position_tag; /* layout specific data for determining
|
||||
* where in the document the user was
|
||||
*/
|
||||
time_t last_modified; /* time of last modification */
|
||||
time_t last_access; /* time of last access */
|
||||
int history_num; /* special hack to add navigation */
|
||||
|
||||
SHIST_SavedData savedData; /* layout data */
|
||||
|
||||
PRPackedBool
|
||||
is_binary, /* is this a binary object pretending
|
||||
* to be HTML?
|
||||
*/
|
||||
is_active, /* is it an active stream? */
|
||||
is_netsite, /* did it come from netsite? */
|
||||
replace; /* did it come from netsite? */
|
||||
|
||||
int transport_method; /* network, disk cache, memory cache */
|
||||
|
||||
uint32 refresh; /* refresh interval */
|
||||
char *refresh_url; /* URL to refresh */
|
||||
char *wysiwyg_url; /* URL for WYSIWYG printing/saving */
|
||||
|
||||
/* Security information */
|
||||
int security_on; /* is security on? */
|
||||
/* Security info on a connection is opaque */
|
||||
unsigned char *sec_info;
|
||||
|
||||
/* Unique identifier */
|
||||
int32 unique_id;
|
||||
int32 ref_count;
|
||||
|
||||
/* Page services*/
|
||||
char *page_services_url; /* If it supports services, what link is used */
|
||||
|
||||
/* HTTP_11 support*/
|
||||
char *etag; /* Unique entity tag */
|
||||
char *origin_url; /* original referrer of javascript: URL */
|
||||
};
|
||||
|
||||
#define SHIST_CAME_FROM_NETWORK 0
|
||||
#define SHIST_CAME_FROM_DISK_CACHE 1
|
||||
#define SHIST_CAME_FROM_MEMORY_CACHE 2
|
||||
|
||||
struct History_ {
|
||||
XP_List * list_ptr; /* pointer to linked list */
|
||||
int cur_doc; /* an index into the list that points to the current document */
|
||||
History_entry *cur_doc_ptr; /* a ptr to the current doc entry */
|
||||
int32 num_entries; /* size of the history list */
|
||||
int32 max_entries; /* maximum size of list; -1 == no limit */
|
||||
};
|
||||
|
||||
|
||||
#endif /* SHISTELE_H */
|
||||
@@ -62,7 +62,7 @@ DEFFILE=$(DLLNAME).def
|
||||
#// -Zi -GM needed to compile mmx functions in assembly.
|
||||
LCFLAGS = -Zi -GM
|
||||
!ifdef MOZ_JAVA
|
||||
LINCS = -I$(PUBLIC)/java -I$(DEPTH)/sun-java/include
|
||||
LINCS = -I$(PUBLIC)/java
|
||||
!else
|
||||
LINCS = -I$(PUBLIC)/java -I$(DEPTH)/sun-java/stubs/include
|
||||
!endif
|
||||
@@ -143,11 +143,12 @@ MAPFILE= $(DLLNAME).map
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
export:: $(DLL)
|
||||
export::
|
||||
libs:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
|
||||
install:: export
|
||||
install:: export libs
|
||||
|
||||
clobber::
|
||||
$(RM) $(JPEG_OBJS)
|
||||
|
||||
@@ -87,11 +87,7 @@ RCFLAGS=$(RCFLAGS) /DXP_WIN32
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
!ifdef MOZ_JAVA
|
||||
include <$(DEPTH)/sun-java/config/rules.mak>
|
||||
!else
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
!endif
|
||||
|
||||
install:: $(DLL) $(LIBRARY)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
|
||||
1107
mozilla/lib/libmisc/shist.c
Normal file
1107
mozilla/lib/libmisc/shist.c
Normal file
File diff suppressed because it is too large
Load Diff
1767
mozilla/lib/libmocha/lm_doc.c
Normal file
1767
mozilla/lib/libmocha/lm_doc.c
Normal file
File diff suppressed because it is too large
Load Diff
880
mozilla/lib/libnet/extcache.c
Normal file
880
mozilla/lib/libnet/extcache.c
Normal file
@@ -0,0 +1,880 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
|
||||
/* Please leave outside of ifdef for window precompiled headers */
|
||||
#include "mkutils.h"
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
/* Publicly released Netscape cache access routines.
|
||||
*
|
||||
* These routines are shared between the netscape executable
|
||||
* and the programs released as a cache developers kit.
|
||||
*
|
||||
* Created: Lou Montulli <montulli@netscape.com>, July-95.
|
||||
* Modifications/Addition: Gagan Saksena, 97
|
||||
*/
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
#include "secnav.h"
|
||||
#include "sechash.h"
|
||||
#endif
|
||||
|
||||
#include "extcache.h" /* include this for everything */
|
||||
|
||||
#ifdef EXT_DB_ROUTINES
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <assert.h>
|
||||
|
||||
typedef struct {
|
||||
int32 len;
|
||||
char *data;
|
||||
} SECItem;
|
||||
|
||||
#ifdef _sgi
|
||||
#include <sys/endian.h>
|
||||
#endif /* _sgi */
|
||||
|
||||
|
||||
/* URL methods
|
||||
*/
|
||||
#define URL_GET_METHOD 0
|
||||
#define URL_POST_METHOD 1
|
||||
#define URL_HEAD_METHOD 2
|
||||
|
||||
#endif /* DB_STORE */
|
||||
|
||||
|
||||
MODULE_PRIVATE DBT *
|
||||
net_CacheDBTDup(DBT *obj)
|
||||
{
|
||||
DBT * rv = XP_NEW(DBT);
|
||||
|
||||
if(!rv)
|
||||
return(NULL);
|
||||
|
||||
rv->size = obj->size;
|
||||
rv->data = XP_ALLOC(rv->size);
|
||||
|
||||
if(!rv->data)
|
||||
{
|
||||
FREE(rv);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
XP_MEMCPY(rv->data, obj->data, rv->size);
|
||||
|
||||
return(rv);
|
||||
|
||||
}
|
||||
|
||||
/* free the cache object
|
||||
*/
|
||||
MODULE_PRIVATE void net_freeCacheObj (net_CacheObject * cache_obj)
|
||||
{
|
||||
|
||||
FREEIF(cache_obj->address);
|
||||
FREEIF(cache_obj->post_data);
|
||||
FREEIF(cache_obj->post_headers);
|
||||
FREEIF(cache_obj->content_type);
|
||||
FREEIF(cache_obj->charset);
|
||||
FREEIF(cache_obj->content_encoding);
|
||||
FREEIF(cache_obj->page_services_url);
|
||||
FREEIF(cache_obj->filename);
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
FREEIF(cache_obj->sec_info);
|
||||
#endif
|
||||
|
||||
FREE(cache_obj);
|
||||
}
|
||||
|
||||
/* returns true if this DBT looks like a valid
|
||||
* entry. It looks at the checksum and the
|
||||
* version number to see if it's valid
|
||||
*/
|
||||
#define MAX_VALID_DBT_SIZE 10000
|
||||
|
||||
MODULE_PRIVATE Bool
|
||||
net_IsValidCacheDBT(DBT *obj)
|
||||
{
|
||||
char *cur_ptr, *max_ptr;
|
||||
uint32 len;
|
||||
|
||||
if(!obj || obj->size < 9 || obj->size > MAX_VALID_DBT_SIZE)
|
||||
return(FALSE);
|
||||
|
||||
cur_ptr = (char *)obj->data;
|
||||
max_ptr = cur_ptr+obj->size;
|
||||
|
||||
/* get the total size of the struct out of
|
||||
* the first field to check it
|
||||
*/
|
||||
COPY_INT32(&len, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if(len != obj->size)
|
||||
{
|
||||
TRACEMSG(("Size going in is not the same as size coming out"));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* get the version number of the written structure
|
||||
*/
|
||||
if(cur_ptr > max_ptr)
|
||||
return(FALSE);
|
||||
COPY_INT32(&len, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if(len != CACHE_FORMAT_VERSION)
|
||||
{
|
||||
TRACEMSG(("Version of cache structure is wrong!: %d", len));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* looks good to me... */
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* takes a cache object and returns a malloc'd
|
||||
* (void *) suitible for passing in as a database
|
||||
* data storage object
|
||||
*/
|
||||
MODULE_PRIVATE DBT *
|
||||
net_CacheStructToDBData(net_CacheObject * old_obj)
|
||||
{
|
||||
int32 len;
|
||||
char *cur_ptr;
|
||||
void *new_obj;
|
||||
int32 total_size;
|
||||
DBT *rv;
|
||||
|
||||
rv = XP_NEW(DBT);
|
||||
|
||||
if(!rv)
|
||||
return(NULL);
|
||||
|
||||
total_size = sizeof(net_CacheObject);
|
||||
|
||||
#define ADD_STRING_SIZE(string) \
|
||||
total_size += old_obj->string ? XP_STRLEN(old_obj->string)+1 : 0
|
||||
|
||||
ADD_STRING_SIZE(address);
|
||||
total_size += old_obj->post_data_size+1;
|
||||
ADD_STRING_SIZE(post_headers);
|
||||
ADD_STRING_SIZE(content_type);
|
||||
ADD_STRING_SIZE(content_encoding);
|
||||
ADD_STRING_SIZE(charset);
|
||||
ADD_STRING_SIZE(filename);
|
||||
total_size += sizeof(uint32); /* size of secinfo */
|
||||
total_size += SECNAV_SSLSocketStatusLength(old_obj->sec_info);
|
||||
ADD_STRING_SIZE(page_services_url);
|
||||
|
||||
#undef ADD_STRING_SIZE
|
||||
|
||||
new_obj = XP_ALLOC(total_size * sizeof(char));
|
||||
|
||||
if(!new_obj)
|
||||
{
|
||||
FREE(rv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XP_MEMSET(new_obj, 0, total_size * sizeof(char));
|
||||
|
||||
/*
|
||||
* order is:
|
||||
* int32 size of the entire structure;
|
||||
*
|
||||
* int32 version of the structure format (CACHE_FORMAT_VERSION)
|
||||
*
|
||||
* time_t last_modified;
|
||||
* time_t last_accessed;
|
||||
* time_t expires;
|
||||
* uint32 content_length;
|
||||
* Bool is_netsite;
|
||||
*
|
||||
* time_t lock_date;
|
||||
*
|
||||
* char * filename;
|
||||
* int32 filename_len;
|
||||
*
|
||||
* int32 security_on;
|
||||
* unsigned char * sec_info;
|
||||
*
|
||||
* int32 method;
|
||||
*
|
||||
* # don't store address, or post_data stuff
|
||||
* # char * address;
|
||||
* # uint32 post_data_size;
|
||||
* # char * post_data;
|
||||
*
|
||||
* char * post_headers;
|
||||
* char * content_type;
|
||||
* char * content_encoding;
|
||||
* char * charset;
|
||||
*
|
||||
* Bool incomplete_file;
|
||||
* uint32 total_content_length;
|
||||
*
|
||||
* char * page_services_url;
|
||||
*
|
||||
* string lengths all include null terminators
|
||||
* all integer constants are stored as 4 bytes
|
||||
* all booleans are stored as one byte
|
||||
*/
|
||||
|
||||
/* VERY VERY IMPORTANT. Whenever the
|
||||
* format of the record structure changes
|
||||
* you must verify that the byte positions
|
||||
* in extcache.h are updated
|
||||
*/
|
||||
|
||||
#define STUFF_STRING(string) \
|
||||
{ \
|
||||
len = (old_obj->string ? XP_STRLEN(old_obj->string)+1 : 0); \
|
||||
COPY_INT32((void *)cur_ptr, &len); \
|
||||
cur_ptr = cur_ptr + sizeof(int32); \
|
||||
if(len) \
|
||||
XP_MEMCPY((void *)cur_ptr, old_obj->string, len); \
|
||||
cur_ptr += len; \
|
||||
}
|
||||
|
||||
#define STUFF_NUMBER(number) \
|
||||
{ \
|
||||
COPY_INT32((void *)cur_ptr, &old_obj->number); \
|
||||
cur_ptr = cur_ptr + sizeof(int32); \
|
||||
}
|
||||
|
||||
#define STUFF_TIMET(number) \
|
||||
{ \
|
||||
COPY_INT32((void *)cur_ptr, &old_obj->number); \
|
||||
cur_ptr = cur_ptr + sizeof(time_t); \
|
||||
}
|
||||
|
||||
#define STUFF_BOOL(bool_val) \
|
||||
{ \
|
||||
if(old_obj->bool_val) \
|
||||
((char *)(cur_ptr))[0] = 1; \
|
||||
else \
|
||||
((char *)(cur_ptr))[0] = 0; \
|
||||
cur_ptr = cur_ptr + sizeof(char); \
|
||||
}
|
||||
|
||||
cur_ptr = (char *)new_obj;
|
||||
|
||||
/* put the total size of the struct into
|
||||
* the first field so that we have
|
||||
* a cross check against corruption
|
||||
*/
|
||||
COPY_INT32((void *)cur_ptr, &total_size);
|
||||
cur_ptr = cur_ptr + sizeof(int32);
|
||||
|
||||
/* put the version number of the structure
|
||||
* format that we are using
|
||||
* By using a version string when writting
|
||||
* we can support backwards compatibility
|
||||
* in our reading code
|
||||
* (use "len" as a temp variable)
|
||||
*/
|
||||
len = CACHE_FORMAT_VERSION;
|
||||
COPY_INT32((void *)cur_ptr, &len);
|
||||
cur_ptr = cur_ptr + sizeof(int32);
|
||||
|
||||
STUFF_TIMET(last_modified);
|
||||
STUFF_TIMET(last_accessed);
|
||||
STUFF_TIMET(expires);
|
||||
STUFF_NUMBER(content_length);
|
||||
STUFF_BOOL(is_netsite);
|
||||
|
||||
STUFF_TIMET(lock_date);
|
||||
|
||||
STUFF_STRING(filename);
|
||||
STUFF_NUMBER(filename_len);
|
||||
|
||||
STUFF_BOOL(is_relative_path);
|
||||
|
||||
STUFF_NUMBER(security_on);
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
/* save the security info */
|
||||
if ( old_obj->sec_info ) {
|
||||
len = SECNAV_SSLSocketStatusLength(old_obj->sec_info);
|
||||
COPY_INT32((void *)cur_ptr, &len);
|
||||
cur_ptr = cur_ptr + sizeof(int32);
|
||||
|
||||
XP_MEMCPY((void *)cur_ptr, old_obj->sec_info, len);
|
||||
cur_ptr += len;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
len = 0;
|
||||
COPY_INT32((void *)cur_ptr, &len);
|
||||
cur_ptr = cur_ptr + sizeof(int32);
|
||||
}
|
||||
|
||||
STUFF_NUMBER(method);
|
||||
|
||||
#ifdef STORE_ADDRESS_AND_POST_DATA
|
||||
|
||||
STUFF_STRING(address);
|
||||
STUFF_NUMBER(post_data_size);
|
||||
|
||||
/* post_data
|
||||
* this is special since it not necessarily a string
|
||||
*/
|
||||
if(old_obj->post_data_size)
|
||||
{
|
||||
XP_MEMCPY(cur_ptr, old_obj->post_data, old_obj->post_data_size+1);
|
||||
cur_ptr += old_obj->post_data_size+1;
|
||||
}
|
||||
|
||||
#endif /* STORE_ADDRESS_AND_POST_DATA */
|
||||
|
||||
STUFF_STRING(post_headers);
|
||||
|
||||
STUFF_STRING(content_type);
|
||||
STUFF_STRING(content_encoding);
|
||||
STUFF_STRING(charset);
|
||||
|
||||
STUFF_BOOL(incomplete_file);
|
||||
STUFF_NUMBER(real_content_length);
|
||||
|
||||
STUFF_STRING(page_services_url);
|
||||
|
||||
#undef STUFF_STRING
|
||||
#undef STUFF_NUMBER
|
||||
#undef STUFF_BOOL
|
||||
|
||||
rv->data = new_obj;
|
||||
rv->size = total_size;
|
||||
|
||||
return(rv);
|
||||
|
||||
}
|
||||
|
||||
/* takes a database storage object and returns a malloc'd
|
||||
* cache data object. The cache object needs all of
|
||||
* it's parts free'd.
|
||||
*
|
||||
* returns NULL on parse error
|
||||
*/
|
||||
MODULE_PRIVATE net_CacheObject *
|
||||
net_DBDataToCacheStruct(DBT * db_obj)
|
||||
{
|
||||
net_CacheObject * rv = XP_NEW(net_CacheObject);
|
||||
char * cur_ptr;
|
||||
char * max_ptr;
|
||||
uint32 len;
|
||||
int32 version;
|
||||
|
||||
if(!rv)
|
||||
return NULL;
|
||||
|
||||
XP_MEMSET(rv, 0, sizeof(net_CacheObject));
|
||||
|
||||
/* if any strings are larger than this then
|
||||
* there was a serious database error
|
||||
*/
|
||||
#define MAX_HUGE_STRING_SIZE 10000
|
||||
|
||||
#define RETRIEVE_STRING(string) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
{ \
|
||||
net_freeCacheObj(rv); \
|
||||
return(NULL); \
|
||||
} \
|
||||
COPY_INT32(&len, cur_ptr); \
|
||||
cur_ptr += sizeof(int32); \
|
||||
if(len) \
|
||||
{ \
|
||||
if(len > MAX_HUGE_STRING_SIZE) \
|
||||
{ \
|
||||
net_freeCacheObj(rv); \
|
||||
return(NULL); \
|
||||
} \
|
||||
rv->string = (char*)XP_ALLOC(len); \
|
||||
if(!rv->string) \
|
||||
{ \
|
||||
net_freeCacheObj(rv); \
|
||||
return(NULL); \
|
||||
} \
|
||||
XP_MEMCPY(rv->string, cur_ptr, len); \
|
||||
cur_ptr += len; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define RETRIEVE_NUMBER(number) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
return(rv); \
|
||||
COPY_INT32(&rv->number, cur_ptr); \
|
||||
cur_ptr += sizeof(int32); \
|
||||
}
|
||||
|
||||
#define RETRIEVE_TIMET(number) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
return(rv); \
|
||||
COPY_INT32(&rv->number, cur_ptr); \
|
||||
cur_ptr += sizeof(time_t); \
|
||||
}
|
||||
|
||||
#define RETRIEVE_BOOL(bool) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
return(rv); \
|
||||
if(((char *)(cur_ptr))[0]) \
|
||||
rv->bool = TRUE; \
|
||||
else \
|
||||
rv->bool = FALSE; \
|
||||
cur_ptr += sizeof(char); \
|
||||
}
|
||||
|
||||
cur_ptr = (char *)db_obj->data;
|
||||
|
||||
max_ptr = cur_ptr+db_obj->size;
|
||||
|
||||
/* get the total size of the struct out of
|
||||
* the first field to check it
|
||||
*/
|
||||
COPY_INT32(&len, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if(len != db_obj->size)
|
||||
{
|
||||
TRACEMSG(("Size going in is not the same as size coming out"));
|
||||
FREE(rv);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* get the version number of the written structure
|
||||
*/
|
||||
if(cur_ptr > max_ptr)
|
||||
return(rv);
|
||||
COPY_INT32(&version, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if(version != CACHE_FORMAT_VERSION)
|
||||
{
|
||||
TRACEMSG(("Version of cache structure is wrong!: %d", version));
|
||||
FREE(rv);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
RETRIEVE_TIMET(last_modified);
|
||||
RETRIEVE_TIMET(last_accessed);
|
||||
RETRIEVE_TIMET(expires);
|
||||
RETRIEVE_NUMBER(content_length);
|
||||
RETRIEVE_BOOL(is_netsite);
|
||||
|
||||
RETRIEVE_TIMET(lock_date);
|
||||
|
||||
RETRIEVE_STRING(filename);
|
||||
RETRIEVE_NUMBER(filename_len);
|
||||
|
||||
RETRIEVE_BOOL(is_relative_path);
|
||||
|
||||
RETRIEVE_NUMBER(security_on);
|
||||
|
||||
/* security info */
|
||||
if(cur_ptr > max_ptr)
|
||||
return(rv);
|
||||
COPY_INT32(&len, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if ( len == 0 ) {
|
||||
rv->sec_info = NULL;
|
||||
} else {
|
||||
rv->sec_info = XP_ALLOC(len);
|
||||
if ( rv->sec_info == NULL ) {
|
||||
return(rv);
|
||||
}
|
||||
|
||||
XP_MEMCPY(rv->sec_info, cur_ptr, len);
|
||||
cur_ptr += len;
|
||||
}
|
||||
|
||||
|
||||
RETRIEVE_NUMBER(method);
|
||||
|
||||
#ifdef STORE_ADDRESS_AND_POST_DATA
|
||||
|
||||
RETRIEVE_STRING(address);
|
||||
RETRIEVE_NUMBER(post_data_size);
|
||||
|
||||
/* post_data
|
||||
* this is special since it not necessarily a string
|
||||
*/
|
||||
if(rv->post_data_size)
|
||||
{
|
||||
rv->post_data = XP_ALLOC(rv->post_data_size+1);
|
||||
if(rv->post_data)
|
||||
XP_MEMCPY(rv->post_data, cur_ptr, rv->post_data_size+1);
|
||||
cur_ptr += rv->post_data_size+1;
|
||||
}
|
||||
|
||||
#endif /* STORE_ADDRESS_AND_POST_DATA */
|
||||
|
||||
RETRIEVE_STRING(post_headers);
|
||||
|
||||
RETRIEVE_STRING(content_type);
|
||||
RETRIEVE_STRING(content_encoding);
|
||||
RETRIEVE_STRING(charset);
|
||||
|
||||
RETRIEVE_BOOL(incomplete_file);
|
||||
RETRIEVE_NUMBER(real_content_length);
|
||||
|
||||
RETRIEVE_STRING(page_services_url);
|
||||
#undef RETRIEVE_STRING
|
||||
#undef RETRIEVE_NUMBER
|
||||
#undef RETRIEVE_BOOL
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
#if defined(DEBUG) && defined(UNIX)
|
||||
int
|
||||
cache_test_me()
|
||||
{
|
||||
|
||||
net_CacheObject test;
|
||||
net_CacheObject *rv;
|
||||
int32 total_size;
|
||||
DBT *db_obj;
|
||||
|
||||
XP_MEMSET(&test, 0, sizeof(net_CacheObject));
|
||||
StrAllocCopy(test.address, "test1");
|
||||
db_obj = net_CacheStructToDBData(&test);
|
||||
rv = net_DBDataToCacheStruct(db_obj);
|
||||
printf("test1: %s\n", rv->address);
|
||||
|
||||
XP_MEMSET(&test, 0, sizeof(net_CacheObject));
|
||||
StrAllocCopy(test.address, "test2");
|
||||
StrAllocCopy(test.charset, "test2");
|
||||
db_obj = net_CacheStructToDBData(&test);
|
||||
rv = net_DBDataToCacheStruct(db_obj);
|
||||
printf("test2: %s %s\n", rv->address, rv->charset);
|
||||
|
||||
XP_MEMSET(&test, 0, sizeof(net_CacheObject));
|
||||
StrAllocCopy(test.address, "test3");
|
||||
StrAllocCopy(test.charset, "test3");
|
||||
test.content_length = 3 ;
|
||||
test.method = 3 ;
|
||||
test.is_netsite = 3 ;
|
||||
db_obj = net_CacheStructToDBData(&test);
|
||||
rv = net_DBDataToCacheStruct(db_obj);
|
||||
printf("test3: %s %s %d %d %s\n",
|
||||
rv->address, rv->charset,
|
||||
rv->content_length, rv->method,
|
||||
(rv->is_netsite == 3 ? "TRUE" : "FALSE"));
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/* generates a key for use in the cache database
|
||||
* from a CacheObject struct
|
||||
*
|
||||
* Key is based on the address and the post_data
|
||||
*
|
||||
* looks like:
|
||||
* size checksum | size of address | ADDRESS | size of post data | POST DATA
|
||||
*/
|
||||
MODULE_PRIVATE DBT *
|
||||
net_GenCacheDBKey(char *address, char *post_data, int32 post_data_size)
|
||||
{
|
||||
DBT *rv = XP_NEW(DBT);
|
||||
char *hash;
|
||||
char *data_ptr;
|
||||
int32 str_len;
|
||||
int32 size;
|
||||
|
||||
#define MD5_HASH_SIZE 16 /* always 16 due to md5 hash type */
|
||||
|
||||
if(!rv)
|
||||
return(NULL);
|
||||
|
||||
if(!address)
|
||||
{
|
||||
XP_ASSERT(0);
|
||||
rv->size = 0;
|
||||
return(rv);
|
||||
}
|
||||
|
||||
hash = XP_STRCHR(address, '#');
|
||||
|
||||
/* don't include '#' in a key */
|
||||
if(hash)
|
||||
*hash = '\0';
|
||||
|
||||
str_len = XP_STRLEN(address)+1;
|
||||
|
||||
size = sizeof(int32); /* for check sum */
|
||||
size += sizeof(int32); /* for size of address */
|
||||
size += str_len; /* for address string */
|
||||
size += sizeof(int32); /* for size of post_data */
|
||||
|
||||
if(post_data_size)
|
||||
size += MD5_HASH_SIZE;
|
||||
|
||||
rv->size = size;
|
||||
rv->data = XP_ALLOC(size);
|
||||
|
||||
if(!rv->data)
|
||||
{
|
||||
FREE(rv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data_ptr = (char *) rv->data;
|
||||
|
||||
/* put in the checksum size */
|
||||
COPY_INT32(data_ptr, &size);
|
||||
data_ptr = data_ptr + sizeof(int32);
|
||||
|
||||
/* put in the size of the address string */
|
||||
COPY_INT32(data_ptr, &str_len);
|
||||
data_ptr = data_ptr + sizeof(int32);
|
||||
|
||||
/* put in the address string data */
|
||||
XP_MEMCPY(data_ptr, address, str_len);
|
||||
data_ptr = data_ptr + str_len;
|
||||
|
||||
/* set the address back to it's original form */
|
||||
if(hash)
|
||||
*hash = '#';
|
||||
|
||||
/* put in the size of the post data */
|
||||
if(post_data_size)
|
||||
{
|
||||
int32 size_of_md5 = MD5_HASH_SIZE;
|
||||
unsigned char post_data_hash[MD5_HASH_SIZE];
|
||||
|
||||
MD5_HashBuf(post_data_hash, (unsigned char*)post_data, post_data_size);
|
||||
|
||||
COPY_INT32(data_ptr, &size_of_md5);
|
||||
data_ptr = data_ptr + sizeof(int32);
|
||||
|
||||
/* put in the post data if there is any */
|
||||
XP_MEMCPY(data_ptr, post_data_hash, sizeof(post_data_hash));
|
||||
}
|
||||
else
|
||||
{
|
||||
COPY_INT32(data_ptr, &post_data_size);
|
||||
data_ptr = data_ptr + sizeof(int32);
|
||||
}
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
/* returns a static string that contains the
|
||||
* URL->address of the key
|
||||
*
|
||||
* returns NULL on error
|
||||
*/
|
||||
MODULE_PRIVATE char *
|
||||
net_GetAddressFromCacheKey(DBT *key)
|
||||
{
|
||||
uint32 size;
|
||||
char *data;
|
||||
|
||||
/* check for minimum size */
|
||||
if(key->size < 10)
|
||||
return(NULL);
|
||||
|
||||
/* validate size checksum */
|
||||
data = (char *)key->data;
|
||||
COPY_INT32(&size, data);
|
||||
data += sizeof(int32);
|
||||
|
||||
if(size != key->size)
|
||||
return(NULL);
|
||||
|
||||
/* get size of address string */
|
||||
COPY_INT32(&size, data);
|
||||
data += sizeof(int32);
|
||||
|
||||
/* make sure it's a valid c string */
|
||||
if(data[size] != '\0')
|
||||
return(NULL);
|
||||
|
||||
/* it's valid return it */
|
||||
return(data);
|
||||
}
|
||||
|
||||
|
||||
/* checks a date within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
MODULE_PRIVATE time_t
|
||||
net_GetTimeInCacheDBT(DBT *data, int byte_position)
|
||||
{
|
||||
time_t date;
|
||||
char *ptr = (char *)data->data;
|
||||
|
||||
if(data->size < byte_position+sizeof(time_t))
|
||||
return(0);
|
||||
|
||||
if(!net_IsValidCacheDBT(data))
|
||||
return(0);
|
||||
|
||||
COPY_INT32(&date, ptr+byte_position);
|
||||
|
||||
/* TRACEMSG(("Got date from cache DBT: %d", date)); */
|
||||
|
||||
return(date);
|
||||
|
||||
}
|
||||
|
||||
/* Sets a date within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
MODULE_PRIVATE void
|
||||
net_SetTimeInCacheDBT(DBT *data, int byte_position, time_t date)
|
||||
{
|
||||
char *ptr = (char *)data->data;
|
||||
|
||||
if(data->size < byte_position+sizeof(time_t))
|
||||
return;
|
||||
|
||||
if(!net_IsValidCacheDBT(data))
|
||||
return;
|
||||
|
||||
COPY_INT32(ptr+byte_position, &date);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/* Gets the filename within a cache DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns NULL on error
|
||||
*/
|
||||
#define MAX_FILE_SIZE 2048
|
||||
MODULE_PRIVATE char *
|
||||
net_GetFilenameInCacheDBT(DBT *data)
|
||||
{
|
||||
int32 size;
|
||||
char *rv;
|
||||
char *ptr = (char*)data->data;
|
||||
|
||||
if(data->size < FILENAME_BYTE_POSITION)
|
||||
return(NULL);
|
||||
|
||||
if(!net_IsValidCacheDBT(data))
|
||||
return(0);
|
||||
|
||||
COPY_INT32(&size, ptr+FILENAME_SIZE_BYTE_POSITION);
|
||||
|
||||
if(data->size < FILENAME_BYTE_POSITION+size
|
||||
|| size > MAX_FILE_SIZE)
|
||||
return(NULL);
|
||||
|
||||
rv = (char *)XP_ALLOC(size);
|
||||
if(!rv)
|
||||
return(NULL);
|
||||
XP_MEMCPY(rv, ptr+FILENAME_BYTE_POSITION, size);
|
||||
|
||||
TRACEMSG(("Got filename: %s from DBT", rv));
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
/* Gets a int32 within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
MODULE_PRIVATE time_t
|
||||
net_GetInt32InCacheDBT(DBT *data, int byte_position)
|
||||
{
|
||||
int32 num;
|
||||
char *ptr = (char *)data->data;
|
||||
|
||||
if(!net_IsValidCacheDBT(data))
|
||||
return(0);
|
||||
|
||||
if(data->size < byte_position+sizeof(time_t))
|
||||
return(0);
|
||||
|
||||
COPY_INT32(&num, ptr+byte_position);
|
||||
|
||||
/* TRACEMSG(("Got int32 from cache DBT: %d", num)); */
|
||||
|
||||
return(num);
|
||||
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void
|
||||
net_FreeCacheDBTdata(DBT *stuff)
|
||||
{
|
||||
if(stuff)
|
||||
{
|
||||
FREE(stuff->data);
|
||||
FREE(stuff);
|
||||
}
|
||||
}
|
||||
|
||||
/* takes a database storage object and returns an un-malloc'd
|
||||
* cache data object. The structure returned has pointers
|
||||
* directly into the database memory and are only valid
|
||||
* until the next call to any database function
|
||||
*
|
||||
* do not free anything returned by this structure
|
||||
*/
|
||||
MODULE_PRIVATE net_CacheObject *
|
||||
net_Fast_DBDataToCacheStruct(DBT *obj)
|
||||
{
|
||||
static net_CacheObject *rv=0;
|
||||
|
||||
/* free any previous one */
|
||||
if(rv)
|
||||
net_freeCacheObj(rv);
|
||||
|
||||
rv = net_DBDataToCacheStruct(obj);
|
||||
|
||||
return(rv);
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
273
mozilla/lib/libnet/extcache.h
Normal file
273
mozilla/lib/libnet/extcache.h
Normal file
@@ -0,0 +1,273 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
|
||||
#ifndef EXT_CACHE_H
|
||||
#define EXT_CACHE_H
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
#include "mcom_db.h"
|
||||
#endif
|
||||
|
||||
#ifdef EXT_DB_ROUTINES
|
||||
#define Bool char
|
||||
#define uint32 unsigned int
|
||||
#define int32 int
|
||||
#define XP_NEW(structure) ((structure *) malloc(sizeof(structure)))
|
||||
#define XP_ALLOC (void *) malloc
|
||||
#define XP_MEMCPY memcpy
|
||||
#define XP_MEMSET memset
|
||||
#define TRACEMSG(x) printf x
|
||||
#define FREEIF(x) do { if(x) free(x); } while(0)
|
||||
#define FREE free
|
||||
#define XP_STRLEN strlen
|
||||
#define XP_STRCHR strchr
|
||||
#define XP_STRCMP strcmp
|
||||
#define XP_ASSERT assert
|
||||
#define MODULE_PRIVATE
|
||||
#define PRIVATE static
|
||||
#define TRUE !0
|
||||
#define FALSE 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <db.h>
|
||||
#endif
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
#include "mkutils.h"
|
||||
|
||||
#ifndef NSPR20
|
||||
#include "prosdep.h" /* for IS_LITTLE_ENDIAN / IS_BIG_ENDIAN */
|
||||
#else
|
||||
#include "prtypes.h"
|
||||
#endif
|
||||
|
||||
#endif /* EXT_DB_ROUTINES */
|
||||
|
||||
#if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
|
||||
ERROR! Must have a byte order
|
||||
#endif
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#define COPY_INT32(_a,_b) XP_MEMCPY(_a, _b, sizeof(int32));
|
||||
#else
|
||||
#define COPY_INT32(_a,_b) /* swap */ \
|
||||
do { \
|
||||
((char *)(_a))[0] = ((char *)(_b))[3]; \
|
||||
((char *)(_a))[1] = ((char *)(_b))[2]; \
|
||||
((char *)(_a))[2] = ((char *)(_b))[1]; \
|
||||
((char *)(_a))[3] = ((char *)(_b))[0]; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#define EXT_CACHE_NAME_STRING "INT_ExternalCacheNameString"
|
||||
|
||||
/* Internal WARNING!! Some slots of this structure
|
||||
* are shared with URL_Struct and
|
||||
* History_entry. If you add a slot, decide whether it needs to be shared
|
||||
* as well.
|
||||
*/
|
||||
typedef struct _net_CacheObject {
|
||||
time_t last_modified;
|
||||
time_t last_accessed;
|
||||
time_t expires;
|
||||
Bool is_netsite;
|
||||
uint32 content_length;
|
||||
|
||||
char * filename; /* cache file name */
|
||||
int32 filename_len; /* optimization */
|
||||
Bool is_relative_path; /* is the path relative? */
|
||||
|
||||
/* Security information */
|
||||
int32 security_on; /* is security on? */
|
||||
unsigned char *sec_info;
|
||||
|
||||
time_t lock_date; /* the file is locked if this
|
||||
* is non-zero. The date
|
||||
* represents the time the
|
||||
* lock was put in place.
|
||||
* Locks are only valid for
|
||||
* one session
|
||||
*/
|
||||
|
||||
int32 method;
|
||||
char * address;
|
||||
uint32 post_data_size;
|
||||
char * post_data;
|
||||
char * post_headers;
|
||||
char * content_type;
|
||||
char * content_encoding;
|
||||
char * charset;
|
||||
|
||||
Bool incomplete_file; /* means that the whole
|
||||
* file is not there.
|
||||
* This can only be true
|
||||
* if the server supports byteranges
|
||||
*/
|
||||
uint32 real_content_length; /* the whole content length
|
||||
* i.e. the server size of a truncated
|
||||
* client file
|
||||
*/
|
||||
char * page_services_url;
|
||||
char * etag; /* HTTP/1.1 Etag */
|
||||
|
||||
} net_CacheObject;
|
||||
|
||||
/* this is the version number of the cache database entry.
|
||||
* It should be incremented in integer ingrements up
|
||||
* to MAXINT32
|
||||
*/
|
||||
#define CACHE_FORMAT_VERSION 5
|
||||
|
||||
/* these defines specify the exact byte position
|
||||
* of the first 4 elements in the DBT data struct
|
||||
* Change these if you change the order of entry into
|
||||
* the DBT
|
||||
*/
|
||||
#define LAST_MODIFIED_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)
|
||||
#define LAST_ACCESSED_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)
|
||||
#define EXPIRES_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t)
|
||||
#define CONTENT_LENGTH_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)
|
||||
#define IS_NETSITE_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)+sizeof(int32)
|
||||
|
||||
#define LOCK_DATE_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)+sizeof(int32)+sizeof(char)
|
||||
|
||||
#define FILENAME_SIZE_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)+sizeof(uint32)+sizeof(char)+sizeof(time_t)
|
||||
#define FILENAME_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)+sizeof(uint32)+sizeof(char)+sizeof(time_t) \
|
||||
+sizeof(int32)
|
||||
|
||||
/* generates a key for use in the cache database
|
||||
* from a CacheObject struct
|
||||
*
|
||||
* Key is based on the address and the post_data
|
||||
*/
|
||||
extern DBT *
|
||||
net_GenCacheDBKey(char *address, char *post_data, int32 post_data_size);
|
||||
|
||||
/* returns a static string that contains the
|
||||
* URL->address of the key
|
||||
*
|
||||
* returns NULL on error
|
||||
*/
|
||||
extern char *
|
||||
net_GetAddressFromCacheKey(DBT *key);
|
||||
|
||||
|
||||
/* allocs and copies a new DBT from an existing DBT
|
||||
*/
|
||||
extern DBT * net_CacheDBTDup(DBT *obj);
|
||||
|
||||
/* free the cache object
|
||||
*/
|
||||
extern void net_freeCacheObj (net_CacheObject * cache_obj);
|
||||
|
||||
/* takes a cache object and returns a malloc'd
|
||||
* (void *) suitible for passing in as a database
|
||||
* data storage object
|
||||
*/
|
||||
extern DBT * net_CacheStructToDBData(net_CacheObject * old_obj);
|
||||
|
||||
/* takes a database storage object and returns a malloc'd
|
||||
* cache data object. The cache object needs all of
|
||||
* it's parts free'd.
|
||||
*
|
||||
* returns NULL on parse error
|
||||
*/
|
||||
extern net_CacheObject * net_DBDataToCacheStruct(DBT * db_obj);
|
||||
|
||||
/* checks a date within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
extern time_t net_GetTimeInCacheDBT(DBT *data, int byte_position);
|
||||
|
||||
/* Sets a date within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
extern void net_SetTimeInCacheDBT(DBT *data, int byte_position, time_t date);
|
||||
|
||||
/* Gets the filename within a cache DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns NULL on error
|
||||
*/
|
||||
extern char * net_GetFilenameInCacheDBT(DBT *data);
|
||||
|
||||
/* Gets a int32 within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
extern time_t net_GetInt32InCacheDBT(DBT *data, int byte_position);
|
||||
|
||||
/* free's a DBT struct
|
||||
*/
|
||||
extern void net_FreeCacheDBTdata(DBT *stuff);
|
||||
|
||||
/* stores a cache object in the DBM database
|
||||
*/
|
||||
extern void net_ExtCacheStore(DB *database, net_CacheObject * obj);
|
||||
|
||||
/* takes a database storage object and returns an un-malloc'd
|
||||
* cache data object. The structure returned has pointers
|
||||
* directly into the database memory and are only valid
|
||||
* until the next call to any database function
|
||||
*
|
||||
* do not free anything returned by this structure
|
||||
*/
|
||||
extern net_CacheObject * net_Fast_DBDataToCacheStruct(DBT *obj);
|
||||
|
||||
/* returns true if this DBT looks like a valid
|
||||
* entry. It looks at the checksum and the
|
||||
* version number to see if it's valid
|
||||
*/
|
||||
extern Bool net_IsValidCacheDBT(DBT *obj);
|
||||
|
||||
#endif /* EXT_CACHE_H */
|
||||
3430
mozilla/lib/libnet/mkcache.c
Normal file
3430
mozilla/lib/libnet/mkcache.c
Normal file
File diff suppressed because it is too large
Load Diff
1551
mozilla/lib/libnet/mkextcac.c
Normal file
1551
mozilla/lib/libnet/mkextcac.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -61,7 +61,6 @@
|
||||
#endif
|
||||
|
||||
#include "mktcp.h" /* for NET_InGetHostByName semaphore */
|
||||
#include "cert.h"
|
||||
#ifdef MOZILLA_CLIENT
|
||||
#include "secnav.h"
|
||||
#ifdef MOCHA
|
||||
@@ -76,7 +75,6 @@
|
||||
#include "il_strm.h" /* Image Lib public API. */
|
||||
|
||||
#include "libi18n.h"
|
||||
#include "xp_sec.h"
|
||||
#include "mkmocha.h"
|
||||
#include "htmldlgs.h"
|
||||
|
||||
@@ -4215,16 +4213,8 @@ NET_FreeURLStruct (URL_Struct * URL_s)
|
||||
FREEIF(URL_s->wysiwyg_url);
|
||||
FREEIF(URL_s->error_msg);
|
||||
|
||||
FREEIF(URL_s->key_cipher);
|
||||
FREEIF(URL_s->key_issuer);
|
||||
FREEIF(URL_s->key_subject);
|
||||
if ( URL_s->certificate ) {
|
||||
CERT_DestroyCertificate(URL_s->certificate);
|
||||
}
|
||||
|
||||
if ( URL_s->redirecting_cert ) {
|
||||
CERT_DestroyCertificate(URL_s->redirecting_cert);
|
||||
}
|
||||
FREEIF(URL_s->sec_info);
|
||||
FREEIF(URL_s->redirect_sec_info);
|
||||
|
||||
/* Free all memory associated with header information */
|
||||
net_FreeURLAllHeaders(URL_s);
|
||||
@@ -4460,10 +4450,8 @@ net_OutputURLDocInfo(MWContext *ctxt, char *which, char **data, int32 *length)
|
||||
}
|
||||
|
||||
if(URL_s->cache_file || URL_s->memory_copy)
|
||||
sec_msg = XP_PrettySecurityStatus(URL_s->security_on,
|
||||
URL_s->key_cipher,
|
||||
URL_s->key_size,
|
||||
URL_s->key_secret_size);
|
||||
sec_msg = SECNAV_PrettySecurityStatus(URL_s->security_on,
|
||||
URL_s->sec_info);
|
||||
else
|
||||
sec_msg = XP_STRDUP(XP_GetString(XP_STATUS_UNKNOWN));
|
||||
|
||||
@@ -4473,20 +4461,10 @@ net_OutputURLDocInfo(MWContext *ctxt, char *which, char **data, int32 *length)
|
||||
FREE(sec_msg);
|
||||
}
|
||||
|
||||
if(URL_s->certificate)
|
||||
sec_msg = CERT_HTMLCertInfo(URL_s->certificate, PR_TRUE,
|
||||
PR_TRUE);
|
||||
else
|
||||
sec_msg = 0;
|
||||
sec_msg = SECNAV_SSLSocketCertString(URL_s->sec_info);
|
||||
|
||||
if(sec_msg)
|
||||
{
|
||||
char *extstring;
|
||||
extstring = SECNAV_MakeCertButtonString(URL_s->certificate);
|
||||
if ( extstring ) {
|
||||
StrAllocCat(sec_msg, extstring);
|
||||
XP_FREE(extstring);
|
||||
}
|
||||
ADD_CELL(XP_GetString(XP_CERTIFICATE_), sec_msg);
|
||||
FREE(sec_msg);
|
||||
}
|
||||
@@ -4653,6 +4631,11 @@ PRIVATE int net_output_about_url(ActiveEntry * cur_entry)
|
||||
NET_DisplayMemCacheInfoAsHTML(cur_entry);
|
||||
return(-1);
|
||||
}
|
||||
else if(!strcasecomp(which, "logout"))
|
||||
{
|
||||
NET_RemoveAllAuthorizations();
|
||||
return(-1);
|
||||
}
|
||||
else if(!strcasecomp(which, "image-cache"))
|
||||
{
|
||||
IL_DisplayMemCacheInfoAsHTML(cur_entry->format_out, cur_entry->URL_s,
|
||||
|
||||
3772
mozilla/lib/libnet/mkhttp.c
Normal file
3772
mozilla/lib/libnet/mkhttp.c
Normal file
File diff suppressed because it is too large
Load Diff
5326
mozilla/lib/libnet/mknews.c
Normal file
5326
mozilla/lib/libnet/mknews.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "npglue.h"
|
||||
#ifdef JAVA
|
||||
#ifdef OJI
|
||||
#include "jvmmgr.h"
|
||||
#endif
|
||||
#include "xp_mem.h"
|
||||
@@ -154,7 +154,7 @@ NPIJVMPluginManager*
|
||||
nsPluginManager::GetJVMMgr(const nsIID& aIID)
|
||||
{
|
||||
NPIJVMPluginManager* result = NULL;
|
||||
#ifdef JAVA
|
||||
#ifdef OJI
|
||||
if (fJVMMgr == NULL) {
|
||||
// The plugin manager is the outer of the JVM manager
|
||||
if (JVMMgr::Create(this, kISupportsIID, (void**)&fJVMMgr) != NS_OK)
|
||||
@@ -197,7 +197,7 @@ nsPluginInstancePeer::AggregatedQueryInterface(const nsIID& aIID, void** aInstan
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
#ifdef JAVA
|
||||
#ifdef OJI
|
||||
// Aggregates...
|
||||
if (fJVMInstancePeer == NULL) {
|
||||
np_instance* instance = (np_instance*) npp->ndata;
|
||||
|
||||
90
mozilla/lib/xp/Makefile
Normal file
90
mozilla/lib/xp/Makefile
Normal file
@@ -0,0 +1,90 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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 = ../..
|
||||
|
||||
MODULE = xp
|
||||
LIBRARY_NAME = xp
|
||||
|
||||
CSRCS = xp_alloc.c \
|
||||
xp_cntxt.c \
|
||||
xp_core.c \
|
||||
xp_error.c \
|
||||
xp_file.c \
|
||||
xp_hash.c \
|
||||
xp_list.c \
|
||||
xp_ncent.c \
|
||||
xp_reg.c \
|
||||
xp_rgb.c \
|
||||
xp_qsort.c \
|
||||
xp_str.c \
|
||||
xp_thrmo.c \
|
||||
xp_time.c \
|
||||
xp_trace.c \
|
||||
xp_wrap.c \
|
||||
xpassert.c \
|
||||
xplocale.c \
|
||||
$(NULL)
|
||||
|
||||
REQUIRES = js nspr dbm security img util jtools layer java lay style pref rdf
|
||||
|
||||
CSRCS += allxpstr.c xp_intl.c
|
||||
|
||||
ifeq ($(STAND_ALONE_JAVA),1)
|
||||
CSRCS = xp_qsort.c
|
||||
endif
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
EMACS = lemacs
|
||||
|
||||
AUDIO_FILES = $(wildcard *.au)
|
||||
GIF_FILES = $(wildcard *.gif)
|
||||
JPEG_FILES = $(wildcard *.jpg)
|
||||
|
||||
GEN_OUT = $(AUDIO_FILES:.au=.h) $(GIF_FILES:.gif=.h) $(JPEG_FILES:.jpg=.h)
|
||||
|
||||
#
|
||||
# Uncomment these to (re)generate the headers.
|
||||
#
|
||||
#GARBAGE += $(GEN_OUT) $(wildcard *~)
|
||||
#
|
||||
#all:: $(GEN_OUT)
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
|
||||
#
|
||||
# Generate c header's for various binary files
|
||||
#
|
||||
.SUFFIXES: .au .gif .jpg
|
||||
|
||||
.au.h:
|
||||
@echo generating $*.h from $<...; \
|
||||
CNAME=`echo $*_au`; \
|
||||
$(EMACS) -batch -q -l bin-to-c.el -f batch-bin-to-c $$CNAME $< $*.h
|
||||
|
||||
.gif.h:
|
||||
@echo generating $*.h from $<...; \
|
||||
CNAME=`echo $*_gif`; \
|
||||
$(EMACS) -batch -q -l bin-to-c.el -f batch-bin-to-c $$CNAME $< $*.h
|
||||
|
||||
.jpg.h:
|
||||
@echo generating $*.h from $<...; \
|
||||
CNAME=`echo $*_jpg`; \
|
||||
$(EMACS) -batch -q -l bin-to-c.el -f batch-bin-to-c $$CNAME $< $*.h
|
||||
@@ -33,7 +33,7 @@ DIRS = \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_JAVA
|
||||
DIRS += applet libreg softupdt zlib li progress
|
||||
DIRS += libreg softupdt zlib li progress
|
||||
|
||||
ifdef EDITOR
|
||||
DIRS += edtplug spellchk
|
||||
|
||||
@@ -87,7 +87,7 @@ LINCS= $(LINCS) -I_jri \
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/sun-java/config/rules.mak>
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
CFLAGS=$(CFLAGS) $(JAVA_DEFINES)
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ DIRS= \
|
||||
!ifdef EDITOR
|
||||
edtplug \
|
||||
!endif
|
||||
applet \
|
||||
softupdt \
|
||||
zlib \
|
||||
!endif
|
||||
|
||||
663
mozilla/modules/security/freenav/navstubs.c
Normal file
663
mozilla/modules/security/freenav/navstubs.c
Normal file
@@ -0,0 +1,663 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "secnav.h"
|
||||
#include "libmocha.h"
|
||||
#include "prlink.h"
|
||||
#include "prinrval.h"
|
||||
|
||||
int
|
||||
SSL_SetSockPeerID(PRFileDesc *fd, char *peerID)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
SECNAV_Posting(PRFileDesc *fd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SECNAV_HTTPHead(PRFileDesc *fd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SECNAV_RegisterNetlibMimeConverters()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
SECNAV_MungeString(const char *unmunged_string)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
SECNAV_UnMungeString(const char *munged_string)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
PRBool
|
||||
SECNAV_GenKeyFromChoice(void *proto_win, LO_Element *form,
|
||||
char *choiceString, char *challenge,
|
||||
char *typeString, char *pqgString,
|
||||
char **pValue, PRBool *pDone)
|
||||
{
|
||||
return(PR_FALSE);
|
||||
}
|
||||
|
||||
|
||||
char **
|
||||
SECNAV_GetKeyChoiceList(char *type, char *pqgString)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
PRBool
|
||||
SECNAV_SecurityDialog(MWContext *context, int state)
|
||||
{
|
||||
return (state == SD_INSECURE_POST_FROM_INSECURE_DOC);
|
||||
}
|
||||
|
||||
JSObject *
|
||||
lm_DefinePkcs11(MochaDecoder *decoder)
|
||||
{
|
||||
return((JSObject *)1);
|
||||
}
|
||||
|
||||
JSObject *
|
||||
lm_DefineCrypto(MochaDecoder *decoder)
|
||||
{
|
||||
return((JSObject *)1);
|
||||
}
|
||||
|
||||
void
|
||||
NET_InitCertLdapProtocol(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CERTCertificate *
|
||||
CERT_DupCertificate(CERTCertificate *cert)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CERT_DestroyCertificate(CERTCertificate *cert)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CERTCertificate *
|
||||
CERT_NewTempCertificate (CERTCertDBHandle *handle, SECItem *derCert,
|
||||
char *nickname, PRBool isperm, PRBool copyDER)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
CERTCertDBHandle *
|
||||
CERT_GetDefaultCertDB(void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
CERTCertificate *
|
||||
CERT_DecodeCertFromPackage(char *certbuf, int certlen)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
CERT_HTMLCertInfo(CERTCertificate *cert, PRBool showImages, PRBool showIssuer)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
PRBool
|
||||
CERT_CompareCertsForRedirection(CERTCertificate *c1, CERTCertificate *c2)
|
||||
{
|
||||
return(PR_FALSE);
|
||||
}
|
||||
|
||||
const char *
|
||||
SECNAV_GetPolicyNameString(void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int
|
||||
SECNAV_InitConfigObject(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
SECNAV_RunInitialSecConfig(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
SECNAV_EarlyInit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SECNAV_Init(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SECNAV_Shutdown(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SECNAV_SecurityAdvisor(void *proto_win, URL_Struct *url)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
SECNAV_MakeCertButtonString(CERTCertificate *cert)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int
|
||||
SECNAV_SecURLData(char *which, NET_StreamClass *stream, MWContext *cx)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
char *
|
||||
SECNAV_SecURLContentType(char *which)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int
|
||||
SECNAV_SecHandleSecurityAdvisorURL(MWContext *cx, const char *which)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void
|
||||
SECNAV_HandleInternalSecURL(URL_Struct *url, MWContext *cx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PRBool
|
||||
SSL_IsDomestic(void)
|
||||
{
|
||||
return(PR_FALSE);
|
||||
}
|
||||
|
||||
SECStatus
|
||||
SECNAV_ComputeFortezzaProxyChallengeResponse(MWContext *context,
|
||||
char *asciiChallenge,
|
||||
char **signature_out,
|
||||
char **clientRan_out,
|
||||
char **certChain_out)
|
||||
{
|
||||
return(SECFailure);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
SECNAV_PrettySecurityStatus(int level, unsigned char *status)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
SECNAV_SecurityVersion(PRBool longForm)
|
||||
{
|
||||
return("N");
|
||||
}
|
||||
|
||||
char *
|
||||
SECNAV_SSLCapabilities(void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
SECNAV_SSLSocketStatus(PRFileDesc *fd, int *return_security_level)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
SECNAV_CopySSLSocketStatus(unsigned char *status)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
SECNAV_SSLSocketStatusLength(unsigned char *status)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
char *
|
||||
SECNAV_SSLSocketCertString(unsigned char *status)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
PRBool
|
||||
SECNAV_CompareCertsForRedirection(unsigned char *status1,
|
||||
unsigned char *status2)
|
||||
{
|
||||
return(PR_FALSE);
|
||||
}
|
||||
|
||||
CERTCertificate *
|
||||
SECNAV_CertFromSSLSocketStatus(unsigned char *status)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
SECStatus
|
||||
RNG_RNGInit(void)
|
||||
{
|
||||
return(SECSuccess);
|
||||
}
|
||||
|
||||
/*
|
||||
* probably need to provide something here
|
||||
*/
|
||||
SECStatus
|
||||
RNG_GenerateGlobalRandomBytes(void *dest, size_t len)
|
||||
{
|
||||
/* This is a temporary implementation to avoid */
|
||||
/* the cache filename horkage. This needs to have a more */
|
||||
/* secure/free implementation here - Gagan */
|
||||
|
||||
char* output=dest;
|
||||
size_t i;
|
||||
srand((unsigned int) PR_IntervalToMilliseconds(PR_IntervalNow()));
|
||||
for (i=0;i<len; i++)
|
||||
{
|
||||
int t = rand();
|
||||
*output = (char) (t % 256);
|
||||
output++;
|
||||
}
|
||||
return(SECSuccess);
|
||||
}
|
||||
|
||||
/*
|
||||
** Get the "noisiest" information available on the system.
|
||||
*/
|
||||
size_t
|
||||
RNG_GetNoise(void *buf, size_t maxbytes)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
** RNG_SystemInfoForRNG should be called before any use of SSL. It
|
||||
** gathers up the system specific information to help seed the
|
||||
** state of the global random number generator.
|
||||
*/
|
||||
void
|
||||
RNG_SystemInfoForRNG(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Use the contents (and stat) of a file to help seed the
|
||||
** global random number generator.
|
||||
*/
|
||||
void RNG_FileForRNG(char *filename)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Update the global random number generator with more seeding
|
||||
** material
|
||||
*/
|
||||
SECStatus
|
||||
RNG_RandomUpdate(void *data, size_t bytes)
|
||||
{
|
||||
return(SECFailure);
|
||||
}
|
||||
|
||||
PRStaticLinkTable jsl_nodl_tab[1];
|
||||
|
||||
void
|
||||
_java_jsl_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
DIGESTS *PR_CALLBACK
|
||||
SOB_calculate_digest(void XP_HUGE *data, long length)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
int PR_CALLBACK
|
||||
SOB_verify_digest(ZIG *siglist, const char *name, DIGESTS *dig)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void PR_CALLBACK
|
||||
SOB_destroy (ZIG *zig)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
SOB_get_error (int status)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ZIG_Context *
|
||||
SOB_find(ZIG *zig, char *pattern, int type)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int
|
||||
SOB_find_next(ZIG_Context *ctx, SOBITEM **it)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void
|
||||
SOB_find_end(ZIG_Context *ctx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
SOB_get_url (ZIG *zig)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ZIG *
|
||||
SOB_new (void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int
|
||||
SOB_set_callback (int type, ZIG *zig,
|
||||
int (*fn) (int status, ZIG *zig,
|
||||
const char *metafile,
|
||||
char *pathname, char *errortext))
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int PR_CALLBACK
|
||||
SOB_cert_attribute(int attrib, ZIG *zig, long keylen, void *key,
|
||||
void **result, unsigned long *length)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int PR_CALLBACK
|
||||
SOB_stash_cert(ZIG *zig, long keylen, void *key)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int SOB_parse_manifest(char XP_HUGE *raw_manifest, long length,
|
||||
const char *path, const char *url, ZIG *zig)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void
|
||||
SECNAV_signedAppletPrivileges(void *proto_win, char *javaPrin,
|
||||
char *javaTarget, char *risk, int isCert)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
SOB_JAR_list_certs (void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int
|
||||
SOB_JAR_validate_archive (char *filename)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void *
|
||||
SOB_JAR_new_hash (int alg)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void *
|
||||
SOB_JAR_hash (int alg, void *cookie, int length, void *data)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void *
|
||||
SOB_JAR_end_hash (int alg, void *cookie)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int
|
||||
SOB_JAR_sign_archive (char *nickname, char *password, char *sf, char *outsig)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int
|
||||
SOB_set_context (ZIG *zig, MWContext *mw)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int
|
||||
SOB_pass_archive(int format, char *filename, const char *url, ZIG *zig)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int
|
||||
SOB_get_metainfo(ZIG *zig, char *name, char *header, void **info,
|
||||
unsigned long *length)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int
|
||||
SOB_verified_extract(ZIG *zig, char *path, char *outpath)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
** Hash a non-null terminated string "src" into "dest" using MD5
|
||||
*/
|
||||
SECStatus
|
||||
MD5_HashBuf(unsigned char *dest, const unsigned char *src,
|
||||
uint32 src_length)
|
||||
{
|
||||
return(SECFailure);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Create a new MD5 context
|
||||
*/
|
||||
MD5Context *
|
||||
MD5_NewContext(void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
** Destroy an MD5 secure hash context.
|
||||
** "cx" the context
|
||||
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
||||
*/
|
||||
void
|
||||
MD5_DestroyContext(MD5Context *cx, PRBool freeit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Reset an MD5 context, preparing it for a fresh round of hashing
|
||||
*/
|
||||
void
|
||||
MD5_Begin(MD5Context *cx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Update the MD5 hash function with more data.
|
||||
** "cx" the context
|
||||
** "input" the data to hash
|
||||
** "inputLen" the amount of data to hash
|
||||
*/
|
||||
void
|
||||
MD5_Update(MD5Context *cx, const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Finish the MD5 hash function. Produce the digested results in "digest"
|
||||
** "cx" the context
|
||||
** "digest" where the 16 bytes of digest data are stored
|
||||
** "digestLen" where the digest length (16) is stored
|
||||
** "maxDigestLen" the maximum amount of data that can ever be
|
||||
** stored in "digest"
|
||||
*/
|
||||
void
|
||||
MD5_End(MD5Context *cx, unsigned char *digest,
|
||||
unsigned int *digestLen, unsigned int maxDigestLen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Hash a non-null terminated string "src" into "dest" using SHA-1
|
||||
*/
|
||||
SECStatus
|
||||
SHA1_HashBuf(unsigned char *dest, const unsigned char *src, uint32 src_length)
|
||||
{
|
||||
return(SECFailure);
|
||||
}
|
||||
|
||||
/*
|
||||
** Create a new SHA-1 context
|
||||
*/
|
||||
SHA1Context *
|
||||
SHA1_NewContext(void)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
** Destroy a SHA-1 secure hash context.
|
||||
** "cx" the context
|
||||
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
||||
*/
|
||||
void
|
||||
SHA1_DestroyContext(SHA1Context *cx, PRBool freeit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Reset a SHA-1 context, preparing it for a fresh round of hashing
|
||||
*/
|
||||
void
|
||||
SHA1_Begin(SHA1Context *cx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Update the SHA-1 hash function with more data.
|
||||
** "cx" the context
|
||||
** "input" the data to hash
|
||||
** "inputLen" the amount of data to hash
|
||||
*/
|
||||
void
|
||||
SHA1_Update(SHA1Context *cx, const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Finish the SHA-1 hash function. Produce the digested results in "digest"
|
||||
** "cx" the context
|
||||
** "digest" where the 16 bytes of digest data are stored
|
||||
** "digestLen" where the digest length (20) is stored
|
||||
** "maxDigestLen" the maximum amount of data that can ever be
|
||||
** stored in "digest"
|
||||
*/
|
||||
void
|
||||
SHA1_End(SHA1Context *cx, unsigned char *digest,
|
||||
unsigned int *digestLen, unsigned int maxDigestLen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a malloc'd ascii string which is the base64 encoded
|
||||
** version of the input string.
|
||||
*/
|
||||
char *
|
||||
BTOA_DataToAscii(const unsigned char *data, unsigned int len)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a malloc'd string which is the base64 decoded version
|
||||
** of the input string; set *lenp to the length of the returned data.
|
||||
*/
|
||||
unsigned char *
|
||||
ATOB_AsciiToData(const char *string, unsigned int *lenp)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
236
mozilla/modules/security/freenav/secstubn.h
Normal file
236
mozilla/modules/security/freenav/secstubn.h
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef _SECSTUBN_H_
|
||||
#define _SECSTUBN_H_
|
||||
|
||||
#include "xp.h"
|
||||
#include "ntypes.h"
|
||||
#include "net.h"
|
||||
|
||||
typedef struct _digests DIGESTS;
|
||||
typedef struct _zig ZIG;
|
||||
typedef struct _zigcontext ZIG_Context;
|
||||
typedef struct _peheader PEHeader;
|
||||
|
||||
typedef struct SOBITEM_ {
|
||||
char *pathname;
|
||||
int type;
|
||||
size_t size;
|
||||
void *data;
|
||||
} SOBITEM;
|
||||
|
||||
typedef struct FINGERZIG_ {
|
||||
size_t length;
|
||||
void *key;
|
||||
CERTCertificate *cert;
|
||||
} FINGERZIG;
|
||||
|
||||
#define ZIG_CB_SIGNAL 1
|
||||
#define ZIG_SIGN 10
|
||||
#define ZIG_F_GUESS 0
|
||||
#define ZIG_MF 2
|
||||
#define ZIG_ERR_PNF 12
|
||||
|
||||
SEC_BEGIN_PROTOS
|
||||
|
||||
void
|
||||
SECNAV_Posting(PRFileDesc *fd);
|
||||
|
||||
void
|
||||
SECNAV_HTTPHead(PRFileDesc *fd);
|
||||
|
||||
void
|
||||
SECNAV_RegisterNetlibMimeConverters();
|
||||
|
||||
char *
|
||||
SECNAV_MungeString(const char *unmunged_string);
|
||||
|
||||
char *
|
||||
SECNAV_UnMungeString(const char *munged_string);
|
||||
|
||||
PRBool
|
||||
SECNAV_GenKeyFromChoice(void *proto_win, LO_Element *form,
|
||||
char *choiceString, char *challenge,
|
||||
char *typeString, char *pqgString,
|
||||
char **pValue, PRBool *pDone);
|
||||
|
||||
char **
|
||||
SECNAV_GetKeyChoiceList(char *type, char *pqgString);
|
||||
|
||||
PRBool
|
||||
SECNAV_SecurityDialog(MWContext *context, int state);
|
||||
|
||||
void
|
||||
NET_InitCertLdapProtocol(void);
|
||||
const char *
|
||||
|
||||
SECNAV_GetPolicyNameString(void);
|
||||
|
||||
int
|
||||
SECNAV_InitConfigObject(void);
|
||||
|
||||
int
|
||||
SECNAV_RunInitialSecConfig(void);
|
||||
|
||||
void
|
||||
SECNAV_EarlyInit(void);
|
||||
|
||||
void
|
||||
SECNAV_Init(void);
|
||||
|
||||
void
|
||||
SECNAV_Shutdown(void);
|
||||
|
||||
void
|
||||
SECNAV_SecurityAdvisor(void *proto_win, URL_Struct *url);
|
||||
|
||||
char *
|
||||
SECNAV_MakeCertButtonString(CERTCertificate *cert);
|
||||
|
||||
int
|
||||
SECNAV_SecURLData(char *which, NET_StreamClass *stream, MWContext *cx);
|
||||
|
||||
char *
|
||||
SECNAV_SecURLContentType(char *which);
|
||||
|
||||
int
|
||||
SECNAV_SecHandleSecurityAdvisorURL(MWContext *cx, const char *which);
|
||||
|
||||
void
|
||||
SECNAV_HandleInternalSecURL(URL_Struct *url, MWContext *cx);
|
||||
|
||||
SECStatus
|
||||
SECNAV_ComputeFortezzaProxyChallengeResponse(MWContext *context,
|
||||
char *asciiChallenge,
|
||||
char **signature_out,
|
||||
char **clientRan_out,
|
||||
char **certChain_out);
|
||||
|
||||
char *
|
||||
SECNAV_PrettySecurityStatus(int level, unsigned char *status);
|
||||
|
||||
char *
|
||||
SECNAV_SecurityVersion(PRBool longForm);
|
||||
|
||||
char *
|
||||
SECNAV_SSLCapabilities(void);
|
||||
|
||||
unsigned char *
|
||||
SECNAV_SSLSocketStatus(PRFileDesc *fd, int *return_security_level);
|
||||
|
||||
unsigned char *
|
||||
SECNAV_CopySSLSocketStatus(unsigned char *status);
|
||||
|
||||
unsigned int
|
||||
SECNAV_SSLSocketStatusLength(unsigned char *status);
|
||||
|
||||
char *
|
||||
SECNAV_SSLSocketCertString(unsigned char *status);
|
||||
|
||||
PRBool
|
||||
SECNAV_CompareCertsForRedirection(unsigned char *status1,
|
||||
unsigned char *status2);
|
||||
|
||||
CERTCertificate *
|
||||
SECNAV_CertFromSSLSocketStatus(unsigned char *status);
|
||||
|
||||
|
||||
DIGESTS *PR_CALLBACK
|
||||
SOB_calculate_digest(void XP_HUGE *data, long length);
|
||||
|
||||
int PR_CALLBACK
|
||||
SOB_verify_digest(ZIG *siglist, const char *name, DIGESTS *dig);
|
||||
|
||||
void PR_CALLBACK
|
||||
SOB_destroy (ZIG *zig);
|
||||
|
||||
char *
|
||||
SOB_get_error (int status);
|
||||
|
||||
ZIG_Context *
|
||||
SOB_find(ZIG *zig, char *pattern, int type);
|
||||
|
||||
int
|
||||
SOB_find_next(ZIG_Context *ctx, SOBITEM **it);
|
||||
|
||||
void
|
||||
SOB_find_end(ZIG_Context *ctx);
|
||||
|
||||
char *
|
||||
SOB_get_url (ZIG *zig);
|
||||
|
||||
ZIG *
|
||||
SOB_new (void);
|
||||
|
||||
int
|
||||
SOB_set_callback (int type, ZIG *zig,
|
||||
int (*fn) (int status, ZIG *zig,
|
||||
const char *metafile,
|
||||
char *pathname, char *errortext));
|
||||
|
||||
int PR_CALLBACK
|
||||
SOB_cert_attribute(int attrib, ZIG *zig, long keylen, void *key,
|
||||
void **result, unsigned long *length);
|
||||
|
||||
int PR_CALLBACK
|
||||
SOB_stash_cert(ZIG *zig, long keylen, void *key);
|
||||
|
||||
int SOB_parse_manifest(char XP_HUGE *raw_manifest, long length,
|
||||
const char *path, const char *url, ZIG *zig);
|
||||
|
||||
void
|
||||
SECNAV_signedAppletPrivileges(void *proto_win, char *javaPrin,
|
||||
char *javaTarget, char *risk, int isCert);
|
||||
|
||||
char *
|
||||
SOB_JAR_list_certs (void);
|
||||
|
||||
int
|
||||
SOB_JAR_validate_archive (char *filename);
|
||||
|
||||
void *
|
||||
SOB_JAR_new_hash (int alg);
|
||||
|
||||
void *
|
||||
SOB_JAR_hash (int alg, void *cookie, int length, void *data);
|
||||
|
||||
void *
|
||||
SOB_JAR_end_hash (int alg, void *cookie);
|
||||
|
||||
int
|
||||
SOB_JAR_sign_archive (char *nickname, char *password, char *sf, char *outsig);
|
||||
|
||||
int
|
||||
SOB_set_context (ZIG *zig, MWContext *mw);
|
||||
|
||||
int
|
||||
SOB_pass_archive(int format, char *filename, const char *url, ZIG *zig);
|
||||
|
||||
int
|
||||
SOB_get_metainfo(ZIG *zig, char *name, char *header, void **info,
|
||||
unsigned long *length);
|
||||
|
||||
int
|
||||
SOB_verified_extract(ZIG *zig, char *path, char *outpath);
|
||||
|
||||
NET_StreamClass *
|
||||
SECNAV_MakePreencryptedWriteStream(FO_Present_Types format_out, void *data,
|
||||
URL_Struct *url, MWContext *window_id);
|
||||
|
||||
SEC_END_PROTOS
|
||||
|
||||
#endif /* _SECSTUBN_H_ */
|
||||
21
mozilla/modules/softupdt/classes/Makefile
Normal file
21
mozilla/modules/softupdt/classes/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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 = ../../..
|
||||
DIRS = netscape
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
25
mozilla/modules/softupdt/classes/makefile.win
Normal file
25
mozilla/modules/softupdt/classes/makefile.win
Normal file
@@ -0,0 +1,25 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
#
|
||||
|
||||
DEPTH=..\..\..
|
||||
DIRS=netscape
|
||||
|
||||
include <$(MOZ_SRC)\ns\config\rules.mak>
|
||||
21
mozilla/modules/softupdt/classes/netscape/Makefile
Normal file
21
mozilla/modules/softupdt/classes/netscape/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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 = ../../../..
|
||||
DIRS = softupdate
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
25
mozilla/modules/softupdt/classes/netscape/makefile.win
Normal file
25
mozilla/modules/softupdt/classes/netscape/makefile.win
Normal file
@@ -0,0 +1,25 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
DIRS=softupdate
|
||||
|
||||
include <$(MOZ_SRC)\ns\config\rules.mak>
|
||||
@@ -0,0 +1,171 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* FolderSpec.java
|
||||
*
|
||||
* 1/3/97 - atotic created the class
|
||||
*/
|
||||
|
||||
package netscape.softupdate ;
|
||||
import netscape.softupdate.*;
|
||||
import netscape.security.Target;
|
||||
|
||||
/**
|
||||
* FolderSpec hides directory path from the user of the
|
||||
* SoftwareUpdate class
|
||||
* It is not visible to classes outside of the softupdate package,
|
||||
* because it is expected to change
|
||||
*
|
||||
*/
|
||||
|
||||
final class FolderSpec {
|
||||
/* This class must stay final
|
||||
* If not, an attacker could subclass it, and override GetCapTarget method */
|
||||
|
||||
private String urlPath; // Full path to the directory. Used to cache results from GetDirectoryPath
|
||||
private String folderID; // Unique string specifying a folder
|
||||
private String versionRegistryPath; // Version registry path of the package
|
||||
private String userPackageName; // Name of the package presented to the user
|
||||
|
||||
/* Error codes */
|
||||
final static int INVALID_PATH_ERR = -100;
|
||||
final static int USER_CANCELLED_ERR = -101;
|
||||
|
||||
/* Constructor
|
||||
*/
|
||||
FolderSpec( String inFolderID , String inVRPath, String inPackageName)
|
||||
{
|
||||
urlPath = null;
|
||||
folderID = inFolderID;
|
||||
versionRegistryPath = inVRPath;
|
||||
userPackageName = inPackageName;
|
||||
}
|
||||
|
||||
/*
|
||||
* GetDirectoryPath
|
||||
* returns full path to the directory in the standard URL form
|
||||
*/
|
||||
String
|
||||
GetDirectoryPath() throws SoftUpdateException
|
||||
{
|
||||
if (urlPath == null)
|
||||
{
|
||||
if (folderID.compareTo("User Pick") == 0) // Default package folder
|
||||
{
|
||||
// Try the version registry default path first
|
||||
// urlPath = VersionRegistry.getDefaultDirectory( versionRegistryPath );
|
||||
// if (urlPath == null)
|
||||
urlPath = PickDefaultDirectory();
|
||||
}
|
||||
else if (folderID.compareTo("Installed") == 0)
|
||||
{
|
||||
// Then use the Version Registry path
|
||||
urlPath = versionRegistryPath;
|
||||
}
|
||||
else
|
||||
// Built-in folder
|
||||
{
|
||||
int err = NativeGetDirectoryPath();
|
||||
if (err != 0)
|
||||
throw( new SoftUpdateException( folderID, err));
|
||||
}
|
||||
}
|
||||
return urlPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns full path to a file. Makes sure that the full path is bellow
|
||||
* this directory (security measure
|
||||
* @param relativePath relative path
|
||||
* @return full path to a file
|
||||
*/
|
||||
String MakeFullPath(String relativePath) throws SoftUpdateException
|
||||
{
|
||||
// Security check. Make sure that we do not have '.. in the name
|
||||
if ( (GetSecurityTargetID() == SoftwareUpdate.LIMITED_INSTALL) &&
|
||||
( relativePath.regionMatches(0, "..", 0, 2)))
|
||||
throw new SoftUpdateException(Strings.error_IllegalPath(), SoftwareUpdate.ILLEGAL_RELATIVE_PATH );
|
||||
String fullPath = GetDirectoryPath() + GetNativePath ( relativePath );
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
/* NativeGetDirectoryPath
|
||||
* gets a platform-specific directory path
|
||||
* stores it in urlPath
|
||||
*/
|
||||
private native int
|
||||
NativeGetDirectoryPath();
|
||||
|
||||
|
||||
/* GetNativePath
|
||||
* returns a native equivalent of a XP directory path
|
||||
*/
|
||||
private native String
|
||||
GetNativePath ( String Path );
|
||||
|
||||
|
||||
/* PickDefaultDirectory
|
||||
* asks the user for the default directory for the package
|
||||
* stores the choice
|
||||
*/
|
||||
private String
|
||||
PickDefaultDirectory() throws SoftUpdateException
|
||||
{
|
||||
urlPath = NativePickDefaultDirectory();
|
||||
|
||||
if (urlPath == null)
|
||||
throw( new SoftUpdateException(folderID, INVALID_PATH_ERR));
|
||||
|
||||
return urlPath;
|
||||
}
|
||||
|
||||
/*
|
||||
* NativePickDefaultDirectory
|
||||
* Platform-specific implementation of GetDirectoryPath
|
||||
*/
|
||||
private native String
|
||||
NativePickDefaultDirectory() throws SoftUpdateException;
|
||||
|
||||
/*
|
||||
* GetSecurityTarget
|
||||
* returns security object associated with the directory
|
||||
*/
|
||||
netscape.security.Target
|
||||
GetSecurityTarget()
|
||||
{
|
||||
int secID = GetSecurityTargetID();
|
||||
return netscape.security.Target.findTarget( SoftwareUpdate.targetNames[secID] );
|
||||
}
|
||||
|
||||
private native int
|
||||
GetSecurityTargetID();
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String path;
|
||||
try
|
||||
{
|
||||
path = GetDirectoryPath();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
path = null;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate ;
|
||||
|
||||
import java.lang.*;
|
||||
import netscape.security.PrivilegeManager;
|
||||
import netscape.security.Target;
|
||||
import netscape.security.AppletSecurity;
|
||||
|
||||
/* InstallFile
|
||||
* extracts the file to the temporary directory
|
||||
* on Complete(), copies it to the final location
|
||||
*/
|
||||
|
||||
class InstallExecute extends InstallObject {
|
||||
private String jarLocation; // Location in the JAR
|
||||
private String tempFile; // temporary file location
|
||||
private String args; // command line arguments
|
||||
private String cmdline; // constructed command-line
|
||||
|
||||
/* Constructor
|
||||
inJarLocation - location inside the JAR file
|
||||
inZigPtr - pointer to the ZIG *
|
||||
*/
|
||||
|
||||
InstallExecute(SoftwareUpdate inSoftUpdate, String inJarLocation, String inArgs)
|
||||
{
|
||||
super(inSoftUpdate);
|
||||
jarLocation = inJarLocation;
|
||||
args = inArgs;
|
||||
|
||||
/* Request impersonation privileges */
|
||||
netscape.security.PrivilegeManager privMgr;
|
||||
Target impersonation, target;
|
||||
|
||||
privMgr = AppletSecurity.getPrivilegeManager();
|
||||
impersonation = Target.findTarget( SoftwareUpdate.IMPERSONATOR );
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
|
||||
/* check the security permissions */
|
||||
target = Target.findTarget( SoftwareUpdate.targetNames[SoftwareUpdate.FULL_INSTALL] );
|
||||
|
||||
/* XXX: we need a way to indicate that a dialog box should appear.*/
|
||||
privMgr.enablePrivilege( target, softUpdate.GetPrincipal() );
|
||||
}
|
||||
|
||||
/* ExtractFile
|
||||
* Extracts file out of the JAR archive into the temp directory
|
||||
*/
|
||||
protected void ExtractFile() throws SoftUpdateException
|
||||
{
|
||||
netscape.security.PrivilegeManager privMgr;
|
||||
Target impersonation;
|
||||
Target execTarget;
|
||||
privMgr = AppletSecurity.getPrivilegeManager();
|
||||
impersonation = Target.findTarget( SoftwareUpdate.IMPERSONATOR );
|
||||
execTarget = Target.findTarget( SoftwareUpdate.targetNames[SoftwareUpdate.FULL_INSTALL] );
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( execTarget, softUpdate.GetPrincipal() );
|
||||
tempFile = softUpdate.ExtractJARFile( jarLocation, null );
|
||||
|
||||
if ( args == null || System.getProperty("os.name").startsWith("Mac") )
|
||||
cmdline = tempFile;
|
||||
else
|
||||
cmdline = tempFile+" "+args;
|
||||
}
|
||||
|
||||
/* Complete
|
||||
* Completes the install by executing the file
|
||||
* Security hazard: make sure we request the right permissions
|
||||
*/
|
||||
protected void Complete() throws SoftUpdateException
|
||||
{
|
||||
int err;
|
||||
Target execTarget;
|
||||
netscape.security.PrivilegeManager privMgr;
|
||||
Target impersonation;
|
||||
|
||||
privMgr = AppletSecurity.getPrivilegeManager();
|
||||
impersonation = Target.findTarget( SoftwareUpdate.IMPERSONATOR );
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
execTarget = Target.findTarget( SoftwareUpdate.targetNames[SoftwareUpdate.FULL_INSTALL] );
|
||||
privMgr.enablePrivilege( execTarget, softUpdate.GetPrincipal() );
|
||||
NativeComplete();
|
||||
privMgr.revertPrivilege( execTarget );
|
||||
//
|
||||
// System.out.println("File executed: " + tempFile);
|
||||
}
|
||||
|
||||
protected void Abort()
|
||||
{
|
||||
NativeAbort();
|
||||
}
|
||||
|
||||
private native void NativeComplete() throws SoftUpdateException;
|
||||
private native void NativeAbort();
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return Strings.details_ExecuteProgress() + tempFile; // Needs I10n
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate ;
|
||||
|
||||
import netscape.softupdate.*;
|
||||
import netscape.util.*;
|
||||
import java.lang.*;
|
||||
import netscape.security.PrivilegeManager;
|
||||
import netscape.security.Target;
|
||||
import netscape.security.AppletSecurity;
|
||||
|
||||
/* InstallFile
|
||||
* extracts the file to the temporary directory
|
||||
* on Complete(), copies it to the final location
|
||||
*/
|
||||
|
||||
final class InstallFile extends InstallObject {
|
||||
|
||||
private String vrName; // Name of the component
|
||||
private VersionInfo versionInfo; // Version
|
||||
private String jarLocation; // Location in the JAR
|
||||
private String tempFile; // temporary file location
|
||||
private String finalFile; // final file destination
|
||||
private netscape.security.Target target; // security target
|
||||
private boolean force; // whether install is forced
|
||||
|
||||
/* Constructor
|
||||
inSoftUpdate - softUpdate object we belong to
|
||||
inComponentName - full path of the registry component
|
||||
inVInfo - full version info
|
||||
inJarLocation - location inside the JAR file
|
||||
inFinalFileSpec - final location on disk
|
||||
*/
|
||||
|
||||
InstallFile(SoftwareUpdate inSoftUpdate,
|
||||
String inVRName,
|
||||
VersionInfo inVInfo,
|
||||
String inJarLocation,
|
||||
FolderSpec folderSpec,
|
||||
String inPartialPath,
|
||||
boolean forceInstall) throws SoftUpdateException
|
||||
{
|
||||
super(inSoftUpdate);
|
||||
tempFile = null;
|
||||
vrName = inVRName;
|
||||
versionInfo = inVInfo;
|
||||
jarLocation = inJarLocation;
|
||||
force = forceInstall;
|
||||
finalFile = folderSpec.MakeFullPath( inPartialPath );
|
||||
|
||||
/* Request impersonation privileges */
|
||||
netscape.security.PrivilegeManager privMgr;
|
||||
Target impersonation;
|
||||
|
||||
privMgr = AppletSecurity.getPrivilegeManager();
|
||||
impersonation = Target.findTarget( SoftwareUpdate.IMPERSONATOR );
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
|
||||
/* check the security permissions */
|
||||
target = folderSpec.GetSecurityTarget();
|
||||
|
||||
/* XXX: we need a way to indicate that a dialog box should appear. */
|
||||
privMgr.enablePrivilege( target, softUpdate.GetPrincipal() );
|
||||
}
|
||||
|
||||
/* ExtractFile
|
||||
* Extracts file out of the JAR archive into the temp directory
|
||||
*/
|
||||
protected void ExtractFile() throws SoftUpdateException
|
||||
{
|
||||
netscape.security.PrivilegeManager privMgr;
|
||||
Target impersonation;
|
||||
|
||||
privMgr = AppletSecurity.getPrivilegeManager();
|
||||
impersonation = Target.findTarget( SoftwareUpdate.IMPERSONATOR );
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, softUpdate.GetPrincipal() );
|
||||
tempFile = softUpdate.ExtractJARFile( jarLocation, finalFile );
|
||||
}
|
||||
|
||||
/* Complete
|
||||
* Completes the install:
|
||||
* - move the downloaded file to the final location
|
||||
* - updates the registry
|
||||
*/
|
||||
protected void Complete() throws SoftUpdateException
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Check the security for our target */
|
||||
netscape.security.PrivilegeManager privMgr;
|
||||
Target impersonation;
|
||||
|
||||
privMgr = AppletSecurity.getPrivilegeManager();
|
||||
impersonation = Target.findTarget( SoftwareUpdate.IMPERSONATOR );
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, softUpdate.GetPrincipal() );
|
||||
err = NativeComplete();
|
||||
privMgr.revertPrivilege(target);
|
||||
|
||||
if ( 0 == err || SoftwareUpdate.REBOOT_NEEDED == err )
|
||||
{
|
||||
VersionRegistry.installComponent(vrName, finalFile, versionInfo);
|
||||
if ( err != 0 )
|
||||
throw( new SoftUpdateException(finalFile, err));
|
||||
}
|
||||
else
|
||||
throw( new SoftUpdateException(Strings.error_InstallFileUnexpected() + finalFile, err));
|
||||
|
||||
// Eventually, put extracted files into proper locations
|
||||
// System.out.println("File installed: " + finalFile);
|
||||
}
|
||||
|
||||
protected void Abort()
|
||||
{
|
||||
NativeAbort();
|
||||
}
|
||||
|
||||
private native void NativeAbort();
|
||||
private native int NativeComplete();
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Copy file to " + finalFile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate ;
|
||||
|
||||
import netscape.softupdate.*;
|
||||
import netscape.util.*;
|
||||
import java.lang.*;
|
||||
|
||||
/*
|
||||
* InstallObject
|
||||
* abstract class for things that get installed
|
||||
* encapsulates a single action
|
||||
* The way your subclass is used:
|
||||
* Constructor should collect all the data needed to perform the action
|
||||
* Complete() is called to complete the action
|
||||
* Abort() is called when update is aborted
|
||||
* You are guaranteed to be called with Complete() or Abort() before finalize
|
||||
* If your Complete() throws, you'll also get called with an Abort()
|
||||
*/
|
||||
|
||||
abstract class InstallObject {
|
||||
|
||||
SoftwareUpdate softUpdate;
|
||||
|
||||
InstallObject(SoftwareUpdate inSoftUpdate)
|
||||
{
|
||||
softUpdate = (SoftwareUpdate) inSoftUpdate;
|
||||
}
|
||||
|
||||
/* Override with your action */
|
||||
abstract protected void Complete() throws SoftUpdateException;
|
||||
|
||||
/* Override with an explanatory string for the progress dialog */
|
||||
abstract public String toString();
|
||||
|
||||
/* Override with your clean-up function */
|
||||
abstract protected void Abort();
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate;
|
||||
|
||||
import netscape.softupdate.*;
|
||||
import netscape.util.*;
|
||||
import java.lang.*;
|
||||
import netscape.security.PrivilegeManager;
|
||||
import netscape.security.Target;
|
||||
import netscape.security.AppletSecurity;
|
||||
|
||||
/* InstallFile
|
||||
* extracts the file to the temporary directory
|
||||
* on Complete(), copies it to the final location
|
||||
*/
|
||||
|
||||
final class InstallPatch extends InstallObject {
|
||||
|
||||
private String vrName; // Registry name of the component
|
||||
private VersionInfo versionInfo; // Version
|
||||
private String jarLocation; // Location in the JAR
|
||||
private String patchURL; // extracted location of diff (xpURL)
|
||||
private String targetfile; // source and final file (native)
|
||||
private String patchedfile; // temp name of patched file
|
||||
|
||||
/* Constructor
|
||||
inSoftUpdate - softUpdate object we belong to
|
||||
inVRName - full path of the registry component
|
||||
inVInfo - full version info
|
||||
inJarLocation - location inside the JAR file
|
||||
folderspec - FolderSpec of target file
|
||||
inPartialPath - target file on disk relative to folderspec
|
||||
*/
|
||||
|
||||
InstallPatch(SoftwareUpdate inSoftUpdate,
|
||||
String inVRName,
|
||||
VersionInfo inVInfo,
|
||||
String inJarLocation) throws SoftUpdateException
|
||||
{
|
||||
super( inSoftUpdate );
|
||||
|
||||
vrName = inVRName;
|
||||
versionInfo = inVInfo;
|
||||
jarLocation = inJarLocation;
|
||||
|
||||
targetfile = VersionRegistry.componentPath( vrName );
|
||||
if ( targetfile == null )
|
||||
throw new SoftUpdateException("", SoftwareUpdate.NO_SUCH_COMPONENT);
|
||||
|
||||
checkPrivileges();
|
||||
}
|
||||
|
||||
|
||||
InstallPatch(SoftwareUpdate inSoftUpdate,
|
||||
String inVRName,
|
||||
VersionInfo inVInfo,
|
||||
String inJarLocation,
|
||||
FolderSpec folderSpec,
|
||||
String inPartialPath) throws SoftUpdateException
|
||||
{
|
||||
super( inSoftUpdate );
|
||||
|
||||
vrName = inVRName;
|
||||
versionInfo = inVInfo;
|
||||
jarLocation = inJarLocation;
|
||||
|
||||
targetfile = folderSpec.MakeFullPath( inPartialPath );
|
||||
|
||||
checkPrivileges();
|
||||
}
|
||||
|
||||
|
||||
private void checkPrivileges()
|
||||
{
|
||||
// This won't actually give us these privileges because
|
||||
// we lose them again as soon as the function returns. But we
|
||||
// don't really need the privs, we're just checking security
|
||||
|
||||
PrivilegeManager privMgr = AppletSecurity.getPrivilegeManager();
|
||||
|
||||
Target impersonation =
|
||||
Target.findTarget( SoftwareUpdate.IMPERSONATOR );
|
||||
|
||||
Target priv = Target.findTarget(
|
||||
SoftwareUpdate.targetNames[ SoftwareUpdate.FULL_INSTALL ] );
|
||||
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( priv, softUpdate.GetPrincipal() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void ApplyPatch() throws SoftUpdateException
|
||||
{
|
||||
String srcname;
|
||||
boolean deleteOldSrc;
|
||||
|
||||
checkPrivileges();
|
||||
|
||||
patchURL = softUpdate.ExtractJARFile( jarLocation, targetfile );
|
||||
|
||||
if ( softUpdate.patchList.containsKey( targetfile ) ) {
|
||||
srcname = (String)softUpdate.patchList.get( targetfile );
|
||||
deleteOldSrc = true;
|
||||
}
|
||||
else {
|
||||
srcname = targetfile;
|
||||
deleteOldSrc = false;
|
||||
}
|
||||
|
||||
patchedfile = NativePatch( srcname, patchURL );
|
||||
|
||||
if ( patchedfile != null ) {
|
||||
softUpdate.patchList.put( targetfile, patchedfile );
|
||||
}
|
||||
else {
|
||||
throw new SoftUpdateException( targetfile + " not patched",
|
||||
SoftwareUpdate.UNEXPECTED_ERROR );
|
||||
}
|
||||
|
||||
if ( deleteOldSrc ) {
|
||||
NativeDeleteFile( srcname );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Complete
|
||||
* Completes the install:
|
||||
* - move the patched file to the final location
|
||||
* - updates the registry
|
||||
*/
|
||||
protected void Complete() throws SoftUpdateException
|
||||
{
|
||||
int err;
|
||||
|
||||
checkPrivileges();
|
||||
|
||||
String tmp = (String)softUpdate.patchList.get( targetfile );
|
||||
if ( tmp.compareTo( patchedfile ) == 0 )
|
||||
{
|
||||
// the patch has not been superceded--do final replacement
|
||||
|
||||
err = NativeReplace( targetfile, patchedfile );
|
||||
|
||||
if ( 0 == err || SoftwareUpdate.REBOOT_NEEDED == err )
|
||||
{
|
||||
VersionRegistry.installComponent(
|
||||
vrName, targetfile, versionInfo);
|
||||
|
||||
if ( err != 0 )
|
||||
throw new SoftUpdateException(targetfile, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SoftUpdateException(
|
||||
Strings.error_InstallFileUnexpected() + targetfile, err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// nothing -- old intermediate patched file was
|
||||
// deleted by superceding patch
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void Abort()
|
||||
{
|
||||
String tmp = (String)softUpdate.patchList.get( targetfile );
|
||||
if ( tmp.compareTo( patchedfile ) == 0 )
|
||||
NativeDeleteFile( patchedfile );
|
||||
}
|
||||
|
||||
|
||||
private native String NativePatch( String srcfile, String diffURL );
|
||||
private native int NativeReplace( String target, String tmpfile );
|
||||
private native void NativeDeleteFile( String file );
|
||||
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Patch " + targetfile + " (" + versionInfo + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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 = ../../../../..
|
||||
|
||||
PACKAGE = netscape/softupdate
|
||||
|
||||
JSRCS = FolderSpec.java \
|
||||
InstallExecute.java \
|
||||
InstallFile.java \
|
||||
InstallPatch.java \
|
||||
InstallObject.java \
|
||||
ProgressDetails.java \
|
||||
ProgressMediator.java \
|
||||
ProgressWindow.java \
|
||||
RegEntryEnumerator.java \
|
||||
Registry.java \
|
||||
RegistryErrors.java \
|
||||
RegistryException.java \
|
||||
RegistryNode.java \
|
||||
RegKeyEnumerator.java \
|
||||
SoftUpdateException.java \
|
||||
SoftUpdateResourceBundle.java \
|
||||
SoftwareUpdate.java \
|
||||
Strings.java \
|
||||
SymProgressDetails.java \
|
||||
SymProgressWindow.java \
|
||||
Trigger.java \
|
||||
VersionInfo.java \
|
||||
VersionRegistry.java \
|
||||
WinProfile.java \
|
||||
WinProfileItem.java \
|
||||
WinReg.java \
|
||||
WinRegItem.java \
|
||||
WinRegValue.java \
|
||||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
JAVA_SOURCEPATH = $(DEPTH)/modules/softupdt/classes
|
||||
@@ -0,0 +1,59 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* ProgressWindow
|
||||
*
|
||||
*/
|
||||
|
||||
package netscape.softupdate ;
|
||||
|
||||
import java.awt.* ;
|
||||
|
||||
class ProgressDetails extends SymProgressDetails
|
||||
{
|
||||
ProgressMediator pm;
|
||||
|
||||
public ProgressDetails(ProgressMediator inPm)
|
||||
{
|
||||
pm = inPm;
|
||||
label1.setText("");
|
||||
btnCancel.setLabel(Strings.getString("s36"));
|
||||
}
|
||||
|
||||
protected void
|
||||
finalize() throws Throwable {
|
||||
super.finalize();
|
||||
if (pm != null)
|
||||
pm.DetailsHidden();
|
||||
}
|
||||
|
||||
void btnCancel_Clicked(Event event) {
|
||||
hide();
|
||||
dispose();
|
||||
}
|
||||
|
||||
public synchronized void hide()
|
||||
{
|
||||
super.hide();
|
||||
if (pm != null)
|
||||
{
|
||||
pm.DetailsHidden();
|
||||
pm = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* ProgressMediator.java 4/16/97
|
||||
* @author atotic
|
||||
*/
|
||||
|
||||
package netscape.softupdate;
|
||||
|
||||
/**
|
||||
* Relays progress messages, and displays status
|
||||
* in the progress window
|
||||
*/
|
||||
|
||||
class ProgressMediator {
|
||||
|
||||
private ProgressWindow progress; // Progress window, guard against null when derefing
|
||||
private ProgressDetails details; // Details window
|
||||
private SoftwareUpdate su; // Object whose progress we are monitoring
|
||||
|
||||
ProgressMediator( SoftwareUpdate inSu)
|
||||
{
|
||||
su = inSu;
|
||||
progress = null;
|
||||
details = null;
|
||||
}
|
||||
protected void
|
||||
finalize() throws Throwable
|
||||
{
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
/* Hide and dereference all the windows */
|
||||
private void
|
||||
CleanUp()
|
||||
{
|
||||
if ( progress != null )
|
||||
{
|
||||
//ProgressWindow p2 = progress;
|
||||
progress.hide();
|
||||
progress.dispose();
|
||||
}
|
||||
if ( details != null)
|
||||
details.btnCancel_Clicked(null);
|
||||
progress = null;
|
||||
details = null;
|
||||
su = null;
|
||||
}
|
||||
|
||||
private void
|
||||
ShowProgress()
|
||||
{
|
||||
if ( su.GetSilent())
|
||||
return;
|
||||
if ( progress == null )
|
||||
progress = new ProgressWindow(this);
|
||||
|
||||
progress.toFront();
|
||||
progress.show();
|
||||
progress.toFront();
|
||||
}
|
||||
|
||||
/* Shows the details window */
|
||||
private void
|
||||
ShowDetails()
|
||||
{
|
||||
if ( su.GetSilent())
|
||||
return;
|
||||
|
||||
if (details == null)
|
||||
{
|
||||
details = new ProgressDetails(this);
|
||||
// Text
|
||||
details.setTitle( Strings.details_WinTitle() + su.GetUserPackageName() );
|
||||
details.label1.setText(Strings.details_Explain(su.GetUserPackageName()));
|
||||
// Fill in the current progress of the install
|
||||
java.util.Enumeration e = su.GetInstallQueue();
|
||||
while ( e.hasMoreElements() )
|
||||
{
|
||||
InstallObject ie = (InstallObject)e.nextElement();
|
||||
details.detailArea.appendText(ie.toString() + "\n");
|
||||
}
|
||||
details.show();
|
||||
|
||||
}
|
||||
details.toFront();
|
||||
}
|
||||
|
||||
|
||||
protected void
|
||||
DetailsHidden()
|
||||
{
|
||||
details = null;
|
||||
}
|
||||
|
||||
/* ProgressWindow API */
|
||||
|
||||
protected void
|
||||
UserCancelled()
|
||||
{
|
||||
if (su != null)
|
||||
su.UserCancelled();
|
||||
}
|
||||
|
||||
protected void
|
||||
UserApproved()
|
||||
{
|
||||
if (su != null)
|
||||
su.UserApproved();
|
||||
}
|
||||
|
||||
protected void
|
||||
MoreInfo()
|
||||
{
|
||||
ShowDetails();
|
||||
}
|
||||
|
||||
/* SofwareUpdate API bellow */
|
||||
|
||||
protected void
|
||||
StartInstall()
|
||||
{
|
||||
ShowProgress();
|
||||
if (progress != null)
|
||||
{
|
||||
// Set up the text
|
||||
progress.setTitle(Strings.progress_Title() + su.GetUserPackageName());
|
||||
progress.status.setText(Strings.progress_GettingReady() + su.GetUserPackageName());
|
||||
progress.progress.setText("");
|
||||
// Disable/enable controls
|
||||
progress.install.disable();
|
||||
}
|
||||
}
|
||||
|
||||
protected void
|
||||
ConfirmWithUser()
|
||||
{
|
||||
ShowProgress();
|
||||
if ( progress != null )
|
||||
{
|
||||
progress.progress.setText("");
|
||||
progress.status.setText(Strings.progress_ReadyToInstall1() +
|
||||
su.GetUserPackageName());
|
||||
progress.install.enable();
|
||||
}
|
||||
else // Give user approval right away if there is no UI
|
||||
UserApproved();
|
||||
}
|
||||
|
||||
/* Add it to the details list if showing */
|
||||
protected void
|
||||
ScheduleForInstall(InstallObject install)
|
||||
{
|
||||
String s = install.toString();
|
||||
if (progress != null) // Display text in progress area
|
||||
progress.progress.setText(s);
|
||||
if (details != null)
|
||||
details.detailArea.appendText(s + "\n");
|
||||
}
|
||||
|
||||
/* SmartUpdate is done */
|
||||
void
|
||||
Complete()
|
||||
{
|
||||
CleanUp();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* ProgressWindow
|
||||
*
|
||||
*/
|
||||
|
||||
package netscape.softupdate ;
|
||||
|
||||
import java.awt.* ;
|
||||
|
||||
class ProgressWindow extends SymProgressWindow
|
||||
{
|
||||
ProgressMediator pm;
|
||||
|
||||
public ProgressWindow(ProgressMediator inPm)
|
||||
{
|
||||
pm = inPm;
|
||||
install.setLabel(Strings.getString("s33"));
|
||||
cancel.setLabel(Strings.getString("s34"));
|
||||
info.setLabel(Strings.getString("s35"));
|
||||
}
|
||||
|
||||
void cancel_Clicked(Event event)
|
||||
{
|
||||
pm.UserCancelled();
|
||||
}
|
||||
|
||||
void install_Clicked(Event event)
|
||||
{
|
||||
pm.UserApproved();
|
||||
}
|
||||
|
||||
void info_Clicked(Event event) {
|
||||
pm.MoreInfo();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
import netscape.security.PrivilegeManager;
|
||||
|
||||
/**
|
||||
* Helper class used to enumerate Registry subkeys
|
||||
* @see RegistryNode#entries
|
||||
*/
|
||||
final class RegEntryEnumerator implements Enumeration {
|
||||
private String name = "";
|
||||
private Registry reg = null;
|
||||
private int key = 0;
|
||||
private int state = 0;
|
||||
private String target;
|
||||
|
||||
RegEntryEnumerator(Registry registry, int startKey, String targ)
|
||||
{
|
||||
reg = registry;
|
||||
key = startKey;
|
||||
target = targ;
|
||||
}
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
String tmp = regNext(false);
|
||||
|
||||
return (tmp != null);
|
||||
}
|
||||
|
||||
public Object nextElement() {
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
name = regNext(true);
|
||||
if (name == null) {
|
||||
throw new NoSuchElementException("RegEntryEnumerator");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private native String regNext(boolean skip);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
import netscape.security.PrivilegeManager;
|
||||
|
||||
/**
|
||||
* Helper class used to enumerate Registry subkeys
|
||||
* @see RegistryNode#subkeys
|
||||
*/
|
||||
final class RegKeyEnumerator implements Enumeration {
|
||||
private String path = "";
|
||||
private Registry reg = null;
|
||||
private int key = 0;
|
||||
private int state = 0;
|
||||
private int style = 0;
|
||||
private String target;
|
||||
|
||||
RegKeyEnumerator(Registry registry, int startKey, int enumStyle, String targ)
|
||||
{
|
||||
reg = registry;
|
||||
key = startKey;
|
||||
style = enumStyle;
|
||||
target = targ;
|
||||
}
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
String tmp = regNext(false);
|
||||
|
||||
return (tmp != null);
|
||||
}
|
||||
|
||||
public Object nextElement() {
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
path = regNext(true);
|
||||
if (path == null) {
|
||||
throw new NoSuchElementException("RegKeyEnumerator");
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
private native String regNext(boolean skip);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* Registry.java
|
||||
*
|
||||
*/
|
||||
package netscape.softupdate ;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
import netscape.security.PrivilegeManager;
|
||||
import netscape.security.Principal;
|
||||
import netscape.security.Target;
|
||||
import netscape.security.UserTarget;
|
||||
import netscape.security.ForbiddenTargetException;
|
||||
|
||||
/**
|
||||
* The Registry class is a Java wrapper
|
||||
* around the Navigator's built-in Cross-Platform Registry.
|
||||
*
|
||||
* @version 1.0 97/2/23
|
||||
* @author Daniel Veditz
|
||||
*/
|
||||
public final class Registry implements RegistryErrors {
|
||||
|
||||
/*------------------
|
||||
* constants
|
||||
*------------------
|
||||
*/
|
||||
protected final static int ROOTKEY_USERS = 1;
|
||||
protected final static int ROOTKEY_COMMON = 2;
|
||||
protected final static int ROOTKEY_CURRENT_USER = 3;
|
||||
protected final static int ROOTKEY_PRIVATE = 4;
|
||||
protected final static int ROOTKEY = 32;
|
||||
protected final static int ROOTKEY_VERSIONS = 33;
|
||||
protected final static int PRIVATE_KEY_COMMON = -2;
|
||||
protected final static int PRIVATE_KEY_USER = -3;
|
||||
|
||||
/* the following statics are actually used by RegistryNode objects,
|
||||
* but that's not a public class--Registry is what people will use.
|
||||
*/
|
||||
protected final static int ENUM_NORMAL = 0;
|
||||
protected final static int ENUM_DESCEND = 1;
|
||||
|
||||
public final static int TYPE_STRING = 0x11;
|
||||
public final static int TYPE_INT_ARRAY = 0x12;
|
||||
public final static int TYPE_BYTES = 0x13;
|
||||
|
||||
private static final String PRIVATE = "PrivateRegistryAccess";
|
||||
private static final String STANDARD = "StandardRegistryAccess";
|
||||
private static final String ADMIN = "AdministratorRegistryAccess";
|
||||
|
||||
/*
|
||||
* Private data members
|
||||
*/
|
||||
private int hReg = 0;
|
||||
private String regName;
|
||||
private String username = null;
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
/**
|
||||
* The no-arg constructor refers to standard netscape registry.
|
||||
*/
|
||||
public Registry() throws RegistryException {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a registry object for the named registry and opens it
|
||||
* (private for now, could be exposed later)
|
||||
*/
|
||||
private Registry(String name) throws RegistryException {
|
||||
regName = name;
|
||||
|
||||
// ensure minimal registry privileges
|
||||
PrivilegeManager.checkPrivilegeEnabled( PRIVATE );
|
||||
|
||||
int status = nOpen();
|
||||
if ( status != REGERR_OK )
|
||||
throw new RegistryException(status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Primary methods, wrappers for native calls plus security
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Add a node to the registry
|
||||
*/
|
||||
public RegistryNode
|
||||
addNode(RegistryNode root, String key) throws RegistryException
|
||||
{
|
||||
int rootkey;
|
||||
String roottarg;
|
||||
if ( root == null ) {
|
||||
roottarg = ADMIN;
|
||||
rootkey = ROOTKEY;
|
||||
}
|
||||
else {
|
||||
roottarg = root.getTarget();
|
||||
rootkey = root.getKey();
|
||||
}
|
||||
|
||||
PrivilegeManager.checkPrivilegeEnabled( roottarg );
|
||||
int status = nAddKey( rootkey, key );
|
||||
if ( status != REGERR_OK )
|
||||
throw new RegistryException(status);
|
||||
|
||||
return nGetKey( rootkey, key, roottarg );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete a node from the registry
|
||||
*/
|
||||
public void
|
||||
deleteNode(RegistryNode root, String key) throws RegistryException
|
||||
{
|
||||
int rootkey;
|
||||
String roottarg;
|
||||
if ( root == null ) {
|
||||
roottarg = ADMIN;
|
||||
rootkey = ROOTKEY;
|
||||
}
|
||||
else {
|
||||
roottarg = root.getTarget();
|
||||
rootkey = root.getKey();
|
||||
}
|
||||
|
||||
PrivilegeManager.checkPrivilegeEnabled( roottarg );
|
||||
int status = nDeleteKey( rootkey, key );
|
||||
if ( status != REGERR_OK )
|
||||
throw new RegistryException(status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get a node object for further registry manipulation
|
||||
*/
|
||||
public RegistryNode
|
||||
getNode(RegistryNode root, String key) throws RegistryException
|
||||
{
|
||||
int rootkey;
|
||||
String roottarg;
|
||||
if ( root == null ) {
|
||||
roottarg = ADMIN;
|
||||
rootkey = ROOTKEY;
|
||||
}
|
||||
else {
|
||||
roottarg = root.getTarget();
|
||||
rootkey = root.getKey();
|
||||
}
|
||||
|
||||
PrivilegeManager.checkPrivilegeEnabled( roottarg );
|
||||
|
||||
return nGetKey( rootkey, key, roottarg );
|
||||
}
|
||||
|
||||
|
||||
public Enumeration
|
||||
children(RegistryNode root, String key) throws RegistryException
|
||||
{
|
||||
RegistryNode node = getNode(root, key);
|
||||
|
||||
return new RegKeyEnumerator(this, node.getKey(),
|
||||
ENUM_NORMAL, node.getTarget());
|
||||
}
|
||||
|
||||
|
||||
public Enumeration
|
||||
subtree(RegistryNode root, String key) throws RegistryException
|
||||
{
|
||||
RegistryNode node = getNode(root, key);
|
||||
|
||||
return new RegKeyEnumerator(this, node.getKey(),
|
||||
ENUM_DESCEND, node.getTarget());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Get starting nodes of varying privileges
|
||||
*/
|
||||
|
||||
public RegistryNode
|
||||
getSharedNode() throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( STANDARD );
|
||||
return nGetKey( ROOTKEY_COMMON, "", STANDARD );
|
||||
}
|
||||
|
||||
|
||||
public RegistryNode
|
||||
getSharedUserNode() throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( STANDARD );
|
||||
return nGetKey( ROOTKEY_CURRENT_USER, "", STANDARD );
|
||||
}
|
||||
|
||||
|
||||
public RegistryNode
|
||||
getPrivateNode() throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( PRIVATE );
|
||||
|
||||
Principal[] p =
|
||||
PrivilegeManager.getPrivilegeManager().getClassPrincipalsFromStack(1);
|
||||
if ( p == null ) {
|
||||
System.out.println("Registry called without principals");
|
||||
throw new NullPointerException("Registry called without principals");
|
||||
}
|
||||
|
||||
String key = "/"+p[0].getFingerPrint()+"/Common";
|
||||
|
||||
int status = nAddKey( ROOTKEY_PRIVATE, key );
|
||||
if ( status != REGERR_OK )
|
||||
throw new RegistryException(status);
|
||||
|
||||
return nGetKey( ROOTKEY_PRIVATE, key, PRIVATE );
|
||||
}
|
||||
|
||||
|
||||
public RegistryNode
|
||||
getPrivateUserNode() throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( PRIVATE );
|
||||
|
||||
Principal[] p =
|
||||
PrivilegeManager.getPrivilegeManager().getClassPrincipalsFromStack(1);
|
||||
if ( p == null ) {
|
||||
System.out.println("Registry called without principals");
|
||||
throw new NullPointerException("Registry called without principals");
|
||||
}
|
||||
|
||||
String key = "/"+p[0].getFingerPrint()+"/Users/"+userName();
|
||||
|
||||
int status = nAddKey( ROOTKEY_PRIVATE, key );
|
||||
if ( status != REGERR_OK )
|
||||
throw new RegistryException(status);
|
||||
|
||||
return nGetKey( ROOTKEY_PRIVATE, key, PRIVATE );
|
||||
}
|
||||
|
||||
/*
|
||||
* private methods
|
||||
*/
|
||||
protected void finalize() throws Throwable {
|
||||
if ( hReg != 0 )
|
||||
nClose();
|
||||
}
|
||||
|
||||
private String userName()
|
||||
{
|
||||
if ( username == null )
|
||||
username = nUserName();
|
||||
|
||||
return username;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* native methods
|
||||
*/
|
||||
private native int nOpen();
|
||||
private native int nClose();
|
||||
private native int nAddKey(int root, String key);
|
||||
private native int nDeleteKey(int root, String key);
|
||||
private native RegistryNode nGetKey(int root, String key, String targ);
|
||||
private native String nUserName();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* RegistryErrors
|
||||
*
|
||||
* This interface defines the error return codes used by the Registry
|
||||
* and VersionRegistry classes and related helper classes. Many of these
|
||||
* errors should never be returned by the Java interface to the registry,
|
||||
* but the complete list is included just in case...
|
||||
*/
|
||||
package netscape.softupdate;
|
||||
|
||||
public interface RegistryErrors {
|
||||
|
||||
public static final int REGERR_OK = 0;
|
||||
public static final int REGERR_FAIL = 1;
|
||||
public static final int REGERR_NOMORE = 2;
|
||||
public static final int REGERR_NOFIND = 3;
|
||||
public static final int REGERR_BADREAD = 4;
|
||||
public static final int REGERR_BADLOCN = 5;
|
||||
public static final int REGERR_PARAM = 6;
|
||||
public static final int REGERR_BADMAGIC = 7;
|
||||
public static final int REGERR_BADCHECK = 8;
|
||||
public static final int REGERR_NOFILE = 9;
|
||||
public static final int REGERR_MEMORY = 10;
|
||||
public static final int REGERR_BUFTOOSMALL = 11;
|
||||
public static final int REGERR_NAMETOOLONG = 12;
|
||||
public static final int REGERR_REGVERSION = 13;
|
||||
public static final int REGERR_DELETED = 14;
|
||||
public static final int REGERR_BADTYPE = 15;
|
||||
public static final int REGERR_NOPATH = 16;
|
||||
public static final int REGERR_BADNAME = 17;
|
||||
public static final int REGERR_READONLY = 18;
|
||||
|
||||
public static final int REGERR_SECURITY = 99;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* RegistryException.java
|
||||
*/
|
||||
|
||||
package netscape.softupdate;
|
||||
|
||||
/*
|
||||
* Registry exception class
|
||||
*/
|
||||
|
||||
public class RegistryException extends Exception {
|
||||
|
||||
|
||||
public RegistryException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
RegistryException(int err) {
|
||||
super("Error "+Integer.toString(err));
|
||||
}
|
||||
|
||||
public RegistryException() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* RegistryNode.java
|
||||
*/
|
||||
package netscape.softupdate ;
|
||||
|
||||
import netscape.softupdate.Registry;
|
||||
import java.util.Enumeration;
|
||||
import netscape.security.PrivilegeManager;
|
||||
|
||||
/**
|
||||
* The RegistryNode class represents a node in an open registry
|
||||
*/
|
||||
public final class RegistryNode implements RegistryErrors {
|
||||
|
||||
/*
|
||||
* Private data members
|
||||
*/
|
||||
private Registry reg;
|
||||
private int key;
|
||||
private String target;
|
||||
|
||||
protected int getKey() { return key; }
|
||||
protected String getTarget() { return target; }
|
||||
|
||||
/**
|
||||
* The constructor is private so this class can only be created
|
||||
* by the native method Registry::nGetKey()
|
||||
*/
|
||||
private RegistryNode(Registry parent, int rootKey, String targ)
|
||||
{
|
||||
reg = parent;
|
||||
key = rootKey;
|
||||
target = targ;
|
||||
}
|
||||
|
||||
|
||||
public Enumeration properties()
|
||||
{
|
||||
return new RegEntryEnumerator(reg, key, target);
|
||||
}
|
||||
|
||||
|
||||
public void
|
||||
deleteProperty(String name) throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
int status = nDeleteEntry(name);
|
||||
if (REGERR_OK != status)
|
||||
throw new RegistryException(status);
|
||||
}
|
||||
|
||||
|
||||
public int
|
||||
getPropertyType(String name) throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
int status = nGetEntryType( name );
|
||||
|
||||
if ( status < 0 )
|
||||
throw new RegistryException(-status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
public Object
|
||||
getProperty(String name) throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
return nGetEntry( name );
|
||||
}
|
||||
|
||||
|
||||
/* the following ugliness is due to a javah bug that can't
|
||||
* entirely handle overloaded methods. (The implementations
|
||||
* are unique, but the native stub redirection isn't.)
|
||||
*/
|
||||
public void
|
||||
setProperty(String name, String value) throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
int status = setEntryS(name, value);
|
||||
if (status != REGERR_OK)
|
||||
throw new RegistryException(status);
|
||||
}
|
||||
|
||||
public void
|
||||
setProperty(String name, int[] value) throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
int status = setEntryI(name, value);
|
||||
if (status != REGERR_OK)
|
||||
throw new RegistryException(status);
|
||||
}
|
||||
|
||||
public void
|
||||
setProperty(String name, byte[] value) throws RegistryException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled( target );
|
||||
int status = setEntryB(name, value);
|
||||
if (status != REGERR_OK)
|
||||
throw new RegistryException(status);
|
||||
}
|
||||
|
||||
|
||||
private native int nDeleteEntry(String name);
|
||||
private native int nGetEntryType(String name);
|
||||
private native Object nGetEntry(String name);
|
||||
private native int setEntryS(String name, String value);
|
||||
private native int setEntryI(String name, int[] value);
|
||||
private native int setEntryB(String name, byte[] value);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* SoftUpdateException.java
|
||||
*
|
||||
* 1/7/97 - atotic created the class
|
||||
*/
|
||||
|
||||
package netscape.softupdate;
|
||||
|
||||
/*
|
||||
* FolderSpec exception class
|
||||
*/
|
||||
|
||||
class SoftUpdateException extends Exception {
|
||||
|
||||
int err; // error code
|
||||
|
||||
/* Constructor
|
||||
* reason is the error code
|
||||
*/
|
||||
SoftUpdateException(String message, int reason)
|
||||
{
|
||||
super(message);
|
||||
err = reason;
|
||||
if ( (message != null) && ( message.length() > 0 ))
|
||||
System.out.println(message + " " + String.valueOf(err));
|
||||
// printStackTrace();
|
||||
}
|
||||
|
||||
int GetError()
|
||||
{
|
||||
return err;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/* Internationalization of string resources for SoftwareUpdate
|
||||
*/
|
||||
package netscape.softupdate;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
public class SoftUpdateResourceBundle extends ListResourceBundle {
|
||||
|
||||
/**
|
||||
* Overrides ListResourceBundle
|
||||
*/
|
||||
public Object[][] getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
static final Object[][] contents = {
|
||||
// Non-Localizable Key // localize these strings
|
||||
{"s1", "Low"},
|
||||
{"s2", "Medium"},
|
||||
{"s3", "High"},
|
||||
{"s4", "Installing Java software on your computer."},
|
||||
{"s5", "Installing and running software on your computer. "},
|
||||
{"s6", "Installing and running software without warning you."},
|
||||
{"s7", "Reading and writing to a windows .INI file"},
|
||||
{"s8", "Reading and writing to the Windows Registry: Use extreme caution!"},
|
||||
{"s9", "SmartUpdate: "},
|
||||
{"s10", "Getting ready to install "},
|
||||
{"s11", "Press \"Install\" to install "},
|
||||
{"s12", ""},
|
||||
{"s13", "Installing "},
|
||||
{"s14", " will perform actions listed bellow:"},
|
||||
{"s15", "Detailed SmartUpdate information: "},
|
||||
{"s16", "Execute a program:"},
|
||||
{"s17", "SmartUpdate:"},
|
||||
{"s18", "Installer script does not have a certificate."},
|
||||
{"s19", "Installer script had more than one certificate"},
|
||||
{"s20", "Silent mode was denied."},
|
||||
{"s21", "Must call StartInstall() to initialize SoftwareUpdate."},
|
||||
{"s22", "Certificate of the Installer file does not match the certificate of the installed file"},
|
||||
{"s23", "Package name is null or empty in StartInstall."},
|
||||
{"s24", "Unexpected error in "},
|
||||
{"s25", "Bad package name in AddSubcomponent. Did you call StartInstall()?"},
|
||||
{"s26", "Illegal file path"},
|
||||
{"s27", "Unexpected error when installing a file"},
|
||||
{"s28", "Verification failed. 'this' must be passed to SoftwareUpdate constructor."},
|
||||
{"s29", "SmartUpdate disabled"},
|
||||
{"s30", "Security integrity check failed."},
|
||||
{"s31", "Could not get installer name out of the global MIME headers inside the JAR file."},
|
||||
{"s32", "Extraction of JAR file failed."},
|
||||
{"s33", "Install"},
|
||||
{"s34", "Cancel"},
|
||||
{"s35", "More Info..."},
|
||||
{"s36", "Close"},
|
||||
{"s37", "Installing Java class files in the \"Java Download\" directory. This form of access allows new files to be added to this single directory on your computer's main hard disk, potentially replacing other files that have previously been installed in the directory. "},
|
||||
{"s38", "Installing software on your computer's main hard disk, potentially deleting other files on the hard disk. Each time a program that has this form of access attempts to install software, it must display a dialog box that lets you choose whether to go ahead with the installation. If you go ahead, the installation program can execute any software on your computer. This potentially dangerous form of access is typically requested by an installation program after you have downloaded new software or a new version of software that you have previously installed. You should not grant this form of access unless you are installing or updating software from a reliable source."},
|
||||
{"s39", "Installing software on your computer's main hard disk without giving you any warning, potentially deleting other files on the hard disk. Any software on the hard disk may be executed in the process. This is an extremely dangerous form of access. It should be granted by system administrators only."},
|
||||
// stop localizing
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,232 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
//
|
||||
// Strings.java
|
||||
// Aleksandar Totic
|
||||
//
|
||||
|
||||
/**
|
||||
* This class is a repository for all the dialog strings. Currently,
|
||||
* it hard-codes the US-English strings, but it should eventually be
|
||||
* linked to the Netscape XP strings library.
|
||||
*
|
||||
* @version
|
||||
* @author atotic
|
||||
*/
|
||||
|
||||
package netscape.softupdate;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
class Strings {
|
||||
// Resource bundle
|
||||
private static ResourceBundle gbundle;
|
||||
|
||||
public static ResourceBundle bundle() {
|
||||
if (gbundle == null)
|
||||
try {
|
||||
gbundle = ResourceBundle.getBundle("netscape.softupdate.SoftUpdateResourceBundle");
|
||||
} catch ( Throwable t)
|
||||
{
|
||||
System.err.println("Could not get localized resources:"); // l10n, no need to localize
|
||||
t.printStackTrace();
|
||||
System.err.println("Using English Language Default.");
|
||||
gbundle = new SoftUpdateResourceBundle();
|
||||
}
|
||||
return gbundle;
|
||||
}
|
||||
|
||||
public static String getString(String key){
|
||||
try {
|
||||
return bundle().getString(key);
|
||||
} catch ( Throwable t){
|
||||
System.err.println("Could not get resource " + key + ":");
|
||||
t.printStackTrace();
|
||||
return key + "(!)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// security resources for user targets
|
||||
//
|
||||
static String targetRiskLow() {
|
||||
return getString("s1");
|
||||
}
|
||||
static String targetRiskColorLow() {
|
||||
return "#aaffaa";
|
||||
}
|
||||
|
||||
static String targetRiskMedium() {
|
||||
return getString("s2");
|
||||
}
|
||||
static String targetRiskColorMedium() {
|
||||
return "#ffffaa";
|
||||
}
|
||||
|
||||
static String targetRiskHigh() {
|
||||
return getString("s3");
|
||||
}
|
||||
static String targetRiskColorHigh() {
|
||||
return "#ffaaaa";
|
||||
}
|
||||
|
||||
static String targetDesc_LimitedInstall() {
|
||||
return getString("s4");
|
||||
}
|
||||
static String targetUrl_LimitedInstall() {
|
||||
// XXX: fix the URL.
|
||||
return "http://iapp16.mcom.com/java/signing/Games.html";
|
||||
}
|
||||
|
||||
static String targetDesc_FullInstall() {
|
||||
return getString("s5");
|
||||
}
|
||||
static String targetUrl_FullInstall() {
|
||||
// XXX: fix the URL.
|
||||
return "http://iapp16.mcom.com/java/signing/FileRead.html";
|
||||
}
|
||||
|
||||
static String targetDesc_SilentInstall() {
|
||||
// XXX: this should be ripped out
|
||||
return getString("s6");
|
||||
}
|
||||
static String targetUrl_SilentInstall() {
|
||||
// XXX: fix the URL.
|
||||
return "http://iapp16.mcom.com/java/signing/FileWrite.html";
|
||||
}
|
||||
|
||||
static String targetDesc_WinIni() {
|
||||
return getString("s7");
|
||||
}
|
||||
static String targetUrl_WinIni() {
|
||||
// XXX: fix the URL.
|
||||
return "http://iapp16.mcom.com/java/signing/FileWrite.html";
|
||||
}
|
||||
|
||||
static String targetDesc_WinReg() {
|
||||
return getString("s8");
|
||||
}
|
||||
static String targetUrl_WinReg() {
|
||||
// XXX: fix the URL.
|
||||
return "http://iapp16.mcom.com/java/signing/FileWrite.html";
|
||||
}
|
||||
|
||||
// PROGRESS WINDOW
|
||||
|
||||
static String progress_Title() {
|
||||
return getString("s9");
|
||||
}
|
||||
|
||||
static String progress_GettingReady() {
|
||||
return getString("s10");
|
||||
}
|
||||
|
||||
static String progress_ReadyToInstall1() {
|
||||
return getString("s11");
|
||||
}
|
||||
|
||||
static String progress_ReadyToInstall2() {
|
||||
return getString("s12");
|
||||
}
|
||||
|
||||
// DETAILS WINDOW
|
||||
|
||||
static String details_Explain(String title) {
|
||||
return getString("s13") + title + getString("s14");
|
||||
}
|
||||
|
||||
static String details_WinTitle() {
|
||||
return getString("s15");
|
||||
}
|
||||
|
||||
static String details_ExecuteProgress() {
|
||||
return getString("s16");
|
||||
}
|
||||
|
||||
// ERROR STRINGS
|
||||
|
||||
static String error_Prefix()
|
||||
{
|
||||
return getString("s17");
|
||||
}
|
||||
static String error_NoCertificate() {
|
||||
return error_Prefix() + getString("s18");
|
||||
}
|
||||
|
||||
static String error_TooManyCertificates() {
|
||||
return error_Prefix() + getString("s19");
|
||||
}
|
||||
|
||||
static String error_SilentModeDenied() {
|
||||
return error_Prefix() + getString("s20");
|
||||
}
|
||||
|
||||
static String error_WinProfileMustCallStart() {
|
||||
return error_Prefix() + getString("s21");
|
||||
}
|
||||
|
||||
static String error_MismatchedCertificate() {
|
||||
return error_Prefix() + getString("s22");
|
||||
}
|
||||
|
||||
static String error_BadPackageName() {
|
||||
return error_Prefix() + getString("s23");
|
||||
}
|
||||
|
||||
static String error_Unexpected() {
|
||||
return error_Prefix() + getString("s24");
|
||||
}
|
||||
|
||||
static String error_BadPackageNameAS() {
|
||||
return error_Prefix() + getString("s25");
|
||||
}
|
||||
|
||||
static String error_IllegalPath() {
|
||||
return error_Prefix() + getString("s26");
|
||||
}
|
||||
|
||||
static String error_InstallFileUnexpected() {
|
||||
return error_Prefix() + getString("s27");
|
||||
}
|
||||
|
||||
static String error_BadJSArgument() {
|
||||
return error_Prefix() + getString("s28");
|
||||
}
|
||||
|
||||
static String error_SmartUpdateDisabled() {
|
||||
return error_Prefix() + getString("s29");
|
||||
}
|
||||
|
||||
static String error_NoInstallerFile() {
|
||||
return "";
|
||||
}
|
||||
|
||||
static String error_VerificationFailed() {
|
||||
return error_Prefix() + getString("s30");
|
||||
}
|
||||
|
||||
static String error_MissingInstaller() {
|
||||
return error_Prefix() + getString("s31");
|
||||
}
|
||||
|
||||
static String error_ExtractFailed() {
|
||||
return error_Prefix() + getString("s32");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
A basic extension of the java.awt.Window class
|
||||
*/
|
||||
|
||||
package netscape.softupdate;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class SymProgressDetails extends Frame {
|
||||
void btnCancel_Clicked(Event event) {
|
||||
|
||||
|
||||
//{{CONNECTION
|
||||
// Disable the Frame
|
||||
disable();
|
||||
//}}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SymProgressDetails() {
|
||||
|
||||
//{{INIT_CONTROLS
|
||||
setLayout(null);
|
||||
addNotify();
|
||||
resize(insets().left + insets().right + 562,insets().top + insets().bottom + 326);
|
||||
setFont(new Font("Dialog", Font.BOLD, 14));
|
||||
label1 = new java.awt.Label("xxxxxIxxxxxx");
|
||||
label1.reshape(insets().left + 12,insets().top + 12,536,36);
|
||||
label1.setFont(new Font("Dialog", Font.PLAIN, 14));
|
||||
add(label1);
|
||||
detailArea = new java.awt.TextArea();
|
||||
detailArea.reshape(insets().left + 12,insets().top + 60,536,216);
|
||||
add(detailArea);
|
||||
btnCancel = new java.awt.Button("xxxCxxx");
|
||||
btnCancel.reshape(insets().left + 464,insets().top + 288,84,26);
|
||||
add(btnCancel);
|
||||
setTitle("Untitled");
|
||||
//}}
|
||||
//{{INIT_MENUS
|
||||
//}}
|
||||
}
|
||||
|
||||
public boolean handleEvent(Event event) {
|
||||
if (event.target == btnCancel && event.id == Event.ACTION_EVENT) {
|
||||
btnCancel_Clicked(event);
|
||||
return true;
|
||||
}
|
||||
return super.handleEvent(event);
|
||||
}
|
||||
|
||||
//{{DECLARE_CONTROLS
|
||||
java.awt.Label label1;
|
||||
java.awt.TextArea detailArea;
|
||||
java.awt.Button btnCancel;
|
||||
//}}
|
||||
//{{DECLARE_MENUS
|
||||
//}}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
A basic extension of the java.awt.Window class
|
||||
*/
|
||||
|
||||
package netscape.softupdate;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class SymProgressWindow extends Frame {
|
||||
void info_Clicked(Event event) {
|
||||
}
|
||||
|
||||
void cancel_Clicked(Event event) {
|
||||
}
|
||||
|
||||
void install_Clicked(Event event) {
|
||||
}
|
||||
|
||||
public SymProgressWindow() {
|
||||
|
||||
//{{INIT_CONTROLS
|
||||
setLayout(null);
|
||||
setResizable(false);
|
||||
addNotify();
|
||||
resize(insets().left + insets().right + 497,insets().top + insets().bottom + 144);
|
||||
setFont(new Font("Dialog", Font.BOLD, 12));
|
||||
status = new java.awt.Label("xxxxxxxxxxxxx");
|
||||
status.reshape(insets().left + 12,insets().top + 12,472,36);
|
||||
status.setFont(new Font("Dialog", Font.BOLD, 12));
|
||||
add(status);
|
||||
progress = new java.awt.Label("xxxxxxxxxxx");
|
||||
progress.reshape(insets().left + 12,insets().top + 48,472,40);
|
||||
progress.setFont(new Font("Courier", Font.PLAIN, 14));
|
||||
add(progress);
|
||||
install = new java.awt.Button("xxxxxIxxx");
|
||||
install.reshape(insets().left + 12,insets().top + 96,108,32);
|
||||
add(install);
|
||||
cancel = new java.awt.Button("xxxxxCxxx");
|
||||
cancel.reshape(insets().left + 132,insets().top + 96,108,32);
|
||||
add(cancel);
|
||||
info = new java.awt.Button("xxxxxMxxxxx");
|
||||
info.reshape(insets().left + 376,insets().top + 96,108,32);
|
||||
add(info);
|
||||
setTitle("Untitled");
|
||||
//}}
|
||||
//{{INIT_MENUS
|
||||
//}}
|
||||
}
|
||||
|
||||
public boolean handleEvent(Event event) {
|
||||
if (event.target == install && event.id == Event.ACTION_EVENT) {
|
||||
install_Clicked(event);
|
||||
return true;
|
||||
}
|
||||
if (event.target == cancel && event.id == Event.ACTION_EVENT) {
|
||||
cancel_Clicked(event);
|
||||
return true;
|
||||
}
|
||||
if (event.target == info && event.id == Event.ACTION_EVENT) {
|
||||
info_Clicked(event);
|
||||
return true;
|
||||
}
|
||||
return super.handleEvent(event);
|
||||
}
|
||||
|
||||
//{{DECLARE_CONTROLS
|
||||
java.awt.Label status;
|
||||
java.awt.Label progress;
|
||||
java.awt.Button install;
|
||||
java.awt.Button cancel;
|
||||
java.awt.Button info;
|
||||
//}}
|
||||
//{{DECLARE_MENUS
|
||||
//}}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate;
|
||||
|
||||
/**
|
||||
* A class for 'triggering' the SmartUpdate and obtaining info
|
||||
* No instances, all static methods
|
||||
*/
|
||||
public class Trigger {
|
||||
|
||||
/**
|
||||
* diff levels are borrowed from the VersionInfo class
|
||||
*/
|
||||
public static final int MAJOR_DIFF = 4;
|
||||
public static final int MINOR_DIFF = 3;
|
||||
public static final int REL_DIFF = 2;
|
||||
public static final int BLD_DIFF = 1;
|
||||
public static final int EQUAL = 0;
|
||||
|
||||
/**
|
||||
* DEFAULT_MODE has UI, triggers conditionally
|
||||
* @see StartSoftwareUpdate flags argument
|
||||
*
|
||||
*/
|
||||
public static int DEFAULT_MODE = 0;
|
||||
/**
|
||||
* FORCE_MODE will install the package regardless of what was installed previously
|
||||
* @see StartSoftwareUpdate flags argument
|
||||
*/
|
||||
public static int FORCE_MODE = 1;
|
||||
/**
|
||||
* SILENT_MODE will not display the UI
|
||||
*/
|
||||
public static int SILENT_MODE = 2;
|
||||
|
||||
|
||||
/**
|
||||
* @return true if SmartUpdate is enabled
|
||||
*/
|
||||
public static native boolean UpdateEnabled();
|
||||
|
||||
/**
|
||||
* @param componentName version registry name of the component
|
||||
* @return version of the package. null if not installed, or SmartUpdate disabled
|
||||
*/
|
||||
public static VersionInfo GetVersionInfo( String componentName )
|
||||
{
|
||||
if (UpdateEnabled())
|
||||
return VersionRegistry.componentVersion( componentName );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unconditionally starts the software update
|
||||
* @param url URL of the JAR file
|
||||
* @param flags SmartUpdate modifiers (SILENT_INSTALL, FORCE_INSTALL)
|
||||
* @return false if SmartUpdate did not trigger
|
||||
*/
|
||||
public static native boolean StartSoftwareUpdate( String url, int flags );
|
||||
|
||||
public static boolean StartSoftwareUpdate( String url )
|
||||
{
|
||||
return StartSoftwareUpdate( url, DEFAULT_MODE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally starts the software update
|
||||
* @param url URL of JAR file
|
||||
* @param componentName name of component in the registry to compare
|
||||
* the version against. This doesn't have to be the
|
||||
* registry name of the installed package but could
|
||||
* instead be a sub-component -- useful because if a
|
||||
* file doesn't exist then it triggers automatically.
|
||||
* @param diffLevel Specifies which component of the version must be
|
||||
* different. If not supplied BLD_DIFF is assumed.
|
||||
* If the diffLevel is positive the install is triggered
|
||||
* if the specified version is NEWER (higher) than the
|
||||
* registered version. If the diffLevel is negative then
|
||||
* the install is triggered if the specified version is
|
||||
* OLDER than the registered version. Obviously this
|
||||
* will only have an effect if FORCE_MODE is also used.
|
||||
* @param version The version that must be newer (can be a VersionInfo
|
||||
* object or a string version
|
||||
* @param flags Same flags as StartSoftwareUpdate (force, silent)
|
||||
*/
|
||||
public static boolean
|
||||
ConditionalSoftwareUpdate( String url,
|
||||
String componentName,
|
||||
int diffLevel,
|
||||
VersionInfo version,
|
||||
int flags)
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean needJar = false;
|
||||
|
||||
if ((version == null) || (componentName == null))
|
||||
needJar = true;
|
||||
else
|
||||
{
|
||||
int stat = VersionRegistry.validateComponent( componentName );
|
||||
if ( stat == VersionRegistry.REGERR_NOFIND ||
|
||||
stat == VersionRegistry.REGERR_NOFILE )
|
||||
{
|
||||
// either component is not in the registry or it's a file
|
||||
// node and the physical file is missing
|
||||
needJar = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
VersionInfo oldVer =
|
||||
VersionRegistry.componentVersion( componentName );
|
||||
|
||||
if ( oldVer == null )
|
||||
needJar = true;
|
||||
else if ( diffLevel < 0 )
|
||||
needJar = (version.compareTo( oldVer ) <= diffLevel);
|
||||
else
|
||||
needJar = (version.compareTo( oldVer ) >= diffLevel);
|
||||
}
|
||||
}
|
||||
|
||||
if (needJar)
|
||||
return StartSoftwareUpdate( url, flags );
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean
|
||||
ConditionalSoftwareUpdate( String url,
|
||||
String componentName,
|
||||
VersionInfo version)
|
||||
{
|
||||
return ConditionalSoftwareUpdate( url, componentName,
|
||||
BLD_DIFF, version, DEFAULT_MODE );
|
||||
}
|
||||
|
||||
public static boolean
|
||||
ConditionalSoftwareUpdate( String url,
|
||||
String componentName,
|
||||
String version)
|
||||
{
|
||||
return ConditionalSoftwareUpdate( url, componentName,
|
||||
BLD_DIFF, new VersionInfo(version), DEFAULT_MODE );
|
||||
}
|
||||
|
||||
public static boolean
|
||||
ConditionalSoftwareUpdate( String url,
|
||||
String componentName,
|
||||
VersionInfo version,
|
||||
int flags)
|
||||
{
|
||||
return ConditionalSoftwareUpdate( url, componentName,
|
||||
BLD_DIFF, version, flags );
|
||||
}
|
||||
|
||||
|
||||
public static boolean
|
||||
ConditionalSoftwareUpdate( String url,
|
||||
String componentName,
|
||||
String version,
|
||||
int flags)
|
||||
{
|
||||
return ConditionalSoftwareUpdate( url, componentName,
|
||||
BLD_DIFF, new VersionInfo(version), flags );
|
||||
}
|
||||
|
||||
|
||||
public static boolean
|
||||
ConditionalSoftwareUpdate( String url,
|
||||
String componentName,
|
||||
int diffLevel,
|
||||
VersionInfo version)
|
||||
{
|
||||
return ConditionalSoftwareUpdate( url, componentName,
|
||||
diffLevel, version, DEFAULT_MODE );
|
||||
}
|
||||
|
||||
|
||||
public static boolean
|
||||
ConditionalSoftwareUpdate( String url,
|
||||
String componentName,
|
||||
int diffLevel,
|
||||
String version)
|
||||
{
|
||||
return ConditionalSoftwareUpdate( url, componentName,
|
||||
diffLevel, new VersionInfo(version), DEFAULT_MODE );
|
||||
}
|
||||
|
||||
|
||||
public static boolean
|
||||
ConditionalSoftwareUpdate( String url,
|
||||
String componentName,
|
||||
int diffLevel,
|
||||
String version,
|
||||
int flags)
|
||||
{
|
||||
return ConditionalSoftwareUpdate( url, componentName,
|
||||
diffLevel, new VersionInfo(version), flags );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates existence and compares versions
|
||||
*
|
||||
* @param regName name of component in the registry to compare
|
||||
* the version against. This doesn't have to be the
|
||||
* registry name of an installed package but could
|
||||
* instead be a sub-component. If the named item
|
||||
* has a Path property the file must exist or a
|
||||
* null version is used in the comparison.
|
||||
* @param version The version to compare against
|
||||
*/
|
||||
|
||||
public static int
|
||||
CompareVersion( String regName, VersionInfo version )
|
||||
{
|
||||
if (!UpdateEnabled())
|
||||
return EQUAL;
|
||||
|
||||
VersionInfo regVersion = GetVersionInfo( regName );
|
||||
|
||||
if ( regVersion == null ||
|
||||
VersionRegistry.validateComponent( regName ) ==
|
||||
VersionRegistry.REGERR_NOFILE ) {
|
||||
|
||||
regVersion = new VersionInfo(0,0,0,0);
|
||||
}
|
||||
|
||||
return regVersion.compareTo( version );
|
||||
}
|
||||
|
||||
public static int
|
||||
CompareVersion( String regName, String version )
|
||||
{
|
||||
return CompareVersion( regName, new VersionInfo( version ) );
|
||||
}
|
||||
|
||||
public static int
|
||||
CompareVersion( String regName, int maj, int min, int rel, int bld )
|
||||
{
|
||||
return CompareVersion( regName, new VersionInfo(maj, min, rel, bld) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate ;
|
||||
|
||||
public class VersionInfo {
|
||||
public static final int MAJOR_DIFF = 4;
|
||||
public static final int MINOR_DIFF = 3;
|
||||
public static final int REL_DIFF = 2;
|
||||
public static final int BLD_DIFF = 1;
|
||||
public static final int EQUAL = 0;
|
||||
|
||||
/* Equivalent to Version Registry structure fields */
|
||||
private int major = 0;
|
||||
private int minor = 0;
|
||||
private int release = 0;
|
||||
private int build = 0;
|
||||
private int check = 0;
|
||||
|
||||
public VersionInfo(int maj, int min, int rel, int bld)
|
||||
{
|
||||
this(maj, min, rel, bld, 0);
|
||||
}
|
||||
|
||||
public VersionInfo(int maj, int min, int rel, int bld, int checksum)
|
||||
{
|
||||
major = maj;
|
||||
minor = min;
|
||||
release = rel;
|
||||
build = bld;
|
||||
check = checksum;
|
||||
}
|
||||
|
||||
public VersionInfo(String version)
|
||||
{
|
||||
int dot = version.indexOf('.');
|
||||
|
||||
try {
|
||||
if ( dot == -1 ) {
|
||||
major = Integer.parseInt(version);
|
||||
}
|
||||
else {
|
||||
major = Integer.parseInt(version.substring(0,dot));
|
||||
|
||||
int prev = dot+1;
|
||||
dot = version.indexOf('.',prev);
|
||||
if ( dot == -1 ) {
|
||||
minor = Integer.parseInt(version.substring(prev));
|
||||
}
|
||||
else {
|
||||
minor = Integer.parseInt(version.substring(prev, dot));
|
||||
|
||||
prev = dot+1;
|
||||
dot = version.indexOf('.',prev);
|
||||
if ( dot == -1 ) {
|
||||
release = Integer.parseInt(version.substring(prev));
|
||||
}
|
||||
else {
|
||||
release = Integer.parseInt(version.substring(prev,dot));
|
||||
|
||||
if ( version.length() > dot ) {
|
||||
build = Integer.parseInt(version.substring(dot+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// parseInt can throw a NumberFormatException--in that case just
|
||||
// trap the exception so we don't blow away someone's JAR install.
|
||||
}
|
||||
}
|
||||
|
||||
// Text representation of the version info
|
||||
public String toString()
|
||||
{
|
||||
String vers = String.valueOf(major) + "." +
|
||||
String.valueOf(minor) + "." +
|
||||
String.valueOf(release) + "." +
|
||||
String.valueOf(build);
|
||||
// vers += ", checksum: " + check;
|
||||
return vers;
|
||||
}
|
||||
|
||||
/*
|
||||
* compareTo() -- Compares version info.
|
||||
* Returns -n, 0, n, where n = {1-4}
|
||||
*/
|
||||
public int compareTo(VersionInfo vi)
|
||||
{
|
||||
int diff;
|
||||
|
||||
if ( vi == null ) {
|
||||
diff = MAJOR_DIFF;
|
||||
}
|
||||
else if ( this.major == vi.major ) {
|
||||
if ( this.minor == vi.minor ) {
|
||||
if ( this.release == vi.release ) {
|
||||
if ( this.build == vi.build )
|
||||
diff = EQUAL;
|
||||
else if ( this.build > vi.build )
|
||||
diff = BLD_DIFF;
|
||||
else
|
||||
diff = -BLD_DIFF;
|
||||
}
|
||||
else if ( this.release > vi.release )
|
||||
diff = REL_DIFF;
|
||||
else
|
||||
diff = -REL_DIFF;
|
||||
}
|
||||
else if ( this. minor > vi.minor )
|
||||
diff = MINOR_DIFF;
|
||||
else
|
||||
diff = -MINOR_DIFF;
|
||||
}
|
||||
else if ( this.major > vi.major )
|
||||
diff = MAJOR_DIFF;
|
||||
else
|
||||
diff = -MAJOR_DIFF;
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
public int compareTo(String version)
|
||||
{
|
||||
return compareTo(new VersionInfo(version));
|
||||
}
|
||||
|
||||
public int compareTo(int maj, int min, int rel, int bld)
|
||||
{
|
||||
return compareTo(new VersionInfo(maj, min, rel, bld));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*
|
||||
* VersionRegistry.java
|
||||
*/
|
||||
package netscape.softupdate ;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* The VersionRegistry class is a set of static functions that form a wrapper
|
||||
* around the Navigator's built-in Version Registry. The Version Registry
|
||||
* represents a hierarchical tree of Navigator "components". Each component
|
||||
* represents a physical file installed on the disk or a logical grouping of
|
||||
* other components (e.g. Java). All components should have an associated
|
||||
* version used to determine when an update is necessary; components that
|
||||
* represent a physical file will also have the disk location of the file.<p>
|
||||
*
|
||||
* Component names passed as arguments can be specified as full paths from
|
||||
* the VersionRegistry root, or as paths relative to the most recently
|
||||
* run version of the Navigator. 3rd-party add-ons that work with
|
||||
* multiple versions of Navigator will probably want to start their
|
||||
* own sub-tree under the root, independent of the components for the
|
||||
* Navigator itself.<p>
|
||||
*
|
||||
* Because this class is intended to be called from JavaScript in addition
|
||||
* to Java, errors are indicated through return values rather than exceptions.
|
||||
*
|
||||
* It is not yet determined if this class will be public for generic use, or
|
||||
* only available through the Automatic Software Download feature.
|
||||
*
|
||||
* @version 1.0 96/11/16
|
||||
* @author Daniel Veditz
|
||||
*/
|
||||
final class VersionRegistry implements RegistryErrors {
|
||||
|
||||
/**
|
||||
* This class is simply static function wrappers; don't "new" one
|
||||
*/
|
||||
private VersionRegistry() {}
|
||||
|
||||
/**
|
||||
* Return the physical disk path for the specified component.
|
||||
* @param component Registry path of the item to look up in the Registry
|
||||
* @return The disk path for the specified component; NULL indicates error
|
||||
* @see VersionRegistry#checkComponent
|
||||
*/
|
||||
protected static native String componentPath( String component );
|
||||
|
||||
/**
|
||||
* Return the version information for the specified component.
|
||||
* @param component Registry path of the item to look up in the Registry
|
||||
* @return A VersionInfo object for the specified component; NULL indicates error
|
||||
* @see VersionRegistry#checkComponent
|
||||
*/
|
||||
protected static native VersionInfo componentVersion( String component );
|
||||
|
||||
protected static native String getDefaultDirectory( String component );
|
||||
|
||||
protected static native int setDefaultDirectory( String component, String directory );
|
||||
|
||||
protected static native int installComponent( String name, String path,
|
||||
VersionInfo version );
|
||||
|
||||
/**
|
||||
* Delete component.
|
||||
* @param component Registry path of the item to delete
|
||||
* @return Error code
|
||||
*/
|
||||
protected static native int deleteComponent( String component );
|
||||
|
||||
/**
|
||||
* Check the status of a named components.
|
||||
* @param component Registry path of the item to check
|
||||
* @return Error code. REGERR_OK means the named component was found in
|
||||
* the registry, the filepath referred to an existing file, and the
|
||||
* checksum matched the physical file. Other error codes can be used to
|
||||
* distinguish which of the above was not true.
|
||||
*/
|
||||
protected static native int validateComponent( String component );
|
||||
|
||||
/**
|
||||
* verify that the named component is in the registry (light-weight
|
||||
* version of validateComponent since it does no disk access).
|
||||
* @param component Registry path of the item to verify
|
||||
* @return Error code. REGERR_OK means it is in the registry.
|
||||
* REGERR_NOFIND will usually be the result otherwise.
|
||||
*/
|
||||
protected static native int inRegistry( String component );
|
||||
|
||||
/**
|
||||
* Closes the registry file.
|
||||
* @return Error code
|
||||
*/
|
||||
protected static native int close();
|
||||
|
||||
/**
|
||||
* Returns an enumeration of the Version Registry contents. Use the
|
||||
* enumeration methods of the returned object to fetch individual
|
||||
* elements sequentially.
|
||||
*/
|
||||
protected static Enumeration elements() {
|
||||
return new VerRegEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Helper class used to enumerate the Version Registry
|
||||
* @see VersionRegistry#elements
|
||||
*/
|
||||
final class VerRegEnumerator implements Enumeration {
|
||||
private String path = "";
|
||||
private int state = 0;
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
int saveState = state;
|
||||
String tmp = regNext();
|
||||
state = saveState;
|
||||
|
||||
return (tmp != null);
|
||||
}
|
||||
|
||||
public Object nextElement() {
|
||||
path = regNext();
|
||||
if (path == null) {
|
||||
throw new NoSuchElementException("VerRegEnumerator");
|
||||
}
|
||||
return "/"+path;
|
||||
}
|
||||
|
||||
private native String regNext();
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate;
|
||||
|
||||
import netscape.security.UserTarget;
|
||||
import netscape.security.PrivilegeManager;
|
||||
import netscape.security.Principal;
|
||||
import netscape.security.Target;
|
||||
import netscape.security.UserDialogHelper;
|
||||
|
||||
|
||||
final class WinProfile {
|
||||
private String filename;
|
||||
private SoftwareUpdate su;
|
||||
private Principal principal;
|
||||
private PrivilegeManager privMgr;
|
||||
private Target impersonation;
|
||||
|
||||
private UserTarget target;
|
||||
|
||||
WinProfile( SoftwareUpdate suObj, FolderSpec folder, String file )
|
||||
throws SoftUpdateException
|
||||
{
|
||||
filename = folder.MakeFullPath( file );
|
||||
su = suObj;
|
||||
principal = suObj.GetPrincipal();
|
||||
privMgr = PrivilegeManager.getPrivilegeManager();
|
||||
impersonation = Target.findTarget( SoftwareUpdate.IMPERSONATOR );
|
||||
target = (UserTarget)Target.findTarget(
|
||||
SoftwareUpdate.targetNames[SoftwareUpdate.FULL_INSTALL] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a write into a windows "ini" file. "Value" can be
|
||||
* null to delete the value, but we don't support deleting an entire
|
||||
* section via a null "key". The actual write takes place during
|
||||
* SoftwareUpdate.FinalizeInstall();
|
||||
*
|
||||
* @return false for failure, true for success
|
||||
*/
|
||||
public boolean writeString( String section, String key, String value ) {
|
||||
boolean result;
|
||||
WinProfileItem item;
|
||||
try {
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, principal );
|
||||
|
||||
item = new WinProfileItem( this, section, key, value );
|
||||
su.ScheduleForInstall( item );
|
||||
result = true;
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace( System.out );
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads a value from a windows "ini" file. We don't support using
|
||||
* a null "key" to return a list of keys--you have to know what you want
|
||||
*
|
||||
* @return String value from INI, "" if not found, null if error
|
||||
*/
|
||||
public String getString( String section, String key ) {
|
||||
String result;
|
||||
try {
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, principal );
|
||||
|
||||
return nativeGetString( section, key );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace( System.out );
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected String filename() { return filename; }
|
||||
protected SoftwareUpdate softUpdate() { return su; }
|
||||
|
||||
protected int finalWriteString( String section, String key, String value ) {
|
||||
// do we need another security check here?
|
||||
return nativeWriteString( section, key, value );
|
||||
}
|
||||
|
||||
private native int nativeWriteString( String section, String key, String value );
|
||||
private native String nativeGetString( String section, String key );
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate ;
|
||||
|
||||
import netscape.softupdate.*;
|
||||
import netscape.util.*;
|
||||
import java.lang.*;
|
||||
|
||||
/**
|
||||
* WinProfileItem
|
||||
* Writes a single item into a Windows .INI file.
|
||||
*/
|
||||
|
||||
final class WinProfileItem extends InstallObject {
|
||||
|
||||
private WinProfile profile; // initiating profile object
|
||||
private String section; // Name of section
|
||||
private String key; // Name of key
|
||||
private String value; // data to write
|
||||
|
||||
|
||||
WinProfileItem(WinProfile profileObj,
|
||||
String sectionName,
|
||||
String keyName,
|
||||
String val) throws SoftUpdateException
|
||||
{
|
||||
super(profileObj.softUpdate());
|
||||
profile = profileObj;
|
||||
section = sectionName;
|
||||
key = keyName;
|
||||
value = val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Completes the install:
|
||||
* - writes the data into the .INI file
|
||||
*/
|
||||
protected void Complete() throws SoftUpdateException
|
||||
{
|
||||
profile.finalWriteString( section, key, value );
|
||||
}
|
||||
|
||||
float GetInstallOrder()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Write "+profile.filename()+": ["+section+"] "+key+"="+value;
|
||||
}
|
||||
|
||||
// no need for special clean-up
|
||||
protected void Abort() {}
|
||||
}
|
||||
234
mozilla/modules/softupdt/classes/netscape/softupdate/WinReg.java
Normal file
234
mozilla/modules/softupdt/classes/netscape/softupdate/WinReg.java
Normal file
@@ -0,0 +1,234 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate;
|
||||
|
||||
import netscape.security.PrivilegeManager;
|
||||
import netscape.security.Principal;
|
||||
import netscape.security.Target;
|
||||
import netscape.security.UserTarget;
|
||||
import netscape.security.UserDialogHelper;
|
||||
|
||||
final class WinReg {
|
||||
/* not static because class is not public--users couldn't get to them */
|
||||
public final int HKEY_CLASSES_ROOT = 0x80000000;
|
||||
public final int HKEY_CURRENT_USER = 0x80000001;
|
||||
public final int HKEY_LOCAL_MACHINE = 0x80000002;
|
||||
public final int HKEY_USERS = 0x80000003;
|
||||
|
||||
protected final int CREATE = 1;
|
||||
protected final int DELETE = 2;
|
||||
protected final int DELETE_VAL = 3;
|
||||
protected final int SET_VAL_STRING = 4;
|
||||
protected final int SET_VAL = 5;
|
||||
|
||||
|
||||
private int rootkey = HKEY_CLASSES_ROOT;
|
||||
private Principal principal;
|
||||
private PrivilegeManager privMgr;
|
||||
private Target impersonation;
|
||||
private SoftwareUpdate su;
|
||||
|
||||
private UserTarget target;
|
||||
// static final String INI_TARGET = "FullWindowsRegistryAccess";
|
||||
|
||||
// static {
|
||||
// /* create the target */
|
||||
// target = new UserTarget(
|
||||
// INI_TARGET,
|
||||
// PrivilegeManager.getSystemPrincipal(),
|
||||
// UserDialogHelper.targetRiskHigh(),
|
||||
// UserDialogHelper.targetRiskColorHigh(),
|
||||
// Strings.targetDesc_WinReg(),
|
||||
// Strings.targetUrl_WinReg() );
|
||||
// target = (UserTarget)target.registerTarget();
|
||||
// };
|
||||
|
||||
|
||||
WinReg(SoftwareUpdate suObj) {
|
||||
su = suObj;
|
||||
principal = suObj.GetPrincipal();
|
||||
privMgr = PrivilegeManager.getPrivilegeManager();
|
||||
impersonation = Target.findTarget( SoftwareUpdate.IMPERSONATOR );
|
||||
target = (UserTarget)Target.findTarget(
|
||||
SoftwareUpdate.targetNames[ SoftwareUpdate.FULL_INSTALL ] );
|
||||
}
|
||||
|
||||
|
||||
public void setRootKey(int key) {
|
||||
rootkey = key;
|
||||
}
|
||||
|
||||
|
||||
public int createKey(String subkey, String classname) {
|
||||
int result;
|
||||
try {
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, principal );
|
||||
|
||||
WinRegItem wi = new WinRegItem( this, rootkey, CREATE,
|
||||
subkey, classname, null );
|
||||
su.ScheduleForInstall( wi );
|
||||
result = 0;
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace( System.out );
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public int deleteKey(String subkey) {
|
||||
int result;
|
||||
try {
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, principal );
|
||||
|
||||
WinRegItem wi = new WinRegItem( this, rootkey, DELETE,
|
||||
subkey, null, null );
|
||||
su.ScheduleForInstall( wi );
|
||||
result = 0;
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace( System.out );
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public int deleteValue(String subkey, String valname) {
|
||||
int result;
|
||||
try {
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, principal );
|
||||
|
||||
WinRegItem wi = new WinRegItem( this, rootkey, DELETE_VAL,
|
||||
subkey, valname, null );
|
||||
su.ScheduleForInstall( wi );
|
||||
result = 0;
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace( System.out );
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int setValueString(String subkey, String valname, String value) {
|
||||
int result;
|
||||
try {
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, principal );
|
||||
|
||||
WinRegItem wi = new WinRegItem( this, rootkey, SET_VAL_STRING,
|
||||
subkey, valname, (Object)value );
|
||||
su.ScheduleForInstall( wi );
|
||||
result = 0;
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace( System.out );
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getValueString(String subkey, String valname) {
|
||||
String result;
|
||||
try {
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, principal );
|
||||
|
||||
result = nativeGetValueString( subkey, valname );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace( System.out );
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int setValue(String subkey, String valname, WinRegValue value) {
|
||||
int result;
|
||||
try {
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, principal );
|
||||
|
||||
WinRegItem wi = new WinRegItem( this, rootkey, SET_VAL,
|
||||
subkey, valname, (Object)value );
|
||||
su.ScheduleForInstall( wi );
|
||||
result = 0;
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace( System.out );
|
||||
result = -1;
|
||||
}
|
||||
return result; }
|
||||
|
||||
public WinRegValue getValue(String subkey, String valname) {
|
||||
WinRegValue result;
|
||||
try {
|
||||
privMgr.enablePrivilege( impersonation );
|
||||
privMgr.enablePrivilege( target, principal );
|
||||
|
||||
result = nativeGetValue( subkey, valname );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace( System.out );
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected SoftwareUpdate softUpdate() { return su; }
|
||||
|
||||
protected int finalCreateKey(int root, String subkey, String classname) {
|
||||
setRootKey(root);
|
||||
return nativeCreateKey(subkey, classname);
|
||||
}
|
||||
|
||||
protected int finalDeleteKey(int root, String subkey) {
|
||||
setRootKey(root);
|
||||
return nativeDeleteKey(subkey);
|
||||
}
|
||||
|
||||
protected int finalDeleteValue(int root, String subkey, String valname) {
|
||||
setRootKey(root);
|
||||
return nativeDeleteValue(subkey, valname);
|
||||
}
|
||||
|
||||
protected int finalSetValueString(int root, String subkey, String valname, String value) {
|
||||
setRootKey(root);
|
||||
return nativeSetValueString(subkey, valname, value);
|
||||
}
|
||||
|
||||
protected int finalSetValue(int root, String subkey, String valname, WinRegValue value) {
|
||||
setRootKey(root);
|
||||
return nativeSetValue(subkey, valname, value);
|
||||
}
|
||||
|
||||
private native int nativeCreateKey(String subkey, String classname);
|
||||
private native int nativeDeleteKey(String subkey);
|
||||
private native int nativeDeleteValue(String subkey, String valname);
|
||||
|
||||
private native int nativeSetValueString(String subkey, String valname, String value);
|
||||
private native String nativeGetValueString(String subkey, String valname);
|
||||
|
||||
private native int nativeSetValue(String subkey, String valname, WinRegValue value);
|
||||
private native WinRegValue nativeGetValue(String subkey, String valname);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
package netscape.softupdate ;
|
||||
|
||||
import netscape.softupdate.*;
|
||||
import netscape.util.*;
|
||||
import java.lang.*;
|
||||
|
||||
/**
|
||||
* WinProfileItem
|
||||
* Writes a single item into a Windows .INI file.
|
||||
*/
|
||||
|
||||
final class WinRegItem extends InstallObject
|
||||
{
|
||||
private WinReg reg; // initiating WinReg object
|
||||
private int rootkey;
|
||||
private int command;
|
||||
private String subkey; // Name of section
|
||||
private String name; // Name of key
|
||||
private Object value; // data to write
|
||||
|
||||
|
||||
WinRegItem(WinReg regObj,
|
||||
int root,
|
||||
int action,
|
||||
String sub,
|
||||
String valname,
|
||||
Object val) throws SoftUpdateException
|
||||
{
|
||||
super(regObj.softUpdate());
|
||||
reg = regObj;
|
||||
command = action;
|
||||
rootkey = root;
|
||||
subkey = sub;
|
||||
name = valname;
|
||||
value = val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Completes the install:
|
||||
* - writes the data into the .INI file
|
||||
*/
|
||||
protected void Complete() throws SoftUpdateException
|
||||
{
|
||||
switch (command) {
|
||||
case reg.CREATE:
|
||||
reg.finalCreateKey(rootkey, subkey, name);
|
||||
break;
|
||||
case reg.DELETE:
|
||||
reg.finalDeleteKey(rootkey, subkey);
|
||||
break;
|
||||
case reg.DELETE_VAL:
|
||||
reg.finalDeleteValue(rootkey, subkey, name );
|
||||
break;
|
||||
case reg.SET_VAL_STRING:
|
||||
reg.finalSetValueString(rootkey, subkey, name, (String)value);
|
||||
break;
|
||||
case reg.SET_VAL:
|
||||
reg.finalSetValue(rootkey, subkey, name, (WinRegValue)value);
|
||||
break;
|
||||
default:
|
||||
throw new SoftUpdateException("WinRegItem", SoftwareUpdate.INVALID_ARGUMENTS);
|
||||
}
|
||||
}
|
||||
|
||||
float GetInstallOrder()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
switch (command) {
|
||||
case reg.CREATE:
|
||||
return "Create Registry Key "+keystr(rootkey,subkey,null);
|
||||
case reg.DELETE:
|
||||
return "Delete Registry key "+keystr(rootkey,subkey,null);
|
||||
case reg.DELETE_VAL:
|
||||
return "Delete Registry value "+keystr(rootkey,subkey,name);
|
||||
case reg.SET_VAL_STRING:
|
||||
return "Store Registry value "+keystr(rootkey,subkey,name);
|
||||
case reg.SET_VAL:
|
||||
return "Store Registry value "+keystr(rootkey,subkey,name);
|
||||
default:
|
||||
return "Unknown "+keystr(rootkey,subkey,name);
|
||||
}
|
||||
}
|
||||
|
||||
private String keystr(int root, String subkey, String name)
|
||||
{
|
||||
String rootstr;
|
||||
switch (root) {
|
||||
case reg.HKEY_CLASSES_ROOT:
|
||||
rootstr = "\\HKEY_CLASSES_ROOT\\";
|
||||
break;
|
||||
case reg.HKEY_CURRENT_USER:
|
||||
rootstr = "\\HKEY_CURRENT_USER\\";
|
||||
break;
|
||||
case reg.HKEY_LOCAL_MACHINE:
|
||||
rootstr = "\\HKEY_LOCAL_MACHINE\\";
|
||||
break;
|
||||
case reg.HKEY_USERS:
|
||||
rootstr = "\\HKEY_USERS\\";
|
||||
break;
|
||||
default:
|
||||
rootstr = "\\#"+root+"\\";
|
||||
break;
|
||||
}
|
||||
|
||||
if ( name == null )
|
||||
return rootstr+subkey;
|
||||
else
|
||||
return rootstr+subkey+" ["+name+"]";
|
||||
}
|
||||
|
||||
// no need for special clean-up
|
||||
protected void Abort() {}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
|
||||
package netscape.softupdate;
|
||||
|
||||
|
||||
public final class WinRegValue {
|
||||
public WinRegValue(int datatype, byte[] regdata) {
|
||||
type = datatype;
|
||||
data = regdata;
|
||||
}
|
||||
|
||||
public int type;
|
||||
public byte[] data;
|
||||
|
||||
public static final int REG_SZ = 1;
|
||||
public static final int REG_EXPAND_SZ = 2;
|
||||
public static final int REG_BINARY = 3;
|
||||
public static final int REG_DWORD = 4;
|
||||
public static final int REG_DWORD_LITTLE_ENDIAN = 4;
|
||||
public static final int REG_DWORD_BIG_ENDIAN = 5;
|
||||
public static final int REG_LINK = 6;
|
||||
public static final int REG_MULTI_SZ = 7;
|
||||
public static final int REG_RESOURCE_LIST = 8;
|
||||
public static final int REG_FULL_RESOURCE_DESCRIPTOR = 9;
|
||||
public static final int REG_RESOURCE_REQUIREMENTS_LIST = 10;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
#
|
||||
|
||||
JAVA_SOURCEPATH=$(DEPTH)\modules\softupdt\classes
|
||||
|
||||
DEPTH=..\..\..\..\..
|
||||
PACKAGE=netscape\softupdate
|
||||
JSRCS=FolderSpec.java \
|
||||
InstallExecute.java \
|
||||
InstallFile.java \
|
||||
InstallPatch.java \
|
||||
InstallObject.java \
|
||||
ProgressDetails.java \
|
||||
ProgressMediator.java \
|
||||
ProgressWindow.java \
|
||||
RegEntryEnumerator.java \
|
||||
Registry.java \
|
||||
RegistryErrors.java \
|
||||
RegistryException.java \
|
||||
RegistryNode.java \
|
||||
RegKeyEnumerator.java \
|
||||
SoftUpdateException.java \
|
||||
SoftUpdateResourceBundle.java \
|
||||
SoftwareUpdate.java \
|
||||
Strings.java \
|
||||
SymProgressDetails.java \
|
||||
SymProgressWindow.java \
|
||||
Trigger.java \
|
||||
VersionInfo.java \
|
||||
VersionRegistry.java \
|
||||
WinProfile.java \
|
||||
WinProfileItem.java \
|
||||
WinReg.java \
|
||||
WinRegItem.java \
|
||||
WinRegValue.java
|
||||
CLASSROOT=y:\ns\modules\softupdt\classes
|
||||
|
||||
include <$(MOZ_SRC)\ns\config\rules.mak>
|
||||
24
mozilla/modules/softupdt/include/Makefile
Normal file
24
mozilla/modules/softupdt/include/Makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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 = ../../..
|
||||
|
||||
MODULE = softupdt
|
||||
|
||||
EXPORTS = softupdt.h su_folderspec.h gdiff.h
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
92
mozilla/modules/softupdt/include/gdiff.h
Normal file
92
mozilla/modules/softupdt/include/gdiff.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*--------------------------------------------------------------
|
||||
* GDIFF.H
|
||||
*
|
||||
* Constants used in processing the GDIFF format
|
||||
*--------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define GDIFF_MAGIC "\xD1\xFF\xD1\xFF"
|
||||
#define GDIFF_MAGIC_LEN 4
|
||||
#define GDIFF_VER 5
|
||||
#define GDIFF_EOF "\0"
|
||||
|
||||
#define GDIFF_VER_POS 4
|
||||
#define GDIFF_CS_POS 5
|
||||
#define GDIFF_CSLEN_POS 6
|
||||
|
||||
#define GDIFF_HEADERSIZE 7
|
||||
#define GDIFF_APPDATALEN 4
|
||||
|
||||
#define GDIFF_CS_NONE 0
|
||||
#define GDIFF_CS_MD5 1
|
||||
#define GDIFF_CS_SHA 2
|
||||
|
||||
/*--------------------------------------
|
||||
* GDIFF opcodes
|
||||
*------------------------------------*/
|
||||
#define ENDDIFF 0
|
||||
#define ADD8MAX 246
|
||||
#define ADD16 247
|
||||
#define ADD32 248
|
||||
#define COPY16BYTE 249
|
||||
#define COPY16SHORT 250
|
||||
#define COPY16LONG 251
|
||||
#define COPY32BYTE 252
|
||||
#define COPY32SHORT 253
|
||||
#define COPY32LONG 254
|
||||
#define COPY64 255
|
||||
|
||||
#define ADD16SIZE 2
|
||||
#define ADD32SIZE 4
|
||||
#define COPY16BYTESIZE 3
|
||||
#define COPY16SHORTSIZE 4
|
||||
#define COPY16LONGSIZE 6
|
||||
#define COPY32BYTESIZE 5
|
||||
#define COPY32SHORTSIZE 6
|
||||
#define COPY32LONGSIZE 8
|
||||
#define COPY64SIZE 12
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* error codes
|
||||
*------------------------------------*/
|
||||
#define ERR_OK 0
|
||||
#define ERR_ARGS 1
|
||||
#define ERR_ACCESS 2
|
||||
#define ERR_MEM 3
|
||||
#define ERR_HEADER 4
|
||||
#define ERR_BADDIFF 5
|
||||
#define ERR_OPCODE 6
|
||||
#define ERR_OLDFILE 7
|
||||
#define ERR_CHKSUMTYPE 8
|
||||
#define ERR_CHECKSUM 9
|
||||
|
||||
/*--------------------------------------
|
||||
* miscellaneous
|
||||
*------------------------------------*/
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
|
||||
33
mozilla/modules/softupdt/include/makefile.win
Normal file
33
mozilla/modules/softupdt/include/makefile.win
Normal file
@@ -0,0 +1,33 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
#
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=softupdt
|
||||
EXPORTS=softupdt.h su_folderspec.h gdiff.h
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to install MODULES/APPLET/INCLUDE header files into the distribution
|
||||
#// directory.
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
54
mozilla/modules/softupdt/include/softupdt.h
Normal file
54
mozilla/modules/softupdt/include/softupdt.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
#include "structs.h"
|
||||
|
||||
/* Public */
|
||||
typedef void (*SoftUpdateCompletionFunction) (int result, void * closure);
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
/* Flags for start software update */
|
||||
/* See trigger.java for docs */
|
||||
#define FORCE_INSTALL 1
|
||||
#define SILENT_INSTALL 2
|
||||
|
||||
/* StartSoftwareUpdate
|
||||
* performs the update, and calls the callback function with the
|
||||
*/
|
||||
extern XP_Bool SU_StartSoftwareUpdate(MWContext * context,
|
||||
const char * url,
|
||||
const char * name,
|
||||
SoftUpdateCompletionFunction f,
|
||||
void * completionClosure,
|
||||
int32 flags); /* FORCE_INSTALL, SILENT_INSTALL */
|
||||
|
||||
/* SU_NewStream
|
||||
* Stream decoder for software updates
|
||||
*/
|
||||
NET_StreamClass * SU_NewStream (int format_out, void * registration,
|
||||
URL_Struct * request, MWContext *context);
|
||||
|
||||
int PR_CALLBACK JavaGetBoolPref(char *pref_name);
|
||||
int PR_CALLBACK IsJavaSecurityEnabled();
|
||||
int PR_CALLBACK IsJavaSecurityDefaultTo30Enabled();
|
||||
|
||||
#define AUTOUPDATE_ENABLE_PREF "autoupdate.enabled"
|
||||
#define CONTENT_ENCODING_HEADER "Content-encoding"
|
||||
#define INSTALLER_HEADER "Install-Script"
|
||||
|
||||
XP_END_PROTOS
|
||||
89
mozilla/modules/softupdt/include/su_folderspec.h
Normal file
89
mozilla/modules/softupdt/include/su_folderspec.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/* su_folderspec.h
|
||||
* public stuff for su_folderspec.c
|
||||
*/
|
||||
|
||||
/* su_DirSpecID
|
||||
* enums for different folder types
|
||||
*/
|
||||
|
||||
#include "xp_mcom.h"
|
||||
|
||||
typedef enum su_DirSpecID {
|
||||
|
||||
/* Common folders */
|
||||
eBadFolder,
|
||||
ePluginFolder, /* where the plugins are */
|
||||
eProgramFolder, /* Where the netscape program is */
|
||||
ePackageFolder, /* Default application folder */
|
||||
eTemporaryFolder, /* Temporary */
|
||||
eCommunicatorFolder,/* Communicator */
|
||||
eInstalledFolder, /* Already installed component */
|
||||
eCurrentUserFolder, /* Navigator's current user */
|
||||
eNetHelpFolder,
|
||||
eOSDriveFolder,
|
||||
eFileURLFolder,
|
||||
|
||||
/* Java folders */
|
||||
eJavaBinFolder,
|
||||
eJavaClassesFolder,
|
||||
eJavaDownloadFolder,
|
||||
|
||||
/* Windows folders */
|
||||
eWin_WindowsFolder,
|
||||
eWin_SystemFolder,
|
||||
eWin_System16Folder,
|
||||
|
||||
/* Macintosh folders */
|
||||
eMac_SystemFolder,
|
||||
eMac_DesktopFolder,
|
||||
eMac_TrashFolder,
|
||||
eMac_StartupFolder,
|
||||
eMac_ShutdownFolder,
|
||||
eMac_AppleMenuFolder,
|
||||
eMac_ControlPanelFolder,
|
||||
eMac_ExtensionFolder,
|
||||
eMac_FontsFolder,
|
||||
eMac_PreferencesFolder,
|
||||
|
||||
/* Unix folders */
|
||||
eUnix_LocalFolder,
|
||||
eUnix_LibFolder
|
||||
|
||||
} su_DirSpecID;
|
||||
|
||||
typedef enum su_SecurityLevel {
|
||||
eOneFolderAccess,
|
||||
eAllFolderAccess
|
||||
} su_SecurityLevel;
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
/* FE_GetDirectoryPath
|
||||
* given a directory id, returns full path in native format
|
||||
* and ends with the platform specific directory separator ('/',':','\\')
|
||||
*/
|
||||
char * FE_GetDirectoryPath( su_DirSpecID folderID );
|
||||
int FE_ReplaceExistingFile(char *, XP_FileType, char *, XP_FileType, XP_Bool);
|
||||
|
||||
#ifdef WIN32
|
||||
BOOL WFE_IsMoveFileExBroken();
|
||||
#endif
|
||||
|
||||
XP_END_PROTOS
|
||||
16
mozilla/modules/softupdt/macbuild/Client.Prefix.h
Normal file
16
mozilla/modules/softupdt/macbuild/Client.Prefix.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Common defines for both debug & non-debug versions of the JavaRuntime
|
||||
//
|
||||
|
||||
#define MOZILLA_CLIENT 1
|
||||
#define MOCHAFILE 1
|
||||
#define COMPILER 0
|
||||
#define JAVA 1
|
||||
#define MOCHA 1
|
||||
#define EDITOR 1
|
||||
#define LAYERS 1
|
||||
#define VERSION_NUMBER "4_0b0"
|
||||
#define ZIP_NAME "java"##VERSION_NUMBER
|
||||
|
||||
#include "NSCrossProductDefines.h"
|
||||
#include "IDE_Options.h"
|
||||
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Debug specific defines for the JavaRuntime
|
||||
//
|
||||
|
||||
#define DEBUG 1
|
||||
#define TRACING 1
|
||||
|
||||
#include "Client.Prefix.h"
|
||||
5
mozilla/modules/softupdt/macbuild/Modules.Client.Prefix
Normal file
5
mozilla/modules/softupdt/macbuild/Modules.Client.Prefix
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Non-debug specific defines for the JavaRuntime
|
||||
//
|
||||
|
||||
#include "Client.Prefix.h"
|
||||
BIN
mozilla/modules/softupdt/macbuild/SoftUpdatePPC.prj
Normal file
BIN
mozilla/modules/softupdt/macbuild/SoftUpdatePPC.prj
Normal file
Binary file not shown.
BIN
mozilla/modules/softupdt/macbuild/SoftUpdatePPCDebug.prj
Normal file
BIN
mozilla/modules/softupdt/macbuild/SoftUpdatePPCDebug.prj
Normal file
Binary file not shown.
5
mozilla/modules/softupdt/macbuild/SoftUpdateStubs.c
Normal file
5
mozilla/modules/softupdt/macbuild/SoftUpdateStubs.c
Normal file
@@ -0,0 +1,5 @@
|
||||
void SU_Initialize(void) {}
|
||||
void VR_Initialize(void) {}
|
||||
void JavaGetBoolPref(void) {}
|
||||
void IsJavaSecurityDefaultTo30Enabled(void) {}
|
||||
void IsJavaSecurityEnabled(void) {}
|
||||
BIN
mozilla/modules/softupdt/macbuild/SoftUpdateStubsPPC.mcp
Normal file
BIN
mozilla/modules/softupdt/macbuild/SoftUpdateStubsPPC.mcp
Normal file
Binary file not shown.
31
mozilla/modules/softupdt/makefile.win
Normal file
31
mozilla/modules/softupdt/makefile.win
Normal file
@@ -0,0 +1,31 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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=..\..
|
||||
|
||||
DIRS=classes src include
|
||||
|
||||
include <$(MOZ_SRC)\ns\config\rules.mak>
|
||||
|
||||
build_classes:
|
||||
cd $(MOZ_SRC)\ns\modules\softupdt
|
||||
$(NMAKE) -f makefile.win
|
||||
cd $(MOZ_SRC)\ns\sun-java\classsrc
|
||||
$(NMAKE) -f makefile.win java40.jar
|
||||
cd $(MOZ_SRC)\ns\cmd\winfe\mkfiles32
|
||||
$(NMAKE) -f mozilla.mak
|
||||
108
mozilla/modules/softupdt/src/Makefile
Normal file
108
mozilla/modules/softupdt/src/Makefile
Normal file
@@ -0,0 +1,108 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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 = ../../..
|
||||
|
||||
MODULE = softupdate
|
||||
LIBRARY_NAME = softupdate
|
||||
|
||||
REQUIRES = softupdt js java net dbm nspr img util layer pref jar security applet lay style libreg
|
||||
|
||||
JRI_GEN = netscape.softupdate.FolderSpec \
|
||||
netscape.softupdate.InstallObject \
|
||||
netscape.softupdate.InstallFile \
|
||||
netscape.softupdate.InstallPatch \
|
||||
netscape.softupdate.InstallExecute \
|
||||
netscape.softupdate.Registry \
|
||||
netscape.softupdate.RegistryNode \
|
||||
netscape.softupdate.RegistryException \
|
||||
netscape.softupdate.RegKeyEnumerator \
|
||||
netscape.softupdate.RegEntryEnumerator \
|
||||
netscape.softupdate.SoftwareUpdate \
|
||||
netscape.softupdate.SoftUpdateException \
|
||||
netscape.softupdate.Strings \
|
||||
netscape.softupdate.Trigger \
|
||||
netscape.softupdate.VersionInfo \
|
||||
netscape.softupdate.VersionRegistry \
|
||||
netscape.softupdate.VerRegEnumerator \
|
||||
$(NULL)
|
||||
|
||||
CSRCS = softupdt.c \
|
||||
su_trigger.c \
|
||||
su_folderspec.c \
|
||||
su_instl.c \
|
||||
su_nodl.c \
|
||||
vr_java.c \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(subst /,_,$(shell uname -s)),OS2)
|
||||
CSRCS += su_unix.c
|
||||
else
|
||||
CSRCS += os2updt.c su_wjava.c
|
||||
CPPSRCS += su_win.cpp
|
||||
JRI_GEN += netscape.softupdate.WinReg netscape.softupdate.WinProfile netscape.softupdate.WinRegValue
|
||||
endif
|
||||
|
||||
EXPORTS = ../include/softupdt.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_InstallFile.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_InstallObject.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_VersionInfo.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_VersionRegistry.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_VerRegEnumerator.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_Registry.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_RegistryNode.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_RegistryException.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_RegKeyEnumerator.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_RegEntryEnumerator.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_Strings.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_Trigger.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_FolderSpec.h \
|
||||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
INCLUDES += -I$(DEPTH)/cmd/os2fe/nfc/include -I$(DEPTH)/cmd/os2fe
|
||||
endif
|
||||
|
||||
$(OBJDIR)/su_folderspec.o: $(JRI_GEN_DIR)/netscape_softupdate_FolderSpec.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h
|
||||
|
||||
$(OBJDIR)/su_instl.o: $(JRI_GEN_DIR)/netscape_softupdate_InstallFile.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_InstallObject.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_InstallExecute.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_InstallPatch.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_Strings.h
|
||||
|
||||
$(OBJDIR)/su_trigger.o: $(JRI_GEN_DIR)/netscape_softupdate_Trigger.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_Strings.c
|
||||
|
||||
$(OBJDIR)/vr_java.o: $(JRI_GEN_DIR)/netscape_softupdate_VersionInfo.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_VersionRegistry.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_VerRegEnumerator.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_Registry.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_RegistryNode.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_RegistryException.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_RegKeyEnumerator.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_RegEntryEnumerator.h
|
||||
|
||||
205
mozilla/modules/softupdt/src/makefile.win
Normal file
205
mozilla/modules/softupdt/src/makefile.win
Normal file
@@ -0,0 +1,205 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
!if "$(MOZ_BITS)" == "16"
|
||||
DIRS= nsinit
|
||||
!else
|
||||
DIRS= nsdiff nspatch
|
||||
!endif
|
||||
|
||||
!ifndef MAKE_OBJ_TYPE
|
||||
MAKE_OBJ_TYPE=EXE
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
LIBNAME=softup$(MOZ_BITS)
|
||||
PDBFILE=$(LIBNAME).pdb
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define the files necessary to build the target (ie. OBJS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\softupdt.obj \
|
||||
.\$(OBJDIR)\su_folderspec.obj \
|
||||
.\$(OBJDIR)\su_instl.obj \
|
||||
.\$(OBJDIR)\su_trigger.obj \
|
||||
.\$(OBJDIR)\su_win.obj \
|
||||
.\$(OBJDIR)\vr_java.obj \
|
||||
!if "$(MOZ_BITS)" == "16"
|
||||
.\$(OBJDIR)\su_nodl.obj \
|
||||
!endif
|
||||
.\$(OBJDIR)\su_wjava.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
JRI_GEN= \
|
||||
netscape.softupdate.FolderSpec \
|
||||
netscape.softupdate.InstallObject \
|
||||
netscape.softupdate.InstallFile \
|
||||
netscape.softupdate.InstallPatch \
|
||||
netscape.softupdate.InstallExecute \
|
||||
netscape.softupdate.Registry \
|
||||
netscape.softupdate.RegistryNode \
|
||||
netscape.softupdate.RegistryException \
|
||||
netscape.softupdate.RegKeyEnumerator \
|
||||
netscape.softupdate.RegEntryEnumerator \
|
||||
netscape.softupdate.SoftwareUpdate \
|
||||
netscape.softupdate.SoftUpdateException \
|
||||
netscape.softupdate.Strings \
|
||||
netscape.softupdate.Trigger \
|
||||
netscape.softupdate.VersionInfo \
|
||||
netscape.softupdate.VersionRegistry \
|
||||
netscape.softupdate.VerRegEnumerator \
|
||||
netscape.softupdate.WinProfile \
|
||||
netscape.softupdate.WinReg \
|
||||
netscape.softupdate.WinRegValue \
|
||||
$(NULL)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
|
||||
#// (these must be defined before the common makefiles are included)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
LIBRARY= .\$(OBJDIR)\$(LIBNAME).lib
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any local options for the make tools
|
||||
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
LINCS= $(LINCS) -I_jri \
|
||||
-I../include \
|
||||
-I$(DEPTH)/lib/libnet \
|
||||
-I$(DEPTH)/lib/layout \
|
||||
-I$(DEPTH)/lib/libjar \
|
||||
-I$(DEPTH)/lib/libstyle \
|
||||
-I$(DEPTH)/cmd/winfe \
|
||||
$(NULL)
|
||||
|
||||
#//
|
||||
#// For Win16 the following directories have been collapsed into
|
||||
#// ns/dist/public/win16 to conserve command-line argument space...
|
||||
#//
|
||||
!if "$(MOZ_BITS)" == "32"
|
||||
LINCS= $(LINCS) \
|
||||
-I$(PUBLIC)/softupdt \
|
||||
-I$(PUBLIC)/libreg \
|
||||
-I$(PUBLIC)/applet \
|
||||
-I$(PUBLIC)/java \
|
||||
-I$(PUBLIC)/nspr \
|
||||
-I$(PUBLIC)/js \
|
||||
-I$(PUBLIC)/dbm \
|
||||
-I$(PUBLIC)/security \
|
||||
-I$(PUBLIC)/pref/ \
|
||||
-I$(PUBLIC)/libfont/ \
|
||||
-I$(PUBLIC)/jtools/ \
|
||||
-I$(PUBLIC)/winfont/ \
|
||||
-I$(PUBLIC)/rdf \
|
||||
-I$(PUBLIC)/java \
|
||||
-I$(PUBLIC)/applet \
|
||||
-I$(PUBLIC)/rdf \
|
||||
$(NULL)
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
CFLAGS=$(CFLAGS) -DMOZILLA_CLIENT
|
||||
|
||||
!if "$(MOZ_BITS)" == "32"
|
||||
PUBLIC_HEADER_DIR=$(PUBLIC)\softupdt
|
||||
!else
|
||||
PUBLIC_HEADER_DIR=$(PUBLIC)\win16
|
||||
!endif
|
||||
|
||||
export::
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_InstallObject.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_SoftwareUpdate.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_SoftUpdateException.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_Strings.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_VersionInfo.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_Trigger.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_FolderSpec.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_VersionRegistry.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_VerRegEnumerator.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_WinProfile.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_WinReg.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) _jri\netscape_softupdate_WinRegValue.h $(PUBLIC_HEADER_DIR)
|
||||
|
||||
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
$(RM_R) _jri
|
||||
|
||||
.\$(OBJDIR)\su_folderspec.obj: \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_FolderSpec.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h \
|
||||
|
||||
|
||||
.\$(OBJDIR)\su_instl.obj: \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_InstallFile.c \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_InstallExecute.c \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_InstallObject.c \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_InstallPatch.c \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h \
|
||||
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.h \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_Strings.h
|
||||
|
||||
.\$(OBJDIR)\su_trigger.obj: \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_Trigger.c \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_SoftUpdateException.c \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_SoftwareUpdate.c \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_Strings.c
|
||||
|
||||
.\$(OBJDIR)\su_wjava.obj: \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_WinProfile.c \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_WinReg.c \
|
||||
$(JRI_GEN_DIR)\netscape_softupdate_WinRegValue.c
|
||||
|
||||
33
mozilla/modules/softupdt/src/nsdiff/Makefile
Normal file
33
mozilla/modules/softupdt/src/nsdiff/Makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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 = ../../../..
|
||||
|
||||
REQUIRES = softupdt
|
||||
|
||||
CSRCS = nsdiff.c
|
||||
|
||||
PROGRAM = nsdiff$(BIN_SUFFIX)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
symbols:
|
||||
@echo "CSRCS = $(CSRCS)"
|
||||
@echo "OBJS = $(OBJS)"
|
||||
@echo "PROGRAM = $(PROGRAM)"
|
||||
@echo "LIBRARY = $(LIBRARY)"
|
||||
@echo "TARGETS = $(TARGETS)"
|
||||
66
mozilla/modules/softupdt/src/nsdiff/makefile.win
Normal file
66
mozilla/modules/softupdt/src/nsdiff/makefile.win
Normal file
@@ -0,0 +1,66 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
#
|
||||
|
||||
#VERBOSE = 1
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
#cannot define PROGRAM in manifest compatibly with NT and UNIX
|
||||
PROGRAM= .\$(OBJDIR)\nsdiff.exe
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
# let manifest generate C_OBJS, it will prepend ./$(OBJDIR)/
|
||||
# rules.mak will append C_OBJS onto OBJS.
|
||||
# OBJS = $(CSRCS:.c=.obj)
|
||||
|
||||
PDBFILE = nsdiff.pdb
|
||||
MAPFILE = nsdiff.map
|
||||
|
||||
REQUIRES=softupdt
|
||||
CSRCS=nsdiff.c
|
||||
C_OBJS=.\$(OBJDIR)\nsdiff.obj
|
||||
!if "$(MOZ_BITS)" != "16"
|
||||
LINCS=-I$(XPDIST)\public\softupdt
|
||||
!endif
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
INSTALL = $(MAKE_INSTALL)
|
||||
|
||||
objs: $(OBJS)
|
||||
|
||||
programs: $(PROGRAM)
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(TARGETS) $(DIST)/bin
|
||||
|
||||
symbols:
|
||||
@echo "CSRCS = $(CSRCS)"
|
||||
@echo "INCS = $(INCS)"
|
||||
@echo "OBJS = $(OBJS)"
|
||||
@echo "LIBRARY = $(LIBRARY)"
|
||||
@echo "PROGRAM = $(PROGRAM)"
|
||||
@echo "TARGETS = $(TARGETS)"
|
||||
@echo "DIST = $(DIST)"
|
||||
@echo "VERSION_NUMBER = $(VERSION_NUMBER)"
|
||||
@echo "WINFE = $(WINFE)"
|
||||
@echo "DBM_LIB = $(DBM_LIB)"
|
||||
@echo "INSTALL = $(INSTALL)"
|
||||
|
||||
952
mozilla/modules/softupdt/src/nsdiff/nsdiff.c
Normal file
952
mozilla/modules/softupdt/src/nsdiff/nsdiff.c
Normal file
@@ -0,0 +1,952 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*--------------------------------------------------------------------
|
||||
* NSDiff
|
||||
*
|
||||
* A binary file diffing utility that creates diffs in GDIFF format
|
||||
*
|
||||
* nsdiff [-b"blocksize"] [-o"outfile"] oldfile newfile
|
||||
*
|
||||
* Blocksize defaults to 32.
|
||||
* The outfile defaults to "newfile" with a .GDF extension
|
||||
*
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "gdiff.h"
|
||||
|
||||
/*--------------------------------------
|
||||
* constants
|
||||
*------------------------------------*/
|
||||
|
||||
#define IGNORE_SIZE 7
|
||||
#define DEFAULT_BLOCKSIZE 32
|
||||
#define FILENAMESIZE 513
|
||||
#define OLDBUFSIZE 0x1FFF
|
||||
#define MAXBUFSIZE 0xFFFF /* more requires long adds, wasting space */
|
||||
#define CHKMOD 65536
|
||||
#define HTBLSIZE 65521
|
||||
|
||||
#define destroyFdata(fd) { if ((fd)->data != NULL) free((fd)->data); }
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* types
|
||||
*------------------------------------*/
|
||||
|
||||
typedef unsigned long uint32;
|
||||
typedef long int32;
|
||||
typedef unsigned short uint16;
|
||||
typedef short int16;
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned char BOOL;
|
||||
|
||||
typedef struct hnode {
|
||||
uint32 chksum; /* true checksum of the block */
|
||||
uint32 offset; /* offset into old file */
|
||||
struct hnode *next; /* next node in collision list */
|
||||
} HNODE, *HPTR;
|
||||
|
||||
typedef struct filedata {
|
||||
uint32 filepos; /* fileposition of start of buffer */
|
||||
int32 offset; /* current position in the buffer */
|
||||
int32 unwritten; /* the start of the unwritten buffer */
|
||||
uint32 datalen; /* actual amount of data in buffer */
|
||||
uint32 bufsize; /* the physical size of the memory buffer */
|
||||
uchar * data; /* a "bufsize" memory block for data */
|
||||
FILE * file; /* file handle */
|
||||
BOOL bDoAdds; /* If true check for "add" data before reading */
|
||||
} FILEDATA;
|
||||
|
||||
/*--------------------------------------
|
||||
* prototypes
|
||||
*------------------------------------*/
|
||||
|
||||
void add( uchar *data, uint32 count, FILE *outf );
|
||||
void adddata( FILEDATA *fd );
|
||||
void copy( uint32 offset, uint32 count, FILE *outf );
|
||||
uint32 checksum( uchar *buffer, uint32 offset, uint32 count );
|
||||
HPTR *chunkOldFile( FILE *fh, uint32 blocksize );
|
||||
void cleanup( void );
|
||||
uint32 compareFdata( FILEDATA *oldfd, uint32 oldpos, FILEDATA *newfd );
|
||||
void diff( FILE *oldf, FILE *newf, FILE *outf );
|
||||
uint32 getChecksum( FILEDATA *fd );
|
||||
BOOL getFdata( FILEDATA *fdata, uint32 position );
|
||||
BOOL initFdata( FILEDATA *fdata, FILE *file, uint32 bufsize, BOOL bDoAdds );
|
||||
BOOL moreFdata( FILEDATA *fdata );
|
||||
int openFiles( void );
|
||||
void readFdata( FILEDATA *fdata, uint32 position );
|
||||
void usage( void );
|
||||
BOOL validateArgs( int argc, char *argv[] );
|
||||
void writeHeader( FILE *outf );
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* Global data
|
||||
*------------------------------------*/
|
||||
|
||||
char *oldname = NULL,
|
||||
*newname = NULL,
|
||||
*outname = NULL;
|
||||
|
||||
FILE *oldfile,
|
||||
*newfile,
|
||||
*outfile;
|
||||
|
||||
uint32 blocksize = DEFAULT_BLOCKSIZE;
|
||||
|
||||
HPTR *htbl;
|
||||
|
||||
/* for hashing stats */
|
||||
uint32 slotsused = 0,
|
||||
blockshashed = 0,
|
||||
blocksfound = 0,
|
||||
hashhits = 0,
|
||||
partialmatch = 0,
|
||||
cmpfailed = 0;
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* main
|
||||
*------------------------------------*/
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Parse command line */
|
||||
|
||||
if ( !validateArgs( argc, argv ) ) {
|
||||
err = ERR_ARGS;
|
||||
}
|
||||
else {
|
||||
err = openFiles();
|
||||
}
|
||||
|
||||
|
||||
/* Calculate block checksums in old file */
|
||||
|
||||
if ( err == ERR_OK ) {
|
||||
htbl = chunkOldFile( oldfile, blocksize );
|
||||
if ( htbl == NULL )
|
||||
err = ERR_MEM;
|
||||
}
|
||||
|
||||
|
||||
/* Do the diff */
|
||||
|
||||
if ( err == ERR_OK ) {
|
||||
writeHeader( outfile );
|
||||
diff( oldfile, newfile, outfile );
|
||||
}
|
||||
|
||||
|
||||
/* Cleanup */
|
||||
|
||||
cleanup();
|
||||
|
||||
|
||||
/* Report status */
|
||||
|
||||
if ( err == ERR_OK ) {
|
||||
fprintf( stderr, "\nHashed %ld blocks into %ld slots (out of %ld)\n",
|
||||
blockshashed, slotsused, HTBLSIZE );
|
||||
fprintf( stderr, "Blocks found: %ld\n", blocksfound );
|
||||
fprintf( stderr, "Hashtable hits: %ld\n", hashhits );
|
||||
fprintf( stderr, "memcmps failed: %ld\n", cmpfailed );
|
||||
fprintf( stderr, "partial matches: %ld\n", partialmatch );
|
||||
}
|
||||
else {
|
||||
switch (err) {
|
||||
case ERR_ARGS:
|
||||
fprintf( stderr, "Invalid arguments\n" );
|
||||
usage();
|
||||
break;
|
||||
|
||||
case ERR_ACCESS:
|
||||
fprintf( stderr, "Error opening file\n" );
|
||||
break;
|
||||
|
||||
case ERR_MEM:
|
||||
fprintf( stderr, "Insufficient memory\n" );
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf( stderr, "Unknown error %d\n", err );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* add
|
||||
*------------------------------------*/
|
||||
|
||||
void add( uchar *data, uint32 count, FILE *outf )
|
||||
{
|
||||
uchar numbuf[5];
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf( stderr, "Adding %ld bytes\n", count );
|
||||
#endif
|
||||
|
||||
if ( count == 0 )
|
||||
return;
|
||||
|
||||
if ( count <= ADD8MAX ) {
|
||||
numbuf[0] = (uchar)count;
|
||||
fwrite( numbuf, 1, 1, outf );
|
||||
}
|
||||
else if ( count <= 0xFFFF ) {
|
||||
numbuf[0] = ADD16;
|
||||
numbuf[1] = (uchar)( count >> 8 );
|
||||
numbuf[2] = (uchar)( count & 0x00FF );
|
||||
fwrite( numbuf, 1, 3, outf );
|
||||
}
|
||||
else {
|
||||
numbuf[0] = ADD32;
|
||||
numbuf[1] = (uchar)( count >> 24 );
|
||||
numbuf[2] = (uchar)( ( count >> 16 ) & 0x00FF );
|
||||
numbuf[3] = (uchar)( ( count >> 8 ) & 0x00FF );
|
||||
numbuf[4] = (uchar)( count & 0x00FF );
|
||||
fwrite( numbuf, 1, 5, outf );
|
||||
}
|
||||
|
||||
fwrite( data, 1, count, outf );
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* copy
|
||||
*------------------------------------*/
|
||||
|
||||
void copy( uint32 offset, uint32 count, FILE *outf )
|
||||
{
|
||||
uchar numbuf[9];
|
||||
#ifdef DEBUG
|
||||
fprintf( stderr, "Copying %ld bytes from offset %ld\n", count, offset );
|
||||
#endif
|
||||
|
||||
if ( count == 0 )
|
||||
return;
|
||||
|
||||
if ( offset <= 0xFFFF ) {
|
||||
numbuf[1] = (uchar)( offset >> 8 );
|
||||
numbuf[2] = (uchar)( offset & 0x00FF );
|
||||
|
||||
if ( count <= 0xFF ) {
|
||||
numbuf[0] = COPY16BYTE;
|
||||
numbuf[3] = (uchar)( count & 0xFF );
|
||||
fwrite( numbuf, 1, 4, outf );
|
||||
}
|
||||
else if ( count <= 0xFFFF ) {
|
||||
numbuf[0] = COPY16SHORT;
|
||||
numbuf[3] = (uchar)( count >> 8 );
|
||||
numbuf[4] = (uchar)( count & 0x00FF );
|
||||
fwrite( numbuf, 1, 5, outf );
|
||||
}
|
||||
else {
|
||||
numbuf[0] = COPY16LONG;
|
||||
numbuf[3] = (uchar)( count >> 24 );
|
||||
numbuf[4] = (uchar)( ( count >> 16 ) & 0x00FF );
|
||||
numbuf[5] = (uchar)( ( count >> 8 ) & 0x00FF );
|
||||
numbuf[6] = (uchar)( count & 0x00FF );
|
||||
fwrite( numbuf, 1, 7, outf );
|
||||
}
|
||||
}
|
||||
else {
|
||||
numbuf[1] = (uchar)( offset >> 24 );
|
||||
numbuf[2] = (uchar)( ( offset >> 16 ) & 0x00FF );
|
||||
numbuf[3] = (uchar)( ( offset >> 8 ) & 0x00FF );
|
||||
numbuf[4] = (uchar)( offset & 0x00FF );
|
||||
|
||||
if ( count <= 0xFF ) {
|
||||
numbuf[0] = COPY32BYTE;
|
||||
numbuf[5] = (uchar)( count & 0xFF );
|
||||
fwrite( numbuf, 1, 6, outf );
|
||||
}
|
||||
else if ( count <= 0xFFFF ) {
|
||||
numbuf[0] = COPY32SHORT;
|
||||
numbuf[5] = (uchar)( count >> 8 );
|
||||
numbuf[6] = (uchar)( count & 0x00FF );
|
||||
fwrite( numbuf, 1, 7, outf );
|
||||
}
|
||||
else {
|
||||
numbuf[0] = COPY32LONG;
|
||||
numbuf[5] = (uchar)( count >> 24 );
|
||||
numbuf[6] = (uchar)( ( count >> 16 ) & 0x00FF );
|
||||
numbuf[7] = (uchar)( ( count >> 8 ) & 0x00FF );
|
||||
numbuf[8] = (uchar)( count & 0x00FF );
|
||||
fwrite( numbuf, 1, 9, outf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* checksum
|
||||
*------------------------------------*/
|
||||
|
||||
uint32 checksum( uchar *buffer, uint32 offset, uint32 count )
|
||||
{
|
||||
uint32 i,
|
||||
s1 = 0,
|
||||
s2 = 0;
|
||||
|
||||
for ( i=0; i < count; i++ ) {
|
||||
s1 = ( s1 + buffer[ offset+i ] ) % CHKMOD ;
|
||||
s2 = ( s2 + s1 ) % CHKMOD ;
|
||||
}
|
||||
|
||||
return ( (s2 << 16) + s1 );
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* chunkOldFile
|
||||
*------------------------------------*/
|
||||
|
||||
HPTR *chunkOldFile( FILE *fh, uint32 blocksize )
|
||||
{
|
||||
HPTR *table;
|
||||
HPTR node;
|
||||
HPTR tmp;
|
||||
uchar *buffer;
|
||||
uint32 filepos;
|
||||
uint32 bufsize;
|
||||
uint32 bytesRead;
|
||||
uint32 chksum;
|
||||
uint32 hash;
|
||||
uint32 i;
|
||||
|
||||
bufsize = ( MAXBUFSIZE / blocksize ) * blocksize ;
|
||||
#ifdef DEBUG
|
||||
fprintf( stderr, "bufsize: %ld, tblsize: %ld\n", bufsize, HTBLSIZE*sizeof(HPTR) );
|
||||
#endif
|
||||
|
||||
table = (HPTR*)malloc( HTBLSIZE * sizeof(HPTR) );
|
||||
buffer = (uchar*)malloc( bufsize );
|
||||
|
||||
if ( table == NULL || buffer == NULL) {
|
||||
fprintf( stderr, "Out of memory\n" );
|
||||
|
||||
if ( table != NULL )
|
||||
free( table );
|
||||
}
|
||||
else {
|
||||
memset( table, 0, HTBLSIZE * sizeof(HPTR) );
|
||||
|
||||
filepos = 0;
|
||||
do {
|
||||
bytesRead = fread( buffer, 1, bufsize, fh );
|
||||
#ifdef DEBUG
|
||||
fprintf( stderr, "read %ld bytes\n", bytesRead );
|
||||
#endif
|
||||
|
||||
i = 0;
|
||||
while ( i < bytesRead ) {
|
||||
blockshashed++;
|
||||
|
||||
node = (HPTR)malloc( sizeof(HNODE) );
|
||||
if ( node != NULL ) {
|
||||
|
||||
if ( blocksize <= bytesRead-i )
|
||||
chksum = checksum( buffer, i, blocksize );
|
||||
else
|
||||
chksum = checksum( buffer, i, bytesRead-i );
|
||||
|
||||
hash = chksum % HTBLSIZE;
|
||||
|
||||
node->chksum = chksum;
|
||||
node->offset = filepos + i;
|
||||
node->next = NULL;
|
||||
|
||||
tmp = table[hash];
|
||||
if (tmp == NULL) {
|
||||
slotsused++;
|
||||
table[hash] = node;
|
||||
}
|
||||
else {
|
||||
#ifdef FRONTHASH
|
||||
node->next = tmp;
|
||||
table[hash] = node;
|
||||
#else
|
||||
while (tmp->next != NULL)
|
||||
tmp = tmp->next;
|
||||
tmp->next = node;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
fprintf( stderr, "Out of memory\n" );
|
||||
}
|
||||
|
||||
i += blocksize;
|
||||
}
|
||||
|
||||
filepos += bytesRead;
|
||||
|
||||
} while ( bytesRead > 0 );
|
||||
|
||||
}
|
||||
|
||||
/* reset file to beginning for comparison */
|
||||
fseek( fh, 0, SEEK_SET );
|
||||
|
||||
if ( buffer != NULL )
|
||||
free(buffer);
|
||||
|
||||
return (table);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* cleanup
|
||||
*------------------------------------*/
|
||||
|
||||
void cleanup()
|
||||
{
|
||||
long i;
|
||||
HPTR tmp;
|
||||
|
||||
if ( oldfile != NULL )
|
||||
fclose( oldfile );
|
||||
|
||||
if ( newfile != NULL )
|
||||
fclose( newfile );
|
||||
|
||||
if ( outfile != NULL )
|
||||
fclose( outfile );
|
||||
|
||||
if ( htbl != NULL ) {
|
||||
for ( i=HTBLSIZE-1; i >= 0; i-- ) {
|
||||
while ( htbl[i] != NULL ) {
|
||||
tmp = htbl[i]->next;
|
||||
free( htbl[i] );
|
||||
htbl[i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
free( htbl );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef OLDDIFF
|
||||
/*--------------------------------------
|
||||
* diff
|
||||
*------------------------------------*/
|
||||
|
||||
void diff( FILE *oldf, FILE *newf, FILE *outf )
|
||||
{
|
||||
FILEDATA oldfd,
|
||||
newfd;
|
||||
|
||||
uint32 rChk,
|
||||
match,
|
||||
tmpfilepos,
|
||||
tmpoffset,
|
||||
hash;
|
||||
|
||||
HPTR node;
|
||||
|
||||
if ( !initFdata( &oldfd, oldf, OLDBUFSIZE, FALSE ) ||
|
||||
!initFdata( &newfd, newf, MAXBUFSIZE, TRUE ) )
|
||||
{
|
||||
fprintf( stderr, "Out of memory!\n" );
|
||||
goto bail;
|
||||
}
|
||||
|
||||
outerloop:
|
||||
while ( moreFdata( &newfd ) ) {
|
||||
rChk = getChecksum( &newfd );
|
||||
hash = rChk % HTBLSIZE;
|
||||
|
||||
node = htbl[hash];
|
||||
while( node != NULL ) {
|
||||
hashhits++;
|
||||
|
||||
/* compare checksums to see if this might be a match */
|
||||
if ( rChk == node->chksum ) {
|
||||
/* might be a match, compare actual bits */
|
||||
tmpfilepos = newfd.filepos;
|
||||
tmpoffset = newfd.offset;
|
||||
match = compareFdata( &oldfd, node->offset, &newfd );
|
||||
|
||||
if ( match > IGNORE_SIZE ) {
|
||||
blocksfound++;
|
||||
if ( match < blocksize )
|
||||
partialmatch++;
|
||||
|
||||
/* add any unmatched bytes from new file */
|
||||
if ( newfd.offset > newfd.unwritten )
|
||||
adddata( &newfd );
|
||||
|
||||
/* copy the matched block from old file */
|
||||
copy( node->offset, match, outf );
|
||||
|
||||
/* skip the copied bytes */
|
||||
newfd.offset = tmpfilepos+tmpoffset + match - newfd.filepos;
|
||||
newfd.unwritten = newfd.offset;
|
||||
|
||||
/* don't increment offset in loop, this is the new start */
|
||||
goto outerloop; /* "continue outerloop" */
|
||||
}
|
||||
else {
|
||||
/* match failed */
|
||||
cmpfailed++;
|
||||
node = node->next;
|
||||
|
||||
if ( tmpfilepos != newfd.filepos ) {
|
||||
/* file buffer was moved during failed compare */
|
||||
readFdata( &newfd, tmpfilepos+tmpoffset );
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* can't be a match */
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
} /* while (node!=NULL) */
|
||||
|
||||
/* examine next byte */
|
||||
newfd.offset++;
|
||||
|
||||
} /* while( modeFdata() ) */
|
||||
|
||||
|
||||
/* check for final unmatched data */
|
||||
|
||||
if ( newfd.offset > newfd.unwritten ) {
|
||||
assert( 0 ); /* this should be taken care of in moreFdata now */
|
||||
adddata( &newfd );
|
||||
}
|
||||
|
||||
|
||||
/* Terminate the GDIFF file */
|
||||
|
||||
fwrite( GDIFF_EOF, 1, 1, outf );
|
||||
|
||||
|
||||
bail:
|
||||
destroyFdata( &oldfd );
|
||||
destroyFdata( &newfd );
|
||||
}
|
||||
|
||||
|
||||
BOOL initFdata( FILEDATA *fdata, FILE *file, uint32 bufsize, BOOL bDoAdds )
|
||||
{
|
||||
fdata->filepos = 0;
|
||||
fdata->offset = 0;
|
||||
fdata->unwritten= 0;
|
||||
fdata->datalen = 0;
|
||||
fdata->data = (uchar*)malloc(bufsize);
|
||||
fdata->bufsize = bufsize;
|
||||
fdata->file = file;
|
||||
fdata->bDoAdds = bDoAdds;
|
||||
|
||||
if ( fdata->data == NULL )
|
||||
return (FALSE);
|
||||
|
||||
readFdata( fdata, 0 );
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
BOOL moreFdata( FILEDATA *fd )
|
||||
{
|
||||
if ( fd->offset < fd->datalen ) {
|
||||
/* pointer still in buffer */
|
||||
return (TRUE);
|
||||
}
|
||||
else {
|
||||
readFdata( fd, (fd->filepos + fd->offset) );
|
||||
|
||||
if (fd->offset >= fd->datalen) {
|
||||
/* no more data */
|
||||
return (FALSE);
|
||||
}
|
||||
else
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL getFdata( FILEDATA *fd, uint32 position )
|
||||
{
|
||||
if ( (position >= fd->filepos) && (position < (fd->filepos+fd->datalen)) ) {
|
||||
/* the position is available in the current buffer */
|
||||
return (TRUE);
|
||||
}
|
||||
else {
|
||||
/* try to get the position into the buffer */
|
||||
readFdata( fd, position );
|
||||
}
|
||||
|
||||
if ( position >= (fd->filepos + fd->datalen) ) {
|
||||
/* position still not in buffer: not enough data */
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
void readFdata( FILEDATA *fd, uint32 position )
|
||||
{
|
||||
if ( fd->bDoAdds && (fd->offset > fd->unwritten) ) {
|
||||
add( fd->data + fd->unwritten, fd->offset - fd->unwritten, outfile );
|
||||
}
|
||||
|
||||
if ( position != (fd->filepos + fd->datalen) ) {
|
||||
/* it's not just the next read so we must seek to it */
|
||||
fseek( fd->file, position, SEEK_SET );
|
||||
/* assert that in newfile we move byte by byte */
|
||||
assert( !fd->bDoAdds || position == fd->filepos+fd->offset );
|
||||
}
|
||||
|
||||
fd->datalen = fread( fd->data, 1, fd->bufsize, fd->file );
|
||||
fd->filepos = position;
|
||||
fd->offset = 0;
|
||||
fd->unwritten = 0;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"Read %ld %s bytes\n",fd->datalen, fd->bDoAdds?"NEW":"old");
|
||||
#endif
|
||||
}
|
||||
|
||||
void adddata( FILEDATA *fd )
|
||||
{
|
||||
uint32 chunksize;
|
||||
|
||||
assert( fd->offset <= fd->datalen ); /* must be in the buffer */
|
||||
|
||||
chunksize = fd->offset - fd->unwritten;
|
||||
|
||||
if ( chunksize > 0 ) {
|
||||
add( fd->data + fd->unwritten, chunksize, outfile );
|
||||
fd->unwritten = fd->offset;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 compareFdata( FILEDATA *oldfd, uint32 oldpos, FILEDATA *newfd )
|
||||
{
|
||||
int32 oldoffset, newoffset;
|
||||
uint32 count = 0;
|
||||
|
||||
if ( getFdata( oldfd, oldpos ) && (newfd->offset < newfd->datalen) ) {
|
||||
oldoffset = oldpos - oldfd->filepos;
|
||||
newoffset = newfd->offset;
|
||||
|
||||
while ( *(oldfd->data + oldoffset) == *(newfd->data + newoffset) ) {
|
||||
oldoffset++;
|
||||
newoffset++;
|
||||
count++;
|
||||
|
||||
if ( oldoffset >= oldfd->datalen ) {
|
||||
readFdata( oldfd, oldfd->filepos + oldoffset );
|
||||
oldoffset = 0;
|
||||
if ( oldfd->datalen == 0 ) {
|
||||
/* out of data */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( newoffset >= newfd->datalen ) {
|
||||
if ( newfd->datalen != newfd->bufsize ) {
|
||||
/* we're at EOF, don't read more */
|
||||
break;
|
||||
}
|
||||
else {
|
||||
readFdata( newfd, newfd->filepos + newoffset );
|
||||
newoffset = 0;
|
||||
if ( newfd->datalen == 0 ) {
|
||||
/* Hm, at EOF after all */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
uint32 getChecksum( FILEDATA *fd )
|
||||
{
|
||||
/* XXX Need to implement a rolling checksum */
|
||||
uint32 remaining;
|
||||
|
||||
assert( fd->offset < fd->datalen ); /* must be in buffer */
|
||||
|
||||
remaining = fd->datalen - fd->offset;
|
||||
|
||||
if ( remaining >= blocksize ) {
|
||||
/* plenty of room to calculate */
|
||||
return checksum( fd->data, fd->offset, blocksize );
|
||||
}
|
||||
else {
|
||||
/* fewer than 'blocksize' bytes remain in buffer */
|
||||
|
||||
if ( fd->datalen == fd->bufsize ) {
|
||||
/* there should be more file to read */
|
||||
readFdata( fd, fd->filepos + fd->offset );
|
||||
remaining = fd->datalen;
|
||||
}
|
||||
|
||||
if ( remaining < blocksize )
|
||||
return checksum( fd->data, fd->offset, remaining );
|
||||
else
|
||||
return checksum( fd->data, fd->offset, blocksize );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else /* !NEWDIFF, i.e. old buggy diff */
|
||||
/*--------------------------------------
|
||||
* diff
|
||||
*------------------------------------*/
|
||||
|
||||
void diff( FILE *oldf, FILE *newf, FILE *outf )
|
||||
{
|
||||
uchar *olddata,
|
||||
*newdata;
|
||||
|
||||
uint32 rChk,
|
||||
i,
|
||||
unwritten,
|
||||
hash,
|
||||
maxShifts,
|
||||
oldbytes,
|
||||
bytesRead;
|
||||
|
||||
HPTR node;
|
||||
|
||||
olddata = (uchar*)malloc(blocksize);
|
||||
newdata = (uchar*)malloc(MAXBUFSIZE);
|
||||
|
||||
if (olddata == NULL || newdata == NULL ) {
|
||||
fprintf( stderr, "Out of memory!\n" );
|
||||
goto bail;
|
||||
}
|
||||
|
||||
do {
|
||||
bytesRead = fread( newdata, 1, MAXBUFSIZE, newf );
|
||||
if ( bytesRead >= blocksize )
|
||||
maxShifts = (bytesRead - blocksize + 1);
|
||||
else
|
||||
maxShifts = 0;
|
||||
#ifdef DEBUG
|
||||
fprintf( stderr, "read %ld new bytes\n", bytesRead );
|
||||
#endif
|
||||
|
||||
unwritten = 0;
|
||||
for ( i=0; i < maxShifts ; i++ ) {
|
||||
/* wastefully slow, convert to rolling checksum */
|
||||
rChk = checksum( newdata, i, blocksize );
|
||||
hash = rChk % HTBLSIZE;
|
||||
|
||||
node = htbl[hash];
|
||||
while( node != NULL ) {
|
||||
hashhits++;
|
||||
/* compare checksums to see if this might really be a match */
|
||||
if ( rChk != node->chksum ) {
|
||||
/* can't be a match */
|
||||
node = node->next;
|
||||
}
|
||||
else {
|
||||
/* might be a match, compare actual bits */
|
||||
fseek( oldf, node->offset, SEEK_SET );
|
||||
oldbytes = fread( olddata, 1, blocksize, oldf );
|
||||
if ( memcmp( olddata, newdata+i, oldbytes ) != 0 ) {
|
||||
cmpfailed++;
|
||||
node = node->next;
|
||||
}
|
||||
else {
|
||||
blocksfound++;
|
||||
|
||||
/* add any unmatched bytes from new file */
|
||||
if ( i > unwritten )
|
||||
add( newdata+unwritten, i-unwritten, outf );
|
||||
|
||||
/* copy the matched block from old file */
|
||||
copy( node->offset, oldbytes, outf );
|
||||
|
||||
/* skip the copied bytes */
|
||||
unwritten = (i + oldbytes);
|
||||
/* "i" gets one less, the "for" increments it */
|
||||
i = unwritten - 1;
|
||||
|
||||
/* done with this hash entry */
|
||||
node = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* prepare to read another block */
|
||||
|
||||
if ( unwritten < i ) {
|
||||
/* add the unmatched data */
|
||||
add( newdata+unwritten, i-unwritten, outf );
|
||||
}
|
||||
|
||||
#if 0
|
||||
if ( i < bytesRead ) {
|
||||
/* shift filepointer back so uncompared data isn't missed */
|
||||
fseek( newf, (i - bytesRead), SEEK_CUR );
|
||||
}
|
||||
#endif
|
||||
|
||||
} while ( bytesRead > 0 );
|
||||
|
||||
|
||||
/* Terminate the GDIFF file */
|
||||
|
||||
fwrite( GDIFF_EOF, 1, 1, outf );
|
||||
|
||||
|
||||
bail:
|
||||
if ( olddata != NULL )
|
||||
free( olddata );
|
||||
if (newdata != NULL )
|
||||
free( newdata );
|
||||
}
|
||||
#endif /* NEWDIFF */
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* openFiles
|
||||
*------------------------------------*/
|
||||
|
||||
int openFiles()
|
||||
{
|
||||
char namebuf[FILENAMESIZE];
|
||||
|
||||
oldfile = fopen( oldname, "rb" );
|
||||
if ( oldfile == NULL ) {
|
||||
fprintf( stderr, "Can't open %s for reading\n", oldname );
|
||||
return ERR_ACCESS;
|
||||
}
|
||||
|
||||
newfile = fopen( newname, "rb" );
|
||||
if ( newfile == NULL ) {
|
||||
fprintf( stderr, "Can't open %s for reading\n", newname );
|
||||
return ERR_ACCESS;
|
||||
}
|
||||
|
||||
if ( outname == NULL || *outname == '\0' ) {
|
||||
strcpy( namebuf, newname );
|
||||
strcat( namebuf, ".gdf" );
|
||||
outname = namebuf;
|
||||
}
|
||||
outfile = fopen( outname, "wb" );
|
||||
if ( outfile == NULL ) {
|
||||
fprintf( stderr, "Can't open %s for writing\n", outname );
|
||||
return ERR_ACCESS;
|
||||
}
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* usage
|
||||
*------------------------------------*/
|
||||
|
||||
void usage ()
|
||||
{
|
||||
fprintf( stderr, "\n NSDiff [-b#] [-o\"outfile\"] oldfile newfile\n\n" );
|
||||
fprintf( stderr, " -b size of blocks to compare in bytes, " \
|
||||
"default %d\n", DEFAULT_BLOCKSIZE );
|
||||
fprintf( stderr, " -o name of output diff file\n\n" );
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* validateArgs
|
||||
*------------------------------------*/
|
||||
|
||||
BOOL validateArgs( int argc, char *argv[] )
|
||||
{
|
||||
int i;
|
||||
for ( i = 1; i < argc; i++ ) {
|
||||
if ( *argv[i] == '-' ) {
|
||||
switch (*(argv[i]+1)) {
|
||||
case 'b':
|
||||
blocksize = atoi( argv[i]+2 );
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
outname = argv[i]+2;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf( stderr, "Unknown option %s\n", argv[i] );
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
else if ( oldname == NULL ) {
|
||||
oldname = argv[i];
|
||||
}
|
||||
else if ( newname == NULL ) {
|
||||
newname = argv[i];
|
||||
}
|
||||
else {
|
||||
fprintf( stderr, "Too many arguments\n" );
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf( stderr, "Blocksize: %d\n", blocksize );
|
||||
fprintf( stderr, "Old file: %s\n", oldname );
|
||||
fprintf( stderr, "New file: %s\n", newname );
|
||||
fprintf( stderr, "diff file: %s\n", outname );
|
||||
#endif
|
||||
|
||||
/* validate arguments */
|
||||
|
||||
if ( blocksize <= IGNORE_SIZE || blocksize > MAXBUFSIZE ) {
|
||||
fprintf( stderr, "Invalid blocksize: %d\n", blocksize );
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if ( oldname == NULL || newname == NULL ) {
|
||||
fprintf( stderr, "Old and new file name parameters are required.\n" );
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* writeHeader
|
||||
*------------------------------------*/
|
||||
|
||||
void writeHeader( FILE *outf )
|
||||
{
|
||||
fwrite( "\xd1\xff\xd1\xff\05\0\0\0\0\0\0", 1, 11, outf );
|
||||
}
|
||||
|
||||
86
mozilla/modules/softupdt/src/nsinit/makefile.win
Normal file
86
mozilla/modules/softupdt/src/nsinit/makefile.win
Normal file
@@ -0,0 +1,86 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..\..\..
|
||||
|
||||
!if "$(MOZ_BITS)" == "32"
|
||||
!ERROR NSINIT is Win16 only
|
||||
!endif
|
||||
|
||||
!ifndef MAKE_OBJ_TYPE
|
||||
MAKE_OBJ_TYPE=EXE
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
EXENAME= nsinit
|
||||
MAPFILE= $(EXENAME).map
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define the files necessary to build the target (ie. OBJS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\nsinit.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
|
||||
#// (these must be defined before the common makefiles are included)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
PROGRAM= .\$(OBJDIR)\$(EXENAME).exe
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any local options for the make tools
|
||||
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
#LINCS= $(LINCS) \
|
||||
# $(NULL)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
install:: $(PROGRAM)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||
|
||||
249
mozilla/modules/softupdt/src/nsinit/nsinit.c
Normal file
249
mozilla/modules/softupdt/src/nsinit/nsinit.c
Normal file
@@ -0,0 +1,249 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <malloc.h>
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
#define BSIZE 16384
|
||||
#define KSIZE 1024
|
||||
#define COPYSIZE 32000
|
||||
|
||||
#define OK 1
|
||||
#define ERROR 0
|
||||
|
||||
|
||||
#ifdef DEBUG_dveditz
|
||||
#define DBG(msg) MessageBox((HWND)NULL, (msg), "NS-Init Debug message", 0);
|
||||
#else
|
||||
#define DBG(msg) ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
//--- Macros for readability ---
|
||||
#define SECTION "Rename"
|
||||
#define INIFILE "WININIT.INI"
|
||||
|
||||
#define GetRenameString(key, buf, bufsize) \
|
||||
GetPrivateProfileString( SECTION, (key), "", (buf), (bufsize), INIFILE)
|
||||
|
||||
#define DeleteRenameString(key) \
|
||||
WritePrivateProfileString( SECTION, (key), NULL, INIFILE )
|
||||
|
||||
// returns buf filled with null separated list of key names
|
||||
// terminated by a double null.
|
||||
#define GetRenameKeys(buf, bufsize) \
|
||||
GetRenameString( NULL, (buf), (bufsize) )
|
||||
|
||||
|
||||
|
||||
//--- prototypes ---
|
||||
int FileReplace( LPCSTR src, LPCSTR dest );
|
||||
int RenameFile( LPCSTR src, LPCSTR dest );
|
||||
|
||||
char *copybuf;
|
||||
|
||||
int PASCAL WinMain(HINSTANCE hinst, HINSTANCE hPrevInst,
|
||||
LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
char *Buff;
|
||||
char *Src;
|
||||
|
||||
Buff = (char*)malloc(BSIZE);
|
||||
Src = (char*)malloc(KSIZE);
|
||||
copybuf = (char*)malloc(COPYSIZE);
|
||||
|
||||
if ( Buff == NULL || Src == NULL || copybuf == NULL )
|
||||
return -1;
|
||||
|
||||
// extract all the keys
|
||||
if ( GetRenameKeys( Buff, BSIZE) ) {
|
||||
char *pDest = Buff;
|
||||
|
||||
// for each key do the specified file swap
|
||||
while ( *pDest ) {
|
||||
if ( GetRenameString( pDest, Src, KSIZE) ) {
|
||||
if ( FileReplace( Src, pDest) ) {
|
||||
DeleteRenameString( pDest );
|
||||
}
|
||||
}
|
||||
// get the next key
|
||||
pDest += strlen(pDest)+1;
|
||||
}
|
||||
}
|
||||
|
||||
// if there are no more keys left in the WININIT.INI [Rename] section then
|
||||
// take the utility out of the WIN.INI run list. We re-check the INI file
|
||||
// (rather than set a flag) because buff may not have been big enough.
|
||||
if ( 0 == GetRenameKeys( Buff, BSIZE ) ) {
|
||||
DBG("[Rename] section empty");
|
||||
|
||||
if ( GetProfileString( "Windows", "Run", "", Buff, BSIZE ) ) {
|
||||
int namelen, taillen;
|
||||
char *pName, *pTail;
|
||||
|
||||
DBG(Buff);
|
||||
namelen = GetModuleFileName( hinst, Src, KSIZE );
|
||||
strupr(Src);
|
||||
strupr(Buff);
|
||||
|
||||
pName = strstr( Buff, Src );
|
||||
if ( pName != NULL ) {
|
||||
if ( *(pName+namelen) == '\0' ) {
|
||||
// there are no trailing commands: chop off the end
|
||||
while( pName > Buff && *pName != ',' ) {
|
||||
pName--;
|
||||
}
|
||||
*pName = '\0';
|
||||
}
|
||||
else {
|
||||
pTail = pName+namelen;
|
||||
while( *pTail && *pTail == ' ' )
|
||||
pTail++;
|
||||
if ( *pTail == ',' )
|
||||
pTail++;
|
||||
taillen = strlen(pTail)+1; // copy '\0' too
|
||||
memmove( pName, pTail, taillen );
|
||||
}
|
||||
DBG(Buff);
|
||||
WriteProfileString( "Windows", "Run", Buff );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(Buff);
|
||||
free(Src);
|
||||
free(copybuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int FileReplace ( LPCSTR Src, LPCSTR Dest )
|
||||
{
|
||||
char buf[KSIZE];
|
||||
struct stat st;
|
||||
int status;
|
||||
|
||||
#ifdef DEBUG_dveditz
|
||||
sprintf (buf,"Renaming %s to %s\n", Src, Dest);
|
||||
DBG(buf);
|
||||
#endif
|
||||
|
||||
|
||||
if ( stat( Src, &st ) != 0 ) {
|
||||
DBG("Missing sourcefile");
|
||||
// Srcfile is missing, nothing to do
|
||||
return OK;
|
||||
}
|
||||
|
||||
if ( stricmp( Dest, "NUL" ) == 0 ) {
|
||||
// special case: delete Srcfile
|
||||
// (part of MS spec for WININIT.INI -- ASD won't generate these)
|
||||
DBG("Special delete case");
|
||||
return ( 0 == unlink( Src ) );
|
||||
}
|
||||
|
||||
|
||||
if ( stat( Dest, &st ) != 0 ) {
|
||||
DBG("Dest doesn't exist");
|
||||
// Dest doesn't exist
|
||||
status = RenameFile( Src, Dest );
|
||||
}
|
||||
else {
|
||||
if ( NULL == tmpnam(buf) || !RenameFile( Dest, buf ) ) {
|
||||
DBG("tmpfile error");
|
||||
status = ERROR;
|
||||
}
|
||||
else {
|
||||
status = RenameFile( Src, Dest );
|
||||
if ( status == OK ) {
|
||||
DBG("rename success");
|
||||
unlink(buf);
|
||||
}
|
||||
else {
|
||||
// put old file back
|
||||
DBG("rename failure");
|
||||
RenameFile( buf, Dest );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int RenameFile ( LPCSTR in, LPCSTR out)
|
||||
{
|
||||
FILE *ifp, *ofp;
|
||||
int rbytes, wbytes;
|
||||
int status = OK;
|
||||
|
||||
if (!in || !out)
|
||||
return ERROR;
|
||||
|
||||
// try a rename first
|
||||
if ( 0 == rename( in, out ) )
|
||||
return OK;
|
||||
else if ( errno != EXDEV )
|
||||
return ERROR;
|
||||
|
||||
// can't rename across drives so do ugly copy
|
||||
DBG("trying copy");
|
||||
ifp = fopen (in, "rb");
|
||||
if (ifp == NULL) {
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
ofp = fopen (out, "wb");
|
||||
if (ofp == NULL) {
|
||||
fclose (ifp);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
while ((rbytes = fread (copybuf, 1, COPYSIZE, ifp)) > 0) {
|
||||
if ((rbytes < COPYSIZE) && (ferror(ifp) != 0)) {
|
||||
DBG("Read error");
|
||||
status = ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( (wbytes = fwrite (copybuf, 1, rbytes, ofp)) < rbytes ) {
|
||||
DBG("Write error");
|
||||
status = ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose (ofp);
|
||||
fclose (ifp);
|
||||
|
||||
if ( status == ERROR )
|
||||
unlink(out);
|
||||
else
|
||||
unlink(in);
|
||||
|
||||
return status;
|
||||
}
|
||||
33
mozilla/modules/softupdt/src/nspatch/Makefile
Normal file
33
mozilla/modules/softupdt/src/nspatch/Makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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 = ../../../..
|
||||
|
||||
REQUIRES = softupdt
|
||||
|
||||
CSRCS = nspatch.c
|
||||
|
||||
PROGRAM = nspatch$(BIN_SUFFIX)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
symbols:
|
||||
@echo "CSRCS = $(CSRCS)"
|
||||
@echo "OBJS = $(OBJS)"
|
||||
@echo "PROGRAM = $(PROGRAM)"
|
||||
@echo "LIBRARY = $(LIBRARY)"
|
||||
@echo "TARGETS = $(TARGETS)"
|
||||
66
mozilla/modules/softupdt/src/nspatch/makefile.win
Normal file
66
mozilla/modules/softupdt/src/nspatch/makefile.win
Normal file
@@ -0,0 +1,66 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
#
|
||||
|
||||
#VERBOSE = 1
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
#cannot define PROGRAM in manifest compatibly with NT and UNIX
|
||||
PROGRAM= .\$(OBJDIR)\nspatch.exe
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
# let manifest generate C_OBJS, it will prepend ./$(OBJDIR)/
|
||||
# rules.mak will append C_OBJS onto OBJS.
|
||||
# OBJS = $(CSRCS:.c=.obj)
|
||||
|
||||
PDBFILE = nspatch.pdb
|
||||
MAPFILE = nspatch.map
|
||||
|
||||
REQUIRES=softupdt
|
||||
CSRCS=nspatch.c
|
||||
C_OBJS=.\$(OBJDIR)\nspatch.obj
|
||||
!if "$(MOZ_BITS)" != "16"
|
||||
LINCS=-I$(XPDIST)\public\softupdt
|
||||
!endif
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
INSTALL = $(MAKE_INSTALL)
|
||||
|
||||
objs: $(OBJS)
|
||||
|
||||
programs: $(PROGRAM)
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(TARGETS) $(DIST)/bin
|
||||
|
||||
symbols:
|
||||
@echo "CSRCS = $(CSRCS)"
|
||||
@echo "INCS = $(INCS)"
|
||||
@echo "OBJS = $(OBJS)"
|
||||
@echo "LIBRARY = $(LIBRARY)"
|
||||
@echo "PROGRAM = $(PROGRAM)"
|
||||
@echo "TARGETS = $(TARGETS)"
|
||||
@echo "DIST = $(DIST)"
|
||||
@echo "VERSION_NUMBER = $(VERSION_NUMBER)"
|
||||
@echo "WINFE = $(WINFE)"
|
||||
@echo "DBM_LIB = $(DBM_LIB)"
|
||||
@echo "INSTALL = $(INSTALL)"
|
||||
|
||||
600
mozilla/modules/softupdt/src/nspatch/nspatch.c
Normal file
600
mozilla/modules/softupdt/src/nspatch/nspatch.c
Normal file
@@ -0,0 +1,600 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*--------------------------------------------------------------------
|
||||
* NSPatch
|
||||
*
|
||||
* Applies GDIFF binary patches
|
||||
*
|
||||
* nspatch [-o"outfile"] oldfile newfile
|
||||
*
|
||||
* The outfile defaults console
|
||||
*
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gdiff.h"
|
||||
|
||||
/*--------------------------------------
|
||||
* constants
|
||||
*------------------------------------*/
|
||||
|
||||
#define BUFSIZE 32768
|
||||
#define OPSIZE 1
|
||||
#define MAXCMDSIZE 12
|
||||
|
||||
#define getshort(s) (uint16)( ((uchar)*(s) << 8) + ((uchar)*((s)+1)) )
|
||||
|
||||
#define getlong(s) \
|
||||
(uint32)( ((uchar)*(s) << 24) + ((uchar)*((s)+1) << 16 ) + \
|
||||
((uchar)*((s)+2) << 8) + ((uchar)*((s)+3)) )
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* types
|
||||
*------------------------------------*/
|
||||
|
||||
typedef unsigned long uint32;
|
||||
typedef long int32;
|
||||
typedef unsigned short uint16;
|
||||
typedef short int16;
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned char BOOL;
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* prototypes
|
||||
*------------------------------------*/
|
||||
|
||||
int add( uint32 count );
|
||||
void cleanup( void );
|
||||
int copy( uint32 position, uint32 count );
|
||||
int doPatch( void );
|
||||
int getcmd( uchar *buffer, uint32 length );
|
||||
char openFiles( void );
|
||||
int parseHeader( void );
|
||||
int parseAppdata( void );
|
||||
void usage( void );
|
||||
char validateArgs( int argc, char *argv[] );
|
||||
int validateNewFile( void );
|
||||
int validateOldFile( void );
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* Global data
|
||||
*------------------------------------*/
|
||||
|
||||
char *oldname = NULL,
|
||||
*difname = NULL,
|
||||
*outname = NULL;
|
||||
|
||||
uchar *databuf;
|
||||
|
||||
FILE *oldfile,
|
||||
*diffile,
|
||||
*outfile;
|
||||
|
||||
uchar checksumType;
|
||||
|
||||
uchar *oldChecksum = NULL,
|
||||
*finalChecksum = NULL;
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* main
|
||||
*------------------------------------*/
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Parse command line */
|
||||
|
||||
if ( !validateArgs( argc, argv ) ) {
|
||||
err = ERR_ARGS;
|
||||
}
|
||||
else {
|
||||
err = openFiles();
|
||||
}
|
||||
|
||||
|
||||
/* Process the patchfile */
|
||||
|
||||
if ( err == ERR_OK ) {
|
||||
err = doPatch();
|
||||
}
|
||||
|
||||
|
||||
/* Cleanup */
|
||||
|
||||
cleanup();
|
||||
|
||||
|
||||
/* Report status */
|
||||
|
||||
if ( err == ERR_OK ) {
|
||||
|
||||
}
|
||||
else {
|
||||
switch (err) {
|
||||
case ERR_ARGS:
|
||||
fprintf( stderr, "Invalid arguments\n" );
|
||||
usage();
|
||||
break;
|
||||
|
||||
case ERR_ACCESS:
|
||||
fprintf( stderr, "Error opening file\n" );
|
||||
break;
|
||||
|
||||
case ERR_MEM:
|
||||
fprintf( stderr, "Insufficient memory\n" );
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf( stderr, "Unexpected error %d\n", err );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* add
|
||||
*------------------------------------*/
|
||||
|
||||
int add( uint32 count )
|
||||
{
|
||||
int err = ERR_OK;
|
||||
uint32 nRead;
|
||||
uint32 chunksize;
|
||||
|
||||
while ( count > 0 ) {
|
||||
chunksize = ( count > BUFSIZE) ? BUFSIZE : count;
|
||||
nRead = fread( databuf, 1, chunksize, diffile );
|
||||
if ( nRead != chunksize ) {
|
||||
err = ERR_BADDIFF;
|
||||
break;
|
||||
}
|
||||
|
||||
fwrite( databuf, 1, chunksize, outfile );
|
||||
|
||||
count -= chunksize;
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* cleanup
|
||||
*------------------------------------*/
|
||||
|
||||
void cleanup()
|
||||
{
|
||||
if ( oldfile != NULL )
|
||||
fclose( oldfile );
|
||||
|
||||
if ( diffile != NULL )
|
||||
fclose( diffile );
|
||||
|
||||
if ( outfile != NULL /* && outfile != stdout */ )
|
||||
fclose( outfile );
|
||||
|
||||
if ( oldChecksum != NULL )
|
||||
free( oldChecksum );
|
||||
|
||||
if ( finalChecksum != NULL )
|
||||
free( finalChecksum );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* copy
|
||||
*------------------------------------*/
|
||||
|
||||
int copy( uint32 position, uint32 count )
|
||||
{
|
||||
int err = ERR_OK;
|
||||
uint32 nRead;
|
||||
uint32 chunksize;
|
||||
|
||||
fseek( oldfile, position, SEEK_SET );
|
||||
|
||||
while ( count > 0 ) {
|
||||
chunksize = (count > BUFSIZE) ? BUFSIZE : count;
|
||||
|
||||
nRead = fread( databuf, 1, chunksize, oldfile );
|
||||
if ( nRead != chunksize ) {
|
||||
err = ERR_OLDFILE;
|
||||
break;
|
||||
}
|
||||
|
||||
fwrite( databuf, 1, chunksize, outfile );
|
||||
|
||||
count -= chunksize;
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* doPatch
|
||||
*------------------------------------*/
|
||||
|
||||
int doPatch()
|
||||
{
|
||||
int err;
|
||||
int done;
|
||||
uchar opcode;
|
||||
uchar cmdbuf[MAXCMDSIZE];
|
||||
|
||||
databuf = (uchar*)malloc(BUFSIZE);
|
||||
if ( databuf == NULL ) {
|
||||
err = ERR_MEM;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
err = parseHeader();
|
||||
if (err != ERR_OK)
|
||||
goto fail;
|
||||
|
||||
err = validateOldFile();
|
||||
if ( err != ERR_OK )
|
||||
goto fail;
|
||||
|
||||
err = parseAppdata();
|
||||
if ( err != ERR_OK )
|
||||
goto fail;
|
||||
|
||||
|
||||
/* apply patch */
|
||||
|
||||
done = feof(diffile);
|
||||
while ( !done ) {
|
||||
err = getcmd( &opcode, OPSIZE );
|
||||
if ( err != ERR_OK )
|
||||
break;
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case ENDDIFF:
|
||||
done = TRUE;
|
||||
break;
|
||||
|
||||
case ADD16:
|
||||
err = getcmd( cmdbuf, ADD16SIZE );
|
||||
if ( err == ERR_OK ) {
|
||||
err = add( getshort( cmdbuf ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD32:
|
||||
err = getcmd( cmdbuf, ADD32SIZE );
|
||||
if ( err == ERR_OK ) {
|
||||
err = add( getlong( cmdbuf ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY16BYTE:
|
||||
err = getcmd( cmdbuf, COPY16BYTESIZE );
|
||||
if ( err == ERR_OK ) {
|
||||
err = copy( getshort(cmdbuf), *(cmdbuf+sizeof(short)) );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY16SHORT:
|
||||
err = getcmd( cmdbuf, COPY16SHORTSIZE );
|
||||
if ( err == ERR_OK ) {
|
||||
err = copy(getshort(cmdbuf),getshort(cmdbuf+sizeof(short)));
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY16LONG:
|
||||
err = getcmd( cmdbuf, COPY16LONGSIZE );
|
||||
if ( err == ERR_OK ) {
|
||||
err = copy(getshort(cmdbuf),getlong(cmdbuf+sizeof(short)));
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY32BYTE:
|
||||
err = getcmd( cmdbuf, COPY32BYTESIZE );
|
||||
if ( err == ERR_OK ) {
|
||||
err = copy( getlong(cmdbuf), *(cmdbuf+sizeof(long)) );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY32SHORT:
|
||||
err = getcmd( cmdbuf, COPY32SHORTSIZE );
|
||||
if ( err == ERR_OK ) {
|
||||
err = copy( getlong(cmdbuf),getshort(cmdbuf+sizeof(long)) );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY32LONG:
|
||||
err = getcmd( cmdbuf, COPY32LONGSIZE );
|
||||
if ( err == ERR_OK ) {
|
||||
err = copy( getlong(cmdbuf), getlong(cmdbuf+sizeof(long)) );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY64:
|
||||
/* we don't support 64-bit file positioning yet */
|
||||
err = ERR_OPCODE;
|
||||
break;
|
||||
|
||||
default:
|
||||
err = add( opcode );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( err != ERR_OK )
|
||||
done = TRUE;
|
||||
}
|
||||
|
||||
if ( err == ERR_OK ) {
|
||||
err = validateNewFile();
|
||||
}
|
||||
|
||||
|
||||
/* return status */
|
||||
fail:
|
||||
if ( databuf != NULL )
|
||||
free( databuf );
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* getcmd
|
||||
*------------------------------------*/
|
||||
int getcmd( uchar *buffer, uint32 length )
|
||||
{
|
||||
uint32 bytesRead;
|
||||
|
||||
bytesRead = fread( buffer, 1, length, diffile );
|
||||
if ( bytesRead != length )
|
||||
return ERR_BADDIFF;
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* openFiles
|
||||
*------------------------------------*/
|
||||
|
||||
char openFiles()
|
||||
{
|
||||
oldfile = fopen( oldname, "rb" );
|
||||
if ( oldfile == NULL ) {
|
||||
fprintf( stderr, "Can't open %s for reading\n", oldname );
|
||||
return ERR_ACCESS;
|
||||
}
|
||||
|
||||
diffile = fopen( difname, "rb" );
|
||||
if ( diffile == NULL ) {
|
||||
fprintf( stderr, "Can't open %s for reading\n", difname );
|
||||
return ERR_ACCESS;
|
||||
}
|
||||
|
||||
if ( outname == NULL || *outname == '\0' ) {
|
||||
outfile = stdout;
|
||||
}
|
||||
else {
|
||||
outfile = fopen( outname, "wb" );
|
||||
}
|
||||
if ( outfile == NULL ) {
|
||||
fprintf( stderr, "Can't open %s for writing\n", outname );
|
||||
return ERR_ACCESS;
|
||||
}
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* parseHeader
|
||||
*------------------------------------*/
|
||||
|
||||
int parseHeader( void )
|
||||
{
|
||||
int err = ERR_OK;
|
||||
uint32 cslen;
|
||||
uint32 oldcslen;
|
||||
uint32 newcslen;
|
||||
uint32 nRead;
|
||||
uchar header[GDIFF_HEADERSIZE];
|
||||
|
||||
nRead = fread( header, 1, GDIFF_HEADERSIZE, diffile );
|
||||
if ( nRead != GDIFF_HEADERSIZE ) {
|
||||
err = ERR_HEADER;
|
||||
}
|
||||
else if (memcmp( header, GDIFF_MAGIC, GDIFF_MAGIC_LEN ) != 0 ) {
|
||||
err = ERR_HEADER;
|
||||
}
|
||||
else if ( header[GDIFF_VER_POS] != GDIFF_VER ) {
|
||||
err = ERR_HEADER;
|
||||
}
|
||||
else {
|
||||
checksumType = header[GDIFF_CS_POS];
|
||||
cslen = header[GDIFF_CSLEN_POS];
|
||||
|
||||
if ( checksumType > 0 ) {
|
||||
err = ERR_CHKSUMTYPE;
|
||||
}
|
||||
else if ( cslen > 0 ) {
|
||||
oldcslen = cslen / 2;
|
||||
newcslen = cslen - oldcslen;
|
||||
|
||||
oldChecksum = (uchar*)malloc(oldcslen);
|
||||
finalChecksum = (uchar*)malloc(newcslen);
|
||||
|
||||
if ( oldChecksum != NULL || finalChecksum != NULL ) {
|
||||
nRead = fread( oldChecksum, 1, oldcslen, diffile );
|
||||
if ( nRead == oldcslen ) {
|
||||
nRead = fread( finalChecksum, 1, newcslen, diffile );
|
||||
if ( nRead != newcslen ) {
|
||||
err = ERR_HEADER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
err = ERR_HEADER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
err = ERR_MEM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (err);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* parseAppdata
|
||||
*------------------------------------*/
|
||||
|
||||
int parseAppdata( void )
|
||||
{
|
||||
int err = ERR_OK;
|
||||
uint32 nRead;
|
||||
uint32 appdataSize;
|
||||
uchar lenbuf[GDIFF_APPDATALEN];
|
||||
|
||||
nRead = fread( lenbuf, 1, GDIFF_APPDATALEN, diffile );
|
||||
if ( nRead != GDIFF_APPDATALEN ) {
|
||||
err = ERR_HEADER;
|
||||
}
|
||||
else {
|
||||
appdataSize = getlong(lenbuf);
|
||||
|
||||
if ( appdataSize > 0 ) {
|
||||
/* we currently don't know about appdata, so skip it */
|
||||
fseek( diffile, appdataSize, SEEK_CUR );
|
||||
}
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* usage
|
||||
*------------------------------------*/
|
||||
|
||||
void usage ()
|
||||
{
|
||||
fprintf( stderr, "\n NSPatch [-o\"outfile\"] oldfile diff\n\n" );
|
||||
fprintf( stderr, " -o name of patched output file\n\n" );
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* validateArgs
|
||||
*------------------------------------*/
|
||||
|
||||
char validateArgs( int argc, char *argv[] )
|
||||
{
|
||||
int i;
|
||||
for ( i = 1; i < argc; i++ ) {
|
||||
if ( *argv[i] == '-' ) {
|
||||
switch (*(argv[i]+1)) {
|
||||
case 'o':
|
||||
outname = argv[i]+2;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf( stderr, "Unknown option %s\n", argv[i] );
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
else if ( oldname == NULL ) {
|
||||
oldname = argv[i];
|
||||
}
|
||||
else if ( difname == NULL ) {
|
||||
difname = argv[i];
|
||||
}
|
||||
else {
|
||||
fprintf( stderr, "Too many arguments\n" );
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf( stderr, "Old file: %s\n", oldname );
|
||||
fprintf( stderr, "Diff file: %s\n", difname );
|
||||
fprintf( stderr, "output file: %s\n", outname );
|
||||
#endif
|
||||
|
||||
/* validate arguments */
|
||||
|
||||
if ( oldname == NULL || difname == NULL ) {
|
||||
fprintf( stderr, "Old and diff file name parameters are required.\n" );
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* validateNewFile
|
||||
*------------------------------------*/
|
||||
int validateNewFile()
|
||||
{
|
||||
if ( checksumType > 0 )
|
||||
return ERR_CHKSUMTYPE;
|
||||
else
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* validateOldFile
|
||||
*------------------------------------*/
|
||||
int validateOldFile()
|
||||
{
|
||||
if ( checksumType > 0 )
|
||||
return ERR_CHKSUMTYPE;
|
||||
else
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
1685
mozilla/modules/softupdt/src/os2updt.c
Normal file
1685
mozilla/modules/softupdt/src/os2updt.c
Normal file
File diff suppressed because it is too large
Load Diff
161
mozilla/modules/softupdt/src/os2updt.h
Normal file
161
mozilla/modules/softupdt/src/os2updt.h
Normal file
@@ -0,0 +1,161 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* Module Name : OS2UPDT.H *
|
||||
* *
|
||||
* *
|
||||
* Description : Include file for SU_WIN.C *
|
||||
* *
|
||||
* *
|
||||
*****************************************************************************/
|
||||
|
||||
/* ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· */
|
||||
/* º Various program defines º */
|
||||
/* ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĽ */
|
||||
/* String processing definitions */
|
||||
//XP_OS2#define CR (CHAR) '\r'
|
||||
//XP_OS2#define LF (CHAR) '\n'
|
||||
// #define EOFFILE (CHAR) '\032' //P1D
|
||||
#define EOFFILE (CHAR) '\x1A' //P1A
|
||||
#define BLANK (CHAR) ' '
|
||||
//XP_OS2#define TAB (CHAR) '\t'
|
||||
#define EQUAL (CHAR) '='
|
||||
#define COLON (CHAR) ':'
|
||||
#define SEMICOLON (CHAR) ';'
|
||||
#define ZEND (CHAR) '\0'
|
||||
|
||||
//XP_OS2#define CRLF "\r\n"
|
||||
// #define EOFLINE "\r\n\032" //P1D
|
||||
#define EOFLINE "\r\n\x1A" //P1A
|
||||
#define BLANK_TAB " \t"
|
||||
//#define BLANK_TAB_EOFLINE " \t\r\n\032" //P1D
|
||||
//#define SEMIC_EOFLINE ";\r\n\032" //P1D
|
||||
#define BLANK_TAB_EOFLINE " \t\r\n\x1A" /* P1A */
|
||||
#define SEMIC_EOFLINE ";\r\n\x1A" /* P1A */
|
||||
|
||||
|
||||
//XP_OS2#define MAXPATHLEN 260
|
||||
#define DASD_FLAG 0
|
||||
#define INHERIT 0x08
|
||||
#define WRITE_THRU 0
|
||||
#define FAIL_FLAG 0
|
||||
#define SHARE_FLAG 0x10
|
||||
#define ACCESS_FLAG 0x02
|
||||
/* ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· */
|
||||
/* º Various program defines º */
|
||||
/* ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĽ */
|
||||
|
||||
#define CONFIGSYS "C:\\CONFIG.SYS"
|
||||
|
||||
#define FOUR_K 4*1024
|
||||
#define SEG_SIZE (ULONG)65536
|
||||
#define NORM 0x00
|
||||
#define OS2HPFS "\\OS2\\HPFS.IFS"
|
||||
#define WOS2HPFS "\\OS2\\BOOT\\HPFS.IFS"
|
||||
#define OS2FAT "DISKCACHE"
|
||||
#define ODI2NDILINE "ODI2NDI.OS2"
|
||||
#define INT15 "INT15.SYS"
|
||||
#define CPQPART "CPQPART.SYS"
|
||||
#define CPQREDIR "CPQREDIR.FLT"
|
||||
#define OS2CDROM "OS2CDROM.DMD"
|
||||
#define DOSSYS "DOS.SYS"
|
||||
#define MOUSESYS "MOUSE.SYS"
|
||||
#define TESTCFG "TESTCFG.SYS"
|
||||
#define INT15 "INT15.SYS"
|
||||
#define CPQPART "CPQPART.SYS"
|
||||
#define NOSWAP "NOSWAP"
|
||||
|
||||
|
||||
/* ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· */
|
||||
/* º Configuration routine defines º */
|
||||
/* ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĽ */
|
||||
/*ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿*/
|
||||
/*³ Type of the configuration line³*/
|
||||
/*ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ*/
|
||||
/* Example: */
|
||||
#define CSYS_COMMAND 200 /* BUFFERS=60 */
|
||||
#define CSYS_EV 201 /* SET PROMPT=$i[$p] */
|
||||
#define CSYS_PATH_EV 202 /* SET HELP=C:\OS2\HELP;E:\EPM */
|
||||
#define CSYS_PATH 203 /* SET PATH=C:\OS2;C:\MUGLIB; */
|
||||
#define CSYS_DPATH 204 /* SET DPATH=C:\OS2;C:\MUGLIB\DLL; */
|
||||
#define CSYS_LIBPATH 205 /* LIBPATH=C:\OS2\DLL; */
|
||||
#define CSYS_DEVICE 206 /* DEVICE=C:\OS2\EGA.SYS */
|
||||
#define CSYS_RUN 207 /* RUN=C:\CMLIB\ACSTRSYS.EXE */
|
||||
#define CSYS_IFS 208 /* IFS=C:\OS2\HPFS.IFS /CACHE:64 */
|
||||
#define CSYS_PROTSHELL 209 /* PROTSHELL=C:\SECURESH.EXE */
|
||||
#define CSYS_BOOKSHELF 210 /* SET BOOKSHELF=C:\OS2;C:\BOOK; */
|
||||
#define CSYS_AUTOSTART 211 /* SET AUTOSTART=PROGRAMS, */
|
||||
#define CSYS_20 212 /* 20=NETWRKSTA.200 */
|
||||
#define CSYS_HELP 213 /* 20=NETWRKSTA.200 */
|
||||
#define CSYS_DISKCACHE 214
|
||||
#define CSYS_CALL 215 /* CALL=C:\XXX... */
|
||||
#define CSYS_REM 216 /* REM ANYTHING */
|
||||
#define CSYS_SET 217 /* SET ANYTHING no '=' used */
|
||||
#define CSYS_BASEDEV 218
|
||||
#define CSYS_MEMMAN 219
|
||||
|
||||
/*ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿*/
|
||||
/*³ CsysUpdate insert positions ³*/
|
||||
/*ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ*/
|
||||
/* These constants represent update*/
|
||||
/* locations within CONFIG.SYS. */
|
||||
/* An update location is specified */
|
||||
/* as either one of these constants*/
|
||||
/* or an actual pointer within the */
|
||||
/* buffer. Note that the constants*/
|
||||
/* can't be misconstrued as buffer */
|
||||
/* pointers since the selector is 0*/
|
||||
/* */
|
||||
/* Update as the: */
|
||||
#define CSYS_FIRST (PSZ) 0x0000FFFF /* First line in CONFIG.SYS */
|
||||
#define CSYS_LAST (PSZ) 0x0000FFFE /* Last line in CONFIG.SYS */
|
||||
#define CSYS_FIRST_TYPE (PSZ) 0x0000FFFD /* First or last DEVICE, RUN, or*/
|
||||
#define CSYS_LAST_TYPE (PSZ) 0x0000FFFC /* IFS (depends on type) */
|
||||
|
||||
|
||||
/* ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· */
|
||||
/* º Forward Function Declarations º */
|
||||
/* ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĽ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
VOID StripFrontWhite(char *);
|
||||
char *NextLine(char *);
|
||||
VOID CopyLine(char *, char *);
|
||||
ULONG InsertString(char *, char *, char *);
|
||||
/* Steve's Functions */
|
||||
CHAR *ScootString(CHAR *, SHORT);
|
||||
CHAR *CopyNBytes(CHAR *, CHAR *, USHORT);
|
||||
USHORT StringLength(CHAR *);
|
||||
ULONG ReadFileToBuffer(char *, char **,ULONG *);
|
||||
ULONG WriteBufferToFile(char *, char **);
|
||||
ULONG search_file_drive(char *, char *);
|
||||
PSZ FAR CsysQuery (PSZ, USHORT, PSZ, PSZ);
|
||||
PSZ FAR CsysUpdate (PSZ, USHORT, PSZ, PSZ, PSZ);
|
||||
PSZ FAR CsysDelete (PSZ, USHORT, PSZ, PSZ);
|
||||
ULONG WriteLockFileDDToConfig (PSZ pszListFile);
|
||||
ULONG WriteLockFileRenameEntry(PSZ final, PSZ current, PSZ listfile);
|
||||
/*ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿*/
|
||||
/*³ Routines used locally ³*/
|
||||
/*ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ*/
|
||||
VOID FAR BuildAssignment (USHORT, PSZ, PSZ);
|
||||
VOID FAR FormatLine (PSZ, PSZ);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
881
mozilla/modules/softupdt/src/softupdt.c
Normal file
881
mozilla/modules/softupdt/src/softupdt.c
Normal file
@@ -0,0 +1,881 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
#include "softupdt.h"
|
||||
#define NEW_FE_CONTEXT_FUNCS
|
||||
#include "zig.h"
|
||||
#include "net.h"
|
||||
#include "libevent.h"
|
||||
#include "prefapi.h"
|
||||
#include "prprf.h"
|
||||
#include "mkutils.h"
|
||||
#include "fe_proto.h"
|
||||
#include "prthread.h"
|
||||
#include "xpgetstr.h"
|
||||
#include "prmon.h"
|
||||
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
#define MOCHA_CONTEXT_PREFIX "autoinstall:"
|
||||
|
||||
/* error codes */
|
||||
#define su_ErrInvalidArgs -1
|
||||
#define su_ErrUnknownInstaller -2
|
||||
#define su_ErrInternalError -3
|
||||
#define su_ErrBadScript -4
|
||||
#define su_JarError -5
|
||||
|
||||
/* xp_string defines */
|
||||
extern int SU_NOT_A_JAR_FILE;
|
||||
extern int SU_SECURITY_CHECK;
|
||||
extern int SU_INSTALL_FILE_HEADER;
|
||||
extern int SU_INSTALL_FILE_MISSING;
|
||||
|
||||
/* structs */
|
||||
|
||||
/* su_DownloadStream
|
||||
* keeps track of all SU specific data needed for the stream
|
||||
*/
|
||||
typedef struct su_DownloadStream_struct {
|
||||
XP_File fFile;
|
||||
char * fJarFile; /* xpURL location of the downloaded file */
|
||||
URL_Struct * fURL;
|
||||
MWContext * fContext;
|
||||
SoftUpdateCompletionFunction fCompletion;
|
||||
void * fCompletionClosure;
|
||||
int32 fFlags; /* download flags */
|
||||
} su_DownloadStream;
|
||||
|
||||
/* su_URLFeData
|
||||
* passes data between the trigger and the stream
|
||||
*/
|
||||
typedef struct su_URLFeData_struct {
|
||||
SoftUpdateCompletionFunction fCompletion;
|
||||
void * fCompletionClosure;
|
||||
int32 fFlags; /* download flags */
|
||||
} su_URLFeData;
|
||||
|
||||
static char * EncodeSoftUpJSArgs(const char * fileName, XP_Bool silent, XP_Bool force);
|
||||
|
||||
/* Stream callbacks */
|
||||
int su_HandleProcess (NET_StreamClass *stream, const char *buffer, int32 buffLen);
|
||||
void su_HandleComplete (NET_StreamClass *stream);
|
||||
void su_HandleAbort (NET_StreamClass *stream, int reason);
|
||||
unsigned int su_HandleWriteReady (NET_StreamClass *stream);
|
||||
|
||||
/* Completion routine for stream handler. Deletes su_DownloadStream */
|
||||
void su_CompleteSoftwareUpdate(MWContext * context,
|
||||
SoftUpdateCompletionFunction f,
|
||||
void * completionClosure,
|
||||
int result,
|
||||
su_DownloadStream* realStream);
|
||||
|
||||
void su_NetExitProc(URL_Struct* url, int result, MWContext * context);
|
||||
void su_HandleCompleteJavaScript (su_DownloadStream* realStream);
|
||||
|
||||
|
||||
/* Completion routine for SU_StartSoftwareUpdate */
|
||||
|
||||
void su_CompleteSoftwareUpdate(MWContext * context,
|
||||
SoftUpdateCompletionFunction f,
|
||||
void * completionClosure,
|
||||
int result,
|
||||
su_DownloadStream* realStream)
|
||||
{
|
||||
/* Notify the trigger */
|
||||
if ( f != NULL )
|
||||
f(result, completionClosure);
|
||||
|
||||
/* Clean up */
|
||||
if (realStream)
|
||||
{
|
||||
if ( realStream->fJarFile )
|
||||
{
|
||||
result = XP_FileRemove( realStream->fJarFile, xpURL );
|
||||
XP_FREE( realStream->fJarFile );
|
||||
}
|
||||
XP_FREE( realStream);
|
||||
}
|
||||
}
|
||||
|
||||
/* a struct to hold the arguments */
|
||||
struct su_startCallback_
|
||||
{
|
||||
char * url;
|
||||
char * name;
|
||||
SoftUpdateCompletionFunction f;
|
||||
void * completionClosure;
|
||||
int32 flags;
|
||||
MWContext * context;
|
||||
} ;
|
||||
|
||||
typedef struct su_startCallback_ su_startCallback;
|
||||
|
||||
XP_Bool QInsert( su_startCallback * Item );
|
||||
su_startCallback * QGetItem(void);
|
||||
void SU_InitMonitor(void);
|
||||
void SU_DestroyMonitor(void);
|
||||
|
||||
/*
|
||||
* This struct represents one entry in a queue setup to hold download
|
||||
* requests if there are more than one.
|
||||
*/
|
||||
typedef struct su_QItem
|
||||
{
|
||||
struct su_QItem * next;
|
||||
struct su_QItem * prev;
|
||||
su_startCallback * QItem;
|
||||
} su_QItem;
|
||||
|
||||
|
||||
XP_Bool DnLoadInProgress = FALSE;
|
||||
PRMonitor * su_monitor = NULL;
|
||||
|
||||
void SU_InitMonitor(void)
|
||||
{
|
||||
su_monitor = PR_NewMonitor();
|
||||
XP_ASSERT( su_monitor != NULL );
|
||||
}
|
||||
|
||||
|
||||
void SU_DestroyMonitor(void)
|
||||
{
|
||||
if ( su_monitor != NULL )
|
||||
{
|
||||
PR_DestroyMonitor(su_monitor);
|
||||
su_monitor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Queue maintanence is done here
|
||||
*/
|
||||
su_QItem * Qhead = NULL;
|
||||
su_QItem * Qtail = NULL;
|
||||
|
||||
XP_Bool QInsert( su_startCallback * Item )
|
||||
{
|
||||
su_QItem *p = XP_ALLOC( sizeof (su_QItem));
|
||||
|
||||
if (p == NULL)
|
||||
return FALSE;
|
||||
|
||||
p->QItem = Item;
|
||||
p->next = Qhead;
|
||||
p->prev = NULL;
|
||||
if (Qhead != NULL)
|
||||
Qhead->prev = p;
|
||||
Qhead = p;
|
||||
if (Qtail == NULL) /* First Item inserted in Q? */
|
||||
Qtail = p;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
su_startCallback *QGetItem(void)
|
||||
{
|
||||
su_QItem *Qtemp = Qtail;
|
||||
|
||||
if (Qtemp != NULL)
|
||||
{
|
||||
su_startCallback *p = NULL;
|
||||
|
||||
Qtail = Qtemp->prev;
|
||||
|
||||
if (Qtail == NULL) /* Last Item deleted from Q? */
|
||||
Qhead = NULL;
|
||||
else
|
||||
Qtail->next = NULL;
|
||||
|
||||
p = Qtemp->QItem;
|
||||
XP_FREE(Qtemp);
|
||||
return p;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* timer callback to start the network download of a JAR file
|
||||
*/
|
||||
PRIVATE void
|
||||
su_FE_timer_callback( void * data)
|
||||
{
|
||||
su_startCallback * c;
|
||||
URL_Struct * urlS = NULL;
|
||||
su_URLFeData * fe_data = NULL;
|
||||
XP_Bool errFound = TRUE;
|
||||
|
||||
c = (su_startCallback*)data;
|
||||
|
||||
if (c->context == NULL)
|
||||
{
|
||||
su_CompleteSoftwareUpdate(c->context, c->f, c->completionClosure, su_ErrInternalError, NULL);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (c->url == NULL)
|
||||
{
|
||||
su_CompleteSoftwareUpdate(c->context, c->f, c->completionClosure, su_ErrInvalidArgs, NULL);
|
||||
goto done;
|
||||
}
|
||||
|
||||
urlS = NET_CreateURLStruct(c->url, NET_DONT_RELOAD);
|
||||
if (urlS == NULL)
|
||||
{
|
||||
su_CompleteSoftwareUpdate(c->context, c->f, c->completionClosure, MK_OUT_OF_MEMORY, NULL);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* fe_data holds the arguments that need to be passed
|
||||
* to our download stream
|
||||
*/
|
||||
fe_data = XP_ALLOC(sizeof(su_URLFeData));
|
||||
|
||||
if (fe_data == NULL)
|
||||
{
|
||||
su_CompleteSoftwareUpdate(c->context, c->f, c->completionClosure, MK_OUT_OF_MEMORY, NULL);
|
||||
NET_FreeURLStruct(urlS);
|
||||
goto done;
|
||||
}
|
||||
|
||||
fe_data->fCompletion = c->f;
|
||||
fe_data->fCompletionClosure = c->completionClosure;
|
||||
fe_data->fFlags = c->flags;
|
||||
|
||||
urlS->fe_data = fe_data;
|
||||
urlS->must_cache = TRUE; /* This is needed for partial caching */
|
||||
|
||||
errFound = FALSE;
|
||||
NET_GetURL(urlS, FO_CACHE_AND_SOFTUPDATE, c->context, su_NetExitProc);
|
||||
|
||||
done:
|
||||
if (errFound)
|
||||
{
|
||||
/* pops next item from queue or sets download flag to false */
|
||||
su_NetExitProc(NULL, 0, NULL);
|
||||
}
|
||||
if (c->url)
|
||||
XP_FREE( c->url);
|
||||
if (c->name)
|
||||
XP_FREE( c->name);
|
||||
XP_FREE( c );
|
||||
}
|
||||
|
||||
/* NET_GetURL exit procedure */
|
||||
void su_NetExitProc(URL_Struct* url, int result, MWContext * context)
|
||||
{
|
||||
su_startCallback * c;
|
||||
|
||||
PR_EnterMonitor(su_monitor);
|
||||
if (c = QGetItem())
|
||||
{
|
||||
FE_SetTimeout( su_FE_timer_callback, c, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
DnLoadInProgress = FALSE;
|
||||
}
|
||||
PR_ExitMonitor(su_monitor);
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
/* SU_StartSoftwareUpdate
|
||||
* Main public interface to software update
|
||||
*/
|
||||
PUBLIC XP_Bool
|
||||
SU_StartSoftwareUpdate(MWContext * context,
|
||||
const char * url,
|
||||
const char * name,
|
||||
SoftUpdateCompletionFunction f,
|
||||
void * completionClosure,
|
||||
int32 flags)
|
||||
{
|
||||
URL_Struct * urlS = NULL;
|
||||
su_URLFeData * fe_data = NULL;
|
||||
XP_Bool enabled;
|
||||
|
||||
/* Better safe than sorry */
|
||||
PREF_GetBoolPref( AUTOUPDATE_ENABLE_PREF, &enabled);
|
||||
if (!enabled)
|
||||
return FALSE;
|
||||
|
||||
/* if we do not have a context, create one */
|
||||
|
||||
if ( context == NULL )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Need to process this on a timer because netlib is not reentrant */
|
||||
{
|
||||
su_startCallback * varHolder;
|
||||
varHolder = XP_ALLOC( sizeof (su_startCallback));
|
||||
if (varHolder == NULL)
|
||||
{
|
||||
su_CompleteSoftwareUpdate(context, f, completionClosure, MK_OUT_OF_MEMORY, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
varHolder->url = url ? XP_STRDUP( url ) : NULL;
|
||||
varHolder->name = name ? XP_STRDUP( name ) : NULL;
|
||||
varHolder->f = f;
|
||||
varHolder->context = context;
|
||||
varHolder->completionClosure = completionClosure;
|
||||
varHolder->flags = flags;
|
||||
|
||||
PR_EnterMonitor(su_monitor);
|
||||
if ( DnLoadInProgress )
|
||||
{
|
||||
if (!QInsert( varHolder ))
|
||||
{ /* cleanup */
|
||||
su_CompleteSoftwareUpdate(context, f, completionClosure, MK_OUT_OF_MEMORY, NULL);
|
||||
if (varHolder->url)
|
||||
XP_FREE( varHolder->url);
|
||||
if (varHolder->name)
|
||||
XP_FREE( varHolder->name);
|
||||
XP_FREE( varHolder );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DnLoadInProgress = TRUE;
|
||||
FE_SetTimeout( su_FE_timer_callback, varHolder, 1 );
|
||||
}
|
||||
PR_ExitMonitor(su_monitor);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* New stream callback */
|
||||
/* creates the stream, and a opens up a temporary file */
|
||||
NET_StreamClass * SU_NewStream (int format_out, void * registration,
|
||||
URL_Struct * request, MWContext *context)
|
||||
{
|
||||
su_DownloadStream * streamData = NULL;
|
||||
su_URLFeData * fe_data = NULL;
|
||||
NET_StreamClass * stream = NULL;
|
||||
SoftUpdateCompletionFunction completion = NULL;
|
||||
void * completionClosure = NULL;
|
||||
int32 flags = 0;
|
||||
short result = 0;
|
||||
XP_Bool isJar;
|
||||
|
||||
/* Initialize the stream data by data passed in the URL*/
|
||||
fe_data = (su_URLFeData *) request->fe_data;
|
||||
|
||||
if ( fe_data != NULL )
|
||||
{
|
||||
completion = fe_data->fCompletion;
|
||||
completionClosure = fe_data->fCompletionClosure;
|
||||
flags = fe_data->fFlags;
|
||||
}
|
||||
|
||||
/* Make sure that we are loading a Java archive
|
||||
Strictly, we should accept only APPLICATION_JAVAARCHIVE,\
|
||||
but I know that many servers will be misconfigured
|
||||
so we'll try to deal with text/plain, and octet-stream
|
||||
So, the logic is:
|
||||
Anything but HTML is OK. Netlib will only trigger us
|
||||
with the correct MIME type, and when we are using triggers
|
||||
this is the right thing to do. HTML is usually an error message
|
||||
from the server.
|
||||
*/
|
||||
if (request->content_type)
|
||||
{
|
||||
if ( XP_STRCMP( APPLICATION_JAVAARCHIVE, request->content_type) == 0) /* Exact match */
|
||||
isJar = TRUE;
|
||||
else if ( XP_STRCMP( TEXT_HTML, request->content_type) == 0)
|
||||
isJar = FALSE;
|
||||
else
|
||||
isJar = TRUE;
|
||||
}
|
||||
else
|
||||
isJar = TRUE; /* Assume we have JAR if no content type */
|
||||
|
||||
/* If we got the wrong MIME type... */
|
||||
if (isJar == FALSE)
|
||||
{
|
||||
if (context)
|
||||
FE_Alert(context, XP_GetString(SU_NOT_A_JAR_FILE));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Create all the structs */
|
||||
streamData = XP_CALLOC(sizeof(su_DownloadStream), 1);
|
||||
|
||||
if (streamData == NULL)
|
||||
{
|
||||
result = MK_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
stream = NET_NewStream (NULL,
|
||||
su_HandleProcess,
|
||||
su_HandleComplete,
|
||||
su_HandleAbort,
|
||||
su_HandleWriteReady,
|
||||
streamData,
|
||||
context);
|
||||
|
||||
if (stream == NULL)
|
||||
{
|
||||
result = MK_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
streamData->fURL = request;
|
||||
streamData->fContext = context;
|
||||
streamData->fCompletion = completion;
|
||||
streamData->fCompletionClosure = completionClosure;
|
||||
streamData->fFlags = flags;
|
||||
|
||||
if (request->fe_data)
|
||||
{
|
||||
XP_FREE( request->fe_data);
|
||||
request->fe_data = NULL;
|
||||
}
|
||||
/* Here we jump through few hoops to get the file name in xpURL kind */
|
||||
streamData->fJarFile = WH_TempName( xpURL, NULL );
|
||||
|
||||
if (streamData->fJarFile == NULL)
|
||||
{
|
||||
result = su_ErrInternalError;
|
||||
goto fail;
|
||||
}
|
||||
streamData->fFile = XP_FileOpen( streamData->fJarFile, xpURL, XP_FILE_WRITE_BIN );
|
||||
|
||||
if ( streamData->fFile == 0)
|
||||
{
|
||||
result = su_ErrInternalError;
|
||||
goto fail;
|
||||
}
|
||||
/* return the stream */
|
||||
return stream;
|
||||
|
||||
fail:
|
||||
if (stream != NULL)
|
||||
XP_FREE( stream );
|
||||
su_CompleteSoftwareUpdate( context, completion, completionClosure, result, streamData );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma export reset
|
||||
#endif
|
||||
|
||||
/* su_HandleProcess
|
||||
* stream method, writes to disk
|
||||
*/
|
||||
int su_HandleProcess (NET_StreamClass *stream, const char *buffer, int32 buffLen)
|
||||
{
|
||||
void *streamData=stream->data_object;
|
||||
return XP_FileWrite( buffer, buffLen, ((su_DownloadStream*)streamData)->fFile );
|
||||
}
|
||||
|
||||
/* su_HandleAbort
|
||||
* Clean up
|
||||
*/
|
||||
void su_HandleAbort (NET_StreamClass *stream, int reason)
|
||||
{
|
||||
void *streamData=stream->data_object;
|
||||
su_DownloadStream* realStream = (su_DownloadStream*)stream->data_object;
|
||||
|
||||
/* Close the files */
|
||||
if (realStream->fFile)
|
||||
XP_FileClose(realStream->fFile);
|
||||
/* Report the result */
|
||||
su_CompleteSoftwareUpdate(realStream->fContext,
|
||||
realStream->fCompletion, realStream->fCompletionClosure, reason, realStream);
|
||||
}
|
||||
|
||||
unsigned int su_HandleWriteReady (NET_StreamClass *stream)
|
||||
{
|
||||
return USHRT_MAX; /* Returning -1 causes errors when loading local file */
|
||||
}
|
||||
|
||||
/* su_HandleComplete
|
||||
* Clean up
|
||||
*/
|
||||
void su_HandleComplete (NET_StreamClass *stream)
|
||||
{
|
||||
|
||||
su_DownloadStream* realStream = (su_DownloadStream*)stream->data_object;
|
||||
|
||||
if (realStream->fFile)
|
||||
XP_FileClose(realStream->fFile);
|
||||
|
||||
su_HandleCompleteJavaScript( realStream );
|
||||
}
|
||||
|
||||
/* This is called when Mocha is done with evaluation */
|
||||
static void
|
||||
su_mocha_eval_exit_fn(void * data, char * str, size_t len, char * wysiwyg_url,
|
||||
char * base_href, Bool valid)
|
||||
{
|
||||
short result = 0;
|
||||
su_DownloadStream* realStream = (su_DownloadStream*) data;
|
||||
MWContext *context = realStream->fContext;
|
||||
|
||||
if (valid == FALSE)
|
||||
result = su_ErrBadScript;
|
||||
|
||||
if (str)
|
||||
XP_FREE( str );
|
||||
|
||||
su_CompleteSoftwareUpdate( context,
|
||||
realStream->fCompletion, realStream->fCompletionClosure, 0, realStream );
|
||||
|
||||
FE_DestroyWindow(context);
|
||||
}
|
||||
/* su_ReadFileIntoBuffer
|
||||
* given a file name, reads it into buffer
|
||||
* returns an error code
|
||||
*/
|
||||
static short su_ReadFileIntoBuffer(char * fileName, void ** buffer, unsigned long * bufferSize)
|
||||
{
|
||||
XP_File file;
|
||||
XP_StatStruct st;
|
||||
short result = 0;
|
||||
|
||||
if ( XP_Stat( fileName, &st, xpURL ) != 0 )
|
||||
{
|
||||
result = su_ErrInternalError;
|
||||
goto fail;
|
||||
}
|
||||
*bufferSize = st.st_size;
|
||||
|
||||
*buffer = XP_ALLOC( st.st_size );
|
||||
if (*buffer == NULL)
|
||||
{
|
||||
result = MK_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
}
|
||||
file = XP_FileOpen( fileName, xpURL, XP_FILE_READ_BIN );
|
||||
if ( file == 0 )
|
||||
{
|
||||
result = su_ErrInternalError;
|
||||
goto fail;
|
||||
}
|
||||
if ( XP_FileRead( *buffer, *bufferSize, file ) != *bufferSize )
|
||||
{
|
||||
result = su_ErrInternalError;
|
||||
XP_FileClose( file );
|
||||
goto fail;
|
||||
}
|
||||
XP_FileClose( file );
|
||||
return result;
|
||||
|
||||
fail:
|
||||
if (*buffer != NULL)
|
||||
XP_FREE( * buffer);
|
||||
*buffer = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Encodes the args in the format
|
||||
* MOCHA_CONTEXT_PREFIX<File>CR<silent>CR<force>
|
||||
* Booleans are encoded as T or F.
|
||||
* DecodeSoftUpJSArgs is in lm_softup.c
|
||||
*/
|
||||
static char *
|
||||
EncodeSoftUpJSArgs(const char * fileName, XP_Bool force, XP_Bool silent )
|
||||
{
|
||||
char * s;
|
||||
int32 length;
|
||||
if (fileName == NULL)
|
||||
return NULL;
|
||||
|
||||
length = XP_STRLEN(fileName) +
|
||||
XP_STRLEN(MOCHA_CONTEXT_PREFIX) + 5; /* 2 booleans and a CR */
|
||||
s = XP_ALLOC(length);
|
||||
if (s != NULL)
|
||||
{
|
||||
s[0] = 0;
|
||||
XP_STRCAT(s, MOCHA_CONTEXT_PREFIX);
|
||||
XP_STRCAT(s, fileName);
|
||||
s[length - 5] = CR;
|
||||
s[length - 4] = silent ? 'T' : 'F';
|
||||
s[length - 3] = CR;
|
||||
s[length - 2] = force ? 'T' : 'F';
|
||||
s[length - 1] = 0;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/* su_HandleCompleteJavaScript
|
||||
* Reads in the mocha script out of the Jar file
|
||||
* Executes the script
|
||||
*/
|
||||
void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
|
||||
{
|
||||
short result = 0;
|
||||
void * buffer = NULL;
|
||||
unsigned long bufferSize;
|
||||
char * installerJarName = NULL;
|
||||
char * installerFileNameURL = NULL;
|
||||
char * codebase = NULL;
|
||||
int32 urlLen;
|
||||
unsigned long fileNameLength;
|
||||
ZIG * jarData = NULL;
|
||||
char s[255];
|
||||
char * jsScope = NULL;
|
||||
ETEvalStuff * stuff = NULL;
|
||||
|
||||
/* Initialize the JAR file */
|
||||
|
||||
jarData = SOB_new();
|
||||
if ( jarData == NULL)
|
||||
{
|
||||
result = MK_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
SOB_set_context (jarData, realStream->fContext);
|
||||
|
||||
result = SOB_pass_archive( ZIG_F_GUESS,
|
||||
realStream->fJarFile,
|
||||
realStream->fURL->address,
|
||||
jarData);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
char *errMsg = SOB_get_error(result);
|
||||
PR_snprintf(s, 255, XP_GetString(SU_SECURITY_CHECK), (errMsg?errMsg:"") );
|
||||
FE_Alert(realStream->fContext, s);
|
||||
|
||||
result = su_JarError;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Get the installer file name */
|
||||
result = SOB_get_metainfo( jarData, NULL, INSTALLER_HEADER, (void**)&installerJarName, &fileNameLength);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
FE_Alert(realStream->fContext, XP_GetString(SU_INSTALL_FILE_HEADER));
|
||||
|
||||
result = su_JarError;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
installerJarName[fileNameLength] = 0; /* Terminate the string */
|
||||
|
||||
/* Need a temporary file name that is the xpURL form */
|
||||
installerFileNameURL = WH_TempName( xpURL, NULL );
|
||||
|
||||
if ( installerFileNameURL == NULL)
|
||||
{
|
||||
result = su_JarError;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Extract the script out */
|
||||
|
||||
result = SOB_verified_extract( jarData, installerJarName, installerFileNameURL);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
PR_snprintf(s, 255, XP_GetString(SU_INSTALL_FILE_MISSING), installerJarName);
|
||||
FE_Alert(realStream->fContext, s);
|
||||
result = su_JarError;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Read the file in */
|
||||
result = su_ReadFileIntoBuffer( installerFileNameURL, &buffer, &bufferSize);
|
||||
XP_FileRemove( installerFileNameURL, xpURL);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
result = su_JarError;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Temporary hack to pass the zig data */
|
||||
/* close the archive */
|
||||
|
||||
SOB_destroy( jarData);
|
||||
jarData = NULL;
|
||||
|
||||
{
|
||||
Chrome chrome;
|
||||
MWContext * context;
|
||||
JSPrincipals *principals;
|
||||
|
||||
/* For security reasons, installer JavaScript has to execute inside a
|
||||
special context. This context is created by ET_EvaluateBuffer as a JS object
|
||||
of type SoftUpdate. the arguments to the object are passed in the string,
|
||||
jsScope
|
||||
*/
|
||||
jsScope = EncodeSoftUpJSArgs(realStream->fJarFile,
|
||||
((realStream->fFlags & FORCE_INSTALL) != 0),
|
||||
((realStream->fFlags & SILENT_INSTALL) != 0));
|
||||
if (jsScope == NULL)
|
||||
goto fail;
|
||||
|
||||
XP_BZERO(&chrome, sizeof(Chrome));
|
||||
chrome.location_is_chrome = TRUE;
|
||||
chrome.l_hint = -3000;
|
||||
chrome.t_hint = -3000;
|
||||
chrome.type = MWContextDialog;
|
||||
context = FE_MakeNewWindow(realStream->fContext, NULL, NULL, &chrome);
|
||||
if (context == NULL)
|
||||
goto fail;
|
||||
|
||||
urlLen = XP_STRLEN(realStream->fURL->address);
|
||||
codebase = XP_ALLOC( urlLen + XP_STRLEN(installerJarName) + 2 );
|
||||
if ( codebase == NULL)
|
||||
goto fail;
|
||||
XP_STRCPY( codebase, realStream->fURL->address );
|
||||
codebase[urlLen] = '/';
|
||||
XP_STRCPY( codebase+urlLen+1, installerJarName );
|
||||
|
||||
principals = LM_NewJSPrincipals(realStream->fURL, installerJarName, codebase );
|
||||
if (principals == NULL) {
|
||||
FE_DestroyWindow(context);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Execute the mocha script, result will be reported in the callback */
|
||||
realStream->fContext = context;
|
||||
|
||||
stuff = (ETEvalStuff *) XP_NEW_ZAP(ETEvalStuff);
|
||||
if (!stuff) {
|
||||
FE_DestroyWindow(context);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
stuff->len = bufferSize;
|
||||
stuff->line_no = 1;
|
||||
stuff->scope_to = jsScope;
|
||||
stuff->want_result = JS_TRUE;
|
||||
stuff->data = realStream;
|
||||
stuff->version = JSVERSION_DEFAULT;
|
||||
stuff->principals = principals;
|
||||
|
||||
ET_EvaluateScript(context, buffer, stuff, su_mocha_eval_exit_fn);
|
||||
|
||||
}
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
if (jarData != NULL)
|
||||
SOB_destroy( jarData);
|
||||
su_CompleteSoftwareUpdate( realStream->fContext,
|
||||
realStream->fCompletion, realStream->fCompletionClosure, result, realStream );
|
||||
/* drop through */
|
||||
done:
|
||||
XP_FREEIF(jsScope);
|
||||
XP_FREEIF(codebase);
|
||||
if ( installerFileNameURL )
|
||||
XP_FREE( installerFileNameURL );
|
||||
|
||||
/* Should we purge stuff from the disk cache here? */
|
||||
}
|
||||
|
||||
/* XXX: Move JavaGetBoolPref to lj_init.c.
|
||||
* Delete IsJavaSecurityEnabled and IsJavaSecurityDefaultTo30Enabled functions
|
||||
* XXX: Cache all security preferences while we are running on mozilla
|
||||
* thread. Hack for 4.0
|
||||
*/
|
||||
#define MAX_PREF 20
|
||||
|
||||
struct {
|
||||
char *pref_name;
|
||||
XP_Bool value;
|
||||
} cachePref[MAX_PREF];
|
||||
|
||||
static int free_idx=0;
|
||||
static XP_Bool locked = FALSE;
|
||||
|
||||
static void AddPrefToCache(char *pref_name, XP_Bool value)
|
||||
{
|
||||
if (!pref_name)
|
||||
return;
|
||||
|
||||
if (free_idx >= MAX_PREF) {
|
||||
XP_ASSERT(FALSE); /* Implement dynamic growth of preferences */
|
||||
return;
|
||||
}
|
||||
|
||||
cachePref[free_idx].pref_name = XP_STRDUP(pref_name);
|
||||
cachePref[free_idx].value = value;
|
||||
free_idx++;
|
||||
}
|
||||
|
||||
static XP_Bool GetPreference(char *pref_name, XP_Bool *pref_value)
|
||||
{
|
||||
int idx = 0;
|
||||
*pref_value = FALSE;
|
||||
|
||||
if (!pref_name)
|
||||
return FALSE;
|
||||
|
||||
for (; idx < free_idx; idx++) {
|
||||
if (XP_STRCMP(cachePref[idx].pref_name, pref_name) == 0) {
|
||||
*pref_value = cachePref[idx].value;
|
||||
locked = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (locked) {
|
||||
XP_ASSERT(FALSE); /* Implement dynamic growth of preferences */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (PREF_GetBoolPref(pref_name, pref_value) >=0) {
|
||||
AddPrefToCache(pref_name, *pref_value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
int PR_CALLBACK JavaGetBoolPref(char * pref_name)
|
||||
{
|
||||
XP_Bool pref;
|
||||
int ret_val;
|
||||
GetPreference(pref_name, &pref);
|
||||
ret_val = pref;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
int PR_CALLBACK IsJavaSecurityEnabled()
|
||||
{
|
||||
XP_Bool pref;
|
||||
int ret_val;
|
||||
GetPreference("signed.applets.codebase_principal_support", &pref);
|
||||
ret_val = !pref;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
int PR_CALLBACK IsJavaSecurityDefaultTo30Enabled()
|
||||
{
|
||||
return JavaGetBoolPref("signed.applets.local_classes_have_30_powers");
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma export reset
|
||||
#endif
|
||||
|
||||
489
mozilla/modules/softupdt/src/su_aplsn.cp
Normal file
489
mozilla/modules/softupdt/src/su_aplsn.cp
Normal file
@@ -0,0 +1,489 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
|
||||
/* Implements a simple AppleSingle decoder, as described in RFC1740 */
|
||||
/* http://andrew2.andrew.cmu.edu/rfc/rfc1740.html */
|
||||
|
||||
/* Code is a bit ugly-looking (not pure C++ style */
|
||||
/* Apologies to the Mac guys, but I have a feeling that this file might be */
|
||||
/* cross-product in the future */
|
||||
|
||||
/* xp */
|
||||
#include "su_aplsn.h"
|
||||
#include "xp_file.h"
|
||||
#include "xp_mcom.h"
|
||||
|
||||
/* Mac */
|
||||
#include "ufilemgr.h"
|
||||
|
||||
#if PRAGMA_ALIGN_SUPPORTED
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
/* struct definitions from RFC1740 */
|
||||
|
||||
typedef struct ASHeader /* header portion of AppleSingle */
|
||||
{
|
||||
/* AppleSingle = 0x00051600; AppleDouble = 0x00051607 */
|
||||
uint32 magicNum; /* internal file type tag */
|
||||
uint32 versionNum; /* format version: 2 = 0x00020000 */
|
||||
uint8 filler[16]; /* filler, currently all bits 0 */
|
||||
uint16 numEntries; /* number of entries which follow */
|
||||
} ASHeader ; /* ASHeader */
|
||||
|
||||
typedef struct ASEntry /* one AppleSingle entry descriptor */
|
||||
{
|
||||
uint32 entryID; /* entry type: see list, 0 invalid */
|
||||
uint32 entryOffset; /* offset, in octets, from beginning */
|
||||
/* of file to this entry's data */
|
||||
uint32 entryLength; /* length of data in octets */
|
||||
} ASEntry; /* ASEntry */
|
||||
|
||||
typedef struct ASFinderInfo
|
||||
{
|
||||
FInfo ioFlFndrInfo; /* PBGetFileInfo() or PBGetCatInfo() */
|
||||
FXInfo ioFlXFndrInfo; /* PBGetCatInfo() (HFS only) */
|
||||
} ASFinderInfo; /* ASFinderInfo */
|
||||
|
||||
typedef struct ASMacInfo /* entry ID 10, Macintosh file information */
|
||||
{
|
||||
uint8 filler[3]; /* filler, currently all bits 0 */
|
||||
uint8 ioFlAttrib; /* PBGetFileInfo() or PBGetCatInfo() */
|
||||
} ASMacInfo;
|
||||
|
||||
typedef struct ASFileDates /* entry ID 8, file dates info */
|
||||
{
|
||||
int32 create; /* file creation date/time */
|
||||
int32 modify; /* last modification date/time */
|
||||
int32 backup; /* last backup date/time */
|
||||
int32 access; /* last access date/time */
|
||||
} ASFileDates; /* ASFileDates */
|
||||
|
||||
/* entryID list */
|
||||
#define AS_DATA 1 /* data fork */
|
||||
#define AS_RESOURCE 2 /* resource fork */
|
||||
#define AS_REALNAME 3 /* File's name on home file system */
|
||||
#define AS_COMMENT 4 /* standard Mac comment */
|
||||
#define AS_ICONBW 5 /* Mac black & white icon */
|
||||
#define AS_ICONCOLOR 6 /* Mac color icon */
|
||||
/* 7 /* not used */
|
||||
#define AS_FILEDATES 8 /* file dates; create, modify, etc */
|
||||
#define AS_FINDERINFO 9 /* Mac Finder info & extended info */
|
||||
#define AS_MACINFO 10 /* Mac file info, attributes, etc */
|
||||
#define AS_PRODOSINFO 11 /* Pro-DOS file info, attrib., etc */
|
||||
#define AS_MSDOSINFO 12 /* MS-DOS file info, attributes, etc */
|
||||
#define AS_AFPNAME 13 /* Short name on AFP server */
|
||||
#define AS_AFPINFO 14 /* AFP file info, attrib., etc */
|
||||
|
||||
#define AS_AFPDIRID 15 /* AFP directory ID */
|
||||
|
||||
#if PRAGMA_ALIGN_SUPPORTED
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
/* su_EntryToMacFile
|
||||
* Blasts the bytes specified in the entry to already opened Mac file
|
||||
*/
|
||||
static int
|
||||
su_EntryToMacFile( ASEntry inEntry, XP_File inFile, uint16 inRefNum)
|
||||
{
|
||||
#define BUFFER_SIZE 8192
|
||||
|
||||
char buffer[BUFFER_SIZE];
|
||||
size_t totalRead = 0, bytesRead;
|
||||
OSErr err;
|
||||
|
||||
if ( XP_FileSeek( inFile, inEntry.entryOffset, SEEK_SET) != 0 )
|
||||
return -1 ;
|
||||
|
||||
while ( totalRead < inEntry.entryLength )
|
||||
{
|
||||
// Should we yield in here?
|
||||
bytesRead = XP_FileRead( buffer, BUFFER_SIZE, inFile );
|
||||
if ( bytesRead <= 0 )
|
||||
return -1;
|
||||
long bytesToWrite = totalRead + bytesRead > inEntry.entryLength ?
|
||||
inEntry.entryLength - totalRead :
|
||||
bytesRead;
|
||||
|
||||
totalRead += bytesRead;
|
||||
err = FSWrite(inRefNum, &bytesToWrite, buffer);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* su_ProcessDataFork
|
||||
* blast the data fork to the disk
|
||||
* returns 0 on success
|
||||
*/
|
||||
static int
|
||||
su_ProcessDataFork( ASEntry inEntry, XP_File inFile, FSSpec * ioSpec )
|
||||
{
|
||||
int16 refNum;
|
||||
OSErr err;
|
||||
|
||||
/* Setup the files */
|
||||
err = FSpOpenDF (ioSpec, fsWrPerm, &refNum);
|
||||
|
||||
if ( err == noErr )
|
||||
err = su_EntryToMacFile( inEntry, inFile, refNum );
|
||||
|
||||
FSClose( refNum );
|
||||
return err;
|
||||
}
|
||||
|
||||
/* su_ProcessDataFork
|
||||
* blast the resource fork to the disk
|
||||
* returns 0 on success
|
||||
*/
|
||||
static int
|
||||
su_ProcessResourceFork( ASEntry inEntry, XP_File inFile, FSSpec * ioSpec )
|
||||
{
|
||||
int16 refNum;
|
||||
OSErr err;
|
||||
|
||||
err = FSpOpenRF (ioSpec, fsWrPerm, &refNum);
|
||||
|
||||
if ( err == noErr )
|
||||
err = su_EntryToMacFile( inEntry, inFile, refNum );
|
||||
|
||||
FSClose( refNum );
|
||||
return err;
|
||||
}
|
||||
|
||||
/* su_ProcessRealName
|
||||
* Renames the file to its real name
|
||||
*/
|
||||
static int
|
||||
su_ProcessRealName( ASEntry inEntry, XP_File inFile, FSSpec * ioSpec )
|
||||
{
|
||||
Str255 newName;
|
||||
OSErr err;
|
||||
|
||||
if ( inEntry.entryLength > 32 ) /* Max file name length for the Mac */
|
||||
return -1;
|
||||
|
||||
if ( XP_FileSeek( inFile, inEntry.entryOffset, SEEK_SET) != 0 )
|
||||
return -1 ;
|
||||
|
||||
if ( XP_FileRead( &newName[1], inEntry.entryLength, inFile ) != inEntry.entryLength )
|
||||
return -1;
|
||||
newName[0] = inEntry.entryLength;
|
||||
err = FSpRename(ioSpec, newName);
|
||||
|
||||
if (err == noErr)
|
||||
XP_MEMCPY( ioSpec->name, newName, 32 );
|
||||
return err;
|
||||
}
|
||||
|
||||
/* su_ProcessComment
|
||||
* Sets the file comment
|
||||
*/
|
||||
static int
|
||||
su_ProcessComment( ASEntry inEntry, XP_File inFile, FSSpec * ioSpec )
|
||||
{
|
||||
Str255 newComment;
|
||||
if ( inEntry.entryLength > 32 ) /* Max file name length for the Mac */
|
||||
return -1;
|
||||
|
||||
if ( XP_FileSeek( inFile, inEntry.entryOffset, SEEK_SET) != 0 )
|
||||
return -1 ;
|
||||
|
||||
if ( XP_FileRead( &newComment[1], inEntry.entryLength, inFile ) != inEntry.entryLength )
|
||||
return -1;
|
||||
newComment[0] = inEntry.entryLength;
|
||||
CFileMgr::FileSetComment(*ioSpec, newComment );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* su_ProcessComment
|
||||
* Sets the modification dates
|
||||
*/
|
||||
static int
|
||||
su_ProcessFileDates( ASEntry inEntry, XP_File inFile, FSSpec * ioSpec )
|
||||
{
|
||||
ASFileDates dates;
|
||||
OSErr err;
|
||||
if ( inEntry.entryLength != sizeof(dates) ) /* Max file name length for the Mac */
|
||||
return -1;
|
||||
|
||||
if ( XP_FileSeek( inFile, inEntry.entryOffset, SEEK_SET) != 0 )
|
||||
return -1 ;
|
||||
|
||||
if ( XP_FileRead( &dates, inEntry.entryLength, inFile ) != inEntry.entryLength )
|
||||
return -1;
|
||||
|
||||
Str31 name;
|
||||
XP_MEMCPY(name, ioSpec->name, ioSpec->name[0] + 1);
|
||||
CInfoPBRec pb;
|
||||
pb.hFileInfo.ioNamePtr = name;
|
||||
pb.hFileInfo.ioVRefNum = ioSpec->vRefNum;
|
||||
pb.hFileInfo.ioDirID = ioSpec->parID;
|
||||
pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
|
||||
err = PBGetCatInfoSync(&pb);
|
||||
if ( err != noErr )
|
||||
return -1;
|
||||
#define YR_2000_SECONDS 3029572800
|
||||
pb.hFileInfo.ioFlCrDat = dates.create + 3029572800;
|
||||
pb.hFileInfo.ioFlMdDat = dates.modify + 3029572800;
|
||||
pb.hFileInfo.ioFlBkDat = dates.backup + 3029572800;
|
||||
/* Not sure if mac has the last access time */
|
||||
|
||||
XP_MEMCPY(name, ioSpec->name, ioSpec->name[0] + 1);
|
||||
pb.hFileInfo.ioNamePtr = name;
|
||||
pb.hFileInfo.ioVRefNum = ioSpec->vRefNum;
|
||||
pb.hFileInfo.ioDirID = ioSpec->parID;
|
||||
pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
|
||||
err = PBSetCatInfoSync(&pb);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* su_ProcessFinderInfo
|
||||
* Sets the Finder info
|
||||
*/
|
||||
static int
|
||||
su_ProcessFinderInfo( ASEntry inEntry, XP_File inFile, FSSpec * ioSpec )
|
||||
{
|
||||
ASFinderInfo info;
|
||||
OSErr err;
|
||||
|
||||
if (inEntry.entryLength != sizeof( ASFinderInfo ))
|
||||
return -1;
|
||||
|
||||
if ( XP_FileSeek( inFile, inEntry.entryOffset, SEEK_SET) != 0 )
|
||||
return -1 ;
|
||||
|
||||
if ( XP_FileRead( &info, sizeof(info), inFile) != inEntry.entryLength )
|
||||
return -1;
|
||||
|
||||
err = FSpSetFInfo(ioSpec, &info.ioFlFndrInfo);
|
||||
if ( err != noErr )
|
||||
return -1;
|
||||
|
||||
Str31 name;
|
||||
XP_MEMCPY(name, ioSpec->name, ioSpec->name[0] + 1);
|
||||
CInfoPBRec pb;
|
||||
pb.hFileInfo.ioNamePtr = name;
|
||||
pb.hFileInfo.ioVRefNum = ioSpec->vRefNum;
|
||||
pb.hFileInfo.ioDirID = ioSpec->parID;
|
||||
pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
|
||||
err = PBGetCatInfoSync(&pb);
|
||||
if ( err != noErr )
|
||||
return -1;
|
||||
|
||||
pb.hFileInfo.ioNamePtr = name;
|
||||
pb.hFileInfo.ioVRefNum = ioSpec->vRefNum;
|
||||
pb.hFileInfo.ioDirID = ioSpec->parID;
|
||||
pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
|
||||
pb.hFileInfo.ioFlXFndrInfo = info.ioFlXFndrInfo;
|
||||
err = PBSetCatInfoSync(&pb);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* su_ProcessMacInfo
|
||||
* Sets the Finder info
|
||||
*/
|
||||
static int
|
||||
su_ProcessMacInfo( ASEntry inEntry, XP_File inFile, FSSpec * ioSpec )
|
||||
{
|
||||
ASMacInfo info;
|
||||
OSErr err;
|
||||
|
||||
if (inEntry.entryLength != sizeof( ASMacInfo ))
|
||||
return -1;
|
||||
|
||||
if ( XP_FileSeek( inFile, inEntry.entryOffset, SEEK_SET) != 0 )
|
||||
return -1 ;
|
||||
|
||||
if ( XP_FileRead( &info, sizeof(info), inFile) != inEntry.entryLength )
|
||||
return -1;
|
||||
|
||||
Str31 name;
|
||||
XP_MEMCPY(name, ioSpec->name, ioSpec->name[0] + 1);
|
||||
CInfoPBRec pb;
|
||||
pb.hFileInfo.ioNamePtr = name;
|
||||
pb.hFileInfo.ioVRefNum = ioSpec->vRefNum;
|
||||
pb.hFileInfo.ioDirID = ioSpec->parID;
|
||||
pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
|
||||
err = PBGetCatInfoSync(&pb);
|
||||
if ( err != noErr )
|
||||
return -1;
|
||||
|
||||
pb.hFileInfo.ioNamePtr = name;
|
||||
pb.hFileInfo.ioVRefNum = ioSpec->vRefNum;
|
||||
pb.hFileInfo.ioDirID = ioSpec->parID;
|
||||
pb.hFileInfo.ioFlAttrib = info.ioFlAttrib;
|
||||
err = PBSetCatInfoSync(&pb);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
su_ProcessASEntry( ASEntry inEntry, XP_File inFile, FSSpec * ioSpec )
|
||||
{
|
||||
switch (inEntry.entryID)
|
||||
{
|
||||
case AS_DATA:
|
||||
return su_ProcessDataFork( inEntry, inFile, ioSpec );
|
||||
break;
|
||||
case AS_RESOURCE:
|
||||
return su_ProcessResourceFork( inEntry, inFile, ioSpec );
|
||||
break;
|
||||
case AS_REALNAME:
|
||||
su_ProcessRealName( inEntry, inFile, ioSpec );
|
||||
return 0; // Ignore these errors in ASD
|
||||
case AS_COMMENT:
|
||||
return su_ProcessComment( inEntry, inFile, ioSpec );
|
||||
break;
|
||||
case AS_ICONBW:
|
||||
// return su_ProcessIconBW( inEntry, inFile, ioSpec );
|
||||
break;
|
||||
case AS_ICONCOLOR:
|
||||
// return su_ProcessIconColor( inEntry, inFile, ioSpec );
|
||||
break;
|
||||
case AS_FILEDATES:
|
||||
return su_ProcessFileDates( inEntry, inFile, ioSpec );
|
||||
break;
|
||||
case AS_FINDERINFO:
|
||||
return su_ProcessFinderInfo( inEntry, inFile, ioSpec );
|
||||
break;
|
||||
case AS_MACINFO:
|
||||
return su_ProcessMacInfo( inEntry, inFile, ioSpec );
|
||||
break;
|
||||
case AS_PRODOSINFO:
|
||||
case AS_MSDOSINFO:
|
||||
case AS_AFPNAME:
|
||||
case AS_AFPINFO:
|
||||
case AS_AFPDIRID:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SU_DecodeAppleSingle(const char * inSrc, char ** dst)
|
||||
{
|
||||
XP_File inFile = NULL;
|
||||
FSSpec outFileSpec;
|
||||
size_t bytesRead;
|
||||
ASHeader header;
|
||||
OSErr err;
|
||||
|
||||
if ( (inSrc == NULL) || (dst == NULL))
|
||||
return -1;
|
||||
|
||||
*dst = NULL;
|
||||
|
||||
XP_MEMSET(&outFileSpec, sizeof(outFileSpec), 0);
|
||||
|
||||
inFile = XP_FileOpen(inSrc, xpURL, XP_FILE_READ_BIN);
|
||||
if (inFile == 0)
|
||||
goto fail;
|
||||
|
||||
/* Header validity check */
|
||||
{
|
||||
bytesRead = XP_FileRead(&header, sizeof(ASHeader), inFile );
|
||||
if ( bytesRead != sizeof(ASHeader))
|
||||
goto fail;
|
||||
if ( header.magicNum != 0x00051600 )
|
||||
goto fail;
|
||||
if ( header.versionNum != 0x00020000 )
|
||||
goto fail;
|
||||
if ( header.numEntries == 0 ) /* nothing in this file ? */
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Create a new file spec, right next to the old file */
|
||||
{
|
||||
char * temp = WH_FileName( inSrc, xpURL );
|
||||
if ( temp == NULL )
|
||||
goto fail;
|
||||
c2pstr( temp );
|
||||
err = FSMakeFSSpec(0, 0, (unsigned char *) temp, &outFileSpec);
|
||||
if ( err != noErr )
|
||||
goto fail;
|
||||
XP_FREE(temp);
|
||||
|
||||
err = CFileMgr::UniqueFileSpec( outFileSpec, "decode", outFileSpec);
|
||||
if ( err != noErr )
|
||||
goto fail;
|
||||
err = FSpCreate( &outFileSpec, 'MOSS', '????', 0);
|
||||
if ( err != noErr )
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Loop through the entries, processing each */
|
||||
/* Set the time/date stamps last, because otherwise they'll be destroyed
|
||||
when we write */
|
||||
{
|
||||
Boolean hasDateEntry = FALSE;
|
||||
ASEntry dateEntry;
|
||||
for ( int i=0; i < header.numEntries; i++ )
|
||||
{
|
||||
ASEntry entry;
|
||||
size_t offset = sizeof( ASHeader ) + sizeof( ASEntry ) * i;
|
||||
if ( XP_FileSeek( inFile, offset, SEEK_SET ) != 0 )
|
||||
goto fail;
|
||||
if ( XP_FileRead( &entry, sizeof( entry ), inFile ) != sizeof( entry ))
|
||||
goto fail;
|
||||
if ( entry.entryID == AS_FILEDATES )
|
||||
{
|
||||
hasDateEntry = TRUE;
|
||||
dateEntry = entry;
|
||||
}
|
||||
else
|
||||
err = su_ProcessASEntry( entry, inFile, &outFileSpec );
|
||||
if ( err != 0)
|
||||
goto fail;
|
||||
}
|
||||
if ( hasDateEntry )
|
||||
err = su_ProcessASEntry( dateEntry, inFile, &outFileSpec );
|
||||
if ( err != 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Return the new file specs in xpURL form */
|
||||
|
||||
{
|
||||
char * temp = CFileMgr::GetURLFromFileSpec(outFileSpec);
|
||||
if ( temp == NULL )
|
||||
goto fail;
|
||||
*dst = XP_STRDUP(&temp[XP_STRLEN("file://")]);
|
||||
XP_FREE(temp);
|
||||
if (*dst == NULL)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
XP_FileClose( inFile);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if ( inFile )
|
||||
XP_FileClose( inFile);
|
||||
|
||||
FSpDelete(&outFileSpec);
|
||||
if (*dst)
|
||||
XP_FREE( *dst);
|
||||
*dst = NULL;
|
||||
return -1;
|
||||
}
|
||||
37
mozilla/modules/softupdt/src/su_aplsn.h
Normal file
37
mozilla/modules/softupdt/src/su_aplsn.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/* su_aplsn.h */
|
||||
|
||||
/* SU_DecodeAppleSingle
|
||||
* Decodes an AppleSingle disk file
|
||||
* Arguments:
|
||||
* src - file path in XP_FILE_URL_PATH format
|
||||
* dst - returns the path of the extracted file. NULL if err
|
||||
* Returns an error on failure
|
||||
*/
|
||||
|
||||
#include "xp_core.h"
|
||||
|
||||
#define APPLESINGLE_MIME_TYPE "application/applefile"
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
int SU_DecodeAppleSingle(const char * inSrc, char ** dst);
|
||||
|
||||
XP_END_PROTOS
|
||||
|
||||
406
mozilla/modules/softupdt/src/su_folderspec.c
Normal file
406
mozilla/modules/softupdt/src/su_folderspec.c
Normal file
@@ -0,0 +1,406 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/* su_trigger.c
|
||||
* netscape.softupdate.FolderSpec.java
|
||||
* native methods
|
||||
* created by atotic, 1/6/97
|
||||
*/
|
||||
|
||||
#include "xp_mcom.h"
|
||||
#include "jri.h"
|
||||
#include "su_folderspec.h"
|
||||
|
||||
/* #include "prthread.h" */
|
||||
|
||||
#include "fe_proto.h"
|
||||
#include "xp_str.h"
|
||||
#include "prefapi.h"
|
||||
#include "proto.h"
|
||||
#include "prthread.h"
|
||||
#include "prprf.h"
|
||||
#include "fe_proto.h"
|
||||
#include "xpgetstr.h"
|
||||
|
||||
#define IMPLEMENT_netscape_softupdate_FolderSpec
|
||||
#define IMPLEMENT_netscape_softupdate_SoftwareUpdate
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "_jri/netscape_softupdate_FolderSpec.c"
|
||||
#include "_jri/netscape_softupdate_SoftwareUpdate.h"
|
||||
#else
|
||||
#include "n_softupdate_FolderSpec.c"
|
||||
#include "n_softupdate_SoftwareUpdate.h"
|
||||
#endif
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
#define MAX_PATH _MAX_PATH
|
||||
#endif
|
||||
#ifdef XP_UNIX
|
||||
#ifdef NSPR20
|
||||
#include "md/prosdep.h"
|
||||
#else
|
||||
#include "prosdep.h"
|
||||
#endif
|
||||
#if defined(HPUX) || defined(SCO)
|
||||
/*
|
||||
** HPUX: PATH_MAX is defined in <limits.h> to be 1023, but they
|
||||
** recommend that it not be used, and that pathconf() be
|
||||
** used to determine the maximum at runtime.
|
||||
** SCO: This is what MAXPATHLEN is set to in <arpa/ftp.h> and
|
||||
** NL_MAXPATHLEN in <nl_types.h>. PATH_MAX is defined in
|
||||
** <limits.h> to be 256, but the comments in that file
|
||||
** claim the setting is wrong.
|
||||
*/
|
||||
#define MAX_PATH 1024
|
||||
#else
|
||||
#define MAX_PATH PATH_MAX
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int SU_INSTALL_ASK_FOR_DIRECTORY;
|
||||
|
||||
/* Standard Java initialization for native classes */
|
||||
void
|
||||
FolderSpecInitialize(JRIEnv * env)
|
||||
{
|
||||
use_netscape_softupdate_FolderSpec( env );
|
||||
}
|
||||
|
||||
/* Makes sure that the path ends with a slash (or other platform end character)
|
||||
* @return alloc'd new path that ends with a slash
|
||||
*/
|
||||
static char *
|
||||
AppendSlashToDirPath(char * dirPath)
|
||||
{
|
||||
char pathSeparator; /* Gross, but harmless */
|
||||
int32 newLen;
|
||||
char * newPath;
|
||||
|
||||
#ifdef XP_WIN
|
||||
pathSeparator = '\\';
|
||||
#elif defined(XP_MAC)
|
||||
pathSeparator = ':';
|
||||
#else /* XP_UNIX */
|
||||
pathSeparator = '/';
|
||||
#endif
|
||||
newLen = XP_STRLEN(dirPath) + 2;
|
||||
newPath = (char*)XP_ALLOC(newLen);
|
||||
if (newPath)
|
||||
{
|
||||
newPath[0] = 0;
|
||||
XP_STRCAT(newPath, dirPath);
|
||||
/* Append the slash if missing */
|
||||
if (newPath[newLen - 3] != pathSeparator)
|
||||
{
|
||||
newPath[newLen - 2] = pathSeparator;
|
||||
newPath[newLen - 1] = 0;
|
||||
}
|
||||
}
|
||||
return newPath;
|
||||
}
|
||||
|
||||
/* su_PickDirTimer
|
||||
* keeps track of all SU specific data needed for the stream
|
||||
*/
|
||||
typedef struct su_PickDirTimer_struct {
|
||||
MWContext * context;
|
||||
char * fileName;
|
||||
char * prompt;
|
||||
XP_Bool done;
|
||||
} su_PickDirTimer;
|
||||
|
||||
|
||||
/* Callback for FE_PromptForFileName */
|
||||
PR_STATIC_CALLBACK(void)
|
||||
GetDirectoryPathCallbackFunction(MWContext *context,
|
||||
char *file_name,
|
||||
void *closure)
|
||||
{
|
||||
su_PickDirTimer *t = (su_PickDirTimer*)closure;
|
||||
|
||||
if (file_name)
|
||||
{
|
||||
char * newName = WH_FileName(file_name, xpURL);
|
||||
if ( newName )
|
||||
t->fileName = AppendSlashToDirPath(newName);
|
||||
XP_FREEIF(newName);
|
||||
XP_FREE(file_name);
|
||||
}
|
||||
t->done = TRUE;
|
||||
}
|
||||
|
||||
/* Callback for the timer set by FE_SetTimer */
|
||||
PR_STATIC_CALLBACK(void)
|
||||
pickDirectoryCallback(void * a)
|
||||
{
|
||||
su_PickDirTimer *t = (su_PickDirTimer *)a;
|
||||
int err;
|
||||
err = FE_PromptForFileName (t->context, t->prompt, NULL, FALSE, TRUE,
|
||||
GetDirectoryPathCallbackFunction, a );
|
||||
if ( err != 0) /* callback will not run */
|
||||
t->done = TRUE;
|
||||
}
|
||||
|
||||
/* NativePickDefaultDirectory
|
||||
* Asks the user where he'd like to install the package
|
||||
*/
|
||||
|
||||
JRI_PUBLIC_API(struct java_lang_String *)
|
||||
native_netscape_softupdate_FolderSpec_NativePickDefaultDirectory(
|
||||
JRIEnv* env,
|
||||
struct netscape_softupdate_FolderSpec* self)
|
||||
{
|
||||
struct java_lang_String * jPackageName, * newName= NULL;
|
||||
su_PickDirTimer callback;
|
||||
char * packageName;
|
||||
char prompt[200];
|
||||
|
||||
|
||||
callback.context = XP_FindSomeContext();
|
||||
callback.fileName = NULL;
|
||||
callback.done = FALSE;
|
||||
/* Get the name of the package to prompt for */
|
||||
jPackageName = get_netscape_softupdate_FolderSpec_userPackageName( env, self);
|
||||
packageName = (char*)JRI_GetStringPlatformChars( env, jPackageName, "", 0 );
|
||||
|
||||
if (packageName)
|
||||
{
|
||||
/* In Java thread now, and need to call FE_PromptForFileName
|
||||
* from the main thread
|
||||
* post an event on a timer, and busy-wait until it completes.
|
||||
*/
|
||||
PR_snprintf(prompt, 200, XP_GetString(SU_INSTALL_ASK_FOR_DIRECTORY), packageName);
|
||||
callback.prompt = prompt;
|
||||
FE_SetTimeout( pickDirectoryCallback, &callback, 1 );
|
||||
while (!callback.done) /* Busy loop for now */
|
||||
PR_Yield(); /* java_lang_Thread_yield(WHAT?); */
|
||||
}
|
||||
|
||||
if (callback.fileName != NULL)
|
||||
{
|
||||
newName = JRI_NewStringPlatform(env, callback.fileName, XP_STRLEN( callback.fileName), "", 0);
|
||||
XP_FREE( callback.fileName);
|
||||
}
|
||||
return newName;
|
||||
}
|
||||
|
||||
/*
|
||||
*Directory manipulation
|
||||
*/
|
||||
|
||||
/* Entry for the DirectoryTable[] */
|
||||
struct su_DirectoryTable
|
||||
{
|
||||
char * directoryName; /* The formal directory name */
|
||||
su_SecurityLevel securityLevel; /* Security level */
|
||||
su_DirSpecID folderEnum; /* Directory ID */
|
||||
};
|
||||
|
||||
/* DirectoryTable holds the info about build-in directories:
|
||||
* Text name, security level, enum
|
||||
*/
|
||||
static struct su_DirectoryTable DirectoryTable[] =
|
||||
{
|
||||
{"Plugins", eAllFolderAccess, ePluginFolder},
|
||||
{"Program", eAllFolderAccess, eProgramFolder},
|
||||
{"Communicator", eAllFolderAccess, eCommunicatorFolder},
|
||||
{"User Pick", eAllFolderAccess, ePackageFolder},
|
||||
{"Temporary", eAllFolderAccess, eTemporaryFolder},
|
||||
{"Installed", eAllFolderAccess, eInstalledFolder},
|
||||
{"Current User", eAllFolderAccess, eCurrentUserFolder},
|
||||
|
||||
{"NetHelp", eAllFolderAccess, eNetHelpFolder},
|
||||
{"OS Drive", eAllFolderAccess, eOSDriveFolder},
|
||||
{"File URL", eAllFolderAccess, eFileURLFolder},
|
||||
|
||||
{"Netscape Java Bin", eAllFolderAccess, eJavaBinFolder},
|
||||
{"Netscape Java Classes", eAllFolderAccess, eJavaClassesFolder},
|
||||
{"Java Download", eOneFolderAccess, eJavaDownloadFolder},
|
||||
|
||||
{"Win System", eAllFolderAccess, eWin_SystemFolder},
|
||||
{"Win System16", eAllFolderAccess, eWin_System16Folder},
|
||||
{"Windows", eAllFolderAccess, eWin_WindowsFolder},
|
||||
|
||||
{"Mac System", eAllFolderAccess, eMac_SystemFolder},
|
||||
{"Mac Desktop", eAllFolderAccess, eMac_DesktopFolder},
|
||||
{"Mac Trash", eAllFolderAccess, eMac_TrashFolder},
|
||||
{"Mac Startup", eAllFolderAccess, eMac_StartupFolder},
|
||||
{"Mac Shutdown", eAllFolderAccess, eMac_ShutdownFolder},
|
||||
{"Mac Apple Menu", eAllFolderAccess, eMac_AppleMenuFolder},
|
||||
{"Mac Control Panel", eAllFolderAccess, eMac_ControlPanelFolder},
|
||||
{"Mac Extension", eAllFolderAccess, eMac_ExtensionFolder},
|
||||
{"Mac Fonts", eAllFolderAccess, eMac_FontsFolder},
|
||||
{"Mac Preferences", eAllFolderAccess, eMac_PreferencesFolder},
|
||||
|
||||
{"Unix Local", eAllFolderAccess, eUnix_LocalFolder},
|
||||
{"Unix Lib", eAllFolderAccess, eUnix_LibFolder},
|
||||
|
||||
{"", eAllFolderAccess, eBadFolder} /* Termination line */
|
||||
};
|
||||
|
||||
/* MapNameToEnum
|
||||
* maps name from the directory table to its enum */
|
||||
static su_DirSpecID MapNameToEnum(const char * name)
|
||||
{
|
||||
int i = 0;
|
||||
XP_ASSERT( name );
|
||||
if ( name == NULL)
|
||||
return eBadFolder;
|
||||
|
||||
while ( DirectoryTable[i].directoryName[0] != 0 )
|
||||
{
|
||||
if ( strcmp(name, DirectoryTable[i].directoryName) == 0 )
|
||||
return DirectoryTable[i].folderEnum;
|
||||
i++;
|
||||
}
|
||||
return eBadFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetNativePickPath -- return a native path equivalent of a XP path
|
||||
*/
|
||||
|
||||
JRI_PUBLIC_API(struct java_lang_String *)
|
||||
native_netscape_softupdate_FolderSpec_GetNativePath (JRIEnv* env,
|
||||
struct netscape_softupdate_FolderSpec* self,
|
||||
struct java_lang_String *a)
|
||||
{
|
||||
struct java_lang_String * nativePath = NULL;
|
||||
char *xpPath, *p;
|
||||
char pathSeparator;
|
||||
|
||||
#define XP_PATH_SEPARATOR '/'
|
||||
|
||||
#ifdef XP_WIN
|
||||
pathSeparator = '\\';
|
||||
#elif defined(XP_MAC)
|
||||
pathSeparator = ':';
|
||||
#else /* XP_UNIX */
|
||||
pathSeparator = '/';
|
||||
#endif
|
||||
|
||||
p = xpPath = (char *) JRI_GetStringUTFChars (env, a); /* UTF OK */
|
||||
|
||||
/*
|
||||
* Traverse XP path and replace XP_PATH_SEPARATOR with
|
||||
* the platform native equivalent
|
||||
*/
|
||||
if ( p == NULL )
|
||||
{
|
||||
xpPath = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
while ( *p )
|
||||
{
|
||||
if ( *p == XP_PATH_SEPARATOR )
|
||||
*p = pathSeparator;
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
||||
nativePath = JRI_NewStringUTF(env, xpPath, XP_STRLEN( xpPath)); /* UTF OK */
|
||||
|
||||
return nativePath;
|
||||
}
|
||||
|
||||
/*
|
||||
* NativeGetDirectoryPath
|
||||
*/
|
||||
JRI_PUBLIC_API(jint)
|
||||
native_netscape_softupdate_FolderSpec_NativeGetDirectoryPath(JRIEnv* env,
|
||||
struct netscape_softupdate_FolderSpec* self)
|
||||
{
|
||||
su_DirSpecID folderID;
|
||||
char * folderName;
|
||||
char * folderPath = NULL;
|
||||
struct java_lang_String * jFolderName;
|
||||
|
||||
/* Get the name of the package to prompt for */
|
||||
|
||||
jFolderName = get_netscape_softupdate_FolderSpec_folderID( env, self);
|
||||
folderName = (char*)JRI_GetStringUTFChars( env, jFolderName ); /* UTF OK */
|
||||
|
||||
folderID = MapNameToEnum(folderName);
|
||||
switch (folderID)
|
||||
{
|
||||
case eBadFolder:
|
||||
return netscape_softupdate_FolderSpec_INVALID_PATH_ERR;
|
||||
|
||||
case eCurrentUserFolder:
|
||||
{
|
||||
char dir[MAX_PATH];
|
||||
int len = MAX_PATH;
|
||||
if ( PREF_GetCharPref("profile.directory", dir, &len) == PREF_NOERROR)
|
||||
{
|
||||
char * platformDir = WH_FileName(dir, xpURL);
|
||||
if (platformDir)
|
||||
folderPath = AppendSlashToDirPath(platformDir);
|
||||
XP_FREEIF(platformDir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Get the FE path */
|
||||
folderPath = FE_GetDirectoryPath( folderID);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Store it in the object */
|
||||
if (folderPath != NULL)
|
||||
{
|
||||
struct java_lang_String * jFolderPath;
|
||||
jFolderPath = JRI_NewStringPlatform(env, folderPath, strlen( folderPath), "", 0);
|
||||
if ( jFolderPath != NULL)
|
||||
set_netscape_softupdate_FolderSpec_urlPath(env, self, jFolderPath);
|
||||
|
||||
XP_FREE(folderPath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return netscape_softupdate_FolderSpec_INVALID_PATH_ERR;
|
||||
}
|
||||
|
||||
JRI_PUBLIC_API(jint)
|
||||
native_netscape_softupdate_FolderSpec_GetSecurityTargetID(JRIEnv* env,
|
||||
struct netscape_softupdate_FolderSpec* self)
|
||||
{
|
||||
su_DirSpecID folderID;
|
||||
char * folderName;
|
||||
struct java_lang_String * jFolderName;
|
||||
|
||||
/* Get the name of the package to prompt for */
|
||||
|
||||
jFolderName = get_netscape_softupdate_FolderSpec_folderID( env, self);
|
||||
folderName = (char*)JRI_GetStringUTFChars( env, jFolderName ); /* UTF OK */
|
||||
folderID = MapNameToEnum(folderName);
|
||||
switch (DirectoryTable[folderID].securityLevel)
|
||||
{
|
||||
case eOneFolderAccess:
|
||||
return netscape_softupdate_SoftwareUpdate_LIMITED_INSTALL;
|
||||
case eAllFolderAccess:
|
||||
return netscape_softupdate_SoftwareUpdate_FULL_INSTALL;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
390
mozilla/modules/softupdt/src/su_instl.c
Normal file
390
mozilla/modules/softupdt/src/su_instl.c
Normal file
@@ -0,0 +1,390 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/* su_instl.c
|
||||
* netscape.softupdate.InstallFile.java
|
||||
* native implementation
|
||||
*/
|
||||
|
||||
/* The following two includes are unnecessary, but prevent
|
||||
* IS_LITTLE_ENDIAN warnings */
|
||||
#include "xp_mcom.h"
|
||||
#include "jri.h"
|
||||
|
||||
#define IMPLEMENT_netscape_softupdate_InstallFile
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "_jri/netscape_softupdate_InstallFile.c"
|
||||
#else
|
||||
#include "n_softupdate_InstallFile.c"
|
||||
#endif
|
||||
|
||||
#define IMPLEMENT_netscape_softupdate_InstallExecute
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "_jri/netscape_softupdate_InstallExecute.c"
|
||||
#else
|
||||
#include "n_softupdate_InstallExecute.c"
|
||||
#endif
|
||||
|
||||
#define IMPLEMENT_netscape_softupdate_InstallPatch
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "_jri/netscape_softupdate_InstallPatch.c"
|
||||
#else
|
||||
#include "n_softupdate_InstallPatch.c"
|
||||
#endif
|
||||
|
||||
#define IMPLEMENT_netscape_softupdate_SoftUpdateException
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "_jri/netscape_softupdate_SoftUpdateException.h"
|
||||
#else
|
||||
#include "n_s_SoftUpdateException.h"
|
||||
#endif
|
||||
|
||||
#define IMPLEMENT_netscape_softupdate_Strings
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "_jri/netscape_softupdate_Strings.h"
|
||||
#else
|
||||
#include "netscape_softupdate_Strings.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_PC
|
||||
#define IMPLEMENT_netscape_softupdate_SoftwareUpdate
|
||||
#define IMPLEMENT_netscape_softupdate_InstallObject
|
||||
#include "_jri/netscape_softupdate_SoftwareUpdate.h"
|
||||
#include "_jri/netscape_softupdate_InstallObject.c"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "zig.h"
|
||||
#include "xp_file.h"
|
||||
#include "su_folderspec.h"
|
||||
#include "su_instl.h"
|
||||
#include "fe_proto.h"
|
||||
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
|
||||
static XP_Bool rebootShown = FALSE;
|
||||
#ifdef XP_WIN16
|
||||
static XP_Bool utilityScheduled = FALSE;
|
||||
#endif
|
||||
|
||||
#ifdef NO_ERROR
|
||||
#undef NO_ERROR
|
||||
#endif
|
||||
#define NO_ERROR 0
|
||||
|
||||
|
||||
/* Standard Java initialization for native methods classes
|
||||
*/
|
||||
void InstallFileInitialize(JRIEnv * env)
|
||||
{
|
||||
use_netscape_softupdate_InstallFile( env );
|
||||
use_netscape_softupdate_InstallExecute( env );
|
||||
#ifdef XP_PC
|
||||
use_netscape_softupdate_InstallObject( env );
|
||||
#endif
|
||||
}
|
||||
|
||||
/* NativeComplete
|
||||
* copies the file to its final location
|
||||
* Tricky, we need to create the directories
|
||||
*/
|
||||
JRI_PUBLIC_API(jint)
|
||||
native_netscape_softupdate_InstallFile_NativeComplete(JRIEnv* env,
|
||||
struct netscape_softupdate_InstallFile* self)
|
||||
{
|
||||
char * currentName;
|
||||
char * finalName = NULL;
|
||||
char * finalNamePlatform;
|
||||
struct java_lang_String * currentNameJava;
|
||||
struct java_lang_String * finalNameJava;
|
||||
int result;
|
||||
|
||||
/* Get the names */
|
||||
currentNameJava = get_netscape_softupdate_InstallFile_tempFile( env, self);
|
||||
currentName = (char*)JRI_GetStringPlatformChars( env, currentNameJava, "", 0);
|
||||
|
||||
finalNameJava = get_netscape_softupdate_InstallFile_finalFile( env, self);
|
||||
finalNamePlatform = (char*)JRI_GetStringPlatformChars( env, finalNameJava, "", 0);
|
||||
finalName = XP_PlatformFileToURL(finalNamePlatform);
|
||||
|
||||
if ( (currentName != NULL) &&
|
||||
(finalName != NULL) &&
|
||||
( XP_STRCMP(finalName, currentName) == 0))
|
||||
return 0; /* No need to rename, they are the same */
|
||||
|
||||
if (finalName != NULL)
|
||||
{
|
||||
char * temp = XP_STRDUP(&finalName[7]);
|
||||
XP_FREEIF(finalName);
|
||||
finalName = temp;
|
||||
if (finalName) {
|
||||
XP_StatStruct s;
|
||||
if ( XP_Stat( finalName, &s, xpURL ) != 0 ) {
|
||||
/* Target file doesn't exist, try to rename file
|
||||
*/
|
||||
result = XP_FileRename(currentName, xpURL, finalName, xpURL);
|
||||
}
|
||||
else {
|
||||
/* Target exists, can't trust XP_FileRename--do platform
|
||||
* specific stuff in FE_ReplaceExistingFile()
|
||||
*/
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
XP_StatStruct s;
|
||||
if ( XP_Stat( finalName, &s, xpURL ) == 0 )
|
||||
/* File already exists, need to remove the original */
|
||||
{
|
||||
XP_Bool force = get_netscape_softupdate_InstallFile_force(env, self);
|
||||
result = FE_ReplaceExistingFile(currentName, xpURL, finalName, xpURL, force);
|
||||
if ( result == REBOOT_NEEDED ) {
|
||||
#ifdef XP_WIN16
|
||||
if (!utilityScheduled) {
|
||||
utilityScheduled = TRUE;
|
||||
FE_ScheduleRenameUtility();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
/* Directory might not exist, check and create if necessary */
|
||||
{
|
||||
char separator;
|
||||
char * end;
|
||||
separator = '/';
|
||||
end = XP_STRRCHR(finalName, separator);
|
||||
if (end)
|
||||
{
|
||||
end[0] = 0;
|
||||
result = XP_MakeDirectoryR( finalName, xpURL);
|
||||
end[0] = separator;
|
||||
if ( 0 == result )
|
||||
result = XP_FileRename(currentName, xpURL, finalName, xpURL);
|
||||
}
|
||||
}
|
||||
#ifdef XP_UNIX
|
||||
/* Last try, can't rename() across file systems on UNIX */
|
||||
if ( -1 == result )
|
||||
{
|
||||
result = FE_CopyFile(currentName, finalName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
XP_FREEIF(finalName);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Removes the temporary file */
|
||||
JRI_PUBLIC_API(void)
|
||||
native_netscape_softupdate_InstallFile_NativeAbort(JRIEnv* env,
|
||||
struct netscape_softupdate_InstallFile* self)
|
||||
{
|
||||
char * currentName;
|
||||
struct java_lang_String * currentNameJava;
|
||||
int result;
|
||||
|
||||
/* Get the names */
|
||||
currentNameJava = get_netscape_softupdate_InstallFile_tempFile( env, self);
|
||||
currentName = (char*)JRI_GetStringPlatformChars( env, currentNameJava, "", 0);
|
||||
|
||||
result = XP_FileRemove(currentName, xpURL);
|
||||
XP_ASSERT(result == 0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------
|
||||
*
|
||||
* InstallExecute native methods
|
||||
*
|
||||
*---------------------------------------*/
|
||||
|
||||
/* Executes the extracted binary
|
||||
*/
|
||||
JRI_PUBLIC_API(void)
|
||||
native_netscape_softupdate_InstallExecute_NativeComplete(JRIEnv* env,
|
||||
struct netscape_softupdate_InstallExecute* self)
|
||||
{
|
||||
char * cmdline;
|
||||
char * filename;
|
||||
int32 err;
|
||||
|
||||
filename = (char*)JRI_GetStringPlatformChars(
|
||||
env,
|
||||
get_netscape_softupdate_InstallExecute_tempFile( env, self ),
|
||||
"",
|
||||
0 );
|
||||
|
||||
cmdline = (char*)JRI_GetStringPlatformChars(
|
||||
env,
|
||||
get_netscape_softupdate_InstallExecute_cmdline( env, self ),
|
||||
"",
|
||||
0 );
|
||||
|
||||
err = FE_ExecuteFile( filename, cmdline );
|
||||
XP_ASSERT( err == 0 );
|
||||
if ( err != 0 )
|
||||
{
|
||||
struct netscape_softupdate_SoftUpdateException* e;
|
||||
struct java_lang_String * errStr;
|
||||
errStr = netscape_softupdate_Strings_error_0005fUnexpected(env,
|
||||
class_netscape_softupdate_Strings(env));
|
||||
|
||||
e = netscape_softupdate_SoftUpdateException_new( env,
|
||||
class_netscape_softupdate_SoftUpdateException(env),
|
||||
errStr,
|
||||
err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Removes the temporary file */
|
||||
JRI_PUBLIC_API(void)
|
||||
native_netscape_softupdate_InstallExecute_NativeAbort(JRIEnv* env,
|
||||
struct netscape_softupdate_InstallExecute* self)
|
||||
{
|
||||
char * currentName;
|
||||
struct java_lang_String * currentNameJava;
|
||||
int result;
|
||||
|
||||
/* Get the names */
|
||||
currentNameJava = get_netscape_softupdate_InstallExecute_tempFile(env,self);
|
||||
currentName = (char*)JRI_GetStringPlatformChars(env, currentNameJava,"",0);
|
||||
|
||||
result = XP_FileRemove(currentName, xpURL);
|
||||
XP_ASSERT(result == 0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------
|
||||
*
|
||||
* InstallPatch native methods
|
||||
*
|
||||
*---------------------------------------*/
|
||||
|
||||
/*** private native NativePatch (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; ***/
|
||||
JRI_PUBLIC_API(struct java_lang_String *)
|
||||
native_netscape_softupdate_InstallPatch_NativePatch(JRIEnv* env,
|
||||
struct netscape_softupdate_InstallPatch* self,
|
||||
struct java_lang_String *jSrcFile,
|
||||
struct java_lang_String *jDiffURL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** private native NativeReplace (Ljava/lang/String;Ljava/lang/String;)I ***/
|
||||
JRI_PUBLIC_API(jint)
|
||||
native_netscape_softupdate_InstallPatch_NativeReplace(JRIEnv* env,
|
||||
struct netscape_softupdate_InstallPatch* self,
|
||||
struct java_lang_String *jTargetfile,
|
||||
struct java_lang_String *jNewfile)
|
||||
{
|
||||
char * targetfile = NULL;
|
||||
char * newfile = NULL;
|
||||
char * targetURL = NULL;
|
||||
char * newURL = NULL;
|
||||
char * pTarget;
|
||||
char * pNew;
|
||||
int err = SU_SUCCESS;
|
||||
|
||||
targetfile = (char*)JRI_GetStringPlatformChars( env, jTargetfile, "", 0 );
|
||||
newfile = (char*)JRI_GetStringPlatformChars( env, jNewfile, "", 0 );
|
||||
|
||||
if ( targetfile != NULL && newfile != NULL )
|
||||
{
|
||||
targetURL = XP_PlatformFileToURL( targetfile );
|
||||
newURL = XP_PlatformFileToURL( newfile );
|
||||
|
||||
if ( targetURL != NULL && newURL != NULL )
|
||||
{
|
||||
XP_StatStruct st;
|
||||
|
||||
pTarget = targetURL+7;
|
||||
pNew = newURL+7;
|
||||
|
||||
if ( XP_Stat( pTarget, &st, xpURL ) == SU_SUCCESS ) {
|
||||
/* file still exists */
|
||||
err = FE_ReplaceExistingFile( pNew, xpURL, pTarget, xpURL, 0 );
|
||||
#ifdef XP_WIN16
|
||||
if ( err == REBOOT_NEEDED && !utilityScheduled) {
|
||||
utilityScheduled = TRUE;
|
||||
FE_ScheduleRenameUtility();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* someone got rid of the target file? */
|
||||
/* can do simple rename, but assert */
|
||||
err = XP_FileRename( pNew, xpURL, pTarget, xpURL );
|
||||
XP_ASSERT( err == SU_SUCCESS );
|
||||
XP_ASSERT(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
err = -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
err = -1;
|
||||
}
|
||||
|
||||
XP_FREEIF( targetURL );
|
||||
XP_FREEIF( newURL );
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** private native NativeDeleteFile (Ljava/lang/String;)V ***/
|
||||
JRI_PUBLIC_API(void)
|
||||
native_netscape_softupdate_InstallPatch_NativeDeleteFile(JRIEnv* env,
|
||||
struct netscape_softupdate_InstallPatch* self,
|
||||
struct java_lang_String *jFilename)
|
||||
{
|
||||
char * filename = NULL;
|
||||
char * fnameURL = NULL;
|
||||
|
||||
filename = (char*)JRI_GetStringPlatformChars( env, jFilename, "", 0 );
|
||||
XP_ASSERT( filename );
|
||||
|
||||
if ( filename != NULL ) {
|
||||
fnameURL = XP_PlatformFileToURL( filename );
|
||||
XP_ASSERT( fnameURL );
|
||||
|
||||
XP_FileRemove( fnameURL+7, xpURL );
|
||||
}
|
||||
|
||||
|
||||
if ( fnameURL != NULL )
|
||||
XP_FREE( fnameURL );
|
||||
}
|
||||
44
mozilla/modules/softupdt/src/su_instl.h
Normal file
44
mozilla/modules/softupdt/src/su_instl.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* -*- 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 "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.
|
||||
*/
|
||||
/* su_instl.h
|
||||
*
|
||||
* created by atotic, 1/22/97
|
||||
*/
|
||||
|
||||
#include "xp_mcom.h"
|
||||
|
||||
#define REBOOT_NEEDED 999
|
||||
#define SU_SUCCESS 0
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
/* Immediately executes the file
|
||||
* returns errors if encountered
|
||||
*/
|
||||
int FE_ExecuteFile( const char * filename, const char * cmdline );
|
||||
#ifdef XP_PC
|
||||
void PR_CALLBACK SU_AlertCallback(void *dummy);
|
||||
void FE_ScheduleRenameUtility(void);
|
||||
#endif
|
||||
|
||||
#ifdef XP_UNIX
|
||||
int FE_CopyFile (const char *in, const char *out);
|
||||
#endif
|
||||
|
||||
XP_END_PROTOS
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user