summaryrefslogtreecommitdiffstats
path: root/other-licenses
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /other-licenses
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'other-licenses')
-rw-r--r--other-licenses/README8
-rw-r--r--other-licenses/atk-1.0/atk/atk-enum-types.h41
-rw-r--r--other-licenses/atk-1.0/atk/atk.h62
-rw-r--r--other-licenses/atk-1.0/atk/atkaction.h112
-rw-r--r--other-licenses/atk-1.0/atk/atkcomponent.h221
-rw-r--r--other-licenses/atk-1.0/atk/atkdocument.h80
-rw-r--r--other-licenses/atk-1.0/atk/atkeditabletext.h105
-rw-r--r--other-licenses/atk-1.0/atk/atkgobjectaccessible.h67
-rw-r--r--other-licenses/atk-1.0/atk/atkhyperlink.h106
-rw-r--r--other-licenses/atk-1.0/atk/atkhyperlinkimpl.h76
-rw-r--r--other-licenses/atk-1.0/atk/atkhypertext.h80
-rw-r--r--other-licenses/atk-1.0/atk/atkimage.h86
-rw-r--r--other-licenses/atk-1.0/atk/atknoopobject.h51
-rw-r--r--other-licenses/atk-1.0/atk/atknoopobjectfactory.h58
-rw-r--r--other-licenses/atk-1.0/atk/atkobject.h875
-rw-r--r--other-licenses/atk-1.0/atk/atkobjectfactory.h68
-rw-r--r--other-licenses/atk-1.0/atk/atkplug.h61
-rw-r--r--other-licenses/atk-1.0/atk/atkregistry.h69
-rw-r--r--other-licenses/atk-1.0/atk/atkrelation.h88
-rw-r--r--other-licenses/atk-1.0/atk/atkrelationset.h79
-rw-r--r--other-licenses/atk-1.0/atk/atkrelationtype.h115
-rw-r--r--other-licenses/atk-1.0/atk/atkselection.h96
-rw-r--r--other-licenses/atk-1.0/atk/atksocket.h65
-rw-r--r--other-licenses/atk-1.0/atk/atkstate.h198
-rw-r--r--other-licenses/atk-1.0/atk/atkstateset.h81
-rw-r--r--other-licenses/atk-1.0/atk/atkstreamablecontent.h107
-rw-r--r--other-licenses/atk-1.0/atk/atktable.h218
-rw-r--r--other-licenses/atk-1.0/atk/atktablecell.h104
-rw-r--r--other-licenses/atk-1.0/atk/atktext.h436
-rw-r--r--other-licenses/atk-1.0/atk/atkutil.h245
-rw-r--r--other-licenses/atk-1.0/atk/atkvalue.h95
-rw-r--r--other-licenses/bsdiff/LICENSE121
-rw-r--r--other-licenses/bsdiff/bsdiff.c411
-rw-r--r--other-licenses/bsdiff/moz.build22
-rw-r--r--other-licenses/ia2/Accessible2.idl694
-rw-r--r--other-licenses/ia2/Accessible2_2.idl123
-rw-r--r--other-licenses/ia2/Accessible2_3.idl50
-rw-r--r--other-licenses/ia2/AccessibleAction.idl220
-rw-r--r--other-licenses/ia2/AccessibleApplication.idl121
-rw-r--r--other-licenses/ia2/AccessibleComponent.idl124
-rw-r--r--other-licenses/ia2/AccessibleDocument.idl78
-rw-r--r--other-licenses/ia2/AccessibleEditableText.idl262
-rw-r--r--other-licenses/ia2/AccessibleEventId.idl235
-rw-r--r--other-licenses/ia2/AccessibleHyperlink.idl187
-rw-r--r--other-licenses/ia2/AccessibleHypertext.idl123
-rw-r--r--other-licenses/ia2/AccessibleHypertext2.idl87
-rw-r--r--other-licenses/ia2/AccessibleImage.idl111
-rw-r--r--other-licenses/ia2/AccessibleRelation.idl245
-rw-r--r--other-licenses/ia2/AccessibleRole.idl348
-rw-r--r--other-licenses/ia2/AccessibleStates.idl209
-rw-r--r--other-licenses/ia2/AccessibleTable.idl551
-rw-r--r--other-licenses/ia2/AccessibleTable2.idl377
-rw-r--r--other-licenses/ia2/AccessibleTableCell.idl194
-rw-r--r--other-licenses/ia2/AccessibleText.idl701
-rw-r--r--other-licenses/ia2/AccessibleText2.idl98
-rw-r--r--other-licenses/ia2/AccessibleValue.idl136
-rw-r--r--other-licenses/ia2/IA2CommonTypes.idl191
-rw-r--r--other-licenses/ia2/IA2TypeLibrary.idl99
-rw-r--r--other-licenses/moz.build29
-rw-r--r--other-licenses/nsis/Contrib/ApplicationID/ApplicationID.vcproj206
-rw-r--r--other-licenses/nsis/Contrib/ApplicationID/Set.cpp219
-rw-r--r--other-licenses/nsis/Contrib/BitsUtils/BitsUtils.cpp317
-rw-r--r--other-licenses/nsis/Contrib/BitsUtils/BitsUtils.sln22
-rw-r--r--other-licenses/nsis/Contrib/BitsUtils/BitsUtils.vcxproj62
-rw-r--r--other-licenses/nsis/Contrib/CertCheck/CertCheck.cpp411
-rw-r--r--other-licenses/nsis/Contrib/CertCheck/CertCheck.sln31
-rw-r--r--other-licenses/nsis/Contrib/CertCheck/CertCheck.vcxproj169
-rw-r--r--other-licenses/nsis/Contrib/CityHash/CityHash.cpp82
-rw-r--r--other-licenses/nsis/Contrib/CityHash/CityHash.def3
-rw-r--r--other-licenses/nsis/Contrib/CityHash/CityHash.dsp159
-rw-r--r--other-licenses/nsis/Contrib/CityHash/CityHash.dsw29
-rwxr-xr-xother-licenses/nsis/Contrib/CityHash/CityHash.h31
-rw-r--r--other-licenses/nsis/Contrib/CityHash/CityHash.vcproj223
-rwxr-xr-xother-licenses/nsis/Contrib/CityHash/cityhash/city.cpp322
-rw-r--r--other-licenses/nsis/Contrib/CityHash/cityhash/city.h98
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/SConscript25
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/exdll.c44
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/exdll.dpr118
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/exdll.dsp111
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/exdll.dsw29
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/exdll.h234
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/exdll_with_unit.dpr31
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp131
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/exdllutil.h119
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/extdll.inc145
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/nsis.pas126
-rw-r--r--other-licenses/nsis/Contrib/ExDLL/tchar.h210
-rw-r--r--other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.cpp212
-rw-r--r--other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.sln31
-rw-r--r--other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.vcxproj175
-rw-r--r--other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.cpp304
-rw-r--r--other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.sln22
-rw-r--r--other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.vcxproj63
-rw-r--r--other-licenses/nsis/Contrib/HttpPostFile/test/postdriver.nsi63
-rw-r--r--other-licenses/nsis/Contrib/HttpPostFile/test/unittest.py247
-rw-r--r--other-licenses/nsis/Contrib/InetBgDL/InetBgDL.cpp739
-rw-r--r--other-licenses/nsis/Contrib/InetBgDL/InetBgDL.h59
-rw-r--r--other-licenses/nsis/Contrib/InetBgDL/InetBgDl.sln25
-rw-r--r--other-licenses/nsis/Contrib/InetBgDL/InetBgDl.vcxproj108
-rw-r--r--other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.cpp150
-rw-r--r--other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.sln31
-rw-r--r--other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.vcxproj175
-rw-r--r--other-licenses/nsis/Contrib/README34
-rw-r--r--other-licenses/nsis/Contrib/ServicesHelper/Services.cpp241
-rw-r--r--other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.dsp115
-rw-r--r--other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.dsw29
-rw-r--r--other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.sln20
-rw-r--r--other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.vcproj212
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/CustomFunctions.cpp75
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/Timers.cpp59
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/WebBrowser.cpp604
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/WebBrowser.h250
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/WebBrowser.sln25
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/WebBrowser.vcxproj160
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/exdll.cpp30
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/exdll.h76
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/main.cpp199
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/resource.h5
-rw-r--r--other-licenses/nsis/Contrib/WebBrowser/resource.rc14
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/License.txt17
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/ReadMe.txt39
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/Sample.nsi25
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/exdll.h97
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/liteFirewall.cpp408
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/liteFirewall.dsp204
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/liteFirewall.dsw29
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/liteFirewall.sln23
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/liteFirewall.vcproj390
-rw-r--r--other-licenses/nsis/Contrib/liteFirewall/netfw.tlbbin0 -> 12184 bytes
-rw-r--r--other-licenses/snappy/README26
-rw-r--r--other-licenses/snappy/moz.build33
-rw-r--r--other-licenses/snappy/snappy-stubs-public.h56
-rw-r--r--other-licenses/snappy/src/AUTHORS1
-rw-r--r--other-licenses/snappy/src/CONTRIBUTING.md46
-rw-r--r--other-licenses/snappy/src/COPYING54
-rw-r--r--other-licenses/snappy/src/NEWS194
-rw-r--r--other-licenses/snappy/src/README.md140
-rw-r--r--other-licenses/snappy/src/format_description.txt110
-rw-r--r--other-licenses/snappy/src/framing_format.txt135
-rw-r--r--other-licenses/snappy/src/snappy-c.cc90
-rw-r--r--other-licenses/snappy/src/snappy-c.h138
-rw-r--r--other-licenses/snappy/src/snappy-internal.h317
-rw-r--r--other-licenses/snappy/src/snappy-sinksource.cc121
-rw-r--r--other-licenses/snappy/src/snappy-sinksource.h182
-rw-r--r--other-licenses/snappy/src/snappy-stubs-internal.cc42
-rw-r--r--other-licenses/snappy/src/snappy-stubs-internal.h492
-rw-r--r--other-licenses/snappy/src/snappy-stubs-public.h.in63
-rw-r--r--other-licenses/snappy/src/snappy-test.cc503
-rw-r--r--other-licenses/snappy/src/snappy-test.h342
-rw-r--r--other-licenses/snappy/src/snappy.cc2193
-rw-r--r--other-licenses/snappy/src/snappy.h209
-rw-r--r--other-licenses/snappy/src/snappy_compress_fuzzer.cc60
-rw-r--r--other-licenses/snappy/src/snappy_uncompress_fuzzer.cc58
-rw-r--r--other-licenses/snappy/src/snappy_unittest.cc966
154 files changed, 26362 insertions, 0 deletions
diff --git a/other-licenses/README b/other-licenses/README
new file mode 100644
index 0000000000..03de0ff209
--- /dev/null
+++ b/other-licenses/README
@@ -0,0 +1,8 @@
+This directory was created for code which is used in the Mozilla project in
+some way but is not under the MPL or a compatible license like the Apache 2,
+BSD or MIT licenses.
+
+It is _NOT_ for "all non-MPLed code".
+
+Before putting any new code in here, please consult licensing@mozilla.org. It
+is quite likely that this is not the right place.
diff --git a/other-licenses/atk-1.0/atk/atk-enum-types.h b/other-licenses/atk-1.0/atk/atk-enum-types.h
new file mode 100644
index 0000000000..f95e70a67b
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atk-enum-types.h
@@ -0,0 +1,41 @@
+
+/* Generated data (by glib-mkenums) */
+
+#ifndef __ATK_ENUM_TYPES_H__
+#define __ATK_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/* enumerations from "atkhyperlink.h" */
+GType atk_hyperlink_state_flags_get_type (void);
+#define ATK_TYPE_HYPERLINK_STATE_FLAGS (atk_hyperlink_state_flags_get_type())
+/* enumerations from "atkobject.h" */
+GType atk_role_get_type (void);
+#define ATK_TYPE_ROLE (atk_role_get_type())
+GType atk_layer_get_type (void);
+#define ATK_TYPE_LAYER (atk_layer_get_type())
+/* enumerations from "atkrelationtype.h" */
+GType atk_relation_type_get_type (void);
+#define ATK_TYPE_RELATION_TYPE (atk_relation_type_get_type())
+/* enumerations from "atkstate.h" */
+GType atk_state_type_get_type (void);
+#define ATK_TYPE_STATE_TYPE (atk_state_type_get_type())
+/* enumerations from "atktext.h" */
+GType atk_text_attribute_get_type (void);
+#define ATK_TYPE_TEXT_ATTRIBUTE (atk_text_attribute_get_type())
+GType atk_text_boundary_get_type (void);
+#define ATK_TYPE_TEXT_BOUNDARY (atk_text_boundary_get_type())
+GType atk_text_clip_type_get_type (void);
+#define ATK_TYPE_TEXT_CLIP_TYPE (atk_text_clip_type_get_type())
+/* enumerations from "atkutil.h" */
+GType atk_key_event_type_get_type (void);
+#define ATK_TYPE_KEY_EVENT_TYPE (atk_key_event_type_get_type())
+GType atk_coord_type_get_type (void);
+#define ATK_TYPE_COORD_TYPE (atk_coord_type_get_type())
+G_END_DECLS
+
+#endif /* __ATK_ENUM_TYPES_H__ */
+
+/* Generated data ends here */
+
diff --git a/other-licenses/atk-1.0/atk/atk.h b/other-licenses/atk-1.0/atk/atk.h
new file mode 100644
index 0000000000..39cec7f055
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atk.h
@@ -0,0 +1,62 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_H__
+#define __ATK_H__
+
+#define __ATK_H_INSIDE__
+
+// XXX this is a Mozilla hack to avoid using atkversion.h which needs to be run
+// through m4, and we don't want to deal with that. Fortunately we don't need
+// any of the fancyness in that header to deal with compile time version
+// detection.
+#define ATK_AVAILABLE_IN_2_12 extern
+
+#include <atk/atkobject.h>
+#include <atk/atkaction.h>
+#include <atk/atkcomponent.h>
+#include <atk/atkdocument.h>
+#include <atk/atkeditabletext.h>
+#include <atk/atkgobjectaccessible.h>
+#include <atk/atkhyperlink.h>
+#include <atk/atkhyperlinkimpl.h>
+#include <atk/atkhypertext.h>
+#include <atk/atkimage.h>
+#include <atk/atknoopobject.h>
+#include <atk/atknoopobjectfactory.h>
+#include <atk/atkobjectfactory.h>
+#include <atk/atkplug.h>
+#include <atk/atkregistry.h>
+#include <atk/atkrelation.h>
+#include <atk/atkrelationset.h>
+#include <atk/atkrelationtype.h>
+#include <atk/atkselection.h>
+#include <atk/atksocket.h>
+#include <atk/atkstate.h>
+#include <atk/atkstateset.h>
+#include <atk/atkstreamablecontent.h>
+#include <atk/atktable.h>
+#include <atk/atktablecell.h>
+#include <atk/atktext.h>
+#include <atk/atkutil.h>
+#include <atk/atkvalue.h>
+
+#undef __ATK_H_INSIDE__
+
+#endif /* __ATK_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkaction.h b/other-licenses/atk-1.0/atk/atkaction.h
new file mode 100644
index 0000000000..8dfee9fe1e
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkaction.h
@@ -0,0 +1,112 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_ACTION_H__
+#define __ATK_ACTION_H__
+
+#include <atk/atkobject.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * The interface AtkAction should be supported by any object that can
+ * perform one or more actions. The interface provides the standard
+ * mechanism for an assistive technology to determine what those actions
+ * are as well as tell the object to perform them. Any object that can
+ * be manipulated should support this interface.
+ */
+
+
+#define ATK_TYPE_ACTION (atk_action_get_type ())
+#define ATK_IS_ACTION(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_ACTION)
+#define ATK_ACTION(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_ACTION, AtkAction)
+#define ATK_ACTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_ACTION, AtkActionIface))
+
+#ifndef _TYPEDEF_ATK_ACTION_
+#define _TYPEDEF_ATK_ACTION_
+typedef struct _AtkAction AtkAction;
+#endif
+typedef struct _AtkActionIface AtkActionIface;
+
+struct _AtkActionIface
+{
+ GTypeInterface parent;
+
+ gboolean (*do_action) (AtkAction *action,
+ gint i);
+ gint (*get_n_actions) (AtkAction *action);
+ G_CONST_RETURN gchar* (*get_description) (AtkAction *action,
+ gint i);
+ G_CONST_RETURN gchar* (*get_name) (AtkAction *action,
+ gint i);
+ G_CONST_RETURN gchar* (*get_keybinding) (AtkAction *action,
+ gint i);
+ gboolean (*set_description) (AtkAction *action,
+ gint i,
+ const gchar *desc);
+ G_CONST_RETURN gchar* (*get_localized_name)(AtkAction *action,
+ gint i);
+ AtkFunction pad2;
+};
+
+GType atk_action_get_type (void);
+
+/*
+ * These are the function which would be called by an application with
+ * the argument being a AtkObject object cast to (AtkAction).
+ *
+ * The function will just check that * the corresponding
+ * function pointer is not NULL and will call it.
+ *
+ * The "real" implementation of the function for accessible will be
+ * provided in a support library
+ */
+
+gboolean atk_action_do_action (AtkAction *action,
+ gint i);
+gint atk_action_get_n_actions (AtkAction *action);
+G_CONST_RETURN gchar* atk_action_get_description (AtkAction *action,
+ gint i);
+G_CONST_RETURN gchar* atk_action_get_name (AtkAction *action,
+ gint i);
+G_CONST_RETURN gchar* atk_action_get_keybinding (AtkAction *action,
+ gint i);
+gboolean atk_action_set_description (AtkAction *action,
+ gint i,
+ const gchar *desc);
+
+/* NEW in ATK 1.1: */
+
+G_CONST_RETURN gchar* atk_action_get_localized_name (AtkAction *action,
+ gint i);
+
+/*
+ * Additional GObject properties exported by AtkAction:
+ * "accessible_action"
+ * (an accessible action, or the list of actions, has changed)
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_ACTION_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkcomponent.h b/other-licenses/atk-1.0/atk/atkcomponent.h
new file mode 100644
index 0000000000..b0e14ca143
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkcomponent.h
@@ -0,0 +1,221 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_COMPONENT_H__
+#define __ATK_COMPONENT_H__
+
+#include <atk/atkobject.h>
+#include <atk/atkutil.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ *AtkScrollType:
+ *@ATK_SCROLL_TOP_LEFT: Scroll the object vertically and horizontally to the top
+ *left corner of the window.
+ *@ATK_SCROLL_BOTTOM_RIGHT: Scroll the object vertically and horizontally to the
+ *bottom right corner of the window.
+ *@ATK_SCROLL_TOP_EDGE: Scroll the object vertically to the top edge of the
+ window.
+ *@ATK_SCROLL_BOTTOM_EDGE: Scroll the object vertically to the bottom edge of
+ *the window.
+ *@ATK_SCROLL_LEFT_EDGE: Scroll the object vertically and horizontally to the
+ *left edge of the window.
+ *@ATK_SCROLL_RIGHT_EDGE: Scroll the object vertically and horizontally to the
+ *right edge of the window.
+ *@ATK_SCROLL_ANYWHERE: Scroll the object vertically and horizontally so that
+ *as much as possible of the object becomes visible. The exact placement is
+ *determined by the application.
+ *
+ * Specifies where an object should be placed on the screen when using scroll_to.
+ **/
+typedef enum {
+ ATK_SCROLL_TOP_LEFT,
+ ATK_SCROLL_BOTTOM_RIGHT,
+ ATK_SCROLL_TOP_EDGE,
+ ATK_SCROLL_BOTTOM_EDGE,
+ ATK_SCROLL_LEFT_EDGE,
+ ATK_SCROLL_RIGHT_EDGE,
+ ATK_SCROLL_ANYWHERE
+} AtkScrollType;
+
+/*
+ * The AtkComponent interface should be supported by any object that is
+ * rendered on the screen. The interface provides the standard mechanism
+ * for an assistive technology to determine and set the graphical
+ * representation of an object.
+ */
+
+#define ATK_TYPE_COMPONENT (atk_component_get_type ())
+#define ATK_IS_COMPONENT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_COMPONENT)
+#define ATK_COMPONENT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_COMPONENT, AtkComponent)
+#define ATK_COMPONENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_COMPONENT, AtkComponentIface))
+
+#ifndef _TYPEDEF_ATK_COMPONENT_
+#define _TYPEDEF_ATK_COMPONENT_
+typedef struct _AtkComponent AtkComponent;
+#endif
+typedef struct _AtkComponentIface AtkComponentIface;
+
+typedef void (*AtkFocusHandler) (AtkObject*, gboolean);
+
+typedef struct _AtkRectangle AtkRectangle;
+
+struct _AtkRectangle
+{
+ gint x;
+ gint y;
+ gint width;
+ gint height;
+};
+
+GType atk_rectangle_get_type (void);
+
+#define ATK_TYPE_RECTANGLE (atk_rectangle_get_type ())
+struct _AtkComponentIface
+{
+ GTypeInterface parent;
+
+ guint (* add_focus_handler) (AtkComponent *component,
+ AtkFocusHandler handler);
+
+ gboolean (* contains) (AtkComponent *component,
+ gint x,
+ gint y,
+ AtkCoordType coord_type);
+
+ AtkObject* (* ref_accessible_at_point) (AtkComponent *component,
+ gint x,
+ gint y,
+ AtkCoordType coord_type);
+ void (* get_extents) (AtkComponent *component,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtkCoordType coord_type);
+ void (* get_position) (AtkComponent *component,
+ gint *x,
+ gint *y,
+ AtkCoordType coord_type);
+ void (* get_size) (AtkComponent *component,
+ gint *width,
+ gint *height);
+ gboolean (* grab_focus) (AtkComponent *component);
+ void (* remove_focus_handler) (AtkComponent *component,
+ guint handler_id);
+ gboolean (* set_extents) (AtkComponent *component,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ AtkCoordType coord_type);
+ gboolean (* set_position) (AtkComponent *component,
+ gint x,
+ gint y,
+ AtkCoordType coord_type);
+ gboolean (* set_size) (AtkComponent *component,
+ gint width,
+ gint height);
+
+ AtkLayer (* get_layer) (AtkComponent *component);
+ gint (* get_mdi_zorder) (AtkComponent *component);
+
+ /*
+ * signal handlers
+ */
+ void (* bounds_changed) (AtkComponent *component,
+ AtkRectangle *bounds);
+ gdouble (* get_alpha) (AtkComponent *component);
+
+ /*
+ * Scrolls this object so it becomes visible on the screen.
+ * Since ATK 2.30
+ */
+ gboolean (*scroll_to) (AtkComponent *component,
+ AtkScrollType type);
+
+ gboolean (*scroll_to_point) (AtkComponent *component,
+ AtkCoordType coords,
+ gint x,
+ gint y);
+};
+
+GType atk_component_get_type (void);
+
+/* convenience functions */
+
+guint atk_component_add_focus_handler (AtkComponent *component,
+ AtkFocusHandler handler);
+gboolean atk_component_contains (AtkComponent *component,
+ gint x,
+ gint y,
+ AtkCoordType coord_type);
+AtkObject* atk_component_ref_accessible_at_point(AtkComponent *component,
+ gint x,
+ gint y,
+ AtkCoordType coord_type);
+void atk_component_get_extents (AtkComponent *component,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtkCoordType coord_type);
+void atk_component_get_position (AtkComponent *component,
+ gint *x,
+ gint *y,
+ AtkCoordType coord_type);
+void atk_component_get_size (AtkComponent *component,
+ gint *width,
+ gint *height);
+AtkLayer atk_component_get_layer (AtkComponent *component);
+gint atk_component_get_mdi_zorder (AtkComponent *component);
+gboolean atk_component_grab_focus (AtkComponent *component);
+void atk_component_remove_focus_handler (AtkComponent *component,
+ guint handler_id);
+gboolean atk_component_set_extents (AtkComponent *component,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ AtkCoordType coord_type);
+gboolean atk_component_set_position (AtkComponent *component,
+ gint x,
+ gint y,
+ AtkCoordType coord_type);
+gboolean atk_component_set_size (AtkComponent *component,
+ gint width,
+ gint height);
+gdouble atk_component_get_alpha (AtkComponent *component);
+gboolean atk_component_scroll_to (AtkComponent *component,
+ AtkScrollType type);
+
+gboolean atk_component_scroll_to_point (AtkComponent *component,
+ AtkCoordType coords,
+ gint x,
+ gint y);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_COMPONENT_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkdocument.h b/other-licenses/atk-1.0/atk/atkdocument.h
new file mode 100644
index 0000000000..4b83aa93d2
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkdocument.h
@@ -0,0 +1,80 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_DOCUMENT_H__
+#define __ATK_DOCUMENT_H__
+
+#include <atk/atkobject.h>
+#include <atk/atkutil.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * The AtkDocument interface should be supported by any object that is a container
+ * for 'document content' as opposed to a collection of user interface elements.
+ *
+ */
+
+#define ATK_TYPE_DOCUMENT (atk_document_get_type ())
+#define ATK_IS_DOCUMENT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_DOCUMENT)
+#define ATK_DOCUMENT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_DOCUMENT, AtkDocument)
+#define ATK_DOCUMENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_DOCUMENT, AtkDocumentIface))
+
+#ifndef _TYPEDEF_ATK_DOCUMENT_
+#define _TYPEDEF_ATK_DOCUMENT_
+typedef struct _AtkDocument AtkDocument;
+#endif
+typedef struct _AtkDocumentIface AtkDocumentIface;
+
+struct _AtkDocumentIface
+{
+ GTypeInterface parent;
+ G_CONST_RETURN gchar* ( *get_document_type) (AtkDocument *document);
+ gpointer ( *get_document) (AtkDocument *document);
+
+ G_CONST_RETURN gchar* ( *get_document_locale) (AtkDocument *document);
+ AtkAttributeSet * ( *get_document_attributes) (AtkDocument *document);
+ G_CONST_RETURN gchar* ( *get_document_attribute_value) (AtkDocument *document,
+ const gchar *attribute_name);
+ gboolean ( *set_document_attribute) (AtkDocument *document,
+ const gchar *attribute_name,
+ const gchar *attribute_value);
+ AtkFunction pad1;
+ AtkFunction pad2;
+ AtkFunction pad3;
+ AtkFunction pad4;
+};
+
+GType atk_document_get_type (void);
+
+G_CONST_RETURN gchar* atk_document_get_document_type (AtkDocument *document);
+gpointer atk_document_get_document (AtkDocument *document);
+G_CONST_RETURN gchar* atk_document_get_locale (AtkDocument *document);
+AtkAttributeSet* atk_document_get_attributes (AtkDocument *document);
+G_CONST_RETURN gchar* atk_document_get_attribute_value (AtkDocument *document,
+ const gchar *attribute_name);
+gboolean atk_document_set_attribute_value (AtkDocument *document,
+ const gchar *attribute_name,
+ const gchar *attribute_value);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __ATK_DOCUMENT_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkeditabletext.h b/other-licenses/atk-1.0/atk/atkeditabletext.h
new file mode 100644
index 0000000000..02937ff875
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkeditabletext.h
@@ -0,0 +1,105 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_EDITABLE_TEXT_H__
+#define __ATK_EDITABLE_TEXT_H__
+
+#include <atk/atkobject.h>
+#include <atk/atktext.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * AtkEditableText is used to support access in an "accessibility" context
+ * to editing features of editable text widgets.
+ */
+
+#define ATK_TYPE_EDITABLE_TEXT (atk_editable_text_get_type ())
+#define ATK_IS_EDITABLE_TEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_EDITABLE_TEXT)
+#define ATK_EDITABLE_TEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_EDITABLE_TEXT, AtkEditableText)
+#define ATK_EDITABLE_TEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_EDITABLE_TEXT, AtkEditableTextIface))
+
+#ifndef _TYPEDEF_ATK_EDITABLE_TEXT_
+#define _TYPEDEF_ATK_EDITABLE_TEXT_
+typedef struct _AtkEditableText AtkEditableText;
+#endif
+typedef struct _AtkEditableTextIface AtkEditableTextIface;
+
+struct _AtkEditableTextIface
+{
+ GTypeInterface parent_interface;
+
+ gboolean (* set_run_attributes) (AtkEditableText *text,
+ AtkAttributeSet *attrib_set,
+ gint start_offset,
+ gint end_offset);
+ void (* set_text_contents) (AtkEditableText *text,
+ const gchar *string);
+ void (* insert_text) (AtkEditableText *text,
+ const gchar *string,
+ gint length,
+ gint *position);
+ void (* copy_text) (AtkEditableText *text,
+ gint start_pos,
+ gint end_pos);
+ void (* cut_text) (AtkEditableText *text,
+ gint start_pos,
+ gint end_pos);
+ void (* delete_text) (AtkEditableText *text,
+ gint start_pos,
+ gint end_pos);
+ void (* paste_text) (AtkEditableText *text,
+ gint position);
+
+ AtkFunction pad1;
+ AtkFunction pad2;
+};
+GType atk_editable_text_get_type (void);
+
+
+gboolean atk_editable_text_set_run_attributes (AtkEditableText *text,
+ AtkAttributeSet *attrib_set,
+ gint start_offset,
+ gint end_offset);
+void atk_editable_text_set_text_contents (AtkEditableText *text,
+ const gchar *string);
+void atk_editable_text_insert_text (AtkEditableText *text,
+ const gchar *string,
+ gint length,
+ gint *position);
+void atk_editable_text_copy_text (AtkEditableText *text,
+ gint start_pos,
+ gint end_pos);
+void atk_editable_text_cut_text (AtkEditableText *text,
+ gint start_pos,
+ gint end_pos);
+void atk_editable_text_delete_text (AtkEditableText *text,
+ gint start_pos,
+ gint end_pos);
+void atk_editable_text_paste_text (AtkEditableText *text,
+ gint position);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_EDITABLE_TEXT_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkgobjectaccessible.h b/other-licenses/atk-1.0/atk/atkgobjectaccessible.h
new file mode 100644
index 0000000000..adb46cd9a9
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkgobjectaccessible.h
@@ -0,0 +1,67 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_GOBJECT_ACCESSIBLE_H__
+#define __ATK_GOBJECT_ACCESSIBLE_H__
+
+#include <atk/atk.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * The AtkGObjectAccessible class is provided as a basis for implementing
+ * accessibility support for objects which are not GTK+ widgets
+ */
+#define ATK_TYPE_GOBJECT_ACCESSIBLE (atk_gobject_accessible_get_type ())
+#define ATK_GOBJECT_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_GOBJECT_ACCESSIBLE, AtkGObjectAccessible))
+#define ATK_GOBJECT_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_GOBJECT_ACCESSIBLE, AtkGObjectAccessibleClass))
+#define ATK_IS_GOBJECT_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_GOBJECT_ACCESSIBLE))
+#define ATK_IS_GOBJECT_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_GOBJECT_ACCESSIBLE))
+#define ATK_GOBJECT_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_GOBJECT_ACCESSIBLE, AtkGObjectAccessibleClass))
+
+typedef struct _AtkGObjectAccessible AtkGObjectAccessible;
+typedef struct _AtkGObjectAccessibleClass AtkGObjectAccessibleClass;
+
+struct _AtkGObjectAccessible
+{
+ AtkObject parent;
+};
+
+GType atk_gobject_accessible_get_type (void);
+
+struct _AtkGObjectAccessibleClass
+{
+ AtkObjectClass parent_class;
+
+ AtkFunction pad1;
+ AtkFunction pad2;
+};
+
+AtkObject *atk_gobject_accessible_for_object (GObject *obj);
+GObject *atk_gobject_accessible_get_object (AtkGObjectAccessible *obj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_GOBJECT_ACCESSIBLE_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkhyperlink.h b/other-licenses/atk-1.0/atk/atkhyperlink.h
new file mode 100644
index 0000000000..a5d3716f00
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkhyperlink.h
@@ -0,0 +1,106 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_HYPERLINK_H__
+#define __ATK_HYPERLINK_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <atk/atkaction.h>
+
+/*
+ * AtkHyperlink encapsulates a link or set of links in a hypertext document.
+ *
+ * It implements the AtkAction interface.
+ */
+
+/**
+ *AtkHyperlinkStateFlags
+ *@ATK_HYPERLINK_IS_INLINE: Link is inline
+ *
+ *Describes the type of link
+ **/
+typedef enum
+{
+ ATK_HYPERLINK_IS_INLINE = 1 << 0
+} AtkHyperlinkStateFlags;
+
+#define ATK_TYPE_HYPERLINK (atk_hyperlink_get_type ())
+#define ATK_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_HYPERLINK, AtkHyperlink))
+#define ATK_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_HYPERLINK, AtkHyperlinkClass))
+#define ATK_IS_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_HYPERLINK))
+#define ATK_IS_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_HYPERLINK))
+#define ATK_HYPERLINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_HYPERLINK, AtkHyperlinkClass))
+
+typedef struct _AtkHyperlink AtkHyperlink;
+typedef struct _AtkHyperlinkClass AtkHyperlinkClass;
+
+struct _AtkHyperlink
+{
+ GObject parent;
+};
+
+struct _AtkHyperlinkClass
+{
+ GObjectClass parent;
+
+ gchar* (* get_uri) (AtkHyperlink *link_,
+ gint i);
+ AtkObject* (* get_object) (AtkHyperlink *link_,
+ gint i);
+ gint (* get_end_index) (AtkHyperlink *link_);
+ gint (* get_start_index) (AtkHyperlink *link_);
+ gboolean (* is_valid) (AtkHyperlink *link_);
+ gint (* get_n_anchors) (AtkHyperlink *link_);
+ guint (* link_state) (AtkHyperlink *link_);
+ gboolean (* is_selected_link) (AtkHyperlink *link_);
+
+ /* Signals */
+ void ( *link_activated) (AtkHyperlink *link_);
+ AtkFunction pad1;
+};
+
+GType atk_hyperlink_get_type (void);
+
+gchar* atk_hyperlink_get_uri (AtkHyperlink *link_,
+ gint i);
+
+AtkObject* atk_hyperlink_get_object (AtkHyperlink *link_,
+ gint i);
+
+gint atk_hyperlink_get_end_index (AtkHyperlink *link_);
+
+gint atk_hyperlink_get_start_index (AtkHyperlink *link_);
+
+gboolean atk_hyperlink_is_valid (AtkHyperlink *link_);
+
+gboolean atk_hyperlink_is_inline (AtkHyperlink *link_);
+
+gint atk_hyperlink_get_n_anchors (AtkHyperlink *link_);
+gboolean atk_hyperlink_is_selected_link (AtkHyperlink *link_);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_HYPERLINK_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkhyperlinkimpl.h b/other-licenses/atk-1.0/atk/atkhyperlinkimpl.h
new file mode 100644
index 0000000000..b08a1d53cf
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkhyperlinkimpl.h
@@ -0,0 +1,76 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_HYPERLINK_IMPL_H__
+#define __ATK_HYPERLINK_IMPL_H__
+
+#include <atk/atkobject.h>
+#include <atk/atkhyperlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * The AtkHyperlinkImpl interface should be supported by objects
+ * exposed within the hierarchy as children of an AtkHypertext container
+ * which correspond to "links" or embedded content within the text.
+ * HTML anchors are not, for instance, normally exposed this way,
+ * but embedded images and components which appear inline in the
+ * content of a text object are. The AtkHyperlinkIface interface
+ * allows a means of determining which children are hyperlinks in this
+ * sense of the word, and for obtaining their corresponding AtkHyperlink
+ * object, from which the embedding range, URI, etc. can be obtained.
+ *
+ * To some extent this interface exists because, for historical
+ * reasons, AtkHyperlink was defined as an object type, not an interface.
+ * Thus, in order to interact with AtkObjects via AtkHyperlink semantics,
+ * a new interface was required.
+ */
+
+#define ATK_TYPE_HYPERLINK_IMPL (atk_hyperlink_impl_get_type ())
+#define ATK_IS_HYPERLINK_IMPL(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_HYPERLINK_IMPL)
+#define ATK_HYPERLINK_IMPL(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_HYPERLINK_IMPL, AtkHyperlinkImpl)
+#define ATK_HYPERLINK_IMPL_GET_IFACE(obj) G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_HYPERLINK_IMPL, AtkHyperlinkImplIface)
+
+#ifndef _TYPEDEF_ATK_HYPERLINK_IMPL_
+#define _TYPEDEF_ATK_HYPERLINK_IMPL__
+typedef struct _AtkHyperlinkImpl AtkHyperlinkImpl;
+#endif
+typedef struct _AtkHyperlinkImplIface AtkHyperlinkImplIface;
+
+struct _AtkHyperlinkImplIface
+{
+ GTypeInterface parent;
+
+ AtkHyperlink* (* get_hyperlink) (AtkHyperlinkImpl *impl);
+
+ AtkFunction pad1;
+};
+
+GType atk_hyperlink_impl_get_type (void);
+
+AtkHyperlink *atk_hyperlink_impl_get_hyperlink (AtkHyperlinkImpl *obj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_HYPERLINK_IMPL_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkhypertext.h b/other-licenses/atk-1.0/atk/atkhypertext.h
new file mode 100644
index 0000000000..18464d9ffc
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkhypertext.h
@@ -0,0 +1,80 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_HYPERTEXT_H__
+#define __ATK_HYPERTEXT_H__
+
+#include <atk/atkobject.h>
+#include <atk/atkhyperlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * The AtkHypertext interface provides standard mechanisms for manipulating
+ * hyperlinks.
+ */
+
+#define ATK_TYPE_HYPERTEXT (atk_hypertext_get_type ())
+#define ATK_IS_HYPERTEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_HYPERTEXT)
+#define ATK_HYPERTEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_HYPERTEXT, AtkHypertext)
+#define ATK_HYPERTEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_HYPERTEXT, AtkHypertextIface))
+
+#ifndef _TYPEDEF_ATK_HYPERTEXT_
+#define _TYPEDEF_ATK_HYPERTEXT_
+typedef struct _AtkHypertext AtkHypertext;
+#endif
+typedef struct _AtkHypertextIface AtkHypertextIface;
+
+struct _AtkHypertextIface
+{
+ GTypeInterface parent;
+
+ AtkHyperlink*(* get_link) (AtkHypertext *hypertext,
+ gint link_index);
+ gint (* get_n_links) (AtkHypertext *hypertext);
+ gint (* get_link_index) (AtkHypertext *hypertext,
+ gint char_index);
+
+ /*
+ * signal handlers
+ */
+ void (* link_selected) (AtkHypertext *hypertext,
+ gint link_index);
+
+ AtkFunction pad1;
+ AtkFunction pad2;
+ AtkFunction pad3;
+};
+GType atk_hypertext_get_type (void);
+
+AtkHyperlink* atk_hypertext_get_link (AtkHypertext *hypertext,
+ gint link_index);
+gint atk_hypertext_get_n_links (AtkHypertext *hypertext);
+gint atk_hypertext_get_link_index (AtkHypertext *hypertext,
+ gint char_index);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_HYPERTEXT_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkimage.h b/other-licenses/atk-1.0/atk/atkimage.h
new file mode 100644
index 0000000000..7e60c81801
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkimage.h
@@ -0,0 +1,86 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_IMAGE_H__
+#define __ATK_IMAGE_H__
+
+#include <atk/atkobject.h>
+#include <atk/atkutil.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * The AtkImage interface should be supported by any object that has an
+ * associated image. This interface provides the standard mechanism for
+ * an assistive technology to get descriptive information about images.
+ */
+
+#define ATK_TYPE_IMAGE (atk_image_get_type ())
+#define ATK_IS_IMAGE(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_IMAGE)
+#define ATK_IMAGE(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_IMAGE, AtkImage)
+#define ATK_IMAGE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_IMAGE, AtkImageIface))
+
+#ifndef _TYPEDEF_ATK_IMAGE_
+#define _TYPEDEF_ATK_IMAGE_
+typedef struct _AtkImage AtkImage;
+#endif
+typedef struct _AtkImageIface AtkImageIface;
+
+struct _AtkImageIface
+{
+ GTypeInterface parent;
+ void ( *get_image_position) (AtkImage *image,
+ gint *x,
+ gint *y,
+ AtkCoordType coord_type);
+ G_CONST_RETURN gchar* ( *get_image_description) (AtkImage *image);
+ void ( *get_image_size) (AtkImage *image,
+ gint *width,
+ gint *height);
+ gboolean ( *set_image_description) (AtkImage *image,
+ const gchar *description);
+ G_CONST_RETURN gchar* ( *get_image_locale) (AtkImage *image);
+
+ AtkFunction pad1;
+
+};
+
+GType atk_image_get_type (void);
+
+G_CONST_RETURN gchar* atk_image_get_image_description (AtkImage *image);
+
+void atk_image_get_image_size (AtkImage *image,
+ gint *width,
+ gint *height);
+
+gboolean atk_image_set_image_description (AtkImage *image,
+ const gchar *description);
+void atk_image_get_image_position (AtkImage *image,
+ gint *x,
+ gint *y,
+ AtkCoordType coord_type);
+
+G_CONST_RETURN gchar* atk_image_get_image_locale (AtkImage *image);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __ATK_IMAGE_H__ */
diff --git a/other-licenses/atk-1.0/atk/atknoopobject.h b/other-licenses/atk-1.0/atk/atknoopobject.h
new file mode 100644
index 0000000000..3c4e432a85
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atknoopobject.h
@@ -0,0 +1,51 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_NO_OP_OBJECT_H__
+#define __ATK_NO_OP_OBJECT_H__
+
+G_BEGIN_DECLS
+
+#define ATK_TYPE_NO_OP_OBJECT (atk_no_op_object_get_type ())
+#define ATK_NO_OP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_NO_OP_OBJECT, AtkNoOpObject))
+#define ATK_NO_OP_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_NO_OP_OBJECT, AtkNoOpObjectClass))
+#define ATK_IS_NO_OP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_NO_OP_OBJECT))
+#define ATK_IS_NO_OP_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_NO_OP_OBJECT))
+#define ATK_NO_OP_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_NO_OP_OBJECT, AtkNoOpObjectClass))
+
+typedef struct _AtkNoOpObject AtkNoOpObject;
+typedef struct _AtkNoOpObjectClass AtkNoOpObjectClass;
+
+struct _AtkNoOpObject
+{
+ AtkObject parent;
+};
+
+GType atk_no_op_object_get_type (void);
+
+struct _AtkNoOpObjectClass
+{
+ AtkObjectClass parent_class;
+};
+
+AtkObject *atk_no_op_object_new (GObject *obj);
+
+G_END_DECLS
+
+#endif /* __ATK_NO_OP_OBJECT_H__ */
diff --git a/other-licenses/atk-1.0/atk/atknoopobjectfactory.h b/other-licenses/atk-1.0/atk/atknoopobjectfactory.h
new file mode 100644
index 0000000000..c324531330
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atknoopobjectfactory.h
@@ -0,0 +1,58 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_NO_OP_OBJECT_FACTORY_H__
+#define __ATK_NO_OP_OBJECT_FACTORY_H__
+
+#include <atk/atkobjectfactory.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define ATK_TYPE_NO_OP_OBJECT_FACTORY (atk_no_op_object_factory_get_type ())
+#define ATK_NO_OP_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_NO_OP_OBJECT_FACTORY, AtkNoOpObjectFactory))
+#define ATK_NO_OP_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_NO_OP_OBJECT_FACTORY, AtkNoOpObjectFactoryClass))
+#define ATK_IS_NO_OP_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_NO_OP_OBJECT_FACTORY))
+#define ATK_IS_NO_OP_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_NO_OP_OBJECT_FACTORY))
+#define ATK_NO_OP_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ( (obj), ATK_TYPE_NO_OP_OBJECT_FACTORY, AtkNoOpObjectFactoryClass))
+
+typedef struct _AtkNoOpObjectFactory AtkNoOpObjectFactory;
+typedef struct _AtkNoOpObjectFactoryClass AtkNoOpObjectFactoryClass;
+
+struct _AtkNoOpObjectFactory
+{
+ AtkObjectFactory parent;
+};
+
+struct _AtkNoOpObjectFactoryClass
+{
+ AtkObjectFactoryClass parent_class;
+};
+
+GType atk_no_op_object_factory_get_type(void);
+
+AtkObjectFactory *atk_no_op_object_factory_new(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_NO_OP_OBJECT_FACTORY_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkobject.h b/other-licenses/atk-1.0/atk/atkobject.h
new file mode 100644
index 0000000000..177c098175
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkobject.h
@@ -0,0 +1,875 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_OBJECT_H__
+#define __ATK_OBJECT_H__
+
+#include <glib-object.h>
+#include <atk/atkstate.h>
+#include <atk/atkrelationtype.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * AtkObject represents the minimum information all accessible objects
+ * return. This information includes accessible name, accessible
+ * description, role and state of the object, as well information about
+ * its parent and children. It is also possible to obtain more specific
+ * accessibility information about a component if it supports one or more
+ * of the following interfaces:
+ */
+
+/**
+ *AtkRole:
+ *@ATK_ROLE_INVALID: Invalid role
+ *@ATK_ROLE_ACCEL_LABEL: A label which represents an accelerator
+ *@ATK_ROLE_ALERT: An object which is an alert to the user. Assistive
+ *Technologies typically respond to ATK_ROLE_ALERT by reading the entire
+ *onscreen contents of containers advertising this role. Should be used for
+ *warning dialogs, etc.
+ *@ATK_ROLE_ANIMATION: An object which is an animated image
+ *@ATK_ROLE_ARROW: An arrow in one of the four cardinal directions
+ *@ATK_ROLE_CALENDAR: An object that displays a calendar and allows the user to
+ *select a date
+ *@ATK_ROLE_CANVAS: An object that can be drawn into and is used to trap events
+ *@ATK_ROLE_CHECK_BOX: A choice that can be checked or unchecked and provides a
+ *separate indicator for the current state
+ *@ATK_ROLE_CHECK_MENU_ITEM: A menu item with a check box
+ *@ATK_ROLE_COLOR_CHOOSER: A specialized dialog that lets the user choose a
+ *color
+ *@ATK_ROLE_COLUMN_HEADER: The header for a column of data
+ *@ATK_ROLE_COMBO_BOX: A collapsible list of choices the user can select from
+ *@ATK_ROLE_DATE_EDITOR: An object whose purpose is to allow a user to edit a
+ *date
+ *@ATK_ROLE_DESKTOP_ICON: An inconifed internal frame within a DESKTOP_PANE
+ *@ATK_ROLE_DESKTOP_FRAME: A pane that supports internal frames and iconified
+ *versions of those internal frames
+ *@ATK_ROLE_DIAL: An object whose purpose is to allow a user to set a value
+ *@ATK_ROLE_DIALOG: A top level window with title bar and a border
+ *@ATK_ROLE_DIRECTORY_PANE: A pane that allows the user to navigate through and
+ *select the contents of a directory
+ *@ATK_ROLE_DRAWING_AREA: An object used for drawing custom user interface
+ *elements
+ *@ATK_ROLE_FILE_CHOOSER: A specialized dialog that lets the user choose a file
+ *@ATK_ROLE_FILLER: A object that fills up space in a user interface
+ *@ATK_ROLE_FONT_CHOOSER: A specialized dialog that lets the user choose a font
+ *@ATK_ROLE_FRAME: A top level window with a title bar, border, menubar, etc.
+ *@ATK_ROLE_GLASS_PANE: A pane that is guaranteed to be painted on top of all
+ *panes beneath it
+ *@ATK_ROLE_HTML_CONTAINER: A document container for HTML, whose children
+ *represent the document content
+ *@ATK_ROLE_ICON: A small fixed size picture, typically used to decorate
+ *components
+ *@ATK_ROLE_IMAGE: An object whose primary purpose is to display an image
+ *@ATK_ROLE_INTERNAL_FRAME: A frame-like object that is clipped by a desktop
+ *pane
+ *@ATK_ROLE_LABEL: An object used to present an icon or short string in an
+ *interface
+ *@ATK_ROLE_LAYERED_PANE: A specialized pane that allows its children to be
+ *drawn in layers, providing a form of stacking order
+ *@ATK_ROLE_LIST: An object that presents a list of objects to the user and
+ *allows the user to select one or more of them
+ *@ATK_ROLE_LIST_ITEM: An object that represents an element of a list
+ *@ATK_ROLE_MENU: An object usually found inside a menu bar that contains a list
+ *of actions the user can choose from
+ *@ATK_ROLE_MENU_BAR: An object usually drawn at the top of the primary dialog
+ *box of an application that contains a list of menus the user can choose from
+ *@ATK_ROLE_MENU_ITEM: An object usually contained in a menu that presents an
+ *action the user can choose
+ *@ATK_ROLE_OPTION_PANE: A specialized pane whose primary use is inside a DIALOG
+ *@ATK_ROLE_PAGE_TAB: An object that is a child of a page tab list
+ *@ATK_ROLE_PAGE_TAB_LIST: An object that presents a series of panels (or page
+ *tabs), one at a time, through some mechanism provided by the object
+ *@ATK_ROLE_PANEL: A generic container that is often used to group objects
+ *@ATK_ROLE_PASSWORD_TEXT: A text object uses for passwords, or other places
+ *where the text content is not shown visibly to the user
+ *@ATK_ROLE_POPUP_MENU: A temporary window that is usually used to offer the
+ *user a list of choices, and then hides when the user selects one of those
+ *choices
+ *@ATK_ROLE_PROGRESS_BAR: An object used to indicate how much of a task has been
+ *completed
+ *@ATK_ROLE_PUSH_BUTTON: An object the user can manipulate to tell the
+ *application to do something
+ *@ATK_ROLE_RADIO_BUTTON: A specialized check box that will cause other radio
+ *buttons in the same group to become unchecked when this one is checked
+ *@ATK_ROLE_RADIO_MENU_ITEM: A check menu item which belongs to a group. At each
+ *instant exactly one of the radio menu items from a group is selected
+ *@ATK_ROLE_ROOT_PANE: A specialized pane that has a glass pane and a layered
+ *pane as its children
+ *@ATK_ROLE_ROW_HEADER: The header for a row of data
+ *@ATK_ROLE_SCROLL_BAR: An object usually used to allow a user to incrementally
+ *view a large amount of data.
+ *@ATK_ROLE_SCROLL_PANE: An object that allows a user to incrementally view a
+ *large amount of information
+ *@ATK_ROLE_SEPARATOR: An object usually contained in a menu to provide a
+ *visible and logical separation of the contents in a menu
+ *@ATK_ROLE_SLIDER: An object that allows the user to select from a bounded
+ *range
+ *@ATK_ROLE_SPLIT_PANE: A specialized panel that presents two other panels at
+ *the same time
+ *@ATK_ROLE_SPIN_BUTTON: An object used to get an integer or floating point
+ *number from the user
+ *@ATK_ROLE_STATUSBAR: An object which reports messages of minor importance to
+ *the user
+ *@ATK_ROLE_TABLE: An object used to represent information in terms of rows and
+ *columns
+ *@ATK_ROLE_TABLE_CELL: A cell in a table
+ *@ATK_ROLE_TABLE_COLUMN_HEADER: The header for a column of a table
+ *@ATK_ROLE_TABLE_ROW_HEADER: The header for a row of a table
+ *@ATK_ROLE_TEAR_OFF_MENU_ITEM: A menu item used to tear off and reattach its
+ *menu
+ *@ATK_ROLE_TERMINAL: An object that represents an accessible terminal. @Since:
+ *ATK-0.6
+ *@ATK_ROLE_TEXT: An interactive widget that supports multiple lines of text and
+ * optionally accepts user input, but whose purpose is not to solicit user
+ *input. Thus ATK_ROLE_TEXT is appropriate for the text view in a plain text
+ *editor but inappropriate for an input field in a dialog box or web form. For
+ *widgets whose purpose is to solicit input from the user, see ATK_ROLE_ENTRY
+ *and ATK_ROLE_PASSWORD_TEXT. For generic objects which display a brief amount
+ *of textual information, see ATK_ROLE_STATIC.
+ *@ATK_ROLE_TOGGLE_BUTTON: A specialized push button that can be checked or
+ *unchecked, but does not provide a separate indicator for the current state
+ *@ATK_ROLE_TOOL_BAR: A bar or palette usually composed of push buttons or
+ *toggle buttons
+ *@ATK_ROLE_TOOL_TIP: An object that provides information about another object
+ *@ATK_ROLE_TREE: An object used to represent hierarchical information to the
+ *user
+ *@ATK_ROLE_TREE_TABLE: An object capable of expanding and collapsing rows as
+ *well as showing multiple columns of data. @Since: ATK-0.7
+ *@ATK_ROLE_UNKNOWN: The object contains some Accessible information, but its
+ *role is not known
+ *@ATK_ROLE_VIEWPORT: An object usually used in a scroll pane
+ *@ATK_ROLE_WINDOW: A top level window with no title or border.
+ *@ATK_ROLE_HEADER: An object that serves as a document header. @Since:
+ *ATK-1.1.1
+ *@ATK_ROLE_FOOTER: An object that serves as a document footer. @Since:
+ *ATK-1.1.1
+ *@ATK_ROLE_PARAGRAPH: An object which is contains a paragraph of text content.
+ *@Since: ATK-1.1.1
+ *@ATK_ROLE_RULER: An object which describes margins and tab stops, etc. for
+ *text objects which it controls (should have CONTROLLER_FOR relation to such).
+ *@Since: ATK-1.1.1
+ *@ATK_ROLE_APPLICATION: The object is an application object, which may contain
+ *@ATK_ROLE_FRAME objects or other types of accessibles. The root accessible of
+ *any application's ATK hierarchy should have ATK_ROLE_APPLICATION. @Since:
+ *ATK-1.1.4
+ *@ATK_ROLE_AUTOCOMPLETE: The object is a dialog or list containing items for
+ *insertion into an entry widget, for instance a list of words for completion of
+ *a text entry. @Since: ATK-1.3
+ *@ATK_ROLE_EDITBAR: The object is an editable text object in a toolbar. @Since:
+ *ATK-1.5
+ *@ATK_ROLE_EMBEDDED: The object is an embedded container within a document or
+ *panel. This role is a grouping "hint" indicating that the contained objects
+ *share a context. @Since: ATK-1.7.2
+ *@ATK_ROLE_ENTRY: The object is a component whose textual content may be
+ *entered or modified by the user, provided @ATK_STATE_EDITABLE is present.
+ *@Since: ATK-1.11
+ *@ATK_ROLE_CHART: The object is a graphical depiction of quantitative data. It
+ *may contain multiple subelements whose attributes and/or description may be
+ *queried to obtain both the quantitative data and information about how the
+ *data is being presented. The LABELLED_BY relation is particularly important in
+ *interpreting objects of this type, as is the accessible-description property.
+ *@Since: ATK-1.11
+ *@ATK_ROLE_CAPTION: The object contains descriptive information, usually
+ *textual, about another user interface element such as a table, chart, or
+ *image. @Since: ATK-1.11
+ *@ATK_ROLE_DOCUMENT_FRAME: The object is a visual frame or container which
+ *contains a view of document content. Document frames may occur within another
+ *Document instance, in which case the second document may be said to be
+ *embedded in the containing instance. HTML frames are often
+ *ROLE_DOCUMENT_FRAME. Either this object, or a singleton descendant, should
+ *implement the Document interface. @Since: ATK-1.11
+ *@ATK_ROLE_HEADING: The object serves as a heading for content which follows it
+ *in a document. The 'heading level' of the heading, if availabe, may be
+ *obtained by querying the object's attributes.
+ *@ATK_ROLE_PAGE: The object is a containing instance which encapsulates a page
+ *of information. @ATK_ROLE_PAGE is used in documents and content which support
+ *a paginated navigation model. @Since: ATK-1.11
+ *@ATK_ROLE_SECTION: The object is a containing instance of document content
+ *which constitutes a particular 'logical' section of the document. The type of
+ *content within a section, and the nature of the section division itself, may
+ *be obtained by querying the object's attributes. Sections may be nested.
+ *@Since: ATK-1.11
+ *@ATK_ROLE_REDUNDANT_OBJECT: The object is redundant with another object in the
+ *hierarchy, and is exposed for purely technical reasons. Objects of this role
+ *should normally be ignored by clients. @Since: ATK-1.11
+ *@ATK_ROLE_FORM: The object is a container for form controls, for instance as
+ *part of a web form or user-input form within a document. This role is
+ *primarily a tag/convenience for clients when navigating complex documents, it
+ *is not expected that ordinary GUI containers will always have ATK_ROLE_FORM.
+ *@Since: ATK-1.12.0
+ *@ATK_ROLE_LINK: The object is a hypertext anchor, i.e. a "link" in a
+ * hypertext document. Such objects are distinct from 'inline'
+ * content which may also use the Hypertext/Hyperlink interfaces
+ * to indicate the range/location within a text object where
+ * an inline or embedded object lies. @Since: ATK-1.12.1
+ *@ATK_ROLE_INPUT_METHOD_WINDOW: The object is a window or similar viewport
+ * which is used to allow composition or input of a 'complex character',
+ * in other words it is an "input method window." @Since: ATK-1.12.1
+ *@ATK_ROLE_TABLE_ROW: A row in a table. @Since: ATK-2.1.0
+ *@ATK_ROLE_TREE_ITEM: An object that represents an element of a tree. @Since:
+ *ATK-2.1.0
+ *@ATK_ROLE_DOCUMENT_SPREADSHEET: A document frame which contains a spreadsheet.
+ *@Since: ATK-2.1.0
+ *@ATK_ROLE_DOCUMENT_PRESENTATION: A document frame which contains a
+ *presentation or slide content. @Since: ATK-2.1.0
+ *@ATK_ROLE_DOCUMENT_TEXT: A document frame which contains textual content, such
+ *as found in a word processing application. @Since: ATK-2.1.0
+ *@ATK_ROLE_DOCUMENT_WEB: A document frame which contains HTML or other markup
+ *suitable for display in a web browser. @Since: ATK-2.1.0
+ *@ATK_ROLE_DOCUMENT_EMAIL: A document frame which contains email content to be
+ *displayed or composed either in plain text or HTML. @Since: ATK-2.1.0
+ *@ATK_ROLE_COMMENT: An object found within a document and designed to present a
+ *comment, note, or other annotation. In some cases, this object might not be
+ *visible until activated. @Since: ATK-2.1.0
+ *@ATK_ROLE_LIST_BOX: A non-collapsible list of choices the user can select
+ *from. @Since: ATK-2.1.0
+ *@ATK_ROLE_GROUPING: A group of related widgets. This group typically has a
+ *label. @Since: ATK-2.1.0
+ *@ATK_ROLE_IMAGE_MAP: An image map object. Usually a graphic with multiple
+ *hotspots, where each hotspot can be activated resulting in the loading of
+ *another document or section of a document. @Since: ATK-2.1.0
+ *@ATK_ROLE_NOTIFICATION: A transitory object designed to present a message to
+ *the user, typically at the desktop level rather than inside a particular
+ *application. @Since: ATK-2.1.0
+ *@ATK_ROLE_INFO_BAR: An object designed to present a message to the user within
+ *an existing window. @Since: ATK-2.1.0
+ *@ATK_ROLE_LEVEL_BAR: A bar that serves as a level indicator to, for instance,
+ *show the strength of a password or the state of a battery. @Since: ATK-2.7.3
+ *@ATK_ROLE_TITLE_BAR: A bar that serves as the title of a window or a
+ * dialog. @Since: ATK-2.12
+ *@ATK_ROLE_BLOCK_QUOTE: An object which contains a text section
+ * that is quoted from another source. @Since: ATK-2.12
+ *@ATK_ROLE_AUDIO: An object which represents an audio element. @Since: ATK-2.12
+ *@ATK_ROLE_VIDEO: An object which represents a video element. @Since: ATK-2.12
+ *@ATK_ROLE_DEFINITION: A definition of a term or concept. @Since: ATK-2.12
+ *@ATK_ROLE_ARTICLE: A section of a page that consists of a
+ * composition that forms an independent part of a document, page, or
+ * site. Examples: A blog entry, a news story, a forum post. @Since:
+ * ATK-2.12
+ *@ATK_ROLE_LANDMARK: A region of a web page intended as a
+ * navigational landmark. This is designed to allow Assistive
+ * Technologies to provide quick navigation among key regions within a
+ * document. @Since: ATK-2.12
+ *@ATK_ROLE_LOG: A text widget or container holding log content, such
+ * as chat history and error logs. In this role there is a
+ * relationship between the arrival of new items in the log and the
+ * reading order. The log contains a meaningful sequence and new
+ * information is added only to the end of the log, not at arbitrary
+ * points. @Since: ATK-2.12
+ *@ATK_ROLE_MARQUEE: A container where non-essential information
+ * changes frequently. Common usages of marquee include stock tickers
+ * and ad banners. The primary difference between a marquee and a log
+ * is that logs usually have a meaningful order or sequence of
+ * important content changes. @Since: ATK-2.12
+ *@ATK_ROLE_MATH: A text widget or container that holds a mathematical
+ * expression. @Since: ATK-2.12
+ *@ATK_ROLE_RATING: A widget whose purpose is to display a rating,
+ * such as the number of stars associated with a song in a media
+ * player. Objects of this role should also implement
+ * AtkValue. @Since: ATK-2.12
+ *@ATK_ROLE_TIMER: An object containing a numerical counter which
+ * indicates an amount of elapsed time from a start point, or the time
+ * remaining until an end point. @Since: ATK-2.12
+ *@ATK_ROLE_DESCRIPTION_LIST: An object that represents a list of
+ * term-value groups. A term-value group represents a individual
+ * description and consist of one or more names
+ * (ATK_ROLE_DESCRIPTION_TERM) followed by one or more values
+ * (ATK_ROLE_DESCRIPTION_VALUE). For each list, there should not be
+ * more than one group with the same term name. @Since: ATK-2.12
+ *@ATK_ROLE_DESCRIPTION_TERM: An object that represents the term, or
+ * name, part of a term-description group in a description
+ * list. @Since: ATK-2.12
+ *@ATK_ROLE_DESCRIPTION_VALUE: An object that represents the
+ * description, definition or value of a term-description group in a
+ * description list. The values within a group are alternatives,
+ * meaning that you can have several ATK_ROLE_DESCRIPTION_VALUE for a
+ * given ATK_ROLE_DESCRIPTION_TERM. @Since: ATK-2.12
+ *@ATK_ROLE_STATIC: A generic non-container object whose purpose is to display a
+ * brief amount of information to the user and whose role is known by the
+ * implementor but lacks semantic value for the user. Examples in which
+ * ATK_ROLE_STATIC is appropriate include the message displayed in a message box
+ * and an image used as an alternative means to display text. ATK_ROLE_STATIC
+ * should not be applied to widgets which are traditionally interactive, objects
+ * which display a significant amount of content, or any object which has an
+ * accessible relation pointing to another object. Implementors should expose
+ *the displayed information through the accessible name of the object. If doing
+ *so seems inappropriate, it may indicate that a different role should be used.
+ *For labels which describe another widget, see ATK_ROLE_LABEL. For text views,
+ *see ATK_ROLE_TEXT. For generic containers, see ATK_ROLE_PANEL. For objects
+ *whose role is not known by the implementor, see ATK_ROLE_UNKNOWN. @Since:
+ *ATK-2.16.
+ *@ATK_ROLE_MATH_FRACTION: An object that represents a mathematical fraction.
+ * @Since: ATK-2.16.
+ *@ATK_ROLE_MATH_ROOT: An object that represents a mathematical expression
+ * displayed with a radical. @Since: ATK-2.16.
+ *@ATK_ROLE_SUBSCRIPT: An object that contains text that is displayed as a
+ * subscript. @Since: ATK-2.16.
+ *@ATK_ROLE_SUPERSCRIPT: An object that contains text that is displayed as a
+ * superscript. @Since: ATK-2.16.
+ *@ATK_ROLE_FOOTNOTE: An object that contains the text of a footnote. @Since:
+ *ATK-2.26.
+ *@ATK_ROLE_CONTENT_DELETION: Content previously deleted or proposed to be
+ * deleted, e.g. in revision history or a content view providing suggestions
+ * from reviewers. (Since: 2.34)
+ *@ATK_ROLE_CONTENT_INSERTION: Content previously inserted or proposed to be
+ * inserted, e.g. in revision history or a content view providing suggestions
+ * from reviewers. (Since: 2.34)
+ *@ATK_ROLE_MARK: A run of content that is marked or highlighted, such as for
+ * reference purposes, or to call it out as having a special purpose. If the
+ * marked content has an associated section in the document elaborating on the
+ * reason for the mark, then %ATK_RELATION_DETAILS should be used on the mark
+ * to point to that associated section. In addition, the reciprocal relation
+ * %ATK_RELATION_DETAILS_FOR should be used on the associated content section
+ * to point back to the mark. (Since: 2.36)
+ *@ATK_ROLE_SUGGESTION: A container for content that is called out as a proposed
+ * change from the current version of the document, such as by a reviewer of the
+ * content. This role should include either %ATK_ROLE_CONTENT_DELETION and/or
+ * %ATK_ROLE_CONTENT_INSERTION children, in any order, to indicate what the
+ * actual change is. (Since: 2.36)
+ *@ATK_ROLE_LAST_DEFINED: not a valid role, used for finding end of the
+ *enumeration
+ *
+ * Describes the role of an object
+ *
+ * These are the built-in enumerated roles that UI components can have in
+ * ATK. Other roles may be added at runtime, so an AtkRole >=
+ * ATK_ROLE_LAST_DEFINED is not necessarily an error.
+ **/
+typedef enum {
+ ATK_ROLE_INVALID = 0,
+ ATK_ROLE_ACCEL_LABEL, /*<nick=accelerator-label>*/
+ ATK_ROLE_ALERT,
+ ATK_ROLE_ANIMATION,
+ ATK_ROLE_ARROW,
+ ATK_ROLE_CALENDAR,
+ ATK_ROLE_CANVAS,
+ ATK_ROLE_CHECK_BOX,
+ ATK_ROLE_CHECK_MENU_ITEM,
+ ATK_ROLE_COLOR_CHOOSER,
+ ATK_ROLE_COLUMN_HEADER,
+ ATK_ROLE_COMBO_BOX,
+ ATK_ROLE_DATE_EDITOR,
+ ATK_ROLE_DESKTOP_ICON,
+ ATK_ROLE_DESKTOP_FRAME,
+ ATK_ROLE_DIAL,
+ ATK_ROLE_DIALOG,
+ ATK_ROLE_DIRECTORY_PANE,
+ ATK_ROLE_DRAWING_AREA,
+ ATK_ROLE_FILE_CHOOSER,
+ ATK_ROLE_FILLER,
+ ATK_ROLE_FONT_CHOOSER,
+ ATK_ROLE_FRAME,
+ ATK_ROLE_GLASS_PANE,
+ ATK_ROLE_HTML_CONTAINER,
+ ATK_ROLE_ICON,
+ ATK_ROLE_IMAGE,
+ ATK_ROLE_INTERNAL_FRAME,
+ ATK_ROLE_LABEL,
+ ATK_ROLE_LAYERED_PANE,
+ ATK_ROLE_LIST,
+ ATK_ROLE_LIST_ITEM,
+ ATK_ROLE_MENU,
+ ATK_ROLE_MENU_BAR,
+ ATK_ROLE_MENU_ITEM,
+ ATK_ROLE_OPTION_PANE,
+ ATK_ROLE_PAGE_TAB,
+ ATK_ROLE_PAGE_TAB_LIST,
+ ATK_ROLE_PANEL,
+ ATK_ROLE_PASSWORD_TEXT,
+ ATK_ROLE_POPUP_MENU,
+ ATK_ROLE_PROGRESS_BAR,
+ ATK_ROLE_PUSH_BUTTON,
+ ATK_ROLE_RADIO_BUTTON,
+ ATK_ROLE_RADIO_MENU_ITEM,
+ ATK_ROLE_ROOT_PANE,
+ ATK_ROLE_ROW_HEADER,
+ ATK_ROLE_SCROLL_BAR,
+ ATK_ROLE_SCROLL_PANE,
+ ATK_ROLE_SEPARATOR,
+ ATK_ROLE_SLIDER,
+ ATK_ROLE_SPLIT_PANE,
+ ATK_ROLE_SPIN_BUTTON,
+ ATK_ROLE_STATUSBAR,
+ ATK_ROLE_TABLE,
+ ATK_ROLE_TABLE_CELL,
+ ATK_ROLE_TABLE_COLUMN_HEADER,
+ ATK_ROLE_TABLE_ROW_HEADER,
+ ATK_ROLE_TEAR_OFF_MENU_ITEM,
+ ATK_ROLE_TERMINAL,
+ ATK_ROLE_TEXT,
+ ATK_ROLE_TOGGLE_BUTTON,
+ ATK_ROLE_TOOL_BAR,
+ ATK_ROLE_TOOL_TIP,
+ ATK_ROLE_TREE,
+ ATK_ROLE_TREE_TABLE,
+ ATK_ROLE_UNKNOWN,
+ ATK_ROLE_VIEWPORT,
+ ATK_ROLE_WINDOW,
+ ATK_ROLE_HEADER,
+ ATK_ROLE_FOOTER,
+ ATK_ROLE_PARAGRAPH,
+ ATK_ROLE_RULER,
+ ATK_ROLE_APPLICATION,
+ ATK_ROLE_AUTOCOMPLETE,
+ ATK_ROLE_EDITBAR,
+ ATK_ROLE_EMBEDDED,
+ ATK_ROLE_ENTRY,
+ ATK_ROLE_CHART,
+ ATK_ROLE_CAPTION,
+ ATK_ROLE_DOCUMENT_FRAME,
+ ATK_ROLE_HEADING,
+ ATK_ROLE_PAGE,
+ ATK_ROLE_SECTION,
+ ATK_ROLE_REDUNDANT_OBJECT,
+ ATK_ROLE_FORM,
+ ATK_ROLE_LINK,
+ ATK_ROLE_INPUT_METHOD_WINDOW,
+ ATK_ROLE_TABLE_ROW,
+ ATK_ROLE_TREE_ITEM,
+ ATK_ROLE_DOCUMENT_SPREADSHEET,
+ ATK_ROLE_DOCUMENT_PRESENTATION,
+ ATK_ROLE_DOCUMENT_TEXT,
+ ATK_ROLE_DOCUMENT_WEB,
+ ATK_ROLE_DOCUMENT_EMAIL,
+ ATK_ROLE_COMMENT,
+ ATK_ROLE_LIST_BOX,
+ ATK_ROLE_GROUPING,
+ ATK_ROLE_IMAGE_MAP,
+ ATK_ROLE_NOTIFICATION,
+ ATK_ROLE_INFO_BAR,
+ ATK_ROLE_LEVEL_BAR,
+ ATK_ROLE_TITLE_BAR,
+ ATK_ROLE_BLOCK_QUOTE,
+ ATK_ROLE_AUDIO,
+ ATK_ROLE_VIDEO,
+ ATK_ROLE_DEFINITION,
+ ATK_ROLE_ARTICLE,
+ ATK_ROLE_LANDMARK,
+ ATK_ROLE_LOG,
+ ATK_ROLE_MARQUEE,
+ ATK_ROLE_MATH,
+ ATK_ROLE_RATING,
+ ATK_ROLE_TIMER,
+ ATK_ROLE_DESCRIPTION_LIST,
+ ATK_ROLE_DESCRIPTION_TERM,
+ ATK_ROLE_DESCRIPTION_VALUE,
+ ATK_ROLE_STATIC,
+ ATK_ROLE_MATH_FRACTION,
+ ATK_ROLE_MATH_ROOT,
+ ATK_ROLE_SUBSCRIPT,
+ ATK_ROLE_SUPERSCRIPT,
+ ATK_ROLE_FOOTNOTE,
+ ATK_ROLE_CONTENT_DELETION,
+ ATK_ROLE_CONTENT_INSERTION,
+ ATK_ROLE_MARK,
+ ATK_ROLE_SUGGESTION,
+ ATK_ROLE_LAST_DEFINED
+} AtkRole;
+
+AtkRole atk_role_register(const gchar* name);
+
+/**
+ *AtkLayer:
+ *@ATK_LAYER_INVALID: The object does not have a layer
+ *@ATK_LAYER_BACKGROUND: This layer is reserved for the desktop background
+ *@ATK_LAYER_CANVAS: This layer is used for Canvas components
+ *@ATK_LAYER_WIDGET: This layer is normally used for components
+ *@ATK_LAYER_MDI: This layer is used for layered components
+ *@ATK_LAYER_POPUP: This layer is used for popup components, such as menus
+ *@ATK_LAYER_OVERLAY: This layer is reserved for future use.
+ *@ATK_LAYER_WINDOW: This layer is used for toplevel windows.
+ *
+ * Describes the layer of a component
+ *
+ * These enumerated "layer values" are used when determining which UI
+ * rendering layer a component is drawn into, which can help in making
+ * determinations of when components occlude one another.
+ **/
+typedef enum {
+ ATK_LAYER_INVALID,
+ ATK_LAYER_BACKGROUND,
+ ATK_LAYER_CANVAS,
+ ATK_LAYER_WIDGET,
+ ATK_LAYER_MDI,
+ ATK_LAYER_POPUP,
+ ATK_LAYER_OVERLAY,
+ ATK_LAYER_WINDOW
+} AtkLayer;
+
+/**
+ * AtkAttributeSet:
+ *
+ * This is a singly-linked list (a #GSList) of #AtkAttribute. It is
+ * used by atk_text_get_run_attributes(), atk_text_get_default_attributes()
+ * and atk_editable_text_set_run_attributes()
+ **/
+typedef GSList AtkAttributeSet;
+
+/**
+ * AtkAttribute:
+ * @name: The attribute name. Call atk_text_attr_get_name()
+ * @value: the value of the attribute, represented as a string.
+ * Call atk_text_attr_get_value() for those which are strings.
+ * For values which are numbers, the string representation of the number
+ * is in value.
+ *
+ * A string name/value pair representing a text attribute.
+ **/
+typedef struct _AtkAttribute AtkAttribute;
+
+struct _AtkAttribute {
+ gchar* name;
+ gchar* value;
+};
+
+#define ATK_TYPE_OBJECT (atk_object_get_type())
+#define ATK_OBJECT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), ATK_TYPE_OBJECT, AtkObject))
+#define ATK_OBJECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), ATK_TYPE_OBJECT, AtkObjectClass))
+#define ATK_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), ATK_TYPE_OBJECT))
+#define ATK_IS_OBJECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), ATK_TYPE_OBJECT))
+#define ATK_OBJECT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), ATK_TYPE_OBJECT, AtkObjectClass))
+
+#define ATK_TYPE_IMPLEMENTOR (atk_implementor_get_type())
+#define ATK_IS_IMPLEMENTOR(obj) \
+ G_TYPE_CHECK_INSTANCE_TYPE((obj), ATK_TYPE_IMPLEMENTOR)
+#define ATK_IMPLEMENTOR(obj) \
+ G_TYPE_CHECK_INSTANCE_CAST((obj), ATK_TYPE_IMPLEMENTOR, AtkImplementor)
+#define ATK_IMPLEMENTOR_GET_IFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE((obj), ATK_TYPE_IMPLEMENTOR, \
+ AtkImplementorIface))
+
+typedef struct _AtkImplementor AtkImplementor; /* dummy typedef */
+typedef struct _AtkImplementorIface AtkImplementorIface;
+
+typedef struct _AtkObject AtkObject;
+typedef struct _AtkObjectClass AtkObjectClass;
+typedef struct _AtkRelationSet AtkRelationSet;
+typedef struct _AtkStateSet AtkStateSet;
+
+/**
+ * AtkPropertyValues:
+ * @property_name: The name of the ATK property which is being presented or
+ *which has been changed.
+ * @old_value: The old property value, NULL; in some contexts this value is
+ *undefined (see note below).
+ * @new_value: The new value of the named property.
+ *
+ * @note: For most properties the old_value field of AtkPropertyValues will
+ * not contain a valid value.
+ *
+ * Currently, the only property for which old_value is used is
+ * accessible-state; for instance if there is a focus state the
+ * property change handler will be called for the object which lost the focus
+ * with the old_value containing an AtkState value corresponding to focused
+ * and the property change handler will be called for the object which
+ * received the focus with the new_value containing an AtkState value
+ * corresponding to focused.
+ *
+ **/
+struct _AtkPropertyValues {
+ const gchar* property_name;
+ GValue old_value;
+ GValue new_value;
+};
+
+typedef struct _AtkPropertyValues AtkPropertyValues;
+
+typedef gboolean (*AtkFunction)(gpointer data);
+/*
+ * For most properties the old_value field of AtkPropertyValues will
+ * not contain a valid value.
+ *
+ * Currently, the only property for which old_value is used is
+ * accessible-state; for instance if there is a focus state the
+ * property change handler will be called for the object which lost the focus
+ * with the old_value containing an AtkState value corresponding to focused
+ * and the property change handler will be called for the object which
+ * received the focus with the new_value containing an AtkState value
+ * corresponding to focused.
+ */
+typedef void (*AtkPropertyChangeHandler)(AtkObject*, AtkPropertyValues*);
+
+struct _AtkObject {
+ GObject parent;
+
+ gchar* description;
+ gchar* name;
+ AtkObject* accessible_parent;
+ AtkRole role;
+ AtkRelationSet* relation_set;
+ AtkLayer layer;
+};
+
+struct _AtkObjectClass {
+ GObjectClass parent;
+
+ /*
+ * Gets the accessible name of the object
+ */
+ G_CONST_RETURN gchar* (*get_name)(AtkObject* accessible);
+ /*
+ * Gets the accessible description of the object
+ */
+ G_CONST_RETURN gchar* (*get_description)(AtkObject* accessible);
+ /*
+ * Gets the accessible parent of the object
+ */
+ AtkObject* (*get_parent)(AtkObject* accessible);
+
+ /*
+ * Gets the number of accessible children of the object
+ */
+ gint (*get_n_children)(AtkObject* accessible);
+ /*
+ * Returns a reference to the specified accessible child of the object.
+ * The accessible children are 0-based so the first accessible child is
+ * at index 0, the second at index 1 and so on.
+ */
+ AtkObject* (*ref_child)(AtkObject* accessible, gint i);
+ /*
+ * Gets the 0-based index of this object in its parent; returns -1 if the
+ * object does not have an accessible parent.
+ */
+ gint (*get_index_in_parent)(AtkObject* accessible);
+ /*
+ * Gets the RelationSet associated with the object
+ */
+ AtkRelationSet* (*ref_relation_set)(AtkObject* accessible);
+ /*
+ * Gets the role of the object
+ */
+ AtkRole (*get_role)(AtkObject* accessible);
+ AtkLayer (*get_layer)(AtkObject* accessible);
+ gint (*get_mdi_zorder)(AtkObject* accessible);
+ /*
+ * Gets the state set of the object
+ */
+ AtkStateSet* (*ref_state_set)(AtkObject* accessible);
+ /*
+ * Sets the accessible name of the object
+ */
+ void (*set_name)(AtkObject* accessible, const gchar* name);
+ /*
+ * Sets the accessible description of the object
+ */
+ void (*set_description)(AtkObject* accessible, const gchar* description);
+ /*
+ * Sets the accessible parent of the object
+ */
+ void (*set_parent)(AtkObject* accessible, AtkObject* parent);
+ /*
+ * Sets the accessible role of the object
+ */
+ void (*set_role)(AtkObject* accessible, AtkRole role);
+ /*
+ * Specifies a function to be called when a property changes value
+ */
+ guint (*connect_property_change_handler)(AtkObject* accessible,
+ AtkPropertyChangeHandler* handler);
+ /*
+ * Removes a property change handler which was specified using
+ * connect_property_change_handler
+ */
+ void (*remove_property_change_handler)(AtkObject* accessible,
+ guint handler_id);
+ void (*initialize)(AtkObject* accessible, gpointer data);
+ /*
+ * The signal handler which is executed when there is a change in the
+ * children of the object
+ */
+ void (*children_changed)(AtkObject* accessible, guint change_index,
+ gpointer changed_child);
+ /*
+ * The signal handler which is executed when there is a focus event
+ * for an object.
+ */
+ void (*focus_event)(AtkObject* accessible, gboolean focus_in);
+ /*
+ * The signal handler which is executed when there is a property_change
+ * signal for an object.
+ */
+ void (*property_change)(AtkObject* accessible, AtkPropertyValues* values);
+ /*
+ * The signal handler which is executed when there is a state_change
+ * signal for an object.
+ */
+ void (*state_change)(AtkObject* accessible, const gchar* name,
+ gboolean state_set);
+ /*
+ * The signal handler which is executed when there is a change in the
+ * visible data for an object
+ */
+ void (*visible_data_changed)(AtkObject* accessible);
+
+ /*
+ * The signal handler which is executed when there is a change in the
+ * 'active' child or children of the object, for instance when
+ * interior focus changes in a table or list. This signal should be emitted
+ * by objects whose state includes ATK_STATE_MANAGES_DESCENDANTS.
+ */
+ void (*active_descendant_changed)(AtkObject* accessible, gpointer* child);
+
+ /*
+ * Gets a list of properties applied to this object as a whole, as an
+ * #AtkAttributeSet consisting of name-value pairs. Since ATK 1.12
+ */
+ AtkAttributeSet* (*get_attributes)(AtkObject* accessible);
+
+ const gchar* (*get_object_locale)(AtkObject* accessible);
+
+ AtkFunction pad1;
+};
+
+GType atk_object_get_type(void);
+
+struct _AtkImplementorIface {
+ GTypeInterface parent;
+
+ AtkObject* (*ref_accessible)(AtkImplementor* implementor);
+};
+GType atk_implementor_get_type(void);
+
+/*
+ * This method uses the ref_accessible method in AtkImplementorIface,
+ * if the object's class implements AtkImplementorIface.
+ * Otherwise it returns %NULL.
+ *
+ * IMPORTANT:
+ * Note also that because this method may return flyweight objects,
+ * it increments the returned AtkObject's reference count.
+ * Therefore it is the responsibility of the calling
+ * program to unreference the object when no longer needed.
+ * (c.f. gtk_widget_get_accessible() where this is not the case).
+ */
+AtkObject* atk_implementor_ref_accessible(AtkImplementor* implementor);
+
+/*
+ * Properties directly supported by AtkObject
+ */
+
+G_CONST_RETURN gchar* atk_object_get_name(AtkObject* accessible);
+G_CONST_RETURN gchar* atk_object_get_description(AtkObject* accessible);
+AtkObject* atk_object_get_parent(AtkObject* accessible);
+gint atk_object_get_n_accessible_children(AtkObject* accessible);
+AtkObject* atk_object_ref_accessible_child(AtkObject* accessible, gint i);
+AtkRelationSet* atk_object_ref_relation_set(AtkObject* accessible);
+AtkRole atk_object_get_role(AtkObject* accessible);
+AtkLayer atk_object_get_layer(AtkObject* accessible);
+gint atk_object_get_mdi_zorder(AtkObject* accessible);
+AtkAttributeSet* atk_object_get_attributes(AtkObject* accessible);
+AtkStateSet* atk_object_ref_state_set(AtkObject* accessible);
+gint atk_object_get_index_in_parent(AtkObject* accessible);
+void atk_object_set_name(AtkObject* accessible, const gchar* name);
+void atk_object_set_description(AtkObject* accessible,
+ const gchar* description);
+void atk_object_set_parent(AtkObject* accessible, AtkObject* parent);
+void atk_object_set_role(AtkObject* accessible, AtkRole role);
+
+guint atk_object_connect_property_change_handler(
+ AtkObject* accessible, AtkPropertyChangeHandler* handler);
+void atk_object_remove_property_change_handler(AtkObject* accessible,
+ guint handler_id);
+
+void atk_object_notify_state_change(AtkObject* accessible, AtkState state,
+ gboolean value);
+void atk_object_initialize(AtkObject* accessible, gpointer data);
+
+G_CONST_RETURN gchar* atk_role_get_name(AtkRole role);
+AtkRole atk_role_for_name(const gchar* name);
+
+/* NEW in 1.1: convenience API */
+gboolean atk_object_add_relationship(AtkObject* object,
+ AtkRelationType relationship,
+ AtkObject* target);
+gboolean atk_object_remove_relationship(AtkObject* object,
+ AtkRelationType relationship,
+ AtkObject* target);
+G_CONST_RETURN gchar* atk_role_get_localized_name(AtkRole role);
+
+/* */
+
+/*
+ * Note: the properties which are registered with the GType
+ * property registry, for type ATK_TYPE_OBJECT, are as follows:
+ *
+ * "accessible-name"
+ * "accessible-description"
+ * "accessible-parent"
+ * "accessible-role"
+ * "accessible-value"
+ * "accessible-component-layer"
+ * "accessible-component-zorder"
+ * "accessible-table-caption"
+ * "accessible-table-column-description"
+ * "accessible-table-column-header"
+ * "accessible-table-row-description"
+ * "accessible-table-row-header"
+ * "accessible-table-summary"
+ * "accessible-model"
+ *
+ * accessibility property change listeners should use the
+ * normal GObject property interfaces and "property-change"
+ * signal handler semantics to interpret the property change
+ * information relayed from AtkObject.
+ * (AtkObject instances will connect to the "notify"
+ * signal in their host objects, and relay the signals when appropriate).
+ */
+
+/* For other signals, see related interfaces
+ *
+ * AtkActionIface,
+ * AtkComponentIface,
+ * AtkHypertextIface,
+ * AtkImageIface,
+ * AtkSelectionIface,
+ * AtkTableIface,
+ * AtkTextIface,
+ * AtkValueIface.
+ *
+ * The usage model for obtaining these interface instances is:
+ * ATK_<interfacename>_GET_IFACE(GObject *accessible),
+ * where accessible, though specified as a GObject, is
+ * the AtkObject instance being queried.
+ * More usually, the interface will be used via a cast to the
+ * interface's corresponding "type":
+ *
+ * AtkText textImpl = ATK_TEXT(accessible);
+ * if (textImpl)
+ * {
+ * cpos = atk_text_get_caret_position(textImpl);
+ * }
+ *
+ * If it's known in advance that accessible implements AtkTextIface,
+ * this is shortened to:
+ *
+ * cpos = atk_text_get_caret_position (ATK_TEXT (accessible));
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __ATK_OBJECT_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkobjectfactory.h b/other-licenses/atk-1.0/atk/atkobjectfactory.h
new file mode 100644
index 0000000000..fb163adb83
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkobjectfactory.h
@@ -0,0 +1,68 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_OBJECT_FACTORY_H__
+#define __ATK_OBJECT_FACTORY_H__
+
+#include <glib-object.h>
+#include <atk/atkobject.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define ATK_TYPE_OBJECT_FACTORY (atk_object_factory_get_type ())
+#define ATK_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_OBJECT_FACTORY, AtkObjectFactory))
+#define ATK_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_OBJECT_FACTORY, AtkObjectFactoryClass))
+#define ATK_IS_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_OBJECT_FACTORY))
+#define ATK_IS_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_OBJECT_FACTORY))
+#define ATK_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_OBJECT_FACTORY, AtkObjectFactoryClass))
+
+typedef struct _AtkObjectFactory AtkObjectFactory;
+typedef struct _AtkObjectFactoryClass AtkObjectFactoryClass;
+
+struct _AtkObjectFactory
+{
+ GObject parent;
+};
+
+struct _AtkObjectFactoryClass
+{
+ GObjectClass parent_class;
+
+ AtkObject* (* create_accessible) (GObject *obj);
+ void (* invalidate) (AtkObjectFactory *factory);
+ GType (* get_accessible_type) (void);
+
+ AtkFunction pad1;
+ AtkFunction pad2;
+};
+
+GType atk_object_factory_get_type(void);
+
+AtkObject* atk_object_factory_create_accessible (AtkObjectFactory *factory, GObject *obj);
+void atk_object_factory_invalidate (AtkObjectFactory *factory);
+GType atk_object_factory_get_accessible_type (AtkObjectFactory *factory);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __GTK_OBJECT_FACTORY_H__ */
+
diff --git a/other-licenses/atk-1.0/atk/atkplug.h b/other-licenses/atk-1.0/atk/atkplug.h
new file mode 100644
index 0000000000..7d6efd4b9d
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkplug.h
@@ -0,0 +1,61 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2009 Novell, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (ATK_COMPILATION)
+#error "Only <atk/atk.h> can be included directly."
+#endif
+
+#ifndef __ATK_PLUG_H__
+#define __ATK_PLUG_H__
+
+G_BEGIN_DECLS
+
+#define ATK_TYPE_PLUG (atk_plug_get_type ())
+#define ATK_PLUG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_PLUG, AtkPlug))
+#define ATK_IS_PLUG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_PLUG))
+#define ATK_PLUG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_PLUG, AtkPlugClass))
+#define ATK_IS_PLUG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_PLUG))
+#define ATK_PLUG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_PLUG, AtkPlugClass))
+
+typedef struct _AtkPlug AtkPlug;
+typedef struct _AtkPlugClass AtkPlugClass;
+
+struct _AtkPlug
+{
+ AtkObject parent;
+};
+
+GType atk_plug_get_type (void);
+
+struct _AtkPlugClass
+{
+ AtkObjectClass parent_class;
+
+ /* to be subscribed to by atk-bridge */
+
+ /*< protected >*/
+ gchar* (* get_object_id) (AtkPlug* obj);
+};
+
+AtkObject* atk_plug_new (void);
+gchar* atk_plug_get_id (AtkPlug* plug);
+
+G_END_DECLS
+
+#endif /* __ATK_PLUG_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkregistry.h b/other-licenses/atk-1.0/atk/atkregistry.h
new file mode 100644
index 0000000000..3ab0414ae7
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkregistry.h
@@ -0,0 +1,69 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_REGISTRY_H__
+#define __ATK_REGISTRY_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <glib-object.h>
+#include "atkobjectfactory.h"
+
+#define ATK_TYPE_REGISTRY (atk_registry_get_type ())
+#define ATK_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_REGISTRY, AtkRegistry))
+#define ATK_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_REGISTRY, AtkRegistryClass))
+#define ATK_IS_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_REGISTRY))
+#define ATK_IS_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_REGISTRY))
+#define ATK_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_REGISTRY, AtkRegistryClass))
+
+struct _AtkRegistry
+{
+ GObject parent;
+ GHashTable *factory_type_registry;
+ GHashTable *factory_singleton_cache;
+};
+
+struct _AtkRegistryClass
+{
+ GObjectClass parent_class;
+};
+
+typedef struct _AtkRegistry AtkRegistry;
+typedef struct _AtkRegistryClass AtkRegistryClass;
+
+
+GType atk_registry_get_type (void);
+void atk_registry_set_factory_type (AtkRegistry *registry,
+ GType type,
+ GType factory_type);
+GType atk_registry_get_factory_type (AtkRegistry *registry,
+ GType type);
+AtkObjectFactory* atk_registry_get_factory (AtkRegistry *registry,
+ GType type);
+
+AtkRegistry* atk_get_default_registry (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __ATK_REGISTRY_H__ */
+
diff --git a/other-licenses/atk-1.0/atk/atkrelation.h b/other-licenses/atk-1.0/atk/atkrelation.h
new file mode 100644
index 0000000000..08b0708f14
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkrelation.h
@@ -0,0 +1,88 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_RELATION_H__
+#define __ATK_RELATION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <glib-object.h>
+#include <atk/atkrelationtype.h>
+
+/*
+ * An AtkRelation describes a relation between the object and one or more
+ * other objects. The actual relations that an object has with other objects
+ * are defined as an AtkRelationSet, which is a set of AtkRelations.
+ */
+
+#define ATK_TYPE_RELATION (atk_relation_get_type ())
+#define ATK_RELATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_RELATION, AtkRelation))
+#define ATK_RELATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_RELATION, AtkRelationClass))
+#define ATK_IS_RELATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_RELATION))
+#define ATK_IS_RELATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_RELATION))
+#define ATK_RELATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_RELATION, AtkRelationClass))
+
+typedef struct _AtkRelation AtkRelation;
+typedef struct _AtkRelationClass AtkRelationClass;
+
+struct _AtkRelation
+{
+ GObject parent;
+
+ GPtrArray *target;
+ AtkRelationType relationship;
+};
+
+struct _AtkRelationClass
+{
+ GObjectClass parent;
+};
+
+GType atk_relation_get_type (void);
+
+AtkRelationType atk_relation_type_register (const gchar *name);
+G_CONST_RETURN gchar* atk_relation_type_get_name (AtkRelationType type);
+AtkRelationType atk_relation_type_for_name (const gchar *name);
+
+/*
+ * Create a new relation for the specified key and the specified list
+ * of targets.
+ */
+AtkRelation* atk_relation_new (AtkObject **targets,
+ gint n_targets,
+ AtkRelationType relationship);
+/*
+ * Returns the type of a relation.
+ */
+AtkRelationType atk_relation_get_relation_type (AtkRelation *relation);
+/*
+ * Returns the target list of a relation.
+ */
+GPtrArray* atk_relation_get_target (AtkRelation *relation);
+void atk_relation_add_target (AtkRelation *relation,
+ AtkObject *target);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __ATK_RELATION_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkrelationset.h b/other-licenses/atk-1.0/atk/atkrelationset.h
new file mode 100644
index 0000000000..2225baf906
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkrelationset.h
@@ -0,0 +1,79 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_RELATION_SET_H__
+#define __ATK_RELATION_SET_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <glib-object.h>
+#include <atk/atkobject.h>
+#include <atk/atkrelation.h>
+
+#define ATK_TYPE_RELATION_SET (atk_relation_set_get_type ())
+#define ATK_RELATION_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_RELATION_SET, AtkRelationSet))
+#define ATK_RELATION_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_RELATION_SET, AtkRelationSetClass))
+#define ATK_IS_RELATION_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_RELATION_SET))
+#define ATK_IS_RELATION_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_RELATION_SET))
+#define ATK_RELATION_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_RELATION_SET, AtkRelationSetClass))
+
+typedef struct _AtkRelationSetClass AtkRelationSetClass;
+
+
+struct _AtkRelationSet
+{
+ GObject parent;
+
+ GPtrArray *relations;
+};
+
+struct _AtkRelationSetClass
+{
+ GObjectClass parent;
+
+ AtkFunction pad1;
+ AtkFunction pad2;
+};
+
+GType atk_relation_set_get_type (void);
+
+AtkRelationSet* atk_relation_set_new (void);
+gboolean atk_relation_set_contains (AtkRelationSet *set,
+ AtkRelationType relationship);
+void atk_relation_set_remove (AtkRelationSet *set,
+ AtkRelation *relation);
+void atk_relation_set_add (AtkRelationSet *set,
+ AtkRelation *relation);
+gint atk_relation_set_get_n_relations (AtkRelationSet *set);
+AtkRelation* atk_relation_set_get_relation (AtkRelationSet *set,
+ gint i);
+AtkRelation* atk_relation_set_get_relation_by_type (AtkRelationSet *set,
+ AtkRelationType relationship);
+void atk_relation_set_add_relation_by_type (AtkRelationSet *set,
+ AtkRelationType relationship,
+ AtkObject *target);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_RELATION_SET_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkrelationtype.h b/other-licenses/atk-1.0/atk/atkrelationtype.h
new file mode 100644
index 0000000000..d1c7410875
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkrelationtype.h
@@ -0,0 +1,115 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2002 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (ATK_COMPILATION)
+#error "Only <atk/atk.h> can be included directly."
+#endif
+
+#ifndef __ATK_RELATION_TYPE_H__
+#define __ATK_RELATION_TYPE_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/**
+ *AtkRelationType:
+ *@ATK_RELATION_NULL: Not used, represens "no relationship" or an error condition.
+ *@ATK_RELATION_CONTROLLED_BY: Indicates an object controlled by one or more target objects.
+ *@ATK_RELATION_CONTROLLER_FOR: Indicates an object is an controller for one or more target objects.
+ *@ATK_RELATION_LABEL_FOR: Indicates an object is a label for one or more target objects.
+ *@ATK_RELATION_LABELLED_BY: Indicates an object is labelled by one or more target objects.
+ *@ATK_RELATION_MEMBER_OF: Indicates an object is a member of a group of one or more target objects.
+ *@ATK_RELATION_NODE_CHILD_OF: Indicates an object is a cell in a treetable which is displayed because a cell in the same column is expanded and identifies that cell.
+ *@ATK_RELATION_FLOWS_TO: Indicates that the object has content that flows logically to another
+ * AtkObject in a sequential way, (for instance text-flow).
+ *@ATK_RELATION_FLOWS_FROM: Indicates that the object has content that flows logically from
+ * another AtkObject in a sequential way, (for instance text-flow).
+ *@ATK_RELATION_SUBWINDOW_OF: Indicates a subwindow attached to a component but otherwise has no connection in the UI heirarchy to that component.
+ *@ATK_RELATION_EMBEDS: Indicates that the object visually embeds
+ * another object's content, i.e. this object's content flows around
+ * another's content.
+ *@ATK_RELATION_EMBEDDED_BY: Reciprocal of %ATK_RELATION_EMBEDS, indicates that
+ * this object's content is visualy embedded in another object.
+ *@ATK_RELATION_POPUP_FOR: Indicates that an object is a popup for another object.
+ *@ATK_RELATION_PARENT_WINDOW_OF: Indicates that an object is a parent window of another object.
+ *@ATK_RELATION_DESCRIBED_BY: Reciprocal of %ATK_RELATION_DESCRIPTION_FOR. Indicates that one
+ * or more target objects provide descriptive information about this object. This relation
+ * type is most appropriate for information that is not essential as its presentation may
+ * be user-configurable and/or limited to an on-demand mechanism such as an assistive
+ * technology command. For brief, essential information such as can be found in a widget's
+ * on-screen label, use %ATK_RELATION_LABELLED_BY. For an on-screen error message, use
+ * %ATK_RELATION_ERROR_MESSAGE. For lengthy extended descriptive information contained in
+ * an on-screen object, consider using %ATK_RELATION_DETAILS as assistive technologies may
+ * provide a means for the user to navigate to objects containing detailed descriptions so
+ * that their content can be more closely reviewed.
+ *@ATK_RELATION_DESCRIPTION_FOR: Reciprocal of %ATK_RELATION_DESCRIBED_BY. Indicates that this
+ * object provides descriptive information about the target object(s). See also
+ * %ATK_RELATION_DETAILS_FOR and %ATK_RELATION_ERROR_FOR.
+ *@ATK_RELATION_NODE_PARENT_OF: Indicates an object is a cell in a treetable and is expanded to display other cells in the same column.
+ *@ATK_RELATION_DETAILS: Reciprocal of %ATK_RELATION_DETAILS_FOR. Indicates that this object
+ * has a detailed or extended description, the contents of which can be found in the target
+ * object(s). This relation type is most appropriate for information that is sufficiently
+ * lengthy as to make navigation to the container of that information desirable. For less
+ * verbose information suitable for announcement only, see %ATK_RELATION_DESCRIBED_BY. If
+ * the detailed information describes an error condition, %ATK_RELATION_ERROR_FOR should be
+ * used instead. @Since: ATK-2.26.
+ *@ATK_RELATION_DETAILS_FOR: Reciprocal of %ATK_RELATION_DETAILS. Indicates that this object
+ * provides a detailed or extended description about the target object(s). See also
+ * %ATK_RELATION_DESCRIPTION_FOR and %ATK_RELATION_ERROR_FOR. @Since: ATK-2.26.
+ *@ATK_RELATION_ERROR_MESSAGE: Reciprocal of %ATK_RELATION_ERROR_FOR. Indicates that this object
+ * has one or more errors, the nature of which is described in the contents of the target
+ * object(s). Objects that have this relation type should also contain %ATK_STATE_INVALID_ENTRY
+ * in their #AtkStateSet. @Since: ATK-2.26.
+ *@ATK_RELATION_ERROR_FOR: Reciprocal of %ATK_RELATION_ERROR_MESSAGE. Indicates that this object
+ * contains an error message describing an invalid condition in the target object(s). @Since:
+ * ATK_2.26.
+ *@ATK_RELATION_LAST_DEFINED: Not used, this value indicates the end of the enumeration.
+ *
+ *Describes the type of the relation
+ **/
+typedef enum
+{
+ ATK_RELATION_NULL = 0,
+ ATK_RELATION_CONTROLLED_BY,
+ ATK_RELATION_CONTROLLER_FOR,
+ ATK_RELATION_LABEL_FOR,
+ ATK_RELATION_LABELLED_BY,
+ ATK_RELATION_MEMBER_OF,
+ ATK_RELATION_NODE_CHILD_OF,
+ ATK_RELATION_FLOWS_TO,
+ ATK_RELATION_FLOWS_FROM,
+ ATK_RELATION_SUBWINDOW_OF,
+ ATK_RELATION_EMBEDS,
+ ATK_RELATION_EMBEDDED_BY,
+ ATK_RELATION_POPUP_FOR,
+ ATK_RELATION_PARENT_WINDOW_OF,
+ ATK_RELATION_DESCRIBED_BY,
+ ATK_RELATION_DESCRIPTION_FOR,
+ ATK_RELATION_NODE_PARENT_OF,
+ ATK_RELATION_DETAILS,
+ ATK_RELATION_DETAILS_FOR,
+ ATK_RELATION_ERROR_MESSAGE,
+ ATK_RELATION_ERROR_FOR,
+ ATK_RELATION_LAST_DEFINED
+} AtkRelationType;
+
+G_END_DECLS
+
+#endif /* __ATK_RELATION_TYPE_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkselection.h b/other-licenses/atk-1.0/atk/atkselection.h
new file mode 100644
index 0000000000..7b16930c1f
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkselection.h
@@ -0,0 +1,96 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_SELECTION_H__
+#define __ATK_SELECTION_H__
+
+#include <atk/atkobject.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * This AtkSelection interface provides the standard mechanism for an
+ * assistive technology to determine what the current selected children are,
+ * as well as modify the selection set. Any object that has children that
+ * can be selected should support the AtkSelection interface.
+ */
+
+#define ATK_TYPE_SELECTION (atk_selection_get_type ())
+#define ATK_IS_SELECTION(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_SELECTION)
+#define ATK_SELECTION(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_SELECTION, AtkSelection)
+#define ATK_SELECTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_SELECTION, AtkSelectionIface))
+
+#ifndef _TYPEDEF_ATK_SELECTION_
+#define _TYPEDEF_ATK_SELECTION_
+typedef struct _AtkSelection AtkSelection;
+#endif
+typedef struct _AtkSelectionIface AtkSelectionIface;
+
+struct _AtkSelectionIface
+{
+ GTypeInterface parent;
+
+ gboolean (* add_selection) (AtkSelection *selection,
+ gint i);
+ gboolean (* clear_selection) (AtkSelection *selection);
+ AtkObject* (* ref_selection) (AtkSelection *selection,
+ gint i);
+ gint (* get_selection_count) (AtkSelection *selection);
+ gboolean (* is_child_selected) (AtkSelection *selection,
+ gint i);
+ gboolean (* remove_selection) (AtkSelection *selection,
+ gint i);
+ gboolean (* select_all_selection) (AtkSelection *selection);
+
+ /* signal handlers */
+
+ void (*selection_changed) (AtkSelection *selection);
+
+ AtkFunction pad1;
+ AtkFunction pad2;
+};
+
+GType atk_selection_get_type (void);
+
+gboolean atk_selection_add_selection (AtkSelection *selection,
+ gint i);
+
+gboolean atk_selection_clear_selection (AtkSelection *selection);
+
+AtkObject* atk_selection_ref_selection (AtkSelection *selection,
+ gint i);
+
+gint atk_selection_get_selection_count (AtkSelection *selection);
+
+gboolean atk_selection_is_child_selected (AtkSelection *selection,
+ gint i);
+
+gboolean atk_selection_remove_selection (AtkSelection *selection,
+ gint i);
+
+gboolean atk_selection_select_all_selection (AtkSelection *selection);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_SELECTION_H__ */
diff --git a/other-licenses/atk-1.0/atk/atksocket.h b/other-licenses/atk-1.0/atk/atksocket.h
new file mode 100644
index 0000000000..813d4f3c97
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atksocket.h
@@ -0,0 +1,65 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2009 Novell, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (ATK_COMPILATION)
+#error "Only <atk/atk.h> can be included directly."
+#endif
+
+#ifndef __ATK_SOCKET_H__
+#define __ATK_SOCKET_H__
+
+G_BEGIN_DECLS
+
+#define ATK_TYPE_SOCKET (atk_socket_get_type ())
+#define ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_SOCKET, AtkSocket))
+#define ATK_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_SOCKET))
+#define ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_SOCKET, AtkSocketClass))
+#define ATK_IS_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_SOCKET))
+#define ATK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_SOCKET, AtkSocketClass))
+
+typedef struct _AtkSocket AtkSocket;
+typedef struct _AtkSocketClass AtkSocketClass;
+
+struct _AtkSocket
+{
+ AtkObject parent;
+
+ /*< private >*/
+ gchar* embedded_plug_id;
+};
+
+GType atk_socket_get_type (void);
+
+struct _AtkSocketClass
+{
+ AtkObjectClass parent_class;
+
+ /* to be subscribed to by atk-bridge */
+
+ /*< protected >*/
+ void (* embed) (AtkSocket *obj, gchar* plug_id);
+};
+
+AtkObject* atk_socket_new (void);
+void atk_socket_embed (AtkSocket* obj, gchar* plug_id);
+gboolean atk_socket_is_occupied (AtkSocket* obj);
+
+G_END_DECLS
+
+#endif /* __ATK_SOCKET_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkstate.h b/other-licenses/atk-1.0/atk/atkstate.h
new file mode 100644
index 0000000000..a3912e98da
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkstate.h
@@ -0,0 +1,198 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_STATE_H__
+#define __ATK_STATE_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/**
+ *AtkStateType:
+ *@ATK_STATE_INVALID: Indicates an invalid state - probably an error condition.
+ *@ATK_STATE_ACTIVE: Indicates a window is currently the active window, or an object is the active subelement within a container or table. ATK_STATE_ACTIVE should not be used for objects which have ATK_STATE_FOCUSABLE or ATK_STATE_SELECTABLE: Those objects should use ATK_STATE_FOCUSED and ATK_STATE_SELECTED respectively. ATK_STATE_ACTIVE is a means to indicate that an object which is not focusable and not selectable is the currently-active item within its parent container.
+ *@ATK_STATE_ARMED: Indicates that the object is 'armed', i.e. will be activated by if a pointer button-release event occurs within its bounds. Buttons often enter this state when a pointer click occurs within their bounds, as a precursor to activation. ATK_STATE_ARMED has been deprecated since ATK-2.16 and should not be used in newly-written code.
+ *@ATK_STATE_BUSY: Indicates the current object is busy, i.e. onscreen representation is in the process of changing, or the object is temporarily unavailable for interaction due to activity already in progress. This state may be used by implementors of Document to indicate that content loading is underway. It also may indicate other 'pending' conditions; clients may wish to interrogate this object when the ATK_STATE_BUSY flag is removed.
+ *@ATK_STATE_CHECKED: Indicates this object is currently checked, for instance a checkbox is 'non-empty'.
+ *@ATK_STATE_DEFUNCT: Indicates that this object no longer has a valid backing widget (for instance, if its peer object has been destroyed)
+ *@ATK_STATE_EDITABLE: Indicates that this object can contain text, and that the
+ * user can change the textual contents of this object by editing those contents
+ * directly. For an object which is expected to be editable due to its type, but
+ * which cannot be edited due to the application or platform preventing the user
+ * from doing so, that object's #AtkStateSet should lack ATK_STATE_EDITABLE and
+ * should contain ATK_STATE_READ_ONLY.
+ *@ATK_STATE_ENABLED: Indicates that this object is enabled, i.e. that it currently reflects some application state. Objects that are "greyed out" may lack this state, and may lack the STATE_SENSITIVE if direct user interaction cannot cause them to acquire STATE_ENABLED. See also: ATK_STATE_SENSITIVE
+ *@ATK_STATE_EXPANDABLE: Indicates this object allows progressive disclosure of its children
+ *@ATK_STATE_EXPANDED: Indicates this object its expanded - see ATK_STATE_EXPANDABLE above
+ *@ATK_STATE_FOCUSABLE: Indicates this object can accept keyboard focus, which means all events resulting from typing on the keyboard will normally be passed to it when it has focus
+ *@ATK_STATE_FOCUSED: Indicates this object currently has the keyboard focus
+ *@ATK_STATE_HORIZONTAL: Indicates the orientation of this object is horizontal; used, for instance, by objects of ATK_ROLE_SCROLL_BAR. For objects where vertical/horizontal orientation is especially meaningful.
+ *@ATK_STATE_ICONIFIED: Indicates this object is minimized and is represented only by an icon
+ *@ATK_STATE_MODAL: Indicates something must be done with this object before the user can interact with an object in a different window
+ *@ATK_STATE_MULTI_LINE: Indicates this (text) object can contain multiple lines of text
+ *@ATK_STATE_MULTISELECTABLE: Indicates this object allows more than one of its children to be selected at the same time, or in the case of text objects, that the object supports non-contiguous text selections.
+ *@ATK_STATE_OPAQUE: Indicates this object paints every pixel within its rectangular region.
+ *@ATK_STATE_PRESSED: Indicates this object is currently pressed.
+ *@ATK_STATE_RESIZABLE: Indicates the size of this object is not fixed
+ *@ATK_STATE_SELECTABLE: Indicates this object is the child of an object that allows its children to be selected and that this child is one of those children that can be selected
+ *@ATK_STATE_SELECTED: Indicates this object is the child of an object that allows its children to be selected and that this child is one of those children that has been selected
+ *@ATK_STATE_SENSITIVE: Indicates this object is sensitive, e.g. to user interaction.
+ * STATE_SENSITIVE usually accompanies STATE_ENABLED for user-actionable controls,
+ * but may be found in the absence of STATE_ENABLED if the current visible state of the
+ * control is "disconnected" from the application state. In such cases, direct user interaction
+ * can often result in the object gaining STATE_SENSITIVE, for instance if a user makes
+ * an explicit selection using an object whose current state is ambiguous or undefined.
+ * @see STATE_ENABLED, STATE_INDETERMINATE.
+ *@ATK_STATE_SHOWING: Indicates this object, the object's parent, the object's parent's parent, and so on,
+ * are all 'shown' to the end-user, i.e. subject to "exposure" if blocking or obscuring objects do not interpose
+ * between this object and the top of the window stack.
+ *@ATK_STATE_SINGLE_LINE: Indicates this (text) object can contain only a single line of text
+ *@ATK_STATE_STALE: Indicates that the information returned for this object may no longer be
+ * synchronized with the application state. This is implied if the object has STATE_TRANSIENT,
+ * and can also occur towards the end of the object peer's lifecycle. It can also be used to indicate that
+ * the index associated with this object has changed since the user accessed the object (in lieu of
+ * "index-in-parent-changed" events).
+ *@ATK_STATE_TRANSIENT: Indicates this object is transient, i.e. a snapshot which may not emit events when its
+ * state changes. Data from objects with ATK_STATE_TRANSIENT should not be cached, since there may be no
+ * notification given when the cached data becomes obsolete.
+ *@ATK_STATE_VERTICAL: Indicates the orientation of this object is vertical
+ *@ATK_STATE_VISIBLE: Indicates this object is visible, e.g. has been explicitly marked for exposure to the user.
+ * @note: STATE_VISIBLE is no guarantee that the object is actually unobscured on the screen, only
+ * that it is 'potentially' visible, barring obstruction, being scrolled or clipped out of the
+ * field of view, or having an ancestor container that has not yet made visible.
+ * A widget is potentially onscreen if it has both STATE_VISIBLE and STATE_SHOWING.
+ * The absence of STATE_VISIBLE and STATE_SHOWING is semantically equivalent to saying
+ * that an object is 'hidden'. See also STATE_TRUNCATED, which applies if a VISIBLE and SHOWING object
+ * lies within a viewport which means that its contents are clipped, e.g. a truncated spreadsheet cell or
+ * an image within a scrolling viewport. Mostly useful for screen-review and magnification algorithms.
+ *@ATK_STATE_MANAGES_DESCENDANTS: Indicates that "active-descendant-changed" event
+ * is sent when children become 'active' (i.e. are selected or navigated to onscreen).
+ * Used to prevent need to enumerate all children in very large containers, like tables.
+ * The presence of STATE_MANAGES_DESCENDANTS is an indication to the client.
+ * that the children should not, and need not, be enumerated by the client.
+ * Objects implementing this state are expected to provide relevant state
+ * notifications to listening clients, for instance notifications of visibility
+ * changes and activation of their contained child objects, without the client
+ * having previously requested references to those children.
+ *@ATK_STATE_INDETERMINATE: Indicates that the value, or some other quantifiable
+ * property, of this AtkObject cannot be fully determined. In the case of a large
+ * data set in which the total number of items in that set is unknown (e.g. 1 of
+ * 999+), implementors should expose the currently-known set size (999) along
+ * with this state. In the case of a check box, this state should be used to
+ * indicate that the check box is a tri-state check box which is currently
+ * neither checked nor unchecked.
+ *@ATK_STATE_TRUNCATED: Indicates that an object is truncated, e.g. a text value in a speradsheet cell.
+ *@ATK_STATE_REQUIRED: Indicates that explicit user interaction with an object is required by the user interface, e.g. a required field in a "web-form" interface.
+ *@ATK_STATE_INVALID_ENTRY: Indicates that the object has encountered an error condition due to failure of input validation. For instance, a form control may acquire this state in response to invalid or malformed user input.
+ *@ATK_STATE_SUPPORTS_AUTOCOMPLETION: Indicates that the object in question implements some form of ¨typeahead¨ or
+ * pre-selection behavior whereby entering the first character of one or more sub-elements
+ * causes those elements to scroll into view or become selected. Subsequent character input
+ * may narrow the selection further as long as one or more sub-elements match the string.
+ * This state is normally only useful and encountered on objects that implement Selection.
+ * In some cases the typeahead behavior may result in full or partial ¨completion¨ of
+ * the data in the input field, in which case these input events may trigger text-changed
+ * events from the AtkText interface. This state supplants @ATK_ROLE_AUTOCOMPLETE.
+ *@ATK_STATE_SELECTABLE_TEXT:Indicates that the object in question supports text selection. It should only be exposed on objects which implement the Text interface, in order to distinguish this state from @ATK_STATE_SELECTABLE, which infers that the object in question is a selectable child of an object which implements Selection. While similar, text selection and subelement selection are distinct operations.
+ *@ATK_STATE_DEFAULT: Indicates that the object is the "default" active component, i.e. the object which is activated by an end-user press of the "Enter" or "Return" key. Typically a "close" or "submit" button.
+ *@ATK_STATE_ANIMATED: Indicates that the object changes its appearance dynamically as an inherent part of its presentation. This state may come and go if an object is only temporarily animated on the way to a 'final' onscreen presentation.
+ * @note some applications, notably content viewers, may not be able to detect
+ * all kinds of animated content. Therefore the absence of this state should not
+ * be taken as definitive evidence that the object's visual representation is
+ * static; this state is advisory.
+ *@ATK_STATE_VISITED: Indicates that the object (typically a hyperlink) has already been 'activated', and/or its backing data has already been downloaded, rendered, or otherwise "visited".
+ *@ATK_STATE_CHECKABLE: Indicates this object has the potential to be
+ * checked, such as a checkbox or toggle-able table cell. @Since:
+ * ATK-2.12
+ *@ATK_STATE_HAS_POPUP: Indicates that the object has a popup context
+ * menu or sub-level menu which may or may not be showing. This means
+ * that activation renders conditional content. Note that ordinary
+ * tooltips are not considered popups in this context. @Since: ATK-2.12
+ *@ATK_STATE_HAS_TOOLTIP: Indicates this object has a tooltip. @Since: ATK-2.16
+ *@ATK_STATE_READ_ONLY: Indicates that a widget which is ENABLED and SENSITIVE
+ * has a value which can be read, but not modified, by the user. Note that this
+ * state should only be applied to widget types whose value is normally directly
+ * user modifiable, such as check boxes, radio buttons, spin buttons, text input
+ * fields, and combo boxes, as a means to convey that the expected interaction
+ * with that widget is not possible. When the expected interaction with a
+ * widget does not include modification by the user, as is the case with
+ * labels and containers, ATK_STATE_READ_ONLY should not be applied. See also
+ * ATK_STATE_EDITABLE. @Since: ATK-2-16
+ *@ATK_STATE_LAST_DEFINED: Not a valid state, used for finding end of enumeration
+ *
+ *The possible types of states of an object
+ **/
+typedef enum
+{
+ ATK_STATE_INVALID,
+ ATK_STATE_ACTIVE,
+ ATK_STATE_ARMED,
+ ATK_STATE_BUSY,
+ ATK_STATE_CHECKED,
+ ATK_STATE_DEFUNCT,
+ ATK_STATE_EDITABLE,
+ ATK_STATE_ENABLED,
+ ATK_STATE_EXPANDABLE,
+ ATK_STATE_EXPANDED,
+ ATK_STATE_FOCUSABLE,
+ ATK_STATE_FOCUSED,
+ ATK_STATE_HORIZONTAL,
+ ATK_STATE_ICONIFIED,
+ ATK_STATE_MODAL,
+ ATK_STATE_MULTI_LINE,
+ ATK_STATE_MULTISELECTABLE,
+ ATK_STATE_OPAQUE,
+ ATK_STATE_PRESSED,
+ ATK_STATE_RESIZABLE,
+ ATK_STATE_SELECTABLE,
+ ATK_STATE_SELECTED,
+ ATK_STATE_SENSITIVE,
+ ATK_STATE_SHOWING,
+ ATK_STATE_SINGLE_LINE,
+ ATK_STATE_STALE,
+ ATK_STATE_TRANSIENT,
+ ATK_STATE_VERTICAL,
+ ATK_STATE_VISIBLE,
+ ATK_STATE_MANAGES_DESCENDANTS,
+ ATK_STATE_INDETERMINATE,
+ ATK_STATE_TRUNCATED,
+ ATK_STATE_REQUIRED,
+ ATK_STATE_INVALID_ENTRY,
+ ATK_STATE_SUPPORTS_AUTOCOMPLETION,
+ ATK_STATE_SELECTABLE_TEXT,
+ ATK_STATE_DEFAULT,
+ ATK_STATE_ANIMATED,
+ ATK_STATE_VISITED,
+ ATK_STATE_CHECKABLE,
+ ATK_STATE_HAS_POPUP,
+ ATK_STATE_HAS_TOOLTIP,
+ ATK_STATE_READ_ONLY,
+ ATK_STATE_LAST_DEFINED
+} AtkStateType;
+
+typedef guint64 AtkState;
+
+AtkStateType atk_state_type_register (const gchar *name);
+
+const gchar* atk_state_type_get_name (AtkStateType type);
+AtkStateType atk_state_type_for_name (const gchar *name);
+
+G_END_DECLS
+
+#endif /* __ATK_STATE_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkstateset.h b/other-licenses/atk-1.0/atk/atkstateset.h
new file mode 100644
index 0000000000..43c3ea3d1b
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkstateset.h
@@ -0,0 +1,81 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_STATE_SET_H__
+#define __ATK_STATE_SET_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <glib-object.h>
+#include <atk/atkobject.h>
+#include <atk/atkstate.h>
+
+#define ATK_TYPE_STATE_SET (atk_state_set_get_type ())
+#define ATK_STATE_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_STATE_SET, AtkStateSet))
+#define ATK_STATE_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_STATE_SET, AtkStateSetClass))
+#define ATK_IS_STATE_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_STATE_SET))
+#define ATK_IS_STATE_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_STATE_SET))
+#define ATK_STATE_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_STATE_SET, AtkStateSetClass))
+
+typedef struct _AtkStateSetClass AtkStateSetClass;
+
+
+struct _AtkStateSet
+{
+ GObject parent;
+
+};
+
+struct _AtkStateSetClass
+{
+ GObjectClass parent;
+};
+
+GType atk_state_set_get_type (void);
+
+AtkStateSet* atk_state_set_new (void);
+gboolean atk_state_set_is_empty (AtkStateSet *set);
+gboolean atk_state_set_add_state (AtkStateSet *set,
+ AtkStateType type);
+void atk_state_set_add_states (AtkStateSet *set,
+ AtkStateType *types,
+ gint n_types);
+void atk_state_set_clear_states (AtkStateSet *set);
+gboolean atk_state_set_contains_state (AtkStateSet *set,
+ AtkStateType type);
+gboolean atk_state_set_contains_states (AtkStateSet *set,
+ AtkStateType *types,
+ gint n_types);
+gboolean atk_state_set_remove_state (AtkStateSet *set,
+ AtkStateType type);
+AtkStateSet* atk_state_set_and_sets (AtkStateSet *set,
+ AtkStateSet *compare_set);
+AtkStateSet* atk_state_set_or_sets (AtkStateSet *set,
+ AtkStateSet *compare_set);
+AtkStateSet* atk_state_set_xor_sets (AtkStateSet *set,
+ AtkStateSet *compare_set);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_STATE_SET_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkstreamablecontent.h b/other-licenses/atk-1.0/atk/atkstreamablecontent.h
new file mode 100644
index 0000000000..abdbfa9590
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkstreamablecontent.h
@@ -0,0 +1,107 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_STREAMABLE_CONTENT_H__
+#define __ATK_STREAMABLE_CONTENT_H__
+
+#include <atk/atkobject.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define ATK_TYPE_STREAMABLE_CONTENT (atk_streamable_content_get_type ())
+#define ATK_IS_STREAMABLE_CONTENT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_STREAMABLE_CONTENT)
+#define ATK_STREAMABLE_CONTENT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_STREAMABLE_CONTENT, AtkStreamableContent)
+#define ATK_STREAMABLE_CONTENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_STREAMABLE_CONTENT, AtkStreamableContentIface))
+
+#ifndef _TYPEDEF_ATK_STREAMABLE_CONTENT
+#define _TYPEDEF_ATK_STREAMABLE_CONTENT
+typedef struct _AtkStreamableContent AtkStreamableContent;
+#endif
+typedef struct _AtkStreamableContentIface AtkStreamableContentIface;
+
+struct _AtkStreamableContentIface
+{
+ GTypeInterface parent;
+
+ /*
+ * Get the number of mime types supported by this object
+ */
+ gint (* get_n_mime_types) (AtkStreamableContent *streamable);
+ /*
+ * Gets the specified mime type supported by this object.
+ * The mime types are 0-based so the first mime type is
+ * at index 0, the second at index 1 and so on. The mime-type
+ * at index 0 should be considered the "default" data type for the stream.
+ *
+ * This assumes that the strings for the mime types are stored in the
+ * AtkStreamableContent. Alternatively the G_CONST_RETURN could be removed
+ * and the caller would be responsible for calling g_free() on the
+ * returned value.
+ */
+ G_CONST_RETURN gchar* (* get_mime_type) (AtkStreamableContent *streamable,
+ gint i);
+ /*
+ * One possible implementation for this method is that it constructs the
+ * content appropriate for the mime type and then creates a temporary
+ * file containing the content, opens the file and then calls
+ * g_io_channel_unix_new_fd().
+ */
+ GIOChannel* (* get_stream) (AtkStreamableContent *streamable,
+ const gchar *mime_type);
+
+/*
+ * Returns a string representing a URI in IETF standard format
+ * (see http://www.ietf.org/rfc/rfc2396.txt) from which the object's content
+ * may be streamed in the specified mime-type.
+ * If mime_type is NULL, the URI for the default (and possibly only) mime-type is
+ * returned.
+ *
+ * returns NULL if the mime-type is not supported, or if no URI can be
+ * constructed. Note that it is possible for get_uri to return NULL but for
+ * get_stream to work nonetheless, since not all GIOChannels connect to URIs.
+ */
+ G_CONST_RETURN gchar* (* get_uri) (AtkStreamableContent *streamable,
+ const gchar *mime_type);
+
+
+ AtkFunction pad1;
+ AtkFunction pad2;
+ AtkFunction pad3;
+};
+GType atk_streamable_content_get_type (void);
+
+gint atk_streamable_content_get_n_mime_types (AtkStreamableContent *streamable);
+
+G_CONST_RETURN gchar* atk_streamable_content_get_mime_type (AtkStreamableContent *streamable,
+ gint i);
+GIOChannel* atk_streamable_content_get_stream (AtkStreamableContent *streamable,
+ const gchar *mime_type);
+
+gchar* atk_streamable_content_get_uri (AtkStreamableContent *streamable,
+ const gchar *mime_type);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_STREAMABLE_CONTENT_H__ */
diff --git a/other-licenses/atk-1.0/atk/atktable.h b/other-licenses/atk-1.0/atk/atktable.h
new file mode 100644
index 0000000000..790fbb4481
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atktable.h
@@ -0,0 +1,218 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_TABLE_H__
+#define __ATK_TABLE_H__
+
+#include <atk/atkobject.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * AtkTable describes a user-interface component that presents data in
+ * two-dimensional table format.
+ */
+
+
+#define ATK_TYPE_TABLE (atk_table_get_type ())
+#define ATK_IS_TABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TABLE)
+#define ATK_TABLE(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TABLE, AtkTable)
+#define ATK_TABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TABLE, AtkTableIface))
+
+#ifndef _TYPEDEF_ATK_TABLE_
+#define _TYPEDEF_ATK_TABLE_
+typedef struct _AtkTable AtkTable;
+#endif
+typedef struct _AtkTableIface AtkTableIface;
+
+struct _AtkTableIface
+{
+ GTypeInterface parent;
+
+ AtkObject* (* ref_at) (AtkTable *table,
+ gint row,
+ gint column);
+ gint (* get_index_at) (AtkTable *table,
+ gint row,
+ gint column);
+ gint (* get_column_at_index) (AtkTable *table,
+ gint index_);
+ gint (* get_row_at_index) (AtkTable *table,
+ gint index_);
+ gint (* get_n_columns) (AtkTable *table);
+ gint (* get_n_rows) (AtkTable *table);
+ gint (* get_column_extent_at) (AtkTable *table,
+ gint row,
+ gint column);
+ gint (* get_row_extent_at) (AtkTable *table,
+ gint row,
+ gint column);
+ AtkObject*
+ (* get_caption) (AtkTable *table);
+ G_CONST_RETURN gchar*
+ (* get_column_description) (AtkTable *table,
+ gint column);
+ AtkObject* (* get_column_header) (AtkTable *table,
+ gint column);
+ G_CONST_RETURN gchar*
+ (* get_row_description) (AtkTable *table,
+ gint row);
+ AtkObject* (* get_row_header) (AtkTable *table,
+ gint row);
+ AtkObject* (* get_summary) (AtkTable *table);
+ void (* set_caption) (AtkTable *table,
+ AtkObject *caption);
+ void (* set_column_description) (AtkTable *table,
+ gint column,
+ const gchar *description);
+ void (* set_column_header) (AtkTable *table,
+ gint column,
+ AtkObject *header);
+ void (* set_row_description) (AtkTable *table,
+ gint row,
+ const gchar *description);
+ void (* set_row_header) (AtkTable *table,
+ gint row,
+ AtkObject *header);
+ void (* set_summary) (AtkTable *table,
+ AtkObject *accessible);
+ gint (* get_selected_columns) (AtkTable *table,
+ gint **selected);
+ gint (* get_selected_rows) (AtkTable *table,
+ gint **selected);
+ gboolean (* is_column_selected) (AtkTable *table,
+ gint column);
+ gboolean (* is_row_selected) (AtkTable *table,
+ gint row);
+ gboolean (* is_selected) (AtkTable *table,
+ gint row,
+ gint column);
+ gboolean (* add_row_selection) (AtkTable *table,
+ gint row);
+ gboolean (* remove_row_selection) (AtkTable *table,
+ gint row);
+ gboolean (* add_column_selection) (AtkTable *table,
+ gint column);
+ gboolean (* remove_column_selection) (AtkTable *table,
+ gint column);
+
+ /*
+ * signal handlers
+ */
+ void (* row_inserted) (AtkTable *table,
+ gint row,
+ gint num_inserted);
+ void (* column_inserted) (AtkTable *table,
+ gint column,
+ gint num_inserted);
+ void (* row_deleted) (AtkTable *table,
+ gint row,
+ gint num_deleted);
+ void (* column_deleted) (AtkTable *table,
+ gint column,
+ gint num_deleted);
+ void (* row_reordered) (AtkTable *table);
+ void (* column_reordered) (AtkTable *table);
+ void (* model_changed) (AtkTable *table);
+
+ AtkFunction pad1;
+ AtkFunction pad2;
+ AtkFunction pad3;
+ AtkFunction pad4;
+};
+
+GType atk_table_get_type (void);
+
+AtkObject* atk_table_ref_at (AtkTable *table,
+ gint row,
+ gint column);
+gint atk_table_get_index_at (AtkTable *table,
+ gint row,
+ gint column);
+gint atk_table_get_column_at_index (AtkTable *table,
+ gint index_);
+gint atk_table_get_row_at_index (AtkTable *table,
+ gint index_);
+gint atk_table_get_n_columns (AtkTable *table);
+gint atk_table_get_n_rows (AtkTable *table);
+gint atk_table_get_column_extent_at (AtkTable *table,
+ gint row,
+ gint column);
+gint atk_table_get_row_extent_at (AtkTable *table,
+ gint row,
+ gint column);
+AtkObject*
+ atk_table_get_caption (AtkTable *table);
+G_CONST_RETURN gchar*
+ atk_table_get_column_description (AtkTable *table,
+ gint column);
+AtkObject* atk_table_get_column_header (AtkTable *table,
+ gint column);
+G_CONST_RETURN gchar*
+ atk_table_get_row_description (AtkTable *table,
+ gint row);
+AtkObject* atk_table_get_row_header (AtkTable *table,
+ gint row);
+AtkObject* atk_table_get_summary (AtkTable *table);
+void atk_table_set_caption (AtkTable *table,
+ AtkObject *caption);
+void atk_table_set_column_description
+ (AtkTable *table,
+ gint column,
+ const gchar *description);
+void atk_table_set_column_header (AtkTable *table,
+ gint column,
+ AtkObject *header);
+void atk_table_set_row_description (AtkTable *table,
+ gint row,
+ const gchar *description);
+void atk_table_set_row_header (AtkTable *table,
+ gint row,
+ AtkObject *header);
+void atk_table_set_summary (AtkTable *table,
+ AtkObject *accessible);
+gint atk_table_get_selected_columns (AtkTable *table,
+ gint **selected);
+gint atk_table_get_selected_rows (AtkTable *table,
+ gint **selected);
+gboolean atk_table_is_column_selected (AtkTable *table,
+ gint column);
+gboolean atk_table_is_row_selected (AtkTable *table,
+ gint row);
+gboolean atk_table_is_selected (AtkTable *table,
+ gint row,
+ gint column);
+gboolean atk_table_add_row_selection (AtkTable *table,
+ gint row);
+gboolean atk_table_remove_row_selection (AtkTable *table,
+ gint row);
+gboolean atk_table_add_column_selection (AtkTable *table,
+ gint column);
+gboolean atk_table_remove_column_selection
+ (AtkTable *table,
+ gint column);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_TABLE_H__ */
diff --git a/other-licenses/atk-1.0/atk/atktablecell.h b/other-licenses/atk-1.0/atk/atktablecell.h
new file mode 100644
index 0000000000..0e70d69ca6
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atktablecell.h
@@ -0,0 +1,104 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2014 SUSE LLC.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (ATK_COMPILATION)
+#error "Only <atk/atk.h> can be included directly."
+#endif
+
+#ifndef __ATK_TABLE_CELL_H__
+#define __ATK_TABLE_CELL_H__
+
+#include <atk/atkobject.h>
+
+G_BEGIN_DECLS
+
+#define ATK_TYPE_TABLE_CELL (atk_table_cell_get_type ())
+#define ATK_IS_TABLE_CELL(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TABLE_CELL)
+#define ATK_TABLE_CELL(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TABLE_CELL, AtkTableCell)
+#define ATK_TABLE_CELL_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TABLE_CELL, AtkTableCellIface))
+
+#ifndef _TYPEDEF_ATK_TABLE_CELL_
+#define _TYPEDEF_ATK_TABLE_CELL_
+typedef struct _AtkTableCell AtkTableCell;
+#endif
+typedef struct _AtkTableCellIface AtkTableCellIface;
+
+/**
+ * AtkTableCellIface:
+ * @get_column_span: virtual function that returns the number of
+ * columns occupied by this cell accessible. @Since: 2.12
+ * @get_column_header_cells: virtual function that returns the column
+ * headers as an array of cell accessibles. @Since: 2.12
+ * @get_position: virtual function that retrieves the tabular position
+ * of this cell. @Since: 2.12
+ * @get_row_span: virtual function that returns the number of rows
+ * occupied by this cell. @Since: 2.12
+ * @get_row_header_cells: virtual function that returns the row
+ * headers as an array of cell accessibles. @Since: 2.12
+ * @get_row_column_span: virtual function that get the row an column
+ * indexes and span of this cell. @Since: 2.12
+ * @get_table: virtual function that returns a reference to the
+ * accessible of the containing table. @Since: 2.12
+ */
+struct _AtkTableCellIface
+{
+ GTypeInterface parent;
+
+ gint (*get_column_span) (AtkTableCell *cell);
+ GPtrArray * (*get_column_header_cells) (AtkTableCell *cell);
+ gboolean (*get_position) (AtkTableCell *cell,
+ gint *row,
+ gint *column);
+ gint (*get_row_span) (AtkTableCell *cell);
+ GPtrArray * (*get_row_header_cells) (AtkTableCell *cell);
+ gboolean (*get_row_column_span) (AtkTableCell *cell,
+ gint *row,
+ gint *column,
+ gint *row_span,
+ gint *column_span);
+ AtkObject * (*get_table) (AtkTableCell *cell);
+};
+
+ATK_AVAILABLE_IN_2_12
+GType atk_table_cell_get_type (void);
+
+ATK_AVAILABLE_IN_2_12
+gint atk_table_cell_get_column_span (AtkTableCell *cell);
+ATK_AVAILABLE_IN_2_12
+GPtrArray * atk_table_cell_get_column_header_cells (AtkTableCell *cell);
+ATK_AVAILABLE_IN_2_12
+gboolean atk_table_cell_get_position (AtkTableCell *cell,
+ gint *row,
+ gint *column);
+ATK_AVAILABLE_IN_2_12
+gint atk_table_cell_get_row_span (AtkTableCell *cell);
+ATK_AVAILABLE_IN_2_12
+GPtrArray * atk_table_cell_get_row_header_cells (AtkTableCell *cell);
+ATK_AVAILABLE_IN_2_12
+gboolean atk_table_cell_get_row_column_span (AtkTableCell *cell,
+ gint *row,
+ gint *column,
+ gint *row_span,
+ gint *column_span);
+ATK_AVAILABLE_IN_2_12
+AtkObject * atk_table_cell_get_table (AtkTableCell *cell);
+
+G_END_DECLS
+
+#endif /* __ATK_TABLE_CELL_H__ */
diff --git a/other-licenses/atk-1.0/atk/atktext.h b/other-licenses/atk-1.0/atk/atktext.h
new file mode 100644
index 0000000000..9b01b25a9f
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atktext.h
@@ -0,0 +1,436 @@
+/* ATK - The Accessibility Toolkit for GTK+
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef __ATK_TEXT_H__
+#define __ATK_TEXT_H__
+
+#include <glib-object.h>
+#include <atk/atkobject.h>
+#include <atk/atkutil.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ *AtkTextAttribute
+ *@ATK_TEXT_ATTR_INVALID: Invalid attribute
+ *@ATK_TEXT_ATTR_LEFT_MARGIN: The pixel width of the left margin
+ *@ATK_TEXT_ATTR_RIGHT_MARGIN: The pixel width of the right margin
+ *@ATK_TEXT_ATTR_INDENT: The number of pixels that the text is indented
+ *@ATK_TEXT_ATTR_INVISIBLE: Either "true" or "false" indicating whether text is visible or not
+ *@ATK_TEXT_ATTR_EDITABLE: Either "true" or "false" indicating whether text is editable or not
+ *@ATK_TEXT_ATTR_PIXELS_ABOVE_LINES: Pixels of blank space to leave above each newline-terminated line.
+ *@ATK_TEXT_ATTR_PIXELS_BELOW_LINES: Pixels of blank space to leave below each newline-terminated line.
+ *@ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP: Pixels of blank space to leave between wrapped lines inside the same newline-terminated line (paragraph).
+ *@ATK_TEXT_ATTR_BG_FULL_HEIGHT: "true" or "false" whether to make the background color for each character the height of the highest font used on the current line, or the height of the font used for the current character.
+ *@ATK_TEXT_ATTR_RISE: Number of pixels that the characters are risen above the baseline
+ *@ATK_TEXT_ATTR_UNDERLINE: "none", "single", "double" or "low"
+ *@ATK_TEXT_ATTR_STRIKETHROUGH: "true" or "false" whether the text is strikethrough
+ *@ATK_TEXT_ATTR_SIZE: The size of the characters.
+ *@ATK_TEXT_ATTR_SCALE: The scale of the characters. The value is a string representation of a double
+ *@ATK_TEXT_ATTR_WEIGHT: The weight of the characters.
+ *@ATK_TEXT_ATTR_LANGUAGE: The language used
+ *@ATK_TEXT_ATTR_FAMILY_NAME: The font family name
+ *@ATK_TEXT_ATTR_BG_COLOR: The background color. The value is an RGB value of the format "%u,%u,%u"
+ *@ATK_TEXT_ATTR_FG_COLOR:The foreground color. The value is an RGB value of the format "%u,%u,%u"
+ *@ATK_TEXT_ATTR_BG_STIPPLE: "true" if a #GdkBitmap is set for stippling the background color.
+ *@ATK_TEXT_ATTR_FG_STIPPLE: "true" if a #GdkBitmap is set for stippling the foreground color.
+ *@ATK_TEXT_ATTR_WRAP_MODE: The wrap mode of the text, if any. Values are "none", "char" or "word"
+ *@ATK_TEXT_ATTR_DIRECTION: The direction of the text, if set. Values are "none", "ltr" or "rtl"
+ *@ATK_TEXT_ATTR_JUSTIFICATION: The justification of the text, if set. Values are "left", "right", "center" or "fill"
+ *@ATK_TEXT_ATTR_STRETCH: The stretch of the text, if set. Values are "ultra_condensed", "extra_condensed", "condensed", "semi_condensed", "normal", "semi_expanded", "expanded", "extra_expanded" or "ultra_expanded"
+ *@ATK_TEXT_ATTR_VARIANT: The capitalization variant of the text, if set. Values are "normal" or "small_caps"
+ *@ATK_TEXT_ATTR_STYLE: The slant style of the text, if set. Values are "normal", "oblique" or "italic"
+ *@ATK_TEXT_ATTR_LAST_DEFINED: not a valid text attribute, used for finding end of enumeration
+ *
+ * Describes the text attributes supported
+ **/
+typedef enum
+{
+ ATK_TEXT_ATTR_INVALID = 0,
+ ATK_TEXT_ATTR_LEFT_MARGIN,
+ ATK_TEXT_ATTR_RIGHT_MARGIN,
+ ATK_TEXT_ATTR_INDENT,
+ ATK_TEXT_ATTR_INVISIBLE,
+ ATK_TEXT_ATTR_EDITABLE,
+ ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
+ ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
+ ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
+ ATK_TEXT_ATTR_BG_FULL_HEIGHT,
+ ATK_TEXT_ATTR_RISE,
+ ATK_TEXT_ATTR_UNDERLINE,
+ ATK_TEXT_ATTR_STRIKETHROUGH,
+ ATK_TEXT_ATTR_SIZE,
+ ATK_TEXT_ATTR_SCALE,
+ ATK_TEXT_ATTR_WEIGHT,
+ ATK_TEXT_ATTR_LANGUAGE,
+ ATK_TEXT_ATTR_FAMILY_NAME,
+ ATK_TEXT_ATTR_BG_COLOR,
+ ATK_TEXT_ATTR_FG_COLOR,
+ ATK_TEXT_ATTR_BG_STIPPLE,
+ ATK_TEXT_ATTR_FG_STIPPLE,
+ ATK_TEXT_ATTR_WRAP_MODE,
+ ATK_TEXT_ATTR_DIRECTION,
+ ATK_TEXT_ATTR_JUSTIFICATION,
+ ATK_TEXT_ATTR_STRETCH,
+ ATK_TEXT_ATTR_VARIANT,
+ ATK_TEXT_ATTR_STYLE,
+ ATK_TEXT_ATTR_LAST_DEFINED
+} AtkTextAttribute;
+
+AtkTextAttribute atk_text_attribute_register (const gchar *name);
+
+
+#define ATK_TYPE_TEXT (atk_text_get_type ())
+#define ATK_IS_TEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TEXT)
+#define ATK_TEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TEXT, AtkText)
+#define ATK_TEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TEXT, AtkTextIface))
+
+#ifndef _TYPEDEF_ATK_TEXT_
+#define _TYPEDEF_ATK_TEXT_
+typedef struct _AtkText AtkText;
+#endif
+typedef struct _AtkTextIface AtkTextIface;
+
+/**
+ *AtkTextBoundary:
+ *@ATK_TEXT_BOUNDARY_CHAR: Boundary is the boundary between characters
+ * (including non-printing characters)
+ *@ATK_TEXT_BOUNDARY_WORD_START: Boundary is the start (i.e. first character) of a word.
+ *@ATK_TEXT_BOUNDARY_WORD_END: Boundary is the end (i.e. last character) of a word.
+ *@ATK_TEXT_BOUNDARY_SENTENCE_START: Boundary is the first character in a sentence.
+ *@ATK_TEXT_BOUNDARY_SENTENCE_END: Boundary is the last (terminal) character in a sentence;
+ * in languages which use "sentence stop" punctuation such as English, the boundary is thus the
+ * '.', '?', or similar terminal punctuation character.
+ *@ATK_TEXT_BOUNDARY_LINE_START: Boundary is the initial character of the content or a
+ * character immediately following a newline, linefeed, or return character.
+ *@ATK_TEXT_BOUNDARY_LINE_END: Boundary is the linefeed, or return character.
+ *
+ *Text boundary types used for specifying boundaries for regions of text
+ **/
+typedef enum {
+ ATK_TEXT_BOUNDARY_CHAR,
+ ATK_TEXT_BOUNDARY_WORD_START,
+ ATK_TEXT_BOUNDARY_WORD_END,
+ ATK_TEXT_BOUNDARY_SENTENCE_START,
+ ATK_TEXT_BOUNDARY_SENTENCE_END,
+ ATK_TEXT_BOUNDARY_LINE_START,
+ ATK_TEXT_BOUNDARY_LINE_END
+} AtkTextBoundary;
+
+/**
+ *AtkTextGranularity:
+ *@ATK_TEXT_GRANULARITY_CHAR: Granularity is defined by the boundaries between characters
+ * (including non-printing characters)
+ *@ATK_TEXT_GRANULARITY_WORD: Granularity is defined by the boundaries of a word,
+ * starting at the beginning of the current word and finishing at the beginning of
+ * the following one, if present.
+ *@ATK_TEXT_GRANULARITY_SENTENCE: Granularity is defined by the boundaries of a sentence,
+ * starting at the beginning of the current sentence and finishing at the beginning of
+ * the following one, if present.
+ *@ATK_TEXT_GRANULARITY_LINE: Granularity is defined by the boundaries of a line,
+ * starting at the beginning of the current line and finishing at the beginning of
+ * the following one, if present.
+ *@ATK_TEXT_GRANULARITY_PARAGRAPH: Granularity is defined by the boundaries of a paragraph,
+ * starting at the beginning of the current paragraph and finishing at the beginning of
+ * the following one, if present.
+ *
+ * Text granularity types used for specifying the granularity of the region of
+ * text we are interested in.
+ **/
+typedef enum {
+ ATK_TEXT_GRANULARITY_CHAR,
+ ATK_TEXT_GRANULARITY_WORD,
+ ATK_TEXT_GRANULARITY_SENTENCE,
+ ATK_TEXT_GRANULARITY_LINE,
+ ATK_TEXT_GRANULARITY_PARAGRAPH
+} AtkTextGranularity;
+
+/**
+ * AtkTextRectangle:
+ * @x: The horizontal coordinate of a rectangle
+ * @y: The vertical coordinate of a rectangle
+ * @width: The width of a rectangle
+ * @height: The height of a rectangle
+ *
+ * A structure used to store a rectangle used by AtkText.
+ **/
+
+typedef struct _AtkTextRectangle AtkTextRectangle;
+
+struct _AtkTextRectangle {
+ gint x;
+ gint y;
+ gint width;
+ gint height;
+};
+
+/**
+ * AtkTextRange:
+ * @bounds: A rectangle giving the bounds of the text range
+ * @start_offset: The start offset of a AtkTextRange
+ * @end_offset: The end offset of a AtkTextRange
+ * @content: The text in the text range
+ *
+ * A structure used to describe a text range.
+ **/
+typedef struct _AtkTextRange AtkTextRange;
+
+struct _AtkTextRange {
+ AtkTextRectangle bounds;
+ gint start_offset;
+ gint end_offset;
+ gchar* content;
+};
+
+/**
+ *AtkTextClipType
+ *@ATK_TEXT_CLIP_NONE: No clipping to be done
+ *@ATK_TEXT_CLIP_MIN: Text clipped by min coordinate is omitted
+ *@ATK_TEXT_CLIP_MAX: Text clipped by max coordinate is omitted
+ *@ATK_TEXT_CLIP_BOTH: Only text fully within mix/max bound is retained
+ *
+ *Describes the type of clipping required.
+ **/
+typedef enum {
+ ATK_TEXT_CLIP_NONE,
+ ATK_TEXT_CLIP_MIN,
+ ATK_TEXT_CLIP_MAX,
+ ATK_TEXT_CLIP_BOTH
+} AtkTextClipType;
+
+struct _AtkTextIface
+{
+ GTypeInterface parent;
+
+ gchar* (* get_text) (AtkText *text,
+ gint start_offset,
+ gint end_offset);
+ gchar* (* get_text_after_offset) (AtkText *text,
+ gint offset,
+ AtkTextBoundary boundary_type,
+ gint *start_offset,
+ gint *end_offset);
+ gchar* (* get_text_at_offset) (AtkText *text,
+ gint offset,
+ AtkTextBoundary boundary_type,
+ gint *start_offset,
+ gint *end_offset);
+ gunichar (* get_character_at_offset) (AtkText *text,
+ gint offset);
+ gchar* (* get_text_before_offset) (AtkText *text,
+ gint offset,
+ AtkTextBoundary boundary_type,
+ gint *start_offset,
+ gint *end_offset);
+ gint (* get_caret_offset) (AtkText *text);
+ AtkAttributeSet* (* get_run_attributes) (AtkText *text,
+ gint offset,
+ gint *start_offset,
+ gint *end_offset);
+ AtkAttributeSet* (* get_default_attributes) (AtkText *text);
+ void (* get_character_extents) (AtkText *text,
+ gint offset,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtkCoordType coords);
+ gint (* get_character_count) (AtkText *text);
+ gint (* get_offset_at_point) (AtkText *text,
+ gint x,
+ gint y,
+ AtkCoordType coords);
+ gint (* get_n_selections) (AtkText *text);
+ gchar* (* get_selection) (AtkText *text,
+ gint selection_num,
+ gint *start_offset,
+ gint *end_offset);
+ gboolean (* add_selection) (AtkText *text,
+ gint start_offset,
+ gint end_offset);
+ gboolean (* remove_selection) (AtkText *text,
+ gint selection_num);
+ gboolean (* set_selection) (AtkText *text,
+ gint selection_num,
+ gint start_offset,
+ gint end_offset);
+ gboolean (* set_caret_offset) (AtkText *text,
+ gint offset);
+
+ /*
+ * signal handlers
+ */
+ void (* text_changed) (AtkText *text,
+ gint position,
+ gint length);
+ void (* text_caret_moved) (AtkText *text,
+ gint location);
+ void (* text_selection_changed) (AtkText *text);
+
+ void (* text_attributes_changed) (AtkText *text);
+
+
+ void (* get_range_extents) (AtkText *text,
+ gint start_offset,
+ gint end_offset,
+ AtkCoordType coord_type,
+ AtkTextRectangle *rect);
+
+ AtkTextRange** (* get_bounded_ranges) (AtkText *text,
+ AtkTextRectangle *rect,
+ AtkCoordType coord_type,
+ AtkTextClipType x_clip_type,
+ AtkTextClipType y_clip_type);
+
+ gchar* (* get_string_at_offset) (AtkText *text,
+ gint offset,
+ AtkTextGranularity granularity,
+ gint *start_offset,
+ gint *end_offset);
+ /*
+ * Scrolls this text range so it becomes visible on the screen.
+ *
+ * scroll_substring_to lets the implementation compute an appropriate target
+ * position on the screen, with type used as a positioning hint.
+ *
+ * scroll_substring_to_point lets the client specify a precise target position
+ * on the screen.
+ *
+ * Since ATK 2.32
+ */
+ gboolean (* scroll_substring_to) (AtkText *text,
+ gint start_offset,
+ gint end_offset,
+ AtkScrollType type);
+ gboolean (* scroll_substring_to_point) (AtkText *text,
+ gint start_offset,
+ gint end_offset,
+ AtkCoordType coords,
+ gint x,
+ gint y);
+};
+
+GType atk_text_get_type (void);
+
+
+/*
+ * Additional AtkObject properties used by AtkText:
+ * "accessible_text" (accessible text has changed)
+ * "accessible_caret" (accessible text cursor position changed:
+ * editable text only)
+ */
+
+gchar* atk_text_get_text (AtkText *text,
+ gint start_offset,
+ gint end_offset);
+gunichar atk_text_get_character_at_offset (AtkText *text,
+ gint offset);
+gchar* atk_text_get_text_after_offset (AtkText *text,
+ gint offset,
+ AtkTextBoundary boundary_type,
+ gint *start_offset,
+ gint *end_offset);
+gchar* atk_text_get_text_at_offset (AtkText *text,
+ gint offset,
+ AtkTextBoundary boundary_type,
+ gint *start_offset,
+ gint *end_offset);
+gchar* atk_text_get_text_before_offset (AtkText *text,
+ gint offset,
+ AtkTextBoundary boundary_type,
+ gint *start_offset,
+ gint *end_offset);
+gchar* atk_text_get_string_at_offset (AtkText *text,
+ gint offset,
+ AtkTextGranularity granularity,
+ gint *start_offset,
+ gint *end_offset);
+gint atk_text_get_caret_offset (AtkText *text);
+void atk_text_get_character_extents (AtkText *text,
+ gint offset,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtkCoordType coords);
+AtkAttributeSet* atk_text_get_run_attributes (AtkText *text,
+ gint offset,
+ gint *start_offset,
+ gint *end_offset);
+AtkAttributeSet* atk_text_get_default_attributes (AtkText *text);
+gint atk_text_get_character_count (AtkText *text);
+gint atk_text_get_offset_at_point (AtkText *text,
+ gint x,
+ gint y,
+ AtkCoordType coords);
+gint atk_text_get_n_selections (AtkText *text);
+gchar* atk_text_get_selection (AtkText *text,
+ gint selection_num,
+ gint *start_offset,
+ gint *end_offset);
+gboolean atk_text_add_selection (AtkText *text,
+ gint start_offset,
+ gint end_offset);
+gboolean atk_text_remove_selection (AtkText *text,
+ gint selection_num);
+gboolean atk_text_set_selection (AtkText *text,
+ gint selection_num,
+ gint start_offset,
+ gint end_offset);
+gboolean atk_text_set_caret_offset (AtkText *text,
+ gint offset);
+void atk_text_get_range_extents (AtkText *text,
+
+ gint start_offset,
+ gint end_offset,
+ AtkCoordType coord_type,
+ AtkTextRectangle *rect);
+AtkTextRange** atk_text_get_bounded_ranges (AtkText *text,
+ AtkTextRectangle *rect,
+ AtkCoordType coord_type,
+ AtkTextClipType x_clip_type,
+ AtkTextClipType y_clip_type);
+void atk_text_free_ranges (AtkTextRange **ranges);
+void atk_attribute_set_free (AtkAttributeSet *attrib_set);
+G_CONST_RETURN gchar* atk_text_attribute_get_name (AtkTextAttribute attr);
+AtkTextAttribute atk_text_attribute_for_name (const gchar *name);
+G_CONST_RETURN gchar* atk_text_attribute_get_value (AtkTextAttribute attr,
+ gint index_);
+
+gboolean atk_text_scroll_substring_to (AtkText *text,
+ gint start_offset,
+ gint end_offset,
+ AtkScrollType type);
+
+gboolean atk_text_scroll_substring_to_point (AtkText *text,
+ gint start_offset,
+ gint end_offset,
+ AtkCoordType coords,
+ gint x,
+ gint y);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_TEXT_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkutil.h b/other-licenses/atk-1.0/atk/atkutil.h
new file mode 100644
index 0000000000..728a10685d
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkutil.h
@@ -0,0 +1,245 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_UTIL_H__
+#define __ATK_UTIL_H__
+
+#include <atk/atkobject.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define ATK_TYPE_UTIL (atk_util_get_type ())
+#define ATK_IS_UTIL(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_UTIL)
+#define ATK_UTIL(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_UTIL, AtkUtil)
+#define ATK_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_UTIL, AtkUtilClass))
+#define ATK_IS_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_UTIL))
+#define ATK_UTIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_UTIL, AtkUtilClass))
+
+
+#ifndef _TYPEDEF_ATK_UTIL_
+#define _TYPEDEF_ATK_UTIL_
+typedef struct _AtkUtil AtkUtil;
+typedef struct _AtkUtilClass AtkUtilClass;
+typedef struct _AtkKeyEventStruct AtkKeyEventStruct;
+#endif
+
+/**
+ * AtkEventListener:
+ * @obj: An #AtkObject instance for whom the callback will be called when
+ * the specified event (e.g. 'focus:') takes place.
+ *
+ * A function which is called when an object emits a matching event,
+ * as used in #atk_add_focus_tracker.
+ * Currently the only events for which object-specific handlers are
+ * supported are events of type "focus:". Most clients of ATK will prefer to
+ * attach signal handlers for the various ATK signals instead.
+ *
+ * @see: atk_add_focus_tracker.
+ **/
+typedef void (*AtkEventListener) (AtkObject* obj);
+/**
+ * AtkEventListenerInit:
+ *
+ * An #AtkEventListenerInit function is a special function that is
+ * called in order to initialize the per-object event registration system
+ * used by #AtkEventListener, if any preparation is required.
+ *
+ * @see: atk_focus_tracker_init.
+ **/
+typedef void (*AtkEventListenerInit) (void);
+/**
+ * AtkKeySnoopFunc:
+ * @event: an AtkKeyEventStruct containing information about the key event for which
+ * notification is being given.
+ * @func_data: a block of data which will be passed to the event listener, on notification.
+ *
+ * An #AtkKeySnoopFunc is a type of callback which is called whenever a key event occurs,
+ * if registered via atk_add_key_event_listener. It allows for pre-emptive
+ * interception of key events via the return code as described below.
+ *
+ * Returns: TRUE (nonzero) if the event emission should be stopped and the event
+ * discarded without being passed to the normal GUI recipient; FALSE (zero) if the
+ * event dispatch to the client application should proceed as normal.
+ *
+ * @see: atk_add_key_event_listener.
+ **/
+typedef gint (*AtkKeySnoopFunc) (AtkKeyEventStruct *event,
+ gpointer func_data);
+
+/**
+ * AtkKeyEventStruct:
+ * @type: An AtkKeyEventType, generally one of ATK_KEY_EVENT_PRESS or ATK_KEY_EVENT_RELEASE
+ * @state: A bitmask representing the state of the modifier keys immediately after the event takes place.
+ * The meaning of the bits is currently defined to match the bitmask used by GDK in
+ * GdkEventType.state, see
+ * http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html#GdkEventKey
+ * @keyval: A guint representing a keysym value corresponding to those used by GDK and X11: see
+ * /usr/X11/include/keysymdef.h.
+ * @length: The length of member #string.
+ * @string: A string containing one of the following: either a string approximating the text that would
+ * result from this keypress, if the key is a control or graphic character, or a symbolic name for this keypress.
+ * Alphanumeric and printable keys will have the symbolic key name in this string member, for instance "A". "0",
+ * "semicolon", "aacute". Keypad keys have the prefix "KP".
+ * @keycode: The raw hardware code that generated the key event. This field is raraly useful.
+ * @timestamp: A timestamp in milliseconds indicating when the event occurred.
+ * These timestamps are relative to a starting point which should be considered arbitrary,
+ * and only used to compare the dispatch times of events to one another.
+ *
+ * Encapsulates information about a key event.
+ **/
+struct _AtkKeyEventStruct {
+ gint type;
+ guint state;
+ guint keyval;
+ gint length;
+ gchar *string;
+ guint16 keycode;
+ guint32 timestamp;
+};
+
+/**
+ *AtkKeyEventType:
+ *@ATK_KEY_EVENT_PRESS: specifies a key press event
+ *@ATK_KEY_EVENT_RELEASE: specifies a key release event
+ *@ATK_KEY_EVENT_LAST_DEFINED: Not a valid value; specifies end of enumeration
+ *
+ *Specifies the type of a keyboard evemt.
+ **/
+typedef enum
+{
+ ATK_KEY_EVENT_PRESS,
+ ATK_KEY_EVENT_RELEASE,
+ ATK_KEY_EVENT_LAST_DEFINED
+} AtkKeyEventType;
+
+struct _AtkUtil
+{
+ GObject parent;
+};
+
+struct _AtkUtilClass
+{
+ GObjectClass parent;
+ guint (* add_global_event_listener) (GSignalEmissionHook listener,
+ const gchar *event_type);
+ void (* remove_global_event_listener) (guint listener_id);
+ guint (* add_key_event_listener) (AtkKeySnoopFunc listener,
+ gpointer data);
+ void (* remove_key_event_listener) (guint listener_id);
+ AtkObject* (* get_root) (void);
+ G_CONST_RETURN gchar* (* get_toolkit_name) (void);
+ G_CONST_RETURN gchar* (* get_toolkit_version) (void);
+};
+GType atk_util_get_type (void);
+
+/**
+ *AtkCoordType:
+ *@ATK_XY_SCREEN: specifies xy coordinates relative to the screen
+ *@ATK_XY_WINDOW: specifies xy coordinates relative to the widget's
+ * top-level window
+ *@ATK_XY_PARENT: specifies xy coordinates relative to the widget's
+ * immediate parent.
+ *
+ *Specifies how xy coordinates are to be interpreted. Used by functions such
+ *as atk_component_get_position() and atk_text_get_character_extents()
+ **/
+typedef enum {
+ ATK_XY_SCREEN,
+ ATK_XY_WINDOW,
+ ATK_XY_PARENT
+}AtkCoordType;
+
+/*
+ * Adds the specified function to the list of functions to be called
+ * when an object receives focus.
+ */
+guint atk_add_focus_tracker (AtkEventListener focus_tracker);
+
+/*
+ * Removes the specified focus tracker from the list of function
+ * to be called when any object receives focus
+ */
+void atk_remove_focus_tracker (guint tracker_id);
+
+/*
+ * atk_focus_tracker_init:
+ * @init: An #AtkEventListenerInit function to be called
+ * prior to any focus-tracking requests.
+ *
+ * Specifies the function to be called for focus tracker initialization.
+ * removal. This function should be called by an implementation of the
+ * ATK interface if any specific work needs to be done to enable
+ * focus tracking.
+ */
+void atk_focus_tracker_init (AtkEventListenerInit init);
+
+/*
+ * Cause the focus tracker functions which have been specified to be
+ * executed for the object.
+ */
+void atk_focus_tracker_notify (AtkObject *object);
+
+/*
+ * Adds the specified function to the list of functions to be called
+ * when an event of type event_type occurs.
+ */
+guint atk_add_global_event_listener (GSignalEmissionHook listener,
+ const gchar *event_type);
+
+/*
+ * Removes the specified event listener
+ */
+void atk_remove_global_event_listener (guint listener_id);
+
+/*
+ * Adds the specified function to the list of functions to be called
+ * when an keyboard event occurs.
+ */
+guint atk_add_key_event_listener (AtkKeySnoopFunc listener, gpointer data);
+
+/*
+ * Removes the specified event listener
+ */
+void atk_remove_key_event_listener (guint listener_id);
+
+/*
+ * Returns the root accessible container for the current application.
+ */
+AtkObject* atk_get_root(void);
+
+AtkObject* atk_get_focus_object (void);
+
+/*
+ * Returns name string for the GUI toolkit.
+ */
+G_CONST_RETURN gchar *atk_get_toolkit_name (void);
+
+/*
+ * Returns version string for the GUI toolkit.
+ */
+G_CONST_RETURN gchar *atk_get_toolkit_version (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_UTIL_H__ */
diff --git a/other-licenses/atk-1.0/atk/atkvalue.h b/other-licenses/atk-1.0/atk/atkvalue.h
new file mode 100644
index 0000000000..f66c015284
--- /dev/null
+++ b/other-licenses/atk-1.0/atk/atkvalue.h
@@ -0,0 +1,95 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ATK_VALUE_H__
+#define __ATK_VALUE_H__
+
+#include <atk/atkobject.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * The AtkValue interface should be supported by any object that
+ * supports a numerical value (e.g., a scroll bar). This interface
+ * provides the standard mechanism for an assistive technology to
+ * determine and set the numerical value as well as get the minimum
+ * and maximum values.
+ */
+
+#define ATK_TYPE_VALUE (atk_value_get_type ())
+#define ATK_IS_VALUE(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_VALUE)
+#define ATK_VALUE(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_VALUE, AtkValue)
+#define ATK_VALUE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_VALUE, AtkValueIface))
+
+#ifndef _TYPEDEF_ATK_VALUE_
+#define _TYPEDEF_ATK_VALUE__
+typedef struct _AtkValue AtkValue;
+#endif
+typedef struct _AtkValueIface AtkValueIface;
+
+struct _AtkValueIface
+{
+ GTypeInterface parent;
+
+ void (* get_current_value) (AtkValue *obj,
+ GValue *value);
+ void (* get_maximum_value) (AtkValue *obj,
+ GValue *value);
+ void (* get_minimum_value) (AtkValue *obj,
+ GValue *value);
+ gboolean (* set_current_value) (AtkValue *obj,
+ const GValue *value);
+ void (* get_minimum_increment) (AtkValue *obj,
+ GValue *value);
+ AtkFunction pad1;
+};
+
+GType atk_value_get_type (void);
+
+void atk_value_get_current_value (AtkValue *obj,
+ GValue *value);
+
+
+void atk_value_get_maximum_value (AtkValue *obj,
+ GValue *value);
+
+void atk_value_get_minimum_value (AtkValue *obj,
+ GValue *value);
+
+gboolean atk_value_set_current_value (AtkValue *obj,
+ const GValue *value);
+
+void atk_value_get_minimum_increment (AtkValue *obj,
+ GValue *value);
+
+/*
+ * Additional GObject properties exported by GaccessibleValue:
+ * "accessible_value"
+ * (the accessible value has changed)
+ */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __ATK_VALUE_H__ */
diff --git a/other-licenses/bsdiff/LICENSE b/other-licenses/bsdiff/LICENSE
new file mode 100644
index 0000000000..c146b5b399
--- /dev/null
+++ b/other-licenses/bsdiff/LICENSE
@@ -0,0 +1,121 @@
+BSD Protection License
+February 2002
+
+Preamble
+--------
+
+The Berkeley Software Distribution ("BSD") license has proven very effective
+over the years at allowing for a wide spread of work throughout both
+commercial and non-commercial products. For programmers whose primary
+intention is to improve the general quality of available software, it is
+arguable that there is no better license than the BSD license, as it
+permits improvements to be used wherever they will help, without idealogical
+or metallic constraint.
+
+This is of particular value to those who produce reference implementations
+of proposed standards: The case of TCP/IP clearly illustrates that freely
+and universally available implementations leads the rapid acceptance of
+standards -- often even being used instead of a de jure standard (eg, OSI
+network models).
+
+With the rapid proliferation of software licensed under the GNU General
+Public License, however, the continued success of this role is called into
+question. Given that the inclusion of a few lines of "GPL-tainted" work
+into a larger body of work will result in restricted distribution -- and
+given that further work will likely build upon the "tainted" portions,
+making them difficult to remove at a future date -- there are inevitable
+circumstances where authors would, in order to protect their goal of
+providing for the widespread usage of their work, wish to guard against
+such "GPL-taint".
+
+In addition, one can imagine that companies which operate by producing and
+selling (possibly closed-source) code would wish to protect themselves
+against the rise of a GPL-licensed competitor. While under existing
+licenses this would mean not releasing their code under any form of open
+license, if a license existed under which they could incorporate any
+improvements back into their own (commercial) products then they might be
+far more willing to provide for non-closed distribution.
+
+For the above reasons, we put forth this "BSD Protection License": A
+license designed to retain the freedom granted by the BSD license to use
+licensed works in a wide variety of settings, both non-commercial and
+commercial, while protecting the work from having future contributors
+restrict that freedom.
+
+The precise terms and conditions for copying, distribution, and
+modification follow.
+
+BSD PROTECTION LICENSE
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION, AND MODIFICATION
+----------------------------------------------------------------
+
+0. Definitions.
+ a) "Program", below, refers to any program or work distributed under
+ the terms of this license.
+ b) A "work based on the Program", below, refers to either the Program
+ or any derivative work under copyright law.
+ c) "Modification", below, refers to the act of creating derivative works.
+ d) "You", below, refers to each licensee.
+
+1. Scope.
+ This license governs the copying, distribution, and modification of the
+ Program. Other activities are outside the scope of this license; The
+ act of running the Program is not restricted, and the output from the
+ Program is covered only if its contents constitute a work based on the
+ Program.
+
+2. Verbatim copies.
+ You may copy and distribute verbatim copies of the Program as you
+ receive it, in any medium, provided that you conspicuously and
+ appropriately publish on each copy an appropriate copyright notice; keep
+ intact all the notices that refer to this License and to the absence of
+ any warranty; and give any other recipients of the Program a copy of this
+ License along with the Program.
+
+3. Modification and redistribution under closed license.
+ You may modify your copy or copies of the Program, and distribute
+ the resulting derivative works, provided that you meet the
+ following conditions:
+ a) The copyright notice and disclaimer on the Program must be reproduced
+ and included in the source code, documentation, and/or other materials
+ provided in a manner in which such notices are normally distributed.
+ b) The derivative work must be clearly identified as such, in order that
+ it may not be confused with the original work.
+ c) The license under which the derivative work is distributed must
+ expressly prohibit the distribution of further derivative works.
+
+4. Modification and redistribution under open license.
+ You may modify your copy or copies of the Program, and distribute
+ the resulting derivative works, provided that you meet the
+ following conditions:
+ a) The copyright notice and disclaimer on the Program must be reproduced
+ and included in the source code, documentation, and/or other materials
+ provided in a manner in which such notices are normally distributed.
+ b) You must clearly indicate the nature and date of any changes made
+ to the Program. The full details need not necessarily be included in
+ the individual modified files, provided that each modified file is
+ clearly marked as such and instructions are included on where the
+ full details of the modifications may be found.
+ c) You must cause any work that you distribute or publish, that in whole
+ or in part contains or is derived from the Program or any part
+ thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+5. Implied acceptance.
+ You may not copy or distribute the Program or any derivative works except
+ as expressly provided under this license. Consequently, any such action
+ will be taken as implied acceptance of the terms of this license.
+
+6. NO WARRANTY.
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ THE COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ TORT, EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES.
diff --git a/other-licenses/bsdiff/bsdiff.c b/other-licenses/bsdiff/bsdiff.c
new file mode 100644
index 0000000000..eaf9027365
--- /dev/null
+++ b/other-licenses/bsdiff/bsdiff.c
@@ -0,0 +1,411 @@
+/* vim:set ts=8 sw=8 sts=8 noet: */
+/*
+ bsdiff.c -- Binary patch generator.
+
+ Copyright 2003 Colin Percival
+
+ For the terms under which this work may be distributed, please see
+ the adjoining file "LICENSE".
+
+ ChangeLog:
+ 2005-05-05 - Use the modified header struct from bspatch.h; use 32-bit
+ values throughout.
+ --Benjamin Smedberg <benjamin@smedbergs.us>
+ 2005-05-18 - Use the same CRC algorithm as bzip2, and leverage the CRC table
+ provided by libbz2.
+ --Darin Fisher <darin@meer.net>
+*/
+
+#include "bspatch.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#ifdef XP_WIN
+#include <io.h>
+#include <winsock2.h>
+#define open _open
+#define close _close
+#define read _read
+#define lseek _lseek
+#define write _write
+#else
+#include <unistd.h>
+#include <arpa/inet.h>
+#define _O_BINARY 0
+#endif
+
+#include "crctable.h"
+
+#undef MIN
+#define MIN(x,y) (((x)<(y)) ? (x) : (y))
+
+/*---------------------------------------------------------------------------*/
+
+/* This variable lives in libbz2. It's declared in bzlib_private.h, so we just
+ * declare it here to avoid including that entire header file.
+ */
+extern unsigned int BZ2_crc32Table[256];
+
+static unsigned int
+crc32(const unsigned char *buf, unsigned int len)
+{
+ unsigned int crc = 0xffffffffL;
+
+ const unsigned char *end = buf + len;
+ for (; buf != end; ++buf)
+ crc = (crc << 8) ^ BZ2_crc32Table[(crc >> 24) ^ *buf];
+
+ crc = ~crc;
+ return crc;
+}
+
+/*---------------------------------------------------------------------------*/
+
+static void
+reporterr(int e, const char *fmt, ...)
+{
+ if (fmt) {
+ va_list args;
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ }
+
+ exit(e);
+}
+
+static void
+split(int32_t *I,int32_t *V,int32_t start,int32_t len,int32_t h)
+{
+ int32_t i,j,k,x,tmp,jj,kk;
+
+ if(len<16) {
+ for(k=start;k<start+len;k+=j) {
+ j=1;x=V[I[k]+h];
+ for(i=1;k+i<start+len;i++) {
+ if(V[I[k+i]+h]<x) {
+ x=V[I[k+i]+h];
+ j=0;
+ };
+ if(V[I[k+i]+h]==x) {
+ tmp=I[k+j];I[k+j]=I[k+i];I[k+i]=tmp;
+ j++;
+ };
+ };
+ for(i=0;i<j;i++) V[I[k+i]]=k+j-1;
+ if(j==1) I[k]=-1;
+ };
+ return;
+ };
+
+ x=V[I[start+len/2]+h];
+ jj=0;kk=0;
+ for(i=start;i<start+len;i++) {
+ if(V[I[i]+h]<x) jj++;
+ if(V[I[i]+h]==x) kk++;
+ };
+ jj+=start;kk+=jj;
+
+ i=start;j=0;k=0;
+ while(i<jj) {
+ if(V[I[i]+h]<x) {
+ i++;
+ } else if(V[I[i]+h]==x) {
+ tmp=I[i];I[i]=I[jj+j];I[jj+j]=tmp;
+ j++;
+ } else {
+ tmp=I[i];I[i]=I[kk+k];I[kk+k]=tmp;
+ k++;
+ };
+ };
+
+ while(jj+j<kk) {
+ if(V[I[jj+j]+h]==x) {
+ j++;
+ } else {
+ tmp=I[jj+j];I[jj+j]=I[kk+k];I[kk+k]=tmp;
+ k++;
+ };
+ };
+
+ if(jj>start) split(I,V,start,jj-start,h);
+
+ for(i=0;i<kk-jj;i++) V[I[jj+i]]=kk-1;
+ if(jj==kk-1) I[jj]=-1;
+
+ if(start+len>kk) split(I,V,kk,start+len-kk,h);
+}
+
+static void
+qsufsort(int32_t *I,int32_t *V,unsigned char *old,int32_t oldsize)
+{
+ int32_t buckets[256];
+ int32_t i,h,len;
+
+ for(i=0;i<256;i++) buckets[i]=0;
+ for(i=0;i<oldsize;i++) buckets[old[i]]++;
+ for(i=1;i<256;i++) buckets[i]+=buckets[i-1];
+ for(i=255;i>0;i--) buckets[i]=buckets[i-1];
+ buckets[0]=0;
+
+ for(i=0;i<oldsize;i++) I[++buckets[old[i]]]=i;
+ I[0]=oldsize;
+ for(i=0;i<oldsize;i++) V[i]=buckets[old[i]];
+ V[oldsize]=0;
+ for(i=1;i<256;i++) if(buckets[i]==buckets[i-1]+1) I[buckets[i]]=-1;
+ I[0]=-1;
+
+ for(h=1;I[0]!=-(oldsize+1);h+=h) {
+ len=0;
+ for(i=0;i<oldsize+1;) {
+ if(I[i]<0) {
+ len-=I[i];
+ i-=I[i];
+ } else {
+ if(len) I[i-len]=-len;
+ len=V[I[i]]+1-i;
+ split(I,V,i,len,h);
+ i+=len;
+ len=0;
+ };
+ };
+ if(len) I[i-len]=-len;
+ };
+
+ for(i=0;i<oldsize+1;i++) I[V[i]]=i;
+}
+
+static int32_t
+matchlen(unsigned char *old,int32_t oldsize,unsigned char *newbuf,int32_t newsize)
+{
+ int32_t i;
+
+ for(i=0;(i<oldsize)&&(i<newsize);i++)
+ if(old[i]!=newbuf[i]) break;
+
+ return i;
+}
+
+static int32_t
+search(int32_t *I,unsigned char *old,int32_t oldsize,
+ unsigned char *newbuf,int32_t newsize,int32_t st,int32_t en,int32_t *pos)
+{
+ int32_t x,y;
+
+ if(en-st<2) {
+ x=matchlen(old+I[st],oldsize-I[st],newbuf,newsize);
+ y=matchlen(old+I[en],oldsize-I[en],newbuf,newsize);
+
+ if(x>y) {
+ *pos=I[st];
+ return x;
+ } else {
+ *pos=I[en];
+ return y;
+ }
+ };
+
+ x=st+(en-st)/2;
+ if(memcmp(old+I[x],newbuf,MIN(oldsize-I[x],newsize))<0) {
+ return search(I,old,oldsize,newbuf,newsize,x,en,pos);
+ } else {
+ return search(I,old,oldsize,newbuf,newsize,st,x,pos);
+ };
+}
+
+int main(int argc,char *argv[])
+{
+ int fd;
+ unsigned char *old,*newbuf;
+ int32_t oldsize,newsize;
+ int32_t *I,*V;
+
+ int32_t scan,pos,len;
+ int32_t lastscan,lastpos,lastoffset;
+ int32_t oldscore,scsc;
+
+ int32_t s,Sf,lenf,Sb,lenb;
+ int32_t overlap,Ss,lens;
+ int32_t i;
+
+ int32_t dblen,eblen;
+ unsigned char *db,*eb;
+
+ unsigned int scrc;
+
+ MBSPatchHeader header = {
+ {'M','B','D','I','F','F','1','0'},
+ 0, 0, 0, 0, 0, 0
+ };
+
+ uint32_t numtriples;
+
+ if(argc!=4)
+ reporterr(1,"usage: %s <oldfile> <newfile> <patchfile>\n",argv[0]);
+
+ /* Allocate oldsize+1 bytes instead of oldsize bytes to ensure
+ that we never try to malloc(0) and get a NULL pointer */
+ if(((fd=open(argv[1],O_RDONLY|_O_BINARY,0))<0) ||
+ ((oldsize=lseek(fd,0,SEEK_END))==-1) ||
+ ((old=(unsigned char*) malloc(oldsize+1))==NULL) ||
+ (lseek(fd,0,SEEK_SET)!=0) ||
+ (read(fd,old,oldsize)!=oldsize) ||
+ (close(fd)==-1))
+ reporterr(1,"%s\n",argv[1]);
+
+ scrc = crc32(old, oldsize);
+
+ if(((I=(int32_t*) malloc((oldsize+1)*sizeof(int32_t)))==NULL) ||
+ ((V=(int32_t*) malloc((oldsize+1)*sizeof(int32_t)))==NULL))
+ reporterr(1,NULL);
+
+ qsufsort(I,V,old,oldsize);
+
+ free(V);
+
+ /* Allocate newsize+1 bytes instead of newsize bytes to ensure
+ that we never try to malloc(0) and get a NULL pointer */
+ if(((fd=open(argv[2],O_RDONLY|_O_BINARY,0))<0) ||
+ ((newsize=lseek(fd,0,SEEK_END))==-1) ||
+ ((newbuf=(unsigned char*) malloc(newsize+1))==NULL) ||
+ (lseek(fd,0,SEEK_SET)!=0) ||
+ (read(fd,newbuf,newsize)!=newsize) ||
+ (close(fd)==-1)) reporterr(1,"%s\n",argv[2]);
+
+ if(((db=(unsigned char*) malloc(newsize+1))==NULL) ||
+ ((eb=(unsigned char*) malloc(newsize+1))==NULL))
+ reporterr(1,NULL);
+
+ dblen=0;
+ eblen=0;
+
+ if((fd=open(argv[3],O_CREAT|O_TRUNC|O_WRONLY|_O_BINARY,0666))<0)
+ reporterr(1,"%s\n",argv[3]);
+
+ /* start writing here */
+
+ /* We don't know the lengths yet, so we will write the header again
+ at the end */
+
+ if(write(fd,&header,sizeof(MBSPatchHeader))!=sizeof(MBSPatchHeader))
+ reporterr(1,"%s\n",argv[3]);
+
+ scan=0;len=0;
+ lastscan=0;lastpos=0;lastoffset=0;
+ numtriples = 0;
+ while(scan<newsize) {
+ oldscore=0;
+
+ for(scsc=scan+=len;scan<newsize;scan++) {
+ len=search(I,old,oldsize,newbuf+scan,newsize-scan,
+ 0,oldsize,&pos);
+
+ for(;scsc<scan+len;scsc++)
+ if((scsc+lastoffset<oldsize) &&
+ (old[scsc+lastoffset] == newbuf[scsc]))
+ oldscore++;
+
+ if(((len==oldscore) && (len!=0)) ||
+ (len>oldscore+10)) break;
+
+ if((scan+lastoffset<oldsize) &&
+ (old[scan+lastoffset] == newbuf[scan]))
+ oldscore--;
+ };
+
+ if((len!=oldscore) || (scan==newsize)) {
+ MBSPatchTriple triple;
+
+ s=0;Sf=0;lenf=0;
+ for(i=0;(lastscan+i<scan)&&(lastpos+i<oldsize);) {
+ if(old[lastpos+i]==newbuf[lastscan+i]) s++;
+ i++;
+ if(s*3-i*2>Sf*3-lenf*2) { Sf=s; lenf=i; };
+ };
+
+ lenb=0;
+ if(scan<newsize) {
+ s=0;Sb=0;
+ for(i=1;(scan>=lastscan+i)&&(pos>=i);i++) {
+ if(old[pos-i]==newbuf[scan-i]) s++;
+ if(s*3-i*2>Sb*3-lenb*2) { Sb=s; lenb=i; };
+ };
+ };
+
+ if(lastscan+lenf>scan-lenb) {
+ overlap=(lastscan+lenf)-(scan-lenb);
+ s=0;Ss=0;lens=0;
+ for(i=0;i<overlap;i++) {
+ if(newbuf[lastscan+lenf-overlap+i]==
+ old[lastpos+lenf-overlap+i]) s++;
+ if(newbuf[scan-lenb+i]==
+ old[pos-lenb+i]) s--;
+ if(s>Ss) { Ss=s; lens=i+1; };
+ };
+
+ lenf+=lens-overlap;
+ lenb-=lens;
+ };
+
+ for(i=0;i<lenf;i++)
+ db[dblen+i]=newbuf[lastscan+i]-old[lastpos+i];
+ for(i=0;i<(scan-lenb)-(lastscan+lenf);i++)
+ eb[eblen+i]=newbuf[lastscan+lenf+i];
+
+ dblen+=lenf;
+ eblen+=(scan-lenb)-(lastscan+lenf);
+
+ triple.x = htonl(lenf);
+ triple.y = htonl((scan-lenb)-(lastscan+lenf));
+ triple.z = htonl((pos-lenb)-(lastpos+lenf));
+ if (write(fd,&triple,sizeof(triple)) != sizeof(triple))
+ reporterr(1,NULL);
+
+#ifdef DEBUG_bsmedberg
+ printf("Writing a block:\n"
+ " X: %u\n"
+ " Y: %u\n"
+ " Z: %i\n",
+ (uint32_t) lenf,
+ (uint32_t) ((scan-lenb)-(lastscan+lenf)),
+ (uint32_t) ((pos-lenb)-(lastpos+lenf)));
+#endif
+
+ ++numtriples;
+
+ lastscan=scan-lenb;
+ lastpos=pos-lenb;
+ lastoffset=pos-scan;
+ };
+ };
+
+ if(write(fd,db,dblen)!=dblen)
+ reporterr(1,NULL);
+
+ if(write(fd,eb,eblen)!=eblen)
+ reporterr(1,NULL);
+
+ header.slen = htonl(oldsize);
+ header.scrc32 = htonl(scrc);
+ header.dlen = htonl(newsize);
+ header.cblen = htonl(numtriples * sizeof(MBSPatchTriple));
+ header.difflen = htonl(dblen);
+ header.extralen = htonl(eblen);
+
+ if (lseek(fd,0,SEEK_SET) == -1 ||
+ write(fd,&header,sizeof(header)) != sizeof(header) ||
+ close(fd) == -1)
+ reporterr(1,NULL);
+
+ free(db);
+ free(eb);
+ free(I);
+ free(old);
+ free(newbuf);
+
+ return 0;
+}
+
diff --git a/other-licenses/bsdiff/moz.build b/other-licenses/bsdiff/moz.build
new file mode 100644
index 0000000000..c7080a6e24
--- /dev/null
+++ b/other-licenses/bsdiff/moz.build
@@ -0,0 +1,22 @@
+# -*- Mode: python; 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/.
+
+HOST_SOURCES += [
+ 'bsdiff.c',
+]
+
+HostProgram('mbsdiff')
+
+if CONFIG['HOST_OS_ARCH'] == 'WINNT':
+ HOST_OS_LIBS += [
+ 'ws2_32',
+ ]
+ USE_STATIC_LIBS = True
+
+LOCAL_INCLUDES += [
+ '/toolkit/mozapps/update/updater',
+ '/toolkit/mozapps/update/updater/bspatch',
+]
diff --git a/other-licenses/ia2/Accessible2.idl b/other-licenses/ia2/Accessible2.idl
new file mode 100644
index 0000000000..71f01f684f
--- /dev/null
+++ b/other-licenses/ia2/Accessible2.idl
@@ -0,0 +1,694 @@
+/*************************************************************************
+ *
+ * File Name (Accessible2.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2013 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+/** @mainpage
+
+ @section _interfaces Interfaces
+ IAccessible2\n
+ IAccessible2_2\n
+ IAccessible2_3\n
+ IAccessibleAction\n
+ IAccessibleApplication\n
+ IAccessibleComponent\n
+ IAccessibleDocument\n
+ IAccessibleEditableText\n
+ IAccessibleHypertext\n
+ IAccessibleHypertext2\n
+ IAccessibleHyperlink\n
+ IAccessibleImage\n
+ IAccessibleRelation\n
+ IAccessibleTable [Deprecated]\n
+ IAccessibleTable2\n
+ IAccessibleTableCell\n
+ IAccessibleText\n
+ IAccessibleText2\n
+ IAccessibleValue
+
+ @section _structs Structs
+ IA2Locale\n
+ IA2Range\n
+ IA2TableModelChange\n
+ IA2TextSegment
+
+ @section _enums Enums
+ ::IA2Actions values are predefined actions for use when implementing support for HTML5 media.\n
+ ::IA2CoordinateType values define the requested coordinate type (screen or parent window).\n
+ ::IA2EventID values identify events.\n
+ ::IA2Role values defines roles which are in addition to the existing MSAA roles.\n
+ ::IA2ScrollType values define where to place an object or substring on the screen.\n
+ ::IA2States values define states which are in addition to the existing MSAA states.\n
+ ::IA2TableModelChangeType values describe the kinds of changes made to a table (insert, delete, update).\n
+ ::IA2TextBoundaryType values define the requested text unit (character, word, sentence, line, paragraph).\n
+ ::IA2TextSpecialOffsets values define special offsets for use in the text interfaces.
+
+ @section _constants Constants
+ @ref grpRelations
+
+ @section _misc Miscellaneous
+ @ref _licensePage "BSD License"\n
+ @ref _generalInfo "General Information"\n
+
+ @page _licensePage BSD License
+ %IAccessible2 IDL Specification
+
+ Copyright (c) 2007, 2013 Linux Foundation\n
+ Copyright (c) 2006 IBM Corporation\n
+ Copyright (c) 2000, 2006 Sun Microsystems, Inc.\n
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials
+ provided with the distribution.
+
+ 3. Neither the name of the Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products
+ derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This BSD License conforms to the Open Source Initiative "Simplified
+ BSD License" as published at:
+ http://www.opensource.org/licenses/bsd-license.php
+
+ %IAccessible2 is a trademark of the Linux Foundation. The %IAccessible2
+ mark may be used in accordance with the
+ <a href="http://www.linuxfoundation.org/collaborate/workgroups/accessibility/trademark-policy">
+ Linux Foundation Trademark Policy</a> to indicate compliance with the %IAccessible2 specification.
+
+ @page _generalInfo General Information
+ The following information is applicable to two or more interfaces.
+
+ @ref _errors\n
+ @ref _memory\n
+ &nbsp;&nbsp;@ref _arrayConsideration\n
+ @ref _indexes\n
+ @ref _enums\n
+ @ref _specialOffsets\n
+ @ref _dicoveringInterfaces\n
+ @ref _changingInterfaces\n
+ @ref _applicationInfo\n
+ @ref _childIDs\n
+ @ref _variants\n
+ @ref _iaaction-iahyperlink\n
+ @ref _trademark
+
+ @section _errors Error Handling
+ HRESULT values are defined by the Microsoft&reg; Win32&reg; API. For more information, refer to
+ <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa378137%28v=vs.85%29.aspx">
+ Interpreting HRESULT Values</a> in MSDN&reg;.
+
+ Note that the S_FALSE return value is considered a non-error value and the
+ SUCCEEDED macro will return TRUE. S_FALSE is used when there is no failure
+ but there was nothing valid to return, e.g. in IAccessible2::attributes when
+ there are no attributes. When S_FALSE is returned [out] pointer types should
+ be NULL and [out] longs should generally be 0, but sometimes -1 is used such
+ as IAccessible2::indexInParent, IAccessibleText::caretOffset, and
+ IAccessibleHypertext::hyperlinkIndex.
+
+ Note that for BSTR [out] variables common COM practice is that the server does
+ the SysAllocString and the client does the SysFreeString. Also note that when
+ NULL is returned there is no need for the client to call SysFreeString. Please
+ refer to the documentation for each method for more details regarding error handling.
+
+ @section _memory Memory Management
+ The following memory management issues should be considered:
+ @li Although [out] BSTR variables are declared by the client, their space is
+ allocated by the server. They need to be freed with SysFreeString by the
+ client at end of life; the same is true when BSTRs are used in structs or
+ arrays which are passed to the server.
+ @li If there is no valid [out] BSTR to return, the server should return S_FALSE and
+ assign NULL to the output, e.g. *theOutBSTR = NULL;.
+ @li COM interfaces need to be referenced with AddRef when used and dereferenced
+ with Release at end of life.
+ @li Single [out] longs, HWNDs, booleans, and structs are declared by the caller
+ and passed by reference. The marshaller does all the memory management.
+
+ The following articles may be helpful for understanding memory management issues:
+ @li An article by Don Box in a
+ <a href="http://www.microsoft.com/msj/1196/activex1196.aspx">Q & A section</a>
+ of the November 1996 edition of the Microsoft Systems Journal.
+ @li A posting to a CodeGuru forum,
+ <a href="http://www.codeguru.com/forum/showthread.php?t=364511">Windows SDK
+ String: What are the rules for BSTR allocation and deallocation?</a>
+
+ @subsection _arrayConsideration Special Consideration when using Arrays
+ There are several methods which return arrays. In the case of IAccessible2::relations
+ and IAccessibleRelation::targets the client must allocate and free the arrays.
+
+ For the remaining methods which return arrays, the server must allocate the array
+ and the client must free the array when no longer needed. These methods are
+ IAccessible2::extendedStates, IAccessible2::localizedExtendedStates,
+ IAccessible2_2::relationTargetsOfType, IAccessibleAction::keyBinding,
+ IAccessibleHypertext2::hyperlinks, IAccessibleTable::selectedChildren,
+ IAccessibleTable::selectedColumns, IAccessibleTable::selectedRows,
+ IAccessibleTable2::selectedCells, IAccessibleTable2::selectedColumns,
+ IAccessibleTable2::selectedRows, IAccessibleTableCell::columnHeaderCells,
+ and IAccessibleTableCell::rowHeaderCells.
+ For those methods, the server must allocate both the top level array and any storage
+ associated with it, e.g. for BSTRs. The server must allocate the arrays with
+ CoTaskMemAlloc and any BSTRs with SysAllocString. The client must use CoTaskMemFree
+ to free the array and any BSTRs must be freed with SysFreeString.
+
+ Also, the IDL for IAccessible2::extendedStates, IAccessible2::localizedExtendedStates,
+ IAccessibleAction::keyBinding, IAccessibleTable::selectedChildren,
+ IAccessibleTable::selectedColumns, and IAccessibleTable::selectedRows includes an
+ extraneous [in] parameter for the caller to specify the max size of the array.
+ This parameter will be ignored by the COM server.
+
+ @section _indexes Zero and One Based Indexes
+ Unless otherwise specified all offsets and indexes are 0 based.
+
+ @section _enums Enums
+ Note that enums start at 0.
+
+ @section _specialOffsets Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods
+ IAccessibleText and IAccessibleEditableText can use one or more of the following
+ special offset values. They are defined in the ::IA2TextSpecialOffsets enum.
+ @li Using ::IA2_TEXT_OFFSET_LENGTH (-1) as an offset in any of the IAccessibleText or
+ IAccessibleEditableText methods is the same as specifying the length of the string.
+ @li Using ::IA2_TEXT_OFFSET_CARET (-2) as an offset for IAccessibleText::textBeforeOffset,
+ IAccessibleText::textAtOffset, and IAccessibleText::textAfterOffset indicates that the
+ text related to the physical location of the caret should be used. This is needed for
+ applications that consider the character offset of the end of one line (as reached by
+ pressing the End key) the same as the offset of the first character on the next line.
+ Since the same offset is associated with two different lines a special means is needed
+ to fetch text from the line where the caret is physically located.
+
+ @section _dicoveringInterfaces Discovery of Interfaces
+ In general AT (Assistive Technology) should try IAccessible2 interfaces, followed by using
+ the MSAA (Microsoft&reg; Active Accessibility&reg;) interfaces. (In cases where the an application
+ is known to have custom interfaces which provide information not supplied by IAccessible2
+ or MSAA, then those custom interfaces can be used.) The AT can then, by default, support
+ unknown IAccessible2/MSAA applications, without the application developers having to request
+ AT vendors for support on an individual application by application basis.
+
+ When you have a reference to an IAccessible and require a reference to an IAccessible2 use
+ QueryService as follows:
+ @code
+ // pAcc is a reference to the accessible object's IAccessible interface.
+ IServiceProvider *pService = NULL;
+ hr = pAcc->QueryInterface(IID_IServiceProvider, (void **)&pService);
+ if(SUCCEEDED(hr)) {
+ IAccessible2 *pIA2 = NULL;
+ hr = pService->QueryService(IID_IAccessible, IID_IAccessible2, (void**)&pIA2);
+ if (SUCCEEDED(hr) && pIA2) {
+ // The control supports IAccessible2.
+ // pIA2 is the reference to the accessible object's IAccessible2 interface.
+ }
+ }
+ @endcode
+
+ @section _changingInterfaces Changing between Accessible Interfaces
+ Note that developers must always implement MSAA's IAccessible and, if needed, some
+ of the interfaces in the set of IAccessible2 interfaces. Although the IAccessible2
+ IDL is coded such that IAccessible2 is a subclass of MSAA's IAccessible, none of
+ MSAA's IAccessible methods are redefined by IAccessible2.
+
+ QueryService must be used to switch from a reference to an MSAA IAccessible interface
+ to another interface. This has been
+ <a href="http://www.atia.org/files/public/Introducing_IAccessibleEx.doc">
+ documented</a> and the pertinent facts have been extracted below:
+
+ @par
+ Why use QueryService instead of just using QueryInterface to get IAccessibleEx
+ directly? The reason is that since MSAA 2.0, clients don't talk to a server's
+ IAccessible interface directly; instead they talk to an intermediate MSAA-provided
+ wrapper that calls through to the original IAccessible. This wrapper provides services
+ such as implementing IDispatch, supplying information from MSAA 2.0's Dynamic Annotation
+ service, and scaling locations when running on Windows Vista with DPI scaling enabled.
+ QueryService is the supported way to expose additional interfaces from an existing
+ IAccessible and was originally used by MSHTML to expose IHTMLElement objects corresponding
+ to IAccessibles. QueryService is often more convenient for servers to implement than
+ QueryInterface because it does not have the same requirements for preserving object
+ identity or symmetry/transitivity as QueryInterface, so QueryService allows servers to
+ easily implement the interface on the same object or a separate object. The latter is
+ often hard to do with QueryInterface unless the original object supports aggregation.
+
+ Two related references in MSDN&reg; are:
+ @li <a href="http://msdn.microsoft.com/en-us/library/ms696078(VS.85).aspx">
+ "Using QueryService to expose a native object model interface for an IAccessible object"</a>
+ @li <a href="http://msdn.microsoft.com/en-us/library/ms528415.aspx#acc_obj">
+ "Accessing the Internet Explorer Object Associated with an Accessible Object"</a>
+
+ Based on this information from Microsoft, QueryService must be used to switch back and forth
+ between a reference to an MSAA IAccessible interface and any of the IAccessible2 interfaces.
+
+ Regarding switching between any of the IAccessible2 interfaces, applications implementing
+ IAccessible2 should implement the IAccessible2 interfaces on a single object since ATs
+ will be using QueryInterface to switch between the IAccessilbe2 interfaces. Implementing
+ the IAccessible2 interfaces on separate objects would require the use of QueryService.
+ There is one exception, IAccessibleApplication can be implemented on a separate object so
+ its common code doesn't have to be included in each accessible object. ATs should use
+ QueryService to access IAccessibleApplication.
+
+ @section _applicationInfo Access to Information about the Application
+ Servers implementing IAccessible2 should provide access to the IAccessibleApplication
+ interface via QueryService from any object so that ATs can easily determine specific
+ information about the application such as its name or version.
+
+ @section _childIDs Child IDs
+ The IAccessible2 interfaces do not support child IDs, i.e. simple child elements.
+ Full accessible objects must be created for each object that supports IAccessible2.
+ Therefore MSAA's get_accChild should never return a child ID (other than CHILDID_SELF)
+ for an object that implements any of the IAccessible2 interfaces.
+
+ Microsoft's UI Automation specification has the same limitation and this was resolved
+ in the UI Automation Express specification by adding IAccessibleEx::GetObjectForChild
+ and IAccessibleEx::GetIAccessiblePair. These methods allow mapping back and forth
+ between an IAccessibleEx and an {IAccessible, Child ID} pair. A future version of
+ IAccessible2 may include similar methods to map back and forth between an IAccessible2
+ and an {IAccessible, Child ID} pair.
+
+ @section _variants VARIANTs
+ Some methods return a VARIANT. Implementers need to make sure that the return type is
+ specified, i.e. VT_I4, VT_IDISPATCH, etc. The methods that return VARIANTs are
+ IAccessibleHyperlink::anchor, IAccessibleHyperlink::anchorTarget, IAccessibleValue::currentValue,
+ IAccessibleValue::maximumValue, IAccessibleValue::minimumValue.
+
+ @section _iaaction-iahyperlink IAccessibleHyperlink as subclass of IAccessibleAction
+ In this version of the IDL, IAccessibleHyperlink is a subclass of IAccessibleAction.
+ However, there is no practical need for that inheritance and in some cases, such as
+ an image map of smart tags, it doesn't make sense because such an image map doesn't
+ have actionable objects; it's the secondary smart tags that are actionable. As a
+ result, implementations should not rely on the inheritance as it may be removed in
+ a later version of the IDL.
+
+ @section _trademark Trademark Attribution
+ The names of actual companies and products mentioned herein may be the trademarks of
+ their respective owners. In particular, Active Accessibility, Microsoft, MSDN, and Win32
+ are trademarks of the Microsoft group of companies in the U.S.A. and/or other countries.
+
+**/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "AccessibleRelation.idl";
+import "AccessibleStates.idl";
+import "IA2CommonTypes.idl";
+
+/** A structure defining the locale of an accessible object.
+
+IAccessible2::locale returns this struct.
+*/
+typedef struct IA2Locale {
+ BSTR language; ///< ISO 639-1 Alpha-2 two character language code
+ BSTR country; ///< ISO 3166-1 Alpha-2 two character country code
+ BSTR variant; ///< Application specific variant of the locale
+} IA2Locale;
+
+/** @brief This interface exposes the primary set of information about an
+ IAccessible2 enabled accessible object.
+
+ This interface must always be provided for objects that support some
+ portion of the collection of the %IAccessible2 interfaces.
+
+ Please refer to @ref _changingInterfaces "Changing between Accessible Interfaces"
+ for special considerations related to use of the MSAA IAccessible interface and
+ the set of %IAccessible2 interfaces.
+ */
+[object, uuid(E89F726E-C4F4-4c19-BB19-B647D7FA8478)]
+interface IAccessible2 : IAccessible
+{
+
+ /** @brief Returns the number of accessible relations for this object.
+ @param [out] nRelations
+ @retval S_OK
+ */
+ [propget] HRESULT nRelations
+ (
+ [out, retval] long *nRelations
+ );
+
+ /** @brief Returns one accessible relation for this object.
+ @param [in] relationIndex
+ 0 based
+ @param [out] relation
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT relation
+ (
+ [in] long relationIndex,
+ [out, retval] IAccessibleRelation **relation
+ );
+
+ /** @brief Returns multiple accessible relations for this object.
+ @param [in] maxRelations
+ maximum size of the array allocated by the client
+ @param [out] relations
+ The array of accessible relation objects. Note that this array is to be
+ allocated by the client and freed when no longer needed. Refer to @ref
+ _arrayConsideration "Special Consideration when using Arrays" for more details.
+ @param [out] nRelations
+ actual number of relations in the returned array (not more than maxRelations)
+ @retval S_OK
+ @retval S_FALSE if there are no relations, nRelations is set to 0
+ @note As a performant alternative, client code should consider using IAccessible2_2::relationTargetsOfType.
+ */
+ [propget] HRESULT relations
+ (
+ [in] long maxRelations,
+ [out, size_is(maxRelations), length_is(*nRelations)]
+ IAccessibleRelation **relations,
+ [out, retval] long *nRelations
+ );
+
+ /** @brief Returns the role of an %IAccessible2 object.
+ @param [out] role
+ The role of an %IAccessible2 object.
+ @retval S_OK
+ @note
+ @li For convenience MSAA roles are also passed through this method so the
+ AT doesn't have to also fetch roles through MSAA's get_accRole.
+ @li %IAccessible2 roles should not be passed through MSAA's get_accRole.
+ @li For compatibility with non IAccessible2 enabled ATs, IAccessible2
+ applications should also add support to get_accRole to return the closest
+ MSAA role or ROLE_SYSTEM_CLIENT (the MSAA defined default role) if there
+ is not a good match.
+ @li This method is missing a [propget] prefix in the IDL. The result is the
+ method is named role in generated C++ code instead of get_role.
+ */
+ HRESULT role
+ (
+ [out, retval] long *role
+ );
+
+ /** @brief Makes an object visible on the screen.
+ @param [in] scrollType
+ Defines where the object should be placed on the screen.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT scrollTo
+ (
+ [in] enum IA2ScrollType scrollType
+ );
+
+ /** @brief Moves the top left of an object to a specified location.
+
+ @param [in] coordinateType
+ Specifies whether the coordinates are relative to the screen or the parent object.
+ @param [in] x
+ Defines the x coordinate.
+ @param [in] y
+ Defines the y coordinate.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT scrollToPoint
+ (
+ [in] enum IA2CoordinateType coordinateType,
+ [in] long x,
+ [in] long y
+ );
+
+ /** @brief Returns grouping information.
+
+ Used for tree items, list items, tab panel labels, radio buttons, etc.
+ Also used for collections of non-text objects.
+
+ @param [out] groupLevel
+ 1 based, 0 indicates that this value is not applicable
+ @param [out] similarItemsInGroup
+ 1 based, 0 indicates that this value is not applicable
+ @param [out] positionInGroup
+ 1 based, 0 indicates that this value is not applicable. This is an index
+ into the objects in the current group, not an index into all the objects
+ at the same group level.
+ @retval S_OK if at least one value is valid
+ @retval S_FALSE if no values are valid, [out] values are 0s
+ @note This method is meant to describe the nature of an object's containment
+ structure. It's exposed by trees, tree grids, nested lists, nested menus,
+ but not headings, which uses the level object attribute. It is also exposed
+ by radio buttons (with groupLevel == 0).
+ @note This is normally not implemented on a combo box to describe the nature
+ of its contents. Normally an AT will get that information from its child list
+ object. However, in some cases when non-edit combo boxes are not able to be structured
+ such that the list is a child of the combo box, this method is implemented on
+ the combo box itself. ATs can use this interface if a child list is not found.
+ */
+ [propget] HRESULT groupPosition
+ (
+ [out] long *groupLevel,
+ [out] long *similarItemsInGroup,
+ [out, retval] long *positionInGroup
+ );
+
+ /** @brief Returns the bit strip containing any IAccessible2 states.
+
+ The IAccessible2 states are in addition to the MSAA states and are defined in
+ the IA2States enum.
+
+ @param [out] states
+ @retval S_OK
+ */
+ [propget] HRESULT states
+ (
+ [out, retval] AccessibleStates *states
+ );
+
+ /** @brief Returns the extended role.
+
+ An extended role is a role which is dynamically generated by the application.
+ It is not predefined by the %IAccessible2 specification.
+
+ @param [out] extendedRole
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT extendedRole
+ (
+ [out, retval] BSTR *extendedRole
+ );
+
+ /** @brief Returns the localized extended role.
+ @param [out] localizedExtendedRole
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT localizedExtendedRole
+ (
+ [out, retval] BSTR *localizedExtendedRole
+ );
+
+ /** @brief Returns the number of extended states.
+ @param [out] nExtendedStates
+ @retval S_OK
+ */
+ [propget] HRESULT nExtendedStates
+ (
+ [out, retval] long *nExtendedStates
+ );
+
+ /** @brief Returns the extended states (array of strings).
+
+ An extended state is a state which is dynamically generated by the application.
+ It is not predefined by the %IAccessible2 specification.
+
+ @param [in] maxExtendedStates
+ This parameter is ignored. Refer to @ref _arrayConsideration
+ "Special Consideration when using Arrays" for more details.
+ @param [out] extendedStates
+ This array is allocated by the server. The client must free it with CoTaskMemFree.
+ @param [out] nExtendedStates
+ The number of extended states returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are no states, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT extendedStates
+ (
+ [in] long maxExtendedStates,
+ [out, size_is(,maxExtendedStates), length_is(,*nExtendedStates)] BSTR **extendedStates,
+ [out, retval] long *nExtendedStates
+ );
+
+ /** @brief Returns the localized extended states (array of strings).
+
+ @param [in] maxLocalizedExtendedStates
+ This parameter is ignored. Refer to @ref _arrayConsideration
+ "Special Consideration when using Arrays" for more details.
+ @param [out] localizedExtendedStates
+ This array is allocated by the server. The client must free it with CoTaskMemFree.
+ @param [out] nLocalizedExtendedStates
+ The number of localized extended states returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are no states, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT localizedExtendedStates
+ (
+ [in] long maxLocalizedExtendedStates,
+ [out, size_is(,maxLocalizedExtendedStates), length_is(,*nLocalizedExtendedStates)] BSTR **localizedExtendedStates,
+ [out, retval] long *nLocalizedExtendedStates
+ );
+
+ /** @brief Returns the unique ID.
+
+ The uniqueID is an identifier for this object, is unique within the
+ current window, and remains the same for the lifetime of the accessible
+ object.
+
+ The uniqueID is not related to:
+ - the MSAA objectID which is used by the server to disambiguate between
+ IAccessibles per HWND or
+ - the MSAA childID which is used to disambiguate between children being
+ managed by an IAccessible.
+
+ This value is provided so the AT can have access to a unique runtime persistent
+ identifier even when not handling an event for the object.
+
+ An example of when this value is useful is if the AT wants to build a cache.
+ The AT could cache the uniqueIDs in addition to other data being cached.
+ When an event is fired the AT could map the uniqueID to its internal model.
+ Thus, if there's a REORDER/SHOW/HIDE event the AT knows which part of the
+ internal structure has been invalidated and can refetch just that part.
+
+ This value can also be used by an AT to determine when the current control
+ has changed. If the role is the same for two controls that are adjacent in
+ the tab order, this can be used to detect the new control.
+
+ Another use of this value by an AT is to identify when a grouping object has
+ changed, e.g. when moving from a radio button in one group to a radio button in a
+ different group.
+
+ One means of implementing this would be to create a factory with a 32 bit number
+ generator and a reuse pool. The number generator would emit numbers starting
+ at 1. Each time an object's life cycle ended, its number would be saved into a
+ reuse pool. The number generator would be used whenever the reuse pool was empty.
+
+ Another way to create a unique ID is to generate it from a pointer value, e.g. an
+ object's address. That would be unique because no two active objects can use the
+ same allocated memory space.
+
+ @param [out] uniqueID
+ @retval S_OK
+ */
+ [propget] HRESULT uniqueID
+ (
+ [out, retval] long *uniqueID
+ );
+
+ /** @brief Returns the window handle for the parent window which contains this object.
+
+ This is the same window handle which will be passed for any events that occur on the
+ object, but is cached in the accessible object for use when it would be helpful to
+ access the window handle in cases where an event isn't fired on this object.
+
+ A use case is when a screen reader is grabbing an entire web page on a page load.
+ Without the availability of windowHandle, the AT would have to get the window handle
+ by using WindowFromAccessibleObject on each IAccessible, which is slow because it's
+ implemented by oleacc.dll as a loop which crawls up the ancestor chain and looks for
+ a ROLE_WINDOW object, mapping that back to a window handle.
+
+ @param [out] windowHandle
+ @retval S_OK
+ */
+ [propget] HRESULT windowHandle
+ (
+ [out, retval] HWND *windowHandle
+ );
+
+ /** @brief Returns the index of this object in its parent object.
+ @param [out] indexInParent
+ 0 based; -1 indicates there is no parent; the upper bound is the value
+ returned by the parent's IAccessible::get_accChildCount.
+ @retval S_OK
+ @retval S_FALSE if no parent, [out] value is -1
+ */
+ [propget] HRESULT indexInParent
+ (
+ [out, retval] long *indexInParent
+ );
+
+ /** @brief Returns the IA2Locale of the accessible object.
+ @param [out] locale
+ @retval S_OK
+ */
+ [propget] HRESULT locale
+ (
+ [out, retval] IA2Locale *locale
+ );
+
+ /** @brief Returns the attributes specific to this object, such as a cell's formula.
+ @param [out] attributes
+ @retval S_OK
+ @retval S_FALSE returned if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT attributes
+ (
+ [out, retval] BSTR *attributes
+ );
+
+}
+
diff --git a/other-licenses/ia2/Accessible2_2.idl b/other-licenses/ia2/Accessible2_2.idl
new file mode 100644
index 0000000000..e90c2a348d
--- /dev/null
+++ b/other-licenses/ia2/Accessible2_2.idl
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * File Name (Accessible2_2.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2013 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "Accessible2.idl";
+
+/** @brief This interface exposes the primary set of information about an
+ IAccessible2 enabled accessible object.
+
+ This interface must always be provided for objects that support some
+ portion of the collection of the %IAccessible2 interfaces.
+
+ Please refer to @ref _changingInterfaces "Changing between Accessible Interfaces"
+ for special considerations related to use of the MSAA IAccessible interface and
+ the set of %IAccessible2 interfaces.
+ */
+[object, uuid(6C9430E9-299D-4E6F-BD01-A82A1E88D3FF)]
+interface IAccessible2_2 : IAccessible2
+{
+ /** @brief Returns the attribute value of a specified attribute specific to this object.
+ @param [in] name
+ @param [out] attribute
+ @retval S_OK
+ @retval S_FALSE returned if there is nothing to return, [out] value is NULL.
+ @retval E_INVALIDARG if bad [in] passed.
+ @note The output value is a VARIANT. Typically it will be a VT_BSTR, but there
+ are some cases where it will be a VT_I4 or VT_BOOL. Refer to the <a href=
+ "http://www.linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2/objectattributesIAccessible2">
+ Object Attributes specification</a> for more information.
+ */
+ [propget] HRESULT attribute
+ (
+ [in] BSTR name,
+ [out, retval] VARIANT *attribute
+ );
+
+ /** @brief Returns the deepest hypertext accessible in the subtree of this object, and the caret offset within it.
+ @param [out] accessible
+ @param [out] caretOffset
+ @retval S_OK
+ @retval S_FALSE returned if there is no caret in any of the objects in the subtree, [out] accessible is NULL and [out] caretOffset is -1.
+ */
+ [propget] HRESULT accessibleWithCaret
+ (
+ [out] IUnknown **accessible,
+ [out, retval] long *caretOffset
+ );
+
+ /** @brief Returns relation targets for a specified target type.
+ @param [in] type
+ The requested @ref grpRelations "relation type".
+ @param [in] maxTargets
+ The number of targets requested. 0 indicates that all targets should be returned.
+ @param [out] targets
+ This array is allocated by the server. The client must free it with CoTaskMemFree.
+ @param [out] nTargets
+ The number of targets returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are no targets, [out] values are NULL and 0 respectively.
+ @retval E_INVALIDARG if bad [in] passed.
+ */
+ [propget] HRESULT relationTargetsOfType
+ (
+ [in] BSTR type,
+ [in] long maxTargets,
+ [out, size_is(,*nTargets)] IUnknown ***targets,
+ [out, retval] long *nTargets
+ );
+
+}
+
diff --git a/other-licenses/ia2/Accessible2_3.idl b/other-licenses/ia2/Accessible2_3.idl
new file mode 100644
index 0000000000..f3a9b18962
--- /dev/null
+++ b/other-licenses/ia2/Accessible2_3.idl
@@ -0,0 +1,50 @@
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "Accessible2_2.idl";
+
+/**
+ * This structure represents a directional range of the content. It is defined
+ * by two points in the content, where each one is defined by an accessible
+ * object and an offset relative to it. A typical case of a range point is
+ * a text accessible and text offset within it.
+ *
+ * The "anchor" is one point of the range and typically remains constant.
+ * The other point is the "active" point, which typically corresponds to
+ * the user's focus or point of interest. The user moves the active point to
+ * expand or collapse the range. In most cases, anchor is the start of the range
+ * and active is the end. However, in case of selection, when selecting
+ * backwards (e.g. pressing shift+left arrow in a text field), the start of
+ * the range is the active point, as the user moves this to manipulate
+ * the selection.
+ */
+typedef struct IA2Range {
+ IUnknown* anchor;
+ long anchorOffset;
+ IUnknown* active;
+ long activeOffset;
+} IA2Range;
+
+/**
+ * @brief This interface is an extension of IAccessible2_2 and IAccessible2
+ * interfaces.
+ */
+[object, uuid(5BE18059-762E-4E73-9476-ABA294FED411)]
+interface IAccessible2_3 : IAccessible2_2
+{
+ /**
+ * @brief Returns an array of ranges for selections within the accessible.
+ * @param [out] ranges
+ The array of selection ranges, allocated by the server. The client must
+ free it with CoTaskMemFree.
+ * @param [out] nRanges
+ the array length
+ * @retval S_OK
+ * @retval S_FALSE returned if there is no selection within the accessible
+ */
+ [propget] HRESULT selectionRanges
+ (
+ [out, size_is(,*nRanges)] IA2Range **ranges,
+ [out, retval] long *nRanges
+ );
+}
diff --git a/other-licenses/ia2/AccessibleAction.idl b/other-licenses/ia2/AccessibleAction.idl
new file mode 100644
index 0000000000..7366f69f80
--- /dev/null
+++ b/other-licenses/ia2/AccessibleAction.idl
@@ -0,0 +1,220 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleAction.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2013 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+
+/** This enum defines values which are predefined actions for use when implementing
+ support for media.
+
+ This enum is used when specifying an action for IAccessibleAction::doAction.
+*/
+
+enum IA2Actions {
+ IA2_ACTION_OPEN = -1, /**< Used to inform the server that the client will
+ signal via IA2_ACTION_COMPLETE when it has consumed
+ the content provided by the object. This action
+ allows the object's server to wait for all clients
+ to signal their readiness for additional content.
+ Any form of content generation that requires
+ synchronization with an AT would require use of this
+ action. One example is the generation of text describing
+ visual content not obvious from a video's sound track.
+ In this scenario the Text to Speech or Braille output
+ may take more time than the related length of silence
+ in the video's sound track. */
+ IA2_ACTION_COMPLETE = -2, /**< Used by the client to inform the server that it has
+ consumed the most recent content provided by this object. */
+ IA2_ACTION_CLOSE = -3 /**< Used to inform the server that the client no longer
+ requires synchronization. */
+};
+
+/** @brief This interface gives access to actions that can be executed
+ for accessible objects.
+
+ Every accessible object that can be manipulated via the native GUI beyond the
+ methods available either in the MSAA IAccessible interface or in the set of
+ IAccessible2 interfaces (other than this IAccessibleAction interface) should
+ support the IAccessibleAction interface in order to provide Assistive Technology
+ access to all the actions that can be performed by the object. Each action can
+ be performed or queried for a name, description or associated key bindings.
+ Actions are needed more for ATs that assist the mobility impaired, such as
+ on-screen keyboards and voice command software. By providing actions directly,
+ the AT can present them to the user without the user having to perform the extra
+ steps to navigate a context menu.
+
+ The first action should be equivalent to the MSAA default action. If there is
+ only one action, %IAccessibleAction should also be implemented.
+*/
+[object, uuid(B70D9F59-3B5A-4dba-AB9E-22012F607DF5)]
+interface IAccessibleAction : IUnknown
+{
+
+ /** @brief Returns the number of accessible actions available in this object.
+
+ If there are more than one, the first one is considered the
+ "default" action of the object.
+ @param [out] nActions
+ The returned value of the number of actions is zero if there are
+ no actions.
+ @retval S_OK
+ @note This method is missing a [propget] prefix in the IDL. The result is the
+ method is named nActions in generated C++ code instead of get_nActions.
+ */
+ HRESULT nActions
+ (
+ [out,retval] long* nActions
+ );
+
+ /** @brief Performs the specified Action on the object.
+ @param [in] actionIndex
+ 0 based index specifying the action to perform. If it lies outside
+ the valid range no action is performed.
+ @retval S_OK
+ @retval S_FALSE if action could not be performed
+ @retval E_INVALIDARG if bad [in] passed
+ @note If implementing support for media, refer to the predefined constants in the ::IA2Actions enum.
+ */
+ HRESULT doAction
+ (
+ [in] long actionIndex
+ );
+
+ /** @brief Returns a description of the specified action of the object.
+ @param [in] actionIndex
+ 0 based index specifying which action's description to return.
+ If it lies outside the valid range an empty string is returned.
+ @param [out] description
+ The returned value is a localized string of the specified action.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT description
+ (
+ [in] long actionIndex,
+ [out, retval] BSTR *description
+ );
+
+ /** @brief Returns an array of BSTRs describing one or more key bindings, if
+ there are any, associated with the specified action.
+
+ The returned strings are the localized human readable key sequences to be
+ used to activate each action, e.g. "Ctrl+Shift+D". Since these key
+ sequences are to be used when the object has focus, they are like
+ mnemonics (access keys), and not like shortcut (accelerator) keys.
+
+ There is no need to implement this method for single action controls since
+ that would be redundant with the standard MSAA programming practice of
+ getting the mnemonic from get_accKeyboardShortcut.
+
+ An AT such as an On Screen Keyboard might not expose these bindings but
+ provide alternative means of activation.
+
+ Note: the client allocates and passes in an array of pointers. The server
+ allocates the BSTRs and passes back one or more pointers to these BSTRs into
+ the array of pointers allocated by the client. The client is responsible
+ for deallocating the BSTRs.
+
+ @param [in] actionIndex
+ 0 based index specifying which action's key bindings should be returned.
+ @param [in] nMaxBindings
+ This parameter is ignored. Refer to @ref _arrayConsideration
+ "Special Consideration when using Arrays" for more details.
+ @param [out] keyBindings
+ An array of BSTRs, allocated by the server, one for each key binding.
+ The client must free it with CoTaskMemFree.
+ @param [out] nBindings
+ The number of key bindings returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are no key bindings, [out] values are NULL and 0 respectively
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT keyBinding
+ (
+ [in] long actionIndex,
+ [in] long nMaxBindings,
+ [out, size_is(,nMaxBindings), length_is(,*nBindings)] BSTR **keyBindings,
+ [out, retval] long *nBindings
+ );
+
+ /** @brief Returns the non-localized name of specified action.
+ @param [in] actionIndex
+ 0 based index specifying which action's non-localized name should be returned.
+ @param [out] name
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT name
+ (
+ [in] long actionIndex,
+ [out, retval] BSTR *name
+ );
+
+ /** @brief Returns the localized name of specified action.
+ @param [in] actionIndex
+ 0 based index specifying which action's localized name should be returned.
+ @param [out] localizedName
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT localizedName
+ (
+ [in] long actionIndex,
+ [out, retval] BSTR *localizedName
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleApplication.idl b/other-licenses/ia2/AccessibleApplication.idl
new file mode 100644
index 0000000000..2586334122
--- /dev/null
+++ b/other-licenses/ia2/AccessibleApplication.idl
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleApplication.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2010 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+
+/** @brief This interface gives access to the application's name and version information.
+
+ This interface provides the AT with the information it needs to differentiate
+ this application from other applications, from other versions of this
+ application, or from other versions of this application running on different
+ versions of an accessibility bridge or accessibility toolkit.
+
+ Servers implementing IAccessible2 should provide access to the %IAccessibleApplication
+ interface via QueryService from any object so that ATs can easily determine specific
+ information about the application such as its name or version.
+*/
+[object, uuid(D49DED83-5B25-43F4-9B95-93B44595979E)]
+interface IAccessibleApplication : IUnknown
+{
+
+ /** @brief Returns the application name.
+ @param [out] name
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT appName
+ (
+ [out, retval] BSTR *name
+ );
+
+ /** @brief Returns the application version.
+ @param [out] version
+ The version string must not contain levels when it is know beforehand that
+ this information will never require a change in a client's behavior.
+ For example, use "3.6.0" rather than "3.6.0.v201005131500".
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT appVersion
+ (
+ [out, retval] BSTR *version
+ );
+
+ /** @brief Returns the toolkit/bridge name.
+ @param [out] name
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT toolkitName
+ (
+ [out, retval] BSTR *name
+ );
+
+ /** @brief Returns the toolkit/bridge version.
+ @param [out] version
+ The version string must not contain levels when it is know beforehand that
+ this information will never require a change in a client's behavior.
+ For example, use "3.6.0" rather than "3.6.0.v201005131500".
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT toolkitVersion
+ (
+ [out, retval] BSTR *version
+ );
+
+}
+
diff --git a/other-licenses/ia2/AccessibleComponent.idl b/other-licenses/ia2/AccessibleComponent.idl
new file mode 100644
index 0000000000..568997d875
--- /dev/null
+++ b/other-licenses/ia2/AccessibleComponent.idl
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleComponent.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2010 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+
+/** A value specifying a color in ARGB format, where each 8 bit color component
+specifies alpha, red, green, and blue respectively. The alpha value is optional.
+*/
+typedef long IA2Color;
+
+/** @brief This interface is implemented by any object that can be rendered
+ on the screen.
+
+ This interface provides the standard mechanism for an assistive technology
+ to retrieve information concerning the graphical representation of an object.
+ Coordinates used by the functions of this interface are specified in
+ different coordinate systems. Their scale is the same and is equal to
+ that of the screen coordinate system. In other words all coordinates
+ are measured in pixels. They differ in their respective origin:
+ <ul>
+ <li>The screen coordinate system has its origin in the upper left
+ corner of the current screen.</li>
+ <li>The origin of the parent coordinate system is the upper left corner
+ of the parent's bounding box. With no parent the screen coordinate
+ system is used instead.</li>
+ </ul>
+*/
+[object, uuid(1546D4B0-4C98-4bda-89AE-9A64748BDDE4)]
+interface IAccessibleComponent : IUnknown
+{
+
+ /** @brief Returns the location of the upper left corner of the object's
+ bounding box relative to the immediate parent object.
+
+ The coordinates of the bounding box are given relative to the parent's
+ coordinate system. The coordinates of the returned position are relative
+ to this object's parent or relative to the screen on which this object
+ is rendered if it has no parent. If the object is not on any screen
+ the returned position is (0,0).
+
+ @param [out] x
+ @param [out] y
+ @retval S_OK
+ */
+ [propget] HRESULT locationInParent
+ (
+ [out] long *x,
+ [out, retval] long *y
+ );
+
+ /** @brief Returns the foreground color of this object.
+ @param [out] foreground
+ The returned color is the foreground color of this object or, if
+ that is not supported, the default foreground color.
+ @retval S_OK
+ */
+ [propget] HRESULT foreground
+ (
+ [out, retval] IA2Color *foreground
+ );
+
+ /** @brief Returns the background color of this object.
+ @param [out] background
+ The returned color is the background color of this object or, if
+ that is not supported, the default background color.
+ @retval S_OK
+ */
+ [propget] HRESULT background
+ (
+ [out, retval] IA2Color *background
+ );
+}
diff --git a/other-licenses/ia2/AccessibleDocument.idl b/other-licenses/ia2/AccessibleDocument.idl
new file mode 100644
index 0000000000..3968f7cc1e
--- /dev/null
+++ b/other-licenses/ia2/AccessibleDocument.idl
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleDocument.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2013 Linux Foundation
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+
+/** @brief This interface represents documents.
+
+ This interface is used for a representation of documents.
+*/
+[object, uuid(C48C7FCF-4AB5-4056-AFA6-902D6E1D1149)]
+interface IAccessibleDocument : IUnknown
+{
+ /** @brief Returns the most recently used anchor target within a document.
+
+ A document's most recently targeted in-page anchor is returned. A typical use
+ of this method is to fetch the anchor target within an HTML document. In this
+ case anchor targets are those which has been defined with the <a> tag.
+
+ @param [out] accessible
+ @retval S_OK
+ @retval S_FALSE if there are no existing valid anchor targets, [out] value is NULL.
+ */
+ [propget] HRESULT anchorTarget
+ (
+ [out, retval] IUnknown **accessible
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleEditableText.idl b/other-licenses/ia2/AccessibleEditableText.idl
new file mode 100644
index 0000000000..08fcbcdbed
--- /dev/null
+++ b/other-licenses/ia2/AccessibleEditableText.idl
@@ -0,0 +1,262 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleEditableText.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2012 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "IA2CommonTypes.idl";
+
+/** @brief This interface provides clipboard capability to text objects.
+
+ This interface is typically used in conjunction with the IAccessibleText
+ interface and complements that interface with the additional capability of
+ clipboard operations. Note that even a read only text object can support
+ the copy capability so this interface is not limited to editable objects.
+
+ The substrings used with this interface are specified as follows:
+ If startOffset is less than endOffset, the substring starts with the
+ character at startOffset and ends with the character just before endOffset.
+ If endOffset is lower than startOffset, the result is the same as a call
+ with the two arguments exchanged. The whole text can be defined by passing
+ the indices zero and IAccessibleText::nCharacters. If both indices have the
+ same value, an empty string is defined.
+
+ Refer to the @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about a special offset constant that can be used in %IAccessibleEditableText methods.
+*/
+[object, uuid(A59AA09A-7011-4b65-939D-32B1FB5547E3)]
+interface IAccessibleEditableText : IUnknown
+{
+
+ /** @brief Copies the text range into the clipboard.
+
+ The selection is set to the specified offsets and then selection is copied into
+ the system clipboard.
+
+ @param [in] startOffset
+ Start index of the text to moved into the clipboard.
+ The valid range is 0..length.
+ @param [in] endOffset
+ End index of the text to moved into the clipboard.
+ The valid range is 0..length.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleEditableText
+ methods.
+ @deprecated This function is available via the application's GUI.
+ */
+ HRESULT copyText
+ (
+ [in] long startOffset,
+ [in] long endOffset
+ );
+
+ /** @brief Deletes a range of text.
+
+ The text between and including the two given indices is deleted
+ from the text represented by this object.
+
+ @param [in] startOffset
+ Start index of the text to be deleted.
+ The valid range is 0..length.
+ @param [in] endOffset
+ End index of the text to be deleted.
+ The valid range is 0..length.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleEditableText
+ methods.
+ */
+ HRESULT deleteText
+ (
+ [in] long startOffset,
+ [in] long endOffset
+ );
+
+ /** @brief Inserts text at the specified position.
+
+ The specified string is inserted at the given index into the text
+ represented by this object.
+
+ @param [in] offset
+ Index at which to insert the text.
+ The valid range is 0..length.
+ Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleEditableText
+ methods.
+ @param [in] text
+ Text that is inserted.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT insertText
+ (
+ [in] long offset,
+ [in] BSTR *text
+ );
+
+ /** @brief Deletes a range of text and copies it to the clipboard.
+
+ The selection is set to the specified offsets, the selection is then copied into
+ the system clipboard, and then the selection is deleted.
+
+ @param [in] startOffset
+ Start index of the text to be deleted.
+ The valid range is 0..length.
+ @param [in] endOffset
+ End index of the text to be deleted.
+ The valid range is 0..length.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleEditableText
+ methods.
+ @deprecated This function is available via the application's GUI.
+ */
+ HRESULT cutText
+ (
+ [in] long startOffset,
+ [in] long endOffset
+ );
+
+ /** @brief Pastes content from the clipboard.
+
+ Any existing selection is removed, the clipboard content is then pasted into
+ this object's text at the given offset. This method is similar to the insertText
+ method. If the index is not valid the system clipboard content is not inserted. The
+ behavior is the same as when Ctrl+V is used, i.e. the pasted contents are not
+ necessarily plain text.
+
+ @param [in] offset
+ Index at which to insert the content from the system clipboard into
+ the text represented by this object.
+ The valid range is 0..length.
+ Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleEditableText
+ methods.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @deprecated This function is available via the application's GUI.
+ */
+ HRESULT pasteText
+ (
+ [in] long offset
+ );
+
+ /** @brief Replaces text.
+
+ The text between the two given indices is replaced by the specified
+ replacement string. This method is equivalent to calling first
+ IAccessibleEditableText::deleteText with the two indices and then
+ calling IAccessibleEditableText::insertText with the replacement text
+ at the start index.
+
+ @param [in] startOffset
+ Start index of the text to be replaced.
+ The valid range is 0..length.
+ @param [in] endOffset
+ End index of the text to be replaced.
+ The valid range is 0..length.
+ @param [in] text
+ The Text that replaces the text between the given indices.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleEditableText
+ methods.
+ */
+ HRESULT replaceText
+ (
+ [in] long startOffset,
+ [in] long endOffset,
+ [in] BSTR *text
+ );
+
+ /** @brief Replaces the attributes of a text range by the given set of attributes.
+
+ Sets the attributes for the text between the two given indices. The old
+ attributes are replaced by the new list of attributes.
+
+ @param [in] startOffset
+ Start index of the text whose attributes are modified.
+ The valid range is 0..length.
+ @param [in] endOffset
+ End index of the text whose attributes are modified.
+ The valid range is 0..length.
+ @param [in] attributes
+ Set of attributes that replaces the old list of attributes of
+ the specified text portion.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleEditableText
+ methods.
+ */
+ HRESULT setAttributes
+ (
+ [in] long startOffset,
+ [in] long endOffset,
+ [in] BSTR *attributes
+ );
+}
+
diff --git a/other-licenses/ia2/AccessibleEventId.idl b/other-licenses/ia2/AccessibleEventId.idl
new file mode 100644
index 0000000000..62a98a97f3
--- /dev/null
+++ b/other-licenses/ia2/AccessibleEventId.idl
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleEventID.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2010 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+/** %IAccessible2 specific event constants
+
+ This enum defines the event IDs fired by %IAccessible2 objects. The event IDs
+ are in addition to those used by MSAA.
+*/
+enum IA2EventID {
+
+ /** The change of the number or attributes of actions of an accessible
+ object is signaled by events of this type.
+ */
+ IA2_EVENT_ACTION_CHANGED = 0x101,
+
+ /** <b>Deprecated.</b> The active descendant of a component has changed.
+
+ Note: This event constant is misspelled and thus is deprecated and will be
+ removed in a later version. Please use the correctly spelled version which
+ follows.
+ */
+ IA2_EVENT_ACTIVE_DECENDENT_CHANGED,
+
+ /** The active descendant of a component has changed. The active descendant
+ is used in objects with transient children.
+
+ Note: Due to the fact that MSAA's WinEvents don't allow the active child index
+ to be passed on the IA2_EVENT_ACTIVE_DESCENDANT_CHANGED event the manages
+ descendants scheme can't be used. Instead the active child object has to fire
+ MSAA's EVENT_OBJECT_FOCUS. In a future release a new event mechanism may be
+ added to provide for event specific data to be passed with the event. At that
+ time the IA2_EVENT_ACTIVE_DECENDENT_CHANGED event and
+ IA2_STATE_MANAGES_DESCENDANTS state would be useful.
+ */
+ IA2_EVENT_ACTIVE_DESCENDANT_CHANGED = IA2_EVENT_ACTIVE_DECENDENT_CHANGED,
+
+ /** The document wide attributes of the document object have changed.
+ */
+ IA2_EVENT_DOCUMENT_ATTRIBUTE_CHANGED,
+
+ /** The contents of the document have changed.
+ */
+ IA2_EVENT_DOCUMENT_CONTENT_CHANGED,
+
+ /** The loading of the document has completed.
+ */
+ IA2_EVENT_DOCUMENT_LOAD_COMPLETE,
+
+ /** The loading of the document was interrupted.
+ */
+ IA2_EVENT_DOCUMENT_LOAD_STOPPED,
+
+ /** The document contents are being reloaded.
+ */
+ IA2_EVENT_DOCUMENT_RELOAD,
+
+ /** The ending index of this link within the containing string has changed.
+ */
+ IA2_EVENT_HYPERLINK_END_INDEX_CHANGED,
+
+ /** The number of anchors associated with this hyperlink object has changed.
+ */
+ IA2_EVENT_HYPERLINK_NUMBER_OF_ANCHORS_CHANGED,
+
+ /** The hyperlink selected state changed from selected to unselected or
+ from unselected to selected.
+ */
+ IA2_EVENT_HYPERLINK_SELECTED_LINK_CHANGED,
+
+ /** One of the links associated with the hypertext object has been activated.
+ */
+ IA2_EVENT_HYPERTEXT_LINK_ACTIVATED,
+
+ /** One of the links associated with the hypertext object has been selected.
+ */
+ IA2_EVENT_HYPERTEXT_LINK_SELECTED,
+
+ /** The starting index of this link within the containing string has changed.
+ */
+ IA2_EVENT_HYPERLINK_START_INDEX_CHANGED,
+
+ /** Focus has changed from one hypertext object to another, or focus moved
+ from a non-hypertext object to a hypertext object, or focus moved from a
+ hypertext object to a non-hypertext object.
+ */
+ IA2_EVENT_HYPERTEXT_CHANGED,
+
+ /** The number of hyperlinks associated with a hypertext object changed
+ */
+ IA2_EVENT_HYPERTEXT_NLINKS_CHANGED,
+
+ /** An object's attributes changed.
+ Also see ::IA2_EVENT_TEXT_ATTRIBUTE_CHANGED.
+ */
+ IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED,
+
+ /** A slide changed in a presentation document or a page boundary was
+ crossed in a word processing document.
+ */
+ IA2_EVENT_PAGE_CHANGED,
+
+ /** The caret moved from one section to the next.
+ */
+ IA2_EVENT_SECTION_CHANGED,
+
+ /** A table caption changed.
+ */
+ IA2_EVENT_TABLE_CAPTION_CHANGED,
+
+ /** A table's column description changed.
+ */
+ IA2_EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED,
+
+ /** A table's column header changed.
+ */
+ IA2_EVENT_TABLE_COLUMN_HEADER_CHANGED,
+
+ /** A table's data changed.
+ */
+ IA2_EVENT_TABLE_MODEL_CHANGED,
+
+ /** A table's row description changed.
+ */
+ IA2_EVENT_TABLE_ROW_DESCRIPTION_CHANGED,
+
+ /** A table's row header changed.
+ */
+ IA2_EVENT_TABLE_ROW_HEADER_CHANGED,
+
+ /** A table's summary changed.
+ */
+ IA2_EVENT_TABLE_SUMMARY_CHANGED,
+
+ /** A text object's attributes changed.
+ Also see ::IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED.
+ */
+ IA2_EVENT_TEXT_ATTRIBUTE_CHANGED,
+
+ /** The caret has moved to a new position.
+ */
+ IA2_EVENT_TEXT_CARET_MOVED,
+
+ /** <b>Deprecated.</b> This event is equivalent to ::IA2_EVENT_TEXT_UPDATED.
+ */
+ IA2_EVENT_TEXT_CHANGED,
+
+ /** The caret moved from one column to the next.
+ */
+ IA2_EVENT_TEXT_COLUMN_CHANGED,
+
+ /** Text was inserted.
+ */
+ IA2_EVENT_TEXT_INSERTED,
+
+ /** Text was removed.
+ */
+ IA2_EVENT_TEXT_REMOVED,
+
+ /** This event indicates general text changes, i.e. changes to text that are
+ exposed through the IAccessibleText interface. For compatibility with ATK/AT-SPI
+ which does not have an equivalent event, servers can alternatively fire
+ ::IA2_EVENT_TEXT_REMOVED and ::IA2_EVENT_TEXT_INSERTED.
+ */
+ IA2_EVENT_TEXT_UPDATED,
+
+ /** The text selection changed. Later versions of Microsoft development environments
+ have an equivalent event identified, EVENT_OBJECT_TEXTSELECTIONCHANGED. Servers
+ should use that if it is available and use IA2_EVENT_TEXT_SELECTION_CHANGED otherwise.
+ Clients should be prepared to respond to either event.
+
+ */
+ IA2_EVENT_TEXT_SELECTION_CHANGED,
+
+ /** A visible data event indicates the change of the visual appearance
+ of an accessible object. This includes for example most of the
+ attributes available via the IAccessibleComponent interface.
+ */
+ IA2_EVENT_VISIBLE_DATA_CHANGED,
+
+ /** The role changed. This should only be used if the interfaces supported by the object
+ did not also change. If the interfaces need to change, the object should be destroyed
+ and a new object created.
+ */
+ IA2_EVENT_ROLE_CHANGED
+};
diff --git a/other-licenses/ia2/AccessibleHyperlink.idl b/other-licenses/ia2/AccessibleHyperlink.idl
new file mode 100644
index 0000000000..76b8acdfe6
--- /dev/null
+++ b/other-licenses/ia2/AccessibleHyperlink.idl
@@ -0,0 +1,187 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleHyperlink.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2010 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "AccessibleAction.idl";
+
+/** @brief This interface represents hyperlinks.
+
+ This interface represents a hyperlink associated with a single substring
+ of text or single non-text object. Non-text objects can have either a
+ single link or a collection of links such as when the non-text object is
+ an image map.
+
+ Linked objects and anchors are implementation dependent. This interface is derived
+ from IAccessibleAction. IAccessibleAction::nActions is one greater than the
+ maximum value for the indices used with the methods of this interface.
+
+ Furthermore, the object that implements this interface has to be connected
+ implicitly or explicitly with an object that implements IAccessibleText.
+ IAccessibleHyperlink::startIndex and IAccessibleHyperlink::endIndex are
+ indices with respect to the text exposed by IAccessibleText.
+
+ This interface provides access to a single object which can have multiple actions.
+ An example is an image map which is an image with multiple links each of which is
+ associated with a separate non-overlapping area of the image. This interface could
+ also be applied to other kinds of objects with multiple actions such as "smart tags"
+ which are objects, typically strings, which have multiple actions such as
+ "Activate URI", "Bookmark URI", etc.
+
+ An interesting use case is an image map where each area is associated with multiple
+ actions, e.g. an image map of smart tags. In this case you would have to implement
+ two levels of accessible hyperlinks. The first level hyperlinks would only implement
+ anchor and anchorTarget. The anchors would all reference the image object. The
+ anchorTargets would reference the second level accessible hyperlink objects. None
+ of the IAccessibleAction methods would be implemented on the first level hyperlink
+ objects. The second level hyperlink objects would implement the IAccessibleAction
+ methods. Their anchors would also reference the image object and their anchorTargets
+ would reference URLs or the objects that would be activated.
+
+ This use case demonstrates that in some cases there is no need for IAccessibleHyperlink
+ to derive from IAccessibleAction. As a result it may be removed in a later version of
+ the IDL and it is suggested that implementations should not rely on the inheritance.
+
+*/
+[object, uuid(01C20F2B-3DD2-400f-949F-AD00BDAB1D41)]
+interface IAccessibleHyperlink : IAccessibleAction
+{
+
+ /** @brief Returns an object that represents the link anchor, as appropriate
+ for the link at the specified index.
+ @param [in] index
+ A 0 based index identifies the anchor when, as in the case of an image map,
+ there is more than one link represented by this object. The valid maximal
+ index is indicated by IAccessibleAction::nActions.
+ @param [out] anchor
+ This is an implementation dependent value. For example, for a text link this
+ method could return the substring of the containing string where the substring
+ is overridden with link behavior, and for an image link this method could return
+ an IUnknown VARIANT for IAccessibleImage. See the section about
+ @ref _variants "VARIANTs" for additional information.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT anchor
+ (
+ [in] long index,
+ [out, retval] VARIANT *anchor
+ );
+
+ /** @brief Returns an object representing the target of the link, as appropriate
+ for the link at the specified index.
+ @param [in] index
+ A 0 based index identifies the anchor when, as in the case of an image map,
+ there is more than one link represented by this object. The valid maximal
+ index is indicated by IAccessibleAction::nActions.
+ @param [out] anchorTarget
+ This is an implementation dependent value. For example this method could
+ return a BSTR VARIANT of the URI. Alternatively this method could return an
+ IUnknown VARIANT of a COM interface representing a target object to be
+ activated when the link is activated. See the section about
+ @ref _variants "VARIANTs" for additional information.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT anchorTarget
+ (
+ [in] long index,
+ [out, retval] VARIANT *anchorTarget
+ );
+
+ /** @brief Returns the 0 based character offset at which the textual representation of the hyperlink starts.
+
+ The returned value is related to the IAccessibleText interface of the object that
+ owns this hyperlink.
+ @param [out] index
+ @retval S_OK
+ */
+ [propget] HRESULT startIndex
+ (
+ [out, retval] long *index
+ );
+
+ /** @brief Returns the 0 based character offset at which the textual representation of the hyperlink ends.
+
+ The returned value is related to the IAccessibleText interface of the object that
+ owns this hyperlink. The character at the index is not part of the hypertext.
+ @param [out] index
+ @retval S_OK
+ */
+ [propget] HRESULT endIndex
+ (
+ [out, retval] long *index
+ );
+
+ /** @brief Returns whether the target object referenced by this link is still valid.
+
+ This is a volatile state that may change without sending an appropriate event.
+ Returns TRUE if the referenced target is still valid and FALSE otherwise.
+
+ This has also been used to indicate whether or not the URI of the anchorTarget
+ is malformed.
+
+ @param [out] valid
+ If false, one or more of the object's links are invalid.
+ If true, all of the object's links are valid.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is FALSE
+ @note This method is not being used, is deprecated, and should not be implemented or
+ used. It is likely that this method will be removed in a later version of the IDL.
+ */
+ [propget] HRESULT valid
+ (
+ [out, retval] boolean *valid
+ );
+}
diff --git a/other-licenses/ia2/AccessibleHypertext.idl b/other-licenses/ia2/AccessibleHypertext.idl
new file mode 100644
index 0000000000..03afe5b021
--- /dev/null
+++ b/other-licenses/ia2/AccessibleHypertext.idl
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleHypertext.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2010 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "AccessibleText.idl";
+import "AccessibleHyperlink.idl";
+
+/** @brief This interface exposes information about hypertext in a document.
+
+ The %IAccessibleHypertext interface is the main interface to expose
+ hyperlinks in a document, typically a text document, that are used
+ to reference other documents. A typical implementation is to implement
+ this interface on the smallest text object such as a paragraph of text.
+*/
+[object, uuid(6B4F8BBF-F1F2-418a-B35E-A195BC4103B9)]
+interface IAccessibleHypertext : IAccessibleText
+{
+
+ /** @brief Returns the number of links and link groups contained within this hypertext
+ paragraph.
+ @param [out] hyperlinkCount
+ The number of links and link groups within this hypertext paragraph.
+ Returns 0 if there is no link.
+ @retval S_OK
+ */
+ [propget] HRESULT nHyperlinks
+ (
+ [out, retval] long *hyperlinkCount
+ );
+
+ /** @brief Returns the specified link.
+
+ The returned IAccessibleHyperlink object encapsulates the hyperlink and
+ provides several kinds of information describing it.
+ @param [in] index
+ This 0 based index specifies the hyperlink to return.
+ @param [out] hyperlink
+ If the given index is valid, i.e. lies in the interval from 0 to the number
+ of links minus one, a reference to the specified hyperlink object is returned.
+ If the index is invalid then a NULL pointer is returned.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT hyperlink
+ (
+ [in] long index,
+ [out, retval] IAccessibleHyperlink **hyperlink
+ );
+
+ /** @brief Returns the index of the hyperlink that is associated with this character index.
+
+ This is the case when a link spans the given character index.
+ @param [in] charIndex
+ A 0 based index of the character for which to return the link index. If
+ IAccessibleText is used to represent the text containing the link, then the
+ character index is only valid if it is greater than or equal to zero and
+ lower than the number of characters in the text.
+ @param [out] hyperlinkIndex
+ Returns the 0 based index of the hyperlink that is associated with this
+ character index, or -1 if charIndex is not on a link.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is -1
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT hyperlinkIndex
+ (
+ [in] long charIndex,
+ [out, retval] long *hyperlinkIndex
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleHypertext2.idl b/other-licenses/ia2/AccessibleHypertext2.idl
new file mode 100644
index 0000000000..2eba16b986
--- /dev/null
+++ b/other-licenses/ia2/AccessibleHypertext2.idl
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleHypertext2.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2013 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "AccessibleHypertext.idl";
+import "AccessibleHyperlink.idl";
+
+/** @brief This interface exposes information about hypertext in a document.
+
+ The %IAccessibleHypertext2 interface extends the functinality of the
+ %IAccessibleHypertext inteface.
+*/
+[object, uuid(CF64D89F-8287-4B44-8501-A827453A6077)]
+interface IAccessibleHypertext2 : IAccessibleHypertext
+{
+
+ /** @brief Returns the links for this object.
+
+ The returned IAccessibleHyperlink objects encapsulate the hyperlink and
+ provides several kinds of information describing it.
+
+ @param [out] hyperlinks
+ This array is allocated by the server. The client must free it with CoTaskMemFree.
+ @param [out] nHyperlinks
+ The number of links returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are no links, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT hyperlinks
+ (
+ [out, size_is(,*nHyperlinks)] IAccessibleHyperlink ***hyperlinks,
+ [out, retval] long *nHyperlinks
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleImage.idl b/other-licenses/ia2/AccessibleImage.idl
new file mode 100644
index 0000000000..21fe0985e5
--- /dev/null
+++ b/other-licenses/ia2/AccessibleImage.idl
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleImage.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2010 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "IA2CommonTypes.idl";
+
+/** @brief This interface represents images and icons.
+
+ This interface is used for a representation of images like icons on buttons.
+ %IAccessibleImage only needs to be implemented in certain situations. Some
+ examples are:
+ <ol>
+ <li>The accessible name and description are not enough to fully
+ describe the image, e.g. when the accessible description is used to define the
+ behavior of an actionable image and the image itself conveys semantically
+ significant information.
+ <li>The user can edit the content that includes an
+ image and therefore the user needs to be able to review the image's position.
+ </ol>
+*/
+[object, uuid(FE5ABB3D-615E-4f7b-909F-5F0EDA9E8DDE)]
+interface IAccessibleImage : IUnknown
+{
+ /** @brief Returns the localized description of the image.
+ @param [out] description
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT description
+ (
+ [out, retval] BSTR *description
+ );
+
+ /** @brief Returns the coordinates of the image.
+ @param [in] coordinateType
+ Specifies whether the returned coordinates should be relative to the screen or the parent object.
+ @param [out] x
+ @param [out] y
+ @retval S_OK
+ */
+ [propget] HRESULT imagePosition
+ (
+ [in] enum IA2CoordinateType coordinateType,
+ [out] long *x,
+ [out, retval] long *y
+ );
+
+ /** @brief Returns the size of the image in units specified by parent's coordinate system.
+ @param [out] height
+ @param [out] width
+ @retval S_OK
+ */
+
+ [propget] HRESULT imageSize
+ (
+ [out] long *height,
+ [out, retval] long *width
+ );
+}
diff --git a/other-licenses/ia2/AccessibleRelation.idl b/other-licenses/ia2/AccessibleRelation.idl
new file mode 100644
index 0000000000..ddb6e7c505
--- /dev/null
+++ b/other-licenses/ia2/AccessibleRelation.idl
@@ -0,0 +1,245 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleRelation.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2013 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+
+/** @defgroup grpRelations Relations
+ Use the following constants to compare against the BSTRs returned by
+ IAccessibleRelation::relationType.
+*/
+///@{
+
+/** The target object is the containing application object. */
+const WCHAR *const IA2_RELATION_CONTAINING_APPLICATION = L"containingApplication";
+
+/** The target object is the containing document object. The target object implements
+ the IAccessibleDocument interface.
+*/
+const WCHAR *const IA2_RELATION_CONTAINING_DOCUMENT = L"containingDocument";
+
+/** The target object is the containing tab pane object. */
+const WCHAR *const IA2_RELATION_CONTAINING_TAB_PANE = L"containingTabPane";
+
+/** The target object is the containing window object. */
+const WCHAR *const IA2_RELATION_CONTAINING_WINDOW = L"containingWindow";
+
+/** Some attribute of this object is affected by a target object. */
+const WCHAR *const IA2_RELATION_CONTROLLED_BY = L"controlledBy";
+
+/** This object is interactive and controls some attribute of a target object. */
+const WCHAR *const IA2_RELATION_CONTROLLER_FOR = L"controllerFor";
+
+/** This object is described by the target object. */
+const WCHAR *const IA2_RELATION_DESCRIBED_BY = L"describedBy";
+
+/** This object is describes the target object. */
+const WCHAR *const IA2_RELATION_DESCRIPTION_FOR = L"descriptionFor";
+
+/** This object is embedded by a target object. */
+const WCHAR *const IA2_RELATION_EMBEDDED_BY = L"embeddedBy";
+
+/** This object embeds a target object. This relation can be used on the
+ OBJID_CLIENT accessible for a top level window to show where the content
+ areas are.
+*/
+const WCHAR *const IA2_RELATION_EMBEDS = L"embeds";
+
+/** Content flows to this object from a target object.
+ This relation and IA2_RELATION_FLOWS_TO are useful to tie text and non-text
+ objects together in order to allow assistive technology to follow the
+ intended reading order.
+*/
+const WCHAR *const IA2_RELATION_FLOWS_FROM = L"flowsFrom";
+
+/** Content flows from this object to a target object. */
+const WCHAR *const IA2_RELATION_FLOWS_TO = L"flowsTo";
+
+/** This object is label for a target object. */
+const WCHAR *const IA2_RELATION_LABEL_FOR = L"labelFor";
+
+/** This object is labelled by a target object. Note that the double L spelling
+ which follows is preferred. Please use it instead. This single L version may
+ be removed in a later version.
+*/
+const WCHAR *const IA2_RELATION_LABELED_BY = L"labelledBy";
+
+/** This object is labelled by a target object. */
+const WCHAR *const IA2_RELATION_LABELLED_BY = L"labelledBy";
+
+/** This object is a member of a group of one or more objects. When
+ there is more than one object in the group each member may have one and the
+ same target, e.g. a grouping object. It is also possible that each member has
+ multiple additional targets, e.g. one for every other member in the group.
+*/
+const WCHAR *const IA2_RELATION_MEMBER_OF = L"memberOf";
+
+/** The target object is the next object in the tab order. */
+const WCHAR *const IA2_RELATION_NEXT_TABBABLE = L"nextTabbable";
+
+/** This object is a logical child of a target object. This relation is the reciprocal
+ of the IA2_RELATION_NODE_PARENT_OF relation. In some cases an application's accessible
+ tree is such that objects can be in a logical parent-child relationship which is
+ different from the hierarchy of the accessible tree. */
+const WCHAR *const IA2_RELATION_NODE_CHILD_OF = L"nodeChildOf";
+
+/** This object is a logical parent of a target object. This relation is the reciprocal
+ of the IA2_RELATION_NODE_CHILD_OF relation. In some cases an application's accessible
+ tree is such that objects can be in a logical parent-child relationship which is
+ different from the hierarchy of the accessible tree. */
+const WCHAR *const IA2_RELATION_NODE_PARENT_OF = L"nodeParentOf";
+
+/** This object is a parent window of the target object. */
+const WCHAR *const IA2_RELATION_PARENT_WINDOW_OF = L"parentWindowOf";
+
+/** This object is a transient component related to the target object.
+ When this object is activated the target object doesn't lose focus.
+*/
+const WCHAR *const IA2_RELATION_POPUP_FOR = L"popupFor";
+
+/** The target object is the previous object in the tab order. */
+const WCHAR *const IA2_RELATION_PREVIOUS_TABBABLE = L"previousTabbable";
+
+/** This object is a sub window of a target object. */
+const WCHAR *const IA2_RELATION_SUBWINDOW_OF = L"subwindowOf";
+
+/** The target object provides the detailed, extended description for this
+ object. It provides more detailed information than would normally be provided
+ using the IA2_RELATION_DESCRIBED_BY relation. A common use for this relation is
+ in digital publishing where an extended description needs to be conveyed in
+ a book that requires structural markup or the embedding of other technology to
+ provide illustrative content. */
+const WCHAR *const IA2_RELATION_DETAILS = L"details";
+
+/** This object provides the detailed, extended description for the target
+ object. See IA2_RELATION_DETAILS. */
+const WCHAR *const IA2_RELATION_DETAILS_FOR = L"detailsFor";
+
+/** The target object is the error message for this object. */
+const WCHAR *const IA2_RELATION_ERROR = L"error";
+
+/** This object is the error message for the target object. */
+const WCHAR *const IA2_RELATION_ERROR_FOR = L"errorFor";
+
+///@}
+
+/** This interface gives access to an object's set of relations.
+*/
+[object, uuid(7CDF86EE-C3DA-496a-BDA4-281B336E1FDC)]
+interface IAccessibleRelation : IUnknown
+{
+ /** @brief Returns the type of the relation.
+ @param [out] relationType
+ The strings returned are defined @ref grpRelations "in this section of the documentation".
+ @retval S_OK
+ */
+ [propget] HRESULT relationType
+ (
+ [out, retval] BSTR *relationType
+ );
+
+ /** @brief Returns a localized version of the relation type.
+ @param [out] localizedRelationType
+ @retval S_OK
+ */
+ [propget] HRESULT localizedRelationType
+ (
+ [out, retval] BSTR *localizedRelationType
+ );
+
+ /** @brief Returns the number of targets for this relation.
+ @param [out] nTargets
+ @retval S_OK
+ */
+ [propget] HRESULT nTargets
+ (
+ [out, retval] long *nTargets
+ );
+
+ /** @brief Returns one accessible relation target.
+ @param [in] targetIndex
+ 0 based index
+ @param [out] target
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note Use QueryInterface to get IAccessible2.
+ */
+ [propget] HRESULT target
+ (
+ [in] long targetIndex,
+ [out, retval] IUnknown **target
+ );
+
+ /** @brief Returns multiple accessible relation targets
+ @param [in] maxTargets
+ maximum size of the array allocated by the client
+ @param [out] targets
+ The array of target objects. Note that this array is to be allocated by the
+ client and freed when no longer needed. Refer to @ref _arrayConsideration
+ "Special Consideration when using Arrays" for more details. You will need to use
+ QueryInterface on the IUnknown to get the IAccessible2.
+ @param [out] nTargets
+ actual number of targets in the returned array (not more than maxTargets)
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, e.g. a negative value
+ */
+ [propget] HRESULT targets
+ (
+ [in] long maxTargets,
+ [out, size_is(maxTargets), length_is(*nTargets)]
+ IUnknown **targets,
+ [out, retval] long *nTargets
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleRole.idl b/other-licenses/ia2/AccessibleRole.idl
new file mode 100644
index 0000000000..c23f1ec70e
--- /dev/null
+++ b/other-licenses/ia2/AccessibleRole.idl
@@ -0,0 +1,348 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleRole.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007-2018 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+
+/** Collection of roles
+
+ This enumerator defines an extended set of accessible roles of objects implementing
+ the %IAccessible2 interface. These roles are in addition to the MSAA roles obtained
+ through the MSAA get_accRole method. Examples are 'footnote', 'heading', and
+ 'label'. You obtain an object's %IAccessible2 roles by calling IAccessible2::role.
+*/
+enum IA2Role {
+
+ /** Unknown role. The object contains some Accessible information, but its
+ role is not known.
+ */
+ IA2_ROLE_UNKNOWN = 0,
+
+ /** An object that can be drawn into and to manage events from the objects
+ drawn into it. Also refer to ::IA2_ROLE_FRAME,
+ ::IA2_ROLE_GLASS_PANE, and ::IA2_ROLE_LAYERED_PANE.
+ */
+ IA2_ROLE_CANVAS = 0x401,
+
+ /// A caption describing another object.
+ IA2_ROLE_CAPTION,
+
+ /// Used for check buttons that are menu items.
+ IA2_ROLE_CHECK_MENU_ITEM,
+
+ /// A specialized dialog that lets the user choose a color.
+ IA2_ROLE_COLOR_CHOOSER,
+
+ /// A date editor.
+ IA2_ROLE_DATE_EDITOR,
+
+ /** An iconified internal frame in an ::IA2_ROLE_DESKTOP_PANE.
+ Also refer to ::IA2_ROLE_INTERNAL_FRAME.
+ */
+ IA2_ROLE_DESKTOP_ICON,
+
+ /** A desktop pane. A pane that supports internal frames and iconified
+ versions of those internal frames. Also refer to ::IA2_ROLE_INTERNAL_FRAME.
+ */
+ IA2_ROLE_DESKTOP_PANE,
+
+ /** A directory pane. A pane that allows the user to navigate through
+ and select the contents of a directory. May be used by a file chooser.
+ Also refer to ::IA2_ROLE_FILE_CHOOSER.
+ */
+ IA2_ROLE_DIRECTORY_PANE,
+
+ /** An editable text object in a toolbar. <b>Deprecated.</b>
+ The edit bar role was meant for a text area in a tool bar. However, to detect
+ a text area in a tool bar the AT can query the parent.
+ */
+ IA2_ROLE_EDITBAR,
+
+ /// Embedded (OLE) object.
+ IA2_ROLE_EMBEDDED_OBJECT,
+
+ /// Text that is used as an endnote (footnote at the end of a chapter or section).
+ IA2_ROLE_ENDNOTE,
+
+ /** A file chooser. A specialized dialog that displays the files in the
+ directory and lets the user select a file, browse a different directory,
+ or specify a filename. May use the directory pane to show the contents of
+ a directory.
+ Also refer to ::IA2_ROLE_DIRECTORY_PANE.
+ */
+ IA2_ROLE_FILE_CHOOSER,
+
+ /** A font chooser. A font chooser is a component that lets the user pick
+ various attributes for fonts.
+ */
+ IA2_ROLE_FONT_CHOOSER,
+
+ /** Footer of a document page.
+ Also refer to ::IA2_ROLE_HEADER.
+ */
+ IA2_ROLE_FOOTER,
+
+ /// Text that is used as a footnote. Also refer to ::IA2_ROLE_ENDNOTE.
+ IA2_ROLE_FOOTNOTE,
+
+ /** A container of form controls. An example of the use of this role is to
+ represent an HTML FORM tag.
+ */
+ IA2_ROLE_FORM,
+
+ /** Frame role. A top level window with a title bar, border, menu bar, etc.
+ It is often used as the primary window for an application. Also refer to
+ ::IA2_ROLE_CANVAS and the MSAA roles of dialog and window.
+ */
+ IA2_ROLE_FRAME,
+
+ /** A glass pane. A pane that is guaranteed to be painted on top of all panes
+ beneath it. Also refer to ::IA2_ROLE_CANVAS, ::IA2_ROLE_INTERNAL_FRAME, and
+ ::IA2_ROLE_ROOT_PANE.
+ */
+ IA2_ROLE_GLASS_PANE,
+
+ /** Header of a document page.
+ Also refer to ::IA2_ROLE_FOOTER.
+ */
+ IA2_ROLE_HEADER,
+
+ /// Heading. Use the IAccessible2::attributes level attribute to determine the heading level.
+ IA2_ROLE_HEADING,
+
+ /// A small fixed size picture, typically used to decorate components.
+ IA2_ROLE_ICON,
+
+ /** An image map object. Usually a graphic with multiple hotspots, where
+ each hotspot can be activated resulting in the loading of another document
+ or section of a document.
+ */
+ IA2_ROLE_IMAGE_MAP,
+
+ /** An object which is used to allow input of characters not found on a keyboard,
+ such as the input of Chinese characters on a Western keyboard.
+ */
+ IA2_ROLE_INPUT_METHOD_WINDOW,
+
+ /** An internal frame. A frame-like object that is clipped by a desktop pane.
+ The desktop pane, internal frame, and desktop icon objects are often used to
+ create multiple document interfaces within an application.
+ Also refer to ::IA2_ROLE_DESKTOP_ICON, ::IA2_ROLE_DESKTOP_PANE, and ::IA2_ROLE_FRAME.
+ */
+ IA2_ROLE_INTERNAL_FRAME,
+
+ /// An object used to present an icon or short string in an interface.
+ IA2_ROLE_LABEL,
+
+ /** A layered pane. A specialized pane that allows its children to be drawn
+ in layers, providing a form of stacking order. This is usually the pane that
+ holds the menu bar as well as the pane that contains most of the visual
+ components in a window.
+ Also refer to ::IA2_ROLE_CANVAS, ::IA2_ROLE_GLASS_PANE, and ::IA2_ROLE_ROOT_PANE.
+ */
+ IA2_ROLE_LAYERED_PANE,
+
+ /** A section whose content is parenthetic or ancillary to the main content
+ of the resource.
+ */
+ IA2_ROLE_NOTE,
+
+ /** A specialized pane whose primary use is inside a dialog.
+ Also refer to MSAA's dialog role.
+ */
+ IA2_ROLE_OPTION_PANE,
+
+ /** An object representing a page of document content. It is used in documents
+ which are accessed by the user on a page by page basis.
+ */
+ IA2_ROLE_PAGE,
+
+ /// A paragraph of text.
+ IA2_ROLE_PARAGRAPH,
+
+ /** A radio button that is a menu item.
+ Also refer to MSAA's button and menu item roles.
+ */
+ IA2_ROLE_RADIO_MENU_ITEM,
+
+ /** An object which is redundant with another object in the accessible hierarchy.
+ ATs typically ignore objects with this role.
+ */
+ IA2_ROLE_REDUNDANT_OBJECT,
+
+ /** A root pane. A specialized pane that has a glass pane and a layered pane
+ as its children.
+ Also refer to ::IA2_ROLE_GLASS_PANE and ::IA2_ROLE_LAYERED_PANE
+ */
+ IA2_ROLE_ROOT_PANE,
+
+ /** A ruler such as those used in word processors.
+ */
+ IA2_ROLE_RULER,
+
+ /** A scroll pane. An object that allows a user to incrementally view a large
+ amount of information. Its children can include scroll bars and a viewport.
+ Also refer to ::IA2_ROLE_VIEW_PORT and MSAA's scroll bar role.
+ */
+ IA2_ROLE_SCROLL_PANE,
+
+ /** A container of document content. An example of the use of this role is to
+ represent an HTML DIV tag. A section may be used as a region. A region is a
+ group of elements that together form a perceivable unit. A region does not
+ necessarily follow the logical structure of the content, but follows the
+ perceivable structure of the page. A region may have an attribute in the set
+ of IAccessible2::attributes which indicates that it is "live". A live region
+ is content that is likely to change in response to a timed change, a user
+ event, or some other programmed logic or event.
+ */
+ IA2_ROLE_SECTION,
+
+ /// Object with graphical representation used to represent content on draw pages.
+ IA2_ROLE_SHAPE,
+
+ /** A split pane. A specialized panel that presents two other panels at the
+ same time. Between the two panels is a divider the user can manipulate to make
+ one panel larger and the other panel smaller.
+ */
+ IA2_ROLE_SPLIT_PANE,
+
+ /** An object that forms part of a menu system but which can be "undocked"
+ from or "torn off" the menu system to exist as a separate window.
+ */
+ IA2_ROLE_TEAR_OFF_MENU,
+
+ /// An object used as a terminal emulator.
+ IA2_ROLE_TERMINAL,
+
+ /// Collection of objects that constitute a logical text entity.
+ IA2_ROLE_TEXT_FRAME,
+
+ /** A toggle button. A specialized push button that can be checked or unchecked,
+ but does not provide a separate indicator for the current state.
+ Also refer to MSAA's roles of push button, check box, and radio button.
+ <BR><B>Note:</B> IA2_ROLE_TOGGLE_BUTTON should not be used. Instead, use MSAA's
+ ROLE_SYSTEM_PUSHBUTTON and STATE_SYSTEM_PRESSED.
+ */
+ IA2_ROLE_TOGGLE_BUTTON,
+
+ /** A viewport. An object usually used in a scroll pane. It represents the
+ portion of the entire data that the user can see. As the user manipulates
+ the scroll bars, the contents of the viewport can change.
+ Also refer to ::IA2_ROLE_SCROLL_PANE.
+ */
+ IA2_ROLE_VIEW_PORT,
+
+ /** An object containing content which is complementary to the main content of
+ a document, but remains meaningful when separated from the main content. There
+ are various types of content that would appropriately have this role. For example,
+ in the case where content is delivered via a web portal to a web browser, this may
+ include but not be limited to show times, current weather, related articles, or
+ stocks to watch. The complementary role indicates that contained content is relevant
+ to the main content. If the complementary content is completely separable main
+ content, it may be appropriate to use a more general role.
+ */
+ IA2_ROLE_COMPLEMENTARY_CONTENT,
+
+ /** An object representing a navigational landmark, a region on a page to
+ which the user may want quick access, such as a navigation area, a search
+ facility or the main content of a page.
+ */
+ IA2_ROLE_LANDMARK,
+
+ /**
+ * A bar that serves as a level indicator to, for instance, show
+ * the strength of a password or the charge of a battery.
+ */
+ IA2_ROLE_LEVEL_BAR,
+
+ /** Content previously deleted or proposed for deletion, e.g. in revision
+ history or a content view providing suggestions from reviewers.
+ */
+ IA2_ROLE_CONTENT_DELETION,
+
+ /** Content previously inserted or proposed for insertion, e.g. in revision
+ history or a content view providing suggestions from reviewers.
+ */
+ IA2_ROLE_CONTENT_INSERTION,
+
+ /// A section of content that is quoted from another source.
+ IA2_ROLE_BLOCK_QUOTE,
+
+ /** A run of content that is marked or highlighted, such as for reference
+ purposes, or to call it out as having a special purpose that is clear from
+ context. If the mark is used in conjuction with a related content section
+ in the document, then IA2_RELATION_DETAILS should be used to link the
+ related content (and the reverse relation IA2_RELATION_DETAILS_FOR should
+ link back to the IA2_ROLE_MARK object). If the mark has related information
+ in a tooltip, or as hidden text, then accDescription should be used to
+ provide this information.
+ */
+ IA2_ROLE_MARK,
+
+ /** A grouping for content that is called out as a proposed change from the
+ current version of the document, such as by a reviewer of the content.
+ Should include as children one or both of:
+ IA2_ROLE_CONTENT_DELETION and IA2_ROLE_CONTENT_INSERTION, in any order,
+ to indicate what the actual change is.
+ If the suggestion is accepted, the implementation should change the role to
+ a generic one such as IA2_ROLE_SECTION or IA2_ROLE_TEXT_FRAME.
+ */
+ IA2_ROLE_SUGGESTION,
+
+ /** A single comment, typically user-generated content. Supports reply
+ hierarchies via descendant structure, e.g. a child comment is a reply
+ to the parent comment. Supports groupPosition() method to determine
+ reply level (top comment is 1), as well as set size and position in set
+ within that level.
+ */
+ IA2_ROLE_COMMENT
+};
diff --git a/other-licenses/ia2/AccessibleStates.idl b/other-licenses/ia2/AccessibleStates.idl
new file mode 100644
index 0000000000..bb0eba5c73
--- /dev/null
+++ b/other-licenses/ia2/AccessibleStates.idl
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleStates.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2010 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+
+typedef long AccessibleStates;
+
+/** %IAccessible2 specific state bit constants
+
+ This enum defines the state bits returned by IAccessible2::states. The
+ %IAccessible2 state bits are in addition to those returned by MSAA.
+*/
+enum IA2States {
+
+/** Indicates a window is currently the active window, or is an active subelement
+ within a container or table.
+
+ This state can be used to indicate the current active item in a container, even
+ if the container itself is not currently active. In other words this would indicate
+ the item that will get focus if you tab to the container.
+
+ This information is important for knowing what to report for trees and potentially
+ other containers in a virtual buffer.
+
+ Also, see ::IA2_STATE_MANAGES_DESCENDANTS for more information.
+*/
+IA2_STATE_ACTIVE = 0x1,
+
+/** Indicates that the object is armed.
+
+ Used to indicate that the control is "pressed" and will be invoked when the
+ actuator, e.g. a mouse button, is "released". An AT which either monitors the
+ mouse or synthesizes mouse events might need to know that, and possibly a talking
+ interface would even let the user know about it. It could also potentially be
+ useful to on screen keyboards or test tools since the information does indicate
+ something about the state of the interface, for example, code operating asynchronously
+ might need to wait for the armed state to change before doing something else.
+
+*/
+IA2_STATE_ARMED = 0x2,
+
+/** Indicates the user interface object corresponding to this object no longer exists. */
+IA2_STATE_DEFUNCT = 0x4,
+
+/** An object with this state has a caret and implements the IAccessibleText interface.
+
+ Such fields may be read-only, so STATE_SYSTEM_READONLY is valid in combination
+ with IA2_STATE_EDITABLE.
+
+*/
+IA2_STATE_EDITABLE = 0x8,
+
+/** Indicates the orientation of this object is horizontal. */
+IA2_STATE_HORIZONTAL = 0x10,
+
+/** Indicates this object is minimized and is represented only by an icon. */
+IA2_STATE_ICONIFIED = 0x20,
+
+/** Indicates an input validation failure. */
+IA2_STATE_INVALID_ENTRY = 0x40,
+
+/** Indicates that this object manages its children.
+
+ Note: Due to the fact that MSAA's WinEvents don't allow the active child index
+ to be passed on the IA2_EVENT_ACTIVE_DESCENDANT_CHANGED event, the manages
+ descendants scheme can't be used. Instead the active child object has to fire
+ MSAA's EVENT_OBJECT_FOCUS. In a future release a new event mechanism may be
+ added to provide for event specific data to be passed with the event. At that
+ time the IA2_EVENT_ACTIVE_DECENDENT_CHANGED event and
+ IA2_STATE_MANAGES_DESCENDANTS state would be useful.
+*/
+IA2_STATE_MANAGES_DESCENDANTS = 0x80,
+
+/** Indicates that an object is modal.
+
+ Modal objects have the behavior that something must be done with the object
+ before the user can interact with an object in a different window.
+*/
+IA2_STATE_MODAL = 0x100,
+
+/** Indicates this text object can contain multiple lines of text. */
+IA2_STATE_MULTI_LINE = 0x200,
+
+/** Indicates this object paints every pixel within its rectangular region. */
+IA2_STATE_OPAQUE = 0x400,
+
+/** Indicates that user interaction is required.
+
+ An example of when this state is used is when a field in a form must be filled
+ before a form can be processed.
+*/
+IA2_STATE_REQUIRED = 0x800,
+
+/** Indicates an object which supports text selection.
+
+ Note: This is different than MSAA STATE_SYSTEM_SELECTABLE.
+*/
+IA2_STATE_SELECTABLE_TEXT = 0x1000,
+
+/** Indicates that this text object can contain only a single line of text. */
+IA2_STATE_SINGLE_LINE = 0x2000,
+
+/** Indicates that the accessible object is stale.
+
+ This state is used when the accessible object no longer accurately
+ represents the state of the object which it is representing such as when an
+ object is transient or when an object has been or is in the process of being
+ destroyed or when the object's index in its parent has changed.
+*/
+IA2_STATE_STALE = 0x4000,
+
+/** Indicates that the object implements autocompletion.
+
+ This state indicates that a text control will respond to the input of
+ one ore more characters and cause a sub-item to become selected. The
+ selection may also result in events fired on the parent object.
+*/
+IA2_STATE_SUPPORTS_AUTOCOMPLETION = 0x8000,
+
+/** Indicates this object is transient.
+
+ An object has this state when its parent object has the state ::IA2_STATE_MANAGES_DESCENDANTS.
+ For example, a list item object may be managed by its parent list object and may only
+ exist as long as the object is actually rendered. Similarly a table cell's accessible
+ object may exist only while the cell has focus. However, from the perspective of an
+ assistive technology a transient object behaves like a non-transient object. As a
+ result it is likely that this state is not of use to an assistive technology, but it
+ is provided in case an assistive technology determines that knowledge of the transient
+ nature of the object is useful and also for harmony with the Linux accessibility API.
+
+ Also, see ::IA2_STATE_MANAGES_DESCENDANTS for more information.
+ */
+IA2_STATE_TRANSIENT = 0x10000,
+
+/** Indicates the orientation of this object is vertical. */
+IA2_STATE_VERTICAL = 0x20000,
+
+/** Indicates this object is checkable.
+
+ The standard checkable objects are check boxes, radio buttons, check box menu
+ items, radio menu items, and toggle buttons. Since assistive technology will
+ determine that these objects are checkable via the object's role the checkable
+ state is not required. However, this state is necessary in those cases where
+ an object has a role which is not one of the previously mentioned roles. An
+ example is a table cell which indicates whether or not an email has an attachment,
+ whether or not an mail is considered spam, and whether or not an email has been read.
+ */
+IA2_STATE_CHECKABLE = 0x40000,
+
+/** Indicates this object is pinned.
+
+ This state indicates that an object is fixed at a certain location. One example
+ is a browser tab that when pinned cannot be moved until unpinned. Another example
+ is a movable or floating object that when pinned remains in its pinned location
+ until being unpinned.
+ */
+IA2_STATE_PINNED = 0x80000
+
+};
diff --git a/other-licenses/ia2/AccessibleTable.idl b/other-licenses/ia2/AccessibleTable.idl
new file mode 100644
index 0000000000..24df659e1a
--- /dev/null
+++ b/other-licenses/ia2/AccessibleTable.idl
@@ -0,0 +1,551 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleTable.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2013 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "Accessible2.idl";
+import "IA2CommonTypes.idl";
+
+/** @brief This interface gives access to a two-dimensional table.
+
+ Typically all accessible objects that represent cells or cell-clusters of a table
+ will be at the same time children of the table. In this case IAccessible2::indexInParent
+ will return the child index which then can be used when calling IAccessibleTable::rowIndex
+ and IAccessibleTable::columnIndex.
+
+ However, in some cases that kind of implementation will not be possible. When
+ the table cells are not direct children of a table, the object representing
+ the cell can define a "table-cell-index" object attribute identifying the 0
+ based table cell index. This object attribute is obtained by parsing the
+ attribute string returned by IAccessible2::attributes. The "table-cell-index"
+ attribute can be used just like a child index of the typical case. ATs should
+ first test for the presence of the "table-cell-index" attribute and if it is not
+ present then IAccessible2::indexInParent can be used as in the typical case
+ where cells are direct children of the table.
+
+ The range of valid coordinates for this interface are implementation dependent.
+ However, that range includes at least the intervals from the from the first row
+ or column with the index 0 up to the last (but not including) used row or column
+ as returned by IAccessibleTable::nRows and IAccessibleTable::nColumns.
+
+ Note that newer implementations are now using IAccessibleTable2 and IAccessibleTableCell
+ rather than this interface.
+*/
+[object, uuid(35AD8070-C20C-4fb4-B094-F4F7275DD469)]
+interface IAccessibleTable : IUnknown
+{
+
+ /** @brief Returns the accessible object at the specified row and column in
+ the table. This object could be an IAccessible or an IAccessible2.
+ @param [in] row
+ The 0 based row index for which to retrieve the cell.
+ @param [in] column
+ The 0 based column index for which to retrieve the cell.
+ @param [out] accessible
+ If both row and column index are valid then the corresponding accessible
+ object is returned that represents the requested cell regardless of whether
+ the cell is currently visible (on the screen).
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] value is NULL
+ */
+ [propget] HRESULT accessibleAt
+ (
+ [in] long row,
+ [in] long column,
+ [out, retval] IUnknown **accessible
+ );
+
+ /** @brief Returns the caption for the table. The returned object could be
+ an IAccessible or an IAccessible2.
+ @param [out] accessible
+ If the table has a caption then a reference to it is returned, else a NULL
+ pointer is returned.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT caption
+ (
+ [out, retval] IUnknown **accessible
+ );
+
+ /** @brief Translates the given row and column indexes into the corresponding cell index.
+ @param [in] rowIndex
+ 0 based row index for the cell.
+ @param [in] columnIndex
+ 0 based column index for the cell.
+ @param [out] cellIndex
+ Returns the 0 based index of the cell at the specified row and column indexes.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] value is 0
+ @note The returned value is not necessarily a child index of the immediate parent.
+ In cases where the table cells are not direct children of the table the index
+ is actually the cell index, i.e. conceptually it's an index into a one dimensional
+ array of cells laid out in row order.
+ */
+ [propget] HRESULT childIndex
+ (
+ [in] long rowIndex,
+ [in] long columnIndex,
+ [out, retval] long *cellIndex
+ );
+
+ /** @brief Returns the description text of the specified column in the table.
+ @param [in] column
+ The 0 based index of the column for which to retrieve the description.
+ @param [out] description
+ Returns the description text of the specified column in the table if such a
+ description exists. Otherwise a NULL pointer is returned.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ @retval E_INVALIDARG if bad [in] passed, [out] value is NULL
+ */
+ [propget] HRESULT columnDescription
+ (
+ [in] long column,
+ [out, retval] BSTR *description
+ );
+
+ /** @brief Returns the number of columns occupied by the accessible object
+ at the specified row and column in the table.
+
+ The result is greater than 1 if the specified cell spans multiple columns.
+ @param [in] row
+ 0 based row index of the accessible for which to return the column extent.
+ @param [in] column
+ 0 based column index of the accessible for which to return the column extent.
+ @param [out] nColumnsSpanned
+ Returns the 1 based column extent of the specified cell.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] value is 0
+ */
+ [propget] HRESULT columnExtentAt
+ (
+ [in] long row,
+ [in] long column,
+ [out, retval] long *nColumnsSpanned
+ );
+
+ /** @brief Returns the column headers as an %IAccessibleTable object.
+
+ Content and size of the returned table are implementation dependent.
+ @param [out] accessibleTable
+ The column header
+ @param [out] startingRowIndex
+ The 0 based row index where the header starts, usually 0.
+ @retval S_OK
+ @retval S_FALSE if there is no header, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT columnHeader
+ (
+ [out] IAccessibleTable **accessibleTable,
+ [out, retval] long *startingRowIndex
+ );
+
+ /** @brief Translates the given cell index into the corresponding column index.
+ @param [in] cellIndex
+ 0 based index of the cell in the parent or closest ancestor table. Typically this
+ is the value returned from IAccessible2::indexInParent, but in the case where the
+ table cells are not direct children of the table this is the cell index specified
+ by the "table-cell-index" object attribute obtained from parsing the attributes
+ string returned by calling IAccessible2::attributes on the cell object.
+ @param [out] columnIndex
+ Returns the 0 based column index of the cell of the specified child or the index of
+ the first column if the child spans multiple columns.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] value is 0
+ */
+ [propget] HRESULT columnIndex
+ (
+ [in] long cellIndex,
+ [out, retval] long *columnIndex
+ );
+
+ /** @brief Returns the total number of columns in table
+ @param [out] columnCount
+ Number of columns in table (including columns outside the current viewport)
+ @retval S_OK
+ */
+ [propget] HRESULT nColumns
+ (
+ [out, retval] long *columnCount
+ );
+
+ /** @brief Returns the total number of rows in table
+ @param [out] rowCount
+ Number of rows in table (including rows outside the current viewport)
+ @retval S_OK
+ */
+ [propget] HRESULT nRows
+ (
+ [out, retval] long *rowCount
+ );
+
+ /** @brief Returns the total number of selected cells
+ @param [out] cellCount
+ Number of cells currently selected
+ @retval S_OK
+ */
+ [propget] HRESULT nSelectedChildren
+ (
+ [out, retval] long *cellCount
+ );
+
+ /** @brief Returns the total number of selected columns
+ @param [out] columnCount
+ Number of columns currently selected
+ @retval S_OK
+ */
+ [propget] HRESULT nSelectedColumns
+ (
+ [out, retval] long *columnCount
+ );
+
+ /** @brief Returns the total number of selected rows
+ @param [out] rowCount
+ Number of rows currently selected
+ @retval S_OK
+ */
+ [propget] HRESULT nSelectedRows
+ (
+ [out, retval] long *rowCount
+ );
+
+ /** @brief Returns the description text of the specified row in the table.
+ @param [in] row
+ The 0 based index of the row for which to retrieve the description.
+ @param [out] description
+ Returns the description text of the specified row in the table if such a
+ description exists. Otherwise a NULL pointer is returned.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ @retval E_INVALIDARG if bad [in] passed, [out] value is NULL
+ */
+ [propget] HRESULT rowDescription
+ (
+ [in] long row,
+ [out, retval] BSTR *description
+ );
+
+ /** @brief Returns the number of rows occupied by the accessible object
+ at the specified row and column in the table.
+
+ The result is greater than 1 if the specified cell spans multiple rows.
+ @param [in] row
+ 0 based row index of the accessible for which to return the row extent.
+ @param [in] column
+ 0 based column index of the accessible for which to return the row extent.
+ @param [out] nRowsSpanned
+ Returns the row extent of the specified cell.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] value is 0
+ */
+ [propget] HRESULT rowExtentAt
+ (
+ [in] long row,
+ [in] long column,
+ [out, retval] long *nRowsSpanned
+ );
+
+ /** @brief Returns the row headers as an %IAccessibleTable object.
+
+ Content and size of the returned table are implementation dependent.
+ @param [out] accessibleTable
+ The row header.
+ @param [out] startingColumnIndex
+ The 0 based column index where the header starts, usually 0.
+ @retval S_OK
+ @retval S_FALSE if there is no header, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT rowHeader
+ (
+ [out] IAccessibleTable **accessibleTable,
+ [out, retval] long *startingColumnIndex
+ );
+
+ /** @brief Translates the given cell index into a row index.
+ @param [in] cellIndex
+ 0 based index of the cell in the parent or closest ancestor table. Typically this
+ is the value returned from IAccessible2::indexInParent, but in the case where the
+ table cells are not direct children of the table this is the cell index specified
+ by the "table-cell-index" object attribute obtained from parsing the attributes
+ string returned by calling IAccessible2::attributes on the cell object.
+ @param [out] rowIndex
+ 0 based row index
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] value is 0
+ */
+ [propget] HRESULT rowIndex
+ (
+ [in] long cellIndex,
+ [out, retval] long *rowIndex
+ );
+
+ /** @brief Returns a list of cell indexes currently selected (0 based).
+ @param [in] maxChildren
+ This parameter is ignored. Refer to @ref _arrayConsideration
+ "Special Consideration when using Arrays" for more details.
+ @param [out] children
+ An array of cell indexes of selected cells (each index is 0 based),
+ allocated by the server. The client must free it with CoTaskMemFree.
+ @param [out] nChildren
+ The number of cell indexes returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are none, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT selectedChildren
+ (
+ [in] long maxChildren,
+ [out, size_is(,maxChildren), length_is(,*nChildren)] long **children,
+ [out, retval] long *nChildren
+ );
+
+ /** @brief Returns a list of column indexes currently selected (0 based).
+ @param [in] maxColumns
+ This parameter is ignored. Refer to @ref _arrayConsideration
+ "Special Consideration when using Arrays" for more details.
+ @param [out] columns
+ An array of column indexes of selected columns (each index is 0 based), allocated
+ by the server. The client must free it with CoTaskMemFree.
+ @param [out] nColumns
+ The number of column indexes returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are none, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT selectedColumns
+ (
+ [in] long maxColumns,
+ [out, size_is(,maxColumns), length_is(,*nColumns)] long **columns,
+ [out, retval] long *nColumns
+ );
+
+ /** @brief Returns a list of row indexes currently selected (0 based).
+ @param [in] maxRows
+ This parameter is ignored. Refer to @ref _arrayConsideration
+ "Special Consideration when using Arrays" for more details.
+ @param [out] rows
+ An array of row indexes of selected rows (each index is 0 based), allocated
+ by the server. The client must free it with CoTaskMemFree.
+ @param [out] nRows
+ The number of row indexes returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are none, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT selectedRows
+ (
+ [in] long maxRows,
+ [out, size_is(,maxRows), length_is(,*nRows)] long **rows,
+ [out, retval] long *nRows
+ );
+
+ /** @brief Returns the summary description of the table. The returned object could be
+ an IAccessible or an IAccessible2.
+ @param [out] accessible
+ Returns a reference to an implementation dependent accessible object
+ representing the table's summary or a NULL pointer if the table
+ does not support a summary.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT summary
+ (
+ [out, retval] IUnknown **accessible
+ );
+
+ /** @brief Returns a boolean value indicating whether the specified column is
+ completely selected.
+ @param [in] column
+ 0 based index of the column for which to determine whether it is selected.
+ @param [out] isSelected
+ Returns TRUE if the specified column is selected completely and FALSE otherwise.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] value is FALSE
+ */
+ [propget] HRESULT isColumnSelected
+ (
+ [in] long column,
+ [out, retval] boolean *isSelected
+ );
+
+ /** @brief Returns a boolean value indicating whether the specified row is completely
+ selected.
+ @param [in] row
+ 0 based index of the row for which to determine whether it is selected.
+ @param [out] isSelected
+ Returns TRUE if the specified row is selected completely and FALSE otherwise.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] value is FALSE
+ */
+ [propget] HRESULT isRowSelected
+ (
+ [in] long row,
+ [out, retval] boolean *isSelected
+ );
+
+ /** @brief Returns a boolean value indicating whether the specified cell is selected.
+ @param [in] row
+ 0 based index of the row for the cell to determine whether it is selected.
+ @param [in] column
+ 0 based index of the column for the cell to determine whether it is selected.
+ @param [out] isSelected
+ Returns TRUE if the specified cell is selected and FALSE otherwise.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] value is FALSE
+ */
+ [propget] HRESULT isSelected
+ (
+ [in] long row,
+ [in] long column,
+ [out, retval] boolean *isSelected
+ );
+
+ /** @brief Selects a row and unselects all previously selected rows.
+ @param [in] row
+ 0 based index of the row to be selected.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT selectRow
+ (
+ [in] long row
+ );
+
+ /** @brief Selects a column and unselects all previously selected columns.
+ @param [in] column
+ 0 based index of the column to be selected.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT selectColumn
+ (
+ [in] long column
+ );
+
+ /** @brief Unselects one row, leaving other selected rows selected (if any).
+ @param [in] row
+ 0 based index of the row to be unselected.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT unselectRow
+ (
+ [in] long row
+ );
+
+ /** @brief Unselects one column, leaving other selected columns selected (if any).
+ @param [in] column
+ 0 based index of the column to be unselected.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT unselectColumn
+ (
+ [in] long column
+ );
+
+ /** @brief Given a cell index, gets the row and column indexes and extents of a cell
+ and whether or not it is selected.
+
+ This is a convenience function. It is not mandatory to implement it.
+ @param [in] index
+ 0 based index of this cell in the table.
+ @param [out] row
+ 0 based row index.
+ @param [out] column
+ 0 based column index.
+ @param [out] rowExtents
+ Number of cells spanned by this cell in this row.
+ @param [out] columnExtents
+ Number of cells spanned by this cell in this column.
+ @param [out] isSelected
+ Indicates if the specified cell is selected.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed, [out] values are 0s and FALSE respectively
+ */
+ [propget] HRESULT rowColumnExtentsAtIndex
+ (
+ [in] long index,
+ [out] long *row,
+ [out] long *column,
+ [out] long *rowExtents,
+ [out] long *columnExtents,
+ [out, retval] boolean *isSelected
+ );
+
+ /** @brief Returns the type and extents describing how a table changed.
+
+ Provided for use by the IA2_EVENT_TABLE_MODEL_CHANGED event handler.
+
+ This data is only guaranteed to be valid while the thread notifying the event
+ continues. Once the handler has returned, the validity of the data depends on
+ how the server manages the life cycle of its objects. Also, note that the server
+ may have different life cycle management strategies for controls depending on
+ whether or not a control manages its children. Lists, trees, and tables can have
+ a large number of children and thus it's possible that the child objects for those
+ controls would only be created as needed. Servers should document their life cycle
+ strategy as this will be of interest to assistive technology or script engines
+ accessing data out of process or from other threads. Servers only need to save the
+ most recent row and column values associated with the change and a scope of the
+ entire application is adequate.
+
+ @param [out] modelChange
+ A struct of (type(insert, delete, update), firstRow, lastRow, firstColumn, lastColumn).
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT modelChange
+ (
+ [out, retval] IA2TableModelChange *modelChange
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleTable2.idl b/other-licenses/ia2/AccessibleTable2.idl
new file mode 100644
index 0000000000..860062c371
--- /dev/null
+++ b/other-licenses/ia2/AccessibleTable2.idl
@@ -0,0 +1,377 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleTable2.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2012 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "Accessible2.idl";
+import "IA2CommonTypes.idl";
+
+/** @brief This interface gives access to a two-dimensional table.
+
+ Please also refer to the IAccessibleTableCell interface.
+
+ If you want to support older applications you should also support the
+ IAccessibleTable inteface.
+*/
+[object, uuid(6167f295-06f0-4cdd-a1fa-02e25153d869)]
+interface IAccessibleTable2 : IUnknown
+{
+
+ /** @brief Returns the accessible object at the specified row and column in
+ the table. This object could be an IAccessible or an IAccessible2.
+ @param [in] row
+ The 0 based row index for which to retrieve the cell.
+ @param [in] column
+ The 0 based column index for which to retrieve the cell.
+ @param [out] cell
+ If both row and column index are valid then the corresponding accessible
+ object is returned that represents the requested cell regardless of whether
+ the cell is currently visible (on the screen).
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT cellAt
+ (
+ [in] long row,
+ [in] long column,
+ [out, retval] IUnknown **cell
+ );
+
+ /** @brief Returns the caption for the table. The returned object could be
+ an IAccessible or an IAccessible2.
+ @param [out] accessible
+ If the table has a caption then a reference to it is returned, else a NULL
+ pointer is returned.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ @deprecated use a describedBy relation
+ */
+ [propget] HRESULT caption
+ (
+ [out, retval] IUnknown **accessible
+ );
+
+ /** @brief Returns the description text of the specified column in the table.
+ @param [in] column
+ The 0 based index of the column for which to retrieve the description.
+ @param [out] description
+ Returns the description text of the specified column in the table if such a
+ description exists. Otherwise a NULL pointer is returned.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT columnDescription
+ (
+ [in] long column,
+ [out, retval] BSTR *description
+ );
+
+
+ /** @brief Returns the total number of columns in table
+ @param [out] columnCount
+ Number of columns in table (including columns outside the current viewport)
+ @retval S_OK
+ */
+ [propget] HRESULT nColumns
+ (
+ [out, retval] long *columnCount
+ );
+
+ /** @brief Returns the total number of rows in table
+ @param [out] rowCount
+ Number of rows in table (including rows outside the current viewport)
+ @retval S_OK
+ */
+ [propget] HRESULT nRows
+ (
+ [out, retval] long *rowCount
+ );
+
+ /** @brief Returns the total number of selected cells
+ @param [out] cellCount
+ Number of cells currently selected
+ @retval S_OK
+ */
+ [propget] HRESULT nSelectedCells
+ (
+ [out, retval] long *cellCount
+ );
+
+ /** @brief Returns the total number of selected columns
+ @param [out] columnCount
+ Number of columns currently selected
+ @retval S_OK
+ */
+ [propget] HRESULT nSelectedColumns
+ (
+ [out, retval] long *columnCount
+ );
+
+ /** @brief Returns the total number of selected rows
+ @param [out] rowCount
+ Number of rows currently selected
+ @retval S_OK
+ */
+ [propget] HRESULT nSelectedRows
+ (
+ [out, retval] long *rowCount
+ );
+
+ /** @brief Returns the description text of the specified row in the table.
+ @param [in] row
+ The 0 based index of the row for which to retrieve the description.
+ @param [out] description
+ Returns the description text of the specified row in the table if such a
+ description exists. Otherwise a NULL pointer is returned.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT rowDescription
+ (
+ [in] long row,
+ [out, retval] BSTR *description
+ );
+
+ /** @brief Returns a list of accessibles currently selected.
+ @param [out] cells
+ Pointer to an array of references to selected accessibles. The array is
+ allocated by the server with CoTaskMemAlloc and freed by the client with
+ CoTaskMemFree.
+ @param [out] nSelectedCells
+ The number of accessibles returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are none, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT selectedCells
+ (
+ [out, size_is(,*nSelectedCells)] IUnknown ***cells,
+ [out, retval] long *nSelectedCells
+ );
+
+ /** @brief Returns a list of column indexes currently selected (0 based).
+ @param [out] selectedColumns
+ A pointer to an array of column indexes of selected columns (each index is
+ 0 based). The array is allocated by the server with CoTaskMemAlloc and
+ freed by the client with CoTaskMemFree.
+ @param [out] nColumns
+ The number of column indexes returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are none, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT selectedColumns
+ (
+ [out, size_is(,*nColumns)] long **selectedColumns,
+ [out, retval] long *nColumns
+ );
+
+ /** @brief Returns a list of row indexes currently selected (0 based).
+ @param [out] selectedRows
+ An array of row indexes of selected rows (each index is 0 based). The array
+ is allocated by the server with CoTaskMemAlloc and freed by the client with
+ CoTaskMemFree.
+ @param [out] nRows
+ The number of row indexes returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there are none, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT selectedRows
+ (
+ [out, size_is(,*nRows)] long **selectedRows,
+ [out, retval] long *nRows
+ );
+
+ /** @brief Returns the summary description of the table. The returned object could be
+ an IAccessible or an IAccessible2.
+ @param [out] accessible
+ Returns a reference to an implementation dependent accessible object
+ representing the table's summary or a NULL pointer if the table
+ does not support a summary.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ @deprecated Use the labeledBy relation
+ */
+ [propget] HRESULT summary
+ (
+ [out, retval] IUnknown **accessible
+ );
+
+ /** @brief Returns a boolean value indicating whether the specified column is
+ completely selected.
+ @param [in] column
+ 0 based index of the column for which to determine whether it is selected.
+ @param [out] isSelected
+ Returns TRUE if the specified column is selected completely and FALSE otherwise.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT isColumnSelected
+ (
+ [in] long column,
+ [out, retval] boolean *isSelected
+ );
+
+ /** @brief Returns a boolean value indicating whether the specified row is completely
+ selected.
+ @param [in] row
+ 0 based index of the row for which to determine whether it is selected.
+ @param [out] isSelected
+ Returns TRUE if the specified row is selected completely and FALSE otherwise.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT isRowSelected
+ (
+ [in] long row,
+ [out, retval] boolean *isSelected
+ );
+
+ /** @brief Selects a row and unselects all previously selected rows.
+
+ The behavior should mimic that of the application, but for those applications
+ which do not have a means in the GUI to select a full row of cells the behavior
+ should be as follows: First any selected rows in the table are unselected. Then
+ the entire row of cells for the specified row is selected. If any of the
+ cells in the selected row span additional rows, the cells in those rows
+ are also selected.
+ @param [in] row
+ 0 based index of the row to be selected.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT selectRow
+ (
+ [in] long row
+ );
+
+ /** @brief Selects a column and unselects all previously selected columns.
+
+ The behavior should mimic that of the application, but for those applications
+ which do not have a means in the GUI to select a full column of cells the behavior
+ should be as follows: First any selected columns in the table are unselected. Then
+ the entire column of cells for the specified column is selected. If any of the
+ cells in the selected column span additional columns, the cells in those columns
+ are also selected.
+ @param [in] column
+ 0 based index of the column to be selected.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT selectColumn
+ (
+ [in] long column
+ );
+
+ /** @brief Unselects one row, leaving other selected rows selected (if any).
+
+ The behavior should mimic that of the application, but for those applications
+ which do not have a means in the GUI to unselect a full row of cells the
+ behavior should be as follows: The entire row of cells for the specified
+ row is unselected. If any of the cells in the selected row span additional
+ rows, the cells in those rows are also unselected.
+ @param [in] row
+ 0 based index of the row to be unselected.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT unselectRow
+ (
+ [in] long row
+ );
+
+ /** @brief Unselects one column, leaving other selected columns selected (if any).
+
+ The behavior should mimic that of the application, but for those applications
+ which do not have a means in the GUI to unselect a full column of cells the
+ behavior should be as follows: The entire column of cells for the specified
+ column is unselected. If any of the cells in the selected column span additional
+ columns, the cells in those columns are also unselected.
+ @param [in] column
+ 0 based index of the column to be unselected.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT unselectColumn
+ (
+ [in] long column
+ );
+
+ /** @brief Returns the type and extents describing how a table changed.
+
+ Provided for use by the IA2_EVENT_TABLE_MODEL_CHANGED event handler.
+
+ This data is only guaranteed to be valid while the thread notifying the event
+ continues. Once the handler has returned, the validity of the data depends on
+ how the server manages the life cycle of its objects. Also, note that the server
+ may have different life cycle management strategies for controls depending on
+ whether or not a control manages its children. Lists, trees, and tables can have
+ a large number of children and thus it's possible that the child objects for those
+ controls would only be created as needed. Servers should document their life cycle
+ strategy as this will be of interest to assistive technology or script engines
+ accessing data out of process or from other threads. Servers only need to save the
+ most recent row and column values associated with the change and a scope of the
+ entire application is adequate.
+
+ @param [out] modelChange
+ A struct of (type(insert, delete, update), firstRow, lastRow, firstColumn, lastColumn).
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is NULL
+ */
+ [propget] HRESULT modelChange
+ (
+ [out, retval] IA2TableModelChange *modelChange
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleTableCell.idl b/other-licenses/ia2/AccessibleTableCell.idl
new file mode 100644
index 0000000000..e98754c5db
--- /dev/null
+++ b/other-licenses/ia2/AccessibleTableCell.idl
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleTableCell.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2013 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "Accessible2.idl";
+
+/** @brief This interface gives access to the cells of a two-dimensional table.
+
+ Please also refer to the IAccessibleTable2 interface.
+
+*/
+[object, uuid(594116B1-C99F-4847-AD06-0A7A86ECE645)]
+interface IAccessibleTableCell : IUnknown
+{
+
+ /** @brief Returns the number of columns occupied by this cell accessible.
+
+ The result is greater than 1 if the specified cell spans multiple columns.
+ @param [out] nColumnsSpanned
+ Returns the 1 based column extent of the specified cell.
+ @retval S_OK
+ */
+ [propget] HRESULT columnExtent
+ (
+ [out, retval] long *nColumnsSpanned
+ );
+
+ /** @brief Returns the column headers as an array of cell accessibles.
+
+ @param [out] cellAccessibles
+ Pointer to an array of references to cell accessibles. The array is allocated
+ by the server. The client must free it with CoTaskMemFree.
+ @param [out] nColumnHeaderCells
+ The number of accessibles returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there is no header, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT columnHeaderCells
+ (
+ [out, size_is(,*nColumnHeaderCells)] IUnknown ***cellAccessibles,
+ [out, retval] long *nColumnHeaderCells
+ );
+
+ /** @brief Translates this cell accessible into the corresponding column index.
+
+ @param [out] columnIndex
+ Returns the 0 based column index of the cell of the specified cell or the index of
+ the first column if the cell spans multiple columns.
+ @retval S_OK
+ */
+ [propget] HRESULT columnIndex
+ (
+ [out, retval] long *columnIndex
+ );
+
+ /** @brief Returns the number of rows occupied by this cell accessible.
+
+ @param [out] nRowsSpanned
+ Returns the row extent of the specified cell.
+ @retval S_OK
+ */
+ [propget] HRESULT rowExtent
+ (
+ [out, retval] long *nRowsSpanned
+ );
+
+ /** @brief Returns the row headers as an array of cell accessibles.
+
+ @param [out] cellAccessibles
+ Pointer to an array of references to cell accessibles. The array is allocated
+ by the server. The client must free it with CoTaskMemFree.
+ @param [out] nRowHeaderCells
+ The number of accessibles returned; the size of the returned array.
+ @retval S_OK
+ @retval S_FALSE if there is no header, [out] values are NULL and 0 respectively
+ */
+ [propget] HRESULT rowHeaderCells
+ (
+ [out, size_is(,*nRowHeaderCells)] IUnknown ***cellAccessibles,
+ [out, retval] long *nRowHeaderCells
+ );
+
+ /** @brief Translates this cell accessible into the corresponding row index.
+
+ @param [out] rowIndex
+ Returns the 0 based row index of the specified cell or the index of
+ the first row if the cell spans multiple rows.
+ @retval S_OK
+ */
+ [propget] HRESULT rowIndex
+ (
+ [out, retval] long *rowIndex
+ );
+
+ /** @brief Returns a boolean value indicating whether this cell is selected.
+
+ @param [out] isSelected
+ Returns TRUE if the specified cell is selected and FALSE otherwise.
+ @retval S_OK
+ */
+ [propget] HRESULT isSelected
+ (
+ [out, retval] boolean *isSelected
+ );
+
+ /** @brief Gets the row and column indexes and extents of this cell accessible
+ and whether or not it is selected.
+
+ This is a convenience function. It is not mandatory to implement it.
+ @param [out] row
+ 0 based row index.
+ @param [out] column
+ 0 based column index.
+ @param [out] rowExtents
+ Number of cells spanned by this cell in this row.
+ @param [out] columnExtents
+ Number of cells spanned by this cell in this column.
+ @param [out] isSelected
+ Indicates if the specified cell is selected.
+ @retval S_OK
+ */
+ [propget] HRESULT rowColumnExtents
+ (
+ [out] long *row,
+ [out] long *column,
+ [out] long *rowExtents,
+ [out] long *columnExtents,
+ [out, retval] boolean *isSelected
+ );
+
+ /** @brief Returns a reference to the accessbile of the containing table.
+
+ @param [out] table
+ Returns a reference to the IUnknown of the containing table.
+ @retval S_OK
+ */
+ [propget] HRESULT table
+ (
+ [out, retval] IUnknown **table
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleText.idl b/other-licenses/ia2/AccessibleText.idl
new file mode 100644
index 0000000000..f29840a1bd
--- /dev/null
+++ b/other-licenses/ia2/AccessibleText.idl
@@ -0,0 +1,701 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleText.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2013 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "IA2CommonTypes.idl";
+
+/** A structure containing a substring and the start and end offsets in the enclosing string.
+
+ IAccessibleText::newText and IAccessibleText::oldText return this struct.
+*/
+typedef struct IA2TextSegment {
+ BSTR text; ///< A copy of a segment of text taken from an enclosing paragraph.
+ long start; ///< Index of the first character of the segment in the enclosing text.
+ long end; ///< Index of the character following the last character of the segment in the enclosing text.
+} IA2TextSegment;
+
+/** This enum defines values which specify a text boundary type.
+
+ IA2_TEXT_BOUNDARY_SENTENCE is optional. When a method doesn't implement this
+ method it must return S_FALSE. Typically this feature would not be implemented
+ by an application. However, if the application developer was not satisfied with
+ how screen readers have handled the reading of sentences this boundary type
+ could be implemented and screen readers could use the application's version of a
+ sentence rather than the screen reader's.
+
+ The rest of the boundary types must be supported.
+
+ This enum is used in IAccessibleText::textBeforeOffset, IAccessibleText::textAtOffset,
+ and IAccessibleText::textAfterOffset.
+*/
+
+enum IA2TextBoundaryType {
+ /** Typically, a single character is returned. In some cases more than one
+ character is returned, for example, when a document contains field data such
+ as a field containing a date, time, or footnote reference. In this case
+ the caret can move over several characters in one movement of the caret.
+ Note, that after the caret moves, the caret offset changes by the number of
+ characters in the field, e.g. by 8 characters in the following date: 03/26/07.
+ */
+ IA2_TEXT_BOUNDARY_CHAR,
+
+ /** The range provided matches the range observed when the application
+ processes the Ctrl + left arrow and Ctrl + right arrow key sequences.
+ Typically this is from the start of one word to the start of the next, but
+ various applications are inconsistent in the handling of the end of a line.
+ */
+ IA2_TEXT_BOUNDARY_WORD,
+
+ /** Range is from start of one sentence to the start of another sentence.
+ */
+ IA2_TEXT_BOUNDARY_SENTENCE,
+
+ /** Range is from start of one paragraph to the start of another paragraph.
+ */
+ IA2_TEXT_BOUNDARY_PARAGRAPH,
+
+ /** Range is from start of one line to the start of another line. This often
+ means that an end-of-line character will appear at the end of the range.
+ However in the case of some applications an end-of-line character indicates
+ the end of a paragraph and the lines composing the paragraph, other than
+ the last line, do not contain an end of line character.
+ */
+ IA2_TEXT_BOUNDARY_LINE,
+
+ /** <b>Deprecated.</b> Using this value will cause all text to be returned.
+ Note: IAccessibleText::text should be used instead.
+ */
+ IA2_TEXT_BOUNDARY_ALL
+};
+
+/** @brief This interface gives read-only access to text.
+
+ The %IAccessibleText interface should be implemented by all components
+ that present textual information on the display like buttons,
+ text entry fields, or text portions of the document window. The interface
+ provides access to the text's content, attributes, and spatial location.
+ However, text can not be modified with this interface. That is the task
+ of the IAccessibleEditableText interface.
+
+ The text length, i.e. the number of characters in the text, is
+ returned by IAccessibleText::nCharacters. All methods that operate
+ on particular characters (e.g. IAccessibleText::textAtOffset) use character
+ indices from 0 to length-1. All methods that operate on character positions
+ (e.g. IAccessibleText::text) use indices from 0 to length.
+
+ Please note that accessible text does not necessarily support selection.
+ In this case it should behave as if there where no selection. An empty
+ selection is used for example to express the current cursor position.
+
+ Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+
+ E_FAIL is returned in the following cases
+ @li endOffset < startOffset
+ @li endoffset > length
+*/
+[object, uuid(24FD2FFB-3AAD-4a08-8335-A3AD89C0FB4B)]
+interface IAccessibleText : IUnknown
+{
+
+ /** @brief Adds a text selection
+ @param [in] startOffset
+ Starting offset ( 0 based).
+ @param [in] endOffset
+ Offset of first character after new selection (0 based).
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ */
+ HRESULT addSelection
+ (
+ [in] long startOffset,
+ [in] long endOffset
+ );
+
+ /** @brief Returns text attributes.
+ @param [in] offset
+ Text offset (0 based). Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ @param [out] startOffset
+ The starting offset of the character range over which all text attributes match
+ those of offset. (0 based)
+ @param [out] endOffset
+ The offset of the first character past the character range over which all text
+ attributes match those of offset. (0 based)
+ @param [out] textAttributes
+ A string of attributes describing the text. The attributes are described in the
+ <a href="http://www.linuxfoundation.org/en/Accessibility/IAccessible2/TextAttributes">
+ text attributes specification</a> on the %IAccessible2 web site.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] values are 0s and NULL respectively
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT attributes
+ (
+ [in] long offset,
+ [out] long *startOffset,
+ [out] long *endOffset,
+ [out, retval] BSTR *textAttributes
+ );
+
+ /** @brief Returns the position of the caret.
+
+ Returns the 0-based offset of the caret within the text. If the text is
+ implemented as a tree of text objects with embed characters in higher levels
+ representing substrings of child text objects and the caret is in one of the
+ child text objects, then the offset in the higher level text object would be
+ at the embed character representing child text object that contains the caret.
+
+ For example, if the string "one two three" is implemented as a two text objects,
+ with a top level text object containing an embed character "one ? three" and a
+ child text object containing "two" and if the caret is in the descendant object
+ just before the 'o' in "two", then:
+ <ul>
+ <li>the caretOffset for the "one ? three" object would be 4, matching the embed character</li>
+ <li>the caretOffset for "two" would be 2, matching the "o"</li>
+ </ul>
+ The caret position/offset is that of the character logically following it, e.g.
+ to the right of it in a left to right language, or to the left of it in a right
+ to left language.
+ @param [out] offset
+ The returned offset is relative to the text represented by this object.
+ @retval S_OK
+ @retval S_FALSE if the caret is not currently active on this object, i.e. the
+ caret is located on some other object. The returned offset value will be -1.
+ @note S_FALSE (and an offset of -1) will not be returned if the caret is somewhere
+ in the text object or one of its descendants.
+ */
+ [propget] HRESULT caretOffset
+ (
+ [out, retval] long *offset
+ );
+
+
+ /** @brief Returns the bounding box of the specified position.
+
+ The virtual character after the last character of the represented
+ text, i.e. the one at position length is a special case. It represents the
+ current input position and will therefore typically be queried by AT more
+ often than other positions. Because it does not represent an existing character
+ its bounding box is defined in relation to preceding characters. It should be
+ roughly equivalent to the bounding box of some character when inserted at the
+ end of the text. Its height typically being the maximal height of all the
+ characters in the text or the height of the preceding character, its width being
+ at least one pixel so that the bounding box is not degenerate.
+
+ Note that the index 'length' is not always valid. Whether it is or not is
+ implementation dependent. It typically is when text is editable or otherwise
+ when on the screen the caret can be placed behind the text. You can be sure
+ that the index is valid after you have received a ::IA2_EVENT_TEXT_CARET_MOVED
+ event for this index.
+ @param [in] offset
+ Index of the character for which to return its bounding box. The valid range
+ is 0..length. Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ @param [in] coordType
+ Specifies if the coordinates are relative to the screen or to the parent window.
+ @param [out] x
+ X coordinate of the top left corner of the bounding box of the referenced character.
+ @param [out] y
+ Y coordinate of the top left corner of the bounding box of the referenced character.
+ @param [out] width
+ Width of the bounding box of the referenced character.
+ @param [out] height
+ Height of the bounding box of the referenced character.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT characterExtents
+ (
+ [in] long offset,
+ [in] enum IA2CoordinateType coordType,
+ [out] long *x,
+ [out] long *y,
+ [out] long *width,
+ [out, retval] long *height
+ );
+
+
+ /** @brief Returns the number of active non-contiguous selections
+ @param [out] nSelections
+ @retval S_OK
+ */
+ [propget] HRESULT nSelections
+ (
+ [out, retval] long *nSelections
+ );
+
+ /** @brief Returns the text position for the specified screen position.
+
+ Given a point return the zero-based index of the character under that
+ point. The same functionality could be achieved by using the bounding
+ boxes for each character as returned by IAccessibleText::characterExtents.
+ The method IAccessibleText::offsetAtPoint, however, can be implemented
+ more efficiently.
+
+ @param [in] x
+ The position's x value for which to look up the index of the character that
+ is rendered on to the display at that point.
+ @param [in] y
+ The position's y value for which to look up the index of the character that
+ is rendered on to the display at that point.
+ @param [in] coordType
+ Screen coordinates or window coordinates.
+ @param [out] offset
+ Index of the character under the given point or -1 if the point
+ is invalid or there is no character under the point.
+ @retval S_OK
+ @retval S_FALSE if nothing to return, [out] value is -1
+
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT offsetAtPoint
+ (
+ [in] long x,
+ [in] long y,
+ [in] enum IA2CoordinateType coordType,
+ [out, retval] long *offset
+ );
+
+ /** @brief Returns the character offsets of Nth active text selection
+
+ Returns the 0-based starting and ending offsets of the Nth selection. If the
+ text is implemented as a tree of text objects with embed characters in higher
+ levels representing substrings of child text objects, consider the following.
+ If the starting selection offset is in one of the child text objects, then the
+ starting offset in the higher level text object would be at the embed character
+ representing the child text object that contains the starting selection offset.
+ If the ending selection offset is in one of the child text objects, then the
+ ending offset in the higher level text object would be just after the embed
+ character representing the child text object that contains the ending selection
+ offset.
+
+ For example, if the string "one two three" is implemented as a two text objects,
+ with a top level text object containing an embed character "one ? three" and a
+ child text object containing "two" and if the selection is the string "two" then:
+ <ul>
+ <li>the startOffset for the "one ? three" object would be 4, matching the embed character and the endOffset would be 5.</li>
+ <li>the startOffset for the "two" object would be 0, and the endOffset would be 3</li>
+ </ul>
+ Selection offsets are that of the character logically following it, e.g.
+ to the right of it in a left to right language or to the left of it in a right to left language.
+ @param [in] selectionIndex
+ Index of selection (0 based).
+ @param [out] startOffset
+ 0 based offset of first selected character
+ @param [out] endOffset
+ 0 based offset of one past the last selected character.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT selection
+ (
+ [in] long selectionIndex,
+ [out] long *startOffset,
+ [out, retval] long *endOffset
+ );
+
+ /** @brief Returns the substring between the two given indices.
+
+ The substring starts with the character at startOffset (inclusive) and up to
+ the character at endOffset (exclusive), if startOffset is less or equal
+ endOffset. If endOffset is lower than startOffset, the result is the same
+ as a call with the two arguments being exchanged.
+
+ The whole text can be requested by passing the indices zero and
+ IAccessibleText::nCharacters. If both indices have the same value, an empty
+ string is returned.
+ @param [in] startOffset
+ Index of the first character to include in the returned string. The valid range
+ is 0..length.
+ @param [in] endOffset
+ Index of the last character to exclude in the returned string. The valid range
+ is 0..length.
+ @param [out] text
+ Returns the substring starting with the character at startOffset (inclusive)
+ and up to the character at endOffset (exclusive), if startOffset is less than
+ or equal to endOffset.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note
+ @li The returned string may be longer than endOffset-startOffset bytes if text
+ contains multi-byte characters.
+ @li Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ */
+ [propget] HRESULT text
+ (
+ [in] long startOffset,
+ [in] long endOffset,
+ [out, retval] BSTR *text
+ );
+
+ /** @brief Returns a text portion before the given position.
+
+ Returns the substring of the specified text type that is located before the
+ given character and does not include it. The result of this method should be
+ same as a result for IAccessibleText::textAtOffset with a suitably decreased
+ index value.
+
+ For example, if text type is ::IA2_TEXT_BOUNDARY_WORD, then the complete
+ word that is closest to and located before offset is returned.
+
+ If the index is valid, but no text is found, S_FALSE is returned along with out
+ values of 0, 0, and a NULL pointer. This would happen for boundary types other
+ than character when the text consists entirely of whitespace.
+
+ @param [in] offset
+ Index of the character for which to return the text part before it. The index
+ character will not be part of the returned string. The valid range is 0..length.
+ Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ @param [in] boundaryType
+ The type of the text portion to return. See ::IA2TextBoundaryType for the
+ complete list.
+ @param [out] startOffset
+ 0 based offset of first character.
+ @param [out] endOffset
+ 0 based offset of one past the last character.
+ @param [out] text
+ Returns the requested text portion. This portion may be empty or invalid when
+ no appropriate text portion is found or text type is invalid.
+ @retval S_OK
+ @retval S_FALSE if the requested boundary type is not implemented, such as
+ ::IA2_TEXT_BOUNDARY_SENTENCE, or if there is nothing to return;
+ [out] values are 0s and NULL respectively
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT textBeforeOffset
+ (
+ [in] long offset,
+ [in] enum IA2TextBoundaryType boundaryType,
+ [out] long *startOffset,
+ [out] long *endOffset,
+ [out, retval] BSTR *text
+ );
+
+ /** @brief Returns a text portion after the given position.
+
+ Returns the substring of the specified text type that is located after the
+ given character and does not include it. The result of this method should be
+ same as a result for IAccessibleText::textAtOffset with a suitably increased
+ index value.
+
+ For example, if text type is ::IA2_TEXT_BOUNDARY_WORD, then the complete
+ word that is closest to and located after offset is returned.
+
+ If the index is valid, but no text is found, S_FALSE is returned along with out
+ values of 0, 0, and a NULL pointer. This would happen for boundary types other
+ than character when the text consists entirely of whitespace.
+
+ @param [in] offset
+ Index of the character for which to return the text part after it. The index
+ character will not be part of the returned string. The valid range is 0..length.
+ Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ @param [in] boundaryType
+ The type of the text portion to return. See ::IA2TextBoundaryType for the complete
+ list.
+ @param [out] startOffset
+ 0 based offset of first character.
+ @param [out] endOffset
+ 0 based offset of one past the last character.
+ @param [out] text
+ Returns the requested text portion. This portion may be empty or invalid when
+ no appropriate text portion is found or text type is invalid.
+ @retval S_OK
+ @retval S_FALSE if the requested boundary type is not implemented, such as
+ ::IA2_TEXT_BOUNDARY_SENTENCE, or if there is nothing to return;
+ [out] values are 0s and NULL respectively
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT textAfterOffset
+ (
+ [in] long offset,
+ [in] enum IA2TextBoundaryType boundaryType,
+ [out] long *startOffset,
+ [out] long *endOffset,
+ [out, retval] BSTR *text
+ );
+
+ /** @brief Returns a text portion that spans the given position.
+
+ Returns the substring defined by the specified boundary type at the specified
+ offset. Refer to IA2TextBoundaryType for more details.
+
+ For the word boundary type the returned string will contain the word at the
+ offset if the offset is inside a word and will contain the word before the
+ offset if the offset is not inside a word. All offsets from the first to the
+ last characters of a word are considered inside the word. Boundary types of
+ sentence and paragraph should exhibit similar behavior.
+
+ If the index is valid, but no text is found, S_FALSE is returned along with out
+ values of 0, 0, and a NULL pointer. This would happen for boundary types other
+ than character when the text consists entirely of whitespace.
+
+ @param [in] offset
+ Index of the character for which to return the text part it belongs to. The valid
+ range is 0..length.
+ Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ @param [in] boundaryType
+ The type of the text portion to return. See ::IA2TextBoundaryType for the complete
+ list.
+ @param [out] startOffset
+ 0 based offset of first character.
+ @param [out] endOffset
+ 0 based offset of one past the last character.
+ @param [out] text
+ Returns the requested text portion. This portion may be empty or invalid when
+ no appropriate text portion is found or text type is invalid.
+ @retval S_OK
+ @retval S_FALSE if the requested boundary type is not implemented, such as
+ ::IA2_TEXT_BOUNDARY_SENTENCE, or if there is nothing to return;
+ [out] values are 0s and NULL respectively
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ [propget] HRESULT textAtOffset
+ (
+ [in] long offset,
+ [in] enum IA2TextBoundaryType boundaryType,
+ [out] long *startOffset,
+ [out] long *endOffset,
+ [out, retval] BSTR *text
+ );
+
+ /** @brief Unselects a range of text.
+ @param [in] selectionIndex
+ Index of selection to remove (0 based).
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT removeSelection
+ (
+ [in] long selectionIndex
+ );
+
+ /** @brief Sets the position of the caret.
+
+ The caret position/offset is that of the character logically following it,
+ e.g. to the right of it in a left to right language.
+
+ Setting the caret position may or may not alter the current selection. A
+ change of the selection is notified to the accessibility event listeners with
+ an ::IA2_EVENT_TEXT_SELECTION_CHANGED event.
+
+ When the new caret position differs from the old one (which, of course, is the
+ standard case) this is notified to the accessibility event listeners with an
+ ::IA2_EVENT_TEXT_CARET_MOVED event.
+ @param [in] offset
+ The new index of the caret. This caret is actually placed to the left side of
+ the character with that index. An index of 0 places the caret so that the next
+ insertion goes before the first character. An index of IAccessibleText::nCharacters
+ leads to insertion after the last character. Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ @retval S_OK
+ @retval E_FAIL if the caret cannot be set
+ @retval E_INVALIDARG if bad [in] passed
+ */
+ HRESULT setCaretOffset
+ (
+ [in] long offset
+ );
+
+ /** @brief Changes the bounds of an existing selection.
+ @param [in] selectionIndex
+ Index of selection to change (0 based)
+ @param [in] startOffset
+ New starting offset (0 based)
+ @param [in] endOffset
+ New ending offset (0 based) - the offset of the character just past the last character of the selection.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ */
+ HRESULT setSelection
+ (
+ [in] long selectionIndex,
+ [in] long startOffset,
+ [in] long endOffset
+ );
+
+ /** @brief Returns total number of characters.
+
+ Note that this may be different than the total number of bytes required to store the
+ text, if the text contains multi-byte characters.
+ @param [out] nCharacters
+ @retval S_OK
+ */
+ [propget] HRESULT nCharacters
+ (
+ [out, retval] long *nCharacters
+ );
+
+ /** @brief Makes a specific part of string visible on screen.
+ @param [in] startIndex
+ 0 based character offset.
+ @param [in] endIndex
+ 0 based character offset - the offset of the character just past the last character of the string.
+ @param [in] scrollType
+ Defines where the object should be placed on the screen.
+ @retval S_OK
+ @retval E_INVALIDARG if bad [in] passed
+ @note Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ */
+ HRESULT scrollSubstringTo
+ (
+ [in] long startIndex,
+ [in] long endIndex,
+ [in] enum IA2ScrollType scrollType
+ );
+
+ /** @brief Moves the top left of a substring to a specified location.
+
+ @param [in] startIndex
+ 0 based character offset.
+ @param [in] endIndex
+ 0 based character offset - the offset of the character just past the last character of the string.
+ @param [in] coordinateType
+ Specifies whether the coordinates are relative to the screen or the parent object.
+ @param [in] x
+ Defines the x coordinate.
+ @param [in] y
+ Defines the y coordinate.
+ @retval S_OK
+ @retval S_FALSE if the object is already at the specified location.
+ @retval E_INVALIDARG if bad [in] passed
+ @note Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for information about special offsets that can be used in %IAccessibleText methods.
+ */
+ HRESULT scrollSubstringToPoint
+ (
+ [in] long startIndex,
+ [in] long endIndex,
+ [in] enum IA2CoordinateType coordinateType,
+ [in] long x,
+ [in] long y
+ );
+
+ /** @brief Returns any inserted text.
+
+ Provided for use by the ::IA2_EVENT_TEXT_INSERTED and ::IA2_EVENT_TEXT_UPDATED
+ event handlers.
+
+ This data is only guaranteed to be valid while the thread notifying the event
+ continues. Once the handler has returned, the validity of the data depends on
+ how the server manages the life cycle of its objects. Also, note that the server
+ may have different life cycle management strategies for controls depending on
+ whether or not a control manages its children. Lists, trees, and tables can have
+ a large number of children and thus it's possible that the child objects for those
+ controls would only be created as needed. Servers should document their life cycle
+ strategy as this will be of interest to assistive technology or script engines
+ accessing data out of process or from other threads. Servers only need to save the
+ last inserted block of text and a scope of the entire application is adequate.
+
+ @param [out] newText
+ The text that was just inserted.
+ @retval S_OK
+ @retval S_FALSE If there is nothing to return, the values of IA2TextSegment
+ struct are set as follows: text = NULL, start = 0, end = 0.
+
+ */
+ [propget] HRESULT newText
+ (
+ [out, retval] IA2TextSegment *newText
+ );
+
+ /** @brief Returns any removed text.
+
+ Provided for use by the IA2_EVENT_TEXT_REMOVED/UPDATED event handlers.
+
+ This data is only guaranteed to be valid while the thread notifying the event
+ continues. Once the handler has returned, the validity of the data depends on
+ how the server manages the life cycle of its objects. Also, note that the server
+ may have different life cycle management strategies for controls depending on
+ whether or not a control manages its children. Lists, trees, and tables can have
+ a large number of children and thus it's possible that the child objects for those
+ controls would only be created as needed. Servers should document their life cycle
+ strategy as this will be of interest to assistive technology or script engines
+ accessing data out of process or from other threads. Servers only need to save the
+ last removed block of text and a scope of the entire application is adequate.
+
+ @param [out] oldText
+ The text that was just removed.
+ @retval S_OK
+ @retval S_FALSE If there is nothing to return, the values of IA2TextSegment
+ struct are set as follows: text = NULL, start = 0, end = 0.
+ */
+ [propget] HRESULT oldText
+ (
+ [out, retval] IA2TextSegment *oldText
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleText2.idl b/other-licenses/ia2/AccessibleText2.idl
new file mode 100644
index 0000000000..bc75cdd6ac
--- /dev/null
+++ b/other-licenses/ia2/AccessibleText2.idl
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleText2.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2013 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+import "IA2CommonTypes.idl";
+import "AccessibleText.idl";
+
+/** @brief This interface gives read-only access to text.
+
+ The %IAccessibleText2 interface extends the functionality of the
+ %IAccessibleText interface.
+*/
+[object, uuid(9690A9CC-5C80-4DF5-852E-2D5AE4189A54)]
+interface IAccessibleText2 : IAccessibleText
+{
+
+ /** @brief Returns the range and of the specified set of attributes.
+
+ Return the range (start and end offsets) and text attributes that correspond
+ to the given attributes filter at the given offset.
+
+ @param [in] offset
+ The offset at which to search for the attributes specified in the filter.
+ @param [in] filter
+ The requested attribute names. The filter format is "attribute1, attribute2".
+ @param [out] startOffset
+ The starting (0-based) offset of the text containing the specified attributes.
+ @param [out] endOffset
+ The (0-based) offset one past the last character of the text containing the
+ specified attributes.
+ @param [out] attributeValues
+ The values of the requested attributes.
+ @retval S_OK
+ @retval S_FALSE if nothing to return, [out] values are -1, -1, NULL respectively.
+ @retval E_INVALIDARG if bad [in] passed.
+ */
+ [propget] HRESULT attributeRange
+ (
+ [in] long offset,
+ [in] BSTR filter,
+ [out] long *startOffset,
+ [out] long *endOffset,
+ [out, retval] BSTR *attributeValues
+ );
+
+}
diff --git a/other-licenses/ia2/AccessibleValue.idl b/other-licenses/ia2/AccessibleValue.idl
new file mode 100644
index 0000000000..c8b4b697ee
--- /dev/null
+++ b/other-licenses/ia2/AccessibleValue.idl
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * File Name (AccessibleValue.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2010 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+import "objidl.idl";
+import "oaidl.idl";
+import "oleacc.idl";
+
+/** @brief This interface gives access to a single numerical value.
+
+ The %IAccessibleValue interface represents a single numerical value and should
+ be implemented by any class that supports numerical value like progress bars
+ and spin boxes. This interface lets you access the value and its upper and
+ lower bounds.
+*/
+[object, uuid(35855B5B-C566-4fd0-A7B1-E65465600394)]
+interface IAccessibleValue : IUnknown
+{
+
+ /** @brief Returns the value of this object as a number.
+
+ The exact return type is implementation dependent. Typical types are long and
+ double.
+ @param [out] currentValue
+ Returns the current value represented by this object. See the section about
+ @ref _variants "VARIANTs" for additional information.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is a VARIANT with vt = VT_EMPTY
+ */
+ [propget] HRESULT currentValue
+ (
+ [out, retval] VARIANT *currentValue
+ );
+
+ /** @brief Sets the value of this object to the given number.
+
+ The argument is clipped to the valid interval whose upper and lower
+ bounds are returned by the methods IAccessibleValue::maximumValue and
+ IAccessibleValue::minimumValue, i.e. if it is lower than the minimum
+ value the new value will be the minimum and if it is greater than the
+ maximum then the new value will be the maximum.
+
+ @param [in] value
+ The new value represented by this object. The set of admissible types for
+ this argument is implementation dependent.
+ @retval S_OK
+ */
+ HRESULT setCurrentValue
+ (
+ [in] VARIANT value
+ );
+
+ /** @brief Returns the maximal value that can be represented by this object.
+
+ The type of the returned value is implementation dependent. It does not have
+ to be the same type as that returned by method IAccessibleValue::currentValue.
+
+ @param [out] maximumValue
+ Returns the maximal value in an implementation dependent type. If this object
+ has no upper bound then an empty object is returned. See the section about
+ @ref _variants "VARIANTs" for additional information.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is a VARIANT with vt = VT_EMPTY
+ */
+ [propget] HRESULT maximumValue
+ (
+ [out, retval] VARIANT *maximumValue
+ );
+
+ /** @brief Returns the minimal value that can be represented by this object.
+
+ The type of the returned value is implementation dependent. It does not have
+ to be the same type as that returned by method IAccessibleValue::currentValue.
+
+ @param [out] minimumValue
+ Returns the minimal value in an implementation dependent type. If this object
+ has no lower bound then an empty object is returned. See the section about
+ @ref _variants "VARIANTs" for additional information.
+ @retval S_OK
+ @retval S_FALSE if there is nothing to return, [out] value is a VARIANT with vt = VT_EMPTY
+ */
+ [propget] HRESULT minimumValue
+ (
+ [out, retval] VARIANT *minimumValue
+ );
+
+};
diff --git a/other-licenses/ia2/IA2CommonTypes.idl b/other-licenses/ia2/IA2CommonTypes.idl
new file mode 100644
index 0000000000..b54f65ccde
--- /dev/null
+++ b/other-licenses/ia2/IA2CommonTypes.idl
@@ -0,0 +1,191 @@
+/*************************************************************************
+ *
+ * File Name (IA2CommonTypes.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2010 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+ /** These constants control the scrolling of an object or substring into a window.
+
+ This enum is used in IAccessible2::scrollTo and IAccessibleText::scrollSubstringTo.
+*/
+enum IA2ScrollType {
+
+ /** Scroll the top left corner of the object or substring such that the top left
+ corner (and as much as possible of the rest of the object or substring) is within
+ the top level window. In cases where the entire object or substring fits within
+ the top level window, the placement of the object or substring is dependent on
+ the application. For example, the object or substring may be scrolled to the
+ closest edge, the furthest edge, or midway between those two edges. In cases
+ where there is a hierarchy of nested scrollable controls, more than one control
+ may have to be scrolled.
+ */
+ IA2_SCROLL_TYPE_TOP_LEFT,
+
+ /** Scroll the bottom right corner of the object or substring such that the bottom right
+ corner (and as much as possible of the rest of the object or substring) is within
+ the top level window. In cases where the entire object or substring fits within
+ the top level window, the placement of the object or substring is dependent on
+ the application. For example, the object or substring may be scrolled to the
+ closest edge, the furthest edge, or midway between those two edges. In cases
+ where there is a hierarchy of nested scrollable controls, more than one control
+ may have to be scrolled.
+ */
+ IA2_SCROLL_TYPE_BOTTOM_RIGHT,
+
+ /** Scroll the top edge of the object or substring such that the top edge
+ (and as much as possible of the rest of the object or substring) is within the
+ top level window. In cases where the entire object or substring fits within
+ the top level window, the placement of the object or substring is dependent on
+ the application. For example, the object or substring may be scrolled to the
+ closest edge, the furthest edge, or midway between those two edges. In cases
+ where there is a hierarchy of nested scrollable controls, more than one control
+ may have to be scrolled.
+ */
+ IA2_SCROLL_TYPE_TOP_EDGE,
+
+ /** Scroll the bottom edge of the object or substring such that the bottom edge
+ (and as much as possible of the rest of the object or substring) is within the
+ top level window. In cases where the entire object or substring fits within
+ the top level window, the placement of the object or substring is dependent on
+ the application. For example, the object or substring may be scrolled to the
+ closest edge, the furthest edge, or midway between those two edges. In cases
+ where there is a hierarchy of nested scrollable controls, more than one control
+ may have to be scrolled.
+ */
+ IA2_SCROLL_TYPE_BOTTOM_EDGE,
+
+ /** Scroll the left edge of the object or substring such that the left edge
+ (and as much as possible of the rest of the object or substring) is within the
+ top level window. In cases where the entire object or substring fits within
+ the top level window, the placement of the object or substring is dependent on
+ the application. For example, the object or substring may be scrolled to the
+ closest edge, the furthest edge, or midway between those two edges. In cases
+ where there is a hierarchy of nested scrollable controls, more than one control
+ may have to be scrolled.
+ */
+ IA2_SCROLL_TYPE_LEFT_EDGE,
+
+ /** Scroll the right edge of the object or substring such that the right edge
+ (and as much as possible of the rest of the object or substring) is within the
+ top level window. In cases where the entire object or substring fits within
+ the top level window, the placement of the object or substring is dependent on
+ the application. For example, the object or substring may be scrolled to the
+ closest edge, the furthest edge, or midway between those two edges. In cases
+ where there is a hierarchy of nested scrollable controls, more than one control
+ may have to be scrolled.
+ */
+ IA2_SCROLL_TYPE_RIGHT_EDGE,
+
+ /** Scroll the object or substring such that as much as possible of the
+ object or substring is within the top level window. The placement of
+ the object is dependent on the application. For example, the object or
+ substring may be scrolled to to closest edge, the furthest edge, or midway
+ between those two edges.
+ */
+ IA2_SCROLL_TYPE_ANYWHERE
+};
+
+/** These constants define which coordinate system a point is located in.
+
+ This enum is used in IAccessible2::scrollToPoint, IAccessibleImage::imagePosition,
+ IAccessibleText::characterExtents, and IAccessibleText::offsetAtPoint, and
+ IAccessibleText::scrollSubstringToPoint.
+*/
+enum IA2CoordinateType {
+
+ /// The coordinates are relative to the screen.
+ IA2_COORDTYPE_SCREEN_RELATIVE,
+
+ /** The coordinates are relative to the upper left corner of the bounding box
+ of the immediate parent.
+ */
+ IA2_COORDTYPE_PARENT_RELATIVE
+
+};
+
+/** Special offsets for use in IAccessibleText and IAccessibleEditableText methods
+
+ Refer to @ref _specialOffsets
+ "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods"
+ for more information.
+*/
+enum IA2TextSpecialOffsets {
+ IA2_TEXT_OFFSET_LENGTH = -1, /**< This offset is equivalent to the length of the string. It eliminates
+ the need to call IAccessibleText::nCharacters. */
+ IA2_TEXT_OFFSET_CARET = -2 /**< This offset signifies that the text related to the physical location
+ of the caret should be used. */
+};
+
+/** These constants specify the kind of change made to a table.
+
+ This enum is used in the IA2TableModelChange struct which in turn is used by
+ IAccessibleTable::modelChange and IAccessibleTable2::modelChange.
+*/
+enum IA2TableModelChangeType {
+ IA2_TABLE_MODEL_CHANGE_INSERT, // = 0;
+ IA2_TABLE_MODEL_CHANGE_DELETE,
+ IA2_TABLE_MODEL_CHANGE_UPDATE
+};
+
+/** A structure defining the type of and extents of changes made to a table
+
+ IAccessibleTable::modelChange and IAccessibleTable2::modelChange return this struct.
+ In the case of an insertion or change the row and column offsets define the boundaries
+ of the inserted or changed subtable after the operation. In the case of a deletion
+ the row and column offsets define the boundaries of the subtable being removed before
+ the removal.
+*/
+typedef struct IA2TableModelChange {
+ enum IA2TableModelChangeType type; // insert, delete, update
+ long firstRow; ///< 0 based, inclusive
+ long lastRow; ///< 0 based, inclusive
+ long firstColumn; ///< 0 based, inclusive
+ long lastColumn; ///< 0 based, inclusive
+} IA2TableModelChange;
diff --git a/other-licenses/ia2/IA2TypeLibrary.idl b/other-licenses/ia2/IA2TypeLibrary.idl
new file mode 100644
index 0000000000..2519aca91e
--- /dev/null
+++ b/other-licenses/ia2/IA2TypeLibrary.idl
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * File Name (IA2TypeLibrary.idl)
+ *
+ * IAccessible2 IDL Specification
+ *
+ * Copyright (c) 2007, 2012 Linux Foundation
+ * Copyright (c) 2006 IBM Corporation
+ * Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This BSD License conforms to the Open Source Initiative "Simplified
+ * BSD License" as published at:
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2
+ * mark may be used in accordance with the Linux Foundation Trademark
+ * Policy to indicate compliance with the IAccessible2 specification.
+ *
+ ************************************************************************/
+
+// This is not a standalone file. It is to be appended to the end of the
+// merged IDL file.
+
+cpp_quote("")
+cpp_quote("// Type Library Definitions")
+cpp_quote("")
+
+[
+ uuid(CE3F726E-D1D3-44FE-B995-FF1DB3B48B2B),
+ helpstring("IAccessible2 Type Library"),
+ version(1.3),
+ hidden
+]
+
+library IAccessible2Lib
+{
+ importlib ("stdole2.tlb");
+ importlib ("oleacc.dll");
+ interface IAccessible2;
+ interface IAccessible2_2;
+ interface IAccessible2_3;
+ interface IAccessibleAction;
+ interface IAccessibleApplication;
+ interface IAccessibleComponent;
+ interface IAccessibleDocument;
+ interface IAccessibleEditableText;
+ interface IAccessibleHyperlink;
+ interface IAccessibleHypertext;
+ interface IAccessibleHypertext2;
+ interface IAccessibleImage;
+ interface IAccessibleRelation;
+ interface IAccessibleTable;
+ interface IAccessibleTable2;
+ interface IAccessibleTableCell;
+ interface IAccessibleText;
+ interface IAccessibleText2;
+ interface IAccessibleValue;
+ enum IA2CoordinateType;
+ enum IA2EventID;
+ enum IA2Role;
+ enum IA2ScrollType;
+ enum IA2States;
+ enum IA2TableModelChangeType;
+ enum IA2TextBoundaryType;
+ enum IA2TextSpecialOffsets;
+}
diff --git a/other-licenses/moz.build b/other-licenses/moz.build
new file mode 100644
index 0000000000..66da6b1bfd
--- /dev/null
+++ b/other-licenses/moz.build
@@ -0,0 +1,29 @@
+# -*- Mode: python; 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/.
+
+with Files('**'):
+ BUG_COMPONENT = ('Core', 'General')
+
+with Files('7zstub/**'):
+ BUG_COMPONENT = ('Firefox', 'Installer')
+
+with Files('atk-1.0/**'):
+ BUG_COMPONENT = ('Core', 'Disability Access APIs')
+
+with Files('bsdiff/**'):
+ BUG_COMPONENT = ('Core', 'XPCOM')
+
+with Files('ia2/**'):
+ BUG_COMPONENT = ('Core', 'Disability Access APIs')
+
+with Files('nsis/**'):
+ BUG_COMPONENT = ('Firefox', 'Installer')
+
+with Files('ply/**'):
+ BUG_COMPONENT = ('Core', 'JavaScript Engine')
+
+with Files('snappy/**'):
+ BUG_COMPONENT = ('Core', 'XPCOM')
diff --git a/other-licenses/nsis/Contrib/ApplicationID/ApplicationID.vcproj b/other-licenses/nsis/Contrib/ApplicationID/ApplicationID.vcproj
new file mode 100644
index 0000000000..6df3794340
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ApplicationID/ApplicationID.vcproj
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="ApplicationID"
+ ProjectGUID="{EBB19D89-C251-4281-BC02-04559F609530}"
+ RootNamespace="ApplicationID"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;APPLICATIONID_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ ATLMinimizesCRunTimeLibraryUsage="true"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;APPLICATIONID_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\Set.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\resource.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\ApplicationID.rc"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/other-licenses/nsis/Contrib/ApplicationID/Set.cpp b/other-licenses/nsis/Contrib/ApplicationID/Set.cpp
new file mode 100644
index 0000000000..82cb77e16f
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ApplicationID/Set.cpp
@@ -0,0 +1,219 @@
+/*
+ * Module : Set.cpp
+ * Purpose: NSIS Plug-in for setting shortcut ApplicationID property
+ * Created: 27/12/2009
+ * Original code Copyright (c) 2009 Mike Anchor.
+ */
+
+/*
+ * Additional Mozilla contributions:
+ * Unicode support
+ * Jump list deletion on uninstall
+ * Pinned item removal on uninstall
+ * contrib: <jmathies@mozilla.com>
+ */
+
+#define INITGUID
+
+#include <windows.h>
+#include <shlobj.h>
+#include <propvarutil.h>
+#include <propkey.h>
+#include <stdio.h>
+
+#pragma comment (lib, "shlwapi.lib")
+
+#define MAX_STRLEN 1024
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[MAX_PATH];
+} stack_t;
+
+stack_t **g_stacktop;
+unsigned int g_stringsize;
+TCHAR *g_variables;
+
+// Indicates that an application supports dual desktop and immersive modes. In Windows 8, this property is only applicable for web browsers.
+DEFINE_PROPERTYKEY(PKEY_AppUserModel_IsDualMode, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 11);
+
+int popstring(TCHAR *str, int len);
+void pushstring(const TCHAR *str, int len);
+
+extern "C" void __declspec(dllexport) Set(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
+{
+ g_stringsize = string_size;
+ g_stacktop = stacktop;
+ g_variables = variables;
+
+ {
+ IPropertyStore *m_pps = NULL;
+ WCHAR wszPath[MAX_PATH];
+ WCHAR wszAppID[MAX_PATH];
+ TCHAR szPath[MAX_PATH];
+ TCHAR szAppID[MAX_PATH];
+ TCHAR szDualMode[MAX_PATH];
+ bool success = false;
+
+ ZeroMemory(wszPath, sizeof(wszPath));
+ ZeroMemory(wszAppID, sizeof(wszAppID));
+ ZeroMemory(szPath, sizeof(szPath));
+ ZeroMemory(szAppID, sizeof(szAppID));
+ ZeroMemory(szDualMode, sizeof(szDualMode));
+
+ popstring(szPath, MAX_PATH);
+ popstring(szAppID, MAX_PATH);
+ bool dualMode = (popstring(szDualMode, MAX_PATH) == 0); // optional
+#if !defined(UNICODE)
+ MultiByteToWideChar(CP_ACP, 0, szPath, -1, wszPath, MAX_PATH);
+ MultiByteToWideChar(CP_ACP, 0, szAppID, -1, wszAppID, MAX_PATH);
+ if (dualMode && stricmp(szDualMode, "true") != 0) {
+ dualMode = false;
+ }
+#else
+ wcscpy_s(wszPath, szPath);
+ wcscpy_s(wszAppID, szAppID);
+ if (dualMode && _wcsicmp(szDualMode, L"true") != 0) {
+ dualMode = false;
+ }
+#endif
+
+ CoInitialize(NULL);
+
+ if (SUCCEEDED(SHGetPropertyStoreFromParsingName(wszPath, NULL, GPS_READWRITE, IID_PPV_ARGS(&m_pps))))
+ {
+ PROPVARIANT propvar;
+ if (SUCCEEDED(InitPropVariantFromString(wszAppID, &propvar))) {
+ if (SUCCEEDED(m_pps->SetValue(PKEY_AppUserModel_ID, propvar))) {
+ if (dualMode) {
+ InitPropVariantFromBoolean(true, &propvar);
+ m_pps->SetValue(PKEY_AppUserModel_IsDualMode, propvar);
+ }
+ if (SUCCEEDED(m_pps->Commit())) {
+ success = true;
+ }
+ }
+ }
+ }
+ if (m_pps != NULL)
+ m_pps->Release();
+
+ CoUninitialize();
+
+ pushstring(success == true ? TEXT("0") : TEXT("-1"), MAX_PATH);
+ }
+}
+
+extern "C" void __declspec(dllexport) UninstallJumpLists(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
+{
+ g_stringsize = string_size;
+ g_stacktop = stacktop;
+ g_variables = variables;
+
+ ICustomDestinationList *m_cdl = NULL;
+ WCHAR wszAppID[MAX_PATH];
+ TCHAR szAppID[MAX_PATH];
+ bool success = false;
+
+ ZeroMemory(wszAppID, sizeof(wszAppID));
+ ZeroMemory(szAppID, sizeof(szAppID));
+
+ popstring(szAppID, MAX_PATH);
+
+#if !defined(UNICODE)
+ MultiByteToWideChar(CP_ACP, 0, szAppID, -1, wszAppID, MAX_PATH);
+#else
+ wcscpy_s(wszAppID, szAppID);
+#endif
+
+ CoInitialize(NULL);
+
+ CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER,
+ IID_ICustomDestinationList, (void**)&m_cdl);
+
+ if (m_cdl) {
+ if (SUCCEEDED(m_cdl->DeleteList(wszAppID))) {
+ success = true;
+ }
+ }
+
+ if (m_cdl)
+ m_cdl->Release();
+
+ CoUninitialize();
+
+ pushstring(success == true ? TEXT("0") : TEXT("-1"), MAX_PATH);
+}
+
+extern "C" void __declspec(dllexport) UninstallPinnedItem(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
+{
+ g_stringsize = string_size;
+ g_stacktop = stacktop;
+ g_variables = variables;
+
+ IShellItem *pItem = NULL;
+ IStartMenuPinnedList *pPinnedList = NULL;
+ WCHAR wszPath[MAX_PATH];
+ TCHAR szPath[MAX_PATH];
+ bool success = false;
+
+ ZeroMemory(wszPath, sizeof(wszPath));
+ ZeroMemory(szPath, sizeof(szPath));
+
+ popstring(szPath, MAX_PATH);
+
+#if !defined(UNICODE)
+ MultiByteToWideChar(CP_ACP, 0, szPath, -1, wszPath, MAX_PATH);
+#else
+ wcscpy_s(wszPath, szPath);
+#endif
+
+ CoInitialize(NULL);
+
+ HRESULT hr;
+ hr = SHCreateItemFromParsingName(wszPath, NULL, IID_PPV_ARGS(&pItem));
+
+ if (SUCCEEDED(hr)) {
+
+ hr = CoCreateInstance(CLSID_StartMenuPin,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_PPV_ARGS(&pPinnedList));
+
+ if (SUCCEEDED(hr)) {
+ hr = pPinnedList->RemoveFromList(pItem);
+ pPinnedList->Release();
+ success = true;
+ }
+
+ pItem->Release();
+ }
+
+ CoUninitialize();
+
+ pushstring(success == true ? TEXT("0") : TEXT("-1"), MAX_PATH);
+}
+
+//Function: Removes the element from the top of the NSIS stack and puts it in the buffer
+int popstring(TCHAR *str, int len)
+{
+ stack_t *th;
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th=(*g_stacktop);
+ lstrcpyn(str,th->text, len);
+ *g_stacktop=th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+//Function: Adds an element to the top of the NSIS stack
+void pushstring(const TCHAR *str, int len)
+{
+ stack_t *th;
+
+ if (!g_stacktop) return;
+ th=(stack_t*)GlobalAlloc(GPTR, sizeof(stack_t) + len);
+ lstrcpyn(th->text, str, len);
+ th->next=*g_stacktop;
+ *g_stacktop=th;
+}
diff --git a/other-licenses/nsis/Contrib/BitsUtils/BitsUtils.cpp b/other-licenses/nsis/Contrib/BitsUtils/BitsUtils.cpp
new file mode 100644
index 0000000000..aea1f270ea
--- /dev/null
+++ b/other-licenses/nsis/Contrib/BitsUtils/BitsUtils.cpp
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 <windows.h>
+#include <bits.h>
+#include <utility>
+
+// Avoid conversions, we will only build Unicode anyway.
+#if !(defined(UNICODE) && defined(_UNICODE))
+# error "Unicode required"
+#endif
+
+static HINSTANCE gHInst;
+
+// ***** Section: ScopeExit
+// Derived from mfbt mozilla::ScopeExit, I have removed the use of
+// GuardObjectNotifier and the MOZ_* annotations.
+template <typename ExitFunction>
+class ScopeExit {
+ ExitFunction mExitFunction;
+ bool mExecuteOnDestruction;
+
+ public:
+ explicit ScopeExit(ExitFunction &&cleanup)
+ : mExitFunction(cleanup), mExecuteOnDestruction(true) {}
+
+ ScopeExit(ScopeExit &&rhs)
+ : mExitFunction(std::move(rhs.mExitFunction)),
+ mExecuteOnDestruction(rhs.mExecuteOnDestruction) {
+ rhs.release();
+ }
+
+ ~ScopeExit() {
+ if (mExecuteOnDestruction) {
+ mExitFunction();
+ }
+ }
+
+ void release() { mExecuteOnDestruction = false; }
+
+ private:
+ explicit ScopeExit(const ScopeExit &) = delete;
+ ScopeExit &operator=(const ScopeExit &) = delete;
+ ScopeExit &operator=(ScopeExit &&) = delete;
+};
+
+template <typename ExitFunction>
+ScopeExit<ExitFunction> MakeScopeExit(ExitFunction &&exitFunction) {
+ return ScopeExit<ExitFunction>(std::move(exitFunction));
+}
+
+// ***** Section: NSIS stack
+typedef struct _stack_t {
+ struct _stack_t *next;
+ WCHAR text[1]; // this should be the length of g_stringsize when allocating
+} stack_t;
+
+static unsigned int g_stringsize;
+static stack_t **g_stacktop;
+
+static int popstringn(LPWSTR str, int maxlen) {
+ stack_t *th;
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th = (*g_stacktop);
+ if (str) lstrcpynW(str, th->text, maxlen ? maxlen : g_stringsize);
+ *g_stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+static void pushstring(LPCWSTR str) {
+ stack_t *th;
+ if (!g_stacktop) return;
+ th = (stack_t *)GlobalAlloc(
+ GPTR, (sizeof(stack_t) + (g_stringsize) * sizeof(*str)));
+ lstrcpynW(th->text, str, g_stringsize);
+ th->next = *g_stacktop;
+ *g_stacktop = th;
+}
+
+// ***** Section: NSIS Plug-In API (from NSIS api.h)
+// NSIS Plug-In Callback Messages
+enum NSPIM {
+ NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
+ NSPIM_GUIUNLOAD, // Called after .onGUIEnd
+};
+
+// Prototype for callbacks registered with
+// extra_parameters->RegisterPluginCallback() Return NULL for unknown messages
+// Should always be __cdecl for future expansion possibilities
+typedef UINT_PTR (*NSISPLUGINCALLBACK)(enum NSPIM);
+
+#define NSISCALL __stdcall
+
+typedef struct {
+ LPVOID exec_flags;
+ int(NSISCALL *ExecuteCodeSegment)(int, HWND);
+ void(NSISCALL *validate_filename)(LPWSTR);
+ int(NSISCALL *RegisterPluginCallback)(
+ HMODULE, NSISPLUGINCALLBACK); // returns 0 on success, 1 if already
+ // registered and < 0 on errors
+} extra_parameters;
+
+// ***** Section: StartBitsThread
+UINT_PTR __cdecl NSISPluginCallback(NSPIM msg);
+
+static struct {
+ HANDLE thread;
+ bool shutdown_requested;
+ CRITICAL_SECTION cs;
+ CONDITION_VARIABLE cv;
+} gStartBitsThread = {nullptr, false, 0, 0};
+
+// This thread connects to the BackgroundCopyManager, which may take some time
+// if the BITS service is not already running. It also holds open the connection
+// until gStartBitsThread.shutdown_requested becomes true.
+DWORD WINAPI StartBitsThreadProc(LPVOID) {
+ EnterCriticalSection(&gStartBitsThread.cs);
+ auto leaveCS =
+ MakeScopeExit([] { LeaveCriticalSection(&gStartBitsThread.cs); });
+
+ if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) {
+ return 0;
+ }
+ auto coUninit = MakeScopeExit([] { CoUninitialize(); });
+
+ IBackgroundCopyManager *bcm = nullptr;
+ if (FAILED(CoCreateInstance(
+ __uuidof(BackgroundCopyManager), nullptr, CLSCTX_LOCAL_SERVER,
+ __uuidof(IBackgroundCopyManager), (LPVOID *)&bcm)) ||
+ !bcm) {
+ return 0;
+ }
+
+ do {
+ SleepConditionVariableCS(&gStartBitsThread.cv, &gStartBitsThread.cs,
+ INFINITE);
+ } while (!gStartBitsThread.shutdown_requested);
+
+ bcm->Release();
+ return 1;
+}
+
+// Start up the thread
+// returns true on success
+bool StartBitsServiceBackgroundThreadImpl(extra_parameters *extra_params) {
+ EnterCriticalSection(&gStartBitsThread.cs);
+ auto leaveCS =
+ MakeScopeExit([] { LeaveCriticalSection(&gStartBitsThread.cs); });
+
+ if (gStartBitsThread.thread) {
+ // Thread is already started, assumed to be still running.
+ return true;
+ }
+
+ // Ensure the callback is registered so the thread can be stopped, and also so
+ // NSIS doesn't unload this DLL.
+ extra_params->RegisterPluginCallback(gHInst, NSISPluginCallback);
+
+ gStartBitsThread.shutdown_requested = false;
+
+ gStartBitsThread.thread =
+ CreateThread(nullptr, 0, StartBitsThreadProc, nullptr, 0, 0);
+ if (!gStartBitsThread.thread) {
+ return false;
+ }
+
+ return true;
+}
+
+// Shut down the Start BITS thread, if it was started.
+void ShutdownStartBitsThread() {
+ EnterCriticalSection(&gStartBitsThread.cs);
+ if (gStartBitsThread.thread) {
+ gStartBitsThread.shutdown_requested = true;
+ WakeAllConditionVariable(&gStartBitsThread.cv);
+ LeaveCriticalSection(&gStartBitsThread.cs);
+
+ // Give the thread a little time to clean up.
+ if (WaitForSingleObject(gStartBitsThread.thread, 1000) == WAIT_OBJECT_0) {
+ EnterCriticalSection(&gStartBitsThread.cs);
+ gStartBitsThread.thread = nullptr;
+ LeaveCriticalSection(&gStartBitsThread.cs);
+ } else {
+ // Don't attempt to recover if we didn't see the thread end,
+ // the process will be exiting soon anyway.
+ }
+
+ } else {
+ LeaveCriticalSection(&gStartBitsThread.cs);
+ }
+}
+
+// ***** Section: CancelBitsJobsByName
+#define MAX_JOB_NAME 256
+
+bool CancelBitsJobsByNameImpl(LPWSTR matchJobName) {
+ if (FAILED(CoInitialize(nullptr))) {
+ return false;
+ }
+ auto coUninit = MakeScopeExit([] { CoUninitialize(); });
+
+ IBackgroundCopyManager *bcm = nullptr;
+ if (FAILED(CoCreateInstance(
+ __uuidof(BackgroundCopyManager), nullptr, CLSCTX_LOCAL_SERVER,
+ __uuidof(IBackgroundCopyManager), (LPVOID *)&bcm)) ||
+ !bcm) {
+ return false;
+ }
+ auto bcmRelease = MakeScopeExit([bcm] { bcm->Release(); });
+
+ IEnumBackgroundCopyJobs *enumerator = nullptr;
+ // Attempt to enumerate jobs for all users. If that fails,
+ // try for only the current user.
+ if (FAILED(bcm->EnumJobs(BG_JOB_ENUM_ALL_USERS, &enumerator))) {
+ enumerator = nullptr;
+ if (FAILED(bcm->EnumJobs(0, &enumerator))) {
+ return false;
+ }
+ }
+ if (!enumerator) {
+ return false;
+ }
+ auto enumeratorRelease =
+ MakeScopeExit([enumerator] { enumerator->Release(); });
+
+ bool success = true;
+
+ IBackgroundCopyJob *job = nullptr;
+ HRESULT nextResult;
+ while ((nextResult = enumerator->Next(1, &job, nullptr),
+ SUCCEEDED(nextResult))) {
+ if (nextResult == S_FALSE) {
+ break;
+ }
+ if (!job) {
+ success = false;
+ break;
+ }
+
+ LPWSTR curJobName = nullptr;
+
+ if (SUCCEEDED(job->GetDisplayName(&curJobName)) && curJobName) {
+ if (lstrcmpW(curJobName, matchJobName) == 0) {
+ if (!SUCCEEDED(job->Cancel())) {
+ // If we can't cancel we can still try the other jobs.
+ success = false;
+ }
+ }
+ CoTaskMemFree((LPVOID)curJobName);
+ curJobName = nullptr;
+ } else {
+ // We may not be able to access certain jobs, keep trying the rest.
+ success = false;
+ }
+
+ job->Release();
+ job = nullptr;
+ }
+
+ if (!SUCCEEDED(nextResult)) {
+ success = false;
+ }
+
+ return success;
+}
+
+// ***** Section: DLL entry points
+extern "C" {
+// Cancel all BITS jobs with the given name.
+void __declspec(dllexport)
+ CancelBitsJobsByName(HWND hwndParent, int string_size, char *variables,
+ stack_t **stacktop, extra_parameters *) {
+ g_stacktop = stacktop;
+ g_stringsize = string_size;
+
+ WCHAR matchJobName[MAX_JOB_NAME + 1];
+ matchJobName[0] = L'\0';
+
+ if (!popstringn(matchJobName, sizeof(matchJobName) / sizeof(WCHAR))) {
+ if (CancelBitsJobsByNameImpl(matchJobName)) {
+ pushstring(L"ok");
+ return;
+ }
+ }
+
+ pushstring(L"error");
+}
+
+// Start the BITS service in the background, and hold a reference to it until
+// the (un)installer exits.
+// Does not provide any feedback or touch the stack.
+void __declspec(dllexport)
+ StartBitsServiceBackground(HWND, int, char *, stack_t **,
+ extra_parameters *extra_params) {
+ StartBitsServiceBackgroundThreadImpl(extra_params);
+}
+}
+
+// Handle messages from NSIS
+UINT_PTR __cdecl NSISPluginCallback(NSPIM msg) {
+ if (msg == NSPIM_UNLOAD) {
+ ShutdownStartBitsThread();
+ }
+ return 0;
+}
+
+BOOL APIENTRY DllMain(HINSTANCE instance, DWORD reason, LPVOID) {
+ if (reason == DLL_PROCESS_ATTACH) {
+ gHInst = instance;
+ InitializeConditionVariable(&gStartBitsThread.cv);
+ InitializeCriticalSection(&gStartBitsThread.cs);
+ }
+ return TRUE;
+}
diff --git a/other-licenses/nsis/Contrib/BitsUtils/BitsUtils.sln b/other-licenses/nsis/Contrib/BitsUtils/BitsUtils.sln
new file mode 100644
index 0000000000..5e0311a9b2
--- /dev/null
+++ b/other-licenses/nsis/Contrib/BitsUtils/BitsUtils.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.271
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BitsUtils", "BitsUtils.vcxproj", "{5058AAED-D02A-4F86-B011-31516AB5CD63}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {5058AAED-D02A-4F86-B011-31516AB5CD63}.Release|x86.ActiveCfg = Release|Win32
+ {5058AAED-D02A-4F86-B011-31516AB5CD63}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {53DD94C2-CC74-40B7-B9B7-08AD945C28F3}
+ EndGlobalSection
+EndGlobal
diff --git a/other-licenses/nsis/Contrib/BitsUtils/BitsUtils.vcxproj b/other-licenses/nsis/Contrib/BitsUtils/BitsUtils.vcxproj
new file mode 100644
index 0000000000..71520de97e
--- /dev/null
+++ b/other-licenses/nsis/Contrib/BitsUtils/BitsUtils.vcxproj
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{5058AAED-D02A-4F86-B011-31516AB5CD63}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>BitsUtils</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>WINVER=0x601;_WIN32_WINNT=0x601;WIN32;NDEBUG;CANCELBITSJOBS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <ExceptionHandling>false</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="BitsUtils.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
diff --git a/other-licenses/nsis/Contrib/CertCheck/CertCheck.cpp b/other-licenses/nsis/Contrib/CertCheck/CertCheck.cpp
new file mode 100644
index 0000000000..e79f19a615
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CertCheck/CertCheck.cpp
@@ -0,0 +1,411 @@
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+#include <softpub.h>
+#include <wintrust.h>
+
+#pragma comment(lib, "wintrust.lib")
+#pragma comment(lib, "crypt32.lib")
+
+#ifndef UNICODE
+#error "This file only supports building in Unicode mode"
+#endif
+
+static const int ENCODING = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
+
+// The definitions for NSPIM, the callback typedef, and
+// extra_parameters all come from the NSIS plugin API source.
+enum NSPIM
+{
+ NSPIM_UNLOAD,
+ NSPIM_GUIUNLOAD,
+};
+
+typedef UINT_PTR(*NSISPLUGINCALLBACK)(enum NSPIM);
+
+struct extra_parameters
+{
+ // The real type of exec_flags is exec_flags_t*, which is a large struct
+ // whose definition is omitted here because this plugin doesn't need it.
+ void* exec_flags;
+ int (__stdcall *ExecuteCodeSegment)(int, HWND);
+ void (__stdcall *validate_filename)(TCHAR*);
+ int (__stdcall *RegisterPluginCallback)(HMODULE, NSISPLUGINCALLBACK);
+};
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[MAX_PATH];
+} stack_t;
+
+int popstring(stack_t **stacktop, LPTSTR str, int len);
+void pushstring(stack_t **stacktop, LPCTSTR str, int len);
+
+struct CertificateCheckInfo
+{
+ wchar_t filePath[MAX_PATH];
+ wchar_t name[MAX_PATH];
+ wchar_t issuer[MAX_PATH];
+};
+
+static HINSTANCE gHInst;
+static HANDLE gCheckThread;
+static HANDLE gCheckEvent;
+static bool gCheckTrustPassed;
+static bool gCheckAttributesPassed;
+
+// We need a plugin callback not only to clean up our thread, but also
+// because registering a callback prevents NSIS from unloading the DLL
+// after each call from the script.
+UINT_PTR __cdecl
+NSISPluginCallback(NSPIM event)
+{
+ if (event == NSPIM_UNLOAD){
+ if (gCheckThread != NULL &&
+ WaitForSingleObject(gCheckThread, 0) != WAIT_OBJECT_0) {
+ TerminateThread(gCheckThread, ERROR_OPERATION_ABORTED);
+ }
+ CloseHandle(gCheckThread);
+ gCheckThread = NULL;
+ CloseHandle(gCheckEvent);
+ gCheckEvent = NULL;
+ }
+ return NULL;
+}
+
+/**
+ * Checks to see if a file stored at filePath matches the specified info. This
+ * only supports the name and issuer attributes currently.
+ *
+ * @param certContext The certificate context of the file
+ * @param infoToMatch The acceptable information to match
+ * @return FALSE if the info does not match or if any error occurs in the check
+ */
+BOOL
+DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
+ CertificateCheckInfo* infoToMatch)
+{
+ DWORD dwData;
+ LPTSTR szName = NULL;
+
+ // Pass in NULL to get the needed size of the issuer buffer.
+ dwData = CertGetNameString(certContext,
+ CERT_NAME_SIMPLE_DISPLAY_TYPE,
+ CERT_NAME_ISSUER_FLAG, NULL,
+ NULL, 0);
+
+ if (!dwData) {
+ return FALSE;
+ }
+
+ // Allocate memory for Issuer name buffer.
+ szName = (LPTSTR)LocalAlloc(LPTR, dwData * sizeof(WCHAR));
+ if (!szName) {
+ return FALSE;
+ }
+
+ // Get Issuer name.
+ if (!CertGetNameString(certContext, CERT_NAME_SIMPLE_DISPLAY_TYPE,
+ CERT_NAME_ISSUER_FLAG, NULL, szName, dwData)) {
+ LocalFree(szName);
+ return FALSE;
+ }
+
+ // If the issuer does not match, return a failure.
+ if (!infoToMatch->issuer ||
+ wcscmp(szName, infoToMatch->issuer)) {
+ LocalFree(szName);
+ return FALSE;
+ }
+
+ LocalFree(szName);
+ szName = NULL;
+
+ // Pass in NULL to get the needed size of the name buffer.
+ dwData = CertGetNameString(certContext, CERT_NAME_SIMPLE_DISPLAY_TYPE,
+ 0, NULL, NULL, 0);
+ if (!dwData) {
+ return FALSE;
+ }
+
+ // Allocate memory for the name buffer.
+ szName = (LPTSTR)LocalAlloc(LPTR, dwData * sizeof(WCHAR));
+ if (!szName) {
+ return FALSE;
+ }
+
+ // Obtain the name.
+ if (!(CertGetNameString(certContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
+ NULL, szName, dwData))) {
+ LocalFree(szName);
+ return FALSE;
+ }
+
+ // If the issuer does not match, return a failure.
+ if (!infoToMatch->name ||
+ wcscmp(szName, infoToMatch->name)) {
+ LocalFree(szName);
+ return FALSE;
+ }
+
+ // We have a match!
+ LocalFree(szName);
+
+ // If there were any errors we would have aborted by now.
+ return TRUE;
+}
+
+/**
+ * Checks to see if a file's signing cert matches the specified info. This
+ * only supports the name and issuer attributes currently.
+ *
+ * @param info The acceptable information to match
+ * @return ERROR_SUCCESS if successful, ERROR_NOT_FOUND if the info
+ * does not match, or the last error otherwise.
+ */
+DWORD
+CheckCertificateInfoForPEFile(CertificateCheckInfo* info)
+{
+ HCERTSTORE certStore = NULL;
+ HCRYPTMSG cryptMsg = NULL;
+ PCCERT_CONTEXT certContext = NULL;
+ PCMSG_SIGNER_INFO signerInfo = NULL;
+ DWORD lastError = ERROR_SUCCESS;
+
+ // Get the HCERTSTORE and HCRYPTMSG from the signed file.
+ DWORD encoding, contentType, formatType;
+ BOOL result = CryptQueryObject(CERT_QUERY_OBJECT_FILE,
+ info->filePath,
+ CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,
+ CERT_QUERY_CONTENT_FLAG_ALL,
+ 0, &encoding, &contentType,
+ &formatType, &certStore, &cryptMsg, NULL);
+ if (!result) {
+ lastError = GetLastError();
+ goto cleanup;
+ }
+
+ // Pass in NULL to get the needed signer information size.
+ DWORD signerInfoSize;
+ result = CryptMsgGetParam(cryptMsg, CMSG_SIGNER_INFO_PARAM, 0,
+ NULL, &signerInfoSize);
+ if (!result) {
+ lastError = GetLastError();
+ goto cleanup;
+ }
+
+ // Allocate the needed size for the signer information.
+ signerInfo = (PCMSG_SIGNER_INFO)LocalAlloc(LPTR, signerInfoSize);
+ if (!signerInfo) {
+ lastError = GetLastError();
+ goto cleanup;
+ }
+
+ // Get the signer information (PCMSG_SIGNER_INFO).
+ // In particular we want the issuer and serial number.
+ result = CryptMsgGetParam(cryptMsg, CMSG_SIGNER_INFO_PARAM, 0,
+ (PVOID)signerInfo, &signerInfoSize);
+ if (!result) {
+ lastError = GetLastError();
+ goto cleanup;
+ }
+
+ // Search for the signer certificate in the certificate store.
+ CERT_INFO certInfo;
+ certInfo.Issuer = signerInfo->Issuer;
+ certInfo.SerialNumber = signerInfo->SerialNumber;
+ certContext = CertFindCertificateInStore(certStore, ENCODING, 0,
+ CERT_FIND_SUBJECT_CERT,
+ (PVOID)&certInfo, NULL);
+ if (!certContext) {
+ lastError = GetLastError();
+ goto cleanup;
+ }
+
+ if (!DoCertificateAttributesMatch(certContext, info)) {
+ lastError = ERROR_NOT_FOUND;
+ goto cleanup;
+ }
+
+cleanup:
+ if (signerInfo) {
+ LocalFree(signerInfo);
+ }
+ if (certContext) {
+ CertFreeCertificateContext(certContext);
+ }
+ if (certStore) {
+ CertCloseStore(certStore, 0);
+ }
+ if (cryptMsg) {
+ CryptMsgClose(cryptMsg);
+ }
+ return lastError;
+}
+
+/**
+ * Verifies the trust of a signed file's certificate.
+ *
+ * @param filePath The file path to check.
+ * @return ERROR_SUCCESS if successful, or the last error code otherwise.
+ */
+DWORD
+VerifyCertificateTrustForFile(LPCWSTR filePath)
+{
+ // Setup the file to check.
+ WINTRUST_FILE_INFO fileToCheck;
+ ZeroMemory(&fileToCheck, sizeof(fileToCheck));
+ fileToCheck.cbStruct = sizeof(WINTRUST_FILE_INFO);
+ fileToCheck.pcwszFilePath = filePath;
+
+ // Setup what to check, we want to check it is signed and trusted.
+ WINTRUST_DATA trustData;
+ // ZeroMemory should be fine here, but the compiler converts that into a
+ // call to memset, and we're avoiding the C runtime to keep file size down.
+ SecureZeroMemory(&trustData, sizeof(trustData));
+ trustData.cbStruct = sizeof(trustData);
+ trustData.dwUIChoice = WTD_UI_NONE;
+ trustData.dwUnionChoice = WTD_CHOICE_FILE;
+ trustData.pFile = &fileToCheck;
+
+ GUID policyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
+ // Check if the file is signed by something that is trusted.
+ LONG ret = WinVerifyTrust(NULL, &policyGUID, &trustData);
+ return ret;
+}
+
+/**
+ * Synchronously verifies the trust and attributes of a signed PE file.
+ * Meant to be invoked as a thread entry point from CheckPETrustAndInfoAsync.
+ */
+DWORD WINAPI
+VerifyCertThreadProc(void* info)
+{
+ CertificateCheckInfo* certInfo = (CertificateCheckInfo*)info;
+
+ if (VerifyCertificateTrustForFile(certInfo->filePath) == ERROR_SUCCESS) {
+ gCheckTrustPassed = true;
+ }
+
+ if (CheckCertificateInfoForPEFile(certInfo) == ERROR_SUCCESS) {
+ gCheckAttributesPassed = true;
+ }
+
+ LocalFree(info);
+ SetEvent(gCheckEvent);
+ return 0;
+}
+
+/**
+ * Verifies the trust and the attributes of a signed PE file's certificate on
+* a separate thread. Returns immediately upon starting that thread.
+ * Call GetStatus (repeatedly if necessary) to get the result of the checks.
+ *
+ * @param stacktop A pointer to the NSIS stack.
+ * From the top down, the stack should contain:
+ * 1) the path to the file that will have its trust verified
+ * 2) the expected certificate subject common name
+ * 3) the expected certificate issuer common name
+ */
+extern "C" void __declspec(dllexport)
+CheckPETrustAndInfoAsync(HWND, int, TCHAR*, stack_t **stacktop, extra_parameters* pX)
+{
+ pX->RegisterPluginCallback(gHInst, NSISPluginCallback);
+
+ gCheckTrustPassed = false;
+ gCheckAttributesPassed = false;
+ gCheckThread = nullptr;
+
+ CertificateCheckInfo* certInfo =
+ (CertificateCheckInfo*)LocalAlloc(0, sizeof(CertificateCheckInfo));
+ if (certInfo) {
+ popstring(stacktop, certInfo->filePath, MAX_PATH);
+ popstring(stacktop, certInfo->name, MAX_PATH);
+ popstring(stacktop, certInfo->issuer, MAX_PATH);
+
+ gCheckThread = CreateThread(nullptr, 0, VerifyCertThreadProc,
+ (void*)certInfo, 0, nullptr);
+ }
+ if (!gCheckThread) {
+ LocalFree(certInfo);
+ SetEvent(gCheckEvent);
+ }
+}
+
+/**
+ * Returns the result of a certificate check on the NSIS stack.
+ *
+ * If the check is not yet finished, will push "0" to the stack.
+ * If the check is finished, the top of the stack will be "1", followed by:
+ * "1" if the certificate is trusted by the system, "0" if not. Then:
+ * "1" if the certificate attributes matched those provided, "0" if not.
+ */
+extern "C" void __declspec(dllexport)
+GetStatus(HWND, int, TCHAR*, stack_t **stacktop, void*)
+{
+ if (WaitForSingleObject(gCheckEvent, 0) == WAIT_OBJECT_0) {
+ pushstring(stacktop, gCheckAttributesPassed ? L"1" : L"0", 2);
+ pushstring(stacktop, gCheckTrustPassed ? L"1" : L"0", 2);
+ pushstring(stacktop, L"1", 2);
+ } else {
+ pushstring(stacktop, L"0", 2);
+ }
+}
+
+BOOL WINAPI
+DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID)
+{
+ if (fdwReason == DLL_PROCESS_ATTACH) {
+ gHInst = hInst;
+ gCheckEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ }
+ return TRUE;
+}
+
+/**
+ * Removes an element from the top of the NSIS stack
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param str The string to pop to
+ * @param len The max length
+ * @return 0 on success
+*/
+int popstring(stack_t **stacktop, LPTSTR str, int len)
+{
+ // Removes the element from the top of the stack and puts it in the buffer
+ stack_t *th;
+ if (!stacktop || !*stacktop) {
+ return 1;
+ }
+
+ th = (*stacktop);
+ lstrcpyn(str,th->text, len);
+ *stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+/**
+ * Adds an element to the top of the NSIS stack
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param str The string to push on the stack
+ * @param len The length of the string to push on the stack
+ * @return 0 on success
+*/
+void pushstring(stack_t **stacktop, LPCTSTR str, int len)
+{
+ stack_t *th;
+ if (!stacktop) {
+ return;
+ }
+
+ th = (stack_t*)GlobalAlloc(GPTR, sizeof(stack_t) + len);
+ lstrcpyn(th->text, str, len);
+ th->next = *stacktop;
+ *stacktop = th;
+}
diff --git a/other-licenses/nsis/Contrib/CertCheck/CertCheck.sln b/other-licenses/nsis/Contrib/CertCheck/CertCheck.sln
new file mode 100644
index 0000000000..5a92a248c4
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CertCheck/CertCheck.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27428.2015
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{D94576A7-B8CF-4E2C-AAF3-89213C9F3F4C}") = "CertCheck", "CertCheck.vcxproj", "{83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}.Debug|x64.ActiveCfg = Debug|x64
+ {83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}.Debug|x64.Build.0 = Debug|x64
+ {83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}.Debug|x86.ActiveCfg = Debug|Win32
+ {83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}.Debug|x86.Build.0 = Debug|Win32
+ {83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}.Release|x64.ActiveCfg = Release|x64
+ {83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}.Release|x64.Build.0 = Release|x64
+ {83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}.Release|x86.ActiveCfg = Release|Win32
+ {83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {182ECAA2-6C57-480C-B5B7-9FFF56875051}
+ EndGlobalSection
+EndGlobal
diff --git a/other-licenses/nsis/Contrib/CertCheck/CertCheck.vcxproj b/other-licenses/nsis/Contrib/CertCheck/CertCheck.vcxproj
new file mode 100644
index 0000000000..9062b38a40
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CertCheck/CertCheck.vcxproj
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{83D56BCB-B9D1-44AB-BC96-9EA8A645CB0D}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>CertCheck</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>WIN32;_DEBUG;CERTCHECK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>_DEBUG;CERTCHECK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>WIN32;NDEBUG;CERTCHECK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>NDEBUG;CERTCHECK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="CertCheck.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/other-licenses/nsis/Contrib/CityHash/CityHash.cpp b/other-licenses/nsis/Contrib/CityHash/CityHash.cpp
new file mode 100644
index 0000000000..9998fb627d
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CityHash/CityHash.cpp
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 "CityHash.h"
+#include "cityhash/city.h"
+#include <tchar.h>
+
+#define MAX_STRLEN 1024
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[MAX_STRLEN];
+} stack_t;
+
+stack_t **g_stacktop;
+char *g_variables;
+
+BOOL APIENTRY DllMain(HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved)
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
+
+bool popString(TCHAR *result)
+{
+ stack_t *th;
+ if (!g_stacktop || !*g_stacktop) return false;
+ th = (*g_stacktop);
+ lstrcpyn(result, th->text, MAX_STRLEN);
+ *g_stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return true;
+}
+
+void pushString(const TCHAR *str)
+{
+ stack_t *th;
+ int strLen = wcslen(str)+1;
+ if (!g_stacktop) return;
+ th = (stack_t*)GlobalAlloc(GPTR, sizeof(stack_t) + (MAX_STRLEN*sizeof(TCHAR)));
+ lstrcpyn(th->text, str, strLen);
+ th->next = *g_stacktop;
+ *g_stacktop = th;
+}
+
+extern "C"
+{
+
+void GetCityHash64(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
+{
+ TCHAR hashString[MAX_STRLEN];
+ TCHAR hexResult[18] = { _T('\0') };
+
+ g_stacktop = stacktop;
+ g_variables = variables;
+
+ memset(hashString, 0, sizeof(hashString));
+ memset(hexResult, 0, sizeof(hexResult));
+
+ if (!popString(hashString)) {
+ pushString(L"error");
+ return;
+ }
+ uint64 result = CityHash64((const char*)&hashString[0], wcslen(hashString)*sizeof(TCHAR));
+ // If the hash happens to work out to less than 16 hash digits it will just
+ // use less of the buffer.
+ swprintf(hexResult, L"%I64X", result);
+ pushString(hexResult);
+}
+
+}
diff --git a/other-licenses/nsis/Contrib/CityHash/CityHash.def b/other-licenses/nsis/Contrib/CityHash/CityHash.def
new file mode 100644
index 0000000000..61acb6e427
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CityHash/CityHash.def
@@ -0,0 +1,3 @@
+LIBRARY CityHash
+EXPORTS
+ GetCityHash64 @1
diff --git a/other-licenses/nsis/Contrib/CityHash/CityHash.dsp b/other-licenses/nsis/Contrib/CityHash/CityHash.dsp
new file mode 100644
index 0000000000..2113913549
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CityHash/CityHash.dsp
@@ -0,0 +1,159 @@
+# Microsoft Developer Studio Project File - Name="CityHash" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=CityHash - Win32 Debug Unicode
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "CityHash.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "CityHash.mak" CFG="CityHash - Win32 Debug Unicode"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "CityHash - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "CityHash - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "CityHash - Win32 Release Unicode" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "CityHash - Win32 Debug Unicode" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "CityHash - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CityHash_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CityHash_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"DllMain" /dll /machine:I386 /nodefaultlib /out:"../../Plugins/CityHash.dll" /opt:nowin98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "CityHash - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CityHash_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CityHash_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "CityHash - Win32 Release Unicode"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "CityHash___Win32_Release_Unicode"
+# PROP BASE Intermediate_Dir "CityHash___Win32_Release_Unicode"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_Unicode"
+# PROP Intermediate_Dir "Release_Unicode"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CityHash_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O1 /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CityHash_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"DllMain" /dll /machine:I386 /nodefaultlib /out:"../../Plugins/CityHash.dll" /opt:nowin98
+# SUBTRACT BASE LINK32 /pdb:none
+# ADD LINK32 wininet.lib kernel32.lib user32.lib gdi32.lib winspool.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"DllMain" /dll /machine:I386 /out:"./Unicode/CityHash.dll" /opt:nowin98
+# SUBTRACT LINK32 /pdb:none /nodefaultlib
+
+!ELSEIF "$(CFG)" == "CityHash - Win32 Debug Unicode"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "CityHash___Win32_Debug_Unicode"
+# PROP BASE Intermediate_Dir "CityHash___Win32_Debug_Unicode"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug_Unicode"
+# PROP Intermediate_Dir "Debug_Unicode"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CityHash_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CityHash_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "CityHash - Win32 Release"
+# Name "CityHash - Win32 Debug"
+# Name "CityHash - Win32 Release Unicode"
+# Name "CityHash - Win32 Debug Unicode"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\CityHash.cpp
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/other-licenses/nsis/Contrib/CityHash/CityHash.dsw b/other-licenses/nsis/Contrib/CityHash/CityHash.dsw
new file mode 100644
index 0000000000..5a77a3c94b
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CityHash/CityHash.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "CityHash"=.\CityHash.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/other-licenses/nsis/Contrib/CityHash/CityHash.h b/other-licenses/nsis/Contrib/CityHash/CityHash.h
new file mode 100755
index 0000000000..4daa91d294
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CityHash/CityHash.h
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 WINVER
+#define WINVER 0x0600
+#endif
+
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#endif
+
+#ifndef _WIN32_WINDOWS
+#define _WIN32_WINDOWS 0x0410
+#endif
+
+#ifndef _WIN32_IE
+#define _WIN32_IE 0x0700
+#endif
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+
+#ifdef CITYHASH_EXPORTS
+#define CITYHASH_API __declspec(dllexport)
+#else
+#define CITYHASH_API __declspec(dllimport)
+#endif
diff --git a/other-licenses/nsis/Contrib/CityHash/CityHash.vcproj b/other-licenses/nsis/Contrib/CityHash/CityHash.vcproj
new file mode 100644
index 0000000000..21f4533aca
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CityHash/CityHash.vcproj
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="CityHash"
+ ProjectGUID="{D98B80BB-829B-4739-9F93-EFF7D01C69CC}"
+ RootNamespace="CityHash"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CITYHASH_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CITYHASH_EXPORTS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\cityhash\city.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CityHash.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ CompileAsManaged="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ CompileAsManaged="0"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\cityhash\city.h"
+ >
+ </File>
+ <File
+ RelativePath=".\CityHash.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/other-licenses/nsis/Contrib/CityHash/cityhash/city.cpp b/other-licenses/nsis/Contrib/CityHash/cityhash/city.cpp
new file mode 100755
index 0000000000..f34777eb84
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CityHash/cityhash/city.cpp
@@ -0,0 +1,322 @@
+// Copyright (c) 2011 Google, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+// CityHash Version 1, by Geoff Pike and Jyrki Alakuijala
+//
+// This file provides CityHash64() and related functions.
+//
+// It's probably possible to create even faster hash functions by
+// writing a program that systematically explores some of the space of
+// possible hash functions, by using SIMD instructions, or by
+// compromising on hash quality.
+
+#include "city.h"
+
+#include <algorithm>
+
+using namespace std;
+
+#if __sparc__
+#include <string.h>
+static inline uint64 UNALIGNED_LOAD64(const char *p) {
+ uint64 val;
+ memcpy(&val, p, sizeof(uint64));
+ return val;
+}
+
+static inline uint32 UNALIGNED_LOAD32(const char *p) {
+ uint32 val;
+ memcpy(&val, p, sizeof(uint32));
+ return val;
+}
+#else
+#define UNALIGNED_LOAD64(p) (*(const uint64*)(p))
+#define UNALIGNED_LOAD32(p) (*(const uint32*)(p))
+#endif
+
+#if !defined(LIKELY)
+#if defined(__GNUC__)
+#define LIKELY(x) (__builtin_expect(!!(x), 1))
+#else
+#define LIKELY(x) (x)
+#endif
+#endif
+
+// Some primes between 2^63 and 2^64 for various uses.
+static const uint64 k0 = 0xc3a5c85c97cb3127;
+static const uint64 k1 = 0xb492b66fbe98f273;
+static const uint64 k2 = 0x9ae16a3b2f90404f;
+static const uint64 k3 = 0xc949d7c7509e6557;
+
+// Bitwise right rotate. Normally this will compile to a single
+// instruction, especially if the shift is a manifest constant.
+static uint64 Rotate(uint64 val, int shift) {
+ // Avoid shifting by 64: doing so yields an undefined result.
+ return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
+}
+
+// Equivalent to Rotate(), but requires the second arg to be non-zero.
+// On x86-64, and probably others, it's possible for this to compile
+// to a single instruction if both args are already in registers.
+static uint64 RotateByAtLeast1(uint64 val, int shift) {
+ return (val >> shift) | (val << (64 - shift));
+}
+
+static uint64 ShiftMix(uint64 val) {
+ return val ^ (val >> 47);
+}
+
+static uint64 HashLen16(uint64 u, uint64 v) {
+ return Hash128to64(uint128(u, v));
+}
+
+static uint64 HashLen0to16(const char *s, size_t len) {
+ if (len > 8) {
+ uint64 a = UNALIGNED_LOAD64(s);
+ uint64 b = UNALIGNED_LOAD64(s + len - 8);
+ return HashLen16(a, RotateByAtLeast1(b + len, len)) ^ b;
+ }
+ if (len >= 4) {
+ uint64 a = UNALIGNED_LOAD32(s);
+ return HashLen16(len + (a << 3), UNALIGNED_LOAD32(s + len - 4));
+ }
+ if (len > 0) {
+ uint8 a = s[0];
+ uint8 b = s[len >> 1];
+ uint8 c = s[len - 1];
+ uint32 y = static_cast<uint32>(a) + (static_cast<uint32>(b) << 8);
+ uint32 z = len + (static_cast<uint32>(c) << 2);
+ return ShiftMix(y * k2 ^ z * k3) * k2;
+ }
+ return k2;
+}
+
+// This probably works well for 16-byte strings as well, but it may be overkill
+// in that case.
+static uint64 HashLen17to32(const char *s, size_t len) {
+ uint64 a = UNALIGNED_LOAD64(s) * k1;
+ uint64 b = UNALIGNED_LOAD64(s + 8);
+ uint64 c = UNALIGNED_LOAD64(s + len - 8) * k2;
+ uint64 d = UNALIGNED_LOAD64(s + len - 16) * k0;
+ return HashLen16(Rotate(a - b, 43) + Rotate(c, 30) + d,
+ a + Rotate(b ^ k3, 20) - c + len);
+}
+
+// Return a 16-byte hash for 48 bytes. Quick and dirty.
+// Callers do best to use "random-looking" values for a and b.
+static pair<uint64, uint64> WeakHashLen32WithSeeds(
+ uint64 w, uint64 x, uint64 y, uint64 z, uint64 a, uint64 b) {
+ a += w;
+ b = Rotate(b + a + z, 21);
+ uint64 c = a;
+ a += x;
+ a += y;
+ b += Rotate(a, 44);
+ return make_pair(a + z, b + c);
+}
+
+// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
+static pair<uint64, uint64> WeakHashLen32WithSeeds(
+ const char* s, uint64 a, uint64 b) {
+ return WeakHashLen32WithSeeds(UNALIGNED_LOAD64(s),
+ UNALIGNED_LOAD64(s + 8),
+ UNALIGNED_LOAD64(s + 16),
+ UNALIGNED_LOAD64(s + 24),
+ a,
+ b);
+}
+
+// Return an 8-byte hash for 33 to 64 bytes.
+static uint64 HashLen33to64(const char *s, size_t len) {
+ uint64 z = UNALIGNED_LOAD64(s + 24);
+ uint64 a = UNALIGNED_LOAD64(s) + (len + UNALIGNED_LOAD64(s + len - 16)) * k0;
+ uint64 b = Rotate(a + z, 52);
+ uint64 c = Rotate(a, 37);
+ a += UNALIGNED_LOAD64(s + 8);
+ c += Rotate(a, 7);
+ a += UNALIGNED_LOAD64(s + 16);
+ uint64 vf = a + z;
+ uint64 vs = b + Rotate(a, 31) + c;
+ a = UNALIGNED_LOAD64(s + 16) + UNALIGNED_LOAD64(s + len - 32);
+ z = UNALIGNED_LOAD64(s + len - 8);
+ b = Rotate(a + z, 52);
+ c = Rotate(a, 37);
+ a += UNALIGNED_LOAD64(s + len - 24);
+ c += Rotate(a, 7);
+ a += UNALIGNED_LOAD64(s + len - 16);
+ uint64 wf = a + z;
+ uint64 ws = b + Rotate(a, 31) + c;
+ uint64 r = ShiftMix((vf + ws) * k2 + (wf + vs) * k0);
+ return ShiftMix(r * k0 + vs) * k2;
+}
+
+uint64 CityHash64(const char *s, size_t len) {
+ if (len <= 32) {
+ if (len <= 16) {
+ return HashLen0to16(s, len);
+ } else {
+ return HashLen17to32(s, len);
+ }
+ } else if (len <= 64) {
+ return HashLen33to64(s, len);
+ }
+
+ // For strings over 64 bytes we hash the end first, and then as we
+ // loop we keep 56 bytes of state: v, w, x, y, and z.
+ uint64 x = UNALIGNED_LOAD64(s);
+ uint64 y = UNALIGNED_LOAD64(s + len - 16) ^ k1;
+ uint64 z = UNALIGNED_LOAD64(s + len - 56) ^ k0;
+ pair<uint64, uint64> v = WeakHashLen32WithSeeds(s + len - 64, len, y);
+ pair<uint64, uint64> w = WeakHashLen32WithSeeds(s + len - 32, len * k1, k0);
+ z += ShiftMix(v.second) * k1;
+ x = Rotate(z + x, 39) * k1;
+ y = Rotate(y, 33) * k1;
+
+ // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
+ len = (len - 1) & ~static_cast<size_t>(63);
+ do {
+ x = Rotate(x + y + v.first + UNALIGNED_LOAD64(s + 16), 37) * k1;
+ y = Rotate(y + v.second + UNALIGNED_LOAD64(s + 48), 42) * k1;
+ x ^= w.second;
+ y ^= v.first;
+ z = Rotate(z ^ w.first, 33);
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y);
+ std::swap(z, x);
+ s += 64;
+ len -= 64;
+ } while (len != 0);
+ return HashLen16(HashLen16(v.first, w.first) + ShiftMix(y) * k1 + z,
+ HashLen16(v.second, w.second) + x);
+}
+
+uint64 CityHash64WithSeed(const char *s, size_t len, uint64 seed) {
+ return CityHash64WithSeeds(s, len, k2, seed);
+}
+
+uint64 CityHash64WithSeeds(const char *s, size_t len,
+ uint64 seed0, uint64 seed1) {
+ return HashLen16(CityHash64(s, len) - seed0, seed1);
+}
+
+// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
+// of any length representable in an int. Based on City and Murmur.
+static uint128 CityMurmur(const char *s, size_t len, uint128 seed) {
+ uint64 a = Uint128Low64(seed);
+ uint64 b = Uint128High64(seed);
+ uint64 c = 0;
+ uint64 d = 0;
+ int l = len - 16;
+ if (l <= 0) { // len <= 16
+ c = b * k1 + HashLen0to16(s, len);
+ d = Rotate(a + (len >= 8 ? UNALIGNED_LOAD64(s) : c), 32);
+ } else { // len > 16
+ c = HashLen16(UNALIGNED_LOAD64(s + len - 8) + k1, a);
+ d = HashLen16(b + len, c + UNALIGNED_LOAD64(s + len - 16));
+ a += d;
+ do {
+ a ^= ShiftMix(UNALIGNED_LOAD64(s) * k1) * k1;
+ a *= k1;
+ b ^= a;
+ c ^= ShiftMix(UNALIGNED_LOAD64(s + 8) * k1) * k1;
+ c *= k1;
+ d ^= c;
+ s += 16;
+ l -= 16;
+ } while (l > 0);
+ }
+ a = HashLen16(a, c);
+ b = HashLen16(d, b);
+ return uint128(a ^ b, HashLen16(b, a));
+}
+
+uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed) {
+ if (len < 128) {
+ return CityMurmur(s, len, seed);
+ }
+
+ // We expect len >= 128 to be the common case. Keep 56 bytes of state:
+ // v, w, x, y, and z.
+ pair<uint64, uint64> v, w;
+ uint64 x = Uint128Low64(seed);
+ uint64 y = Uint128High64(seed);
+ uint64 z = len * k1;
+ v.first = Rotate(y ^ k1, 49) * k1 + UNALIGNED_LOAD64(s);
+ v.second = Rotate(v.first, 42) * k1 + UNALIGNED_LOAD64(s + 8);
+ w.first = Rotate(y + z, 35) * k1 + x;
+ w.second = Rotate(x + UNALIGNED_LOAD64(s + 88), 53) * k1;
+
+ // This is the same inner loop as CityHash64(), manually unrolled.
+ do {
+ x = Rotate(x + y + v.first + UNALIGNED_LOAD64(s + 16), 37) * k1;
+ y = Rotate(y + v.second + UNALIGNED_LOAD64(s + 48), 42) * k1;
+ x ^= w.second;
+ y ^= v.first;
+ z = Rotate(z ^ w.first, 33);
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y);
+ std::swap(z, x);
+ s += 64;
+ x = Rotate(x + y + v.first + UNALIGNED_LOAD64(s + 16), 37) * k1;
+ y = Rotate(y + v.second + UNALIGNED_LOAD64(s + 48), 42) * k1;
+ x ^= w.second;
+ y ^= v.first;
+ z = Rotate(z ^ w.first, 33);
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y);
+ std::swap(z, x);
+ s += 64;
+ len -= 128;
+ } while (LIKELY(len >= 128));
+ y += Rotate(w.first, 37) * k0 + z;
+ x += Rotate(v.first + z, 49) * k0;
+ // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
+ for (size_t tail_done = 0; tail_done < len; ) {
+ tail_done += 32;
+ y = Rotate(y - x, 42) * k0 + v.second;
+ w.first += UNALIGNED_LOAD64(s + len - tail_done + 16);
+ x = Rotate(x, 49) * k0 + w.first;
+ w.first += v.first;
+ v = WeakHashLen32WithSeeds(s + len - tail_done, v.first, v.second);
+ }
+ // At this point our 48 bytes of state should contain more than
+ // enough information for a strong 128-bit hash. We use two
+ // different 48-byte-to-8-byte hashes to get a 16-byte final result.
+ x = HashLen16(x, v.first);
+ y = HashLen16(y, w.first);
+ return uint128(HashLen16(x + v.second, w.second) + y,
+ HashLen16(x + w.second, y + v.second));
+}
+
+uint128 CityHash128(const char *s, size_t len) {
+ if (len >= 16) {
+ return CityHash128WithSeed(s + 16,
+ len - 16,
+ uint128(UNALIGNED_LOAD64(s) ^ k3,
+ UNALIGNED_LOAD64(s + 8)));
+ } else if (len >= 8) {
+ return CityHash128WithSeed(NULL,
+ 0,
+ uint128(UNALIGNED_LOAD64(s) ^ (len * k0),
+ UNALIGNED_LOAD64(s + len - 8) ^ k1));
+ } else {
+ return CityHash128WithSeed(s, len, uint128(k0, k1));
+ }
+}
diff --git a/other-licenses/nsis/Contrib/CityHash/cityhash/city.h b/other-licenses/nsis/Contrib/CityHash/cityhash/city.h
new file mode 100644
index 0000000000..01d47e4c1f
--- /dev/null
+++ b/other-licenses/nsis/Contrib/CityHash/cityhash/city.h
@@ -0,0 +1,98 @@
+// Copyright (c) 2011 Google, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+// CityHash Version 1, by Geoff Pike and Jyrki Alakuijala
+//
+// This file provides a few functions for hashing strings. On x86-64
+// hardware in 2011, CityHash64() is faster than other high-quality
+// hash functions, such as Murmur. This is largely due to higher
+// instruction-level parallelism. CityHash64() and CityHash128() also perform
+// well on hash-quality tests.
+//
+// CityHash128() is optimized for relatively long strings and returns
+// a 128-bit hash. For strings more than about 2000 bytes it can be
+// faster than CityHash64().
+//
+// Functions in the CityHash family are not suitable for cryptography.
+//
+// WARNING: This code has not been tested on big-endian platforms!
+// It is known to work well on little-endian platforms that have a small penalty
+// for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs.
+//
+// By the way, for some hash functions, given strings a and b, the hash
+// of a+b is easily derived from the hashes of a and b. This property
+// doesn't hold for any hash functions in this file.
+
+#ifndef CITY_HASH_H_
+#define CITY_HASH_H_
+
+#include <stdlib.h> // for size_t.
+#include <stdint.h>
+
+typedef uint8_t uint8;
+typedef uint32_t uint32;
+typedef uint64_t uint64;
+
+#ifdef __cplusplus
+
+#include <utility>
+typedef std::pair<uint64, uint64> uint128;
+inline uint64 Uint128Low64(const uint128& x) { return x.first; }
+inline uint64 Uint128High64(const uint128& x) { return x.second; }
+
+extern "C" {
+#endif
+
+// Hash function for a byte array.
+uint64 CityHash64(const char *buf, size_t len);
+
+// Hash function for a byte array. For convenience, a 64-bit seed is also
+// hashed into the result.
+uint64 CityHash64WithSeed(const char *buf, size_t len, uint64 seed);
+
+// Hash function for a byte array. For convenience, two seeds are also
+// hashed into the result.
+uint64 CityHash64WithSeeds(const char *buf, size_t len,
+ uint64 seed0, uint64 seed1);
+
+#ifdef __cplusplus
+}
+// Hash function for a byte array.
+uint128 CityHash128(const char *s, size_t len);
+
+// Hash function for a byte array. For convenience, a 128-bit seed is also
+// hashed into the result.
+uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed);
+
+// Hash 128 input bits down to 64 bits of output.
+// This is intended to be a reasonably good hash function.
+inline uint64 Hash128to64(const uint128& x) {
+ // Murmur-inspired hashing.
+ const uint64 kMul = 0x9ddfea08eb382d69;
+ uint64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
+ a ^= (a >> 47);
+ uint64 b = (Uint128High64(x) ^ a) * kMul;
+ b ^= (b >> 47);
+ b *= kMul;
+ return b;
+}
+#endif
+
+#endif // CITY_HASH_H_
diff --git a/other-licenses/nsis/Contrib/ExDLL/SConscript b/other-licenses/nsis/Contrib/ExDLL/SConscript
new file mode 100644
index 0000000000..2c6308545f
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/SConscript
@@ -0,0 +1,25 @@
+# FIXME: install assembly and pascal includes into the correct locations
+
+c_devel = Split("""
+ exdll.h
+""")
+
+example = Split("""
+ exdll.c
+ exdll.dpr
+ exdll.dsp
+ exdll.dsw
+ exdll_with_unit.dpr
+ nsis.pas
+ extdll.inc
+""")
+
+Import('defenv')
+
+if defenv['PLATFORM'] == 'win32':
+ example += c_devel
+else:
+ defenv.DistributeIncC(c_devel)
+
+defenv.DistributeExamples(example, path='Plugin')
+
diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.c b/other-licenses/nsis/Contrib/ExDLL/exdll.c
new file mode 100644
index 0000000000..c46e621a03
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.c
@@ -0,0 +1,44 @@
+// Unicode support by Jim Park -- 08/02/2007
+
+#include <windows.h>
+#include "tchar.h"
+#include "exdll.h"
+
+HINSTANCE g_hInstance;
+
+HWND g_hwndParent;
+
+// To work with Unicode version of NSIS, please use TCHAR-type
+// functions for accessing the variables and the stack.
+
+void __declspec(dllexport) myFunction(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop,
+ extra_parameters *extra)
+{
+ g_hwndParent=hwndParent;
+
+ EXDLL_INIT();
+
+
+ // note if you want parameters from the stack, pop them off in order.
+ // i.e. if you are called via exdll::myFunction file.dat poop.dat
+ // calling popstring() the first time would give you file.dat,
+ // and the second time would give you poop.dat.
+ // you should empty the stack of your parameters, and ONLY your
+ // parameters.
+
+ // do your stuff here
+ {
+ TCHAR buf[1024];
+ wsprintf(buf,_T("$0=%s\n"),getuservariable(INST_0));
+ MessageBox(g_hwndParent,buf,0,MB_OK);
+ }
+}
+
+
+
+BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
+{
+ g_hInstance=hInst;
+ return TRUE;
+}
diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.dpr b/other-licenses/nsis/Contrib/ExDLL/exdll.dpr
new file mode 100644
index 0000000000..ab3f03d3dd
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.dpr
@@ -0,0 +1,118 @@
+{
+ NSIS ExDLL example
+ (C) 2001 - Peter Windridge
+
+ Fixed and formatted by Brett Dever
+ http://editor.nfscheats.com/
+
+ Tested in Delphi 7.0
+}
+
+library exdll;
+
+uses Windows;
+
+type
+ VarConstants = (
+ INST_0,
+ INST_1, // $1
+ INST_2, // $2
+ INST_3, // $3
+ INST_4, // $4
+ INST_5, // $5
+ INST_6, // $6
+ INST_7, // $7
+ INST_8, // $8
+ INST_9, // $9
+ INST_R0, // $R0
+ INST_R1, // $R1
+ INST_R2, // $R2
+ INST_R3, // $R3
+ INST_R4, // $R4
+ INST_R5, // $R5
+ INST_R6, // $R6
+ INST_R7, // $R7
+ INST_R8, // $R8
+ INST_R9, // $R9
+ INST_CMDLINE, // $CMDLINE
+ INST_INSTDIR, // $INSTDIR
+ INST_OUTDIR, // $OUTDIR
+ INST_EXEDIR, // $EXEDIR
+ INST_LANG, // $LANGUAGE
+ __INST_LAST
+ );
+ TVariableList = INST_0..__INST_LAST;
+ pstack_t = ^stack_t;
+ stack_t = record
+ next: pstack_t;
+ text: PChar;
+ end;
+
+var
+ g_stringsize: integer;
+ g_stacktop: ^pstack_t;
+ g_variables: PChar;
+ g_hwndParent: HWND;
+
+function PopString(): string;
+var
+ th: pstack_t;
+begin
+ if integer(g_stacktop^) <> 0 then begin
+ th := g_stacktop^;
+ Result := PChar(@th.text);
+ g_stacktop^ := th.next;
+ GlobalFree(HGLOBAL(th));
+ end;
+end;
+
+procedure PushString(const str: string='');
+var
+ th: pstack_t;
+begin
+ if integer(g_stacktop) <> 0 then begin
+ th := pstack_t(GlobalAlloc(GPTR, SizeOf(stack_t) + g_stringsize));
+ lstrcpyn(@th.text, PChar(str), g_stringsize);
+ th.next := g_stacktop^;
+ g_stacktop^ := th;
+ end;
+end;
+
+function GetUserVariable(const varnum: TVariableList): string;
+begin
+ if (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
+ Result := g_variables + integer(varnum) * g_stringsize
+ else
+ Result := '';
+end;
+
+procedure SetUserVariable(const varnum: TVariableList; const value: string);
+begin
+ if (value <> '') and (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
+ lstrcpy(g_variables + integer(varnum) * g_stringsize, PChar(value))
+end;
+
+procedure NSISDialog(const text, caption: string; const buttons: integer);
+begin
+ MessageBox(g_hwndParent, PChar(text), PChar(caption), buttons);
+end;
+
+procedure ex_dll(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); cdecl;
+begin
+ // setup global variables
+ g_stringsize := string_size;
+ g_hwndParent := hwndParent;
+ g_stacktop := stacktop;
+ g_variables := variables;
+ // end global variable setup
+
+ NSISDialog(GetUserVariable(INST_0), 'The value of $0', MB_OK);
+ NSISDialog(PopString, 'pop', MB_OK);
+ PushString('Hello, this is a push');
+ SetUserVariable(INST_0, 'This is user var $0');
+end;
+
+exports ex_dll;
+
+begin
+end.
diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.dsp b/other-licenses/nsis/Contrib/ExDLL/exdll.dsp
new file mode 100644
index 0000000000..9888726515
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.dsp
@@ -0,0 +1,111 @@
+# Microsoft Developer Studio Project File - Name="exdll" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=exdll - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "exdll.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "exdll.mak" CFG="exdll - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "exdll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "exdll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "exdll - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"DllMain" /dll /machine:I386 /nodefaultlib /out:"../../Plugins/exdll.dll" /opt:nowin98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "exdll - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "exdll - Win32 Release"
+# Name "exdll - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\exdll.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\exdll.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.dsw b/other-licenses/nsis/Contrib/ExDLL/exdll.dsw
new file mode 100644
index 0000000000..f40ce32de8
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "exdll"=.\exdll.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.h b/other-licenses/nsis/Contrib/ExDLL/exdll.h
new file mode 100644
index 0000000000..c923c5197d
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.h
@@ -0,0 +1,234 @@
+// Unicode support added by Jim Park -- 07/27/2007
+// Unicode support requires that all plugins take TCHARs instead as well. This
+// means existing plugins will not work for the Unicode version of NSIS unless
+// recompiled. You have been warned.
+
+#ifndef _EXDLL_H_
+#define _EXDLL_H_
+
+#include <windows.h>
+#include "tchar.h"
+
+#if defined(__GNUC__)
+#define UNUSED __attribute__((unused))
+#else
+#define UNUSED
+#endif
+
+// only include this file from one place in your DLL.
+// (it is all static, if you use it in two places it will fail)
+
+#define EXDLL_INIT() { \
+ g_stringsize=string_size; \
+ g_stacktop=stacktop; \
+ g_variables=variables; }
+
+// For page showing plug-ins
+#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
+#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
+
+/* Jim Park: This char is compared as an int value and therefore
+ it's fine as an ASCII. Do not need to change to wchar_t since
+ it will get the same integer value. */
+#define NOTIFY_BYE_BYE _T('x')
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[1]; // this should be the length of string_size
+} stack_t;
+
+
+static unsigned int g_stringsize;
+static stack_t **g_stacktop;
+static TCHAR *g_variables;
+
+static int __stdcall popstring(TCHAR *str) UNUSED; // 0 on success, 1 on empty stack
+static void __stdcall pushstring(const TCHAR *str) UNUSED;
+static TCHAR * __stdcall getuservariable(const int varnum) UNUSED;
+static void __stdcall setuservariable(const int varnum, const TCHAR *var) UNUSED;
+
+enum
+{
+INST_0, // $0
+INST_1, // $1
+INST_2, // $2
+INST_3, // $3
+INST_4, // $4
+INST_5, // $5
+INST_6, // $6
+INST_7, // $7
+INST_8, // $8
+INST_9, // $9
+INST_R0, // $R0
+INST_R1, // $R1
+INST_R2, // $R2
+INST_R3, // $R3
+INST_R4, // $R4
+INST_R5, // $R5
+INST_R6, // $R6
+INST_R7, // $R7
+INST_R8, // $R8
+INST_R9, // $R9
+INST_CMDLINE, // $CMDLINE
+INST_INSTDIR, // $INSTDIR
+INST_OUTDIR, // $OUTDIR
+INST_EXEDIR, // $EXEDIR
+INST_LANG, // $LANGUAGE
+__INST_LAST
+};
+
+typedef struct {
+ int autoclose;
+ int all_user_var;
+ int exec_error;
+ int abort;
+ int exec_reboot;
+ int reboot_called;
+ int XXX_cur_insttype; // deprecated
+ int XXX_insttype_changed; // deprecated
+ int silent;
+ int instdir_error;
+ int rtl;
+ int errlvl;
+ int alter_reg_view;
+ int status_update;
+} exec_flags_type;
+
+typedef struct {
+ exec_flags_type *exec_flags;
+ int (__stdcall *ExecuteCodeSegment)(int, HWND);
+ void (__stdcall *validate_filename)(TCHAR *);
+} extra_parameters;
+
+// utility functions (not required but often useful)
+static int __stdcall popstring(TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th=(*g_stacktop);
+ lstrcpy(str,th->text);
+ *g_stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+static void __stdcall pushstring(const TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop) return;
+ th=(stack_t*)GlobalAlloc(GPTR,(sizeof(stack_t)+(g_stringsize)*sizeof(TCHAR)));
+ lstrcpyn(th->text,str,g_stringsize);
+ th->next=*g_stacktop;
+ *g_stacktop=th;
+}
+
+static TCHAR * __stdcall getuservariable(const int varnum)
+{
+ if (varnum < 0 || varnum >= __INST_LAST) return NULL;
+ return g_variables+varnum*g_stringsize;
+}
+
+static void __stdcall setuservariable(const int varnum, const TCHAR *var)
+{
+ if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
+ lstrcpy(g_variables + varnum*g_stringsize, var);
+}
+
+#ifdef _UNICODE
+#define PopStringW(x) popstring(x)
+#define PushStringW(x) pushstring(x)
+#define SetUserVariableW(x,y) setuservariable(x,y)
+
+static int __stdcall PopStringA(char* ansiStr)
+{
+ wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
+ int rval = popstring(wideStr);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ GlobalFree((HGLOBAL)wideStr);
+ return rval;
+}
+
+static void __stdcall PushStringA(const char* ansiStr)
+{
+ wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ pushstring(wideStr);
+ GlobalFree((HGLOBAL)wideStr);
+ return;
+}
+
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr)
+{
+ lstrcpyW(wideStr, getuservariable(varnum));
+}
+
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr)
+{
+ wchar_t* wideStr = getuservariable(varnum);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+}
+
+static void __stdcall SetUserVariableA(const int varnum, const char* ansiStr)
+{
+ if (ansiStr != NULL && varnum >= 0 && varnum < __INST_LAST)
+ {
+ wchar_t* wideStr = g_variables + varnum * g_stringsize;
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ }
+}
+
+#else
+// ANSI defs
+
+#define PopStringA(x) popstring(x)
+#define PushStringA(x) pushstring(x)
+#define SetUserVariableA(x,y) setuservariable(x,y)
+
+static int __stdcall PopStringW(wchar_t* wideStr)
+{
+ char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
+ int rval = popstring(ansiStr);
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ GlobalFree((HGLOBAL)ansiStr);
+ return rval;
+}
+
+static void __stdcall PushStringW(wchar_t* wideStr)
+{
+ char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ pushstring(ansiStr);
+ GlobalFree((HGLOBAL)ansiStr);
+}
+
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr)
+{
+ char* ansiStr = getuservariable(varnum);
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+}
+
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr)
+{
+ lstrcpyA(ansiStr, getuservariable(varnum));
+}
+
+static void __stdcall SetUserVariableW(const int varnum, const wchar_t* wideStr)
+{
+ if (wideStr != NULL && varnum >= 0 && varnum < __INST_LAST)
+ {
+ char* ansiStr = g_variables + varnum * g_stringsize;
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ }
+}
+#endif
+
+static BOOL __stdcall IsUnicode(void)
+{
+#ifdef _UNICODE
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+#endif//_EXDLL_H_
diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll_with_unit.dpr b/other-licenses/nsis/Contrib/ExDLL/exdll_with_unit.dpr
new file mode 100644
index 0000000000..007e350dc0
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll_with_unit.dpr
@@ -0,0 +1,31 @@
+{
+ NSIS ExDLL2 example
+ Original is ExDLL
+ (C) 2001 - Peter Windridge
+
+ Changed with delphi unit nsis.pas
+ by bernhard mayer
+
+ Tested in Delphi 7.0
+}
+
+library exdll;
+
+uses
+ nsis, windows;
+
+procedure ex_dll(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); cdecl;
+begin
+ // set up global variables
+ Init(hwndParent, string_size, variables, stacktop);
+
+ NSISDialog(GetUserVariable(INST_0), 'The value of $0', MB_OK);
+ NSISDialog(PopString, 'pop', MB_OK);
+ PushString('Hello, this is a push');
+ SetUserVariable(INST_0, 'This is user var $0');
+end;
+
+exports ex_dll;
+
+begin
+end.
diff --git a/other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp b/other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp
new file mode 100644
index 0000000000..f1413767aa
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp
@@ -0,0 +1,131 @@
+// Unicode support by Jim Park -- 08/23/2007
+
+#include <windows.h>
+#include "exdllutil.h"
+
+// utility functions (not required but often useful)
+static int __stdcall popstring(TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th=(*g_stacktop);
+ lstrcpy(str,th->text);
+ *g_stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+static void __stdcall pushstring(const TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop) return;
+ th=(stack_t*)GlobalAlloc(GPTR,(sizeof(stack_t)+(g_stringsize)*sizeof(TCHAR)));
+ lstrcpyn(th->text,str,g_stringsize);
+ th->next=*g_stacktop;
+ *g_stacktop=th;
+}
+
+static TCHAR * __stdcall getuservariable(const int varnum)
+{
+ if (varnum < 0 || varnum >= __INST_LAST) return NULL;
+ return g_variables+varnum*g_stringsize;
+}
+
+static void __stdcall setuservariable(const int varnum, const TCHAR *var)
+{
+ if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
+ lstrcpy(g_variables + varnum*g_stringsize, var);
+}
+
+#ifdef _UNICODE
+static int __stdcall PopStringA(char* ansiStr)
+{
+ wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
+ int rval = popstring(wideStr);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ GlobalFree((HGLOBAL)wideStr);
+ return rval;
+}
+
+static void __stdcall PushStringA(const char* ansiStr)
+{
+ wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ pushtring(wideStr);
+ GlobalFree((HGLOBAL)wideStr);
+ return;
+}
+
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr)
+{
+ lstrcpyW(wideStr, getuservariable(varnum));
+}
+
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr)
+{
+ wchar_t* wideStr = getuservariable(varnum);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+}
+
+static void __stdcall SetUserVariableA(const int varnum, const char* ansiStr)
+{
+ if (ansiStr != NULL && varnum >= 0 && varnum < __INST_LAST)
+ {
+ wchar_t* wideStr = g_variables + varnum * g_stringsize;
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ }
+}
+
+#else
+// ANSI defs
+static int __stdcall PopStringW(wchar_t* wideStr)
+{
+ char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
+ int rval = popstring(ansiStr);
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ GlobalFree((HGLOBAL)ansiStr);
+ return rval;
+}
+
+static void __stdcall PushStringW(wchar_t* wideStr)
+{
+ char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ pushstring(ansiStr);
+ GlobalFree((HGLOBAL)ansiStr);
+}
+
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr)
+{
+ char* ansiStr = getuservariable(varnum);
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+}
+
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr)
+{
+ lstrcpyA(ansiStr, getuservariable(varnum));
+}
+
+static void __stdcall SetUserVariableW(const int varnum, const wchar_t* wideStr)
+{
+ if (wideStr != NULL && varnum >= 0 && varnum < __INST_LAST)
+ {
+ char* ansiStr = g_variables + varnum * g_stringsize;
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ }
+}
+#endif
+
+static BOOL __stdcall IsUnicode(void)
+{
+#ifdef _UNICODE
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+static TCHAR* __stdcall AllocString()
+{
+ return (TCHAR*) GlobalAlloc(GPTR, g_stringsize*sizeof(TCHAR));
+}
diff --git a/other-licenses/nsis/Contrib/ExDLL/exdllutil.h b/other-licenses/nsis/Contrib/ExDLL/exdllutil.h
new file mode 100644
index 0000000000..51897fc643
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdllutil.h
@@ -0,0 +1,119 @@
+// Unicode support by Jim Park -- 08/23/2007
+// Jim Park: Should probably turn this into a nice class for C++ programs.
+
+#pragma once
+#include <windows.h>
+#include <tchar.h>
+// only include this file from one place in your DLL.
+// (it is all static, if you use it in two places it will fail)
+
+#define EXDLL_INIT() { \
+ g_stringsize=string_size; \
+ g_stacktop=stacktop; \
+ g_variables=variables; }
+
+// For page showing plug-ins
+#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
+#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
+
+/* Jim Park: This char is compared as an int value and therefore
+ it's fine as an ASCII. Do not need to change to wchar_t since
+ it will get the same integer value. */
+#define NOTIFY_BYE_BYE _T('x')
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[1]; // this should be the length of string_size
+} stack_t;
+
+static unsigned int g_stringsize;
+static stack_t **g_stacktop;
+static TCHAR *g_variables;
+
+
+enum
+{
+INST_0, // $0
+INST_1, // $1
+INST_2, // $2
+INST_3, // $3
+INST_4, // $4
+INST_5, // $5
+INST_6, // $6
+INST_7, // $7
+INST_8, // $8
+INST_9, // $9
+INST_R0, // $R0
+INST_R1, // $R1
+INST_R2, // $R2
+INST_R3, // $R3
+INST_R4, // $R4
+INST_R5, // $R5
+INST_R6, // $R6
+INST_R7, // $R7
+INST_R8, // $R8
+INST_R9, // $R9
+INST_CMDLINE, // $CMDLINE
+INST_INSTDIR, // $INSTDIR
+INST_OUTDIR, // $OUTDIR
+INST_EXEDIR, // $EXEDIR
+INST_LANG, // $LANGUAGE
+__INST_LAST
+};
+
+typedef struct {
+ int autoclose;
+ int all_user_var;
+ int exec_error;
+ int abort;
+ int exec_reboot;
+ int reboot_called;
+ int XXX_cur_insttype; // deprecated
+ int XXX_insttype_changed; // deprecated
+ int silent;
+ int instdir_error;
+ int rtl;
+ int errlvl;
+ int alter_reg_view;
+} exec_flags_type;
+
+typedef struct {
+ exec_flags_type *exec_flags;
+ int (__stdcall *ExecuteCodeSegment)(int, HWND);
+ void (__stdcall *validate_filename)(TCHAR *);
+} extra_parameters;
+
+static int __stdcall popstring(TCHAR *str); // 0 on success, 1 on empty stack
+static void __stdcall pushstring(const TCHAR *str);
+static char * __stdcall getuservariable(const int varnum);
+static void __stdcall setuservariable(const int varnum, const TCHAR *var);
+
+#ifdef _UNICODE
+#define PopStringW(x) popstring(x)
+#define PushStringW(x) pushstring(x)
+#define SetUserVariableW(x,y) setuservariable(x,y)
+
+static int __stdcall PopStringA(char* ansiStr);
+static void __stdcall PushStringA(const char* ansiStr);
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr);
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr);
+static void __stdcall SetUserVariableA(const int varnum, const char* ansiStr);
+
+#else
+// ANSI defs
+
+#define PopStringA(x) popstring(x)
+#define PushStringA(x) pushstring(x)
+#define SetUserVariableA(x,y) setuservariable(x,y)
+
+static int __stdcall PopStringW(wchar_t* wideStr);
+static void __stdcall PushStringW(wchar_t* wideStr);
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr);
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr);
+static void __stdcall SetUserVariableW(const int varnum, const wchar_t* wideStr);
+
+#endif
+
+static BOOL __stdcall IsUnicode(void)
+static TCHAR* __stdcall AllocString();
+
diff --git a/other-licenses/nsis/Contrib/ExDLL/extdll.inc b/other-licenses/nsis/Contrib/ExDLL/extdll.inc
new file mode 100644
index 0000000000..4c48ae5ce5
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/extdll.inc
@@ -0,0 +1,145 @@
+;################################################################
+; ExtDLL header for MASM32
+;
+; Author: Ramon
+;
+; Obs: This header must be included after windows.inc and kernel32.inc
+; because it need the prototypes for lstrcpy, lstrcpyn,
+; GlobalAlloc and GlobalFree
+;
+;################################################################
+stack_t struct
+ next dd ?
+ text dd ? ; 1 DUP(?) ; this should be the length of string_size
+stack_t ends
+
+.const
+; For page showing plug-ins
+WM_NOTIFY_OUTER_NEXT equ (WM_USER+0x8)
+WM_NOTIFY_CUSTOM_READY equ (WM_USER+0xd)
+NOTIFY_BYE_BYE equ 'x'
+
+INST_0 EQU 0 ; $0
+INST_1 EQU 1 ; $1
+INST_2 EQU 2 ; $2
+INST_3 EQU 3 ; $3
+INST_4 EQU 4 ; $4
+INST_5 EQU 5 ; $5
+INST_6 EQU 6 ; $6
+INST_7 EQU 7 ; $7
+INST_8 EQU 8 ; $8
+INST_9 EQU 9 ; $9
+INST_R0 EQU 10 ; $R0
+INST_R1 EQU 11 ; $R1
+INST_R2 EQU 12 ; $R2
+INST_R3 EQU 13 ; $R3
+INST_R4 EQU 14 ; $R4
+INST_R5 EQU 15 ; $R5
+INST_R6 EQU 16 ; $R6
+INST_R7 EQU 17 ; $R7
+INST_R8 EQU 18 ; $R8
+INST_R9 EQU 19 ; $R9
+INST_CMDLINE EQU 20 ; $CMDLINE
+INST_INSTDIR EQU 21 ; $INSTDIR
+INST_OUTDIR EQU 22 ; $OUTDIR
+INST_EXEDIR EQU 23 ; $EXEDIR
+INST_LANG EQU 24 ; $LANGUAGE
+__INST_LAST EQU 25
+
+.data?
+g_stringsize dd ?
+g_stacktop dd ?
+g_variables dd ?
+
+m2m MACRO M1, M2
+ push M2
+ pop M1
+ENDM
+
+EXDLL_INIT MACRO
+ m2m g_stringsize, string_size
+ m2m g_stacktop, stacktop
+ m2m g_variables, variables
+ENDM
+
+.code
+
+; utility functions (not required but often useful)
+popstring proc uses edi pStr:DWORD
+
+ LOCAL th:DWORD
+
+ mov edi, g_stacktop
+ cmp edi, 0
+ jz STACK_ERR
+ mov edi, [edi]
+ cmp edi, 0
+ jz STACK_ERR
+
+ ASSUME edi:PTR stack_t
+ invoke lstrcpy, pStr, ADDR [edi].text
+ mov th , edi
+ mov edi, [edi].next
+ mov eax, g_stacktop
+ mov [eax], edi
+ invoke GlobalFree, th
+ ASSUME edi:PTR NOTHING
+ mov eax, 0
+ ret
+
+STACK_ERR:
+ mov eax, 1
+ ret
+
+popstring endp
+
+pushstring proc uses edi pStr:DWORD
+
+ cmp g_stacktop, 0
+ jz STACK_ERR
+
+ mov eax, sizeof stack_t
+ add eax, g_stringsize
+ invoke GlobalAlloc, GPTR, eax
+
+ mov edi, eax
+ assume edi:PTR stack_t
+
+ invoke lstrcpyn, ADDR [edi].text, pStr, g_stringsize
+ mov eax, g_stacktop
+ push DWORD PTR[eax]
+ mov [eax], edi
+ pop eax
+ ;lea edi, [edi].next ; Not needed [edi].next == edi
+ mov DWORD PTR[edi], eax
+ ASSUME edi:PTR NOTHING
+
+STACK_ERR:
+ ret
+
+pushstring endp
+
+getuservariable proc varnum:DWORD
+
+ .if varnum < 0 || varnum >= __INST_LAST
+ xor eax, eax
+ .else
+ mov eax, varnum
+ imul eax, g_stringsize
+ add eax, g_variables
+ .endif
+ ret
+
+getuservariable endp
+
+setuservariable proc varnum:DWORD, var:DWORD
+
+ .if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
+ mov eax, varnum
+ imul eax, g_stringsize
+ add eax, g_variables
+ invoke lstrcpy, eax, var
+ .endif
+ ret
+
+setuservariable endp
diff --git a/other-licenses/nsis/Contrib/ExDLL/nsis.pas b/other-licenses/nsis/Contrib/ExDLL/nsis.pas
new file mode 100644
index 0000000000..356d26cbde
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/nsis.pas
@@ -0,0 +1,126 @@
+{
+ Original Code from
+ (C) 2001 - Peter Windridge
+
+ Code in seperate unit and some changes
+ 2003 by Bernhard Mayer
+
+ Fixed and formatted by Brett Dever
+ http://editor.nfscheats.com/
+
+ simply include this unit in your plugin project and export
+ functions as needed
+}
+
+
+unit nsis;
+
+interface
+
+uses
+ windows;
+
+type
+ VarConstants = (
+ INST_0, // $0
+ INST_1, // $1
+ INST_2, // $2
+ INST_3, // $3
+ INST_4, // $4
+ INST_5, // $5
+ INST_6, // $6
+ INST_7, // $7
+ INST_8, // $8
+ INST_9, // $9
+ INST_R0, // $R0
+ INST_R1, // $R1
+ INST_R2, // $R2
+ INST_R3, // $R3
+ INST_R4, // $R4
+ INST_R5, // $R5
+ INST_R6, // $R6
+ INST_R7, // $R7
+ INST_R8, // $R8
+ INST_R9, // $R9
+ INST_CMDLINE, // $CMDLINE
+ INST_INSTDIR, // $INSTDIR
+ INST_OUTDIR, // $OUTDIR
+ INST_EXEDIR, // $EXEDIR
+ INST_LANG, // $LANGUAGE
+ __INST_LAST
+ );
+ TVariableList = INST_0..__INST_LAST;
+ pstack_t = ^stack_t;
+ stack_t = record
+ next: pstack_t;
+ text: PChar;
+ end;
+
+var
+ g_stringsize: integer;
+ g_stacktop: ^pstack_t;
+ g_variables: PChar;
+ g_hwndParent: HWND;
+
+procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer);
+function PopString(): string;
+procedure PushString(const str: string='');
+function GetUserVariable(const varnum: TVariableList): string;
+procedure SetUserVariable(const varnum: TVariableList; const value: string);
+procedure NSISDialog(const text, caption: string; const buttons: integer);
+
+implementation
+
+procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer);
+begin
+ g_stringsize := string_size;
+ g_hwndParent := hwndParent;
+ g_stacktop := stacktop;
+ g_variables := variables;
+end;
+
+function PopString(): string;
+var
+ th: pstack_t;
+begin
+ if integer(g_stacktop^) <> 0 then begin
+ th := g_stacktop^;
+ Result := PChar(@th.text);
+ g_stacktop^ := th.next;
+ GlobalFree(HGLOBAL(th));
+ end;
+end;
+
+procedure PushString(const str: string='');
+var
+ th: pstack_t;
+begin
+ if integer(g_stacktop) <> 0 then begin
+ th := pstack_t(GlobalAlloc(GPTR, SizeOf(stack_t) + g_stringsize));
+ lstrcpyn(@th.text, PChar(str), g_stringsize);
+ th.next := g_stacktop^;
+ g_stacktop^ := th;
+ end;
+end;
+
+function GetUserVariable(const varnum: TVariableList): string;
+begin
+ if (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
+ Result := g_variables + integer(varnum) * g_stringsize
+ else
+ Result := '';
+end;
+
+procedure SetUserVariable(const varnum: TVariableList; const value: string);
+begin
+ if (value <> '') and (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
+ lstrcpy(g_variables + integer(varnum) * g_stringsize, PChar(value))
+end;
+
+procedure NSISDialog(const text, caption: string; const buttons: integer);
+begin
+ MessageBox(g_hwndParent, PChar(text), PChar(caption), buttons);
+end;
+
+begin
+end.
diff --git a/other-licenses/nsis/Contrib/ExDLL/tchar.h b/other-licenses/nsis/Contrib/ExDLL/tchar.h
new file mode 100644
index 0000000000..5c18ffb778
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/tchar.h
@@ -0,0 +1,210 @@
+/*
+ * tchar.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ *
+ * For Unicode support by Jim Park -- 08/30/2007
+ */
+
+// Jim Park: Only those we use are listed here.
+
+#pragma once
+
+#ifdef _UNICODE
+
+#ifndef _T
+#define __T(x) L ## x
+#define _T(x) __T(x)
+#define _TEXT(x) __T(x)
+#endif
+typedef wchar_t TCHAR;
+typedef wchar_t _TUCHAR;
+
+// program
+#define _tmain wmain
+#define _tWinMain wWinMain
+#define _tenviron _wenviron
+#define __targv __wargv
+
+// printfs
+#define _ftprintf fwprintf
+#define _sntprintf _snwprintf
+#define _stprintf _swprintf
+#define _tprintf wprintf
+#define _vftprintf vfwprintf
+#define _vsntprintf _vsnwprintf
+#define _vstprintf _vswprintf
+
+// scanfs
+#define _tscanf wscanf
+#define _stscanf swscanf
+
+// string manipulations
+#define _tcscat wcscat
+#define _tcschr wcschr
+#define _tcsclen wcslen
+#define _tcscpy wcscpy
+#define _tcsdup _wcsdup
+#define _tcslen wcslen
+#define _tcsnccpy wcsncpy
+#define _tcsncpy wcsncpy
+#define _tcsrchr wcsrchr
+#define _tcsstr wcsstr
+#define _tcstok wcstok
+
+// string comparisons
+#define _tcscmp wcscmp
+#define _tcsicmp _wcsicmp
+#define _tcsncicmp _wcsnicmp
+#define _tcsncmp wcsncmp
+#define _tcsnicmp _wcsnicmp
+
+// upper / lower
+#define _tcslwr _wcslwr
+#define _tcsupr _wcsupr
+#define _totlower towlower
+#define _totupper towupper
+
+// conversions to numbers
+#define _tcstoi64 _wcstoi64
+#define _tcstol wcstol
+#define _tcstoul wcstoul
+#define _tstof _wtof
+#define _tstoi _wtoi
+#define _tstoi64 _wtoi64
+#define _ttoi _wtoi
+#define _ttoi64 _wtoi64
+#define _ttol _wtol
+
+// conversion from numbers to strings
+#define _itot _itow
+#define _ltot _ltow
+#define _i64tot _i64tow
+#define _ui64tot _ui64tow
+
+// file manipulations
+#define _tfopen _wfopen
+#define _topen _wopen
+#define _tremove _wremove
+#define _tunlink _wunlink
+
+// reading and writing to i/o
+#define _fgettc fgetwc
+#define _fgetts fgetws
+#define _fputts fputws
+#define _gettchar getwchar
+
+// directory
+#define _tchdir _wchdir
+
+// environment
+#define _tgetenv _wgetenv
+#define _tsystem _wsystem
+
+// time
+#define _tcsftime wcsftime
+
+#else // ANSI
+
+#ifndef _T
+#define _T(x) x
+#define _TEXT(x) x
+#endif
+typedef char TCHAR;
+typedef unsigned char _TUCHAR;
+
+// program
+#define _tmain main
+#define _tWinMain WinMain
+#define _tenviron environ
+#define __targv __argv
+
+// printfs
+#define _ftprintf fprintf
+#define _sntprintf _snprintf
+#define _stprintf sprintf
+#define _tprintf printf
+#define _vftprintf vfprintf
+#define _vsntprintf _vsnprintf
+#define _vstprintf vsprintf
+
+// scanfs
+#define _tscanf scanf
+#define _stscanf sscanf
+
+// string manipulations
+#define _tcscat strcat
+#define _tcschr strchr
+#define _tcsclen strlen
+#define _tcscnlen strnlen
+#define _tcscpy strcpy
+#define _tcsdup _strdup
+#define _tcslen strlen
+#define _tcsnccpy strncpy
+#define _tcsrchr strrchr
+#define _tcsstr strstr
+#define _tcstok strtok
+
+// string comparisons
+#define _tcscmp strcmp
+#define _tcsicmp _stricmp
+#define _tcsncmp strncmp
+#define _tcsncicmp _strnicmp
+#define _tcsnicmp _strnicmp
+
+// upper / lower
+#define _tcslwr _strlwr
+#define _tcsupr _strupr
+
+#define _totupper toupper
+#define _totlower tolower
+
+// conversions to numbers
+#define _tcstol strtol
+#define _tcstoul strtoul
+#define _tstof atof
+#define _tstoi atoi
+#define _tstoi64 _atoi64
+#define _tstoi64 _atoi64
+#define _ttoi atoi
+#define _ttoi64 _atoi64
+#define _ttol atol
+
+// conversion from numbers to strings
+#define _i64tot _i64toa
+#define _itot _itoa
+#define _ltot _ltoa
+#define _ui64tot _ui64toa
+
+// file manipulations
+#define _tfopen fopen
+#define _topen _open
+#define _tremove remove
+#define _tunlink _unlink
+
+// reading and writing to i/o
+#define _fgettc fgetc
+#define _fgetts fgets
+#define _fputts fputs
+#define _gettchar getchar
+
+// directory
+#define _tchdir _chdir
+
+// environment
+#define _tgetenv getenv
+#define _tsystem system
+
+// time
+#define _tcsftime strftime
+
+#endif
+
+// is functions (the same in Unicode / ANSI)
+#define _istgraph isgraph
+#define _istascii __isascii
diff --git a/other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.cpp b/other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.cpp
new file mode 100644
index 0000000000..05e0ed5e92
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.cpp
@@ -0,0 +1,212 @@
+/* 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 file is an NSIS plugin which exports a function that starts a process
+// from a provided path by using the shell automation API to have explorer.exe
+// invoke ShellExecute. This roundabout method of starting a process is useful
+// because it means the new process will use the integrity level and security
+// token of the shell, so it allows starting an unelevated process from inside
+// an elevated one. The method is based on
+// https://blogs.msdn.microsoft.com/oldnewthing/20131118-00/?p=2643
+// but the code has been rewritten to remove the need for ATL or the C runtime.
+
+// Normally an NSIS installer would use the UAC plugin, which itself uses both
+// an unelevated and an elevated process, and the elevated process can invoke
+// functions in the unelevated one, so this plugin wouldn't be needed.
+// But uninstallers are often directly run elevated because that's just how
+// the Windows UI launches them, so there is no unelevated process. This
+// plugin allows starting a needed unelevated process in that situation.
+
+#include <windows.h>
+#include <shlobj.h>
+
+#pragma comment(lib, "shlwapi.lib")
+
+static IShellView*
+GetDesktopWindowShellView()
+{
+ IShellView* view = nullptr;
+ IShellWindows* shell = nullptr;
+ CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER,
+ IID_PPV_ARGS(&shell));
+ if (shell) {
+ VARIANT empty;
+ VariantInit(&empty);
+
+ VARIANT loc;
+ loc.vt = VT_VARIANT | VT_BYREF;
+ PIDLIST_ABSOLUTE locList;
+ SHGetFolderLocation(nullptr, CSIDL_DESKTOP, nullptr, 0, &locList);
+ loc.byref = locList;
+
+ HWND windowHandle = 0;
+ IDispatch* dispatch = nullptr;
+
+ shell->FindWindowSW(&loc, &empty, SWC_DESKTOP, (long*)&windowHandle,
+ SWFO_NEEDDISPATCH, &dispatch);
+ if (dispatch) {
+ IServiceProvider* provider = nullptr;
+ dispatch->QueryInterface(IID_PPV_ARGS(&provider));
+ if (provider) {
+ IShellBrowser* browser = nullptr;
+ provider->QueryService(SID_STopLevelBrowser, IID_PPV_ARGS(&browser));
+ if (browser) {
+ browser->QueryActiveShellView(&view);
+ browser->Release();
+ }
+ provider->Release();
+ }
+ dispatch->Release();
+ }
+ shell->Release();
+ }
+
+ return view;
+}
+
+static IShellDispatch2*
+GetApplicationFromShellView(IShellView* view)
+{
+ IShellDispatch2* shellDispatch = nullptr;
+ IDispatch* viewDisp = nullptr;
+ HRESULT hr = view->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&viewDisp));
+ if (SUCCEEDED(hr)) {
+ IShellFolderViewDual* shellViewFolder = nullptr;
+ viewDisp->QueryInterface(IID_PPV_ARGS(&shellViewFolder));
+ if (shellViewFolder) {
+ IDispatch* dispatch = nullptr;
+ shellViewFolder->get_Application(&dispatch);
+ if (dispatch) {
+ dispatch->QueryInterface(IID_PPV_ARGS(&shellDispatch));
+ dispatch->Release();
+ }
+ shellViewFolder->Release();
+ }
+ viewDisp->Release();
+ }
+ return shellDispatch;
+}
+
+static bool
+ShellExecInExplorerProcess(wchar_t* path, wchar_t* args = nullptr)
+{
+ bool rv = false;
+ if (SUCCEEDED(CoInitialize(nullptr))) {
+ IShellView *desktopView = GetDesktopWindowShellView();
+ if (desktopView) {
+ IShellDispatch2 *shellDispatch = GetApplicationFromShellView(desktopView);
+ if (shellDispatch) {
+ BSTR bstrPath = SysAllocString(path);
+ VARIANT vArgs;
+ VariantInit(&vArgs);
+ if (args) {
+ vArgs.vt = VT_BSTR;
+ vArgs.bstrVal = SysAllocString(args);
+ }
+ rv = SUCCEEDED(shellDispatch->ShellExecuteW(bstrPath, vArgs, VARIANT{},
+ VARIANT{}, VARIANT{}));
+ VariantClear(&vArgs);
+ SysFreeString(bstrPath);
+ shellDispatch->Release();
+ }
+ desktopView->Release();
+ }
+ CoUninitialize();
+ }
+ return rv;
+}
+
+struct stack_t {
+ stack_t* next;
+ TCHAR text[MAX_PATH];
+};
+
+/**
+ * Removes an element from the top of the NSIS stack
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param str The string to pop to
+ * @param len The max length
+ * @return 0 on success
+ */
+int
+popstring(stack_t **stacktop, TCHAR *str, int len)
+{
+ // Removes the element from the top of the stack and puts it in the buffer
+ stack_t *th;
+ if (!stacktop || !*stacktop) {
+ return 1;
+ }
+
+ th = (*stacktop);
+ lstrcpyn(str, th->text, len);
+ *stacktop = th->next;
+ HeapFree(GetProcessHeap(), 0, th);
+ return 0;
+}
+
+/**
+ * Adds an element to the top of the NSIS stack
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param str The string to push on the stack
+ * @param len The length of the string to push on the stack
+ * @return 0 on success
+ */
+void
+pushstring(stack_t **stacktop, const TCHAR *str, int len)
+{
+ stack_t *th;
+ if (!stacktop) {
+ return;
+ }
+ th = (stack_t*)HeapAlloc(GetProcessHeap(), 0, sizeof(stack_t) + len);
+ lstrcpyn(th->text, str, len);
+ th->next = *stacktop;
+ *stacktop = th;
+}
+
+/**
+* Starts an executable or URL from the shell process.
+*
+* @param stacktop Pointer to the top of the stack, AKA the first parameter to
+ the plugin call. Should contain the file or URL to execute.
+* @return 1 if the file/URL was executed successfully, 0 if it was not
+*/
+extern "C" void __declspec(dllexport)
+Exec(HWND, int, TCHAR *, stack_t **stacktop, void *)
+{
+ wchar_t path[MAX_PATH + 1];
+ wchar_t args[MAX_PATH + 1];
+ bool rv = false;
+ bool restoreArgString = false;
+ // We're skipping building the C runtime to keep the file size low, so we
+ // can't use a normal string initialization because that would call memset.
+ path[0] = L'\0';
+ args[0] = L'\0';
+ popstring(stacktop, path, MAX_PATH);
+ if (popstring(stacktop, args, MAX_PATH) == 0) {
+ // This stack item may not be for us, but we don't know yet.
+ restoreArgString = true;
+ }
+
+ if (lstrcmpW(args, L"/cmdargs") == 0) {
+ popstring(stacktop, args, MAX_PATH);
+ rv = ShellExecInExplorerProcess(path, args);
+ } else {
+ // If the stack wasn't empty, then we popped something that wasn't for us.
+ if (restoreArgString) {
+ pushstring(stacktop, args, lstrlenW(args));
+ }
+ rv = ShellExecInExplorerProcess(path);
+ }
+
+ pushstring(stacktop, rv ? L"1" : L"0", 2);
+}
+
+BOOL APIENTRY
+DllMain(HMODULE, DWORD, LPVOID)
+{
+ return TRUE;
+}
diff --git a/other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.sln b/other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.sln
new file mode 100644
index 0000000000..cbd2ea4bf0
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27428.2015
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExecInExplorer", "ExecInExplorer.vcxproj", "{B5DBA89B-37EE-425C-A375-4E04E69731FA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B5DBA89B-37EE-425C-A375-4E04E69731FA}.Debug|x64.ActiveCfg = Debug|x64
+ {B5DBA89B-37EE-425C-A375-4E04E69731FA}.Debug|x64.Build.0 = Debug|x64
+ {B5DBA89B-37EE-425C-A375-4E04E69731FA}.Debug|x86.ActiveCfg = Debug|Win32
+ {B5DBA89B-37EE-425C-A375-4E04E69731FA}.Debug|x86.Build.0 = Debug|Win32
+ {B5DBA89B-37EE-425C-A375-4E04E69731FA}.Release|x64.ActiveCfg = Release|x64
+ {B5DBA89B-37EE-425C-A375-4E04E69731FA}.Release|x64.Build.0 = Release|x64
+ {B5DBA89B-37EE-425C-A375-4E04E69731FA}.Release|x86.ActiveCfg = Release|Win32
+ {B5DBA89B-37EE-425C-A375-4E04E69731FA}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {69740CF4-5E42-4A56-AFF5-2D17D42CFB75}
+ EndGlobalSection
+EndGlobal
diff --git a/other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.vcxproj b/other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.vcxproj
new file mode 100644
index 0000000000..fcb217d87c
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExecInExplorer/ExecInExplorer.vcxproj
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{B5DBA89B-37EE-425C-A375-4E04E69731FA}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>ExecInExplorer</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>WIN32;_DEBUG;EXECINEXPLORER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>_DEBUG;EXECINEXPLORER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>WIN32;NDEBUG;EXECINEXPLORER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>NDEBUG;EXECINEXPLORER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="ExecInExplorer.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.cpp b/other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.cpp
new file mode 100644
index 0000000000..7b55493829
--- /dev/null
+++ b/other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.cpp
@@ -0,0 +1,304 @@
+/* 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/. */
+
+// To explain some of the oddities:
+// This plugin avoids linking against a runtime that might not be present, thus
+// it avoids standard library functions.
+// NSIS requires GlobalAlloc/GlobalFree for its interfaces, and I use them for
+// other allocations (vs e.g. HeapAlloc) for the sake of consistency.
+
+#include <Windows.h>
+#include <Wininet.h>
+
+#define AGENT_NAME L"HttpPostFile plugin"
+
+PBYTE LoadFileData(LPWSTR fileName, DWORD& cbData);
+bool HttpPost(LPURL_COMPONENTS pUrl, LPWSTR contentTypeHeader, PBYTE data,
+ DWORD cbData);
+
+// NSIS API
+typedef struct _stack_t {
+ struct _stack_t* next;
+ WCHAR text[1];
+} stack_t;
+
+// Unlink and return the topmost element of the stack, if any.
+static stack_t* popstack(stack_t** stacktop) {
+ if (!stacktop || !*stacktop) return nullptr;
+ stack_t* element = *stacktop;
+ *stacktop = element->next;
+ element->next = nullptr;
+ return element;
+}
+
+// Allocate a new stack element (with space for `stringsize`), copy the string,
+// add to the top of the stack.
+static void pushstring(LPCWSTR str, stack_t** stacktop,
+ unsigned int stringsize) {
+ stack_t* element;
+ if (!stacktop) return;
+
+ // The allocation here has space for stringsize+1 WCHARs, because stack_t.text
+ // is 1 element long. This is consistent with the NSIS ExDLL example, though
+ // inconsistent with the comment that says the array "should be the length of
+ // g_stringsize when allocating". I'm sticking to consistency with
+ // the code, and erring towards having a larger buffer than necessary.
+
+ element = (stack_t*)GlobalAlloc(
+ GPTR, (sizeof(stack_t) + stringsize * sizeof(*str)));
+ lstrcpynW(element->text, str, stringsize);
+ element->next = *stacktop;
+ *stacktop = element;
+}
+
+BOOL APIENTRY DllMain(HINSTANCE instance, DWORD reason, LPVOID) {
+ // No initialization or cleanup is needed.
+ return TRUE;
+}
+
+extern "C" {
+
+// HttpPostFile::Post <File> <Content-Type header with \r\n> <URL>
+//
+// e.g. HttpPostFile "C:\blah.json" "Content-Type: application/json$\r$\n"
+// "https://example.com"
+//
+// Leaves a result string on the stack, "success" if the POST was successful, an
+// error message otherwise.
+// The status code from the server is not checked, as long as we got some
+// response the result will be "success". The response is read, but discarded.
+void __declspec(dllexport)
+ Post(HWND hwndParent, int string_size, char* /* variables */,
+ stack_t** stacktop, void* /* extra_parameters */) {
+ static const URL_COMPONENTS kZeroComponents = {0};
+ const WCHAR* errorMsg = L"error";
+
+ DWORD cbData = INVALID_FILE_SIZE;
+ PBYTE data = nullptr;
+
+ // Copy a constant, because initializing an automatic variable with {0} ends
+ // up linking to memset, which isn't available.
+ URL_COMPONENTS components = kZeroComponents;
+
+ // Get args, taking ownership of the strings from the stack, to avoid
+ // allocating and copying strings.
+ stack_t* postFileName = popstack(stacktop);
+ stack_t* contentTypeHeader = popstack(stacktop);
+ stack_t* url = popstack(stacktop);
+
+ if (!postFileName || !contentTypeHeader || !url) {
+ errorMsg = L"error getting arguments";
+ goto finish;
+ }
+
+ data = LoadFileData(postFileName->text, cbData);
+ if (!data || cbData == INVALID_FILE_SIZE) {
+ errorMsg = L"error reading file";
+ goto finish;
+ }
+
+ {
+ // This length is used to allocate for the host name and path components,
+ // which should be no longer than the source URL.
+ int urlBufLen = lstrlenW(url->text) + 1;
+
+ components.dwStructSize = sizeof(components);
+ components.dwHostNameLength = urlBufLen;
+ components.dwUrlPathLength = urlBufLen;
+ components.lpszHostName =
+ (LPWSTR)GlobalAlloc(GPTR, urlBufLen * sizeof(WCHAR));
+ components.lpszUrlPath =
+ (LPWSTR)GlobalAlloc(GPTR, urlBufLen * sizeof(WCHAR));
+ }
+
+ errorMsg = L"error parsing URL";
+ if (components.lpszHostName && components.lpszUrlPath &&
+ InternetCrackUrl(url->text, 0, 0, &components) &&
+ (components.nScheme == INTERNET_SCHEME_HTTP ||
+ components.nScheme == INTERNET_SCHEME_HTTPS)) {
+ errorMsg = L"error sending HTTP request";
+ if (HttpPost(&components, contentTypeHeader->text, data, cbData)) {
+ // success!
+ errorMsg = nullptr;
+ }
+ }
+
+finish:
+ if (components.lpszUrlPath) {
+ GlobalFree(components.lpszUrlPath);
+ }
+ if (components.lpszHostName) {
+ GlobalFree(components.lpszHostName);
+ }
+ if (data) {
+ GlobalFree(data);
+ }
+
+ // Free args taken from the NSIS stack
+ if (url) {
+ GlobalFree(url);
+ }
+ if (contentTypeHeader) {
+ GlobalFree(contentTypeHeader);
+ }
+ if (postFileName) {
+ GlobalFree(postFileName);
+ }
+
+ if (errorMsg) {
+ pushstring(errorMsg, stacktop, string_size);
+ } else {
+ pushstring(L"success", stacktop, string_size);
+ }
+}
+}
+
+// Returns buffer with file contents on success, placing the size in cbData.
+// Returns nullptr on failure.
+// Caller must use GlobalFree() on the returned buffer if non-null.
+PBYTE LoadFileData(LPWSTR fileName, DWORD& cbData) {
+ bool success = false;
+
+ HANDLE hPostFile = INVALID_HANDLE_VALUE;
+
+ PBYTE data = nullptr;
+
+ DWORD bytesRead;
+ DWORD bytesReadTotal;
+
+ hPostFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, nullptr,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
+ if (hPostFile == INVALID_HANDLE_VALUE) {
+ goto finish;
+ }
+
+ cbData = GetFileSize(hPostFile, NULL);
+ if (cbData == INVALID_FILE_SIZE) {
+ goto finish;
+ }
+
+ data = (PBYTE)GlobalAlloc(GPTR, cbData);
+ if (!data) {
+ goto finish;
+ }
+
+ bytesReadTotal = 0;
+ do {
+ if (!ReadFile(hPostFile, data + bytesReadTotal, cbData - bytesReadTotal,
+ &bytesRead, nullptr /* overlapped */)) {
+ goto finish;
+ }
+ bytesReadTotal += bytesRead;
+ } while (bytesReadTotal < cbData && bytesRead > 0);
+
+ if (bytesReadTotal == cbData) {
+ success = true;
+ }
+
+finish:
+ if (!success) {
+ if (data) {
+ GlobalFree(data);
+ data = nullptr;
+ }
+ cbData = INVALID_FILE_SIZE;
+ }
+ if (hPostFile != INVALID_HANDLE_VALUE) {
+ CloseHandle(hPostFile);
+ hPostFile = INVALID_HANDLE_VALUE;
+ }
+
+ return data;
+}
+
+// Returns true on success
+bool HttpPost(LPURL_COMPONENTS pUrl, LPWSTR contentTypeHeader, PBYTE data,
+ DWORD cbData) {
+ bool success = false;
+
+ HINTERNET hInternet = nullptr;
+ HINTERNET hConnect = nullptr;
+ HINTERNET hRequest = nullptr;
+
+ hInternet = InternetOpen(AGENT_NAME, INTERNET_OPEN_TYPE_PRECONFIG,
+ nullptr, // proxy
+ nullptr, // proxy bypass
+ 0 // flags
+ );
+ if (!hInternet) {
+ goto finish;
+ }
+
+ hConnect = InternetConnect(hInternet, pUrl->lpszHostName, pUrl->nPort,
+ nullptr, // userName,
+ nullptr, // password
+ INTERNET_SERVICE_HTTP,
+ 0, // flags
+ 0 // context
+ );
+ if (!hConnect) {
+ goto finish;
+ }
+
+ {
+ // NOTE: Some of these settings are perhaps unnecessary for a POST.
+ DWORD httpFlags = INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES |
+ INTERNET_FLAG_NO_UI | INTERNET_FLAG_RELOAD;
+ if (pUrl->nScheme == INTERNET_SCHEME_HTTPS) {
+ // NOTE: nsJSON sets flags to allow redirecting HTTPS to HTTP, or HTTP to
+ // HTTPS I left those out because it seemed undesirable for our use case.
+ httpFlags |= INTERNET_FLAG_SECURE;
+ }
+ hRequest = HttpOpenRequest(hConnect, L"POST", pUrl->lpszUrlPath,
+ nullptr, // version,
+ nullptr, // referrer
+ nullptr, // accept types
+ httpFlags,
+ 0 // context
+ );
+ if (!hRequest) {
+ goto finish;
+ }
+ }
+
+ if (contentTypeHeader) {
+ if (!HttpAddRequestHeaders(hRequest, contentTypeHeader,
+ -1L, // headers length (count string length)
+ HTTP_ADDREQ_FLAG_ADD)) {
+ goto finish;
+ }
+ }
+
+ if (!HttpSendRequestW(hRequest,
+ nullptr, // additional headers
+ 0, // headers length
+ data, cbData)) {
+ goto finish;
+ }
+
+ BYTE readBuffer[1024];
+ DWORD bytesRead;
+ do {
+ if (!InternetReadFile(hRequest, readBuffer, sizeof(readBuffer),
+ &bytesRead)) {
+ goto finish;
+ }
+ // read data is thrown away
+ } while (bytesRead > 0);
+
+ success = true;
+
+finish:
+ if (hRequest) {
+ InternetCloseHandle(hRequest);
+ }
+ if (hConnect) {
+ InternetCloseHandle(hConnect);
+ }
+ if (hInternet) {
+ InternetCloseHandle(hInternet);
+ }
+
+ return success;
+} \ No newline at end of file
diff --git a/other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.sln b/other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.sln
new file mode 100644
index 0000000000..c6fd9ca5e5
--- /dev/null
+++ b/other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30128.74
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HttpPostFile", "HttpPostFile.vcxproj", "{A8BF99FD-8603-4137-862A-1D14268D7812}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A8BF99FD-8603-4137-862A-1D14268D7812}.Release|x86.ActiveCfg = Release|Win32
+ {A8BF99FD-8603-4137-862A-1D14268D7812}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {5EF33D14-5BB9-4E44-A347-9FF33E86D9DC}
+ EndGlobalSection
+EndGlobal
diff --git a/other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.vcxproj b/other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.vcxproj
new file mode 100644
index 0000000000..32ca342ea2
--- /dev/null
+++ b/other-licenses/nsis/Contrib/HttpPostFile/HttpPostFile.vcxproj
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>16.0</VCProjectVersion>
+ <Keyword>Win32Proj</Keyword>
+ <ProjectGuid>{a8bf99fd-8603-4137-862a-1d14268d7812}</ProjectGuid>
+ <RootNamespace>HttpPostFile</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v142</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WINVER=0x601;_WIN32_WINNT=0x601;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <ExceptionHandling>false</ExceptionHandling>
+ <SDLCheck>false</SDLCheck>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="HttpPostFile.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/other-licenses/nsis/Contrib/HttpPostFile/test/postdriver.nsi b/other-licenses/nsis/Contrib/HttpPostFile/test/postdriver.nsi
new file mode 100644
index 0000000000..6a54bf3ca3
--- /dev/null
+++ b/other-licenses/nsis/Contrib/HttpPostFile/test/postdriver.nsi
@@ -0,0 +1,63 @@
+; Any copyright is dedicated to the Public Domain.
+; http://creativecommons.org/publicdomain/zero/1.0/
+
+; Simple driver for HttpPostFile, passes command line args to HttpPostFile::Post and
+; writes the result string to a file for automated checking.
+; Always specifies Content-Type: application/json
+;
+; Usage: posttest /postfile=postfile.json /url=http://example.com /resultfile=result.txt
+
+!include LogicLib.nsh
+!include FileFunc.nsh
+
+OutFile "postdriver.exe"
+RequestExecutionLevel user
+ShowInstDetails show
+Unicode true
+
+!addplugindir ..\..\..\Plugins
+
+Var PostFileArg
+Var UrlArg
+Var ResultFileArg
+Var ResultString
+
+Section
+
+StrCpy $ResultString "error getting command line arguments"
+
+ClearErrors
+${GetParameters} $0
+IfErrors done
+
+ClearErrors
+${GetOptions} " $0" " /postfile=" $PostFileArg
+IfErrors done
+
+${GetOptions} " $0" " /url=" $UrlArg
+IfErrors done
+
+${GetOptions} " $0" " /resultfile=" $ResultFileArg
+IfErrors done
+
+DetailPrint "POST File = $PostFileArg"
+DetailPrint "URL = $UrlArg"
+DetailPrint "Result File = $ResultFileArg"
+
+StrCpy $ResultString "error running plugin"
+HttpPostFile::Post $PostFileArg "Content-Type: application/json$\r$\n" $UrlArg
+Pop $ResultString
+
+done:
+${If} $ResultString != "success"
+DetailPrint $ResultString
+${EndIf}
+
+ClearErrors
+FileOpen $0 $ResultFileArg "w"
+${Unless} ${Errors}
+FileWrite $0 $ResultString
+FileClose $0
+${EndUnless}
+
+SectionEnd
diff --git a/other-licenses/nsis/Contrib/HttpPostFile/test/unittest.py b/other-licenses/nsis/Contrib/HttpPostFile/test/unittest.py
new file mode 100644
index 0000000000..2d5cd94d26
--- /dev/null
+++ b/other-licenses/nsis/Contrib/HttpPostFile/test/unittest.py
@@ -0,0 +1,247 @@
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+# Unit test for the HttpPostFile plugin, using a server on localhost.
+#
+# This test has not been set up to run in continuous integration. It is
+# intended to be run manually, and only on Windows.
+#
+# Requires postdriver.exe, which can be built from postdriver.nsi with makensis
+# from MozillaBuild:
+#
+# makensis-3.01.exe postdriver.nsi
+#
+# It can then be run from this directory as:
+#
+# python3 test.py
+
+import os
+import subprocess
+import http.server
+import socketserver
+import threading
+
+DRIVER_EXE_FILE_NAME = "postdriver.exe"
+JSON_FILE_NAME = "test1.json"
+RESULT_FILE_NAME = "result.txt"
+BIND_HOST = "127.0.0.1"
+BIND_PORT = 8080
+COMMON_URL = f"http://{BIND_HOST}:{BIND_PORT}/submit"
+COMMON_JSON_BYTES = '{"yes": "indeed",\n"and": "ij"}'.encode('utf-8')
+
+DRIVER_TIMEOUT_SECS = 60
+SERVER_TIMEOUT_SECS = 120
+
+
+class PostHandler(http.server.BaseHTTPRequestHandler):
+ """BaseHTTPRequestHandler, basically just here to have a configurable do_POST handler"""
+
+
+last_submission = None
+last_content_type = None
+server_response = 'Hello, plugin'.encode('utf-8')
+
+
+def server_accept_submit(handler):
+ """Plugs into PostHandler.do_POST, accepts a POST on /submit and saves it into
+ the globals"""
+
+ global last_submission
+ global last_content_type
+ global server_response
+
+ last_submission = None
+ last_content_type = None
+
+ if handler.path == "/submit":
+ handler.send_response(200, 'Ok')
+ content_length = int(handler.headers['Content-Length'])
+ last_submission = handler.rfile.read(content_length)
+ last_content_type = handler.headers['Content-Type']
+ else:
+ handler.send_response(404, 'Not found')
+ handler.end_headers()
+
+ handler.wfile.write(server_response)
+ handler.wfile.flush()
+
+ handler.log_message("sent response")
+
+
+server_hang_event = None
+
+
+def server_hang(handler):
+ """Plugs into PostHandler.do_POST, waits on server_hang_event or until timeout"""
+ server_hang_event.wait(SERVER_TIMEOUT_SECS)
+
+
+def run_and_assert_result(handle_request, post_file, url, expected_result):
+ """Sets up the server on another thread, runs the NSIS driver, and checks the result"""
+ global last_submission
+ global server_hang_event
+
+ try:
+ os.remove(RESULT_FILE_NAME)
+ except FileNotFoundError:
+ pass
+
+ PostHandler.do_POST = handle_request
+ last_submission = None
+
+ def handler_thread():
+ with socketserver.TCPServer((BIND_HOST, BIND_PORT), PostHandler) as httpd:
+ httpd.timeout = SERVER_TIMEOUT_SECS
+ httpd.handle_request()
+
+ if handle_request:
+ server_thread = threading.Thread(target=handler_thread)
+ server_thread.start()
+
+ try:
+ subprocess.call([DRIVER_EXE_FILE_NAME, f'/postfile={post_file}', f'/url={url}',
+ f'/resultfile={RESULT_FILE_NAME}', '/S'], timeout=DRIVER_TIMEOUT_SECS)
+
+ with open(RESULT_FILE_NAME, "r") as result_file:
+ result = result_file.read()
+
+ if result != expected_result:
+ raise AssertionError(f'{result} != {expected_result}')
+
+ finally:
+ if server_hang_event:
+ server_hang_event.set()
+
+ if handle_request:
+ server_thread.join()
+ os.remove(RESULT_FILE_NAME)
+
+
+def create_json_file(json_bytes=COMMON_JSON_BYTES):
+ with open(JSON_FILE_NAME, "wb") as outfile:
+ outfile.write(json_bytes)
+
+
+def check_submission(json_bytes=COMMON_JSON_BYTES):
+ if last_submission != json_bytes:
+ raise AssertionError(f'{last_submission.hex()} != {COMMON_JSON_BYTES}')
+
+
+def cleanup_json_file():
+ os.remove(JSON_FILE_NAME)
+
+
+# Tests begin here
+
+try:
+ cleanup_json_file()
+except FileNotFoundError:
+ pass
+
+# Basic test
+
+create_json_file()
+run_and_assert_result(server_accept_submit, JSON_FILE_NAME, COMMON_URL, "success")
+check_submission()
+assert last_content_type == 'application/json'
+cleanup_json_file()
+
+print("Basic test OK\n")
+
+# Test with missing file
+
+try:
+ cleanup_json_file()
+except FileNotFoundError:
+ pass
+
+run_and_assert_result(None, JSON_FILE_NAME, COMMON_URL, "error reading file")
+
+print("Missing file test OK\n")
+
+# Test with empty file
+
+create_json_file(bytes())
+run_and_assert_result(server_accept_submit, JSON_FILE_NAME, COMMON_URL, "success")
+check_submission(bytes())
+cleanup_json_file()
+
+print("Empty file test OK\n")
+
+# Test with large file
+
+# NOTE: Not actually JSON, but nothing here should care
+four_mbytes = bytes([x & 255 for x in range(4*1024*1024)])
+create_json_file(four_mbytes)
+run_and_assert_result(server_accept_submit, JSON_FILE_NAME, COMMON_URL, "success")
+if last_submission != four_mbytes:
+ raise AssertionError("large file mismatch")
+cleanup_json_file()
+
+print("Large file test OK\n")
+
+# Test with long file name
+
+# Test with bad URL
+
+bogus_url = "notAUrl"
+create_json_file()
+run_and_assert_result(None, JSON_FILE_NAME, bogus_url, "error parsing URL")
+cleanup_json_file()
+
+print("Bad URL test OK\n")
+
+# Test with empty response
+
+server_response = bytes()
+create_json_file()
+run_and_assert_result(server_accept_submit, JSON_FILE_NAME, COMMON_URL, "success")
+check_submission()
+cleanup_json_file()
+
+print("Empty response test OK\n")
+
+# Test with large response
+
+server_response = four_mbytes
+create_json_file()
+run_and_assert_result(server_accept_submit, JSON_FILE_NAME, COMMON_URL, "success")
+check_submission()
+cleanup_json_file()
+
+print("Large response test OK\n")
+
+# Test with 404
+# NOTE: This succeeds since the client doesn't check the status code
+
+create_json_file()
+nonexistent_url = f"http://{BIND_HOST}:{BIND_PORT}/bad"
+run_and_assert_result(server_accept_submit, JSON_FILE_NAME, nonexistent_url, "success")
+cleanup_json_file()
+
+print("404 response test OK\n")
+
+# Test with no server on the port
+# NOTE: I'm assuming nothing else has been able to bind to the port
+
+print("Running no server test, this will take a few seconds...")
+
+create_json_file()
+run_and_assert_result(None, JSON_FILE_NAME, COMMON_URL, "error sending HTTP request")
+cleanup_json_file()
+
+print("No server test OK\n")
+
+# Test with server that hangs on response
+# NOTE: HttpPostFile doesn't currently set the timeouts. Defaults seem to be around 30 seconds,
+# but if they end up being longer than the 60 second driver timeout then this will fail.
+
+print("Running server hang test, this will take up to a minute...")
+
+server_hang_event = threading.Event()
+create_json_file()
+run_and_assert_result(server_hang, JSON_FILE_NAME, COMMON_URL, "error sending HTTP request")
+cleanup_json_file()
+server_hang_event = None
+
+print("Server hang test OK\n")
diff --git a/other-licenses/nsis/Contrib/InetBgDL/InetBgDL.cpp b/other-licenses/nsis/Contrib/InetBgDL/InetBgDL.cpp
new file mode 100644
index 0000000000..0d248be60d
--- /dev/null
+++ b/other-licenses/nsis/Contrib/InetBgDL/InetBgDL.cpp
@@ -0,0 +1,739 @@
+//
+// Copyright (C) Anders Kjersem. Licensed under the zlib/libpng license
+//
+
+// This file is intended to be compiled with MSVC's Omit Default Library Name (/Zl)
+// option enabled, in order to keep the file size low for bundling this DLL with
+// the stub installer. That means that any code requiring the C runtime will fail
+// to link. You'll see a couple of odd-looking things here for this reason; they
+// should all be called out with comments.
+
+#include "InetBgDL.h"
+
+#define USERAGENT _T("NSIS InetBgDL (Mozilla)")
+
+#define STATUS_COMPLETEDALL 0
+#define STATUS_INITIAL 202
+#define STATUS_CONNECTING STATUS_INITIAL //102
+#define STATUS_DOWNLOADING STATUS_INITIAL
+#define STATUS_ERR_GETLASTERROR 418 //HTTP: I'm a teapot: Win32 error code in $3
+#define STATUS_ERR_LOCALFILEWRITEERROR 450 //HTTP: MS parental control extension
+#define STATUS_ERR_CANCELLED 499
+#define STATUS_ERR_CONNECTION_LOST 1000
+
+typedef DWORD FILESIZE_T; // Limit to 4GB for now...
+#define FILESIZE_UNKNOWN (-1)
+
+#define MAX_STRLEN 1024
+
+HINSTANCE g_hInst;
+NSIS::stack_t*g_pLocations = NULL;
+HANDLE g_hThread = NULL;
+HANDLE g_hGETStartedEvent = NULL;
+HINTERNET g_hInetSes = NULL;
+HINTERNET g_hInetFile = NULL;
+volatile UINT g_FilesTotal = 0;
+volatile UINT g_FilesCompleted = 0;
+volatile UINT g_Status = STATUS_INITIAL;
+volatile FILESIZE_T g_cbCurrXF;
+volatile FILESIZE_T g_cbCurrTot = FILESIZE_UNKNOWN;
+CRITICAL_SECTION g_CritLock;
+UINT g_N_CCH;
+PTSTR g_N_Vars;
+TCHAR g_ServerIP[128] = { _T('\0') };
+
+DWORD g_ConnectTimeout = 0;
+DWORD g_ReceiveTimeout = 0;
+
+// Setup a buffer of size 256KiB to store the downloaded data.
+constexpr UINT g_cbBufXF = 262144;
+// This buffer is only needed inside TaskThreadProc(), but declaring it on
+// the stack there triggers a runtime stack size check, which is implemented
+// by a C runtime library function, so we have to avoid the compiler wanting
+// to build that check by not having any large stack buffers.
+BYTE g_bufXF[g_cbBufXF];
+
+#define NSISPI_INITGLOBALS(N_CCH, N_Vars) do { \
+ g_N_CCH = N_CCH; \
+ g_N_Vars = N_Vars; \
+ } while(0)
+
+#define ONELOCKTORULETHEMALL
+#ifdef ONELOCKTORULETHEMALL
+#define TaskLock_AcquireExclusive() EnterCriticalSection(&g_CritLock)
+#define TaskLock_ReleaseExclusive() LeaveCriticalSection(&g_CritLock)
+#define StatsLock_AcquireExclusive() TaskLock_AcquireExclusive()
+#define StatsLock_ReleaseExclusive() TaskLock_ReleaseExclusive()
+#define StatsLock_AcquireShared() StatsLock_AcquireExclusive()
+#define StatsLock_ReleaseShared() StatsLock_ReleaseExclusive()
+#endif
+
+// Normally we would just call the C library wcstol, but since we can't use the
+// C runtime, we'll supply our own function as an understudy.
+static DWORD
+MyTStrToL(TCHAR const* str)
+{
+ if (!str) {
+ return 0;
+ }
+
+ int len = lstrlen(str);
+ DWORD place = 1;
+ DWORD rv = 0;
+ for (int i = len - 1; i >= 0; --i) {
+ int digit = str[i] - 0x30;
+ rv += digit * place;
+ place *= 10;
+ }
+ return rv;
+}
+
+PTSTR NSIS_SetRegStr(UINT Reg, LPCTSTR Value)
+{
+ PTSTR s = g_N_Vars + (Reg * g_N_CCH);
+ lstrcpy(s, Value);
+ return s;
+}
+#define NSIS_SetRegStrEmpty(r) NSIS_SetRegStr(r, _T(""))
+void NSIS_SetRegUINT(UINT Reg, UINT Value)
+{
+ TCHAR buf[32];
+ wsprintf(buf, _T("%u"), Value);
+ NSIS_SetRegStr(Reg, buf);
+}
+#define StackFreeItem(pI) GlobalFree(pI)
+NSIS::stack_t* StackPopItem(NSIS::stack_t**ppST)
+{
+ if (*ppST)
+ {
+ NSIS::stack_t*pItem = *ppST;
+ *ppST = pItem->next;
+ return pItem;
+ }
+ return NULL;
+}
+
+void Reset()
+{
+ // The g_hGETStartedEvent event is used to make sure that the Get() call will
+ // acquire the lock before the Reset() call acquires the lock.
+ if (g_hGETStartedEvent) {
+ TRACE(_T("InetBgDl: waiting on g_hGETStartedEvent\n"));
+ WaitForSingleObject(g_hGETStartedEvent, INFINITE);
+ CloseHandle(g_hGETStartedEvent);
+ g_hGETStartedEvent = NULL;
+ }
+
+ TaskLock_AcquireExclusive();
+#ifndef ONELOCKTORULETHEMALL
+ StatsLock_AcquireExclusive();
+#endif
+ g_FilesTotal = 0; // This causes the Task thread to exit the transfer loop
+ if (g_hThread)
+ {
+ TRACE(_T("InetBgDl: waiting on g_hThread\n"));
+ if (WAIT_OBJECT_0 != WaitForSingleObject(g_hThread, 5 * 1000))
+ {
+ TRACE(_T("InetBgDl: terminating g_hThread\n"));
+ // Suspend the thread so that it's not still trying to use these handles
+ // that we're about to close out from under it.
+ SuspendThread(g_hThread);
+ if (g_hInetFile) {
+ InternetCloseHandle(g_hInetFile);
+ g_hInetFile = nullptr;
+ }
+ if (g_hInetSes) {
+ InternetCloseHandle(g_hInetSes);
+ g_hInetSes = nullptr;
+ }
+ TerminateThread(g_hThread, ERROR_OPERATION_ABORTED);
+ }
+ CloseHandle(g_hThread);
+ g_hThread = NULL;
+ }
+ g_FilesTotal = 0;
+ g_FilesCompleted = 0;
+ g_Status = STATUS_INITIAL;
+#ifndef ONELOCKTORULETHEMALL
+ StatsLock_ReleaseExclusive();
+#endif
+ for (NSIS::stack_t*pTmpTast,*pTask = g_pLocations; pTask ;)
+ {
+ pTmpTast = pTask;
+ pTask = pTask->next;
+ StackFreeItem(pTmpTast);
+ }
+ g_pLocations = NULL;
+ TaskLock_ReleaseExclusive();
+}
+
+UINT_PTR __cdecl NSISPluginCallback(UINT Event)
+{
+ switch(Event)
+ {
+ case NSPIM_UNLOAD:
+ Reset();
+ break;
+ }
+ return NULL;
+}
+
+void __stdcall InetStatusCallback(HINTERNET hInternet, DWORD_PTR dwContext,
+ DWORD dwInternetStatus,
+ LPVOID lpvStatusInformation,
+ DWORD dwStatusInformationLength)
+{
+ if (dwInternetStatus == INTERNET_STATUS_NAME_RESOLVED) {
+ // If we're in the process of being reset, don't try to update g_ServerIP;
+ // there's no need for it, and Reset() will be holding the StatsLock, so
+ // we'll hang here and block the reset if we try to acquire it.
+ if (g_FilesTotal != 0) {
+ // The documentation states the IP address is a PCTSTR but it is usually a
+ // PCSTR and only sometimes a PCTSTR.
+ StatsLock_AcquireExclusive();
+ wsprintf(g_ServerIP, _T("%S"), lpvStatusInformation);
+ if (lstrlen(g_ServerIP) == 1)
+ {
+ wsprintf(g_ServerIP, _T("%s"), lpvStatusInformation);
+ }
+ StatsLock_ReleaseExclusive();
+ }
+ }
+
+#if defined(PLUGIN_DEBUG)
+ switch (dwInternetStatus)
+ {
+ case INTERNET_STATUS_RESOLVING_NAME:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_RESOLVING_NAME (%d), name=%s\n"),
+ dwStatusInformationLength, lpvStatusInformation);
+ break;
+ case INTERNET_STATUS_NAME_RESOLVED:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_NAME_RESOLVED (%d), resolved name=%s\n"),
+ dwStatusInformationLength, g_ServerIP);
+ break;
+ case INTERNET_STATUS_CONNECTING_TO_SERVER:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_CONNECTING_TO_SERVER (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_CONNECTED_TO_SERVER:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_CONNECTED_TO_SERVER (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_SENDING_REQUEST:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_SENDING_REQUEST (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_REQUEST_SENT:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_REQUEST_SENT (%d), bytes sent=%d\n"),
+ dwStatusInformationLength, lpvStatusInformation);
+ break;
+ case INTERNET_STATUS_RECEIVING_RESPONSE:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_RECEIVING_RESPONSE (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_RESPONSE_RECEIVED:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_RESPONSE_RECEIVED (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_CTL_RESPONSE_RECEIVED (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_PREFETCH:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_PREFETCH (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_CLOSING_CONNECTION:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_CLOSING_CONNECTION (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_CONNECTION_CLOSED:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_CONNECTION_CLOSED (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_HANDLE_CREATED:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_HANDLE_CREATED (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_HANDLE_CLOSING:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_HANDLE_CLOSING (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_DETECTING_PROXY:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_DETECTING_PROXY (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_REQUEST_COMPLETE:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_REQUEST_COMPLETE (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_REDIRECT:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_REDIRECT (%d), new url=%s\n"),
+ dwStatusInformationLength, lpvStatusInformation);
+ break;
+ case INTERNET_STATUS_INTERMEDIATE_RESPONSE:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_INTERMEDIATE_RESPONSE (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_USER_INPUT_REQUIRED:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_USER_INPUT_REQUIRED (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_STATE_CHANGE:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_STATE_CHANGE (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_COOKIE_SENT:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_COOKIE_SENT (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_COOKIE_RECEIVED:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_COOKIE_RECEIVED (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_PRIVACY_IMPACTED:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_PRIVACY_IMPACTED (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_P3P_HEADER:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_P3P_HEADER (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_P3P_POLICYREF:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_P3P_POLICYREF (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ case INTERNET_STATUS_COOKIE_HISTORY:
+ TRACE(_T("InetBgDl: INTERNET_STATUS_COOKIE_HISTORY (%d)\n"),
+ dwStatusInformationLength);
+ break;
+ default:
+ TRACE(_T("InetBgDl: Unknown Status %d\n"), dwInternetStatus);
+ break;
+ }
+#endif
+}
+
+DWORD CALLBACK TaskThreadProc(LPVOID ThreadParam)
+{
+ NSIS::stack_t *pURL,*pFile;
+ DWORD cbio = sizeof(DWORD);
+ DWORD previouslyWritten = 0, writtenThisSession = 0;
+ HANDLE hLocalFile;
+ bool completedFile = false;
+startnexttask:
+ hLocalFile = INVALID_HANDLE_VALUE;
+ pFile = NULL;
+ TaskLock_AcquireExclusive();
+ // Now that we've acquired the lock, we can set the event to indicate this.
+ // SetEvent will likely never fail, but if it does we should set it to NULL
+ // to avoid anyone waiting on it.
+ if (!SetEvent(g_hGETStartedEvent)) {
+ CloseHandle(g_hGETStartedEvent);
+ g_hGETStartedEvent = NULL;
+ }
+ pURL = g_pLocations;
+ if (pURL)
+ {
+ pFile = pURL->next;
+ g_pLocations = pFile->next;
+ }
+#ifndef ONELOCKTORULETHEMALL
+ StatsLock_AcquireExclusive();
+#endif
+ if (completedFile)
+ {
+ ++g_FilesCompleted;
+ }
+ completedFile = false;
+ g_cbCurrXF = 0;
+ g_cbCurrTot = FILESIZE_UNKNOWN;
+ if (!pURL)
+ {
+ if (g_FilesTotal)
+ {
+ if (g_FilesTotal == g_FilesCompleted)
+ {
+ g_Status = STATUS_COMPLETEDALL;
+ }
+ }
+ g_hThread = NULL;
+ }
+#ifndef ONELOCKTORULETHEMALL
+ StatsLock_ReleaseExclusive();
+#endif
+ TaskLock_ReleaseExclusive();
+
+ if (!pURL)
+ {
+ if (0)
+ {
+diegle:
+ DWORD gle = GetLastError();
+ //TODO? if (ERROR_INTERNET_EXTENDED_ERROR==gle) InternetGetLastResponseInfo(...)
+ g_Status = STATUS_ERR_GETLASTERROR;
+ }
+die:
+ if (g_hInetSes)
+ {
+ InternetCloseHandle(g_hInetSes);
+ g_hInetSes = nullptr;
+ }
+ if (INVALID_HANDLE_VALUE != hLocalFile)
+ {
+ CloseHandle(hLocalFile);
+ }
+ StackFreeItem(pURL);
+ StackFreeItem(pFile);
+ return 0;
+ }
+
+ if (!g_hInetSes)
+ {
+ g_hInetSes = InternetOpen(USERAGENT, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
+ if (!g_hInetSes)
+ {
+ TRACE(_T("InetBgDl: InternetOpen failed with gle=%u\n"),
+ GetLastError());
+ goto diegle;
+ }
+ InternetSetStatusCallback(g_hInetSes, (INTERNET_STATUS_CALLBACK)InetStatusCallback);
+
+ //msdn.microsoft.com/library/default.asp?url=/workshop/components/offline/offline.asp#Supporting Offline Browsing in Applications and Components
+ ULONG longOpt;
+ DWORD cbio = sizeof(ULONG);
+ if (InternetQueryOption(g_hInetSes, INTERNET_OPTION_CONNECTED_STATE, &longOpt, &cbio))
+ {
+ if (INTERNET_STATE_DISCONNECTED_BY_USER&longOpt)
+ {
+ INTERNET_CONNECTED_INFO ci = {INTERNET_STATE_CONNECTED, 0};
+ InternetSetOption(g_hInetSes, INTERNET_OPTION_CONNECTED_STATE, &ci, sizeof(ci));
+ }
+ }
+
+ // Change the default connect timeout if specified.
+ if(g_ConnectTimeout > 0)
+ {
+ InternetSetOption(g_hInetSes, INTERNET_OPTION_CONNECT_TIMEOUT,
+ &g_ConnectTimeout, sizeof(g_ConnectTimeout));
+ }
+
+ // Change the default receive timeout if specified.
+ if (g_ReceiveTimeout)
+ {
+ InternetSetOption(g_hInetSes, INTERNET_OPTION_RECEIVE_TIMEOUT,
+ &g_ReceiveTimeout, sizeof(DWORD));
+ }
+ }
+
+ DWORD ec = ERROR_SUCCESS;
+ hLocalFile = CreateFile(pFile->text, GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_DELETE,
+ NULL, OPEN_ALWAYS, 0, NULL);
+ if (INVALID_HANDLE_VALUE == hLocalFile)
+ {
+ TRACE(_T("InetBgDl: CreateFile file handle invalid\n"));
+ goto diegle;
+ }
+ if (GetLastError() == ERROR_ALREADY_EXISTS) {
+ // Resuming a download that was started earlier and then aborted.
+ previouslyWritten = GetFileSize(hLocalFile, NULL);
+ g_cbCurrXF = previouslyWritten;
+ SetFilePointer(hLocalFile, previouslyWritten, NULL, FILE_BEGIN);
+ }
+
+ const DWORD IOURedirFlags = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP |
+ INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS;
+ const DWORD IOUCacheFlags = INTERNET_FLAG_RESYNCHRONIZE |
+ INTERNET_FLAG_NO_CACHE_WRITE |
+ INTERNET_FLAG_PRAGMA_NOCACHE |
+ INTERNET_FLAG_RELOAD;
+ const DWORD IOUCookieFlags = INTERNET_FLAG_NO_COOKIES;
+ DWORD IOUFlags = IOURedirFlags | IOUCacheFlags | IOUCookieFlags |
+ INTERNET_FLAG_NO_UI | INTERNET_FLAG_EXISTING_CONNECT;
+
+ TCHAR *hostname = (TCHAR*) GlobalAlloc(GPTR, MAX_STRLEN * sizeof(TCHAR)),
+ *urlpath = (TCHAR*) GlobalAlloc(GPTR, MAX_STRLEN * sizeof(TCHAR)),
+ *extrainfo = (TCHAR*) GlobalAlloc(GPTR, MAX_STRLEN * sizeof(TCHAR));
+
+ URL_COMPONENTS uc = { sizeof(URL_COMPONENTS), NULL, 0, (INTERNET_SCHEME)0,
+ hostname, MAX_STRLEN, (INTERNET_PORT)0, NULL, 0,
+ NULL, 0, urlpath, MAX_STRLEN, extrainfo, MAX_STRLEN};
+ uc.dwHostNameLength = uc.dwUrlPathLength = uc.dwExtraInfoLength = MAX_STRLEN;
+
+ if (!InternetCrackUrl(pURL->text, 0, ICU_ESCAPE, &uc))
+ {
+ // Bad url or param passed in
+ TRACE(_T("InetBgDl: InternetCrackUrl false with url=%s, gle=%u\n"),
+ pURL->text, GetLastError());
+ goto diegle;
+ }
+
+ TRACE(_T("InetBgDl: scheme_id=%d, hostname=%s, port=%d, urlpath=%s, extrainfo=%s\n"),
+ uc.nScheme, hostname, uc.nPort, urlpath, extrainfo);
+
+ // Only http and https are supported
+ if (uc.nScheme != INTERNET_SCHEME_HTTP &&
+ uc.nScheme != INTERNET_SCHEME_HTTPS)
+ {
+ TRACE(_T("InetBgDl: only http and https is supported, aborting...\n"));
+ goto diegle;
+ }
+
+ // Tell the server to pick up wherever we left off.
+ TCHAR headers[32];
+ // We're skipping building the C runtime to keep the file size low, so we
+ // can't use a normal string initialization because that would call memset.
+ headers[0] = _T('\0');
+ wsprintf(headers, _T("Range: bytes=%d-\r\n"), previouslyWritten);
+
+ TRACE(_T("InetBgDl: calling InternetOpenUrl with url=%s\n"), pURL->text);
+ g_hInetFile = InternetOpenUrl(g_hInetSes, pURL->text,
+ headers, -1, IOUFlags |
+ (uc.nScheme == INTERNET_SCHEME_HTTPS ?
+ INTERNET_FLAG_SECURE : 0), 1);
+ if (!g_hInetFile)
+ {
+ TRACE(_T("InetBgDl: InternetOpenUrl failed with gle=%u\n"),
+ GetLastError());
+ goto diegle;
+ }
+
+ // Get the file length via the Content-Length header
+ FILESIZE_T cbThisFile;
+ cbio = sizeof(cbThisFile);
+ if (!HttpQueryInfo(g_hInetFile,
+ HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
+ &cbThisFile, &cbio, NULL))
+ {
+ cbThisFile = FILESIZE_UNKNOWN;
+ }
+ TRACE(_T("InetBgDl: file size=%d bytes\n"), cbThisFile);
+
+ // Use a 4MiB read buffer for the connection.
+ // Bigger buffers will be faster.
+ // cbReadBufXF should be a multiple of g_cbBufXF.
+ const UINT cbReadBufXF = 4194304;
+
+ // Up the default internal buffer size from 4096 to internalReadBufferSize.
+ DWORD internalReadBufferSize = cbReadBufXF;
+ if (!InternetSetOption(g_hInetFile, INTERNET_OPTION_READ_BUFFER_SIZE,
+ &internalReadBufferSize, sizeof(DWORD)))
+ {
+ TRACE(_T("InetBgDl: InternetSetOption failed to set read buffer size to %u bytes, gle=%u\n"),
+ internalReadBufferSize, GetLastError());
+
+ // Maybe it's too big, try half of the optimal value. If that fails just
+ // use the default.
+ internalReadBufferSize /= 2;
+ if (!InternetSetOption(g_hInetFile, INTERNET_OPTION_READ_BUFFER_SIZE,
+ &internalReadBufferSize, sizeof(DWORD)))
+ {
+ TRACE(_T("InetBgDl: InternetSetOption failed to set read buffer size ") \
+ _T("to %u bytes (using default read buffer size), gle=%u\n"),
+ internalReadBufferSize, GetLastError());
+ }
+ }
+
+ for(;;)
+ {
+ DWORD cbio = 0, cbXF = 0;
+ BOOL retXF = InternetReadFile(g_hInetFile, g_bufXF, g_cbBufXF, &cbio);
+ if (!retXF)
+ {
+ ec = GetLastError();
+ TRACE(_T("InetBgDl: InternetReadFile failed, gle=%u\n"), ec);
+ if (ERROR_INTERNET_CONNECTION_ABORTED == ec ||
+ ERROR_INTERNET_CONNECTION_RESET == ec)
+ {
+ ec = ERROR_BROKEN_PIPE;
+ }
+ break;
+ }
+
+ if (0 == cbio)
+ {
+ ASSERT(ERROR_SUCCESS == ec);
+ // EOF or broken connection?
+ // TODO: Can InternetQueryDataAvailable detect this?
+
+ TRACE(_T("InetBgDl: InternetReadFile true with 0 cbio, cbThisFile=%d, gle=%u\n"),
+ cbThisFile, GetLastError());
+ // If we haven't transferred all of the file, and we know how big the file
+ // is, and we have no more data to read from the HTTP request, then set a
+ // broken pipe error. Reading without StatsLock is ok in this thread.
+ if (FILESIZE_UNKNOWN != cbThisFile && writtenThisSession != cbThisFile)
+ {
+ TRACE(_T("InetBgDl: expected Content-Length of %d bytes, ")
+ _T("but transferred %d bytes\n"),
+ cbThisFile, writtenThisSession);
+ ec = ERROR_BROKEN_PIPE;
+ }
+ break;
+ }
+
+ // Check if we canceled the download
+ if (0 == g_FilesTotal)
+ {
+ TRACE(_T("InetBgDl: 0 == g_FilesTotal, aborting transfer loop...\n"));
+ ec = ERROR_CANCELLED;
+ break;
+ }
+
+ cbXF = cbio;
+ if (cbXF)
+ {
+ retXF = WriteFile(hLocalFile, g_bufXF, cbXF, &cbio, NULL);
+ if (!retXF || cbXF != cbio)
+ {
+ ec = GetLastError();
+ break;
+ }
+
+ StatsLock_AcquireExclusive();
+ if (FILESIZE_UNKNOWN != cbThisFile) {
+ g_cbCurrTot = cbThisFile;
+ }
+ writtenThisSession += cbXF;
+ g_cbCurrXF += cbXF;
+ StatsLock_ReleaseExclusive();
+ }
+ }
+
+ TRACE(_T("InetBgDl: TaskThreadProc completed %s, ec=%u\n"), pURL->text, ec);
+ InternetCloseHandle(g_hInetFile);
+ g_hInetFile = nullptr;
+ if (ERROR_SUCCESS == ec)
+ {
+ if (INVALID_HANDLE_VALUE != hLocalFile)
+ {
+ CloseHandle(hLocalFile);
+ hLocalFile = INVALID_HANDLE_VALUE;
+ }
+ StackFreeItem(pURL);
+ StackFreeItem(pFile);
+ ++completedFile;
+ }
+ else if (ERROR_BROKEN_PIPE == ec)
+ {
+ g_Status = STATUS_ERR_CONNECTION_LOST;
+ goto die;
+ }
+ else
+ {
+ TRACE(_T("InetBgDl: failed with ec=%u\n"), ec);
+ SetLastError(ec);
+ goto diegle;
+ }
+ goto startnexttask;
+}
+
+NSISPIEXPORTFUNC Get(HWND hwndNSIS, UINT N_CCH, TCHAR*N_Vars, NSIS::stack_t**ppST, NSIS::xparams_t*pX)
+{
+ pX->RegisterPluginCallback(g_hInst, NSISPluginCallback);
+ for (;;)
+ {
+ NSIS::stack_t*pURL = StackPopItem(ppST);
+ if (!pURL)
+ {
+ break;
+ }
+
+ if (lstrcmpi(pURL->text, _T("/connecttimeout")) == 0)
+ {
+ NSIS::stack_t*pConnectTimeout = StackPopItem(ppST);
+ g_ConnectTimeout = MyTStrToL(pConnectTimeout->text) * 1000;
+ continue;
+ }
+ else if (lstrcmpi(pURL->text, _T("/receivetimeout")) == 0)
+ {
+ NSIS::stack_t*pReceiveTimeout = StackPopItem(ppST);
+ g_ReceiveTimeout = MyTStrToL(pReceiveTimeout->text) * 1000;
+ continue;
+ }
+ else if (lstrcmpi(pURL->text, _T("/reset")) == 0)
+ {
+ StackFreeItem(pURL);
+ Reset();
+ continue;
+ }
+ else if (lstrcmpi(pURL->text, _T("/end")) == 0)
+ {
+freeurlandexit:
+ StackFreeItem(pURL);
+ break;
+ }
+
+ NSIS::stack_t*pFile = StackPopItem(ppST);
+ if (!pFile)
+ {
+ goto freeurlandexit;
+ }
+
+ TaskLock_AcquireExclusive();
+
+ pFile->next = NULL;
+ pURL->next = pFile;
+ NSIS::stack_t*pTasksTail = g_pLocations;
+ while(pTasksTail && pTasksTail->next) pTasksTail = pTasksTail->next;
+ if (pTasksTail)
+ {
+ pTasksTail->next = pURL;
+ }
+ else
+ {
+ g_pLocations = pURL;
+ }
+
+ if (!g_hThread)
+ {
+ DWORD tid;
+ if (g_hGETStartedEvent) {
+ CloseHandle(g_hGETStartedEvent);
+ }
+ g_hGETStartedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ g_hThread = CreateThread(NULL, 0, TaskThreadProc, NULL, 0, &tid);
+ }
+
+ if (!g_hThread)
+ {
+ goto freeurlandexit;
+ }
+
+#ifndef ONELOCKTORULETHEMALL
+ StatsLock_AcquireExclusive();
+#endif
+ ++g_FilesTotal;
+#ifndef ONELOCKTORULETHEMALL
+ StatsLock_ReleaseExclusive();
+#endif
+ TaskLock_ReleaseExclusive();
+ }
+}
+
+NSISPIEXPORTFUNC GetStats(HWND hwndNSIS, UINT N_CCH, TCHAR*N_Vars, NSIS::stack_t**ppST, NSIS::xparams_t*pX)
+{
+ NSISPI_INITGLOBALS(N_CCH, N_Vars);
+ StatsLock_AcquireShared();
+ NSIS_SetRegUINT(0, g_Status);
+ NSIS_SetRegUINT(1, g_FilesCompleted);
+ NSIS_SetRegUINT(2, g_FilesTotal - g_FilesCompleted);
+ NSIS_SetRegUINT(3, g_cbCurrXF);
+ NSIS_SetRegStrEmpty(4);
+ if (FILESIZE_UNKNOWN != g_cbCurrTot)
+ {
+ NSIS_SetRegUINT(4, g_cbCurrTot);
+ }
+ NSIS_SetRegStr(5, g_ServerIP);
+ StatsLock_ReleaseShared();
+}
+
+BOOL WINAPI DllMain(HINSTANCE hInst, ULONG Reason, LPVOID pCtx)
+{
+ if (DLL_PROCESS_ATTACH==Reason)
+ {
+ g_hInst=hInst;
+ InitializeCriticalSection(&g_CritLock);
+ }
+ return TRUE;
+}
diff --git a/other-licenses/nsis/Contrib/InetBgDL/InetBgDL.h b/other-licenses/nsis/Contrib/InetBgDL/InetBgDL.h
new file mode 100644
index 0000000000..b0397ab7a0
--- /dev/null
+++ b/other-licenses/nsis/Contrib/InetBgDL/InetBgDL.h
@@ -0,0 +1,59 @@
+//
+// Copyright (C) Anders Kjersem. Licensed under the zlib/libpng license
+//
+
+#ifdef UNICODE
+# ifndef _UNICODE
+# define _UNICODE
+# endif
+#endif
+
+#define _WIN32_WINNT 0x0400
+#include <windows.h>
+#include <tchar.h>
+#include <wininet.h>
+
+#if defined(_DEBUG) || 0
+# define PLUGIN_DEBUG 1
+void MYTRACE(LPCTSTR fmt, ...)
+{
+ va_list argptr;
+ va_start(argptr, fmt);
+ TCHAR buffer[2048] = { _T('\0') };
+ wvsprintf(buffer, fmt, argptr);
+ buffer[(sizeof(buffer)/sizeof(*buffer)) - 1] = _T('\0');
+ OutputDebugString(buffer);
+ va_end(argptr);
+}
+#else
+void MYTRACE(...) { }
+#endif
+# define TRACE MYTRACE
+
+#ifndef ASSERT
+# define ASSERT(x)
+#endif
+
+#define NSISPIEXPORTFUNC EXTERN_C void __declspec(dllexport) __cdecl
+
+namespace NSIS {
+
+#define NSISCALL __stdcall
+typedef struct _xparams_t {
+ LPVOID xx1;//exec_flags_type *exec_flags;
+ int (NSISCALL *ExecuteCodeSegment)(int, HWND);
+ void (NSISCALL *validate_filename)(TCHAR*);
+ int (NSISCALL *RegisterPluginCallback)(HMODULE,LPVOID);
+} xparams_t;
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[1];
+} stack_t;
+
+} // namespace NSIS
+
+enum NSPIM
+{
+ NSPIM_UNLOAD,
+ NSPIM_GUIUNLOAD,
+};
diff --git a/other-licenses/nsis/Contrib/InetBgDL/InetBgDl.sln b/other-licenses/nsis/Contrib/InetBgDL/InetBgDl.sln
new file mode 100644
index 0000000000..0e84c0f982
--- /dev/null
+++ b/other-licenses/nsis/Contrib/InetBgDL/InetBgDl.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.28922.388
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InetBgDl", "InetBgDl.vcxproj", "{B9B76BC4-5C6C-4808-AC23-2C10126CDFC0}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B9B76BC4-5C6C-4808-AC23-2C10126CDFC0}.Debug|x86.ActiveCfg = Debug|Win32
+ {B9B76BC4-5C6C-4808-AC23-2C10126CDFC0}.Debug|x86.Build.0 = Debug|Win32
+ {B9B76BC4-5C6C-4808-AC23-2C10126CDFC0}.Release|x86.ActiveCfg = Release|Win32
+ {B9B76BC4-5C6C-4808-AC23-2C10126CDFC0}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {58385AF6-83F5-4D76-903D-2CFEDAFFCDC6}
+ EndGlobalSection
+EndGlobal
diff --git a/other-licenses/nsis/Contrib/InetBgDL/InetBgDl.vcxproj b/other-licenses/nsis/Contrib/InetBgDL/InetBgDl.vcxproj
new file mode 100644
index 0000000000..99b7684797
--- /dev/null
+++ b/other-licenses/nsis/Contrib/InetBgDL/InetBgDl.vcxproj
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="InetBgDL.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="InetBgDL.h" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>16.0</VCProjectVersion>
+ <ProjectGuid>{B9B76BC4-5C6C-4808-AC23-2C10126CDFC0}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>InetBgDl</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v142</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v142</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>WINVER=0x601;_WIN32_WINNT=0x601;WIN32;_DEBUG;INETBGDL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <ExceptionHandling>false</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableUAC>false</EnableUAC>
+ <AdditionalDependencies>wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MinSpace</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>WINVER=0x601;_WIN32_WINNT=0x601;WIN32;NDEBUG;INETBGDL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EnableUAC>false</EnableUAC>
+ <AdditionalDependencies>wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.cpp b/other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.cpp
new file mode 100644
index 0000000000..c891680549
--- /dev/null
+++ b/other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.cpp
@@ -0,0 +1,150 @@
+/* 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 file is an NSIS plugin which exports a function that pins a provided
+// Shortcut to the Windows Taskbar on Windows 10 (1903+) and Windows 11.
+// This is an adapted version of the Pin to Taskbar code that is used in
+// Firefox: https://searchfox.org/mozilla-central/rev/4bce7d85ba4796dd03c5dcc7cfe8eee0e4c07b3b/browser/components/shell/nsWindowsShellService.cpp#1178
+
+#include <objbase.h>
+#include <shlobj.h>
+
+#pragma comment(lib, "shlwapi.lib")
+
+static bool
+PinShortcutToTaskbar(const wchar_t *shortcutPath)
+{
+ // This enum is likely only used for Windows telemetry, INT_MAX is chosen to
+ // avoid confusion with existing uses.
+ enum PINNEDLISTMODIFYCALLER { PLMC_INT_MAX = INT_MAX };
+
+ // The types below, and the idea of using IPinnedList3::Modify,
+ // are thanks to Gee Law <https://geelaw.blog/entries/msedge-pins/>
+ static constexpr GUID CLSID_TaskbandPin = {
+ 0x90aa3a4e,
+ 0x1cba,
+ 0x4233,
+ {0xb8, 0xbb, 0x53, 0x57, 0x73, 0xd4, 0x84, 0x49}};
+
+ static constexpr GUID IID_IPinnedList3 = {
+ 0x0dd79ae2,
+ 0xd156,
+ 0x45d4,
+ {0x9e, 0xeb, 0x3b, 0x54, 0x97, 0x69, 0xe9, 0x40}};
+
+ struct IPinnedList3Vtbl;
+ struct IPinnedList3 {
+ IPinnedList3Vtbl* vtbl;
+ };
+
+ typedef ULONG STDMETHODCALLTYPE ReleaseFunc(IPinnedList3 * that);
+ typedef HRESULT STDMETHODCALLTYPE ModifyFunc(
+ IPinnedList3 * that, PCIDLIST_ABSOLUTE unpin, PCIDLIST_ABSOLUTE pin,
+ PINNEDLISTMODIFYCALLER caller);
+
+ struct IPinnedList3Vtbl {
+ void* QueryInterface; // 0
+ void* AddRef; // 1
+ ReleaseFunc* Release; // 2
+ void* Other[13]; // 3-15
+ ModifyFunc* Modify; // 16
+ };
+
+ PIDLIST_ABSOLUTE path = nullptr;
+ HRESULT hr = SHParseDisplayName(shortcutPath, nullptr, &path, 0, nullptr);
+ if (FAILED(hr) || !path) {
+ return false;
+ }
+
+ IPinnedList3* pinnedList = nullptr;
+ hr = CoCreateInstance(CLSID_TaskbandPin, nullptr, CLSCTX_INPROC_SERVER,
+ IID_IPinnedList3, (void**)&pinnedList);
+ if (FAILED(hr) || !pinnedList) {
+ return false;
+ }
+
+ hr = pinnedList->vtbl->Modify(pinnedList, nullptr, path, PLMC_INT_MAX);
+
+ pinnedList->vtbl->Release(pinnedList);
+ CoTaskMemFree(path);
+ return true;
+}
+
+struct stack_t {
+ stack_t* next;
+ TCHAR text[MAX_PATH];
+};
+
+/**
+ * Removes an element from the top of the NSIS stack
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param str The string to pop to
+ * @param len The max length
+ * @return 0 on success
+ */
+int
+popstring(stack_t **stacktop, TCHAR *str, int len)
+{
+ // Removes the element from the top of the stack and puts it in the buffer
+ stack_t *th;
+ if (!stacktop || !*stacktop) {
+ return 1;
+ }
+
+ th = (*stacktop);
+ lstrcpyn(str, th->text, len);
+ *stacktop = th->next;
+ HeapFree(GetProcessHeap(), 0, th);
+ return 0;
+}
+
+/**
+ * Adds an element to the top of the NSIS stack
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param str The string to push on the stack
+ * @param len The length of the string to push on the stack
+ * @return 0 on success
+ */
+void
+pushstring(stack_t **stacktop, const TCHAR *str, int len)
+{
+ stack_t *th;
+ if (!stacktop) {
+ return;
+ }
+ th = (stack_t*)HeapAlloc(GetProcessHeap(), 0, sizeof(stack_t) + len);
+ lstrcpyn(th->text, str, len);
+ th->next = *stacktop;
+ *stacktop = th;
+}
+
+/**
+* Pins a provided shortcut to the Taskbar on Windows 10 (1903) and up.
+*
+* @param stacktop Pointer to the top of the stack, AKA the first parameter to
+ the plugin call. Should contain the shortcut to pin.
+* @return 1 if the shortcut was pinned successfully, otherwise 0
+*/
+extern "C" void __declspec(dllexport)
+Pin(HWND, int, TCHAR *, stack_t **stacktop, void *)
+{
+ wchar_t shortcutPath[MAX_PATH + 1];
+ bool rv = false;
+ // We're skipping building the C runtime to keep the file size low, so we
+ // can't use a normal string initialization because that would call memset.
+ shortcutPath[0] = L'\0';
+ popstring(stacktop, shortcutPath, MAX_PATH);
+
+ rv = PinShortcutToTaskbar(shortcutPath);
+
+ pushstring(stacktop, rv ? L"1" : L"0", 2);
+}
+
+BOOL APIENTRY
+DllMain(HMODULE, DWORD, LPVOID)
+{
+ return TRUE;
+}
diff --git a/other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.sln b/other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.sln
new file mode 100644
index 0000000000..834ba1c920
--- /dev/null
+++ b/other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27428.2015
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PinToTaskbar", "PinToTaskbar.vcxproj", "{84FDFDE2-893F-418F-A524-4B8DACF11EB6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {84FDFDE2-893F-418F-A524-4B8DACF11EB6}.Debug|x64.ActiveCfg = Debug|x64
+ {84FDFDE2-893F-418F-A524-4B8DACF11EB6}.Debug|x64.Build.0 = Debug|x64
+ {84FDFDE2-893F-418F-A524-4B8DACF11EB6}.Debug|x86.ActiveCfg = Debug|Win32
+ {84FDFDE2-893F-418F-A524-4B8DACF11EB6}.Debug|x86.Build.0 = Debug|Win32
+ {84FDFDE2-893F-418F-A524-4B8DACF11EB6}.Release|x64.ActiveCfg = Release|x64
+ {84FDFDE2-893F-418F-A524-4B8DACF11EB6}.Release|x64.Build.0 = Release|x64
+ {84FDFDE2-893F-418F-A524-4B8DACF11EB6}.Release|x86.ActiveCfg = Release|Win32
+ {84FDFDE2-893F-418F-A524-4B8DACF11EB6}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {975FF9C9-7351-4314-BC67-F348FAC9ECB2}
+ EndGlobalSection
+EndGlobal
diff --git a/other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.vcxproj b/other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.vcxproj
new file mode 100644
index 0000000000..d62b345757
--- /dev/null
+++ b/other-licenses/nsis/Contrib/PinToTaskbar/PinToTaskbar.vcxproj
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{84fdfde2-893f-418f-a524-4b8dacf11eb6}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>PinToTaskbar</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>WIN32;_DEBUG;EXECINEXPLORER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>_DEBUG;EXECINEXPLORER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>WIN32;NDEBUG;EXECINEXPLORER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <PreprocessorDefinitions>NDEBUG;EXECINEXPLORER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <OmitDefaultLibName>true</OmitDefaultLibName>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EntryPointSymbol>DllMain</EntryPointSymbol>
+ <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="PinToTaskbar.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
diff --git a/other-licenses/nsis/Contrib/README b/other-licenses/nsis/Contrib/README
new file mode 100644
index 0000000000..8301fe26c4
--- /dev/null
+++ b/other-licenses/nsis/Contrib/README
@@ -0,0 +1,34 @@
+These directories contain modified source code to the NSIS Plugins used by the
+Windows installers.
+
+NSIS project page: http://nsis.sourceforge.net/
+NSIS Unicode port project page: http://www.scratchpaper.com/
+
+APPLICABLE LICENSES
+-------------------
+* All NSIS source code, plug-ins, documentation, examples, header files and
+ graphics, with the exception of the compression modules and where otherwise
+ noted, are licensed under the zlib/libpng license.
+
+* The zlib compression module for NSIS is licensed under the zlib/libpng
+ license.
+
+* The bzip2 compression module for NSIS is licensed under the bzip2 license.
+
+* The LZMA compression module for NSIS is licensed under the Common Public
+ License version 1.0.
+
+-------------------------------------------------------------------------------
+
+ExDLL NSIS Unicode source 2.38.1 for plugin projects
+http://www.scratchpaper.com/
+These files are required to compile the nsProcess and ShellLink plugins. No
+changes were made to these files.
+
+-------------------------------------------------------------------------------
+
+ApplicationID v1.0
+http://nsis.sourceforge.net/ApplicationID_plug-in
+Unicode support and taskbar resource deleteion was added for this plugin. A diff
+of the changes to the source is available at:
+https://bugzilla.mozilla.org/show_bug.cgi?id=521141
diff --git a/other-licenses/nsis/Contrib/ServicesHelper/Services.cpp b/other-licenses/nsis/Contrib/ServicesHelper/Services.cpp
new file mode 100644
index 0000000000..5c3d2fe59f
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ServicesHelper/Services.cpp
@@ -0,0 +1,241 @@
+/* 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 <windows.h>
+#include "../../../../toolkit/mozapps/update/common/pathhash.h"
+
+#pragma comment(lib, "advapi32.lib")
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[MAX_PATH];
+} stack_t;
+
+int popstring(stack_t **stacktop, LPTSTR str, int len);
+void pushstring(stack_t **stacktop, LPCTSTR str, int len);
+
+/**
+ * Determines if the specified service exists or not
+ *
+ * @param serviceName The name of the service to check
+ * @param exists Whether or not the service exists
+ * @return TRUE if there were no errors
+ */
+static BOOL
+IsServiceInstalled(LPCWSTR serviceName, BOOL &exists)
+{
+ exists = FALSE;
+
+ // Get a handle to the local computer SCM database with full access rights.
+ SC_HANDLE serviceManager = OpenSCManager(NULL, NULL,
+ SC_MANAGER_ENUMERATE_SERVICE);
+ if (!serviceManager) {
+ return FALSE;
+ }
+
+ SC_HANDLE serviceHandle = OpenServiceW(serviceManager,
+ serviceName,
+ SERVICE_QUERY_CONFIG);
+ if (!serviceHandle && GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST) {
+ CloseServiceHandle(serviceManager);
+ return FALSE;
+ }
+
+ if (serviceHandle) {
+ CloseServiceHandle(serviceHandle);
+ exists = TRUE;
+ }
+
+ CloseServiceHandle(serviceManager);
+ return TRUE;
+}
+
+/**
+ * Determines if the specified service is installed or not
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param variables A pointer to the NSIS variables
+ * @return 0 if the service does not exist
+ * 1 if the service does exist
+ * -1 if there was an error.
+ */
+extern "C" void __declspec(dllexport)
+IsInstalled(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop, void *extra)
+{
+ TCHAR tmp[MAX_PATH] = { L'\0' };
+ WCHAR serviceName[MAX_PATH] = { '\0' };
+ popstring(stacktop, tmp, MAX_PATH);
+
+#if !defined(UNICODE)
+ MultiByteToWideChar(CP_ACP, 0, tmp, -1, serviceName, MAX_PATH);
+#else
+ wcscpy(serviceName, tmp);
+#endif
+
+ BOOL serviceInstalled;
+ if (!IsServiceInstalled(serviceName, serviceInstalled)) {
+ pushstring(stacktop, TEXT("-1"), 3);
+ } else {
+ pushstring(stacktop, serviceInstalled ? TEXT("1") : TEXT("0"), 2);
+ }
+}
+
+/**
+ * Stops the specified service.
+ *
+ * @param serviceName The name of the service to stop
+ * @return TRUE if the operation was successful
+ */
+static BOOL
+StopService(LPCWSTR serviceName)
+{
+ // Get a handle to the local computer SCM database with full access rights.
+ SC_HANDLE serviceManager = OpenSCManager(NULL, NULL,
+ SC_MANAGER_ENUMERATE_SERVICE);
+ if (!serviceManager) {
+ return FALSE;
+ }
+
+ SC_HANDLE serviceHandle = OpenServiceW(serviceManager,
+ serviceName,
+ SERVICE_STOP);
+ if (!serviceHandle) {
+ CloseServiceHandle(serviceManager);
+ return FALSE;
+ }
+
+ //Stop the service so it deletes faster and so the uninstaller
+ // can actually delete its EXE.
+ DWORD totalWaitTime = 0;
+ SERVICE_STATUS status;
+ static const int maxWaitTime = 1000 * 60; // Never wait more than a minute
+ BOOL stopped = FALSE;
+ if (ControlService(serviceHandle, SERVICE_CONTROL_STOP, &status)) {
+ do {
+ Sleep(status.dwWaitHint);
+ // + 10 milliseconds to make sure we always approach maxWaitTime
+ totalWaitTime += (status.dwWaitHint + 10);
+ if (status.dwCurrentState == SERVICE_STOPPED) {
+ stopped = true;
+ break;
+ } else if (totalWaitTime > maxWaitTime) {
+ break;
+ }
+ } while (QueryServiceStatus(serviceHandle, &status));
+ }
+
+ CloseServiceHandle(serviceHandle);
+ CloseServiceHandle(serviceManager);
+ return stopped;
+}
+
+/**
+ * Stops the specified service
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param variables A pointer to the NSIS variables
+ * @return 1 if the service was stopped, 0 on error
+ */
+extern "C" void __declspec(dllexport)
+Stop(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop, void *extra)
+{
+ TCHAR tmp[MAX_PATH] = { L'\0' };
+ WCHAR serviceName[MAX_PATH] = { '\0' };
+
+ popstring(stacktop, tmp, MAX_PATH);
+
+#if !defined(UNICODE)
+ MultiByteToWideChar(CP_ACP, 0, tmp, -1, serviceName, MAX_PATH);
+#else
+ wcscpy(serviceName, tmp);
+#endif
+
+ if (StopService(serviceName)) {
+ pushstring(stacktop, TEXT("1"), 2);
+ } else {
+ pushstring(stacktop, TEXT("0"), 2);
+ }
+}
+
+/**
+ * Determines a unique registry path from a file or directory path
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param variables A pointer to the NSIS variables
+ * @return The unique registry path or an empty string on error
+ */
+extern "C" void __declspec(dllexport)
+PathToUniqueRegistryPath(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop,
+ void *extra)
+{
+ TCHAR tmp[MAX_PATH] = { L'\0' };
+ WCHAR installBasePath[MAX_PATH] = { '\0' };
+ popstring(stacktop, tmp, MAX_PATH);
+
+#if !defined(UNICODE)
+ MultiByteToWideChar(CP_ACP, 0, tmp, -1, installBasePath, MAX_PATH);
+#else
+ wcscpy(installBasePath, tmp);
+#endif
+
+ WCHAR registryPath[MAX_PATH + 1] = { '\0' };
+ if (CalculateRegistryPathFromFilePath(installBasePath, registryPath)) {
+ pushstring(stacktop, registryPath, wcslen(registryPath) + 1);
+ } else {
+ pushstring(stacktop, TEXT(""), 1);
+ }
+}
+
+BOOL WINAPI
+DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
+{
+ return TRUE;
+}
+
+/**
+ * Removes an element from the top of the NSIS stack
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param str The string to pop to
+ * @param len The max length
+ * @return 0 on success
+*/
+int popstring(stack_t **stacktop, TCHAR *str, int len)
+{
+ // Removes the element from the top of the stack and puts it in the buffer
+ stack_t *th;
+ if (!stacktop || !*stacktop) {
+ return 1;
+ }
+
+ th = (*stacktop);
+ lstrcpyn(str,th->text, len);
+ *stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+/**
+ * Adds an element to the top of the NSIS stack
+ *
+ * @param stacktop A pointer to the top of the stack
+ * @param str The string to push on the stack
+ * @param len The length of the string to push on the stack
+ * @return 0 on success
+*/
+void pushstring(stack_t **stacktop, const TCHAR *str, int len)
+{
+ stack_t *th;
+ if (!stacktop) {
+ return;
+ }
+
+ th = (stack_t*)GlobalAlloc(GPTR, sizeof(stack_t) + len);
+ lstrcpyn(th->text, str, len);
+ th->next = *stacktop;
+ *stacktop = th;
+}
diff --git a/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.dsp b/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.dsp
new file mode 100644
index 0000000000..8c9577c516
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.dsp
@@ -0,0 +1,115 @@
+# Microsoft Developer Studio Project File - Name="ServicesHelper" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=ServicesHelper - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ServicesHelper.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ServicesHelper.mak" CFG="ServicesHelper - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ServicesHelper - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "ServicesHelper - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ServicesHelper - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "EXDLL_EXPORTS" /D _WIN32_WINNT=0x0400 /FR /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib MSVCRT.LIB /nologo /entry:"DllMain" /dll /machine:I386 /nodefaultlib /out:"../../Plugins/ServicesHelper.dll" /opt:nowin98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "ServicesHelper - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "ServicesHelper - Win32 Release"
+# Name "ServicesHelper - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=\toolkit\mozapps\update\common\pathhash.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=\toolkit\mozapps\update\common\pathhash.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Services.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.dsw b/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.dsw
new file mode 100644
index 0000000000..c144217016
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "ServicesHelper"=.\ServicesHelper.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.sln b/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.sln
new file mode 100644
index 0000000000..348a8e3003
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServicesHelper", "ServicesHelper.vcproj", "{A0D0AD52-1D8B-402E-92EF-81AE0C320BD7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A0D0AD52-1D8B-402E-92EF-81AE0C320BD7}.Debug|Win32.ActiveCfg = Debug|Win32
+ {A0D0AD52-1D8B-402E-92EF-81AE0C320BD7}.Debug|Win32.Build.0 = Debug|Win32
+ {A0D0AD52-1D8B-402E-92EF-81AE0C320BD7}.Release|Win32.ActiveCfg = Release|Win32
+ {A0D0AD52-1D8B-402E-92EF-81AE0C320BD7}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.vcproj b/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.vcproj
new file mode 100644
index 0000000000..637fa5110f
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ServicesHelper/ServicesHelper.vcproj
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="ServicesHelper"
+ ProjectGUID="{A0D0AD52-1D8B-402E-92EF-81AE0C320BD7}"
+ RootNamespace="ServicesHelper"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../Plugins"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../toolkit/components/maintenanceservice/"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;APPLICATIONID_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../Plugins"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ ATLMinimizesCRunTimeLibraryUsage="true"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../toolkit/components/maintenanceservice/"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;APPLICATIONID_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\..\..\toolkit\mozapps\update\common\pathhash.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Services.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\resource.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\ServicesHelper.rc"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/other-licenses/nsis/Contrib/WebBrowser/CustomFunctions.cpp b/other-licenses/nsis/Contrib/WebBrowser/CustomFunctions.cpp
new file mode 100644
index 0000000000..4ad004b841
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/CustomFunctions.cpp
@@ -0,0 +1,75 @@
+// 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 "WebBrowser.h"
+#include "exdll.h"
+
+extern WebBrowser* gBrowser;
+void Init(HWND hWndParent, int string_size, TCHAR* variables,
+ stack_t** stacktop, extra_parameters* extra);
+
+static void CustomFunctionWrapper(void* NSISFunctionAddr, VARIANT jsArg,
+ VARIANT* retVal) {
+ // Marshal the argument passed to the JavaScript function onto the NSIS stack.
+ switch (jsArg.vt) {
+ case VT_BSTR:
+ pushstring(jsArg.bstrVal);
+ break;
+ case VT_I4: {
+ TCHAR intArgStr[32] = _T("");
+ _itot_s(jsArg.intVal, intArgStr, 10);
+ pushstring(intArgStr);
+ break;
+ }
+ case VT_BOOL:
+ pushstring(jsArg.boolVal == VARIANT_TRUE ? _T("1") : _T("0"));
+ break;
+ default:
+ // No other argument types supported.
+ pushstring(_T(""));
+ break;
+ }
+
+ // Call the NSIS function.
+ int rv = g_executeCodeSegment((int)NSISFunctionAddr, nullptr);
+
+ // Retrieve the return value from the NSIS stack.
+ TCHAR* nsisRetval =
+ (TCHAR*)HeapAlloc(GetProcessHeap(), 0, g_stringsize * sizeof(TCHAR));
+ popstring(nsisRetval);
+
+ // Pass the return value back to JavaScript, if it asked for one.
+ if (retVal) {
+ VariantInit(retVal);
+ retVal->vt = VT_BSTR;
+ retVal->bstrVal = SysAllocString(nsisRetval);
+ }
+
+ HeapFree(GetProcessHeap(), 0, nsisRetval);
+}
+
+PLUGINFUNCTION(RegisterCustomFunction) {
+ if (!gBrowser) {
+ Init(hWndParent, string_size, variables, stacktop, extra);
+ }
+
+ TCHAR* funcAddrStr =
+ (TCHAR*)HeapAlloc(GetProcessHeap(), 0, g_stringsize * sizeof(TCHAR));
+ popstring(funcAddrStr);
+
+ TCHAR* funcName =
+ (TCHAR*)HeapAlloc(GetProcessHeap(), 0, g_stringsize * sizeof(TCHAR));
+ popstring(funcName);
+
+ if (gBrowser && funcAddrStr && funcName) {
+ // Apparently GetFunctionAddress returnes a 1-indexed offset, but
+ // ExecuteCodeSegment expects a 0-indexed one. Or something.
+ uintptr_t funcAddr = static_cast<uintptr_t>(_ttoi64(funcAddrStr)) - 1;
+ gBrowser->AddCustomFunction(funcName, CustomFunctionWrapper,
+ (void*)funcAddr);
+ }
+
+ HeapFree(GetProcessHeap(), 0, funcName);
+ HeapFree(GetProcessHeap(), 0, funcAddrStr);
+}
diff --git a/other-licenses/nsis/Contrib/WebBrowser/Timers.cpp b/other-licenses/nsis/Contrib/WebBrowser/Timers.cpp
new file mode 100644
index 0000000000..00844b7091
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/Timers.cpp
@@ -0,0 +1,59 @@
+// 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 <windows.h>
+#include "exdll.h"
+
+static void APIENTRY TimerCallback(LPVOID NSISFunctionAddr, DWORD, DWORD) {
+ g_executeCodeSegment((int)NSISFunctionAddr, nullptr);
+}
+
+PLUGINFUNCTION(CreateTimer) {
+ EXDLL_INIT();
+ extra->RegisterPluginCallback(gHInst, NSISPluginCallback);
+
+ TCHAR* funcAddrStr =
+ (TCHAR*)HeapAlloc(GetProcessHeap(), 0, g_stringsize * sizeof(TCHAR));
+ popstring(funcAddrStr);
+ // Apparently GetFunctionAddress returnes a 1-indexed offset, but
+ // ExecuteCodeSegment expects a 0-indexed one. Or something.
+ uintptr_t funcAddr = static_cast<uintptr_t>(_ttoi64(funcAddrStr)) - 1;
+ HeapFree(GetProcessHeap(), 0, funcAddrStr);
+
+ TCHAR* intervalStr =
+ (TCHAR*)HeapAlloc(GetProcessHeap(), 0, g_stringsize * sizeof(TCHAR));
+ popstring(intervalStr);
+ long interval = _ttol(intervalStr);
+ HeapFree(GetProcessHeap(), 0, intervalStr);
+
+ HANDLE timer = CreateWaitableTimer(nullptr, FALSE, nullptr);
+ if (!timer) {
+ return;
+ }
+
+ // The interval we were passed is in milliseconds, so we need to convert it
+ // to the 100-nanosecond units that SetWaitableTimer expects. We also need to
+ // make it negative, because that's what signifies a relative offset from now
+ // instead of an epoch-based time stamp.
+ LARGE_INTEGER dueTime;
+ dueTime.QuadPart = -(interval * 10000);
+
+ SetWaitableTimer(timer, &dueTime, interval, TimerCallback, (void*)funcAddr,
+ FALSE);
+
+ TCHAR timerStr[32] = _T("");
+ _ltot_s((long)timer, timerStr, 10);
+ pushstring(timerStr);
+}
+
+PLUGINFUNCTION(CancelTimer) {
+ TCHAR* timerStr =
+ (TCHAR*)HeapAlloc(GetProcessHeap(), 0, g_stringsize * sizeof(TCHAR));
+ popstring(timerStr);
+ HANDLE timer = reinterpret_cast<HANDLE>(_ttoi(timerStr));
+ HeapFree(GetProcessHeap(), 0, timerStr);
+
+ CancelWaitableTimer(timer);
+ CloseHandle(timer);
+}
diff --git a/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.cpp b/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.cpp
new file mode 100644
index 0000000000..59e0a1d881
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.cpp
@@ -0,0 +1,604 @@
+// 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 "WebBrowser.h"
+#include <mshtmdid.h>
+
+WebBrowser::WebBrowser(HWND _hWndParent) : mHwndParent(_hWndParent) {
+ // Whatever executed this constructor owns our first reference.
+ AddRef();
+
+ HRESULT hr = ::OleCreate(CLSID_WebBrowser, IID_IOleObject, OLERENDER_DRAW, 0,
+ this, this, (void**)&mOleObject);
+ if (FAILED(hr)) {
+ return;
+ }
+
+ RECT posRect;
+ ::GetClientRect(mHwndParent, &posRect);
+
+ hr = mOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, nullptr, this, 0,
+ mHwndParent, &posRect);
+ if (FAILED(hr)) {
+ mOleObject->Release();
+ mOleObject = nullptr;
+ return;
+ }
+
+ SetRect(posRect);
+
+ hr = mOleObject->QueryInterface(&mWebBrowser2);
+ if (FAILED(hr)) {
+ mOleObject->Release();
+ mOleObject = nullptr;
+ return;
+ }
+
+ mWebBrowser2->put_Silent(VARIANT_TRUE);
+}
+
+WebBrowser::~WebBrowser() {
+ if (mWebBrowser2) {
+ mWebBrowser2->Release();
+ mWebBrowser2 = nullptr;
+ }
+ if (mOleInPlaceActiveObject) {
+ mOleInPlaceActiveObject->Release();
+ mOleInPlaceActiveObject = nullptr;
+ }
+ if (mOleInPlaceObject) {
+ mOleInPlaceObject->Release();
+ mOleInPlaceObject = nullptr;
+ }
+ if (mOleObject) {
+ mOleObject->Release();
+ mOleObject = nullptr;
+ }
+}
+
+void WebBrowser::Shutdown() {
+ if (mOleObject) {
+ mOleObject->Close(OLECLOSE_NOSAVE);
+ mOleObject->SetClientSite(nullptr);
+ }
+}
+
+bool WebBrowser::IsInitialized() { return mOleObject != nullptr; }
+
+HRESULT WebBrowser::ActiveObjectTranslateAccelerator(bool tab, LPMSG lpmsg) {
+ if (IsInitialized() && mOleInPlaceActiveObject) {
+ HRESULT hr = mOleInPlaceActiveObject->TranslateAcceleratorW(lpmsg);
+ if (hr == S_FALSE && tab) {
+ // The browser control will give up focus, but it is the only control so
+ // it would get focus again via IsDialogMessage. This does not result in
+ // the focus returning to the web page, though, so instead let the
+ // control process the tab again.
+ hr = mOleInPlaceActiveObject->TranslateAcceleratorW(lpmsg);
+ }
+ return hr;
+ } else {
+ return S_FALSE;
+ }
+}
+
+void WebBrowser::SetRect(const RECT& _rc) {
+ mRect = _rc;
+
+ if (mOleInPlaceObject) {
+ mOleInPlaceObject->SetObjectRects(&mRect, &mRect);
+ }
+}
+
+void WebBrowser::Resize(DWORD width, DWORD height) {
+ RECT r = mRect;
+ r.bottom = r.top + height;
+ r.right = r.left + width;
+ SetRect(r);
+}
+
+void WebBrowser::Navigate(wchar_t* url) {
+ if (!IsInitialized()) {
+ return;
+ }
+
+ VARIANT flags;
+ VariantInit(&flags);
+ flags.vt = VT_I4;
+ flags.intVal = navNoHistory | navEnforceRestricted | navUntrustedForDownload |
+ navBlockRedirectsXDomain;
+
+ mWebBrowser2->Navigate(url, &flags, nullptr, nullptr, nullptr);
+}
+
+void WebBrowser::AddCustomFunction(wchar_t* name, CustomFunction function,
+ void* arg) {
+ CustomFunctionRecord record = {name, function, arg};
+
+// We've disabled exceptions but push_back can throw on an allocation
+// failure, so we need to suppress a warning trying to tell us that
+// that combination doesn't make any sense.
+#pragma warning(suppress : 4530)
+ mCustomFunctions.push_back(record);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// IUnknown
+//////////////////////////////////////////////////////////////////////////////
+// This is a standard IUnknown implementation, we don't need anything special.
+
+HRESULT STDMETHODCALLTYPE WebBrowser::QueryInterface(REFIID riid,
+ void** ppvObject) {
+ if (riid == __uuidof(IUnknown)) {
+ *ppvObject = static_cast<IOleClientSite*>(this);
+ } else if (riid == __uuidof(IOleClientSite)) {
+ *ppvObject = static_cast<IOleClientSite*>(this);
+ } else if (riid == __uuidof(IOleInPlaceSite)) {
+ *ppvObject = static_cast<IOleInPlaceSite*>(this);
+ } else if (riid == __uuidof(IDropTarget)) {
+ *ppvObject = static_cast<IDropTarget*>(this);
+ } else if (riid == __uuidof(IStorage)) {
+ *ppvObject = static_cast<IStorage*>(this);
+ } else if (riid == __uuidof(IDocHostUIHandler)) {
+ *ppvObject = static_cast<IDocHostUIHandler*>(this);
+ } else if (riid == __uuidof(IDocHostShowUI)) {
+ *ppvObject = static_cast<IDocHostShowUI*>(this);
+ } else if (riid == __uuidof(IDispatch)) {
+ *ppvObject = static_cast<IDispatch*>(this);
+ } else {
+ *ppvObject = nullptr;
+ return E_NOINTERFACE;
+ }
+
+ AddRef();
+ return S_OK;
+}
+
+ULONG STDMETHODCALLTYPE WebBrowser::AddRef() {
+ return InterlockedIncrement(&mComRefCount);
+}
+
+ULONG STDMETHODCALLTYPE WebBrowser::Release() {
+ ULONG refCount = InterlockedDecrement(&mComRefCount);
+ if (refCount == 0) {
+ delete this;
+ }
+ return refCount;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// IOleWindow
+//////////////////////////////////////////////////////////////////////////////
+
+HRESULT STDMETHODCALLTYPE
+WebBrowser::GetWindow(__RPC__deref_out_opt HWND* phwnd) {
+ *phwnd = mHwndParent;
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::ContextSensitiveHelp(BOOL fEnterMode) {
+ // We don't provide context-sensitive help.
+ return E_NOTIMPL;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// IOleInPlaceSite
+//////////////////////////////////////////////////////////////////////////////
+
+HRESULT STDMETHODCALLTYPE WebBrowser::CanInPlaceActivate() {
+ // We always support in-place activation.
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::OnInPlaceActivate() {
+ OleLockRunning(mOleObject, TRUE, FALSE);
+ mOleObject->QueryInterface(&mOleInPlaceObject);
+ mOleInPlaceObject->QueryInterface(&mOleInPlaceActiveObject);
+ mOleInPlaceObject->SetObjectRects(&mRect, &mRect);
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::OnUIActivate() {
+ // Nothing to do before activating the control's UI.
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::GetWindowContext(
+ __RPC__deref_out_opt IOleInPlaceFrame** ppFrame,
+ __RPC__deref_out_opt IOleInPlaceUIWindow** ppDoc,
+ __RPC__out LPRECT lprcPosRect, __RPC__out LPRECT lprcClipRect,
+ __RPC__inout LPOLEINPLACEFRAMEINFO lpFrameInfo) {
+ *ppFrame = nullptr;
+ *ppDoc = nullptr;
+ *lprcPosRect = mRect;
+ *lprcClipRect = mRect;
+
+ lpFrameInfo->fMDIApp = false;
+ lpFrameInfo->hwndFrame = mHwndParent;
+ lpFrameInfo->haccel = nullptr;
+ lpFrameInfo->cAccelEntries = 0;
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::Scroll(SIZE scrollExtant) {
+ // We should have disabled all scrollbars.
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::OnUIDeactivate(BOOL fUndoable) {
+ // Nothing to do after deactivating the control's UI.
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::OnInPlaceDeactivate() {
+ if (mOleInPlaceObject) {
+ mOleInPlaceObject->Release();
+ mOleInPlaceObject = nullptr;
+ }
+
+ return S_OK;
+}
+
+// We don't support the concept of undo.
+HRESULT STDMETHODCALLTYPE WebBrowser::DiscardUndoState() { return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE WebBrowser::DeactivateAndUndo() { return E_NOTIMPL; }
+
+// We don't support moving or resizing the control.
+HRESULT STDMETHODCALLTYPE
+WebBrowser::OnPosRectChange(__RPC__in LPCRECT lprcPosRect) {
+ return E_NOTIMPL;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// IOleClientSite
+//////////////////////////////////////////////////////////////////////////////
+// We don't need anything that IOleClientSite does, because we're doing OLE
+// only in the most basic sense and we don't support linking (or, indeed,
+// embedding), but some implementation of this interface is required for
+// OleCreate to work, so we have to have a stub version.
+
+HRESULT STDMETHODCALLTYPE WebBrowser::SaveObject() { return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE
+WebBrowser::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker,
+ __RPC__deref_out_opt IMoniker** ppmk) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE
+WebBrowser::GetContainer(__RPC__deref_out_opt IOleContainer** ppContainer) {
+ *ppContainer = nullptr;
+ return E_NOINTERFACE;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::ShowObject() { return S_OK; }
+
+HRESULT STDMETHODCALLTYPE WebBrowser::OnShowWindow(BOOL fShow) { return S_OK; }
+
+HRESULT STDMETHODCALLTYPE WebBrowser::RequestNewObjectLayout() {
+ return E_NOTIMPL;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// IDropTarget
+//////////////////////////////////////////////////////////////////////////////
+// This is a stub implementation which blocks all dropping. The main reason we
+// want to do that is prevent accidentally dropping something on the control
+// and having it navigate, because there's no recovering from that except to
+// restart the app, and also it would look ridiculous. There could also be
+// security implications though, which we'd rather just avoid engaging with
+// altogether if we can.
+
+HRESULT STDMETHODCALLTYPE
+WebBrowser::DragEnter(__RPC__in_opt IDataObject* pDataObj, DWORD grfKeyState,
+ POINTL pt, __RPC__inout DWORD* pdwEffect) {
+ *pdwEffect = DROPEFFECT_NONE;
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::DragOver(DWORD grfKeyState, POINTL pt,
+ __RPC__inout DWORD* pdwEffect) {
+ *pdwEffect = DROPEFFECT_NONE;
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::DragLeave() { return S_OK; }
+
+HRESULT STDMETHODCALLTYPE WebBrowser::Drop(__RPC__in_opt IDataObject* pDataObj,
+ DWORD grfKeyState, POINTL pt,
+ __RPC__inout DWORD* pdwEffect) {
+ *pdwEffect = DROPEFFECT_NONE;
+ return S_OK;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// IStorage
+//////////////////////////////////////////////////////////////////////////////
+// We don't need anything that IStorage does, but we have to pass some
+// implementation of it to OleCreate, so we need to have a stub version.
+
+HRESULT STDMETHODCALLTYPE WebBrowser::CreateStream(
+ __RPC__in_string const OLECHAR* pwcsName, DWORD grfMode, DWORD reserved1,
+ DWORD reserved2, __RPC__deref_out_opt IStream** ppstm) {
+ *ppstm = nullptr;
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::OpenStream(const OLECHAR* pwcsName,
+ void* reserved1, DWORD grfMode,
+ DWORD reserved2,
+ IStream** ppstm) {
+ *ppstm = nullptr;
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::CreateStorage(
+ __RPC__in_string const OLECHAR* pwcsName, DWORD grfMode, DWORD reserved1,
+ DWORD reserved2, __RPC__deref_out_opt IStorage** ppstg) {
+ *ppstg = nullptr;
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE
+WebBrowser::OpenStorage(__RPC__in_opt_string const OLECHAR* pwcsName,
+ __RPC__in_opt IStorage* pstgPriority, DWORD grfMode,
+ __RPC__deref_opt_in_opt SNB snbExclude, DWORD reserved,
+ __RPC__deref_out_opt IStorage** ppstg) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::CopyTo(DWORD ciidExclude,
+ const IID* rgiidExclude,
+ __RPC__in_opt SNB snbExclude,
+ IStorage* pstgDest) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::MoveElementTo(
+ __RPC__in_string const OLECHAR* pwcsName, __RPC__in_opt IStorage* pstgDest,
+ __RPC__in_string const OLECHAR* pwcsNewName, DWORD grfFlags) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::Commit(DWORD grfCommitFlags) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::Revert() { return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE WebBrowser::EnumElements(DWORD reserved1,
+ void* reserved2,
+ DWORD reserved3,
+ IEnumSTATSTG** ppenum) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE
+WebBrowser::DestroyElement(__RPC__in_string const OLECHAR* pwcsName) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE
+WebBrowser::RenameElement(__RPC__in_string const OLECHAR* pwcsOldName,
+ __RPC__in_string const OLECHAR* pwcsNewName) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::SetElementTimes(
+ __RPC__in_opt_string const OLECHAR* pwcsName,
+ __RPC__in_opt const FILETIME* pctime, __RPC__in_opt const FILETIME* patime,
+ __RPC__in_opt const FILETIME* pmtime) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::SetClass(__RPC__in REFCLSID clsid) {
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::SetStateBits(DWORD grfStateBits,
+ DWORD grfMask) {
+ return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebBrowser::Stat(__RPC__out STATSTG* pstatstg,
+ DWORD grfStatFlag) {
+ return E_NOTIMPL;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// IDocHostUIHandler
+//////////////////////////////////////////////////////////////////////////////
+// Our implementation for this interface is basically all about disabling
+// things that we don't want/need.
+
+HRESULT __stdcall WebBrowser::ShowContextMenu(DWORD dwID, POINT* ppt,
+ IUnknown* pcmdtReserved,
+ IDispatch* pdispReserved) {
+ // Returning S_OK signals that we've handled the request for a context menu
+ // (which we did, by doing nothing), so the control won't try to open one.
+ return S_OK;
+}
+
+HRESULT __stdcall WebBrowser::GetHostInfo(DOCHOSTUIINFO* pInfo) {
+ pInfo->cbSize = sizeof(DOCHOSTUIINFO);
+ pInfo->dwFlags =
+ DOCHOSTUIFLAG_DIALOG | DOCHOSTUIFLAG_DISABLE_HELP_MENU |
+ DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_SCROLL_NO |
+ DOCHOSTUIFLAG_OPENNEWWIN | DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY |
+ DOCHOSTUIFLAG_THEME | DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK |
+ DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL | DOCHOSTUIFLAG_DPI_AWARE;
+ pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
+ pInfo->pchHostCss = nullptr;
+ pInfo->pchHostNS = nullptr;
+ return S_OK;
+}
+
+HRESULT __stdcall WebBrowser::ShowUI(DWORD dwID,
+ IOleInPlaceActiveObject* pActiveObject,
+ IOleCommandTarget* pCommandTarget,
+ IOleInPlaceFrame* pFrame,
+ IOleInPlaceUIWindow* pDoc) {
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall WebBrowser::HideUI() { return E_NOTIMPL; }
+
+HRESULT __stdcall WebBrowser::UpdateUI() { return E_NOTIMPL; }
+
+HRESULT __stdcall WebBrowser::EnableModeless(BOOL fEnable) { return E_NOTIMPL; }
+
+HRESULT __stdcall WebBrowser::OnDocWindowActivate(BOOL fActivate) {
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall WebBrowser::OnFrameWindowActivate(BOOL fActivate) {
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall WebBrowser::ResizeBorder(LPCRECT prcBorder,
+ IOleInPlaceUIWindow* pUIWindow,
+ BOOL fRameWindow) {
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall WebBrowser::TranslateAccelerator(LPMSG lpMsg,
+ const GUID* pguidCmdGroup,
+ DWORD nCmdID) {
+ return S_FALSE;
+}
+
+HRESULT __stdcall WebBrowser::GetOptionKeyPath(LPOLESTR* pchKey, DWORD dw) {
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall WebBrowser::GetDropTarget(IDropTarget* pDropTarget,
+ IDropTarget** ppDropTarget) {
+ // The IDropTarget implementation that we need is an empty stub, so we'll do
+ // the easy and convenient thing and just use this object.
+ return QueryInterface(IID_PPV_ARGS(ppDropTarget));
+}
+
+HRESULT __stdcall WebBrowser::GetExternal(IDispatch** ppDispatch) {
+ // This object has to implement IDispatch anyway so that we can use
+ // DISPID_AMBIENT_DLCONTROL, so we'll make this the external handler also.
+ return QueryInterface(IID_PPV_ARGS(ppDispatch));
+}
+
+HRESULT __stdcall WebBrowser::TranslateUrl(DWORD dwTranslate, LPWSTR pchURLIn,
+ LPWSTR* ppchURLOut) {
+ *ppchURLOut = nullptr;
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall WebBrowser::FilterDataObject(IDataObject* pDO,
+ IDataObject** ppDORet) {
+ *ppDORet = nullptr;
+ return E_NOTIMPL;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// IDocHostShowUI
+//////////////////////////////////////////////////////////////////////////////
+
+HRESULT __stdcall WebBrowser::ShowMessage(HWND hwnd, LPOLESTR lpstrText,
+ LPOLESTR lpstrCaption, DWORD dwType,
+ LPOLESTR lpstrHelpFile,
+ DWORD dwHelpContext,
+ LRESULT* plResult) {
+ // Don't allow MSHTML to generate message boxes.
+ return S_OK;
+}
+
+HRESULT __stdcall WebBrowser::ShowHelp(HWND hwnd, LPOLESTR pszHelpFile,
+ UINT uCommand, DWORD dwData,
+ POINT ptMouse,
+ IDispatch* pDispatchObjectHit) {
+ // Don't allow MSHTML to show any help.
+ return S_OK;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// IDispatch
+//////////////////////////////////////////////////////////////////////////////
+
+// We're not using a type library.
+HRESULT __stdcall WebBrowser::GetTypeInfoCount(UINT* pctinfo) {
+ if (pctinfo) {
+ *pctinfo = 0;
+ }
+ return S_OK;
+}
+
+HRESULT __stdcall WebBrowser::GetTypeInfo(UINT iTInfo, LCID lcid,
+ ITypeInfo** ppTInfo) {
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall WebBrowser::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+ UINT cNames, LCID lcid,
+ DISPID* rgDispId) {
+ if (cNames != 1) {
+ return E_NOTIMPL;
+ }
+
+ for (size_t i = 0; i < mCustomFunctions.size(); ++i) {
+ if (mCustomFunctions[i].mName == rgszNames[0]) {
+ // DISPID values need to be 1-indexed because 0 is reserved
+ // (DISPID_VALUE).
+ *rgDispId = i + 1;
+ return S_OK;
+ }
+ }
+
+ *rgDispId = DISPID_UNKNOWN;
+ return DISP_E_UNKNOWNNAME;
+}
+
+HRESULT __stdcall WebBrowser::Invoke(DISPID dispIdMember, REFIID riid,
+ LCID lcid, WORD wFlags,
+ DISPPARAMS* pDispParams,
+ VARIANT* pVarResult, EXCEPINFO* pExcepInfo,
+ UINT* puArgErr) {
+ if (dispIdMember == DISPID_AMBIENT_DLCONTROL && pVarResult) {
+ VariantClear(pVarResult);
+ pVarResult->vt = VT_I4;
+ // As a light security measure, disable a bunch of stuff we don't want
+ // to be able to run in the web control.
+ pVarResult->intVal = DLCTL_NO_JAVA | DLCTL_NO_DLACTIVEXCTLS |
+ DLCTL_NO_RUNACTIVEXCTLS | DLCTL_NO_FRAMEDOWNLOAD |
+ DLCTL_NO_BEHAVIORS | DLCTL_NO_CLIENTPULL |
+ DLCTL_NOFRAMES | DLCTL_FORCEOFFLINE | DLCTL_SILENT |
+ DLCTL_OFFLINE | DLCTL_DLIMAGES;
+ return S_OK;
+ }
+
+ // Otherwise this should be one of our custom functions.
+ // We only support invoking these as methods, not property access.
+ if ((wFlags & DISPATCH_METHOD) == 0) {
+ return DISP_E_TYPEMISMATCH;
+ }
+
+ // Make sure this DISPID is valid in our custom functions list.
+ // DISPID values are 1-indexed because 0 is reserved (DISPID_VALUE).
+ DISPID customFunctionIndex = dispIdMember - 1;
+ if (customFunctionIndex < 0 ||
+ customFunctionIndex >= (DISPID)mCustomFunctions.size()) {
+ return DISP_E_MEMBERNOTFOUND;
+ }
+
+ // If the caller passed an argument to this custom function, use it.
+ // If not, make an empty VARIANT we can pass to it instead.
+ VARIANT argument;
+ VariantInit(&argument);
+ if (pDispParams->cArgs > 0) {
+ argument = pDispParams->rgvarg[0];
+ }
+
+ CustomFunctionRecord foundFunction = mCustomFunctions[customFunctionIndex];
+ foundFunction.mFunction(foundFunction.mArg, argument, pVarResult);
+
+ return S_OK;
+}
diff --git a/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.h b/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.h
new file mode 100644
index 0000000000..8bc4800a2e
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.h
@@ -0,0 +1,250 @@
+// 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 <exdisp.h>
+#include <mshtmhst.h>
+
+#include <vector>
+#include <string>
+
+class WebBrowser final :
+ /* public IUnknown, */
+ /* public IOleWindow, */
+ public IOleInPlaceSite,
+ public IOleClientSite,
+ public IDropTarget,
+ public IStorage,
+ public IDocHostUIHandler,
+ public IDocHostShowUI,
+ public IDispatch {
+ public:
+ /////////////////////////////////////////////////////////////////////////////
+ // Our own methods
+ /////////////////////////////////////////////////////////////////////////////
+ WebBrowser(HWND hWndParent);
+ ~WebBrowser();
+
+ WebBrowser(const WebBrowser&) = delete;
+ WebBrowser& operator=(const WebBrowser&) = delete;
+
+ void Shutdown();
+
+ bool IsInitialized();
+
+ HRESULT ActiveObjectTranslateAccelerator(bool tab, LPMSG lpmsg);
+ void SetRect(const RECT& _rc);
+ void Resize(DWORD width, DWORD height);
+ void Navigate(wchar_t* szUrl);
+
+ using CustomFunction = void (*)(void* context, VARIANT parameter,
+ VARIANT* retVal);
+ void AddCustomFunction(wchar_t* name, CustomFunction function, void* arg);
+
+ /////////////////////////////////////////////////////////////////////////////
+ // Data members
+ /////////////////////////////////////////////////////////////////////////////
+ private:
+ IOleObject* mOleObject = nullptr;
+ IOleInPlaceObject* mOleInPlaceObject = nullptr;
+ IOleInPlaceActiveObject* mOleInPlaceActiveObject = nullptr;
+ IWebBrowser2* mWebBrowser2 = nullptr;
+
+ LONG mComRefCount = 0;
+
+ RECT mRect = {0, 0, 0, 0};
+
+ HWND mHwndParent = nullptr;
+
+ struct CustomFunctionRecord {
+ std::wstring mName;
+ CustomFunction mFunction;
+ void* mArg;
+ };
+ std::vector<CustomFunctionRecord> mCustomFunctions;
+
+ //////////////////////////////////////////////////////////////////////////////
+ // COM interface methods
+ //////////////////////////////////////////////////////////////////////////////
+ public:
+ // IUnknown
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid,
+ void** ppvObject) override;
+ ULONG STDMETHODCALLTYPE AddRef() override;
+ ULONG STDMETHODCALLTYPE Release() override;
+
+ // IOleWindow
+ HRESULT STDMETHODCALLTYPE
+ GetWindow(__RPC__deref_out_opt HWND* phwnd) override;
+ HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode) override;
+
+ // IOleInPlaceSite
+ HRESULT STDMETHODCALLTYPE CanInPlaceActivate() override;
+ HRESULT STDMETHODCALLTYPE OnInPlaceActivate() override;
+ HRESULT STDMETHODCALLTYPE OnUIActivate() override;
+ HRESULT STDMETHODCALLTYPE GetWindowContext(
+ __RPC__deref_out_opt IOleInPlaceFrame** ppFrame,
+ __RPC__deref_out_opt IOleInPlaceUIWindow** ppDoc,
+ __RPC__out LPRECT lprcPosRect, __RPC__out LPRECT lprcClipRect,
+ __RPC__inout LPOLEINPLACEFRAMEINFO lpFrameInfo) override;
+ HRESULT STDMETHODCALLTYPE Scroll(SIZE scrollExtant) override;
+ HRESULT STDMETHODCALLTYPE OnUIDeactivate(BOOL fUndoable) override;
+ HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate() override;
+ HRESULT STDMETHODCALLTYPE DiscardUndoState() override;
+ HRESULT STDMETHODCALLTYPE DeactivateAndUndo() override;
+ HRESULT STDMETHODCALLTYPE
+ OnPosRectChange(__RPC__in LPCRECT lprcPosRect) override;
+
+ // IOleClientSite
+ HRESULT STDMETHODCALLTYPE SaveObject() override;
+ HRESULT STDMETHODCALLTYPE
+ GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker,
+ __RPC__deref_out_opt IMoniker** ppmk) override;
+ HRESULT STDMETHODCALLTYPE
+ GetContainer(__RPC__deref_out_opt IOleContainer** ppContainer) override;
+ HRESULT STDMETHODCALLTYPE ShowObject() override;
+ HRESULT STDMETHODCALLTYPE OnShowWindow(BOOL fShow) override;
+ HRESULT STDMETHODCALLTYPE RequestNewObjectLayout() override;
+
+ // IDropTarget
+ HRESULT STDMETHODCALLTYPE DragEnter(__RPC__in_opt IDataObject* pDataObj,
+ DWORD grfKeyState, POINTL pt,
+ __RPC__inout DWORD* pdwEffect) override;
+ HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt,
+ __RPC__inout DWORD* pdwEffect) override;
+ HRESULT STDMETHODCALLTYPE DragLeave() override;
+ HRESULT STDMETHODCALLTYPE Drop(__RPC__in_opt IDataObject* pDataObj,
+ DWORD grfKeyState, POINTL pt,
+ __RPC__inout DWORD* pdwEffect) override;
+
+ // IStorage
+ HRESULT STDMETHODCALLTYPE CreateStream(
+ __RPC__in_string const OLECHAR* pwcsName, DWORD grfMode, DWORD reserved1,
+ DWORD reserved2, __RPC__deref_out_opt IStream** ppstm) override;
+ HRESULT STDMETHODCALLTYPE OpenStream(const OLECHAR* pwcsName, void* reserved1,
+ DWORD grfMode, DWORD reserved2,
+ IStream** ppstm) override;
+ HRESULT STDMETHODCALLTYPE CreateStorage(
+ __RPC__in_string const OLECHAR* pwcsName, DWORD grfMode, DWORD reserved1,
+ DWORD reserved2, __RPC__deref_out_opt IStorage** ppstg) override;
+ HRESULT STDMETHODCALLTYPE
+ OpenStorage(__RPC__in_opt_string const OLECHAR* pwcsName,
+ __RPC__in_opt IStorage* pstgPriority, DWORD grfMode,
+ __RPC__deref_opt_in_opt SNB snbExclude, DWORD reserved,
+ __RPC__deref_out_opt IStorage** ppstg) override;
+ HRESULT STDMETHODCALLTYPE CopyTo(DWORD ciidExclude, const IID* rgiidExclude,
+ __RPC__in_opt SNB snbExclude,
+ IStorage* pstgDest) override;
+ HRESULT STDMETHODCALLTYPE MoveElementTo(
+ __RPC__in_string const OLECHAR* pwcsName,
+ __RPC__in_opt IStorage* pstgDest,
+ __RPC__in_string const OLECHAR* pwcsNewName, DWORD grfFlags) override;
+ HRESULT STDMETHODCALLTYPE Commit(DWORD grfCommitFlags) override;
+ HRESULT STDMETHODCALLTYPE Revert(void) override;
+ HRESULT STDMETHODCALLTYPE EnumElements(DWORD reserved1, void* reserved2,
+ DWORD reserved3,
+ IEnumSTATSTG** ppenum) override;
+ HRESULT STDMETHODCALLTYPE
+ DestroyElement(__RPC__in_string const OLECHAR* pwcsName) override;
+ HRESULT STDMETHODCALLTYPE
+ RenameElement(__RPC__in_string const OLECHAR* pwcsOldName,
+ __RPC__in_string const OLECHAR* pwcsNewName) override;
+ HRESULT STDMETHODCALLTYPE
+ SetElementTimes(__RPC__in_opt_string const OLECHAR* pwcsName,
+ __RPC__in_opt const FILETIME* pctime,
+ __RPC__in_opt const FILETIME* patime,
+ __RPC__in_opt const FILETIME* pmtime) override;
+ HRESULT STDMETHODCALLTYPE SetClass(__RPC__in REFCLSID clsid) override;
+ HRESULT STDMETHODCALLTYPE SetStateBits(DWORD grfStateBits,
+ DWORD grfMask) override;
+ HRESULT STDMETHODCALLTYPE Stat(__RPC__out STATSTG* pstatstg,
+ DWORD grfStatFlag) override;
+
+ // IDocHostUIHandler
+ HRESULT STDMETHODCALLTYPE ShowContextMenu(
+ _In_ DWORD dwID, _In_ POINT* ppt, _In_ IUnknown* pcmdtReserved,
+ _In_ IDispatch* pdispReserved) override;
+ HRESULT STDMETHODCALLTYPE GetHostInfo(_Inout_ DOCHOSTUIINFO* pInfo) override;
+ HRESULT STDMETHODCALLTYPE ShowUI(_In_ DWORD dwID,
+ _In_ IOleInPlaceActiveObject* pActiveObject,
+ _In_ IOleCommandTarget* pCommandTarget,
+ _In_ IOleInPlaceFrame* pFrame,
+ _In_ IOleInPlaceUIWindow* pDoc) override;
+ HRESULT STDMETHODCALLTYPE HideUI() override;
+ HRESULT STDMETHODCALLTYPE UpdateUI() override;
+ HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable) override;
+ HRESULT STDMETHODCALLTYPE OnDocWindowActivate(BOOL fActivate) override;
+ HRESULT STDMETHODCALLTYPE OnFrameWindowActivate(BOOL fActivate) override;
+ HRESULT STDMETHODCALLTYPE ResizeBorder(_In_ LPCRECT prcBorder,
+ _In_ IOleInPlaceUIWindow* pUIWindow,
+ _In_ BOOL fRameWindow) override;
+ HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG lpMsg,
+ const GUID* pguidCmdGroup,
+ DWORD nCmdID) override;
+ HRESULT STDMETHODCALLTYPE GetOptionKeyPath(_Out_ LPOLESTR* pchKey,
+ DWORD dw) override;
+ HRESULT STDMETHODCALLTYPE
+ GetDropTarget(_In_ IDropTarget* pDropTarget,
+ _Outptr_ IDropTarget** ppDropTarget) override;
+ HRESULT STDMETHODCALLTYPE
+ GetExternal(_Outptr_result_maybenull_ IDispatch** ppDispatch) override;
+ HRESULT STDMETHODCALLTYPE TranslateUrl(DWORD dwTranslate,
+ _In_ LPWSTR pchURLIn,
+ _Outptr_ LPWSTR* ppchURLOut) override;
+ HRESULT STDMETHODCALLTYPE
+ FilterDataObject(_In_ IDataObject* pDO,
+ _Outptr_result_maybenull_ IDataObject** ppDORet) override;
+
+ // IDocHostShowUI
+ HRESULT STDMETHODCALLTYPE ShowMessage(
+ /* [in] */ HWND hwnd,
+ /* [annotation][in] */
+ _In_ LPOLESTR lpstrText,
+ /* [annotation][in] */
+ _In_ LPOLESTR lpstrCaption,
+ /* [in] */ DWORD dwType,
+ /* [annotation][in] */
+ _In_ LPOLESTR lpstrHelpFile,
+ /* [in] */ DWORD dwHelpContext,
+ /* [out] */ LRESULT* plResult) override;
+ HRESULT STDMETHODCALLTYPE ShowHelp(
+ /* [in] */ HWND hwnd,
+ /* [annotation][in] */
+ _In_ LPOLESTR pszHelpFile,
+ /* [in] */ UINT uCommand,
+ /* [in] */ DWORD dwData,
+ /* [in] */ POINT ptMouse,
+ /* [out] */ IDispatch* pDispatchObjectHit) override;
+
+ // IDispatch
+ HRESULT STDMETHODCALLTYPE GetTypeInfoCount(
+ /* [out] */ __RPC__out UINT* pctinfo) override;
+ HRESULT STDMETHODCALLTYPE GetTypeInfo(
+ /* [in] */ UINT iTInfo,
+ /* [in] */ LCID lcid,
+ /* [out] */ __RPC__deref_out_opt ITypeInfo** ppTInfo) override;
+ HRESULT STDMETHODCALLTYPE GetIDsOfNames(
+ /* [in] */ __RPC__in REFIID riid,
+ /* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR* rgszNames,
+ /* [range][in] */ __RPC__in_range(0, 16384) UINT cNames,
+ /* [in] */ LCID lcid,
+ /* [size_is][out] */ __RPC__out_ecount_full(cNames) DISPID* rgDispId)
+ override;
+ /* [local] */ HRESULT STDMETHODCALLTYPE Invoke(
+ /* [annotation][in] */
+ _In_ DISPID dispIdMember,
+ /* [annotation][in] */
+ _In_ REFIID riid,
+ /* [annotation][in] */
+ _In_ LCID lcid,
+ /* [annotation][in] */
+ _In_ WORD wFlags,
+ /* [annotation][out][in] */
+ _In_ DISPPARAMS* pDispParams,
+ /* [annotation][out] */
+ _Out_opt_ VARIANT* pVarResult,
+ /* [annotation][out] */
+ _Out_opt_ EXCEPINFO* pExcepInfo,
+ /* [annotation][out] */
+ _Out_opt_ UINT* puArgErr) override;
+}; \ No newline at end of file
diff --git a/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.sln b/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.sln
new file mode 100644
index 0000000000..8e12b98f5e
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.28803.452
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebBrowser", "WebBrowser.vcxproj", "{EF903B79-AD97-45E0-BC6E-4FF846D6A2ED}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EF903B79-AD97-45E0-BC6E-4FF846D6A2ED}.Debug|x86.ActiveCfg = Debug|Win32
+ {EF903B79-AD97-45E0-BC6E-4FF846D6A2ED}.Debug|x86.Build.0 = Debug|Win32
+ {EF903B79-AD97-45E0-BC6E-4FF846D6A2ED}.Release|x86.ActiveCfg = Release|Win32
+ {EF903B79-AD97-45E0-BC6E-4FF846D6A2ED}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {3A087FCC-55DC-4C48-8A22-A6FFB3247674}
+ EndGlobalSection
+EndGlobal
diff --git a/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.vcxproj b/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.vcxproj
new file mode 100644
index 0000000000..8d13e050b6
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/WebBrowser.vcxproj
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <SccProjectName />
+ <SccLocalPath />
+ <ProjectGuid>{EF903B79-AD97-45E0-BC6E-4FF846D6A2ED}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v142</PlatformToolset>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>Unicode</CharacterSet>
+ <SpectreMitigation>false</SpectreMitigation>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v142</PlatformToolset>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <SpectreMitigation>false</SpectreMitigation>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>.\Release\</OutDir>
+ <IntDir>.\Release\</IntDir>
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>.\Debug\</OutDir>
+ <IntDir>.\Debug\</IntDir>
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <StringPooling>true</StringPooling>
+ <Optimization>MinSpace</Optimization>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <DebugInformationFormat>None</DebugInformationFormat>
+ <ExceptionHandling>false</ExceptionHandling>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ </ClCompile>
+ <Midl>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <TypeLibraryName>.\Release\WebBrowser.tlb</TypeLibraryName>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ </Midl>
+ <ResourceCompile>
+ <Culture>0x080a</Culture>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Bscmake>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <OutputFile>.\Release\WebBrowser.bsc</OutputFile>
+ </Bscmake>
+ <Link>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <LinkDLL>true</LinkDLL>
+ <SubSystem>Windows</SubSystem>
+ <OutputFile>.\Release\WebBrowser.dll</OutputFile>
+ <ImportLibrary>.\Release\WebBrowser.lib</ImportLibrary>
+ <AdditionalDependencies>odbc32.lib;odbccp32.lib;urlmon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <OptimizeReferences>true</OptimizeReferences>
+ <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <EntryPointSymbol>
+ </EntryPointSymbol>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <InlineFunctionExpansion>Default</InlineFunctionExpansion>
+ <Optimization>Disabled</Optimization>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <ExceptionHandling>false</ExceptionHandling>
+ <LanguageStandard>Default</LanguageStandard>
+ </ClCompile>
+ <Midl>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <TypeLibraryName>.\Debug\WebBrowser.tlb</TypeLibraryName>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ </Midl>
+ <ResourceCompile>
+ <Culture>0x080a</Culture>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Bscmake>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <OutputFile>.\Debug\WebBrowser.bsc</OutputFile>
+ </Bscmake>
+ <Link>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <LinkDLL>true</LinkDLL>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OutputFile>.\Debug\WebBrowser.dll</OutputFile>
+ <ImportLibrary>.\Debug\WebBrowser.lib</ImportLibrary>
+ <AdditionalDependencies>odbc32.lib;odbccp32.lib;urlmon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OptimizeReferences>false</OptimizeReferences>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="CustomFunctions.cpp" />
+ <ClCompile Include="exdll.cpp" />
+ <ClCompile Include="main.cpp" />
+ <ClCompile Include="Timers.cpp" />
+ <ClCompile Include="WebBrowser.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="exdll.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="WebBrowser.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="resource.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/other-licenses/nsis/Contrib/WebBrowser/exdll.cpp b/other-licenses/nsis/Contrib/WebBrowser/exdll.cpp
new file mode 100644
index 0000000000..3cad7307ee
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/exdll.cpp
@@ -0,0 +1,30 @@
+// 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 "exdll.h"
+
+unsigned int g_stringsize;
+stack_t** g_stacktop;
+int(__stdcall* g_executeCodeSegment)(int pos, HWND hwndProgress);
+HWND g_hwndParent;
+
+int popstring(TCHAR* str) {
+ stack_t* th;
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th = (*g_stacktop);
+ lstrcpy(str, th->text);
+ *g_stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+void pushstring(const TCHAR* str) {
+ stack_t* th;
+ if (!g_stacktop) return;
+ th = (stack_t*)GlobalAlloc(GPTR,
+ sizeof(stack_t) + (g_stringsize * sizeof(TCHAR)));
+ lstrcpyn(th->text, str, g_stringsize);
+ th->next = *g_stacktop;
+ *g_stacktop = th;
+}
diff --git a/other-licenses/nsis/Contrib/WebBrowser/exdll.h b/other-licenses/nsis/Contrib/WebBrowser/exdll.h
new file mode 100644
index 0000000000..1fa5659641
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/exdll.h
@@ -0,0 +1,76 @@
+// 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 _EXDLL_H_
+#define _EXDLL_H_
+
+#include <windows.h>
+#include <tchar.h>
+
+#define PLUGINFUNCTION(name) \
+ extern "C" void __declspec(dllexport) \
+ name(HWND hWndParent, int string_size, TCHAR* variables, \
+ stack_t** stacktop, extra_parameters* extra)
+
+#define EXDLL_INIT() \
+ { \
+ g_stringsize = string_size; \
+ g_stacktop = stacktop; \
+ g_executeCodeSegment = extra->ExecuteCodeSegment; \
+ g_hwndParent = hWndParent; \
+ }
+
+#define WM_NOTIFY_OUTER_NEXT (WM_USER + 0x8)
+#define WM_NOTIFY_CUSTOM_READY (WM_USER + 0xd)
+
+typedef struct _stack_t {
+ struct _stack_t* next;
+ TCHAR text[1]; // the real length of this buffer should be string_size
+} stack_t;
+
+extern unsigned int g_stringsize;
+extern stack_t** g_stacktop;
+extern int(__stdcall* g_executeCodeSegment)(int pos, HWND hwndProgress);
+extern HWND g_hwndParent;
+extern HINSTANCE gHInst;
+
+typedef struct {
+ int autoclose;
+ int all_user_var;
+ int exec_error;
+ int abort;
+ int exec_reboot;
+ int reboot_called;
+ int XXX_cur_insttype; // deprecated
+ int XXX_insttype_changed; // deprecated
+ int silent;
+ int instdir_error;
+ int rtl;
+ int errlvl;
+} exec_flags;
+
+// NSIS Plug-In Callback Messages
+enum NSPIM {
+ NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
+ NSPIM_GUIUNLOAD, // Called after .onGUIEnd
+};
+
+typedef UINT_PTR (*NSISPLUGINCALLBACK)(enum NSPIM);
+
+typedef struct {
+ exec_flags* exec_flags;
+ int(__stdcall* ExecuteCodeSegment)(int pos, HWND hwndProgress);
+ void(__stdcall* validate_filename)(LPWSTR);
+ int(__stdcall* RegisterPluginCallback)(
+ HMODULE,
+ NSISPLUGINCALLBACK); // returns 0 on success, 1 if already
+ // registered and < 0 on errors
+} extra_parameters;
+
+int popstring(TCHAR* str);
+void pushstring(const TCHAR* str);
+
+UINT_PTR __cdecl NSISPluginCallback(NSPIM msg);
+
+#endif //_EXDLL_H_
diff --git a/other-licenses/nsis/Contrib/WebBrowser/main.cpp b/other-licenses/nsis/Contrib/WebBrowser/main.cpp
new file mode 100644
index 0000000000..e0589531ee
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/main.cpp
@@ -0,0 +1,199 @@
+// 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 <windows.h>
+#include "resource.h"
+#include "WebBrowser.h"
+#include "exdll.h"
+
+// These variables are global because they're needed by more than one of
+// our plugin methods. The expectation is that these are safe because the
+// NSIS framework doesn't really support more than one dialog or thread
+// at a time, and that means we don't have to either.
+
+// Instance handle for this DLL
+HINSTANCE gHInst = nullptr;
+// Parent window proc which we'll need to override and then restore
+WNDPROC gWndProcOld = nullptr;
+// Handle to the dialog we'll create
+HWND gHwnd = nullptr;
+// Set to true when our dialog should be destroyed
+bool gDone = false;
+// Web browser OLE site
+WebBrowser* gBrowser = nullptr;
+
+// Set web browser control feature flags that are configured on a per-process
+// basis, not for individual instances of the control. This mainly means
+// disabling things that could turn into security holes.
+static void ConfigurePerProcessBrowserFeatures() {
+ // For most of the features we're configuring, setting them to TRUE means
+ // we're disabling something, but for a few setting them to FALSE disables the
+ // thing. We don't necessarily care about *every* feature that's in the
+ // INTERNETFEATURELIST enum, but it seems safer to set them all anyway, to
+ // make sure we don't miss anything we *do* care about.
+ struct Feature {
+ INTERNETFEATURELIST id;
+ BOOL value;
+ } features[] = {{FEATURE_OBJECT_CACHING, TRUE},
+ {FEATURE_ZONE_ELEVATION, TRUE},
+ {FEATURE_MIME_HANDLING, TRUE},
+ {FEATURE_MIME_SNIFFING, FALSE},
+ {FEATURE_WINDOW_RESTRICTIONS, TRUE},
+ {FEATURE_WEBOC_POPUPMANAGEMENT, TRUE},
+ {FEATURE_BEHAVIORS, TRUE},
+ {FEATURE_DISABLE_MK_PROTOCOL, TRUE},
+ // It isn't possible to set FEATURE_LOCALMACHINE_LOCKDOWN
+ // using the SET_FEATURE_ON_PROCESS mode; see the MSDN page
+ // on CoInternetSetFeatureEnabled for the explanation.
+ //{FEATURE_LOCALMACHINE_LOCKDOWN, TRUE},
+ {FEATURE_SECURITYBAND, FALSE},
+ {FEATURE_RESTRICT_ACTIVEXINSTALL, TRUE},
+ {FEATURE_VALIDATE_NAVIGATE_URL, TRUE},
+ {FEATURE_RESTRICT_FILEDOWNLOAD, TRUE},
+ {FEATURE_ADDON_MANAGEMENT, TRUE},
+ {FEATURE_PROTOCOL_LOCKDOWN, TRUE},
+ {FEATURE_HTTP_USERNAME_PASSWORD_DISABLE, TRUE},
+ {FEATURE_SAFE_BINDTOOBJECT, TRUE},
+ {FEATURE_UNC_SAVEDFILECHECK, TRUE},
+ {FEATURE_GET_URL_DOM_FILEPATH_UNENCODED, FALSE},
+ {FEATURE_TABBED_BROWSING, FALSE},
+ {FEATURE_SSLUX, FALSE},
+ {FEATURE_DISABLE_NAVIGATION_SOUNDS, TRUE},
+ {FEATURE_DISABLE_LEGACY_COMPRESSION, TRUE},
+ {FEATURE_FORCE_ADDR_AND_STATUS, FALSE},
+ {FEATURE_XMLHTTP, FALSE},
+ {FEATURE_DISABLE_TELNET_PROTOCOL, TRUE},
+ {FEATURE_FEEDS, FALSE},
+ {FEATURE_BLOCK_INPUT_PROMPTS, TRUE}};
+
+ for (Feature feature : features) {
+ CoInternetSetFeatureEnabled(feature.id, SET_FEATURE_ON_PROCESS,
+ feature.value);
+ }
+}
+
+BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID) {
+ if (reason == DLL_PROCESS_ATTACH) {
+ gHInst = instance;
+ (void)OleInitialize(nullptr);
+ ConfigurePerProcessBrowserFeatures();
+ }
+ return TRUE;
+}
+
+UINT_PTR __cdecl NSISPluginCallback(NSPIM msg) {
+ if (msg == NSPIM_UNLOAD) {
+ OleUninitialize();
+ }
+ return 0;
+}
+
+BOOL CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam,
+ LPARAM lParam) {
+ BOOL bRes =
+ CallWindowProc((WNDPROC)gWndProcOld, hwnd, message, wParam, lParam);
+ if (!bRes && message == WM_NOTIFY_OUTER_NEXT) {
+ gDone = true;
+ PostMessage(gHwnd, WM_CLOSE, 0, 0);
+ }
+ return bRes;
+}
+
+BOOL CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
+ return FALSE;
+}
+
+void Init(HWND hWndParent, int string_size, TCHAR* variables,
+ stack_t** stacktop, extra_parameters* extra) {
+ EXDLL_INIT();
+ extra->RegisterPluginCallback(gHInst, NSISPluginCallback);
+
+ HWND hwndChild = GetDlgItem(hWndParent, 1018);
+ if (!hwndChild) {
+ return;
+ }
+
+ HWND hwnd =
+ CreateDialog(gHInst, MAKEINTRESOURCE(IDD_DIALOG1), hWndParent, DlgProc);
+ if (!hwnd) {
+ gDone = true;
+ } else {
+ gDone = false;
+ gWndProcOld =
+ (WNDPROC)SetWindowLong(hWndParent, DWL_DLGPROC, (LONG)ParentWndProc);
+
+ // Tell NSIS to replace its inner dialog with ours.
+ SendMessage(hWndParent, WM_NOTIFY_CUSTOM_READY, (WPARAM)hwnd, 0);
+
+ // Initialize the browser control.
+ if (gBrowser) {
+ gBrowser->Shutdown();
+ gBrowser->Release();
+ }
+ gBrowser = new WebBrowser(hwnd);
+
+ if (!gBrowser || !gBrowser->IsInitialized()) {
+ return;
+ }
+
+ gHwnd = hwnd;
+
+ // Move our dialog to match the size of the parent.
+ RECT r;
+ GetClientRect(hwndChild, &r);
+ MoveWindow(hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, FALSE);
+ gBrowser->SetRect(r);
+ }
+}
+
+PLUGINFUNCTION(ShowPage) {
+ if (!gBrowser) {
+ Init(hWndParent, string_size, variables, stacktop, extra);
+ }
+
+ if (!gBrowser->IsInitialized()) {
+ return;
+ }
+
+ TCHAR* sUrl =
+ (TCHAR*)HeapAlloc(GetProcessHeap(), 0, g_stringsize * sizeof(TCHAR));
+ popstring(sUrl);
+
+ if (gBrowser) {
+ gBrowser->Navigate(sUrl);
+
+ ShowWindow(gHwnd, SW_SHOWNA);
+ UpdateWindow(gHwnd);
+
+ while (!gDone) {
+ // This explicit wait call is needed rather than just a blocking
+ // GetMessage because we need this thread to be alertable so that our
+ // timers can wake it up and run their callbacks.
+ MsgWaitForMultipleObjectsEx(0, nullptr, 100, QS_ALLINPUT,
+ MWMO_ALERTABLE | MWMO_INPUTAVAILABLE);
+ MSG msg;
+ if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
+ bool tab = msg.message == WM_KEYDOWN && msg.wParam == VK_TAB;
+
+ if (gBrowser->ActiveObjectTranslateAccelerator(tab, &msg) != S_OK &&
+ !IsDialogMessage(gHwnd, &msg) &&
+ !IsDialogMessage(g_hwndParent, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ }
+
+ SetWindowLong(g_hwndParent, DWL_DLGPROC, (LONG)gWndProcOld);
+ if (gHwnd) {
+ DestroyWindow(gHwnd);
+ }
+
+ gBrowser->Shutdown();
+ gBrowser->Release();
+ gBrowser = nullptr;
+ }
+
+ HeapFree(GetProcessHeap(), 0, (char*)sUrl);
+}
diff --git a/other-licenses/nsis/Contrib/WebBrowser/resource.h b/other-licenses/nsis/Contrib/WebBrowser/resource.h
new file mode 100644
index 0000000000..6fdee73b5f
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/resource.h
@@ -0,0 +1,5 @@
+// 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/.
+
+#define IDD_DIALOG1 101
diff --git a/other-licenses/nsis/Contrib/WebBrowser/resource.rc b/other-licenses/nsis/Contrib/WebBrowser/resource.rc
new file mode 100644
index 0000000000..0bc4fcc11f
--- /dev/null
+++ b/other-licenses/nsis/Contrib/WebBrowser/resource.rc
@@ -0,0 +1,14 @@
+// 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 "resource.h"
+#include "afxres.h"
+
+// The size of this dialog is a placeholder;
+// it's going to get resized to fit its parent.
+IDD_DIALOG1 DIALOGEX 0, 0, 1, 1
+STYLE DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS
+FONT 8, "MS Shell Dlg"
+BEGIN
+END
diff --git a/other-licenses/nsis/Contrib/liteFirewall/License.txt b/other-licenses/nsis/Contrib/liteFirewall/License.txt
new file mode 100644
index 0000000000..5e9673682f
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/License.txt
@@ -0,0 +1,17 @@
+liteFirewall is based on nsisFirewall.
+
+nsisFirewall -- Small NSIS plugin for simple tasks with Windows Firewall
+Web site: http://wiz0u.free.fr/prog/nsisFirewall
+
+Copyright (c) 2007-2009 Olivier Marcoux
+
+This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
diff --git a/other-licenses/nsis/Contrib/liteFirewall/ReadMe.txt b/other-licenses/nsis/Contrib/liteFirewall/ReadMe.txt
new file mode 100644
index 0000000000..42560ae0c0
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/ReadMe.txt
@@ -0,0 +1,39 @@
+liteFirewall 1.0 -- based on nsisFirewall 1.2
+
+http://liangsun.info/portfolio/nsis-plugin-litefirewall/
+http://nsis.sourceforge.net/LiteFirewall_Plugin
+
+---------------------------------------------------------
+liteFirewall resolved the issue nsisFirewall exists on Vista/Windows 7 platforms.
+It support the profiles (private, domain, public) of firewall rules.
+It support Unicode NSIS, while another firewall plugin SimpleFC not.
+------------------------------------------------------------
+
+Usage
+----------------------------------------------------------
+liteFirewall::AddRule "<application path>" "<rule name>"
+liteFirewall::RemoveRule "<application path>" "<rule name>"
+
+<application path> is the full path to the application you want to be authorized to
+ access the network (or accept incoming connections)
+
+<rule name> is the title that will be given to this exception entry in the firewall
+ control panel list
+
+
+Notes
+-----
+1) Your installer must be run with administrator rights for liteFirewall to work
+2) When compiling with more recent compiler than VC60, you need to choose the compilation
+option to use static MFC library.
+
+Sample scripts
+--------------
+
+ ; Add NOTEPAD to the authorized list
+ liteFirewall::AddRule "$WINDIR\Notepad.exe" "liteFirewall Test"
+ Pop $0
+
+ ; Remove NOTEPAD from the authorized list
+ liteFirewall::RemoveRule "$WINDIR\Notepad.exe" "liteFirewall Test"
+ Pop $0 \ No newline at end of file
diff --git a/other-licenses/nsis/Contrib/liteFirewall/Sample.nsi b/other-licenses/nsis/Contrib/liteFirewall/Sample.nsi
new file mode 100644
index 0000000000..20b0be47ca
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/Sample.nsi
@@ -0,0 +1,25 @@
+; liteFirewall - Sample script
+
+!ifdef TARGETDIR
+!addplugindir "${TARGETDIR}"
+!else
+!addplugindir "..\bin"
+!endif
+
+Name "Sample liteFirewall"
+OutFile "Sample.exe"
+ShowInstDetails show
+
+Section "Main program"
+ ; Add NOTEPAD to the authorized list
+ liteFirewallW::AddRule "$WINDIR\Notepad.exe" "liteFirewall Test"
+ Pop $0
+ Exec "rundll32.exe shell32.dll,Control_RunDLL firewall.cpl"
+ MessageBox MB_OK "Program added to Firewall exception list.$\r$\n(close the control panel before clicking OK)"
+
+ ; Remove NOTEPAD from the authorized list
+ liteFirewallW::RemoveRule "$WINDIR\Notepad.exe" "liteFirewall Test"
+ Pop $0
+ Exec "rundll32.exe shell32.dll,Control_RunDLL firewall.cpl"
+ MessageBox MB_OK "Program removed to Firewall exception list"
+SectionEnd
diff --git a/other-licenses/nsis/Contrib/liteFirewall/exdll.h b/other-licenses/nsis/Contrib/liteFirewall/exdll.h
new file mode 100644
index 0000000000..feca246b5a
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/exdll.h
@@ -0,0 +1,97 @@
+#ifndef _EXDLL_H_
+#define _EXDLL_H_
+
+// only include this file from one place in your DLL.
+// (it is all static, if you use it in two places it will fail)
+
+#define EXDLL_INIT() { \
+ g_stringsize=string_size; \
+ g_stacktop=stacktop; \
+ g_variables=variables; }
+
+// For page showing plug-ins
+#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
+#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
+#define NOTIFY_BYE_BYE 'x'
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[1]; // this should be the length of string_size
+} stack_t;
+
+
+static unsigned int g_stringsize;
+static stack_t **g_stacktop;
+static TCHAR *g_variables;
+
+static int __stdcall popstring(TCHAR *str); // 0 on success, 1 on empty stack
+static void __stdcall pushstring(const TCHAR *str);
+
+enum
+{
+INST_0, // $0
+INST_1, // $1
+INST_2, // $2
+INST_3, // $3
+INST_4, // $4
+INST_5, // $5
+INST_6, // $6
+INST_7, // $7
+INST_8, // $8
+INST_9, // $9
+INST_R0, // $R0
+INST_R1, // $R1
+INST_R2, // $R2
+INST_R3, // $R3
+INST_R4, // $R4
+INST_R5, // $R5
+INST_R6, // $R6
+INST_R7, // $R7
+INST_R8, // $R8
+INST_R9, // $R9
+INST_CMDLINE, // $CMDLINE
+INST_INSTDIR, // $INSTDIR
+INST_OUTDIR, // $OUTDIR
+INST_EXEDIR, // $EXEDIR
+INST_LANG, // $LANGUAGE
+__INST_LAST
+};
+
+
+// utility functions (not required but often useful)
+static int __stdcall popstring(TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th=(*g_stacktop);
+ lstrcpy(str,th->text);
+ *g_stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+static void __stdcall pushstring(const TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop) return;
+ th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize*sizeof(TCHAR));
+ lstrcpyn(th->text,str,g_stringsize);
+ th->next=*g_stacktop;
+ *g_stacktop=th;
+}
+
+static TCHAR * __stdcall getuservariable(int varnum)
+{
+ if (varnum < 0 || varnum >= __INST_LAST) return NULL;
+ return g_variables+varnum*g_stringsize;
+}
+
+static void __stdcall setuservariable(int varnum, const TCHAR *var)
+{
+ if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
+ lstrcpy(g_variables + varnum*g_stringsize, var);
+}
+
+
+
+#endif//_EXDLL_H_ \ No newline at end of file
diff --git a/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.cpp b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.cpp
new file mode 100644
index 0000000000..5319938a04
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.cpp
@@ -0,0 +1,408 @@
+/*
+liteFirewall is based on nsisFirewall.
+Modified by Liang Sun on 19, July, 2011
+http://liangsun.info/portfolio/nsis-plugin-litefirewall/
+http://nsis.sourceforge.net/LiteFirewall_Plugin
+http://www.msnlite.org
+*/
+
+/*
+nsisFirewall -- Small NSIS plugin for simple tasks with Windows Firewall
+Web site: http://wiz0u.free.fr/prog/nsisFirewall
+
+Copyright (c) 2007-2009 Olivier Marcoux
+
+This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include <windows.h>
+#include <tchar.h>
+#include <shlwapi.h>
+//#include <stdio.h>
+
+#ifdef NSIS
+#include "exdll.h"
+#endif
+
+//#import "libid:58FBCF7C-E7A9-467C-80B3-FC65E8FCCA08"
+#import "netfw.tlb"
+#include <netfw.h>
+using namespace NetFwTypeLib;
+
+
+#pragma comment( lib, "ole32.lib" )
+#pragma comment( lib, "oleaut32.lib" )
+// Forward declarations
+
+#ifdef NSIS
+HINSTANCE g_hInstance;
+#endif
+
+HRESULT WFCOMInitialize(INetFwPolicy2** ppNetFwPolicy2);
+
+HRESULT AddRule(LPCTSTR ExceptionName, LPCTSTR ProcessPath)
+{
+ HRESULT result = CoInitialize(NULL);
+ if (FAILED(result))
+ return result;
+ result = REGDB_E_CLASSNOTREG;
+
+ HRESULT hrComInit = S_OK;
+ HRESULT hr = S_OK;
+
+ INetFwPolicy2 *pNetFwPolicy2 = NULL;
+ INetFwRules *pFwRules = NULL;
+ INetFwRule *pFwRule = NULL;
+/* Start Mozilla modification */
+ INetFwRule *pFwRuleExisting = NULL;
+
+// long CurrentProfilesBitMask = 0;
+/* End Mozilla modification */
+
+ BSTR bstrRuleName = SysAllocString(ExceptionName);
+ BSTR bstrApplicationName = SysAllocString(ProcessPath);
+ BSTR bstrRuleInterfaceType = SysAllocString(L"All");
+
+ // Initialize COM.
+ hrComInit = CoInitializeEx(
+ 0,
+ COINIT_APARTMENTTHREADED
+ );
+
+ // Ignore RPC_E_CHANGED_MODE; this just means that COM has already been
+ // initialized with a different mode. Since we don't care what the mode is,
+ // we'll just use the existing mode.
+ if (hrComInit != RPC_E_CHANGED_MODE)
+ {
+ if (FAILED(hrComInit))
+ {
+ printf("CoInitializeEx failed: 0x%08lx\n", hrComInit);
+ goto Cleanup;
+ }
+ }
+
+ // Retrieve INetFwPolicy2
+ hr = WFCOMInitialize(&pNetFwPolicy2);
+ if (FAILED(hr))
+ {
+ try
+ {
+ INetFwMgrPtr fwMgr(L"HNetCfg.FwMgr");
+ if (fwMgr)
+ {
+ INetFwAuthorizedApplicationPtr app(L"HNetCfg.FwAuthorizedApplication");
+ if (app)
+ {
+ app->ProcessImageFileName = ProcessPath;
+ app->Name = ExceptionName;
+ app->Scope = NetFwTypeLib::NET_FW_SCOPE_ALL;
+ app->IpVersion = NetFwTypeLib::NET_FW_IP_VERSION_ANY;
+ app->Enabled = VARIANT_TRUE;
+ fwMgr->LocalPolicy->CurrentProfile->AuthorizedApplications->Add(app);
+ }
+ }
+ }
+ catch (_com_error& e)
+ {
+ printf("%s", e.Error());
+ }
+ goto Cleanup;
+ }
+
+ // Retrieve INetFwRules
+ hr = pNetFwPolicy2->get_Rules(&pFwRules);
+ if (FAILED(hr))
+ {
+ printf("get_Rules failed: 0x%08lx\n", hr);
+ goto Cleanup;
+ }
+
+/* Start Mozilla modification */
+ // Don't add a new rule if there is an existing rule with the same name.
+ hr = pFwRules->Item(bstrRuleName, &pFwRuleExisting);
+ // Release the INetFwRule object
+ if (pFwRuleExisting != NULL)
+ {
+ pFwRuleExisting->Release();
+ }
+ if (SUCCEEDED(hr))
+ {
+ printf("Firewall profile already exists\n");
+ goto Cleanup;
+ }
+
+ // Retrieve Current Profiles bitmask
+// hr = pNetFwPolicy2->get_CurrentProfileTypes(&CurrentProfilesBitMask);
+// if (FAILED(hr))
+// {
+// printf("get_CurrentProfileTypes failed: 0x%08lx\n", hr);
+// goto Cleanup;
+// }
+
+ // When possible we avoid adding firewall rules to the \ profile.
+ // If Public is currently active and it is not the only active profile, we remove it from the bitmask
+// if ((CurrentProfilesBitMask & NET_FW_PROFILE2_PUBLIC) &&
+// (CurrentProfilesBitMask != NET_FW_PROFILE2_PUBLIC))
+// {
+// CurrentProfilesBitMask ^= NET_FW_PROFILE2_PUBLIC;
+// }
+
+ // Create a new Firewall Rule object.
+ hr = CoCreateInstance(
+ __uuidof(NetFwRule),
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ __uuidof(INetFwRule),
+ (void**)&pFwRule);
+ if (FAILED(hr))
+ {
+ printf("CoCreateInstance for Firewall Rule failed: 0x%08lx\n", hr);
+ goto Cleanup;
+ }
+
+ // Populate the Firewall Rule object
+ pFwRule->put_Name(bstrRuleName);
+ pFwRule->put_Protocol(NetFwTypeLib::NET_FW_IP_PROTOCOL_TCP);
+ pFwRule->put_InterfaceTypes(bstrRuleInterfaceType);
+ pFwRule->put_Profiles(NET_FW_PROFILE2_PRIVATE);
+ pFwRule->put_Action(NET_FW_ACTION_ALLOW);
+ pFwRule->put_Enabled(VARIANT_TRUE);
+
+ pFwRule->put_ApplicationName(bstrApplicationName);
+ // Add the Firewall Rule
+ hr = pFwRules->Add(pFwRule);
+ if (FAILED(hr))
+ {
+ printf("Firewall Rule Add failed: 0x%08lx\n", hr);
+ goto Cleanup;
+ }
+
+ pFwRule->Release();
+/* End Mozilla modification */
+
+ // Create a new Firewall Rule object.
+ hr = CoCreateInstance(
+ __uuidof(NetFwRule),
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ __uuidof(INetFwRule),
+ (void**)&pFwRule);
+ if (FAILED(hr))
+ {
+ printf("CoCreateInstance for Firewall Rule failed: 0x%08lx\n", hr);
+ goto Cleanup;
+ }
+
+ // Populate the Firewall Rule object
+ pFwRule->put_Name(bstrRuleName);
+/* Start Mozilla modification */
+// pFwRule->put_Protocol(NET_FW_IP_PROTOCOL_ANY);
+ pFwRule->put_Protocol(NetFwTypeLib::NET_FW_IP_PROTOCOL_UDP);
+/* End Mozilla modification */
+ pFwRule->put_InterfaceTypes(bstrRuleInterfaceType);
+/* Start Mozilla modification */
+// pFwRule->put_Profiles(CurrentProfilesBitMask);
+ pFwRule->put_Profiles(NET_FW_PROFILE2_PRIVATE);
+/* End Mozilla modification */
+ pFwRule->put_Action(NET_FW_ACTION_ALLOW);
+ pFwRule->put_Enabled(VARIANT_TRUE);
+
+ pFwRule->put_ApplicationName(bstrApplicationName);
+ // Add the Firewall Rule
+ hr = pFwRules->Add(pFwRule);
+ if (FAILED(hr))
+ {
+ printf("Firewall Rule Add failed: 0x%08lx\n", hr);
+ goto Cleanup;
+ }
+
+Cleanup:
+
+ // Free BSTR's
+ SysFreeString(bstrRuleName);
+ SysFreeString(bstrApplicationName);
+ SysFreeString(bstrRuleInterfaceType);
+
+ // Release the INetFwRule object
+ if (pFwRule != NULL)
+ {
+ pFwRule->Release();
+ }
+
+ // Release the INetFwRules object
+ if (pFwRules != NULL)
+ {
+ pFwRules->Release();
+ }
+
+ // Release the INetFwPolicy2 object
+ if (pNetFwPolicy2 != NULL)
+ {
+ pNetFwPolicy2->Release();
+ }
+
+ CoUninitialize();
+ return 0;
+}
+
+HRESULT RemoveRule(LPCTSTR ExceptionName, LPCTSTR ProcessPath)
+{
+ HRESULT result = CoInitialize(NULL);
+ if (FAILED(result))
+ return result;
+ try
+ {
+ INetFwMgrPtr fwMgr(L"HNetCfg.FwMgr");
+ if (fwMgr)
+ {
+ fwMgr->LocalPolicy->CurrentProfile->AuthorizedApplications->Remove(ProcessPath);
+ result = S_OK;
+ }
+ }
+ catch (_com_error& e)
+ {
+ e;
+ }
+ HRESULT hrComInit = S_OK;
+ HRESULT hr = S_OK;
+
+ INetFwPolicy2 *pNetFwPolicy2 = NULL;
+ INetFwRules *pFwRules = NULL;
+
+/* Start Mozilla modification */
+// long CurrentProfilesBitMask = 0;
+/* End Mozilla modification */
+
+ BSTR bstrRuleName = SysAllocString(ExceptionName);
+
+ // Retrieve INetFwPolicy2
+ hr = WFCOMInitialize(&pNetFwPolicy2);
+ if (FAILED(hr))
+ {
+ goto Cleanup;
+ }
+
+ // Retrieve INetFwRules
+ hr = pNetFwPolicy2->get_Rules(&pFwRules);
+ if (FAILED(hr))
+ {
+ printf("get_Rules failed: 0x%08lx\n", hr);
+ goto Cleanup;
+ }
+
+/* Start Mozilla modification */
+ // Retrieve Current Profiles bitmask
+// hr = pNetFwPolicy2->get_CurrentProfileTypes(&CurrentProfilesBitMask);
+// if (FAILED(hr))
+// {
+// printf("get_CurrentProfileTypes failed: 0x%08lx\n", hr);
+// goto Cleanup;
+// }
+
+ // When possible we avoid adding firewall rules to the Public profile.
+ // If Public is currently active and it is not the only active profile, we remove it from the bitmask
+// if ((CurrentProfilesBitMask & NET_FW_PROFILE2_PUBLIC) &&
+// (CurrentProfilesBitMask != NET_FW_PROFILE2_PUBLIC))
+// {
+// CurrentProfilesBitMask ^= NET_FW_PROFILE2_PUBLIC;
+// }
+/* End Mozilla modification */
+
+ // Remove the Firewall Rule
+ hr = pFwRules->Remove(bstrRuleName);
+ if (FAILED(hr))
+ {
+ printf("Firewall Rule Remove failed: 0x%08lx\n", hr);
+ goto Cleanup;
+ }
+
+Cleanup:
+
+ // Free BSTR's
+ SysFreeString(bstrRuleName);
+
+ // Release the INetFwRules object
+ if (pFwRules != NULL)
+ {
+ pFwRules->Release();
+ }
+
+ // Release the INetFwPolicy2 object
+ if (pNetFwPolicy2 != NULL)
+ {
+ pNetFwPolicy2->Release();
+ }
+
+ CoUninitialize();
+ return 0;
+}
+
+
+#ifdef NSIS
+extern "C" void __declspec(dllexport) AddRule(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ EXDLL_INIT();
+
+ TCHAR ExceptionName[256], ProcessPath[MAX_PATH];
+ popstring(ProcessPath);
+ popstring(ExceptionName);
+ HRESULT result = AddRule(ExceptionName, ProcessPath);
+ // push the result back to NSIS
+ TCHAR intBuffer[16];
+ wsprintf(intBuffer, _T("%d"), result);
+ pushstring(intBuffer);
+}
+
+extern "C" void __declspec(dllexport) RemoveRule(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ EXDLL_INIT();
+
+ TCHAR ExceptionName[256], ProcessPath[MAX_PATH];
+ popstring(ProcessPath);
+ popstring(ExceptionName);
+ HRESULT result = RemoveRule(ExceptionName, ProcessPath);
+ // push the result back to NSIS
+ TCHAR intBuffer[16];
+ wsprintf(intBuffer, _T("%d"), result);
+ pushstring(intBuffer);
+}
+
+extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
+{
+ g_hInstance = hInstance;
+ return TRUE;
+}
+#endif
+
+
+// Instantiate INetFwPolicy2
+
+HRESULT WFCOMInitialize(INetFwPolicy2** ppNetFwPolicy2)
+{
+ HRESULT hr = S_OK;
+
+ hr = CoCreateInstance(
+ __uuidof(NetFwPolicy2),
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ __uuidof(INetFwPolicy2),
+ (void**)ppNetFwPolicy2);
+
+ if (FAILED(hr))
+ {
+ printf("CoCreateInstance for INetFwPolicy2 failed: 0x%08lx\n", hr);
+ goto Cleanup;
+ }
+
+Cleanup:
+ return hr;
+}
diff --git a/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.dsp b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.dsp
new file mode 100644
index 0000000000..cae606b4cb
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.dsp
@@ -0,0 +1,204 @@
+# Microsoft Developer Studio Project File - Name="liteFirewall" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=liteFirewall - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "liteFirewall.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "liteFirewall.mak" CFG="liteFirewall - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "liteFirewall - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "liteFirewall - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "liteFirewall - Win32 Release UNICODE" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "liteFirewall - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /Zi /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /Zi /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NSIS" /FR /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib shlwapi.lib /nologo /dll /machine:I386 /out:"../bin/liteFirewall.dll" /OPT:REF /OPT:NOWIN98
+# SUBTRACT LINK32 /pdb:none /debug /nodefaultlib
+# Begin Special Build Tool
+IntDir=.\Release
+ProjDir=.
+TargetDir=\Prog\shared\bin
+SOURCE="$(InputPath)"
+PostBuild_Desc=Building Sample Installer...
+PostBuild_Cmds="%ProgramFiles%\NSIS\makensis" /V2 "/DTARGETDIR=$(TargetDir)" "/DINTDIR=$(IntDir)" "$(ProjDir)\Sample.nsi"
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "liteFirewall - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "NSIS" /FR /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib shlwapi.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# SUBTRACT LINK32 /nodefaultlib
+# Begin Special Build Tool
+IntDir=.\Debug
+ProjDir=.
+TargetDir=.\Debug
+SOURCE="$(InputPath)"
+PostBuild_Desc=Building Sample Installer...
+PostBuild_Cmds="%ProgramFiles%\NSIS\makensis" /V4 /DTARGETDIR=$(TargetDir) /DINTDIR=$(IntDir) $(ProjDir)\Sample.nsi
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "liteFirewall - Win32 Release UNICODE"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release_UNICODE"
+# PROP BASE Intermediate_Dir "Release_UNICODE"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_UNICODE"
+# PROP Intermediate_Dir "Release_UNICODE"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /Zi /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NSIS" /FR /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /Zi /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "NSIS" /FR /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib shlwapi.lib /nologo /dll /machine:I386 /out:"../bin/liteFirewall.dll" /OPT:REF /OPT:NOWIN98
+# SUBTRACT BASE LINK32 /pdb:none /debug /nodefaultlib
+# ADD LINK32 kernel32.lib user32.lib shlwapi.lib /nologo /dll /machine:I386 /out:"../bin/liteFirewallW.dll" /OPT:REF /OPT:NOWIN98
+# SUBTRACT LINK32 /pdb:none /debug /nodefaultlib
+# Begin Special Build Tool
+IntDir=.\Release_UNICODE
+ProjDir=.
+TargetDir=\Prog\shared\bin
+SOURCE="$(InputPath)"
+PostBuild_Desc=Building Sample Installer...
+PostBuild_Cmds="%ProgramFiles%\NSIS\makensis" /V2 "/DTARGETDIR=$(TargetDir)" "/DINTDIR=$(IntDir)" "$(ProjDir)\Sample.nsi"
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "liteFirewall - Win32 Release"
+# Name "liteFirewall - Win32 Debug"
+# Name "liteFirewall - Win32 Release UNICODE"
+# Begin Source File
+
+SOURCE=.\exdll.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\License.txt
+# End Source File
+# Begin Source File
+
+SOURCE=.\liteFirewall.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ReadMe.txt
+# End Source File
+# Begin Source File
+
+SOURCE=.\Sample.nsi
+
+!IF "$(CFG)" == "liteFirewall - Win32 Release"
+
+# Begin Custom Build
+ProjDir=.
+InputPath=.\Sample.nsi
+
+"$(ProjDir)\Sample.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ rem Force Post-Build Step
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "liteFirewall - Win32 Debug"
+
+# Begin Custom Build
+ProjDir=.
+InputPath=.\Sample.nsi
+
+"$(ProjDir)\Sample.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ rem Force Post-Build Step
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "liteFirewall - Win32 Release UNICODE"
+
+# Begin Custom Build
+ProjDir=.
+InputPath=.\Sample.nsi
+
+"$(ProjDir)\Sample.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ rem Force Post-Build Step
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.dsw b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.dsw
new file mode 100644
index 0000000000..d4ca962de0
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "liteFirewall"=.\liteFirewall.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.sln b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.sln
new file mode 100644
index 0000000000..e62a48e344
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.sln
@@ -0,0 +1,23 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liteFirewall", "liteFirewall.vcproj", "{F7462DF9-A430-4185-9AFC-8FAEA0FB98EA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release UNICODE|Win32 = Release UNICODE|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F7462DF9-A430-4185-9AFC-8FAEA0FB98EA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F7462DF9-A430-4185-9AFC-8FAEA0FB98EA}.Debug|Win32.Build.0 = Debug|Win32
+ {F7462DF9-A430-4185-9AFC-8FAEA0FB98EA}.Release UNICODE|Win32.ActiveCfg = Release UNICODE|Win32
+ {F7462DF9-A430-4185-9AFC-8FAEA0FB98EA}.Release UNICODE|Win32.Build.0 = Release UNICODE|Win32
+ {F7462DF9-A430-4185-9AFC-8FAEA0FB98EA}.Release|Win32.ActiveCfg = Release|Win32
+ {F7462DF9-A430-4185-9AFC-8FAEA0FB98EA}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.vcproj b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.vcproj
new file mode 100644
index 0000000000..e1832b7ce6
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/liteFirewall.vcproj
@@ -0,0 +1,390 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="liteFirewall"
+ ProjectGUID="{F7462DF9-A430-4185-9AFC-8FAEA0FB98EA}"
+ TargetFrameworkVersion="0"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="1"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/liteFirewall.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;UNICODE;NSIS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ PrecompiledHeaderFile=".\Debug/liteFirewall.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib"
+ OutputFile=".\Debug/liteFirewall.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/liteFirewall.pdb"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\Debug/liteFirewall.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\Debug/liteFirewall.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ Description="Building Sample Installer..."
+ CommandLine="&quot;E:\Program Files (x86)\NSIS\Unicode\makensis&quot; /V4 /DTARGETDIR=$(TargetDir) /DINTDIR=$(IntDir) $(ProjectDir)Sample.nsi"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release UNICODE|Win32"
+ OutputDirectory=".\Release_UNICODE"
+ IntermediateDirectory=".\Release_UNICODE"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="1"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release_UNICODE/liteFirewall.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;UNICODE;NSIS"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ PrecompiledHeaderFile=".\Release_UNICODE/liteFirewall.pch"
+ AssemblerListingLocation=".\Release_UNICODE/"
+ ObjectFile=".\Release_UNICODE/"
+ ProgramDataBaseFileName=".\Release_UNICODE/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib"
+ OutputFile="../bin/liteFirewallW.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ProgramDatabaseFile=".\Release_UNICODE/liteFirewallW.pdb"
+ OptimizeReferences="2"
+ OptimizeForWindows98="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\Release_UNICODE/liteFirewallW.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\Release_UNICODE/liteFirewall.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ Description="Building Sample Installer..."
+ CommandLine="&quot;E:\Program Files (x86)\NSIS\Unicode\makensis&quot; /V2 /DTARGETDIR=$(TargetDir) /DINTDIR=$(IntDir) $(ProjectDir)Sample.nsi"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="1"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/liteFirewall.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;NSIS"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ PrecompiledHeaderFile=".\Release/liteFirewall.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib"
+ OutputFile="../bin/liteFirewall.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ProgramDatabaseFile=".\Release/liteFirewall.pdb"
+ OptimizeReferences="2"
+ OptimizeForWindows98="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\Release/liteFirewall.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\Release/liteFirewall.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ Description="Building Sample Installer..."
+ CommandLine="&quot;E:\Program Files (x86)\NSIS\Unicode\makensis&quot; /V2 /DTARGETDIR=$(TargetDir) /DINTDIR=$(IntDir) $(ProjectDir)Sample.nsi"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="exdll.h"
+ >
+ </File>
+ <File
+ RelativePath="License.txt"
+ >
+ </File>
+ <File
+ RelativePath="liteFirewall.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release UNICODE|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="ReadMe.txt"
+ >
+ </File>
+ <File
+ RelativePath="Sample.nsi"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="rem Force Post-Build Step&#x0D;&#x0A;"
+ Outputs="$(ProjectDir)Sample.exe"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release UNICODE|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="rem Force Post-Build Step&#x0D;&#x0A;"
+ Outputs="$(ProjectDir)Sample.exe"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="rem Force Post-Build Step&#x0D;&#x0A;"
+ Outputs="$(ProjectDir)Sample.exe"
+ />
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/other-licenses/nsis/Contrib/liteFirewall/netfw.tlb b/other-licenses/nsis/Contrib/liteFirewall/netfw.tlb
new file mode 100644
index 0000000000..18ff3481a6
--- /dev/null
+++ b/other-licenses/nsis/Contrib/liteFirewall/netfw.tlb
Binary files differ
diff --git a/other-licenses/snappy/README b/other-licenses/snappy/README
new file mode 100644
index 0000000000..2538acab69
--- /dev/null
+++ b/other-licenses/snappy/README
@@ -0,0 +1,26 @@
+See src/README for the README that ships with snappy.
+
+Mozilla does not modify the actual snappy source with the exception of the
+'snappy-stubs-public.h' header. We have replaced its build system with our own.
+
+Snappy comes from:
+ https://github.com/google/snappy
+
+We are currently using revision: 1.1.9
+
+To upgrade to a newer version:
+ 1. Check out the new code using subversion.
+ 2. Update 'snappy-stubs-public.h' in this directory with any changes that were
+ made to 'snappy-stubs-public.h.in' in the new source.
+ 3. Copy the major/minor/patch versions from 'CMakeLists.txt' into
+ 'snappy-stubs-public.h'.
+ 4. Copy all source files from the new version into the src subdirectory. The
+ following are not needed:
+ - 'CMakeLists.txt', 'snappy_benchmark.cc', 'snappy_test_data.cc',
+ 'snappy_test_data.h', and 'snappy_test_tool.cc' files
+ - 'cmake' subdirectory
+ - 'docs' subdirectory
+ - 'testdata' subdirectory
+ - 'third_party' subdirectory
+ 5. Update the revision stamp in this file.
+
diff --git a/other-licenses/snappy/moz.build b/other-licenses/snappy/moz.build
new file mode 100644
index 0000000000..56fc2ce4c3
--- /dev/null
+++ b/other-licenses/snappy/moz.build
@@ -0,0 +1,33 @@
+# -*- Mode: python; 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.snappy += [
+ 'snappy-stubs-public.h',
+ 'src/snappy-c.h',
+ 'src/snappy.h',
+]
+
+UNIFIED_SOURCES += [
+ 'src/snappy-c.cc',
+ 'src/snappy-sinksource.cc',
+ 'src/snappy-stubs-internal.cc',
+ 'src/snappy.cc',
+]
+
+# We allow warnings for third-party code that can be updated from upstream.
+AllowCompilerWarnings()
+
+FINAL_LIBRARY = 'xul'
+
+# Suppress warnings in third-party code.
+if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
+ CXXFLAGS += [
+ '-Wno-sign-compare',
+ '-Wno-unused-function'
+ ]
+
+if CONFIG['TARGET_ENDIANNESS'] == 'big':
+ DEFINES['SNAPPY_IS_BIG_ENDIAN'] = 1
diff --git a/other-licenses/snappy/snappy-stubs-public.h b/other-licenses/snappy/snappy-stubs-public.h
new file mode 100644
index 0000000000..42b690094c
--- /dev/null
+++ b/other-licenses/snappy/snappy-stubs-public.h
@@ -0,0 +1,56 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+// Author: sesse@google.com (Steinar H. Gunderson)
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Various type stubs for the open-source version of Snappy.
+//
+// This file cannot include config.h, as it is included from snappy.h,
+// which is a public header. Instead, snappy-stubs-public.h is generated by
+// from snappy-stubs-public.h.in at configure time.
+
+#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
+#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
+
+#include <cstddef>
+
+#define SNAPPY_MAJOR 1
+#define SNAPPY_MINOR 1
+#define SNAPPY_PATCHLEVEL 9
+#define SNAPPY_VERSION \
+ ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
+
+namespace snappy {
+
+struct iovec {
+ void* iov_base;
+ size_t iov_len;
+};
+
+} // namespace snappy
+
+#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
diff --git a/other-licenses/snappy/src/AUTHORS b/other-licenses/snappy/src/AUTHORS
new file mode 100644
index 0000000000..4858b377c7
--- /dev/null
+++ b/other-licenses/snappy/src/AUTHORS
@@ -0,0 +1 @@
+opensource@google.com
diff --git a/other-licenses/snappy/src/CONTRIBUTING.md b/other-licenses/snappy/src/CONTRIBUTING.md
new file mode 100644
index 0000000000..d0ce551527
--- /dev/null
+++ b/other-licenses/snappy/src/CONTRIBUTING.md
@@ -0,0 +1,46 @@
+# How to Contribute
+
+We'd love to accept your patches and contributions to this project. There are
+just a few small guidelines you need to follow.
+
+## Project Goals
+
+In addition to the aims listed at the top of the [README](README.md) Snappy
+explicitly supports the following:
+
+1. C++11
+2. Clang (gcc and MSVC are best-effort).
+3. Low level optimizations (e.g. assembly or equivalent intrinsics) for:
+ 1. [x86](https://en.wikipedia.org/wiki/X86)
+ 2. [x86-64](https://en.wikipedia.org/wiki/X86-64)
+ 3. ARMv7 (32-bit)
+ 4. ARMv8 (AArch64)
+4. Supports only the Snappy compression scheme as described in
+ [format_description.txt](format_description.txt).
+5. CMake for building
+
+Changes adding features or dependencies outside of the core area of focus listed
+above might not be accepted. If in doubt post a message to the
+[Snappy discussion mailing list](https://groups.google.com/g/snappy-compression).
+
+## Contributor License Agreement
+
+Contributions to this project must be accompanied by a Contributor License
+Agreement. You (or your employer) retain the copyright to your contribution,
+this simply gives us permission to use and redistribute your contributions as
+part of the project. Head over to <https://cla.developers.google.com/> to see
+your current agreements on file or to sign a new one.
+
+You generally only need to submit a CLA once, so if you've already submitted one
+(even if it was for a different project), you probably don't need to do it
+again.
+
+## Code reviews
+
+All submissions, including submissions by project members, require review. We
+use GitHub pull requests for this purpose. Consult
+[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
+information on using pull requests.
+
+Please make sure that all the automated checks (CLA, AppVeyor, Travis) pass for
+your pull requests. Pull requests whose checks fail may be ignored.
diff --git a/other-licenses/snappy/src/COPYING b/other-licenses/snappy/src/COPYING
new file mode 100644
index 0000000000..bd0e5971db
--- /dev/null
+++ b/other-licenses/snappy/src/COPYING
@@ -0,0 +1,54 @@
+Copyright 2011, Google Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+===
+
+Some of the benchmark data in testdata/ is licensed differently:
+
+ - fireworks.jpeg is Copyright 2013 Steinar H. Gunderson, and
+ is licensed under the Creative Commons Attribution 3.0 license
+ (CC-BY-3.0). See https://creativecommons.org/licenses/by/3.0/
+ for more information.
+
+ - kppkn.gtb is taken from the Gaviota chess tablebase set, and
+ is licensed under the MIT License. See
+ https://sites.google.com/site/gaviotachessengine/Home/endgame-tablebases-1
+ for more information.
+
+ - paper-100k.pdf is an excerpt (bytes 92160 to 194560) from the paper
+ “Combinatorial Modeling of Chromatin Features Quantitatively Predicts DNA
+ Replication Timing in _Drosophila_” by Federico Comoglio and Renato Paro,
+ which is licensed under the CC-BY license. See
+ http://www.ploscompbiol.org/static/license for more ifnormation.
+
+ - alice29.txt, asyoulik.txt, plrabn12.txt and lcet10.txt are from Project
+ Gutenberg. The first three have expired copyrights and are in the public
+ domain; the latter does not have expired copyright, but is still in the
+ public domain according to the license information
+ (http://www.gutenberg.org/ebooks/53).
diff --git a/other-licenses/snappy/src/NEWS b/other-licenses/snappy/src/NEWS
new file mode 100644
index 0000000000..931a5e13fd
--- /dev/null
+++ b/other-licenses/snappy/src/NEWS
@@ -0,0 +1,194 @@
+Snappy v1.1.9, May 4th 2021:
+
+ * Performance improvements.
+
+ * Google Test and Google Benchmark are now bundled in third_party/.
+
+Snappy v1.1.8, January 15th 2020:
+
+ * Small performance improvements.
+
+ * Removed snappy::string alias for std::string.
+
+ * Improved CMake configuration.
+
+Snappy v1.1.7, August 24th 2017:
+
+ * Improved CMake build support for 64-bit Linux distributions.
+
+ * MSVC builds now use MSVC-specific intrinsics that map to clzll.
+
+ * ARM64 (AArch64) builds use the code paths optimized for 64-bit processors.
+
+Snappy v1.1.6, July 12th 2017:
+
+This is a re-release of v1.1.5 with proper SONAME / SOVERSION values.
+
+Snappy v1.1.5, June 28th 2017:
+
+This release has broken SONAME / SOVERSION values. Users of snappy as a shared
+library should avoid 1.1.5 and use 1.1.6 instead. SONAME / SOVERSION errors will
+manifest as the dynamic library loader complaining that it cannot find snappy's
+shared library file (libsnappy.so / libsnappy.dylib), or that the library it
+found does not have the required version. 1.1.6 has the same code as 1.1.5, but
+carries build configuration fixes for the issues above.
+
+ * Add CMake build support. The autoconf build support is now deprecated, and
+ will be removed in the next release.
+
+ * Add AppVeyor configuration, for Windows CI coverage.
+
+ * Small performance improvement on little-endian PowerPC.
+
+ * Small performance improvement on LLVM with position-independent executables.
+
+ * Fix a few issues with various build environments.
+
+Snappy v1.1.4, January 25th 2017:
+
+ * Fix a 1% performance regression when snappy is used in PIE executables.
+
+ * Improve compression performance by 5%.
+
+ * Improve decompression performance by 20%.
+
+Snappy v1.1.3, July 6th 2015:
+
+This is the first release to be done from GitHub, which means that
+some minor things like the ChangeLog format has changed (git log
+format instead of svn log).
+
+ * Add support for Uncompress() from a Source to a Sink.
+
+ * Various minor changes to improve MSVC support; in particular,
+ the unit tests now compile and run under MSVC.
+
+
+Snappy v1.1.2, February 28th 2014:
+
+This is a maintenance release with no changes to the actual library
+source code.
+
+ * Stop distributing benchmark data files that have unclear
+ or unsuitable licensing.
+
+ * Add support for padding chunks in the framing format.
+
+
+Snappy v1.1.1, October 15th 2013:
+
+ * Add support for uncompressing to iovecs (scatter I/O).
+ The bulk of this patch was contributed by Mohit Aron.
+
+ * Speed up decompression by ~2%; much more so (~13-20%) on
+ a few benchmarks on given compilers and CPUs.
+
+ * Fix a few issues with MSVC compilation.
+
+ * Support truncated test data in the benchmark.
+
+
+Snappy v1.1.0, January 18th 2013:
+
+ * Snappy now uses 64 kB block size instead of 32 kB. On average,
+ this means it compresses about 3% denser (more so for some
+ inputs), at the same or better speeds.
+
+ * libsnappy no longer depends on iostream.
+
+ * Some small performance improvements in compression on x86
+ (0.5–1%).
+
+ * Various portability fixes for ARM-based platforms, for MSVC,
+ and for GNU/Hurd.
+
+
+Snappy v1.0.5, February 24th 2012:
+
+ * More speed improvements. Exactly how big will depend on
+ the architecture:
+
+ - 3–10% faster decompression for the base case (x86-64).
+
+ - ARMv7 and higher can now use unaligned accesses,
+ and will see about 30% faster decompression and
+ 20–40% faster compression.
+
+ - 32-bit platforms (ARM and 32-bit x86) will see 2–5%
+ faster compression.
+
+ These are all cumulative (e.g., ARM gets all three speedups).
+
+ * Fixed an issue where the unit test would crash on system
+ with less than 256 MB address space available,
+ e.g. some embedded platforms.
+
+ * Added a framing format description, for use over e.g. HTTP,
+ or for a command-line compressor. We do not have any
+ implementations of this at the current point, but there seems
+ to be enough of a general interest in the topic.
+ Also make the format description slightly clearer.
+
+ * Remove some compile-time warnings in -Wall
+ (mostly signed/unsigned comparisons), for easier embedding
+ into projects that use -Wall -Werror.
+
+
+Snappy v1.0.4, September 15th 2011:
+
+ * Speeded up the decompressor somewhat; typically about 2–8%
+ for Core i7, in 64-bit mode (comparable for Opteron).
+ Somewhat more for some tests, almost no gain for others.
+
+ * Make Snappy compile on certain platforms it didn't before
+ (Solaris with SunPro C++, HP-UX, AIX).
+
+ * Correct some minor errors in the format description.
+
+
+Snappy v1.0.3, June 2nd 2011:
+
+ * Speeded up the decompressor somewhat; about 3-6% for Core 2,
+ 6-13% for Core i7, and 5-12% for Opteron (all in 64-bit mode).
+
+ * Added compressed format documentation. This text is new,
+ but an earlier version from Zeev Tarantov was used as reference.
+
+ * Only link snappy_unittest against -lz and other autodetected
+ libraries, not libsnappy.so (which doesn't need any such dependency).
+
+ * Fixed some display issues in the microbenchmarks, one of which would
+ frequently make the test crash on GNU/Hurd.
+
+
+Snappy v1.0.2, April 29th 2011:
+
+ * Relicense to a BSD-type license.
+
+ * Added C bindings, contributed by Martin Gieseking.
+
+ * More Win32 fixes, in particular for MSVC.
+
+ * Replace geo.protodata with a newer version.
+
+ * Fix timing inaccuracies in the unit test when comparing Snappy
+ to other algorithms.
+
+
+Snappy v1.0.1, March 25th 2011:
+
+This is a maintenance release, mostly containing minor fixes.
+There is no new functionality. The most important fixes include:
+
+ * The COPYING file and all licensing headers now correctly state that
+ Snappy is licensed under the Apache 2.0 license.
+
+ * snappy_unittest should now compile natively under Windows,
+ as well as on embedded systems with no mmap().
+
+ * Various autotools nits have been fixed.
+
+
+Snappy v1.0, March 17th 2011:
+
+ * Initial version.
diff --git a/other-licenses/snappy/src/README.md b/other-licenses/snappy/src/README.md
new file mode 100644
index 0000000000..7917d1bf05
--- /dev/null
+++ b/other-licenses/snappy/src/README.md
@@ -0,0 +1,140 @@
+Snappy, a fast compressor/decompressor.
+
+[![Build Status](https://travis-ci.org/google/snappy.svg?branch=master)](https://travis-ci.org/google/snappy)
+[![Build status](https://ci.appveyor.com/api/projects/status/t9nubcqkwo8rw8yn/branch/master?svg=true)](https://ci.appveyor.com/project/pwnall/leveldb)
+
+Introduction
+============
+
+Snappy is a compression/decompression library. It does not aim for maximum
+compression, or compatibility with any other compression library; instead,
+it aims for very high speeds and reasonable compression. For instance,
+compared to the fastest mode of zlib, Snappy is an order of magnitude faster
+for most inputs, but the resulting compressed files are anywhere from 20% to
+100% bigger. (For more information, see "Performance", below.)
+
+Snappy has the following properties:
+
+ * Fast: Compression speeds at 250 MB/sec and beyond, with no assembler code.
+ See "Performance" below.
+ * Stable: Over the last few years, Snappy has compressed and decompressed
+ petabytes of data in Google's production environment. The Snappy bitstream
+ format is stable and will not change between versions.
+ * Robust: The Snappy decompressor is designed not to crash in the face of
+ corrupted or malicious input.
+ * Free and open source software: Snappy is licensed under a BSD-type license.
+ For more information, see the included COPYING file.
+
+Snappy has previously been called "Zippy" in some Google presentations
+and the like.
+
+
+Performance
+===========
+
+Snappy is intended to be fast. On a single core of a Core i7 processor
+in 64-bit mode, it compresses at about 250 MB/sec or more and decompresses at
+about 500 MB/sec or more. (These numbers are for the slowest inputs in our
+benchmark suite; others are much faster.) In our tests, Snappy usually
+is faster than algorithms in the same class (e.g. LZO, LZF, QuickLZ,
+etc.) while achieving comparable compression ratios.
+
+Typical compression ratios (based on the benchmark suite) are about 1.5-1.7x
+for plain text, about 2-4x for HTML, and of course 1.0x for JPEGs, PNGs and
+other already-compressed data. Similar numbers for zlib in its fastest mode
+are 2.6-2.8x, 3-7x and 1.0x, respectively. More sophisticated algorithms are
+capable of achieving yet higher compression rates, although usually at the
+expense of speed. Of course, compression ratio will vary significantly with
+the input.
+
+Although Snappy should be fairly portable, it is primarily optimized
+for 64-bit x86-compatible processors, and may run slower in other environments.
+In particular:
+
+ - Snappy uses 64-bit operations in several places to process more data at
+ once than would otherwise be possible.
+ - Snappy assumes unaligned 32 and 64-bit loads and stores are cheap.
+ On some platforms, these must be emulated with single-byte loads
+ and stores, which is much slower.
+ - Snappy assumes little-endian throughout, and needs to byte-swap data in
+ several places if running on a big-endian platform.
+
+Experience has shown that even heavily tuned code can be improved.
+Performance optimizations, whether for 64-bit x86 or other platforms,
+are of course most welcome; see "Contact", below.
+
+
+Building
+========
+
+You need the CMake version specified in [CMakeLists.txt](./CMakeLists.txt)
+or later to build:
+
+```bash
+git submodule update --init
+mkdir build
+cd build && cmake ../ && make
+```
+
+Usage
+=====
+
+Note that Snappy, both the implementation and the main interface,
+is written in C++. However, several third-party bindings to other languages
+are available; see the [home page](docs/README.md) for more information.
+Also, if you want to use Snappy from C code, you can use the included C
+bindings in snappy-c.h.
+
+To use Snappy from your own C++ program, include the file "snappy.h" from
+your calling file, and link against the compiled library.
+
+There are many ways to call Snappy, but the simplest possible is
+
+```c++
+snappy::Compress(input.data(), input.size(), &output);
+```
+
+and similarly
+
+```c++
+snappy::Uncompress(input.data(), input.size(), &output);
+```
+
+where "input" and "output" are both instances of std::string.
+
+There are other interfaces that are more flexible in various ways, including
+support for custom (non-array) input sources. See the header file for more
+information.
+
+
+Tests and benchmarks
+====================
+
+When you compile Snappy, the following binaries are compiled in addition to the
+library itself. You do not need them to use the compressor from your own
+library, but they are useful for Snappy development.
+
+* `snappy_benchmark` contains microbenchmarks used to tune compression and
+ decompression performance.
+* `snappy_unittests` contains unit tests, verifying correctness on your machine
+ in various scenarios.
+* `snappy_test_tool` can benchmark Snappy against a few other compression
+ libraries (zlib, LZO, LZF, and QuickLZ), if they were detected at configure
+ time. To benchmark using a given file, give the compression algorithm you want
+ to test Snappy against (e.g. --zlib) and then a list of one or more file names
+ on the command line.
+
+If you want to change or optimize Snappy, please run the tests and benchmarks to
+verify you have not broken anything.
+
+The testdata/ directory contains the files used by the microbenchmarks, which
+should provide a reasonably balanced starting point for benchmarking. (Note that
+baddata[1-3].snappy are not intended as benchmarks; they are used to verify
+correctness in the presence of corrupted data in the unit test.)
+
+
+Contact
+=======
+
+Snappy is distributed through GitHub. For the latest version and other
+information, see https://github.com/google/snappy.
diff --git a/other-licenses/snappy/src/format_description.txt b/other-licenses/snappy/src/format_description.txt
new file mode 100644
index 0000000000..20db66c1f2
--- /dev/null
+++ b/other-licenses/snappy/src/format_description.txt
@@ -0,0 +1,110 @@
+Snappy compressed format description
+Last revised: 2011-10-05
+
+
+This is not a formal specification, but should suffice to explain most
+relevant parts of how the Snappy format works. It is originally based on
+text by Zeev Tarantov.
+
+Snappy is a LZ77-type compressor with a fixed, byte-oriented encoding.
+There is no entropy encoder backend nor framing layer -- the latter is
+assumed to be handled by other parts of the system.
+
+This document only describes the format, not how the Snappy compressor nor
+decompressor actually works. The correctness of the decompressor should not
+depend on implementation details of the compressor, and vice versa.
+
+
+1. Preamble
+
+The stream starts with the uncompressed length (up to a maximum of 2^32 - 1),
+stored as a little-endian varint. Varints consist of a series of bytes,
+where the lower 7 bits are data and the upper bit is set iff there are
+more bytes to be read. In other words, an uncompressed length of 64 would
+be stored as 0x40, and an uncompressed length of 2097150 (0x1FFFFE)
+would be stored as 0xFE 0xFF 0x7F.
+
+
+2. The compressed stream itself
+
+There are two types of elements in a Snappy stream: Literals and
+copies (backreferences). There is no restriction on the order of elements,
+except that the stream naturally cannot start with a copy. (Having
+two literals in a row is never optimal from a compression point of
+view, but nevertheless fully permitted.) Each element starts with a tag byte,
+and the lower two bits of this tag byte signal what type of element will
+follow:
+
+ 00: Literal
+ 01: Copy with 1-byte offset
+ 10: Copy with 2-byte offset
+ 11: Copy with 4-byte offset
+
+The interpretation of the upper six bits are element-dependent.
+
+
+2.1. Literals (00)
+
+Literals are uncompressed data stored directly in the byte stream.
+The literal length is stored differently depending on the length
+of the literal:
+
+ - For literals up to and including 60 bytes in length, the upper
+ six bits of the tag byte contain (len-1). The literal follows
+ immediately thereafter in the bytestream.
+ - For longer literals, the (len-1) value is stored after the tag byte,
+ little-endian. The upper six bits of the tag byte describe how
+ many bytes are used for the length; 60, 61, 62 or 63 for
+ 1-4 bytes, respectively. The literal itself follows after the
+ length.
+
+
+2.2. Copies
+
+Copies are references back into previous decompressed data, telling
+the decompressor to reuse data it has previously decoded.
+They encode two values: The _offset_, saying how many bytes back
+from the current position to read, and the _length_, how many bytes
+to copy. Offsets of zero can be encoded, but are not legal;
+similarly, it is possible to encode backreferences that would
+go past the end of the block (offset > current decompressed position),
+which is also nonsensical and thus not allowed.
+
+As in most LZ77-based compressors, the length can be larger than the offset,
+yielding a form of run-length encoding (RLE). For instance,
+"xababab" could be encoded as
+
+ <literal: "xab"> <copy: offset=2 length=4>
+
+Note that since the current Snappy compressor works in 32 kB
+blocks and does not do matching across blocks, it will never produce
+a bitstream with offsets larger than about 32768. However, the
+decompressor should not rely on this, as it may change in the future.
+
+There are several different kinds of copy elements, depending on
+the amount of bytes to be copied (length), and how far back the
+data to be copied is (offset).
+
+
+2.2.1. Copy with 1-byte offset (01)
+
+These elements can encode lengths between [4..11] bytes and offsets
+between [0..2047] bytes. (len-4) occupies three bits and is stored
+in bits [2..4] of the tag byte. The offset occupies 11 bits, of which the
+upper three are stored in the upper three bits ([5..7]) of the tag byte,
+and the lower eight are stored in a byte following the tag byte.
+
+
+2.2.2. Copy with 2-byte offset (10)
+
+These elements can encode lengths between [1..64] and offsets from
+[0..65535]. (len-1) occupies six bits and is stored in the upper
+six bits ([2..7]) of the tag byte. The offset is stored as a
+little-endian 16-bit integer in the two bytes following the tag byte.
+
+
+2.2.3. Copy with 4-byte offset (11)
+
+These are like the copies with 2-byte offsets (see previous subsection),
+except that the offset is stored as a 32-bit integer instead of a
+16-bit integer (and thus will occupy four bytes).
diff --git a/other-licenses/snappy/src/framing_format.txt b/other-licenses/snappy/src/framing_format.txt
new file mode 100644
index 0000000000..9764e83de6
--- /dev/null
+++ b/other-licenses/snappy/src/framing_format.txt
@@ -0,0 +1,135 @@
+Snappy framing format description
+Last revised: 2013-10-25
+
+This format decribes a framing format for Snappy, allowing compressing to
+files or streams that can then more easily be decompressed without having
+to hold the entire stream in memory. It also provides data checksums to
+help verify integrity. It does not provide metadata checksums, so it does
+not protect against e.g. all forms of truncations.
+
+Implementation of the framing format is optional for Snappy compressors and
+decompressor; it is not part of the Snappy core specification.
+
+
+1. General structure
+
+The file consists solely of chunks, lying back-to-back with no padding
+in between. Each chunk consists first a single byte of chunk identifier,
+then a three-byte little-endian length of the chunk in bytes (from 0 to
+16777215, inclusive), and then the data if any. The four bytes of chunk
+header is not counted in the data length.
+
+The different chunk types are listed below. The first chunk must always
+be the stream identifier chunk (see section 4.1, below). The stream
+ends when the file ends -- there is no explicit end-of-file marker.
+
+
+2. File type identification
+
+The following identifiers for this format are recommended where appropriate.
+However, note that none have been registered officially, so this is only to
+be taken as a guideline. We use "Snappy framed" to distinguish between this
+format and raw Snappy data.
+
+ File extension: .sz
+ MIME type: application/x-snappy-framed
+ HTTP Content-Encoding: x-snappy-framed
+
+
+3. Checksum format
+
+Some chunks have data protected by a checksum (the ones that do will say so
+explicitly). The checksums are always masked CRC-32Cs.
+
+A description of CRC-32C can be found in RFC 3720, section 12.1, with
+examples in section B.4.
+
+Checksums are not stored directly, but masked, as checksumming data and
+then its own checksum can be problematic. The masking is the same as used
+in Apache Hadoop: Rotate the checksum by 15 bits, then add the constant
+0xa282ead8 (using wraparound as normal for unsigned integers). This is
+equivalent to the following C code:
+
+ uint32_t mask_checksum(uint32_t x) {
+ return ((x >> 15) | (x << 17)) + 0xa282ead8;
+ }
+
+Note that the masking is reversible.
+
+The checksum is always stored as a four bytes long integer, in little-endian.
+
+
+4. Chunk types
+
+The currently supported chunk types are described below. The list may
+be extended in the future.
+
+
+4.1. Stream identifier (chunk type 0xff)
+
+The stream identifier is always the first element in the stream.
+It is exactly six bytes long and contains "sNaPpY" in ASCII. This means that
+a valid Snappy framed stream always starts with the bytes
+
+ 0xff 0x06 0x00 0x00 0x73 0x4e 0x61 0x50 0x70 0x59
+
+The stream identifier chunk can come multiple times in the stream besides
+the first; if such a chunk shows up, it should simply be ignored, assuming
+it has the right length and contents. This allows for easy concatenation of
+compressed files without the need for re-framing.
+
+
+4.2. Compressed data (chunk type 0x00)
+
+Compressed data chunks contain a normal Snappy compressed bitstream;
+see the compressed format specification. The compressed data is preceded by
+the CRC-32C (see section 3) of the _uncompressed_ data.
+
+Note that the data portion of the chunk, i.e., the compressed contents,
+can be at most 16777211 bytes (2^24 - 1, minus the checksum).
+However, we place an additional restriction that the uncompressed data
+in a chunk must be no longer than 65536 bytes. This allows consumers to
+easily use small fixed-size buffers.
+
+
+4.3. Uncompressed data (chunk type 0x01)
+
+Uncompressed data chunks allow a compressor to send uncompressed,
+raw data; this is useful if, for instance, uncompressible or
+near-incompressible data is detected, and faster decompression is desired.
+
+As in the compressed chunks, the data is preceded by its own masked
+CRC-32C (see section 3).
+
+An uncompressed data chunk, like compressed data chunks, should contain
+no more than 65536 data bytes, so the maximum legal chunk length with the
+checksum is 65540.
+
+
+4.4. Padding (chunk type 0xfe)
+
+Padding chunks allow a compressor to increase the size of the data stream
+so that it complies with external demands, e.g. that the total number of
+bytes is a multiple of some value.
+
+All bytes of the padding chunk, except the chunk byte itself and the length,
+should be zero, but decompressors must not try to interpret or verify the
+padding data in any way.
+
+
+4.5. Reserved unskippable chunks (chunk types 0x02-0x7f)
+
+These are reserved for future expansion. A decoder that sees such a chunk
+should immediately return an error, as it must assume it cannot decode the
+stream correctly.
+
+Future versions of this specification may define meanings for these chunks.
+
+
+4.6. Reserved skippable chunks (chunk types 0x80-0xfd)
+
+These are also reserved for future expansion, but unlike the chunks
+described in 4.5, a decoder seeing these must skip them and continue
+decoding.
+
+Future versions of this specification may define meanings for these chunks.
diff --git a/other-licenses/snappy/src/snappy-c.cc b/other-licenses/snappy/src/snappy-c.cc
new file mode 100644
index 0000000000..473a0b0978
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-c.cc
@@ -0,0 +1,90 @@
+// Copyright 2011 Martin Gieseking <martin.gieseking@uos.de>.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "snappy.h"
+#include "snappy-c.h"
+
+extern "C" {
+
+snappy_status snappy_compress(const char* input,
+ size_t input_length,
+ char* compressed,
+ size_t *compressed_length) {
+ if (*compressed_length < snappy_max_compressed_length(input_length)) {
+ return SNAPPY_BUFFER_TOO_SMALL;
+ }
+ snappy::RawCompress(input, input_length, compressed, compressed_length);
+ return SNAPPY_OK;
+}
+
+snappy_status snappy_uncompress(const char* compressed,
+ size_t compressed_length,
+ char* uncompressed,
+ size_t* uncompressed_length) {
+ size_t real_uncompressed_length;
+ if (!snappy::GetUncompressedLength(compressed,
+ compressed_length,
+ &real_uncompressed_length)) {
+ return SNAPPY_INVALID_INPUT;
+ }
+ if (*uncompressed_length < real_uncompressed_length) {
+ return SNAPPY_BUFFER_TOO_SMALL;
+ }
+ if (!snappy::RawUncompress(compressed, compressed_length, uncompressed)) {
+ return SNAPPY_INVALID_INPUT;
+ }
+ *uncompressed_length = real_uncompressed_length;
+ return SNAPPY_OK;
+}
+
+size_t snappy_max_compressed_length(size_t source_length) {
+ return snappy::MaxCompressedLength(source_length);
+}
+
+snappy_status snappy_uncompressed_length(const char *compressed,
+ size_t compressed_length,
+ size_t *result) {
+ if (snappy::GetUncompressedLength(compressed,
+ compressed_length,
+ result)) {
+ return SNAPPY_OK;
+ } else {
+ return SNAPPY_INVALID_INPUT;
+ }
+}
+
+snappy_status snappy_validate_compressed_buffer(const char *compressed,
+ size_t compressed_length) {
+ if (snappy::IsValidCompressedBuffer(compressed, compressed_length)) {
+ return SNAPPY_OK;
+ } else {
+ return SNAPPY_INVALID_INPUT;
+ }
+}
+
+} // extern "C"
diff --git a/other-licenses/snappy/src/snappy-c.h b/other-licenses/snappy/src/snappy-c.h
new file mode 100644
index 0000000000..32aa0c6b8b
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-c.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2011 Martin Gieseking <martin.gieseking@uos.de>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Plain C interface (a wrapper around the C++ implementation).
+ */
+
+#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_C_H_
+#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_C_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+
+/*
+ * Return values; see the documentation for each function to know
+ * what each can return.
+ */
+typedef enum {
+ SNAPPY_OK = 0,
+ SNAPPY_INVALID_INPUT = 1,
+ SNAPPY_BUFFER_TOO_SMALL = 2
+} snappy_status;
+
+/*
+ * Takes the data stored in "input[0..input_length-1]" and stores
+ * it in the array pointed to by "compressed".
+ *
+ * <compressed_length> signals the space available in "compressed".
+ * If it is not at least equal to "snappy_max_compressed_length(input_length)",
+ * SNAPPY_BUFFER_TOO_SMALL is returned. After successful compression,
+ * <compressed_length> contains the true length of the compressed output,
+ * and SNAPPY_OK is returned.
+ *
+ * Example:
+ * size_t output_length = snappy_max_compressed_length(input_length);
+ * char* output = (char*)malloc(output_length);
+ * if (snappy_compress(input, input_length, output, &output_length)
+ * == SNAPPY_OK) {
+ * ... Process(output, output_length) ...
+ * }
+ * free(output);
+ */
+snappy_status snappy_compress(const char* input,
+ size_t input_length,
+ char* compressed,
+ size_t* compressed_length);
+
+/*
+ * Given data in "compressed[0..compressed_length-1]" generated by
+ * calling the snappy_compress routine, this routine stores
+ * the uncompressed data to
+ * uncompressed[0..uncompressed_length-1].
+ * Returns failure (a value not equal to SNAPPY_OK) if the message
+ * is corrupted and could not be decrypted.
+ *
+ * <uncompressed_length> signals the space available in "uncompressed".
+ * If it is not at least equal to the value returned by
+ * snappy_uncompressed_length for this stream, SNAPPY_BUFFER_TOO_SMALL
+ * is returned. After successful decompression, <uncompressed_length>
+ * contains the true length of the decompressed output.
+ *
+ * Example:
+ * size_t output_length;
+ * if (snappy_uncompressed_length(input, input_length, &output_length)
+ * != SNAPPY_OK) {
+ * ... fail ...
+ * }
+ * char* output = (char*)malloc(output_length);
+ * if (snappy_uncompress(input, input_length, output, &output_length)
+ * == SNAPPY_OK) {
+ * ... Process(output, output_length) ...
+ * }
+ * free(output);
+ */
+snappy_status snappy_uncompress(const char* compressed,
+ size_t compressed_length,
+ char* uncompressed,
+ size_t* uncompressed_length);
+
+/*
+ * Returns the maximal size of the compressed representation of
+ * input data that is "source_length" bytes in length.
+ */
+size_t snappy_max_compressed_length(size_t source_length);
+
+/*
+ * REQUIRES: "compressed[]" was produced by snappy_compress()
+ * Returns SNAPPY_OK and stores the length of the uncompressed data in
+ * *result normally. Returns SNAPPY_INVALID_INPUT on parsing error.
+ * This operation takes O(1) time.
+ */
+snappy_status snappy_uncompressed_length(const char* compressed,
+ size_t compressed_length,
+ size_t* result);
+
+/*
+ * Check if the contents of "compressed[]" can be uncompressed successfully.
+ * Does not return the uncompressed data; if so, returns SNAPPY_OK,
+ * or if not, returns SNAPPY_INVALID_INPUT.
+ * Takes time proportional to compressed_length, but is usually at least a
+ * factor of four faster than actual decompression.
+ */
+snappy_status snappy_validate_compressed_buffer(const char* compressed,
+ size_t compressed_length);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif /* THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_C_H_ */
diff --git a/other-licenses/snappy/src/snappy-internal.h b/other-licenses/snappy/src/snappy-internal.h
new file mode 100644
index 0000000000..720ccd8282
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-internal.h
@@ -0,0 +1,317 @@
+// Copyright 2008 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Internals shared between the Snappy implementation and its unittest.
+
+#ifndef THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_
+#define THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_
+
+#include "snappy-stubs-internal.h"
+
+namespace snappy {
+namespace internal {
+
+// Working memory performs a single allocation to hold all scratch space
+// required for compression.
+class WorkingMemory {
+ public:
+ explicit WorkingMemory(size_t input_size);
+ ~WorkingMemory();
+
+ // Allocates and clears a hash table using memory in "*this",
+ // stores the number of buckets in "*table_size" and returns a pointer to
+ // the base of the hash table.
+ uint16_t* GetHashTable(size_t fragment_size, int* table_size) const;
+ char* GetScratchInput() const { return input_; }
+ char* GetScratchOutput() const { return output_; }
+
+ private:
+ char* mem_; // the allocated memory, never nullptr
+ size_t size_; // the size of the allocated memory, never 0
+ uint16_t* table_; // the pointer to the hashtable
+ char* input_; // the pointer to the input scratch buffer
+ char* output_; // the pointer to the output scratch buffer
+
+ // No copying
+ WorkingMemory(const WorkingMemory&);
+ void operator=(const WorkingMemory&);
+};
+
+// Flat array compression that does not emit the "uncompressed length"
+// prefix. Compresses "input" string to the "*op" buffer.
+//
+// REQUIRES: "input_length <= kBlockSize"
+// REQUIRES: "op" points to an array of memory that is at least
+// "MaxCompressedLength(input_length)" in size.
+// REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero.
+// REQUIRES: "table_size" is a power of two
+//
+// Returns an "end" pointer into "op" buffer.
+// "end - op" is the compressed size of "input".
+char* CompressFragment(const char* input,
+ size_t input_length,
+ char* op,
+ uint16_t* table,
+ const int table_size);
+
+// Find the largest n such that
+//
+// s1[0,n-1] == s2[0,n-1]
+// and n <= (s2_limit - s2).
+//
+// Return make_pair(n, n < 8).
+// Does not read *s2_limit or beyond.
+// Does not read *(s1 + (s2_limit - s2)) or beyond.
+// Requires that s2_limit >= s2.
+//
+// In addition populate *data with the next 5 bytes from the end of the match.
+// This is only done if 8 bytes are available (s2_limit - s2 >= 8). The point is
+// that on some arch's this can be done faster in this routine than subsequent
+// loading from s2 + n.
+//
+// Separate implementation for 64-bit, little-endian cpus.
+#if !defined(SNAPPY_IS_BIG_ENDIAN) && \
+ (defined(__x86_64__) || defined(_M_X64) || defined(ARCH_PPC) || defined(ARCH_ARM))
+static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
+ const char* s2,
+ const char* s2_limit,
+ uint64_t* data) {
+ assert(s2_limit >= s2);
+ size_t matched = 0;
+
+ // This block isn't necessary for correctness; we could just start looping
+ // immediately. As an optimization though, it is useful. It creates some not
+ // uncommon code paths that determine, without extra effort, whether the match
+ // length is less than 8. In short, we are hoping to avoid a conditional
+ // branch, and perhaps get better code layout from the C++ compiler.
+ if (SNAPPY_PREDICT_TRUE(s2 <= s2_limit - 16)) {
+ uint64_t a1 = UNALIGNED_LOAD64(s1);
+ uint64_t a2 = UNALIGNED_LOAD64(s2);
+ if (SNAPPY_PREDICT_TRUE(a1 != a2)) {
+ // This code is critical for performance. The reason is that it determines
+ // how much to advance `ip` (s2). This obviously depends on both the loads
+ // from the `candidate` (s1) and `ip`. Furthermore the next `candidate`
+ // depends on the advanced `ip` calculated here through a load, hash and
+ // new candidate hash lookup (a lot of cycles). This makes s1 (ie.
+ // `candidate`) the variable that limits throughput. This is the reason we
+ // go through hoops to have this function update `data` for the next iter.
+ // The straightforward code would use *data, given by
+ //
+ // *data = UNALIGNED_LOAD64(s2 + matched_bytes) (Latency of 5 cycles),
+ //
+ // as input for the hash table lookup to find next candidate. However
+ // this forces the load on the data dependency chain of s1, because
+ // matched_bytes directly depends on s1. However matched_bytes is 0..7, so
+ // we can also calculate *data by
+ //
+ // *data = AlignRight(UNALIGNED_LOAD64(s2), UNALIGNED_LOAD64(s2 + 8),
+ // matched_bytes);
+ //
+ // The loads do not depend on s1 anymore and are thus off the bottleneck.
+ // The straightforward implementation on x86_64 would be to use
+ //
+ // shrd rax, rdx, cl (cl being matched_bytes * 8)
+ //
+ // unfortunately shrd with a variable shift has a 4 cycle latency. So this
+ // only wins 1 cycle. The BMI2 shrx instruction is a 1 cycle variable
+ // shift instruction but can only shift 64 bits. If we focus on just
+ // obtaining the least significant 4 bytes, we can obtain this by
+ //
+ // *data = ConditionalMove(matched_bytes < 4, UNALIGNED_LOAD64(s2),
+ // UNALIGNED_LOAD64(s2 + 4) >> ((matched_bytes & 3) * 8);
+ //
+ // Writen like above this is not a big win, the conditional move would be
+ // a cmp followed by a cmov (2 cycles) followed by a shift (1 cycle).
+ // However matched_bytes < 4 is equal to
+ // static_cast<uint32_t>(xorval) != 0. Writen that way, the conditional
+ // move (2 cycles) can execute in parallel with FindLSBSetNonZero64
+ // (tzcnt), which takes 3 cycles.
+ uint64_t xorval = a1 ^ a2;
+ int shift = Bits::FindLSBSetNonZero64(xorval);
+ size_t matched_bytes = shift >> 3;
+#ifndef __x86_64__
+ *data = UNALIGNED_LOAD64(s2 + matched_bytes);
+#else
+ // Ideally this would just be
+ //
+ // a2 = static_cast<uint32_t>(xorval) == 0 ? a3 : a2;
+ //
+ // However clang correctly infers that the above statement participates on
+ // a critical data dependency chain and thus, unfortunately, refuses to
+ // use a conditional move (it's tuned to cut data dependencies). In this
+ // case there is a longer parallel chain anyway AND this will be fairly
+ // unpredictable.
+ uint64_t a3 = UNALIGNED_LOAD64(s2 + 4);
+ asm("testl %k2, %k2\n\t"
+ "cmovzq %1, %0\n\t"
+ : "+r"(a2)
+ : "r"(a3), "r"(xorval));
+ *data = a2 >> (shift & (3 * 8));
+#endif
+ return std::pair<size_t, bool>(matched_bytes, true);
+ } else {
+ matched = 8;
+ s2 += 8;
+ }
+ }
+
+ // Find out how long the match is. We loop over the data 64 bits at a
+ // time until we find a 64-bit block that doesn't match; then we find
+ // the first non-matching bit and use that to calculate the total
+ // length of the match.
+ while (SNAPPY_PREDICT_TRUE(s2 <= s2_limit - 16)) {
+ uint64_t a1 = UNALIGNED_LOAD64(s1 + matched);
+ uint64_t a2 = UNALIGNED_LOAD64(s2);
+ if (a1 == a2) {
+ s2 += 8;
+ matched += 8;
+ } else {
+ uint64_t xorval = a1 ^ a2;
+ int shift = Bits::FindLSBSetNonZero64(xorval);
+ size_t matched_bytes = shift >> 3;
+#ifndef __x86_64__
+ *data = UNALIGNED_LOAD64(s2 + matched_bytes);
+#else
+ uint64_t a3 = UNALIGNED_LOAD64(s2 + 4);
+ asm("testl %k2, %k2\n\t"
+ "cmovzq %1, %0\n\t"
+ : "+r"(a2)
+ : "r"(a3), "r"(xorval));
+ *data = a2 >> (shift & (3 * 8));
+#endif
+ matched += matched_bytes;
+ assert(matched >= 8);
+ return std::pair<size_t, bool>(matched, false);
+ }
+ }
+ while (SNAPPY_PREDICT_TRUE(s2 < s2_limit)) {
+ if (s1[matched] == *s2) {
+ ++s2;
+ ++matched;
+ } else {
+ if (s2 <= s2_limit - 8) {
+ *data = UNALIGNED_LOAD64(s2);
+ }
+ return std::pair<size_t, bool>(matched, matched < 8);
+ }
+ }
+ return std::pair<size_t, bool>(matched, matched < 8);
+}
+#else
+static inline std::pair<size_t, bool> FindMatchLength(const char* s1,
+ const char* s2,
+ const char* s2_limit,
+ uint64_t* data) {
+ // Implementation based on the x86-64 version, above.
+ assert(s2_limit >= s2);
+ int matched = 0;
+
+ while (s2 <= s2_limit - 4 &&
+ UNALIGNED_LOAD32(s2) == UNALIGNED_LOAD32(s1 + matched)) {
+ s2 += 4;
+ matched += 4;
+ }
+ if (LittleEndian::IsLittleEndian() && s2 <= s2_limit - 4) {
+ uint32_t x = UNALIGNED_LOAD32(s2) ^ UNALIGNED_LOAD32(s1 + matched);
+ int matching_bits = Bits::FindLSBSetNonZero(x);
+ matched += matching_bits >> 3;
+ s2 += matching_bits >> 3;
+ } else {
+ while ((s2 < s2_limit) && (s1[matched] == *s2)) {
+ ++s2;
+ ++matched;
+ }
+ }
+ if (s2 <= s2_limit - 8) *data = LittleEndian::Load64(s2);
+ return std::pair<size_t, bool>(matched, matched < 8);
+}
+#endif
+
+// Lookup tables for decompression code. Give --snappy_dump_decompression_table
+// to the unit test to recompute char_table.
+
+enum {
+ LITERAL = 0,
+ COPY_1_BYTE_OFFSET = 1, // 3 bit length + 3 bits of offset in opcode
+ COPY_2_BYTE_OFFSET = 2,
+ COPY_4_BYTE_OFFSET = 3
+};
+static const int kMaximumTagLength = 5; // COPY_4_BYTE_OFFSET plus the actual offset.
+
+// Data stored per entry in lookup table:
+// Range Bits-used Description
+// ------------------------------------
+// 1..64 0..7 Literal/copy length encoded in opcode byte
+// 0..7 8..10 Copy offset encoded in opcode byte / 256
+// 0..4 11..13 Extra bytes after opcode
+//
+// We use eight bits for the length even though 7 would have sufficed
+// because of efficiency reasons:
+// (1) Extracting a byte is faster than a bit-field
+// (2) It properly aligns copy offset so we do not need a <<8
+static constexpr uint16_t char_table[256] = {
+ // clang-format off
+ 0x0001, 0x0804, 0x1001, 0x2001, 0x0002, 0x0805, 0x1002, 0x2002,
+ 0x0003, 0x0806, 0x1003, 0x2003, 0x0004, 0x0807, 0x1004, 0x2004,
+ 0x0005, 0x0808, 0x1005, 0x2005, 0x0006, 0x0809, 0x1006, 0x2006,
+ 0x0007, 0x080a, 0x1007, 0x2007, 0x0008, 0x080b, 0x1008, 0x2008,
+ 0x0009, 0x0904, 0x1009, 0x2009, 0x000a, 0x0905, 0x100a, 0x200a,
+ 0x000b, 0x0906, 0x100b, 0x200b, 0x000c, 0x0907, 0x100c, 0x200c,
+ 0x000d, 0x0908, 0x100d, 0x200d, 0x000e, 0x0909, 0x100e, 0x200e,
+ 0x000f, 0x090a, 0x100f, 0x200f, 0x0010, 0x090b, 0x1010, 0x2010,
+ 0x0011, 0x0a04, 0x1011, 0x2011, 0x0012, 0x0a05, 0x1012, 0x2012,
+ 0x0013, 0x0a06, 0x1013, 0x2013, 0x0014, 0x0a07, 0x1014, 0x2014,
+ 0x0015, 0x0a08, 0x1015, 0x2015, 0x0016, 0x0a09, 0x1016, 0x2016,
+ 0x0017, 0x0a0a, 0x1017, 0x2017, 0x0018, 0x0a0b, 0x1018, 0x2018,
+ 0x0019, 0x0b04, 0x1019, 0x2019, 0x001a, 0x0b05, 0x101a, 0x201a,
+ 0x001b, 0x0b06, 0x101b, 0x201b, 0x001c, 0x0b07, 0x101c, 0x201c,
+ 0x001d, 0x0b08, 0x101d, 0x201d, 0x001e, 0x0b09, 0x101e, 0x201e,
+ 0x001f, 0x0b0a, 0x101f, 0x201f, 0x0020, 0x0b0b, 0x1020, 0x2020,
+ 0x0021, 0x0c04, 0x1021, 0x2021, 0x0022, 0x0c05, 0x1022, 0x2022,
+ 0x0023, 0x0c06, 0x1023, 0x2023, 0x0024, 0x0c07, 0x1024, 0x2024,
+ 0x0025, 0x0c08, 0x1025, 0x2025, 0x0026, 0x0c09, 0x1026, 0x2026,
+ 0x0027, 0x0c0a, 0x1027, 0x2027, 0x0028, 0x0c0b, 0x1028, 0x2028,
+ 0x0029, 0x0d04, 0x1029, 0x2029, 0x002a, 0x0d05, 0x102a, 0x202a,
+ 0x002b, 0x0d06, 0x102b, 0x202b, 0x002c, 0x0d07, 0x102c, 0x202c,
+ 0x002d, 0x0d08, 0x102d, 0x202d, 0x002e, 0x0d09, 0x102e, 0x202e,
+ 0x002f, 0x0d0a, 0x102f, 0x202f, 0x0030, 0x0d0b, 0x1030, 0x2030,
+ 0x0031, 0x0e04, 0x1031, 0x2031, 0x0032, 0x0e05, 0x1032, 0x2032,
+ 0x0033, 0x0e06, 0x1033, 0x2033, 0x0034, 0x0e07, 0x1034, 0x2034,
+ 0x0035, 0x0e08, 0x1035, 0x2035, 0x0036, 0x0e09, 0x1036, 0x2036,
+ 0x0037, 0x0e0a, 0x1037, 0x2037, 0x0038, 0x0e0b, 0x1038, 0x2038,
+ 0x0039, 0x0f04, 0x1039, 0x2039, 0x003a, 0x0f05, 0x103a, 0x203a,
+ 0x003b, 0x0f06, 0x103b, 0x203b, 0x003c, 0x0f07, 0x103c, 0x203c,
+ 0x0801, 0x0f08, 0x103d, 0x203d, 0x1001, 0x0f09, 0x103e, 0x203e,
+ 0x1801, 0x0f0a, 0x103f, 0x203f, 0x2001, 0x0f0b, 0x1040, 0x2040,
+ // clang-format on
+};
+
+} // end namespace internal
+} // end namespace snappy
+
+#endif // THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_
diff --git a/other-licenses/snappy/src/snappy-sinksource.cc b/other-licenses/snappy/src/snappy-sinksource.cc
new file mode 100644
index 0000000000..8214964a7e
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-sinksource.cc
@@ -0,0 +1,121 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <stddef.h>
+#include <cstring>
+
+#include "snappy-sinksource.h"
+
+namespace snappy {
+
+Source::~Source() = default;
+
+Sink::~Sink() = default;
+
+char* Sink::GetAppendBuffer(size_t length, char* scratch) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)length;
+
+ return scratch;
+}
+
+char* Sink::GetAppendBufferVariable(
+ size_t min_size, size_t desired_size_hint, char* scratch,
+ size_t scratch_size, size_t* allocated_size) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)min_size;
+ (void)desired_size_hint;
+
+ *allocated_size = scratch_size;
+ return scratch;
+}
+
+void Sink::AppendAndTakeOwnership(
+ char* bytes, size_t n,
+ void (*deleter)(void*, const char*, size_t),
+ void *deleter_arg) {
+ Append(bytes, n);
+ (*deleter)(deleter_arg, bytes, n);
+}
+
+ByteArraySource::~ByteArraySource() = default;
+
+size_t ByteArraySource::Available() const { return left_; }
+
+const char* ByteArraySource::Peek(size_t* len) {
+ *len = left_;
+ return ptr_;
+}
+
+void ByteArraySource::Skip(size_t n) {
+ left_ -= n;
+ ptr_ += n;
+}
+
+UncheckedByteArraySink::~UncheckedByteArraySink() { }
+
+void UncheckedByteArraySink::Append(const char* data, size_t n) {
+ // Do no copying if the caller filled in the result of GetAppendBuffer()
+ if (data != dest_) {
+ std::memcpy(dest_, data, n);
+ }
+ dest_ += n;
+}
+
+char* UncheckedByteArraySink::GetAppendBuffer(size_t len, char* scratch) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)len;
+ (void)scratch;
+
+ return dest_;
+}
+
+void UncheckedByteArraySink::AppendAndTakeOwnership(
+ char* bytes, size_t n,
+ void (*deleter)(void*, const char*, size_t),
+ void *deleter_arg) {
+ if (bytes != dest_) {
+ std::memcpy(dest_, bytes, n);
+ (*deleter)(deleter_arg, bytes, n);
+ }
+ dest_ += n;
+}
+
+char* UncheckedByteArraySink::GetAppendBufferVariable(
+ size_t min_size, size_t desired_size_hint, char* scratch,
+ size_t scratch_size, size_t* allocated_size) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)min_size;
+ (void)scratch;
+ (void)scratch_size;
+
+ *allocated_size = desired_size_hint;
+ return dest_;
+}
+
+} // namespace snappy
diff --git a/other-licenses/snappy/src/snappy-sinksource.h b/other-licenses/snappy/src/snappy-sinksource.h
new file mode 100644
index 0000000000..3c74e1bb6e
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-sinksource.h
@@ -0,0 +1,182 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef THIRD_PARTY_SNAPPY_SNAPPY_SINKSOURCE_H_
+#define THIRD_PARTY_SNAPPY_SNAPPY_SINKSOURCE_H_
+
+#include <stddef.h>
+
+namespace snappy {
+
+// A Sink is an interface that consumes a sequence of bytes.
+class Sink {
+ public:
+ Sink() { }
+ virtual ~Sink();
+
+ // Append "bytes[0,n-1]" to this.
+ virtual void Append(const char* bytes, size_t n) = 0;
+
+ // Returns a writable buffer of the specified length for appending.
+ // May return a pointer to the caller-owned scratch buffer which
+ // must have at least the indicated length. The returned buffer is
+ // only valid until the next operation on this Sink.
+ //
+ // After writing at most "length" bytes, call Append() with the
+ // pointer returned from this function and the number of bytes
+ // written. Many Append() implementations will avoid copying
+ // bytes if this function returned an internal buffer.
+ //
+ // If a non-scratch buffer is returned, the caller may only pass a
+ // prefix of it to Append(). That is, it is not correct to pass an
+ // interior pointer of the returned array to Append().
+ //
+ // The default implementation always returns the scratch buffer.
+ virtual char* GetAppendBuffer(size_t length, char* scratch);
+
+ // For higher performance, Sink implementations can provide custom
+ // AppendAndTakeOwnership() and GetAppendBufferVariable() methods.
+ // These methods can reduce the number of copies done during
+ // compression/decompression.
+
+ // Append "bytes[0,n-1] to the sink. Takes ownership of "bytes"
+ // and calls the deleter function as (*deleter)(deleter_arg, bytes, n)
+ // to free the buffer. deleter function must be non NULL.
+ //
+ // The default implementation just calls Append and frees "bytes".
+ // Other implementations may avoid a copy while appending the buffer.
+ virtual void AppendAndTakeOwnership(
+ char* bytes, size_t n, void (*deleter)(void*, const char*, size_t),
+ void *deleter_arg);
+
+ // Returns a writable buffer for appending and writes the buffer's capacity to
+ // *allocated_size. Guarantees *allocated_size >= min_size.
+ // May return a pointer to the caller-owned scratch buffer which must have
+ // scratch_size >= min_size.
+ //
+ // The returned buffer is only valid until the next operation
+ // on this ByteSink.
+ //
+ // After writing at most *allocated_size bytes, call Append() with the
+ // pointer returned from this function and the number of bytes written.
+ // Many Append() implementations will avoid copying bytes if this function
+ // returned an internal buffer.
+ //
+ // If the sink implementation allocates or reallocates an internal buffer,
+ // it should use the desired_size_hint if appropriate. If a caller cannot
+ // provide a reasonable guess at the desired capacity, it should set
+ // desired_size_hint = 0.
+ //
+ // If a non-scratch buffer is returned, the caller may only pass
+ // a prefix to it to Append(). That is, it is not correct to pass an
+ // interior pointer to Append().
+ //
+ // The default implementation always returns the scratch buffer.
+ virtual char* GetAppendBufferVariable(
+ size_t min_size, size_t desired_size_hint, char* scratch,
+ size_t scratch_size, size_t* allocated_size);
+
+ private:
+ // No copying
+ Sink(const Sink&);
+ void operator=(const Sink&);
+};
+
+// A Source is an interface that yields a sequence of bytes
+class Source {
+ public:
+ Source() { }
+ virtual ~Source();
+
+ // Return the number of bytes left to read from the source
+ virtual size_t Available() const = 0;
+
+ // Peek at the next flat region of the source. Does not reposition
+ // the source. The returned region is empty iff Available()==0.
+ //
+ // Returns a pointer to the beginning of the region and store its
+ // length in *len.
+ //
+ // The returned region is valid until the next call to Skip() or
+ // until this object is destroyed, whichever occurs first.
+ //
+ // The returned region may be larger than Available() (for example
+ // if this ByteSource is a view on a substring of a larger source).
+ // The caller is responsible for ensuring that it only reads the
+ // Available() bytes.
+ virtual const char* Peek(size_t* len) = 0;
+
+ // Skip the next n bytes. Invalidates any buffer returned by
+ // a previous call to Peek().
+ // REQUIRES: Available() >= n
+ virtual void Skip(size_t n) = 0;
+
+ private:
+ // No copying
+ Source(const Source&);
+ void operator=(const Source&);
+};
+
+// A Source implementation that yields the contents of a flat array
+class ByteArraySource : public Source {
+ public:
+ ByteArraySource(const char* p, size_t n) : ptr_(p), left_(n) { }
+ ~ByteArraySource() override;
+ size_t Available() const override;
+ const char* Peek(size_t* len) override;
+ void Skip(size_t n) override;
+ private:
+ const char* ptr_;
+ size_t left_;
+};
+
+// A Sink implementation that writes to a flat array without any bound checks.
+class UncheckedByteArraySink : public Sink {
+ public:
+ explicit UncheckedByteArraySink(char* dest) : dest_(dest) { }
+ ~UncheckedByteArraySink() override;
+ void Append(const char* data, size_t n) override;
+ char* GetAppendBuffer(size_t len, char* scratch) override;
+ char* GetAppendBufferVariable(
+ size_t min_size, size_t desired_size_hint, char* scratch,
+ size_t scratch_size, size_t* allocated_size) override;
+ void AppendAndTakeOwnership(
+ char* bytes, size_t n, void (*deleter)(void*, const char*, size_t),
+ void *deleter_arg) override;
+
+ // Return the current output pointer so that a caller can see how
+ // many bytes were produced.
+ // Note: this is not a Sink method.
+ char* CurrentDestination() const { return dest_; }
+ private:
+ char* dest_;
+};
+
+} // namespace snappy
+
+#endif // THIRD_PARTY_SNAPPY_SNAPPY_SINKSOURCE_H_
diff --git a/other-licenses/snappy/src/snappy-stubs-internal.cc b/other-licenses/snappy/src/snappy-stubs-internal.cc
new file mode 100644
index 0000000000..0bc8c2d344
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-stubs-internal.cc
@@ -0,0 +1,42 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <algorithm>
+#include <string>
+
+#include "snappy-stubs-internal.h"
+
+namespace snappy {
+
+void Varint::Append32(std::string* s, uint32_t value) {
+ char buf[Varint::kMax32];
+ const char* p = Varint::Encode32(buf, value);
+ s->append(buf, p - buf);
+}
+
+} // namespace snappy
diff --git a/other-licenses/snappy/src/snappy-stubs-internal.h b/other-licenses/snappy/src/snappy-stubs-internal.h
new file mode 100644
index 0000000000..c2a838f38f
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-stubs-internal.h
@@ -0,0 +1,492 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Various stubs for the open-source version of Snappy.
+
+#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_INTERNAL_H_
+#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_INTERNAL_H_
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdint.h>
+
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
+#include <limits>
+#include <string>
+
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if defined(_MSC_VER)
+#include <intrin.h>
+#endif // defined(_MSC_VER)
+
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+
+#if __has_feature(memory_sanitizer)
+#include <sanitizer/msan_interface.h>
+#define SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) \
+ __msan_unpoison((address), (size))
+#else
+#define SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) /* empty */
+#endif // __has_feature(memory_sanitizer)
+
+#include "snappy-stubs-public.h"
+
+// Used to enable 64-bit optimized versions of some routines.
+#if defined(__PPC64__) || defined(__powerpc64__)
+#define ARCH_PPC 1
+#elif defined(__aarch64__) || defined(_M_ARM64)
+#define ARCH_ARM 1
+#endif
+
+// Needed by OS X, among others.
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+// The size of an array, if known at compile-time.
+// Will give unexpected results if used on a pointer.
+// We undefine it first, since some compilers already have a definition.
+#ifdef ARRAYSIZE
+#undef ARRAYSIZE
+#endif
+#define ARRAYSIZE(a) int{sizeof(a) / sizeof(*(a))}
+
+// Static prediction hints.
+#ifdef HAVE_BUILTIN_EXPECT
+#define SNAPPY_PREDICT_FALSE(x) (__builtin_expect(x, 0))
+#define SNAPPY_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
+#else
+#define SNAPPY_PREDICT_FALSE(x) x
+#define SNAPPY_PREDICT_TRUE(x) x
+#endif
+
+// Inlining hints.
+#ifdef HAVE_ATTRIBUTE_ALWAYS_INLINE
+#define SNAPPY_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
+#else
+#define SNAPPY_ATTRIBUTE_ALWAYS_INLINE
+#endif
+
+// Stubbed version of ABSL_FLAG.
+//
+// In the open source version, flags can only be changed at compile time.
+#define SNAPPY_FLAG(flag_type, flag_name, default_value, help) \
+ flag_type FLAGS_ ## flag_name = default_value
+
+namespace snappy {
+
+// Stubbed version of absl::GetFlag().
+template <typename T>
+inline T GetFlag(T flag) { return flag; }
+
+static const uint32_t kuint32max = std::numeric_limits<uint32_t>::max();
+static const int64_t kint64max = std::numeric_limits<int64_t>::max();
+
+// Potentially unaligned loads and stores.
+
+inline uint16_t UNALIGNED_LOAD16(const void *p) {
+ // Compiles to a single movzx/ldrh on clang/gcc/msvc.
+ uint16_t v;
+ std::memcpy(&v, p, sizeof(v));
+ return v;
+}
+
+inline uint32_t UNALIGNED_LOAD32(const void *p) {
+ // Compiles to a single mov/ldr on clang/gcc/msvc.
+ uint32_t v;
+ std::memcpy(&v, p, sizeof(v));
+ return v;
+}
+
+inline uint64_t UNALIGNED_LOAD64(const void *p) {
+ // Compiles to a single mov/ldr on clang/gcc/msvc.
+ uint64_t v;
+ std::memcpy(&v, p, sizeof(v));
+ return v;
+}
+
+inline void UNALIGNED_STORE16(void *p, uint16_t v) {
+ // Compiles to a single mov/strh on clang/gcc/msvc.
+ std::memcpy(p, &v, sizeof(v));
+}
+
+inline void UNALIGNED_STORE32(void *p, uint32_t v) {
+ // Compiles to a single mov/str on clang/gcc/msvc.
+ std::memcpy(p, &v, sizeof(v));
+}
+
+inline void UNALIGNED_STORE64(void *p, uint64_t v) {
+ // Compiles to a single mov/str on clang/gcc/msvc.
+ std::memcpy(p, &v, sizeof(v));
+}
+
+// Convert to little-endian storage, opposite of network format.
+// Convert x from host to little endian: x = LittleEndian.FromHost(x);
+// convert x from little endian to host: x = LittleEndian.ToHost(x);
+//
+// Store values into unaligned memory converting to little endian order:
+// LittleEndian.Store16(p, x);
+//
+// Load unaligned values stored in little endian converting to host order:
+// x = LittleEndian.Load16(p);
+class LittleEndian {
+ public:
+ // Functions to do unaligned loads and stores in little-endian order.
+ static inline uint16_t Load16(const void *ptr) {
+ const uint8_t* const buffer = reinterpret_cast<const uint8_t*>(ptr);
+
+ // Compiles to a single mov/str on recent clang and gcc.
+ return (static_cast<uint16_t>(buffer[0])) |
+ (static_cast<uint16_t>(buffer[1]) << 8);
+ }
+
+ static inline uint32_t Load32(const void *ptr) {
+ const uint8_t* const buffer = reinterpret_cast<const uint8_t*>(ptr);
+
+ // Compiles to a single mov/str on recent clang and gcc.
+ return (static_cast<uint32_t>(buffer[0])) |
+ (static_cast<uint32_t>(buffer[1]) << 8) |
+ (static_cast<uint32_t>(buffer[2]) << 16) |
+ (static_cast<uint32_t>(buffer[3]) << 24);
+ }
+
+ static inline uint64_t Load64(const void *ptr) {
+ const uint8_t* const buffer = reinterpret_cast<const uint8_t*>(ptr);
+
+ // Compiles to a single mov/str on recent clang and gcc.
+ return (static_cast<uint64_t>(buffer[0])) |
+ (static_cast<uint64_t>(buffer[1]) << 8) |
+ (static_cast<uint64_t>(buffer[2]) << 16) |
+ (static_cast<uint64_t>(buffer[3]) << 24) |
+ (static_cast<uint64_t>(buffer[4]) << 32) |
+ (static_cast<uint64_t>(buffer[5]) << 40) |
+ (static_cast<uint64_t>(buffer[6]) << 48) |
+ (static_cast<uint64_t>(buffer[7]) << 56);
+ }
+
+ static inline void Store16(void *dst, uint16_t value) {
+ uint8_t* const buffer = reinterpret_cast<uint8_t*>(dst);
+
+ // Compiles to a single mov/str on recent clang and gcc.
+ buffer[0] = static_cast<uint8_t>(value);
+ buffer[1] = static_cast<uint8_t>(value >> 8);
+ }
+
+ static void Store32(void *dst, uint32_t value) {
+ uint8_t* const buffer = reinterpret_cast<uint8_t*>(dst);
+
+ // Compiles to a single mov/str on recent clang and gcc.
+ buffer[0] = static_cast<uint8_t>(value);
+ buffer[1] = static_cast<uint8_t>(value >> 8);
+ buffer[2] = static_cast<uint8_t>(value >> 16);
+ buffer[3] = static_cast<uint8_t>(value >> 24);
+ }
+
+ static void Store64(void* dst, uint64_t value) {
+ uint8_t* const buffer = reinterpret_cast<uint8_t*>(dst);
+
+ // Compiles to a single mov/str on recent clang and gcc.
+ buffer[0] = static_cast<uint8_t>(value);
+ buffer[1] = static_cast<uint8_t>(value >> 8);
+ buffer[2] = static_cast<uint8_t>(value >> 16);
+ buffer[3] = static_cast<uint8_t>(value >> 24);
+ buffer[4] = static_cast<uint8_t>(value >> 32);
+ buffer[5] = static_cast<uint8_t>(value >> 40);
+ buffer[6] = static_cast<uint8_t>(value >> 48);
+ buffer[7] = static_cast<uint8_t>(value >> 56);
+ }
+
+ static inline constexpr bool IsLittleEndian() {
+#if defined(SNAPPY_IS_BIG_ENDIAN)
+ return false;
+#else
+ return true;
+#endif // defined(SNAPPY_IS_BIG_ENDIAN)
+ }
+};
+
+// Some bit-manipulation functions.
+class Bits {
+ public:
+ // Return floor(log2(n)) for positive integer n.
+ static int Log2FloorNonZero(uint32_t n);
+
+ // Return floor(log2(n)) for positive integer n. Returns -1 iff n == 0.
+ static int Log2Floor(uint32_t n);
+
+ // Return the first set least / most significant bit, 0-indexed. Returns an
+ // undefined value if n == 0. FindLSBSetNonZero() is similar to ffs() except
+ // that it's 0-indexed.
+ static int FindLSBSetNonZero(uint32_t n);
+
+ static int FindLSBSetNonZero64(uint64_t n);
+
+ private:
+ // No copying
+ Bits(const Bits&);
+ void operator=(const Bits&);
+};
+
+#if defined(HAVE_BUILTIN_CTZ)
+
+inline int Bits::Log2FloorNonZero(uint32_t n) {
+ assert(n != 0);
+ // (31 ^ x) is equivalent to (31 - x) for x in [0, 31]. An easy proof
+ // represents subtraction in base 2 and observes that there's no carry.
+ //
+ // GCC and Clang represent __builtin_clz on x86 as 31 ^ _bit_scan_reverse(x).
+ // Using "31 ^" here instead of "31 -" allows the optimizer to strip the
+ // function body down to _bit_scan_reverse(x).
+ return 31 ^ __builtin_clz(n);
+}
+
+inline int Bits::Log2Floor(uint32_t n) {
+ return (n == 0) ? -1 : Bits::Log2FloorNonZero(n);
+}
+
+inline int Bits::FindLSBSetNonZero(uint32_t n) {
+ assert(n != 0);
+ return __builtin_ctz(n);
+}
+
+#elif defined(_MSC_VER)
+
+inline int Bits::Log2FloorNonZero(uint32_t n) {
+ assert(n != 0);
+ // NOLINTNEXTLINE(runtime/int): The MSVC intrinsic demands unsigned long.
+ unsigned long where;
+ _BitScanReverse(&where, n);
+ return static_cast<int>(where);
+}
+
+inline int Bits::Log2Floor(uint32_t n) {
+ // NOLINTNEXTLINE(runtime/int): The MSVC intrinsic demands unsigned long.
+ unsigned long where;
+ if (_BitScanReverse(&where, n))
+ return static_cast<int>(where);
+ return -1;
+}
+
+inline int Bits::FindLSBSetNonZero(uint32_t n) {
+ assert(n != 0);
+ // NOLINTNEXTLINE(runtime/int): The MSVC intrinsic demands unsigned long.
+ unsigned long where;
+ if (_BitScanForward(&where, n))
+ return static_cast<int>(where);
+ return 32;
+}
+
+#else // Portable versions.
+
+inline int Bits::Log2FloorNonZero(uint32_t n) {
+ assert(n != 0);
+
+ int log = 0;
+ uint32_t value = n;
+ for (int i = 4; i >= 0; --i) {
+ int shift = (1 << i);
+ uint32_t x = value >> shift;
+ if (x != 0) {
+ value = x;
+ log += shift;
+ }
+ }
+ assert(value == 1);
+ return log;
+}
+
+inline int Bits::Log2Floor(uint32_t n) {
+ return (n == 0) ? -1 : Bits::Log2FloorNonZero(n);
+}
+
+inline int Bits::FindLSBSetNonZero(uint32_t n) {
+ assert(n != 0);
+
+ int rc = 31;
+ for (int i = 4, shift = 1 << 4; i >= 0; --i) {
+ const uint32_t x = n << shift;
+ if (x != 0) {
+ n = x;
+ rc -= shift;
+ }
+ shift >>= 1;
+ }
+ return rc;
+}
+
+#endif // End portable versions.
+
+#if defined(HAVE_BUILTIN_CTZ)
+
+inline int Bits::FindLSBSetNonZero64(uint64_t n) {
+ assert(n != 0);
+ return __builtin_ctzll(n);
+}
+
+#elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64))
+// _BitScanForward64() is only available on x64 and ARM64.
+
+inline int Bits::FindLSBSetNonZero64(uint64_t n) {
+ assert(n != 0);
+ // NOLINTNEXTLINE(runtime/int): The MSVC intrinsic demands unsigned long.
+ unsigned long where;
+ if (_BitScanForward64(&where, n))
+ return static_cast<int>(where);
+ return 64;
+}
+
+#else // Portable version.
+
+// FindLSBSetNonZero64() is defined in terms of FindLSBSetNonZero().
+inline int Bits::FindLSBSetNonZero64(uint64_t n) {
+ assert(n != 0);
+
+ const uint32_t bottombits = static_cast<uint32_t>(n);
+ if (bottombits == 0) {
+ // Bottom bits are zero, so scan the top bits.
+ return 32 + FindLSBSetNonZero(static_cast<uint32_t>(n >> 32));
+ } else {
+ return FindLSBSetNonZero(bottombits);
+ }
+}
+
+#endif // End portable version.
+
+// Variable-length integer encoding.
+class Varint {
+ public:
+ // Maximum lengths of varint encoding of uint32_t.
+ static const int kMax32 = 5;
+
+ // Attempts to parse a varint32 from a prefix of the bytes in [ptr,limit-1].
+ // Never reads a character at or beyond limit. If a valid/terminated varint32
+ // was found in the range, stores it in *OUTPUT and returns a pointer just
+ // past the last byte of the varint32. Else returns NULL. On success,
+ // "result <= limit".
+ static const char* Parse32WithLimit(const char* ptr, const char* limit,
+ uint32_t* OUTPUT);
+
+ // REQUIRES "ptr" points to a buffer of length sufficient to hold "v".
+ // EFFECTS Encodes "v" into "ptr" and returns a pointer to the
+ // byte just past the last encoded byte.
+ static char* Encode32(char* ptr, uint32_t v);
+
+ // EFFECTS Appends the varint representation of "value" to "*s".
+ static void Append32(std::string* s, uint32_t value);
+};
+
+inline const char* Varint::Parse32WithLimit(const char* p,
+ const char* l,
+ uint32_t* OUTPUT) {
+ const unsigned char* ptr = reinterpret_cast<const unsigned char*>(p);
+ const unsigned char* limit = reinterpret_cast<const unsigned char*>(l);
+ uint32_t b, result;
+ if (ptr >= limit) return NULL;
+ b = *(ptr++); result = b & 127; if (b < 128) goto done;
+ if (ptr >= limit) return NULL;
+ b = *(ptr++); result |= (b & 127) << 7; if (b < 128) goto done;
+ if (ptr >= limit) return NULL;
+ b = *(ptr++); result |= (b & 127) << 14; if (b < 128) goto done;
+ if (ptr >= limit) return NULL;
+ b = *(ptr++); result |= (b & 127) << 21; if (b < 128) goto done;
+ if (ptr >= limit) return NULL;
+ b = *(ptr++); result |= (b & 127) << 28; if (b < 16) goto done;
+ return NULL; // Value is too long to be a varint32
+ done:
+ *OUTPUT = result;
+ return reinterpret_cast<const char*>(ptr);
+}
+
+inline char* Varint::Encode32(char* sptr, uint32_t v) {
+ // Operate on characters as unsigneds
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(sptr);
+ static const uint8_t B = 128;
+ if (v < (1 << 7)) {
+ *(ptr++) = static_cast<uint8_t>(v);
+ } else if (v < (1 << 14)) {
+ *(ptr++) = static_cast<uint8_t>(v | B);
+ *(ptr++) = static_cast<uint8_t>(v >> 7);
+ } else if (v < (1 << 21)) {
+ *(ptr++) = static_cast<uint8_t>(v | B);
+ *(ptr++) = static_cast<uint8_t>((v >> 7) | B);
+ *(ptr++) = static_cast<uint8_t>(v >> 14);
+ } else if (v < (1 << 28)) {
+ *(ptr++) = static_cast<uint8_t>(v | B);
+ *(ptr++) = static_cast<uint8_t>((v >> 7) | B);
+ *(ptr++) = static_cast<uint8_t>((v >> 14) | B);
+ *(ptr++) = static_cast<uint8_t>(v >> 21);
+ } else {
+ *(ptr++) = static_cast<uint8_t>(v | B);
+ *(ptr++) = static_cast<uint8_t>((v>>7) | B);
+ *(ptr++) = static_cast<uint8_t>((v>>14) | B);
+ *(ptr++) = static_cast<uint8_t>((v>>21) | B);
+ *(ptr++) = static_cast<uint8_t>(v >> 28);
+ }
+ return reinterpret_cast<char*>(ptr);
+}
+
+// If you know the internal layout of the std::string in use, you can
+// replace this function with one that resizes the string without
+// filling the new space with zeros (if applicable) --
+// it will be non-portable but faster.
+inline void STLStringResizeUninitialized(std::string* s, size_t new_size) {
+ s->resize(new_size);
+}
+
+// Return a mutable char* pointing to a string's internal buffer,
+// which may not be null-terminated. Writing through this pointer will
+// modify the string.
+//
+// string_as_array(&str)[i] is valid for 0 <= i < str.size() until the
+// next call to a string method that invalidates iterators.
+//
+// As of 2006-04, there is no standard-blessed way of getting a
+// mutable reference to a string's internal buffer. However, issue 530
+// (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-defects.html#530)
+// proposes this as the method. It will officially be part of the standard
+// for C++0x. This should already work on all current implementations.
+inline char* string_as_array(std::string* str) {
+ return str->empty() ? NULL : &*str->begin();
+}
+
+} // namespace snappy
+
+#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_INTERNAL_H_
diff --git a/other-licenses/snappy/src/snappy-stubs-public.h.in b/other-licenses/snappy/src/snappy-stubs-public.h.in
new file mode 100644
index 0000000000..02947fabd5
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-stubs-public.h.in
@@ -0,0 +1,63 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Various type stubs for the open-source version of Snappy.
+//
+// This file cannot include config.h, as it is included from snappy.h,
+// which is a public header. Instead, snappy-stubs-public.h is generated by
+// from snappy-stubs-public.h.in at configure time.
+
+#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
+#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
+
+#include <cstddef>
+
+#if ${HAVE_SYS_UIO_H_01} // HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif // HAVE_SYS_UIO_H
+
+#define SNAPPY_MAJOR ${PROJECT_VERSION_MAJOR}
+#define SNAPPY_MINOR ${PROJECT_VERSION_MINOR}
+#define SNAPPY_PATCHLEVEL ${PROJECT_VERSION_PATCH}
+#define SNAPPY_VERSION \
+ ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
+
+namespace snappy {
+
+#if !${HAVE_SYS_UIO_H_01} // !HAVE_SYS_UIO_H
+// Windows does not have an iovec type, yet the concept is universally useful.
+// It is simple to define it ourselves, so we put it inside our own namespace.
+struct iovec {
+ void* iov_base;
+ size_t iov_len;
+};
+#endif // !HAVE_SYS_UIO_H
+
+} // namespace snappy
+
+#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
diff --git a/other-licenses/snappy/src/snappy-test.cc b/other-licenses/snappy/src/snappy-test.cc
new file mode 100644
index 0000000000..7eb490ac17
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-test.cc
@@ -0,0 +1,503 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Various stubs for the unit tests for the open-source version of Snappy.
+
+#include "snappy-test.h"
+
+#include <algorithm>
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+namespace file {
+
+OptionsStub::OptionsStub() = default;
+OptionsStub::~OptionsStub() = default;
+
+const OptionsStub &Defaults() {
+ static OptionsStub defaults;
+ return defaults;
+}
+
+StatusStub::StatusStub() = default;
+StatusStub::StatusStub(const StatusStub &) = default;
+StatusStub &StatusStub::operator=(const StatusStub &) = default;
+StatusStub::~StatusStub() = default;
+
+bool StatusStub::ok() { return true; }
+
+StatusStub GetContents(const std::string &filename, std::string *output,
+ const OptionsStub & /* options */) {
+ std::FILE *fp = std::fopen(filename.c_str(), "rb");
+ if (fp == nullptr) {
+ std::perror(filename.c_str());
+ std::exit(1);
+ }
+
+ output->clear();
+ while (!std::feof(fp)) {
+ char buffer[4096];
+ size_t bytes_read = std::fread(buffer, 1, sizeof(buffer), fp);
+ if (bytes_read == 0 && std::ferror(fp)) {
+ std::perror("fread");
+ std::exit(1);
+ }
+ output->append(buffer, bytes_read);
+ }
+
+ std::fclose(fp);
+ return StatusStub();
+}
+
+StatusStub SetContents(const std::string &file_name, const std::string &content,
+ const OptionsStub & /* options */) {
+ std::FILE *fp = std::fopen(file_name.c_str(), "wb");
+ if (fp == nullptr) {
+ std::perror(file_name.c_str());
+ std::exit(1);
+ }
+
+ size_t bytes_written = std::fwrite(content.data(), 1, content.size(), fp);
+ if (bytes_written != content.size()) {
+ std::perror("fwrite");
+ std::exit(1);
+ }
+
+ std::fclose(fp);
+ return StatusStub();
+}
+
+} // namespace file
+
+namespace snappy {
+
+std::string ReadTestDataFile(const std::string& base, size_t size_limit) {
+ std::string contents;
+ const char* srcdir = getenv("srcdir"); // This is set by Automake.
+ std::string prefix;
+ if (srcdir) {
+ prefix = std::string(srcdir) + "/";
+ }
+ file::GetContents(prefix + "testdata/" + base, &contents, file::Defaults()
+ ).ok();
+ if (size_limit > 0) {
+ contents = contents.substr(0, size_limit);
+ }
+ return contents;
+}
+
+std::string StrFormat(const char* format, ...) {
+ char buffer[4096];
+ std::va_list ap;
+ va_start(ap, format);
+ std::vsnprintf(buffer, sizeof(buffer), format, ap);
+ va_end(ap);
+ return buffer;
+}
+
+LogMessage::~LogMessage() { std::cerr << std::endl; }
+
+LogMessage &LogMessage::operator<<(const std::string &message) {
+ std::cerr << message;
+ return *this;
+}
+
+LogMessage &LogMessage::operator<<(int number) {
+ std::cerr << number;
+ return *this;
+}
+
+#ifdef _MSC_VER
+// ~LogMessageCrash calls std::abort() and therefore never exits. This is by
+// design, so temporarily disable warning C4722.
+#pragma warning(push)
+#pragma warning(disable : 4722)
+#endif
+
+LogMessageCrash::~LogMessageCrash() {
+ std::cerr << std::endl;
+ std::abort();
+}
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+#ifdef HAVE_LIBZ
+
+ZLib::ZLib()
+ : comp_init_(false),
+ uncomp_init_(false) {
+ Reinit();
+}
+
+ZLib::~ZLib() {
+ if (comp_init_) { deflateEnd(&comp_stream_); }
+ if (uncomp_init_) { inflateEnd(&uncomp_stream_); }
+}
+
+void ZLib::Reinit() {
+ compression_level_ = Z_DEFAULT_COMPRESSION;
+ window_bits_ = MAX_WBITS;
+ mem_level_ = 8; // DEF_MEM_LEVEL
+ if (comp_init_) {
+ deflateEnd(&comp_stream_);
+ comp_init_ = false;
+ }
+ if (uncomp_init_) {
+ inflateEnd(&uncomp_stream_);
+ uncomp_init_ = false;
+ }
+ first_chunk_ = true;
+}
+
+void ZLib::Reset() {
+ first_chunk_ = true;
+}
+
+// --------- COMPRESS MODE
+
+// Initialization method to be called if we hit an error while
+// compressing. On hitting an error, call this method before returning
+// the error.
+void ZLib::CompressErrorInit() {
+ deflateEnd(&comp_stream_);
+ comp_init_ = false;
+ Reset();
+}
+
+int ZLib::DeflateInit() {
+ return deflateInit2(&comp_stream_,
+ compression_level_,
+ Z_DEFLATED,
+ window_bits_,
+ mem_level_,
+ Z_DEFAULT_STRATEGY);
+}
+
+int ZLib::CompressInit(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen) {
+ int err;
+
+ comp_stream_.next_in = (Bytef*)source;
+ comp_stream_.avail_in = (uInt)*sourceLen;
+ if ((uLong)comp_stream_.avail_in != *sourceLen) return Z_BUF_ERROR;
+ comp_stream_.next_out = dest;
+ comp_stream_.avail_out = (uInt)*destLen;
+ if ((uLong)comp_stream_.avail_out != *destLen) return Z_BUF_ERROR;
+
+ if ( !first_chunk_ ) // only need to set up stream the first time through
+ return Z_OK;
+
+ if (comp_init_) { // we've already initted it
+ err = deflateReset(&comp_stream_);
+ if (err != Z_OK) {
+ LOG(WARNING) << "ERROR: Can't reset compress object; creating a new one";
+ deflateEnd(&comp_stream_);
+ comp_init_ = false;
+ }
+ }
+ if (!comp_init_) { // first use
+ comp_stream_.zalloc = (alloc_func)0;
+ comp_stream_.zfree = (free_func)0;
+ comp_stream_.opaque = (voidpf)0;
+ err = DeflateInit();
+ if (err != Z_OK) return err;
+ comp_init_ = true;
+ }
+ return Z_OK;
+}
+
+// In a perfect world we'd always have the full buffer to compress
+// when the time came, and we could just call Compress(). Alas, we
+// want to do chunked compression on our webserver. In this
+// application, we compress the header, send it off, then compress the
+// results, send them off, then compress the footer. Thus we need to
+// use the chunked compression features of zlib.
+int ZLib::CompressAtMostOrAll(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen,
+ int flush_mode) { // Z_FULL_FLUSH or Z_FINISH
+ int err;
+
+ if ( (err=CompressInit(dest, destLen, source, sourceLen)) != Z_OK )
+ return err;
+
+ // This is used to figure out how many bytes we wrote *this chunk*
+ int compressed_size = comp_stream_.total_out;
+
+ // Some setup happens only for the first chunk we compress in a run
+ if ( first_chunk_ ) {
+ first_chunk_ = false;
+ }
+
+ // flush_mode is Z_FINISH for all mode, Z_SYNC_FLUSH for incremental
+ // compression.
+ err = deflate(&comp_stream_, flush_mode);
+
+ *sourceLen = comp_stream_.avail_in;
+
+ if ((err == Z_STREAM_END || err == Z_OK)
+ && comp_stream_.avail_in == 0
+ && comp_stream_.avail_out != 0 ) {
+ // we processed everything ok and the output buffer was large enough.
+ ;
+ } else if (err == Z_STREAM_END && comp_stream_.avail_in > 0) {
+ return Z_BUF_ERROR; // should never happen
+ } else if (err != Z_OK && err != Z_STREAM_END && err != Z_BUF_ERROR) {
+ // an error happened
+ CompressErrorInit();
+ return err;
+ } else if (comp_stream_.avail_out == 0) { // not enough space
+ err = Z_BUF_ERROR;
+ }
+
+ assert(err == Z_OK || err == Z_STREAM_END || err == Z_BUF_ERROR);
+ if (err == Z_STREAM_END)
+ err = Z_OK;
+
+ // update the crc and other metadata
+ compressed_size = comp_stream_.total_out - compressed_size; // delta
+ *destLen = compressed_size;
+
+ return err;
+}
+
+int ZLib::CompressChunkOrAll(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen,
+ int flush_mode) { // Z_FULL_FLUSH or Z_FINISH
+ const int ret =
+ CompressAtMostOrAll(dest, destLen, source, &sourceLen, flush_mode);
+ if (ret == Z_BUF_ERROR)
+ CompressErrorInit();
+ return ret;
+}
+
+// This routine only initializes the compression stream once. Thereafter, it
+// just does a deflateReset on the stream, which should be faster.
+int ZLib::Compress(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen) {
+ int err;
+ if ( (err=CompressChunkOrAll(dest, destLen, source, sourceLen,
+ Z_FINISH)) != Z_OK )
+ return err;
+ Reset(); // reset for next call to Compress
+
+ return Z_OK;
+}
+
+
+// --------- UNCOMPRESS MODE
+
+int ZLib::InflateInit() {
+ return inflateInit2(&uncomp_stream_, MAX_WBITS);
+}
+
+// Initialization method to be called if we hit an error while
+// uncompressing. On hitting an error, call this method before
+// returning the error.
+void ZLib::UncompressErrorInit() {
+ inflateEnd(&uncomp_stream_);
+ uncomp_init_ = false;
+ Reset();
+}
+
+int ZLib::UncompressInit(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen) {
+ int err;
+
+ uncomp_stream_.next_in = (Bytef*)source;
+ uncomp_stream_.avail_in = (uInt)*sourceLen;
+ // Check for source > 64K on 16-bit machine:
+ if ((uLong)uncomp_stream_.avail_in != *sourceLen) return Z_BUF_ERROR;
+
+ uncomp_stream_.next_out = dest;
+ uncomp_stream_.avail_out = (uInt)*destLen;
+ if ((uLong)uncomp_stream_.avail_out != *destLen) return Z_BUF_ERROR;
+
+ if ( !first_chunk_ ) // only need to set up stream the first time through
+ return Z_OK;
+
+ if (uncomp_init_) { // we've already initted it
+ err = inflateReset(&uncomp_stream_);
+ if (err != Z_OK) {
+ LOG(WARNING)
+ << "ERROR: Can't reset uncompress object; creating a new one";
+ UncompressErrorInit();
+ }
+ }
+ if (!uncomp_init_) {
+ uncomp_stream_.zalloc = (alloc_func)0;
+ uncomp_stream_.zfree = (free_func)0;
+ uncomp_stream_.opaque = (voidpf)0;
+ err = InflateInit();
+ if (err != Z_OK) return err;
+ uncomp_init_ = true;
+ }
+ return Z_OK;
+}
+
+// If you compressed your data a chunk at a time, with CompressChunk,
+// you can uncompress it a chunk at a time with UncompressChunk.
+// Only difference bewteen chunked and unchunked uncompression
+// is the flush mode we use: Z_SYNC_FLUSH (chunked) or Z_FINISH (unchunked).
+int ZLib::UncompressAtMostOrAll(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen,
+ int flush_mode) { // Z_SYNC_FLUSH or Z_FINISH
+ int err = Z_OK;
+
+ if ( (err=UncompressInit(dest, destLen, source, sourceLen)) != Z_OK ) {
+ LOG(WARNING) << "UncompressInit: Error: " << err << " SourceLen: "
+ << *sourceLen;
+ return err;
+ }
+
+ // This is used to figure out how many output bytes we wrote *this chunk*:
+ const uLong old_total_out = uncomp_stream_.total_out;
+
+ // This is used to figure out how many input bytes we read *this chunk*:
+ const uLong old_total_in = uncomp_stream_.total_in;
+
+ // Some setup happens only for the first chunk we compress in a run
+ if ( first_chunk_ ) {
+ first_chunk_ = false; // so we don't do this again
+
+ // For the first chunk *only* (to avoid infinite troubles), we let
+ // there be no actual data to uncompress. This sometimes triggers
+ // when the input is only the gzip header, say.
+ if ( *sourceLen == 0 ) {
+ *destLen = 0;
+ return Z_OK;
+ }
+ }
+
+ // We'll uncompress as much as we can. If we end OK great, otherwise
+ // if we get an error that seems to be the gzip footer, we store the
+ // gzip footer and return OK, otherwise we return the error.
+
+ // flush_mode is Z_SYNC_FLUSH for chunked mode, Z_FINISH for all mode.
+ err = inflate(&uncomp_stream_, flush_mode);
+
+ // Figure out how many bytes of the input zlib slurped up:
+ const uLong bytes_read = uncomp_stream_.total_in - old_total_in;
+ CHECK_LE(source + bytes_read, source + *sourceLen);
+ *sourceLen = uncomp_stream_.avail_in;
+
+ if ((err == Z_STREAM_END || err == Z_OK) // everything went ok
+ && uncomp_stream_.avail_in == 0) { // and we read it all
+ ;
+ } else if (err == Z_STREAM_END && uncomp_stream_.avail_in > 0) {
+ LOG(WARNING)
+ << "UncompressChunkOrAll: Received some extra data, bytes total: "
+ << uncomp_stream_.avail_in << " bytes: "
+ << std::string(reinterpret_cast<const char *>(uncomp_stream_.next_in),
+ std::min(int(uncomp_stream_.avail_in), 20));
+ UncompressErrorInit();
+ return Z_DATA_ERROR; // what's the extra data for?
+ } else if (err != Z_OK && err != Z_STREAM_END && err != Z_BUF_ERROR) {
+ // an error happened
+ LOG(WARNING) << "UncompressChunkOrAll: Error: " << err
+ << " avail_out: " << uncomp_stream_.avail_out;
+ UncompressErrorInit();
+ return err;
+ } else if (uncomp_stream_.avail_out == 0) {
+ err = Z_BUF_ERROR;
+ }
+
+ assert(err == Z_OK || err == Z_BUF_ERROR || err == Z_STREAM_END);
+ if (err == Z_STREAM_END)
+ err = Z_OK;
+
+ *destLen = uncomp_stream_.total_out - old_total_out; // size for this call
+
+ return err;
+}
+
+int ZLib::UncompressChunkOrAll(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen,
+ int flush_mode) { // Z_SYNC_FLUSH or Z_FINISH
+ const int ret =
+ UncompressAtMostOrAll(dest, destLen, source, &sourceLen, flush_mode);
+ if (ret == Z_BUF_ERROR)
+ UncompressErrorInit();
+ return ret;
+}
+
+int ZLib::UncompressAtMost(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen) {
+ return UncompressAtMostOrAll(dest, destLen, source, sourceLen, Z_SYNC_FLUSH);
+}
+
+// We make sure we've uncompressed everything, that is, the current
+// uncompress stream is at a compressed-buffer-EOF boundary. In gzip
+// mode, we also check the gzip footer to make sure we pass the gzip
+// consistency checks. We RETURN true iff both types of checks pass.
+bool ZLib::UncompressChunkDone() {
+ assert(!first_chunk_ && uncomp_init_);
+ // Make sure we're at the end-of-compressed-data point. This means
+ // if we call inflate with Z_FINISH we won't consume any input or
+ // write any output
+ Bytef dummyin, dummyout;
+ uLongf dummylen = 0;
+ if ( UncompressChunkOrAll(&dummyout, &dummylen, &dummyin, 0, Z_FINISH)
+ != Z_OK ) {
+ return false;
+ }
+
+ // Make sure that when we exit, we can start a new round of chunks later
+ Reset();
+
+ return true;
+}
+
+// Uncompresses the source buffer into the destination buffer.
+// The destination buffer must be long enough to hold the entire
+// decompressed contents.
+//
+// We only initialize the uncomp_stream once. Thereafter, we use
+// inflateReset, which should be faster.
+//
+// Returns Z_OK on success, otherwise, it returns a zlib error code.
+int ZLib::Uncompress(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen) {
+ int err;
+ if ( (err=UncompressChunkOrAll(dest, destLen, source, sourceLen,
+ Z_FINISH)) != Z_OK ) {
+ Reset(); // let us try to compress again
+ return err;
+ }
+ if ( !UncompressChunkDone() ) // calls Reset()
+ return Z_DATA_ERROR;
+ return Z_OK; // stream_end is ok
+}
+
+#endif // HAVE_LIBZ
+
+} // namespace snappy
diff --git a/other-licenses/snappy/src/snappy-test.h b/other-licenses/snappy/src/snappy-test.h
new file mode 100644
index 0000000000..f80d343377
--- /dev/null
+++ b/other-licenses/snappy/src/snappy-test.h
@@ -0,0 +1,342 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Various stubs for the unit tests for the open-source version of Snappy.
+
+#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_
+#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "snappy-stubs-internal.h"
+
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+// Needed to be able to use std::max without workarounds in the source code.
+// https://support.microsoft.com/en-us/help/143208/prb-using-stl-in-windows-program-can-cause-min-max-conflicts
+#define NOMINMAX
+#include <windows.h>
+#endif
+
+#define InitGoogle(argv0, argc, argv, remove_flags) ((void)(0))
+
+#ifdef HAVE_LIBZ
+#include "zlib.h"
+#endif
+
+#ifdef HAVE_LIBLZO2
+#include "lzo/lzo1x.h"
+#endif
+
+#ifdef HAVE_LIBLZ4
+#include "lz4.h"
+#endif
+
+namespace file {
+
+// Stubs the class file::Options.
+//
+// This class should not be instantiated explicitly. It should only be used by
+// passing file::Defaults() to file::GetContents() / file::SetContents().
+class OptionsStub {
+ public:
+ OptionsStub();
+ OptionsStub(const OptionsStub &) = delete;
+ OptionsStub &operator=(const OptionsStub &) = delete;
+ ~OptionsStub();
+};
+
+const OptionsStub &Defaults();
+
+// Stubs the class absl::Status.
+//
+// This class should not be instantiated explicitly. It should only be used by
+// passing the result of file::GetContents() / file::SetContents() to
+// CHECK_OK().
+class StatusStub {
+ public:
+ StatusStub();
+ StatusStub(const StatusStub &);
+ StatusStub &operator=(const StatusStub &);
+ ~StatusStub();
+
+ bool ok();
+};
+
+StatusStub GetContents(const std::string &file_name, std::string *output,
+ const OptionsStub & /* options */);
+
+StatusStub SetContents(const std::string &file_name, const std::string &content,
+ const OptionsStub & /* options */);
+
+} // namespace file
+
+namespace snappy {
+
+#define FLAGS_test_random_seed 301
+
+std::string ReadTestDataFile(const std::string& base, size_t size_limit);
+
+// A std::sprintf() variant that returns a std::string.
+// Not safe for general use due to truncation issues.
+std::string StrFormat(const char* format, ...);
+
+// A wall-time clock. This stub is not super-accurate, nor resistant to the
+// system time changing.
+class CycleTimer {
+ public:
+ inline CycleTimer() : real_time_us_(0) {}
+ inline ~CycleTimer() = default;
+
+ inline void Start() {
+#ifdef WIN32
+ QueryPerformanceCounter(&start_);
+#else
+ ::gettimeofday(&start_, nullptr);
+#endif
+ }
+
+ inline void Stop() {
+#ifdef WIN32
+ LARGE_INTEGER stop;
+ LARGE_INTEGER frequency;
+ QueryPerformanceCounter(&stop);
+ QueryPerformanceFrequency(&frequency);
+
+ double elapsed = static_cast<double>(stop.QuadPart - start_.QuadPart) /
+ frequency.QuadPart;
+ real_time_us_ += elapsed * 1e6 + 0.5;
+#else
+ struct ::timeval stop;
+ ::gettimeofday(&stop, nullptr);
+
+ real_time_us_ += 1000000 * (stop.tv_sec - start_.tv_sec);
+ real_time_us_ += (stop.tv_usec - start_.tv_usec);
+#endif
+ }
+
+ inline double Get() { return real_time_us_ * 1e-6; }
+
+ private:
+ int64_t real_time_us_;
+#ifdef WIN32
+ LARGE_INTEGER start_;
+#else
+ struct ::timeval start_;
+#endif
+};
+
+// Logging.
+
+class LogMessage {
+ public:
+ inline LogMessage() = default;
+ ~LogMessage();
+
+ LogMessage &operator<<(const std::string &message);
+ LogMessage &operator<<(int number);
+};
+
+class LogMessageCrash : public LogMessage {
+ public:
+ inline LogMessageCrash() = default;
+ ~LogMessageCrash();
+};
+
+// This class is used to explicitly ignore values in the conditional
+// logging macros. This avoids compiler warnings like "value computed
+// is not used" and "statement has no effect".
+
+class LogMessageVoidify {
+ public:
+ inline LogMessageVoidify() = default;
+ inline ~LogMessageVoidify() = default;
+
+ // This has to be an operator with a precedence lower than << but
+ // higher than ?:
+ inline void operator&(const LogMessage &) {}
+};
+
+// Asserts, both versions activated in debug mode only,
+// and ones that are always active.
+
+#define CRASH_UNLESS(condition) \
+ SNAPPY_PREDICT_TRUE(condition) \
+ ? (void)0 \
+ : snappy::LogMessageVoidify() & snappy::LogMessageCrash()
+
+#define LOG(level) LogMessage()
+#define VLOG(level) \
+ true ? (void)0 : snappy::LogMessageVoidify() & snappy::LogMessage()
+
+#define CHECK(cond) CRASH_UNLESS(cond)
+#define CHECK_LE(a, b) CRASH_UNLESS((a) <= (b))
+#define CHECK_GE(a, b) CRASH_UNLESS((a) >= (b))
+#define CHECK_EQ(a, b) CRASH_UNLESS((a) == (b))
+#define CHECK_NE(a, b) CRASH_UNLESS((a) != (b))
+#define CHECK_LT(a, b) CRASH_UNLESS((a) < (b))
+#define CHECK_GT(a, b) CRASH_UNLESS((a) > (b))
+#define CHECK_OK(cond) (cond).ok()
+
+#ifdef HAVE_LIBZ
+
+// Object-oriented wrapper around zlib.
+class ZLib {
+ public:
+ ZLib();
+ ~ZLib();
+
+ // Wipe a ZLib object to a virgin state. This differs from Reset()
+ // in that it also breaks any state.
+ void Reinit();
+
+ // Call this to make a zlib buffer as good as new. Here's the only
+ // case where they differ:
+ // CompressChunk(a); CompressChunk(b); CompressChunkDone(); vs
+ // CompressChunk(a); Reset(); CompressChunk(b); CompressChunkDone();
+ // You'll want to use Reset(), then, when you interrupt a compress
+ // (or uncompress) in the middle of a chunk and want to start over.
+ void Reset();
+
+ // According to the zlib manual, when you Compress, the destination
+ // buffer must have size at least src + .1%*src + 12. This function
+ // helps you calculate that. Augment this to account for a potential
+ // gzip header and footer, plus a few bytes of slack.
+ static int MinCompressbufSize(int uncompress_size) {
+ return uncompress_size + uncompress_size/1000 + 40;
+ }
+
+ // Compresses the source buffer into the destination buffer.
+ // sourceLen is the byte length of the source buffer.
+ // Upon entry, destLen is the total size of the destination buffer,
+ // which must be of size at least MinCompressbufSize(sourceLen).
+ // Upon exit, destLen is the actual size of the compressed buffer.
+ //
+ // This function can be used to compress a whole file at once if the
+ // input file is mmap'ed.
+ //
+ // Returns Z_OK if success, Z_MEM_ERROR if there was not
+ // enough memory, Z_BUF_ERROR if there was not enough room in the
+ // output buffer. Note that if the output buffer is exactly the same
+ // size as the compressed result, we still return Z_BUF_ERROR.
+ // (check CL#1936076)
+ int Compress(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen);
+
+ // Uncompresses the source buffer into the destination buffer.
+ // The destination buffer must be long enough to hold the entire
+ // decompressed contents.
+ //
+ // Returns Z_OK on success, otherwise, it returns a zlib error code.
+ int Uncompress(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen);
+
+ // Uncompress data one chunk at a time -- ie you can call this
+ // more than once. To get this to work you need to call per-chunk
+ // and "done" routines.
+ //
+ // Returns Z_OK if success, Z_MEM_ERROR if there was not
+ // enough memory, Z_BUF_ERROR if there was not enough room in the
+ // output buffer.
+
+ int UncompressAtMost(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen);
+
+ // Checks gzip footer information, as needed. Mostly this just
+ // makes sure the checksums match. Whenever you call this, it
+ // will assume the last 8 bytes from the previous UncompressChunk
+ // call are the footer. Returns true iff everything looks ok.
+ bool UncompressChunkDone();
+
+ private:
+ int InflateInit(); // sets up the zlib inflate structure
+ int DeflateInit(); // sets up the zlib deflate structure
+
+ // These init the zlib data structures for compressing/uncompressing
+ int CompressInit(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen);
+ int UncompressInit(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen);
+ // Initialization method to be called if we hit an error while
+ // uncompressing. On hitting an error, call this method before
+ // returning the error.
+ void UncompressErrorInit();
+
+ // Helper function for Compress
+ int CompressChunkOrAll(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen,
+ int flush_mode);
+ int CompressAtMostOrAll(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen,
+ int flush_mode);
+
+ // Likewise for UncompressAndUncompressChunk
+ int UncompressChunkOrAll(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen,
+ int flush_mode);
+
+ int UncompressAtMostOrAll(Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen,
+ int flush_mode);
+
+ // Initialization method to be called if we hit an error while
+ // compressing. On hitting an error, call this method before
+ // returning the error.
+ void CompressErrorInit();
+
+ int compression_level_; // compression level
+ int window_bits_; // log base 2 of the window size used in compression
+ int mem_level_; // specifies the amount of memory to be used by
+ // compressor (1-9)
+ z_stream comp_stream_; // Zlib stream data structure
+ bool comp_init_; // True if we have initialized comp_stream_
+ z_stream uncomp_stream_; // Zlib stream data structure
+ bool uncomp_init_; // True if we have initialized uncomp_stream_
+
+ // These are used only with chunked compression.
+ bool first_chunk_; // true if we need to emit headers with this chunk
+};
+
+#endif // HAVE_LIBZ
+
+} // namespace snappy
+
+#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_
diff --git a/other-licenses/snappy/src/snappy.cc b/other-licenses/snappy/src/snappy.cc
new file mode 100644
index 0000000000..57df3f11fc
--- /dev/null
+++ b/other-licenses/snappy/src/snappy.cc
@@ -0,0 +1,2193 @@
+// Copyright 2005 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "snappy-internal.h"
+#include "snappy-sinksource.h"
+#include "snappy.h"
+
+#if !defined(SNAPPY_HAVE_SSSE3)
+// __SSSE3__ is defined by GCC and Clang. Visual Studio doesn't target SIMD
+// support between SSE2 and AVX (so SSSE3 instructions require AVX support), and
+// defines __AVX__ when AVX support is available.
+#if defined(__SSSE3__) || defined(__AVX__)
+#define SNAPPY_HAVE_SSSE3 1
+#else
+#define SNAPPY_HAVE_SSSE3 0
+#endif
+#endif // !defined(SNAPPY_HAVE_SSSE3)
+
+#if !defined(SNAPPY_HAVE_BMI2)
+// __BMI2__ is defined by GCC and Clang. Visual Studio doesn't target BMI2
+// specifically, but it does define __AVX2__ when AVX2 support is available.
+// Fortunately, AVX2 was introduced in Haswell, just like BMI2.
+//
+// BMI2 is not defined as a subset of AVX2 (unlike SSSE3 and AVX above). So,
+// GCC and Clang can build code with AVX2 enabled but BMI2 disabled, in which
+// case issuing BMI2 instructions results in a compiler error.
+#if defined(__BMI2__) || (defined(_MSC_VER) && defined(__AVX2__))
+#define SNAPPY_HAVE_BMI2 1
+#else
+#define SNAPPY_HAVE_BMI2 0
+#endif
+#endif // !defined(SNAPPY_HAVE_BMI2)
+
+#if SNAPPY_HAVE_SSSE3
+// Please do not replace with <x86intrin.h>. or with headers that assume more
+// advanced SSE versions without checking with all the OWNERS.
+#include <tmmintrin.h>
+#endif
+
+#if SNAPPY_HAVE_BMI2
+// Please do not replace with <x86intrin.h>. or with headers that assume more
+// advanced SSE versions without checking with all the OWNERS.
+#include <immintrin.h>
+#endif
+
+#include <algorithm>
+#include <array>
+#include <cstddef>
+#include <cstdint>
+#include <cstdio>
+#include <cstring>
+#include <string>
+#include <utility>
+#include <vector>
+
+namespace snappy {
+
+namespace {
+
+// The amount of slop bytes writers are using for unconditional copies.
+constexpr int kSlopBytes = 64;
+
+using internal::char_table;
+using internal::COPY_1_BYTE_OFFSET;
+using internal::COPY_2_BYTE_OFFSET;
+using internal::COPY_4_BYTE_OFFSET;
+using internal::kMaximumTagLength;
+using internal::LITERAL;
+
+// We translate the information encoded in a tag through a lookup table to a
+// format that requires fewer instructions to decode. Effectively we store
+// the length minus the tag part of the offset. The lowest significant byte
+// thus stores the length. While total length - offset is given by
+// entry - ExtractOffset(type). The nice thing is that the subtraction
+// immediately sets the flags for the necessary check that offset >= length.
+// This folds the cmp with sub. We engineer the long literals and copy-4 to
+// always fail this check, so their presence doesn't affect the fast path.
+// To prevent literals from triggering the guard against offset < length (offset
+// does not apply to literals) the table is giving them a spurious offset of
+// 256.
+inline constexpr int16_t MakeEntry(int16_t len, int16_t offset) {
+ return len - (offset << 8);
+}
+
+inline constexpr int16_t LengthMinusOffset(int data, int type) {
+ return type == 3 ? 0xFF // copy-4 (or type == 3)
+ : type == 2 ? MakeEntry(data + 1, 0) // copy-2
+ : type == 1 ? MakeEntry((data & 7) + 4, data >> 3) // copy-1
+ : data < 60 ? MakeEntry(data + 1, 1) // note spurious offset.
+ : 0xFF; // long literal
+}
+
+inline constexpr int16_t LengthMinusOffset(uint8_t tag) {
+ return LengthMinusOffset(tag >> 2, tag & 3);
+}
+
+template <size_t... Ints>
+struct index_sequence {};
+
+template <std::size_t N, size_t... Is>
+struct make_index_sequence : make_index_sequence<N - 1, N - 1, Is...> {};
+
+template <size_t... Is>
+struct make_index_sequence<0, Is...> : index_sequence<Is...> {};
+
+template <size_t... seq>
+constexpr std::array<int16_t, 256> MakeTable(index_sequence<seq...>) {
+ return std::array<int16_t, 256>{LengthMinusOffset(seq)...};
+}
+
+// We maximally co-locate the two tables so that only one register needs to be
+// reserved for the table address.
+struct {
+ alignas(64) const std::array<int16_t, 256> length_minus_offset;
+ uint32_t extract_masks[4]; // Used for extracting offset based on tag type.
+} table = {MakeTable(make_index_sequence<256>{}), {0, 0xFF, 0xFFFF, 0}};
+
+// Any hash function will produce a valid compressed bitstream, but a good
+// hash function reduces the number of collisions and thus yields better
+// compression for compressible input, and more speed for incompressible
+// input. Of course, it doesn't hurt if the hash function is reasonably fast
+// either, as it gets called a lot.
+inline uint32_t HashBytes(uint32_t bytes, uint32_t mask) {
+ constexpr uint32_t kMagic = 0x1e35a7bd;
+ return ((kMagic * bytes) >> (32 - kMaxHashTableBits)) & mask;
+}
+
+} // namespace
+
+size_t MaxCompressedLength(size_t source_bytes) {
+ // Compressed data can be defined as:
+ // compressed := item* literal*
+ // item := literal* copy
+ //
+ // The trailing literal sequence has a space blowup of at most 62/60
+ // since a literal of length 60 needs one tag byte + one extra byte
+ // for length information.
+ //
+ // Item blowup is trickier to measure. Suppose the "copy" op copies
+ // 4 bytes of data. Because of a special check in the encoding code,
+ // we produce a 4-byte copy only if the offset is < 65536. Therefore
+ // the copy op takes 3 bytes to encode, and this type of item leads
+ // to at most the 62/60 blowup for representing literals.
+ //
+ // Suppose the "copy" op copies 5 bytes of data. If the offset is big
+ // enough, it will take 5 bytes to encode the copy op. Therefore the
+ // worst case here is a one-byte literal followed by a five-byte copy.
+ // I.e., 6 bytes of input turn into 7 bytes of "compressed" data.
+ //
+ // This last factor dominates the blowup, so the final estimate is:
+ return 32 + source_bytes + source_bytes / 6;
+}
+
+namespace {
+
+void UnalignedCopy64(const void* src, void* dst) {
+ char tmp[8];
+ std::memcpy(tmp, src, 8);
+ std::memcpy(dst, tmp, 8);
+}
+
+void UnalignedCopy128(const void* src, void* dst) {
+ // std::memcpy() gets vectorized when the appropriate compiler options are
+ // used. For example, x86 compilers targeting SSE2+ will optimize to an SSE2
+ // load and store.
+ char tmp[16];
+ std::memcpy(tmp, src, 16);
+ std::memcpy(dst, tmp, 16);
+}
+
+template <bool use_16bytes_chunk>
+inline void ConditionalUnalignedCopy128(const char* src, char* dst) {
+ if (use_16bytes_chunk) {
+ UnalignedCopy128(src, dst);
+ } else {
+ UnalignedCopy64(src, dst);
+ UnalignedCopy64(src + 8, dst + 8);
+ }
+}
+
+// Copy [src, src+(op_limit-op)) to [op, (op_limit-op)) a byte at a time. Used
+// for handling COPY operations where the input and output regions may overlap.
+// For example, suppose:
+// src == "ab"
+// op == src + 2
+// op_limit == op + 20
+// After IncrementalCopySlow(src, op, op_limit), the result will have eleven
+// copies of "ab"
+// ababababababababababab
+// Note that this does not match the semantics of either std::memcpy() or
+// std::memmove().
+inline char* IncrementalCopySlow(const char* src, char* op,
+ char* const op_limit) {
+ // TODO: Remove pragma when LLVM is aware this
+ // function is only called in cold regions and when cold regions don't get
+ // vectorized or unrolled.
+#ifdef __clang__
+#pragma clang loop unroll(disable)
+#endif
+ while (op < op_limit) {
+ *op++ = *src++;
+ }
+ return op_limit;
+}
+
+#if SNAPPY_HAVE_SSSE3
+
+// Computes the bytes for shuffle control mask (please read comments on
+// 'pattern_generation_masks' as well) for the given index_offset and
+// pattern_size. For example, when the 'offset' is 6, it will generate a
+// repeating pattern of size 6. So, the first 16 byte indexes will correspond to
+// the pattern-bytes {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3} and the
+// next 16 byte indexes will correspond to the pattern-bytes {4, 5, 0, 1, 2, 3,
+// 4, 5, 0, 1, 2, 3, 4, 5, 0, 1}. These byte index sequences are generated by
+// calling MakePatternMaskBytes(0, 6, index_sequence<16>()) and
+// MakePatternMaskBytes(16, 6, index_sequence<16>()) respectively.
+template <size_t... indexes>
+inline constexpr std::array<char, sizeof...(indexes)> MakePatternMaskBytes(
+ int index_offset, int pattern_size, index_sequence<indexes...>) {
+ return {static_cast<char>((index_offset + indexes) % pattern_size)...};
+}
+
+// Computes the shuffle control mask bytes array for given pattern-sizes and
+// returns an array.
+template <size_t... pattern_sizes_minus_one>
+inline constexpr std::array<std::array<char, sizeof(__m128i)>,
+ sizeof...(pattern_sizes_minus_one)>
+MakePatternMaskBytesTable(int index_offset,
+ index_sequence<pattern_sizes_minus_one...>) {
+ return {MakePatternMaskBytes(
+ index_offset, pattern_sizes_minus_one + 1,
+ make_index_sequence</*indexes=*/sizeof(__m128i)>())...};
+}
+
+// This is an array of shuffle control masks that can be used as the source
+// operand for PSHUFB to permute the contents of the destination XMM register
+// into a repeating byte pattern.
+alignas(16) constexpr std::array<std::array<char, sizeof(__m128i)>,
+ 16> pattern_generation_masks =
+ MakePatternMaskBytesTable(
+ /*index_offset=*/0,
+ /*pattern_sizes_minus_one=*/make_index_sequence<16>());
+
+// Similar to 'pattern_generation_masks', this table is used to "rotate" the
+// pattern so that we can copy the *next 16 bytes* consistent with the pattern.
+// Basically, pattern_reshuffle_masks is a continuation of
+// pattern_generation_masks. It follows that, pattern_reshuffle_masks is same as
+// pattern_generation_masks for offsets 1, 2, 4, 8 and 16.
+alignas(16) constexpr std::array<std::array<char, sizeof(__m128i)>,
+ 16> pattern_reshuffle_masks =
+ MakePatternMaskBytesTable(
+ /*index_offset=*/16,
+ /*pattern_sizes_minus_one=*/make_index_sequence<16>());
+
+SNAPPY_ATTRIBUTE_ALWAYS_INLINE
+static inline __m128i LoadPattern(const char* src, const size_t pattern_size) {
+ __m128i generation_mask = _mm_load_si128(reinterpret_cast<const __m128i*>(
+ pattern_generation_masks[pattern_size - 1].data()));
+ // Uninitialized bytes are masked out by the shuffle mask.
+ // TODO: remove annotation and macro defs once MSan is fixed.
+ SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(src + pattern_size, 16 - pattern_size);
+ return _mm_shuffle_epi8(
+ _mm_loadu_si128(reinterpret_cast<const __m128i*>(src)), generation_mask);
+}
+
+SNAPPY_ATTRIBUTE_ALWAYS_INLINE
+static inline std::pair<__m128i /* pattern */, __m128i /* reshuffle_mask */>
+LoadPatternAndReshuffleMask(const char* src, const size_t pattern_size) {
+ __m128i pattern = LoadPattern(src, pattern_size);
+
+ // This mask will generate the next 16 bytes in-place. Doing so enables us to
+ // write data by at most 4 _mm_storeu_si128.
+ //
+ // For example, suppose pattern is: abcdefabcdefabcd
+ // Shuffling with this mask will generate: efabcdefabcdefab
+ // Shuffling again will generate: cdefabcdefabcdef
+ __m128i reshuffle_mask = _mm_load_si128(reinterpret_cast<const __m128i*>(
+ pattern_reshuffle_masks[pattern_size - 1].data()));
+ return {pattern, reshuffle_mask};
+}
+
+#endif // SNAPPY_HAVE_SSSE3
+
+// Fallback for when we need to copy while extending the pattern, for example
+// copying 10 bytes from 3 positions back abc -> abcabcabcabca.
+//
+// REQUIRES: [dst - offset, dst + 64) is a valid address range.
+SNAPPY_ATTRIBUTE_ALWAYS_INLINE
+static inline bool Copy64BytesWithPatternExtension(char* dst, size_t offset) {
+#if SNAPPY_HAVE_SSSE3
+ if (SNAPPY_PREDICT_TRUE(offset <= 16)) {
+ switch (offset) {
+ case 0:
+ return false;
+ case 1: {
+ std::memset(dst, dst[-1], 64);
+ return true;
+ }
+ case 2:
+ case 4:
+ case 8:
+ case 16: {
+ __m128i pattern = LoadPattern(dst - offset, offset);
+ for (int i = 0; i < 4; i++) {
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(dst + 16 * i), pattern);
+ }
+ return true;
+ }
+ default: {
+ auto pattern_and_reshuffle_mask =
+ LoadPatternAndReshuffleMask(dst - offset, offset);
+ __m128i pattern = pattern_and_reshuffle_mask.first;
+ __m128i reshuffle_mask = pattern_and_reshuffle_mask.second;
+ for (int i = 0; i < 4; i++) {
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(dst + 16 * i), pattern);
+ pattern = _mm_shuffle_epi8(pattern, reshuffle_mask);
+ }
+ return true;
+ }
+ }
+ }
+#else
+ if (SNAPPY_PREDICT_TRUE(offset < 16)) {
+ if (SNAPPY_PREDICT_FALSE(offset == 0)) return false;
+ // Extend the pattern to the first 16 bytes.
+ for (int i = 0; i < 16; i++) dst[i] = (dst - offset)[i];
+ // Find a multiple of pattern >= 16.
+ static std::array<uint8_t, 16> pattern_sizes = []() {
+ std::array<uint8_t, 16> res;
+ for (int i = 1; i < 16; i++) res[i] = (16 / i + 1) * i;
+ return res;
+ }();
+ offset = pattern_sizes[offset];
+ for (int i = 1; i < 4; i++) {
+ std::memcpy(dst + i * 16, dst + i * 16 - offset, 16);
+ }
+ return true;
+ }
+#endif // SNAPPY_HAVE_SSSE3
+
+ // Very rare.
+ for (int i = 0; i < 4; i++) {
+ std::memcpy(dst + i * 16, dst + i * 16 - offset, 16);
+ }
+ return true;
+}
+
+// Copy [src, src+(op_limit-op)) to [op, op_limit) but faster than
+// IncrementalCopySlow. buf_limit is the address past the end of the writable
+// region of the buffer.
+inline char* IncrementalCopy(const char* src, char* op, char* const op_limit,
+ char* const buf_limit) {
+#if SNAPPY_HAVE_SSSE3
+ constexpr int big_pattern_size_lower_bound = 16;
+#else
+ constexpr int big_pattern_size_lower_bound = 8;
+#endif
+
+ // Terminology:
+ //
+ // slop = buf_limit - op
+ // pat = op - src
+ // len = op_limit - op
+ assert(src < op);
+ assert(op < op_limit);
+ assert(op_limit <= buf_limit);
+ // NOTE: The copy tags use 3 or 6 bits to store the copy length, so len <= 64.
+ assert(op_limit - op <= 64);
+ // NOTE: In practice the compressor always emits len >= 4, so it is ok to
+ // assume that to optimize this function, but this is not guaranteed by the
+ // compression format, so we have to also handle len < 4 in case the input
+ // does not satisfy these conditions.
+
+ size_t pattern_size = op - src;
+ // The cases are split into different branches to allow the branch predictor,
+ // FDO, and static prediction hints to work better. For each input we list the
+ // ratio of invocations that match each condition.
+ //
+ // input slop < 16 pat < 8 len > 16
+ // ------------------------------------------
+ // html|html4|cp 0% 1.01% 27.73%
+ // urls 0% 0.88% 14.79%
+ // jpg 0% 64.29% 7.14%
+ // pdf 0% 2.56% 58.06%
+ // txt[1-4] 0% 0.23% 0.97%
+ // pb 0% 0.96% 13.88%
+ // bin 0.01% 22.27% 41.17%
+ //
+ // It is very rare that we don't have enough slop for doing block copies. It
+ // is also rare that we need to expand a pattern. Small patterns are common
+ // for incompressible formats and for those we are plenty fast already.
+ // Lengths are normally not greater than 16 but they vary depending on the
+ // input. In general if we always predict len <= 16 it would be an ok
+ // prediction.
+ //
+ // In order to be fast we want a pattern >= 16 bytes (or 8 bytes in non-SSE)
+ // and an unrolled loop copying 1x 16 bytes (or 2x 8 bytes in non-SSE) at a
+ // time.
+
+ // Handle the uncommon case where pattern is less than 16 (or 8 in non-SSE)
+ // bytes.
+ if (pattern_size < big_pattern_size_lower_bound) {
+#if SNAPPY_HAVE_SSSE3
+ // Load the first eight bytes into an 128-bit XMM register, then use PSHUFB
+ // to permute the register's contents in-place into a repeating sequence of
+ // the first "pattern_size" bytes.
+ // For example, suppose:
+ // src == "abc"
+ // op == op + 3
+ // After _mm_shuffle_epi8(), "pattern" will have five copies of "abc"
+ // followed by one byte of slop: abcabcabcabcabca.
+ //
+ // The non-SSE fallback implementation suffers from store-forwarding stalls
+ // because its loads and stores partly overlap. By expanding the pattern
+ // in-place, we avoid the penalty.
+
+ // Typically, the op_limit is the gating factor so try to simplify the loop
+ // based on that.
+ if (SNAPPY_PREDICT_TRUE(op_limit <= buf_limit - 15)) {
+ auto pattern_and_reshuffle_mask =
+ LoadPatternAndReshuffleMask(src, pattern_size);
+ __m128i pattern = pattern_and_reshuffle_mask.first;
+ __m128i reshuffle_mask = pattern_and_reshuffle_mask.second;
+
+ // There is at least one, and at most four 16-byte blocks. Writing four
+ // conditionals instead of a loop allows FDO to layout the code with
+ // respect to the actual probabilities of each length.
+ // TODO: Replace with loop with trip count hint.
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(op), pattern);
+
+ if (op + 16 < op_limit) {
+ pattern = _mm_shuffle_epi8(pattern, reshuffle_mask);
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(op + 16), pattern);
+ }
+ if (op + 32 < op_limit) {
+ pattern = _mm_shuffle_epi8(pattern, reshuffle_mask);
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(op + 32), pattern);
+ }
+ if (op + 48 < op_limit) {
+ pattern = _mm_shuffle_epi8(pattern, reshuffle_mask);
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(op + 48), pattern);
+ }
+ return op_limit;
+ }
+ char* const op_end = buf_limit - 15;
+ if (SNAPPY_PREDICT_TRUE(op < op_end)) {
+ auto pattern_and_reshuffle_mask =
+ LoadPatternAndReshuffleMask(src, pattern_size);
+ __m128i pattern = pattern_and_reshuffle_mask.first;
+ __m128i reshuffle_mask = pattern_and_reshuffle_mask.second;
+
+ // This code path is relatively cold however so we save code size
+ // by avoiding unrolling and vectorizing.
+ //
+ // TODO: Remove pragma when when cold regions don't get
+ // vectorized or unrolled.
+#ifdef __clang__
+#pragma clang loop unroll(disable)
+#endif
+ do {
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(op), pattern);
+ pattern = _mm_shuffle_epi8(pattern, reshuffle_mask);
+ op += 16;
+ } while (SNAPPY_PREDICT_TRUE(op < op_end));
+ }
+ return IncrementalCopySlow(op - pattern_size, op, op_limit);
+#else // !SNAPPY_HAVE_SSSE3
+ // If plenty of buffer space remains, expand the pattern to at least 8
+ // bytes. The way the following loop is written, we need 8 bytes of buffer
+ // space if pattern_size >= 4, 11 bytes if pattern_size is 1 or 3, and 10
+ // bytes if pattern_size is 2. Precisely encoding that is probably not
+ // worthwhile; instead, invoke the slow path if we cannot write 11 bytes
+ // (because 11 are required in the worst case).
+ if (SNAPPY_PREDICT_TRUE(op <= buf_limit - 11)) {
+ while (pattern_size < 8) {
+ UnalignedCopy64(src, op);
+ op += pattern_size;
+ pattern_size *= 2;
+ }
+ if (SNAPPY_PREDICT_TRUE(op >= op_limit)) return op_limit;
+ } else {
+ return IncrementalCopySlow(src, op, op_limit);
+ }
+#endif // SNAPPY_HAVE_SSSE3
+ }
+ assert(pattern_size >= big_pattern_size_lower_bound);
+ constexpr bool use_16bytes_chunk = big_pattern_size_lower_bound == 16;
+
+ // Copy 1x 16 bytes (or 2x 8 bytes in non-SSE) at a time. Because op - src can
+ // be < 16 in non-SSE, a single UnalignedCopy128 might overwrite data in op.
+ // UnalignedCopy64 is safe because expanding the pattern to at least 8 bytes
+ // guarantees that op - src >= 8.
+ //
+ // Typically, the op_limit is the gating factor so try to simplify the loop
+ // based on that.
+ if (SNAPPY_PREDICT_TRUE(op_limit <= buf_limit - 15)) {
+ // There is at least one, and at most four 16-byte blocks. Writing four
+ // conditionals instead of a loop allows FDO to layout the code with respect
+ // to the actual probabilities of each length.
+ // TODO: Replace with loop with trip count hint.
+ ConditionalUnalignedCopy128<use_16bytes_chunk>(src, op);
+ if (op + 16 < op_limit) {
+ ConditionalUnalignedCopy128<use_16bytes_chunk>(src + 16, op + 16);
+ }
+ if (op + 32 < op_limit) {
+ ConditionalUnalignedCopy128<use_16bytes_chunk>(src + 32, op + 32);
+ }
+ if (op + 48 < op_limit) {
+ ConditionalUnalignedCopy128<use_16bytes_chunk>(src + 48, op + 48);
+ }
+ return op_limit;
+ }
+
+ // Fall back to doing as much as we can with the available slop in the
+ // buffer. This code path is relatively cold however so we save code size by
+ // avoiding unrolling and vectorizing.
+ //
+ // TODO: Remove pragma when when cold regions don't get vectorized
+ // or unrolled.
+#ifdef __clang__
+#pragma clang loop unroll(disable)
+#endif
+ for (char* op_end = buf_limit - 16; op < op_end; op += 16, src += 16) {
+ ConditionalUnalignedCopy128<use_16bytes_chunk>(src, op);
+ }
+ if (op >= op_limit) return op_limit;
+
+ // We only take this branch if we didn't have enough slop and we can do a
+ // single 8 byte copy.
+ if (SNAPPY_PREDICT_FALSE(op <= buf_limit - 8)) {
+ UnalignedCopy64(src, op);
+ src += 8;
+ op += 8;
+ }
+ return IncrementalCopySlow(src, op, op_limit);
+}
+
+} // namespace
+
+template <bool allow_fast_path>
+static inline char* EmitLiteral(char* op, const char* literal, int len) {
+ // The vast majority of copies are below 16 bytes, for which a
+ // call to std::memcpy() is overkill. This fast path can sometimes
+ // copy up to 15 bytes too much, but that is okay in the
+ // main loop, since we have a bit to go on for both sides:
+ //
+ // - The input will always have kInputMarginBytes = 15 extra
+ // available bytes, as long as we're in the main loop, and
+ // if not, allow_fast_path = false.
+ // - The output will always have 32 spare bytes (see
+ // MaxCompressedLength).
+ assert(len > 0); // Zero-length literals are disallowed
+ int n = len - 1;
+ if (allow_fast_path && len <= 16) {
+ // Fits in tag byte
+ *op++ = LITERAL | (n << 2);
+
+ UnalignedCopy128(literal, op);
+ return op + len;
+ }
+
+ if (n < 60) {
+ // Fits in tag byte
+ *op++ = LITERAL | (n << 2);
+ } else {
+ int count = (Bits::Log2Floor(n) >> 3) + 1;
+ assert(count >= 1);
+ assert(count <= 4);
+ *op++ = LITERAL | ((59 + count) << 2);
+ // Encode in upcoming bytes.
+ // Write 4 bytes, though we may care about only 1 of them. The output buffer
+ // is guaranteed to have at least 3 more spaces left as 'len >= 61' holds
+ // here and there is a std::memcpy() of size 'len' below.
+ LittleEndian::Store32(op, n);
+ op += count;
+ }
+ std::memcpy(op, literal, len);
+ return op + len;
+}
+
+template <bool len_less_than_12>
+static inline char* EmitCopyAtMost64(char* op, size_t offset, size_t len) {
+ assert(len <= 64);
+ assert(len >= 4);
+ assert(offset < 65536);
+ assert(len_less_than_12 == (len < 12));
+
+ if (len_less_than_12) {
+ uint32_t u = (len << 2) + (offset << 8);
+ uint32_t copy1 = COPY_1_BYTE_OFFSET - (4 << 2) + ((offset >> 3) & 0xe0);
+ uint32_t copy2 = COPY_2_BYTE_OFFSET - (1 << 2);
+ // It turns out that offset < 2048 is a difficult to predict branch.
+ // `perf record` shows this is the highest percentage of branch misses in
+ // benchmarks. This code produces branch free code, the data dependency
+ // chain that bottlenecks the throughput is so long that a few extra
+ // instructions are completely free (IPC << 6 because of data deps).
+ u += offset < 2048 ? copy1 : copy2;
+ LittleEndian::Store32(op, u);
+ op += offset < 2048 ? 2 : 3;
+ } else {
+ // Write 4 bytes, though we only care about 3 of them. The output buffer
+ // is required to have some slack, so the extra byte won't overrun it.
+ uint32_t u = COPY_2_BYTE_OFFSET + ((len - 1) << 2) + (offset << 8);
+ LittleEndian::Store32(op, u);
+ op += 3;
+ }
+ return op;
+}
+
+template <bool len_less_than_12>
+static inline char* EmitCopy(char* op, size_t offset, size_t len) {
+ assert(len_less_than_12 == (len < 12));
+ if (len_less_than_12) {
+ return EmitCopyAtMost64</*len_less_than_12=*/true>(op, offset, len);
+ } else {
+ // A special case for len <= 64 might help, but so far measurements suggest
+ // it's in the noise.
+
+ // Emit 64 byte copies but make sure to keep at least four bytes reserved.
+ while (SNAPPY_PREDICT_FALSE(len >= 68)) {
+ op = EmitCopyAtMost64</*len_less_than_12=*/false>(op, offset, 64);
+ len -= 64;
+ }
+
+ // One or two copies will now finish the job.
+ if (len > 64) {
+ op = EmitCopyAtMost64</*len_less_than_12=*/false>(op, offset, 60);
+ len -= 60;
+ }
+
+ // Emit remainder.
+ if (len < 12) {
+ op = EmitCopyAtMost64</*len_less_than_12=*/true>(op, offset, len);
+ } else {
+ op = EmitCopyAtMost64</*len_less_than_12=*/false>(op, offset, len);
+ }
+ return op;
+ }
+}
+
+bool GetUncompressedLength(const char* start, size_t n, size_t* result) {
+ uint32_t v = 0;
+ const char* limit = start + n;
+ if (Varint::Parse32WithLimit(start, limit, &v) != NULL) {
+ *result = v;
+ return true;
+ } else {
+ return false;
+ }
+}
+
+namespace {
+uint32_t CalculateTableSize(uint32_t input_size) {
+ static_assert(
+ kMaxHashTableSize >= kMinHashTableSize,
+ "kMaxHashTableSize should be greater or equal to kMinHashTableSize.");
+ if (input_size > kMaxHashTableSize) {
+ return kMaxHashTableSize;
+ }
+ if (input_size < kMinHashTableSize) {
+ return kMinHashTableSize;
+ }
+ // This is equivalent to Log2Ceiling(input_size), assuming input_size > 1.
+ // 2 << Log2Floor(x - 1) is equivalent to 1 << (1 + Log2Floor(x - 1)).
+ return 2u << Bits::Log2Floor(input_size - 1);
+}
+} // namespace
+
+namespace internal {
+WorkingMemory::WorkingMemory(size_t input_size) {
+ const size_t max_fragment_size = std::min(input_size, kBlockSize);
+ const size_t table_size = CalculateTableSize(max_fragment_size);
+ size_ = table_size * sizeof(*table_) + max_fragment_size +
+ MaxCompressedLength(max_fragment_size);
+ mem_ = std::allocator<char>().allocate(size_);
+ table_ = reinterpret_cast<uint16_t*>(mem_);
+ input_ = mem_ + table_size * sizeof(*table_);
+ output_ = input_ + max_fragment_size;
+}
+
+WorkingMemory::~WorkingMemory() {
+ std::allocator<char>().deallocate(mem_, size_);
+}
+
+uint16_t* WorkingMemory::GetHashTable(size_t fragment_size,
+ int* table_size) const {
+ const size_t htsize = CalculateTableSize(fragment_size);
+ memset(table_, 0, htsize * sizeof(*table_));
+ *table_size = htsize;
+ return table_;
+}
+} // end namespace internal
+
+// Flat array compression that does not emit the "uncompressed length"
+// prefix. Compresses "input" string to the "*op" buffer.
+//
+// REQUIRES: "input" is at most "kBlockSize" bytes long.
+// REQUIRES: "op" points to an array of memory that is at least
+// "MaxCompressedLength(input.size())" in size.
+// REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero.
+// REQUIRES: "table_size" is a power of two
+//
+// Returns an "end" pointer into "op" buffer.
+// "end - op" is the compressed size of "input".
+namespace internal {
+char* CompressFragment(const char* input, size_t input_size, char* op,
+ uint16_t* table, const int table_size) {
+ // "ip" is the input pointer, and "op" is the output pointer.
+ const char* ip = input;
+ assert(input_size <= kBlockSize);
+ assert((table_size & (table_size - 1)) == 0); // table must be power of two
+ const uint32_t mask = table_size - 1;
+ const char* ip_end = input + input_size;
+ const char* base_ip = ip;
+
+ const size_t kInputMarginBytes = 15;
+ if (SNAPPY_PREDICT_TRUE(input_size >= kInputMarginBytes)) {
+ const char* ip_limit = input + input_size - kInputMarginBytes;
+
+ for (uint32_t preload = LittleEndian::Load32(ip + 1);;) {
+ // Bytes in [next_emit, ip) will be emitted as literal bytes. Or
+ // [next_emit, ip_end) after the main loop.
+ const char* next_emit = ip++;
+ uint64_t data = LittleEndian::Load64(ip);
+ // The body of this loop calls EmitLiteral once and then EmitCopy one or
+ // more times. (The exception is that when we're close to exhausting
+ // the input we goto emit_remainder.)
+ //
+ // In the first iteration of this loop we're just starting, so
+ // there's nothing to copy, so calling EmitLiteral once is
+ // necessary. And we only start a new iteration when the
+ // current iteration has determined that a call to EmitLiteral will
+ // precede the next call to EmitCopy (if any).
+ //
+ // Step 1: Scan forward in the input looking for a 4-byte-long match.
+ // If we get close to exhausting the input then goto emit_remainder.
+ //
+ // Heuristic match skipping: If 32 bytes are scanned with no matches
+ // found, start looking only at every other byte. If 32 more bytes are
+ // scanned (or skipped), look at every third byte, etc.. When a match is
+ // found, immediately go back to looking at every byte. This is a small
+ // loss (~5% performance, ~0.1% density) for compressible data due to more
+ // bookkeeping, but for non-compressible data (such as JPEG) it's a huge
+ // win since the compressor quickly "realizes" the data is incompressible
+ // and doesn't bother looking for matches everywhere.
+ //
+ // The "skip" variable keeps track of how many bytes there are since the
+ // last match; dividing it by 32 (ie. right-shifting by five) gives the
+ // number of bytes to move ahead for each iteration.
+ uint32_t skip = 32;
+
+ const char* candidate;
+ if (ip_limit - ip >= 16) {
+ auto delta = ip - base_ip;
+ for (int j = 0; j < 4; ++j) {
+ for (int k = 0; k < 4; ++k) {
+ int i = 4 * j + k;
+ // These for-loops are meant to be unrolled. So we can freely
+ // special case the first iteration to use the value already
+ // loaded in preload.
+ uint32_t dword = i == 0 ? preload : static_cast<uint32_t>(data);
+ assert(dword == LittleEndian::Load32(ip + i));
+ uint32_t hash = HashBytes(dword, mask);
+ candidate = base_ip + table[hash];
+ assert(candidate >= base_ip);
+ assert(candidate < ip + i);
+ table[hash] = delta + i;
+ if (SNAPPY_PREDICT_FALSE(LittleEndian::Load32(candidate) == dword)) {
+ *op = LITERAL | (i << 2);
+ UnalignedCopy128(next_emit, op + 1);
+ ip += i;
+ op = op + i + 2;
+ goto emit_match;
+ }
+ data >>= 8;
+ }
+ data = LittleEndian::Load64(ip + 4 * j + 4);
+ }
+ ip += 16;
+ skip += 16;
+ }
+ while (true) {
+ assert(static_cast<uint32_t>(data) == LittleEndian::Load32(ip));
+ uint32_t hash = HashBytes(data, mask);
+ uint32_t bytes_between_hash_lookups = skip >> 5;
+ skip += bytes_between_hash_lookups;
+ const char* next_ip = ip + bytes_between_hash_lookups;
+ if (SNAPPY_PREDICT_FALSE(next_ip > ip_limit)) {
+ ip = next_emit;
+ goto emit_remainder;
+ }
+ candidate = base_ip + table[hash];
+ assert(candidate >= base_ip);
+ assert(candidate < ip);
+
+ table[hash] = ip - base_ip;
+ if (SNAPPY_PREDICT_FALSE(static_cast<uint32_t>(data) ==
+ LittleEndian::Load32(candidate))) {
+ break;
+ }
+ data = LittleEndian::Load32(next_ip);
+ ip = next_ip;
+ }
+
+ // Step 2: A 4-byte match has been found. We'll later see if more
+ // than 4 bytes match. But, prior to the match, input
+ // bytes [next_emit, ip) are unmatched. Emit them as "literal bytes."
+ assert(next_emit + 16 <= ip_end);
+ op = EmitLiteral</*allow_fast_path=*/true>(op, next_emit, ip - next_emit);
+
+ // Step 3: Call EmitCopy, and then see if another EmitCopy could
+ // be our next move. Repeat until we find no match for the
+ // input immediately after what was consumed by the last EmitCopy call.
+ //
+ // If we exit this loop normally then we need to call EmitLiteral next,
+ // though we don't yet know how big the literal will be. We handle that
+ // by proceeding to the next iteration of the main loop. We also can exit
+ // this loop via goto if we get close to exhausting the input.
+ emit_match:
+ do {
+ // We have a 4-byte match at ip, and no need to emit any
+ // "literal bytes" prior to ip.
+ const char* base = ip;
+ std::pair<size_t, bool> p =
+ FindMatchLength(candidate + 4, ip + 4, ip_end, &data);
+ size_t matched = 4 + p.first;
+ ip += matched;
+ size_t offset = base - candidate;
+ assert(0 == memcmp(base, candidate, matched));
+ if (p.second) {
+ op = EmitCopy</*len_less_than_12=*/true>(op, offset, matched);
+ } else {
+ op = EmitCopy</*len_less_than_12=*/false>(op, offset, matched);
+ }
+ if (SNAPPY_PREDICT_FALSE(ip >= ip_limit)) {
+ goto emit_remainder;
+ }
+ // Expect 5 bytes to match
+ assert((data & 0xFFFFFFFFFF) ==
+ (LittleEndian::Load64(ip) & 0xFFFFFFFFFF));
+ // We are now looking for a 4-byte match again. We read
+ // table[Hash(ip, shift)] for that. To improve compression,
+ // we also update table[Hash(ip - 1, mask)] and table[Hash(ip, mask)].
+ table[HashBytes(LittleEndian::Load32(ip - 1), mask)] = ip - base_ip - 1;
+ uint32_t hash = HashBytes(data, mask);
+ candidate = base_ip + table[hash];
+ table[hash] = ip - base_ip;
+ // Measurements on the benchmarks have shown the following probabilities
+ // for the loop to exit (ie. avg. number of iterations is reciprocal).
+ // BM_Flat/6 txt1 p = 0.3-0.4
+ // BM_Flat/7 txt2 p = 0.35
+ // BM_Flat/8 txt3 p = 0.3-0.4
+ // BM_Flat/9 txt3 p = 0.34-0.4
+ // BM_Flat/10 pb p = 0.4
+ // BM_Flat/11 gaviota p = 0.1
+ // BM_Flat/12 cp p = 0.5
+ // BM_Flat/13 c p = 0.3
+ } while (static_cast<uint32_t>(data) == LittleEndian::Load32(candidate));
+ // Because the least significant 5 bytes matched, we can utilize data
+ // for the next iteration.
+ preload = data >> 8;
+ }
+ }
+
+emit_remainder:
+ // Emit the remaining bytes as a literal
+ if (ip < ip_end) {
+ op = EmitLiteral</*allow_fast_path=*/false>(op, ip, ip_end - ip);
+ }
+
+ return op;
+}
+} // end namespace internal
+
+// Called back at avery compression call to trace parameters and sizes.
+static inline void Report(const char *algorithm, size_t compressed_size,
+ size_t uncompressed_size) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)algorithm;
+ (void)compressed_size;
+ (void)uncompressed_size;
+}
+
+// Signature of output types needed by decompression code.
+// The decompression code is templatized on a type that obeys this
+// signature so that we do not pay virtual function call overhead in
+// the middle of a tight decompression loop.
+//
+// class DecompressionWriter {
+// public:
+// // Called before decompression
+// void SetExpectedLength(size_t length);
+//
+// // For performance a writer may choose to donate the cursor variable to the
+// // decompression function. The decompression will inject it in all its
+// // function calls to the writer. Keeping the important output cursor as a
+// // function local stack variable allows the compiler to keep it in
+// // register, which greatly aids performance by avoiding loads and stores of
+// // this variable in the fast path loop iterations.
+// T GetOutputPtr() const;
+//
+// // At end of decompression the loop donates the ownership of the cursor
+// // variable back to the writer by calling this function.
+// void SetOutputPtr(T op);
+//
+// // Called after decompression
+// bool CheckLength() const;
+//
+// // Called repeatedly during decompression
+// // Each function get a pointer to the op (output pointer), that the writer
+// // can use and update. Note it's important that these functions get fully
+// // inlined so that no actual address of the local variable needs to be
+// // taken.
+// bool Append(const char* ip, size_t length, T* op);
+// bool AppendFromSelf(uint32_t offset, size_t length, T* op);
+//
+// // The rules for how TryFastAppend differs from Append are somewhat
+// // convoluted:
+// //
+// // - TryFastAppend is allowed to decline (return false) at any
+// // time, for any reason -- just "return false" would be
+// // a perfectly legal implementation of TryFastAppend.
+// // The intention is for TryFastAppend to allow a fast path
+// // in the common case of a small append.
+// // - TryFastAppend is allowed to read up to <available> bytes
+// // from the input buffer, whereas Append is allowed to read
+// // <length>. However, if it returns true, it must leave
+// // at least five (kMaximumTagLength) bytes in the input buffer
+// // afterwards, so that there is always enough space to read the
+// // next tag without checking for a refill.
+// // - TryFastAppend must always return decline (return false)
+// // if <length> is 61 or more, as in this case the literal length is not
+// // decoded fully. In practice, this should not be a big problem,
+// // as it is unlikely that one would implement a fast path accepting
+// // this much data.
+// //
+// bool TryFastAppend(const char* ip, size_t available, size_t length, T* op);
+// };
+
+static inline uint32_t ExtractLowBytes(uint32_t v, int n) {
+ assert(n >= 0);
+ assert(n <= 4);
+#if SNAPPY_HAVE_BMI2
+ return _bzhi_u32(v, 8 * n);
+#else
+ // This needs to be wider than uint32_t otherwise `mask << 32` will be
+ // undefined.
+ uint64_t mask = 0xffffffff;
+ return v & ~(mask << (8 * n));
+#endif
+}
+
+static inline bool LeftShiftOverflows(uint8_t value, uint32_t shift) {
+ assert(shift < 32);
+ static const uint8_t masks[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
+ 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe};
+ return (value & masks[shift]) != 0;
+}
+
+inline bool Copy64BytesWithPatternExtension(ptrdiff_t dst, size_t offset) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)dst;
+ return offset != 0;
+}
+
+void MemCopy(char* dst, const uint8_t* src, size_t size) {
+ std::memcpy(dst, src, size);
+}
+
+void MemCopy(ptrdiff_t dst, const uint8_t* src, size_t size) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)dst;
+ (void)src;
+ (void)size;
+}
+
+void MemMove(char* dst, const void* src, size_t size) {
+ std::memmove(dst, src, size);
+}
+
+void MemMove(ptrdiff_t dst, const void* src, size_t size) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)dst;
+ (void)src;
+ (void)size;
+}
+
+SNAPPY_ATTRIBUTE_ALWAYS_INLINE
+size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
+ const uint8_t*& ip = *ip_p;
+ // This section is crucial for the throughput of the decompression loop.
+ // The latency of an iteration is fundamentally constrained by the
+ // following data chain on ip.
+ // ip -> c = Load(ip) -> ip1 = ip + 1 + (c & 3) -> ip = ip1 or ip2
+ // ip2 = ip + 2 + (c >> 2)
+ // This amounts to 8 cycles.
+ // 5 (load) + 1 (c & 3) + 1 (lea ip1, [ip + (c & 3) + 1]) + 1 (cmov)
+ size_t literal_len = *tag >> 2;
+ size_t tag_type = *tag;
+ bool is_literal;
+#if defined(__GNUC__) && defined(__x86_64__) && defined(__GCC_ASM_FLAG_OUTPUTS__)
+ // TODO clang misses the fact that the (c & 3) already correctly
+ // sets the zero flag.
+ asm("and $3, %k[tag_type]\n\t"
+ : [tag_type] "+r"(tag_type), "=@ccz"(is_literal));
+#else
+ tag_type &= 3;
+ is_literal = (tag_type == 0);
+#endif
+ // TODO
+ // This is code is subtle. Loading the values first and then cmov has less
+ // latency then cmov ip and then load. However clang would move the loads
+ // in an optimization phase, volatile prevents this transformation.
+ // Note that we have enough slop bytes (64) that the loads are always valid.
+ size_t tag_literal =
+ static_cast<const volatile uint8_t*>(ip)[1 + literal_len];
+ size_t tag_copy = static_cast<const volatile uint8_t*>(ip)[tag_type];
+ *tag = is_literal ? tag_literal : tag_copy;
+ const uint8_t* ip_copy = ip + 1 + tag_type;
+ const uint8_t* ip_literal = ip + 2 + literal_len;
+ ip = is_literal ? ip_literal : ip_copy;
+#if defined(__GNUC__) && defined(__x86_64__)
+ // TODO Clang is "optimizing" zero-extension (a totally free
+ // operation) this means that after the cmov of tag, it emits another movzb
+ // tag, byte(tag). It really matters as it's on the core chain. This dummy
+ // asm, persuades clang to do the zero-extension at the load (it's automatic)
+ // removing the expensive movzb.
+ asm("" ::"r"(tag_copy));
+#endif
+ return tag_type;
+}
+
+// Extract the offset for copy-1 and copy-2 returns 0 for literals or copy-4.
+inline uint32_t ExtractOffset(uint32_t val, size_t tag_type) {
+ return val & table.extract_masks[tag_type];
+};
+
+// Core decompression loop, when there is enough data available.
+// Decompresses the input buffer [ip, ip_limit) into the output buffer
+// [op, op_limit_min_slop). Returning when either we are too close to the end
+// of the input buffer, or we exceed op_limit_min_slop or when a exceptional
+// tag is encountered (literal of length > 60) or a copy-4.
+// Returns {ip, op} at the points it stopped decoding.
+// TODO This function probably does not need to be inlined, as it
+// should decode large chunks at a time. This allows runtime dispatch to
+// implementations based on CPU capability (BMI2 / perhaps 32 / 64 byte memcpy).
+template <typename T>
+std::pair<const uint8_t*, ptrdiff_t> DecompressBranchless(
+ const uint8_t* ip, const uint8_t* ip_limit, ptrdiff_t op, T op_base,
+ ptrdiff_t op_limit_min_slop) {
+ // We unroll the inner loop twice so we need twice the spare room.
+ op_limit_min_slop -= kSlopBytes;
+ if (2 * (kSlopBytes + 1) < ip_limit - ip && op < op_limit_min_slop) {
+ const uint8_t* const ip_limit_min_slop = ip_limit - 2 * kSlopBytes - 1;
+ ip++;
+ // ip points just past the tag and we are touching at maximum kSlopBytes
+ // in an iteration.
+ size_t tag = ip[-1];
+ do {
+ // The throughput is limited by instructions, unrolling the inner loop
+ // twice reduces the amount of instructions checking limits and also
+ // leads to reduced mov's.
+ for (int i = 0; i < 2; i++) {
+ const uint8_t* old_ip = ip;
+ assert(tag == ip[-1]);
+ // For literals tag_type = 0, hence we will always obtain 0 from
+ // ExtractLowBytes. For literals offset will thus be kLiteralOffset.
+ ptrdiff_t len_min_offset = table.length_minus_offset[tag];
+ size_t tag_type = AdvanceToNextTag(&ip, &tag);
+ uint32_t next = LittleEndian::Load32(old_ip);
+ size_t len = len_min_offset & 0xFF;
+ len_min_offset -= ExtractOffset(next, tag_type);
+ if (SNAPPY_PREDICT_FALSE(len_min_offset > 0)) {
+ if (SNAPPY_PREDICT_FALSE(len & 0x80)) {
+ // Exceptional case (long literal or copy 4).
+ // Actually doing the copy here is negatively impacting the main
+ // loop due to compiler incorrectly allocating a register for
+ // this fallback. Hence we just break.
+ break_loop:
+ ip = old_ip;
+ goto exit;
+ }
+ // Only copy-1 or copy-2 tags can get here.
+ assert(tag_type == 1 || tag_type == 2);
+ std::ptrdiff_t delta = op + len_min_offset - len;
+ // Guard against copies before the buffer start.
+ if (SNAPPY_PREDICT_FALSE(delta < 0 ||
+ !Copy64BytesWithPatternExtension(
+ op_base + op, len - len_min_offset))) {
+ goto break_loop;
+ }
+ op += len;
+ continue;
+ }
+ std::ptrdiff_t delta = op + len_min_offset - len;
+ if (SNAPPY_PREDICT_FALSE(delta < 0)) {
+#if defined(__GNUC__) && defined(__x86_64__)
+ // TODO
+ // When validating, both code path reduced to `op += len`. Ie. this
+ // becomes effectively
+ //
+ // if (delta < 0) if (tag_type != 0) goto break_loop;
+ // op += len;
+ //
+ // The compiler interchanges the predictable and almost always false
+ // first if-statement with the completely unpredictable second
+ // if-statement, putting an unpredictable branch on every iteration.
+ // This empty asm is worth almost 2x, which I think qualifies for an
+ // award for the most load-bearing empty statement.
+ asm("");
+#endif
+
+ // Due to the spurious offset in literals have this will trigger
+ // at the start of a block when op is still smaller than 256.
+ if (tag_type != 0) goto break_loop;
+ MemCopy(op_base + op, old_ip, 64);
+ op += len;
+ continue;
+ }
+
+ // For copies we need to copy from op_base + delta, for literals
+ // we need to copy from ip instead of from the stream.
+ const void* from =
+ tag_type ? reinterpret_cast<void*>(op_base + delta) : old_ip;
+ MemMove(op_base + op, from, 64);
+ op += len;
+ }
+ } while (ip < ip_limit_min_slop && op < op_limit_min_slop);
+ exit:
+ ip--;
+ assert(ip <= ip_limit);
+ }
+ return {ip, op};
+}
+
+// Helper class for decompression
+class SnappyDecompressor {
+ private:
+ Source* reader_; // Underlying source of bytes to decompress
+ const char* ip_; // Points to next buffered byte
+ const char* ip_limit_; // Points just past buffered bytes
+ // If ip < ip_limit_min_maxtaglen_ it's safe to read kMaxTagLength from
+ // buffer.
+ const char* ip_limit_min_maxtaglen_;
+ uint32_t peeked_; // Bytes peeked from reader (need to skip)
+ bool eof_; // Hit end of input without an error?
+ char scratch_[kMaximumTagLength]; // See RefillTag().
+
+ // Ensure that all of the tag metadata for the next tag is available
+ // in [ip_..ip_limit_-1]. Also ensures that [ip,ip+4] is readable even
+ // if (ip_limit_ - ip_ < 5).
+ //
+ // Returns true on success, false on error or end of input.
+ bool RefillTag();
+
+ void ResetLimit(const char* ip) {
+ ip_limit_min_maxtaglen_ =
+ ip_limit_ - std::min<ptrdiff_t>(ip_limit_ - ip, kMaximumTagLength - 1);
+ }
+
+ public:
+ explicit SnappyDecompressor(Source* reader)
+ : reader_(reader), ip_(NULL), ip_limit_(NULL), peeked_(0), eof_(false) {}
+
+ ~SnappyDecompressor() {
+ // Advance past any bytes we peeked at from the reader
+ reader_->Skip(peeked_);
+ }
+
+ // Returns true iff we have hit the end of the input without an error.
+ bool eof() const { return eof_; }
+
+ // Read the uncompressed length stored at the start of the compressed data.
+ // On success, stores the length in *result and returns true.
+ // On failure, returns false.
+ bool ReadUncompressedLength(uint32_t* result) {
+ assert(ip_ == NULL); // Must not have read anything yet
+ // Length is encoded in 1..5 bytes
+ *result = 0;
+ uint32_t shift = 0;
+ while (true) {
+ if (shift >= 32) return false;
+ size_t n;
+ const char* ip = reader_->Peek(&n);
+ if (n == 0) return false;
+ const unsigned char c = *(reinterpret_cast<const unsigned char*>(ip));
+ reader_->Skip(1);
+ uint32_t val = c & 0x7f;
+ if (LeftShiftOverflows(static_cast<uint8_t>(val), shift)) return false;
+ *result |= val << shift;
+ if (c < 128) {
+ break;
+ }
+ shift += 7;
+ }
+ return true;
+ }
+
+ // Process the next item found in the input.
+ // Returns true if successful, false on error or end of input.
+ template <class Writer>
+#if defined(__GNUC__) && defined(__x86_64__)
+ __attribute__((aligned(32)))
+#endif
+ void
+ DecompressAllTags(Writer* writer) {
+ const char* ip = ip_;
+ ResetLimit(ip);
+ auto op = writer->GetOutputPtr();
+ // We could have put this refill fragment only at the beginning of the loop.
+ // However, duplicating it at the end of each branch gives the compiler more
+ // scope to optimize the <ip_limit_ - ip> expression based on the local
+ // context, which overall increases speed.
+#define MAYBE_REFILL() \
+ if (SNAPPY_PREDICT_FALSE(ip >= ip_limit_min_maxtaglen_)) { \
+ ip_ = ip; \
+ if (SNAPPY_PREDICT_FALSE(!RefillTag())) goto exit; \
+ ip = ip_; \
+ ResetLimit(ip); \
+ } \
+ preload = static_cast<uint8_t>(*ip)
+
+ // At the start of the for loop below the least significant byte of preload
+ // contains the tag.
+ uint32_t preload;
+ MAYBE_REFILL();
+ for (;;) {
+ {
+ ptrdiff_t op_limit_min_slop;
+ auto op_base = writer->GetBase(&op_limit_min_slop);
+ if (op_base) {
+ auto res =
+ DecompressBranchless(reinterpret_cast<const uint8_t*>(ip),
+ reinterpret_cast<const uint8_t*>(ip_limit_),
+ op - op_base, op_base, op_limit_min_slop);
+ ip = reinterpret_cast<const char*>(res.first);
+ op = op_base + res.second;
+ MAYBE_REFILL();
+ }
+ }
+ const uint8_t c = static_cast<uint8_t>(preload);
+ ip++;
+
+ // Ratio of iterations that have LITERAL vs non-LITERAL for different
+ // inputs.
+ //
+ // input LITERAL NON_LITERAL
+ // -----------------------------------
+ // html|html4|cp 23% 77%
+ // urls 36% 64%
+ // jpg 47% 53%
+ // pdf 19% 81%
+ // txt[1-4] 25% 75%
+ // pb 24% 76%
+ // bin 24% 76%
+ if (SNAPPY_PREDICT_FALSE((c & 0x3) == LITERAL)) {
+ size_t literal_length = (c >> 2) + 1u;
+ if (writer->TryFastAppend(ip, ip_limit_ - ip, literal_length, &op)) {
+ assert(literal_length < 61);
+ ip += literal_length;
+ // NOTE: There is no MAYBE_REFILL() here, as TryFastAppend()
+ // will not return true unless there's already at least five spare
+ // bytes in addition to the literal.
+ preload = static_cast<uint8_t>(*ip);
+ continue;
+ }
+ if (SNAPPY_PREDICT_FALSE(literal_length >= 61)) {
+ // Long literal.
+ const size_t literal_length_length = literal_length - 60;
+ literal_length =
+ ExtractLowBytes(LittleEndian::Load32(ip), literal_length_length) +
+ 1;
+ ip += literal_length_length;
+ }
+
+ size_t avail = ip_limit_ - ip;
+ while (avail < literal_length) {
+ if (!writer->Append(ip, avail, &op)) goto exit;
+ literal_length -= avail;
+ reader_->Skip(peeked_);
+ size_t n;
+ ip = reader_->Peek(&n);
+ avail = n;
+ peeked_ = avail;
+ if (avail == 0) goto exit;
+ ip_limit_ = ip + avail;
+ ResetLimit(ip);
+ }
+ if (!writer->Append(ip, literal_length, &op)) goto exit;
+ ip += literal_length;
+ MAYBE_REFILL();
+ } else {
+ if (SNAPPY_PREDICT_FALSE((c & 3) == COPY_4_BYTE_OFFSET)) {
+ const size_t copy_offset = LittleEndian::Load32(ip);
+ const size_t length = (c >> 2) + 1;
+ ip += 4;
+
+ if (!writer->AppendFromSelf(copy_offset, length, &op)) goto exit;
+ } else {
+ const ptrdiff_t entry = table.length_minus_offset[c];
+ preload = LittleEndian::Load32(ip);
+ const uint32_t trailer = ExtractLowBytes(preload, c & 3);
+ const uint32_t length = entry & 0xff;
+ assert(length > 0);
+
+ // copy_offset/256 is encoded in bits 8..10. By just fetching
+ // those bits, we get copy_offset (since the bit-field starts at
+ // bit 8).
+ const uint32_t copy_offset = trailer - entry + length;
+ if (!writer->AppendFromSelf(copy_offset, length, &op)) goto exit;
+
+ ip += (c & 3);
+ // By using the result of the previous load we reduce the critical
+ // dependency chain of ip to 4 cycles.
+ preload >>= (c & 3) * 8;
+ if (ip < ip_limit_min_maxtaglen_) continue;
+ }
+ MAYBE_REFILL();
+ }
+ }
+#undef MAYBE_REFILL
+ exit:
+ writer->SetOutputPtr(op);
+ }
+};
+
+constexpr uint32_t CalculateNeeded(uint8_t tag) {
+ return ((tag & 3) == 0 && tag >= (60 * 4))
+ ? (tag >> 2) - 58
+ : (0x05030201 >> ((tag * 8) & 31)) & 0xFF;
+}
+
+#if __cplusplus >= 201402L
+constexpr bool VerifyCalculateNeeded() {
+ for (int i = 0; i < 1; i++) {
+ if (CalculateNeeded(i) != (char_table[i] >> 11) + 1) return false;
+ }
+ return true;
+}
+
+// Make sure CalculateNeeded is correct by verifying it against the established
+// table encoding the number of added bytes needed.
+static_assert(VerifyCalculateNeeded(), "");
+#endif // c++14
+
+bool SnappyDecompressor::RefillTag() {
+ const char* ip = ip_;
+ if (ip == ip_limit_) {
+ // Fetch a new fragment from the reader
+ reader_->Skip(peeked_); // All peeked bytes are used up
+ size_t n;
+ ip = reader_->Peek(&n);
+ peeked_ = n;
+ eof_ = (n == 0);
+ if (eof_) return false;
+ ip_limit_ = ip + n;
+ }
+
+ // Read the tag character
+ assert(ip < ip_limit_);
+ const unsigned char c = *(reinterpret_cast<const unsigned char*>(ip));
+ // At this point make sure that the data for the next tag is consecutive.
+ // For copy 1 this means the next 2 bytes (tag and 1 byte offset)
+ // For copy 2 the next 3 bytes (tag and 2 byte offset)
+ // For copy 4 the next 5 bytes (tag and 4 byte offset)
+ // For all small literals we only need 1 byte buf for literals 60...63 the
+ // length is encoded in 1...4 extra bytes.
+ const uint32_t needed = CalculateNeeded(c);
+ assert(needed <= sizeof(scratch_));
+
+ // Read more bytes from reader if needed
+ uint32_t nbuf = ip_limit_ - ip;
+ if (nbuf < needed) {
+ // Stitch together bytes from ip and reader to form the word
+ // contents. We store the needed bytes in "scratch_". They
+ // will be consumed immediately by the caller since we do not
+ // read more than we need.
+ std::memmove(scratch_, ip, nbuf);
+ reader_->Skip(peeked_); // All peeked bytes are used up
+ peeked_ = 0;
+ while (nbuf < needed) {
+ size_t length;
+ const char* src = reader_->Peek(&length);
+ if (length == 0) return false;
+ uint32_t to_add = std::min<uint32_t>(needed - nbuf, length);
+ std::memcpy(scratch_ + nbuf, src, to_add);
+ nbuf += to_add;
+ reader_->Skip(to_add);
+ }
+ assert(nbuf == needed);
+ ip_ = scratch_;
+ ip_limit_ = scratch_ + needed;
+ } else if (nbuf < kMaximumTagLength) {
+ // Have enough bytes, but move into scratch_ so that we do not
+ // read past end of input
+ std::memmove(scratch_, ip, nbuf);
+ reader_->Skip(peeked_); // All peeked bytes are used up
+ peeked_ = 0;
+ ip_ = scratch_;
+ ip_limit_ = scratch_ + nbuf;
+ } else {
+ // Pass pointer to buffer returned by reader_.
+ ip_ = ip;
+ }
+ return true;
+}
+
+template <typename Writer>
+static bool InternalUncompress(Source* r, Writer* writer) {
+ // Read the uncompressed length from the front of the compressed input
+ SnappyDecompressor decompressor(r);
+ uint32_t uncompressed_len = 0;
+ if (!decompressor.ReadUncompressedLength(&uncompressed_len)) return false;
+
+ return InternalUncompressAllTags(&decompressor, writer, r->Available(),
+ uncompressed_len);
+}
+
+template <typename Writer>
+static bool InternalUncompressAllTags(SnappyDecompressor* decompressor,
+ Writer* writer, uint32_t compressed_len,
+ uint32_t uncompressed_len) {
+ Report("snappy_uncompress", compressed_len, uncompressed_len);
+
+ writer->SetExpectedLength(uncompressed_len);
+
+ // Process the entire input
+ decompressor->DecompressAllTags(writer);
+ writer->Flush();
+ return (decompressor->eof() && writer->CheckLength());
+}
+
+bool GetUncompressedLength(Source* source, uint32_t* result) {
+ SnappyDecompressor decompressor(source);
+ return decompressor.ReadUncompressedLength(result);
+}
+
+size_t Compress(Source* reader, Sink* writer) {
+ size_t written = 0;
+ size_t N = reader->Available();
+ const size_t uncompressed_size = N;
+ char ulength[Varint::kMax32];
+ char* p = Varint::Encode32(ulength, N);
+ writer->Append(ulength, p - ulength);
+ written += (p - ulength);
+
+ internal::WorkingMemory wmem(N);
+
+ while (N > 0) {
+ // Get next block to compress (without copying if possible)
+ size_t fragment_size;
+ const char* fragment = reader->Peek(&fragment_size);
+ assert(fragment_size != 0); // premature end of input
+ const size_t num_to_read = std::min(N, kBlockSize);
+ size_t bytes_read = fragment_size;
+
+ size_t pending_advance = 0;
+ if (bytes_read >= num_to_read) {
+ // Buffer returned by reader is large enough
+ pending_advance = num_to_read;
+ fragment_size = num_to_read;
+ } else {
+ char* scratch = wmem.GetScratchInput();
+ std::memcpy(scratch, fragment, bytes_read);
+ reader->Skip(bytes_read);
+
+ while (bytes_read < num_to_read) {
+ fragment = reader->Peek(&fragment_size);
+ size_t n = std::min<size_t>(fragment_size, num_to_read - bytes_read);
+ std::memcpy(scratch + bytes_read, fragment, n);
+ bytes_read += n;
+ reader->Skip(n);
+ }
+ assert(bytes_read == num_to_read);
+ fragment = scratch;
+ fragment_size = num_to_read;
+ }
+ assert(fragment_size == num_to_read);
+
+ // Get encoding table for compression
+ int table_size;
+ uint16_t* table = wmem.GetHashTable(num_to_read, &table_size);
+
+ // Compress input_fragment and append to dest
+ const int max_output = MaxCompressedLength(num_to_read);
+
+ // Need a scratch buffer for the output, in case the byte sink doesn't
+ // have room for us directly.
+
+ // Since we encode kBlockSize regions followed by a region
+ // which is <= kBlockSize in length, a previously allocated
+ // scratch_output[] region is big enough for this iteration.
+ char* dest = writer->GetAppendBuffer(max_output, wmem.GetScratchOutput());
+ char* end = internal::CompressFragment(fragment, fragment_size, dest, table,
+ table_size);
+ writer->Append(dest, end - dest);
+ written += (end - dest);
+
+ N -= num_to_read;
+ reader->Skip(pending_advance);
+ }
+
+ Report("snappy_compress", written, uncompressed_size);
+
+ return written;
+}
+
+// -----------------------------------------------------------------------
+// IOVec interfaces
+// -----------------------------------------------------------------------
+
+// A type that writes to an iovec.
+// Note that this is not a "ByteSink", but a type that matches the
+// Writer template argument to SnappyDecompressor::DecompressAllTags().
+class SnappyIOVecWriter {
+ private:
+ // output_iov_end_ is set to iov + count and used to determine when
+ // the end of the iovs is reached.
+ const struct iovec* output_iov_end_;
+
+#if !defined(NDEBUG)
+ const struct iovec* output_iov_;
+#endif // !defined(NDEBUG)
+
+ // Current iov that is being written into.
+ const struct iovec* curr_iov_;
+
+ // Pointer to current iov's write location.
+ char* curr_iov_output_;
+
+ // Remaining bytes to write into curr_iov_output.
+ size_t curr_iov_remaining_;
+
+ // Total bytes decompressed into output_iov_ so far.
+ size_t total_written_;
+
+ // Maximum number of bytes that will be decompressed into output_iov_.
+ size_t output_limit_;
+
+ static inline char* GetIOVecPointer(const struct iovec* iov, size_t offset) {
+ return reinterpret_cast<char*>(iov->iov_base) + offset;
+ }
+
+ public:
+ // Does not take ownership of iov. iov must be valid during the
+ // entire lifetime of the SnappyIOVecWriter.
+ inline SnappyIOVecWriter(const struct iovec* iov, size_t iov_count)
+ : output_iov_end_(iov + iov_count),
+#if !defined(NDEBUG)
+ output_iov_(iov),
+#endif // !defined(NDEBUG)
+ curr_iov_(iov),
+ curr_iov_output_(iov_count ? reinterpret_cast<char*>(iov->iov_base)
+ : nullptr),
+ curr_iov_remaining_(iov_count ? iov->iov_len : 0),
+ total_written_(0),
+ output_limit_(-1) {
+ }
+
+ inline void SetExpectedLength(size_t len) { output_limit_ = len; }
+
+ inline bool CheckLength() const { return total_written_ == output_limit_; }
+
+ inline bool Append(const char* ip, size_t len, char**) {
+ if (total_written_ + len > output_limit_) {
+ return false;
+ }
+
+ return AppendNoCheck(ip, len);
+ }
+
+ char* GetOutputPtr() { return nullptr; }
+ char* GetBase(ptrdiff_t*) { return nullptr; }
+ void SetOutputPtr(char* op) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)op;
+ }
+
+ inline bool AppendNoCheck(const char* ip, size_t len) {
+ while (len > 0) {
+ if (curr_iov_remaining_ == 0) {
+ // This iovec is full. Go to the next one.
+ if (curr_iov_ + 1 >= output_iov_end_) {
+ return false;
+ }
+ ++curr_iov_;
+ curr_iov_output_ = reinterpret_cast<char*>(curr_iov_->iov_base);
+ curr_iov_remaining_ = curr_iov_->iov_len;
+ }
+
+ const size_t to_write = std::min(len, curr_iov_remaining_);
+ std::memcpy(curr_iov_output_, ip, to_write);
+ curr_iov_output_ += to_write;
+ curr_iov_remaining_ -= to_write;
+ total_written_ += to_write;
+ ip += to_write;
+ len -= to_write;
+ }
+
+ return true;
+ }
+
+ inline bool TryFastAppend(const char* ip, size_t available, size_t len,
+ char**) {
+ const size_t space_left = output_limit_ - total_written_;
+ if (len <= 16 && available >= 16 + kMaximumTagLength && space_left >= 16 &&
+ curr_iov_remaining_ >= 16) {
+ // Fast path, used for the majority (about 95%) of invocations.
+ UnalignedCopy128(ip, curr_iov_output_);
+ curr_iov_output_ += len;
+ curr_iov_remaining_ -= len;
+ total_written_ += len;
+ return true;
+ }
+
+ return false;
+ }
+
+ inline bool AppendFromSelf(size_t offset, size_t len, char**) {
+ // See SnappyArrayWriter::AppendFromSelf for an explanation of
+ // the "offset - 1u" trick.
+ if (offset - 1u >= total_written_) {
+ return false;
+ }
+ const size_t space_left = output_limit_ - total_written_;
+ if (len > space_left) {
+ return false;
+ }
+
+ // Locate the iovec from which we need to start the copy.
+ const iovec* from_iov = curr_iov_;
+ size_t from_iov_offset = curr_iov_->iov_len - curr_iov_remaining_;
+ while (offset > 0) {
+ if (from_iov_offset >= offset) {
+ from_iov_offset -= offset;
+ break;
+ }
+
+ offset -= from_iov_offset;
+ --from_iov;
+#if !defined(NDEBUG)
+ assert(from_iov >= output_iov_);
+#endif // !defined(NDEBUG)
+ from_iov_offset = from_iov->iov_len;
+ }
+
+ // Copy <len> bytes starting from the iovec pointed to by from_iov_index to
+ // the current iovec.
+ while (len > 0) {
+ assert(from_iov <= curr_iov_);
+ if (from_iov != curr_iov_) {
+ const size_t to_copy =
+ std::min(from_iov->iov_len - from_iov_offset, len);
+ AppendNoCheck(GetIOVecPointer(from_iov, from_iov_offset), to_copy);
+ len -= to_copy;
+ if (len > 0) {
+ ++from_iov;
+ from_iov_offset = 0;
+ }
+ } else {
+ size_t to_copy = curr_iov_remaining_;
+ if (to_copy == 0) {
+ // This iovec is full. Go to the next one.
+ if (curr_iov_ + 1 >= output_iov_end_) {
+ return false;
+ }
+ ++curr_iov_;
+ curr_iov_output_ = reinterpret_cast<char*>(curr_iov_->iov_base);
+ curr_iov_remaining_ = curr_iov_->iov_len;
+ continue;
+ }
+ if (to_copy > len) {
+ to_copy = len;
+ }
+ assert(to_copy > 0);
+
+ IncrementalCopy(GetIOVecPointer(from_iov, from_iov_offset),
+ curr_iov_output_, curr_iov_output_ + to_copy,
+ curr_iov_output_ + curr_iov_remaining_);
+ curr_iov_output_ += to_copy;
+ curr_iov_remaining_ -= to_copy;
+ from_iov_offset += to_copy;
+ total_written_ += to_copy;
+ len -= to_copy;
+ }
+ }
+
+ return true;
+ }
+
+ inline void Flush() {}
+};
+
+bool RawUncompressToIOVec(const char* compressed, size_t compressed_length,
+ const struct iovec* iov, size_t iov_cnt) {
+ ByteArraySource reader(compressed, compressed_length);
+ return RawUncompressToIOVec(&reader, iov, iov_cnt);
+}
+
+bool RawUncompressToIOVec(Source* compressed, const struct iovec* iov,
+ size_t iov_cnt) {
+ SnappyIOVecWriter output(iov, iov_cnt);
+ return InternalUncompress(compressed, &output);
+}
+
+// -----------------------------------------------------------------------
+// Flat array interfaces
+// -----------------------------------------------------------------------
+
+// A type that writes to a flat array.
+// Note that this is not a "ByteSink", but a type that matches the
+// Writer template argument to SnappyDecompressor::DecompressAllTags().
+class SnappyArrayWriter {
+ private:
+ char* base_;
+ char* op_;
+ char* op_limit_;
+ // If op < op_limit_min_slop_ then it's safe to unconditionally write
+ // kSlopBytes starting at op.
+ char* op_limit_min_slop_;
+
+ public:
+ inline explicit SnappyArrayWriter(char* dst)
+ : base_(dst),
+ op_(dst),
+ op_limit_(dst),
+ op_limit_min_slop_(dst) {} // Safe default see invariant.
+
+ inline void SetExpectedLength(size_t len) {
+ op_limit_ = op_ + len;
+ // Prevent pointer from being past the buffer.
+ op_limit_min_slop_ = op_limit_ - std::min<size_t>(kSlopBytes - 1, len);
+ }
+
+ inline bool CheckLength() const { return op_ == op_limit_; }
+
+ char* GetOutputPtr() { return op_; }
+ char* GetBase(ptrdiff_t* op_limit_min_slop) {
+ *op_limit_min_slop = op_limit_min_slop_ - base_;
+ return base_;
+ }
+ void SetOutputPtr(char* op) { op_ = op; }
+
+ inline bool Append(const char* ip, size_t len, char** op_p) {
+ char* op = *op_p;
+ const size_t space_left = op_limit_ - op;
+ if (space_left < len) return false;
+ std::memcpy(op, ip, len);
+ *op_p = op + len;
+ return true;
+ }
+
+ inline bool TryFastAppend(const char* ip, size_t available, size_t len,
+ char** op_p) {
+ char* op = *op_p;
+ const size_t space_left = op_limit_ - op;
+ if (len <= 16 && available >= 16 + kMaximumTagLength && space_left >= 16) {
+ // Fast path, used for the majority (about 95%) of invocations.
+ UnalignedCopy128(ip, op);
+ *op_p = op + len;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ SNAPPY_ATTRIBUTE_ALWAYS_INLINE
+ inline bool AppendFromSelf(size_t offset, size_t len, char** op_p) {
+ assert(len > 0);
+ char* const op = *op_p;
+ assert(op >= base_);
+ char* const op_end = op + len;
+
+ // Check if we try to append from before the start of the buffer.
+ if (SNAPPY_PREDICT_FALSE(static_cast<size_t>(op - base_) < offset))
+ return false;
+
+ if (SNAPPY_PREDICT_FALSE((kSlopBytes < 64 && len > kSlopBytes) ||
+ op >= op_limit_min_slop_ || offset < len)) {
+ if (op_end > op_limit_ || offset == 0) return false;
+ *op_p = IncrementalCopy(op - offset, op, op_end, op_limit_);
+ return true;
+ }
+ std::memmove(op, op - offset, kSlopBytes);
+ *op_p = op_end;
+ return true;
+ }
+ inline size_t Produced() const {
+ assert(op_ >= base_);
+ return op_ - base_;
+ }
+ inline void Flush() {}
+};
+
+bool RawUncompress(const char* compressed, size_t compressed_length,
+ char* uncompressed) {
+ ByteArraySource reader(compressed, compressed_length);
+ return RawUncompress(&reader, uncompressed);
+}
+
+bool RawUncompress(Source* compressed, char* uncompressed) {
+ SnappyArrayWriter output(uncompressed);
+ return InternalUncompress(compressed, &output);
+}
+
+bool Uncompress(const char* compressed, size_t compressed_length,
+ std::string* uncompressed) {
+ size_t ulength;
+ if (!GetUncompressedLength(compressed, compressed_length, &ulength)) {
+ return false;
+ }
+ // On 32-bit builds: max_size() < kuint32max. Check for that instead
+ // of crashing (e.g., consider externally specified compressed data).
+ if (ulength > uncompressed->max_size()) {
+ return false;
+ }
+ STLStringResizeUninitialized(uncompressed, ulength);
+ return RawUncompress(compressed, compressed_length,
+ string_as_array(uncompressed));
+}
+
+// A Writer that drops everything on the floor and just does validation
+class SnappyDecompressionValidator {
+ private:
+ size_t expected_;
+ size_t produced_;
+
+ public:
+ inline SnappyDecompressionValidator() : expected_(0), produced_(0) {}
+ inline void SetExpectedLength(size_t len) { expected_ = len; }
+ size_t GetOutputPtr() { return produced_; }
+ size_t GetBase(ptrdiff_t* op_limit_min_slop) {
+ *op_limit_min_slop = std::numeric_limits<ptrdiff_t>::max() - kSlopBytes + 1;
+ return 1;
+ }
+ void SetOutputPtr(size_t op) { produced_ = op; }
+ inline bool CheckLength() const { return expected_ == produced_; }
+ inline bool Append(const char* ip, size_t len, size_t* produced) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)ip;
+
+ *produced += len;
+ return *produced <= expected_;
+ }
+ inline bool TryFastAppend(const char* ip, size_t available, size_t length,
+ size_t* produced) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)ip;
+ (void)available;
+ (void)length;
+ (void)produced;
+
+ return false;
+ }
+ inline bool AppendFromSelf(size_t offset, size_t len, size_t* produced) {
+ // See SnappyArrayWriter::AppendFromSelf for an explanation of
+ // the "offset - 1u" trick.
+ if (*produced <= offset - 1u) return false;
+ *produced += len;
+ return *produced <= expected_;
+ }
+ inline void Flush() {}
+};
+
+bool IsValidCompressedBuffer(const char* compressed, size_t compressed_length) {
+ ByteArraySource reader(compressed, compressed_length);
+ SnappyDecompressionValidator writer;
+ return InternalUncompress(&reader, &writer);
+}
+
+bool IsValidCompressed(Source* compressed) {
+ SnappyDecompressionValidator writer;
+ return InternalUncompress(compressed, &writer);
+}
+
+void RawCompress(const char* input, size_t input_length, char* compressed,
+ size_t* compressed_length) {
+ ByteArraySource reader(input, input_length);
+ UncheckedByteArraySink writer(compressed);
+ Compress(&reader, &writer);
+
+ // Compute how many bytes were added
+ *compressed_length = (writer.CurrentDestination() - compressed);
+}
+
+size_t Compress(const char* input, size_t input_length,
+ std::string* compressed) {
+ // Pre-grow the buffer to the max length of the compressed output
+ STLStringResizeUninitialized(compressed, MaxCompressedLength(input_length));
+
+ size_t compressed_length;
+ RawCompress(input, input_length, string_as_array(compressed),
+ &compressed_length);
+ compressed->resize(compressed_length);
+ return compressed_length;
+}
+
+// -----------------------------------------------------------------------
+// Sink interface
+// -----------------------------------------------------------------------
+
+// A type that decompresses into a Sink. The template parameter
+// Allocator must export one method "char* Allocate(int size);", which
+// allocates a buffer of "size" and appends that to the destination.
+template <typename Allocator>
+class SnappyScatteredWriter {
+ Allocator allocator_;
+
+ // We need random access into the data generated so far. Therefore
+ // we keep track of all of the generated data as an array of blocks.
+ // All of the blocks except the last have length kBlockSize.
+ std::vector<char*> blocks_;
+ size_t expected_;
+
+ // Total size of all fully generated blocks so far
+ size_t full_size_;
+
+ // Pointer into current output block
+ char* op_base_; // Base of output block
+ char* op_ptr_; // Pointer to next unfilled byte in block
+ char* op_limit_; // Pointer just past block
+ // If op < op_limit_min_slop_ then it's safe to unconditionally write
+ // kSlopBytes starting at op.
+ char* op_limit_min_slop_;
+
+ inline size_t Size() const { return full_size_ + (op_ptr_ - op_base_); }
+
+ bool SlowAppend(const char* ip, size_t len);
+ bool SlowAppendFromSelf(size_t offset, size_t len);
+
+ public:
+ inline explicit SnappyScatteredWriter(const Allocator& allocator)
+ : allocator_(allocator),
+ full_size_(0),
+ op_base_(NULL),
+ op_ptr_(NULL),
+ op_limit_(NULL),
+ op_limit_min_slop_(NULL) {}
+ char* GetOutputPtr() { return op_ptr_; }
+ char* GetBase(ptrdiff_t* op_limit_min_slop) {
+ *op_limit_min_slop = op_limit_min_slop_ - op_base_;
+ return op_base_;
+ }
+ void SetOutputPtr(char* op) { op_ptr_ = op; }
+
+ inline void SetExpectedLength(size_t len) {
+ assert(blocks_.empty());
+ expected_ = len;
+ }
+
+ inline bool CheckLength() const { return Size() == expected_; }
+
+ // Return the number of bytes actually uncompressed so far
+ inline size_t Produced() const { return Size(); }
+
+ inline bool Append(const char* ip, size_t len, char** op_p) {
+ char* op = *op_p;
+ size_t avail = op_limit_ - op;
+ if (len <= avail) {
+ // Fast path
+ std::memcpy(op, ip, len);
+ *op_p = op + len;
+ return true;
+ } else {
+ op_ptr_ = op;
+ bool res = SlowAppend(ip, len);
+ *op_p = op_ptr_;
+ return res;
+ }
+ }
+
+ inline bool TryFastAppend(const char* ip, size_t available, size_t length,
+ char** op_p) {
+ char* op = *op_p;
+ const int space_left = op_limit_ - op;
+ if (length <= 16 && available >= 16 + kMaximumTagLength &&
+ space_left >= 16) {
+ // Fast path, used for the majority (about 95%) of invocations.
+ UnalignedCopy128(ip, op);
+ *op_p = op + length;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ inline bool AppendFromSelf(size_t offset, size_t len, char** op_p) {
+ char* op = *op_p;
+ assert(op >= op_base_);
+ // Check if we try to append from before the start of the buffer.
+ if (SNAPPY_PREDICT_FALSE((kSlopBytes < 64 && len > kSlopBytes) ||
+ static_cast<size_t>(op - op_base_) < offset ||
+ op >= op_limit_min_slop_ || offset < len)) {
+ if (offset == 0) return false;
+ if (SNAPPY_PREDICT_FALSE(static_cast<size_t>(op - op_base_) < offset ||
+ op + len > op_limit_)) {
+ op_ptr_ = op;
+ bool res = SlowAppendFromSelf(offset, len);
+ *op_p = op_ptr_;
+ return res;
+ }
+ *op_p = IncrementalCopy(op - offset, op, op + len, op_limit_);
+ return true;
+ }
+ // Fast path
+ char* const op_end = op + len;
+ std::memmove(op, op - offset, kSlopBytes);
+ *op_p = op_end;
+ return true;
+ }
+
+ // Called at the end of the decompress. We ask the allocator
+ // write all blocks to the sink.
+ inline void Flush() { allocator_.Flush(Produced()); }
+};
+
+template <typename Allocator>
+bool SnappyScatteredWriter<Allocator>::SlowAppend(const char* ip, size_t len) {
+ size_t avail = op_limit_ - op_ptr_;
+ while (len > avail) {
+ // Completely fill this block
+ std::memcpy(op_ptr_, ip, avail);
+ op_ptr_ += avail;
+ assert(op_limit_ - op_ptr_ == 0);
+ full_size_ += (op_ptr_ - op_base_);
+ len -= avail;
+ ip += avail;
+
+ // Bounds check
+ if (full_size_ + len > expected_) return false;
+
+ // Make new block
+ size_t bsize = std::min<size_t>(kBlockSize, expected_ - full_size_);
+ op_base_ = allocator_.Allocate(bsize);
+ op_ptr_ = op_base_;
+ op_limit_ = op_base_ + bsize;
+ op_limit_min_slop_ = op_limit_ - std::min<size_t>(kSlopBytes - 1, bsize);
+
+ blocks_.push_back(op_base_);
+ avail = bsize;
+ }
+
+ std::memcpy(op_ptr_, ip, len);
+ op_ptr_ += len;
+ return true;
+}
+
+template <typename Allocator>
+bool SnappyScatteredWriter<Allocator>::SlowAppendFromSelf(size_t offset,
+ size_t len) {
+ // Overflow check
+ // See SnappyArrayWriter::AppendFromSelf for an explanation of
+ // the "offset - 1u" trick.
+ const size_t cur = Size();
+ if (offset - 1u >= cur) return false;
+ if (expected_ - cur < len) return false;
+
+ // Currently we shouldn't ever hit this path because Compress() chops the
+ // input into blocks and does not create cross-block copies. However, it is
+ // nice if we do not rely on that, since we can get better compression if we
+ // allow cross-block copies and thus might want to change the compressor in
+ // the future.
+ // TODO Replace this with a properly optimized path. This is not
+ // triggered right now. But this is so super slow, that it would regress
+ // performance unacceptably if triggered.
+ size_t src = cur - offset;
+ char* op = op_ptr_;
+ while (len-- > 0) {
+ char c = blocks_[src >> kBlockLog][src & (kBlockSize - 1)];
+ if (!Append(&c, 1, &op)) {
+ op_ptr_ = op;
+ return false;
+ }
+ src++;
+ }
+ op_ptr_ = op;
+ return true;
+}
+
+class SnappySinkAllocator {
+ public:
+ explicit SnappySinkAllocator(Sink* dest) : dest_(dest) {}
+ ~SnappySinkAllocator() {}
+
+ char* Allocate(int size) {
+ Datablock block(new char[size], size);
+ blocks_.push_back(block);
+ return block.data;
+ }
+
+ // We flush only at the end, because the writer wants
+ // random access to the blocks and once we hand the
+ // block over to the sink, we can't access it anymore.
+ // Also we don't write more than has been actually written
+ // to the blocks.
+ void Flush(size_t size) {
+ size_t size_written = 0;
+ for (Datablock& block : blocks_) {
+ size_t block_size = std::min<size_t>(block.size, size - size_written);
+ dest_->AppendAndTakeOwnership(block.data, block_size,
+ &SnappySinkAllocator::Deleter, NULL);
+ size_written += block_size;
+ }
+ blocks_.clear();
+ }
+
+ private:
+ struct Datablock {
+ char* data;
+ size_t size;
+ Datablock(char* p, size_t s) : data(p), size(s) {}
+ };
+
+ static void Deleter(void* arg, const char* bytes, size_t size) {
+ // TODO: Switch to [[maybe_unused]] when we can assume C++17.
+ (void)arg;
+ (void)size;
+
+ delete[] bytes;
+ }
+
+ Sink* dest_;
+ std::vector<Datablock> blocks_;
+
+ // Note: copying this object is allowed
+};
+
+size_t UncompressAsMuchAsPossible(Source* compressed, Sink* uncompressed) {
+ SnappySinkAllocator allocator(uncompressed);
+ SnappyScatteredWriter<SnappySinkAllocator> writer(allocator);
+ InternalUncompress(compressed, &writer);
+ return writer.Produced();
+}
+
+bool Uncompress(Source* compressed, Sink* uncompressed) {
+ // Read the uncompressed length from the front of the compressed input
+ SnappyDecompressor decompressor(compressed);
+ uint32_t uncompressed_len = 0;
+ if (!decompressor.ReadUncompressedLength(&uncompressed_len)) {
+ return false;
+ }
+
+ char c;
+ size_t allocated_size;
+ char* buf = uncompressed->GetAppendBufferVariable(1, uncompressed_len, &c, 1,
+ &allocated_size);
+
+ const size_t compressed_len = compressed->Available();
+ // If we can get a flat buffer, then use it, otherwise do block by block
+ // uncompression
+ if (allocated_size >= uncompressed_len) {
+ SnappyArrayWriter writer(buf);
+ bool result = InternalUncompressAllTags(&decompressor, &writer,
+ compressed_len, uncompressed_len);
+ uncompressed->Append(buf, writer.Produced());
+ return result;
+ } else {
+ SnappySinkAllocator allocator(uncompressed);
+ SnappyScatteredWriter<SnappySinkAllocator> writer(allocator);
+ return InternalUncompressAllTags(&decompressor, &writer, compressed_len,
+ uncompressed_len);
+ }
+}
+
+} // namespace snappy
diff --git a/other-licenses/snappy/src/snappy.h b/other-licenses/snappy/src/snappy.h
new file mode 100644
index 0000000000..e4fdad3354
--- /dev/null
+++ b/other-licenses/snappy/src/snappy.h
@@ -0,0 +1,209 @@
+// Copyright 2005 and onwards Google Inc.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// A light-weight compression algorithm. It is designed for speed of
+// compression and decompression, rather than for the utmost in space
+// savings.
+//
+// For getting better compression ratios when you are compressing data
+// with long repeated sequences or compressing data that is similar to
+// other data, while still compressing fast, you might look at first
+// using BMDiff and then compressing the output of BMDiff with
+// Snappy.
+
+#ifndef THIRD_PARTY_SNAPPY_SNAPPY_H__
+#define THIRD_PARTY_SNAPPY_SNAPPY_H__
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <string>
+
+#include "snappy-stubs-public.h"
+
+namespace snappy {
+ class Source;
+ class Sink;
+
+ // ------------------------------------------------------------------------
+ // Generic compression/decompression routines.
+ // ------------------------------------------------------------------------
+
+ // Compress the bytes read from "*source" and append to "*sink". Return the
+ // number of bytes written.
+ size_t Compress(Source* source, Sink* sink);
+
+ // Find the uncompressed length of the given stream, as given by the header.
+ // Note that the true length could deviate from this; the stream could e.g.
+ // be truncated.
+ //
+ // Also note that this leaves "*source" in a state that is unsuitable for
+ // further operations, such as RawUncompress(). You will need to rewind
+ // or recreate the source yourself before attempting any further calls.
+ bool GetUncompressedLength(Source* source, uint32_t* result);
+
+ // ------------------------------------------------------------------------
+ // Higher-level string based routines (should be sufficient for most users)
+ // ------------------------------------------------------------------------
+
+ // Sets "*compressed" to the compressed version of "input[0,input_length-1]".
+ // Original contents of *compressed are lost.
+ //
+ // REQUIRES: "input[]" is not an alias of "*compressed".
+ size_t Compress(const char* input, size_t input_length,
+ std::string* compressed);
+
+ // Decompresses "compressed[0,compressed_length-1]" to "*uncompressed".
+ // Original contents of "*uncompressed" are lost.
+ //
+ // REQUIRES: "compressed[]" is not an alias of "*uncompressed".
+ //
+ // returns false if the message is corrupted and could not be decompressed
+ bool Uncompress(const char* compressed, size_t compressed_length,
+ std::string* uncompressed);
+
+ // Decompresses "compressed" to "*uncompressed".
+ //
+ // returns false if the message is corrupted and could not be decompressed
+ bool Uncompress(Source* compressed, Sink* uncompressed);
+
+ // This routine uncompresses as much of the "compressed" as possible
+ // into sink. It returns the number of valid bytes added to sink
+ // (extra invalid bytes may have been added due to errors; the caller
+ // should ignore those). The emitted data typically has length
+ // GetUncompressedLength(), but may be shorter if an error is
+ // encountered.
+ size_t UncompressAsMuchAsPossible(Source* compressed, Sink* uncompressed);
+
+ // ------------------------------------------------------------------------
+ // Lower-level character array based routines. May be useful for
+ // efficiency reasons in certain circumstances.
+ // ------------------------------------------------------------------------
+
+ // REQUIRES: "compressed" must point to an area of memory that is at
+ // least "MaxCompressedLength(input_length)" bytes in length.
+ //
+ // Takes the data stored in "input[0..input_length]" and stores
+ // it in the array pointed to by "compressed".
+ //
+ // "*compressed_length" is set to the length of the compressed output.
+ //
+ // Example:
+ // char* output = new char[snappy::MaxCompressedLength(input_length)];
+ // size_t output_length;
+ // RawCompress(input, input_length, output, &output_length);
+ // ... Process(output, output_length) ...
+ // delete [] output;
+ void RawCompress(const char* input,
+ size_t input_length,
+ char* compressed,
+ size_t* compressed_length);
+
+ // Given data in "compressed[0..compressed_length-1]" generated by
+ // calling the Snappy::Compress routine, this routine
+ // stores the uncompressed data to
+ // uncompressed[0..GetUncompressedLength(compressed)-1]
+ // returns false if the message is corrupted and could not be decrypted
+ bool RawUncompress(const char* compressed, size_t compressed_length,
+ char* uncompressed);
+
+ // Given data from the byte source 'compressed' generated by calling
+ // the Snappy::Compress routine, this routine stores the uncompressed
+ // data to
+ // uncompressed[0..GetUncompressedLength(compressed,compressed_length)-1]
+ // returns false if the message is corrupted and could not be decrypted
+ bool RawUncompress(Source* compressed, char* uncompressed);
+
+ // Given data in "compressed[0..compressed_length-1]" generated by
+ // calling the Snappy::Compress routine, this routine
+ // stores the uncompressed data to the iovec "iov". The number of physical
+ // buffers in "iov" is given by iov_cnt and their cumulative size
+ // must be at least GetUncompressedLength(compressed). The individual buffers
+ // in "iov" must not overlap with each other.
+ //
+ // returns false if the message is corrupted and could not be decrypted
+ bool RawUncompressToIOVec(const char* compressed, size_t compressed_length,
+ const struct iovec* iov, size_t iov_cnt);
+
+ // Given data from the byte source 'compressed' generated by calling
+ // the Snappy::Compress routine, this routine stores the uncompressed
+ // data to the iovec "iov". The number of physical
+ // buffers in "iov" is given by iov_cnt and their cumulative size
+ // must be at least GetUncompressedLength(compressed). The individual buffers
+ // in "iov" must not overlap with each other.
+ //
+ // returns false if the message is corrupted and could not be decrypted
+ bool RawUncompressToIOVec(Source* compressed, const struct iovec* iov,
+ size_t iov_cnt);
+
+ // Returns the maximal size of the compressed representation of
+ // input data that is "source_bytes" bytes in length;
+ size_t MaxCompressedLength(size_t source_bytes);
+
+ // REQUIRES: "compressed[]" was produced by RawCompress() or Compress()
+ // Returns true and stores the length of the uncompressed data in
+ // *result normally. Returns false on parsing error.
+ // This operation takes O(1) time.
+ bool GetUncompressedLength(const char* compressed, size_t compressed_length,
+ size_t* result);
+
+ // Returns true iff the contents of "compressed[]" can be uncompressed
+ // successfully. Does not return the uncompressed data. Takes
+ // time proportional to compressed_length, but is usually at least
+ // a factor of four faster than actual decompression.
+ bool IsValidCompressedBuffer(const char* compressed,
+ size_t compressed_length);
+
+ // Returns true iff the contents of "compressed" can be uncompressed
+ // successfully. Does not return the uncompressed data. Takes
+ // time proportional to *compressed length, but is usually at least
+ // a factor of four faster than actual decompression.
+ // On success, consumes all of *compressed. On failure, consumes an
+ // unspecified prefix of *compressed.
+ bool IsValidCompressed(Source* compressed);
+
+ // The size of a compression block. Note that many parts of the compression
+ // code assumes that kBlockSize <= 65536; in particular, the hash table
+ // can only store 16-bit offsets, and EmitCopy() also assumes the offset
+ // is 65535 bytes or less. Note also that if you change this, it will
+ // affect the framing format (see framing_format.txt).
+ //
+ // Note that there might be older data around that is compressed with larger
+ // block sizes, so the decompression code should not rely on the
+ // non-existence of long backreferences.
+ static constexpr int kBlockLog = 16;
+ static constexpr size_t kBlockSize = 1 << kBlockLog;
+
+ static constexpr int kMinHashTableBits = 8;
+ static constexpr size_t kMinHashTableSize = 1 << kMinHashTableBits;
+
+ static constexpr int kMaxHashTableBits = 14;
+ static constexpr size_t kMaxHashTableSize = 1 << kMaxHashTableBits;
+} // end namespace snappy
+
+#endif // THIRD_PARTY_SNAPPY_SNAPPY_H__
diff --git a/other-licenses/snappy/src/snappy_compress_fuzzer.cc b/other-licenses/snappy/src/snappy_compress_fuzzer.cc
new file mode 100644
index 0000000000..1d4429a8c1
--- /dev/null
+++ b/other-licenses/snappy/src/snappy_compress_fuzzer.cc
@@ -0,0 +1,60 @@
+// Copyright 2019 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// libFuzzer harness for fuzzing snappy compression code.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <cassert>
+#include <string>
+
+#include "snappy.h"
+
+// Entry point for LibFuzzer.
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ std::string input(reinterpret_cast<const char*>(data), size);
+
+ std::string compressed;
+ size_t compressed_size =
+ snappy::Compress(input.data(), input.size(), &compressed);
+
+ (void)compressed_size; // Variable only used in debug builds.
+ assert(compressed_size == compressed.size());
+ assert(compressed.size() <= snappy::MaxCompressedLength(input.size()));
+ assert(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
+
+ std::string uncompressed_after_compress;
+ bool uncompress_succeeded = snappy::Uncompress(
+ compressed.data(), compressed.size(), &uncompressed_after_compress);
+
+ (void)uncompress_succeeded; // Variable only used in debug builds.
+ assert(uncompress_succeeded);
+ assert(input == uncompressed_after_compress);
+ return 0;
+}
diff --git a/other-licenses/snappy/src/snappy_uncompress_fuzzer.cc b/other-licenses/snappy/src/snappy_uncompress_fuzzer.cc
new file mode 100644
index 0000000000..385bfb5a33
--- /dev/null
+++ b/other-licenses/snappy/src/snappy_uncompress_fuzzer.cc
@@ -0,0 +1,58 @@
+// Copyright 2019 Google Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// libFuzzer harness for fuzzing snappy's decompression code.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <cassert>
+#include <string>
+
+#include "snappy.h"
+
+// Entry point for LibFuzzer.
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ std::string input(reinterpret_cast<const char*>(data), size);
+
+ // Avoid self-crafted decompression bombs.
+ size_t uncompressed_size;
+ constexpr size_t kMaxUncompressedSize = 1 << 20;
+ bool get_uncompressed_length_succeeded = snappy::GetUncompressedLength(
+ input.data(), input.size(), &uncompressed_size);
+ if (!get_uncompressed_length_succeeded ||
+ (uncompressed_size > kMaxUncompressedSize)) {
+ return 0;
+ }
+
+ std::string uncompressed;
+ // The return value of snappy::Uncompress() is ignored because decompression
+ // will fail on invalid inputs.
+ snappy::Uncompress(input.data(), input.size(), &uncompressed);
+ return 0;
+}
diff --git a/other-licenses/snappy/src/snappy_unittest.cc b/other-licenses/snappy/src/snappy_unittest.cc
new file mode 100644
index 0000000000..7a85635d73
--- /dev/null
+++ b/other-licenses/snappy/src/snappy_unittest.cc
@@ -0,0 +1,966 @@
+// Copyright 2005 and onwards Google Inc.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <algorithm>
+#include <cmath>
+#include <cstdlib>
+#include <random>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "snappy-test.h"
+
+#include "gtest/gtest.h"
+
+#include "snappy-internal.h"
+#include "snappy-sinksource.h"
+#include "snappy.h"
+#include "snappy_test_data.h"
+
+SNAPPY_FLAG(bool, snappy_dump_decompression_table, false,
+ "If true, we print the decompression table during tests.");
+
+namespace snappy {
+
+namespace {
+
+#if defined(HAVE_FUNC_MMAP) && defined(HAVE_FUNC_SYSCONF)
+
+// To test against code that reads beyond its input, this class copies a
+// string to a newly allocated group of pages, the last of which
+// is made unreadable via mprotect. Note that we need to allocate the
+// memory with mmap(), as POSIX allows mprotect() only on memory allocated
+// with mmap(), and some malloc/posix_memalign implementations expect to
+// be able to read previously allocated memory while doing heap allocations.
+class DataEndingAtUnreadablePage {
+ public:
+ explicit DataEndingAtUnreadablePage(const std::string& s) {
+ const size_t page_size = sysconf(_SC_PAGESIZE);
+ const size_t size = s.size();
+ // Round up space for string to a multiple of page_size.
+ size_t space_for_string = (size + page_size - 1) & ~(page_size - 1);
+ alloc_size_ = space_for_string + page_size;
+ mem_ = mmap(NULL, alloc_size_,
+ PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ CHECK_NE(MAP_FAILED, mem_);
+ protected_page_ = reinterpret_cast<char*>(mem_) + space_for_string;
+ char* dst = protected_page_ - size;
+ std::memcpy(dst, s.data(), size);
+ data_ = dst;
+ size_ = size;
+ // Make guard page unreadable.
+ CHECK_EQ(0, mprotect(protected_page_, page_size, PROT_NONE));
+ }
+
+ ~DataEndingAtUnreadablePage() {
+ const size_t page_size = sysconf(_SC_PAGESIZE);
+ // Undo the mprotect.
+ CHECK_EQ(0, mprotect(protected_page_, page_size, PROT_READ|PROT_WRITE));
+ CHECK_EQ(0, munmap(mem_, alloc_size_));
+ }
+
+ const char* data() const { return data_; }
+ size_t size() const { return size_; }
+
+ private:
+ size_t alloc_size_;
+ void* mem_;
+ char* protected_page_;
+ const char* data_;
+ size_t size_;
+};
+
+#else // defined(HAVE_FUNC_MMAP) && defined(HAVE_FUNC_SYSCONF)
+
+// Fallback for systems without mmap.
+using DataEndingAtUnreadablePage = std::string;
+
+#endif
+
+int VerifyString(const std::string& input) {
+ std::string compressed;
+ DataEndingAtUnreadablePage i(input);
+ const size_t written = snappy::Compress(i.data(), i.size(), &compressed);
+ CHECK_EQ(written, compressed.size());
+ CHECK_LE(compressed.size(),
+ snappy::MaxCompressedLength(input.size()));
+ CHECK(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
+
+ std::string uncompressed;
+ DataEndingAtUnreadablePage c(compressed);
+ CHECK(snappy::Uncompress(c.data(), c.size(), &uncompressed));
+ CHECK_EQ(uncompressed, input);
+ return uncompressed.size();
+}
+
+void VerifyStringSink(const std::string& input) {
+ std::string compressed;
+ DataEndingAtUnreadablePage i(input);
+ const size_t written = snappy::Compress(i.data(), i.size(), &compressed);
+ CHECK_EQ(written, compressed.size());
+ CHECK_LE(compressed.size(),
+ snappy::MaxCompressedLength(input.size()));
+ CHECK(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
+
+ std::string uncompressed;
+ uncompressed.resize(input.size());
+ snappy::UncheckedByteArraySink sink(string_as_array(&uncompressed));
+ DataEndingAtUnreadablePage c(compressed);
+ snappy::ByteArraySource source(c.data(), c.size());
+ CHECK(snappy::Uncompress(&source, &sink));
+ CHECK_EQ(uncompressed, input);
+}
+
+void VerifyIOVec(const std::string& input) {
+ std::string compressed;
+ DataEndingAtUnreadablePage i(input);
+ const size_t written = snappy::Compress(i.data(), i.size(), &compressed);
+ CHECK_EQ(written, compressed.size());
+ CHECK_LE(compressed.size(),
+ snappy::MaxCompressedLength(input.size()));
+ CHECK(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
+
+ // Try uncompressing into an iovec containing a random number of entries
+ // ranging from 1 to 10.
+ char* buf = new char[input.size()];
+ std::minstd_rand0 rng(input.size());
+ std::uniform_int_distribution<size_t> uniform_1_to_10(1, 10);
+ size_t num = uniform_1_to_10(rng);
+ if (input.size() < num) {
+ num = input.size();
+ }
+ struct iovec* iov = new iovec[num];
+ size_t used_so_far = 0;
+ std::bernoulli_distribution one_in_five(1.0 / 5);
+ for (size_t i = 0; i < num; ++i) {
+ assert(used_so_far < input.size());
+ iov[i].iov_base = buf + used_so_far;
+ if (i == num - 1) {
+ iov[i].iov_len = input.size() - used_so_far;
+ } else {
+ // Randomly choose to insert a 0 byte entry.
+ if (one_in_five(rng)) {
+ iov[i].iov_len = 0;
+ } else {
+ std::uniform_int_distribution<size_t> uniform_not_used_so_far(
+ 0, input.size() - used_so_far - 1);
+ iov[i].iov_len = uniform_not_used_so_far(rng);
+ }
+ }
+ used_so_far += iov[i].iov_len;
+ }
+ CHECK(snappy::RawUncompressToIOVec(
+ compressed.data(), compressed.size(), iov, num));
+ CHECK(!memcmp(buf, input.data(), input.size()));
+ delete[] iov;
+ delete[] buf;
+}
+
+// Test that data compressed by a compressor that does not
+// obey block sizes is uncompressed properly.
+void VerifyNonBlockedCompression(const std::string& input) {
+ if (input.length() > snappy::kBlockSize) {
+ // We cannot test larger blocks than the maximum block size, obviously.
+ return;
+ }
+
+ std::string prefix;
+ Varint::Append32(&prefix, input.size());
+
+ // Setup compression table
+ snappy::internal::WorkingMemory wmem(input.size());
+ int table_size;
+ uint16_t* table = wmem.GetHashTable(input.size(), &table_size);
+
+ // Compress entire input in one shot
+ std::string compressed;
+ compressed += prefix;
+ compressed.resize(prefix.size()+snappy::MaxCompressedLength(input.size()));
+ char* dest = string_as_array(&compressed) + prefix.size();
+ char* end = snappy::internal::CompressFragment(input.data(), input.size(),
+ dest, table, table_size);
+ compressed.resize(end - compressed.data());
+
+ // Uncompress into std::string
+ std::string uncomp_str;
+ CHECK(snappy::Uncompress(compressed.data(), compressed.size(), &uncomp_str));
+ CHECK_EQ(uncomp_str, input);
+
+ // Uncompress using source/sink
+ std::string uncomp_str2;
+ uncomp_str2.resize(input.size());
+ snappy::UncheckedByteArraySink sink(string_as_array(&uncomp_str2));
+ snappy::ByteArraySource source(compressed.data(), compressed.size());
+ CHECK(snappy::Uncompress(&source, &sink));
+ CHECK_EQ(uncomp_str2, input);
+
+ // Uncompress into iovec
+ {
+ static const int kNumBlocks = 10;
+ struct iovec vec[kNumBlocks];
+ const int block_size = 1 + input.size() / kNumBlocks;
+ std::string iovec_data(block_size * kNumBlocks, 'x');
+ for (int i = 0; i < kNumBlocks; ++i) {
+ vec[i].iov_base = string_as_array(&iovec_data) + i * block_size;
+ vec[i].iov_len = block_size;
+ }
+ CHECK(snappy::RawUncompressToIOVec(compressed.data(), compressed.size(),
+ vec, kNumBlocks));
+ CHECK_EQ(std::string(iovec_data.data(), input.size()), input);
+ }
+}
+
+// Expand the input so that it is at least K times as big as block size
+std::string Expand(const std::string& input) {
+ static const int K = 3;
+ std::string data = input;
+ while (data.size() < K * snappy::kBlockSize) {
+ data += input;
+ }
+ return data;
+}
+
+int Verify(const std::string& input) {
+ VLOG(1) << "Verifying input of size " << input.size();
+
+ // Compress using string based routines
+ const int result = VerifyString(input);
+
+ // Verify using sink based routines
+ VerifyStringSink(input);
+
+ VerifyNonBlockedCompression(input);
+ VerifyIOVec(input);
+ if (!input.empty()) {
+ const std::string expanded = Expand(input);
+ VerifyNonBlockedCompression(expanded);
+ VerifyIOVec(input);
+ }
+
+ return result;
+}
+
+bool IsValidCompressedBuffer(const std::string& c) {
+ return snappy::IsValidCompressedBuffer(c.data(), c.size());
+}
+bool Uncompress(const std::string& c, std::string* u) {
+ return snappy::Uncompress(c.data(), c.size(), u);
+}
+
+// This test checks to ensure that snappy doesn't coredump if it gets
+// corrupted data.
+TEST(CorruptedTest, VerifyCorrupted) {
+ std::string source = "making sure we don't crash with corrupted input";
+ VLOG(1) << source;
+ std::string dest;
+ std::string uncmp;
+ snappy::Compress(source.data(), source.size(), &dest);
+
+ // Mess around with the data. It's hard to simulate all possible
+ // corruptions; this is just one example ...
+ CHECK_GT(dest.size(), 3);
+ dest[1]--;
+ dest[3]++;
+ // this really ought to fail.
+ CHECK(!IsValidCompressedBuffer(dest));
+ CHECK(!Uncompress(dest, &uncmp));
+
+ // This is testing for a security bug - a buffer that decompresses to 100k
+ // but we lie in the snappy header and only reserve 0 bytes of memory :)
+ source.resize(100000);
+ for (char& source_char : source) {
+ source_char = 'A';
+ }
+ snappy::Compress(source.data(), source.size(), &dest);
+ dest[0] = dest[1] = dest[2] = dest[3] = 0;
+ CHECK(!IsValidCompressedBuffer(dest));
+ CHECK(!Uncompress(dest, &uncmp));
+
+ if (sizeof(void *) == 4) {
+ // Another security check; check a crazy big length can't DoS us with an
+ // over-allocation.
+ // Currently this is done only for 32-bit builds. On 64-bit builds,
+ // where 3 GB might be an acceptable allocation size, Uncompress()
+ // attempts to decompress, and sometimes causes the test to run out of
+ // memory.
+ dest[0] = dest[1] = dest[2] = dest[3] = '\xff';
+ // This decodes to a really large size, i.e., about 3 GB.
+ dest[4] = 'k';
+ CHECK(!IsValidCompressedBuffer(dest));
+ CHECK(!Uncompress(dest, &uncmp));
+ } else {
+ LOG(WARNING) << "Crazy decompression lengths not checked on 64-bit build";
+ }
+
+ // This decodes to about 2 MB; much smaller, but should still fail.
+ dest[0] = dest[1] = dest[2] = '\xff';
+ dest[3] = 0x00;
+ CHECK(!IsValidCompressedBuffer(dest));
+ CHECK(!Uncompress(dest, &uncmp));
+
+ // try reading stuff in from a bad file.
+ for (int i = 1; i <= 3; ++i) {
+ std::string data =
+ ReadTestDataFile(StrFormat("baddata%d.snappy", i).c_str(), 0);
+ std::string uncmp;
+ // check that we don't return a crazy length
+ size_t ulen;
+ CHECK(!snappy::GetUncompressedLength(data.data(), data.size(), &ulen)
+ || (ulen < (1<<20)));
+ uint32_t ulen2;
+ snappy::ByteArraySource source(data.data(), data.size());
+ CHECK(!snappy::GetUncompressedLength(&source, &ulen2) ||
+ (ulen2 < (1<<20)));
+ CHECK(!IsValidCompressedBuffer(data));
+ CHECK(!Uncompress(data, &uncmp));
+ }
+}
+
+// Helper routines to construct arbitrary compressed strings.
+// These mirror the compression code in snappy.cc, but are copied
+// here so that we can bypass some limitations in the how snappy.cc
+// invokes these routines.
+void AppendLiteral(std::string* dst, const std::string& literal) {
+ if (literal.empty()) return;
+ int n = literal.size() - 1;
+ if (n < 60) {
+ // Fit length in tag byte
+ dst->push_back(0 | (n << 2));
+ } else {
+ // Encode in upcoming bytes
+ char number[4];
+ int count = 0;
+ while (n > 0) {
+ number[count++] = n & 0xff;
+ n >>= 8;
+ }
+ dst->push_back(0 | ((59+count) << 2));
+ *dst += std::string(number, count);
+ }
+ *dst += literal;
+}
+
+void AppendCopy(std::string* dst, int offset, int length) {
+ while (length > 0) {
+ // Figure out how much to copy in one shot
+ int to_copy;
+ if (length >= 68) {
+ to_copy = 64;
+ } else if (length > 64) {
+ to_copy = 60;
+ } else {
+ to_copy = length;
+ }
+ length -= to_copy;
+
+ if ((to_copy >= 4) && (to_copy < 12) && (offset < 2048)) {
+ assert(to_copy-4 < 8); // Must fit in 3 bits
+ dst->push_back(1 | ((to_copy-4) << 2) | ((offset >> 8) << 5));
+ dst->push_back(offset & 0xff);
+ } else if (offset < 65536) {
+ dst->push_back(2 | ((to_copy-1) << 2));
+ dst->push_back(offset & 0xff);
+ dst->push_back(offset >> 8);
+ } else {
+ dst->push_back(3 | ((to_copy-1) << 2));
+ dst->push_back(offset & 0xff);
+ dst->push_back((offset >> 8) & 0xff);
+ dst->push_back((offset >> 16) & 0xff);
+ dst->push_back((offset >> 24) & 0xff);
+ }
+ }
+}
+
+TEST(Snappy, SimpleTests) {
+ Verify("");
+ Verify("a");
+ Verify("ab");
+ Verify("abc");
+
+ Verify("aaaaaaa" + std::string(16, 'b') + std::string("aaaaa") + "abc");
+ Verify("aaaaaaa" + std::string(256, 'b') + std::string("aaaaa") + "abc");
+ Verify("aaaaaaa" + std::string(2047, 'b') + std::string("aaaaa") + "abc");
+ Verify("aaaaaaa" + std::string(65536, 'b') + std::string("aaaaa") + "abc");
+ Verify("abcaaaaaaa" + std::string(65536, 'b') + std::string("aaaaa") + "abc");
+}
+
+// Regression test for cr/345340892.
+TEST(Snappy, AppendSelfPatternExtensionEdgeCases) {
+ Verify("abcabcabcabcabcabcab");
+ Verify("abcabcabcabcabcabcab0123456789ABCDEF");
+
+ Verify("abcabcabcabcabcabcabcabcabcabcabcabc");
+ Verify("abcabcabcabcabcabcabcabcabcabcabcabc0123456789ABCDEF");
+}
+
+// Regression test for cr/345340892.
+TEST(Snappy, AppendSelfPatternExtensionEdgeCasesExhaustive) {
+ std::mt19937 rng;
+ std::uniform_int_distribution<int> uniform_byte(0, 255);
+ for (int pattern_size = 1; pattern_size <= 18; ++pattern_size) {
+ for (int length = 1; length <= 64; ++length) {
+ for (int extra_bytes_after_pattern : {0, 1, 15, 16, 128}) {
+ const int size = pattern_size + length + extra_bytes_after_pattern;
+ std::string input;
+ input.resize(size);
+ for (int i = 0; i < pattern_size; ++i) {
+ input[i] = 'a' + i;
+ }
+ for (int i = 0; i < length; ++i) {
+ input[pattern_size + i] = input[i];
+ }
+ for (int i = 0; i < extra_bytes_after_pattern; ++i) {
+ input[pattern_size + length + i] =
+ static_cast<char>(uniform_byte(rng));
+ }
+ Verify(input);
+ }
+ }
+ }
+}
+
+// Verify max blowup (lots of four-byte copies)
+TEST(Snappy, MaxBlowup) {
+ std::mt19937 rng;
+ std::uniform_int_distribution<int> uniform_byte(0, 255);
+ std::string input;
+ for (int i = 0; i < 80000; ++i)
+ input.push_back(static_cast<char>(uniform_byte(rng)));
+
+ for (int i = 0; i < 80000; i += 4) {
+ std::string four_bytes(input.end() - i - 4, input.end() - i);
+ input.append(four_bytes);
+ }
+ Verify(input);
+}
+
+TEST(Snappy, RandomData) {
+ std::minstd_rand0 rng(snappy::GetFlag(FLAGS_test_random_seed));
+ std::uniform_int_distribution<int> uniform_0_to_3(0, 3);
+ std::uniform_int_distribution<int> uniform_0_to_8(0, 8);
+ std::uniform_int_distribution<int> uniform_byte(0, 255);
+ std::uniform_int_distribution<size_t> uniform_4k(0, 4095);
+ std::uniform_int_distribution<size_t> uniform_64k(0, 65535);
+ std::bernoulli_distribution one_in_ten(1.0 / 10);
+
+ constexpr int num_ops = 20000;
+ for (int i = 0; i < num_ops; ++i) {
+ if ((i % 1000) == 0) {
+ VLOG(0) << "Random op " << i << " of " << num_ops;
+ }
+
+ std::string x;
+ size_t len = uniform_4k(rng);
+ if (i < 100) {
+ len = 65536 + uniform_64k(rng);
+ }
+ while (x.size() < len) {
+ int run_len = 1;
+ if (one_in_ten(rng)) {
+ int skewed_bits = uniform_0_to_8(rng);
+ // int is guaranteed to hold at least 16 bits, this uses at most 8 bits.
+ std::uniform_int_distribution<int> skewed_low(0,
+ (1 << skewed_bits) - 1);
+ run_len = skewed_low(rng);
+ }
+ char c = static_cast<char>(uniform_byte(rng));
+ if (i >= 100) {
+ int skewed_bits = uniform_0_to_3(rng);
+ // int is guaranteed to hold at least 16 bits, this uses at most 3 bits.
+ std::uniform_int_distribution<int> skewed_low(0,
+ (1 << skewed_bits) - 1);
+ c = static_cast<char>(skewed_low(rng));
+ }
+ while (run_len-- > 0 && x.size() < len) {
+ x.push_back(c);
+ }
+ }
+
+ Verify(x);
+ }
+}
+
+TEST(Snappy, FourByteOffset) {
+ // The new compressor cannot generate four-byte offsets since
+ // it chops up the input into 32KB pieces. So we hand-emit the
+ // copy manually.
+
+ // The two fragments that make up the input string.
+ std::string fragment1 = "012345689abcdefghijklmnopqrstuvwxyz";
+ std::string fragment2 = "some other string";
+
+ // How many times each fragment is emitted.
+ const int n1 = 2;
+ const int n2 = 100000 / fragment2.size();
+ const size_t length = n1 * fragment1.size() + n2 * fragment2.size();
+
+ std::string compressed;
+ Varint::Append32(&compressed, length);
+
+ AppendLiteral(&compressed, fragment1);
+ std::string src = fragment1;
+ for (int i = 0; i < n2; ++i) {
+ AppendLiteral(&compressed, fragment2);
+ src += fragment2;
+ }
+ AppendCopy(&compressed, src.size(), fragment1.size());
+ src += fragment1;
+ CHECK_EQ(length, src.size());
+
+ std::string uncompressed;
+ CHECK(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
+ CHECK(snappy::Uncompress(compressed.data(), compressed.size(),
+ &uncompressed));
+ CHECK_EQ(uncompressed, src);
+}
+
+TEST(Snappy, IOVecEdgeCases) {
+ // Test some tricky edge cases in the iovec output that are not necessarily
+ // exercised by random tests.
+
+ // Our output blocks look like this initially (the last iovec is bigger
+ // than depicted):
+ // [ ] [ ] [ ] [ ] [ ]
+ static const int kLengths[] = { 2, 1, 4, 8, 128 };
+
+ struct iovec iov[ARRAYSIZE(kLengths)];
+ for (int i = 0; i < ARRAYSIZE(kLengths); ++i) {
+ iov[i].iov_base = new char[kLengths[i]];
+ iov[i].iov_len = kLengths[i];
+ }
+
+ std::string compressed;
+ Varint::Append32(&compressed, 22);
+
+ // A literal whose output crosses three blocks.
+ // [ab] [c] [123 ] [ ] [ ]
+ AppendLiteral(&compressed, "abc123");
+
+ // A copy whose output crosses two blocks (source and destination
+ // segments marked).
+ // [ab] [c] [1231] [23 ] [ ]
+ // ^--^ --
+ AppendCopy(&compressed, 3, 3);
+
+ // A copy where the input is, at first, in the block before the output:
+ //
+ // [ab] [c] [1231] [231231 ] [ ]
+ // ^--- ^---
+ // Then during the copy, the pointers move such that the input and
+ // output pointers are in the same block:
+ //
+ // [ab] [c] [1231] [23123123] [ ]
+ // ^- ^-
+ // And then they move again, so that the output pointer is no longer
+ // in the same block as the input pointer:
+ // [ab] [c] [1231] [23123123] [123 ]
+ // ^-- ^--
+ AppendCopy(&compressed, 6, 9);
+
+ // Finally, a copy where the input is from several blocks back,
+ // and it also crosses three blocks:
+ //
+ // [ab] [c] [1231] [23123123] [123b ]
+ // ^ ^
+ // [ab] [c] [1231] [23123123] [123bc ]
+ // ^ ^
+ // [ab] [c] [1231] [23123123] [123bc12 ]
+ // ^- ^-
+ AppendCopy(&compressed, 17, 4);
+
+ CHECK(snappy::RawUncompressToIOVec(
+ compressed.data(), compressed.size(), iov, ARRAYSIZE(iov)));
+ CHECK_EQ(0, memcmp(iov[0].iov_base, "ab", 2));
+ CHECK_EQ(0, memcmp(iov[1].iov_base, "c", 1));
+ CHECK_EQ(0, memcmp(iov[2].iov_base, "1231", 4));
+ CHECK_EQ(0, memcmp(iov[3].iov_base, "23123123", 8));
+ CHECK_EQ(0, memcmp(iov[4].iov_base, "123bc12", 7));
+
+ for (int i = 0; i < ARRAYSIZE(kLengths); ++i) {
+ delete[] reinterpret_cast<char *>(iov[i].iov_base);
+ }
+}
+
+TEST(Snappy, IOVecLiteralOverflow) {
+ static const int kLengths[] = { 3, 4 };
+
+ struct iovec iov[ARRAYSIZE(kLengths)];
+ for (int i = 0; i < ARRAYSIZE(kLengths); ++i) {
+ iov[i].iov_base = new char[kLengths[i]];
+ iov[i].iov_len = kLengths[i];
+ }
+
+ std::string compressed;
+ Varint::Append32(&compressed, 8);
+
+ AppendLiteral(&compressed, "12345678");
+
+ CHECK(!snappy::RawUncompressToIOVec(
+ compressed.data(), compressed.size(), iov, ARRAYSIZE(iov)));
+
+ for (int i = 0; i < ARRAYSIZE(kLengths); ++i) {
+ delete[] reinterpret_cast<char *>(iov[i].iov_base);
+ }
+}
+
+TEST(Snappy, IOVecCopyOverflow) {
+ static const int kLengths[] = { 3, 4 };
+
+ struct iovec iov[ARRAYSIZE(kLengths)];
+ for (int i = 0; i < ARRAYSIZE(kLengths); ++i) {
+ iov[i].iov_base = new char[kLengths[i]];
+ iov[i].iov_len = kLengths[i];
+ }
+
+ std::string compressed;
+ Varint::Append32(&compressed, 8);
+
+ AppendLiteral(&compressed, "123");
+ AppendCopy(&compressed, 3, 5);
+
+ CHECK(!snappy::RawUncompressToIOVec(
+ compressed.data(), compressed.size(), iov, ARRAYSIZE(iov)));
+
+ for (int i = 0; i < ARRAYSIZE(kLengths); ++i) {
+ delete[] reinterpret_cast<char *>(iov[i].iov_base);
+ }
+}
+
+bool CheckUncompressedLength(const std::string& compressed, size_t* ulength) {
+ const bool result1 = snappy::GetUncompressedLength(compressed.data(),
+ compressed.size(),
+ ulength);
+
+ snappy::ByteArraySource source(compressed.data(), compressed.size());
+ uint32_t length;
+ const bool result2 = snappy::GetUncompressedLength(&source, &length);
+ CHECK_EQ(result1, result2);
+ return result1;
+}
+
+TEST(SnappyCorruption, TruncatedVarint) {
+ std::string compressed, uncompressed;
+ size_t ulength;
+ compressed.push_back('\xf0');
+ CHECK(!CheckUncompressedLength(compressed, &ulength));
+ CHECK(!snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
+ CHECK(!snappy::Uncompress(compressed.data(), compressed.size(),
+ &uncompressed));
+}
+
+TEST(SnappyCorruption, UnterminatedVarint) {
+ std::string compressed, uncompressed;
+ size_t ulength;
+ compressed.push_back('\x80');
+ compressed.push_back('\x80');
+ compressed.push_back('\x80');
+ compressed.push_back('\x80');
+ compressed.push_back('\x80');
+ compressed.push_back(10);
+ CHECK(!CheckUncompressedLength(compressed, &ulength));
+ CHECK(!snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
+ CHECK(!snappy::Uncompress(compressed.data(), compressed.size(),
+ &uncompressed));
+}
+
+TEST(SnappyCorruption, OverflowingVarint) {
+ std::string compressed, uncompressed;
+ size_t ulength;
+ compressed.push_back('\xfb');
+ compressed.push_back('\xff');
+ compressed.push_back('\xff');
+ compressed.push_back('\xff');
+ compressed.push_back('\x7f');
+ CHECK(!CheckUncompressedLength(compressed, &ulength));
+ CHECK(!snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
+ CHECK(!snappy::Uncompress(compressed.data(), compressed.size(),
+ &uncompressed));
+}
+
+TEST(Snappy, ReadPastEndOfBuffer) {
+ // Check that we do not read past end of input
+
+ // Make a compressed string that ends with a single-byte literal
+ std::string compressed;
+ Varint::Append32(&compressed, 1);
+ AppendLiteral(&compressed, "x");
+
+ std::string uncompressed;
+ DataEndingAtUnreadablePage c(compressed);
+ CHECK(snappy::Uncompress(c.data(), c.size(), &uncompressed));
+ CHECK_EQ(uncompressed, std::string("x"));
+}
+
+// Check for an infinite loop caused by a copy with offset==0
+TEST(Snappy, ZeroOffsetCopy) {
+ const char* compressed = "\x40\x12\x00\x00";
+ // \x40 Length (must be > kMaxIncrementCopyOverflow)
+ // \x12\x00\x00 Copy with offset==0, length==5
+ char uncompressed[100];
+ EXPECT_FALSE(snappy::RawUncompress(compressed, 4, uncompressed));
+}
+
+TEST(Snappy, ZeroOffsetCopyValidation) {
+ const char* compressed = "\x05\x12\x00\x00";
+ // \x05 Length
+ // \x12\x00\x00 Copy with offset==0, length==5
+ EXPECT_FALSE(snappy::IsValidCompressedBuffer(compressed, 4));
+}
+
+int TestFindMatchLength(const char* s1, const char *s2, unsigned length) {
+ uint64_t data;
+ std::pair<size_t, bool> p =
+ snappy::internal::FindMatchLength(s1, s2, s2 + length, &data);
+ CHECK_EQ(p.first < 8, p.second);
+ return p.first;
+}
+
+TEST(Snappy, FindMatchLength) {
+ // Exercise all different code paths through the function.
+ // 64-bit version:
+
+ // Hit s1_limit in 64-bit loop, hit s1_limit in single-character loop.
+ EXPECT_EQ(6, TestFindMatchLength("012345", "012345", 6));
+ EXPECT_EQ(11, TestFindMatchLength("01234567abc", "01234567abc", 11));
+
+ // Hit s1_limit in 64-bit loop, find a non-match in single-character loop.
+ EXPECT_EQ(9, TestFindMatchLength("01234567abc", "01234567axc", 9));
+
+ // Same, but edge cases.
+ EXPECT_EQ(11, TestFindMatchLength("01234567abc!", "01234567abc!", 11));
+ EXPECT_EQ(11, TestFindMatchLength("01234567abc!", "01234567abc?", 11));
+
+ // Find non-match at once in first loop.
+ EXPECT_EQ(0, TestFindMatchLength("01234567xxxxxxxx", "?1234567xxxxxxxx", 16));
+ EXPECT_EQ(1, TestFindMatchLength("01234567xxxxxxxx", "0?234567xxxxxxxx", 16));
+ EXPECT_EQ(4, TestFindMatchLength("01234567xxxxxxxx", "01237654xxxxxxxx", 16));
+ EXPECT_EQ(7, TestFindMatchLength("01234567xxxxxxxx", "0123456?xxxxxxxx", 16));
+
+ // Find non-match in first loop after one block.
+ EXPECT_EQ(8, TestFindMatchLength("abcdefgh01234567xxxxxxxx",
+ "abcdefgh?1234567xxxxxxxx", 24));
+ EXPECT_EQ(9, TestFindMatchLength("abcdefgh01234567xxxxxxxx",
+ "abcdefgh0?234567xxxxxxxx", 24));
+ EXPECT_EQ(12, TestFindMatchLength("abcdefgh01234567xxxxxxxx",
+ "abcdefgh01237654xxxxxxxx", 24));
+ EXPECT_EQ(15, TestFindMatchLength("abcdefgh01234567xxxxxxxx",
+ "abcdefgh0123456?xxxxxxxx", 24));
+
+ // 32-bit version:
+
+ // Short matches.
+ EXPECT_EQ(0, TestFindMatchLength("01234567", "?1234567", 8));
+ EXPECT_EQ(1, TestFindMatchLength("01234567", "0?234567", 8));
+ EXPECT_EQ(2, TestFindMatchLength("01234567", "01?34567", 8));
+ EXPECT_EQ(3, TestFindMatchLength("01234567", "012?4567", 8));
+ EXPECT_EQ(4, TestFindMatchLength("01234567", "0123?567", 8));
+ EXPECT_EQ(5, TestFindMatchLength("01234567", "01234?67", 8));
+ EXPECT_EQ(6, TestFindMatchLength("01234567", "012345?7", 8));
+ EXPECT_EQ(7, TestFindMatchLength("01234567", "0123456?", 8));
+ EXPECT_EQ(7, TestFindMatchLength("01234567", "0123456?", 7));
+ EXPECT_EQ(7, TestFindMatchLength("01234567!", "0123456??", 7));
+
+ // Hit s1_limit in 32-bit loop, hit s1_limit in single-character loop.
+ EXPECT_EQ(10, TestFindMatchLength("xxxxxxabcd", "xxxxxxabcd", 10));
+ EXPECT_EQ(10, TestFindMatchLength("xxxxxxabcd?", "xxxxxxabcd?", 10));
+ EXPECT_EQ(13, TestFindMatchLength("xxxxxxabcdef", "xxxxxxabcdef", 13));
+
+ // Same, but edge cases.
+ EXPECT_EQ(12, TestFindMatchLength("xxxxxx0123abc!", "xxxxxx0123abc!", 12));
+ EXPECT_EQ(12, TestFindMatchLength("xxxxxx0123abc!", "xxxxxx0123abc?", 12));
+
+ // Hit s1_limit in 32-bit loop, find a non-match in single-character loop.
+ EXPECT_EQ(11, TestFindMatchLength("xxxxxx0123abc", "xxxxxx0123axc", 13));
+
+ // Find non-match at once in first loop.
+ EXPECT_EQ(6, TestFindMatchLength("xxxxxx0123xxxxxxxx",
+ "xxxxxx?123xxxxxxxx", 18));
+ EXPECT_EQ(7, TestFindMatchLength("xxxxxx0123xxxxxxxx",
+ "xxxxxx0?23xxxxxxxx", 18));
+ EXPECT_EQ(8, TestFindMatchLength("xxxxxx0123xxxxxxxx",
+ "xxxxxx0132xxxxxxxx", 18));
+ EXPECT_EQ(9, TestFindMatchLength("xxxxxx0123xxxxxxxx",
+ "xxxxxx012?xxxxxxxx", 18));
+
+ // Same, but edge cases.
+ EXPECT_EQ(6, TestFindMatchLength("xxxxxx0123", "xxxxxx?123", 10));
+ EXPECT_EQ(7, TestFindMatchLength("xxxxxx0123", "xxxxxx0?23", 10));
+ EXPECT_EQ(8, TestFindMatchLength("xxxxxx0123", "xxxxxx0132", 10));
+ EXPECT_EQ(9, TestFindMatchLength("xxxxxx0123", "xxxxxx012?", 10));
+
+ // Find non-match in first loop after one block.
+ EXPECT_EQ(10, TestFindMatchLength("xxxxxxabcd0123xx",
+ "xxxxxxabcd?123xx", 16));
+ EXPECT_EQ(11, TestFindMatchLength("xxxxxxabcd0123xx",
+ "xxxxxxabcd0?23xx", 16));
+ EXPECT_EQ(12, TestFindMatchLength("xxxxxxabcd0123xx",
+ "xxxxxxabcd0132xx", 16));
+ EXPECT_EQ(13, TestFindMatchLength("xxxxxxabcd0123xx",
+ "xxxxxxabcd012?xx", 16));
+
+ // Same, but edge cases.
+ EXPECT_EQ(10, TestFindMatchLength("xxxxxxabcd0123", "xxxxxxabcd?123", 14));
+ EXPECT_EQ(11, TestFindMatchLength("xxxxxxabcd0123", "xxxxxxabcd0?23", 14));
+ EXPECT_EQ(12, TestFindMatchLength("xxxxxxabcd0123", "xxxxxxabcd0132", 14));
+ EXPECT_EQ(13, TestFindMatchLength("xxxxxxabcd0123", "xxxxxxabcd012?", 14));
+}
+
+TEST(Snappy, FindMatchLengthRandom) {
+ constexpr int kNumTrials = 10000;
+ constexpr int kTypicalLength = 10;
+ std::minstd_rand0 rng(snappy::GetFlag(FLAGS_test_random_seed));
+ std::uniform_int_distribution<int> uniform_byte(0, 255);
+ std::bernoulli_distribution one_in_two(1.0 / 2);
+ std::bernoulli_distribution one_in_typical_length(1.0 / kTypicalLength);
+
+ for (int i = 0; i < kNumTrials; ++i) {
+ std::string s, t;
+ char a = static_cast<char>(uniform_byte(rng));
+ char b = static_cast<char>(uniform_byte(rng));
+ while (!one_in_typical_length(rng)) {
+ s.push_back(one_in_two(rng) ? a : b);
+ t.push_back(one_in_two(rng) ? a : b);
+ }
+ DataEndingAtUnreadablePage u(s);
+ DataEndingAtUnreadablePage v(t);
+ size_t matched = TestFindMatchLength(u.data(), v.data(), t.size());
+ if (matched == t.size()) {
+ EXPECT_EQ(s, t);
+ } else {
+ EXPECT_NE(s[matched], t[matched]);
+ for (size_t j = 0; j < matched; ++j) {
+ EXPECT_EQ(s[j], t[j]);
+ }
+ }
+ }
+}
+
+uint16_t MakeEntry(unsigned int extra, unsigned int len,
+ unsigned int copy_offset) {
+ // Check that all of the fields fit within the allocated space
+ assert(extra == (extra & 0x7)); // At most 3 bits
+ assert(copy_offset == (copy_offset & 0x7)); // At most 3 bits
+ assert(len == (len & 0x7f)); // At most 7 bits
+ return len | (copy_offset << 8) | (extra << 11);
+}
+
+// Check that the decompression table is correct, and optionally print out
+// the computed one.
+TEST(Snappy, VerifyCharTable) {
+ using snappy::internal::LITERAL;
+ using snappy::internal::COPY_1_BYTE_OFFSET;
+ using snappy::internal::COPY_2_BYTE_OFFSET;
+ using snappy::internal::COPY_4_BYTE_OFFSET;
+ using snappy::internal::char_table;
+
+ uint16_t dst[256];
+
+ // Place invalid entries in all places to detect missing initialization
+ int assigned = 0;
+ for (int i = 0; i < 256; ++i) {
+ dst[i] = 0xffff;
+ }
+
+ // Small LITERAL entries. We store (len-1) in the top 6 bits.
+ for (uint8_t len = 1; len <= 60; ++len) {
+ dst[LITERAL | ((len - 1) << 2)] = MakeEntry(0, len, 0);
+ assigned++;
+ }
+
+ // Large LITERAL entries. We use 60..63 in the high 6 bits to
+ // encode the number of bytes of length info that follow the opcode.
+ for (uint8_t extra_bytes = 1; extra_bytes <= 4; ++extra_bytes) {
+ // We set the length field in the lookup table to 1 because extra
+ // bytes encode len-1.
+ dst[LITERAL | ((extra_bytes + 59) << 2)] = MakeEntry(extra_bytes, 1, 0);
+ assigned++;
+ }
+
+ // COPY_1_BYTE_OFFSET.
+ //
+ // The tag byte in the compressed data stores len-4 in 3 bits, and
+ // offset/256 in 5 bits. offset%256 is stored in the next byte.
+ //
+ // This format is used for length in range [4..11] and offset in
+ // range [0..2047]
+ for (uint8_t len = 4; len < 12; ++len) {
+ for (uint16_t offset = 0; offset < 2048; offset += 256) {
+ uint8_t offset_high = static_cast<uint8_t>(offset >> 8);
+ dst[COPY_1_BYTE_OFFSET | ((len - 4) << 2) | (offset_high << 5)] =
+ MakeEntry(1, len, offset_high);
+ assigned++;
+ }
+ }
+
+ // COPY_2_BYTE_OFFSET.
+ // Tag contains len-1 in top 6 bits, and offset in next two bytes.
+ for (uint8_t len = 1; len <= 64; ++len) {
+ dst[COPY_2_BYTE_OFFSET | ((len - 1) << 2)] = MakeEntry(2, len, 0);
+ assigned++;
+ }
+
+ // COPY_4_BYTE_OFFSET.
+ // Tag contents len-1 in top 6 bits, and offset in next four bytes.
+ for (uint8_t len = 1; len <= 64; ++len) {
+ dst[COPY_4_BYTE_OFFSET | ((len - 1) << 2)] = MakeEntry(4, len, 0);
+ assigned++;
+ }
+
+ // Check that each entry was initialized exactly once.
+ EXPECT_EQ(256, assigned) << "Assigned only " << assigned << " of 256";
+ for (int i = 0; i < 256; ++i) {
+ EXPECT_NE(0xffff, dst[i]) << "Did not assign byte " << i;
+ }
+
+ if (snappy::GetFlag(FLAGS_snappy_dump_decompression_table)) {
+ std::printf("static const uint16_t char_table[256] = {\n ");
+ for (int i = 0; i < 256; ++i) {
+ std::printf("0x%04x%s",
+ dst[i],
+ ((i == 255) ? "\n" : (((i % 8) == 7) ? ",\n " : ", ")));
+ }
+ std::printf("};\n");
+ }
+
+ // Check that computed table matched recorded table.
+ for (int i = 0; i < 256; ++i) {
+ EXPECT_EQ(dst[i], char_table[i]) << "Mismatch in byte " << i;
+ }
+}
+
+TEST(Snappy, TestBenchmarkFiles) {
+ for (int i = 0; i < ARRAYSIZE(kTestDataFiles); ++i) {
+ Verify(ReadTestDataFile(kTestDataFiles[i].filename,
+ kTestDataFiles[i].size_limit));
+ }
+}
+
+} // namespace
+
+} // namespace snappy