Kaydet (Commit) 8c07510f authored tarafından Nathan Yee's avatar Nathan Yee Kaydeden (comit) Jan Holesovsky

online update: Add updater executable build support

Change-Id: I033f114d29cd020b6dba5a74257d3f577dd73ea7
üst 7316144b
......@@ -179,9 +179,10 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,pdfimport, \
))
endif
$(eval $(call gb_Helper_register_executables_for_install,OOO,onlineupdate, \
$(eval $(call gb_Helper_register_executables_for_install,OOO,updater,\
$(if $(ENABLE_ONLINE_UPDATE), \
mar \
updater \
) \
))
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_Executable_Executable,updater))
$(eval $(call gb_Executable_set_include,updater,\
-I$(SRCDIR)/onlineupdate/source/update/src \
-I$(SRCDIR)/onlineupdate/source/update/inc \
-I$(SRCDIR)/onlineupdate/source/update/common \
-I$(SRCDIR)/onlineupdate/source/update/updater/libbz2/src \
-I$(SRCDIR)/onlineupdate/source/update/updater/xpcom/glue \
-lpthread \
$$(INCLUDE) \
))
$(eval $(call gb_Executable_add_libs,updater,\
-lX11 \
-lXext \
-lXrender \
-lSM \
-lICE \
))
ifeq ($(OS),MACOSX)
$(eval $(call gb_Executable_set_include,updater,\
-lgtk \
))
$(eval $(call gb_Exectuable_add_libs,updater,\
-lpthread \
))
else ifeq ($(OS),LINUX)
$(eval $(call gb_Executable_set_include,updater,\
-lgtk \
))
$(eval $(call gb_Exectuable_add_libs,updater,\
-lpthread \
))
endif
$(eval $(call gb_Executable_add_cxxflags,updater,\
$$(GTK3_CFLAGS) \
))
$(eval $(call gb_Executable_add_libs,updater,\
$(GTK3_LIBS) \
))
$(eval $(call gb_Executable_use_libraries,updater,\
libreofficekitgtk \
))
$(eval $(call gb_Executable_use_externals,updater,\
gtk \
))
$(eval $(call gb_Executable_add_exception_objects,updater,\
onlineupdate/source/update/updater/xpcom/glue/nsVersionComparator \
onlineupdate/source/update/updater/archivereader \
onlineupdate/source/update/updater/bspatch \
onlineupdate/source/update/updater/loaddlls \
onlineupdate/source/update/updater/progressui_gtk \
onlineupdate/source/update/updater/progressui_null \
onlineupdate/source/update/updater/progressui_win \
onlineupdate/source/update/updater/updater \
onlineupdate/source/update/updater/win_dirent \
onlineupdate/source/update/common/pathhash \
onlineupdate/source/update/common/readstrings \
onlineupdate/source/update/common/uachelper \
onlineupdate/source/update/common/updatehelper \
onlineupdate/source/update/common/updatelogging \
))
$(eval $(call gb_Executable_add_cobjects,updater,\
onlineupdate/source/update/src/mar_create \
onlineupdate/source/update/src/mar_extract \
onlineupdate/source/update/src/mar_read \
onlineupdate/source/update/updater/libbz2/src/blocksort \
onlineupdate/source/update/updater/libbz2/src/bzlib \
onlineupdate/source/update/updater/libbz2/src/compress \
onlineupdate/source/update/updater/libbz2/src/crctable \
onlineupdate/source/update/updater/libbz2/src/decompress \
onlineupdate/source/update/updater/libbz2/src/huffman \
onlineupdate/source/update/updater/libbz2/src/randtable \
))
# vim:set shiftwidth=4 tabstop=4 noexpandtab: */
......@@ -11,7 +11,8 @@
$(eval $(call gb_Module_Module,onlineupdate))
$(eval $(call gb_Module_add_targets,onlineupdate,\
Executable_mar \
Executable_mar \
Executable_updater \
))
# vim: set noet sw=4 ts=4:
......@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef WNT
#include <windows.h>
#include <wincrypt.h>
#include "pathhash.h"
......@@ -137,3 +138,4 @@ CalculateRegistryPathFromFilePath(const LPCWSTR filePath,
delete[] hash;
return TRUE;
}
#endif
......@@ -10,7 +10,7 @@
#include "readstrings.h"
#include "errors.h"
#ifdef XP_WIN
#ifdef WNT
# define NS_tfopen _wfopen
# define OPEN_MODE L"rb"
#else
......
......@@ -9,7 +9,7 @@
#define MAX_TEXT_LEN 600
#ifdef XP_WIN
#ifdef WNT
# include <windows.h>
typedef WCHAR NS_tchar;
#else
......
......@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef WNT
#include <windows.h>
#include <wtsapi32.h>
#include "uachelper.h"
......@@ -220,3 +221,4 @@ UACHelper::CanUserElevate()
return canElevate;
}
#endif
......@@ -21,7 +21,7 @@
# endif
#endif
#if defined(XP_WIN)
#if defined(WNT)
# include <windows.h>
# include <shlwapi.h>
# include <direct.h>
......@@ -116,7 +116,7 @@ static inline int mywcsprintf(WCHAR* dest, size_t count, const WCHAR* fmt, ...)
#endif
# include <dirent.h>
#ifdef XP_MACOSX
#ifdef MACOSX
# include <sys/time.h>
#endif
......
......@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef WNT
#include <windows.h>
// Needed for CreateToolhelp32Snapshot
......@@ -749,3 +750,4 @@ IsUnpromptedElevation(BOOL &isUnpromptedElevation)
RegCloseKey(baseKey);
return success;
}
#endif
......@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if defined(XP_WIN)
#if defined(WNT)
#include <windows.h>
#endif
......
......@@ -6,11 +6,7 @@
#ifndef WINDIRENT_H__
#define WINDIRENT_H__
#ifndef XP_WIN
#error This library should only be used on Windows
#endif
#ifdef WNT
#include <windows.h>
struct DIR {
......@@ -29,4 +25,5 @@ DIR* opendir(const WCHAR* path);
int closedir(DIR* dir);
dirent* readdir(DIR* dir);
#endif // WNT
#endif // WINDIRENT_H__
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Various compiler checks. */
#ifndef mozilla_Compiler_h
#define mozilla_Compiler_h
#define MOZ_IS_GCC 0
#define MOS_IS_MSVC 0
#if !defined(__clang__) && defined(__GNUC__)
# undef MOZ_IS_GCC
# define MOZ_IS_GCC 1
/*
* This macro should simplify gcc version checking. For example, to check
* for gcc 4.7.1 or later, check `#if MOZ_GCC_VERSION_AT_LEAST(4, 7, 1)`.
*/
# define MOZ_GCC_VERSION_AT_LEAST(major, minor, patchlevel) \
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \
>= ((major) * 10000 + (minor) * 100 + (patchlevel)))
# if !MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
# error "mfbt (and Gecko) require at least gcc 4.7 to build."
# endif
#elif defined(_MSC_VER)
# undef MOZ_IS_MSVC
# define MOZ_IS_MSVC 1
#endif
/*
* The situation with standard libraries is a lot worse than with compilers,
* particularly as clang and gcc could end up using one of three or so standard
* libraries, and they may not be up-to-snuff with newer C++11 versions. To
* detect the library, we're going to include cstddef (which is a small header
* which will be transitively included by everybody else at some point) to grab
* the version macros and deduce macros from there.
*/
#ifdef __cplusplus
# include <cstddef>
# ifdef _STLPORT_MAJOR
# define MOZ_USING_STLPORT 1
# define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) \
(_STLPORT_VERSION >= ((major) << 8 | (minor) << 4 | (patch)))
# elif defined(_LIBCPP_VERSION)
/*
* libc++, unfortunately, doesn't appear to have useful versioning macros.
* Hopefully, the recommendations of N3694 with respect to standard libraries
* will get applied instead and we won't need to worry about version numbers
* here.
*/
# define MOZ_USING_LIBCXX 1
# elif defined(__GLIBCXX__)
# define MOZ_USING_LIBSTDCXX 1
/*
* libstdc++ is also annoying and doesn't give us useful versioning macros
* for the library. If we're using gcc, then assume that libstdc++ matches
* the compiler version. If we're using clang, we're going to have to fake
* major/minor combinations by looking for newly-defined config macros.
*/
# if MOZ_IS_GCC
# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
MOZ_GCC_VERSION_AT_LEAST(major, minor, patch)
# elif defined(_GLIBCXX_THROW_OR_ABORT)
# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
((major) < 4 || ((major) == 4 && (minor) <= 8))
# elif defined(_GLIBCXX_NOEXCEPT)
# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
((major) < 4 || ((major) == 4 && (minor) <= 7))
# elif defined(_GLIBCXX_USE_DEPRECATED)
# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
((major) < 4 || ((major) == 4 && (minor) <= 6))
# elif defined(_GLIBCXX_PSEUDO_VISIBILITY)
# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
((major) < 4 || ((major) == 4 && (minor) <= 5))
# elif defined(_GLIBCXX_BEGIN_EXTERN_C)
# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
((major) < 4 || ((major) == 4 && (minor) <= 4))
# elif defined(_GLIBCXX_VISIBILITY_ATTR)
# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
((major) < 4 || ((major) == 4 && (minor) <= 3))
# elif defined(_GLIBCXX_VISIBILITY)
# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
((major) < 4 || ((major) == 4 && (minor) <= 2))
# else
# error "Your version of libstdc++ is unknown to us and is likely too old."
# endif
# endif
// Flesh out the defines for everyone else
# ifndef MOZ_USING_STLPORT
# define MOZ_USING_STLPORT 0
# define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) 0
# endif
# ifndef MOZ_USING_LIBCXX
# define MOZ_USING_LIBCXX 0
# endif
# ifndef MOZ_USING_LIBSTDCXX
# define MOZ_USING_LIBSTDCXX 0
# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) 0
# endif
#endif /* __cplusplus */
#endif /* mozilla_Compiler_h */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* MOZ_LIKELY and MOZ_UNLIKELY macros to hint to the compiler how a
* boolean predicate should be branch-predicted.
*/
#ifndef mozilla_Likely_h
#define mozilla_Likely_h
#if defined(__clang__) || defined(__GNUC__)
# define MOZ_LIKELY(x) (__builtin_expect(!!(x), 1))
# define MOZ_UNLIKELY(x) (__builtin_expect(!!(x), 0))
#else
# define MOZ_LIKELY(x) (!!(x))
# define MOZ_UNLIKELY(x) (!!(x))
#endif
#endif /* mozilla_Likely_h */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* Implements various macros meant to ease the use of variadic macros.
*/
#ifndef mozilla_MacroArgs_h
#define mozilla_MacroArgs_h
/*
* MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) counts the number of variadic
* arguments and prefixes it with |aPrefix|. For example:
*
* MOZ_PASTE_PREFIX_AND_ARG_COUNT(, foo, 42) expands to 2
* MOZ_PASTE_PREFIX_AND_ARG_COUNT(A, foo, 42, bar) expands to A3
*
* You must pass in between 1 and 50 (inclusive) variadic arguments, past
* |aPrefix|. It is not legal to do
*
* MOZ_PASTE_PREFIX_AND_ARG_COUNT(prefix)
*
* (that is, pass in 0 variadic arguments). To ensure that a compile-time
* error occurs when these constraints are violated, use the
* MOZ_STATIC_ASSERT_VALID_ARG_COUNT macro with the same variaidc arguments
* wherever this macro is used.
*
* Passing (__VA_ARGS__, <rest of arguments>) rather than simply calling
* MOZ_MACROARGS_ARG_COUNT_HELPER2(__VA_ARGS__, <rest of arguments>) very
* carefully tiptoes around a MSVC bug where it improperly expands __VA_ARGS__
* as a single token in argument lists. For details, see:
*
* http://connect.microsoft.com/VisualStudio/feedback/details/380090/variadic-macro-replacement
* http://cplusplus.co.il/2010/07/17/variadic-macro-to-count-number-of-arguments/#comment-644
*/
#define MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) \
MOZ_MACROARGS_ARG_COUNT_HELPER((__VA_ARGS__, \
aPrefix##50, aPrefix##49, aPrefix##48, aPrefix##47, aPrefix##46, \
aPrefix##45, aPrefix##44, aPrefix##43, aPrefix##42, aPrefix##41, \
aPrefix##40, aPrefix##39, aPrefix##38, aPrefix##37, aPrefix##36, \
aPrefix##35, aPrefix##34, aPrefix##33, aPrefix##32, aPrefix##31, \
aPrefix##30, aPrefix##29, aPrefix##28, aPrefix##27, aPrefix##26, \
aPrefix##25, aPrefix##24, aPrefix##23, aPrefix##22, aPrefix##21, \
aPrefix##20, aPrefix##19, aPrefix##18, aPrefix##17, aPrefix##16, \
aPrefix##15, aPrefix##14, aPrefix##13, aPrefix##12, aPrefix##11, \
aPrefix##10, aPrefix##9, aPrefix##8, aPrefix##7, aPrefix##6, \
aPrefix##5, aPrefix##4, aPrefix##3, aPrefix##2, aPrefix##1, aPrefix##0))
#define MOZ_MACROARGS_ARG_COUNT_HELPER(aArgs) \
MOZ_MACROARGS_ARG_COUNT_HELPER2 aArgs
#define MOZ_MACROARGS_ARG_COUNT_HELPER2( \
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, \
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, \
a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, \
a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, \
a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, \
a51, ...) a51
/*
* MOZ_STATIC_ASSERT_VALID_ARG_COUNT ensures that a compile-time error occurs
* when the argument count constraints of MOZ_PASTE_PREFIX_AND_ARG_COUNT are
* violated. Use this macro wherever MOZ_PASTE_PREFIX_AND_ARG_COUNT is used
* and pass it the same variadic arguments.
*
* This macro employs a few dirty tricks to function. To detect the zero
* argument case, |(__VA_ARGS__)| is stringified, sizeof-ed, and compared to
* what it should be in the absence of arguments.
*
* Detecting too many arguments is a little trickier. With a valid argument
* count and a prefix of 1, MOZ_PASTE_PREFIX_AND_ARG_COUNT expands to e.g. 14.
* With a prefix of 0.0, it expands to e.g. 0.04. If there are too many
* arguments, it expands to the first argument over the limit. If this
* exceeding argument is a number, the assertion will fail as there is no
* number than can simultaneously be both > 10 and == 0. If the exceeding
* argument is not a number, a compile-time error should still occur due to
* the operations performed on it.
*/
#define MOZ_MACROARGS_STRINGIFY_HELPER(x) #x
#define MOZ_STATIC_ASSERT_VALID_ARG_COUNT(...) \
static_assert( \
sizeof(MOZ_MACROARGS_STRINGIFY_HELPER((__VA_ARGS__))) != sizeof("()") && \
(MOZ_PASTE_PREFIX_AND_ARG_COUNT(1, __VA_ARGS__)) > 10 && \
(int)(MOZ_PASTE_PREFIX_AND_ARG_COUNT(0.0, __VA_ARGS__)) == 0, \
"MOZ_STATIC_ASSERT_VALID_ARG_COUNT requires 1 to 50 arguments") /* ; */
/*
* MOZ_ARGS_AFTER_N expands to its arguments excluding the first |N|
* arguments. For example:
*
* MOZ_ARGS_AFTER_2(a, b, c, d) expands to: c, d
*/
#define MOZ_ARGS_AFTER_1(a1, ...) __VA_ARGS__
#define MOZ_ARGS_AFTER_2(a1, a2, ...) __VA_ARGS__
/*
* MOZ_ARG_N expands to its |N|th argument.
*/
#define MOZ_ARG_1(a1, ...) a1
#define MOZ_ARG_2(a1, a2, ...) a2
#endif /* mozilla_MacroArgs_h */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* mfbt foundational types and macros. */
#ifndef mozilla_Types_h
#define mozilla_Types_h
/*
* This header must be valid C and C++, includable by code embedding either
* SpiderMonkey or Gecko.
*/
/* Expose all <stdint.h> types and size_t. */
#include <stddef.h>
#include <stdint.h>
/* Implement compiler and linker macros needed for APIs. */
/*
* MOZ_EXPORT is used to declare and define a symbol or type which is externally
* visible to users of the current library. It encapsulates various decorations
* needed to properly export the method's symbol.
*
* api.h:
* extern MOZ_EXPORT int MeaningOfLife(void);
* extern MOZ_EXPORT int LuggageCombination;
*
* api.c:
* int MeaningOfLife(void) { return 42; }
* int LuggageCombination = 12345;
*
* If you are merely sharing a method across files, just use plain |extern|.
* These macros are designed for use by library interfaces -- not for normal
* methods or data used cross-file.
*/
#if defined(WIN32)
# define MOZ_EXPORT __declspec(dllexport)
#else /* Unix */
# ifdef HAVE_VISIBILITY_ATTRIBUTE
# define MOZ_EXPORT __attribute__((visibility("default")))
# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# define MOZ_EXPORT __global
# else
# define MOZ_EXPORT /* nothing */
# endif
#endif
/*
* Whereas implementers use MOZ_EXPORT to declare and define library symbols,
* users use MOZ_IMPORT_API and MOZ_IMPORT_DATA to access them. Most often the
* implementer of the library will expose an API macro which expands to either
* the export or import version of the macro, depending upon the compilation
* mode.
*/
#ifdef _WIN32
# if defined(__MWERKS__)
# define MOZ_IMPORT_API /* nothing */
# else
# define MOZ_IMPORT_API __declspec(dllimport)
# endif
#else
# define MOZ_IMPORT_API MOZ_EXPORT
#endif
#if defined(_WIN32) && !defined(__MWERKS__)
# define MOZ_IMPORT_DATA __declspec(dllimport)
#else
# define MOZ_IMPORT_DATA MOZ_EXPORT
#endif
/*
* Consistent with the above comment, the MFBT_API and MFBT_DATA macros expose
* export mfbt declarations when building mfbt, and they expose import mfbt
* declarations when using mfbt.
*/
#if defined(IMPL_MFBT)
# define MFBT_API MOZ_EXPORT
# define MFBT_DATA MOZ_EXPORT
#else
/*
* On linux mozglue is linked in the program and we link libxul.so with
* -z,defs. Normally that causes the linker to reject undefined references in
* libxul.so, but as a loophole it allows undefined references to weak
* symbols. We add the weak attribute to the import version of the MFBT API
* macros to exploit this.
*/
# if defined(MOZ_GLUE_IN_PROGRAM) && !defined(MOZILLA_XPCOMRT_API)
# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API
# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA
# else
# define MFBT_API MOZ_IMPORT_API
# define MFBT_DATA MOZ_IMPORT_DATA
# endif
#endif
/*
* C symbols in C++ code must be declared immediately within |extern "C"|
* blocks. However, in C code, they need not be declared specially. This
* difference is abstracted behind the MOZ_BEGIN_EXTERN_C and MOZ_END_EXTERN_C
* macros, so that the user need not know whether he is being used in C or C++
* code.
*
* MOZ_BEGIN_EXTERN_C
*
* extern MOZ_EXPORT int MostRandomNumber(void);
* ...other declarations...
*
* MOZ_END_EXTERN_C
*
* This said, it is preferable to just use |extern "C"| in C++ header files for
* its greater clarity.
*/
#ifdef __cplusplus
# define MOZ_BEGIN_EXTERN_C extern "C" {
# define MOZ_END_EXTERN_C }
#else
# define MOZ_BEGIN_EXTERN_C
# define MOZ_END_EXTERN_C
#endif
/*
* GCC's typeof is available when decltype is not.
*/
#if defined(__GNUC__) && defined(__cplusplus) && \
!defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
# define decltype __typeof__
#endif
#endif /* mozilla_Types_h */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsTraceRefcnt_h___
#define nsTraceRefcnt_h___
#include <stdio.h> // for FILE
#include "nscore.h"
class nsTraceRefcnt
{
public:
static void Shutdown();
enum StatisticsType {
ALL_STATS,
NEW_STATS
};
static nsresult DumpStatistics(StatisticsType aType = ALL_STATS,
FILE* aOut = 0);
static void ResetStatistics();
static void DemangleSymbol(const char* aSymbol, char* aBuffer, int aBufLen);
static void WalkTheStack(FILE* aStream);
/**
* This is a variant of |WalkTheStack| that uses |CodeAddressService| to cache
* the results of |NS_DescribeCodeAddress|. If |WalkTheStackCached| is being
* called frequently, it will be a few orders of magnitude faster than
* |WalkTheStack|. However, the cache uses a lot of memory, which can cause
* OOM crashes. Therefore, this should only be used for things like refcount
* logging which walk the stack extremely frequently.
*/
static void WalkTheStackCached(FILE* aStream);
/**
* Tell nsTraceRefcnt whether refcounting, allocation, and destruction
* activity is legal. This is used to trigger assertions for any such
* activity that occurs because of static constructors or destructors.
*/
static void SetActivityIsLegal(bool aLegal);
};
#define NS_TRACE_REFCNT_CONTRACTID "@mozilla.org/xpcom/trace-refcnt;1"
#define NS_TRACE_REFCNT_CID \
{ /* e3e7511e-a395-4924-94b1-d527861cded4 */ \
0xe3e7511e, \
0xa395, \
0x4924, \
{0x94, 0xb1, 0xd5, 0x27, 0x86, 0x1c, 0xde, 0xd4} \
} \
////////////////////////////////////////////////////////////////////////////////
// And now for that utility that you've all been asking for...
extern "C" void
NS_MeanAndStdDev(double aNumberOfValues,
double aSumOfValues, double aSumOfSquaredValues,
double* aMeanResult, double* aStdDevResult);
////////////////////////////////////////////////////////////////////////////////
#endif
# vim:set ts=8 sw=8 sts=8 noet:
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# This makefile just builds support for reading archives.
include $(topsrcdir)/config/rules.mk
# The intermediate (.ii/.s) files for host and target can have the same name...
# disable parallel builds
.NOTPARALLEL:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MAR_H__
#define MAR_H__
#include "mozilla/Assertions.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* We have a MAX_SIGNATURES limit so that an invalid MAR will never
* waste too much of either updater's or signmar's time.
* It is also used at various places internally and will affect memory usage.
* If you want to increase this value above 9 then you need to adjust parsing
* code in tool/mar.c.
*/
#define MAX_SIGNATURES 8
#ifdef __cplusplus
static_assert(MAX_SIGNATURES <= 9, "too many signatures");
#else
MOZ_STATIC_ASSERT(MAX_SIGNATURES <= 9, "too many signatures");
#endif
struct ProductInformationBlock {
const char *MARChannelID;
const char *productVersion;
};
/**
* The MAR item data structure.
*/
typedef struct MarItem_ {
struct MarItem_ *next; /* private field */
uint32_t offset; /* offset into archive */
uint32_t length; /* length of data in bytes */
uint32_t flags; /* contains file mode bits */
char name[1]; /* file path */
} MarItem;
#define TABLESIZE 256
struct MarFile_ {
FILE *fp;
MarItem *item_table[TABLESIZE];
};
typedef struct MarFile_ MarFile;
/**
* Signature of callback function passed to mar_enum_items.
* @param mar The MAR file being visited.
* @param item The MAR item being visited.
* @param data The data parameter passed by the caller of mar_enum_items.
* @return A non-zero value to stop enumerating.
*/
typedef int (* MarItemCallback)(MarFile *mar, const MarItem *item, void *data);
/**
* Open a MAR file for reading.
* @param path Specifies the path to the MAR file to open. This path must
* be compatible with fopen.
* @return NULL if an error occurs.
*/
MarFile *mar_open(const char *path);
#ifdef XP_WIN
MarFile *mar_wopen(const wchar_t *path);
#endif
/**
* Close a MAR file that was opened using mar_open.
* @param mar The MarFile object to close.
*/
void mar_close(MarFile *mar);
/**
* Find an item in the MAR file by name.
* @param mar The MarFile object to query.
* @param item The name of the item to query.
* @return A const reference to a MAR item or NULL if not found.
*/
const MarItem *mar_find_item(MarFile *mar, const char *item);
/**
* Enumerate all MAR items via callback function.
* @param mar The MAR file to enumerate.
* @param callback The function to call for each MAR item.
* @param data A caller specified value that is passed along to the
* callback function.
* @return 0 if the enumeration ran to completion. Otherwise, any
* non-zero return value from the callback is returned.
*/
int mar_enum_items(MarFile *mar, MarItemCallback callback, void *data);
/**
* Read from MAR item at given offset up to bufsize bytes.
* @param mar The MAR file to read.
* @param item The MAR item to read.
* @param offset The byte offset relative to the start of the item.
* @param buf A pointer to a buffer to copy the data into.
* @param bufsize The length of the buffer to copy the data into.
* @return The number of bytes written or a negative value if an
* error occurs.
*/
int mar_read(MarFile *mar, const MarItem *item, int offset, char *buf,
int bufsize);
/**
* Create a MAR file from a set of files.
* @param dest The path to the file to create. This path must be
* compatible with fopen.
* @param numfiles The number of files to store in the archive.
* @param files The list of null-terminated file paths. Each file
* path must be compatible with fopen.
* @param infoBlock The information to store in the product information block.
* @return A non-zero value if an error occurs.
*/
int mar_create(const char *dest,
int numfiles,
char **files,
struct ProductInformationBlock *infoBlock);
/**
* Extract a MAR file to the current working directory.
* @param path The path to the MAR file to extract. This path must be
* compatible with fopen.
* @return A non-zero value if an error occurs.
*/
int mar_extract(const char *path);
#define MAR_MAX_CERT_SIZE (16*1024) // Way larger than necessary
/* Read the entire file (not a MAR file) into a newly-allocated buffer.
* This function does not write to stderr. Instead, the caller should
* write whatever error messages it sees fit. The caller must free the returned
* buffer using free().
*
* @param filePath The path to the file that should be read.
* @param maxSize The maximum valid file size.
* @param data On success, *data will point to a newly-allocated buffer
* with the file's contents in it.
* @param size On success, *size will be the size of the created buffer.
*
* @return 0 on success, -1 on error
*/
int mar_read_entire_file(const char * filePath,
uint32_t maxSize,
/*out*/ const uint8_t * *data,
/*out*/ uint32_t *size);
/**
* Verifies a MAR file by verifying each signature with the corresponding
* certificate. That is, the first signature will be verified using the first
* certificate given, the second signature will be verified using the second
* certificate given, etc. The signature count must exactly match the number of
* certificates given, and all signature verifications must succeed.
* We do not check that the certificate was issued by any trusted authority.
* We assume it to be self-signed. We do not check whether the certificate
* is valid for this usage.
*
* @param mar The already opened MAR file.
* @param certData Pointer to the first element in an array of certificate
* file data.
* @param certDataSizes Pointer to the first element in an array for size of
* the cert data.
* @param certCount The number of elements in certData and certDataSizes
* @return 0 on success
* a negative number if there was an error
* a positive number if the signature does not verify
*/
int mar_verify_signatures(MarFile *mar,
const uint8_t * const *certData,
const uint32_t *certDataSizes,
uint32_t certCount);
/**
* Reads the product info block from the MAR file's additional block section.
* The caller is responsible for freeing the fields in infoBlock
* if the return is successful.
*
* @param infoBlock Out parameter for where to store the result to
* @return 0 on success, -1 on failure
*/
int
mar_read_product_info_block(MarFile *mar,
struct ProductInformationBlock *infoBlock);
#ifdef __cplusplus
}
#endif
#endif /* MAR_H__ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MAR_CMDLINE_H__
#define MAR_CMDLINE_H__
/* We use NSPR here just to import the definition of uint32_t */
#ifdef __cplusplus
extern "C" {
#endif
struct ProductInformationBlock;
/**
* Determines MAR file information.
*
* @param path The path of the MAR file to check.
* @param hasSignatureBlock Optional out parameter specifying if the MAR
* file has a signature block or not.
* @param numSignatures Optional out parameter for storing the number
* of signatures in the MAR file.
* @param hasAdditionalBlocks Optional out parameter specifying if the MAR
* file has additional blocks or not.
* @param offsetAdditionalBlocks Optional out parameter for the offset to the
* first additional block. Value is only valid if
* hasAdditionalBlocks is not equal to 0.
* @param numAdditionalBlocks Optional out parameter for the number of
* additional blocks. Value is only valid if
* has_additional_blocks is not equal to 0.
* @return 0 on success and non-zero on failure.
*/
int get_mar_file_info(const char *path,
int *hasSignatureBlock,
uint32_t *numSignatures,
int *hasAdditionalBlocks,
uint32_t *offsetAdditionalBlocks,
uint32_t *numAdditionalBlocks);
/**
* Reads the product info block from the MAR file's additional block section.
* The caller is responsible for freeing the fields in infoBlock
* if the return is successful.
*
* @param infoBlock Out parameter for where to store the result to
* @return 0 on success, -1 on failure
*/
int
read_product_info_block(char *path,
struct ProductInformationBlock *infoBlock);
/**
* Refreshes the product information block with the new information.
* The input MAR must not be signed or the function call will fail.
*
* @param path The path to the MAR file whose product info block
* should be refreshed.
* @param infoBlock Out parameter for where to store the result to
* @return 0 on success, -1 on failure
*/
int
refresh_product_info_block(const char *path,
struct ProductInformationBlock *infoBlock);
/**
* Writes out a copy of the MAR at src but with the signature block stripped.
*
* @param src The path of the source MAR file
* @param dest The path of the MAR file to write out that
has no signature block
* @return 0 on success
* -1 on error
*/
int
strip_signature_block(const char *src, const char * dest);
/**
* Extracts a signature from a MAR file, base64 encodes it, and writes it out
*
* @param src The path of the source MAR file
* @param sigIndex The index of the signature to extract
* @param dest The path of file to write the signature to
* @return 0 on success
* -1 on error
*/
int
extract_signature(const char *src, uint32_t sigIndex, const char * dest);
/**
* Imports a base64 encoded signature into a MAR file
*
* @param src The path of the source MAR file
* @param sigIndex The index of the signature to import
* @param base64SigFile A file which contains the signature to import
* @param dest The path of the destination MAR file with replaced signature
* @return 0 on success
* -1 on error
*/
int
import_signature(const char *src,
uint32_t sigIndex,
const char * base64SigFile,
const char *dest);
#ifdef __cplusplus
}
#endif
#endif /* MAR_CMDLINE_H__ */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include "mar_private.h"
#include "mar.h"
#ifdef XP_WIN
#include <io.h>
#include <direct.h>
#endif
/* Ensure that the directory containing this file exists */
static int mar_ensure_parent_dir(const char *path)
{
char *slash = strrchr(path, '/');
if (slash)
{
*slash = '\0';
mar_ensure_parent_dir(path);
#ifdef XP_WIN
_mkdir(path);
#else
mkdir(path, 0755);
#endif
*slash = '/';
}
return 0;
}
static int mar_test_callback(MarFile *mar, const MarItem *item, void *unused) {
FILE *fp;
char buf[BLOCKSIZE];
int fd, len, offset = 0;
if (mar_ensure_parent_dir(item->name))
return -1;
#ifdef XP_WIN
fd = _open(item->name, _O_BINARY|_O_CREAT|_O_TRUNC|_O_WRONLY, item->flags);
#else
fd = creat(item->name, item->flags);
#endif
if (fd == -1) {
fprintf(stderr, "ERROR: could not create file in mar_test_callback()\n");
perror(item->name);
return -1;
}
fp = fdopen(fd, "wb");
if (!fp)
return -1;
while ((len = mar_read(mar, item, offset, buf, sizeof(buf))) > 0) {
if (fwrite(buf, len, 1, fp) != 1)
break;
offset += len;
}
fclose(fp);
return len == 0 ? 0 : -1;
}
int mar_extract(const char *path) {
MarFile *mar;
int rv;
mar = mar_open(path);
if (!mar)
return -1;
rv = mar_enum_items(mar, mar_test_callback, NULL);
mar_close(mar);
return rv;
}
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MAR_PRIVATE_H__
#define MAR_PRIVATE_H__
#include "limits.h"
#include "mozilla/Assertions.h"
#include <stdint.h>
#define BLOCKSIZE 4096
#define ROUND_UP(n, incr) (((n) / (incr) + 1) * (incr))
#define MAR_ID "MAR1"
#define MAR_ID_SIZE 4
/* The signature block comes directly after the header block
which is 16 bytes */
#define SIGNATURE_BLOCK_OFFSET 16
/* Make sure the file is less than 500MB. We do this to protect against
invalid MAR files. */
#define MAX_SIZE_OF_MAR_FILE ((int64_t)524288000)
/* Existing code makes assumptions that the file size is
smaller than LONG_MAX. */
MOZ_STATIC_ASSERT(MAX_SIZE_OF_MAR_FILE < ((int64_t)LONG_MAX),
"max mar file size is too big");
/* We store at most the size up to the signature block + 4
bytes per BLOCKSIZE bytes */
MOZ_STATIC_ASSERT(sizeof(BLOCKSIZE) < \
(SIGNATURE_BLOCK_OFFSET + sizeof(uint32_t)),
"BLOCKSIZE is too big");
/* The maximum size of any signature supported by current and future
implementations of the signmar program. */
#define MAX_SIGNATURE_LENGTH 2048
/* Each additional block has a unique ID.
The product information block has an ID of 1. */
#define PRODUCT_INFO_BLOCK_ID 1
#define MAR_ITEM_SIZE(namelen) (3*sizeof(uint32_t) + (namelen) + 1)
/* Product Information Block (PIB) constants */
#define PIB_MAX_MAR_CHANNEL_ID_SIZE 63
#define PIB_MAX_PRODUCT_VERSION_SIZE 31
/* The mar program is compiled as a host bin so we don't have access to NSPR at
runtime. For that reason we use ntohl, htonl, and define HOST_TO_NETWORK64
instead of the NSPR equivalents. */
#ifdef XP_WIN
#include <winsock2.h>
#define ftello _ftelli64
#define fseeko _fseeki64
#else
#define _FILE_OFFSET_BITS 64
#include <netinet/in.h>
#include <unistd.h>
#endif
#include <stdio.h>
#define HOST_TO_NETWORK64(x) ( \
((((uint64_t) x) & 0xFF) << 56) | \
((((uint64_t) x) >> 8) & 0xFF) << 48) | \
(((((uint64_t) x) >> 16) & 0xFF) << 40) | \
(((((uint64_t) x) >> 24) & 0xFF) << 32) | \
(((((uint64_t) x) >> 32) & 0xFF) << 24) | \
(((((uint64_t) x) >> 40) & 0xFF) << 16) | \
(((((uint64_t) x) >> 48) & 0xFF) << 8) | \
(((uint64_t) x) >> 56)
#define NETWORK_TO_HOST64 HOST_TO_NETWORK64
#endif /* MAR_PRIVATE_H__ */
This diff is collapsed.
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS += [
'mar.h',
'mar_cmdline.h',
]
HOST_SOURCES += [
'mar_create.c',
'mar_extract.c',
'mar_read.c',
]
HostLibrary('hostmar')
Library('mar')
UNIFIED_SOURCES += [
'mar_create.c',
'mar_extract.c',
'mar_read.c',
]
FORCE_STATIC_LIB = True
if CONFIG['OS_ARCH'] == 'WINNT':
USE_STATIC_LIBS = True
......@@ -10,7 +10,7 @@
#include "bzlib.h"
#include "archivereader.h"
#include "errors.h"
#ifdef XP_WIN
#ifdef WNT
#include "nsAlgorithm.h" // Needed by nsVersionComparator.cpp
#include "updatehelper.h"
#endif
......@@ -27,12 +27,12 @@
#endif
#define UPDATER_NO_STRING_GLUE_STL
#include "nsVersionComparator.cpp"
#include "nsVersionComparator.h"
#undef UPDATER_NO_STRING_GLUE_STL
#if defined(XP_UNIX)
#if defined(UNIX)
# include <sys/types.h>
#elif defined(XP_WIN)
#elif defined(WNT)
# include <io.h>
#endif
......@@ -203,7 +203,7 @@ ArchiveReader::Open(const NS_tchar *path)
}
}
#ifdef XP_WIN
#ifdef WNT
mArchive = mar_wopen(path);
#else
mArchive = mar_open(path);
......@@ -240,7 +240,7 @@ ArchiveReader::ExtractFile(const char *name, const NS_tchar *dest)
if (!item)
return READ_ERROR;
#ifdef XP_WIN
#ifdef WNT
FILE* fp = _wfopen(dest, L"wb+");
#else
int fd = creat(dest, item->flags);
......
......@@ -10,7 +10,7 @@
#include <stdio.h>
#include "mar.h"
#ifdef XP_WIN
#ifdef WNT
typedef WCHAR NS_tchar;
#else
typedef char NS_tchar;
......
......@@ -39,13 +39,13 @@
#include <string.h>
#include <limits.h>
#if defined(XP_WIN)
#if defined(WNT)
# include <io.h>
#else
# include <unistd.h>
#endif
#ifdef XP_WIN
#ifdef WNT
# include <winsock2.h>
#else
# include <arpa/inet.h>
......
......@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef WNT
#include <windows.h>
// Delayed load libraries are loaded when the first symbol is used.
......@@ -101,3 +103,4 @@ struct AutoLoadSystemDependencies
}
}
} loadDLLs;
#endif
......@@ -9,7 +9,7 @@
#include "updatedefines.h"
#if defined(XP_WIN)
#if defined(WNT)
typedef WCHAR NS_tchar;
#define NS_main wmain
#else
......@@ -20,7 +20,7 @@
// Called to perform any initialization of the widget toolkit
int InitProgressUI(int *argc, NS_tchar ***argv);
#if defined(XP_WIN)
#if defined(WNT)
// Called on the main thread at startup
int ShowProgressUI(bool indeterminate = false, bool initUIStrings = true);
int InitProgressUIStrings();
......
......@@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if defined(UNIX) || defined(MACOSX)
#include <stdio.h>
#include <gtk/gtk.h>
#include <unistd.h>
......@@ -129,3 +130,4 @@ UpdateProgressUI(float progress)
{
sProgressVal = progress; // 32-bit writes are atomic
}
#endif // defined(UNIX) || defined(MACOSX)
......@@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined(MACOSX) && !defined(UNIX) && !defined(WNT)
#include "progressui.h"
int InitProgressUI(int *argc, char ***argv)
......@@ -23,3 +24,4 @@ void QuitProgressUI()
void UpdateProgressUI(float progress)
{
}
#endif // !defined(MACOSX) && !defined(UNIX) && !defined(WNT)
......@@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef WNT
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
......@@ -317,3 +318,4 @@ UpdateProgressUI(float progress)
{
sProgress = progress; // 32-bit writes are atomic
}
#endif // WNT
......@@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef WNT
#include "win_dirent.h"
#include <errno.h>
#include <string.h>
......@@ -75,4 +76,4 @@ dirent* readdir(DIR* dir)
sizeof(gDirEnt.d_name)/sizeof(gDirEnt.d_name[0]));
return &gDirEnt;
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment