diff --git a/externals/ace/win/VC90/ace.vcproj b/externals/ace/win/VC90/ace.vcproj
deleted file mode 100644
index 39b0872d0a..0000000000
--- a/externals/ace/win/VC90/ace.vcproj
+++ /dev/null
@@ -1,5308 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/externals/ace/win/ace.sln b/externals/ace/win/ace.sln
deleted file mode 100644
index 6b09a5f85b..0000000000
--- a/externals/ace/win/ace.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_Wrappers", "VC90\ace.vcproj", "{BD537C9A-FECA-1BAD-6757-8A6348EA12C8}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {BD537C9A-FECA-1BAD-6757-8A6348EA12C8}.Debug|Win32.ActiveCfg = Debug|Win32
- {BD537C9A-FECA-1BAD-6757-8A6348EA12C8}.Debug|Win32.Build.0 = Debug|Win32
- {BD537C9A-FECA-1BAD-6757-8A6348EA12C8}.Debug|x64.ActiveCfg = Debug|x64
- {BD537C9A-FECA-1BAD-6757-8A6348EA12C8}.Debug|x64.Build.0 = Debug|x64
- {BD537C9A-FECA-1BAD-6757-8A6348EA12C8}.Release|Win32.ActiveCfg = Release|Win32
- {BD537C9A-FECA-1BAD-6757-8A6348EA12C8}.Release|Win32.Build.0 = Release|Win32
- {BD537C9A-FECA-1BAD-6757-8A6348EA12C8}.Release|x64.ActiveCfg = Release|x64
- {BD537C9A-FECA-1BAD-6757-8A6348EA12C8}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/externals/bzip2/win/VC90/bzip2.vcproj b/externals/bzip2/win/VC90/bzip2.vcproj
deleted file mode 100644
index 98b3a33d9b..0000000000
--- a/externals/bzip2/win/VC90/bzip2.vcproj
+++ /dev/null
@@ -1,333 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/externals/bzip2/win/bzip2.sln b/externals/bzip2/win/bzip2.sln
deleted file mode 100644
index 1a637e4a9f..0000000000
--- a/externals/bzip2/win/bzip2.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "VC90\bzip2.vcproj", "{CE773400-763E-4B71-B5E2-C9B60A752EB1}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {CE773400-763E-4B71-B5E2-C9B60A752EB1}.Debug|Win32.ActiveCfg = Debug|Win32
- {CE773400-763E-4B71-B5E2-C9B60A752EB1}.Debug|Win32.Build.0 = Debug|Win32
- {CE773400-763E-4B71-B5E2-C9B60A752EB1}.Debug|x64.ActiveCfg = Debug|x64
- {CE773400-763E-4B71-B5E2-C9B60A752EB1}.Debug|x64.Build.0 = Debug|x64
- {CE773400-763E-4B71-B5E2-C9B60A752EB1}.Release|Win32.ActiveCfg = Release|Win32
- {CE773400-763E-4B71-B5E2-C9B60A752EB1}.Release|Win32.Build.0 = Release|Win32
- {CE773400-763E-4B71-B5E2-C9B60A752EB1}.Release|x64.ActiveCfg = Release|x64
- {CE773400-763E-4B71-B5E2-C9B60A752EB1}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/externals/g3dlite/win/VC90/g3dlite.vcproj b/externals/g3dlite/win/VC90/g3dlite.vcproj
deleted file mode 100644
index 6d6c4c07fc..0000000000
--- a/externals/g3dlite/win/VC90/g3dlite.vcproj
+++ /dev/null
@@ -1,965 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/externals/g3dlite/win/g3dlite.sln b/externals/g3dlite/win/g3dlite.sln
deleted file mode 100644
index 875374e394..0000000000
--- a/externals/g3dlite/win/g3dlite.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "g3dlite", "VC90\g3dlite.vcproj", "{8072769E-CF10-48BF-B9E1-12752A5DAC6E}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8072769E-CF10-48BF-B9E1-12752A5DAC6E}.Debug|Win32.ActiveCfg = Debug|Win32
- {8072769E-CF10-48BF-B9E1-12752A5DAC6E}.Debug|Win32.Build.0 = Debug|Win32
- {8072769E-CF10-48BF-B9E1-12752A5DAC6E}.Debug|x64.ActiveCfg = Debug|x64
- {8072769E-CF10-48BF-B9E1-12752A5DAC6E}.Debug|x64.Build.0 = Debug|x64
- {8072769E-CF10-48BF-B9E1-12752A5DAC6E}.Release|Win32.ActiveCfg = Release|Win32
- {8072769E-CF10-48BF-B9E1-12752A5DAC6E}.Release|Win32.Build.0 = Release|Win32
- {8072769E-CF10-48BF-B9E1-12752A5DAC6E}.Release|x64.ActiveCfg = Release|x64
- {8072769E-CF10-48BF-B9E1-12752A5DAC6E}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/externals/gsoap/VC90/gsoap.vcproj b/externals/gsoap/VC90/gsoap.vcproj
deleted file mode 100644
index 2d52f32bfd..0000000000
--- a/externals/gsoap/VC90/gsoap.vcproj
+++ /dev/null
@@ -1,331 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/externals/libmpq/win/VC90/libmpq.vcproj b/externals/libmpq/win/VC90/libmpq.vcproj
deleted file mode 100644
index 8394785713..0000000000
--- a/externals/libmpq/win/VC90/libmpq.vcproj
+++ /dev/null
@@ -1,216 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/externals/libmpq/win/VS100/libmpq.vcxproj b/externals/libmpq/win/VS100/libmpq.vcxproj
deleted file mode 100644
index e68a67ccd5..0000000000
--- a/externals/libmpq/win/VS100/libmpq.vcxproj
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- libmpq
- {03AB0F44-628E-4855-99A0-C98A1EB52C50}
- libmpq
-
-
-
- StaticLibrary
- Unicode
- true
-
-
- StaticLibrary
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- ..\..\bin\$(Platform)_$(Configuration)\
- ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\
- ..\..\bin\$(Platform)_$(Configuration)\
- ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\
-
-
-
- Disabled
- ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories)
- WIN32;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
- Level3
- EditAndContinue
- CompileAsC
-
-
- true
-
-
- ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)
-
-
-
-
- MaxSpeed
- true
- ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories)
- WIN32;%(PreprocessorDefinitions)
- MultiThreadedDLL
- true
- StreamingSIMDExtensions
- Level3
- ProgramDatabase
- CompileAsC
-
-
- true
-
-
- ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {b96f612a-c91d-43b3-a4c3-d4294817ec6c}
- false
-
-
- {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
- false
-
-
-
-
-
-
\ No newline at end of file
diff --git a/externals/libmpq/win/libmpq_VC100.sln b/externals/libmpq/win/libmpq_VC100.sln
deleted file mode 100644
index 5c88e2e495..0000000000
--- a/externals/libmpq/win/libmpq_VC100.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpq", "VS100\libmpq.vcxproj", "{03AB0F44-628E-4855-99A0-C98A1EB52C50}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\win\VC100\zlib.vcxproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "..\..\..\win\VC100\bzip2.vcxproj", "{B96F612A-C91D-43B3-A4C3-D4294817EC6C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Debug|Win32.ActiveCfg = Debug|Win32
- {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Debug|Win32.Build.0 = Debug|Win32
- {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Release|Win32.ActiveCfg = Release|Win32
- {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Release|Win32.Build.0 = Release|Win32
- {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.ActiveCfg = Debug|Win32
- {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.Build.0 = Debug|Win32
- {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.ActiveCfg = Release|Win32
- {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.Build.0 = Release|Win32
- {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Debug|Win32.ActiveCfg = Debug|Win32
- {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Debug|Win32.Build.0 = Debug|Win32
- {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Release|Win32.ActiveCfg = Release|Win32
- {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/externals/libmpq/win/libmpq_VC90.sln b/externals/libmpq/win/libmpq_VC90.sln
deleted file mode 100644
index c55968a73a..0000000000
--- a/externals/libmpq/win/libmpq_VC90.sln
+++ /dev/null
@@ -1,19 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpq", "VC90\libmpq.vcproj", "{03AB0F44-628E-4855-99A0-C98A1EB52C50}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Debug|Win32.ActiveCfg = Debug|Win32
- {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Debug|Win32.Build.0 = Debug|Win32
- {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Release|Win32.ActiveCfg = Release|Win32
- {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/externals/mysql/atomic/gcc_builtins.h b/externals/mysql/atomic/gcc_builtins.h
deleted file mode 100644
index 4600a0ef4b..0000000000
--- a/externals/mysql/atomic/gcc_builtins.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 2008 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#define MY_ATOMIC_MODE "atomic_builtins"
-
-#define make_atomic_add_body(S) \
- v= __sync_fetch_and_add(a, v);
-#define make_atomic_swap_body(S) \
- v= __sync_lock_test_and_set(a, v);
-#define make_atomic_cas_body(S) \
- int ## S sav; \
- sav= __sync_val_compare_and_swap(a, *cmp, set); \
- if (!(ret= (sav == *cmp))) *cmp= sav;
-
-#ifdef MY_ATOMIC_MODE_DUMMY
-#define make_atomic_load_body(S) ret= *a
-#define make_atomic_store_body(S) *a= v
-#define MY_ATOMIC_MODE "gcc-builtins-up"
-
-#else
-#define MY_ATOMIC_MODE "gcc-builtins-smp"
-#define make_atomic_load_body(S) \
- ret= __sync_fetch_and_or(a, 0);
-#define make_atomic_store_body(S) \
- (void) __sync_lock_test_and_set(a, v);
-#endif
diff --git a/externals/mysql/atomic/generic-msvc.h b/externals/mysql/atomic/generic-msvc.h
deleted file mode 100644
index a8601e993b..0000000000
--- a/externals/mysql/atomic/generic-msvc.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef _atomic_h_cleanup_
-#define _atomic_h_cleanup_ "atomic/generic-msvc.h"
-
-/*
- We don't implement anything specific for MY_ATOMIC_MODE_DUMMY, always use
- intrinsics.
- 8 and 16-bit atomics are not implemented, but it can be done if necessary.
-*/
-
-/*
- x86 compilers (both VS2003 or VS2005) never use instrinsics, but generate
- function calls to kernel32 instead, even in the optimized build.
- We force intrinsics as described in MSDN documentation for
- _InterlockedCompareExchange.
-*/
-#ifdef _M_IX86
-
-#if (_MSC_VER >= 1500)
-#include
-#else
-C_MODE_START
-/*Visual Studio 2003 and earlier do not have prototypes for atomic intrinsics*/
-LONG _InterlockedExchange (LONG volatile *Target,LONG Value);
-LONG _InterlockedCompareExchange (LONG volatile *Target, LONG Value, LONG Comp);
-LONG _InterlockedExchangeAdd (LONG volatile *Addend, LONG Value);
-C_MODE_END
-
-#pragma intrinsic(_InterlockedExchangeAdd)
-#pragma intrinsic(_InterlockedCompareExchange)
-#pragma intrinsic(_InterlockedExchange)
-#endif
-
-#define InterlockedExchange _InterlockedExchange
-#define InterlockedExchangeAdd _InterlockedExchangeAdd
-#define InterlockedCompareExchange _InterlockedCompareExchange
-/*
- No need to do something special for InterlockedCompareExchangePointer
- as it is a #define to InterlockedCompareExchange. The same applies to
- InterlockedExchangePointer.
-*/
-#endif /*_M_IX86*/
-
-#define MY_ATOMIC_MODE "msvc-intrinsics"
-#define IL_EXCHG_ADD32(X,Y) InterlockedExchangeAdd((volatile LONG *)(X),(Y))
-#define IL_COMP_EXCHG32(X,Y,Z) InterlockedCompareExchange((volatile LONG *)(X),(Y),(Z))
-#define IL_COMP_EXCHGptr InterlockedCompareExchangePointer
-#define IL_EXCHG32(X,Y) InterlockedExchange((volatile LONG *)(X),(Y))
-#define IL_EXCHGptr InterlockedExchangePointer
-#define make_atomic_add_body(S) \
- v= IL_EXCHG_ADD ## S (a, v)
-#define make_atomic_cas_body(S) \
- int ## S initial_cmp= *cmp; \
- int ## S initial_a= IL_COMP_EXCHG ## S (a, set, initial_cmp); \
- if (!(ret= (initial_a == initial_cmp))) *cmp= initial_a;
-#define make_atomic_swap_body(S) \
- v= IL_EXCHG ## S (a, v)
-#define make_atomic_load_body(S) \
- ret= 0; /* avoid compiler warning */ \
- ret= IL_COMP_EXCHG ## S (a, ret, ret);
-
-/*
- my_yield_processor (equivalent of x86 PAUSE instruction) should be used
- to improve performance on hyperthreaded CPUs. Intel recommends to use it in
- spin loops also on non-HT machines to reduce power consumption (see e.g
- http://softwarecommunity.intel.com/articles/eng/2004.htm)
-
- Running benchmarks for spinlocks implemented with InterlockedCompareExchange
- and YieldProcessor shows that much better performance is achieved by calling
- YieldProcessor in a loop - that is, yielding longer. On Intel boxes setting
- loop count in the range 200-300 brought best results.
- */
-#ifndef YIELD_LOOPS
-#define YIELD_LOOPS 200
-#endif
-
-static __inline int my_yield_processor()
-{
- int i;
- for(i=0; irw)
-#define my_atomic_rwlock_init(name) pthread_mutex_init(& (name)->rw, 0)
-#define my_atomic_rwlock_rdlock(name) pthread_mutex_lock(& (name)->rw)
-#define my_atomic_rwlock_wrlock(name) pthread_mutex_lock(& (name)->rw)
-#define my_atomic_rwlock_rdunlock(name) pthread_mutex_unlock(& (name)->rw)
-#define my_atomic_rwlock_wrunlock(name) pthread_mutex_unlock(& (name)->rw)
-#define MY_ATOMIC_MODE "mutex"
-#ifndef MY_ATOMIC_MODE_RWLOCKS
-#define MY_ATOMIC_MODE_RWLOCKS 1
-#endif
-#endif
-
-#define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav;
-#define make_atomic_fas_body(S) int ## S sav; sav= *a; *a= v; v=sav;
-#define make_atomic_cas_body(S) if ((ret= (*a == *cmp))) *a= set; else *cmp=*a;
-#define make_atomic_load_body(S) ret= *a;
-#define make_atomic_store_body(S) *a= v;
-
diff --git a/externals/mysql/atomic/x86-gcc.h b/externals/mysql/atomic/x86-gcc.h
deleted file mode 100644
index 5a34bc22f9..0000000000
--- a/externals/mysql/atomic/x86-gcc.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (C) 2006 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/*
- XXX 64-bit atomic operations can be implemented using
- cmpxchg8b, if necessary. Though I've heard that not all 64-bit
- architectures support double-word (128-bit) cas.
-*/
-
-#ifdef __x86_64__
-# ifdef MY_ATOMIC_NO_XADD
-# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix "-no-xadd"
-# else
-# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix
-# endif
-#else
-# ifdef MY_ATOMIC_NO_XADD
-# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix "-no-xadd"
-# else
-# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix
-# endif
-#endif
-
-/* fix -ansi errors while maintaining readability */
-#ifndef asm
-#define asm __asm__
-#endif
-
-#ifndef MY_ATOMIC_NO_XADD
-#define make_atomic_add_body(S) \
- asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a))
-#endif
-#define make_atomic_fas_body(S) \
- asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a))
-#define make_atomic_cas_body(S) \
- asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \
- : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set))
-
-#ifdef MY_ATOMIC_MODE_DUMMY
-#define make_atomic_load_body(S) ret=*a
-#define make_atomic_store_body(S) *a=v
-#else
-/*
- Actually 32-bit reads/writes are always atomic on x86
- But we add LOCK_prefix here anyway to force memory barriers
-*/
-#define make_atomic_load_body(S) \
- ret=0; \
- asm volatile (LOCK_prefix "; cmpxchg %2, %0" \
- : "+m" (*a), "+a" (ret): "r" (ret))
-#define make_atomic_store_body(S) \
- asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v))
-#endif
-
-/* TODO test on intel whether the below helps. on AMD it makes no difference */
-//#define LF_BACKOFF ({asm volatile ("rep; nop"); 1; })
-
diff --git a/externals/mysql/base64.h b/externals/mysql/base64.h
deleted file mode 100644
index 155d6691b9..0000000000
--- a/externals/mysql/base64.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (C) 2003 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef __BASE64_H_INCLUDED__
-#define __BASE64_H_INCLUDED__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- Calculate how much memory needed for dst of base64_encode()
-*/
-int my_base64_needed_encoded_length(int length_of_data);
-
-/*
- Calculate how much memory needed for dst of base64_decode()
-*/
-int my_base64_needed_decoded_length(int length_of_encoded_data);
-
-
-/*
- Encode data as a base64 string
-*/
-int my_base64_encode(const void *src, size_t src_len, char *dst);
-
-/*
- Decode a base64 string into data
-*/
-int my_base64_decode(const char *src, size_t src_len,
- void *dst, const char **end_ptr);
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !__BASE64_H_INCLUDED__ */
diff --git a/externals/mysql/config-win.h b/externals/mysql/config-win.h
deleted file mode 100644
index 94577211eb..0000000000
--- a/externals/mysql/config-win.h
+++ /dev/null
@@ -1,392 +0,0 @@
-/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* Defines for Win32 to make it compatible for MySQL */
-
-#define BIG_TABLES
-
-/*
- Minimal version of Windows we should be able to run on.
- Currently Windows 2000
-*/
-#define _WIN32_WINNT 0x0500
-
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-/* Avoid endless warnings about sprintf() etc. being unsafe. */
-#define _CRT_SECURE_NO_DEPRECATE 1
-#endif
-
-#include
-#include /* chmod() constants*/
-#include
-#include
-#include
-#include
-#include
-#include
-#include /* getpid()*/
-
-#define HAVE_SMEM 1
-
-#if defined(_WIN64) || defined(WIN64)
-#define SYSTEM_TYPE "Win64"
-#elif defined(_WIN32) || defined(WIN32)
-#define SYSTEM_TYPE "Win32"
-#else
-#define SYSTEM_TYPE "Windows"
-#endif
-
-#if defined(_M_IA64)
-#define MACHINE_TYPE "ia64"
-#elif defined(_M_IX86)
-#define MACHINE_TYPE "ia32"
-#elif defined(_M_ALPHA)
-#define MACHINE_TYPE "axp"
-#else
-#define MACHINE_TYPE "unknown" /* Define to machine type name */
-#endif
-
-#if !(defined(_WIN64) || defined(WIN64))
-#ifndef _WIN32
-#define _WIN32 /* Compatible with old source */
-#endif
-#ifndef __WIN32__
-#define __WIN32__
-#endif
-#endif /* _WIN64 */
-#ifndef __WIN__
-#define __WIN__ /* To make it easier in VC++ */
-#endif
-
-#ifndef MAX_INDEXES
-#define MAX_INDEXES 64
-#endif
-
-/* File and lock constants */
-#ifdef __BORLANDC__
-#define F_RDLCK LK_NBLCK /* read lock */
-#define F_WRLCK LK_NBRLCK /* write lock */
-#define F_UNLCK LK_UNLCK /* remove lock(s) */
-#else
-#define F_RDLCK _LK_NBLCK /* read lock */
-#define F_WRLCK _LK_NBRLCK /* write lock */
-#define F_UNLCK _LK_UNLCK /* remove lock(s) */
-#endif
-
-#define F_EXCLUSIVE 1 /* We have only exclusive locking */
-#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */
-#define F_OK 0 /* parameter to access() */
-#define W_OK 2
-
-#define S_IROTH S_IREAD /* for my_lib */
-
-/* for MY_S_ISFIFO() macro from my_lib */
-#if defined (_S_IFIFO) && !defined (S_IFIFO)
-#define S_IFIFO _S_IFIFO
-#endif
-
-/* Winsock2 constant (Vista SDK and later)*/
-#define IPPROTO_IPV6 41
-#ifndef IPV6_V6ONLY
-#define IPV6_V6ONLY 27
-#endif
-
-/*
- Constants used by chmod. Note, that group/others is ignored
- - because unsupported by Windows due to different access control model.
-*/
-#define S_IRWXU S_IREAD|S_IWRITE
-#define S_IRWXG 0
-#define S_IRWXO 0
-typedef int mode_t;
-
-#ifdef __BORLANDC__
-#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
-#define O_TEMPORARY 0
-#define O_SHORT_LIVED 0
-#define SH_DENYNO _SH_DENYNO
-#else
-#define O_BINARY _O_BINARY /* compability with older style names */
-#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */
-#define O_TEMPORARY _O_TEMPORARY
-#define O_SHORT_LIVED _O_SHORT_LIVED
-#define SH_DENYNO _SH_DENYNO
-#endif
-#define NO_OPEN_3 /* For my_create() */
-
-#define SIGQUIT SIGTERM /* No SIGQUIT */
-
-#undef _REENTRANT /* Crashes something for win32 */
-#undef SAFE_MUTEX /* Can't be used on windows */
-
-#define LONGLONG_MIN 0x8000000000000000LL
-#define LONGLONG_MAX 0x7FFFFFFFFFFFFFFFLL
-#define ULONGLONG_MAX 0xFFFFFFFFFFFFFFFFULL
-
-/* Type information */
-
-#if !defined(HAVE_UINT)
-#undef HAVE_UINT
-#define HAVE_UINT
-typedef unsigned short ushort;
-typedef unsigned int uint;
-#endif /* !defined(HAVE_UINT) */
-
-typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
-typedef __int64 longlong;
-#ifndef HAVE_SIGSET_T
-typedef int sigset_t;
-#endif
-#define longlong_defined
-/*
- off_t should not be __int64 because of conflicts in header files;
- Use my_off_t or os_off_t instead
-*/
-#ifndef HAVE_OFF_T
-typedef long off_t;
-#endif
-typedef __int64 os_off_t;
-#ifdef _WIN64
-typedef UINT_PTR rf_SetTimer;
-#else
-typedef uint rf_SetTimer;
-#endif
-
-#ifndef HAVE_SIZE_T
-#ifndef _SIZE_T_DEFINED
-typedef SIZE_T size_t;
-#define _SIZE_T_DEFINED
-#endif
-#endif
-
-#ifndef HAVE_SSIZE_T
-#ifndef _SSIZE_T_DEFINED
-typedef SSIZE_T ssize_t;
-#define _SSIZE_T_DEFINED
-#endif
-#endif
-
-#define Socket_defined
-#define my_socket SOCKET
-#define SIGPIPE SIGINT
-#define RETQSORTTYPE void
-#define QSORT_TYPE_IS_VOID
-#define SOCKET_SIZE_TYPE int
-#define my_socket_defined
-#define byte_defined
-#define HUGE_PTR
-#define STDCALL __stdcall /* Used by libmysql.dll */
-#define isnan(X) _isnan(X)
-#define finite(X) _finite(X)
-
-#ifndef UNDEF_THREAD_HACK
-#define THREAD
-#endif
-#define VOID_SIGHANDLER
-#define SIZEOF_CHAR 1
-#define SIZEOF_INT 4
-#define SIZEOF_LONG 4
-#define SIZEOF_LONG_LONG 8
-#define SIZEOF_OFF_T 8
-#ifdef _WIN64
-#define SIZEOF_CHARP 8
-#else
-#define SIZEOF_CHARP 4
-#endif
-#define HAVE_BROKEN_NETINET_INCLUDES
-#ifdef _WIN32
-#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
-#endif
-
-/* ERROR is defined in wingdi.h */
-#undef ERROR
-
-/* We need to close files to break connections on shutdown */
-#ifndef SIGNAL_WITH_VIO_CLOSE
-#define SIGNAL_WITH_VIO_CLOSE
-#endif
-
-/* All windows servers should support .sym files */
-#undef USE_SYMDIR
-#define USE_SYMDIR
-
-/* If LOAD DATA LOCAL INFILE should be enabled by default */
-#define ENABLED_LOCAL_INFILE 1
-
-/* If query profiling should be enabled by default */
-#define ENABLED_PROFILING 1
-
-/* Convert some simple functions to Posix */
-
-#define my_sigset(A,B) signal((A),(B))
-#define finite(A) _finite(A)
-#define sleep(A) Sleep((A)*1000)
-#define popen(A,B) _popen((A),(B))
-#define pclose(A) _pclose(A)
-
-#ifndef __BORLANDC__
-#define access(A,B) _access(A,B)
-#endif
-
-#if !defined(__cplusplus)
-#define inline __inline
-#endif /* __cplusplus */
-
-#ifdef _WIN64
-#define ulonglong2double(A) ((double) (ulonglong) (A))
-#define my_off_t2double(A) ((double) (my_off_t) (A))
-
-#else
-inline double ulonglong2double(ulonglong value)
-{
- longlong nr=(longlong) value;
- if (nr >= 0)
- return (double) nr;
- return (18446744073709551616.0 + (double) nr);
-}
-#define my_off_t2double(A) ulonglong2double(A)
-#endif /* _WIN64 */
-
-inline ulonglong double2ulonglong(double d)
-{
- double t= d - (double) 0x8000000000000000ULL;
-
- if (t >= 0)
- return ((ulonglong) t) + 0x8000000000000000ULL;
- return (ulonglong) d;
-}
-
-#if SIZEOF_OFF_T > 4
-#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
-#define tell(A) _telli64(A)
-#endif
-
-#define STACK_DIRECTION -1
-
-/* Difference between GetSystemTimeAsFileTime() and now() */
-#define OFFSET_TO_EPOCH 116444736000000000ULL
-
-#define HAVE_PERROR
-#define HAVE_VFPRINT
-#define HAVE_RENAME /* Have rename() as function */
-#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
-#define HAVE_LONG_JMP /* Have long jump function */
-#define HAVE_LOCKING /* have locking() call */
-#define HAVE_ERRNO_AS_DEFINE /* errno is a define */
-#define HAVE_STDLIB /* everything is include in this file */
-#define HAVE_MEMCPY
-#define HAVE_MEMMOVE
-#define HAVE_GETCWD
-#define HAVE_TELL
-#define HAVE_TZNAME
-#define HAVE_PUTENV
-#define HAVE_SELECT
-#define HAVE_SETLOCALE
-#define HAVE_SOCKET /* Giangi */
-#define HAVE_FLOAT_H
-#define HAVE_LIMITS_H
-#define HAVE_STDDEF_H
-#define NO_FCNTL_NONBLOCK /* No FCNTL */
-#define HAVE_ALLOCA
-#define HAVE_STRPBRK
-#define HAVE_STRSTR
-#define HAVE_COMPRESS
-#define HAVE_CREATESEMAPHORE
-#define HAVE_ISNAN
-#define HAVE_FINITE
-#define HAVE_QUERY_CACHE
-#define SPRINTF_RETURNS_INT
-#define HAVE_SETFILEPOINTER
-#define HAVE_VIO_READ_BUFF
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-/* strnlen() appeared in Studio 2005 */
-#define HAVE_STRNLEN
-#endif
-#define HAVE_WINSOCK2
-
-#define strcasecmp stricmp
-#define strncasecmp strnicmp
-
-#ifndef _WIN32
-#undef FILE_SHARE_DELETE
-#define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */
-#endif
-
-#ifdef NOT_USED
-#define HAVE_SNPRINTF /* Gave link error */
-#define _snprintf snprintf
-#endif
-
-#ifdef _MSC_VER
-#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
-#define HAVE_ANSI_INCLUDE
-#define HAVE_SYS_UTIME_H
-#define HAVE_STRTOUL
-#endif
-#define my_reinterpret_cast(A) reinterpret_cast
-#define my_const_cast(A) const_cast
-
-
-/* MYSQL OPTIONS */
-
-#ifdef _CUSTOMCONFIG_
-#include
-#else
-#define DEFAULT_MYSQL_HOME "c:\\mysql"
-#define DATADIR "c:\\mysql\\data"
-#define PACKAGE "mysql"
-#define DEFAULT_BASEDIR "C:\\"
-#define SHAREDIR "share"
-#define DEFAULT_CHARSET_HOME "C:/mysql/"
-#endif
-#ifndef DEFAULT_HOME_ENV
-#define DEFAULT_HOME_ENV MYSQL_HOME
-#endif
-#ifndef DEFAULT_GROUP_SUFFIX_ENV
-#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX
-#endif
-
-/* File name handling */
-
-#define FN_LIBCHAR '\\'
-#define FN_ROOTDIR "\\"
-#define FN_DEVCHAR ':'
-#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
-#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
-#define OS_FILE_LIMIT UINT_MAX /* No limit*/
-
-#define DO_NOT_REMOVE_THREAD_WRAPPERS
-#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
-#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
-/* The following is only used for statistics, so it should be good enough */
-#ifdef _WIN32 /* This should also work on Win98 but .. */
-#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
-#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
-#endif
-
-#define shared_memory_buffer_length 16000
-#define default_shared_memory_base_name "MYSQL"
-
-#define HAVE_SPATIAL 1
-#define HAVE_RTREE_KEYS 1
-
-#define HAVE_OPENSSL 1
-#define HAVE_YASSL 1
-
-#define COMMUNITY_SERVER 1
-#define ENABLED_PROFILING 1
-
-#define HAVE_BOOL 1
diff --git a/externals/mysql/decimal.h b/externals/mysql/decimal.h
deleted file mode 100644
index 530ed9e175..0000000000
--- a/externals/mysql/decimal.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef _decimal_h
-#define _decimal_h
-
-typedef enum
-{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
- decimal_round_mode;
-typedef int32 decimal_digit_t;
-
-typedef struct st_decimal_t {
- int intg, frac, len;
- my_bool sign;
- decimal_digit_t *buf;
-} decimal_t;
-
-int internal_str2dec(const char *from, decimal_t *to, char **end,
- my_bool fixed);
-int decimal2string(decimal_t *from, char *to, int *to_len,
- int fixed_precision, int fixed_decimals,
- char filler);
-int decimal2ulonglong(decimal_t *from, ulonglong *to);
-int ulonglong2decimal(ulonglong from, decimal_t *to);
-int decimal2longlong(decimal_t *from, longlong *to);
-int longlong2decimal(longlong from, decimal_t *to);
-int decimal2double(decimal_t *from, double *to);
-int double2decimal(double from, decimal_t *to);
-int decimal_actual_fraction(decimal_t *from);
-int decimal2bin(decimal_t *from, uchar *to, int precision, int scale);
-int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale);
-
-int decimal_size(int precision, int scale);
-int decimal_bin_size(int precision, int scale);
-int decimal_result_size(decimal_t *from1, decimal_t *from2, char op,
- int param);
-
-int decimal_intg(decimal_t *from);
-int decimal_add(decimal_t *from1, decimal_t *from2, decimal_t *to);
-int decimal_sub(decimal_t *from1, decimal_t *from2, decimal_t *to);
-int decimal_cmp(decimal_t *from1, decimal_t *from2);
-int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to);
-int decimal_div(decimal_t *from1, decimal_t *from2, decimal_t *to,
- int scale_incr);
-int decimal_mod(decimal_t *from1, decimal_t *from2, decimal_t *to);
-int decimal_round(decimal_t *from, decimal_t *to, int new_scale,
- decimal_round_mode mode);
-int decimal_is_zero(decimal_t *from);
-void max_decimal(int precision, int frac, decimal_t *to);
-
-#define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0)
-#define string2decimal_fixed(A,B,C) internal_str2dec((A), (B), (C), 1)
-
-/* set a decimal_t to zero */
-
-#define decimal_make_zero(dec) do { \
- (dec)->buf[0]=0; \
- (dec)->intg=1; \
- (dec)->frac=0; \
- (dec)->sign=0; \
- } while(0)
-
-/*
- returns the length of the buffer to hold string representation
- of the decimal (including decimal dot, possible sign and \0)
-*/
-
-#define decimal_string_size(dec) (((dec)->intg ? (dec)->intg : 1) + \
- (dec)->frac + ((dec)->frac > 0) + 2)
-
-/* negate a decimal */
-#define decimal_neg(dec) do { (dec)->sign^=1; } while(0)
-
-/*
- conventions:
-
- decimal_smth() == 0 -- everything's ok
- decimal_smth() <= 1 -- result is usable, but precision loss is possible
- decimal_smth() <= 2 -- result can be unusable, most significant digits
- could've been lost
- decimal_smth() > 2 -- no result was generated
-*/
-
-#define E_DEC_OK 0
-#define E_DEC_TRUNCATED 1
-#define E_DEC_OVERFLOW 2
-#define E_DEC_DIV_ZERO 4
-#define E_DEC_BAD_NUM 8
-#define E_DEC_OOM 16
-
-#define E_DEC_ERROR 31
-#define E_DEC_FATAL_ERROR 30
-
-#endif
-
diff --git a/externals/mysql/errmsg.h b/externals/mysql/errmsg.h
deleted file mode 100644
index 92d70abb9f..0000000000
--- a/externals/mysql/errmsg.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* Error messages for MySQL clients */
-/* (Error messages for the daemon are in sql/share/errmsg.txt) */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-void init_client_errs(void);
-void finish_client_errs(void);
-extern const char *client_errors[]; /* Error messages */
-#ifdef __cplusplus
-}
-#endif
-
-#define CR_MIN_ERROR 2000 /* For easier client code */
-#define CR_MAX_ERROR 2999
-#if !defined(ER)
-#define ER(X) client_errors[(X)-CR_MIN_ERROR]
-#endif
-#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
-
-/* Do not add error numbers before CR_ERROR_FIRST. */
-/* If necessary to add lower numbers, change CR_ERROR_FIRST accordingly. */
-#define CR_ERROR_FIRST 2000 /*Copy first error nr.*/
-#define CR_UNKNOWN_ERROR 2000
-#define CR_SOCKET_CREATE_ERROR 2001
-#define CR_CONNECTION_ERROR 2002
-#define CR_CONN_HOST_ERROR 2003
-#define CR_IPSOCK_ERROR 2004
-#define CR_UNKNOWN_HOST 2005
-#define CR_SERVER_GONE_ERROR 2006
-#define CR_VERSION_ERROR 2007
-#define CR_OUT_OF_MEMORY 2008
-#define CR_WRONG_HOST_INFO 2009
-#define CR_LOCALHOST_CONNECTION 2010
-#define CR_TCP_CONNECTION 2011
-#define CR_SERVER_HANDSHAKE_ERR 2012
-#define CR_SERVER_LOST 2013
-#define CR_COMMANDS_OUT_OF_SYNC 2014
-#define CR_NAMEDPIPE_CONNECTION 2015
-#define CR_NAMEDPIPEWAIT_ERROR 2016
-#define CR_NAMEDPIPEOPEN_ERROR 2017
-#define CR_NAMEDPIPESETSTATE_ERROR 2018
-#define CR_CANT_READ_CHARSET 2019
-#define CR_NET_PACKET_TOO_LARGE 2020
-#define CR_EMBEDDED_CONNECTION 2021
-#define CR_PROBE_SLAVE_STATUS 2022
-#define CR_PROBE_SLAVE_HOSTS 2023
-#define CR_PROBE_SLAVE_CONNECT 2024
-#define CR_PROBE_MASTER_CONNECT 2025
-#define CR_SSL_CONNECTION_ERROR 2026
-#define CR_MALFORMED_PACKET 2027
-#define CR_WRONG_LICENSE 2028
-
-/* new 4.1 error codes */
-#define CR_NULL_POINTER 2029
-#define CR_NO_PREPARE_STMT 2030
-#define CR_PARAMS_NOT_BOUND 2031
-#define CR_DATA_TRUNCATED 2032
-#define CR_NO_PARAMETERS_EXISTS 2033
-#define CR_INVALID_PARAMETER_NO 2034
-#define CR_INVALID_BUFFER_USE 2035
-#define CR_UNSUPPORTED_PARAM_TYPE 2036
-
-#define CR_SHARED_MEMORY_CONNECTION 2037
-#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2038
-#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2039
-#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2040
-#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2041
-#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2042
-#define CR_SHARED_MEMORY_MAP_ERROR 2043
-#define CR_SHARED_MEMORY_EVENT_ERROR 2044
-#define CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR 2045
-#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2046
-#define CR_CONN_UNKNOW_PROTOCOL 2047
-#define CR_INVALID_CONN_HANDLE 2048
-#define CR_SECURE_AUTH 2049
-#define CR_FETCH_CANCELED 2050
-#define CR_NO_DATA 2051
-#define CR_NO_STMT_METADATA 2052
-#define CR_NO_RESULT_SET 2053
-#define CR_NOT_IMPLEMENTED 2054
-#define CR_SERVER_LOST_EXTENDED 2055
-#define CR_STMT_CLOSED 2056
-#define CR_NEW_STMT_METADATA 2057
-#define CR_ALREADY_CONNECTED 2058
-#define CR_ERROR_LAST /*Copy last error nr:*/ 2058
-/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
-
diff --git a/externals/mysql/extlib/dbug/dbug.c b/externals/mysql/extlib/dbug/dbug.c
deleted file mode 100644
index 68932adf1e..0000000000
--- a/externals/mysql/extlib/dbug/dbug.c
+++ /dev/null
@@ -1,2583 +0,0 @@
-/******************************************************************************
- * *
- * N O T I C E *
- * *
- * Copyright Abandoned, 1987, Fred Fish *
- * *
- * *
- * This previously copyrighted work has been placed into the public *
- * domain by the author and may be freely used for any purpose, *
- * private or commercial. *
- * *
- * Because of the number of inquiries I was receiving about the use *
- * of this product in commercially developed works I have decided to *
- * simply make it public domain to further its unrestricted use. I *
- * specifically would be most happy to see this material become a *
- * part of the standard Unix distributions by AT&T and the Berkeley *
- * Computer Science Research Group, and a standard part of the GNU *
- * system from the Free Software Foundation. *
- * *
- * I would appreciate it, as a courtesy, if this notice is left in *
- * all copies and derivative works. Thank you. *
- * *
- * The author makes no warranty of any kind with respect to this *
- * product and explicitly disclaims any implied warranties of mer- *
- * chantability or fitness for any particular purpose. *
- * *
- ******************************************************************************
- */
-
-/*
- * FILE
- *
- * dbug.c runtime support routines for dbug package
- *
- * SCCS
- *
- * @(#)dbug.c 1.25 7/25/89
- *
- * DESCRIPTION
- *
- * These are the runtime support routines for the dbug package.
- * The dbug package has two main components; the user include
- * file containing various macro definitions, and the runtime
- * support routines which are called from the macro expansions.
- *
- * Externally visible functions in the runtime support module
- * use the naming convention pattern "_db_xx...xx_", thus
- * they are unlikely to collide with user defined function names.
- *
- * AUTHOR(S)
- *
- * Fred Fish (base code)
- * Enhanced Software Technologies, Tempe, AZ
- * asuvax!mcdphx!estinc!fnf
- *
- * Binayak Banerjee (profiling enhancements)
- * seismo!bpa!sjuvax!bbanerje
- *
- * Michael Widenius:
- * DBUG_DUMP - To dump a block of memory.
- * PUSH_FLAG "O" - To be used insted of "o" if we
- * want flushing after each write
- * PUSH_FLAG "A" - as 'O', but we will append to the out file instead
- * of creating a new one.
- * Check of malloc on entry/exit (option "S")
- *
- * Sergei Golubchik:
- * DBUG_EXECUTE_IF
- * incremental mode (-#+t:-d,info ...)
- * DBUG_SET, _db_explain_
- * thread-local settings
- * negative lists (-#-d,info => everything but "info")
- *
- * function/ syntax
- * (the logic is - think of a call stack as of a path.
- * "function" means only this function, "function/" means the hierarchy.
- * in the future, filters like function1/function2 could be supported.
- * following this logic glob(7) wildcards are supported.)
- *
- */
-
-/*
- We can't have SAFE_MUTEX defined here as this will cause recursion
- in pthread_mutex_lock
-*/
-
-#undef SAFE_MUTEX
-#include
-#include
-#include
-
-#ifdef HAVE_FNMATCH_H
-#include
-#else
-#define fnmatch(A,B,C) strcmp(A,B)
-#endif
-
-#if defined(MSDOS) || defined(__WIN__)
-#include
-#endif
-
-#ifndef DBUG_OFF
-
-
-/*
- * Manifest constants which may be "tuned" if desired.
- */
-
-#define PRINTBUF 1024 /* Print buffer size */
-#define INDENT 2 /* Indentation per trace level */
-#define MAXDEPTH 200 /* Maximum trace depth default */
-
-/*
- * The following flags are used to determine which
- * capabilities the user has enabled with the settings
- * push macro.
- *
- * TRACE_ON is also used in _db_stack_frame_->level
- * (until we add flags to _db_stack_frame_, increasing it by 4 bytes)
- */
-
-#define DEBUG_ON (1 << 1) /* Debug enabled */
-#define FILE_ON (1 << 2) /* File name print enabled */
-#define LINE_ON (1 << 3) /* Line number print enabled */
-#define DEPTH_ON (1 << 4) /* Function nest level print enabled */
-#define PROCESS_ON (1 << 5) /* Process name print enabled */
-#define NUMBER_ON (1 << 6) /* Number each line of output */
-#define PROFILE_ON (1 << 7) /* Print out profiling code */
-#define PID_ON (1 << 8) /* Identify each line with process id */
-#define TIMESTAMP_ON (1 << 9) /* timestamp every line of output */
-#define SANITY_CHECK_ON (1 << 10) /* Check safemalloc on DBUG_ENTER */
-#define FLUSH_ON_WRITE (1 << 11) /* Flush on every write */
-#define OPEN_APPEND (1 << 12) /* Open for append */
-#define TRACE_ON ((uint)1 << 31) /* Trace enabled. MUST be the highest bit!*/
-
-#define TRACING (cs->stack->flags & TRACE_ON)
-#define DEBUGGING (cs->stack->flags & DEBUG_ON)
-#define PROFILING (cs->stack->flags & PROFILE_ON)
-
-/*
- * Typedefs to make things more obvious.
- */
-
-#define BOOLEAN my_bool
-
-/*
- * Make it easy to change storage classes if necessary.
- */
-
-#define IMPORT extern /* Names defined externally */
-#define EXPORT /* Allocated here, available globally */
-#define AUTO auto /* Names to be allocated on stack */
-#define REGISTER register /* Names to be placed in registers */
-
-/*
- * The default file for profiling. Could also add another flag
- * (G?) which allowed the user to specify this.
- *
- * If the automatic variables get allocated on the stack in
- * reverse order from their declarations, then define AUTOS_REVERSE to 1.
- * This is used by the code that keeps track of stack usage. For
- * forward allocation, the difference in the dbug frame pointers
- * represents stack used by the callee function. For reverse allocation,
- * the difference represents stack used by the caller function.
- *
- */
-
-#define PROF_FILE "dbugmon.out"
-#define PROF_EFMT "E\t%ld\t%s\n"
-#define PROF_SFMT "S\t%lx\t%lx\t%s\n"
-#define PROF_XFMT "X\t%ld\t%s\n"
-
-#ifdef M_I386 /* predefined by xenix 386 compiler */
-#define AUTOS_REVERSE 1
-#else
-#define AUTOS_REVERSE 0
-#endif
-
-/*
- * Externally supplied functions.
- */
-
-#ifndef HAVE_PERROR
-static void perror(); /* Fake system/library error print routine */
-#endif
-
-#ifdef SAFEMALLOC
-IMPORT int _sanity(const char *file,uint line); /* safemalloc sanity checker */
-#else
-#define _sanity(X,Y) (1)
-#endif
-
-/*
- * The user may specify a list of functions to trace or
- * debug. These lists are kept in a linear linked list,
- * a very simple implementation.
- */
-
-struct link {
- struct link *next_link; /* Pointer to the next link */
- char flags;
- char str[1]; /* Pointer to link's contents */
-};
-
-/* flags for struct link and return flags of InList */
-#define SUBDIR 1 /* this MUST be 1 */
-#define INCLUDE 2
-#define EXCLUDE 4
-/* this is not a struct link flag, but only a return flags of InList */
-#define MATCHED 65536
-#define NOT_MATCHED 0
-
-/*
- * Debugging settings can be pushed or popped off of a
- * stack which is implemented as a linked list. Note
- * that the head of the list is the current settings and the
- * stack is pushed by adding a new settings to the head of the
- * list or popped by removing the first link.
- *
- * Note: if out_file is NULL, the other fields are not initialized at all!
- */
-
-struct settings {
- uint flags; /* Current settings flags */
- uint maxdepth; /* Current maximum trace depth */
- uint delay; /* Delay after each output line */
- uint sub_level; /* Sub this from code_state->level */
- FILE *out_file; /* Current output stream */
- FILE *prof_file; /* Current profiling stream */
- char name[FN_REFLEN]; /* Name of output file */
- struct link *functions; /* List of functions */
- struct link *p_functions; /* List of profiled functions */
- struct link *keywords; /* List of debug keywords */
- struct link *processes; /* List of process names */
- struct settings *next; /* Next settings in the list */
-};
-
-#define is_shared(S, V) ((S)->next && (S)->next->V == (S)->V)
-
-/*
- * Local variables not seen by user.
- */
-
-
-static BOOLEAN init_done= FALSE; /* Set to TRUE when initialization done */
-static struct settings init_settings;
-static const char *db_process= 0;/* Pointer to process name; argv[0] */
-my_bool _dbug_on_= TRUE; /* FALSE if no debugging at all */
-
-typedef struct _db_code_state_ {
- const char *process; /* Pointer to process name; usually argv[0] */
- const char *func; /* Name of current user function */
- const char *file; /* Name of current user file */
- struct _db_stack_frame_ *framep; /* Pointer to current frame */
- struct settings *stack; /* debugging settings */
- const char *jmpfunc; /* Remember current function for setjmp */
- const char *jmpfile; /* Remember current file for setjmp */
- int lineno; /* Current debugger output line number */
- uint level; /* Current function nesting level */
- int jmplevel; /* Remember nesting level at setjmp() */
-
-/*
- * The following variables are used to hold the state information
- * between the call to _db_pargs_() and _db_doprnt_(), during
- * expansion of the DBUG_PRINT macro. This is the only macro
- * that currently uses these variables.
- *
- * These variables are currently used only by _db_pargs_() and
- * _db_doprnt_().
- */
-
- uint u_line; /* User source code line number */
- int locked; /* If locked with _db_lock_file_ */
- const char *u_keyword; /* Keyword for current macro */
-} CODE_STATE;
-
-/*
- The test below is so we could call functions with DBUG_ENTER before
- my_thread_init().
-*/
-#define get_code_state_if_not_set_or_return if (!cs && !((cs=code_state()))) return
-#define get_code_state_or_return if (!((cs=code_state()))) return
-
- /* Handling lists */
-#define ListAdd(A,B,C) ListAddDel(A,B,C,INCLUDE)
-#define ListDel(A,B,C) ListAddDel(A,B,C,EXCLUDE)
-static struct link *ListAddDel(struct link *, const char *, const char *, int);
-static struct link *ListCopy(struct link *);
-static int InList(struct link *linkp,const char *cp);
-static uint ListFlags(struct link *linkp);
-static void FreeList(struct link *linkp);
-
- /* OpenClose debug output stream */
-static void DBUGOpenFile(CODE_STATE *,const char *, const char *, int);
-static void DBUGCloseFile(CODE_STATE *cs, FILE *fp);
- /* Push current debug settings */
-static void PushState(CODE_STATE *cs);
- /* Free memory associated with debug state. */
-static void FreeState (CODE_STATE *cs, struct settings *state, int free_state);
- /* Test for tracing enabled */
-static int DoTrace(CODE_STATE *cs);
-/*
- return values of DoTrace.
- Can also be used as bitmask: ret & DO_TRACE
-*/
-#define DO_TRACE 1
-#define DONT_TRACE 2
-#define ENABLE_TRACE 3
-#define DISABLE_TRACE 4
-
- /* Test to see if file is writable */
-#if defined(HAVE_ACCESS) && !defined(MSDOS)
-static BOOLEAN Writable(const char *pathname);
- /* Change file owner and group */
-static void ChangeOwner(CODE_STATE *cs, char *pathname);
- /* Allocate memory for runtime support */
-#endif
-
-static void DoPrefix(CODE_STATE *cs, uint line);
-
-static char *DbugMalloc(size_t size);
-static const char *BaseName(const char *pathname);
-static void Indent(CODE_STATE *cs, int indent);
-static void DbugFlush(CODE_STATE *);
-static void DbugExit(const char *why);
-static const char *DbugStrTok(const char *s);
-static void DbugFprintf(FILE *stream, const char* format, va_list args);
-
-#ifndef THREAD
- /* Open profile output stream */
-static FILE *OpenProfile(CODE_STATE *cs, const char *name);
- /* Profile if asked for it */
-static BOOLEAN DoProfile(CODE_STATE *);
- /* Return current user time (ms) */
-static unsigned long Clock(void);
-#endif
-
-/*
- * Miscellaneous printf format strings.
- */
-
-#define ERR_MISSING_RETURN "%s: missing DBUG_RETURN or DBUG_VOID_RETURN macro in function \"%s\"\n"
-#define ERR_OPEN "%s: can't open debug output stream \"%s\": "
-#define ERR_CLOSE "%s: can't close debug file: "
-#define ERR_ABORT "%s: debugger aborting because %s\n"
-#define ERR_CHOWN "%s: can't change owner/group of \"%s\": "
-
-/*
- * Macros and defines for testing file accessibility under UNIX and MSDOS.
- */
-
-#undef EXISTS
-#if !defined(HAVE_ACCESS) || defined(MSDOS)
-#define EXISTS(pathname) (FALSE) /* Assume no existance */
-#define Writable(name) (TRUE)
-#else
-#define EXISTS(pathname) (access(pathname, F_OK) == 0)
-#define WRITABLE(pathname) (access(pathname, W_OK) == 0)
-#endif
-#ifndef MSDOS
-#define ChangeOwner(cs,name)
-#endif
-
-
-/*
-** Macros to allow dbugging with threads
-*/
-
-#ifdef THREAD
-#include
-static pthread_mutex_t THR_LOCK_dbug;
-
-static CODE_STATE *code_state(void)
-{
- CODE_STATE *cs, **cs_ptr;
-
- /*
- _dbug_on_ is reset if we don't plan to use any debug commands at all and
- we want to run on maximum speed
- */
- if (!_dbug_on_)
- return 0;
-
- if (!init_done)
- {
- init_done=TRUE;
- pthread_mutex_init(&THR_LOCK_dbug,MY_MUTEX_INIT_FAST);
- bzero(&init_settings, sizeof(init_settings));
- init_settings.out_file=stderr;
- init_settings.flags=OPEN_APPEND;
- }
-
- if (!(cs_ptr= (CODE_STATE**) my_thread_var_dbug()))
- return 0; /* Thread not initialised */
- if (!(cs= *cs_ptr))
- {
- cs=(CODE_STATE*) DbugMalloc(sizeof(*cs));
- bzero((uchar*) cs,sizeof(*cs));
- cs->process= db_process ? db_process : "dbug";
- cs->func="?func";
- cs->file="?file";
- cs->stack=&init_settings;
- *cs_ptr= cs;
- }
- return cs;
-}
-
-#else /* !THREAD */
-
-static CODE_STATE static_code_state=
-{
- "dbug", "?func", "?file", NULL, &init_settings,
- NullS, NullS, 0,0,0,0,0,NullS
-};
-
-static CODE_STATE *code_state(void)
-{
- if (!init_done)
- {
- bzero(&init_settings, sizeof(init_settings));
- init_settings.out_file=stderr;
- init_settings.flags=OPEN_APPEND;
- init_done=TRUE;
- }
- return &static_code_state;
-}
-
-#define pthread_mutex_lock(A) {}
-#define pthread_mutex_unlock(A) {}
-#endif
-
-/*
- * Translate some calls among different systems.
- */
-
-#ifdef HAVE_SLEEP
-/* sleep() wants seconds */
-#define Delay(A) sleep(((uint) A)/10)
-#else
-#define Delay(A) (0)
-#endif
-
-/*
- * FUNCTION
- *
- * _db_process_ give the name to the current process/thread
- *
- * SYNOPSIS
- *
- * VOID _process_(name)
- * char *name;
- *
- */
-
-void _db_process_(const char *name)
-{
- CODE_STATE *cs;
-
- if (!db_process)
- db_process= name;
-
- get_code_state_or_return;
- cs->process= name;
-}
-
-/*
- * FUNCTION
- *
- * DbugParse parse control string and set current debugger settings
- *
- * DESCRIPTION
- *
- * Given pointer to a debug control string in "control",
- * parses the control string, and sets
- * up a current debug settings.
- *
- * The debug control string is a sequence of colon separated fields
- * as follows:
- *
- * [+]::...:
- *
- * Each field consists of a mandatory flag character followed by
- * an optional "," and comma separated list of modifiers:
- *
- * [sign]flag[,modifier,modifier,...,modifier]
- *
- * See the manual for the list of supported signs, flags, and modifiers
- *
- * For convenience, any leading "-#" is stripped off.
- *
- * RETURN
- * 1 - a list of functions ("f" flag) was possibly changed
- * 0 - a list of functions was not changed
- */
-
-int DbugParse(CODE_STATE *cs, const char *control)
-{
- const char *end;
- int rel, f_used=0;
- struct settings *stack;
-
- stack= cs->stack;
-
- if (control[0] == '-' && control[1] == '#')
- control+=2;
-
- rel= control[0] == '+' || control[0] == '-';
- if ((!rel || (!stack->out_file && !stack->next)))
- {
- FreeState(cs, stack, 0);
- stack->flags= 0;
- stack->delay= 0;
- stack->maxdepth= 0;
- stack->sub_level= 0;
- stack->out_file= stderr;
- stack->prof_file= NULL;
- stack->functions= NULL;
- stack->p_functions= NULL;
- stack->keywords= NULL;
- stack->processes= NULL;
- }
- else if (!stack->out_file)
- {
- stack->flags= stack->next->flags;
- stack->delay= stack->next->delay;
- stack->maxdepth= stack->next->maxdepth;
- stack->sub_level= stack->next->sub_level;
- strcpy(stack->name, stack->next->name);
- stack->out_file= stack->next->out_file;
- stack->prof_file= stack->next->prof_file;
- if (stack->next == &init_settings)
- {
- /* never share with the global parent - it can change under your feet */
- stack->functions= ListCopy(init_settings.functions);
- stack->p_functions= ListCopy(init_settings.p_functions);
- stack->keywords= ListCopy(init_settings.keywords);
- stack->processes= ListCopy(init_settings.processes);
- }
- else
- {
- stack->functions= stack->next->functions;
- stack->p_functions= stack->next->p_functions;
- stack->keywords= stack->next->keywords;
- stack->processes= stack->next->processes;
- }
- }
-
- end= DbugStrTok(control);
- while (control < end)
- {
- int c, sign= (*control == '+') ? 1 : (*control == '-') ? -1 : 0;
- if (sign) control++;
- c= *control++;
- if (*control == ',') control++;
- /* XXX when adding new cases here, don't forget _db_explain_ ! */
- switch (c) {
- case 'd':
- if (sign < 0 && control == end)
- {
- if (!is_shared(stack, keywords))
- FreeList(stack->keywords);
- stack->keywords=NULL;
- stack->flags &= ~DEBUG_ON;
- break;
- }
- if (rel && is_shared(stack, keywords))
- stack->keywords= ListCopy(stack->keywords);
- if (sign < 0)
- {
- if (DEBUGGING)
- stack->keywords= ListDel(stack->keywords, control, end);
- break;
- }
- stack->keywords= ListAdd(stack->keywords, control, end);
- stack->flags |= DEBUG_ON;
- break;
- case 'D':
- stack->delay= atoi(control);
- break;
- case 'f':
- f_used= 1;
- if (sign < 0 && control == end)
- {
- if (!is_shared(stack,functions))
- FreeList(stack->functions);
- stack->functions=NULL;
- break;
- }
- if (rel && is_shared(stack,functions))
- stack->functions= ListCopy(stack->functions);
- if (sign < 0)
- stack->functions= ListDel(stack->functions, control, end);
- else
- stack->functions= ListAdd(stack->functions, control, end);
- break;
- case 'F':
- if (sign < 0)
- stack->flags &= ~FILE_ON;
- else
- stack->flags |= FILE_ON;
- break;
- case 'i':
- if (sign < 0)
- stack->flags &= ~PID_ON;
- else
- stack->flags |= PID_ON;
- break;
-#ifndef THREAD
- case 'g':
- if (OpenProfile(cs, PROF_FILE))
- {
- stack->flags |= PROFILE_ON;
- stack->p_functions= ListAdd(stack->p_functions, control, end);
- }
- break;
-#endif
- case 'L':
- if (sign < 0)
- stack->flags &= ~LINE_ON;
- else
- stack->flags |= LINE_ON;
- break;
- case 'n':
- if (sign < 0)
- stack->flags &= ~DEPTH_ON;
- else
- stack->flags |= DEPTH_ON;
- break;
- case 'N':
- if (sign < 0)
- stack->flags &= ~NUMBER_ON;
- else
- stack->flags |= NUMBER_ON;
- break;
- case 'A':
- case 'O':
- stack->flags |= FLUSH_ON_WRITE;
- /* fall through */
- case 'a':
- case 'o':
- if (sign < 0)
- {
- if (!is_shared(stack, out_file))
- DBUGCloseFile(cs, stack->out_file);
- stack->flags &= ~FLUSH_ON_WRITE;
- stack->out_file= stderr;
- break;
- }
- if (c == 'a' || c == 'A')
- stack->flags |= OPEN_APPEND;
- else
- stack->flags &= ~OPEN_APPEND;
- if (control != end)
- DBUGOpenFile(cs, control, end, stack->flags & OPEN_APPEND);
- else
- DBUGOpenFile(cs, "-",0,0);
- break;
- case 'p':
- if (sign < 0 && control == end)
- {
- if (!is_shared(stack,processes))
- FreeList(stack->processes);
- stack->processes=NULL;
- break;
- }
- if (rel && is_shared(stack, processes))
- stack->processes= ListCopy(stack->processes);
- if (sign < 0)
- stack->processes= ListDel(stack->processes, control, end);
- else
- stack->processes= ListAdd(stack->processes, control, end);
- break;
- case 'P':
- if (sign < 0)
- stack->flags &= ~PROCESS_ON;
- else
- stack->flags |= PROCESS_ON;
- break;
- case 'r':
- stack->sub_level= cs->level;
- break;
- case 't':
- if (sign < 0)
- {
- if (control != end)
- stack->maxdepth-= atoi(control);
- else
- stack->maxdepth= 0;
- }
- else
- {
- if (control != end)
- stack->maxdepth+= atoi(control);
- else
- stack->maxdepth= MAXDEPTH;
- }
- if (stack->maxdepth > 0)
- stack->flags |= TRACE_ON;
- else
- stack->flags &= ~TRACE_ON;
- break;
- case 'T':
- if (sign < 0)
- stack->flags &= ~TIMESTAMP_ON;
- else
- stack->flags |= TIMESTAMP_ON;
- break;
- case 'S':
- if (sign < 0)
- stack->flags &= ~SANITY_CHECK_ON;
- else
- stack->flags |= SANITY_CHECK_ON;
- break;
- }
- if (!*end)
- break;
- control=end+1;
- end= DbugStrTok(control);
- }
- return !rel || f_used;
-}
-
-#define framep_trace_flag(cs, frp) (frp ? \
- frp->level & TRACE_ON : \
- (ListFlags(cs->stack->functions) & INCLUDE) ? \
- 0 : (uint)TRACE_ON)
-
-void FixTraceFlags_helper(CODE_STATE *cs, const char *func,
- struct _db_stack_frame_ *framep)
-{
- if (framep->prev)
- FixTraceFlags_helper(cs, framep->func, framep->prev);
-
- cs->func= func;
- cs->level= framep->level & ~TRACE_ON;
- framep->level= cs->level | framep_trace_flag(cs, framep->prev);
- /*
- we don't set cs->framep correctly, even though DoTrace uses it.
- It's ok, because cs->framep may only affect DO_TRACE/DONT_TRACE return
- values, but we ignore them here anyway
- */
- switch(DoTrace(cs)) {
- case ENABLE_TRACE:
- framep->level|= TRACE_ON;
- break;
- case DISABLE_TRACE:
- framep->level&= ~TRACE_ON;
- break;
- }
-}
-
-#define fflags(cs) cs->stack->out_file ? ListFlags(cs->stack->functions) : TRACE_ON;
-
-void FixTraceFlags(uint old_fflags, CODE_STATE *cs)
-{
- const char *func;
- uint new_fflags, traceon, level;
- struct _db_stack_frame_ *framep;
-
- /*
- first (a.k.a. safety) check:
- if we haven't started tracing yet, no call stack at all - we're safe.
- */
- framep=cs->framep;
- if (framep == 0)
- return;
-
- /*
- Ok, the tracing has started, call stack isn't empty.
-
- second check: does the new list have a SUBDIR rule ?
- */
- new_fflags=fflags(cs);
- if (new_fflags & SUBDIR)
- goto yuck;
-
- /*
- Ok, new list doesn't use SUBDIR.
-
- third check: we do NOT need to re-scan if
- neither old nor new lists used SUBDIR flag and if a default behavior
- (whether an unlisted function is traced) hasn't changed.
- Default behavior depends on whether there're INCLUDE elements in the list.
- */
- if (!(old_fflags & SUBDIR) && !((new_fflags^old_fflags) & INCLUDE))
- return;
-
- /*
- Ok, old list may've used SUBDIR, or defaults could've changed.
-
- fourth check: are we inside a currently active SUBDIR rule ?
- go up the call stack, if TRACE_ON flag ever changes its value - we are.
- */
- for (traceon=framep->level; framep; framep=framep->prev)
- if ((traceon ^ framep->level) & TRACE_ON)
- goto yuck;
-
- /*
- Ok, TRACE_ON flag doesn't change in the call stack.
-
- fifth check: but is the top-most value equal to a default one ?
- */
- if (((traceon & TRACE_ON) != 0) == ((new_fflags & INCLUDE) == 0))
- return;
-
-yuck:
- /*
- Yuck! function list was changed, and one of the currently active rules
- was possibly affected. For example, a tracing could've been enabled or
- disabled for a function somewhere up the call stack.
- To react correctly, we must go up the call stack all the way to
- the top and re-match rules to set TRACE_ON bit correctly.
-
- We must traverse the stack forwards, not backwards.
- That's what a recursive helper is doing.
- It'll destroy two CODE_STATE fields, save them now.
- */
- func= cs->func;
- level= cs->level;
- FixTraceFlags_helper(cs, func, cs->framep);
- /* now we only need to restore CODE_STATE fields, and we're done */
- cs->func= func;
- cs->level= level;
-}
-
-/*
- * FUNCTION
- *
- * _db_set_ set current debugger settings
- *
- * SYNOPSIS
- *
- * VOID _db_set_(control)
- * char *control;
- *
- * DESCRIPTION
- *
- * Given pointer to a debug control string in "control",
- * parses the control string, and sets up a current debug
- * settings. Pushes a new debug settings if the current is
- * set to the initial debugger settings.
- *
- */
-
-void _db_set_(const char *control)
-{
- CODE_STATE *cs;
- uint old_fflags;
- get_code_state_or_return;
- old_fflags=fflags(cs);
- if (cs->stack == &init_settings)
- PushState(cs);
- if (DbugParse(cs, control))
- FixTraceFlags(old_fflags, cs);
-}
-
-/*
- * FUNCTION
- *
- * _db_push_ push current debugger settings and set up new one
- *
- * SYNOPSIS
- *
- * VOID _db_push_(control)
- * char *control;
- *
- * DESCRIPTION
- *
- * Given pointer to a debug control string in "control", pushes
- * the current debug settings, parses the control string, and sets
- * up a new debug settings with DbugParse()
- *
- */
-
-void _db_push_(const char *control)
-{
- CODE_STATE *cs;
- uint old_fflags;
- get_code_state_or_return;
- old_fflags=fflags(cs);
- PushState(cs);
- if (DbugParse(cs, control))
- FixTraceFlags(old_fflags, cs);
-}
-
-
-/**
- Returns TRUE if session-local settings have been set.
-*/
-
-int _db_is_pushed_()
-{
- CODE_STATE *cs= NULL;
- get_code_state_or_return FALSE;
- return (cs->stack != &init_settings);
-}
-
-/*
- * FUNCTION
- *
- * _db_set_init_ set initial debugger settings
- *
- * SYNOPSIS
- *
- * VOID _db_set_init_(control)
- * char *control;
- *
- * DESCRIPTION
- * see _db_set_
- *
- */
-
-void _db_set_init_(const char *control)
-{
- CODE_STATE tmp_cs;
- bzero((uchar*) &tmp_cs, sizeof(tmp_cs));
- tmp_cs.stack= &init_settings;
- DbugParse(&tmp_cs, control);
-}
-
-/*
- * FUNCTION
- *
- * _db_pop_ pop the debug stack
- *
- * DESCRIPTION
- *
- * Pops the debug stack, returning the debug settings to its
- * condition prior to the most recent _db_push_ invocation.
- * Note that the pop will fail if it would remove the last
- * valid settings from the stack. This prevents user errors
- * in the push/pop sequence from screwing up the debugger.
- * Maybe there should be some kind of warning printed if the
- * user tries to pop too many states.
- *
- */
-
-void _db_pop_()
-{
- struct settings *discard;
- uint old_fflags;
- CODE_STATE *cs;
-
- get_code_state_or_return;
-
- discard= cs->stack;
- if (discard != &init_settings)
- {
- old_fflags=fflags(cs);
- cs->stack= discard->next;
- FreeState(cs, discard, 1);
- FixTraceFlags(old_fflags, cs);
- }
-}
-
-/*
- * FUNCTION
- *
- * _db_explain_ generates 'control' string for the current settings
- *
- * RETURN
- * 0 - ok
- * 1 - buffer too short, output truncated
- *
- */
-
-/* helper macros */
-#define char_to_buf(C) do { \
- *buf++=(C); \
- if (buf >= end) goto overflow; \
- } while (0)
-#define str_to_buf(S) do { \
- char_to_buf(','); \
- buf=strnmov(buf, (S), len+1); \
- if (buf >= end) goto overflow; \
- } while (0)
-#define list_to_buf(l, f) do { \
- struct link *listp=(l); \
- while (listp) \
- { \
- if (listp->flags & (f)) \
- { \
- str_to_buf(listp->str); \
- if (listp->flags & SUBDIR) \
- char_to_buf('/'); \
- } \
- listp=listp->next_link; \
- } \
- } while (0)
-#define int_to_buf(i) do { \
- char b[50]; \
- int10_to_str((i), b, 10); \
- str_to_buf(b); \
- } while (0)
-#define colon_to_buf do { \
- if (buf != start) char_to_buf(':'); \
- } while(0)
-#define op_int_to_buf(C, val, def) do { \
- if ((val) != (def)) \
- { \
- colon_to_buf; \
- char_to_buf((C)); \
- int_to_buf(val); \
- } \
- } while (0)
-#define op_intf_to_buf(C, val, def, cond) do { \
- if ((cond)) \
- { \
- colon_to_buf; \
- char_to_buf((C)); \
- if ((val) != (def)) int_to_buf(val); \
- } \
- } while (0)
-#define op_str_to_buf(C, val, cond) do { \
- if ((cond)) \
- { \
- char *s=(val); \
- colon_to_buf; \
- char_to_buf((C)); \
- if (*s) str_to_buf(s); \
- } \
- } while (0)
-#define op_list_to_buf(C, val, cond) do { \
- if ((cond)) \
- { \
- int f=ListFlags(val); \
- colon_to_buf; \
- char_to_buf((C)); \
- if (f & INCLUDE) \
- list_to_buf(val, INCLUDE); \
- if (f & EXCLUDE) \
- { \
- colon_to_buf; \
- char_to_buf('-'); \
- char_to_buf((C)); \
- list_to_buf(val, EXCLUDE); \
- } \
- } \
- } while (0)
-#define op_bool_to_buf(C, cond) do { \
- if ((cond)) \
- { \
- colon_to_buf; \
- char_to_buf((C)); \
- } \
- } while (0)
-
-int _db_explain_ (CODE_STATE *cs, char *buf, size_t len)
-{
- char *start=buf, *end=buf+len-4;
-
- get_code_state_if_not_set_or_return *buf=0;
-
- op_list_to_buf('d', cs->stack->keywords, DEBUGGING);
- op_int_to_buf ('D', cs->stack->delay, 0);
- op_list_to_buf('f', cs->stack->functions, cs->stack->functions);
- op_bool_to_buf('F', cs->stack->flags & FILE_ON);
- op_bool_to_buf('i', cs->stack->flags & PID_ON);
- op_list_to_buf('g', cs->stack->p_functions, PROFILING);
- op_bool_to_buf('L', cs->stack->flags & LINE_ON);
- op_bool_to_buf('n', cs->stack->flags & DEPTH_ON);
- op_bool_to_buf('N', cs->stack->flags & NUMBER_ON);
- op_str_to_buf(
- ((cs->stack->flags & FLUSH_ON_WRITE ? 0 : 32) |
- (cs->stack->flags & OPEN_APPEND ? 'A' : 'O')),
- cs->stack->name, cs->stack->out_file != stderr);
- op_list_to_buf('p', cs->stack->processes, cs->stack->processes);
- op_bool_to_buf('P', cs->stack->flags & PROCESS_ON);
- op_bool_to_buf('r', cs->stack->sub_level != 0);
- op_intf_to_buf('t', cs->stack->maxdepth, MAXDEPTH, TRACING);
- op_bool_to_buf('T', cs->stack->flags & TIMESTAMP_ON);
- op_bool_to_buf('S', cs->stack->flags & SANITY_CHECK_ON);
-
- *buf= '\0';
- return 0;
-
-overflow:
- *end++= '.';
- *end++= '.';
- *end++= '.';
- *end= '\0';
- return 1;
-}
-
-#undef char_to_buf
-#undef str_to_buf
-#undef list_to_buf
-#undef int_to_buf
-#undef colon_to_buf
-#undef op_int_to_buf
-#undef op_intf_to_buf
-#undef op_str_to_buf
-#undef op_list_to_buf
-#undef op_bool_to_buf
-
-/*
- * FUNCTION
- *
- * _db_explain_init_ explain initial debugger settings
- *
- * DESCRIPTION
- * see _db_explain_
- */
-
-int _db_explain_init_(char *buf, size_t len)
-{
- CODE_STATE cs;
- bzero((uchar*) &cs,sizeof(cs));
- cs.stack=&init_settings;
- return _db_explain_(&cs, buf, len);
-}
-
-/*
- * FUNCTION
- *
- * _db_enter_ process entry point to user function
- *
- * SYNOPSIS
- *
- * VOID _db_enter_(_func_, _file_, _line_, _stack_frame_)
- * char *_func_; points to current function name
- * char *_file_; points to current file name
- * int _line_; called from source line number
- * struct _db_stack_frame_ allocated on the caller's stack
- *
- * DESCRIPTION
- *
- * Called at the beginning of each user function to tell
- * the debugger that a new function has been entered.
- * Note that the pointers to the previous user function
- * name and previous user file name are stored on the
- * caller's stack (this is why the ENTER macro must be
- * the first "executable" code in a function, since it
- * allocates these storage locations). The previous nesting
- * level is also stored on the callers stack for internal
- * self consistency checks.
- *
- * Also prints a trace line if tracing is enabled and
- * increments the current function nesting depth.
- *
- * Note that this mechanism allows the debugger to know
- * what the current user function is at all times, without
- * maintaining an internal stack for the function names.
- *
- */
-
-void _db_enter_(const char *_func_, const char *_file_,
- uint _line_, struct _db_stack_frame_ *_stack_frame_)
-{
- int save_errno;
- CODE_STATE *cs;
- if (!((cs=code_state())))
- {
- _stack_frame_->level= 0; /* Set to avoid valgrind warnings if dbug is enabled later */
- _stack_frame_->prev= 0;
- return;
- }
- save_errno= errno;
-
- _stack_frame_->func= cs->func;
- _stack_frame_->file= cs->file;
- cs->func= _func_;
- cs->file= _file_;
- _stack_frame_->prev= cs->framep;
- _stack_frame_->level= ++cs->level | framep_trace_flag(cs, cs->framep);
- cs->framep= _stack_frame_;
-#ifndef THREAD
- if (DoProfile(cs))
- {
- long stackused;
- if (cs->framep->prev == NULL)
- stackused= 0;
- else
- {
- stackused= (char*)(cs->framep->prev) - (char*)(cs->framep);
- stackused= stackused > 0 ? stackused : -stackused;
- }
- (void) fprintf(cs->stack->prof_file, PROF_EFMT , Clock(), cs->func);
- (void) fprintf(cs->stack->prof_file, PROF_SFMT, (ulong) cs->framep, stackused,
- AUTOS_REVERSE ? _stack_frame_->func : cs->func);
- (void) fflush(cs->stack->prof_file);
- }
-#endif
- switch (DoTrace(cs)) {
- case ENABLE_TRACE:
- cs->framep->level|= TRACE_ON;
- if (!TRACING) break;
- /* fall through */
- case DO_TRACE:
- if ((cs->stack->flags & SANITY_CHECK_ON) && _sanity(_file_,_line_))
- cs->stack->flags &= ~SANITY_CHECK_ON;
- if (TRACING)
- {
- if (!cs->locked)
- pthread_mutex_lock(&THR_LOCK_dbug);
- DoPrefix(cs, _line_);
- Indent(cs, cs->level);
- (void) fprintf(cs->stack->out_file, ">%s\n", cs->func);
- DbugFlush(cs); /* This does a unlock */
- }
- break;
- case DISABLE_TRACE:
- cs->framep->level&= ~TRACE_ON;
- /* fall through */
- case DONT_TRACE:
- break;
- }
- errno=save_errno;
-}
-
-/*
- * FUNCTION
- *
- * _db_return_ process exit from user function
- *
- * SYNOPSIS
- *
- * VOID _db_return_(_line_, _stack_frame_)
- * int _line_; current source line number
- * struct _db_stack_frame_ allocated on the caller's stack
- *
- * DESCRIPTION
- *
- * Called just before user function executes an explicit or implicit
- * return. Prints a trace line if trace is enabled, decrements
- * the current nesting level, and restores the current function and
- * file names from the defunct function's stack.
- *
- */
-
-/* helper macro */
-void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
-{
- int save_errno=errno;
- uint _slevel_= _stack_frame_->level & ~TRACE_ON;
- CODE_STATE *cs;
- get_code_state_or_return;
-
- if (cs->level != _slevel_)
- {
- if (!cs->locked)
- pthread_mutex_lock(&THR_LOCK_dbug);
- (void) fprintf(cs->stack->out_file, ERR_MISSING_RETURN, cs->process,
- cs->func);
- DbugFlush(cs);
- }
- else
- {
-#ifndef THREAD
- if (DoProfile(cs))
- (void) fprintf(cs->stack->prof_file, PROF_XFMT, Clock(), cs->func);
-#endif
- if (DoTrace(cs) & DO_TRACE)
- {
- if ((cs->stack->flags & SANITY_CHECK_ON) &&
- _sanity(_stack_frame_->file,_line_))
- cs->stack->flags &= ~SANITY_CHECK_ON;
- if (TRACING)
- {
- if (!cs->locked)
- pthread_mutex_lock(&THR_LOCK_dbug);
- DoPrefix(cs, _line_);
- Indent(cs, cs->level);
- (void) fprintf(cs->stack->out_file, "<%s\n", cs->func);
- DbugFlush(cs);
- }
- }
- }
- /*
- Check to not set level < 0. This can happen if DBUG was disabled when
- function was entered and enabled in function.
- */
- cs->level= _slevel_ != 0 ? _slevel_ - 1 : 0;
- cs->func= _stack_frame_->func;
- cs->file= _stack_frame_->file;
- if (cs->framep != NULL)
- cs->framep= cs->framep->prev;
- errno=save_errno;
-}
-
-
-/*
- * FUNCTION
- *
- * _db_pargs_ log arguments for subsequent use by _db_doprnt_()
- *
- * SYNOPSIS
- *
- * VOID _db_pargs_(_line_, keyword)
- * int _line_;
- * char *keyword;
- *
- * DESCRIPTION
- *
- * The new universal printing macro DBUG_PRINT, which replaces
- * all forms of the DBUG_N macros, needs two calls to runtime
- * support routines. The first, this function, remembers arguments
- * that are used by the subsequent call to _db_doprnt_().
- *
- */
-
-void _db_pargs_(uint _line_, const char *keyword)
-{
- CODE_STATE *cs;
- get_code_state_or_return;
- cs->u_line= _line_;
- cs->u_keyword= keyword;
-}
-
-
-/*
- * FUNCTION
- *
- * _db_doprnt_ handle print of debug lines
- *
- * SYNOPSIS
- *
- * VOID _db_doprnt_(format, va_alist)
- * char *format;
- * va_dcl;
- *
- * DESCRIPTION
- *
- * When invoked via one of the DBUG macros, tests the current keyword
- * set by calling _db_pargs_() to see if that macro has been selected
- * for processing via the debugger control string, and if so, handles
- * printing of the arguments via the format string. The line number
- * of the DBUG macro in the source is found in u_line.
- *
- * Note that the format string SHOULD NOT include a terminating
- * newline, this is supplied automatically.
- *
- */
-
-#include
-
-void _db_doprnt_(const char *format,...)
-{
- va_list args;
- CODE_STATE *cs;
- get_code_state_or_return;
-
- va_start(args,format);
-
- if (_db_keyword_(cs, cs->u_keyword, 0))
- {
- int save_errno=errno;
- if (!cs->locked)
- pthread_mutex_lock(&THR_LOCK_dbug);
- DoPrefix(cs, cs->u_line);
- if (TRACING)
- Indent(cs, cs->level + 1);
- else
- (void) fprintf(cs->stack->out_file, "%s: ", cs->func);
- (void) fprintf(cs->stack->out_file, "%s: ", cs->u_keyword);
- DbugFprintf(cs->stack->out_file, format, args);
- DbugFlush(cs);
- errno=save_errno;
- }
- va_end(args);
-}
-
-/*
- * fprintf clone with consistent, platform independent output for
- * problematic formats like %p, %zd and %lld.
- */
-static void DbugFprintf(FILE *stream, const char* format, va_list args)
-{
- char cvtbuf[1024];
- size_t len;
- len = my_vsnprintf(cvtbuf, sizeof(cvtbuf), format, args);
- (void) fprintf(stream, "%s\n", cvtbuf);
-}
-
-
-/*
- * FUNCTION
- *
- * _db_dump_ dump a string in hex
- *
- * SYNOPSIS
- *
- * void _db_dump_(_line_,keyword,memory,length)
- * int _line_; current source line number
- * char *keyword;
- * char *memory; Memory to print
- * int length; Bytes to print
- *
- * DESCRIPTION
- * Dump N characters in a binary array.
- * Is used to examine corrputed memory or arrays.
- */
-
-void _db_dump_(uint _line_, const char *keyword,
- const unsigned char *memory, size_t length)
-{
- int pos;
- char dbuff[90];
- CODE_STATE *cs;
- get_code_state_or_return;
-
- if (_db_keyword_(cs, keyword, 0))
- {
- if (!cs->locked)
- pthread_mutex_lock(&THR_LOCK_dbug);
- DoPrefix(cs, _line_);
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
- fprintf(cs->stack->out_file, "%s: ", cs->func);
- }
- sprintf(dbuff,"%s: Memory: 0x%lx Bytes: (%ld)\n",
- keyword, (ulong) memory, (long) length);
- (void) fputs(dbuff,cs->stack->out_file);
-
- pos=0;
- while (length-- > 0)
- {
- uint tmp= *((unsigned char*) memory++);
- if ((pos+=3) >= 80)
- {
- fputc('\n',cs->stack->out_file);
- pos=3;
- }
- fputc(_dig_vec_upper[((tmp >> 4) & 15)], cs->stack->out_file);
- fputc(_dig_vec_upper[tmp & 15], cs->stack->out_file);
- fputc(' ',cs->stack->out_file);
- }
- (void) fputc('\n',cs->stack->out_file);
- DbugFlush(cs);
- }
-}
-
-
-/*
- * FUNCTION
- *
- * ListAddDel modify the list according to debug control string
- *
- * DESCRIPTION
- *
- * Given pointer to a comma separated list of strings in "cltp",
- * parses the list, and modifies "listp", returning a pointer
- * to the new list.
- *
- * The mode of operation is defined by "todo" parameter.
- *
- * If it is INCLUDE, elements (strings from "cltp") are added to the
- * list, they will have INCLUDE flag set. If the list already contains
- * the string in question, new element is not added, but a flag of
- * the existing element is adjusted (INCLUDE bit is set, EXCLUDE bit
- * is removed).
- *
- * If it is EXCLUDE, elements are added to the list with the EXCLUDE
- * flag set. If the list already contains the string in question,
- * it is removed, new element is not added.
- */
-
-static struct link *ListAddDel(struct link *head, const char *ctlp,
- const char *end, int todo)
-{
- const char *start;
- struct link **cur;
- size_t len;
- int subdir;
-
- ctlp--;
-next:
- while (++ctlp < end)
- {
- start= ctlp;
- subdir=0;
- while (ctlp < end && *ctlp != ',')
- ctlp++;
- len=ctlp-start;
- if (start[len-1] == '/')
- {
- len--;
- subdir=SUBDIR;
- }
- if (len == 0) continue;
- for (cur=&head; *cur; cur=&((*cur)->next_link))
- {
- if (!strncmp((*cur)->str, start, len))
- {
- if ((*cur)->flags & todo) /* same action ? */
- (*cur)->flags|= subdir; /* just merge the SUBDIR flag */
- else if (todo == EXCLUDE)
- {
- struct link *delme=*cur;
- *cur=(*cur)->next_link;
- free((void*) delme);
- }
- else
- {
- (*cur)->flags&=~(EXCLUDE & SUBDIR);
- (*cur)->flags|=INCLUDE | subdir;
- }
- goto next;
- }
- }
- *cur= (struct link *) DbugMalloc(sizeof(struct link)+len);
- memcpy((*cur)->str, start, len);
- (*cur)->str[len]=0;
- (*cur)->flags=todo | subdir;
- (*cur)->next_link=0;
- }
- return head;
-}
-
-/*
- * FUNCTION
- *
- * ListCopy make a copy of the list
- *
- * SYNOPSIS
- *
- * static struct link *ListCopy(orig)
- * struct link *orig;
- *
- * DESCRIPTION
- *
- * Given pointer to list, which contains a copy of every element from
- * the original list.
- *
- * the orig pointer can be NULL
- *
- * Note that since each link is added at the head of the list,
- * the final list will be in "reverse order", which is not
- * significant for our usage here.
- *
- */
-
-static struct link *ListCopy(struct link *orig)
-{
- struct link *new_malloc;
- struct link *head;
- size_t len;
-
- head= NULL;
- while (orig != NULL)
- {
- len= strlen(orig->str);
- new_malloc= (struct link *) DbugMalloc(sizeof(struct link)+len);
- memcpy(new_malloc->str, orig->str, len);
- new_malloc->str[len]= 0;
- new_malloc->flags=orig->flags;
- new_malloc->next_link= head;
- head= new_malloc;
- orig= orig->next_link;
- }
- return head;
-}
-
-/*
- * FUNCTION
- *
- * InList test a given string for member of a given list
- *
- * DESCRIPTION
- *
- * Tests the string pointed to by "cp" to determine if it is in
- * the list pointed to by "linkp". Linkp points to the first
- * link in the list. If linkp is NULL or contains only EXCLUDE
- * elements then the string is treated as if it is in the list.
- * This may seem rather strange at first but leads to the desired
- * operation if no list is given. The net effect is that all
- * strings will be accepted when there is no list, and when there
- * is a list, only those strings in the list will be accepted.
- *
- * RETURN
- * combination of SUBDIR, INCLUDE, EXCLUDE, MATCHED flags
- *
- */
-
-static int InList(struct link *linkp, const char *cp)
-{
- int result;
-
- for (result=MATCHED; linkp != NULL; linkp= linkp->next_link)
- {
- if (!fnmatch(linkp->str, cp, 0))
- return linkp->flags;
- if (!(linkp->flags & EXCLUDE))
- result=NOT_MATCHED;
- if (linkp->flags & SUBDIR)
- result|=SUBDIR;
- }
- return result;
-}
-
-/*
- * FUNCTION
- *
- * ListFlags returns aggregated list flags (ORed over all elements)
- *
- */
-
-static uint ListFlags(struct link *linkp)
-{
- uint f;
- for (f=0; linkp != NULL; linkp= linkp->next_link)
- f|= linkp->flags;
- return f;
-}
-
-/*
- * FUNCTION
- *
- * PushState push current settings onto stack and set up new one
- *
- * SYNOPSIS
- *
- * static VOID PushState()
- *
- * DESCRIPTION
- *
- * Pushes the current settings on the settings stack, and creates
- * a new settings. The new settings is NOT initialized
- *
- * The settings stack is a linked list of settings, with the new
- * settings added at the head. This allows the stack to grow
- * to the limits of memory if necessary.
- *
- */
-
-static void PushState(CODE_STATE *cs)
-{
- struct settings *new_malloc;
-
- new_malloc= (struct settings *) DbugMalloc(sizeof(struct settings));
- bzero(new_malloc, sizeof(*new_malloc));
- new_malloc->next= cs->stack;
- cs->stack= new_malloc;
-}
-
-/*
- * FUNCTION
- *
- * FreeState Free memory associated with a struct state.
- *
- * SYNOPSIS
- *
- * static void FreeState (state)
- * struct state *state;
- * int free_state;
- *
- * DESCRIPTION
- *
- * Deallocates the memory allocated for various information in a
- * state. If free_state is set, also free 'state'
- *
- */
-static void FreeState(CODE_STATE *cs, struct settings *state, int free_state)
-{
- if (!is_shared(state, keywords))
- FreeList(state->keywords);
- if (!is_shared(state, functions))
- FreeList(state->functions);
- if (!is_shared(state, processes))
- FreeList(state->processes);
- if (!is_shared(state, p_functions))
- FreeList(state->p_functions);
-
- if (!is_shared(state, out_file))
- DBUGCloseFile(cs, state->out_file);
- else
- (void) fflush(state->out_file);
-
- if (!is_shared(state, prof_file))
- DBUGCloseFile(cs, state->prof_file);
- else
- (void) fflush(state->prof_file);
-
- if (free_state)
- free((void*) state);
-}
-
-
-/*
- * FUNCTION
- *
- * _db_end_ End debugging, freeing state stack memory.
- *
- * SYNOPSIS
- *
- * static VOID _db_end_ ()
- *
- * DESCRIPTION
- *
- * Ends debugging, de-allocating the memory allocated to the
- * state stack.
- *
- * To be called at the very end of the program.
- *
- */
-void _db_end_()
-{
- struct settings *discard;
- static struct settings tmp;
- CODE_STATE *cs;
- /*
- Set _dbug_on_ to be able to do full reset even when DEBUGGER_OFF was
- called after dbug was initialized
- */
- _dbug_on_= 1;
- get_code_state_or_return;
-
- while ((discard= cs->stack))
- {
- if (discard == &init_settings)
- break;
- cs->stack= discard->next;
- FreeState(cs, discard, 1);
- }
- tmp= init_settings;
-
- /* Use mutex lock to make it less likely anyone access out_file */
- pthread_mutex_lock(&THR_LOCK_dbug);
- init_settings.flags= OPEN_APPEND;
- init_settings.out_file= stderr;
- init_settings.prof_file= stderr;
- init_settings.maxdepth= 0;
- init_settings.delay= 0;
- init_settings.sub_level= 0;
- init_settings.functions= 0;
- init_settings.p_functions= 0;
- init_settings.keywords= 0;
- init_settings.processes= 0;
- pthread_mutex_unlock(&THR_LOCK_dbug);
- FreeState(cs, &tmp, 0);
-}
-
-
-/*
- * FUNCTION
- *
- * DoTrace check to see if tracing is current enabled
- *
- * DESCRIPTION
- *
- * Checks to see if dbug in this function is enabled based on
- * whether the maximum trace depth has been reached, the current
- * function is selected, and the current process is selected.
- *
- */
-
-static int DoTrace(CODE_STATE *cs)
-{
- if ((cs->stack->maxdepth == 0 || cs->level <= cs->stack->maxdepth) &&
- InList(cs->stack->processes, cs->process) & (MATCHED|INCLUDE))
- switch(InList(cs->stack->functions, cs->func)) {
- case INCLUDE|SUBDIR: return ENABLE_TRACE;
- case INCLUDE: return DO_TRACE;
- case MATCHED|SUBDIR:
- case NOT_MATCHED|SUBDIR:
- case MATCHED: return framep_trace_flag(cs, cs->framep) ?
- DO_TRACE : DONT_TRACE;
- case EXCLUDE:
- case NOT_MATCHED: return DONT_TRACE;
- case EXCLUDE|SUBDIR: return DISABLE_TRACE;
- }
- return DONT_TRACE;
-}
-
-
-/*
- * FUNCTION
- *
- * DoProfile check to see if profiling is current enabled
- *
- * SYNOPSIS
- *
- * static BOOLEAN DoProfile()
- *
- * DESCRIPTION
- *
- * Checks to see if profiling is enabled based on whether the
- * user has specified profiling, the maximum trace depth has
- * not yet been reached, the current function is selected,
- * and the current process is selected. Returns TRUE if
- * profiling is enabled, FALSE otherwise.
- *
- */
-
-#ifndef THREAD
-static BOOLEAN DoProfile(CODE_STATE *cs)
-{
- return PROFILING &&
- cs->level <= cs->stack->maxdepth &&
- InList(cs->stack->p_functions, cs->func) & (INCLUDE|MATCHED) &&
- InList(cs->stack->processes, cs->process) & (INCLUDE|MATCHED);
-}
-#endif
-
-FILE *_db_fp_(void)
-{
- CODE_STATE *cs;
- get_code_state_or_return NULL;
- return cs->stack->out_file;
-}
-
-/*
- * FUNCTION
- *
- * _db_keyword_ test keyword for member of keyword list
- *
- * DESCRIPTION
- *
- * Test a keyword to determine if it is in the currently active
- * keyword list. If strict=0, a keyword is accepted
- * if the list is null, otherwise it must match one of the list
- * members. When debugging is not on, no keywords are accepted.
- * After the maximum trace level is exceeded, no keywords are
- * accepted (this behavior subject to change). Additionally,
- * the current function and process must be accepted based on
- * their respective lists.
- *
- * Returns TRUE if keyword accepted, FALSE otherwise.
- *
- */
-
-BOOLEAN _db_keyword_(CODE_STATE *cs, const char *keyword, int strict)
-{
- get_code_state_if_not_set_or_return FALSE;
- strict=strict ? INCLUDE : INCLUDE|MATCHED;
-
- return DEBUGGING && DoTrace(cs) & DO_TRACE &&
- InList(cs->stack->keywords, keyword) & strict;
-}
-
-/*
- * FUNCTION
- *
- * Indent indent a line to the given indentation level
- *
- * SYNOPSIS
- *
- * static VOID Indent(indent)
- * int indent;
- *
- * DESCRIPTION
- *
- * Indent a line to the given level. Note that this is
- * a simple minded but portable implementation.
- * There are better ways.
- *
- * Also, the indent must be scaled by the compile time option
- * of character positions per nesting level.
- *
- */
-
-static void Indent(CODE_STATE *cs, int indent)
-{
- REGISTER int count;
-
- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
- fputc('|',cs->stack->out_file);
- else
- fputc(' ',cs->stack->out_file);
- }
-}
-
-
-/*
- * FUNCTION
- *
- * FreeList free all memory associated with a linked list
- *
- * SYNOPSIS
- *
- * static VOID FreeList(linkp)
- * struct link *linkp;
- *
- * DESCRIPTION
- *
- * Given pointer to the head of a linked list, frees all
- * memory held by the list and the members of the list.
- *
- */
-
-static void FreeList(struct link *linkp)
-{
- REGISTER struct link *old;
-
- while (linkp != NULL)
- {
- old= linkp;
- linkp= linkp->next_link;
- free((void*) old);
- }
-}
-
-
-/*
- * FUNCTION
- *
- * DoPrefix print debugger line prefix prior to indentation
- *
- * SYNOPSIS
- *
- * static VOID DoPrefix(_line_)
- * int _line_;
- *
- * DESCRIPTION
- *
- * Print prefix common to all debugger output lines, prior to
- * doing indentation if necessary. Print such information as
- * current process name, current source file name and line number,
- * and current function nesting depth.
- *
- */
-
-static void DoPrefix(CODE_STATE *cs, uint _line_)
-{
- cs->lineno++;
- if (cs->stack->flags & PID_ON)
- {
-#ifdef THREAD
- (void) fprintf(cs->stack->out_file, "%-7s: ", my_thread_name());
-#else
- (void) fprintf(cs->stack->out_file, "%5d: ", (int) getpid());
-#endif
- }
- if (cs->stack->flags & NUMBER_ON)
- (void) fprintf(cs->stack->out_file, "%5d: ", cs->lineno);
- if (cs->stack->flags & TIMESTAMP_ON)
- {
-#ifdef __WIN__
- /* FIXME This doesn't give microseconds as in Unix case, and the resolution is
- in system ticks, 10 ms intervals. See my_getsystime.c for high res */
- SYSTEMTIME loc_t;
- GetLocalTime(&loc_t);
- (void) fprintf (cs->stack->out_file,
- /* "%04d-%02d-%02d " */
- "%02d:%02d:%02d.%06d ",
- /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/
- loc_t.wHour, loc_t.wMinute, loc_t.wSecond, loc_t.wMilliseconds);
-#else
- struct timeval tv;
- struct tm *tm_p;
- if (gettimeofday(&tv, NULL) != -1)
- {
- if ((tm_p= localtime((const time_t *)&tv.tv_sec)))
- {
- (void) fprintf (cs->stack->out_file,
- /* "%04d-%02d-%02d " */
- "%02d:%02d:%02d.%06d ",
- /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/
- tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec,
- (int) (tv.tv_usec));
- }
- }
-#endif
- }
- if (cs->stack->flags & PROCESS_ON)
- (void) fprintf(cs->stack->out_file, "%s: ", cs->process);
- if (cs->stack->flags & FILE_ON)
- (void) fprintf(cs->stack->out_file, "%14s: ", BaseName(cs->file));
- if (cs->stack->flags & LINE_ON)
- (void) fprintf(cs->stack->out_file, "%5d: ", _line_);
- if (cs->stack->flags & DEPTH_ON)
- (void) fprintf(cs->stack->out_file, "%4d: ", cs->level);
-}
-
-
-/*
- * FUNCTION
- *
- * DBUGOpenFile open new output stream for debugger output
- *
- * SYNOPSIS
- *
- * static VOID DBUGOpenFile(name)
- * char *name;
- *
- * DESCRIPTION
- *
- * Given name of a new file (or "-" for stdout) opens the file
- * and sets the output stream to the new file.
- *
- */
-
-static void DBUGOpenFile(CODE_STATE *cs,
- const char *name,const char *end,int append)
-{
- REGISTER FILE *fp;
- REGISTER BOOLEAN newfile;
-
- if (name != NULL)
- {
- if (end)
- {
- size_t len=end-name;
- memcpy(cs->stack->name, name, len);
- cs->stack->name[len]=0;
- }
- else
- strmov(cs->stack->name,name);
- name=cs->stack->name;
- if (strcmp(name, "-") == 0)
- {
- cs->stack->out_file= stdout;
- cs->stack->flags |= FLUSH_ON_WRITE;
- cs->stack->name[0]=0;
- }
- else
- {
- if (!Writable(name))
- {
- (void) fprintf(stderr, ERR_OPEN, cs->process, name);
- perror("");
- fflush(stderr);
- }
- else
- {
- newfile= !EXISTS(name);
- if (!(fp= fopen(name, append ? "a+" : "w")))
- {
- (void) fprintf(stderr, ERR_OPEN, cs->process, name);
- perror("");
- fflush(stderr);
- }
- else
- {
- cs->stack->out_file= fp;
- if (newfile)
- {
- ChangeOwner(cs, name);
- }
- }
- }
- }
- }
-}
-
-
-/*
- * FUNCTION
- *
- * OpenProfile open new output stream for profiler output
- *
- * SYNOPSIS
- *
- * static FILE *OpenProfile(name)
- * char *name;
- *
- * DESCRIPTION
- *
- * Given name of a new file, opens the file
- * and sets the profiler output stream to the new file.
- *
- * It is currently unclear whether the prefered behavior is
- * to truncate any existing file, or simply append to it.
- * The latter behavior would be desirable for collecting
- * accumulated runtime history over a number of separate
- * runs. It might take some changes to the analyzer program
- * though, and the notes that Binayak sent with the profiling
- * diffs indicated that append was the normal mode, but this
- * does not appear to agree with the actual code. I haven't
- * investigated at this time [fnf; 24-Jul-87].
- */
-
-#ifndef THREAD
-static FILE *OpenProfile(CODE_STATE *cs, const char *name)
-{
- REGISTER FILE *fp;
- REGISTER BOOLEAN newfile;
-
- fp=0;
- if (!Writable(name))
- {
- (void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name);
- perror("");
- (void) Delay(cs->stack->delay);
- }
- else
- {
- newfile= !EXISTS(name);
- if (!(fp= fopen(name, "w")))
- {
- (void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name);
- perror("");
- }
- else
- {
- cs->stack->prof_file= fp;
- if (newfile)
- {
- ChangeOwner(cs, name);
- }
- }
- }
- return fp;
-}
-#endif
-
-/*
- * FUNCTION
- *
- * DBUGCloseFile close the debug output stream
- *
- * SYNOPSIS
- *
- * static VOID DBUGCloseFile(fp)
- * FILE *fp;
- *
- * DESCRIPTION
- *
- * Closes the debug output stream unless it is standard output
- * or standard error.
- *
- */
-
-static void DBUGCloseFile(CODE_STATE *cs, FILE *fp)
-{
- if (fp && fp != stderr && fp != stdout && fclose(fp) == EOF)
- {
- pthread_mutex_lock(&THR_LOCK_dbug);
- (void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process);
- perror("");
- DbugFlush(cs);
- }
-}
-
-
-/*
- * FUNCTION
- *
- * DbugExit print error message and exit
- *
- * SYNOPSIS
- *
- * static VOID DbugExit(why)
- * char *why;
- *
- * DESCRIPTION
- *
- * Prints error message using current process name, the reason for
- * aborting (typically out of memory), and exits with status 1.
- * This should probably be changed to use a status code
- * defined in the user's debugger include file.
- *
- */
-
-static void DbugExit(const char *why)
-{
- CODE_STATE *cs=code_state();
- (void) fprintf(stderr, ERR_ABORT, cs ? cs->process : "(null)", why);
- (void) fflush(stderr);
- exit(1);
-}
-
-
-/*
- * FUNCTION
- *
- * DbugMalloc allocate memory for debugger runtime support
- *
- * SYNOPSIS
- *
- * static long *DbugMalloc(size)
- * int size;
- *
- * DESCRIPTION
- *
- * Allocate more memory for debugger runtime support functions.
- * Failure to to allocate the requested number of bytes is
- * immediately fatal to the current process. This may be
- * rather unfriendly behavior. It might be better to simply
- * print a warning message, freeze the current debugger cs,
- * and continue execution.
- *
- */
-
-static char *DbugMalloc(size_t size)
-{
- register char *new_malloc;
-
- if (!(new_malloc= (char*) malloc(size)))
- DbugExit("out of memory");
- return new_malloc;
-}
-
-
-/*
- * strtok lookalike - splits on ':', magically handles ::, :\ and :/
- */
-
-static const char *DbugStrTok(const char *s)
-{
- while (s[0] && (s[0] != ':' ||
- (s[1] == '\\' || s[1] == '/' || (s[1] == ':' && s++))))
- s++;
- return s;
-}
-
-
-/*
- * FUNCTION
- *
- * BaseName strip leading pathname components from name
- *
- * SYNOPSIS
- *
- * static char *BaseName(pathname)
- * char *pathname;
- *
- * DESCRIPTION
- *
- * Given pointer to a complete pathname, locates the base file
- * name at the end of the pathname and returns a pointer to
- * it.
- *
- */
-
-static const char *BaseName(const char *pathname)
-{
- register const char *base;
-
- base= strrchr(pathname, FN_LIBCHAR);
- if (base++ == NullS)
- base= pathname;
- return base;
-}
-
-
-/*
- * FUNCTION
- *
- * Writable test to see if a pathname is writable/creatable
- *
- * SYNOPSIS
- *
- * static BOOLEAN Writable(pathname)
- * char *pathname;
- *
- * DESCRIPTION
- *
- * Because the debugger might be linked in with a program that
- * runs with the set-uid-bit (suid) set, we have to be careful
- * about opening a user named file for debug output. This consists
- * of checking the file for write access with the real user id,
- * or checking the directory where the file will be created.
- *
- * Returns TRUE if the user would normally be allowed write or
- * create access to the named file. Returns FALSE otherwise.
- *
- */
-
-
-#ifndef Writable
-
-static BOOLEAN Writable(const char *pathname)
-{
- REGISTER BOOLEAN granted;
- REGISTER char *lastslash;
-
- granted= FALSE;
- if (EXISTS(pathname))
- {
- if (WRITABLE(pathname))
- granted= TRUE;
- }
- else
- {
- lastslash= strrchr(pathname, '/');
- if (lastslash != NULL)
- *lastslash= '\0';
- else
- pathname= ".";
- if (WRITABLE(pathname))
- granted= TRUE;
- if (lastslash != NULL)
- *lastslash= '/';
- }
- return granted;
-}
-#endif
-
-
-/*
- * FUNCTION
- *
- * ChangeOwner change owner to real user for suid programs
- *
- * SYNOPSIS
- *
- * static VOID ChangeOwner(pathname)
- *
- * DESCRIPTION
- *
- * For unix systems, change the owner of the newly created debug
- * file to the real owner. This is strictly for the benefit of
- * programs that are running with the set-user-id bit set.
- *
- * Note that at this point, the fact that pathname represents
- * a newly created file has already been established. If the
- * program that the debugger is linked to is not running with
- * the suid bit set, then this operation is redundant (but
- * harmless).
- *
- */
-
-#ifndef ChangeOwner
-static void ChangeOwner(CODE_STATE *cs, char *pathname)
-{
- if (chown(pathname, getuid(), getgid()) == -1)
- {
- (void) fprintf(stderr, ERR_CHOWN, cs->process, pathname);
- perror("");
- (void) fflush(stderr);
- }
-}
-#endif
-
-
-/*
- * FUNCTION
- *
- * _db_setjmp_ save debugger environment
- *
- * SYNOPSIS
- *
- * VOID _db_setjmp_()
- *
- * DESCRIPTION
- *
- * Invoked as part of the user's DBUG_SETJMP macro to save
- * the debugger environment in parallel with saving the user's
- * environment.
- *
- */
-
-#ifdef HAVE_LONGJMP
-
-EXPORT void _db_setjmp_()
-{
- CODE_STATE *cs;
- get_code_state_or_return;
-
- cs->jmplevel= cs->level;
- cs->jmpfunc= cs->func;
- cs->jmpfile= cs->file;
-}
-
-/*
- * FUNCTION
- *
- * _db_longjmp_ restore previously saved debugger environment
- *
- * SYNOPSIS
- *
- * VOID _db_longjmp_()
- *
- * DESCRIPTION
- *
- * Invoked as part of the user's DBUG_LONGJMP macro to restore
- * the debugger environment in parallel with restoring the user's
- * previously saved environment.
- *
- */
-
-EXPORT void _db_longjmp_()
-{
- CODE_STATE *cs;
- get_code_state_or_return;
-
- cs->level= cs->jmplevel;
- if (cs->jmpfunc)
- cs->func= cs->jmpfunc;
- if (cs->jmpfile)
- cs->file= cs->jmpfile;
-}
-#endif
-
-/*
- * FUNCTION
- *
- * perror perror simulation for systems that don't have it
- *
- * SYNOPSIS
- *
- * static VOID perror(s)
- * char *s;
- *
- * DESCRIPTION
- *
- * Perror produces a message on the standard error stream which
- * provides more information about the library or system error
- * just encountered. The argument string s is printed, followed
- * by a ':', a blank, and then a message and a newline.
- *
- * An undocumented feature of the unix perror is that if the string
- * 's' is a null string (NOT a NULL pointer!), then the ':' and
- * blank are not printed.
- *
- * This version just complains about an "unknown system error".
- *
- */
-
-#ifndef HAVE_PERROR
-static void perror(s)
-char *s;
-{
- if (s && *s != '\0')
- (void) fprintf(stderr, "%s: ", s);
- (void) fprintf(stderr, "\n");
-}
-#endif /* HAVE_PERROR */
-
-
- /* flush dbug-stream, free mutex lock & wait delay */
- /* This is because some systems (MSDOS!!) dosn't flush fileheader */
- /* and dbug-file isn't readable after a system crash !! */
-
-static void DbugFlush(CODE_STATE *cs)
-{
- if (cs->stack->flags & FLUSH_ON_WRITE)
- {
- (void) fflush(cs->stack->out_file);
- if (cs->stack->delay)
- (void) Delay(cs->stack->delay);
- }
- if (!cs->locked)
- pthread_mutex_unlock(&THR_LOCK_dbug);
-} /* DbugFlush */
-
-
-/* For debugging */
-
-void _db_flush_()
-{
- CODE_STATE *cs;
- get_code_state_or_return;
- (void) fflush(cs->stack->out_file);
-}
-
-
-void _db_lock_file_()
-{
- CODE_STATE *cs;
- get_code_state_or_return;
- pthread_mutex_lock(&THR_LOCK_dbug);
- cs->locked=1;
-}
-
-void _db_unlock_file_()
-{
- CODE_STATE *cs;
- get_code_state_or_return;
- cs->locked=0;
- pthread_mutex_unlock(&THR_LOCK_dbug);
-}
-
-/*
- * Here we need the definitions of the clock routine. Add your
- * own for whatever system that you have.
- */
-
-#ifndef THREAD
-#if defined(HAVE_GETRUSAGE)
-
-#include
-#include
-
-/* extern int getrusage(int, struct rusage *); */
-
-/*
- * Returns the user time in milliseconds used by this process so
- * far.
- */
-
-static unsigned long Clock()
-{
- struct rusage ru;
-
- (void) getrusage(RUSAGE_SELF, &ru);
- return ru.ru_utime.tv_sec*1000 + ru.ru_utime.tv_usec/1000;
-}
-
-#elif defined(MSDOS) || defined(__WIN__)
-
-static ulong Clock()
-{
- return clock()*(1000/CLOCKS_PER_SEC);
-}
-#elif defined(amiga)
-
-struct DateStamp { /* Yes, this is a hack, but doing it right */
- long ds_Days; /* is incredibly ugly without splitting this */
- long ds_Minute; /* off into a separate file */
- long ds_Tick;
-};
-
-static int first_clock= TRUE;
-static struct DateStamp begin;
-static struct DateStamp elapsed;
-
-static unsigned long Clock()
-{
- register struct DateStamp *now;
- register unsigned long millisec= 0;
- extern VOID *AllocMem();
-
- now= (struct DateStamp *) AllocMem((long) sizeof(struct DateStamp), 0L);
- if (now != NULL)
- {
- if (first_clock == TRUE)
- {
- first_clock= FALSE;
- (void) DateStamp(now);
- begin= *now;
- }
- (void) DateStamp(now);
- millisec= 24 * 3600 * (1000 / HZ) * (now->ds_Days - begin.ds_Days);
- millisec += 60 * (1000 / HZ) * (now->ds_Minute - begin.ds_Minute);
- millisec += (1000 / HZ) * (now->ds_Tick - begin.ds_Tick);
- (void) FreeMem(now, (long) sizeof(struct DateStamp));
- }
- return millisec;
-}
-#else
-static unsigned long Clock()
-{
- return 0;
-}
-#endif /* RUSAGE */
-#endif /* THREADS */
-
-#ifdef NO_VARARGS
-
-/*
- * Fake vfprintf for systems that don't support it. If this
- * doesn't work, you are probably SOL...
- */
-
-static int vfprintf(stream, format, ap)
-FILE *stream;
-char *format;
-va_list ap;
-{
- int rtnval;
- ARGS_DCL;
-
- ARG0= va_arg(ap, ARGS_TYPE);
- ARG1= va_arg(ap, ARGS_TYPE);
- ARG2= va_arg(ap, ARGS_TYPE);
- ARG3= va_arg(ap, ARGS_TYPE);
- ARG4= va_arg(ap, ARGS_TYPE);
- ARG5= va_arg(ap, ARGS_TYPE);
- ARG6= va_arg(ap, ARGS_TYPE);
- ARG7= va_arg(ap, ARGS_TYPE);
- ARG8= va_arg(ap, ARGS_TYPE);
- ARG9= va_arg(ap, ARGS_TYPE);
- rtnval= fprintf(stream, format, ARGS_LIST);
- return rtnval;
-}
-
-#endif /* NO_VARARGS */
-
-#else
-
-/*
- * Dummy function, workaround for MySQL bug#14420 related
- * build failure on a platform where linking with an empty
- * archive fails.
- *
- * This block can be removed as soon as a fix for bug#14420
- * is implemented.
- */
-int i_am_a_dummy_function() {
- return 0;
-}
-
-#endif
diff --git a/externals/mysql/extlib/dbug/dbug_analyze.c b/externals/mysql/extlib/dbug/dbug_analyze.c
deleted file mode 100644
index 3263b2ccc5..0000000000
--- a/externals/mysql/extlib/dbug/dbug_analyze.c
+++ /dev/null
@@ -1,726 +0,0 @@
-/*
- * Analyze the profile file (cmon.out) written out by the dbug
- * routines with profiling enabled.
- *
- * Copyright June 1987, Binayak Banerjee
- * All rights reserved.
- *
- * This program may be freely distributed under the same terms and
- * conditions as Fred Fish's Dbug package.
- *
- * Compile with -- cc -O -s -o %s analyze.c
- *
- * Analyze will read an trace file created by the dbug package
- * (when run with traceing enabled). It will then produce a
- * summary on standard output listing the name of each traced
- * function, the number of times it was called, the percentage
- * of total calls, the time spent executing the function, the
- * proportion of the total time and the 'importance'. The last
- * is a metric which is obtained by multiplying the proportions
- * of calls and the proportions of time for each function. The
- * greater the importance, the more likely it is that a speedup
- * could be obtained by reducing the time taken by that function.
- *
- * Note that the timing values that you obtain are only rough
- * measures. The overhead of the dbug package is included
- * within. However, there is no need to link in special profiled
- * libraries and the like.
- *
- * CHANGES:
- *
- * 2-Mar-89: fnf
- * Changes to support tracking of stack usage. This required
- * reordering the fields in the profile log file to make
- * parsing of different record types easier. Corresponding
- * changes made in dbug runtime library. Also used this
- * opportunity to reformat the code more to my liking (my
- * apologies to Binayak Banerjee for "uglifying" his code).
- *
- * 24-Jul-87: fnf
- * Because I tend to use functions names like
- * "ExternalFunctionDoingSomething", I've rearranged the
- * printout to put the function name last in each line, so
- * long names don't screw up the formatting unless they are
- * *very* long and wrap around the screen width...
- *
- * 24-Jul-87: fnf
- * Modified to put out table very similar to Unix profiler
- * by default, but also puts out original verbose table
- * if invoked with -v flag.
- */
-
-#include
-#include
-#include
-
-static char *my_name;
-static int verbose;
-
-/*
- * Structure of the stack.
- */
-
-#define PRO_FILE "dbugmon.out" /* Default output file name */
-#define STACKSIZ 100 /* Maximum function nesting */
-#define MAXPROCS 10000 /* Maximum number of function calls */
-
-# ifdef BSD
-# include
-# else
-# define EX_SOFTWARE 1
-# define EX_DATAERR 1
-# define EX_USAGE 1
-# define EX_OSERR 1
-# define EX_IOERR 1
-#ifndef EX_OK
-# define EX_OK 0
-#endif
-# endif
-
-#define __MERF_OO_ "%s: Malloc Failed in %s: %d\n"
-
-#define MALLOC(Ptr,Num,Typ) do /* Malloc w/error checking & exit */ \
- if (!(Ptr = (Typ *)malloc((Num)*(sizeof(Typ))))) \
- {fprintf(stderr,__MERF_OO_,my_name,__FILE__,__LINE__);\
- exit(EX_OSERR);} while(0)
-
-#define Malloc(Ptr,Num,Typ) do /* Weaker version of above */\
- if (!(Ptr = (Typ *)malloc((Num)*(sizeof(Typ))))) \
- fprintf(stderr,__MERF_OO_,my_name,__FILE__,__LINE__);\
- while(0)
-
-#define FILEOPEN(Fp,Fn,Mod) do /* File open with error exit */ \
- if (!(Fp = fopen(Fn,Mod)))\
- {fprintf(stderr,"%s: Couldn't open %s\n",my_name,Fn);\
- exit(EX_IOERR);} while(0)
-
-#define Fileopen(Fp,Fn,Mod) do /* Weaker version of above */ \
- if(!(Fp = fopen(Fn,Mod))) \
- fprintf(stderr,"%s: Couldn't open %s\n",my_name,Fn);\
- while(0)
-
-
-struct stack_t {
- unsigned int pos; /* which function? */
- unsigned long time; /* Time that this was entered */
- unsigned long children; /* Time spent in called funcs */
-};
-
-static struct stack_t fn_stack[STACKSIZ+1];
-
-static unsigned int stacktop = 0; /* Lowest stack position is a dummy */
-
-static unsigned long tot_time = 0;
-static unsigned long tot_calls = 0;
-static unsigned long highstack = 0;
-static unsigned long lowstack = (ulong) ~0;
-
-/*
- * top() returns a pointer to the top item on the stack.
- * (was a function, now a macro)
- */
-
-#define top() &fn_stack[stacktop]
-
-/*
- * Push - Push the given record on the stack.
- */
-
-void push (name_pos, time_entered)
-register unsigned int name_pos;
-register unsigned long time_entered;
-{
- register struct stack_t *t;
-
- DBUG_ENTER("push");
- if (++stacktop > STACKSIZ) {
- fprintf (DBUG_FILE,"%s: stack overflow (%s:%d)\n",
- my_name, __FILE__, __LINE__);
- exit (EX_SOFTWARE);
- }
- DBUG_PRINT ("push", ("%d %ld",name_pos,time_entered));
- t = &fn_stack[stacktop];
- t -> pos = name_pos;
- t -> time = time_entered;
- t -> children = 0;
- DBUG_VOID_RETURN;
-}
-
-/*
- * Pop - pop the top item off the stack, assigning the field values
- * to the arguments. Returns 0 on stack underflow, or on popping first
- * item off stack.
- */
-
-unsigned int pop (name_pos, time_entered, child_time)
-register unsigned int *name_pos;
-register unsigned long *time_entered;
-register unsigned long *child_time;
-{
- register struct stack_t *temp;
- register unsigned int rtnval;
-
- DBUG_ENTER ("pop");
-
- if (stacktop < 1) {
- rtnval = 0;
- } else {
- temp = &fn_stack[stacktop];
- *name_pos = temp->pos;
- *time_entered = temp->time;
- *child_time = temp->children;
- DBUG_PRINT ("pop", ("%d %lu %lu",*name_pos,*time_entered,*child_time));
- rtnval = stacktop--;
- }
- DBUG_RETURN (rtnval);
-}
-
-/*
- * We keep the function info in another array (serves as a simple
- * symbol table)
- */
-
-struct module_t {
- char *name;
- unsigned long m_time;
- unsigned long m_calls;
- unsigned long m_stkuse;
-};
-
-static struct module_t modules[MAXPROCS];
-
-/*
- * We keep a binary search tree in order to look up function names
- * quickly (and sort them at the end.
- */
-
-struct bnode {
- unsigned int lchild; /* Index of left subtree */
- unsigned int rchild; /* Index of right subtree */
- unsigned int pos; /* Index of module_name entry */
-};
-
-static struct bnode s_table[MAXPROCS];
-
-static unsigned int n_items = 0; /* No. of items in the array so far */
-
-/*
- * Need a function to allocate space for a string and squirrel it away.
- */
-
-char *strsave (s)
-char *s;
-{
- register char *retval;
- register unsigned int len;
-
- DBUG_ENTER ("strsave");
- DBUG_PRINT ("strsave", ("%s",s));
- if (!s || (len = strlen (s)) == 0) {
- DBUG_RETURN (0);
- }
- MALLOC (retval, ++len, char);
- strcpy (retval, s);
- DBUG_RETURN (retval);
-}
-
-/*
- * add() - adds m_name to the table (if not already there), and returns
- * the index of its location in the table. Checks s_table (which is a
- * binary search tree) to see whether or not it should be added.
- */
-
-unsigned int add (m_name)
-char *m_name;
-{
- register unsigned int ind = 0;
- register int cmp;
-
- DBUG_ENTER ("add");
- if (n_items == 0) { /* First item to be added */
- s_table[0].pos = ind;
- s_table[0].lchild = s_table[0].rchild = MAXPROCS;
- addit:
- modules[n_items].name = strsave (m_name);
- modules[n_items].m_time = 0;
- modules[n_items].m_calls = 0;
- modules[n_items].m_stkuse = 0;
- DBUG_RETURN (n_items++);
- }
- while ((cmp = strcmp (m_name,modules[ind].name))) {
- if (cmp < 0) { /* In left subtree */
- if (s_table[ind].lchild == MAXPROCS) {
- /* Add as left child */
- if (n_items >= MAXPROCS) {
- fprintf (DBUG_FILE,
- "%s: Too many functions being profiled\n",
- my_name);
- exit (EX_SOFTWARE);
- }
- s_table[n_items].pos = s_table[ind].lchild = n_items;
- s_table[n_items].lchild = s_table[n_items].rchild = MAXPROCS;
-#ifdef notdef
- modules[n_items].name = strsave (m_name);
- modules[n_items].m_time = modules[n_items].m_calls = 0;
- DBUG_RETURN (n_items++);
-#else
- goto addit;
-#endif
-
- }
- ind = s_table[ind].lchild; /* else traverse l-tree */
- } else {
- if (s_table[ind].rchild == MAXPROCS) {
- /* Add as right child */
- if (n_items >= MAXPROCS) {
- fprintf (DBUG_FILE,
- "%s: Too many functions being profiled\n",
- my_name);
- exit (EX_SOFTWARE);
- }
- s_table[n_items].pos = s_table[ind].rchild = n_items;
- s_table[n_items].lchild = s_table[n_items].rchild = MAXPROCS;
-#ifdef notdef
- modules[n_items].name = strsave (m_name);
- modules[n_items].m_time = modules[n_items].m_calls = 0;
- DBUG_RETURN (n_items++);
-#else
- goto addit;
-#endif
-
- }
- ind = s_table[ind].rchild; /* else traverse r-tree */
- }
- }
- DBUG_RETURN (ind);
-}
-
-/*
- * process() - process the input file, filling in the modules table.
- */
-
-void process (inf)
-FILE *inf;
-{
- char buf[BUFSIZ];
- char fn_name[64]; /* Max length of fn_name */
- unsigned long fn_time;
- unsigned long fn_sbot;
- unsigned long fn_ssz;
- unsigned long lastuse;
- unsigned int pos;
- unsigned long local_time;
- unsigned int oldpos;
- unsigned long oldtime;
- unsigned long oldchild;
- struct stack_t *t;
-
- DBUG_ENTER ("process");
- while (fgets (buf,BUFSIZ,inf) != NULL) {
- switch (buf[0]) {
- case 'E':
- sscanf (buf+2, "%ld %64s", &fn_time, fn_name);
- DBUG_PRINT ("erec", ("%ld %s", fn_time, fn_name));
- pos = add (fn_name);
- push (pos, fn_time);
- break;
- case 'X':
- sscanf (buf+2, "%ld %64s", &fn_time, fn_name);
- DBUG_PRINT ("xrec", ("%ld %s", fn_time, fn_name));
- pos = add (fn_name);
- /*
- * An exited function implies that all stacked
- * functions are also exited, until the matching
- * function is found on the stack.
- */
- while (pop (&oldpos, &oldtime, &oldchild)) {
- DBUG_PRINT ("popped", ("%lu %lu", oldtime, oldchild));
- local_time = fn_time - oldtime;
- t = top ();
- t -> children += local_time;
- DBUG_PRINT ("update", ("%s", modules[t -> pos].name));
- DBUG_PRINT ("update", ("%lu", t -> children));
- local_time -= oldchild;
- modules[oldpos].m_time += local_time;
- modules[oldpos].m_calls++;
- tot_time += local_time;
- tot_calls++;
- if (pos == oldpos) {
- goto next_line; /* Should be a break2 */
- }
- }
- /*
- * Assume that item seen started at time 0.
- * (True for function main). But initialize
- * it so that it works the next time too.
- */
- t = top ();
- local_time = fn_time - t -> time - t -> children;
- t -> time = fn_time; t -> children = 0;
- modules[pos].m_time += local_time;
- modules[pos].m_calls++;
- tot_time += local_time;
- tot_calls++;
- break;
- case 'S':
- sscanf (buf+2, "%lx %lx %64s", &fn_sbot, &fn_ssz, fn_name);
- DBUG_PRINT ("srec", ("%lx %lx %s", fn_sbot, fn_ssz, fn_name));
- pos = add (fn_name);
- lastuse = modules[pos].m_stkuse;
-#if 0
- /*
- * Needs further thought. Stack use is determined by
- * difference in stack between two functions with DBUG_ENTER
- * macros. If A calls B calls C, where A and C have the
- * macros, and B doesn't, then B's stack use will be lumped
- * in with either A's or C's. If somewhere else A calls
- * C directly, the stack use will seem to change. Just
- * take the biggest for now...
- */
- if (lastuse > 0 && lastuse != fn_ssz) {
- fprintf (stderr,
- "warning - %s stack use changed (%lx to %lx)\n",
- fn_name, lastuse, fn_ssz);
- }
-#endif
- if (fn_ssz > lastuse) {
- modules[pos].m_stkuse = fn_ssz;
- }
- if (fn_sbot > highstack) {
- highstack = fn_sbot;
- } else if (fn_sbot < lowstack) {
- lowstack = fn_sbot;
- }
- break;
- default:
- fprintf (stderr, "unknown record type '%c'\n", buf[0]);
- break;
- }
- next_line:;
- }
-
- /*
- * Now, we've hit eof. If we still have stuff stacked, then we
- * assume that the user called exit, so give everything the exited
- * time of fn_time.
- */
- while (pop (&oldpos,&oldtime,&oldchild)) {
- local_time = fn_time - oldtime;
- t = top ();
- t -> children += local_time;
- local_time -= oldchild;
- modules[oldpos].m_time += local_time;
- modules[oldpos].m_calls++;
- tot_time += local_time;
- tot_calls++;
- }
- DBUG_VOID_RETURN;
-}
-
-/*
- * out_header () -- print out the header of the report.
- */
-
-void out_header (outf)
-FILE *outf;
-{
- DBUG_ENTER ("out_header");
- if (verbose) {
- fprintf (outf, "Profile of Execution\n");
- fprintf (outf, "Execution times are in milliseconds\n\n");
- fprintf (outf, " Calls\t\t\t Time\n");
- fprintf (outf, " -----\t\t\t ----\n");
- fprintf (outf, "Times\tPercentage\tTime Spent\tPercentage\n");
- fprintf (outf, "Called\tof total\tin Function\tof total Importance\tFunction\n");
- fprintf (outf, "======\t==========\t===========\t========== ==========\t========\t\n");
- } else {
- fprintf (outf, "%ld bytes of stack used, from %lx down to %lx\n\n",
- highstack - lowstack, highstack, lowstack);
- fprintf (outf,
- " %%time sec #call ms/call %%calls weight stack name\n");
- }
- DBUG_VOID_RETURN;
-}
-
-/*
- * out_trailer () - writes out the summary line of the report.
- */
-
-void out_trailer (outf,sum_calls,sum_time)
-FILE *outf;
-unsigned long int sum_calls, sum_time;
-{
- DBUG_ENTER ("out_trailer");
- if (verbose)
- {
- fprintf(outf, "======\t==========\t===========\t==========\t========\n");
- fprintf(outf, "%6ld\t%10.2f\t%11ld\t%10.2f\t\t%-15s\n",
- sum_calls, 100.0, sum_time, 100.0, "Totals");
- }
- DBUG_VOID_RETURN;
-}
-
-/*
- * out_item () - prints out the output line for a single entry,
- * and sets the calls and time fields appropriately.
- */
-
-void out_item (outf, m,called,timed)
-FILE *outf;
-register struct module_t *m;
-unsigned long int *called, *timed;
-{
- char *name = m -> name;
- register unsigned int calls = m -> m_calls;
- register unsigned long local_time = m -> m_time;
- register unsigned long stkuse = m -> m_stkuse;
- unsigned int import;
- double per_time = 0.0;
- double per_calls = 0.0;
- double ms_per_call, local_ftime;
-
- DBUG_ENTER ("out_item");
-
- if (tot_time > 0) {
- per_time = (double) (local_time * 100) / (double) tot_time;
- }
- if (tot_calls > 0) {
- per_calls = (double) (calls * 100) / (double) tot_calls;
- }
- import = (unsigned int) (per_time * per_calls);
-
- if (verbose) {
- fprintf (outf, "%6d\t%10.2f\t%11ld\t%10.2f %10d\t%-15s\n",
- calls, per_calls, local_time, per_time, import, name);
- } else {
- ms_per_call = local_time;
- ms_per_call /= calls;
- local_ftime = local_time;
- local_ftime /= 1000;
- fprintf(outf, "%8.2f%8.3f%8u%8.3f%8.2f%8u%8lu %-s\n",
- per_time, local_ftime, calls, ms_per_call, per_calls, import,
- stkuse, name);
- }
- *called = calls;
- *timed = local_time;
- DBUG_VOID_RETURN;
-}
-
-/*
- * out_body (outf, root,s_calls,s_time) -- Performs an inorder traversal
- * on the binary search tree (root). Calls out_item to actually print
- * the item out.
- */
-
-void out_body (outf, root,s_calls,s_time)
-FILE *outf;
-register unsigned int root;
-register unsigned long int *s_calls, *s_time;
-{
- unsigned long int calls, local_time;
-
- DBUG_ENTER ("out_body");
- DBUG_PRINT ("out_body", ("%lu,%lu",*s_calls,*s_time));
- if (root == MAXPROCS) {
- DBUG_PRINT ("out_body", ("%lu,%lu",*s_calls,*s_time));
- } else {
- while (root != MAXPROCS) {
- out_body (outf, s_table[root].lchild,s_calls,s_time);
- out_item (outf, &modules[s_table[root].pos],&calls,&local_time);
- DBUG_PRINT ("out_body", ("-- %lu -- %lu --", calls, local_time));
- *s_calls += calls;
- *s_time += local_time;
- root = s_table[root].rchild;
- }
- DBUG_PRINT ("out_body", ("%lu,%lu", *s_calls, *s_time));
- }
- DBUG_VOID_RETURN;
-}
-
-/*
- * output () - print out a nice sorted output report on outf.
- */
-
-void output (outf)
-FILE *outf;
-{
- unsigned long int sum_calls = 0;
- unsigned long int sum_time = 0;
-
- DBUG_ENTER ("output");
- if (n_items == 0) {
- fprintf (outf, "%s: No functions to trace\n", my_name);
- exit (EX_DATAERR);
- }
- out_header (outf);
- out_body (outf, 0,&sum_calls,&sum_time);
- out_trailer (outf, sum_calls,sum_time);
- DBUG_VOID_RETURN;
-}
-
-
-#define usage() fprintf (DBUG_FILE,"Usage: %s [-v] [prof-file]\n",my_name)
-
-#ifdef MSDOS
-extern int getopt(int argc, char **argv, char *opts);
-#endif
-extern int optind;
-extern char *optarg;
-
-int main (int argc, char **argv)
-{
- register int c;
- int badflg = 0;
- FILE *infile;
- FILE *outfile = {stdout};
-
-#ifdef THREAD
-#if defined(HAVE_PTHREAD_INIT)
- pthread_init(); /* Must be called before DBUG_ENTER */
-#endif
- my_thread_global_init();
-#endif /* THREAD */
- {
- DBUG_ENTER ("main");
- DBUG_PROCESS (argv[0]);
- my_name = argv[0];
- while ((c = getopt (argc,argv,"#:v")) != EOF) {
- switch (c) {
- case '#': /* Debugging Macro enable */
- DBUG_PUSH (optarg);
- break;
- case 'v': /* Verbose mode */
- verbose++;
- break;
- default:
- badflg++;
- break;
- }
- }
- if (badflg) {
- usage ();
- DBUG_RETURN (EX_USAGE);
- }
- if (optind < argc) {
- FILEOPEN (infile, argv[optind], "r");
- } else {
- FILEOPEN (infile, PRO_FILE, "r");
- }
- process (infile);
- output (outfile);
- DBUG_RETURN (EX_OK);
-}
-}
-
-#ifdef MSDOS
-
-/*
- * From std-unix@ut-sally.UUCP (Moderator, John Quarterman) Sun Nov 3 14:34:15 1985
- * Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site gatech.CSNET
- * Posting-Version: version B 2.10.2 9/18/84; site ut-sally.UUCP
- * Path: gatech!akgua!mhuxv!mhuxt!mhuxr!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!ut-sally!std-unix
- * From: std-unix@ut-sally.UUCP (Moderator, John Quarterman)
- * Newsgroups: mod.std.unix
- * Subject: public domain AT&T getopt source
- * Message-ID: <3352@ut-sally.UUCP>
- * Date: 3 Nov 85 19:34:15 GMT
- * Date-Received: 4 Nov 85 12:25:09 GMT
- * Organization: IEEE/P1003 Portable Operating System Environment Committee
- * Lines: 91
- * Approved: jsq@ut-sally.UUCP
- *
- * Here's something you've all been waiting for: the AT&T public domain
- * source for getopt(3). It is the code which was given out at the 1985
- * UNIFORUM conference in Dallas. I obtained it by electronic mail
- * directly from AT&T. The people there assure me that it is indeed
- * in the public domain.
- *
- * There is no manual page. That is because the one they gave out at
- * UNIFORUM was slightly different from the current System V Release 2
- * manual page. The difference apparently involved a note about the
- * famous rules 5 and 6, recommending using white space between an option
- * and its first argument, and not grouping options that have arguments.
- * Getopt itself is currently lenient about both of these things White
- * space is allowed, but not mandatory, and the last option in a group can
- * have an argument. That particular version of the man page evidently
- * has no official existence, and my source at AT&T did not send a copy.
- * The current SVR2 man page reflects the actual behavor of this getopt.
- * However, I am not about to post a copy of anything licensed by AT&T.
- *
- * I will submit this source to Berkeley as a bug fix.
- *
- * I, personally, make no claims or guarantees of any kind about the
- * following source. I did compile it to get some confidence that
- * it arrived whole, but beyond that you're on your own.
- *
- */
-
-/*LINTLIBRARY*/
-
-int opterr = 1;
-int optind = 1;
-int optopt;
-char *optarg;
-
-static void _ERR(s,c,argv)
-char *s;
-int c;
-char *argv[];
-{
- char errbuf[3];
-
- if (opterr) {
- errbuf[0] = c;
- errbuf[1] = '\n';
- (void) fprintf(stderr, "%s", argv[0]);
- (void) fprintf(stderr, "%s", s);
- (void) fprintf(stderr, "%s", errbuf);
- }
-}
-
-int getopt(argc, argv, opts)
-int argc;
-char **argv, *opts;
-{
- static int sp = 1;
- register int c;
- register char *cp;
-
- if(sp == 1)
- if(optind >= argc ||
- argv[optind][0] != '-' || argv[optind][1] == '\0')
- return(EOF);
- else if(strcmp(argv[optind], "--") == 0) {
- optind++;
- return(EOF);
- }
- optopt = c = argv[optind][sp];
- if(c == ':' || (cp=strchr(opts, c)) == NULL) {
- _ERR(": illegal option -- ", c, argv);
- if(argv[optind][++sp] == '\0') {
- optind++;
- sp = 1;
- }
- return('?');
- }
- if(*++cp == ':') {
- if(argv[optind][sp+1] != '\0')
- optarg = &argv[optind++][sp+1];
- else if(++optind >= argc) {
- _ERR(": option requires an argument -- ", c, argv);
- sp = 1;
- return('?');
- } else
- optarg = argv[optind++];
- sp = 1;
- } else {
- if(argv[optind][++sp] == '\0') {
- sp = 1;
- optind++;
- }
- optarg = NULL;
- }
- return(c);
-}
-
-#endif /* !unix && !xenix */
diff --git a/externals/mysql/extlib/dbug/dbug_long.h b/externals/mysql/extlib/dbug/dbug_long.h
deleted file mode 100644
index 829df181ef..0000000000
--- a/externals/mysql/extlib/dbug/dbug_long.h
+++ /dev/null
@@ -1,160 +0,0 @@
-#error This file is not used in MySQL - see ../include/my_dbug.h instead
-/******************************************************************************
- * *
- * N O T I C E *
- * *
- * Copyright Abandoned, 1987, Fred Fish *
- * *
- * *
- * This previously copyrighted work has been placed into the public *
- * domain by the author and may be freely used for any purpose, *
- * private or commercial. *
- * *
- * Because of the number of inquiries I was receiving about the use *
- * of this product in commercially developed works I have decided to *
- * simply make it public domain to further its unrestricted use. I *
- * specifically would be most happy to see this material become a *
- * part of the standard Unix distributions by AT&T and the Berkeley *
- * Computer Science Research Group, and a standard part of the GNU *
- * system from the Free Software Foundation. *
- * *
- * I would appreciate it, as a courtesy, if this notice is left in *
- * all copies and derivative works. Thank you. *
- * *
- * The author makes no warranty of any kind with respect to this *
- * product and explicitly disclaims any implied warranties of mer- *
- * chantability or fitness for any particular purpose. *
- * *
- ******************************************************************************
- */
-
-/*
- * FILE
- *
- * dbug.h user include file for programs using the dbug package
- *
- * SYNOPSIS
- *
- * #include
- *
- * SCCS ID
- *
- * @(#)dbug.h 1.13 7/17/89
- *
- * DESCRIPTION
- *
- * Programs which use the dbug package must include this file.
- * It contains the appropriate macros to call support routines
- * in the dbug runtime library.
- *
- * To disable compilation of the macro expansions define the
- * preprocessor symbol "DBUG_OFF". This will result in null
- * macros expansions so that the resulting code will be smaller
- * and faster. (The difference may be smaller than you think
- * so this step is recommended only when absolutely necessary).
- * In general, tradeoffs between space and efficiency are
- * decided in favor of efficiency since space is seldom a
- * problem on the new machines).
- *
- * All externally visible symbol names follow the pattern
- * "_db_xxx..xx_" to minimize the possibility of a dbug package
- * symbol colliding with a user defined symbol.
- *
- * The DBUG_ style macros are obsolete and should not be used
- * in new code. Macros to map them to instances of DBUG_PRINT
- * are provided for compatibility with older code. They may go
- * away completely in subsequent releases.
- *
- * AUTHOR
- *
- * Fred Fish
- * (Currently employed by Motorola Computer Division, Tempe, Az.)
- * hao!noao!mcdsun!fnf
- * (602) 438-3614
- *
- */
-
-/*
- * Internally used dbug variables which must be global.
- */
-
-#ifndef DBUG_OFF
- extern int _db_on_; /* TRUE if debug currently enabled */
- extern FILE *_db_fp_; /* Current debug output stream */
- extern char *_db_process_; /* Name of current process */
- extern int _db_keyword_ (); /* Accept/reject keyword */
- extern void _db_push_ (); /* Push state, set up new state */
- extern void _db_pop_ (); /* Pop previous debug state */
- extern void _db_enter_ (); /* New user function entered */
- extern void _db_return_ (); /* User function return */
- extern void _db_pargs_ (); /* Remember args for line */
- extern void _db_doprnt_ (); /* Print debug output */
- extern void _db_setjmp_ (); /* Save debugger environment */
- extern void _db_longjmp_ (); /* Restore debugger environment */
- extern void _db_dump_(); /* Dump memory */
-# endif
-
-
-/*
- * These macros provide a user interface into functions in the
- * dbug runtime support library. They isolate users from changes
- * in the MACROS and/or runtime support.
- *
- * The symbols "__LINE__" and "__FILE__" are expanded by the
- * preprocessor to the current source file line number and file
- * name respectively.
- *
- * WARNING --- Because the DBUG_ENTER macro allocates space on
- * the user function's stack, it must precede any executable
- * statements in the user function.
- *
- */
-
-# ifdef DBUG_OFF
-# define DBUG_ENTER(a1)
-# define DBUG_RETURN(a1) return(a1)
-# define DBUG_VOID_RETURN return
-# define DBUG_EXECUTE(keyword,a1)
-# define DBUG_PRINT(keyword,arglist)
-# define DBUG_2(keyword,format) /* Obsolete */
-# define DBUG_3(keyword,format,a1) /* Obsolete */
-# define DBUG_4(keyword,format,a1,a2) /* Obsolete */
-# define DBUG_5(keyword,format,a1,a2,a3) /* Obsolete */
-# define DBUG_PUSH(a1)
-# define DBUG_POP()
-# define DBUG_PROCESS(a1)
-# define DBUG_FILE (stderr)
-# define DBUG_SETJMP setjmp
-# define DBUG_LONGJMP longjmp
-# define DBUG_DUMP(keyword,a1)
-# else
-# define DBUG_ENTER(a) \
- auto char *_db_func_; auto char *_db_file_; auto int _db_level_; \
- auto char **_db_framep_; \
- _db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
- &_db_framep_)
-# define DBUG_LEAVE \
- (_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
-# define DBUG_RETURN(a1) return (DBUG_LEAVE, (a1))
-/* define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);} Alternate form */
-# define DBUG_VOID_RETURN {DBUG_LEAVE; return;}
-# define DBUG_EXECUTE(keyword,a1) \
- {if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
-# define DBUG_PRINT(keyword,arglist) \
- {if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
-# define DBUG_2(keyword,format) \
- DBUG_PRINT(keyword,(format)) /* Obsolete */
-# define DBUG_3(keyword,format,a1) \
- DBUG_PRINT(keyword,(format,a1)) /* Obsolete */
-# define DBUG_4(keyword,format,a1,a2) \
- DBUG_PRINT(keyword,(format,a1,a2)) /* Obsolete */
-# define DBUG_5(keyword,format,a1,a2,a3) \
- DBUG_PRINT(keyword,(format,a1,a2,a3)) /* Obsolete */
-# define DBUG_PUSH(a1) _db_push_ (a1)
-# define DBUG_POP() _db_pop_ ()
-# define DBUG_PROCESS(a1) (_db_process_ = a1)
-# define DBUG_FILE (_db_fp_)
-# define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
-# define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
-# define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
-# endif
diff --git a/externals/mysql/extlib/dbug/example1.c b/externals/mysql/extlib/dbug/example1.c
deleted file mode 100644
index 7b3c3fcd63..0000000000
--- a/externals/mysql/extlib/dbug/example1.c
+++ /dev/null
@@ -1,10 +0,0 @@
-main (argc, argv)
-int argc;
-char *argv[];
-{
- printf ("argv[0] = %d\n", argv[0]);
- /*
- * Rest of program
- */
- printf ("== done ==\n");
-}
diff --git a/externals/mysql/extlib/dbug/example2.c b/externals/mysql/extlib/dbug/example2.c
deleted file mode 100644
index 75fc1321b1..0000000000
--- a/externals/mysql/extlib/dbug/example2.c
+++ /dev/null
@@ -1,15 +0,0 @@
-int debug = 0;
-
-main (argc, argv)
-int argc;
-char *argv[];
-{
- /* printf ("argv = %x\n", argv) */
- if (debug) printf ("argv[0] = %d\n", argv[0]);
- /*
- * Rest of program
- */
-#ifdef DEBUG
- printf ("== done ==\n");
-#endif
-}
diff --git a/externals/mysql/extlib/dbug/example3.c b/externals/mysql/extlib/dbug/example3.c
deleted file mode 100644
index c035cdfffa..0000000000
--- a/externals/mysql/extlib/dbug/example3.c
+++ /dev/null
@@ -1,14 +0,0 @@
-main (argc, argv)
-int argc;
-char *argv[];
-{
-# ifdef DEBUG
- printf ("argv[0] = %d\n", argv[0]);
-# endif
- /*
- * Rest of program
- */
-# ifdef DEBUG
- printf ("== done ==\n");
-# endif
-}
diff --git a/externals/mysql/extlib/dbug/factorial.c b/externals/mysql/extlib/dbug/factorial.c
deleted file mode 100644
index 7b190ea8d8..0000000000
--- a/externals/mysql/extlib/dbug/factorial.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifdef DBUG_OFF /* We are testing dbug */
-
-int factorial(register int value) {
- if(value > 1) {
- value *= factorial(value-1);
- }
- return value;
-}
-
-#else
-
-#include
-
-int factorial (
-register int value)
-{
- DBUG_ENTER ("factorial");
- DBUG_PRINT ("find", ("find %d factorial", value));
- if (value > 1) {
- value *= factorial (value - 1);
- }
- DBUG_PRINT ("result", ("result is %d", value));
- DBUG_RETURN (value);
-}
-
-#endif
-
diff --git a/externals/mysql/extlib/dbug/main.c b/externals/mysql/extlib/dbug/main.c
deleted file mode 100644
index 00e80c8ba3..0000000000
--- a/externals/mysql/extlib/dbug/main.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include
-
-int main (argc, argv)
-int argc;
-char *argv[];
-{
- int result, ix;
- extern int factorial(int);
- DBUG_ENTER ("main");
- DBUG_PROCESS (argv[0]);
- for (ix = 1; ix < argc && argv[ix][0] == '-'; ix++) {
- switch (argv[ix][1]) {
- case '#':
- DBUG_PUSH (&(argv[ix][2]));
- break;
- }
- }
- for (; ix < argc; ix++) {
- DBUG_PRINT ("args", ("argv[%d] = %s", ix, argv[ix]));
- result = factorial (atoi(argv[ix]));
- printf ("%d\n", result);
- }
- DBUG_RETURN (0);
-}
diff --git a/externals/mysql/extlib/dbug/my_main.c b/externals/mysql/extlib/dbug/my_main.c
deleted file mode 100644
index 31c15aa67a..0000000000
--- a/externals/mysql/extlib/dbug/my_main.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- this is modified version of the original example main.c
- fixed so that it could compile and run in MySQL source tree
-*/
-
-#ifdef DBUG_OFF /* We are testing dbug */
-#undef DBUG_OFF
-#endif
-
-#include /* This includes dbug.h */
-#include
-
-int main (argc, argv)
-int argc;
-char *argv[];
-{
- register int result, ix;
- extern int factorial(int);
-#if defined(HAVE_PTHREAD_INIT) && defined(THREAD)
- pthread_init(); /* Must be called before DBUG_ENTER */
-#endif
-#ifdef THREAD
- my_thread_global_init();
-#endif
- {
- DBUG_ENTER ("main");
- DBUG_PROCESS (argv[0]);
- for (ix = 1; ix < argc && argv[ix][0] == '-'; ix++) {
- switch (argv[ix][1]) {
- case '#':
- DBUG_PUSH (&(argv[ix][2]));
- break;
- }
- }
- for (; ix < argc; ix++) {
- DBUG_PRINT ("args", ("argv[%d] = %s", ix, argv[ix]));
- result = factorial (atoi(argv[ix]));
- printf ("%d\n", result);
- }
- DBUG_RETURN (0);
- }
-}
diff --git a/externals/mysql/extlib/dbug/sanity.c b/externals/mysql/extlib/dbug/sanity.c
deleted file mode 100644
index df43fc14ba..0000000000
--- a/externals/mysql/extlib/dbug/sanity.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Declarate _sanity() if not declared in main program */
-
-#include
-
-extern int _sanity(const char *file,uint line);
-
-#if defined(SAFEMALLOC) && !defined(MASTER) /* Avoid errors in MySQL */
-int _sanity(const char * file __attribute__((unused)),
- uint line __attribute__((unused)))
-{
- return 0;
-}
-#endif
diff --git a/externals/mysql/extlib/dbug/tests.c b/externals/mysql/extlib/dbug/tests.c
deleted file mode 100644
index d76266d34a..0000000000
--- a/externals/mysql/extlib/dbug/tests.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- A program to test DBUG features. Used by tests-t.pl
-*/
-
-char *push1=0;
-
-#include /* This includes dbug.h */
-#include
-#include
-
-const char *func3()
-{
- DBUG_ENTER("func3");
- DBUG_RETURN(DBUG_EVALUATE("ret3", "ok", "ko"));
-}
-
-void func2()
-{
- const char *s;
- DBUG_ENTER("func2");
- s=func3();
- DBUG_PRINT("info", ("s=%s", s));
- DBUG_VOID_RETURN;
-}
-
-int func1()
-{
- DBUG_ENTER("func1");
- func2();
- if (push1)
- {
- DBUG_PUSH(push1);
- fprintf(DBUG_FILE, "=> push1\n");
- }
- DBUG_RETURN(10);
-}
-
-int main (int argc, char *argv[])
-{
- int i;
-#ifdef DBUG_OFF
- return 1;
-#endif
- if (argc == 1)
- return 0;
-
-#if defined(HAVE_PTHREAD_INIT) && defined(THREAD)
- pthread_init(); /* Must be called before DBUG_ENTER */
-#endif
-#ifdef THREAD
- my_thread_global_init();
-#endif
- dup2(1, 2);
- for (i = 1; i < argc; i++)
- {
- if (strncmp(argv[i], "--push1=", 8) == 0)
- push1=argv[i]+8;
- else
- DBUG_PUSH (argv[i]);
- }
- {
- DBUG_ENTER ("main");
- DBUG_PROCESS ("dbug-tests");
- func1();
- DBUG_EXECUTE_IF("dump",
- {
- char s[1000];
- DBUG_EXPLAIN(s, sizeof(s)-1);
- DBUG_DUMP("dump", (uchar*)s, strlen(s));
- });
- DBUG_EXECUTE_IF("push", DBUG_PUSH("+t"); );
- DBUG_EXECUTE("execute", fprintf(DBUG_FILE, "=> execute\n"); );
- DBUG_EXECUTE_IF("set", DBUG_SET("+F"); );
- fprintf(DBUG_FILE, "=> evaluate: %s\n",
- DBUG_EVALUATE("evaluate", "ON", "OFF"));
- fprintf(DBUG_FILE, "=> evaluate_if: %s\n",
- DBUG_EVALUATE_IF("evaluate_if", "ON", "OFF"));
- DBUG_EXECUTE_IF("pop", DBUG_POP(); );
- {
- char s[1000] __attribute__((unused));
- DBUG_EXPLAIN(s, sizeof(s)-1);
- DBUG_PRINT("explain", ("dbug explained: %s", s));
- }
- func2();
- DBUG_RETURN (0);
- }
-}
diff --git a/externals/mysql/extlib/regex/cclass.h b/externals/mysql/extlib/regex/cclass.h
deleted file mode 100644
index b877b5dee6..0000000000
--- a/externals/mysql/extlib/regex/cclass.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* character-class table */
-
-#define CCLASS_ALNUM 0
-#define CCLASS_ALPHA 1
-#define CCLASS_BLANK 2
-#define CCLASS_CNTRL 3
-#define CCLASS_DIGIT 4
-#define CCLASS_GRAPH 5
-#define CCLASS_LOWER 6
-#define CCLASS_PRINT 7
-#define CCLASS_PUNCT 8
-#define CCLASS_SPACE 9
-#define CCLASS_UPPER 10
-#define CCLASS_XDIGIT 11
-#define CCLASS_LAST 12
-
-extern struct cclass {
- const char *name;
- const char *chars;
- const char *multis;
- uint mask;
-} cclasses[];
diff --git a/externals/mysql/extlib/regex/cname.h b/externals/mysql/extlib/regex/cname.h
deleted file mode 100644
index 06865f3e10..0000000000
--- a/externals/mysql/extlib/regex/cname.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* character-name table */
-static struct cname {
- const char *name;
- const char code;
-} cnames[] = {
- {"NUL", '\0'},
- {"SOH", '\001'},
- {"STX", '\002'},
- {"ETX", '\003'},
- {"EOT", '\004'},
- {"ENQ", '\005'},
- {"ACK", '\006'},
- {"BEL", '\007'},
- {"alert", '\007'},
- {"BS", '\010'},
- {"backspace", '\b'},
- {"HT", '\011'},
- {"tab", '\t'},
- {"LF", '\012'},
- {"newline", '\n'},
- {"VT", '\013'},
- {"vertical-tab",'\v'},
- {"FF", '\014'},
- {"form-feed", '\f'},
- {"CR", '\015'},
- {"carriage-return", '\r'},
- {"SO", '\016'},
- {"SI", '\017'},
- {"DLE", '\020'},
- {"DC1", '\021'},
- {"DC2", '\022'},
- {"DC3", '\023'},
- {"DC4", '\024'},
- {"NAK", '\025'},
- {"SYN", '\026'},
- {"ETB", '\027'},
- {"CAN", '\030'},
- {"EM", '\031'},
- {"SUB", '\032'},
- {"ESC", '\033'},
- {"IS4", '\034'},
- {"FS", '\034'},
- {"IS3", '\035'},
- {"GS", '\035'},
- {"IS2", '\036'},
- {"RS", '\036'},
- {"IS1", '\037'},
- {"US", '\037'},
- {"space", ' '},
- {"exclamation-mark", '!'},
- {"quotation-mark", '"'},
- {"number-sign", '#'},
- {"dollar-sign", '$'},
- {"percent-sign", '%'},
- {"ampersand", '&'},
- {"apostrophe", '\''},
- {"left-parenthesis", '('},
- {"right-parenthesis", ')'},
- {"asterisk", '*'},
- {"plus-sign", '+'},
- {"comma", ','},
- {"hyphen", '-'},
- {"hyphen-minus", '-'},
- {"period", '.'},
- {"full-stop", '.'},
- {"slash", '/'},
- {"solidus", '/'},
- {"zero", '0'},
- {"one", '1'},
- {"two", '2'},
- {"three", '3'},
- {"four", '4'},
- {"five", '5'},
- {"six", '6'},
- {"seven", '7'},
- {"eight", '8'},
- {"nine", '9'},
- {"colon", ':'},
- {"semicolon", ';'},
- {"less-than-sign", '<'},
- {"equals-sign", '='},
- {"greater-than-sign", '>'},
- {"question-mark", '?'},
- {"commercial-at", '@'},
- {"left-square-bracket", '['},
- {"backslash", '\\'},
- {"reverse-solidus", '\\'},
- {"right-square-bracket",']'},
- {"circumflex", '^'},
- {"circumflex-accent", '^'},
- {"underscore", '_'},
- {"low-line", '_'},
- {"grave-accent", '`'},
- {"left-brace", '{'},
- {"left-curly-bracket", '{'},
- {"vertical-line", '|'},
- {"right-brace", '}'},
- {"right-curly-bracket", '}'},
- {"tilde", '~'},
- {"DEL", '\177'},
- {NULL, 0},
-};
-
-
diff --git a/externals/mysql/extlib/regex/debug.c b/externals/mysql/extlib/regex/debug.c
deleted file mode 100644
index 271b09bb27..0000000000
--- a/externals/mysql/extlib/regex/debug.c
+++ /dev/null
@@ -1,246 +0,0 @@
-#include
-#include
-#include
-#include
-
-#include "my_regex.h"
-#include "utils.h"
-#include "regex2.h"
-#include "debug.ih"
-
-/* Added extra paramter to regchar to remove static buffer ; Monty 96.11.27 */
-
-/*
- - regprint - print a regexp for debugging
- == void regprint(regex_t *r, FILE *d);
- */
-void
-regprint(r, d)
-my_regex_t *r;
-FILE *d;
-{
- register struct re_guts *g = r->re_g;
- register int i;
- register int c;
- register int last;
- int nincat[NC];
- char buf[10];
-
- fprintf(d, "%ld states, %d categories", (long)g->nstates,
- g->ncategories);
- fprintf(d, ", first %ld last %ld", (long)g->firststate,
- (long)g->laststate);
- if (g->iflags&USEBOL)
- fprintf(d, ", USEBOL");
- if (g->iflags&USEEOL)
- fprintf(d, ", USEEOL");
- if (g->iflags&BAD)
- fprintf(d, ", BAD");
- if (g->nsub > 0)
- fprintf(d, ", nsub=%ld", (long)g->nsub);
- if (g->must != NULL)
- fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen,
- g->must);
- if (g->backrefs)
- fprintf(d, ", backrefs");
- if (g->nplus > 0)
- fprintf(d, ", nplus %ld", (long)g->nplus);
- fprintf(d, "\n");
- s_print(r->charset, g, d);
- for (i = 0; i < g->ncategories; i++) {
- nincat[i] = 0;
- for (c = CHAR_MIN; c <= CHAR_MAX; c++)
- if (g->categories[c] == i)
- nincat[i]++;
- }
- fprintf(d, "cc0#%d", nincat[0]);
- for (i = 1; i < g->ncategories; i++)
- if (nincat[i] == 1) {
- for (c = CHAR_MIN; c <= CHAR_MAX; c++)
- if (g->categories[c] == i)
- break;
- fprintf(d, ", %d=%s", i, regchar(r->charset,c,buf));
- }
- fprintf(d, "\n");
- for (i = 1; i < g->ncategories; i++)
- if (nincat[i] != 1) {
- fprintf(d, "cc%d\t", i);
- last = -1;
- for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */
- if (c <= CHAR_MAX && g->categories[c] == i) {
- if (last < 0) {
- fprintf(d, "%s", regchar(r->charset,c,buf));
- last = c;
- }
- } else {
- if (last >= 0) {
- if (last != c-1)
- fprintf(d, "-%s",
- regchar(r->charset,c-1,buf));
- last = -1;
- }
- }
- fprintf(d, "\n");
- }
-}
-
-/*
- - s_print - print the strip for debugging
- == static void s_print(register struct re_guts *g, FILE *d);
- */
-static void
-s_print(charset, g, d)
-CHARSET_INFO *charset;
-register struct re_guts *g;
-FILE *d;
-{
- register sop *s;
- register cset *cs;
- register int i;
- register int done = 0;
- register sop opnd;
- register int col = 0;
- register int last;
- register sopno offset = 2;
- char buf[10];
-# define GAP() { if (offset % 5 == 0) { \
- if (col > 40) { \
- fprintf(d, "\n\t"); \
- col = 0; \
- } else { \
- fprintf(d, " "); \
- col++; \
- } \
- } else \
- col++; \
- offset++; \
- }
-
- if (OP(g->strip[0]) != OEND)
- fprintf(d, "missing initial OEND!\n");
- for (s = &g->strip[1]; !done; s++) {
- opnd = OPND(*s);
- switch (OP(*s)) {
- case OEND:
- fprintf(d, "\n");
- done = 1;
- break;
- case OCHAR:
- if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL)
- fprintf(d, "\\%c", (char)opnd);
- else
- fprintf(d, "%s", regchar(charset,(char)opnd,buf));
- break;
- case OBOL:
- fprintf(d, "^");
- break;
- case OEOL:
- fprintf(d, "$");
- break;
- case OBOW:
- fprintf(d, "\\{");
- break;
- case OEOW:
- fprintf(d, "\\}");
- break;
- case OANY:
- fprintf(d, ".");
- break;
- case OANYOF:
- fprintf(d, "[(%ld)", (long)opnd);
- cs = &g->sets[opnd];
- last = -1;
- for (i = 0; i < g->csetsize+1; i++) /* +1 flushes */
- if (CHIN(cs, i) && i < g->csetsize) {
- if (last < 0) {
- fprintf(d, "%s", regchar(charset,i,buf));
- last = i;
- }
- } else {
- if (last >= 0) {
- if (last != i-1)
- fprintf(d, "-%s",
- regchar(charset,i-1,buf));
- last = -1;
- }
- }
- fprintf(d, "]");
- break;
- case OBACK_:
- fprintf(d, "(\\<%ld>", (long)opnd);
- break;
- case O_BACK:
- fprintf(d, "<%ld>\\)", (long)opnd);
- break;
- case OPLUS_:
- fprintf(d, "(+");
- if (OP(*(s+opnd)) != O_PLUS)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case O_PLUS:
- if (OP(*(s-opnd)) != OPLUS_)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, "+)");
- break;
- case OQUEST_:
- fprintf(d, "(?");
- if (OP(*(s+opnd)) != O_QUEST)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case O_QUEST:
- if (OP(*(s-opnd)) != OQUEST_)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, "?)");
- break;
- case OLPAREN:
- fprintf(d, "((<%ld>", (long)opnd);
- break;
- case ORPAREN:
- fprintf(d, "<%ld>))", (long)opnd);
- break;
- case OCH_:
- fprintf(d, "<");
- if (OP(*(s+opnd)) != OOR2)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case OOR1:
- if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, "|");
- break;
- case OOR2:
- fprintf(d, "|");
- if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH)
- fprintf(d, "<%ld>", (long)opnd);
- break;
- case O_CH:
- if (OP(*(s-opnd)) != OOR1)
- fprintf(d, "<%ld>", (long)opnd);
- fprintf(d, ">");
- break;
- default:
- fprintf(d, "!%ld(%ld)!", OP(*s), opnd);
- break;
- }
- if (!done)
- GAP();
- }
-}
-
-/*
- - regchar - make a character printable
- == static char *regchar(int ch);
- */
-static char * /* -> representation */
-regchar(charset,ch,buf)
-CHARSET_INFO *charset;
-int ch;
-char *buf;
-{
-
- if (my_isprint(charset,ch) || ch == ' ')
- sprintf(buf, "%c", ch);
- else
- sprintf(buf, "\\%o", ch);
- return(buf);
-}
diff --git a/externals/mysql/extlib/regex/engine.c b/externals/mysql/extlib/regex/engine.c
deleted file mode 100644
index 1968ca61a9..0000000000
--- a/externals/mysql/extlib/regex/engine.c
+++ /dev/null
@@ -1,1031 +0,0 @@
-/*
- * The matching engine and friends. This file is #included by regexec.c
- * after suitable #defines of a variety of macros used herein, so that
- * different state representations can be used without duplicating masses
- * of code.
- */
-
-#ifdef SNAMES
-#define matcher smatcher
-#define fast sfast
-#define slow sslow
-#define dissect sdissect
-#define backref sbackref
-#define step sstep
-#define print sprint
-#define at sat
-#define match smat
-#endif
-#ifdef LNAMES
-#define matcher lmatcher
-#define fast lfast
-#define slow lslow
-#define dissect ldissect
-#define backref lbackref
-#define step lstep
-#define print lprint
-#define at lat
-#define match lmat
-#endif
-
-/* another structure passed up and down to avoid zillions of parameters */
-struct match {
- struct re_guts *g;
- int eflags;
- my_regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
- char *offp; /* offsets work from here */
- char *beginp; /* start of string -- virtual NUL precedes */
- char *endp; /* end of string -- virtual NUL here */
- char *coldp; /* can be no match starting before here */
- char **lastpos; /* [nplus+1] */
- STATEVARS;
- states st; /* current states */
- states fresh; /* states for a fresh start */
- states tmp; /* temporary */
- states empty; /* empty set of states */
-};
-
-#include "engine.ih"
-
-#ifdef REDEBUG
-#define SP(t, s, c) print(m, t, s, c, stdout)
-#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
-#define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); }
-#else
-#define SP(t, s, c) /* nothing */
-#define AT(t, p1, p2, s1, s2) /* nothing */
-#define NOTE(s) /* nothing */
-#endif
-
-/*
- - matcher - the actual matching engine
- == static int matcher(register struct re_guts *g, char *string, \
- == size_t nmatch, regmatch_t pmatch[], int eflags);
- */
-static int /* 0 success, REG_NOMATCH failure */
-matcher(charset,g, str, nmatch, pmatch, eflags)
-CHARSET_INFO *charset;
-register struct re_guts *g;
-char *str;
-size_t nmatch;
-my_regmatch_t pmatch[];
-int eflags;
-{
- register char *endp;
- register uint i;
- struct match mv;
- register struct match *m = &mv;
- register char *dp;
- register const sopno gf = g->firststate+1; /* +1 for OEND */
- register const sopno gl = g->laststate;
- char *start;
- char *stop;
-
- /* simplify the situation where possible */
- if (g->cflags®_NOSUB)
- nmatch = 0;
- if (eflags®_STARTEND) {
- start = str + pmatch[0].rm_so;
- stop = str + pmatch[0].rm_eo;
- } else {
- start = str;
- stop = start + strlen(start);
- }
- if (stop < start)
- return(REG_INVARG);
-
- /* prescreening; this does wonders for this rather slow code */
- if (g->must != NULL) {
- for (dp = start; dp < stop; dp++)
- if (*dp == g->must[0] && stop - dp >= g->mlen &&
- memcmp(dp, g->must, (size_t)g->mlen) == 0)
- break;
- if (dp == stop) /* we didn't find g->must */
- return(REG_NOMATCH);
- }
-
- /* match struct setup */
- m->g = g;
- m->eflags = eflags;
- m->pmatch = NULL;
- m->lastpos = NULL;
- m->offp = str;
- m->beginp = start;
- m->endp = stop;
- STATESETUP(m, 4);
- SETUP(m->st);
- SETUP(m->fresh);
- SETUP(m->tmp);
- SETUP(m->empty);
- CLEAR(m->empty);
-
- /* this loop does only one repetition except for backrefs */
- for (;;) {
- endp = fast(charset, m, start, stop, gf, gl);
- if (endp == NULL) { /* a miss */
- if (m->pmatch != NULL)
- free((char *)m->pmatch);
- if (m->lastpos != NULL)
- free((char *)m->lastpos);
- STATETEARDOWN(m);
- return(REG_NOMATCH);
- }
- if (nmatch == 0 && !g->backrefs)
- break; /* no further info needed */
-
- /* where? */
- assert(m->coldp != NULL);
- for (;;) {
- NOTE("finding start");
- endp = slow(charset, m, m->coldp, stop, gf, gl);
- if (endp != NULL)
- break;
- assert(m->coldp < m->endp);
- m->coldp++;
- }
- if (nmatch == 1 && !g->backrefs)
- break; /* no further info needed */
-
- /* oh my, he wants the subexpressions... */
- if (m->pmatch == NULL)
- m->pmatch = (my_regmatch_t *)malloc((m->g->nsub + 1) *
- sizeof(my_regmatch_t));
- if (m->pmatch == NULL) {
- if (m->lastpos != NULL)
- free((char *)m->lastpos);
- STATETEARDOWN(m);
- return(REG_ESPACE);
- }
- for (i = 1; i <= m->g->nsub; i++)
- m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
- if (!g->backrefs && !(m->eflags®_BACKR)) {
- NOTE("dissecting");
- dp = dissect(charset, m, m->coldp, endp, gf, gl);
- } else {
- if (g->nplus > 0 && m->lastpos == NULL)
- m->lastpos = (char **)malloc((g->nplus+1) *
- sizeof(char *));
- if (g->nplus > 0 && m->lastpos == NULL) {
- free(m->pmatch);
- STATETEARDOWN(m);
- return(REG_ESPACE);
- }
- NOTE("backref dissect");
- dp = backref(charset, m, m->coldp, endp, gf, gl, (sopno)0);
- }
- if (dp != NULL)
- break;
-
- /* uh-oh... we couldn't find a subexpression-level match */
- assert(g->backrefs); /* must be back references doing it */
- assert(g->nplus == 0 || m->lastpos != NULL);
- for (;;) {
- if (dp != NULL || endp <= m->coldp)
- break; /* defeat */
- NOTE("backoff");
- endp = slow(charset, m, m->coldp, endp-1, gf, gl);
- if (endp == NULL)
- break; /* defeat */
- /* try it on a shorter possibility */
-#ifndef NDEBUG
- for (i = 1; i <= m->g->nsub; i++) {
- assert(m->pmatch[i].rm_so == -1);
- assert(m->pmatch[i].rm_eo == -1);
- }
-#endif
- NOTE("backoff dissect");
- dp = backref(charset, m, m->coldp, endp, gf, gl, (sopno)0);
- }
- assert(dp == NULL || dp == endp);
- if (dp != NULL) /* found a shorter one */
- break;
-
- /* despite initial appearances, there is no match here */
- NOTE("false alarm");
- start = m->coldp + 1; /* recycle starting later */
- assert(start <= stop);
- }
-
- /* fill in the details if requested */
- if (nmatch > 0) {
- pmatch[0].rm_so = m->coldp - m->offp;
- pmatch[0].rm_eo = endp - m->offp;
- }
- if (nmatch > 1) {
- assert(m->pmatch != NULL);
- for (i = 1; i < nmatch; i++)
- if (i <= m->g->nsub)
- pmatch[i] = m->pmatch[i];
- else {
- pmatch[i].rm_so = -1;
- pmatch[i].rm_eo = -1;
- }
- }
-
- if (m->pmatch != NULL)
- free((char *)m->pmatch);
- if (m->lastpos != NULL)
- free((char *)m->lastpos);
- STATETEARDOWN(m);
- return(0);
-}
-
-/*
- - dissect - figure out what matched what, no back references
- == static char *dissect(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst);
- */
-static char * /* == stop (success) always */
-dissect(charset, m, start, stop, startst, stopst)
-CHARSET_INFO *charset;
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- register uint i;
- register sopno ss; /* start sop of current subRE */
- register sopno es; /* end sop of current subRE */
- register char *sp; /* start of string matched by it */
- register char *stp; /* string matched by it cannot pass here */
- register char *rest; /* start of rest of string */
- register char *tail; /* string unmatched by rest of RE */
- register sopno ssub; /* start sop of subsubRE */
- register sopno esub; /* end sop of subsubRE */
- register char *ssp; /* start of string matched by subsubRE */
- register char *sep; /* end of string matched by subsubRE */
- register char *oldssp; /* previous ssp */
- register char *dp; /* used in debug mode to check asserts */
-
- AT("diss", start, stop, startst, stopst);
- sp = start;
- for (ss = startst; ss < stopst; ss = es) {
- /* identify end of subRE */
- es = ss;
- switch (OP(m->g->strip[es])) {
- case OPLUS_:
- case OQUEST_:
- es += OPND(m->g->strip[es]);
- break;
- case OCH_:
- while (OP(m->g->strip[es]) != O_CH)
- es += OPND(m->g->strip[es]);
- break;
- }
- es++;
-
- /* figure out what it matched */
- switch (OP(m->g->strip[ss])) {
- case OEND:
- assert(nope);
- break;
- case OCHAR:
- sp++;
- break;
- case OBOL:
- case OEOL:
- case OBOW:
- case OEOW:
- break;
- case OANY:
- case OANYOF:
- sp++;
- break;
- case OBACK_:
- case O_BACK:
- assert(nope);
- break;
- /* cases where length of match is hard to find */
- case OQUEST_:
- stp = stop;
- for (;;) {
- /* how long could this one be? */
- rest = slow(charset, m, sp, stp, ss, es);
- assert(rest != NULL); /* it did match */
- /* could the rest match the rest? */
- tail = slow(charset, m, rest, stop, es, stopst);
- if (tail == stop)
- break; /* yes! */
- /* no -- try a shorter match for this one */
- stp = rest - 1;
- assert(stp >= sp); /* it did work */
- }
- ssub = ss + 1;
- esub = es - 1;
- /* did innards match? */
- if (slow(charset, m, sp, rest, ssub, esub) != NULL) {
- dp = dissect(charset, m, sp, rest, ssub, esub);
- assert(dp == rest);
- } else /* no */
- assert(sp == rest);
- sp = rest;
- break;
- case OPLUS_:
- stp = stop;
- for (;;) {
- /* how long could this one be? */
- rest = slow(charset, m, sp, stp, ss, es);
- assert(rest != NULL); /* it did match */
- /* could the rest match the rest? */
- tail = slow(charset, m, rest, stop, es, stopst);
- if (tail == stop)
- break; /* yes! */
- /* no -- try a shorter match for this one */
- stp = rest - 1;
- assert(stp >= sp); /* it did work */
- }
- ssub = ss + 1;
- esub = es - 1;
- ssp = sp;
- oldssp = ssp;
- for (;;) { /* find last match of innards */
- sep = slow(charset, m, ssp, rest, ssub, esub);
- if (sep == NULL || sep == ssp)
- break; /* failed or matched null */
- oldssp = ssp; /* on to next try */
- ssp = sep;
- }
- if (sep == NULL) {
- /* last successful match */
- sep = ssp;
- ssp = oldssp;
- }
- assert(sep == rest); /* must exhaust substring */
- assert(slow(charset, m, ssp, sep, ssub, esub) == rest);
- dp = dissect(charset, m, ssp, sep, ssub, esub);
- assert(dp == sep);
- sp = rest;
- break;
- case OCH_:
- stp = stop;
- for (;;) {
- /* how long could this one be? */
- rest = slow(charset, m, sp, stp, ss, es);
- assert(rest != NULL); /* it did match */
- /* could the rest match the rest? */
- tail = slow(charset, m, rest, stop, es, stopst);
- if (tail == stop)
- break; /* yes! */
- /* no -- try a shorter match for this one */
- stp = rest - 1;
- assert(stp >= sp); /* it did work */
- }
- ssub = ss + 1;
- esub = ss + OPND(m->g->strip[ss]) - 1;
- assert(OP(m->g->strip[esub]) == OOR1);
- for (;;) { /* find first matching branch */
- if (slow(charset, m, sp, rest, ssub, esub) == rest)
- break; /* it matched all of it */
- /* that one missed, try next one */
- assert(OP(m->g->strip[esub]) == OOR1);
- esub++;
- assert(OP(m->g->strip[esub]) == OOR2);
- ssub = esub + 1;
- esub += OPND(m->g->strip[esub]);
- if (OP(m->g->strip[esub]) == OOR2)
- esub--;
- else
- assert(OP(m->g->strip[esub]) == O_CH);
- }
- dp = dissect(charset, m, sp, rest, ssub, esub);
- assert(dp == rest);
- sp = rest;
- break;
- case O_PLUS:
- case O_QUEST:
- case OOR1:
- case OOR2:
- case O_CH:
- assert(nope);
- break;
- case OLPAREN:
- i = OPND(m->g->strip[ss]);
- assert(0 < i && i <= m->g->nsub);
- m->pmatch[i].rm_so = sp - m->offp;
- break;
- case ORPAREN:
- i = OPND(m->g->strip[ss]);
- assert(0 < i && i <= m->g->nsub);
- m->pmatch[i].rm_eo = sp - m->offp;
- break;
- default: /* uh oh */
- assert(nope);
- break;
- }
- }
-
- assert(sp == stop);
- return(sp);
-}
-
-/*
- - backref - figure out what matched what, figuring in back references
- == static char *backref(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst, sopno lev);
- */
-static char * /* == stop (success) or NULL (failure) */
-backref(charset,m, start, stop, startst, stopst, lev)
-CHARSET_INFO *charset;
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-sopno lev; /* PLUS nesting level */
-{
- register uint i;
- register sopno ss; /* start sop of current subRE */
- register char *sp; /* start of string matched by it */
- register sopno ssub; /* start sop of subsubRE */
- register sopno esub; /* end sop of subsubRE */
- register char *ssp; /* start of string matched by subsubRE */
- register char *dp;
- register size_t len;
- register int hard;
- register sop s;
- register regoff_t offsave;
- register cset *cs;
-
- AT("back", start, stop, startst, stopst);
- sp = start;
-
- /* get as far as we can with easy stuff */
- hard = 0;
- for (ss = startst; !hard && ss < stopst; ss++)
- switch (OP(s = m->g->strip[ss])) {
- case OCHAR:
- if (sp == stop || *sp++ != (char)OPND(s))
- return(NULL);
- break;
- case OANY:
- if (sp == stop)
- return(NULL);
- sp++;
- break;
- case OANYOF:
- cs = &m->g->sets[OPND(s)];
- if (sp == stop || !CHIN(cs, *sp++))
- return(NULL);
- break;
- case OBOL:
- if ( (sp == m->beginp && !(m->eflags®_NOTBOL)) ||
- (sp < m->endp && *(sp-1) == '\n' &&
- (m->g->cflags®_NEWLINE)) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case OEOL:
- if ( (sp == m->endp && !(m->eflags®_NOTEOL)) ||
- (sp < m->endp && *sp == '\n' &&
- (m->g->cflags®_NEWLINE)) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case OBOW:
- if (( (sp == m->beginp && !(m->eflags®_NOTBOL)) ||
- (sp < m->endp && *(sp-1) == '\n' &&
- (m->g->cflags®_NEWLINE)) ||
- (sp > m->beginp &&
- !ISWORD(charset,*(sp-1))) ) &&
- (sp < m->endp && ISWORD(charset,*sp)) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case OEOW:
- if (( (sp == m->endp && !(m->eflags®_NOTEOL)) ||
- (sp < m->endp && *sp == '\n' &&
- (m->g->cflags®_NEWLINE)) ||
- (sp < m->endp && !ISWORD(charset,*sp)) ) &&
- (sp > m->beginp && ISWORD(charset,*(sp-1))) )
- { /* yes */ }
- else
- return(NULL);
- break;
- case O_QUEST:
- break;
- case OOR1: /* matches null but needs to skip */
- ss++;
- s = m->g->strip[ss];
- do {
- assert(OP(s) == OOR2);
- ss += OPND(s);
- } while (OP(s = m->g->strip[ss]) != O_CH);
- /* note that the ss++ gets us past the O_CH */
- break;
- default: /* have to make a choice */
- hard = 1;
- break;
- }
- if (!hard) { /* that was it! */
- if (sp != stop)
- return(NULL);
- return(sp);
- }
- ss--; /* adjust for the for's final increment */
-
- /* the hard stuff */
- AT("hard", sp, stop, ss, stopst);
- s = m->g->strip[ss];
- switch (OP(s)) {
- case OBACK_: /* the vilest depths */
- i = OPND(s);
- assert(0 < i && i <= m->g->nsub);
- if (m->pmatch[i].rm_eo == -1)
- return(NULL);
- assert(m->pmatch[i].rm_so != -1);
- len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
- assert((size_t) (stop - m->beginp) >= len);
- if (sp > stop - len)
- return(NULL); /* not enough left to match */
- ssp = m->offp + m->pmatch[i].rm_so;
- if (memcmp(sp, ssp, len) != 0)
- return(NULL);
- while (m->g->strip[ss] != SOP(O_BACK, i))
- ss++;
- return(backref(charset, m, sp+len, stop, ss+1, stopst, lev));
- break;
- case OQUEST_: /* to null or not */
- dp = backref(charset, m, sp, stop, ss+1, stopst, lev);
- if (dp != NULL)
- return(dp); /* not */
- return(backref(charset, m, sp, stop, ss+OPND(s)+1, stopst, lev));
- break;
- case OPLUS_:
- assert(m->lastpos != NULL);
- assert(lev+1 <= m->g->nplus);
- m->lastpos[lev+1] = sp;
- return(backref(charset, m, sp, stop, ss+1, stopst, lev+1));
- break;
- case O_PLUS:
- if (sp == m->lastpos[lev]) /* last pass matched null */
- return(backref(charset, m, sp, stop, ss+1, stopst, lev-1));
- /* try another pass */
- m->lastpos[lev] = sp;
- dp = backref(charset, m, sp, stop, ss-OPND(s)+1, stopst, lev);
- if (dp == NULL)
- return(backref(charset, m, sp, stop, ss+1, stopst, lev-1));
- else
- return(dp);
- break;
- case OCH_: /* find the right one, if any */
- ssub = ss + 1;
- esub = ss + OPND(s) - 1;
- assert(OP(m->g->strip[esub]) == OOR1);
- for (;;) { /* find first matching branch */
- dp = backref(charset, m, sp, stop, ssub, esub, lev);
- if (dp != NULL)
- return(dp);
- /* that one missed, try next one */
- if (OP(m->g->strip[esub]) == O_CH)
- return(NULL); /* there is none */
- esub++;
- assert(OP(m->g->strip[esub]) == OOR2);
- ssub = esub + 1;
- esub += OPND(m->g->strip[esub]);
- if (OP(m->g->strip[esub]) == OOR2)
- esub--;
- else
- assert(OP(m->g->strip[esub]) == O_CH);
- }
- break;
- case OLPAREN: /* must undo assignment if rest fails */
- i = OPND(s);
- assert(0 < i && i <= m->g->nsub);
- offsave = m->pmatch[i].rm_so;
- m->pmatch[i].rm_so = sp - m->offp;
- dp = backref(charset, m, sp, stop, ss+1, stopst, lev);
- if (dp != NULL)
- return(dp);
- m->pmatch[i].rm_so = offsave;
- return(NULL);
- break;
- case ORPAREN: /* must undo assignment if rest fails */
- i = OPND(s);
- assert(0 < i && i <= m->g->nsub);
- offsave = m->pmatch[i].rm_eo;
- m->pmatch[i].rm_eo = sp - m->offp;
- dp = backref(charset, m, sp, stop, ss+1, stopst, lev);
- if (dp != NULL)
- return(dp);
- m->pmatch[i].rm_eo = offsave;
- return(NULL);
- break;
- default: /* uh oh */
- assert(nope);
- break;
- }
-
- /* "can't happen" */
- assert(nope);
- /* NOTREACHED */
- return 0; /* Keep gcc happy */
-}
-
-/*
- - fast - step through the string at top speed
- == static char *fast(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst);
- */
-static char * /* where tentative match ended, or NULL */
-fast(charset, m, start, stop, startst, stopst)
-CHARSET_INFO *charset;
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- register states st = m->st;
- register states fresh = m->fresh;
- register states tmp = m->tmp;
- register char *p = start;
- register int c = (start == m->beginp) ? OUT : *(start-1);
- register int lastc; /* previous c */
- register int flagch;
- register int i;
- register char *coldp; /* last p after which no match was underway */
-
- CLEAR(st);
- SET1(st, startst);
- st = step(m->g, startst, stopst, st, NOTHING, st);
- ASSIGN(fresh, st);
- SP("start", st, *p);
- coldp = NULL;
- for (;;) {
- /* next character */
- lastc = c;
- c = (p == m->endp) ? OUT : *p;
- if (EQ(st, fresh))
- coldp = p;
-
- /* is there an EOL and/or BOL between lastc and c? */
- flagch = '\0';
- i = 0;
- if ( (lastc == '\n' && m->g->cflags®_NEWLINE) ||
- (lastc == OUT && !(m->eflags®_NOTBOL)) ) {
- flagch = BOL;
- i = m->g->nbol;
- }
- if ( (c == '\n' && m->g->cflags®_NEWLINE) ||
- (c == OUT && !(m->eflags®_NOTEOL)) ) {
- flagch = (flagch == BOL) ? BOLEOL : EOL;
- i += m->g->neol;
- }
- if (i != 0) {
- for (; i > 0; i--)
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("boleol", st, c);
- }
-
- /* how about a word boundary? */
- if ( (flagch == BOL || (lastc != OUT && !ISWORD(charset,lastc))) &&
- (c != OUT && ISWORD(charset,c)) ) {
- flagch = BOW;
- }
- if ( (lastc != OUT && ISWORD(charset,lastc)) &&
- (flagch == EOL || (c != OUT && !ISWORD(charset,c))) ) {
- flagch = EOW;
- }
- if (flagch == BOW || flagch == EOW) {
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("boweow", st, c);
- }
-
- /* are we done? */
- if (ISSET(st, stopst) || p == stop)
- break; /* NOTE BREAK OUT */
-
- /* no, we must deal with this character */
- ASSIGN(tmp, st);
- ASSIGN(st, fresh);
- assert(c != OUT);
- st = step(m->g, startst, stopst, tmp, c, st);
- SP("aft", st, c);
- assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
- p++;
- }
-
- assert(coldp != NULL);
- m->coldp = coldp;
- if (ISSET(st, stopst))
- return(p+1);
- else
- return(NULL);
-}
-
-/*
- - slow - step through the string more deliberately
- == static char *slow(register struct match *m, char *start, \
- == char *stop, sopno startst, sopno stopst);
- */
-static char * /* where it ended */
-slow(charset, m, start, stop, startst, stopst)
-CHARSET_INFO *charset;
-register struct match *m;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- register states st = m->st;
- register states empty = m->empty;
- register states tmp = m->tmp;
- register char *p = start;
- register int c = (start == m->beginp) ? OUT : *(start-1);
- register int lastc; /* previous c */
- register int flagch;
- register int i;
- register char *matchp; /* last p at which a match ended */
-
- AT("slow", start, stop, startst, stopst);
- CLEAR(st);
- SET1(st, startst);
- SP("sstart", st, *p);
- st = step(m->g, startst, stopst, st, NOTHING, st);
- matchp = NULL;
- for (;;) {
- /* next character */
- lastc = c;
- c = (p == m->endp) ? OUT : *p;
-
- /* is there an EOL and/or BOL between lastc and c? */
- flagch = '\0';
- i = 0;
- if ( (lastc == '\n' && m->g->cflags®_NEWLINE) ||
- (lastc == OUT && !(m->eflags®_NOTBOL)) ) {
- flagch = BOL;
- i = m->g->nbol;
- }
- if ( (c == '\n' && m->g->cflags®_NEWLINE) ||
- (c == OUT && !(m->eflags®_NOTEOL)) ) {
- flagch = (flagch == BOL) ? BOLEOL : EOL;
- i += m->g->neol;
- }
- if (i != 0) {
- for (; i > 0; i--)
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("sboleol", st, c);
- }
-
- /* how about a word boundary? */
- if ( (flagch == BOL || (lastc != OUT && !ISWORD(charset,lastc))) &&
- (c != OUT && ISWORD(charset,c)) ) {
- flagch = BOW;
- }
- if ( (lastc != OUT && ISWORD(charset,lastc)) &&
- (flagch == EOL || (c != OUT && !ISWORD(charset,c))) ) {
- flagch = EOW;
- }
- if (flagch == BOW || flagch == EOW) {
- st = step(m->g, startst, stopst, st, flagch, st);
- SP("sboweow", st, c);
- }
-
- /* are we done? */
- if (ISSET(st, stopst))
- matchp = p;
- if (EQ(st, empty) || p == stop)
- break; /* NOTE BREAK OUT */
-
- /* no, we must deal with this character */
- ASSIGN(tmp, st);
- ASSIGN(st, empty);
- assert(c != OUT);
- st = step(m->g, startst, stopst, tmp, c, st);
- SP("saft", st, c);
- assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
- p++;
- }
-
- return(matchp);
-}
-
-
-/*
- - step - map set of states reachable before char to set reachable after
- == static states step(register struct re_guts *g, sopno start, sopno stop, \
- == register states bef, int ch, register states aft);
- == #define BOL (OUT+1)
- == #define EOL (BOL+1)
- == #define BOLEOL (BOL+2)
- == #define NOTHING (BOL+3)
- == #define BOW (BOL+4)
- == #define EOW (BOL+5)
- == #define CODEMAX (BOL+5) // highest code used
- == #define NONCHAR(c) ((c) > CHAR_MAX)
- == #define NNONCHAR (CODEMAX-CHAR_MAX)
- */
-static states
-step(g, start, stop, bef, ch, aft)
-register struct re_guts *g;
-sopno start; /* start state within strip */
-sopno stop; /* state after stop state within strip */
-register states bef; /* states reachable before */
-int ch; /* character or NONCHAR code */
-register states aft; /* states already known reachable after */
-{
- register cset *cs;
- register sop s;
- register sopno pc;
- register onestate here; /* note, macros know this name */
- register sopno look;
- register onestate i; /* Changed from int by Monty */
-
- for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) {
- s = g->strip[pc];
- switch (OP(s)) {
- case OEND:
- assert(pc == stop-1);
- break;
- case OCHAR:
- /* only characters can match */
- assert(!NONCHAR(ch) || ch != (char)OPND(s));
- if (ch == (char)OPND(s))
- FWD(aft, bef, 1);
- break;
- case OBOL:
- if (ch == BOL || ch == BOLEOL)
- FWD(aft, bef, 1);
- break;
- case OEOL:
- if (ch == EOL || ch == BOLEOL)
- FWD(aft, bef, 1);
- break;
- case OBOW:
- if (ch == BOW)
- FWD(aft, bef, 1);
- break;
- case OEOW:
- if (ch == EOW)
- FWD(aft, bef, 1);
- break;
- case OANY:
- if (!NONCHAR(ch))
- FWD(aft, bef, 1);
- break;
- case OANYOF:
- cs = &g->sets[OPND(s)];
- if (!NONCHAR(ch) && CHIN(cs, ch))
- FWD(aft, bef, 1);
- break;
- case OBACK_: /* ignored here */
- case O_BACK:
- FWD(aft, aft, 1);
- break;
- case OPLUS_: /* forward, this is just an empty */
- FWD(aft, aft, 1);
- break;
- case O_PLUS: /* both forward and back */
- FWD(aft, aft, 1);
- i = ISSETBACK(aft, OPND(s));
- BACK(aft, aft, OPND(s));
- if (!i && ISSETBACK(aft, OPND(s))) {
- /* oho, must reconsider loop body */
- pc -= OPND(s) + 1;
- INIT(here, pc);
- }
- break;
- case OQUEST_: /* two branches, both forward */
- FWD(aft, aft, 1);
- FWD(aft, aft, OPND(s));
- break;
- case O_QUEST: /* just an empty */
- FWD(aft, aft, 1);
- break;
- case OLPAREN: /* not significant here */
- case ORPAREN:
- FWD(aft, aft, 1);
- break;
- case OCH_: /* mark the first two branches */
- FWD(aft, aft, 1);
- assert(OP(g->strip[pc+OPND(s)]) == OOR2);
- FWD(aft, aft, OPND(s));
- break;
- case OOR1: /* done a branch, find the O_CH */
- if (ISSTATEIN(aft, here)) {
- for (look = 1;
- OP(s = g->strip[pc+look]) != O_CH;
- look += OPND(s))
- assert(OP(s) == OOR2);
- FWD(aft, aft, look);
- }
- break;
- case OOR2: /* propagate OCH_'s marking */
- FWD(aft, aft, 1);
- if (OP(g->strip[pc+OPND(s)]) != O_CH) {
- assert(OP(g->strip[pc+OPND(s)]) == OOR2);
- FWD(aft, aft, OPND(s));
- }
- break;
- case O_CH: /* just empty */
- FWD(aft, aft, 1);
- break;
- default: /* ooooops... */
- assert(nope);
- break;
- }
- }
-
- return(aft);
-}
-
-#ifdef REDEBUG
-/*
- - print - print a set of states
- == #ifdef REDEBUG
- == static void print(struct match *m, char *caption, states st, \
- == int ch, FILE *d);
- == #endif
- */
-static void
-print(m, caption, st, ch, d)
-struct match *m;
-char *caption;
-states st;
-int ch;
-FILE *d;
-{
- register struct re_guts *g = m->g;
- register int i;
- register int first = 1;
- char buf[10];
-
- if (!(m->eflags®_TRACE))
- return;
-
- fprintf(d, "%s", caption);
- if (ch != '\0')
- fprintf(d, " %s", printchar(ch,buf));
- for (i = 0; i < g->nstates; i++)
- if (ISSET(st, i)) {
- fprintf(d, "%s%d", (first) ? "\t" : ", ", i);
- first = 0;
- }
- fprintf(d, "\n");
-}
-
-/*
- - at - print current situation
- == #ifdef REDEBUG
- == static void at(struct match *m, char *title, char *start, char *stop, \
- == sopno startst, sopno stopst);
- == #endif
- */
-static void
-at(m, title, start, stop, startst, stopst)
-struct match *m;
-char *title;
-char *start;
-char *stop;
-sopno startst;
-sopno stopst;
-{
- char buf[10];
- if (!(m->eflags®_TRACE))
- return;
-
- printf("%s %s-", title, printchar(*start,buf));
- printf("%s ", printchar(*stop,buf));
- printf("%ld-%ld\n", (long)startst, (long)stopst,buf);
-}
-
-#ifndef PCHARDONE
-#define PCHARDONE /* never again */
-/*
- - printchar - make a character printable
- == #ifdef REDEBUG
- == static char *printchar(int ch);
- == #endif
- *
- * Is this identical to regchar() over in debug.c? Well, yes. But a
- * duplicate here avoids having a debugging-capable regexec.o tied to
- * a matching debug.o, and this is convenient. It all disappears in
- * the non-debug compilation anyway, so it doesn't matter much.
- */
-static char * /* -> representation */
-printchar(ch,pbuf)
-int ch;
-char *pbuf;
-{
- if (isprint(ch) || ch == ' ')
- sprintf(pbuf, "%c", ch);
- else
- sprintf(pbuf, "\\%o", ch);
- return(pbuf);
-}
-#endif
-#endif
-
-#undef matcher
-#undef fast
-#undef slow
-#undef dissect
-#undef backref
-#undef step
-#undef print
-#undef at
-#undef match
diff --git a/externals/mysql/extlib/regex/main.c b/externals/mysql/extlib/regex/main.c
deleted file mode 100644
index fa97ca8904..0000000000
--- a/externals/mysql/extlib/regex/main.c
+++ /dev/null
@@ -1,509 +0,0 @@
-#include
-#include
-#include
-#include
-
-#include "my_regex.h"
-#include "main.ih"
-
-char *progname;
-int debug = 0;
-int line = 0;
-int status = 0;
-
-int copts = REG_EXTENDED;
-int eopts = 0;
-regoff_t startoff = 0;
-regoff_t endoff = 0;
-
-
-extern int split();
-extern void regprint();
-
-/*
- - main - do the simple case, hand off to regress() for regression
- */
-int main(argc, argv)
-int argc;
-char *argv[];
-{
- my_regex_t re;
-# define NS 10
- my_regmatch_t subs[NS];
- char erbuf[100];
- int err;
- size_t len;
- int c;
- int errflg = 0;
- register int i;
- extern int optind;
- extern char *optarg;
-
- progname = argv[0];
-
- while ((c = getopt(argc, argv, "c:e:S:E:x")) != EOF)
- switch (c) {
- case 'c': /* compile options */
- copts = options('c', optarg);
- break;
- case 'e': /* execute options */
- eopts = options('e', optarg);
- break;
- case 'S': /* start offset */
- startoff = (regoff_t)atoi(optarg);
- break;
- case 'E': /* end offset */
- endoff = (regoff_t)atoi(optarg);
- break;
- case 'x': /* Debugging. */
- debug++;
- break;
- case '?':
- default:
- errflg++;
- break;
- }
- if (errflg) {
- fprintf(stderr, "usage: %s ", progname);
- fprintf(stderr, "[-c copt][-C][-d] [re]\n");
- exit(2);
- }
-
- if (optind >= argc) {
- regress(stdin);
- exit(status);
- }
-
- err = my_regcomp(&re, argv[optind++], copts, &my_charset_latin1);
- if (err) {
- len = my_regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), (int) len, (int) sizeof(erbuf), erbuf);
- exit(status);
- }
- regprint(&re, stdout);
-
- if (optind >= argc) {
- my_regfree(&re);
- exit(status);
- }
-
- if (eopts®_STARTEND) {
- subs[0].rm_so = startoff;
- subs[0].rm_eo = strlen(argv[optind]) - endoff;
- }
- err = my_regexec(&re, argv[optind], (size_t)NS, subs, eopts);
- if (err) {
- len = my_regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), (int) len, (int) sizeof(erbuf), erbuf);
- exit(status);
- }
- if (!(copts®_NOSUB)) {
- len = (int)(subs[0].rm_eo - subs[0].rm_so);
- if (subs[0].rm_so != -1) {
- if (len != 0)
- printf("match `%.*s'\n", (int)len,
- argv[optind] + subs[0].rm_so);
- else
- printf("match `'@%.1s\n",
- argv[optind] + subs[0].rm_so);
- }
- for (i = 1; i < NS; i++)
- if (subs[i].rm_so != -1)
- printf("(%d) `%.*s'\n", i,
- (int)(subs[i].rm_eo - subs[i].rm_so),
- argv[optind] + subs[i].rm_so);
- }
- exit(status);
-}
-
-/*
- - regress - main loop of regression test
- == void regress(FILE *in);
- */
-void
-regress(in)
-FILE *in;
-{
- char inbuf[1000];
-# define MAXF 10
- char *f[MAXF];
- int nf;
- int i;
- char erbuf[100];
- size_t ne;
- const char *badpat = "invalid regular expression";
-# define SHORT 10
- const char *bpname = "REG_BADPAT";
- my_regex_t re;
-
- while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
- line++;
- if (inbuf[0] == '#' || inbuf[0] == '\n')
- continue; /* NOTE CONTINUE */
- inbuf[strlen(inbuf)-1] = '\0'; /* get rid of stupid \n */
- if (debug)
- fprintf(stdout, "%d:\n", line);
- nf = split(inbuf, f, MAXF, "\t\t");
- if (nf < 3) {
- fprintf(stderr, "bad input, line %d\n", line);
- exit(1);
- }
- for (i = 0; i < nf; i++)
- if (strcmp(f[i], "\"\"") == 0)
- f[i] = (char*) "";
- if (nf <= 3)
- f[3] = NULL;
- if (nf <= 4)
- f[4] = NULL;
- rx_try(f[0], f[1], f[2], f[3], f[4], options('c', f[1]));
- if (opt('&', f[1])) /* try with either type of RE */
- rx_try(f[0], f[1], f[2], f[3], f[4],
- options('c', f[1]) &~ REG_EXTENDED);
- }
-
- ne = my_regerror(REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
- if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) {
- fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n",
- erbuf, badpat);
- status = 1;
- }
- ne = my_regerror(REG_BADPAT, (my_regex_t *)NULL, erbuf, (size_t)SHORT);
- if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' ||
- ne != strlen(badpat)+1) {
- fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n",
- erbuf, SHORT-1, badpat);
- status = 1;
- }
- ne = my_regerror(REG_ITOA|REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
- if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
- fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
- erbuf, bpname);
- status = 1;
- }
- re.re_endp = bpname;
- ne = my_regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
- if (atoi(erbuf) != (int)REG_BADPAT) {
- fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
- erbuf, (long)REG_BADPAT);
- status = 1;
- } else if (ne != strlen(erbuf)+1) {
- fprintf(stderr, "end: regerror() ATOI test len(`%s') = %ld\n",
- erbuf, (long)REG_BADPAT);
- status = 1;
- }
-}
-
-/*
- - rx_try - try it, and report on problems
- == void rx_try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
- */
-void
-rx_try(f0, f1, f2, f3, f4, opts)
-char *f0;
-char *f1;
-char *f2;
-char *f3;
-char *f4;
-int opts; /* may not match f1 */
-{
- my_regex_t re;
-# define NSUBS 10
- my_regmatch_t subs[NSUBS];
-# define NSHOULD 15
- char *should[NSHOULD];
- int nshould;
- char erbuf[100];
- int err;
- int len;
- const char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE";
- register int i;
- char *grump;
- char f0copy[1000];
- char f2copy[1000];
-
- strcpy(f0copy, f0);
- re.re_endp = (opts®_PEND) ? f0copy + strlen(f0copy) : NULL;
- fixstr(f0copy);
- err = my_regcomp(&re, f0copy, opts, &my_charset_latin1);
- if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
- /* unexpected error or wrong error */
- len = my_regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
- line, type, eprint(err), len,
- (int) sizeof(erbuf), erbuf);
- status = 1;
- } else if (err == 0 && opt('C', f1)) {
- /* unexpected success */
- fprintf(stderr, "%d: %s should have given REG_%s\n",
- line, type, f2);
- status = 1;
- err = 1; /* so we won't try regexec */
- }
-
- if (err != 0) {
- my_regfree(&re);
- return;
- }
-
- strcpy(f2copy, f2);
- fixstr(f2copy);
-
- if (options('e', f1)®_STARTEND) {
- if (strchr(f2, '(') == NULL || strchr(f2, ')') == NULL)
- fprintf(stderr, "%d: bad STARTEND syntax\n", line);
- subs[0].rm_so = strchr(f2, '(') - f2 + 1;
- subs[0].rm_eo = strchr(f2, ')') - f2;
- }
- err = my_regexec(&re, f2copy, NSUBS, subs, options('e', f1));
-
- if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
- /* unexpected error or wrong error */
- len = my_regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
- line, type, eprint(err), len,
- (int) sizeof(erbuf), erbuf);
- status = 1;
- } else if (err != 0) {
- /* nothing more to check */
- } else if (f3 == NULL) {
- /* unexpected success */
- fprintf(stderr, "%d: %s exec should have failed\n",
- line, type);
- status = 1;
- err = 1; /* just on principle */
- } else if (opts®_NOSUB) {
- /* nothing more to check */
- } else if ((grump = check(f2, subs[0], f3)) != NULL) {
- fprintf(stderr, "%d: %s %s\n", line, type, grump);
- status = 1;
- err = 1;
- }
-
- if (err != 0 || f4 == NULL) {
- my_regfree(&re);
- return;
- }
-
- for (i = 1; i < NSHOULD; i++)
- should[i] = NULL;
- nshould = split(f4, should+1, NSHOULD-1, ",");
- if (nshould == 0) {
- nshould = 1;
- should[1] = (char*) "";
- }
- for (i = 1; i < NSUBS; i++) {
- grump = check(f2, subs[i], should[i]);
- if (grump != NULL) {
- fprintf(stderr, "%d: %s $%d %s\n", line,
- type, i, grump);
- status = 1;
- err = 1;
- }
- }
-
- my_regfree(&re);
-}
-
-/*
- - options - pick options out of a regression-test string
- == int options(int type, char *s);
- */
-int
-options(type, s)
-int type; /* 'c' compile, 'e' exec */
-char *s;
-{
- register char *p;
- register int o = (type == 'c') ? copts : eopts;
- register const char *legal = (type == 'c') ? "bisnmp" : "^$#tl";
-
- for (p = s; *p != '\0'; p++)
- if (strchr(legal, *p) != NULL)
- switch (*p) {
- case 'b':
- o &= ~REG_EXTENDED;
- break;
- case 'i':
- o |= REG_ICASE;
- break;
- case 's':
- o |= REG_NOSUB;
- break;
- case 'n':
- o |= REG_NEWLINE;
- break;
- case 'm':
- o &= ~REG_EXTENDED;
- o |= REG_NOSPEC;
- break;
- case 'p':
- o |= REG_PEND;
- break;
- case '^':
- o |= REG_NOTBOL;
- break;
- case '$':
- o |= REG_NOTEOL;
- break;
- case '#':
- o |= REG_STARTEND;
- break;
- case 't': /* trace */
- o |= REG_TRACE;
- break;
- case 'l': /* force long representation */
- o |= REG_LARGE;
- break;
- case 'r': /* force backref use */
- o |= REG_BACKR;
- break;
- }
- return(o);
-}
-
-/*
- - opt - is a particular option in a regression string?
- == int opt(int c, char *s);
- */
-int /* predicate */
-opt(c, s)
-int c;
-char *s;
-{
- return(strchr(s, c) != NULL);
-}
-
-/*
- - fixstr - transform magic characters in strings
- == void fixstr(register char *p);
- */
-void
-fixstr(p)
-register char *p;
-{
- if (p == NULL)
- return;
-
- for (; *p != '\0'; p++)
- if (*p == 'N')
- *p = '\n';
- else if (*p == 'T')
- *p = '\t';
- else if (*p == 'S')
- *p = ' ';
- else if (*p == 'Z')
- *p = '\0';
-}
-
-/*
- - check - check a substring match
- == char *check(char *str, regmatch_t sub, char *should);
- */
-char * /* NULL or complaint */
-check(str, sub, should)
-char *str;
-my_regmatch_t sub;
-char *should;
-{
- register int len;
- register int shlen;
- register char *p;
- static char grump[500];
- register char *at = NULL;
-
- if (should != NULL && strcmp(should, "-") == 0)
- should = NULL;
- if (should != NULL && should[0] == '@') {
- at = should + 1;
- should = (char*) "";
- }
-
- /* check rm_so and rm_eo for consistency */
- if (sub.rm_so > sub.rm_eo || (sub.rm_so == -1 && sub.rm_eo != -1) ||
- (sub.rm_so != -1 && sub.rm_eo == -1) ||
- (sub.rm_so != -1 && sub.rm_so < 0) ||
- (sub.rm_eo != -1 && sub.rm_eo < 0) ) {
- sprintf(grump, "start %ld end %ld", (long)sub.rm_so,
- (long)sub.rm_eo);
- return(grump);
- }
-
- /* check for no match */
- if (sub.rm_so == -1 && should == NULL)
- return(NULL);
- if (sub.rm_so == -1)
- return((char*) "did not match");
-
- /* check for in range */
- if ((int) sub.rm_eo > (int) strlen(str)) {
- sprintf(grump, "start %ld end %ld, past end of string",
- (long)sub.rm_so, (long)sub.rm_eo);
- return(grump);
- }
-
- len = (int)(sub.rm_eo - sub.rm_so);
- shlen = (int)strlen(should);
- p = str + sub.rm_so;
-
- /* check for not supposed to match */
- if (should == NULL) {
- sprintf(grump, "matched `%.*s'", len, p);
- return(grump);
- }
-
- /* check for wrong match */
- if (len != shlen || strncmp(p, should, (size_t)shlen) != 0) {
- sprintf(grump, "matched `%.*s' instead", len, p);
- return(grump);
- }
- if (shlen > 0)
- return(NULL);
-
- /* check null match in right place */
- if (at == NULL)
- return(NULL);
- shlen = strlen(at);
- if (shlen == 0)
- shlen = 1; /* force check for end-of-string */
- if (strncmp(p, at, shlen) != 0) {
- sprintf(grump, "matched null at `%.20s'", p);
- return(grump);
- }
- return(NULL);
-}
-
-/*
- - eprint - convert error number to name
- == static char *eprint(int err);
- */
-static char *
-eprint(err)
-int err;
-{
- static char epbuf[100];
- size_t len;
-
- len = my_regerror(REG_ITOA|err, (my_regex_t *)NULL, epbuf, sizeof(epbuf));
- assert(len <= sizeof(epbuf));
- return(epbuf);
-}
-
-/*
- - efind - convert error name to number
- == static int efind(char *name);
- */
-static int
-efind(name)
-char *name;
-{
- static char efbuf[100];
- my_regex_t re;
-
- sprintf(efbuf, "REG_%s", name);
- assert(strlen(efbuf) < sizeof(efbuf));
- re.re_endp = efbuf;
- (void) my_regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
- return(atoi(efbuf));
-}
diff --git a/externals/mysql/extlib/regex/my_regex.h b/externals/mysql/extlib/regex/my_regex.h
deleted file mode 100644
index 0d1cedf543..0000000000
--- a/externals/mysql/extlib/regex/my_regex.h
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef _REGEX_H_
-#define _REGEX_H_ /* never again */
-/* ========= begin header generated by ./mkh ========= */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "m_ctype.h"
-
-/* === regex2.h === */
-#ifdef _WIN64
-typedef __int64 regoff_t;
-#else
-typedef off_t regoff_t;
-#endif
-struct re_guts; /* none of your business :-) */
-typedef struct {
- int re_magic;
- size_t re_nsub; /* number of parenthesized subexpressions */
- const char *re_endp; /* end pointer for REG_PEND */
- struct re_guts *re_g; /* none of your business :-) */
- CHARSET_INFO *charset; /* For ctype things */
-} my_regex_t;
-typedef struct {
- regoff_t rm_so; /* start of match */
- regoff_t rm_eo; /* end of match */
-} my_regmatch_t;
-
-
-/* === regcomp.c === */
-extern int my_regcomp(my_regex_t *, const char *, int, CHARSET_INFO *charset);
-#define REG_BASIC 0000
-#define REG_EXTENDED 0001
-#define REG_ICASE 0002
-#define REG_NOSUB 0004
-#define REG_NEWLINE 0010
-#define REG_NOSPEC 0020
-#define REG_PEND 0040
-#define REG_DUMP 0200
-
-
-/* === regerror.c === */
-#define REG_NOMATCH 1
-#define REG_BADPAT 2
-#define REG_ECOLLATE 3
-#define REG_ECTYPE 4
-#define REG_EESCAPE 5
-#define REG_ESUBREG 6
-#define REG_EBRACK 7
-#define REG_EPAREN 8
-#define REG_EBRACE 9
-#define REG_BADBR 10
-#define REG_ERANGE 11
-#define REG_ESPACE 12
-#define REG_BADRPT 13
-#define REG_EMPTY 14
-#define REG_ASSERT 15
-#define REG_INVARG 16
-#define REG_ATOI 255 /* convert name to number (!) */
-#define REG_ITOA 0400 /* convert number to name (!) */
-extern size_t my_regerror(int, const my_regex_t *, char *, size_t);
-
-
-/* === regexec.c === */
-extern int my_regexec(const my_regex_t *, const char *, size_t, my_regmatch_t [], int);
-#define REG_NOTBOL 00001
-#define REG_NOTEOL 00002
-#define REG_STARTEND 00004
-#define REG_TRACE 00400 /* tracing of execution */
-#define REG_LARGE 01000 /* force large representation */
-#define REG_BACKR 02000 /* force use of backref code */
-
-
-/* === regfree.c === */
-extern void my_regfree(my_regex_t *);
-
-/* === reginit.c === */
-
-extern void my_regex_init(CHARSET_INFO *cs); /* Should be called for multithread progs */
-extern void my_regex_end(void); /* If one wants a clean end */
-
-#ifdef __cplusplus
-}
-#endif
-/* ========= end header generated by ./mkh ========= */
-#endif
diff --git a/externals/mysql/extlib/regex/regcomp.c b/externals/mysql/extlib/regex/regcomp.c
deleted file mode 100644
index 398e132d97..0000000000
--- a/externals/mysql/extlib/regex/regcomp.c
+++ /dev/null
@@ -1,1672 +0,0 @@
-#include
-#include
-#include
-#ifdef __WIN__
-#include
-#endif
-
-#include "my_regex.h"
-#include "utils.h"
-#include "regex2.h"
-
-#include "cclass.h"
-#include "cname.h"
-
-/*
- * parse structure, passed up and down to avoid global variables and
- * other clumsinesses
- */
-struct parse {
- char *next; /* next character in RE */
- char *end; /* end of string (-> NUL normally) */
- int error; /* has an error been seen? */
- sop *strip; /* malloced strip */
- sopno ssize; /* malloced strip size (allocated) */
- sopno slen; /* malloced strip length (used) */
- int ncsalloc; /* number of csets allocated */
- struct re_guts *g;
-# define NPAREN 10 /* we need to remember () 1-9 for back refs */
- sopno pbegin[NPAREN]; /* -> ( ([0] unused) */
- sopno pend[NPAREN]; /* -> ) ([0] unused) */
- CHARSET_INFO *charset; /* for ctype things */
-};
-
-#include "regcomp.ih"
-
-static char nuls[10]; /* place to point scanner in event of error */
-
-struct cclass cclasses[CCLASS_LAST+1]= {
- { "alnum", "","", _MY_U | _MY_L | _MY_NMR},
- { "alpha", "","", _MY_U | _MY_L },
- { "blank", "","", _MY_B },
- { "cntrl", "","", _MY_CTR },
- { "digit", "","", _MY_NMR },
- { "graph", "","", _MY_PNT | _MY_U | _MY_L | _MY_NMR},
- { "lower", "","", _MY_L },
- { "print", "","", _MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B },
- { "punct", "","", _MY_PNT },
- { "space", "","", _MY_SPC },
- { "upper", "","", _MY_U },
- { "xdigit", "","", _MY_X },
- { NULL,NULL,NULL, 0 }
-};
-
-/*
- * macros for use with parse structure
- * BEWARE: these know that the parse structure is named `p' !!!
- */
-#define PEEK() (*p->next)
-#define PEEK2() (*(p->next+1))
-#define MORE() (p->next < p->end)
-#define MORE2() (p->next+1 < p->end)
-#define SEE(c) (MORE() && PEEK() == (c))
-#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))
-#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0)
-#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
-#define NEXT() (p->next++)
-#define NEXT2() (p->next += 2)
-#define NEXTn(n) (p->next += (n))
-#define GETNEXT() (*p->next++)
-#define SETERROR(e) seterr(p, (e))
-#define REQUIRE(co, e) ((co) || SETERROR(e))
-#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e))
-#define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e))
-#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e))
-#define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd))
-#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
-#define AHEAD(pos) dofwd(p, pos, HERE()-(pos))
-#define ASTERN(sop, pos) EMIT(sop, HERE()-pos)
-#define HERE() (p->slen)
-#define THERE() (p->slen - 1)
-#define THERETHERE() (p->slen - 2)
-#define DROP(n) (p->slen -= (n))
-
-#ifndef NDEBUG
-static int never = 0; /* for use in asserts; shuts lint up */
-#else
-#define never 0 /* some s have bugs too */
-#endif
-
-/*
- - regcomp - interface for parser and compilation
- = extern int regcomp(regex_t *, const char *, int);
- = #define REG_BASIC 0000
- = #define REG_EXTENDED 0001
- = #define REG_ICASE 0002
- = #define REG_NOSUB 0004
- = #define REG_NEWLINE 0010
- = #define REG_NOSPEC 0020
- = #define REG_PEND 0040
- = #define REG_DUMP 0200
- */
-int /* 0 success, otherwise REG_something */
-my_regcomp(preg, pattern, cflags, charset)
-my_regex_t *preg;
-const char *pattern;
-int cflags;
-CHARSET_INFO *charset;
-{
- struct parse pa;
- register struct re_guts *g;
- register struct parse *p = &pa;
- register int i;
- register size_t len;
-#ifdef REDEBUG
-# define GOODFLAGS(f) (f)
-#else
-# define GOODFLAGS(f) ((f)&~REG_DUMP)
-#endif
-
- my_regex_init(charset); /* Init cclass if neaded */
- preg->charset=charset;
- cflags = GOODFLAGS(cflags);
- if ((cflags®_EXTENDED) && (cflags®_NOSPEC))
- return(REG_INVARG);
-
- if (cflags®_PEND) {
- if (preg->re_endp < pattern)
- return(REG_INVARG);
- len = preg->re_endp - pattern;
- } else
- len = strlen((char *)pattern);
-
- /* do the mallocs early so failure handling is easy */
- g = (struct re_guts *)malloc(sizeof(struct re_guts) +
- (NC-1)*sizeof(cat_t));
- if (g == NULL)
- return(REG_ESPACE);
- p->ssize = (long) (len/(size_t)2*(size_t)3 + (size_t)1); /* ugh */
- p->strip = (sop *)malloc(p->ssize * sizeof(sop));
- p->slen = 0;
- if (p->strip == NULL) {
- free((char *)g);
- return(REG_ESPACE);
- }
-
- /* set things up */
- p->g = g;
- p->next = (char *)pattern; /* convenience; we do not modify it */
- p->end = p->next + len;
- p->error = 0;
- p->ncsalloc = 0;
- p->charset = preg->charset;
- for (i = 0; i < NPAREN; i++) {
- p->pbegin[i] = 0;
- p->pend[i] = 0;
- }
- g->csetsize = NC;
- g->sets = NULL;
- g->setbits = NULL;
- g->ncsets = 0;
- g->cflags = cflags;
- g->iflags = 0;
- g->nbol = 0;
- g->neol = 0;
- g->must = NULL;
- g->mlen = 0;
- g->nsub = 0;
- g->ncategories = 1; /* category 0 is "everything else" */
- g->categories = &g->catspace[-(CHAR_MIN)];
- (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t));
- g->backrefs = 0;
-
- /* do it */
- EMIT(OEND, 0);
- g->firststate = THERE();
- if (cflags®_EXTENDED)
- p_ere(p, OUT);
- else if (cflags®_NOSPEC)
- p_str(p);
- else
- p_bre(p, OUT, OUT);
- EMIT(OEND, 0);
- g->laststate = THERE();
-
- /* tidy up loose ends and fill things in */
- categorize(p, g);
- stripsnug(p, g);
- findmust(p, g);
- g->nplus = pluscount(p, g);
- g->magic = MAGIC2;
- preg->re_nsub = g->nsub;
- preg->re_g = g;
- preg->re_magic = MAGIC1;
-#ifndef REDEBUG
- /* not debugging, so can't rely on the assert() in regexec() */
- if (g->iflags&BAD)
- SETERROR(REG_ASSERT);
-#endif
-
- /* win or lose, we're done */
- if (p->error != 0) /* lose */
- my_regfree(preg);
- return(p->error);
-}
-
-/*
- - p_ere - ERE parser top level, concatenation and alternation
- == static void p_ere(register struct parse *p, int stop);
- */
-static void
-p_ere(p, stop)
-register struct parse *p;
-int stop; /* character this ERE should end at */
-{
- register char c;
- register sopno prevback;
- register sopno prevfwd;
- register sopno conc;
- register int first = 1; /* is this the first alternative? */
- LINT_INIT(prevback); LINT_INIT(prevfwd);
- for (;;) {
- /* do a bunch of concatenated expressions */
- conc = HERE();
- while (MORE() && (c = PEEK()) != '|' && c != stop)
- p_ere_exp(p);
- if(REQUIRE(HERE() != conc, REG_EMPTY)) {}/* require nonempty */
-
- if (!EAT('|'))
- break; /* NOTE BREAK OUT */
-
- if (first) {
- INSERT(OCH_, conc); /* offset is wrong */
- prevfwd = conc;
- prevback = conc;
- first = 0;
- }
- ASTERN(OOR1, prevback);
- prevback = THERE();
- AHEAD(prevfwd); /* fix previous offset */
- prevfwd = HERE();
- EMIT(OOR2, 0); /* offset is very wrong */
- }
-
- if (!first) { /* tail-end fixups */
- AHEAD(prevfwd);
- ASTERN(O_CH, prevback);
- }
-
- assert(!MORE() || SEE(stop));
-}
-
-/*
- - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op
- == static void p_ere_exp(register struct parse *p);
- */
-static void
-p_ere_exp(p)
-register struct parse *p;
-{
- register char c;
- register sopno pos;
- register int count;
- register int count2;
- register sopno subno;
- int wascaret = 0;
-
- assert(MORE()); /* caller should have ensured this */
- c = GETNEXT();
-
- pos = HERE();
- switch (c) {
- case '(':
- if(REQUIRE(MORE(), REG_EPAREN)) {}
- p->g->nsub++;
- subno = (sopno) p->g->nsub;
- if (subno < NPAREN)
- p->pbegin[subno] = HERE();
- EMIT(OLPAREN, subno);
- if (!SEE(')'))
- p_ere(p, ')');
- if (subno < NPAREN) {
- p->pend[subno] = HERE();
- assert(p->pend[subno] != 0);
- }
- EMIT(ORPAREN, subno);
- if(MUSTEAT(')', REG_EPAREN)) {}
- break;
-#ifndef POSIX_MISTAKE
- case ')': /* happens only if no current unmatched ( */
- /*
- * You may ask, why the ifndef? Because I didn't notice
- * this until slightly too late for 1003.2, and none of the
- * other 1003.2 regular-expression reviewers noticed it at
- * all. So an unmatched ) is legal POSIX, at least until
- * we can get it fixed.
- */
- SETERROR(REG_EPAREN);
- break;
-#endif
- case '^':
- EMIT(OBOL, 0);
- p->g->iflags |= USEBOL;
- p->g->nbol++;
- wascaret = 1;
- break;
- case '$':
- EMIT(OEOL, 0);
- p->g->iflags |= USEEOL;
- p->g->neol++;
- break;
- case '|':
- SETERROR(REG_EMPTY);
- break;
- case '*':
- case '+':
- case '?':
- SETERROR(REG_BADRPT);
- break;
- case '.':
- if (p->g->cflags®_NEWLINE)
- nonnewline(p);
- else
- EMIT(OANY, 0);
- break;
- case '[':
- p_bracket(p);
- break;
- case '\\':
- if(REQUIRE(MORE(), REG_EESCAPE)) {}
- c = GETNEXT();
- ordinary(p, c);
- break;
- case '{': /* okay as ordinary except if digit follows */
- if(REQUIRE(!MORE() || !my_isdigit(p->charset,PEEK()), REG_BADRPT)) {}
- /* FALLTHROUGH */
- default:
- ordinary(p, c);
- break;
- }
-
- if (!MORE())
- return;
- c = PEEK();
- /* we call { a repetition if followed by a digit */
- if (!( c == '*' || c == '+' || c == '?' ||
- (c == '{' && MORE2() &&
- my_isdigit(p->charset,PEEK2())) ))
- return; /* no repetition, we're done */
- NEXT();
-
- if(REQUIRE(!wascaret, REG_BADRPT)) {}
- switch (c) {
- case '*': /* implemented as +? */
- /* this case does not require the (y|) trick, noKLUDGE */
- INSERT(OPLUS_, pos);
- ASTERN(O_PLUS, pos);
- INSERT(OQUEST_, pos);
- ASTERN(O_QUEST, pos);
- break;
- case '+':
- INSERT(OPLUS_, pos);
- ASTERN(O_PLUS, pos);
- break;
- case '?':
- /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, pos); /* offset slightly wrong */
- ASTERN(OOR1, pos); /* this one's right */
- AHEAD(pos); /* fix the OCH_ */
- EMIT(OOR2, 0); /* offset very wrong... */
- AHEAD(THERE()); /* ...so fix it */
- ASTERN(O_CH, THERETHERE());
- break;
- case '{':
- count = p_count(p);
- if (EAT(',')) {
- if (my_isdigit(p->charset,PEEK())) {
- count2 = p_count(p);
- if(REQUIRE(count <= count2, REG_BADBR)) {}
- } else /* single number with comma */
- count2 = RE_INFINITY;
- } else /* just a single number */
- count2 = count;
- repeat(p, pos, count, count2);
- if (!EAT('}')) { /* error heuristics */
- while (MORE() && PEEK() != '}')
- NEXT();
- if(REQUIRE(MORE(), REG_EBRACE)) {}
- SETERROR(REG_BADBR);
- }
- break;
- }
-
- if (!MORE())
- return;
- c = PEEK();
- if (!( c == '*' || c == '+' || c == '?' ||
- (c == '{' && MORE2() &&
- my_isdigit(p->charset,PEEK2())) ) )
- return;
- SETERROR(REG_BADRPT);
-}
-
-/*
- - p_str - string (no metacharacters) "parser"
- == static void p_str(register struct parse *p);
- */
-static void
-p_str(p)
-register struct parse *p;
-{
- if(REQUIRE(MORE(), REG_EMPTY)) {}
- while (MORE())
- ordinary(p, GETNEXT());
-}
-
-/*
- - p_bre - BRE parser top level, anchoring and concatenation
- == static void p_bre(register struct parse *p, register int end1, \
- == register int end2);
- * Giving end1 as OUT essentially eliminates the end1/end2 check.
- *
- * This implementation is a bit of a kludge, in that a trailing $ is first
- * taken as an ordinary character and then revised to be an anchor. The
- * only undesirable side effect is that '$' gets included as a character
- * category in such cases. This is fairly harmless; not worth fixing.
- * The amount of lookahead needed to avoid this kludge is excessive.
- */
-static void
-p_bre(p, end1, end2)
-register struct parse *p;
-register int end1; /* first terminating character */
-register int end2; /* second terminating character */
-{
- register sopno start = HERE();
- register int first = 1; /* first subexpression? */
- register int wasdollar = 0;
-
- if (EAT('^')) {
- EMIT(OBOL, 0);
- p->g->iflags |= USEBOL;
- p->g->nbol++;
- }
- while (MORE() && !SEETWO(end1, end2)) {
- wasdollar = p_simp_re(p, first);
- first = 0;
- }
- if (wasdollar) { /* oops, that was a trailing anchor */
- DROP(1);
- EMIT(OEOL, 0);
- p->g->iflags |= USEEOL;
- p->g->neol++;
- }
-
- if(REQUIRE(HERE() != start, REG_EMPTY)) {} /* require nonempty */
-}
-
-/*
- - p_simp_re - parse a simple RE, an atom possibly followed by a repetition
- == static int p_simp_re(register struct parse *p, int starordinary);
- */
-static int /* was the simple RE an unbackslashed $? */
-p_simp_re(p, starordinary)
-register struct parse *p;
-int starordinary; /* is a leading * an ordinary character? */
-{
- register int c;
- register int count;
- register int count2;
- register sopno pos;
- register int i;
- register sopno subno;
-# define BACKSL (1<g->cflags®_NEWLINE)
- nonnewline(p);
- else
- EMIT(OANY, 0);
- break;
- case '[':
- p_bracket(p);
- break;
- case BACKSL|'{':
- SETERROR(REG_BADRPT);
- break;
- case BACKSL|'(':
- p->g->nsub++;
- subno = (sopno) p->g->nsub;
- if (subno < NPAREN)
- p->pbegin[subno] = HERE();
- EMIT(OLPAREN, subno);
- /* the MORE here is an error heuristic */
- if (MORE() && !SEETWO('\\', ')'))
- p_bre(p, '\\', ')');
- if (subno < NPAREN) {
- p->pend[subno] = HERE();
- assert(p->pend[subno] != 0);
- }
- EMIT(ORPAREN, subno);
- if(REQUIRE(EATTWO('\\', ')'), REG_EPAREN)) {}
- break;
- case BACKSL|')': /* should not get here -- must be user */
- case BACKSL|'}':
- SETERROR(REG_EPAREN);
- break;
- case BACKSL|'1':
- case BACKSL|'2':
- case BACKSL|'3':
- case BACKSL|'4':
- case BACKSL|'5':
- case BACKSL|'6':
- case BACKSL|'7':
- case BACKSL|'8':
- case BACKSL|'9':
- i = (c&~BACKSL) - '0';
- assert(i < NPAREN);
- if (p->pend[i] != 0) {
- assert((uint) i <= p->g->nsub);
- EMIT(OBACK_, i);
- assert(p->pbegin[i] != 0);
- assert(OP(p->strip[p->pbegin[i]]) == OLPAREN);
- assert(OP(p->strip[p->pend[i]]) == ORPAREN);
- (void) dupl(p, p->pbegin[i]+1, p->pend[i]);
- EMIT(O_BACK, i);
- } else
- SETERROR(REG_ESUBREG);
- p->g->backrefs = 1;
- break;
- case '*':
- if(REQUIRE(starordinary, REG_BADRPT)) {}
- /* FALLTHROUGH */
- default:
- ordinary(p, c &~ BACKSL);
- break;
- }
-
- if (EAT('*')) { /* implemented as +? */
- /* this case does not require the (y|) trick, noKLUDGE */
- INSERT(OPLUS_, pos);
- ASTERN(O_PLUS, pos);
- INSERT(OQUEST_, pos);
- ASTERN(O_QUEST, pos);
- } else if (EATTWO('\\', '{')) {
- count = p_count(p);
- if (EAT(',')) {
- if (MORE() && my_isdigit(p->charset,PEEK())) {
- count2 = p_count(p);
- if(REQUIRE(count <= count2, REG_BADBR)) {}
- } else /* single number with comma */
- count2 = RE_INFINITY;
- } else /* just a single number */
- count2 = count;
- repeat(p, pos, count, count2);
- if (!EATTWO('\\', '}')) { /* error heuristics */
- while (MORE() && !SEETWO('\\', '}'))
- NEXT();
- if(REQUIRE(MORE(), REG_EBRACE)) {}
- SETERROR(REG_BADBR);
- }
- } else if (c == (unsigned char)'$') /* $ (but not \$) ends it */
- return(1);
-
- return(0);
-}
-
-/*
- - p_count - parse a repetition count
- == static int p_count(register struct parse *p);
- */
-static int /* the value */
-p_count(p)
-register struct parse *p;
-{
- register int count = 0;
- register int ndigits = 0;
-
- while (MORE() && my_isdigit(p->charset,PEEK()) && count <= DUPMAX) {
- count = count*10 + (GETNEXT() - '0');
- ndigits++;
- }
-
- if(REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR)) {}
- return(count);
-}
-
-/*
- - p_bracket - parse a bracketed character list
- == static void p_bracket(register struct parse *p);
- *
- * Note a significant property of this code: if the allocset() did SETERROR,
- * no set operations are done.
- */
-static void
-p_bracket(p)
-register struct parse *p;
-{
- register cset *cs = allocset(p);
- register int invert = 0;
-
- /* Dept of Truly Sickening Special-Case Kludges */
- if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) {
- EMIT(OBOW, 0);
- NEXTn(6);
- return;
- }
- if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) {
- EMIT(OEOW, 0);
- NEXTn(6);
- return;
- }
-
- if (EAT('^'))
- invert++; /* make note to invert set at end */
- if (EAT(']'))
- CHadd(cs, ']');
- else if (EAT('-'))
- CHadd(cs, '-');
- while (MORE() && PEEK() != ']' && !SEETWO('-', ']'))
- p_b_term(p, cs);
- if (EAT('-'))
- CHadd(cs, '-');
- if(MUSTEAT(']', REG_EBRACK)) {}
-
- if (p->error != 0) /* don't mess things up further */
- return;
-
- if (p->g->cflags®_ICASE) {
- register int i;
- register int ci;
-
- for (i = p->g->csetsize - 1; i >= 0; i--)
- if (CHIN(cs, i) && my_isalpha(p->charset,i)) {
- ci = othercase(p->charset,i);
- if (ci != i)
- CHadd(cs, ci);
- }
- if (cs->multis != NULL)
- mccase(p, cs);
- }
- if (invert) {
- register int i;
-
- for (i = p->g->csetsize - 1; i >= 0; i--)
- if (CHIN(cs, i))
- CHsub(cs, i);
- else
- CHadd(cs, i);
- if (p->g->cflags®_NEWLINE)
- CHsub(cs, '\n');
- if (cs->multis != NULL)
- mcinvert(p, cs);
- }
-
- assert(cs->multis == NULL); /* xxx */
-
- if (nch(p, cs) == 1) { /* optimize singleton sets */
- ordinary(p, firstch(p, cs));
- freeset(p, cs);
- } else
- EMIT(OANYOF, freezeset(p, cs));
-}
-
-/*
- - p_b_term - parse one term of a bracketed character list
- == static void p_b_term(register struct parse *p, register cset *cs);
- */
-static void
-p_b_term(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register char c;
- register char start, finish;
- register int i;
-
- /* classify what we've got */
- switch ((MORE()) ? PEEK() : '\0') {
- case '[':
- c = (MORE2()) ? PEEK2() : '\0';
- break;
- case '-':
- SETERROR(REG_ERANGE);
- return; /* NOTE RETURN */
- break;
- default:
- c = '\0';
- break;
- }
-
- switch (c) {
- case ':': /* character class */
- NEXT2();
- if(REQUIRE(MORE(), REG_EBRACK)) {}
- c = PEEK();
- if(REQUIRE(c != '-' && c != ']', REG_ECTYPE)) {}
- p_b_cclass(p, cs);
- if(REQUIRE(MORE(), REG_EBRACK)) {}
- if(REQUIRE(EATTWO(':', ']'), REG_ECTYPE)) {}
- break;
- case '=': /* equivalence class */
- NEXT2();
- if(REQUIRE(MORE(), REG_EBRACK)) {}
- c = PEEK();
- if(REQUIRE(c != '-' && c != ']', REG_ECOLLATE)) {}
- p_b_eclass(p, cs);
- if(REQUIRE(MORE(), REG_EBRACK)) {}
- if(REQUIRE(EATTWO('=', ']'), REG_ECOLLATE)) {}
- break;
- default: /* symbol, ordinary character, or range */
-/* xxx revision needed for multichar stuff */
- start = p_b_symbol(p);
- if (SEE('-') && MORE2() && PEEK2() != ']') {
- /* range */
- NEXT();
- if (EAT('-'))
- finish = '-';
- else
- finish = p_b_symbol(p);
- } else
- finish = start;
-/* xxx what about signed chars here... */
- if(REQUIRE(start <= finish, REG_ERANGE)) {}
- for (i = start; i <= finish; i++)
- CHadd(cs, i);
- break;
- }
-}
-
-/*
- - p_b_cclass - parse a character-class name and deal with it
- == static void p_b_cclass(register struct parse *p, register cset *cs);
- */
-static void
-p_b_cclass(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register char *sp = p->next;
- register struct cclass *cp;
- register size_t len;
-
- while (MORE() && my_isalpha(p->charset,PEEK()))
- NEXT();
- len = p->next - sp;
- for (cp = cclasses; cp->name != NULL; cp++)
- if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
- break;
- if (cp->name == NULL) {
- /* oops, didn't find it */
- SETERROR(REG_ECTYPE);
- return;
- }
-
-#ifndef USE_ORIG_REGEX_CODE
- {
- register size_t i;
- for (i=1 ; i<256 ; i++)
- if (p->charset->ctype[i+1] & cp->mask)
- CHadd(cs, i);
- }
-#else
- {
- register char *u = (char*) cp->chars;
- register char c;
-
- while ((c = *u++) != '\0')
- CHadd(cs, c);
-
- for (u = (char*) cp->multis; *u != '\0'; u += strlen(u) + 1)
- MCadd(p, cs, u);
- }
-#endif
-
-}
-
-/*
- - p_b_eclass - parse an equivalence-class name and deal with it
- == static void p_b_eclass(register struct parse *p, register cset *cs);
- *
- * This implementation is incomplete. xxx
- */
-static void
-p_b_eclass(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register char c;
-
- c = p_b_coll_elem(p, '=');
- CHadd(cs, c);
-}
-
-/*
- - p_b_symbol - parse a character or [..]ed multicharacter collating symbol
- == static char p_b_symbol(register struct parse *p);
- */
-static char /* value of symbol */
-p_b_symbol(p)
-register struct parse *p;
-{
- register char value;
-
- if(REQUIRE(MORE(), REG_EBRACK)) {}
- if (!EATTWO('[', '.'))
- return(GETNEXT());
-
- /* collating symbol */
- value = p_b_coll_elem(p, '.');
- if(REQUIRE(EATTWO('.', ']'), REG_ECOLLATE)) {}
- return(value);
-}
-
-/*
- - p_b_coll_elem - parse a collating-element name and look it up
- == static char p_b_coll_elem(register struct parse *p, int endc);
- */
-static char /* value of collating element */
-p_b_coll_elem(p, endc)
-register struct parse *p;
-int endc; /* name ended by endc,']' */
-{
- register char *sp = p->next;
- register struct cname *cp;
-#ifdef _WIN64
- register __int64 len;
-#else
- register int len;
-#endif
- while (MORE() && !SEETWO(endc, ']'))
- NEXT();
- if (!MORE()) {
- SETERROR(REG_EBRACK);
- return(0);
- }
- len = p->next - sp;
- for (cp = cnames; cp->name != NULL; cp++)
- if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
- return(cp->code); /* known name */
- if (len == 1)
- return(*sp); /* single character */
- SETERROR(REG_ECOLLATE); /* neither */
- return(0);
-}
-
-/*
- - othercase - return the case counterpart of an alphabetic
- == static char othercase(int ch);
- */
-static char /* if no counterpart, return ch */
-othercase(charset,ch)
-CHARSET_INFO *charset;
-int ch;
-{
- /*
- In MySQL some multi-byte character sets
- have 'ctype' array but don't have 'to_lower'
- and 'to_upper' arrays. In this case we handle
- only basic latin letters a..z and A..Z.
-
- If 'to_lower' and 'to_upper' arrays are empty in a character set,
- then my_isalpha(cs, ch) should never return TRUE for characters
- other than basic latin letters. Otherwise it should be
- considered as a mistake in character set definition.
- */
- assert(my_isalpha(charset,ch));
- if (my_isupper(charset,ch))
- {
- return(charset->to_lower ? my_tolower(charset,ch) :
- ch - 'A' + 'a');
- }
- else if (my_islower(charset,ch))
- {
- return(charset->to_upper ? my_toupper(charset,ch) :
- ch - 'a' + 'A');
- }
- else /* peculiar, but could happen */
- return(ch);
-}
-
-/*
- - bothcases - emit a dualcase version of a two-case character
- == static void bothcases(register struct parse *p, int ch);
- *
- * Boy, is this implementation ever a kludge...
- */
-static void
-bothcases(p, ch)
-register struct parse *p;
-int ch;
-{
- register char *oldnext = p->next;
- register char *oldend = p->end;
- char bracket[3];
-
- assert(othercase(p->charset, ch) != ch); /* p_bracket() would recurse */
- p->next = bracket;
- p->end = bracket+2;
- bracket[0] = ch;
- bracket[1] = ']';
- bracket[2] = '\0';
- p_bracket(p);
- assert(p->next == bracket+2);
- p->next = oldnext;
- p->end = oldend;
-}
-
-/*
- - ordinary - emit an ordinary character
- == static void ordinary(register struct parse *p, register int ch);
- */
-static void
-ordinary(p, ch)
-register struct parse *p;
-register int ch;
-{
- register cat_t *cap = p->g->categories;
-
- if ((p->g->cflags®_ICASE) && my_isalpha(p->charset,ch) &&
- othercase(p->charset,ch) != ch)
- bothcases(p, ch);
- else {
- EMIT(OCHAR, (unsigned char)ch);
- if (cap[ch] == 0)
- cap[ch] = p->g->ncategories++;
- }
-}
-
-/*
- - nonnewline - emit REG_NEWLINE version of OANY
- == static void nonnewline(register struct parse *p);
- *
- * Boy, is this implementation ever a kludge...
- */
-static void
-nonnewline(p)
-register struct parse *p;
-{
- register char *oldnext = p->next;
- register char *oldend = p->end;
- char bracket[4];
-
- p->next = bracket;
- p->end = bracket+3;
- bracket[0] = '^';
- bracket[1] = '\n';
- bracket[2] = ']';
- bracket[3] = '\0';
- p_bracket(p);
- assert(p->next == bracket+3);
- p->next = oldnext;
- p->end = oldend;
-}
-
-/*
- - repeat - generate code for a bounded repetition, recursively if needed
- == static void repeat(register struct parse *p, sopno start, int from, int to);
- */
-static void
-repeat(p, start, from, to)
-register struct parse *p;
-sopno start; /* operand from here to end of strip */
-int from; /* repeated from this number */
-int to; /* to this number of times (maybe RE_INFINITY) */
-{
- register sopno finish = HERE();
-# define N 2
-# define INF 3
-# define REP(f, t) ((f)*8 + (t))
-# define MAP(n) (((n) <= 1) ? (n) : ((n) == RE_INFINITY) ? INF : N)
- register sopno copy;
-
- if (p->error != 0) /* head off possible runaway recursion */
- return;
-
- assert(from <= to);
-
- switch (REP(MAP(from), MAP(to))) {
- case REP(0, 0): /* must be user doing this */
- DROP(finish-start); /* drop the operand */
- break;
- case REP(0, 1): /* as x{1,1}? */
- case REP(0, N): /* as x{1,n}? */
- case REP(0, INF): /* as x{1,}? */
- /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, start); /* offset is wrong... */
- repeat(p, start+1, 1, to);
- ASTERN(OOR1, start);
- AHEAD(start); /* ... fix it */
- EMIT(OOR2, 0);
- AHEAD(THERE());
- ASTERN(O_CH, THERETHERE());
- break;
- case REP(1, 1): /* trivial case */
- /* done */
- break;
- case REP(1, N): /* as x?x{1,n-1} */
- /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
- INSERT(OCH_, start);
- ASTERN(OOR1, start);
- AHEAD(start);
- EMIT(OOR2, 0); /* offset very wrong... */
- AHEAD(THERE()); /* ...so fix it */
- ASTERN(O_CH, THERETHERE());
- copy = dupl(p, start+1, finish+1);
- assert(copy == finish+4);
- repeat(p, copy, 1, to-1);
- break;
- case REP(1, INF): /* as x+ */
- INSERT(OPLUS_, start);
- ASTERN(O_PLUS, start);
- break;
- case REP(N, N): /* as xx{m-1,n-1} */
- copy = dupl(p, start, finish);
- repeat(p, copy, from-1, to-1);
- break;
- case REP(N, INF): /* as xx{n-1,INF} */
- copy = dupl(p, start, finish);
- repeat(p, copy, from-1, to);
- break;
- default: /* "can't happen" */
- SETERROR(REG_ASSERT); /* just in case */
- break;
- }
-}
-
-/*
- - seterr - set an error condition
- == static int seterr(register struct parse *p, int e);
- */
-static int /* useless but makes type checking happy */
-seterr(p, e)
-register struct parse *p;
-int e;
-{
- if (p->error == 0) /* keep earliest error condition */
- p->error = e;
- p->next = nuls; /* try to bring things to a halt */
- p->end = nuls;
- return(0); /* make the return value well-defined */
-}
-
-/*
- - allocset - allocate a set of characters for []
- == static cset *allocset(register struct parse *p);
- */
-static cset *
-allocset(p)
-register struct parse *p;
-{
- register int no = p->g->ncsets++;
- register size_t nc;
- register size_t nbytes;
- register cset *cs;
- register size_t css = (size_t)p->g->csetsize;
- register int i;
-
- if (no >= p->ncsalloc) { /* need another column of space */
- p->ncsalloc += CHAR_BIT;
- nc = p->ncsalloc;
- assert(nc % CHAR_BIT == 0);
- nbytes = nc / CHAR_BIT * css;
- if (p->g->sets == NULL)
- p->g->sets = (cset *)malloc(nc * sizeof(cset));
- else
- p->g->sets = (cset *)realloc((char *)p->g->sets,
- nc * sizeof(cset));
- if (p->g->setbits == NULL)
- p->g->setbits = (uch *)malloc(nbytes);
- else {
- p->g->setbits = (uch *)realloc((char *)p->g->setbits,
- nbytes);
- /* xxx this isn't right if setbits is now NULL */
- for (i = 0; i < no; i++)
- p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT);
- }
- if (p->g->sets != NULL && p->g->setbits != NULL)
- (void) memset((char *)p->g->setbits + (nbytes - css),
- 0, css);
- else {
- no = 0;
- SETERROR(REG_ESPACE);
- /* caller's responsibility not to do set ops */
- }
- }
-
- assert(p->g->sets != NULL); /* xxx */
- cs = &p->g->sets[no];
- cs->ptr = p->g->setbits + css*((no)/CHAR_BIT);
- cs->mask = 1 << ((no) % CHAR_BIT);
- cs->hash = 0;
- cs->smultis = 0;
- cs->multis = NULL;
-
- return(cs);
-}
-
-/*
- - freeset - free a now-unused set
- == static void freeset(register struct parse *p, register cset *cs);
- */
-static void
-freeset(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register size_t i;
- register cset *top = &p->g->sets[p->g->ncsets];
- register size_t css = (size_t)p->g->csetsize;
-
- for (i = 0; i < css; i++)
- CHsub(cs, i);
- if (cs == top-1) /* recover only the easy case */
- p->g->ncsets--;
-}
-
-/*
- - freezeset - final processing on a set of characters
- == static int freezeset(register struct parse *p, register cset *cs);
- *
- * The main task here is merging identical sets. This is usually a waste
- * of time (although the hash code minimizes the overhead), but can win
- * big if REG_ICASE is being used. REG_ICASE, by the way, is why the hash
- * is done using addition rather than xor -- all ASCII [aA] sets xor to
- * the same value!
- */
-static int /* set number */
-freezeset(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register uch h = cs->hash;
- register size_t i;
- register cset *top = &p->g->sets[p->g->ncsets];
- register cset *cs2;
- register size_t css = (size_t)p->g->csetsize;
-
- /* look for an earlier one which is the same */
- for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
- if (cs2->hash == h && cs2 != cs) {
- /* maybe */
- for (i = 0; i < css; i++)
- if (!!CHIN(cs2, i) != !!CHIN(cs, i))
- break; /* no */
- if (i == css)
- break; /* yes */
- }
-
- if (cs2 < top) { /* found one */
- freeset(p, cs);
- cs = cs2;
- }
-
- return((int)(cs - p->g->sets));
-}
-
-/*
- - firstch - return first character in a set (which must have at least one)
- == static int firstch(register struct parse *p, register cset *cs);
- */
-static int /* character; there is no "none" value */
-firstch(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register size_t i;
- register size_t css = (size_t)p->g->csetsize;
-
- for (i = 0; i < css; i++)
- if (CHIN(cs, i))
- return((char)i);
- assert(never);
- return(0); /* arbitrary */
-}
-
-/*
- - nch - number of characters in a set
- == static int nch(register struct parse *p, register cset *cs);
- */
-static int
-nch(p, cs)
-register struct parse *p;
-register cset *cs;
-{
- register size_t i;
- register size_t css = (size_t)p->g->csetsize;
- register int n = 0;
-
- for (i = 0; i < css; i++)
- if (CHIN(cs, i))
- n++;
- return(n);
-}
-
-#ifdef USE_ORIG_REGEX_CODE
-/*
- - mcadd - add a collating element to a cset
- == static void mcadd(register struct parse *p, register cset *cs, \
- == register char *cp);
- */
-static void
-mcadd(p, cs, cp)
-register struct parse *p;
-register cset *cs;
-register char *cp;
-{
- register size_t oldend = cs->smultis;
-
- cs->smultis += strlen(cp) + 1;
- if (cs->multis == NULL)
- cs->multis = malloc(cs->smultis);
- else
- cs->multis = realloc(cs->multis, cs->smultis);
- if (cs->multis == NULL) {
- SETERROR(REG_ESPACE);
- return;
- }
-
- (void) strcpy(cs->multis + oldend - 1, cp);
- cs->multis[cs->smultis - 1] = '\0';
-}
-#endif
-
-#ifdef NOT_USED
-/*
- - mcsub - subtract a collating element from a cset
- == static void mcsub(register cset *cs, register char *cp);
- */
-static void
-mcsub(cs, cp)
-register cset *cs;
-register char *cp;
-{
- register char *fp = mcfind(cs, cp);
- register size_t len = strlen(fp);
-
- assert(fp != NULL);
- (void) memmove(fp, fp + len + 1,
- cs->smultis - (fp + len + 1 - cs->multis));
- cs->smultis -= len;
-
- if (cs->smultis == 0) {
- free(cs->multis);
- cs->multis = NULL;
- return;
- }
-
- cs->multis = realloc(cs->multis, cs->smultis);
- assert(cs->multis != NULL);
-}
-
-/*
- - mcin - is a collating element in a cset?
- == static int mcin(register cset *cs, register char *cp);
- */
-static int
-mcin(cs, cp)
-register cset *cs;
-register char *cp;
-{
- return(mcfind(cs, cp) != NULL);
-}
-
-/*
- - mcfind - find a collating element in a cset
- == static char *mcfind(register cset *cs, register char *cp);
- */
-static char *
-mcfind(cs, cp)
-register cset *cs;
-register char *cp;
-{
- register char *p;
-
- if (cs->multis == NULL)
- return(NULL);
- for (p = cs->multis; *p != '\0'; p += strlen(p) + 1)
- if (strcmp(cp, p) == 0)
- return(p);
- return(NULL);
-}
-#endif
-
-/*
- - mcinvert - invert the list of collating elements in a cset
- == static void mcinvert(register struct parse *p, register cset *cs);
- *
- * This would have to know the set of possibilities. Implementation
- * is deferred.
- */
-static void
-mcinvert(p, cs)
- register struct parse *p __attribute__((unused));
- register cset *cs __attribute__((unused));
-{
- assert(cs->multis == NULL); /* xxx */
-}
-
-/*
- - mccase - add case counterparts of the list of collating elements in a cset
- == static void mccase(register struct parse *p, register cset *cs);
- *
- * This would have to know the set of possibilities. Implementation
- * is deferred.
- */
-static void
-mccase(p, cs)
-register struct parse *p __attribute__((unused));
-register cset *cs __attribute__((unused));
-{
- assert(cs->multis == NULL); /* xxx */
-}
-
-/*
- - isinsets - is this character in any sets?
- == static int isinsets(register struct re_guts *g, int c);
- */
-static int /* predicate */
-isinsets(g, c)
-register struct re_guts *g;
-int c;
-{
- register uch *col;
- register int i;
- register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
- register unsigned uc = (unsigned char)c;
-
- for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
- if (col[uc] != 0)
- return(1);
- return(0);
-}
-
-/*
- - samesets - are these two characters in exactly the same sets?
- == static int samesets(register struct re_guts *g, int c1, int c2);
- */
-static int /* predicate */
-samesets(g, c1, c2)
-register struct re_guts *g;
-int c1;
-int c2;
-{
- register uch *col;
- register int i;
- register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
- register unsigned uc1 = (unsigned char)c1;
- register unsigned uc2 = (unsigned char)c2;
-
- for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
- if (col[uc1] != col[uc2])
- return(0);
- return(1);
-}
-
-/*
- - categorize - sort out character categories
- == static void categorize(struct parse *p, register struct re_guts *g);
- */
-static void
-categorize(p, g)
-struct parse *p;
-register struct re_guts *g;
-{
- register cat_t *cats = g->categories;
- register int c;
- register int c2;
- register cat_t cat;
-
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- for (c = CHAR_MIN; c <= CHAR_MAX; c++)
- if (cats[c] == 0 && isinsets(g, c)) {
- cat = g->ncategories++;
- cats[c] = cat;
- for (c2 = c+1; c2 <= CHAR_MAX; c2++)
- if (cats[c2] == 0 && samesets(g, c, c2))
- cats[c2] = cat;
- }
-}
-
-/*
- - dupl - emit a duplicate of a bunch of sops
- == static sopno dupl(register struct parse *p, sopno start, sopno finish);
- */
-static sopno /* start of duplicate */
-dupl(p, start, finish)
-register struct parse *p;
-sopno start; /* from here */
-sopno finish; /* to this less one */
-{
- register sopno ret = HERE();
- register sopno len = finish - start;
-
- assert(finish >= start);
- if (len == 0)
- return(ret);
- enlarge(p, p->ssize + len); /* this many unexpected additions */
- assert(p->ssize >= p->slen + len);
- (void) memcpy((char *)(p->strip + p->slen),
- (char *)(p->strip + start), (size_t)len*sizeof(sop));
- p->slen += len;
- return(ret);
-}
-
-/*
- - doemit - emit a strip operator
- == static void doemit(register struct parse *p, sop op, size_t opnd);
- *
- * It might seem better to implement this as a macro with a function as
- * hard-case backup, but it's just too big and messy unless there are
- * some changes to the data structures. Maybe later.
- */
-static void
-doemit(p, op, opnd)
-register struct parse *p;
-sop op;
-size_t opnd;
-{
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- /* deal with oversize operands ("can't happen", more or less) */
- assert(opnd < 1<slen >= p->ssize)
- enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */
- assert(p->slen < p->ssize);
-
- /* finally, it's all reduced to the easy case */
- p->strip[p->slen++] = SOP(op, opnd);
-}
-
-/*
- - doinsert - insert a sop into the strip
- == static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos);
- */
-static void
-doinsert(p, op, opnd, pos)
-register struct parse *p;
-sop op;
-size_t opnd;
-sopno pos;
-{
- register sopno sn;
- register sop s;
- register int i;
-
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- sn = HERE();
- EMIT(op, opnd); /* do checks, ensure space */
- assert(HERE() == sn+1);
- s = p->strip[sn];
-
- /* adjust paren pointers */
- assert(pos > 0);
- for (i = 1; i < NPAREN; i++) {
- if (p->pbegin[i] >= pos) {
- p->pbegin[i]++;
- }
- if (p->pend[i] >= pos) {
- p->pend[i]++;
- }
- }
- {
- int length=(HERE()-pos-1)*sizeof(sop);
- bmove_upp((uchar *) &p->strip[pos+1]+length,
- (uchar *) &p->strip[pos]+length,
- length);
- }
-#ifdef OLD_CODE
- memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos],
- (HERE()-pos-1)*sizeof(sop));
-#endif
- p->strip[pos] = s;
-}
-
-/*
- - dofwd - complete a forward reference
- == static void dofwd(register struct parse *p, sopno pos, sop value);
- */
-static void
-dofwd(p, pos, value)
-register struct parse *p;
-register sopno pos;
-sop value;
-{
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- assert(value < 1<strip[pos] = OP(p->strip[pos]) | value;
-}
-
-/*
- - enlarge - enlarge the strip
- == static void enlarge(register struct parse *p, sopno size);
- */
-static void
-enlarge(p, size)
-register struct parse *p;
-register sopno size;
-{
- register sop *sp;
-
- if (p->ssize >= size)
- return;
-
- sp = (sop *)realloc(p->strip, size*sizeof(sop));
- if (sp == NULL) {
- SETERROR(REG_ESPACE);
- return;
- }
- p->strip = sp;
- p->ssize = size;
-}
-
-/*
- - stripsnug - compact the strip
- == static void stripsnug(register struct parse *p, register struct re_guts *g);
- */
-static void
-stripsnug(p, g)
-register struct parse *p;
-register struct re_guts *g;
-{
- g->nstates = p->slen;
- g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop));
- if (g->strip == NULL) {
- SETERROR(REG_ESPACE);
- g->strip = p->strip;
- }
-}
-
-/*
- - findmust - fill in must and mlen with longest mandatory literal string
- == static void findmust(register struct parse *p, register struct re_guts *g);
- *
- * This algorithm could do fancy things like analyzing the operands of |
- * for common subsequences. Someday. This code is simple and finds most
- * of the interesting cases.
- *
- * Note that must and mlen got initialized during setup.
- */
-static void
-findmust(p, g)
-struct parse *p;
-register struct re_guts *g;
-{
- register sop *scan;
- sop *start;
- register sop *newstart;
- register sopno newlen;
- register sop s;
- register char *cp;
- register sopno i;
- LINT_INIT(start); LINT_INIT(newstart);
- /* avoid making error situations worse */
- if (p->error != 0)
- return;
-
- /* find the longest OCHAR sequence in strip */
- newlen = 0;
- scan = g->strip + 1;
- do {
- s = *scan++;
- switch (OP(s)) {
- case OCHAR: /* sequence member */
- if (newlen == 0) /* new sequence */
- newstart = scan - 1;
- newlen++;
- break;
- case OPLUS_: /* things that don't break one */
- case OLPAREN:
- case ORPAREN:
- break;
- case OQUEST_: /* things that must be skipped */
- case OCH_:
- scan--;
- do {
- scan += OPND(s);
- s = *scan;
- /* assert() interferes w debug printouts */
- if (OP(s) != O_QUEST && OP(s) != O_CH &&
- OP(s) != OOR2) {
- g->iflags |= BAD;
- return;
- }
- } while (OP(s) != O_QUEST && OP(s) != O_CH);
- /* fallthrough */
- default: /* things that break a sequence */
- if (newlen > g->mlen) { /* ends one */
- start = newstart;
- g->mlen = newlen;
- }
- newlen = 0;
- break;
- }
- } while (OP(s) != OEND);
-
- if (g->mlen == 0) /* there isn't one */
- return;
-
- /* turn it into a character string */
- g->must = malloc((size_t)g->mlen + 1);
- if (g->must == NULL) { /* argh; just forget it */
- g->mlen = 0;
- return;
- }
- cp = g->must;
- scan = start;
- for (i = g->mlen; i > 0; i--) {
- while (OP(s = *scan++) != OCHAR)
- continue;
- assert(cp < g->must + g->mlen);
- *cp++ = (char)OPND(s);
- }
- assert(cp == g->must + g->mlen);
- *cp++ = '\0'; /* just on general principles */
-}
-
-/*
- - pluscount - count + nesting
- == static sopno pluscount(register struct parse *p, register struct re_guts *g);
- */
-static sopno /* nesting depth */
-pluscount(p, g)
-struct parse *p;
-register struct re_guts *g;
-{
- register sop *scan;
- register sop s;
- register sopno plusnest = 0;
- register sopno maxnest = 0;
-
- if (p->error != 0)
- return(0); /* there may not be an OEND */
-
- scan = g->strip + 1;
- do {
- s = *scan++;
- switch (OP(s)) {
- case OPLUS_:
- plusnest++;
- break;
- case O_PLUS:
- if (plusnest > maxnest)
- maxnest = plusnest;
- plusnest--;
- break;
- }
- } while (OP(s) != OEND);
- if (plusnest != 0)
- g->iflags |= BAD;
- return(maxnest);
-}
diff --git a/externals/mysql/extlib/regex/regerror.c b/externals/mysql/extlib/regex/regerror.c
deleted file mode 100644
index 489f2e35ab..0000000000
--- a/externals/mysql/extlib/regex/regerror.c
+++ /dev/null
@@ -1,116 +0,0 @@
-#include
-#include
-#include
-
-#include "my_regex.h"
-#include "utils.h"
-#include "regerror.ih"
-
-/*
- = #define REG_NOMATCH 1
- = #define REG_BADPAT 2
- = #define REG_ECOLLATE 3
- = #define REG_ECTYPE 4
- = #define REG_EESCAPE 5
- = #define REG_ESUBREG 6
- = #define REG_EBRACK 7
- = #define REG_EPAREN 8
- = #define REG_EBRACE 9
- = #define REG_BADBR 10
- = #define REG_ERANGE 11
- = #define REG_ESPACE 12
- = #define REG_BADRPT 13
- = #define REG_EMPTY 14
- = #define REG_ASSERT 15
- = #define REG_INVARG 16
- = #define REG_ATOI 255 // convert name to number (!)
- = #define REG_ITOA 0400 // convert number to name (!)
- */
-static struct rerr {
- int code;
- const char *name;
- const char *explain;
-} rerrs[] = {
- {REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match"},
- {REG_BADPAT, "REG_BADPAT", "invalid regular expression"},
- {REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element"},
- {REG_ECTYPE, "REG_ECTYPE", "invalid character class"},
- {REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)"},
- {REG_ESUBREG, "REG_ESUBREG", "invalid backreference number"},
- {REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced"},
- {REG_EPAREN, "REG_EPAREN", "parentheses not balanced"},
- {REG_EBRACE, "REG_EBRACE", "braces not balanced"},
- {REG_BADBR, "REG_BADBR", "invalid repetition count(s)"},
- {REG_ERANGE, "REG_ERANGE", "invalid character range"},
- {REG_ESPACE, "REG_ESPACE", "out of memory"},
- {REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid"},
- {REG_EMPTY, "REG_EMPTY", "empty (sub)expression"},
- {REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug"},
- {REG_INVARG, "REG_INVARG", "invalid argument to regex routine"},
- {0, "", "*** unknown regexp error code ***"},
-};
-
-/*
- - regerror - the interface to error numbers
- = extern size_t regerror(int, const regex_t *, char *, size_t);
- */
-/* ARGSUSED */
-size_t
-my_regerror(int errcode, const my_regex_t *preg, char *errbuf, size_t errbuf_size)
-{
- register struct rerr *r;
- register size_t len;
- register int target = errcode &~ REG_ITOA;
- register char *s;
- char convbuf[50];
-
- if (errcode == REG_ATOI)
- s = regatoi(preg, convbuf);
- else {
- for (r = rerrs; r->code != 0; r++)
- if (r->code == target)
- break;
-
- if (errcode®_ITOA) {
- if (r->code != 0)
- (void) strcpy(convbuf, r->name);
- else
- sprintf(convbuf, "REG_0x%x", target);
- assert(strlen(convbuf) < sizeof(convbuf));
- s = convbuf;
- } else
- s = (char*) r->explain;
- }
-
- len = strlen(s) + 1;
- if (errbuf_size > 0) {
- if (errbuf_size > len)
- (void) strcpy(errbuf, s);
- else {
- (void) strncpy(errbuf, s, errbuf_size-1);
- errbuf[errbuf_size-1] = '\0';
- }
- }
-
- return(len);
-}
-
-/*
- - regatoi - internal routine to implement REG_ATOI
- == static char *regatoi(const regex_t *preg, char *localbuf);
- */
-static char *
-regatoi(preg, localbuf)
-const my_regex_t *preg;
-char *localbuf;
-{
- register struct rerr *r;
- for (r = rerrs; r->code != 0; r++)
- if (strcmp(r->name, preg->re_endp) == 0)
- break;
- if (r->code == 0)
- return((char*) "0");
-
- sprintf(localbuf, "%d", r->code);
- return(localbuf);
-}
diff --git a/externals/mysql/extlib/regex/regex2.h b/externals/mysql/extlib/regex/regex2.h
deleted file mode 100644
index bba54ea205..0000000000
--- a/externals/mysql/extlib/regex/regex2.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * First, the stuff that ends up in the outside-world include file
- = typedef off_t regoff_t;
- = typedef struct {
- = int re_magic;
- = size_t re_nsub; // number of parenthesized subexpressions
- = const char *re_endp; // end pointer for REG_PEND
- = struct re_guts *re_g; // none of your business :-)
- = } regex_t;
- = typedef struct {
- = regoff_t rm_so; // start of match
- = regoff_t rm_eo; // end of match
- = } regmatch_t;
- */
-/*
- * internals of regex_t
- */
-#ifndef __regex2_h__
-#define __regex2_h__
-
-#define MAGIC1 ((('r'^0200)<<8) | 'e')
-
-/*
- * The internal representation is a *strip*, a sequence of
- * operators ending with an endmarker. (Some terminology etc. is a
- * historical relic of earlier versions which used multiple strips.)
- * Certain oddities in the representation are there to permit running
- * the machinery backwards; in particular, any deviation from sequential
- * flow must be marked at both its source and its destination. Some
- * fine points:
- *
- * - OPLUS_ and O_PLUS are *inside* the loop they create.
- * - OQUEST_ and O_QUEST are *outside* the bypass they create.
- * - OCH_ and O_CH are *outside* the multi-way branch they create, while
- * OOR1 and OOR2 are respectively the end and the beginning of one of
- * the branches. Note that there is an implicit OOR2 following OCH_
- * and an implicit OOR1 preceding O_CH.
- *
- * In state representations, an operator's bit is on to signify a state
- * immediately *preceding* "execution" of that operator.
- */
-typedef unsigned long sop; /* strip operator */
-typedef long sopno;
-#define OPRMASK 0xf8000000
-#define OPDMASK 0x07ffffff
-#define OPSHIFT ((unsigned long)27)
-#define OP(n) ((unsigned long) ((n)&OPRMASK))
-#define OPND(n) ((unsigned long) ((n)&OPDMASK))
-#define SOP(op, opnd) (unsigned long) ((op)|(opnd))
-#define OSHIFT(A) ((unsigned long) (A) << OPSHIFT)
-/* operators meaning operand */
-/* (back, fwd are offsets) */
-#define OEND OSHIFT(1) /* endmarker - */
-#define OCHAR OSHIFT(2) /* character unsigned char */
-#define OBOL OSHIFT(3) /* left anchor - */
-#define OEOL OSHIFT(4) /* right anchor - */
-#define OANY OSHIFT(5) /* . - */
-#define OANYOF OSHIFT(6) /* [...] set number */
-#define OBACK_ OSHIFT(7) /* begin \d paren number */
-#define O_BACK OSHIFT(8) /* end \d paren number */
-#define OPLUS_ OSHIFT(9) /* + prefix fwd to suffix */
-#define O_PLUS OSHIFT(10) /* + suffix back to prefix */
-#define OQUEST_ OSHIFT(11) /* ? prefix fwd to suffix */
-#define O_QUEST OSHIFT(12) /* ? suffix back to prefix */
-#define OLPAREN OSHIFT(13) /* ( fwd to ) */
-#define ORPAREN OSHIFT(14) /* ) back to ( */
-#define OCH_ OSHIFT(15) /* begin choice fwd to OOR2 */
-#define OOR1 OSHIFT(16) /* | pt. 1 back to OOR1 or OCH_ */
-#define OOR2 OSHIFT(17) /* | pt. 2 fwd to OOR2 or O_CH */
-#define O_CH OSHIFT(18) /* end choice back to OOR1 */
-#define OBOW OSHIFT(19) /* begin word - */
-#define OEOW OSHIFT(20) /* end word - */
-
-/*
- * Structure for [] character-set representation. Character sets are
- * done as bit vectors, grouped 8 to a byte vector for compactness.
- * The individual set therefore has both a pointer to the byte vector
- * and a mask to pick out the relevant bit of each byte. A hash code
- * simplifies testing whether two sets could be identical.
- *
- * This will get trickier for multicharacter collating elements. As
- * preliminary hooks for dealing with such things, we also carry along
- * a string of multi-character elements, and decide the size of the
- * vectors at run time.
- */
-#ifdef __WIN__
-typedef unsigned char uch ;
-#endif
-
-typedef struct {
- uch *ptr; /* -> uch [csetsize] */
- uch mask; /* bit within array */
- uch hash; /* hash code */
- size_t smultis;
- char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */
-} cset;
-/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
-#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (uch) (c))
-#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (uch)(c))
-#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask)
-#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */
-#define MCsub(p, cs, cp) mcsub(p, cs, cp)
-#define MCin(p, cs, cp) mcin(p, cs, cp)
-
-/* stuff for character categories */
-typedef unsigned char cat_t;
-
-/*
- * main compiled-expression structure
- */
-struct re_guts {
- int magic;
-# define MAGIC2 ((('R'^0200)<<8)|'E')
- sop *strip; /* malloced area for strip */
- int csetsize; /* number of bits in a cset vector */
- int ncsets; /* number of csets in use */
- cset *sets; /* -> cset [ncsets] */
- uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */
- int cflags; /* copy of regcomp() cflags argument */
- sopno nstates; /* = number of sops */
- sopno firststate; /* the initial OEND (normally 0) */
- sopno laststate; /* the final OEND */
- int iflags; /* internal flags */
-# define USEBOL 01 /* used ^ */
-# define USEEOL 02 /* used $ */
-# define BAD 04 /* something wrong */
- int nbol; /* number of ^ used */
- int neol; /* number of $ used */
- int ncategories; /* how many character categories */
- cat_t *categories; /* ->catspace[-CHAR_MIN] */
- char *must; /* match must contain this string */
- int mlen; /* length of must */
- size_t nsub; /* copy of re_nsub */
- int backrefs; /* does it use back references? */
- sopno nplus; /* how deep does it nest +s? */
- /* catspace must be last */
- cat_t catspace[1]; /* actually [NC] */
-};
-
-/* misc utilities */
-#undef OUT /* May be defined in windows */
-#define OUT (CHAR_MAX+1) /* a non-character value */
-#define ISWORD(s,c) (my_isalnum(s,c) || (c) == '_')
-
-#endif /* __regex2_h__ */
diff --git a/externals/mysql/extlib/regex/regexec.c b/externals/mysql/extlib/regex/regexec.c
deleted file mode 100644
index 338c1bfa7f..0000000000
--- a/externals/mysql/extlib/regex/regexec.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * the outer shell of regexec()
- *
- * This file includes engine.c *twice*, after muchos fiddling with the
- * macros that code uses. This lets the same code operate on two different
- * representations for state sets.
- */
-#include
-#include
-#include
-#ifdef __WIN__
-#include
-#endif
-#include "my_regex.h"
-#include "utils.h"
-#include "regex2.h"
-
-/* for use in asserts */
-#define nope 0
-
-/* macros for manipulating states, small version */
-#define states long
-#define states1 long /* for later use in regexec() decision. Ensure Win64 definition is correct.*/
-#define CLEAR(v) ((v) = 0)
-#define SET0(v, n) ((v) &= ~((states) 1 << (n)))
-#define SET1(v, n) ((v) |= (states) 1 << (n))
-#define ISSET(v, n) ((v) & ((states) 1 << (n)))
-#define ASSIGN(d, s) ((d) = (s))
-#define EQ(a, b) ((a) == (b))
-#define STATEVARS int dummy /* dummy version */
-#define STATESETUP(m, n) /* nothing */
-#define STATETEARDOWN(m) /* nothing */
-#define SETUP(v) ((v) = 0)
-#define onestate long /* Changed from int by Monty */
-#define INIT(o, n) ((o) = (unsigned states)1 << (n))
-#define INC(o) ((o) <<= 1)
-#define ISSTATEIN(v, o) ((v) & (o))
-/* some abbreviations; note that some of these know variable names! */
-/* do "if I'm here, I can also be there" etc without branches */
-#define FWD(dst, src, n) ((dst) |= ((unsigned states)(src)&(here)) << (n))
-#define BACK(dst, src, n) ((dst) |= ((unsigned states)(src)&(here)) >> (n))
-#define ISSETBACK(v, n) ((v) & ((unsigned states)here >> (n)))
-/* function names */
-#define SNAMES /* engine.c looks after details */
-
-#include "engine.c"
-
-/* now undo things */
-#undef states
-#undef CLEAR
-#undef SET0
-#undef SET1
-#undef ISSET
-#undef ASSIGN
-#undef EQ
-#undef STATEVARS
-#undef STATESETUP
-#undef STATETEARDOWN
-#undef SETUP
-#undef onestate
-#undef INIT
-#undef INC
-#undef ISSTATEIN
-#undef FWD
-#undef BACK
-#undef ISSETBACK
-#undef SNAMES
-
-/* macros for manipulating states, large version */
-#define states char *
-#define CLEAR(v) memset(v, 0, m->g->nstates)
-#define SET0(v, n) ((v)[n] = 0)
-#define SET1(v, n) ((v)[n] = 1)
-#define ISSET(v, n) ((v)[n])
-#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
-#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
-#define STATEVARS int vn; char *space
-#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
- if ((m)->space == NULL) return(REG_ESPACE); \
- (m)->vn = 0; }
-#define STATETEARDOWN(m) { free((m)->space); }
-#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
-#define onestate int
-#define INIT(o, n) ((o) = (n))
-#define INC(o) ((o)++)
-#define ISSTATEIN(v, o) ((v)[o])
-/* some abbreviations; note that some of these know variable names! */
-/* do "if I'm here, I can also be there" etc without branches */
-#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here])
-#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here])
-#define ISSETBACK(v, n) ((v)[here - (n)])
-/* function names */
-#define LNAMES /* flag */
-
-#include "engine.c"
-
-/*
- - regexec - interface for matching
- = extern int regexec(const regex_t *, const char *, size_t, \
- = regmatch_t [], int);
- = #define REG_NOTBOL 00001
- = #define REG_NOTEOL 00002
- = #define REG_STARTEND 00004
- = #define REG_TRACE 00400 // tracing of execution
- = #define REG_LARGE 01000 // force large representation
- = #define REG_BACKR 02000 // force use of backref code
- *
- * We put this here so we can exploit knowledge of the state representation
- * when choosing which matcher to call. Also, by this point the matchers
- * have been prototyped.
- */
-int /* 0 success, REG_NOMATCH failure */
-my_regexec(preg, str, nmatch, pmatch, eflags)
-const my_regex_t *preg;
-const char *str;
-size_t nmatch;
-my_regmatch_t pmatch[];
-int eflags;
-{
- register struct re_guts *g = preg->re_g;
-#ifdef REDEBUG
-# define GOODFLAGS(f) (f)
-#else
-# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
-#endif
-
- if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
- return(REG_BADPAT);
- assert(!(g->iflags&BAD));
- if (g->iflags&BAD) /* backstop for no-debug case */
- return(REG_BADPAT);
- eflags = GOODFLAGS(eflags);
-
- if ((size_t) g->nstates <= CHAR_BIT*sizeof(states1) &&
- !(eflags®_LARGE))
- return(smatcher(preg->charset, g, (char *)str, nmatch, pmatch, eflags));
- else
- return(lmatcher(preg->charset, g, (char *)str, nmatch, pmatch, eflags));
-}
diff --git a/externals/mysql/extlib/regex/regexp.c b/externals/mysql/extlib/regex/regexp.c
deleted file mode 100644
index 8ddf90f294..0000000000
--- a/externals/mysql/extlib/regex/regexp.c
+++ /dev/null
@@ -1,1348 +0,0 @@
-/*
- *
- * regexp.c - regular expression matching
- *
- * DESCRIPTION
- *
- * Underneath the reformatting and comment blocks which were added to
- * make it consistent with the rest of the code, you will find a
- * modified version of Henry Specer's regular expression library.
- * Henry's functions were modified to provide the minimal regular
- * expression matching, as required by P1003. Henry's code was
- * copyrighted, and copy of the copyright message and restrictions
- * are provided, verbatim, below:
- *
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- *
- *
- * This version modified by Ian Phillipps to return pointer to terminating
- * NUL on substitution string. [ Temp mail address ex-igp@camcon.co.uk ]
- *
- * Altered by amylaar to support excompatible option and the
- * operators \< and >\ . ( 7.Sep. 1991 )
- *
- * regsub altered by amylaar to take an additional parameter specifying
- * maximum number of bytes that can be written to the memory region
- * pointed to by dest
- *
- * Also altered by Fredrik Hubinette to handle the + operator and
- * eight-bit chars. Mars 22 1996
- *
- *
- * Beware that some of this code is subtly aware of the way operator
- * precedence is structured in regular expressions. Serious changes in
- * regular-expression syntax might require a total rethink.
- *
- * AUTHORS
- *
- * Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
- * Henry Spencer, University of Torronto (henry@utzoo.edu)
- *
- * Sponsored by The USENIX Association for public distribution.
- *
- */
-
-/* Headers */
-#include "my_global.h"
-#include
-#include "regexp.h"
-#ifdef __WIN__
-#include
-#else
-#include "memory.h"
-#include "error.h"
-#endif
-
-/*
- * The "internal use only" fields in regexp.h are present to pass info from
- * compile to execute that permits the execute phase to run lots faster on
- * simple cases. They are:
- *
- * regstart char that must begin a match; '\0' if none obvious
- * reganch is the match anchored (at beginning-of-line only)?
- * regmust string (pointer into program) that match must include, or NULL
- * regmlen length of regmust string
- *
- * Regstart and reganch permit very fast decisions on suitable starting points
- * for a match, cutting down the work a lot. Regmust permits fast rejection
- * of lines that cannot possibly match. The regmust tests are costly enough
- * that regcomp() supplies a regmust only if the r.e. contains something
- * potentially expensive (at present, the only such thing detected is * or +
- * at the start of the r.e., which can involve a lot of backup). Regmlen is
- * supplied because the test in regexec() needs it and regcomp() is computing
- * it anyway.
- */
-
-/*
- * Structure for regexp "program". This is essentially a linear encoding
- * of a nondeterministic finite-state machine (aka syntax charts or
- * "railroad normal form" in parsing technology). Each node is an opcode
- * plus a "nxt" pointer, possibly plus an operand. "Nxt" pointers of
- * all nodes except BRANCH implement concatenation; a "nxt" pointer with
- * a BRANCH on both ends of it is connecting two alternatives. (Here we
- * have one of the subtle syntax dependencies: an individual BRANCH (as
- * opposed to a collection of them) is never concatenated with anything
- * because of operator precedence.) The operand of some types of node is
- * a literal string; for others, it is a node leading into a sub-FSM. In
- * particular, the operand of a BRANCH node is the first node of the branch.
- * (NB this is *not* a tree structure: the tail of the branch connects
- * to the thing following the set of BRANCHes.) The opcodes are:
- */
-
-/* definition number opnd? meaning */
-#define END 0 /* no End of program. */
-#define BOL 1 /* no Match "" at beginning of line. */
-#define EOL 2 /* no Match "" at end of line. */
-#define ANY 3 /* no Match any one character. */
-#define ANYOF 4 /* str Match any character in this string. */
-#define ANYBUT 5 /* str Match any character not in this
- * string. */
-#define BRANCH 6 /* node Match this alternative, or the
- * nxt... */
-#define BACK 7 /* no Match "", "nxt" ptr points backward. */
-#define EXACTLY 8 /* str Match this string. */
-#define NOTHING 9 /* no Match empty string. */
-#define STAR 10 /* node Match this (simple) thing 0 or more
- * times. */
-#define WORDSTART 11 /* node matching a start of a word */
-#define WORDEND 12 /* node matching an end of a word */
-#define OPEN 20 /* no Mark this point in input as start of
- * #n. */
- /* OPEN+1 is number 1, etc. */
-#define CLOSE 30 /* no Analogous to OPEN. */
-
-/*
- * Opcode notes:
- *
- * BRANCH The set of branches constituting a single choice are hooked
- * together with their "nxt" pointers, since precedence prevents
- * anything being concatenated to any individual branch. The
- * "nxt" pointer of the last BRANCH in a choice points to the
- * thing following the whole choice. This is also where the
- * final "nxt" pointer of each individual branch points; each
- * branch starts with the operand node of a BRANCH node.
- *
- * BACK Normal "nxt" pointers all implicitly point forward; BACK
- * exists to make loop structures possible.
- *
- * STAR complex '*', are implemented as circular BRANCH structures
- * using BACK. Simple cases (one character per match) are
- * implemented with STAR for speed and to minimize recursive
- * plunges.
- *
- * OPEN,CLOSE ...are numbered at compile time.
- */
-
-/*
- * A node is one char of opcode followed by two chars of "nxt" pointer.
- * "Nxt" pointers are stored as two 8-bit pieces, high order first. The
- * value is a positive offset from the opcode of the node containing it.
- * An operand, if any, simply follows the node. (Note that much of the
- * code generation knows about this implicit relationship.)
- *
- * Using two bytes for the "nxt" pointer is vast overkill for most things,
- * but allows patterns to get big without disasters.
- */
-#define OP(p) (*(p))
-#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
-#define OPERAND(p) ((p) + 3)
-
-/*
- * The first byte of the regexp internal "program" is actually this magic
- * number; the start node begins in the second byte.
- */
-#define MAGIC 0234
-
-/*
- * Utility definitions.
- */
-
-#ifdef __WIN__
-#define error(X,Y) fprintf(stderr, X, Y)
-#endif
-#define regerror(X) error("Regexp: %s\n",X);
-#define SPECIAL 0x100
-#define LBRAC ('('|SPECIAL)
-#define RBRAC (')'|SPECIAL)
-#define ASTERIX ('*'|SPECIAL)
-#define PLUS ('+'|SPECIAL)
-#define OR_OP ('|'|SPECIAL)
-#define DOLLAR ('$'|SPECIAL)
-#define DOT ('.'|SPECIAL)
-#define CARET ('^'|SPECIAL)
-#define LSQBRAC ('['|SPECIAL)
-#define RSQBRAC (']'|SPECIAL)
-#define LSHBRAC ('<'|SPECIAL)
-#define RSHBRAC ('>'|SPECIAL)
-#define FAIL(m) { regerror(m); return(NULL); }
-#define ISMULT(c) ((c) == ASTERIX || (c)==PLUS)
-#define META "^$.[()|*+\\"
-#ifndef CHARBITS
-#define CHARBITS 0xff
-#define UCHARAT(p) ((int)*(unsigned char *)(p))
-#else
-#define UCHARAT(p) ((int)*(p)&CHARBITS)
-#endif
-#define ISWORDPART(c) ( isalnum(c) || (c) == '_' )
-
-/*
- * Flags to be passed up and down.
- */
-#define HASWIDTH 01 /* Known never to match null string. */
-#define SIMPLE 02 /* Simple enough to be STAR operand. */
-#define SPSTART 04 /* Starts with * */
-#define WORST 0 /* Worst case. */
-#ifdef __WIN__
-#define STRCHR(A,B) strchr(A,B)
-#endif
-
-/*
- * Global work variables for regcomp().
- */
-static short *regparse; /* Input-scan pointer. */
-static int regnpar; /* () count. */
-static char regdummy;
-static char *regcode; /* Code-emit pointer; ®dummy = don't. */
-static long regsize; /* Code size. */
-
-/*
- * Forward declarations for regcomp()'s friends.
- */
-#ifndef STATIC
-#define STATIC static
-#endif
-STATIC char *reg();
-STATIC char *regbranch();
-STATIC char *regpiece();
-STATIC char *regatom();
-STATIC char *regnode();
-STATIC char *regnext();
-STATIC void regc();
-STATIC void reginsert();
-STATIC void regtail();
-STATIC void regoptail();
-
-/*
- - regcomp - compile a regular expression into internal code
- *
- * We can't allocate space until we know how big the compiled form will be,
- * but we can't compile it (and thus know how big it is) until we've got a
- * place to put the code. So we cheat: we compile it twice, once with code
- * generation turned off and size counting turned on, and once "for real".
- * This also means that we don't allocate space until we are sure that the
- * thing really will compile successfully, and we never have to move the
- * code and thus invalidate pointers into it. (Note that it has to be in
- * one piece because free() must be able to free it all.)
- *
- * Beware that the optimization-preparation code in here knows about some
- * of the structure of the compiled regexp.
- */
-regexp *regcomp(exp,excompat)
-char *exp;
-int excompat; /* \( \) operators like in unix ex */
-{
- register regexp *r;
- register char *scan;
- register char *longest;
- register int len;
- int flags;
- short *exp2,*dest,c;
-
- if (exp == (char *)NULL)
- FAIL("NULL argument");
-
- exp2=(short*)malloc( (strlen(exp)+1) * (sizeof(short[8])/sizeof(char[8])) );
- for ( scan=exp,dest=exp2;( c= UCHARAT(scan++)); ) {
- switch (c) {
- case '(':
- case ')':
- *dest++ = excompat ? c : c | SPECIAL;
- break;
- case '.':
- case '*':
- case '+':
- case '|':
- case '$':
- case '^':
- case '[':
- case ']':
- *dest++ = c | SPECIAL;
- break;
- case '\\':
- switch ( c = *scan++ ) {
- case '(':
- case ')':
- *dest++ = excompat ? c | SPECIAL : c;
- break;
- case '<':
- case '>':
- *dest++ = c | SPECIAL;
- break;
- case '{':
- case '}':
- FAIL("sorry, unimplemented operator");
- case 'b': *dest++ = '\b'; break;
- case 't': *dest++ = '\t'; break;
- case 'r': *dest++ = '\r'; break;
- default:
- *dest++ = c;
- }
- break;
- default:
- *dest++ = c;
- }
- }
- *dest=0;
- /* First pass: determine size, legality. */
- regparse = exp2;
- regnpar = 1;
- regsize = 0L;
- regcode = ®dummy;
- regc(MAGIC);
- if (reg(0, &flags) == (char *)NULL)
- return ((regexp *)NULL);
-
- /* Small enough for pointer-storage convention? */
- if (regsize >= 32767L) /* Probably could be 65535L. */
- FAIL("regexp too big");
-
- /* Allocate space. */
- r = (regexp *) malloc(sizeof(regexp) + (unsigned) regsize);
- if (r == (regexp *) NULL)
- FAIL("out of space");
- (void) bzero(r, sizeof(regexp) + (unsigned)regsize);
-
- /* Second pass: emit code. */
- regparse = exp2;
- regnpar = 1;
- regcode = r->program;
- regc(MAGIC);
- if (reg(0, &flags) == NULL)
- return ((regexp *) NULL);
-
- /* Dig out information for optimizations. */
- r->regstart = '\0'; /* Worst-case defaults. */
- r->reganch = 0;
- r->regmust = NULL;
- r->regmlen = 0;
- scan = r->program + 1; /* First BRANCH. */
- if (OP(regnext(scan)) == END) { /* Only one top-level choice. */
- scan = OPERAND(scan);
-
- /* Starting-point info. */
- if (OP(scan) == EXACTLY)
- r->regstart = *OPERAND(scan);
- else if (OP(scan) == BOL)
- r->reganch++;
-
- /*
- * If there's something expensive in the r.e., find the longest
- * literal string that must appear and make it the regmust. Resolve
- * ties in favor of later strings, since the regstart check works
- * with the beginning of the r.e. and avoiding duplication
- * strengthens checking. Not a strong reason, but sufficient in the
- * absence of others.
- */
- if (flags & SPSTART) {
- longest = NULL;
- len = 0;
- for (; scan != NULL; scan = regnext(scan))
- if (OP(scan) == EXACTLY &&
- (int)strlen(OPERAND(scan)) >= len) {
- longest = OPERAND(scan);
- len = strlen(OPERAND(scan));
- }
- r->regmust = longest;
- r->regmlen = len;
- }
- }
- free((char*)exp2);
- return (r);
-}
-
-/*
- - reg - regular expression, i.e. main body or parenthesized thing
- *
- * Caller must absorb opening parenthesis.
- *
- * Combining parenthesis handling with the base level of regular expression
- * is a trifle forced, but the need to tie the tails of the branches to what
- * follows makes it hard to avoid.
- */
-static char *reg(paren, flagp)
-int paren; /* Parenthesized? */
-int *flagp;
-{
- register char *ret;
- register char *br;
- register char *ender;
- register int parno=0; /* make gcc happy */
- int flags;
-
- *flagp = HASWIDTH; /* Tentatively. */
-
- /* Make an OPEN node, if parenthesized. */
- if (paren) {
- if (regnpar >= NSUBEXP)
- FAIL("too many ()");
- parno = regnpar;
- regnpar++;
- ret = regnode(OPEN + parno);
- } else
- ret = (char *)NULL;
-
- /* Pick up the branches, linking them together. */
- br = regbranch(&flags);
- if (br == (char *)NULL)
- return ((char *)NULL);
- if (ret != (char *)NULL)
- regtail(ret, br); /* OPEN -> first. */
- else
- ret = br;
- if (!(flags & HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags & SPSTART;
- while (*regparse == OR_OP) {
- regparse++;
- br = regbranch(&flags);
- if (br == (char *)NULL)
- return ((char *)NULL);
- regtail(ret, br); /* BRANCH -> BRANCH. */
- if (!(flags & HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags & SPSTART;
- }
-
- /* Make a closing node, and hook it on the end. */
- ender = regnode((paren) ? CLOSE + parno : END);
- regtail(ret, ender);
-
- /* Hook the tails of the branches to the closing node. */
- for (br = ret; br != (char *)NULL; br = regnext(br))
- regoptail(br, ender);
-
- /* Check for proper termination. */
- if (paren && *regparse++ != RBRAC) {
- FAIL("unmatched ()");
- } else if (!paren && *regparse != '\0') {
- if (*regparse == RBRAC) {
- FAIL("unmatched ()");
- } else
- FAIL("junk on end");/* "Can't happen". */
- /* NOTREACHED */
- }
- return (ret);
-}
-
-/*
- - regbranch - one alternative of an | operator
- *
- * Implements the concatenation operator.
- */
-static char *regbranch(flagp)
-int *flagp;
-{
- register char *ret;
- register char *chain;
- register char *latest;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- ret = regnode(BRANCH);
- chain = (char *)NULL;
- while (*regparse != '\0' && *regparse != OR_OP && *regparse != RBRAC) {
- latest = regpiece(&flags);
- if (latest == (char *)NULL)
- return ((char *)NULL);
- *flagp |= flags & HASWIDTH;
- if (chain == (char *)NULL) /* First piece. */
- *flagp |= flags & SPSTART;
- else
- regtail(chain, latest);
- chain = latest;
- }
- if (chain == (char *)NULL) /* Loop ran zero times. */
- regnode(NOTHING);
-
- return (ret);
-}
-
-/*
- - regpiece - something followed by possible [*]
- *
- * Note that the branching code sequence used for * is somewhat optimized:
- * they use the same NOTHING node as both the endmarker for their branch
- * list and the body of the last branch. It might seem that this node could
- * be dispensed with entirely, but the endmarker role is not redundant.
- */
-static char *regpiece(flagp)
-int *flagp;
-{
- register char *ret;
- register short op;
- /* register char *nxt; */
- int flags;
-
- ret = regatom(&flags);
- if (ret == (char *)NULL)
- return ((char *)NULL);
-
- op = *regparse;
- if (!ISMULT(op)) {
- *flagp = flags;
- return (ret);
- }
- if (!(flags & HASWIDTH))
- FAIL("* or + operand could be empty");
- *flagp = (WORST | SPSTART);
-
- if(op == ASTERIX)
- {
- if (flags & SIMPLE)
- {
- reginsert(STAR, ret);
- }
- else
- {
- /* Emit x* as (x&|), where & means "self". */
- reginsert(BRANCH, ret); /* Either x */
- regoptail(ret, regnode(BACK)); /* and loop */
- regoptail(ret, ret); /* back */
- regtail(ret, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- }
- }
- else if(op == PLUS)
- {
- /* Emit a+ as (a&) where & means "self" /Fredrik Hubinette */
- char *tmp;
- tmp=regnode(BACK);
- reginsert(BRANCH, tmp);
- regtail(ret, tmp);
- regoptail(tmp, ret);
- regtail(ret, regnode(BRANCH));
- regtail(ret, regnode(NOTHING));
- }
-
- regparse++;
- if (ISMULT(*regparse))
- FAIL("nested * or +");
-
- return (ret);
-}
-
-
-/*
- - regatom - the lowest level
- *
- * Optimization: gobbles an entire sequence of ordinary characters so that
- * it can turn them into a single node, which is smaller to store and
- * faster to run.
- */
-static char *regatom(flagp)
-int *flagp;
-{
- register char *ret;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- switch (*regparse++) {
- case CARET:
- ret = regnode(BOL);
- break;
- case DOLLAR:
- ret = regnode(EOL);
- break;
- case DOT:
- ret = regnode(ANY);
- *flagp |= HASWIDTH | SIMPLE;
- break;
- case LSHBRAC:
- ret = regnode(WORDSTART);
- break;
- case RSHBRAC:
- ret = regnode(WORDEND);
- break;
- case LSQBRAC:{
- register int class;
- register int classend;
-
- if (*regparse == CARET) { /* Complement of range. */
- ret = regnode(ANYBUT);
- regparse++;
- } else
- ret = regnode(ANYOF);
- if (*regparse == RSQBRAC || *regparse == '-')
- regc(*regparse++);
- while (*regparse != '\0' && *regparse != RSQBRAC) {
- if (*regparse == '-') {
- regparse++;
- if (*regparse == RSQBRAC || *regparse == '\0')
- regc('-');
- else {
- class = (CHARBITS & *(regparse - 2)) + 1;
- classend = (CHARBITS & *(regparse));
- if (class > classend + 1)
- FAIL("invalid [] range");
- for (; class <= classend; class++)
- regc(class);
- regparse++;
- }
- } else
- regc(*regparse++);
- }
- regc('\0');
- if (*regparse != RSQBRAC)
- FAIL("unmatched []");
- regparse++;
- *flagp |= HASWIDTH | SIMPLE;
- }
- break;
- case LBRAC:
- ret = reg(1, &flags);
- if (ret == (char *)NULL)
- return ((char *)NULL);
- *flagp |= flags & (HASWIDTH | SPSTART);
- break;
- case '\0':
- case OR_OP:
- case RBRAC:
- FAIL("internal urp"); /* Supposed to be caught earlier. */
-
- case ASTERIX:
- FAIL("* follows nothing\n");
-
- default:{
- register int len;
- register short ender;
-
- regparse--;
- for (len=0; regparse[len] &&
- !(regparse[len]&SPECIAL) && regparse[len] != RSQBRAC; len++) ;
- if (len <= 0)
- {
- FAIL("internal disaster");
- }
- ender = *(regparse + len);
- if (len > 1 && ISMULT(ender))
- len--; /* Back off clear of * operand. */
- *flagp |= HASWIDTH;
- if (len == 1)
- *flagp |= SIMPLE;
- ret = regnode(EXACTLY);
- while (len > 0) {
- regc(*regparse++);
- len--;
- }
- regc('\0');
- }
- break;
- }
-
- return (ret);
-}
-
-/*
- - regnode - emit a node
- */
-static char *regnode(op)
-char op;
-{
- register char *ret;
- register char *ptr;
-
- ret = regcode;
- if (ret == ®dummy) {
- regsize += 3;
- return (ret);
- }
- ptr = ret;
- *ptr++ = op;
- *ptr++ = '\0'; /* Null "nxt" pointer. */
- *ptr++ = '\0';
- regcode = ptr;
-
- return (ret);
-}
-
-/*
- - regc - emit (if appropriate) a byte of code
- */
-static void regc(b)
-char b;
-{
- if (regcode != ®dummy)
- *regcode++ = b;
- else
- regsize++;
-}
-
-/*
- - reginsert - insert an operator in front of already-emitted operand
- *
- * Means relocating the operand.
- */
-static void reginsert(op, opnd)
-char op;
-char *opnd;
-{
- register char *src;
- register char *dst;
- register char *place;
-
- if (regcode == ®dummy) {
- regsize += 3;
- return;
- }
- src = regcode;
- regcode += 3;
- dst = regcode;
- while (src > opnd)
- *--dst = *--src;
-
- place = opnd; /* Op node, where operand used to be. */
- *place++ = op;
- *place++ = '\0';
- *place++ = '\0';
-}
-
-/*
- - regtail - set the next-pointer at the end of a node chain
- */
-static void regtail(p, val)
-char *p;
-char *val;
-{
- register char *scan;
- register char *temp;
- register int offset;
-
- if (p == ®dummy)
- return;
-
- /* Find last node. */
- scan = p;
- for (;;) {
- temp = regnext(scan);
- if (temp == (char *)NULL)
- break;
- scan = temp;
- }
-
- if (OP(scan) == BACK)
- offset = scan - val;
- else
- offset = val - scan;
- *(scan + 1) = (offset >> 8) & 0377;
- *(scan + 2) = offset & 0377;
-}
-
-/*
- - regoptail - regtail on operand of first argument; nop if operandless
- */
-static void regoptail(p, val)
-char *p;
-char *val;
-{
- /* "Operandless" and "op != BRANCH" are synonymous in practice. */
- if (p == (char *)NULL || p == ®dummy || OP(p) != BRANCH)
- return;
- regtail(OPERAND(p), val);
-}
-
-/*
- * regexec and friends
- */
-
-/*
- * Global work variables for regexec().
- */
-static char *reginput; /* String-input pointer. */
-static char *regbol; /* Beginning of input, for ^ check. */
-static char **regstartp; /* Pointer to startp array. */
-static char **regendp; /* Ditto for endp. */
-
-/*
- * Forwards.
- */
-STATIC int regtry();
-STATIC int regmatch();
-STATIC int regrepeat();
-
-#ifdef DEBUG
-int regnarrate = 0;
-void regdump();
-STATIC char *regprop();
-#endif
-
-/*
- - regexec - match a regexp against a string
- */
-int regexec(prog, string)
-register regexp *prog;
-register char *string;
-{
- register char *s;
-
- /* Be paranoid... */
- if (prog == (regexp *)NULL || string == (char *)NULL) {
- regerror("NULL parameter");
- return (0);
- }
- /* Check validity of program. */
- if (UCHARAT(prog->program) != MAGIC) {
- regerror("corrupted program");
- return (0);
- }
- /* If there is a "must appear" string, look for it. */
- if (prog->regmust != (char *)NULL) {
- s = string;
- while ((s = STRCHR(s, prog->regmust[0])) != (char *)NULL) {
- if (strncmp(s, prog->regmust, prog->regmlen) == 0)
- break; /* Found it. */
- s++;
- }
- if (s == (char *)NULL) /* Not present. */
- return (0);
- }
- /* Mark beginning of line for ^ . */
- regbol = string;
-
- /* Simplest case: anchored match need be tried only once. */
- if (prog->reganch)
- return (regtry(prog, string));
-
- /* Messy cases: unanchored match. */
- s = string;
- if (prog->regstart != '\0')
- /* We know what char it must start with. */
- while ((s = STRCHR(s, prog->regstart)) != (char *)NULL) {
- if (regtry(prog, s))
- return (1);
- s++;
- }
- else
- /* We don't -- general case. */
- do {
- if (regtry(prog, s))
- return (1);
- } while (*s++ != '\0');
-
- /* Failure. */
- return (0);
-}
-
-/*
- - regtry - try match at specific point
- */
-
-static int regtry(regexp *prog, char *string)
-{
- register int i;
- register char **sp;
- register char **ep;
-
- reginput = string;
- regstartp = prog->startp;
- regendp = prog->endp;
-
- sp = prog->startp;
- ep = prog->endp;
- for (i = NSUBEXP; i > 0; i--) {
- *sp++ = (char *)NULL;
- *ep++ = (char *)NULL;
- }
- if (regmatch(prog->program + 1)) {
- prog->startp[0] = string;
- prog->endp[0] = reginput;
- return (1);
- } else
- return (0);
-}
-
-/*
- - regmatch - main matching routine
- *
- * Conceptually the strategy is simple: check to see whether the current
- * node matches, call self recursively to see whether the rest matches,
- * and then act accordingly. In practice we make some effort to avoid
- * recursion, in particular by going through "ordinary" nodes (that don't
- * need to know whether the rest of the match failed) by a loop instead of
- * by recursion.
- */
-
-static int regmatch(char *prog)
-{
- register char *scan; /* Current node. */
- char *nxt; /* nxt node. */
-
- scan = prog;
-#ifdef DEBUG
- if (scan != (char *)NULL && regnarrate)
- fprintf(stderr, "%s(\n", regprop(scan));
-#endif
- while (scan != (char *)NULL) {
-#ifdef DEBUG
- if (regnarrate)
- fprintf(stderr, "%s...\n", regprop(scan));
-#endif
- nxt = regnext(scan);
-
- switch (OP(scan)) {
- case BOL:
- if (reginput != regbol)
- return (0);
- break;
- case EOL:
- if (*reginput != '\0')
- return (0);
- break;
- case ANY:
- if (*reginput == '\0')
- return (0);
- reginput++;
- break;
- case WORDSTART:
- if (reginput == regbol)
- break;
- if (*reginput == '\0' ||
- ISWORDPART( *(reginput-1) ) || !ISWORDPART( *reginput ) )
- return (0);
- break;
- case WORDEND:
- if (*reginput == '\0')
- break;
- if ( reginput == regbol ||
- !ISWORDPART( *(reginput-1) ) || ISWORDPART( *reginput ) )
- return (0);
- break;
- case EXACTLY:{
- register int len;
- register char *opnd;
-
- opnd = OPERAND(scan);
- /* Inline the first character, for speed. */
- if (*opnd != *reginput)
- return (0);
- len = strlen(opnd);
- if (len > 1 && strncmp(opnd, reginput, len) != 0)
- return (0);
- reginput += len;
- }
- break;
- case ANYOF:
- if (*reginput == '\0' ||
- STRCHR(OPERAND(scan), *reginput) == (char *)NULL)
- return (0);
- reginput++;
- break;
- case ANYBUT:
- if (*reginput == '\0' ||
- STRCHR(OPERAND(scan), *reginput) != (char *)NULL)
- return (0);
- reginput++;
- break;
- case NOTHING:
- break;
- case BACK:
- break;
- case OPEN + 1:
- case OPEN + 2:
- case OPEN + 3:
- case OPEN + 4:
- case OPEN + 5:
- case OPEN + 6:
- case OPEN + 7:
- case OPEN + 8:
- case OPEN + 9:{
- register int no;
- register char *save;
-
- no = OP(scan) - OPEN;
- save = reginput;
-
- if (regmatch(nxt)) {
- /*
- * Don't set startp if some later invocation of the same
- * parentheses already has.
- */
- if (regstartp[no] == (char *)NULL)
- regstartp[no] = save;
- return (1);
- } else
- return (0);
- }
-
- case CLOSE + 1:
- case CLOSE + 2:
- case CLOSE + 3:
- case CLOSE + 4:
- case CLOSE + 5:
- case CLOSE + 6:
- case CLOSE + 7:
- case CLOSE + 8:
- case CLOSE + 9:{
- register int no;
- register char *save;
-
- no = OP(scan) - CLOSE;
- save = reginput;
-
- if (regmatch(nxt)) {
- /*
- * Don't set endp if some later invocation of the same
- * parentheses already has.
- */
- if (regendp[no] == (char *)NULL)
- regendp[no] = save;
- return (1);
- } else
- return (0);
- }
-
- case BRANCH:{
- register char *save;
-
- if (OP(nxt) != BRANCH) /* No choice. */
- nxt = OPERAND(scan); /* Avoid recursion. */
- else {
- do {
- save = reginput;
- if (regmatch(OPERAND(scan)))
- return (1);
- reginput = save;
- scan = regnext(scan);
- } while (scan != (char *)NULL && OP(scan) == BRANCH);
- return (0);
- /* NOTREACHED */
- }
- }
- break;
- case STAR:{
- register char nextch;
- register int no;
- register char *save;
- register int minimum;
-
- /*
- * Lookahead to avoid useless match attempts when we know
- * what character comes next.
- */
- nextch = '\0';
- if (OP(nxt) == EXACTLY)
- nextch = *OPERAND(nxt);
- minimum = (OP(scan) == STAR) ? 0 : 1;
- save = reginput;
- no = regrepeat(OPERAND(scan));
- while (no >= minimum) {
- /* If it could work, try it. */
- if (nextch == '\0' || *reginput == nextch)
- if (regmatch(nxt))
- return (1);
- /* Couldn't or didn't -- back up. */
- no--;
- reginput = save + no;
- }
- return (0);
- }
-
- case END:
- return (1); /* Success! */
-
- default:
- regerror("memory corruption");
- return (0);
-
- }
-
- scan = nxt;
- }
-
- /*
- * We get here only if there's trouble -- normally "case END" is the
- * terminating point.
- */
- regerror("corrupted pointers");
- return (0);
-}
-
-/*
- - regrepeat - repeatedly match something simple, report how many
- */
-
-static int regrepeat(char *p)
-{
- register int count = 0;
- register char *scan;
- register char *opnd;
-
- scan = reginput;
- opnd = OPERAND(p);
- switch (OP(p)) {
- case ANY:
- count = strlen(scan);
- scan += count;
- break;
- case EXACTLY:
- while (*opnd == *scan) {
- count++;
- scan++;
- }
- break;
- case ANYOF:
- while (*scan != '\0' && STRCHR(opnd, *scan) != (char *)NULL) {
- count++;
- scan++;
- }
- break;
- case ANYBUT:
- while (*scan != '\0' && STRCHR(opnd, *scan) == (char *)NULL) {
- count++;
- scan++;
- }
- break;
- default: /* Oh dear. Called inappropriately. */
- regerror("internal foulup");
- count = 0; /* Best compromise. */
- break;
- }
- reginput = scan;
-
- return (count);
-}
-
-
-/*
- - regnext - dig the "nxt" pointer out of a node
- */
-
-static char *regnext(register char *p)
-{
- register int offset;
-
- if (p == ®dummy)
- return ((char *)NULL);
-
- offset = NEXT(p);
- if (offset == 0)
- return ((char *)NULL);
-
- if (OP(p) == BACK)
- return (p - offset);
- else
- return (p + offset);
-}
-
-#ifdef DEBUG
-
-STATIC char *regprop();
-
-/*
- - regdump - dump a regexp onto stdout in vaguely comprehensible form
- */
-void regdump(regexp *r)
-{
- register char *s;
- register char op = EXACTLY; /* Arbitrary non-END op. */
- register char *nxt;
-
- s = r->program + 1;
- while (op != END) { /* While that wasn't END last time... */
- op = OP(s);
- printf("%2ld%s", (long)(s - r->program), regprop(s)); /* Where, what. */
- nxt = regnext(s);
- if (nxt == (char *)NULL) /* nxt ptr. */
- printf("(0)");
- else
- printf("(%ld)", (long)( (s - r->program) + (nxt - s)));
- s += 3;
- if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
- /* Literal string, where present. */
- while (*s != '\0') {
- putchar(*s);
- s++;
- }
- s++;
- }
- putchar('\n');
- }
-
- /* Header fields of interest. */
- if (r->regstart != '\0')
- printf("start `%c' ", r->regstart);
- if (r->reganch)
- printf("anchored ");
- if (r->regmust != (char *)NULL)
- printf("must have \"%s\"", r->regmust);
- printf("\n");
-}
-
-/*
- - regprop - printable representation of opcode
- */
-
-static char *regprop(char *op)
-{
- register char *p;
- static char buf[50];
-
- strcpy(buf, ":");
-
- switch (OP(op)) {
- case BOL:
- p = "BOL";
- break;
- case EOL:
- p = "EOL";
- break;
- case ANY:
- p = "ANY";
- break;
- case ANYOF:
- p = "ANYOF";
- break;
- case ANYBUT:
- p = "ANYBUT";
- break;
- case BRANCH:
- p = "BRANCH";
- break;
- case EXACTLY:
- p = "EXACTLY";
- break;
- case NOTHING:
- p = "NOTHING";
- break;
- case BACK:
- p = "BACK";
- break;
- case END:
- p = "END";
- break;
- case OPEN + 1:
- case OPEN + 2:
- case OPEN + 3:
- case OPEN + 4:
- case OPEN + 5:
- case OPEN + 6:
- case OPEN + 7:
- case OPEN + 8:
- case OPEN + 9:
- sprintf(buf + strlen(buf), "OPEN%d", OP(op) - OPEN);
- p = (char *)NULL;
- break;
- case CLOSE + 1:
- case CLOSE + 2:
- case CLOSE + 3:
- case CLOSE + 4:
- case CLOSE + 5:
- case CLOSE + 6:
- case CLOSE + 7:
- case CLOSE + 8:
- case CLOSE + 9:
- sprintf(buf + strlen(buf), "CLOSE%d", OP(op) - CLOSE);
- p = (char *)NULL;
- break;
- case STAR:
- p = "STAR";
- break;
- default:
- regerror("corrupted opcode");
- p=(char *)NULL;
- break;
- }
- if (p != (char *)NULL)
- strcat(buf, p);
- return (buf);
-}
-#endif
-
-/*
- - regsub - perform substitutions after a regexp match
- */
-
-char *regsub(regexp *prog, char *source, char *dest, int n)
-{
- register char *src;
- register char *dst;
- register char c;
- register int no;
- register int len;
- extern char *strncpy();
-
- if (prog == (regexp *)NULL ||
- source == (char *)NULL || dest == (char *)NULL) {
- regerror("NULL parm to regsub");
- return NULL;
- }
- if (UCHARAT(prog->program) != MAGIC) {
- regerror("damaged regexp fed to regsub");
- return NULL;
- }
- src = source;
- dst = dest;
- while ((c = *src++) != '\0') {
- if (c == '&')
- no = 0;
- else if (c == '\\' && '0' <= *src && *src <= '9')
- no = *src++ - '0';
- else
- no = -1;
-
- if (no < 0) { /* Ordinary character. */
- if (c == '\\' && (*src == '\\' || *src == '&'))
- c = *src++;
- if (--n < 0) { /* amylaar */
- regerror("line too long");
- return NULL;
- }
- *dst++ = c;
- } else if (prog->startp[no] != (char *)NULL &&
- prog->endp[no] != (char *)NULL) {
- len = prog->endp[no] - prog->startp[no];
- if ( (n-=len) < 0 ) { /* amylaar */
- regerror("line too long");
- return NULL;
- }
- strncpy(dst, prog->startp[no], len);
- dst += len;
- if (len != 0 && *(dst - 1) == '\0') { /* strncpy hit NUL. */
- regerror("damaged match string");
- return NULL;
- }
- }
- }
- if (--n < 0) { /* amylaar */
- regerror("line too long");
- return NULL;
- }
- *dst = '\0';
- return dst;
-}
-
-
-#if 0 /* Use the local regerror() in ed.c */
-
-void regerror(char *s)
-{
- fprintf(stderr, "regexp(3): %s", s);
- exit(1);
-}
-#endif /* 0 */
diff --git a/externals/mysql/extlib/regex/regfree.c b/externals/mysql/extlib/regex/regfree.c
deleted file mode 100644
index f764fcdf84..0000000000
--- a/externals/mysql/extlib/regex/regfree.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include
-#include
-#include
-#include
-#include "my_regex.h"
-
-#include "utils.h"
-#include "regex2.h"
-
-/*
- - regfree - free everything
- = extern void regfree(regex_t *);
- */
-void
-my_regfree(preg)
-my_regex_t *preg;
-{
- register struct re_guts *g;
-
- if (preg->re_magic != MAGIC1) /* oops */
- return; /* nice to complain, but hard */
-
- g = preg->re_g;
- if (g == NULL || g->magic != MAGIC2) /* oops again */
- return;
- preg->re_magic = 0; /* mark it invalid */
- g->magic = 0; /* mark it invalid */
-
- if (g->strip != NULL)
- free((char *)g->strip);
- if (g->sets != NULL)
- free((char *)g->sets);
- if (g->setbits != NULL)
- free((char *)g->setbits);
- if (g->must != NULL)
- free(g->must);
- free((char *)g);
-}
diff --git a/externals/mysql/extlib/regex/reginit.c b/externals/mysql/extlib/regex/reginit.c
deleted file mode 100644
index 5980de2403..0000000000
--- a/externals/mysql/extlib/regex/reginit.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Init cclasses array from ctypes */
-
-#include
-#include
-#include
-#include "cclass.h"
-
-static my_bool regex_inited=0;
-
-void my_regex_init(CHARSET_INFO *cs)
-{
- char buff[CCLASS_LAST][256];
- int count[CCLASS_LAST];
- uint i;
-
- if (!regex_inited)
- {
- regex_inited=1;
- bzero((uchar*) &count,sizeof(count));
-
- for (i=1 ; i<= 255; i++)
- {
- if (my_isalnum(cs,i))
- buff[CCLASS_ALNUM][count[CCLASS_ALNUM]++]=(char) i;
- if (my_isalpha(cs,i))
- buff[CCLASS_ALPHA][count[CCLASS_ALPHA]++]=(char) i;
- if (my_iscntrl(cs,i))
- buff[CCLASS_CNTRL][count[CCLASS_CNTRL]++]=(char) i;
- if (my_isdigit(cs,i))
- buff[CCLASS_DIGIT][count[CCLASS_DIGIT]++]=(char) i;
- if (my_isgraph(cs,i))
- buff[CCLASS_GRAPH][count[CCLASS_GRAPH]++]=(char) i;
- if (my_islower(cs,i))
- buff[CCLASS_LOWER][count[CCLASS_LOWER]++]=(char) i;
- if (my_isprint(cs,i))
- buff[CCLASS_PRINT][count[CCLASS_PRINT]++]=(char) i;
- if (my_ispunct(cs,i))
- buff[CCLASS_PUNCT][count[CCLASS_PUNCT]++]=(char) i;
- if (my_isspace(cs,i))
- buff[CCLASS_SPACE][count[CCLASS_SPACE]++]=(char) i;
- if (my_isupper(cs,i))
- buff[CCLASS_UPPER][count[CCLASS_UPPER]++]=(char) i;
- if (my_isxdigit(cs,i))
- buff[CCLASS_XDIGIT][count[CCLASS_XDIGIT]++]=(char) i;
- }
- buff[CCLASS_BLANK][0]=' ';
- buff[CCLASS_BLANK][1]='\t';
- count[CCLASS_BLANK]=2;
- for (i=0; i < CCLASS_LAST ; i++)
- {
- char *tmp=(char*) malloc(count[i]+1);
- if (!tmp)
- {
- /*
- This is very unlikely to happen as this function is called once
- at program startup
- */
- fprintf(stderr,
- "Fatal error: Can't allocate memory in regex_init\n");
- exit(1);
- }
- memcpy(tmp,buff[i],count[i]*sizeof(char));
- tmp[count[i]]=0;
- cclasses[i].chars=tmp;
- }
- }
- return;
-}
-
-void my_regex_end()
-{
- if (regex_inited)
- {
- int i;
- for (i=0; i < CCLASS_LAST ; i++)
- free((char*) cclasses[i].chars);
- regex_inited=0;
- }
-}
-
-
diff --git a/externals/mysql/extlib/regex/split.c b/externals/mysql/extlib/regex/split.c
deleted file mode 100644
index bd2a53c01e..0000000000
--- a/externals/mysql/extlib/regex/split.c
+++ /dev/null
@@ -1,316 +0,0 @@
-#include
-#include
-
-/*
- - split - divide a string into fields, like awk split()
- = int split(char *string, char *fields[], int nfields, char *sep);
- */
-int /* number of fields, including overflow */
-split(string, fields, nfields, sep)
-char *string;
-char *fields[]; /* list is not NULL-terminated */
-int nfields; /* number of entries available in fields[] */
-char *sep; /* "" white, "c" single char, "ab" [ab]+ */
-{
- register char *p = string;
- register char c; /* latest character */
- register char sepc = sep[0];
- register char sepc2;
- register int fn;
- register char **fp = fields;
- register char *sepp;
- register int trimtrail;
-
- /* white space */
- if (sepc == '\0') {
- while ((c = *p++) == ' ' || c == '\t')
- continue;
- p--;
- trimtrail = 1;
- sep = (char*) " \t"; /* note, code below knows this is 2 long */
- sepc = ' ';
- } else
- trimtrail = 0;
- sepc2 = sep[1]; /* now we can safely pick this up */
-
- /* catch empties */
- if (*p == '\0')
- return(0);
-
- /* single separator */
- if (sepc2 == '\0') {
- fn = nfields;
- for (;;) {
- *fp++ = p;
- fn--;
- if (fn == 0)
- break;
- while ((c = *p++) != sepc)
- if (c == '\0')
- return(nfields - fn);
- *(p-1) = '\0';
- }
- /* we have overflowed the fields vector -- just count them */
- fn = nfields;
- for (;;) {
- while ((c = *p++) != sepc)
- if (c == '\0')
- return(fn);
- fn++;
- }
- /* not reached */
- }
-
- /* two separators */
- if (sep[2] == '\0') {
- fn = nfields;
- for (;;) {
- *fp++ = p;
- fn--;
- while ((c = *p++) != sepc && c != sepc2)
- if (c == '\0') {
- if (trimtrail && **(fp-1) == '\0')
- fn++;
- return(nfields - fn);
- }
- if (fn == 0)
- break;
- *(p-1) = '\0';
- while ((c = *p++) == sepc || c == sepc2)
- continue;
- p--;
- }
- /* we have overflowed the fields vector -- just count them */
- fn = nfields;
- while (c != '\0') {
- while ((c = *p++) == sepc || c == sepc2)
- continue;
- p--;
- fn++;
- while ((c = *p++) != '\0' && c != sepc && c != sepc2)
- continue;
- }
- /* might have to trim trailing white space */
- if (trimtrail) {
- p--;
- while ((c = *--p) == sepc || c == sepc2)
- continue;
- p++;
- if (*p != '\0') {
- if (fn == nfields+1)
- *p = '\0';
- fn--;
- }
- }
- return(fn);
- }
-
- /* n separators */
- fn = 0;
- for (;;) {
- if (fn < nfields)
- *fp++ = p;
- fn++;
- for (;;) {
- c = *p++;
- if (c == '\0')
- return(fn);
- sepp = sep;
- while ((sepc = *sepp++) != '\0' && sepc != c)
- continue;
- if (sepc != '\0') /* it was a separator */
- break;
- }
- if (fn < nfields)
- *(p-1) = '\0';
- for (;;) {
- c = *p++;
- sepp = sep;
- while ((sepc = *sepp++) != '\0' && sepc != c)
- continue;
- if (sepc == '\0') /* it wasn't a separator */
- break;
- }
- p--;
- }
-
- /* not reached */
-}
-
-#ifdef TEST_SPLIT
-
-
-/*
- * test program
- * pgm runs regression
- * pgm sep splits stdin lines by sep
- * pgm str sep splits str by sep
- * pgm str sep n splits str by sep n times
- */
-int
-main(argc, argv)
-int argc;
-char *argv[];
-{
- char buf[512];
- register int n;
-# define MNF 10
- char *fields[MNF];
-
- if (argc > 4)
- for (n = atoi(argv[3]); n > 0; n--) {
- (void) strcpy(buf, argv[1]);
- }
- else if (argc > 3)
- for (n = atoi(argv[3]); n > 0; n--) {
- (void) strcpy(buf, argv[1]);
- (void) split(buf, fields, MNF, argv[2]);
- }
- else if (argc > 2)
- dosplit(argv[1], argv[2]);
- else if (argc > 1)
- while (fgets(buf, sizeof(buf), stdin) != NULL) {
- buf[strlen(buf)-1] = '\0'; /* stomp newline */
- dosplit(buf, argv[1]);
- }
- else
- regress();
-
- exit(0);
-}
-
-dosplit(string, seps)
-char *string;
-char *seps;
-{
-# define NF 5
- char *fields[NF];
- register int nf;
-
- nf = split(string, fields, NF, seps);
- print(nf, NF, fields);
-}
-
-print(nf, nfp, fields)
-int nf;
-int nfp;
-char *fields[];
-{
- register int fn;
- register int bound;
-
- bound = (nf > nfp) ? nfp : nf;
- printf("%d:\t", nf);
- for (fn = 0; fn < bound; fn++)
- printf("\"%s\"%s", fields[fn], (fn+1 < nf) ? ", " : "\n");
-}
-
-#define RNF 5 /* some table entries know this */
-struct {
- char *str;
- char *seps;
- int nf;
- char *fi[RNF];
-} tests[] = {
- "", " ", 0, { "" },
- " ", " ", 2, { "", "" },
- "x", " ", 1, { "x" },
- "xy", " ", 1, { "xy" },
- "x y", " ", 2, { "x", "y" },
- "abc def g ", " ", 5, { "abc", "def", "", "g", "" },
- " a bcd", " ", 4, { "", "", "a", "bcd" },
- "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
- " a b c d ", " ", 6, { "", "a", "b", "c", "d " },
-
- "", " _", 0, { "" },
- " ", " _", 2, { "", "" },
- "x", " _", 1, { "x" },
- "x y", " _", 2, { "x", "y" },
- "ab _ cd", " _", 2, { "ab", "cd" },
- " a_b c ", " _", 5, { "", "a", "b", "c", "" },
- "a b c_d e f", " _", 6, { "a", "b", "c", "d", "e f" },
- " a b c d ", " _", 6, { "", "a", "b", "c", "d " },
-
- "", " _~", 0, { "" },
- " ", " _~", 2, { "", "" },
- "x", " _~", 1, { "x" },
- "x y", " _~", 2, { "x", "y" },
- "ab _~ cd", " _~", 2, { "ab", "cd" },
- " a_b c~", " _~", 5, { "", "a", "b", "c", "" },
- "a b_c d~e f", " _~", 6, { "a", "b", "c", "d", "e f" },
- "~a b c d ", " _~", 6, { "", "a", "b", "c", "d " },
-
- "", " _~-", 0, { "" },
- " ", " _~-", 2, { "", "" },
- "x", " _~-", 1, { "x" },
- "x y", " _~-", 2, { "x", "y" },
- "ab _~- cd", " _~-", 2, { "ab", "cd" },
- " a_b c~", " _~-", 5, { "", "a", "b", "c", "" },
- "a b_c-d~e f", " _~-", 6, { "a", "b", "c", "d", "e f" },
- "~a-b c d ", " _~-", 6, { "", "a", "b", "c", "d " },
-
- "", " ", 0, { "" },
- " ", " ", 2, { "", "" },
- "x", " ", 1, { "x" },
- "xy", " ", 1, { "xy" },
- "x y", " ", 2, { "x", "y" },
- "abc def g ", " ", 4, { "abc", "def", "g", "" },
- " a bcd", " ", 3, { "", "a", "bcd" },
- "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
- " a b c d ", " ", 6, { "", "a", "b", "c", "d " },
-
- "", "", 0, { "" },
- " ", "", 0, { "" },
- "x", "", 1, { "x" },
- "xy", "", 1, { "xy" },
- "x y", "", 2, { "x", "y" },
- "abc def g ", "", 3, { "abc", "def", "g" },
- "\t a bcd", "", 2, { "a", "bcd" },
- " a \tb\t c ", "", 3, { "a", "b", "c" },
- "a b c d e ", "", 5, { "a", "b", "c", "d", "e" },
- "a b\tc d e f", "", 6, { "a", "b", "c", "d", "e f" },
- " a b c d e f ", "", 6, { "a", "b", "c", "d", "e f " },
-
- NULL, NULL, 0, { NULL },
-};
-
-regress()
-{
- char buf[512];
- register int n;
- char *fields[RNF+1];
- register int nf;
- register int i;
- register int printit;
- register char *f;
-
- for (n = 0; tests[n].str != NULL; n++) {
- (void) strcpy(buf, tests[n].str);
- fields[RNF] = NULL;
- nf = split(buf, fields, RNF, tests[n].seps);
- printit = 0;
- if (nf != tests[n].nf) {
- printf("split `%s' by `%s' gave %d fields, not %d\n",
- tests[n].str, tests[n].seps, nf, tests[n].nf);
- printit = 1;
- } else if (fields[RNF] != NULL) {
- printf("split() went beyond array end\n");
- printit = 1;
- } else {
- for (i = 0; i < nf && i < RNF; i++) {
- f = fields[i];
- if (f == NULL)
- f = "(NULL)";
- if (strcmp(f, tests[n].fi[i]) != 0) {
- printf("split `%s' by `%s', field %d is `%s', not `%s'\n",
- tests[n].str, tests[n].seps,
- i, fields[i], tests[n].fi[i]);
- printit = 1;
- }
- }
- }
- if (printit)
- print(nf, RNF, fields);
- }
-}
-#endif
diff --git a/externals/mysql/extlib/regex/utils.h b/externals/mysql/extlib/regex/utils.h
deleted file mode 100644
index 8f85b705bb..0000000000
--- a/externals/mysql/extlib/regex/utils.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* utility definitions */
-#ifdef _POSIX2_RE_DUP_MAX
-#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */
-#else
-#define DUPMAX 255
-#endif
-#define RE_INFINITY (DUPMAX + 1)
-#define NC (CHAR_MAX - CHAR_MIN + 1)
-typedef unsigned char uch;
-
-/* switch off assertions (if not already off) if no REDEBUG */
-#ifndef REDEBUG
-#ifndef NDEBUG
-#define NDEBUG /* no assertions please */
-#endif
-#endif
-#include
-
-/* for old systems with bcopy() but no memmove() */
-#ifdef USEBCOPY
-#define memmove(d, s, c) bcopy(s, d, c)
-#endif
diff --git a/externals/mysql/extlib/yassl/include/buffer.hpp b/externals/mysql/extlib/yassl/include/buffer.hpp
deleted file mode 100644
index a51bca9a63..0000000000
--- a/externals/mysql/extlib/yassl/include/buffer.hpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* yaSSL buffer header defines input and output buffers to simulate streaming
- * with SSL types and sockets
- */
-
-#ifndef yaSSL_BUFFER_HPP
-#define yaSSL_BUFFER_HPP
-
-#include // assert
-#include "yassl_types.hpp" // ysDelete
-#include "memory.hpp" // mySTL::auto_ptr
-#include STL_ALGORITHM_FILE
-
-
-namespace STL = STL_NAMESPACE;
-
-
-#ifdef _MSC_VER
- // disable truncated debug symbols
- #pragma warning(disable:4786)
-#endif
-
-
-namespace yaSSL {
-
-typedef unsigned char byte;
-typedef unsigned int uint;
-const uint AUTO = 0xFEEDBEEF;
-
-
-// Checking Policy should implement a check function that tests whether the
-// index is within the size limit of the array
-struct Check {
- void check(uint i, uint limit);
-};
-
-
-struct NoCheck {
- void check(uint, uint);
-};
-
-/* input_buffer operates like a smart c style array with a checking option,
- * meant to be read from through [] with AUTO index or read().
- * Should only write to at/near construction with assign() or raw (e.g., recv)
- * followed by add_size with the number of elements added by raw write.
- *
- * Not using vector because need checked []access, offset, and the ability to
- * write to the buffer bulk wise and have the correct size
- */
-
-class input_buffer : public Check {
- uint size_; // number of elements in buffer
- uint current_; // current offset position in buffer
- byte* buffer_; // storage for buffer
- byte* end_; // end of storage marker
-public:
- input_buffer();
-
- explicit input_buffer(uint s);
-
- // with assign
- input_buffer(uint s, const byte* t, uint len);
-
- ~input_buffer();
-
- // users can pass defualt zero length buffer and then allocate
- void allocate(uint s);
-
- // for passing to raw writing functions at beginning, then use add_size
- byte* get_buffer() const;
-
- // after a raw write user can set new size
- // if you know the size before the write use assign()
- void add_size(uint i);
-
- uint get_capacity() const;
-
- uint get_current() const;
-
- uint get_size() const;
-
- uint get_remaining() const;
-
- void set_current(uint i);
-
- // read only access through [], advance current
- // user passes in AUTO index for ease of use
- const byte& operator[](uint i);
-
- // end of input test
- bool eof();
-
- // peek ahead
- byte peek() const;
-
- // write function, should use at/near construction
- void assign(const byte* t, uint s);
-
- // use read to query input, adjusts current
- void read(byte* dst, uint length);
-
-private:
- input_buffer(const input_buffer&); // hide copy
- input_buffer& operator=(const input_buffer&); // and assign
-};
-
-
-/* output_buffer operates like a smart c style array with a checking option.
- * Meant to be written to through [] with AUTO index or write().
- * Size (current) counter increases when written to. Can be constructed with
- * zero length buffer but be sure to allocate before first use.
- * Don't use add write for a couple bytes, use [] instead, way less overhead.
- *
- * Not using vector because need checked []access and the ability to
- * write to the buffer bulk wise and retain correct size
- */
-class output_buffer : public Check {
- uint current_; // current offset and elements in buffer
- byte* buffer_; // storage for buffer
- byte* end_; // end of storage marker
-public:
- // default
- output_buffer();
-
- // with allocate
- explicit output_buffer(uint s);
-
- // with assign
- output_buffer(uint s, const byte* t, uint len);
-
- ~output_buffer();
-
- uint get_size() const;
-
- uint get_capacity() const;
-
- void set_current(uint c);
-
- // users can pass defualt zero length buffer and then allocate
- void allocate(uint s);
-
- // for passing to reading functions when finished
- const byte* get_buffer() const;
-
- // allow write access through [], update current
- // user passes in AUTO as index for ease of use
- byte& operator[](uint i);
-
- // end of output test
- bool eof();
-
- void write(const byte* t, uint s);
-
-private:
- output_buffer(const output_buffer&); // hide copy
- output_buffer& operator=(const output_buffer&); // and assign
-};
-
-
-
-
-// turn delete an incomplete type into comipler error instead of warning
-template
-inline void checked_delete(T* p)
-{
- typedef char complete_type[sizeof(T) ? 1 : -1];
- (void)sizeof(complete_type);
- ysDelete(p);
-}
-
-
-// checked delete functor increases effeciency, no indirection on function call
-// sets pointer to zero so safe for std conatiners
-struct del_ptr_zero
-{
- template
- void operator()(T*& p) const
- {
- T* tmp = 0;
- STL::swap(tmp, p);
- checked_delete(tmp);
- }
-};
-
-
-
-} // naemspace
-
-#endif // yaSSL_BUUFER_HPP
diff --git a/externals/mysql/extlib/yassl/include/cert_wrapper.hpp b/externals/mysql/extlib/yassl/include/cert_wrapper.hpp
deleted file mode 100644
index 572b9f8729..0000000000
--- a/externals/mysql/extlib/yassl/include/cert_wrapper.hpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* The certificate wrapper header defines certificate management functions
- *
- */
-
-
-#ifndef yaSSL_CERT_WRAPPER_HPP
-#define yaSSL_CERT_WRAPPER_HPP
-
-#ifdef _MSC_VER
- // disable truncated debug symbols
- #pragma warning(disable:4786)
-#endif
-
-
-#include "yassl_types.hpp" // SignatureAlgorithm
-#include "buffer.hpp" // input_buffer
-#include "asn.hpp" // SignerList
-#include "openssl/ssl.h" // internal and external use
-#include STL_LIST_FILE
-#include STL_ALGORITHM_FILE
-
-
-namespace STL = STL_NAMESPACE;
-
-
-namespace yaSSL {
-
-typedef unsigned char opaque;
-class X509; // forward openSSL type
-
-using TaoCrypt::SignerList;
-
-// an x509 version 3 certificate
-class x509 {
- uint length_;
- opaque* buffer_;
-public:
- explicit x509(uint sz);
- ~x509();
-
- uint get_length() const;
- const opaque* get_buffer() const;
- opaque* use_buffer();
-
- x509(const x509&);
- x509& operator=(const x509&);
-private:
- void Swap(x509&);
-};
-
-
-// Certificate Manager keeps a list of the cert chain and public key
-class CertManager {
- typedef STL::list CertList;
-
- CertList list_; // self
- input_buffer privateKey_;
-
- CertList peerList_; // peer
- input_buffer peerPublicKey_;
- X509* peerX509_; // peer's openSSL X509
-
- SignatureAlgorithm keyType_; // self key type
- SignatureAlgorithm peerKeyType_; // peer's key type
-
- SignerList signers_; // decoded CA keys and names
- // plus verified chained certs
- bool verifyPeer_;
- bool verifyNone_; // no error if verify fails
- bool failNoCert_;
- bool sendVerify_;
- VerifyCallback verifyCallback_; // user verify callback
-public:
- CertManager();
- ~CertManager();
-
- void AddPeerCert(x509* x); // take ownership
- void CopySelfCert(const x509* x);
- int CopyCaCert(const x509* x);
- int Validate();
-
- int SetPrivateKey(const x509&);
-
- const x509* get_cert() const;
- const opaque* get_peerKey() const;
- const opaque* get_privateKey() const;
- X509* get_peerX509() const;
- SignatureAlgorithm get_keyType() const;
- SignatureAlgorithm get_peerKeyType() const;
-
- uint get_peerKeyLength() const;
- uint get_privateKeyLength() const;
-
- bool verifyPeer() const;
- bool verifyNone() const;
- bool failNoCert() const;
- bool sendVerify() const;
-
- void setVerifyPeer();
- void setVerifyNone();
- void setFailNoCert();
- void setSendVerify();
- void setPeerX509(X509*);
- void setVerifyCallback(VerifyCallback);
-private:
- CertManager(const CertManager&); // hide copy
- CertManager& operator=(const CertManager&); // and assign
-};
-
-
-} // naemspace
-
-#endif // yaSSL_CERT_WRAPPER_HPP
diff --git a/externals/mysql/extlib/yassl/include/config.h b/externals/mysql/extlib/yassl/include/config.h
deleted file mode 100644
index adea8dbe8e..0000000000
--- a/externals/mysql/extlib/yassl/include/config.h
+++ /dev/null
@@ -1,295 +0,0 @@
-
-/* Headers we may want to use. */
-/* #undef HAVE_ALLOCA_H */
-/* #undef HAVE_ARPA_INET_H */
-/* #undef HAVE_CRYPT_H */
-/* #undef HAVE_DIRENT_H */
-/* #undef HAVE_EXECINFO_H */
-#define HAVE_FCNTL_H 1
-/* #undef HAVE_FENV_H */
-#define HAVE_FLOAT_H 1
-/* #undef HAVE_FPU_CONTROL_H */
-/* #undef HAVE_GRP_H */
-/* #undef HAVE_IEEEFP_H */
-#define HAVE_LIMITS_H 1
-#define HAVE_MALLOC_H 1
-#define HAVE_MEMORY_H 1
-/* #undef HAVE_NETINET_IN_H */
-/* #undef HAVE_PATHS_H */
-/* #undef HAVE_PWD_H */
-/* #undef HAVE_SCHED_H */
-/* #undef HAVE_SELECT_H */
-#define HAVE_STDDEF_H 1
-#define HAVE_STDLIB_H 1
-/* #undef HAVE_STRINGS_H */
-#define HAVE_STRING_H 1
-/* #undef HAVE_SYNCH_H */
-/* #undef HAVE_SYSENT_H */
-/* #undef HAVE_SYS_FPU_H */
-/* #undef HAVE_SYS_IOCTL_H */
-/* #undef HAVE_SYS_IPC_H */
-/* #undef HAVE_SYS_MMAN_H */
-/* #undef HAVE_SYS_PRCTL_H */
-/* #undef HAVE_SYS_SELECT_H */
-/* #undef HAVE_SYS_SHM_H */
-/* #undef HAVE_SYS_SOCKET_H */
-#define HAVE_SYS_STAT_H 1
-/* #undef HAVE_SYS_STREAM_H */
-#define HAVE_SYS_TIMEB_H 1
-#define HAVE_SYS_TYPES_H 1
-/* #undef HAVE_SYS_UN_H */
-/* #undef HAVE_TERMIOS_H */
-/* #undef HAVE_TERMIO_H */
-/* #undef HAVE_UNISTD_H */
-/* #undef HAVE_UTIME_H */
-
-/* Functions we may want to use. */
-#define HAVE_ACCESS 1
-/* #undef HAVE_AIOWAIT */
-/* #undef HAVE_ALARM */
-/* #undef HAVE_ALLOCA */
-/* #undef HAVE_BCMP */
-/* #undef HAVE_BFILL */
-/* #undef HAVE_BMOVE */
-/* #undef HAVE_BZERO */
-/* #undef HAVE_CLOCK_GETTIME */
-/* #undef HAVE_COMPRESS */
-/* #undef HAVE_CRYPT */
-/* #undef HAVE_DLERROR */
-/* #undef HAVE_DLOPEN */
-/* #undef HAVE_FCHMOD */
-/* #undef HAVE_FCNTL */
-/* #undef HAVE_FCONVERT */
-/* #undef HAVE_FDATASYNC */
-/* #undef HAVE_FESETROUND */
-/* #undef HAVE_FINITE */
-/* #undef HAVE_FP_EXCEPT */
-/* #undef HAVE_FSEEKO */
-/* #undef HAVE_FSYNC */
-/* #undef HAVE_GETADDRINFO */
-#define HAVE_GETCWD 1
-/* #undef HAVE_GETHOSTBYADDR_R */
-/* #undef HAVE_GETHOSTBYNAME_R */
-/* #undef HAVE_GETHRTIME */
-/* #undef HAVE_GETNAMEINFO */
-/* #undef HAVE_GETPAGESIZE */
-/* #undef HAVE_GETPASS */
-/* #undef HAVE_GETPASSPHRASE */
-/* #undef HAVE_GETPWNAM */
-/* #undef HAVE_GETPWUID */
-/* #undef HAVE_GETRLIMIT */
-/* #undef HAVE_GETRUSAGE */
-/* #undef HAVE_GETWD */
-/* #undef HAVE_GMTIME_R */
-/* #undef HAVE_INITGROUPS */
-/* #undef HAVE_ISNAN */
-#define HAVE_LDIV 1
-/* #undef HAVE_LOCALTIME_R */
-/* #undef HAVE_LOG2 */
-#define HAVE_LONGJMP 1
-/* #undef HAVE_LSTAT */
-/* #undef HAVE_MADVISE */
-/* #undef HAVE_DECL_MADVISE */
-/* #undef HAVE_MALLINFO */
-#define HAVE_MEMCPY 1
-#define HAVE_MEMCPY 1
-#define HAVE_MEMMOVE 1
-#define HAVE_MEMMOVE 1
-/* #undef HAVE_MKSTEMP */
-/* #undef HAVE_MLOCK */
-/* #undef HAVE_MLOCKALL */
-/* #undef HAVE_MMAP */
-/* #undef HAVE_MMAP64 */
-#define HAVE_PERROR 1
-/* #undef HAVE_POLL */
-/* #undef HAVE_PREAD */
-/* #undef HAVE_PTHREAD_ATTR_CREATE */
-/* #undef HAVE_PTHREAD_ATTR_GETSTACKSIZE */
-/* #undef HAVE_PTHREAD_ATTR_SETPRIO */
-/* #undef HAVE_PTHREAD_ATTR_SETSCHEDPARAM */
-/* #undef HAVE_PTHREAD_ATTR_SETSCOPE */
-/* #undef HAVE_PTHREAD_ATTR_SETSTACKSIZE */
-/* #undef HAVE_PTHREAD_CONDATTR_CREATE */
-/* #undef HAVE_PTHREAD_INIT */
-/* #undef HAVE_PTHREAD_KEY_DELETE */
-/* #undef HAVE_PTHREAD_KEY_DELETE */
-/* #undef HAVE_PTHREAD_KILL */
-/* #undef HAVE_PTHREAD_RWLOCK_RDLOCK */
-/* #undef HAVE_PTHREAD_SETPRIO_NP */
-/* #undef HAVE_PTHREAD_SETSCHEDPARAM */
-/* #undef HAVE_PTHREAD_SIGMASK */
-/* #undef HAVE_PTHREAD_THREADMASK */
-/* #undef HAVE_PTHREAD_YIELD_NP */
-/* #undef HAVE_READDIR_R */
-/* #undef HAVE_READLINK */
-/* #undef HAVE_REALPATH */
-#define HAVE_RENAME 1
-/* #undef HAVE_RINT */
-/* #undef HAVE_SCHED_YIELD */
-/* #undef HAVE_SELECT */
-/* #undef HAVE_SETFD */
-/* #undef HAVE_SETFILEPOINTER */
-/* #undef HAVE_SIGACTION */
-/* #undef HAVE_SIGTHREADMASK */
-/* #undef HAVE_SIGWAIT */
-/* #undef HAVE_SLEEP */
-/* #undef HAVE_SNPRINTF */
-/* #undef HAVE_STPCPY */
-#define HAVE_STRERROR 1
-/* #undef HAVE_STRLCPY */
-#define HAVE_STRNLEN 1
-#define HAVE_STRPBRK 1
-/* #undef HAVE_STRSEP */
-#define HAVE_STRSTR 1
-/* #undef HAVE_STRTOK_R */
-/* #undef HAVE_STRTOK_R */
-#define HAVE_STRTOL 1
-/* #undef HAVE_STRTOLL */
-#define HAVE_STRTOUL 1
-/* #undef HAVE_STRTOULL */
-#define HAVE_TELL 1
-/* #undef HAVE_THR_SETCONCURRENCY */
-/* #undef HAVE_THR_YIELD */
-/* #undef HAVE_VASPRINTF */
-#define HAVE_VSNPRINTF 1
-
-/* Symbols we may use */
-/* #undef HAVE_SYS_ERRLIST */
-/* used by stacktrace functions */
-/* #undef HAVE_BSS_START */
-
-/* Does "struct timespec" have a "sec" and "nsec" field? */
-/* #undef HAVE_TIMESPEC_TS_SEC */
-
-/* Types we may use */
-#define SIZEOF_CHAR 1
-#if SIZEOF_CHAR
-# define HAVE_CHAR 1
-#endif
-
-#define SIZEOF_CHARP 4
-#if SIZEOF_CHARP
-# define HAVE_CHARP 1
-#endif
-
-#define SIZEOF_SHORT 2
-#if SIZEOF_SHORT
-# define HAVE_SHORT 1
-#endif
-
-#define SIZEOF_INT 4
-#if SIZEOF_INT
-# define HAVE_INT 1
-#endif
-
-#define SIZEOF_LONG 4
-#if SIZEOF_LONG
-# define HAVE_LONG 1
-#endif
-
-#define SIZEOF_LONG_LONG 8
-#if SIZEOF_LONG_LONG
-# define HAVE_LONG_LONG 1
-#endif
-
-#define SIZEOF_OFF_T 4
-#if SIZEOF_OFF_T
-# define HAVE_OFF_T 1
-#endif
-
-/* #undef SIZEOF_SIGSET_T */
-#if SIZEOF_SIGSET_T
-# define HAVE_SIGSET_T 1
-#endif
-
-#define SIZEOF_SIZE_T 4
-#if SIZEOF_SIZE_T
-# define HAVE_SIZE_T 1
-#endif
-
-/* #undef SIZEOF_UCHAR */
-#if SIZEOF_UCHAR
-# define HAVE_UCHAR 1
-#endif
-
-/* #undef SIZEOF_UINT */
-#if SIZEOF_UINT
-# define HAVE_UINT 1
-#endif
-
-/* #undef SIZEOF_ULONG */
-#if SIZEOF_ULONG
-# define HAVE_ULONG 1
-#endif
-
-/* #undef SIZEOF_INT8 */
-#if SIZEOF_INT8
-# define HAVE_INT8 1
-#endif
-/* #undef SIZEOF_UINT8 */
-#if SIZEOF_UINT8
-# define HAVE_UINT8 1
-#endif
-
-/* #undef SIZEOF_INT16 */
-#if SIZEOF_INT16
-# define HAVE_INT16 1
-#endif
-/* #undef SIZEOF_UINT16 */
-#if SIZEOF_UINT16
-# define HAVE_UINT16 1
-#endif
-
-/* #undef SIZEOF_INT32 */
-#if SIZEOF_INT32
-# define HAVE_INT32 1
-#endif
-/* #undef SIZEOF_UINT32 */
-#if SIZEOF_UINT32
-# define HAVE_UINT32 1
-#endif
-/* #undef SIZEOF_U_INT32_T */
-#if SIZEOF_U_INT32_T
-# define HAVE_U_INT32_T 1
-#endif
-
-/* #undef SIZEOF_INT64 */
-#if SIZEOF_INT64
-# define HAVE_INT64 1
-#endif
-/* #undef SIZEOF_UINT64 */
-#if SIZEOF_UINT64
-# define HAVE_UINT64 1
-#endif
-
-/* #undef SIZEOF_SOCKLEN_T */
-#if SIZEOF_SOCKLEN_T
-# define HAVE_SOCKLEN_T 1
-#endif
-
-/* XXX mysql_client_test uses this -- rip it out, please! */
-#define MAX_INDEXES 64
-
-#define QSORT_TYPE_IS_VOID 1
-#define RETQSORTTYPE void
-
-#define SIGNAL_RETURN_TYPE_IS_VOID 1
-#define RETSIGTYPE void
-
-/* #undef WORDS_BIGENDIAN */
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler calls
- it, or to nothing if 'inline' is not supported under any name. */
-#ifndef __cplusplus
-# define inline
-#endif
-
-#define TIME_WITH_SYS_TIME 1
-
-#define STACK_DIRECTION -1
-
-#define SHAREDIR "share"
-#define THREAD 1
-#define THREAD_SAFE_CLIENT 1
-
-#define DEFAULT_CHARSET_HOME "C:/mysql/"
diff --git a/externals/mysql/extlib/yassl/include/crypto_wrapper.hpp b/externals/mysql/extlib/yassl/include/crypto_wrapper.hpp
deleted file mode 100644
index 07b5925265..0000000000
--- a/externals/mysql/extlib/yassl/include/crypto_wrapper.hpp
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* The crypto wrapper header is used to define policies for the cipher
- * components used by SSL. There are 3 policies to consider:
- *
- * 1) MAC, the Message Authentication Code used for each Message
- * 2) Bulk Cipher, the Cipher used to encrypt/decrypt each Message
- * 3) Atuhentication, the Digitial Signing/Verifiaction scheme used
- *
- * This header doesn't rely on a specific crypto libraries internals,
- * only the implementation should.
- */
-
-
-#ifndef yaSSL_CRYPTO_WRAPPER_HPP
-#define yaSSL_CRYPTO_WRAPPER_HPP
-
-#include "yassl_types.hpp"
-#include // FILE
-
-
-namespace yaSSL {
-
-
-// Digest policy should implement a get_digest, update, and get sizes for pad
-// and digest
-struct Digest : public virtual_base {
- virtual void get_digest(byte*) = 0;
- virtual void get_digest(byte*, const byte*, unsigned int) = 0;
- virtual void update(const byte*, unsigned int) = 0;
- virtual uint get_digestSize() const = 0;
- virtual uint get_padSize() const = 0;
- virtual ~Digest() {}
-};
-
-
-// For use with NULL Digests
-struct NO_MAC : public Digest {
- void get_digest(byte*);
- void get_digest(byte*, const byte*, unsigned int);
- void update(const byte*, unsigned int);
- uint get_digestSize() const;
- uint get_padSize() const;
-};
-
-
-// MD5 Digest
-class MD5 : public Digest {
-public:
- void get_digest(byte*);
- void get_digest(byte*, const byte*, unsigned int);
- void update(const byte*, unsigned int);
- uint get_digestSize() const;
- uint get_padSize() const;
- MD5();
- ~MD5();
- MD5(const MD5&);
- MD5& operator=(const MD5&);
-private:
- struct MD5Impl;
- MD5Impl* pimpl_;
-};
-
-
-// SHA-1 Digest
-class SHA : public Digest {
-public:
- void get_digest(byte*);
- void get_digest(byte*, const byte*, unsigned int);
- void update(const byte*, unsigned int);
- uint get_digestSize() const;
- uint get_padSize() const;
- SHA();
- ~SHA();
- SHA(const SHA&);
- SHA& operator=(const SHA&);
-private:
- struct SHAImpl;
- SHAImpl* pimpl_;
-
-};
-
-
-// RIPEMD-160 Digest
-class RMD : public Digest {
-public:
- void get_digest(byte*);
- void get_digest(byte*, const byte*, unsigned int);
- void update(const byte*, unsigned int);
- uint get_digestSize() const;
- uint get_padSize() const;
- RMD();
- ~RMD();
- RMD(const RMD&);
- RMD& operator=(const RMD&);
-private:
- struct RMDImpl;
- RMDImpl* pimpl_;
-
-};
-
-
-// HMAC_MD5
-class HMAC_MD5 : public Digest {
-public:
- void get_digest(byte*);
- void get_digest(byte*, const byte*, unsigned int);
- void update(const byte*, unsigned int);
- uint get_digestSize() const;
- uint get_padSize() const;
- HMAC_MD5(const byte*, unsigned int);
- ~HMAC_MD5();
-private:
- struct HMAC_MD5Impl;
- HMAC_MD5Impl* pimpl_;
-
- HMAC_MD5(const HMAC_MD5&);
- HMAC_MD5& operator=(const HMAC_MD5&);
-};
-
-
-// HMAC_SHA-1
-class HMAC_SHA : public Digest {
-public:
- void get_digest(byte*);
- void get_digest(byte*, const byte*, unsigned int);
- void update(const byte*, unsigned int);
- uint get_digestSize() const;
- uint get_padSize() const;
- HMAC_SHA(const byte*, unsigned int);
- ~HMAC_SHA();
-private:
- struct HMAC_SHAImpl;
- HMAC_SHAImpl* pimpl_;
-
- HMAC_SHA(const HMAC_SHA&);
- HMAC_SHA& operator=(const HMAC_SHA&);
-};
-
-
-// HMAC_RMD
-class HMAC_RMD : public Digest {
-public:
- void get_digest(byte*);
- void get_digest(byte*, const byte*, unsigned int);
- void update(const byte*, unsigned int);
- uint get_digestSize() const;
- uint get_padSize() const;
- HMAC_RMD(const byte*, unsigned int);
- ~HMAC_RMD();
-private:
- struct HMAC_RMDImpl;
- HMAC_RMDImpl* pimpl_;
-
- HMAC_RMD(const HMAC_RMD&);
- HMAC_RMD& operator=(const HMAC_RMD&);
-};
-
-
-// BulkCipher policy should implement encrypt, decrypt, get block size,
-// and set keys for encrypt and decrypt
-struct BulkCipher : public virtual_base {
- virtual void encrypt(byte*, const byte*, unsigned int) = 0;
- virtual void decrypt(byte*, const byte*, unsigned int) = 0;
- virtual void set_encryptKey(const byte*, const byte* = 0) = 0;
- virtual void set_decryptKey(const byte*, const byte* = 0) = 0;
- virtual uint get_blockSize() const = 0;
- virtual int get_keySize() const = 0;
- virtual int get_ivSize() const = 0;
- virtual ~BulkCipher() {}
-};
-
-
-// For use with NULL Ciphers
-struct NO_Cipher : public BulkCipher {
- void encrypt(byte*, const byte*, unsigned int) {}
- void decrypt(byte*, const byte*, unsigned int) {}
- void set_encryptKey(const byte*, const byte*) {}
- void set_decryptKey(const byte*, const byte*) {}
- uint get_blockSize() const { return 0; }
- int get_keySize() const { return 0; }
- int get_ivSize() const { return 0; }
-};
-
-
-// SSLv3 and TLSv1 always use DES in CBC mode so IV is required
-class DES : public BulkCipher {
-public:
- void encrypt(byte*, const byte*, unsigned int);
- void decrypt(byte*, const byte*, unsigned int);
- void set_encryptKey(const byte*, const byte*);
- void set_decryptKey(const byte*, const byte*);
- uint get_blockSize() const { return DES_BLOCK; }
- int get_keySize() const { return DES_KEY_SZ; }
- int get_ivSize() const { return DES_IV_SZ; }
- DES();
- ~DES();
-private:
- struct DESImpl;
- DESImpl* pimpl_;
-
- DES(const DES&); // hide copy
- DES& operator=(const DES&); // & assign
-};
-
-
-// 3DES Encrypt-Decrypt-Encrypt in CBC mode
-class DES_EDE : public BulkCipher {
-public:
- void encrypt(byte*, const byte*, unsigned int);
- void decrypt(byte*, const byte*, unsigned int);
- void set_encryptKey(const byte*, const byte*);
- void set_decryptKey(const byte*, const byte*);
- uint get_blockSize() const { return DES_BLOCK; }
- int get_keySize() const { return DES_EDE_KEY_SZ; }
- int get_ivSize() const { return DES_IV_SZ; }
- DES_EDE();
- ~DES_EDE();
-private:
- struct DES_EDEImpl;
- DES_EDEImpl* pimpl_;
-
- DES_EDE(const DES_EDE&); // hide copy
- DES_EDE& operator=(const DES_EDE&); // & assign
-};
-
-
-// Alledged RC4
-class RC4 : public BulkCipher {
-public:
- void encrypt(byte*, const byte*, unsigned int);
- void decrypt(byte*, const byte*, unsigned int);
- void set_encryptKey(const byte*, const byte*);
- void set_decryptKey(const byte*, const byte*);
- uint get_blockSize() const { return 0; }
- int get_keySize() const { return RC4_KEY_SZ; }
- int get_ivSize() const { return 0; }
- RC4();
- ~RC4();
-private:
- struct RC4Impl;
- RC4Impl* pimpl_;
-
- RC4(const RC4&); // hide copy
- RC4& operator=(const RC4&); // & assign
-};
-
-
-// AES
-class AES : public BulkCipher {
-public:
- void encrypt(byte*, const byte*, unsigned int);
- void decrypt(byte*, const byte*, unsigned int);
- void set_encryptKey(const byte*, const byte*);
- void set_decryptKey(const byte*, const byte*);
- uint get_blockSize() const { return AES_BLOCK_SZ; }
- int get_keySize() const;
- int get_ivSize() const { return AES_IV_SZ; }
- explicit AES(unsigned int = AES_128_KEY_SZ);
- ~AES();
-private:
- struct AESImpl;
- AESImpl* pimpl_;
-
- AES(const AES&); // hide copy
- AES& operator=(const AES&); // & assign
-};
-
-
-// Random number generator
-class RandomPool {
-public:
- void Fill(opaque* dst, uint sz) const;
- RandomPool();
- ~RandomPool();
-
- int GetError() const;
-
- friend class RSA;
- friend class DSS;
- friend class DiffieHellman;
-private:
- struct RandomImpl;
- RandomImpl* pimpl_;
-
- RandomPool(const RandomPool&); // hide copy
- RandomPool& operator=(const RandomPool&); // & assign
-};
-
-
-// Authentication policy should implement sign, and verify
-struct Auth : public virtual_base {
- virtual void sign(byte*, const byte*, unsigned int, const RandomPool&) = 0;
- virtual bool verify(const byte*, unsigned int, const byte*,
- unsigned int) = 0;
- virtual uint get_signatureLength() const = 0;
- virtual ~Auth() {}
-};
-
-
-// For use with NULL Authentication schemes
-struct NO_Auth : public Auth {
- void sign(byte*, const byte*, unsigned int, const RandomPool&) {}
- bool verify(const byte*, unsigned int, const byte*, unsigned int)
- { return true; }
-};
-
-
-// Digitial Signature Standard scheme
-class DSS : public Auth {
-public:
- void sign(byte*, const byte*, unsigned int, const RandomPool&);
- bool verify(const byte*, unsigned int, const byte*, unsigned int);
- uint get_signatureLength() const;
- DSS(const byte*, unsigned int, bool publicKey = true);
- ~DSS();
-private:
- struct DSSImpl;
- DSSImpl* pimpl_;
-
- DSS(const DSS&);
- DSS& operator=(const DSS&);
-};
-
-
-// RSA Authentication and exchange
-class RSA : public Auth {
-public:
- void sign(byte*, const byte*, unsigned int, const RandomPool&);
- bool verify(const byte*, unsigned int, const byte*, unsigned int);
- void encrypt(byte*, const byte*, unsigned int, const RandomPool&);
- void decrypt(byte*, const byte*, unsigned int, const RandomPool&);
- uint get_signatureLength() const;
- uint get_cipherLength() const;
- RSA(const byte*, unsigned int, bool publicKey = true);
- ~RSA();
-private:
- struct RSAImpl;
- RSAImpl* pimpl_;
-
- RSA(const RSA&); // hide copy
- RSA& operator=(const RSA&); // & assing
-};
-
-
-class Integer;
-
-// Diffie-Hellman agreement
-// hide for now TODO: figure out a way to give access to C clients p and g args
-class DiffieHellman {
-public:
- DiffieHellman(const byte*, unsigned int, const byte*, unsigned int,
- const byte*, unsigned int, const RandomPool& random);
- //DiffieHellman(const char*, const RandomPool&);
- DiffieHellman(const Integer&, const Integer&, const RandomPool&);
- ~DiffieHellman();
-
- DiffieHellman(const DiffieHellman&);
- DiffieHellman& operator=(const DiffieHellman&);
-
- uint get_agreedKeyLength() const;
- const byte* get_agreedKey() const;
- const byte* get_publicKey() const;
- void makeAgreement(const byte*, unsigned int);
-
- void set_sizes(int&, int&, int&) const;
- void get_parms(byte*, byte*, byte*) const;
-private:
- struct DHImpl;
- DHImpl* pimpl_;
-};
-
-
-// Lagrge Integer
-class Integer {
-public:
- Integer();
- ~Integer();
-
- Integer(const Integer&);
- Integer& operator=(const Integer&);
-
- void assign(const byte*, unsigned int);
-
- friend class DiffieHellman;
-private:
- struct IntegerImpl;
- IntegerImpl* pimpl_;
-};
-
-
-class x509;
-
-
-struct EncryptedInfo {
- enum { IV_SZ = 32, NAME_SZ = 80 };
- char name[NAME_SZ]; // max one line
- byte iv[IV_SZ]; // in base16 rep
- uint ivSz;
- bool set;
-
- EncryptedInfo() : ivSz(0), set(false) {}
-};
-
-x509* PemToDer(FILE*, CertType, EncryptedInfo* info = 0);
-
-
-} // naemspace
-
-#endif // yaSSL_CRYPTO_WRAPPER_HPP
diff --git a/externals/mysql/extlib/yassl/include/factory.hpp b/externals/mysql/extlib/yassl/include/factory.hpp
deleted file mode 100644
index e66e32dcdf..0000000000
--- a/externals/mysql/extlib/yassl/include/factory.hpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* The factory header defines an Object Factory, used by SSL message and
- * handshake types.
- *
- * See Desgin Pattern in GoF and Alexandrescu's chapter in Modern C++ Design,
- * page 208
- */
-
-
-
-#ifndef yaSSL_FACTORY_HPP
-#define yaSSL_FACTORY_HPP
-
-#include STL_VECTOR_FILE
-#include STL_PAIR_FILE
-
-
-namespace STL = STL_NAMESPACE;
-
-
-
-
-
-namespace yaSSL {
-
-
-// Factory uses its callback map to create objects by id,
-// returning an abstract base pointer
-template
-class Factory {
- typedef STL::pair CallBack;
- typedef STL::vector CallBackVector;
-
- CallBackVector callbacks_;
-public:
- // pass function pointer to register all callbacks upon creation
- explicit Factory(void (*init)(Factory&))
- {
- init(*this);
- }
-
- // reserve place in vector before registering, used by init funcion
- void Reserve(size_t sz)
- {
- callbacks_.reserve(sz);
- }
-
- // register callback
- void Register(const IdentifierType& id, ProductCreator pc)
- {
- callbacks_.push_back(STL::make_pair(id, pc));
- }
-
- // THE Creator, returns a new object of the proper type or 0
- AbstractProduct* CreateObject(const IdentifierType& id) const
- {
- typedef typename STL::vector::const_iterator cIter;
-
- cIter first = callbacks_.begin();
- cIter last = callbacks_.end();
-
- while (first != last) {
- if (first->first == id)
- break;
- ++first;
- }
-
- if (first == callbacks_.end())
- return 0;
- return (first->second)();
- }
-private:
- Factory(const Factory&); // hide copy
- Factory& operator=(const Factory&); // and assign
-};
-
-
-} // naemspace
-
-#endif // yaSSL_FACTORY_HPP
diff --git a/externals/mysql/extlib/yassl/include/handshake.hpp b/externals/mysql/extlib/yassl/include/handshake.hpp
deleted file mode 100644
index 549a31bf3e..0000000000
--- a/externals/mysql/extlib/yassl/include/handshake.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* The handshake header declares function prototypes for creating and reading
- * the various handshake messages.
- */
-
-
-
-#ifndef yaSSL_HANDSHAKE_HPP
-#define yaSSL_HANDSHAKE_HPP
-
-#include "yassl_types.hpp"
-
-
-namespace yaSSL {
-
-// forward decls
-class SSL;
-class Finished;
-class Data;
-class Alert;
-struct Hashes;
-
-enum BufferOutput { buffered, unbuffered };
-
-void sendClientHello(SSL&);
-void sendServerHello(SSL&, BufferOutput = buffered);
-void sendServerHelloDone(SSL&, BufferOutput = buffered);
-void sendClientKeyExchange(SSL&, BufferOutput = buffered);
-void sendServerKeyExchange(SSL&, BufferOutput = buffered);
-void sendChangeCipher(SSL&, BufferOutput = buffered);
-void sendFinished(SSL&, ConnectionEnd, BufferOutput = buffered);
-void sendCertificate(SSL&, BufferOutput = buffered);
-void sendCertificateRequest(SSL&, BufferOutput = buffered);
-void sendCertificateVerify(SSL&, BufferOutput = buffered);
-int sendData(SSL&, const void*, int);
-int sendAlert(SSL& ssl, const Alert& alert);
-
-int receiveData(SSL&, Data&, bool peek = false);
-void processReply(SSL&);
-
-void buildFinished(SSL&, Finished&, const opaque*);
-void build_certHashes(SSL&, Hashes&);
-
-void hmac(SSL&, byte*, const byte*, uint, ContentType, bool verify = false);
-void TLS_hmac(SSL&, byte*, const byte*, uint, ContentType,
- bool verify = false);
-void PRF(byte* digest, uint digLen, const byte* secret, uint secLen,
- const byte* label, uint labLen, const byte* seed, uint seedLen);
-
-} // naemspace
-
-#endif // yaSSL_HANDSHAKE_HPP
diff --git a/externals/mysql/extlib/yassl/include/lock.hpp b/externals/mysql/extlib/yassl/include/lock.hpp
deleted file mode 100644
index 0525943e45..0000000000
--- a/externals/mysql/extlib/yassl/include/lock.hpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* lock.hpp provides an os specific Lock, locks mutex on entry and unlocks
- * automatically upon exit, no-ops provided for Single Threaded
-*/
-
-#ifndef yaSSL_LOCK_HPP
-#define yaSSL_LOCK_HPP
-
-
-namespace yaSSL {
-
-
-#ifdef MULTI_THREADED
- #ifdef _WIN32
- #include
-
- class Mutex {
- CRITICAL_SECTION cs_;
- public:
- Mutex();
- ~Mutex();
-
- class Lock;
- friend class Lock;
-
- class Lock {
- Mutex& mutex_;
- public:
- explicit Lock(Mutex& lm);
- ~Lock();
- };
- };
- #else // _WIN32
- #include
-
- class Mutex {
- pthread_mutex_t mutex_;
- public:
-
- Mutex();
- ~Mutex();
-
- class Lock;
- friend class Lock;
-
- class Lock {
- Mutex& mutex_;
- public:
- explicit Lock(Mutex& lm);
- ~Lock();
- };
- };
-
- #endif // _WIN32
-#else // MULTI_THREADED (WE'RE SINGLE)
-
- class Mutex {
- public:
- class Lock {
- public:
- explicit Lock(Mutex&) {}
- };
- };
-
-#endif // MULTI_THREADED
-
-
-
-} // namespace
-#endif // yaSSL_LOCK_HPP
diff --git a/externals/mysql/extlib/yassl/include/log.hpp b/externals/mysql/extlib/yassl/include/log.hpp
deleted file mode 100644
index fb480eeefb..0000000000
--- a/externals/mysql/extlib/yassl/include/log.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* yaSSL log interface
- *
- */
-
-#ifndef yaSSL_LOG_HPP
-#define yaSSL_LOG_HPP
-
-#include "socket_wrapper.hpp"
-
-#ifdef YASSL_LOG
-#include
-#endif
-
-namespace yaSSL {
-
-typedef unsigned int uint;
-
-
-// Debug logger
-class Log {
-#ifdef YASSL_LOG
- FILE* log_;
-#endif
-public:
- explicit Log(const char* str = "yaSSL.log");
- ~Log();
-
- void Trace(const char*);
- void ShowTCP(socket_t, bool ended = false);
- void ShowData(uint, bool sent = false);
-};
-
-
-} // naemspace
-
-#endif // yaSSL_LOG_HPP
diff --git a/externals/mysql/extlib/yassl/include/openssl/crypto.h b/externals/mysql/extlib/yassl/include/openssl/crypto.h
deleted file mode 100644
index f53e523102..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/crypto.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* crypto.h for openSSL */
-
-#ifndef ysSSL_crypto_h__
-#define yaSSL_crypto_h__
-
-#ifdef YASSL_PREFIX
-#include "prefix_crypto.h"
-#endif
-
-const char* SSLeay_version(int type);
-
-#define SSLEAY_NUMBER_DEFINED
-#define SSLEAY_VERSION 0x0900L
-#define SSLEAY_VERSION_NUMBER SSLEAY_VERSION
-
-
-#endif /* yaSSL_crypto_h__ */
-
diff --git a/externals/mysql/extlib/yassl/include/openssl/des.h b/externals/mysql/extlib/yassl/include/openssl/des.h
deleted file mode 100644
index 67be7eecfb..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/des.h
+++ /dev/null
@@ -1 +0,0 @@
-/* des.h for openssl */
diff --git a/externals/mysql/extlib/yassl/include/openssl/des_old.h b/externals/mysql/extlib/yassl/include/openssl/des_old.h
deleted file mode 100644
index 40e8fbc02a..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/des_old.h
+++ /dev/null
@@ -1 +0,0 @@
-/* des_old.h for openvn */
diff --git a/externals/mysql/extlib/yassl/include/openssl/engine.h b/externals/mysql/extlib/yassl/include/openssl/engine.h
deleted file mode 100644
index 39952fcae8..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/engine.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/* engine.h for libcurl */
-
-#undef HAVE_OPENSSL_ENGINE_H
-
-
diff --git a/externals/mysql/extlib/yassl/include/openssl/err.h b/externals/mysql/extlib/yassl/include/openssl/err.h
deleted file mode 100644
index 45ac1ca246..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/err.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* err.h for openssl */
-
-#ifndef yaSSL_err_h__
-#define yaSSL_err_h__
-
-
-
-#endif /* yaSSL_err_h__ */
diff --git a/externals/mysql/extlib/yassl/include/openssl/evp.h b/externals/mysql/extlib/yassl/include/openssl/evp.h
deleted file mode 100644
index 1d66b08df4..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/evp.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* evp.h for openSSL */
-
-#ifndef SSLEAY_NUMBER_DEFINED
-#define SSLEAY_NUMBER_DEFINED
-
-/* for OpenVPN */
-#define SSLEAY_VERSION_NUMBER 0x0090700f
-
-
-#endif /* SSLEAY_NUMBER_DEFINED */
diff --git a/externals/mysql/extlib/yassl/include/openssl/generate_prefix_files.pl b/externals/mysql/extlib/yassl/include/openssl/generate_prefix_files.pl
deleted file mode 100644
index da591b3133..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/generate_prefix_files.pl
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-#
-# This script generates defines for all functions
-# in yassl/include/openssl/ so they are renamed to
-# ya. Hopefully that is unique enough.
-#
-# The script is to be run manually when we import
-# a new version of yaSSL
-#
-
-
-
-# Find all functions in "input" and add macros
-# to prefix/rename them into "output
-sub generate_prefix($$)
-{
- my $input= shift;
- my $output= shift;
- open(IN, $input)
- or die("Can't open input file $input: $!");
- open(OUT, ">", $output)
- or mtr_error("Can't open output file $output: $!");
-
- while ()
- {
- chomp;
-
- if ( /typedef/ )
- {
- next;
- }
-
- if ( /^\s*[a-zA-Z0-9*_ ]+\s+\*?([_a-zA-Z0-9]+)\s*\(/ )
- {
- print OUT "#define $1 ya$1\n";
- }
- }
-
- close OUT;
- close IN;
-}
-
-generate_prefix("ssl.h", "prefix_ssl.h");
-generate_prefix("crypto.h", "prefix_crypto.h");
-
diff --git a/externals/mysql/extlib/yassl/include/openssl/hmac.h b/externals/mysql/extlib/yassl/include/openssl/hmac.h
deleted file mode 100644
index a2eae4c08c..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/hmac.h
+++ /dev/null
@@ -1 +0,0 @@
-/* hmac.h for openvpn */
diff --git a/externals/mysql/extlib/yassl/include/openssl/lhash.h b/externals/mysql/extlib/yassl/include/openssl/lhash.h
deleted file mode 100644
index 01f8535f86..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/lhash.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* lhash.h for openSSL */
-
diff --git a/externals/mysql/extlib/yassl/include/openssl/md4.h b/externals/mysql/extlib/yassl/include/openssl/md4.h
deleted file mode 100644
index 2e99f977fc..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/md4.h
+++ /dev/null
@@ -1 +0,0 @@
-/* md4.h for libcurl */
diff --git a/externals/mysql/extlib/yassl/include/openssl/md5.h b/externals/mysql/extlib/yassl/include/openssl/md5.h
deleted file mode 100644
index dfaf9799c4..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/md5.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/* md5.h for openssl */
-
-#include "ssl.h" /* in there for now */
-
diff --git a/externals/mysql/extlib/yassl/include/openssl/objects.h b/externals/mysql/extlib/yassl/include/openssl/objects.h
deleted file mode 100644
index 99f2326e51..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/objects.h
+++ /dev/null
@@ -1 +0,0 @@
-/* objects.h for openvpn */
diff --git a/externals/mysql/extlib/yassl/include/openssl/opensslv.h b/externals/mysql/extlib/yassl/include/openssl/opensslv.h
deleted file mode 100644
index d932130684..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/opensslv.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* opensslv.h compatibility */
-
-#ifndef yaSSL_opensslv_h__
-#define yaSSL_opensslv_h__
-
-
-/* api version compatibility */
-#define OPENSSL_VERSION_NUMBER 0x0090700f
-
-
-#endif /* yaSSLopensslv_h__ */
-
diff --git a/externals/mysql/extlib/yassl/include/openssl/pem.h b/externals/mysql/extlib/yassl/include/openssl/pem.h
deleted file mode 100644
index b4c63d56a4..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/pem.h
+++ /dev/null
@@ -1 +0,0 @@
-/* pem.h for libcurl */
diff --git a/externals/mysql/extlib/yassl/include/openssl/pkcs12.h b/externals/mysql/extlib/yassl/include/openssl/pkcs12.h
deleted file mode 100644
index e452fc879c..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/pkcs12.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/* pkcs12.h for libcurl */
-
-
-#undef HAVE_OPENSSL_PKCS12_H
-
diff --git a/externals/mysql/extlib/yassl/include/openssl/prefix_crypto.h b/externals/mysql/extlib/yassl/include/openssl/prefix_crypto.h
deleted file mode 100644
index 3fa5f32c62..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/prefix_crypto.h
+++ /dev/null
@@ -1 +0,0 @@
-#define SSLeay_version yaSSLeay_version
diff --git a/externals/mysql/extlib/yassl/include/openssl/prefix_ssl.h b/externals/mysql/extlib/yassl/include/openssl/prefix_ssl.h
deleted file mode 100644
index 138d9fb882..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/prefix_ssl.h
+++ /dev/null
@@ -1,169 +0,0 @@
-#define Copyright yaCopyright
-#define yaSSL_CleanUp yayaSSL_CleanUp
-#define BN_bin2bn yaBN_bin2bn
-#define DH_new yaDH_new
-#define DH_free yaDH_free
-#define RSA_free yaRSA_free
-#define RSA_generate_key yaRSA_generate_key
-#define X509_free yaX509_free
-#define X509_STORE_CTX_get_current_cert yaX509_STORE_CTX_get_current_cert
-#define X509_STORE_CTX_get_error yaX509_STORE_CTX_get_error
-#define X509_STORE_CTX_get_error_depth yaX509_STORE_CTX_get_error_depth
-#define X509_NAME_oneline yaX509_NAME_oneline
-#define X509_get_issuer_name yaX509_get_issuer_name
-#define X509_get_subject_name yaX509_get_subject_name
-#define X509_verify_cert_error_string yaX509_verify_cert_error_string
-#define X509_LOOKUP_add_dir yaX509_LOOKUP_add_dir
-#define X509_LOOKUP_load_file yaX509_LOOKUP_load_file
-#define X509_LOOKUP_hash_dir yaX509_LOOKUP_hash_dir
-#define X509_LOOKUP_file yaX509_LOOKUP_file
-#define X509_STORE_add_lookup yaX509_STORE_add_lookup
-#define X509_STORE_new yaX509_STORE_new
-#define X509_STORE_get_by_subject yaX509_STORE_get_by_subject
-#define ERR_get_error_line_data yaERR_get_error_line_data
-#define ERR_print_errors_fp yaERR_print_errors_fp
-#define ERR_error_string yaERR_error_string
-#define ERR_remove_state yaERR_remove_state
-#define ERR_get_error yaERR_get_error
-#define ERR_peek_error yaERR_peek_error
-#define ERR_GET_REASON yaERR_GET_REASON
-#define SSL_CTX_new yaSSL_CTX_new
-#define SSL_new yaSSL_new
-#define SSL_set_fd yaSSL_set_fd
-#define SSL_get_fd yaSSL_get_fd
-#define SSL_connect yaSSL_connect
-#define SSL_write yaSSL_write
-#define SSL_read yaSSL_read
-#define SSL_accept yaSSL_accept
-#define SSL_CTX_free yaSSL_CTX_free
-#define SSL_free yaSSL_free
-#define SSL_clear yaSSL_clear
-#define SSL_shutdown yaSSL_shutdown
-#define SSL_set_connect_state yaSSL_set_connect_state
-#define SSL_set_accept_state yaSSL_set_accept_state
-#define SSL_do_handshake yaSSL_do_handshake
-#define SSL_get_cipher yaSSL_get_cipher
-#define SSL_get_cipher_name yaSSL_get_cipher_name
-#define SSL_get_shared_ciphers yaSSL_get_shared_ciphers
-#define SSL_get_cipher_list yaSSL_get_cipher_list
-#define SSL_get_version yaSSL_get_version
-#define SSLeay_version yaSSLeay_version
-#define SSL_get_error yaSSL_get_error
-#define SSL_load_error_strings yaSSL_load_error_strings
-#define SSL_set_session yaSSL_set_session
-#define SSL_get_session yaSSL_get_session
-#define SSL_flush_sessions yaSSL_flush_sessions
-#define SSL_SESSION_set_timeout yaSSL_SESSION_set_timeout
-#define SSL_CTX_set_session_cache_mode yaSSL_CTX_set_session_cache_mode
-#define SSL_get_peer_certificate yaSSL_get_peer_certificate
-#define SSL_get_verify_result yaSSL_get_verify_result
-#define SSL_CTX_set_verify yaSSL_CTX_set_verify
-#define SSL_CTX_load_verify_locations yaSSL_CTX_load_verify_locations
-#define SSL_CTX_set_default_verify_paths yaSSL_CTX_set_default_verify_paths
-#define SSL_CTX_check_private_key yaSSL_CTX_check_private_key
-#define SSL_CTX_set_session_id_context yaSSL_CTX_set_session_id_context
-#define SSL_CTX_set_tmp_rsa_callback yaSSL_CTX_set_tmp_rsa_callback
-#define SSL_CTX_set_options yaSSL_CTX_set_options
-#define SSL_CTX_set_session_cache_mode yaSSL_CTX_set_session_cache_mode
-#define SSL_CTX_set_timeout yaSSL_CTX_set_timeout
-#define SSL_CTX_use_certificate_chain_file yaSSL_CTX_use_certificate_chain_file
-#define SSL_CTX_set_default_passwd_cb yaSSL_CTX_set_default_passwd_cb
-#define SSL_CTX_use_RSAPrivateKey_file yaSSL_CTX_use_RSAPrivateKey_file
-#define SSL_CTX_set_info_callback yaSSL_CTX_set_info_callback
-#define SSL_CTX_sess_accept yaSSL_CTX_sess_accept
-#define SSL_CTX_sess_connect yaSSL_CTX_sess_connect
-#define SSL_CTX_sess_accept_good yaSSL_CTX_sess_accept_good
-#define SSL_CTX_sess_connect_good yaSSL_CTX_sess_connect_good
-#define SSL_CTX_sess_accept_renegotiate yaSSL_CTX_sess_accept_renegotiate
-#define SSL_CTX_sess_connect_renegotiate yaSSL_CTX_sess_connect_renegotiate
-#define SSL_CTX_sess_hits yaSSL_CTX_sess_hits
-#define SSL_CTX_sess_cb_hits yaSSL_CTX_sess_cb_hits
-#define SSL_CTX_sess_cache_full yaSSL_CTX_sess_cache_full
-#define SSL_CTX_sess_misses yaSSL_CTX_sess_misses
-#define SSL_CTX_sess_timeouts yaSSL_CTX_sess_timeouts
-#define SSL_CTX_sess_number yaSSL_CTX_sess_number
-#define SSL_CTX_sess_get_cache_size yaSSL_CTX_sess_get_cache_size
-#define SSL_CTX_get_verify_mode yaSSL_CTX_get_verify_mode
-#define SSL_get_verify_mode yaSSL_get_verify_mode
-#define SSL_CTX_get_verify_depth yaSSL_CTX_get_verify_depth
-#define SSL_get_verify_depth yaSSL_get_verify_depth
-#define SSL_get_default_timeout yaSSL_get_default_timeout
-#define SSL_CTX_get_session_cache_mode yaSSL_CTX_get_session_cache_mode
-#define SSL_session_reused yaSSL_session_reused
-#define SSL_set_rfd yaSSL_set_rfd
-#define SSL_set_wfd yaSSL_set_wfd
-#define SSL_set_shutdown yaSSL_set_shutdown
-#define SSL_set_quiet_shutdown yaSSL_set_quiet_shutdown
-#define SSL_get_quiet_shutdown yaSSL_get_quiet_shutdown
-#define SSL_want_read yaSSL_want_read
-#define SSL_want_write yaSSL_want_write
-#define SSL_pending yaSSL_pending
-#define SSLv3_method yaSSLv3_method
-#define SSLv3_server_method yaSSLv3_server_method
-#define SSLv3_client_method yaSSLv3_client_method
-#define TLSv1_server_method yaTLSv1_server_method
-#define TLSv1_client_method yaTLSv1_client_method
-#define TLSv1_1_server_method yaTLSv1_1_server_method
-#define TLSv1_1_client_method yaTLSv1_1_client_method
-#define SSLv23_server_method yaSSLv23_server_method
-#define SSL_CTX_use_certificate_file yaSSL_CTX_use_certificate_file
-#define SSL_CTX_use_PrivateKey_file yaSSL_CTX_use_PrivateKey_file
-#define SSL_CTX_set_cipher_list yaSSL_CTX_set_cipher_list
-#define SSL_CTX_sess_set_cache_size yaSSL_CTX_sess_set_cache_size
-#define SSL_CTX_set_tmp_dh yaSSL_CTX_set_tmp_dh
-#define OpenSSL_add_all_algorithms yaOpenSSL_add_all_algorithms
-#define SSL_library_init yaSSL_library_init
-#define SSLeay_add_ssl_algorithms yaSSLeay_add_ssl_algorithms
-#define SSL_get_current_cipher yaSSL_get_current_cipher
-#define SSL_CIPHER_description yaSSL_CIPHER_description
-#define SSL_alert_type_string_long yaSSL_alert_type_string_long
-#define SSL_alert_desc_string_long yaSSL_alert_desc_string_long
-#define SSL_state_string_long yaSSL_state_string_long
-#define EVP_md5 yaEVP_md5
-#define EVP_des_ede3_cbc yaEVP_des_ede3_cbc
-#define EVP_BytesToKey yaEVP_BytesToKey
-#define DES_set_key_unchecked yaDES_set_key_unchecked
-#define DES_ede3_cbc_encrypt yaDES_ede3_cbc_encrypt
-#define RAND_screen yaRAND_screen
-#define RAND_file_name yaRAND_file_name
-#define RAND_write_file yaRAND_write_file
-#define RAND_load_file yaRAND_load_file
-#define RAND_status yaRAND_status
-#define RAND_bytes yaRAND_bytes
-#define DES_set_key yaDES_set_key
-#define DES_set_odd_parity yaDES_set_odd_parity
-#define DES_ecb_encrypt yaDES_ecb_encrypt
-#define SSL_CTX_set_default_passwd_cb_userdata yaSSL_CTX_set_default_passwd_cb_userdata
-#define SSL_SESSION_free yaSSL_SESSION_free
-#define SSL_peek yaSSL_peek
-#define SSL_get_certificate yaSSL_get_certificate
-#define SSL_get_privatekey yaSSL_get_privatekey
-#define X509_get_pubkey yaX509_get_pubkey
-#define EVP_PKEY_copy_parameters yaEVP_PKEY_copy_parameters
-#define EVP_PKEY_free yaEVP_PKEY_free
-#define ERR_error_string_n yaERR_error_string_n
-#define ERR_free_strings yaERR_free_strings
-#define EVP_cleanup yaEVP_cleanup
-#define X509_get_ext_d2i yaX509_get_ext_d2i
-#define GENERAL_NAMES_free yaGENERAL_NAMES_free
-#define sk_GENERAL_NAME_num yask_GENERAL_NAME_num
-#define sk_GENERAL_NAME_value yask_GENERAL_NAME_value
-#define ASN1_STRING_data yaASN1_STRING_data
-#define ASN1_STRING_length yaASN1_STRING_length
-#define ASN1_STRING_type yaASN1_STRING_type
-#define X509_NAME_get_index_by_NID yaX509_NAME_get_index_by_NID
-#define X509_NAME_ENTRY_get_data yaX509_NAME_ENTRY_get_data
-#define X509_NAME_get_entry yaX509_NAME_get_entry
-#define ASN1_STRING_to_UTF8 yaASN1_STRING_to_UTF8
-#define SSLv23_client_method yaSSLv23_client_method
-#define SSLv2_client_method yaSSLv2_client_method
-#define SSL_get1_session yaSSL_get1_session
-#define X509_get_notBefore yaX509_get_notBefore
-#define X509_get_notAfter yaX509_get_notAfter
-#define MD4_Init yaMD4_Init
-#define MD4_Update yaMD4_Update
-#define MD4_Final yaMD4_Final
-#define MD5_Init yaMD5_Init
-#define MD5_Update yaMD5_Update
-#define MD5_Final yaMD5_Final
-#define SSL_set_compression yaSSL_set_compression
diff --git a/externals/mysql/extlib/yassl/include/openssl/rand.h b/externals/mysql/extlib/yassl/include/openssl/rand.h
deleted file mode 100644
index df9c902034..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/rand.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* rand.h for openSSL */
-
diff --git a/externals/mysql/extlib/yassl/include/openssl/rsa.h b/externals/mysql/extlib/yassl/include/openssl/rsa.h
deleted file mode 100644
index fe64e655bd..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/rsa.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* rsa.h for openSSL */
-
-
-#ifndef yaSSL_rsa_h__
-#define yaSSL_rsa_h__
-
-enum { RSA_F4 = 1 };
-
-
-#endif /* yaSSL_rsa_h__ */
diff --git a/externals/mysql/extlib/yassl/include/openssl/sha.h b/externals/mysql/extlib/yassl/include/openssl/sha.h
deleted file mode 100644
index bb487c05c2..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/sha.h
+++ /dev/null
@@ -1 +0,0 @@
-/* sha.h for openvpn */
diff --git a/externals/mysql/extlib/yassl/include/openssl/ssl.h b/externals/mysql/extlib/yassl/include/openssl/ssl.h
deleted file mode 100644
index 05b34a0dc4..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/ssl.h
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* ssl.h defines openssl compatibility layer
- *
- */
-
-
-
-#ifndef yaSSL_openssl_h__
-#define yaSSL_openssl_h__
-
-#ifdef YASSL_PREFIX
-#include "prefix_ssl.h"
-#endif
-
-#include /* ERR_print fp */
-#include "opensslv.h" /* for version number */
-#include "rsa.h"
-
-
-#define YASSL_VERSION "1.7.2"
-
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
- void yaSSL_CleanUp(); /* call once at end of application use to
- free static singleton memory holders,
- not a leak per se, but helpful when
- looking for them */
-
-#if defined(__cplusplus)
-} // extern
-#endif
-
-#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)
-namespace yaSSL {
-extern "C" {
-#endif
-
-#undef X509_NAME /* wincrypt.h clash */
-
-#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)
- class SSL;
- class SSL_SESSION;
- class SSL_METHOD;
- class SSL_CTX;
- class SSL_CIPHER;
-
- class RSA;
-
- class X509;
- class X509_NAME;
-#else
- typedef struct SSL SSL;
- typedef struct SSL_SESSION SSL_SESSION;
- typedef struct SSL_METHOD SSL_METHOD;
- typedef struct SSL_CTX SSL_CTX;
- typedef struct SSL_CIPHER SSL_CIPHER;
-
- typedef struct RSA RSA;
-
- typedef struct X509 X509;
- typedef struct X509_NAME X509_NAME;
-#endif
-
-
-/* Big Number stuff, different file? */
-typedef struct BIGNUM BIGNUM;
-
-BIGNUM *BN_bin2bn(const unsigned char*, int, BIGNUM*);
-
-
-/* Diffie-Hellman stuff, different file? */
-/* mySQL deferences to set group parameters */
-typedef struct DH {
- BIGNUM* p;
- BIGNUM* g;
-} DH;
-
-DH* DH_new(void);
-void DH_free(DH*);
-
-/* RSA stuff */
-
-void RSA_free(RSA*);
-RSA* RSA_generate_key(int, unsigned long, void(*)(int, int, void*), void*);
-
-
-/* X509 stuff, different file? */
-
-typedef struct X509_STORE X509_STORE;
-typedef struct X509_LOOKUP X509_LOOKUP;
-typedef struct X509_OBJECT { char c; } X509_OBJECT;
-typedef struct X509_CRL X509_CRL;
-typedef struct X509_REVOKED X509_REVOKED;
-typedef struct X509_LOOKUP_METHOD X509_LOOKUP_METHOD;
-
-
-void X509_free(X509*);
-
-
-/* bio stuff */
-typedef struct BIO BIO;
-
-/* ASN stuff */
-
-
-
-/* because mySQL dereferences to use error and current_cert, even after calling
- * get functions for local references */
-typedef struct X509_STORE_CTX {
- int error;
- int error_depth;
- X509* current_cert;
-} X509_STORE_CTX;
-
-
-
-X509* X509_STORE_CTX_get_current_cert(X509_STORE_CTX*);
-int X509_STORE_CTX_get_error(X509_STORE_CTX*);
-int X509_STORE_CTX_get_error_depth(X509_STORE_CTX*);
-
-char* X509_NAME_oneline(X509_NAME*, char*, int);
-X509_NAME* X509_get_issuer_name(X509*);
-X509_NAME* X509_get_subject_name(X509*);
-const char* X509_verify_cert_error_string(long);
-
-int X509_LOOKUP_add_dir(X509_LOOKUP*, const char*, long);
-int X509_LOOKUP_load_file(X509_LOOKUP*, const char*, long);
-X509_LOOKUP_METHOD* X509_LOOKUP_hash_dir(void);
-X509_LOOKUP_METHOD* X509_LOOKUP_file(void);
-
-X509_LOOKUP* X509_STORE_add_lookup(X509_STORE*, X509_LOOKUP_METHOD*);
-X509_STORE* X509_STORE_new(void);
-int X509_STORE_get_by_subject(X509_STORE_CTX*, int, X509_NAME*,
- X509_OBJECT*);
-
-
-
-
-enum { /* X509 Constants */
- X509_V_OK = 0,
- X509_V_ERR_CERT_CHAIN_TOO_LONG = 1,
- X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 2,
- X509_V_ERR_CERT_NOT_YET_VALID = 3,
- X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 4,
- X509_V_ERR_CERT_HAS_EXPIRED = 5,
- X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 6,
- X509_FILETYPE_PEM = 7,
- X509_LU_X509 = 8,
- X509_LU_CRL = 9,
- X509_V_ERR_CRL_SIGNATURE_FAILURE = 10,
- X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 11,
- X509_V_ERR_CRL_HAS_EXPIRED = 12,
- X509_V_ERR_CERT_REVOKED = 13,
- X509_V_FLAG_CRL_CHECK = 14,
- X509_V_FLAG_CRL_CHECK_ALL = 15
-};
-
-
-/* Error stuff, could move to yassl_error */
-unsigned long ERR_get_error_line_data(const char**, int*, const char**, int *);
-void ERR_print_errors_fp(FILE*);
-char* ERR_error_string(unsigned long,char*);
-void ERR_remove_state(unsigned long);
-unsigned long ERR_get_error(void);
-unsigned long ERR_peek_error(void);
-int ERR_GET_REASON(int);
-
-
-enum { /* ERR Constants */
- ERR_TXT_STRING = 1,
- EVP_R_BAD_DECRYPT = 2
-};
-
-/*
- Allow type used by SSL_set_fd to be changed, default to int
- in order to be compatible with OpenSSL
- */
-#ifndef YASSL_SOCKET_T_DEFINED
-typedef int YASSL_SOCKET_T;
-#endif
-
-SSL_CTX* SSL_CTX_new(SSL_METHOD*);
-SSL* SSL_new(SSL_CTX*);
-int SSL_set_fd (SSL*, YASSL_SOCKET_T);
-YASSL_SOCKET_T SSL_get_fd(const SSL*);
-int SSL_connect(SSL*); /* if you get an error from connect
- see note at top of REAMDE */
-int SSL_write(SSL*, const void*, int);
-int SSL_read(SSL*, void*, int);
-int SSL_accept(SSL*);
-void SSL_CTX_free(SSL_CTX*);
-void SSL_free(SSL*);
-int SSL_clear(SSL*);
-int SSL_shutdown(SSL*);
-
-void SSL_set_connect_state(SSL*);
-void SSL_set_accept_state(SSL*);
-int SSL_do_handshake(SSL*);
-
-const char* SSL_get_cipher(SSL*);
-const char* SSL_get_cipher_name(SSL*); /* uses SSL_get_cipher */
-char* SSL_get_shared_ciphers(SSL*, char*, int);
-const char* SSL_get_cipher_list(SSL*, int);
-const char* SSL_get_version(SSL*);
-const char* SSLeay_version(int);
-
-int SSL_get_error(SSL*, int);
-void SSL_load_error_strings(void);
-
-int SSL_set_session(SSL *ssl, SSL_SESSION *session);
-SSL_SESSION* SSL_get_session(SSL* ssl);
-void SSL_flush_sessions(SSL_CTX *ctx, long tm);
-long SSL_SESSION_set_timeout(SSL_SESSION*, long);
-long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode);
-X509* SSL_get_peer_certificate(SSL*);
-long SSL_get_verify_result(SSL*);
-
-
-typedef int (*VerifyCallback)(int, X509_STORE_CTX*);
-typedef int (*pem_password_cb)(char*, int, int, void*);
-
-void SSL_CTX_set_verify(SSL_CTX*, int, VerifyCallback verify_callback);
-int SSL_CTX_load_verify_locations(SSL_CTX*, const char*, const char*);
-int SSL_CTX_set_default_verify_paths(SSL_CTX*);
-int SSL_CTX_check_private_key(SSL_CTX*);
-int SSL_CTX_set_session_id_context(SSL_CTX*, const unsigned char*,
- unsigned int);
-
-void SSL_CTX_set_tmp_rsa_callback(SSL_CTX*, RSA*(*)(SSL*, int, int));
-long SSL_CTX_set_options(SSL_CTX*, long);
-long SSL_CTX_set_session_cache_mode(SSL_CTX*, long);
-long SSL_CTX_set_timeout(SSL_CTX*, long);
-int SSL_CTX_use_certificate_chain_file(SSL_CTX*, const char*);
-void SSL_CTX_set_default_passwd_cb(SSL_CTX*, pem_password_cb);
-int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX*, const char*, int);
-void SSL_CTX_set_info_callback(SSL_CTX*, void (*)());
-
-long SSL_CTX_sess_accept(SSL_CTX*);
-long SSL_CTX_sess_connect(SSL_CTX*);
-long SSL_CTX_sess_accept_good(SSL_CTX*);
-long SSL_CTX_sess_connect_good(SSL_CTX*);
-long SSL_CTX_sess_accept_renegotiate(SSL_CTX*);
-long SSL_CTX_sess_connect_renegotiate(SSL_CTX*);
-long SSL_CTX_sess_hits(SSL_CTX*);
-long SSL_CTX_sess_cb_hits(SSL_CTX*);
-long SSL_CTX_sess_cache_full(SSL_CTX*);
-long SSL_CTX_sess_misses(SSL_CTX*);
-long SSL_CTX_sess_timeouts(SSL_CTX*);
-long SSL_CTX_sess_number(SSL_CTX*);
-long SSL_CTX_sess_get_cache_size(SSL_CTX*);
-
-int SSL_CTX_get_verify_mode(SSL_CTX*);
-int SSL_get_verify_mode(SSL*);
-int SSL_CTX_get_verify_depth(SSL_CTX*);
-int SSL_get_verify_depth(SSL*);
-
-long SSL_get_default_timeout(SSL*);
-long SSL_CTX_get_session_cache_mode(SSL_CTX*);
-int SSL_session_reused(SSL*);
-
-int SSL_set_rfd(SSL*, int);
-int SSL_set_wfd(SSL*, int);
-void SSL_set_shutdown(SSL*, int);
-void SSL_set_quiet_shutdown(SSL *ssl,int mode);
-int SSL_get_quiet_shutdown(SSL *ssl);
-
-int SSL_want_read(SSL*);
-int SSL_want_write(SSL*);
-
-int SSL_pending(SSL*);
-
-
-enum { /* ssl Constants */
- SSL_WOULD_BLOCK = -8,
- SSL_BAD_STAT = -7,
- SSL_BAD_PATH = -6,
- SSL_BAD_FILETYPE = -5,
- SSL_BAD_FILE = -4,
- SSL_NOT_IMPLEMENTED = -3,
- SSL_UNKNOWN = -2,
- SSL_FATAL_ERROR = -1,
- SSL_NORMAL_SHUTDOWN = 0,
- SSL_ERROR_NONE = 0, /* for most functions */
- SSL_FAILURE = 0, /* for some functions */
- SSL_SUCCESS = 1,
-
- SSL_FILETYPE_ASN1 = 10,
- SSL_FILETYPE_PEM = 11,
- SSL_FILETYPE_DEFAULT = 10, /* ASN1 */
-
- SSL_VERIFY_NONE = 0,
- SSL_VERIFY_PEER = 1,
- SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2,
- SSL_VERIFY_CLIENT_ONCE = 4,
-
- SSL_SESS_CACHE_OFF = 30,
- SSL_SESS_CACHE_CLIENT = 31,
- SSL_SESS_CACHE_SERVER = 32,
- SSL_SESS_CACHE_BOTH = 33,
- SSL_SESS_CACHE_NO_AUTO_CLEAR = 34,
- SSL_SESS_CACHE_NO_INTERNAL_LOOKUP = 35,
-
- SSL_OP_MICROSOFT_SESS_ID_BUG = 50,
- SSL_OP_NETSCAPE_CHALLENGE_BUG = 51,
- SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = 52,
- SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG = 53,
- SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = 54,
- SSL_OP_MSIE_SSLV2_RSA_PADDING = 55,
- SSL_OP_SSLEAY_080_CLIENT_DH_BUG = 56,
- SSL_OP_TLS_D5_BUG = 57,
- SSL_OP_TLS_BLOCK_PADDING_BUG = 58,
- SSL_OP_TLS_ROLLBACK_BUG = 59,
- SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = 60,
- SSL_OP_ALL = 61,
- SSL_OP_SINGLE_DH_USE = 62,
- SSL_OP_EPHEMERAL_RSA = 63,
- SSL_OP_NO_SSLv2 = 64,
- SSL_OP_NO_SSLv3 = 65,
- SSL_OP_NO_TLSv1 = 66,
- SSL_OP_PKCS1_CHECK_1 = 67,
- SSL_OP_PKCS1_CHECK_2 = 68,
- SSL_OP_NETSCAPE_CA_DN_BUG = 69,
- SSL_OP_NON_EXPORT_FIRST = 70,
- SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 71,
-
- SSL_ERROR_WANT_READ = 80,
- SSL_ERROR_WANT_WRITE = 81,
- SSL_ERROR_SYSCALL = 82,
- SSL_ERROR_WANT_X509_LOOKUP = 83,
- SSL_ERROR_ZERO_RETURN = 84,
- SSL_ERROR_SSL = 85,
-
- SSL_SENT_SHUTDOWN = 90,
- SSL_RECEIVED_SHUTDOWN = 91,
- SSL_CB_LOOP = 92,
- SSL_ST_CONNECT = 93,
- SSL_ST_ACCEPT = 94,
- SSL_CB_ALERT = 95,
- SSL_CB_READ = 96,
- SSL_CB_HANDSHAKE_DONE = 97
-
-};
-
-
-SSL_METHOD *SSLv3_method(void);
-SSL_METHOD *SSLv3_server_method(void);
-SSL_METHOD *SSLv3_client_method(void);
-SSL_METHOD *TLSv1_server_method(void);
-SSL_METHOD *TLSv1_client_method(void);
-SSL_METHOD *TLSv1_1_server_method(void);
-SSL_METHOD *TLSv1_1_client_method(void);
-SSL_METHOD *SSLv23_server_method(void);
-
-int SSL_CTX_use_certificate_file(SSL_CTX*, const char*, int);
-int SSL_CTX_use_PrivateKey_file(SSL_CTX*, const char*, int);
-int SSL_CTX_set_cipher_list(SSL_CTX*, const char*);
-
-long SSL_CTX_sess_set_cache_size(SSL_CTX*, long);
-long SSL_CTX_set_tmp_dh(SSL_CTX*, DH*);
-
-void OpenSSL_add_all_algorithms(void);
-int SSL_library_init();
-int SSLeay_add_ssl_algorithms(void);
-
-
-SSL_CIPHER* SSL_get_current_cipher(SSL*);
-char* SSL_CIPHER_description(SSL_CIPHER*, char*, int);
-
-
-char* SSL_alert_type_string_long(int);
-char* SSL_alert_desc_string_long(int);
-char* SSL_state_string_long(SSL*);
-
-
-/* EVP stuff, des and md5, different file? */
-typedef char EVP_MD;
-
-typedef char EVP_CIPHER;
-
-typedef struct EVP_PKEY EVP_PKEY;
-
-typedef unsigned char DES_cblock[8];
-typedef const DES_cblock const_DES_cblock;
-typedef DES_cblock DES_key_schedule;
-
-enum {
- DES_ENCRYPT = 1,
- DES_DECRYPT = 0
-};
-
-const EVP_MD* EVP_md5(void);
-const EVP_CIPHER* EVP_des_ede3_cbc(void);
-
-typedef unsigned char opaque;
-
-int EVP_BytesToKey(const EVP_CIPHER*, const EVP_MD*, const opaque*,
- const opaque*, int, int, opaque*, opaque*);
-
-void DES_set_key_unchecked(const_DES_cblock*, DES_key_schedule*);
-void DES_ede3_cbc_encrypt(const opaque*, opaque*, long, DES_key_schedule*,
- DES_key_schedule*, DES_key_schedule*, DES_cblock*, int);
-
-
-/* RAND stuff */
-void RAND_screen(void);
-const char* RAND_file_name(char*, size_t);
-int RAND_write_file(const char*);
-int RAND_load_file(const char*, long);
-
-
-/* for libcurl */
-int RAND_status(void);
-int RAND_bytes(unsigned char* buf, int num);
-
-int DES_set_key(const_DES_cblock*, DES_key_schedule*);
-void DES_set_odd_parity(DES_cblock*);
-void DES_ecb_encrypt(DES_cblock*, DES_cblock*, DES_key_schedule*, int);
-
-void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*, void* userdata);
-void SSL_SESSION_free(SSL_SESSION* session);
-int SSL_peek(SSL* ssl, void* buf, int num);
-
-X509* SSL_get_certificate(SSL* ssl);
-EVP_PKEY* SSL_get_privatekey(SSL* ssl);
-EVP_PKEY* X509_get_pubkey(X509* x);
-
-int EVP_PKEY_copy_parameters(EVP_PKEY* to, const EVP_PKEY* from);
-void EVP_PKEY_free(EVP_PKEY* pkey);
-void ERR_error_string_n(unsigned long e, char *buf, size_t len);
-void ERR_free_strings(void);
-void EVP_cleanup(void);
-
-void* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx);
-
-#define GEN_IPADD 7
-#define NID_subject_alt_name 85
-#define STACK_OF(x) x
-
-
-/* defined here because libcurl dereferences */
-typedef struct ASN1_STRING {
- int type;
- int length;
- unsigned char* data;
-} ASN1_STRING;
-
-
-typedef struct GENERAL_NAME {
- int type;
- union {
- ASN1_STRING* ia5;
- } d;
-} GENERAL_NAME;
-
-void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *x);
-
-int sk_GENERAL_NAME_num(STACK_OF(GENERAL_NAME) *x);
-GENERAL_NAME* sk_GENERAL_NAME_value(STACK_OF(GENERAL_NAME) *x, int i);
-
-
-unsigned char* ASN1_STRING_data(ASN1_STRING* x);
-int ASN1_STRING_length(ASN1_STRING* x);
-int ASN1_STRING_type(ASN1_STRING *x);
-
-typedef ASN1_STRING X509_NAME_ENTRY;
-
-int X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos);
-
-ASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne);
-X509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME* name, int loc);
-
-#define OPENSSL_malloc(x) malloc(x)
-#define OPENSSL_free(x) free(x)
-
-int ASN1_STRING_to_UTF8(unsigned char** out, ASN1_STRING* in);
-
-SSL_METHOD* SSLv23_client_method(void); /* doesn't actually roll back */
-SSL_METHOD* SSLv2_client_method(void); /* will never work, no v 2 */
-
-
-SSL_SESSION* SSL_get1_session(SSL* ssl); /* what's ref count */
-
-
-#define CRYPTO_free(x) free(x)
-#define ASN1_TIME ASN1_STRING
-
-ASN1_TIME* X509_get_notBefore(X509* x);
-ASN1_TIME* X509_get_notAfter(X509* x);
-
-
-#define ASN1_UTCTIME ASN1_STRING
-#define NID_commonName 13
-#define V_ASN1_UTF8STRING 12
-#define GEN_DNS 2
-
-#define CERTFICATE_ERROR 0x14090086 /* SSLv3 error */
-
-
-typedef struct MD4_CTX {
- int buffer[32]; /* big enough to hold, check size in Init */
-} MD4_CTX;
-
-void MD4_Init(MD4_CTX*);
-void MD4_Update(MD4_CTX*, const void*, unsigned long);
-void MD4_Final(unsigned char*, MD4_CTX*);
-
-
-typedef struct MD5_CTX {
- int buffer[32]; /* big enough to hold, check size in Init */
-} MD5_CTX;
-
-void MD5_Init(MD5_CTX*);
-void MD5_Update(MD5_CTX*, const void*, unsigned long);
-void MD5_Final(unsigned char*, MD5_CTX*);
-
-#define MD5_DIGEST_LENGTH 16
-
-
-#define SSL_DEFAULT_CIPHER_LIST "" /* default all */
-
-
-/* yaSSL adds */
-int SSL_set_compression(SSL*); /* turn on yaSSL zlib compression */
-
-
-
-
-#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)
-} /* namespace */
-} /* extern "C" */
-#endif
-
-
-#endif /* yaSSL_openssl_h__ */
diff --git a/externals/mysql/extlib/yassl/include/openssl/x509.h b/externals/mysql/extlib/yassl/include/openssl/x509.h
deleted file mode 100644
index dcd847c033..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/x509.h
+++ /dev/null
@@ -1 +0,0 @@
-/* x509.h for libcurl */
diff --git a/externals/mysql/extlib/yassl/include/openssl/x509v3.h b/externals/mysql/extlib/yassl/include/openssl/x509v3.h
deleted file mode 100644
index adf94af8f4..0000000000
--- a/externals/mysql/extlib/yassl/include/openssl/x509v3.h
+++ /dev/null
@@ -1 +0,0 @@
-/* x509v3.h for libcurl */
diff --git a/externals/mysql/extlib/yassl/include/socket_wrapper.hpp b/externals/mysql/extlib/yassl/include/socket_wrapper.hpp
deleted file mode 100644
index 308704c2af..0000000000
--- a/externals/mysql/extlib/yassl/include/socket_wrapper.hpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* The socket wrapper header defines a Socket class that hides the differences
- * between Berkely style sockets and Windows sockets, allowing transparent TCP
- * access.
- */
-
-
-#ifndef yaSSL_SOCKET_WRAPPER_HPP
-#define yaSSL_SOCKET_WRAPPER_HPP
-
-#include
-
-#ifdef _WIN32
- #include
-#else
- #include
- #include
- #include
- #include
- #include
- #include
-#endif
-
-
-namespace yaSSL {
-
-typedef unsigned int uint;
-
-#ifdef _WIN32
- typedef SOCKET socket_t;
-#else
- typedef int socket_t;
- const socket_t INVALID_SOCKET = -1;
- const int SD_RECEIVE = 0;
- const int SD_SEND = 1;
- const int SD_BOTH = 2;
- const int SOCKET_ERROR = -1;
-#endif
-
-
-
-typedef unsigned char byte;
-
-
-// Wraps Windows Sockets and BSD Sockets
-class Socket {
- socket_t socket_; // underlying socket descriptor
- bool wouldBlock_; // if non-blocking data, for last read
- bool nonBlocking_; // is option set
-public:
- explicit Socket(socket_t s = INVALID_SOCKET);
- ~Socket();
-
- void set_fd(socket_t s);
- uint get_ready() const;
- socket_t get_fd() const;
-
- uint send(const byte* buf, unsigned int len, int flags = 0) const;
- uint receive(byte* buf, unsigned int len, int flags = 0);
-
- bool wait();
- bool WouldBlock() const;
- bool IsNonBlocking() const;
-
- void closeSocket();
- void shutDown(int how = SD_SEND);
-
- static int get_lastError();
- static void set_lastError(int error);
-private:
- Socket(const Socket&); // hide copy
- Socket& operator= (const Socket&); // and assign
-};
-
-
-} // naemspace
-
-#endif // yaSSL_SOCKET_WRAPPER_HPP
diff --git a/externals/mysql/extlib/yassl/include/timer.hpp b/externals/mysql/extlib/yassl/include/timer.hpp
deleted file mode 100644
index 725e73cf45..0000000000
--- a/externals/mysql/extlib/yassl/include/timer.hpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* timer.hpp provides a high res and low res timers
- *
-*/
-
-
-#ifndef yaSSL_TIMER_HPP
-#define yaSSL_TIMER_HPP
-
-namespace yaSSL {
-
-typedef double timer_d;
-typedef unsigned int uint;
-
-
-
-timer_d timer();
-uint lowResTimer();
-
-
-
-} // namespace
-#endif // yaSSL_TIMER_HPP
diff --git a/externals/mysql/extlib/yassl/include/yassl.hpp b/externals/mysql/extlib/yassl/include/yassl.hpp
deleted file mode 100644
index 29e0a5d94e..0000000000
--- a/externals/mysql/extlib/yassl/include/yassl.hpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* yaSSL externel header defines yaSSL API
- */
-
-
-#ifndef yaSSL_EXT_HPP
-#define yaSSL_EXT_HPP
-
-
-namespace yaSSL {
-
-
-#ifdef _WIN32
- typedef unsigned int SOCKET_T;
-#else
- typedef int SOCKET_T;
-#endif
-
-
-class Client {
-public:
- Client();
- ~Client();
-
- // basics
- int Connect(SOCKET_T);
- int Write(const void*, int);
- int Read(void*, int);
-
- // options
- void SetCA(const char*);
- void SetCert(const char*);
- void SetKey(const char*);
-private:
- struct ClientImpl;
- ClientImpl* pimpl_;
-
- Client(const Client&); // hide copy
- Client& operator=(const Client&); // and assign
-};
-
-
-class Server {
-public:
- Server();
- ~Server();
-
- // basics
- int Accept(SOCKET_T);
- int Write(const void*, int);
- int Read(void*, int);
-
- // options
- void SetCA(const char*);
- void SetCert(const char*);
- void SetKey(const char*);
-private:
- struct ServerImpl;
- ServerImpl* pimpl_;
-
- Server(const Server&); // hide copy
- Server& operator=(const Server&); // and assign
-};
-
-
-} // namespace yaSSL
-#endif // yaSSL_EXT_HPP
diff --git a/externals/mysql/extlib/yassl/include/yassl_error.hpp b/externals/mysql/extlib/yassl/include/yassl_error.hpp
deleted file mode 100644
index 63fa9a761b..0000000000
--- a/externals/mysql/extlib/yassl/include/yassl_error.hpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* yaSSL error header defines error codes and an exception class
- */
-
-#ifndef yaSSL_ERROR_HPP
-#define yaSSL_ERROR_HPP
-
-
-
-namespace yaSSL {
-
-
-enum YasslError {
- no_error = 0,
-
- // 10 - 47 from AlertDescription, 0 also close_notify
-
- range_error = 101,
- realloc_error = 102,
- factory_error = 103,
- unknown_cipher = 104,
- prefix_error = 105,
- record_layer = 106,
- handshake_layer = 107,
- out_of_order = 108,
- bad_input = 109,
- match_error = 110,
- no_key_file = 111,
- verify_error = 112,
- send_error = 113,
- receive_error = 114,
- certificate_error = 115,
- privateKey_error = 116,
- badVersion_error = 117,
- compress_error = 118,
- decompress_error = 119,
- pms_version_error = 120
-
- // !!!! add error message to .cpp !!!!
-
- // 1000+ from TaoCrypt error.hpp
-
-};
-
-
-enum Library { yaSSL_Lib = 0, CryptoLib, SocketLib };
-enum { MAX_ERROR_SZ = 80 };
-
-void SetErrorString(YasslError, char*);
-
-/* remove for now, if go back to exceptions use this wrapper
-// Base class for all yaSSL exceptions
-class Error : public mySTL::runtime_error {
- YasslError error_;
- Library lib_;
-public:
- explicit Error(const char* s = "", YasslError e = no_error,
- Library l = yaSSL_Lib);
-
- YasslError get_number() const;
- Library get_lib() const;
-};
-*/
-
-
-} // naemspace
-
-#endif // yaSSL_ERROR_HPP
diff --git a/externals/mysql/extlib/yassl/include/yassl_imp.hpp b/externals/mysql/extlib/yassl/include/yassl_imp.hpp
deleted file mode 100644
index 8893ba8a8b..0000000000
--- a/externals/mysql/extlib/yassl/include/yassl_imp.hpp
+++ /dev/null
@@ -1,748 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* yaSSL implementation header defines all strucutres from the SSL.v3
- * specification "draft-freier-ssl-version3-02.txt"
- * all page citations refer to this document unless otherwise noted.
- */
-
-
-#ifndef yaSSL_IMP_HPP
-#define yaSSL_IMP_HPP
-
-#ifdef _MSC_VER
- // disable truncated debug symbols
- #pragma warning(disable:4786)
-#endif
-
-#include "yassl_types.hpp"
-#include "factory.hpp"
-#include STL_LIST_FILE
-
-
-namespace STL = STL_NAMESPACE;
-
-
-namespace yaSSL {
-
-
-class SSL; // forward decls
-class input_buffer;
-class output_buffer;
-
-
-struct ProtocolVersion {
- uint8 major_;
- uint8 minor_; // major and minor SSL/TLS version numbers
-
- ProtocolVersion(uint8 maj = 3, uint8 min = 0);
-};
-
-
-// Record Layer Header for PlainText, Compressed, and CipherText
-struct RecordLayerHeader {
- ContentType type_;
- ProtocolVersion version_;
- uint16 length_; // should not exceed 2^14
-};
-
-
-// base for all messages
-struct Message : public virtual_base {
- virtual input_buffer& set(input_buffer&) =0;
- virtual output_buffer& get(output_buffer&) const =0;
-
- virtual void Process(input_buffer&, SSL&) =0;
- virtual ContentType get_type() const =0;
- virtual uint16 get_length() const =0;
-
- virtual ~Message() {}
-};
-
-
-class ChangeCipherSpec : public Message {
- CipherChoice type_;
-public:
- ChangeCipherSpec();
-
- friend input_buffer& operator>>(input_buffer&, ChangeCipherSpec&);
- friend output_buffer& operator<<(output_buffer&, const ChangeCipherSpec&);
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- ContentType get_type() const;
- uint16 get_length() const;
- void Process(input_buffer&, SSL&);
-private:
- ChangeCipherSpec(const ChangeCipherSpec&); // hide copy
- ChangeCipherSpec& operator=(const ChangeCipherSpec&); // and assign
-};
-
-
-
-class Alert : public Message {
- AlertLevel level_;
- AlertDescription description_;
-public:
- Alert() {}
- Alert(AlertLevel al, AlertDescription ad);
-
- ContentType get_type() const;
- uint16 get_length() const;
- void Process(input_buffer&, SSL&);
-
- friend input_buffer& operator>>(input_buffer&, Alert&);
- friend output_buffer& operator<<(output_buffer&, const Alert&);
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-private:
- Alert(const Alert&); // hide copy
- Alert& operator=(const Alert&); // and assign
-};
-
-
-class Data : public Message {
- uint16 length_;
- opaque* buffer_; // read buffer used by fillData input
- const opaque* write_buffer_; // write buffer used by output operator
-public:
- Data();
- Data(uint16 len, opaque* b);
-
- friend output_buffer& operator<<(output_buffer&, const Data&);
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- ContentType get_type() const;
- uint16 get_length() const;
- void set_length(uint16 l);
- opaque* set_buffer();
- void SetData(uint16, const opaque*);
- void Process(input_buffer&, SSL&);
-private:
- Data(const Data&); // hide copy
- Data& operator=(const Data&); // and assign
-};
-
-
-uint32 c24to32(const uint24); // forward form internal header
-void c32to24(uint32, uint24&);
-
-
-// HandShake header, same for each message type from page 20/21
-class HandShakeHeader : public Message {
- HandShakeType type_;
- uint24 length_; // length of message
-public:
- HandShakeHeader() {}
-
- ContentType get_type() const;
- uint16 get_length() const;
- HandShakeType get_handshakeType() const;
- void Process(input_buffer&, SSL&);
-
- void set_type(HandShakeType hst);
- void set_length(uint32 u32);
-
- friend input_buffer& operator>>(input_buffer&, HandShakeHeader&);
- friend output_buffer& operator<<(output_buffer&, const HandShakeHeader&);
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-private:
- HandShakeHeader(const HandShakeHeader&); // hide copy
- HandShakeHeader& operator=(const HandShakeHeader&); // and assign
-};
-
-
-// Base Class for all handshake messages
-class HandShakeBase : public virtual_base {
- int length_;
-public:
- int get_length() const;
- void set_length(int);
-
- // for building buffer's type field
- virtual HandShakeType get_type() const =0;
-
- // handles dispactch of proper >>
- virtual input_buffer& set(input_buffer& in) =0;
- virtual output_buffer& get(output_buffer& out) const =0;
-
- virtual void Process(input_buffer&, SSL&) =0;
-
- virtual ~HandShakeBase() {}
-};
-
-
-struct HelloRequest : public HandShakeBase {
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- void Process(input_buffer&, SSL&);
-
- HandShakeType get_type() const;
-};
-
-
-// The Client's Hello Message from page 23
-class ClientHello : public HandShakeBase {
- ProtocolVersion client_version_;
- Random random_;
- uint8 id_len_; // session id length
- opaque session_id_[ID_LEN];
- uint16 suite_len_; // cipher suite length
- opaque cipher_suites_[MAX_SUITE_SZ];
- uint8 comp_len_; // compression length
- CompressionMethod compression_methods_;
-public:
- friend input_buffer& operator>>(input_buffer&, ClientHello&);
- friend output_buffer& operator<<(output_buffer&, const ClientHello&);
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- HandShakeType get_type() const;
- void Process(input_buffer&, SSL&);
-
- const opaque* get_random() const;
- friend void buildClientHello(SSL&, ClientHello&);
- friend void ProcessOldClientHello(input_buffer& input, SSL& ssl);
-
- ClientHello();
- ClientHello(ProtocolVersion pv, bool useCompression);
-private:
- ClientHello(const ClientHello&); // hide copy
- ClientHello& operator=(const ClientHello&); // and assign
-};
-
-
-
-// The Server's Hello Message from page 24
-class ServerHello : public HandShakeBase {
- ProtocolVersion server_version_;
- Random random_;
- uint8 id_len_; // session id length
- opaque session_id_[ID_LEN];
- opaque cipher_suite_[SUITE_LEN];
- CompressionMethod compression_method_;
-public:
- ServerHello(ProtocolVersion pv, bool useCompression);
- ServerHello();
-
- friend input_buffer& operator>>(input_buffer&, ServerHello&);
- friend output_buffer& operator<<(output_buffer&, const ServerHello&);
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- HandShakeType get_type() const;
- void Process(input_buffer&, SSL&);
-
- const opaque* get_random() const;
- friend void buildServerHello(SSL&, ServerHello&);
-private:
- ServerHello(const ServerHello&); // hide copy
- ServerHello& operator=(const ServerHello&); // and assign
-};
-
-
-class x509;
-
-// Certificate could be a chain
-class Certificate : public HandShakeBase {
- const x509* cert_;
-public:
- Certificate();
- explicit Certificate(const x509* cert);
- friend output_buffer& operator<<(output_buffer&, const Certificate&);
-
- const opaque* get_buffer() const;
-
- // Process handles input, needs SSL
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- HandShakeType get_type() const;
- void Process(input_buffer&, SSL&);
-private:
- Certificate(const Certificate&); // hide copy
- Certificate& operator=(const Certificate&); // and assign
-};
-
-
-
-// RSA Public Key
-struct ServerRSAParams {
- opaque* rsa_modulus_;
- opaque* rsa_exponent_;
-};
-
-
-// Ephemeral Diffie-Hellman Parameters
-class ServerDHParams {
- int pSz_;
- int gSz_;
- int pubSz_;
- opaque* p_;
- opaque* g_;
- opaque* Ys_;
-public:
- ServerDHParams();
- ~ServerDHParams();
-
- int get_pSize() const;
- int get_gSize() const;
- int get_pubSize() const;
-
- const opaque* get_p() const;
- const opaque* get_g() const;
- const opaque* get_pub() const;
-
- opaque* alloc_p(int sz);
- opaque* alloc_g(int sz);
- opaque* alloc_pub(int sz);
-private:
- ServerDHParams(const ServerDHParams&); // hide copy
- ServerDHParams& operator=(const ServerDHParams&); // and assign
-};
-
-
-struct ServerKeyBase : public virtual_base {
- virtual ~ServerKeyBase() {}
- virtual void build(SSL&) {}
- virtual void read(SSL&, input_buffer&) {}
- virtual int get_length() const;
- virtual opaque* get_serverKey() const;
-};
-
-
-// Server random number for FORTEZZA KEA
-struct Fortezza_Server : public ServerKeyBase {
- opaque r_s_[FORTEZZA_MAX];
-};
-
-
-struct SignatureBase : public virtual_base {
- virtual ~SignatureBase() {}
-};
-
-struct anonymous_sa : public SignatureBase {};
-
-
-struct Hashes {
- uint8 md5_[MD5_LEN];
- uint8 sha_[SHA_LEN];
-};
-
-
-struct rsa_sa : public SignatureBase {
- Hashes hashes_;
-};
-
-
-struct dsa_sa : public SignatureBase {
- uint8 sha_[SHA_LEN];
-};
-
-
-// Server's Diffie-Hellman exchange
-class DH_Server : public ServerKeyBase {
- ServerDHParams parms_;
- opaque* signature_;
-
- int length_; // total length of message
- opaque* keyMessage_; // total exchange message
-public:
- DH_Server();
- ~DH_Server();
-
- void build(SSL&);
- void read(SSL&, input_buffer&);
- int get_length() const;
- opaque* get_serverKey() const;
-private:
- DH_Server(const DH_Server&); // hide copy
- DH_Server& operator=(const DH_Server&); // and assign
-};
-
-
-// Server's RSA exchange
-struct RSA_Server : public ServerKeyBase {
- ServerRSAParams params_;
- opaque* signature_; // signed rsa_sa hashes
-};
-
-
-class ServerKeyExchange : public HandShakeBase {
- ServerKeyBase* server_key_;
-public:
- explicit ServerKeyExchange(SSL&);
- ServerKeyExchange();
- ~ServerKeyExchange();
-
- void createKey(SSL&);
- void build(SSL& ssl);
-
- const opaque* getKey() const;
- int getKeyLength() const;
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- friend output_buffer& operator<<(output_buffer&, const ServerKeyExchange&);
-
- void Process(input_buffer&, SSL&);
- HandShakeType get_type() const;
-private:
- ServerKeyExchange(const ServerKeyExchange&); // hide copy
- ServerKeyExchange& operator=(const ServerKeyExchange&); // and assign
-};
-
-
-
-class CertificateRequest : public HandShakeBase {
- ClientCertificateType certificate_types_[CERT_TYPES];
- int typeTotal_;
- STL::list certificate_authorities_;
-public:
- CertificateRequest();
- ~CertificateRequest();
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- friend input_buffer& operator>>(input_buffer&, CertificateRequest&);
- friend output_buffer& operator<<(output_buffer&,
- const CertificateRequest&);
-
- void Process(input_buffer&, SSL&);
- HandShakeType get_type() const;
-
- void Build();
-private:
- CertificateRequest(const CertificateRequest&); // hide copy
- CertificateRequest& operator=(const CertificateRequest&); // and assign
-};
-
-
-struct ServerHelloDone : public HandShakeBase {
- ServerHelloDone();
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- void Process(input_buffer& input, SSL& ssl);
-
- HandShakeType get_type() const;
-};
-
-
-struct PreMasterSecret {
- opaque random_[SECRET_LEN]; // first two bytes Protocol Version
-};
-
-
-struct ClientKeyBase : public virtual_base {
- virtual ~ClientKeyBase() {}
- virtual void build(SSL&) {}
- virtual void read(SSL&, input_buffer&) {}
- virtual int get_length() const;
- virtual opaque* get_clientKey() const;
-};
-
-
-class EncryptedPreMasterSecret : public ClientKeyBase {
- opaque* secret_;
- int length_;
-public:
- EncryptedPreMasterSecret();
- ~EncryptedPreMasterSecret();
-
- void build(SSL&);
- void read(SSL&, input_buffer&);
- int get_length() const;
- opaque* get_clientKey() const;
- void alloc(int sz);
-private:
- // hide copy and assign
- EncryptedPreMasterSecret(const EncryptedPreMasterSecret&);
- EncryptedPreMasterSecret& operator=(const EncryptedPreMasterSecret&);
-};
-
-
-// Fortezza Key Parameters from page 29
-// hard code lengths cause only used here
-struct FortezzaKeys : public ClientKeyBase {
- opaque y_c_ [128]; // client's Yc, public value
- opaque r_c_ [128]; // client's Rc
- opaque y_signature_ [40]; // DSS signed public key
- opaque wrapped_client_write_key_ [12]; // wrapped by the TEK
- opaque wrapped_server_write_key_ [12]; // wrapped by the TEK
- opaque client_write_iv_ [24];
- opaque server_write_iv_ [24];
- opaque master_secret_iv_ [24]; // IV used to encrypt preMaster
- opaque encrypted_preMasterSecret_[48]; // random & crypted by the TEK
-};
-
-
-
-// Diffie-Hellman public key from page 40/41
-class ClientDiffieHellmanPublic : public ClientKeyBase {
- PublicValueEncoding public_value_encoding_;
- int length_; // includes two byte length for message
- opaque* Yc_; // length + Yc_
- // dh_Yc only if explicit, otherwise sent in certificate
- enum { KEY_OFFSET = 2 };
-public:
- ClientDiffieHellmanPublic();
- ~ClientDiffieHellmanPublic();
-
- void build(SSL&);
- void read(SSL&, input_buffer&);
- int get_length() const;
- opaque* get_clientKey() const;
- void alloc(int sz, bool offset = false);
-private:
- // hide copy and assign
- ClientDiffieHellmanPublic(const ClientDiffieHellmanPublic&);
- ClientDiffieHellmanPublic& operator=(const ClientDiffieHellmanPublic&);
-};
-
-
-class ClientKeyExchange : public HandShakeBase {
- ClientKeyBase* client_key_;
-public:
- explicit ClientKeyExchange(SSL& ssl);
- ClientKeyExchange();
- ~ClientKeyExchange();
-
- void createKey(SSL&);
- void build(SSL& ssl);
-
- const opaque* getKey() const;
- int getKeyLength() const;
-
- friend output_buffer& operator<<(output_buffer&, const ClientKeyExchange&);
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- HandShakeType get_type() const;
- void Process(input_buffer&, SSL&);
-private:
- ClientKeyExchange(const ClientKeyExchange&); // hide copy
- ClientKeyExchange& operator=(const ClientKeyExchange&); // and assign
-};
-
-
-class CertificateVerify : public HandShakeBase {
- Hashes hashes_;
- byte* signature_; // owns
-public:
- CertificateVerify();
- ~CertificateVerify();
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- friend input_buffer& operator>>(input_buffer&, CertificateVerify&);
- friend output_buffer& operator<<(output_buffer&, const CertificateVerify&);
-
- void Process(input_buffer&, SSL&);
- HandShakeType get_type() const;
-
- void Build(SSL&);
-private:
- CertificateVerify(const CertificateVerify&); // hide copy
- CertificateVerify& operator=(const CertificateVerify&); // and assign
-};
-
-
-class Finished : public HandShakeBase {
- Hashes hashes_;
-public:
- Finished();
-
- uint8* set_md5();
- uint8* set_sha();
-
- friend input_buffer& operator>>(input_buffer&, Finished&);
- friend output_buffer& operator<<(output_buffer&, const Finished&);
-
- input_buffer& set(input_buffer& in);
- output_buffer& get(output_buffer& out) const;
-
- void Process(input_buffer&, SSL&);
-
- HandShakeType get_type() const;
-private:
- Finished(const Finished&); // hide copy
- Finished& operator=(const Finished&); // and assign
-};
-
-
-class RandomPool; // forward for connection
-
-
-// SSL Connection defined on page 11
-struct Connection {
- opaque *pre_master_secret_;
- opaque master_secret_[SECRET_LEN];
- opaque client_random_[RAN_LEN];
- opaque server_random_[RAN_LEN];
- opaque sessionID_[ID_LEN];
- opaque client_write_MAC_secret_[SHA_LEN]; // sha is max size
- opaque server_write_MAC_secret_[SHA_LEN];
- opaque client_write_key_[AES_256_KEY_SZ]; // aes 256bit is max sz
- opaque server_write_key_[AES_256_KEY_SZ];
- opaque client_write_IV_[AES_IV_SZ]; // aes is max size
- opaque server_write_IV_[AES_IV_SZ];
- uint32 sequence_number_;
- uint32 peer_sequence_number_;
- uint32 pre_secret_len_; // pre master length
- bool send_server_key_; // server key exchange?
- bool master_clean_; // master secret clean?
- bool TLS_; // TLSv1 or greater
- bool TLSv1_1_; // TLSv1.1 or greater
- bool sessionID_Set_; // do we have a session
- bool compression_; // zlib compression?
- ProtocolVersion version_; // negotiated version
- ProtocolVersion chVersion_; // client hello version
- RandomPool& random_;
-
- Connection(ProtocolVersion v, RandomPool& ran);
- ~Connection();
-
- void AllocPreSecret(uint sz);
- void CleanPreMaster();
- void CleanMaster();
- void TurnOffTLS();
- void TurnOffTLS1_1();
-private:
- Connection(const Connection&); // hide copy
- Connection& operator=(const Connection&); // and assign
-};
-
-
-struct Ciphers; // forward
-
-
-// TLSv1 Security Spec, defined on page 56 of RFC 2246
-struct Parameters {
- ConnectionEnd entity_;
- BulkCipherAlgorithm bulk_cipher_algorithm_;
- CipherType cipher_type_;
- uint8 key_size_;
- uint8 iv_size_;
- IsExportable is_exportable_;
- MACAlgorithm mac_algorithm_;
- uint8 hash_size_;
- CompressionMethod compression_algorithm_;
- KeyExchangeAlgorithm kea_; // yassl additions
- SignatureAlgorithm sig_algo_; // signature auth type
- SignatureAlgorithm verify_algo_; // cert verify auth type
- bool pending_;
- bool resumable_; // new conns by session
- uint16 encrypt_size_; // current msg encrypt sz
- Cipher suite_[SUITE_LEN]; // choosen suite
- uint8 suites_size_;
- Cipher suites_[MAX_SUITE_SZ];
- char cipher_name_[MAX_SUITE_NAME];
- char cipher_list_[MAX_CIPHERS][MAX_SUITE_NAME];
- bool removeDH_; // for server's later use
-
- Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion, bool haveDH);
-
- void SetSuites(ProtocolVersion pv, bool removeDH = false,
- bool removeRSA = false, bool removeDSA = false);
- void SetCipherNames();
-private:
- Parameters(const Parameters&); // hide copy
- Parameters& operator=(const Parameters&); // and assing
-};
-
-
-input_buffer& operator>>(input_buffer&, RecordLayerHeader&);
-output_buffer& operator<<(output_buffer&, const RecordLayerHeader&);
-
-input_buffer& operator>>(input_buffer&, Message&);
-output_buffer& operator<<(output_buffer&, const Message&);
-
-input_buffer& operator>>(input_buffer&, HandShakeBase&);
-output_buffer& operator<<(output_buffer&, const HandShakeBase&);
-
-
-// Message Factory definition
-// uses the ContentType enumeration for unique id
-typedef Factory MessageFactory;
-void InitMessageFactory(MessageFactory&); // registers derived classes
-
-// HandShake Factory definition
-// uses the HandShakeType enumeration for unique id
-typedef Factory HandShakeFactory;
-void InitHandShakeFactory(HandShakeFactory&); // registers derived classes
-
-// ServerKey Factory definition
-// uses KeyExchangeAlgorithm enumeration for unique id
-typedef Factory ServerKeyFactory;
-void InitServerKeyFactory(ServerKeyFactory&);
-
-// ClientKey Factory definition
-// uses KeyExchangeAlgorithm enumeration for unique id
-typedef Factory ClientKeyFactory;
-void InitClientKeyFactory(ClientKeyFactory&);
-
-
-// Message Creators
-Message* CreateHandShake();
-Message* CreateCipherSpec();
-Message* CreateAlert();
-Message* CreateData();
-
-
-// HandShake Creators
-HandShakeBase* CreateCertificate();
-HandShakeBase* CreateHelloRequest();
-HandShakeBase* CreateClientHello();
-HandShakeBase* CreateServerHello();
-HandShakeBase* CreateServerKeyExchange();
-HandShakeBase* CreateCertificateRequest();
-HandShakeBase* CreateServerHelloDone();
-HandShakeBase* CreateClientKeyExchange();
-HandShakeBase* CreateCertificateVerify();
-HandShakeBase* CreateFinished();
-
-
-// ServerKey Exchange Creators
-ServerKeyBase* CreateRSAServerKEA();
-ServerKeyBase* CreateDHServerKEA();
-ServerKeyBase* CreateFortezzaServerKEA();
-
-// ClientKey Exchange Creators
-ClientKeyBase* CreateRSAClient();
-ClientKeyBase* CreateDHClient();
-ClientKeyBase* CreateFortezzaClient();
-
-
-
-} // naemspace
-
-#endif // yaSSL_IMP_HPP
diff --git a/externals/mysql/extlib/yassl/include/yassl_int.hpp b/externals/mysql/extlib/yassl/include/yassl_int.hpp
deleted file mode 100644
index d18dc41860..0000000000
--- a/externals/mysql/extlib/yassl/include/yassl_int.hpp
+++ /dev/null
@@ -1,693 +0,0 @@
-/*
- Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* yaSSL internal header defines SSL supporting types not specified in the
- * draft along with type conversion functions and openssl compatibility
- */
-
-
-#ifndef yaSSL_INT_HPP
-#define yaSSL_INT_HPP
-
-#include "yassl_imp.hpp"
-#include "yassl_error.hpp"
-#include "crypto_wrapper.hpp"
-#include "cert_wrapper.hpp"
-#include "log.hpp"
-#include "lock.hpp"
-#include "openssl/ssl.h" // ASN1_STRING and DH
-
-// Check if _POSIX_THREADS should be forced
-#if !defined(_POSIX_THREADS) && (defined(__NETWARE__) || defined(__hpux))
-// HPUX does not define _POSIX_THREADS as it's not _fully_ implemented
-// Netware supports pthreads but does not announce it
-#define _POSIX_THREADS
-#endif
-
-#ifdef _POSIX_THREADS
- #include
-#endif
-
-
-namespace STL = STL_NAMESPACE;
-
-
-namespace yaSSL {
-
-
-// State Machine for Record Layer Protocol
-enum RecordLayerState {
- recordNotReady = 0, // fatal error, no more processing
- recordReady
-};
-
-
-// State Machine for HandShake Protocol
-enum HandShakeState {
- handShakeNotReady = 0, // fatal error, no more processing
- preHandshake, // initial state
- inHandshake, // handshake started
- handShakeReady // handshake done
-};
-
-
-// client input HandShake state, use if HandShakeState == inHandShake
-enum ClientState {
- serverNull = 0,
- serverHelloComplete,
- serverCertComplete,
- serverKeyExchangeComplete,
- serverHelloDoneComplete,
- serverFinishedComplete
-};
-
-
-// server input HandShake state, use if HandShakeState == inHandShake
-enum ServerState {
- clientNull = 0,
- clientHelloComplete,
- clientKeyExchangeComplete,
- clientFinishedComplete
-};
-
-
-// client connect state for nonblocking restart
-enum ConnectState {
- CONNECT_BEGIN = 0,
- CLIENT_HELLO_SENT,
- FIRST_REPLY_DONE,
- FINISHED_DONE,
- SECOND_REPLY_DONE
-};
-
-
-// server accpet state for nonblocking restart
-enum AcceptState {
- ACCEPT_BEGIN = 0,
- ACCEPT_FIRST_REPLY_DONE,
- SERVER_HELLO_DONE,
- ACCEPT_SECOND_REPLY_DONE,
- ACCEPT_FINISHED_DONE,
- ACCEPT_THIRD_REPLY_DONE
-};
-
-
-// combines all states
-class States {
- RecordLayerState recordLayer_;
- HandShakeState handshakeLayer_;
- ClientState clientState_;
- ServerState serverState_;
- ConnectState connectState_;
- AcceptState acceptState_;
- char errorString_[MAX_ERROR_SZ];
- YasslError what_;
-public:
- States();
-
- const RecordLayerState& getRecord() const;
- const HandShakeState& getHandShake() const;
- const ClientState& getClient() const;
- const ServerState& getServer() const;
- const ConnectState& GetConnect() const;
- const AcceptState& GetAccept() const;
- const char* getString() const;
- YasslError What() const;
-
- RecordLayerState& useRecord();
- HandShakeState& useHandShake();
- ClientState& useClient();
- ServerState& useServer();
- ConnectState& UseConnect();
- AcceptState& UseAccept();
- char* useString();
- void SetError(YasslError);
-private:
- States(const States&); // hide copy
- States& operator=(const States&); // and assign
-};
-
-
-// holds all factories
-class sslFactory {
- MessageFactory messageFactory_; // creates new messages by type
- HandShakeFactory handShakeFactory_; // creates new handshake types
- ServerKeyFactory serverKeyFactory_; // creates new server key types
- ClientKeyFactory clientKeyFactory_; // creates new client key types
-
- sslFactory(); // only GetSSL_Factory creates
-public:
- const MessageFactory& getMessage() const;
- const HandShakeFactory& getHandShake() const;
- const ServerKeyFactory& getServerKey() const;
- const ClientKeyFactory& getClientKey() const;
-
- friend sslFactory& GetSSL_Factory(); // singleton creator
-private:
- sslFactory(const sslFactory&); // hide copy
- sslFactory& operator=(const sslFactory&); // and assign
-};
-
-
-#undef X509_NAME // wincrypt.h clash
-
-// openSSL X509 names
-class X509_NAME {
- char* name_;
- size_t sz_;
- ASN1_STRING entry_;
-public:
- X509_NAME(const char*, size_t sz);
- ~X509_NAME();
-
- const char* GetName() const;
- ASN1_STRING* GetEntry(int i);
- size_t GetLength() const;
-private:
- X509_NAME(const X509_NAME&); // hide copy
- X509_NAME& operator=(const X509_NAME&); // and assign
-};
-
-
-class StringHolder {
- ASN1_STRING asnString_;
-public:
- StringHolder(const char* str, int sz);
- ~StringHolder();
-
- ASN1_STRING* GetString();
-private:
- StringHolder(const StringHolder&); // hide copy
- StringHolder& operator=(const StringHolder&); // and assign
-};
-
-
-// openSSL X509
-class X509 {
- X509_NAME issuer_;
- X509_NAME subject_;
- StringHolder beforeDate_; // not valid before
- StringHolder afterDate_; // not valid after
-public:
- X509(const char* i, size_t, const char* s, size_t,
- const char* b, int, const char* a, int);
- ~X509() {}
-
- X509_NAME* GetIssuer();
- X509_NAME* GetSubject();
-
- ASN1_STRING* GetBefore();
- ASN1_STRING* GetAfter();
-
-private:
- X509(const X509&); // hide copy
- X509& operator=(const X509&); // and assign
-};
-
-
-// openSSL bignum
-struct BIGNUM {
- /*
- gcc 2.96 fix: because of two Integer classes (yaSSL::Integer and
- TaoCrypt::Integer), we need to explicitly state the namespace
- here to let gcc 2.96 deduce the correct type.
- */
- yaSSL::Integer int_;
- void assign(const byte* b, uint s) { int_.assign(b,s); }
-};
-
-
-// openSSL session
-class SSL_SESSION {
- opaque sessionID_[ID_LEN];
- opaque master_secret_[SECRET_LEN];
- Cipher suite_[SUITE_LEN];
- uint bornOn_; // create time in seconds
- uint timeout_; // timeout in seconds
- RandomPool& random_; // will clean master secret
- X509* peerX509_;
-public:
- explicit SSL_SESSION(RandomPool&);
- SSL_SESSION(const SSL&, RandomPool&);
- ~SSL_SESSION();
-
- const opaque* GetID() const;
- const opaque* GetSecret() const;
- const Cipher* GetSuite() const;
- uint GetBornOn() const;
- uint GetTimeOut() const;
- X509* GetPeerX509() const;
- void SetTimeOut(uint);
-
- SSL_SESSION& operator=(const SSL_SESSION&); // allow assign for resumption
-private:
- SSL_SESSION(const SSL_SESSION&); // hide copy
-
- void CopyX509(X509*);
-};
-
-
-// holds all sessions
-class Sessions {
- STL::list list_;
- RandomPool random_; // for session cleaning
- Mutex mutex_; // no-op for single threaded
- int count_; // flush counter
-
- Sessions() : count_(0) {} // only GetSessions can create
-public:
- SSL_SESSION* lookup(const opaque*, SSL_SESSION* copy = 0);
- void add(const SSL&);
- void remove(const opaque*);
- void Flush();
-
- ~Sessions();
-
- friend Sessions& GetSessions(); // singleton creator
-private:
- Sessions(const Sessions&); // hide copy
- Sessions& operator=(const Sessions&); // and assign
-};
-
-
-#ifdef _POSIX_THREADS
- typedef pthread_t THREAD_ID_T;
-#else
- typedef DWORD THREAD_ID_T;
-#endif
-
-// thread error data
-struct ThreadError {
- THREAD_ID_T threadID_;
- int errorID_;
-};
-
-
-// holds all errors
-class Errors {
- STL::list list_;
- Mutex mutex_;
-
- Errors() {} // only GetErrors can create
-public:
- int Lookup(bool peek); // self lookup
- void Add(int);
- void Remove(); // remove self
-
- ~Errors() {}
-
- friend Errors& GetErrors(); // singleton creator
-private:
- Errors(const Errors&); // hide copy
- Errors& operator=(const Errors); // and assign
-};
-
-
-Sessions& GetSessions(); // forward singletons
-sslFactory& GetSSL_Factory();
-Errors& GetErrors();
-
-
-// openSSL method and context types
-class SSL_METHOD {
- ProtocolVersion version_;
- ConnectionEnd side_;
- bool verifyPeer_; // request or send certificate
- bool verifyNone_; // whether to verify certificate
- bool failNoCert_;
- bool multipleProtocol_; // for SSLv23 compatibility
-public:
- SSL_METHOD(ConnectionEnd ce, ProtocolVersion pv,
- bool multipleProtocol = false);
-
- ProtocolVersion getVersion() const;
- ConnectionEnd getSide() const;
-
- void setVerifyPeer();
- void setVerifyNone();
- void setFailNoCert();
-
- bool verifyPeer() const;
- bool verifyNone() const;
- bool failNoCert() const;
- bool multipleProtocol() const;
-private:
- SSL_METHOD(const SSL_METHOD&); // hide copy
- SSL_METHOD& operator=(const SSL_METHOD&); // and assign
-};
-
-
-struct Ciphers {
- bool setSuites_; // user set suites from default
- byte suites_[MAX_SUITE_SZ]; // new suites
- int suiteSz_; // suite length in bytes
-
- Ciphers() : setSuites_(false), suiteSz_(0) {}
-};
-
-
-struct DH; // forward
-
-
-// save for SSL construction
-struct DH_Parms {
- Integer p_;
- Integer g_;
- bool set_; // if set by user
-
- DH_Parms() : set_(false) {}
-};
-
-
-enum StatsField {
- Accept, Connect, AcceptGood, ConnectGood, AcceptRenegotiate,
- ConnectRenegotiate, Hits, CbHits, CacheFull, Misses, Timeouts, Number,
- GetCacheSize, VerifyMode, VerifyDepth
-};
-
-
-// SSL stats
-struct Stats {
- long accept_;
- long connect_;
- long acceptGood_;
- long connectGood_;
- long acceptRenegotiate_;
- long connectRenegotiate_;
-
- long hits_;
- long cbHits_;
- long cacheFull_;
- long misses_;
- long timeouts_;
- long number_;
- long getCacheSize_;
-
- int verifyMode_;
- int verifyDepth_;
-public:
- Stats() : accept_(0), connect_(0), acceptGood_(0), connectGood_(0),
- acceptRenegotiate_(0), connectRenegotiate_(0), hits_(0), cbHits_(0),
- cacheFull_(0), misses_(0), timeouts_(0), number_(0), getCacheSize_(0),
- verifyMode_(0), verifyDepth_(0)
- {}
-private:
- Stats(const Stats&); // hide copy
- Stats& operator=(const Stats&); // and assign
-};
-
-
-// the SSL context
-class SSL_CTX {
-public:
- typedef STL::list CertList;
-private:
- SSL_METHOD* method_;
- x509* certificate_;
- x509* privateKey_;
- CertList caList_;
- Ciphers ciphers_;
- DH_Parms dhParms_;
- pem_password_cb passwordCb_;
- void* userData_;
- bool sessionCacheOff_;
- bool sessionCacheFlushOff_;
- Stats stats_;
- Mutex mutex_; // for Stats
- VerifyCallback verifyCallback_;
-public:
- explicit SSL_CTX(SSL_METHOD* meth);
- ~SSL_CTX();
-
- const x509* getCert() const;
- const x509* getKey() const;
- const SSL_METHOD* getMethod() const;
- const Ciphers& GetCiphers() const;
- const DH_Parms& GetDH_Parms() const;
- const Stats& GetStats() const;
- const VerifyCallback getVerifyCallback() const;
- pem_password_cb GetPasswordCb() const;
- void* GetUserData() const;
- bool GetSessionCacheOff() const;
- bool GetSessionCacheFlushOff() const;
-
- void setVerifyPeer();
- void setVerifyNone();
- void setFailNoCert();
- void setVerifyCallback(VerifyCallback);
- bool SetCipherList(const char*);
- bool SetDH(const DH&);
- void SetPasswordCb(pem_password_cb cb);
- void SetUserData(void*);
- void SetSessionCacheOff();
- void SetSessionCacheFlushOff();
-
- void IncrementStats(StatsField);
- void AddCA(x509* ca);
- const CertList& GetCA_List() const;
-
- friend int read_file(SSL_CTX*, const char*, int, CertType);
-private:
- SSL_CTX(const SSL_CTX&); // hide copy
- SSL_CTX& operator=(const SSL_CTX&); // and assign
-};
-
-
-// holds all cryptographic types
-class Crypto {
- Digest* digest_; // agreed upon digest
- BulkCipher* cipher_; // agreed upon cipher
- DiffieHellman* dh_; // dh parms
- RandomPool random_; // random number generator
- CertManager cert_; // manages certificates
-public:
- explicit Crypto();
- ~Crypto();
-
- const Digest& get_digest() const;
- const BulkCipher& get_cipher() const;
- const DiffieHellman& get_dh() const;
- const RandomPool& get_random() const;
- const CertManager& get_certManager() const;
-
- Digest& use_digest();
- BulkCipher& use_cipher();
- DiffieHellman& use_dh();
- RandomPool& use_random();
- CertManager& use_certManager();
-
- void SetDH(DiffieHellman*);
- void SetDH(const DH_Parms&);
- void setDigest(Digest*);
- void setCipher(BulkCipher*);
-
- bool DhSet();
-private:
- Crypto(const Crypto&); // hide copy
- Crypto& operator=(const Crypto&); // and assign
-};
-
-
-// holds all handshake and verify hashes
-class sslHashes {
- MD5 md5HandShake_; // md5 handshake hash
- SHA shaHandShake_; // sha handshake hash
- Finished verify_; // peer's verify hash
- Hashes certVerify_; // peer's cert verify hash
-public:
- sslHashes() {}
-
- const MD5& get_MD5() const;
- const SHA& get_SHA() const;
- const Finished& get_verify() const;
- const Hashes& get_certVerify() const;
-
- MD5& use_MD5();
- SHA& use_SHA();
- Finished& use_verify();
- Hashes& use_certVerify();
-private:
- sslHashes(const sslHashes&); // hide copy
- sslHashes& operator=(const sslHashes&); // and assign
-};
-
-
-// holds input and output buffers
-class Buffers {
-public:
- typedef STL::list inputList;
- typedef STL::list outputList;
-private:
- inputList dataList_; // list of users app data / handshake
- outputList handShakeList_; // buffered handshake msgs
- input_buffer* rawInput_; // buffered raw input yet to process
-public:
- Buffers();
- ~Buffers();
-
- const inputList& getData() const;
- const outputList& getHandShake() const;
-
- inputList& useData();
- outputList& useHandShake();
-
- void SetRawInput(input_buffer*); // takes ownership
- input_buffer* TakeRawInput(); // takes ownership
-private:
- Buffers(const Buffers&); // hide copy
- Buffers& operator=(const Buffers&); // and assign
-};
-
-
-// wraps security parameters
-class Security {
- Connection conn_; // connection information
- Parameters parms_; // may be pending
- SSL_SESSION resumeSession_; // if resuming
- SSL_CTX* ctx_; // context used to init
- bool resuming_; // trying to resume
-public:
- Security(ProtocolVersion, RandomPool&, ConnectionEnd, const Ciphers&,
- SSL_CTX*, bool);
-
- const SSL_CTX* GetContext() const;
- const Connection& get_connection() const;
- const Parameters& get_parms() const;
- const SSL_SESSION& get_resume() const;
- bool get_resuming() const;
-
- Connection& use_connection();
- Parameters& use_parms();
- SSL_SESSION& use_resume();
-
- void set_resuming(bool b);
-private:
- Security(const Security&); // hide copy
- Security& operator=(const Security&); // and assign
-};
-
-
-// THE SSL type
-class SSL {
- Crypto crypto_; // agreed crypto agents
- Security secure_; // Connection and Session parms
- States states_; // Record and HandShake states
- sslHashes hashes_; // handshake, finished hashes
- Socket socket_; // socket wrapper
- Buffers buffers_; // buffered handshakes and data
- Log log_; // logger
- bool quietShutdown_;
-
- // optimization variables
- bool has_data_; // buffered data ready?
-public:
- SSL(SSL_CTX* ctx);
-
- // gets and uses
- const Crypto& getCrypto() const;
- const Security& getSecurity() const;
- const States& getStates() const;
- const sslHashes& getHashes() const;
- const sslFactory& getFactory() const;
- const Socket& getSocket() const;
- YasslError GetError() const;
- bool GetMultiProtocol() const;
- bool CompressionOn() const;
-
- Crypto& useCrypto();
- Security& useSecurity();
- States& useStates();
- sslHashes& useHashes();
- Socket& useSocket();
- Log& useLog();
- Buffers& useBuffers();
-
- bool HasData() const;
- bool GetQuietShutdown() const;
-
- // sets
- void set_pending(Cipher suite);
- void set_random(const opaque*, ConnectionEnd);
- void set_sessionID(const opaque*);
- void set_session(SSL_SESSION*);
- void set_preMaster(const opaque*, uint);
- void set_masterSecret(const opaque*);
- void SetError(YasslError);
- int SetCompression();
- void UnSetCompression();
- void SetQuietShutdown(bool mode);
-
- // helpers
- bool isTLS() const;
- bool isTLSv1_1() const;
- void order_error();
- void makeMasterSecret();
- void makeTLSMasterSecret();
- void addData(input_buffer* data);
- void fillData(Data&);
- void PeekData(Data&);
- void addBuffer(output_buffer* b);
- void flushBuffer();
- void verifyState(const RecordLayerHeader&);
- void verifyState(const HandShakeHeader&);
- void verifyState(ClientState);
- void verifyState(ServerState);
- void verfiyHandShakeComplete();
- void matchSuite(const opaque*, uint length);
- void deriveKeys();
- void deriveTLSKeys();
- void Send(const byte*, uint);
-
- uint bufferedData();
- uint get_SEQIncrement(bool);
-
- const byte* get_macSecret(bool);
-private:
- void storeKeys(const opaque*);
- void setKeys();
- void verifyClientState(HandShakeType);
- void verifyServerState(HandShakeType);
-
- SSL(const SSL&); // hide copy
- const SSL& operator=(const SSL&); // and assign
-};
-
-
-// compression
-int Compress(const byte*, int, input_buffer&);
-int DeCompress(input_buffer&, int, input_buffer&);
-
-
-// conversion functions
-void c32to24(uint32, uint24&);
-void c24to32(const uint24, uint32&);
-
-uint32 c24to32(const uint24);
-
-void ato16(const opaque*, uint16&);
-void ato24(const opaque*, uint24&);
-
-void c16toa(uint16, opaque*);
-void c24toa(const uint24, opaque*);
-void c32toa(uint32 u32, opaque*);
-
-
-} // naemspace
-
-#endif // yaSSL_INT_HPP
diff --git a/externals/mysql/extlib/yassl/include/yassl_types.hpp b/externals/mysql/extlib/yassl/include/yassl_types.hpp
deleted file mode 100644
index 1af9e90f90..0000000000
--- a/externals/mysql/extlib/yassl/include/yassl_types.hpp
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* yaSSL types header defines all constants, enums, and typedefs
- * from the SSL.v3 specification "draft-freier-ssl-version3-02.txt"
- */
-
-
-#ifndef yaSSL_TYPES_HPP
-#define yaSSL_TYPES_HPP
-
-#include
-#include
-#include "type_traits.hpp"
-
-
-#ifdef _MSC_VER
- // disable conversion warning
- // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
- #pragma warning(disable:4244 4996)
-#endif
-
-
-namespace yaSSL {
-
-#define YASSL_LIB
-
-
-#ifdef YASSL_PURE_C
-
- // library allocation
- struct new_t {}; // yaSSL New type
- extern new_t ys; // pass in parameter
-
- } // namespace yaSSL
-
- void* operator new (size_t, yaSSL::new_t);
- void* operator new[](size_t, yaSSL::new_t);
-
- void operator delete (void*, yaSSL::new_t);
- void operator delete[](void*, yaSSL::new_t);
-
-
- namespace yaSSL {
-
-
- template
- void ysDelete(T* ptr)
- {
- if (ptr) ptr->~T();
- ::operator delete(ptr, yaSSL::ys);
- }
-
- template
- void ysArrayDelete(T* ptr)
- {
- // can't do array placement destruction since not tracking size in
- // allocation, only allow builtins to use array placement since they
- // don't need destructors called
- typedef char builtin[TaoCrypt::IsFundamentalType::Yes ? 1 : -1];
- (void)sizeof(builtin);
-
- ::operator delete[](ptr, yaSSL::ys);
- }
-
- #define NEW_YS new (yaSSL::ys)
-
- // to resolve compiler generated operator delete on base classes with
- // virtual destructors (when on stack), make sure doesn't get called
- class virtual_base {
- public:
- static void operator delete(void*) { assert(0); }
- };
-
-
-#else // YASSL_PURE_C
-
-
- template
- void ysDelete(T* ptr)
- {
- delete ptr;
- }
-
- template
- void ysArrayDelete(T* ptr)
- {
- delete[] ptr;
- }
-
- #define NEW_YS new
-
- class virtual_base {};
-
-
-
-#endif // YASSL_PURE_C
-
-
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
-typedef uint8 uint24[3];
-typedef uint32 uint64[2];
-
-typedef uint8 opaque;
-typedef opaque byte;
-
-typedef unsigned int uint;
-
-
-#ifdef USE_SYS_STL
- // use system STL
- #define STL_VECTOR_FILE
- #define STL_LIST_FILE
- #define STL_ALGORITHM_FILE
- #define STL_MEMORY_FILE
- #define STL_PAIR_FILE
-
- #define STL_NAMESPACE std
-#else
- // use mySTL
- #define STL_VECTOR_FILE "vector.hpp"
- #define STL_LIST_FILE "list.hpp"
- #define STL_ALGORITHM_FILE "algorithm.hpp"
- #define STL_MEMORY_FILE "memory.hpp"
- #define STL_PAIR_FILE "pair.hpp"
-
- #define STL_NAMESPACE mySTL
-#endif
-
-
-#ifndef min
-template
-T min(T a, T b)
-{
- return a < b ? a : b;
-}
-#endif
-
-
-
-// all length constants in bytes
-const int ID_LEN = 32; // session id length
-const int SUITE_LEN = 2; // cipher suite length
-const int SECRET_LEN = 48; // pre RSA and all master secret length
-const int MASTER_ROUNDS = 3; // master secret derivation rounds
-const int RAN_LEN = 32; // client and server random length
-const int MAC_BLOCK_SZ = 64; // MAC block size, & padding
-const int MD5_LEN = 16; // MD5 digest length
-const int SHA_LEN = 20; // SHA digest length
-const int RMD_LEN = 20; // RIPEMD-160 digest length
-const int PREFIX = 3; // up to 3 prefix letters for secret rounds
-const int KEY_PREFIX = 7; // up to 7 prefix letters for key rounds
-const int FORTEZZA_MAX = 128; // Maximum Fortezza Key length
-const int MAX_SUITE_SZ = 128; // 64 max suites * sizeof(suite)
-const int MAX_SUITE_NAME = 48; // max length of suite name
-const int MAX_CIPHERS = 32; // max supported ciphers for cipher list
-const int SIZEOF_ENUM = 1; // SSL considers an enum 1 byte, not 4
-const int SIZEOF_SENDER = 4; // Sender constant, for finished generation
-const int PAD_MD5 = 48; // pad length 1 and 2 for md5 finished
-const int PAD_SHA = 40; // should be 44, specd wrong by netscape
-const int PAD_RMD = 44; // pad length for RIPEMD-160, some use 40??
-const int CERT_HEADER = 3; // always use 3 bytes for certificate
-const int CERT_TYPES = 7; // certificate request types
-const int REQUEST_HEADER = 2; // request uses 2 bytes
-const int VERIFY_HEADER = 2; // verify length field
-const int MIN_CERT_TYPES = 1; // minimum certificate request types
-const int MIN_DIS_NAMES = 3; // minimum distinguished names
-const int MIN_DIS_SIZE = 1; // minimum distinguished name size
-const int RECORD_HEADER = 5; // type + version + length(2)
-const int HANDSHAKE_HEADER = 4; // type + length(3)
-const int FINISHED_SZ = MD5_LEN + SHA_LEN; // sizeof finished data
-const int TLS_FINISHED_SZ = 12; // TLS verify data size
-const int SEQ_SZ = 8; // 64 bit sequence number
-const int LENGTH_SZ = 2; // length field for HMAC, data only
-const int VERSION_SZ = SIZEOF_ENUM * 2; // SSL/TLS length of version
-const int DES_KEY_SZ = 8; // DES Key length
-const int DES_EDE_KEY_SZ = 24; // DES EDE Key length
-const int DES_BLOCK = 8; // DES is always fixed block size 8
-const int DES_IV_SZ = DES_BLOCK; // Init Vector length for DES
-const int RC4_KEY_SZ = 16; // RC4 Key length
-const int AES_128_KEY_SZ = 16; // AES 128bit Key length
-const int AES_192_KEY_SZ = 24; // AES 192bit Key length
-const int AES_256_KEY_SZ = 32; // AES 256bit Key length
-const int AES_BLOCK_SZ = 16; // AES 128bit block size, rfc 3268
-const int AES_IV_SZ = AES_BLOCK_SZ; // AES Init Vector length
-const int DSS_SIG_SZ = 40; // two 20 byte high byte first Integers
-const int DSS_ENCODED_EXTRA = 6; // seqID + len(1) + (intID + len(1)) * 2
-const int EVP_SALT_SZ = 8;
-const int MASTER_LABEL_SZ = 13; // TLS master secret label size
-const int KEY_LABEL_SZ = 13; // TLS key block expansion size
-const int FINISHED_LABEL_SZ = 15; // TLS finished lable length
-const int SEED_LEN = RAN_LEN * 2; // TLS seed, client + server random
-const int DEFAULT_TIMEOUT = 500; // Default Session timeout in seconds
-const int MAX_RECORD_SIZE = 16384; // 2^14, max size by standard
-const int COMPRESS_EXTRA = 1024; // extra compression possible addition
-const int SESSION_FLUSH_COUNT = 256; // when to flush session cache
-
-
-typedef uint8 Cipher; // first byte is always 0x00 for SSLv3 & TLS
-
-typedef opaque Random[RAN_LEN];
-
-typedef opaque* DistinguishedName;
-
-typedef bool IsExportable;
-
-
-enum CompressionMethod { no_compression = 0, zlib = 221 };
-
-enum CipherType { stream, block };
-
-enum CipherChoice { change_cipher_spec_choice = 1 };
-
-enum PublicValueEncoding { implicit_encoding, explicit_encoding };
-
-enum ConnectionEnd { server_end, client_end };
-
-enum AlertLevel { warning = 1, fatal = 2 };
-
-
-
-// Record Layer Header identifier from page 12
-enum ContentType {
- no_type = 0,
- change_cipher_spec = 20,
- alert = 21,
- handshake = 22,
- application_data = 23
-};
-
-
-// HandShake Layer Header identifier from page 20
-enum HandShakeType {
- no_shake = -1,
- hello_request = 0,
- client_hello = 1,
- server_hello = 2,
- certificate = 11,
- server_key_exchange = 12,
- certificate_request = 13,
- server_hello_done = 14,
- certificate_verify = 15,
- client_key_exchange = 16,
- finished = 20
-};
-
-
-// Valid Alert types from page 16/17
-enum AlertDescription {
- close_notify = 0,
- unexpected_message = 10,
- bad_record_mac = 20,
- decompression_failure = 30,
- handshake_failure = 40,
- no_certificate = 41,
- bad_certificate = 42,
- unsupported_certificate = 43,
- certificate_revoked = 44,
- certificate_expired = 45,
- certificate_unknown = 46,
- illegal_parameter = 47
-};
-
-
-// Supported Key Exchange Protocols
-enum KeyExchangeAlgorithm {
- no_kea = 0,
- rsa_kea,
- diffie_hellman_kea,
- fortezza_kea
-};
-
-
-// Supported Authentication Schemes
-enum SignatureAlgorithm {
- anonymous_sa_algo = 0,
- rsa_sa_algo,
- dsa_sa_algo
-};
-
-
-// Valid client certificate request types from page 27
-enum ClientCertificateType {
- rsa_sign = 1,
- dss_sign = 2,
- rsa_fixed_dh = 3,
- dss_fixed_dh = 4,
- rsa_ephemeral_dh = 5,
- dss_ephemeral_dh = 6,
- fortezza_kea_cert = 20
-};
-
-
-// Supported Ciphers from page 43
-enum BulkCipherAlgorithm {
- cipher_null,
- rc4,
- rc2,
- des,
- triple_des, // leading 3 (3des) not valid identifier
- des40,
- idea,
- aes
-};
-
-
-// Supported Message Authentication Codes from page 43
-enum MACAlgorithm {
- no_mac,
- md5,
- sha,
- rmd
-};
-
-
-// Certificate file Type
-enum CertType { Cert = 0, PrivateKey, CA };
-
-
-// all Cipher Suites from pages 41/42
-const Cipher SSL_NULL_WITH_NULL_NULL = 0; // { 0x00, 0x00 }
-const Cipher SSL_RSA_WITH_NULL_MD5 = 1; // { 0x00, 0x01 }
-const Cipher SSL_RSA_WITH_NULL_SHA = 2; // { 0x00, 0x02 }
-const Cipher SSL_RSA_EXPORT_WITH_RC4_40_MD5 = 3; // { 0x00, 0x03 }
-const Cipher SSL_RSA_WITH_RC4_128_MD5 = 4; // { 0x00, 0x04 }
-const Cipher SSL_RSA_WITH_RC4_128_SHA = 5; // { 0x00, 0x05 }
-const Cipher SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 6; // { 0x00, 0x06 }
-const Cipher SSL_RSA_WITH_IDEA_CBC_SHA = 7; // { 0x00, 0x07 }
-const Cipher SSL_RSA_EXPORT_WITH_DES40_CBC_SHA = 8; // { 0x00, 0x08 }
-const Cipher SSL_RSA_WITH_DES_CBC_SHA = 9; // { 0x00, 0x09 }
-const Cipher SSL_RSA_WITH_3DES_EDE_CBC_SHA = 10; // { 0x00, 0x0A }
-const Cipher SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 11; // { 0x00, 0x0B }
-const Cipher SSL_DH_DSS_WITH_DES_CBC_SHA = 12; // { 0x00, 0x0C }
-const Cipher SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA = 13; // { 0x00, 0x0D }
-const Cipher SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 14; // { 0x00, 0x0E }
-const Cipher SSL_DH_RSA_WITH_DES_CBC_SHA = 15; // { 0x00, 0x0F }
-const Cipher SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA = 16; // { 0x00, 0x10 }
-const Cipher SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 17; // { 0x00, 0x11 }
-const Cipher SSL_DHE_DSS_WITH_DES_CBC_SHA = 18; // { 0x00, 0x12 }
-const Cipher SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 19; // { 0x00, 0x13 }
-const Cipher SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 20; // { 0x00, 0x14 }
-const Cipher SSL_DHE_RSA_WITH_DES_CBC_SHA = 21; // { 0x00, 0x15 }
-const Cipher SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 22; // { 0x00, 0x16 }
-const Cipher SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 = 23; // { 0x00, 0x17 }
-const Cipher SSL_DH_anon_WITH_RC4_128_MD5 = 24; // { 0x00, 0x18 }
-const Cipher SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 25; // { 0x00, 0x19 }
-const Cipher SSL_DH_anon_WITH_DES_CBC_SHA = 26; // { 0x00, 0x1A }
-const Cipher SSL_DH_anon_WITH_3DES_EDE_CBC_SHA = 27; // { 0x00, 0x1B }
-const Cipher SSL_FORTEZZA_KEA_WITH_NULL_SHA = 28; // { 0x00, 0x1C }
-const Cipher SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 29; // { 0x00, 0x1D }
-const Cipher SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 30; // { 0x00, 0x1E }
-
-// .. to 0x2B uses Kerberos Authentication
-
-
-// TLS AES extensions
-const Cipher TLS_RSA_WITH_AES_128_CBC_SHA = 47; // { 0x00, 0x2F }
-const Cipher TLS_DH_DSS_WITH_AES_128_CBC_SHA = 48; // { 0x00, 0x30 }
-const Cipher TLS_DH_RSA_WITH_AES_128_CBC_SHA = 49; // { 0x00, 0x31 }
-const Cipher TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 50; // { 0x00, 0x32 }
-const Cipher TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 51; // { 0x00, 0x33 }
-const Cipher TLS_DH_anon_WITH_AES_128_CBC_SHA = 52; // { 0x00, 0x34 }
-
-const Cipher TLS_RSA_WITH_AES_256_CBC_SHA = 53; // { 0x00, 0x35 }
-const Cipher TLS_DH_DSS_WITH_AES_256_CBC_SHA = 54; // { 0x00, 0x36 }
-const Cipher TLS_DH_RSA_WITH_AES_256_CBC_SHA = 55; // { 0x00, 0x37 }
-const Cipher TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 56; // { 0x00, 0x38 }
-const Cipher TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 57; // { 0x00, 0x39 }
-const Cipher TLS_DH_anon_WITH_AES_256_CBC_SHA = 58; // { 0x00, 0x3A }
-
-
-// OpenPGP extensions
-
-const Cipher TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160 = 114; // { 0x00, 0x72 };
-const Cipher TLS_DHE_DSS_WITH_AES_128_CBC_RMD160 = 115; // { 0x00, 0x73 };
-const Cipher TLS_DHE_DSS_WITH_AES_256_CBC_RMD160 = 116; // { 0x00, 0x74 };
-const Cipher TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160 = 119; // { 0x00, 0x77 };
-const Cipher TLS_DHE_RSA_WITH_AES_128_CBC_RMD160 = 120; // { 0x00, 0x78 };
-const Cipher TLS_DHE_RSA_WITH_AES_256_CBC_RMD160 = 121; // { 0x00, 0x79 };
-const Cipher TLS_RSA_WITH_3DES_EDE_CBC_RMD160 = 124; // { 0x00, 0x7C };
-const Cipher TLS_RSA_WITH_AES_128_CBC_RMD160 = 125; // { 0x00, 0x7D };
-const Cipher TLS_RSA_WITH_AES_256_CBC_RMD160 = 126; // { 0x00, 0x7E };
-
-
-const char* const null_str = "";
-
-const char* const cipher_names[128] =
-{
- null_str, // SSL_NULL_WITH_NULL_NULL = 0
- null_str, // SSL_RSA_WITH_NULL_MD5 = 1
- null_str, // SSL_RSA_WITH_NULL_SHA = 2
- null_str, // SSL_RSA_EXPORT_WITH_RC4_40_MD5 = 3
- "RC4-MD5", // SSL_RSA_WITH_RC4_128_MD5 = 4
- "RC4-SHA", // SSL_RSA_WITH_RC4_128_SHA = 5
- null_str, // SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 6
- null_str, // SSL_RSA_WITH_IDEA_CBC_SHA = 7
- null_str, // SSL_RSA_EXPORT_WITH_DES40_CBC_SHA = 8
- "DES-CBC-SHA", // SSL_RSA_WITH_DES_CBC_SHA = 9
- "DES-CBC3-SHA", // SSL_RSA_WITH_3DES_EDE_CBC_SHA = 10
-
- null_str, // SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 11
- null_str, // SSL_DH_DSS_WITH_DES_CBC_SHA = 12
- null_str, // SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA = 13
- null_str, // SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 14
- null_str, // SSL_DH_RSA_WITH_DES_CBC_SHA = 15
- null_str, // SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA = 16
- null_str, // SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 17
- "EDH-DSS-DES-CBC-SHA", // SSL_DHE_DSS_WITH_DES_CBC_SHA = 18
- "EDH-DSS-DES-CBC3-SHA", // SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 19
- null_str, // SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 20
-
- "EDH-RSA-DES-CBC-SHA", // SSL_DHE_RSA_WITH_DES_CBC_SHA = 21
- "EDH-RSA-DES-CBC3-SHA", // SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 22
- null_str, // SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 = 23
- null_str, // SSL_DH_anon_WITH_RC4_128_MD5 = 24
- null_str, // SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 25
- null_str, // SSL_DH_anon_WITH_DES_CBC_SHA = 26
- null_str, // SSL_DH_anon_WITH_3DES_EDE_CBC_SHA = 27
- null_str, // SSL_FORTEZZA_KEA_WITH_NULL_SHA = 28
- null_str, // SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 29
- null_str, // SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 30
-
- null_str, null_str, null_str, null_str, null_str, // 31 - 35
- null_str, null_str, null_str, null_str, null_str, // 36 - 40
- null_str, null_str, null_str, null_str, null_str, // 41 - 45
- null_str, // 46
-
- // TLS AES extensions
- "AES128-SHA", // TLS_RSA_WITH_AES_128_CBC_SHA = 47
- null_str, // TLS_DH_DSS_WITH_AES_128_CBC_SHA = 48
- null_str, // TLS_DH_RSA_WITH_AES_128_CBC_SHA = 49
- "DHE-DSS-AES128-SHA", // TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 50
- "DHE-RSA-AES128-SHA", // TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 51
- null_str, // TLS_DH_anon_WITH_AES_128_CBC_SHA = 52
-
- "AES256-SHA", // TLS_RSA_WITH_AES_256_CBC_SHA = 53
- null_str, // TLS_DH_DSS_WITH_AES_256_CBC_SHA = 54
- null_str, // TLS_DH_RSA_WITH_AES_256_CBC_SHA = 55
- "DHE-DSS-AES256-SHA", // TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 56
- "DHE-RSA-AES256-SHA", // TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 57
- null_str, // TLS_DH_anon_WITH_AES_256_CBC_SHA = 58
-
- null_str, // 59
- null_str, // 60
- null_str, null_str, null_str, null_str, null_str, // 61 - 65
- null_str, null_str, null_str, null_str, null_str, // 66 - 70
- null_str, null_str, null_str, null_str, null_str, // 71 - 75
- null_str, null_str, null_str, null_str, null_str, // 76 - 80
- null_str, null_str, null_str, null_str, null_str, // 81 - 85
- null_str, null_str, null_str, null_str, null_str, // 86 - 90
- null_str, null_str, null_str, null_str, null_str, // 91 - 95
- null_str, null_str, null_str, null_str, null_str, // 96 - 100
- null_str, null_str, null_str, null_str, null_str, // 101 - 105
- null_str, null_str, null_str, null_str, null_str, // 106 - 110
- null_str, null_str, null_str, // 111 - 113
-
- "DHE-DSS-DES-CBC3-RMD", // TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160 = 114
- "DHE-DSS-AES128-RMD", // TLS_DHE_DSS_WITH_AES_128_CBC_RMD160 = 115
- "DHE-DSS-AES256-RMD", // TLS_DHE_DSS_WITH_AES_256_CBC_RMD160 = 116
- null_str, // 117
- null_str, // 118
- "DHE-RSA-DES-CBC3-RMD", // TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160 = 119
- "DHE-RSA-AES128-RMD", // TLS_DHE_RSA_WITH_AES_128_CBC_RMD160 = 120
- "DHE-RSA-AES256-RMD", // TLS_DHE_RSA_WITH_AES_256_CBC_RMD160 = 121
- null_str, // 122
- null_str, // 123
- "DES-CBC3-RMD", // TLS_RSA_WITH_3DES_EDE_CBC_RMD160 = 124
- "AES128-RMD", // TLS_RSA_WITH_AES_128_CBC_RMD160 = 125
- "AES256-RMD", // TLS_RSA_WITH_AES_256_CBC_RMD160 = 126
- null_str // 127
-};
-
-// fill with MD5 pad size since biggest required
-const opaque PAD1[PAD_MD5] = { 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
- 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
- 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
- 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
- 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
- 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36
- };
-const opaque PAD2[PAD_MD5] = { 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
- 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
- 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
- 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
- 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
- 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c
- };
-
-const opaque client[SIZEOF_SENDER] = { 0x43, 0x4C, 0x4E, 0x54 };
-const opaque server[SIZEOF_SENDER] = { 0x53, 0x52, 0x56, 0x52 };
-
-const opaque tls_client[FINISHED_LABEL_SZ + 1] = "client finished";
-const opaque tls_server[FINISHED_LABEL_SZ + 1] = "server finished";
-
-const opaque master_label[MASTER_LABEL_SZ + 1] = "master secret";
-const opaque key_label [KEY_LABEL_SZ + 1] = "key expansion";
-
-
-} // naemspace
-
-#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96
-/*
- gcc 2.96 bails out because of two declarations of byte: yaSSL::byte and
- TaoCrypt::byte. TODO: define global types.hpp and move the declaration of
- 'byte' there.
-*/
-using yaSSL::byte;
-#endif
-
-
-#endif // yaSSL_TYPES_HPP
diff --git a/externals/mysql/extlib/yassl/src/buffer.cpp b/externals/mysql/extlib/yassl/src/buffer.cpp
deleted file mode 100644
index 0c3f23b0cb..0000000000
--- a/externals/mysql/extlib/yassl/src/buffer.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* yaSSL buffer header implements input/output buffers to simulate streaming
- * with SSL types and sockets
- */
-
-
-#include // memcpy
-#include "runtime.hpp"
-#include "buffer.hpp"
-#include "yassl_types.hpp"
-
-namespace yaSSL {
-
-
-
-// Checking Policy should implement a check function that tests whether the
-// index is within the size limit of the array
-
-void Check::check(uint i, uint limit)
-{
- assert(i < limit);
-}
-
-
-void NoCheck::check(uint, uint)
-{
-}
-
-
-/* input_buffer operates like a smart c style array with a checking option,
- * meant to be read from through [] with AUTO index or read().
- * Should only write to at/near construction with assign() or raw (e.g., recv)
- * followed by add_size with the number of elements added by raw write.
- *
- * Not using vector because need checked []access, offset, and the ability to
- * write to the buffer bulk wise and have the correct size
- */
-
-
-input_buffer::input_buffer()
- : size_(0), current_(0), buffer_(0), end_(0)
-{}
-
-
-input_buffer::input_buffer(uint s)
- : size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
-{}
-
-
-// with assign
-input_buffer::input_buffer(uint s, const byte* t, uint len)
- : size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
-{
- assign(t, len);
-}
-
-
-input_buffer::~input_buffer()
-{
- ysArrayDelete(buffer_);
-}
-
-
-// users can pass defualt zero length buffer and then allocate
-void input_buffer::allocate(uint s)
-{
- assert(!buffer_); // find realloc error
- buffer_ = NEW_YS byte[s];
- end_ = buffer_ + s;
-}
-
-
-// for passing to raw writing functions at beginning, then use add_size
-byte* input_buffer::get_buffer() const
-{
- return buffer_;
-}
-
-
-// after a raw write user can set NEW_YS size
-// if you know the size before the write use assign()
-void input_buffer::add_size(uint i)
-{
- check(size_ + i-1, get_capacity());
- size_ += i;
-}
-
-
-uint input_buffer::get_capacity() const
-{
- return end_ - buffer_;
-}
-
-
-uint input_buffer::get_current() const
-{
- return current_;
-}
-
-
-uint input_buffer::get_size() const
-{
- return size_;
-}
-
-
-uint input_buffer::get_remaining() const
-{
- return size_ - current_;
-}
-
-
-void input_buffer::set_current(uint i)
-{
- if (i)
- check(i - 1, size_);
- current_ = i;
-}
-
-
-// read only access through [], advance current
-// user passes in AUTO index for ease of use
-const byte& input_buffer::operator[](uint i)
-{
- assert (i == AUTO);
- check(current_, size_);
- return buffer_[current_++];
-}
-
-
-// end of input test
-bool input_buffer::eof()
-{
- return current_ >= size_;
-}
-
-
-// peek ahead
-byte input_buffer::peek() const
-{
- return buffer_[current_];
-}
-
-
-// write function, should use at/near construction
-void input_buffer::assign(const byte* t, uint s)
-{
- check(current_, get_capacity());
- add_size(s);
- memcpy(&buffer_[current_], t, s);
-}
-
-
-// use read to query input, adjusts current
-void input_buffer::read(byte* dst, uint length)
-{
- check(current_ + length - 1, size_);
- memcpy(dst, &buffer_[current_], length);
- current_ += length;
-}
-
-
-
-/* output_buffer operates like a smart c style array with a checking option.
- * Meant to be written to through [] with AUTO index or write().
- * Size (current) counter increases when written to. Can be constructed with
- * zero length buffer but be sure to allocate before first use.
- * Don't use add write for a couple bytes, use [] instead, way less overhead.
- *
- * Not using vector because need checked []access and the ability to
- * write to the buffer bulk wise and retain correct size
- */
-
-
-output_buffer::output_buffer()
- : current_(0), buffer_(0), end_(0)
-{}
-
-
-// with allocate
-output_buffer::output_buffer(uint s)
- : current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
-{}
-
-
-// with assign
-output_buffer::output_buffer(uint s, const byte* t, uint len)
- : current_(0), buffer_(NEW_YS byte[s]), end_(buffer_+ s)
-{
- write(t, len);
-}
-
-
-output_buffer::~output_buffer()
-{
- ysArrayDelete(buffer_);
-}
-
-
-uint output_buffer::get_size() const
-{
- return current_;
-}
-
-
-uint output_buffer::get_capacity() const
-{
- return end_ - buffer_;
-}
-
-
-void output_buffer::set_current(uint c)
-{
- check(c, get_capacity());
- current_ = c;
-}
-
-
-// users can pass defualt zero length buffer and then allocate
-void output_buffer::allocate(uint s)
-{
- assert(!buffer_); // find realloc error
- buffer_ = NEW_YS byte[s]; end_ = buffer_ + s;
-}
-
-
-// for passing to reading functions when finished
-const byte* output_buffer::get_buffer() const
-{
- return buffer_;
-}
-
-
-// allow write access through [], update current
-// user passes in AUTO as index for ease of use
-byte& output_buffer::operator[](uint i)
-{
- assert(i == AUTO);
- check(current_, get_capacity());
- return buffer_[current_++];
-}
-
-
-// end of output test
-bool output_buffer::eof()
-{
- return current_ >= get_capacity();
-}
-
-
-void output_buffer::write(const byte* t, uint s)
-{
- check(current_ + s - 1, get_capacity());
- memcpy(&buffer_[current_], t, s);
- current_ += s;
-}
-
-
-
-} // naemspace
-
diff --git a/externals/mysql/extlib/yassl/src/cert_wrapper.cpp b/externals/mysql/extlib/yassl/src/cert_wrapper.cpp
deleted file mode 100644
index ebec088226..0000000000
--- a/externals/mysql/extlib/yassl/src/cert_wrapper.cpp
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* The certificate wrapper source implements certificate management functions
- *
- */
-
-#include "runtime.hpp"
-#include "cert_wrapper.hpp"
-#include "yassl_int.hpp"
-#include "error.hpp"
-
-#if defined(USE_CML_LIB)
- #include "cmapi_cpp.h"
-#else
- #include "asn.hpp"
- #include "file.hpp"
-#endif // USE_CML_LIB
-
-
-namespace yaSSL {
-
-
-x509::x509(uint sz) : length_(sz), buffer_(NEW_YS opaque[sz])
-{
-}
-
-
-x509::~x509()
-{
- ysArrayDelete(buffer_);
-}
-
-
-x509::x509(const x509& that) : length_(that.length_),
- buffer_(NEW_YS opaque[length_])
-{
- memcpy(buffer_, that.buffer_, length_);
-}
-
-
-void x509::Swap(x509& that)
-{
- STL::swap(length_, that.length_);
- STL::swap(buffer_, that.buffer_);
-}
-
-
-x509& x509::operator=(const x509& that)
-{
- x509 temp(that);
- Swap(temp);
- return *this;
-}
-
-
-uint x509::get_length() const
-{
- return length_;
-}
-
-
-const opaque* x509::get_buffer() const
-{
- return buffer_;
-}
-
-
-opaque* x509::use_buffer()
-{
- return buffer_;
-}
-
-
-//CertManager
-CertManager::CertManager()
- : peerX509_(0), verifyPeer_(false), verifyNone_(false), failNoCert_(false),
- sendVerify_(false), verifyCallback_(0)
-{}
-
-
-CertManager::~CertManager()
-{
- ysDelete(peerX509_);
-
- STL::for_each(signers_.begin(), signers_.end(), del_ptr_zero()) ;
-
- STL::for_each(peerList_.begin(), peerList_.end(), del_ptr_zero()) ;
-
- STL::for_each(list_.begin(), list_.end(), del_ptr_zero()) ;
-}
-
-
-bool CertManager::verifyPeer() const
-{
- return verifyPeer_;
-}
-
-
-bool CertManager::verifyNone() const
-{
- return verifyNone_;
-}
-
-
-bool CertManager::failNoCert() const
-{
- return failNoCert_;
-}
-
-
-bool CertManager::sendVerify() const
-{
- return sendVerify_;
-}
-
-
-void CertManager::setVerifyPeer()
-{
- verifyPeer_ = true;
-}
-
-
-void CertManager::setVerifyNone()
-{
- verifyNone_ = true;
-}
-
-
-void CertManager::setFailNoCert()
-{
- failNoCert_ = true;
-}
-
-
-void CertManager::setSendVerify()
-{
- sendVerify_ = true;
-}
-
-
-void CertManager::setVerifyCallback(VerifyCallback vc)
-{
- verifyCallback_ = vc;
-}
-
-
-void CertManager::AddPeerCert(x509* x)
-{
- peerList_.push_back(x); // take ownership
-}
-
-
-void CertManager::CopySelfCert(const x509* x)
-{
- if (x)
- list_.push_back(NEW_YS x509(*x));
-}
-
-
-// add to signers
-int CertManager::CopyCaCert(const x509* x)
-{
- TaoCrypt::Source source(x->get_buffer(), x->get_length());
- TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_,
- TaoCrypt::CertDecoder::CA);
-
- if (!cert.GetError().What()) {
- const TaoCrypt::PublicKey& key = cert.GetPublicKey();
- signers_.push_back(NEW_YS TaoCrypt::Signer(key.GetKey(), key.size(),
- cert.GetCommonName(), cert.GetHash()));
- }
- // just don't add, not an error return cert.GetError().What();
- return 0;
-}
-
-
-const x509* CertManager::get_cert() const
-{
- return list_.front();
-}
-
-
-const opaque* CertManager::get_peerKey() const
-{
- return peerPublicKey_.get_buffer();
-}
-
-
-X509* CertManager::get_peerX509() const
-{
- return peerX509_;
-}
-
-
-SignatureAlgorithm CertManager::get_peerKeyType() const
-{
- return peerKeyType_;
-}
-
-
-SignatureAlgorithm CertManager::get_keyType() const
-{
- return keyType_;
-}
-
-
-uint CertManager::get_peerKeyLength() const
-{
- return peerPublicKey_.get_size();
-}
-
-
-const opaque* CertManager::get_privateKey() const
-{
- return privateKey_.get_buffer();
-}
-
-
-uint CertManager::get_privateKeyLength() const
-{
- return privateKey_.get_size();
-}
-
-
-// Validate the peer's certificate list, from root to peer (last to first)
-int CertManager::Validate()
-{
- CertList::reverse_iterator last = peerList_.rbegin();
- size_t count = peerList_.size();
-
- while ( count > 1 ) {
- TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());
- TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
-
- if (int err = cert.GetError().What())
- return err;
-
- const TaoCrypt::PublicKey& key = cert.GetPublicKey();
- signers_.push_back(NEW_YS TaoCrypt::Signer(key.GetKey(), key.size(),
- cert.GetCommonName(), cert.GetHash()));
- ++last;
- --count;
- }
-
- if (count) {
- // peer's is at the front
- TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());
- TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
-
- int err = cert.GetError().What();
- if ( err )
- return err;
-
- uint sz = cert.GetPublicKey().size();
- peerPublicKey_.allocate(sz);
- peerPublicKey_.assign(cert.GetPublicKey().GetKey(), sz);
-
- if (cert.GetKeyType() == TaoCrypt::RSAk)
- peerKeyType_ = rsa_sa_algo;
- else
- peerKeyType_ = dsa_sa_algo;
-
- size_t iSz = strlen(cert.GetIssuer()) + 1;
- size_t sSz = strlen(cert.GetCommonName()) + 1;
- int bSz = (int)strlen(cert.GetBeforeDate()) + 1;
- int aSz = (int)strlen(cert.GetAfterDate()) + 1;
- peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(),
- sSz, cert.GetBeforeDate(), bSz,
- cert.GetAfterDate(), aSz);
-
- if (err == TaoCrypt::SIG_OTHER_E && verifyCallback_) {
- X509_STORE_CTX store;
- store.error = err;
- store.error_depth = static_cast(count) - 1;
- store.current_cert = peerX509_;
-
- int ok = verifyCallback_(0, &store);
- if (ok) return 0;
- }
-
- if (err == TaoCrypt::SIG_OTHER_E) return err;
- }
- return 0;
-}
-
-
-// Set the private key
-int CertManager::SetPrivateKey(const x509& key)
-{
- privateKey_.allocate(key.get_length());
- privateKey_.assign(key.get_buffer(), key.get_length());
-
- // set key type
- if (x509* cert = list_.front()) {
- TaoCrypt::Source source(cert->get_buffer(), cert->get_length());
- TaoCrypt::CertDecoder cd(source, false);
- cd.DecodeToKey();
- if (int err = cd.GetError().What())
- return err;
- if (cd.GetKeyType() == TaoCrypt::RSAk)
- keyType_ = rsa_sa_algo;
- else
- keyType_ = dsa_sa_algo;
- }
- return 0;
-}
-
-
-// Store OpenSSL type peer's cert
-void CertManager::setPeerX509(X509* x)
-{
- assert(peerX509_ == 0);
- if (x == 0) return;
-
- X509_NAME* issuer = x->GetIssuer();
- X509_NAME* subject = x->GetSubject();
- ASN1_STRING* before = x->GetBefore();
- ASN1_STRING* after = x->GetAfter();
-
- peerX509_ = NEW_YS X509(issuer->GetName(), issuer->GetLength(),
- subject->GetName(), subject->GetLength(), (const char*) before->data,
- before->length, (const char*) after->data, after->length);
-}
-
-
-#if defined(USE_CML_LIB)
-
-// Get the peer's certificate, extract and save public key
-void CertManager::SetPeerKey()
-{
- // first cert is the peer's
- x509* main = peerList_.front();
-
- Bytes_struct cert;
- cert.num = main->get_length();
- cert.data = main->set_buffer();
-
- CML::Certificate cm(cert);
- const CML::ASN::Cert& raw = cm.base();
- CTIL::CSM_Buffer key = raw.pubKeyInfo.key;
-
- uint sz;
- opaque* key_buffer = reinterpret_cast(key.Get(sz));
- peerPublicKey_.allocate(sz);
- peerPublicKey_.assign(key_buffer, sz);
-}
-
-
-#endif // USE_CML_LIB
-
-
-
-} // namespace
diff --git a/externals/mysql/extlib/yassl/src/crypto_wrapper.cpp b/externals/mysql/extlib/yassl/src/crypto_wrapper.cpp
deleted file mode 100644
index 28d7f1b569..0000000000
--- a/externals/mysql/extlib/yassl/src/crypto_wrapper.cpp
+++ /dev/null
@@ -1,1013 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* The crypto wrapper source implements the policies for the cipher
- * components used by SSL.
- *
- * The implementation relies on a specfic library, taoCrypt.
- */
-
-#if !defined(USE_CRYPTOPP_LIB)
-
-#include "runtime.hpp"
-#include "crypto_wrapper.hpp"
-#include "cert_wrapper.hpp"
-
-#include "md5.hpp"
-#include "sha.hpp"
-#include "ripemd.hpp"
-#include "hmac.hpp"
-#include "modes.hpp"
-#include "des.hpp"
-#include "arc4.hpp"
-#include "aes.hpp"
-#include "rsa.hpp"
-#include "dsa.hpp"
-#include "dh.hpp"
-#include "random.hpp"
-#include "file.hpp"
-#include "coding.hpp"
-
-
-namespace yaSSL {
-
-
-// MD5 Implementation
-struct MD5::MD5Impl {
- TaoCrypt::MD5 md5_;
- MD5Impl() {}
- explicit MD5Impl(const TaoCrypt::MD5& md5) : md5_(md5) {}
-};
-
-
-MD5::MD5() : pimpl_(NEW_YS MD5Impl) {}
-
-
-MD5::~MD5() { ysDelete(pimpl_); }
-
-
-MD5::MD5(const MD5& that) : Digest(), pimpl_(NEW_YS
- MD5Impl(that.pimpl_->md5_)) {}
-
-
-MD5& MD5::operator=(const MD5& that)
-{
- pimpl_->md5_ = that.pimpl_->md5_;
- return *this;
-}
-
-
-uint MD5::get_digestSize() const
-{
- return MD5_LEN;
-}
-
-
-uint MD5::get_padSize() const
-{
- return PAD_MD5;
-}
-
-
-// Fill out with MD5 digest from in that is sz bytes, out must be >= digest sz
-void MD5::get_digest(byte* out, const byte* in, unsigned int sz)
-{
- pimpl_->md5_.Update(in, sz);
- pimpl_->md5_.Final(out);
-}
-
-// Fill out with MD5 digest from previous updates
-void MD5::get_digest(byte* out)
-{
- pimpl_->md5_.Final(out);
-}
-
-
-// Update the current digest
-void MD5::update(const byte* in, unsigned int sz)
-{
- pimpl_->md5_.Update(in, sz);
-}
-
-
-// SHA Implementation
-struct SHA::SHAImpl {
- TaoCrypt::SHA sha_;
- SHAImpl() {}
- explicit SHAImpl(const TaoCrypt::SHA& sha) : sha_(sha) {}
-};
-
-
-SHA::SHA() : pimpl_(NEW_YS SHAImpl) {}
-
-
-SHA::~SHA() { ysDelete(pimpl_); }
-
-
-SHA::SHA(const SHA& that) : Digest(), pimpl_(NEW_YS SHAImpl(that.pimpl_->sha_)) {}
-
-SHA& SHA::operator=(const SHA& that)
-{
- pimpl_->sha_ = that.pimpl_->sha_;
- return *this;
-}
-
-
-uint SHA::get_digestSize() const
-{
- return SHA_LEN;
-}
-
-
-uint SHA::get_padSize() const
-{
- return PAD_SHA;
-}
-
-
-// Fill out with SHA digest from in that is sz bytes, out must be >= digest sz
-void SHA::get_digest(byte* out, const byte* in, unsigned int sz)
-{
- pimpl_->sha_.Update(in, sz);
- pimpl_->sha_.Final(out);
-}
-
-
-// Fill out with SHA digest from previous updates
-void SHA::get_digest(byte* out)
-{
- pimpl_->sha_.Final(out);
-}
-
-
-// Update the current digest
-void SHA::update(const byte* in, unsigned int sz)
-{
- pimpl_->sha_.Update(in, sz);
-}
-
-
-// RMD-160 Implementation
-struct RMD::RMDImpl {
- TaoCrypt::RIPEMD160 rmd_;
- RMDImpl() {}
- explicit RMDImpl(const TaoCrypt::RIPEMD160& rmd) : rmd_(rmd) {}
-};
-
-
-RMD::RMD() : pimpl_(NEW_YS RMDImpl) {}
-
-
-RMD::~RMD() { ysDelete(pimpl_); }
-
-
-RMD::RMD(const RMD& that) : Digest(), pimpl_(NEW_YS RMDImpl(that.pimpl_->rmd_)) {}
-
-RMD& RMD::operator=(const RMD& that)
-{
- pimpl_->rmd_ = that.pimpl_->rmd_;
- return *this;
-}
-
-
-uint RMD::get_digestSize() const
-{
- return RMD_LEN;
-}
-
-
-uint RMD::get_padSize() const
-{
- return PAD_RMD;
-}
-
-
-// Fill out with RMD digest from in that is sz bytes, out must be >= digest sz
-void RMD::get_digest(byte* out, const byte* in, unsigned int sz)
-{
- pimpl_->rmd_.Update(in, sz);
- pimpl_->rmd_.Final(out);
-}
-
-
-// Fill out with RMD digest from previous updates
-void RMD::get_digest(byte* out)
-{
- pimpl_->rmd_.Final(out);
-}
-
-
-// Update the current digest
-void RMD::update(const byte* in, unsigned int sz)
-{
- pimpl_->rmd_.Update(in, sz);
-}
-
-
-// HMAC_MD5 Implementation
-struct HMAC_MD5::HMAC_MD5Impl {
- TaoCrypt::HMAC mac_;
- HMAC_MD5Impl() {}
-};
-
-
-HMAC_MD5::HMAC_MD5(const byte* secret, unsigned int len)
- : pimpl_(NEW_YS HMAC_MD5Impl)
-{
- pimpl_->mac_.SetKey(secret, len);
-}
-
-
-HMAC_MD5::~HMAC_MD5() { ysDelete(pimpl_); }
-
-
-uint HMAC_MD5::get_digestSize() const
-{
- return MD5_LEN;
-}
-
-
-uint HMAC_MD5::get_padSize() const
-{
- return PAD_MD5;
-}
-
-
-// Fill out with MD5 digest from in that is sz bytes, out must be >= digest sz
-void HMAC_MD5::get_digest(byte* out, const byte* in, unsigned int sz)
-{
- pimpl_->mac_.Update(in, sz);
- pimpl_->mac_.Final(out);
-}
-
-// Fill out with MD5 digest from previous updates
-void HMAC_MD5::get_digest(byte* out)
-{
- pimpl_->mac_.Final(out);
-}
-
-
-// Update the current digest
-void HMAC_MD5::update(const byte* in, unsigned int sz)
-{
- pimpl_->mac_.Update(in, sz);
-}
-
-
-// HMAC_SHA Implementation
-struct HMAC_SHA::HMAC_SHAImpl {
- TaoCrypt::HMAC mac_;
- HMAC_SHAImpl() {}
-};
-
-
-HMAC_SHA::HMAC_SHA(const byte* secret, unsigned int len)
- : pimpl_(NEW_YS HMAC_SHAImpl)
-{
- pimpl_->mac_.SetKey(secret, len);
-}
-
-
-HMAC_SHA::~HMAC_SHA() { ysDelete(pimpl_); }
-
-
-uint HMAC_SHA::get_digestSize() const
-{
- return SHA_LEN;
-}
-
-
-uint HMAC_SHA::get_padSize() const
-{
- return PAD_SHA;
-}
-
-
-// Fill out with SHA digest from in that is sz bytes, out must be >= digest sz
-void HMAC_SHA::get_digest(byte* out, const byte* in, unsigned int sz)
-{
- pimpl_->mac_.Update(in, sz);
- pimpl_->mac_.Final(out);
-}
-
-// Fill out with SHA digest from previous updates
-void HMAC_SHA::get_digest(byte* out)
-{
- pimpl_->mac_.Final(out);
-}
-
-
-// Update the current digest
-void HMAC_SHA::update(const byte* in, unsigned int sz)
-{
- pimpl_->mac_.Update(in, sz);
-}
-
-
-
-// HMAC_RMD Implementation
-struct HMAC_RMD::HMAC_RMDImpl {
- TaoCrypt::HMAC mac_;
- HMAC_RMDImpl() {}
-};
-
-
-HMAC_RMD::HMAC_RMD(const byte* secret, unsigned int len)
- : pimpl_(NEW_YS HMAC_RMDImpl)
-{
- pimpl_->mac_.SetKey(secret, len);
-}
-
-
-HMAC_RMD::~HMAC_RMD() { ysDelete(pimpl_); }
-
-
-uint HMAC_RMD::get_digestSize() const
-{
- return RMD_LEN;
-}
-
-
-uint HMAC_RMD::get_padSize() const
-{
- return PAD_RMD;
-}
-
-
-// Fill out with RMD digest from in that is sz bytes, out must be >= digest sz
-void HMAC_RMD::get_digest(byte* out, const byte* in, unsigned int sz)
-{
- pimpl_->mac_.Update(in, sz);
- pimpl_->mac_.Final(out);
-}
-
-// Fill out with RMD digest from previous updates
-void HMAC_RMD::get_digest(byte* out)
-{
- pimpl_->mac_.Final(out);
-}
-
-
-// Update the current digest
-void HMAC_RMD::update(const byte* in, unsigned int sz)
-{
- pimpl_->mac_.Update(in, sz);
-}
-
-
-struct DES::DESImpl {
- TaoCrypt::DES_CBC_Encryption encryption;
- TaoCrypt::DES_CBC_Decryption decryption;
-};
-
-
-DES::DES() : pimpl_(NEW_YS DESImpl) {}
-
-DES::~DES() { ysDelete(pimpl_); }
-
-
-void DES::set_encryptKey(const byte* k, const byte* iv)
-{
- pimpl_->encryption.SetKey(k, DES_KEY_SZ, iv);
-}
-
-
-void DES::set_decryptKey(const byte* k, const byte* iv)
-{
- pimpl_->decryption.SetKey(k, DES_KEY_SZ, iv);
-}
-
-// DES encrypt plain of length sz into cipher
-void DES::encrypt(byte* cipher, const byte* plain, unsigned int sz)
-{
- pimpl_->encryption.Process(cipher, plain, sz);
-}
-
-
-// DES decrypt cipher of length sz into plain
-void DES::decrypt(byte* plain, const byte* cipher, unsigned int sz)
-{
- pimpl_->decryption.Process(plain, cipher, sz);
-}
-
-
-struct DES_EDE::DES_EDEImpl {
- TaoCrypt::DES_EDE3_CBC_Encryption encryption;
- TaoCrypt::DES_EDE3_CBC_Decryption decryption;
-};
-
-
-DES_EDE::DES_EDE() : pimpl_(NEW_YS DES_EDEImpl) {}
-
-DES_EDE::~DES_EDE() { ysDelete(pimpl_); }
-
-
-void DES_EDE::set_encryptKey(const byte* k, const byte* iv)
-{
- pimpl_->encryption.SetKey(k, DES_EDE_KEY_SZ, iv);
-}
-
-
-void DES_EDE::set_decryptKey(const byte* k, const byte* iv)
-{
- pimpl_->decryption.SetKey(k, DES_EDE_KEY_SZ, iv);
-}
-
-
-// 3DES encrypt plain of length sz into cipher
-void DES_EDE::encrypt(byte* cipher, const byte* plain, unsigned int sz)
-{
- pimpl_->encryption.Process(cipher, plain, sz);
-}
-
-
-// 3DES decrypt cipher of length sz into plain
-void DES_EDE::decrypt(byte* plain, const byte* cipher, unsigned int sz)
-{
- pimpl_->decryption.Process(plain, cipher, sz);
-}
-
-
-// Implementation of alledged RC4
-struct RC4::RC4Impl {
- TaoCrypt::ARC4::Encryption encryption;
- TaoCrypt::ARC4::Decryption decryption;
-};
-
-
-RC4::RC4() : pimpl_(NEW_YS RC4Impl) {}
-
-RC4::~RC4() { ysDelete(pimpl_); }
-
-
-void RC4::set_encryptKey(const byte* k, const byte*)
-{
- pimpl_->encryption.SetKey(k, RC4_KEY_SZ);
-}
-
-
-void RC4::set_decryptKey(const byte* k, const byte*)
-{
- pimpl_->decryption.SetKey(k, RC4_KEY_SZ);
-}
-
-
-// RC4 encrypt plain of length sz into cipher
-void RC4::encrypt(byte* cipher, const byte* plain, unsigned int sz)
-{
- pimpl_->encryption.Process(cipher, plain, sz);
-}
-
-
-// RC4 decrypt cipher of length sz into plain
-void RC4::decrypt(byte* plain, const byte* cipher, unsigned int sz)
-{
- pimpl_->decryption.Process(plain, cipher, sz);
-}
-
-
-
-// Implementation of AES
-struct AES::AESImpl {
- TaoCrypt::AES_CBC_Encryption encryption;
- TaoCrypt::AES_CBC_Decryption decryption;
- unsigned int keySz_;
-
- AESImpl(unsigned int ks) : keySz_(ks) {}
-};
-
-
-AES::AES(unsigned int ks) : pimpl_(NEW_YS AESImpl(ks)) {}
-
-AES::~AES() { ysDelete(pimpl_); }
-
-
-int AES::get_keySize() const
-{
- return pimpl_->keySz_;
-}
-
-
-void AES::set_encryptKey(const byte* k, const byte* iv)
-{
- pimpl_->encryption.SetKey(k, pimpl_->keySz_, iv);
-}
-
-
-void AES::set_decryptKey(const byte* k, const byte* iv)
-{
- pimpl_->decryption.SetKey(k, pimpl_->keySz_, iv);
-}
-
-
-// AES encrypt plain of length sz into cipher
-void AES::encrypt(byte* cipher, const byte* plain, unsigned int sz)
-{
- pimpl_->encryption.Process(cipher, plain, sz);
-}
-
-
-// AES decrypt cipher of length sz into plain
-void AES::decrypt(byte* plain, const byte* cipher, unsigned int sz)
-{
- pimpl_->decryption.Process(plain, cipher, sz);
-}
-
-
-struct RandomPool::RandomImpl {
- TaoCrypt::RandomNumberGenerator RNG_;
-};
-
-RandomPool::RandomPool() : pimpl_(NEW_YS RandomImpl) {}
-
-RandomPool::~RandomPool() { ysDelete(pimpl_); }
-
-int RandomPool::GetError() const
-{
- return pimpl_->RNG_.GetError();
-}
-
-void RandomPool::Fill(opaque* dst, uint sz) const
-{
- pimpl_->RNG_.GenerateBlock(dst, sz);
-}
-
-
-// Implementation of DSS Authentication
-struct DSS::DSSImpl {
- void SetPublic (const byte*, unsigned int);
- void SetPrivate(const byte*, unsigned int);
- TaoCrypt::DSA_PublicKey publicKey_;
- TaoCrypt::DSA_PrivateKey privateKey_;
-};
-
-
-// Decode and store the public key
-void DSS::DSSImpl::SetPublic(const byte* key, unsigned int sz)
-{
- TaoCrypt::Source source(key, sz);
- publicKey_.Initialize(source);
-}
-
-
-// Decode and store the public key
-void DSS::DSSImpl::SetPrivate(const byte* key, unsigned int sz)
-{
- TaoCrypt::Source source(key, sz);
- privateKey_.Initialize(source);
- publicKey_ = TaoCrypt::DSA_PublicKey(privateKey_);
-
-}
-
-
-// Set public or private key
-DSS::DSS(const byte* key, unsigned int sz, bool publicKey)
- : pimpl_(NEW_YS DSSImpl)
-{
- if (publicKey)
- pimpl_->SetPublic(key, sz);
- else
- pimpl_->SetPrivate(key, sz);
-}
-
-
-DSS::~DSS()
-{
- ysDelete(pimpl_);
-}
-
-
-uint DSS::get_signatureLength() const
-{
- return pimpl_->publicKey_.SignatureLength();
-}
-
-
-// DSS Sign message of length sz into sig
-void DSS::sign(byte* sig, const byte* sha_digest, unsigned int /* shaSz */,
- const RandomPool& random)
-{
- using namespace TaoCrypt;
-
- DSA_Signer signer(pimpl_->privateKey_);
- signer.Sign(sha_digest, sig, random.pimpl_->RNG_);
-}
-
-
-// DSS Verify message of length sz against sig, is it correct?
-bool DSS::verify(const byte* sha_digest, unsigned int /* shaSz */,
- const byte* sig, unsigned int /* sigSz */)
-{
- using namespace TaoCrypt;
-
- DSA_Verifier ver(pimpl_->publicKey_);
- return ver.Verify(sha_digest, sig);
-}
-
-
-// Implementation of RSA key interface
-struct RSA::RSAImpl {
- void SetPublic (const byte*, unsigned int);
- void SetPrivate(const byte*, unsigned int);
- TaoCrypt::RSA_PublicKey publicKey_;
- TaoCrypt::RSA_PrivateKey privateKey_;
-};
-
-
-// Decode and store the public key
-void RSA::RSAImpl::SetPublic(const byte* key, unsigned int sz)
-{
- TaoCrypt::Source source(key, sz);
- publicKey_.Initialize(source);
-}
-
-
-// Decode and store the private key
-void RSA::RSAImpl::SetPrivate(const byte* key, unsigned int sz)
-{
- TaoCrypt::Source source(key, sz);
- privateKey_.Initialize(source);
- publicKey_ = TaoCrypt::RSA_PublicKey(privateKey_);
-}
-
-
-// Set public or private key
-RSA::RSA(const byte* key, unsigned int sz, bool publicKey)
- : pimpl_(NEW_YS RSAImpl)
-{
- if (publicKey)
- pimpl_->SetPublic(key, sz);
- else
- pimpl_->SetPrivate(key, sz);
-}
-
-RSA::~RSA()
-{
- ysDelete(pimpl_);
-}
-
-
-// get cipher text length, varies on key size
-unsigned int RSA::get_cipherLength() const
-{
- return pimpl_->publicKey_.FixedCiphertextLength();
-}
-
-
-// get signautre length, varies on key size
-unsigned int RSA::get_signatureLength() const
-{
- return get_cipherLength();
-}
-
-
-// RSA Sign message of length sz into sig
-void RSA::sign(byte* sig, const byte* message, unsigned int sz,
- const RandomPool& random)
-{
- TaoCrypt::RSAES_Decryptor dec(pimpl_->privateKey_);
- dec.SSL_Sign(message, sz, sig, random.pimpl_->RNG_);
-}
-
-
-// RSA Verify message of length sz against sig
-bool RSA::verify(const byte* message, unsigned int sz, const byte* sig,
- unsigned int)
-{
- TaoCrypt::RSAES_Encryptor enc(pimpl_->publicKey_);
- return enc.SSL_Verify(message, sz, sig);
-}
-
-
-// RSA public encrypt plain of length sz into cipher
-void RSA::encrypt(byte* cipher, const byte* plain, unsigned int sz,
- const RandomPool& random)
-{
-
- TaoCrypt::RSAES_Encryptor enc(pimpl_->publicKey_);
- enc.Encrypt(plain, sz, cipher, random.pimpl_->RNG_);
-}
-
-
-// RSA private decrypt cipher of length sz into plain
-void RSA::decrypt(byte* plain, const byte* cipher, unsigned int sz,
- const RandomPool& random)
-{
- TaoCrypt::RSAES_Decryptor dec(pimpl_->privateKey_);
- dec.Decrypt(cipher, sz, plain, random.pimpl_->RNG_);
-}
-
-
-struct Integer::IntegerImpl {
- TaoCrypt::Integer int_;
-
- IntegerImpl() {}
- explicit IntegerImpl(const TaoCrypt::Integer& i) : int_(i) {}
-};
-
-Integer::Integer() : pimpl_(NEW_YS IntegerImpl) {}
-
-Integer::~Integer() { ysDelete(pimpl_); }
-
-
-
-Integer::Integer(const Integer& other) : pimpl_(NEW_YS
- IntegerImpl(other.pimpl_->int_))
-{}
-
-
-Integer& Integer::operator=(const Integer& that)
-{
- pimpl_->int_ = that.pimpl_->int_;
-
- return *this;
-}
-
-
-void Integer::assign(const byte* num, unsigned int sz)
-{
- pimpl_->int_ = TaoCrypt::Integer(num, sz);
-}
-
-
-struct DiffieHellman::DHImpl {
- TaoCrypt::DH dh_;
- TaoCrypt::RandomNumberGenerator& ranPool_;
- byte* publicKey_;
- byte* privateKey_;
- byte* agreedKey_;
-
- DHImpl(TaoCrypt::RandomNumberGenerator& r) : ranPool_(r), publicKey_(0),
- privateKey_(0), agreedKey_(0) {}
- ~DHImpl()
- {
- ysArrayDelete(agreedKey_);
- ysArrayDelete(privateKey_);
- ysArrayDelete(publicKey_);
- }
-
- DHImpl(const DHImpl& that) : dh_(that.dh_), ranPool_(that.ranPool_),
- publicKey_(0), privateKey_(0), agreedKey_(0)
- {
- uint length = dh_.GetByteLength();
- AllocKeys(length, length, length);
- }
-
- void AllocKeys(unsigned int pubSz, unsigned int privSz, unsigned int agrSz)
- {
- publicKey_ = NEW_YS byte[pubSz];
- privateKey_ = NEW_YS byte[privSz];
- agreedKey_ = NEW_YS byte[agrSz];
- }
-};
-
-
-
-/*
-// server Side DH, server's view
-DiffieHellman::DiffieHellman(const char* file, const RandomPool& random)
- : pimpl_(NEW_YS DHImpl(random.pimpl_->RNG_))
-{
- using namespace TaoCrypt;
- Source source;
- FileSource(file, source);
- if (source.size() == 0)
- return; // TODO add error state, and force check
- HexDecoder hd(source);
-
- pimpl_->dh_.Initialize(source);
-
- uint length = pimpl_->dh_.GetByteLength();
-
- pimpl_->AllocKeys(length, length, length);
- pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,
- pimpl_->publicKey_);
-}
-*/
-
-
-// server Side DH, client's view
-DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g,
- unsigned int gSz, const byte* pub,
- unsigned int pubSz, const RandomPool& random)
- : pimpl_(NEW_YS DHImpl(random.pimpl_->RNG_))
-{
- using TaoCrypt::Integer;
-
- pimpl_->dh_.Initialize(Integer(p, pSz).Ref(), Integer(g, gSz).Ref());
- pimpl_->publicKey_ = NEW_YS opaque[pubSz];
- memcpy(pimpl_->publicKey_, pub, pubSz);
-}
-
-
-// Server Side DH, server's view
-DiffieHellman::DiffieHellman(const Integer& p, const Integer& g,
- const RandomPool& random)
-: pimpl_(NEW_YS DHImpl(random.pimpl_->RNG_))
-{
- using TaoCrypt::Integer;
-
- pimpl_->dh_.Initialize(p.pimpl_->int_, g.pimpl_->int_);
-
- uint length = pimpl_->dh_.GetByteLength();
-
- pimpl_->AllocKeys(length, length, length);
- pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,
- pimpl_->publicKey_);
-}
-
-DiffieHellman::~DiffieHellman() { ysDelete(pimpl_); }
-
-
-// Client side and view, use server that for p and g
-DiffieHellman::DiffieHellman(const DiffieHellman& that)
- : pimpl_(NEW_YS DHImpl(*that.pimpl_))
-{
- pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,
- pimpl_->publicKey_);
-}
-
-
-DiffieHellman& DiffieHellman::operator=(const DiffieHellman& that)
-{
- pimpl_->dh_ = that.pimpl_->dh_;
- pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,
- pimpl_->publicKey_);
- return *this;
-}
-
-
-void DiffieHellman::makeAgreement(const byte* other, unsigned int otherSz)
-{
- pimpl_->dh_.Agree(pimpl_->agreedKey_, pimpl_->privateKey_, other, otherSz);
-}
-
-
-uint DiffieHellman::get_agreedKeyLength() const
-{
- return pimpl_->dh_.GetByteLength();
-}
-
-
-const byte* DiffieHellman::get_agreedKey() const
-{
- return pimpl_->agreedKey_;
-}
-
-
-const byte* DiffieHellman::get_publicKey() const
-{
- return pimpl_->publicKey_;
-}
-
-
-void DiffieHellman::set_sizes(int& pSz, int& gSz, int& pubSz) const
-{
- using TaoCrypt::Integer;
- Integer p = pimpl_->dh_.GetP();
- Integer g = pimpl_->dh_.GetG();
-
- pSz = p.ByteCount();
- gSz = g.ByteCount();
- pubSz = pimpl_->dh_.GetByteLength();
-}
-
-
-void DiffieHellman::get_parms(byte* bp, byte* bg, byte* bpub) const
-{
- using TaoCrypt::Integer;
- Integer p = pimpl_->dh_.GetP();
- Integer g = pimpl_->dh_.GetG();
-
- p.Encode(bp, p.ByteCount());
- g.Encode(bg, g.ByteCount());
- memcpy(bpub, pimpl_->publicKey_, pimpl_->dh_.GetByteLength());
-}
-
-
-// convert PEM file to DER x509 type
-x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info)
-{
- using namespace TaoCrypt;
-
- char header[80];
- char footer[80];
-
- if (type == Cert) {
- strncpy(header, "-----BEGIN CERTIFICATE-----", sizeof(header));
- strncpy(footer, "-----END CERTIFICATE-----", sizeof(footer));
- } else {
- strncpy(header, "-----BEGIN RSA PRIVATE KEY-----", sizeof(header));
- strncpy(footer, "-----END RSA PRIVATE KEY-----", sizeof(header));
- }
-
- long begin = -1;
- long end = 0;
- bool foundEnd = false;
-
- char line[80];
-
- while(fgets(line, sizeof(line), file))
- if (strncmp(header, line, strlen(header)) == 0) {
- begin = ftell(file);
- break;
- }
-
- // remove encrypted header if there
- if (fgets(line, sizeof(line), file)) {
- char encHeader[] = "Proc-Type";
- if (strncmp(encHeader, line, strlen(encHeader)) == 0 &&
- fgets(line,sizeof(line), file)) {
-
- char* start = strstr(line, "DES");
- char* finish = strstr(line, ",");
- if (!start)
- start = strstr(line, "AES");
-
- if (!info) return 0;
-
- if ( start && finish && (start < finish)) {
- memcpy(info->name, start, finish - start);
- info->name[finish - start] = 0;
- memcpy(info->iv, finish + 1, sizeof(info->iv));
-
- char* newline = strstr(line, "\r");
- if (!newline) newline = strstr(line, "\n");
- if (newline && (newline > finish)) {
- info->ivSz = newline - (finish + 1);
- info->set = true;
- }
- }
- fgets(line,sizeof(line), file); // get blank line
- begin = ftell(file);
- }
-
- }
-
- while(fgets(line, sizeof(line), file))
- if (strncmp(footer, line, strlen(footer)) == 0) {
- foundEnd = true;
- break;
- }
- else
- end = ftell(file);
-
- if (begin == -1 || !foundEnd)
- return 0;
-
- input_buffer tmp(end - begin);
- fseek(file, begin, SEEK_SET);
- size_t bytes = fread(tmp.get_buffer(), end - begin, 1, file);
- if (bytes != 1)
- return 0;
-
- Source der(tmp.get_buffer(), end - begin);
- Base64Decoder b64Dec(der);
-
- uint sz = der.size();
- mySTL::auto_ptr x(NEW_YS x509(sz));
- memcpy(x->use_buffer(), der.get_buffer(), sz);
-
- return x.release();
-}
-
-
-} // namespace
-
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-namespace yaSSL {
-template void ysDelete(DiffieHellman::DHImpl*);
-template void ysDelete(Integer::IntegerImpl*);
-template void ysDelete(RSA::RSAImpl*);
-template void ysDelete(DSS::DSSImpl*);
-template void ysDelete(RandomPool::RandomImpl*);
-template void ysDelete(AES::AESImpl*);
-template void ysDelete(RC4::RC4Impl*);
-template void ysDelete(DES_EDE::DES_EDEImpl*);
-template void ysDelete(DES::DESImpl*);
-template void ysDelete(HMAC_RMD::HMAC_RMDImpl*);
-template void ysDelete(HMAC_SHA::HMAC_SHAImpl*);
-template void ysDelete(HMAC_MD5::HMAC_MD5Impl*);
-template void ysDelete(RMD::RMDImpl*);
-template void ysDelete(SHA::SHAImpl*);
-template void ysDelete(MD5::MD5Impl*);
-}
-#endif // HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-
-#endif // !USE_CRYPTOPP_LIB
diff --git a/externals/mysql/extlib/yassl/src/dummy.cpp b/externals/mysql/extlib/yassl/src/dummy.cpp
deleted file mode 100644
index 19b7fe887c..0000000000
--- a/externals/mysql/extlib/yassl/src/dummy.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-/*
- To make libtool always use a C++ linker when compiling with yaSSL we need
- to add a dummy C++ file to the source list.
-*/
diff --git a/externals/mysql/extlib/yassl/src/handshake.cpp b/externals/mysql/extlib/yassl/src/handshake.cpp
deleted file mode 100644
index 262b5cb3b8..0000000000
--- a/externals/mysql/extlib/yassl/src/handshake.cpp
+++ /dev/null
@@ -1,1117 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* The handshake source implements functions for creating and reading
- * the various handshake messages.
- */
-
-
-
-#include "runtime.hpp"
-#include "handshake.hpp"
-#include "yassl_int.hpp"
-
-
-namespace yaSSL {
-
-
-
-// Build a client hello message from cipher suites and compression method
-void buildClientHello(SSL& ssl, ClientHello& hello)
-{
- // store for pre master secret
- ssl.useSecurity().use_connection().chVersion_ = hello.client_version_;
-
- ssl.getCrypto().get_random().Fill(hello.random_, RAN_LEN);
- if (ssl.getSecurity().get_resuming()) {
- hello.id_len_ = ID_LEN;
- memcpy(hello.session_id_, ssl.getSecurity().get_resume().GetID(),
- ID_LEN);
- }
- else
- hello.id_len_ = 0;
- hello.suite_len_ = ssl.getSecurity().get_parms().suites_size_;
- memcpy(hello.cipher_suites_, ssl.getSecurity().get_parms().suites_,
- hello.suite_len_);
- hello.comp_len_ = 1;
-
- hello.set_length(sizeof(ProtocolVersion) +
- RAN_LEN +
- hello.id_len_ + sizeof(hello.id_len_) +
- hello.suite_len_ + sizeof(hello.suite_len_) +
- hello.comp_len_ + sizeof(hello.comp_len_));
-}
-
-
-// Build a server hello message
-void buildServerHello(SSL& ssl, ServerHello& hello)
-{
- if (ssl.getSecurity().get_resuming()) {
- memcpy(hello.random_,ssl.getSecurity().get_connection().server_random_,
- RAN_LEN);
- memcpy(hello.session_id_, ssl.getSecurity().get_resume().GetID(),
- ID_LEN);
- }
- else {
- ssl.getCrypto().get_random().Fill(hello.random_, RAN_LEN);
- ssl.getCrypto().get_random().Fill(hello.session_id_, ID_LEN);
- }
- hello.id_len_ = ID_LEN;
- ssl.set_sessionID(hello.session_id_);
-
- hello.cipher_suite_[0] = ssl.getSecurity().get_parms().suite_[0];
- hello.cipher_suite_[1] = ssl.getSecurity().get_parms().suite_[1];
- hello.compression_method_ = hello.compression_method_;
-
- hello.set_length(sizeof(ProtocolVersion) + RAN_LEN + ID_LEN +
- sizeof(hello.id_len_) + SUITE_LEN + SIZEOF_ENUM);
-}
-
-
-// add handshake from buffer into md5 and sha hashes, use handshake header
-void hashHandShake(SSL& ssl, const input_buffer& input, uint sz)
-{
- const opaque* buffer = input.get_buffer() + input.get_current() -
- HANDSHAKE_HEADER;
- sz += HANDSHAKE_HEADER;
- ssl.useHashes().use_MD5().update(buffer, sz);
- ssl.useHashes().use_SHA().update(buffer, sz);
-}
-
-
-// locals
-namespace {
-
-// Write a plaintext record to buffer
-void buildOutput(output_buffer& buffer, const RecordLayerHeader& rlHdr,
- const Message& msg)
-{
- buffer.allocate(RECORD_HEADER + rlHdr.length_);
- buffer << rlHdr << msg;
-}
-
-
-// Write a plaintext record to buffer
-void buildOutput(output_buffer& buffer, const RecordLayerHeader& rlHdr,
- const HandShakeHeader& hsHdr, const HandShakeBase& shake)
-{
- buffer.allocate(RECORD_HEADER + rlHdr.length_);
- buffer << rlHdr << hsHdr << shake;
-}
-
-
-// Build Record Layer header for Message without handshake header
-void buildHeader(SSL& ssl, RecordLayerHeader& rlHeader, const Message& msg)
-{
- ProtocolVersion pv = ssl.getSecurity().get_connection().version_;
- rlHeader.type_ = msg.get_type();
- rlHeader.version_.major_ = pv.major_;
- rlHeader.version_.minor_ = pv.minor_;
- rlHeader.length_ = msg.get_length();
-}
-
-
-// Build HandShake and RecordLayer Headers for handshake output
-void buildHeaders(SSL& ssl, HandShakeHeader& hsHeader,
- RecordLayerHeader& rlHeader, const HandShakeBase& shake)
-{
- int sz = shake.get_length();
-
- hsHeader.set_type(shake.get_type());
- hsHeader.set_length(sz);
-
- ProtocolVersion pv = ssl.getSecurity().get_connection().version_;
- rlHeader.type_ = handshake;
- rlHeader.version_.major_ = pv.major_;
- rlHeader.version_.minor_ = pv.minor_;
- rlHeader.length_ = sz + HANDSHAKE_HEADER;
-}
-
-
-// add handshake from buffer into md5 and sha hashes, exclude record header
-void hashHandShake(SSL& ssl, const output_buffer& output, bool removeIV = false)
-{
- uint sz = output.get_size() - RECORD_HEADER;
-
- const opaque* buffer = output.get_buffer() + RECORD_HEADER;
-
- if (removeIV) { // TLSv1_1 IV
- uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();
- sz -= blockSz;
- buffer += blockSz;
- }
-
- ssl.useHashes().use_MD5().update(buffer, sz);
- ssl.useHashes().use_SHA().update(buffer, sz);
-}
-
-
-// calculate MD5 hash for finished
-void buildMD5(SSL& ssl, Finished& fin, const opaque* sender)
-{
-
- opaque md5_result[MD5_LEN];
- opaque md5_inner[SIZEOF_SENDER + SECRET_LEN + PAD_MD5];
- opaque md5_outer[SECRET_LEN + PAD_MD5 + MD5_LEN];
-
- const opaque* master_secret =
- ssl.getSecurity().get_connection().master_secret_;
-
- // make md5 inner
- memcpy(md5_inner, sender, SIZEOF_SENDER);
- memcpy(&md5_inner[SIZEOF_SENDER], master_secret, SECRET_LEN);
- memcpy(&md5_inner[SIZEOF_SENDER + SECRET_LEN], PAD1, PAD_MD5);
-
- ssl.useHashes().use_MD5().get_digest(md5_result, md5_inner,
- sizeof(md5_inner));
-
- // make md5 outer
- memcpy(md5_outer, master_secret, SECRET_LEN);
- memcpy(&md5_outer[SECRET_LEN], PAD2, PAD_MD5);
- memcpy(&md5_outer[SECRET_LEN + PAD_MD5], md5_result, MD5_LEN);
-
- ssl.useHashes().use_MD5().get_digest(fin.set_md5(), md5_outer,
- sizeof(md5_outer));
-}
-
-
-// calculate SHA hash for finished
-void buildSHA(SSL& ssl, Finished& fin, const opaque* sender)
-{
-
- opaque sha_result[SHA_LEN];
- opaque sha_inner[SIZEOF_SENDER + SECRET_LEN + PAD_SHA];
- opaque sha_outer[SECRET_LEN + PAD_SHA + SHA_LEN];
-
- const opaque* master_secret =
- ssl.getSecurity().get_connection().master_secret_;
-
- // make sha inner
- memcpy(sha_inner, sender, SIZEOF_SENDER);
- memcpy(&sha_inner[SIZEOF_SENDER], master_secret, SECRET_LEN);
- memcpy(&sha_inner[SIZEOF_SENDER + SECRET_LEN], PAD1, PAD_SHA);
-
- ssl.useHashes().use_SHA().get_digest(sha_result, sha_inner,
- sizeof(sha_inner));
-
- // make sha outer
- memcpy(sha_outer, master_secret, SECRET_LEN);
- memcpy(&sha_outer[SECRET_LEN], PAD2, PAD_SHA);
- memcpy(&sha_outer[SECRET_LEN + PAD_SHA], sha_result, SHA_LEN);
-
- ssl.useHashes().use_SHA().get_digest(fin.set_sha(), sha_outer,
- sizeof(sha_outer));
-}
-
-
-// decrypt input message in place, store size in case needed later
-void decrypt_message(SSL& ssl, input_buffer& input, uint sz)
-{
- input_buffer plain(sz);
- opaque* cipher = input.get_buffer() + input.get_current();
-
- ssl.useCrypto().use_cipher().decrypt(plain.get_buffer(), cipher, sz);
- memcpy(cipher, plain.get_buffer(), sz);
- ssl.useSecurity().use_parms().encrypt_size_ = sz;
-
- if (ssl.isTLSv1_1()) // IV
- input.set_current(input.get_current() +
- ssl.getCrypto().get_cipher().get_blockSize());
-}
-
-
-// output operator for input_buffer
-output_buffer& operator<<(output_buffer& output, const input_buffer& input)
-{
- output.write(input.get_buffer(), input.get_size());
- return output;
-}
-
-
-// write headers, handshake hash, mac, pad, and encrypt
-void cipherFinished(SSL& ssl, Finished& fin, output_buffer& output)
-{
- uint digestSz = ssl.getCrypto().get_digest().get_digestSize();
- uint finishedSz = ssl.isTLS() ? TLS_FINISHED_SZ : FINISHED_SZ;
- uint sz = RECORD_HEADER + HANDSHAKE_HEADER + finishedSz + digestSz;
- uint pad = 0;
- uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();
-
- if (ssl.getSecurity().get_parms().cipher_type_ == block) {
- if (ssl.isTLSv1_1())
- sz += blockSz; // IV
- sz += 1; // pad byte
- pad = (sz - RECORD_HEADER) % blockSz;
- pad = blockSz - pad;
- sz += pad;
- }
-
- RecordLayerHeader rlHeader;
- HandShakeHeader hsHeader;
- buildHeaders(ssl, hsHeader, rlHeader, fin);
- rlHeader.length_ = sz - RECORD_HEADER; // record header includes mac
- // and pad, hanshake doesn't
- input_buffer iv;
- if (ssl.isTLSv1_1() && ssl.getSecurity().get_parms().cipher_type_== block){
- iv.allocate(blockSz);
- ssl.getCrypto().get_random().Fill(iv.get_buffer(), blockSz);
- iv.add_size(blockSz);
- }
- uint ivSz = iv.get_size();
- output.allocate(sz);
- output << rlHeader << iv << hsHeader << fin;
-
- hashHandShake(ssl, output, ssl.isTLSv1_1() ? true : false);
- opaque digest[SHA_LEN]; // max size
- if (ssl.isTLS())
- TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER + ivSz,
- output.get_size() - RECORD_HEADER - ivSz, handshake);
- else
- hmac(ssl, digest, output.get_buffer() + RECORD_HEADER,
- output.get_size() - RECORD_HEADER, handshake);
- output.write(digest, digestSz);
-
- if (ssl.getSecurity().get_parms().cipher_type_ == block)
- for (uint i = 0; i <= pad; i++) output[AUTO] = pad; // pad byte gets
- // pad value too
- input_buffer cipher(rlHeader.length_);
- ssl.useCrypto().use_cipher().encrypt(cipher.get_buffer(),
- output.get_buffer() + RECORD_HEADER, output.get_size() - RECORD_HEADER);
- output.set_current(RECORD_HEADER);
- output.write(cipher.get_buffer(), cipher.get_capacity());
-}
-
-
-// build an encrypted data or alert message for output
-void buildMessage(SSL& ssl, output_buffer& output, const Message& msg)
-{
- uint digestSz = ssl.getCrypto().get_digest().get_digestSize();
- uint sz = RECORD_HEADER + msg.get_length() + digestSz;
- uint pad = 0;
- uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();
-
- if (ssl.getSecurity().get_parms().cipher_type_ == block) {
- if (ssl.isTLSv1_1()) // IV
- sz += blockSz;
- sz += 1; // pad byte
- pad = (sz - RECORD_HEADER) % blockSz;
- pad = blockSz - pad;
- sz += pad;
- }
-
- RecordLayerHeader rlHeader;
- buildHeader(ssl, rlHeader, msg);
- rlHeader.length_ = sz - RECORD_HEADER; // record header includes mac
- // and pad, hanshake doesn't
- input_buffer iv;
- if (ssl.isTLSv1_1() && ssl.getSecurity().get_parms().cipher_type_== block){
- iv.allocate(blockSz);
- ssl.getCrypto().get_random().Fill(iv.get_buffer(), blockSz);
- iv.add_size(blockSz);
- }
-
- uint ivSz = iv.get_size();
- output.allocate(sz);
- output << rlHeader << iv << msg;
-
- opaque digest[SHA_LEN]; // max size
- if (ssl.isTLS())
- TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER + ivSz,
- output.get_size() - RECORD_HEADER - ivSz, msg.get_type());
- else
- hmac(ssl, digest, output.get_buffer() + RECORD_HEADER,
- output.get_size() - RECORD_HEADER, msg.get_type());
- output.write(digest, digestSz);
-
- if (ssl.getSecurity().get_parms().cipher_type_ == block)
- for (uint i = 0; i <= pad; i++) output[AUTO] = pad; // pad byte gets
- // pad value too
- input_buffer cipher(rlHeader.length_);
- ssl.useCrypto().use_cipher().encrypt(cipher.get_buffer(),
- output.get_buffer() + RECORD_HEADER, output.get_size() - RECORD_HEADER);
- output.set_current(RECORD_HEADER);
- output.write(cipher.get_buffer(), cipher.get_capacity());
-}
-
-
-// build alert message
-void buildAlert(SSL& ssl, output_buffer& output, const Alert& alert)
-{
- if (ssl.getSecurity().get_parms().pending_ == false) // encrypted
- buildMessage(ssl, output, alert);
- else {
- RecordLayerHeader rlHeader;
- buildHeader(ssl, rlHeader, alert);
- buildOutput(output, rlHeader, alert);
- }
-}
-
-
-// build TLS finished message
-void buildFinishedTLS(SSL& ssl, Finished& fin, const opaque* sender)
-{
- opaque handshake_hash[FINISHED_SZ];
-
- ssl.useHashes().use_MD5().get_digest(handshake_hash);
- ssl.useHashes().use_SHA().get_digest(&handshake_hash[MD5_LEN]);
-
- const opaque* side;
- if ( strncmp((const char*)sender, (const char*)client, SIZEOF_SENDER) == 0)
- side = tls_client;
- else
- side = tls_server;
-
- PRF(fin.set_md5(), TLS_FINISHED_SZ,
- ssl.getSecurity().get_connection().master_secret_, SECRET_LEN,
- side, FINISHED_LABEL_SZ,
- handshake_hash, FINISHED_SZ);
-
- fin.set_length(TLS_FINISHED_SZ); // shorter length for TLS
-}
-
-
-// compute p_hash for MD5 or SHA-1 for TLSv1 PRF
-void p_hash(output_buffer& result, const output_buffer& secret,
- const output_buffer& seed, MACAlgorithm hash)
-{
- uint len = hash == md5 ? MD5_LEN : SHA_LEN;
- uint times = result.get_capacity() / len;
- uint lastLen = result.get_capacity() % len;
- opaque previous[SHA_LEN]; // max size
- opaque current[SHA_LEN]; // max size
- mySTL::auto_ptr hmac;
-
- if (lastLen) times += 1;
-
- if (hash == md5)
- hmac.reset(NEW_YS HMAC_MD5(secret.get_buffer(), secret.get_size()));
- else
- hmac.reset(NEW_YS HMAC_SHA(secret.get_buffer(), secret.get_size()));
- // A0 = seed
- hmac->get_digest(previous, seed.get_buffer(), seed.get_size());// A1
- uint lastTime = times - 1;
-
- for (uint i = 0; i < times; i++) {
- hmac->update(previous, len);
- hmac->get_digest(current, seed.get_buffer(), seed.get_size());
-
- if (lastLen && (i == lastTime))
- result.write(current, lastLen);
- else {
- result.write(current, len);
- //memcpy(previous, current, len);
- hmac->get_digest(previous, previous, len);
- }
- }
-}
-
-
-// calculate XOR for TLSv1 PRF
-void get_xor(byte *digest, uint digLen, output_buffer& md5,
- output_buffer& sha)
-{
- for (uint i = 0; i < digLen; i++)
- digest[i] = md5[AUTO] ^ sha[AUTO];
-}
-
-
-// build MD5 part of certificate verify
-void buildMD5_CertVerify(SSL& ssl, byte* digest)
-{
- opaque md5_result[MD5_LEN];
- opaque md5_inner[SECRET_LEN + PAD_MD5];
- opaque md5_outer[SECRET_LEN + PAD_MD5 + MD5_LEN];
-
- const opaque* master_secret =
- ssl.getSecurity().get_connection().master_secret_;
-
- // make md5 inner
- memcpy(md5_inner, master_secret, SECRET_LEN);
- memcpy(&md5_inner[SECRET_LEN], PAD1, PAD_MD5);
-
- ssl.useHashes().use_MD5().get_digest(md5_result, md5_inner,
- sizeof(md5_inner));
-
- // make md5 outer
- memcpy(md5_outer, master_secret, SECRET_LEN);
- memcpy(&md5_outer[SECRET_LEN], PAD2, PAD_MD5);
- memcpy(&md5_outer[SECRET_LEN + PAD_MD5], md5_result, MD5_LEN);
-
- ssl.useHashes().use_MD5().get_digest(digest, md5_outer, sizeof(md5_outer));
-}
-
-
-// build SHA part of certificate verify
-void buildSHA_CertVerify(SSL& ssl, byte* digest)
-{
- opaque sha_result[SHA_LEN];
- opaque sha_inner[SECRET_LEN + PAD_SHA];
- opaque sha_outer[SECRET_LEN + PAD_SHA + SHA_LEN];
-
- const opaque* master_secret =
- ssl.getSecurity().get_connection().master_secret_;
-
- // make sha inner
- memcpy(sha_inner, master_secret, SECRET_LEN);
- memcpy(&sha_inner[SECRET_LEN], PAD1, PAD_SHA);
-
- ssl.useHashes().use_SHA().get_digest(sha_result, sha_inner,
- sizeof(sha_inner));
-
- // make sha outer
- memcpy(sha_outer, master_secret, SECRET_LEN);
- memcpy(&sha_outer[SECRET_LEN], PAD2, PAD_SHA);
- memcpy(&sha_outer[SECRET_LEN + PAD_SHA], sha_result, SHA_LEN);
-
- ssl.useHashes().use_SHA().get_digest(digest, sha_outer, sizeof(sha_outer));
-}
-
-
-} // namespace for locals
-
-
-// some clients still send sslv2 client hello
-void ProcessOldClientHello(input_buffer& input, SSL& ssl)
-{
- if (input.get_remaining() < 2) {
- ssl.SetError(bad_input);
- return;
- }
- byte b0 = input[AUTO];
- byte b1 = input[AUTO];
-
- uint16 sz = ((b0 & 0x7f) << 8) | b1;
-
- if (sz > input.get_remaining()) {
- ssl.SetError(bad_input);
- return;
- }
-
- // hashHandShake manually
- const opaque* buffer = input.get_buffer() + input.get_current();
- ssl.useHashes().use_MD5().update(buffer, sz);
- ssl.useHashes().use_SHA().update(buffer, sz);
-
- b1 = input[AUTO]; // does this value mean client_hello?
-
- ClientHello ch;
- ch.client_version_.major_ = input[AUTO];
- ch.client_version_.minor_ = input[AUTO];
-
- byte len[2];
-
- input.read(len, sizeof(len));
- ato16(len, ch.suite_len_);
-
- input.read(len, sizeof(len));
- uint16 sessionLen;
- ato16(len, sessionLen);
- ch.id_len_ = sessionLen;
-
- input.read(len, sizeof(len));
- uint16 randomLen;
- ato16(len, randomLen);
- if (ch.suite_len_ > MAX_SUITE_SZ || sessionLen > ID_LEN ||
- randomLen > RAN_LEN) {
- ssl.SetError(bad_input);
- return;
- }
-
- int j = 0;
- for (uint16 i = 0; i < ch.suite_len_; i += 3) {
- byte first = input[AUTO];
- if (first) // sslv2 type
- input.read(len, SUITE_LEN); // skip
- else {
- input.read(&ch.cipher_suites_[j], SUITE_LEN);
- j += SUITE_LEN;
- }
- }
- ch.suite_len_ = j;
-
- if (ch.id_len_)
- input.read(ch.session_id_, ch.id_len_);
-
- if (randomLen < RAN_LEN)
- memset(ch.random_, 0, RAN_LEN - randomLen);
- input.read(&ch.random_[RAN_LEN - randomLen], randomLen);
-
-
- ch.Process(input, ssl);
-}
-
-
-// Build a finished message, see 7.6.9
-void buildFinished(SSL& ssl, Finished& fin, const opaque* sender)
-{
- // store current states, building requires get_digest which resets state
- MD5 md5(ssl.getHashes().get_MD5());
- SHA sha(ssl.getHashes().get_SHA());
-
- if (ssl.isTLS())
- buildFinishedTLS(ssl, fin, sender);
- else {
- buildMD5(ssl, fin, sender);
- buildSHA(ssl, fin, sender);
- }
-
- // restore
- ssl.useHashes().use_MD5() = md5;
- ssl.useHashes().use_SHA() = sha;
-}
-
-
-/* compute SSLv3 HMAC into digest see
- * buffer is of sz size and includes HandShake Header but not a Record Header
- * verify means to check peers hmac
-*/
-void hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz,
- ContentType content, bool verify)
-{
- Digest& mac = ssl.useCrypto().use_digest();
- opaque inner[SHA_LEN + PAD_MD5 + SEQ_SZ + SIZEOF_ENUM + LENGTH_SZ];
- opaque outer[SHA_LEN + PAD_MD5 + SHA_LEN];
- opaque result[SHA_LEN]; // max possible sizes
- uint digestSz = mac.get_digestSize(); // actual sizes
- uint padSz = mac.get_padSize();
- uint innerSz = digestSz + padSz + SEQ_SZ + SIZEOF_ENUM + LENGTH_SZ;
- uint outerSz = digestSz + padSz + digestSz;
-
- // data
- const opaque* mac_secret = ssl.get_macSecret(verify);
- opaque seq[SEQ_SZ] = { 0x00, 0x00, 0x00, 0x00 };
- opaque length[LENGTH_SZ];
- c16toa(sz, length);
- c32toa(ssl.get_SEQIncrement(verify), &seq[sizeof(uint32)]);
-
- // make inner
- memcpy(inner, mac_secret, digestSz);
- memcpy(&inner[digestSz], PAD1, padSz);
- memcpy(&inner[digestSz + padSz], seq, SEQ_SZ);
- inner[digestSz + padSz + SEQ_SZ] = content;
- memcpy(&inner[digestSz + padSz + SEQ_SZ + SIZEOF_ENUM], length, LENGTH_SZ);
-
- mac.update(inner, innerSz);
- mac.get_digest(result, buffer, sz); // append content buffer
-
- // make outer
- memcpy(outer, mac_secret, digestSz);
- memcpy(&outer[digestSz], PAD2, padSz);
- memcpy(&outer[digestSz + padSz], result, digestSz);
-
- mac.get_digest(digest, outer, outerSz);
-}
-
-
-// TLS type HAMC
-void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz,
- ContentType content, bool verify)
-{
- mySTL::auto_ptr hmac;
- opaque seq[SEQ_SZ] = { 0x00, 0x00, 0x00, 0x00 };
- opaque length[LENGTH_SZ];
- opaque inner[SIZEOF_ENUM + VERSION_SZ + LENGTH_SZ]; // type + version + len
-
- c16toa(sz, length);
- c32toa(ssl.get_SEQIncrement(verify), &seq[sizeof(uint32)]);
-
- MACAlgorithm algo = ssl.getSecurity().get_parms().mac_algorithm_;
-
- if (algo == sha)
- hmac.reset(NEW_YS HMAC_SHA(ssl.get_macSecret(verify), SHA_LEN));
- else if (algo == rmd)
- hmac.reset(NEW_YS HMAC_RMD(ssl.get_macSecret(verify), RMD_LEN));
- else
- hmac.reset(NEW_YS HMAC_MD5(ssl.get_macSecret(verify), MD5_LEN));
-
- hmac->update(seq, SEQ_SZ); // seq_num
- inner[0] = content; // type
- inner[SIZEOF_ENUM] = ssl.getSecurity().get_connection().version_.major_;
- inner[SIZEOF_ENUM + SIZEOF_ENUM] =
- ssl.getSecurity().get_connection().version_.minor_; // version
- memcpy(&inner[SIZEOF_ENUM + VERSION_SZ], length, LENGTH_SZ); // length
- hmac->update(inner, sizeof(inner));
- hmac->get_digest(digest, buffer, sz); // content
-}
-
-
-// compute TLSv1 PRF (pseudo random function using HMAC)
-void PRF(byte* digest, uint digLen, const byte* secret, uint secLen,
- const byte* label, uint labLen, const byte* seed, uint seedLen)
-{
- uint half = (secLen + 1) / 2;
-
- output_buffer md5_half(half);
- output_buffer sha_half(half);
- output_buffer labelSeed(labLen + seedLen);
-
- md5_half.write(secret, half);
- sha_half.write(secret + half - secLen % 2, half);
- labelSeed.write(label, labLen);
- labelSeed.write(seed, seedLen);
-
- output_buffer md5_result(digLen);
- output_buffer sha_result(digLen);
-
- p_hash(md5_result, md5_half, labelSeed, md5);
- p_hash(sha_result, sha_half, labelSeed, sha);
-
- md5_result.set_current(0);
- sha_result.set_current(0);
- get_xor(digest, digLen, md5_result, sha_result);
-}
-
-
-// build certificate hashes
-void build_certHashes(SSL& ssl, Hashes& hashes)
-{
- // store current states, building requires get_digest which resets state
- MD5 md5(ssl.getHashes().get_MD5());
- SHA sha(ssl.getHashes().get_SHA());
-
- if (ssl.isTLS()) {
- ssl.useHashes().use_MD5().get_digest(hashes.md5_);
- ssl.useHashes().use_SHA().get_digest(hashes.sha_);
- }
- else {
- buildMD5_CertVerify(ssl, hashes.md5_);
- buildSHA_CertVerify(ssl, hashes.sha_);
- }
-
- // restore
- ssl.useHashes().use_MD5() = md5;
- ssl.useHashes().use_SHA() = sha;
-}
-
-
-
-// do process input requests, return 0 is done, 1 is call again to complete
-int DoProcessReply(SSL& ssl)
-{
- // wait for input if blocking
- if (!ssl.useSocket().wait()) {
- ssl.SetError(receive_error);
- return 0;
- }
- uint ready = ssl.getSocket().get_ready();
- if (!ready) return 1;
-
- // add buffered data if its there
- input_buffer* buffered = ssl.useBuffers().TakeRawInput();
- uint buffSz = buffered ? buffered->get_size() : 0;
- input_buffer buffer(buffSz + ready);
- if (buffSz) {
- buffer.assign(buffered->get_buffer(), buffSz);
- ysDelete(buffered);
- buffered = 0;
- }
-
- // add new data
- uint read = ssl.useSocket().receive(buffer.get_buffer() + buffSz, ready);
- if (read == static_cast(-1)) {
- ssl.SetError(receive_error);
- return 0;
- }
- buffer.add_size(read);
- uint offset = 0;
- const MessageFactory& mf = ssl.getFactory().getMessage();
-
- // old style sslv2 client hello?
- if (ssl.getSecurity().get_parms().entity_ == server_end &&
- ssl.getStates().getServer() == clientNull)
- if (buffer.peek() != handshake) {
- ProcessOldClientHello(buffer, ssl);
- if (ssl.GetError())
- return 0;
- }
-
- while(!buffer.eof()) {
- // each record
- RecordLayerHeader hdr;
- bool needHdr = false;
-
- if (static_cast(RECORD_HEADER) > buffer.get_remaining())
- needHdr = true;
- else {
- buffer >> hdr;
- ssl.verifyState(hdr);
- }
-
- // make sure we have enough input in buffer to process this record
- if (needHdr || hdr.length_ > buffer.get_remaining()) {
- // put header in front for next time processing
- uint extra = needHdr ? 0 : RECORD_HEADER;
- uint sz = buffer.get_remaining() + extra;
- ssl.useBuffers().SetRawInput(NEW_YS input_buffer(sz,
- buffer.get_buffer() + buffer.get_current() - extra, sz));
- return 1;
- }
-
- while (buffer.get_current() < hdr.length_ + RECORD_HEADER + offset) {
- // each message in record, can be more than 1 if not encrypted
- if (ssl.getSecurity().get_parms().pending_ == false) // cipher on
- decrypt_message(ssl, buffer, hdr.length_);
-
- mySTL::auto_ptr msg(mf.CreateObject(hdr.type_));
- if (!msg.get()) {
- ssl.SetError(factory_error);
- return 0;
- }
- buffer >> *msg;
- msg->Process(buffer, ssl);
- if (ssl.GetError())
- return 0;
- }
- offset += hdr.length_ + RECORD_HEADER;
- }
- return 0;
-}
-
-
-// process input requests
-void processReply(SSL& ssl)
-{
- if (ssl.GetError()) return;
-
- if (DoProcessReply(ssl))
- // didn't complete process
- if (!ssl.getSocket().IsNonBlocking()) {
- // keep trying now, blocking ok
- while (!ssl.GetError())
- if (DoProcessReply(ssl) == 0) break;
- }
- else
- // user will have try again later, non blocking
- ssl.SetError(YasslError(SSL_ERROR_WANT_READ));
-}
-
-
-// send client_hello, no buffering
-void sendClientHello(SSL& ssl)
-{
- ssl.verifyState(serverNull);
- if (ssl.GetError()) return;
-
- ClientHello ch(ssl.getSecurity().get_connection().version_,
- ssl.getSecurity().get_connection().compression_);
- RecordLayerHeader rlHeader;
- HandShakeHeader hsHeader;
- output_buffer out;
-
- buildClientHello(ssl, ch);
- ssl.set_random(ch.get_random(), client_end);
- buildHeaders(ssl, hsHeader, rlHeader, ch);
- buildOutput(out, rlHeader, hsHeader, ch);
- hashHandShake(ssl, out);
-
- ssl.Send(out.get_buffer(), out.get_size());
-}
-
-
-// send client key exchange
-void sendClientKeyExchange(SSL& ssl, BufferOutput buffer)
-{
- ssl.verifyState(serverHelloDoneComplete);
- if (ssl.GetError()) return;
-
- ClientKeyExchange ck(ssl);
- ck.build(ssl);
- ssl.makeMasterSecret();
-
- RecordLayerHeader rlHeader;
- HandShakeHeader hsHeader;
- mySTL::auto_ptr out(NEW_YS output_buffer);
- buildHeaders(ssl, hsHeader, rlHeader, ck);
- buildOutput(*out.get(), rlHeader, hsHeader, ck);
- hashHandShake(ssl, *out.get());
-
- if (buffer == buffered)
- ssl.addBuffer(out.release());
- else
- ssl.Send(out->get_buffer(), out->get_size());
-}
-
-
-// send server key exchange
-void sendServerKeyExchange(SSL& ssl, BufferOutput buffer)
-{
- if (ssl.GetError()) return;
- ServerKeyExchange sk(ssl);
- sk.build(ssl);
-
- RecordLayerHeader rlHeader;
- HandShakeHeader hsHeader;
- mySTL::auto_ptr out(NEW_YS output_buffer);
- buildHeaders(ssl, hsHeader, rlHeader, sk);
- buildOutput(*out.get(), rlHeader, hsHeader, sk);
- hashHandShake(ssl, *out.get());
-
- if (buffer == buffered)
- ssl.addBuffer(out.release());
- else
- ssl.Send(out->get_buffer(), out->get_size());
-}
-
-
-// send change cipher
-void sendChangeCipher(SSL& ssl, BufferOutput buffer)
-{
- if (ssl.getSecurity().get_parms().entity_ == server_end)
- if (ssl.getSecurity().get_resuming())
- ssl.verifyState(clientKeyExchangeComplete);
- else
- ssl.verifyState(clientFinishedComplete);
- if (ssl.GetError()) return;
-
- ChangeCipherSpec ccs;
- RecordLayerHeader rlHeader;
- buildHeader(ssl, rlHeader, ccs);
- mySTL::auto_ptr out(NEW_YS output_buffer);
- buildOutput(*out.get(), rlHeader, ccs);
-
- if (buffer == buffered)
- ssl.addBuffer(out.release());
- else
- ssl.Send(out->get_buffer(), out->get_size());
-}
-
-
-// send finished
-void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer)
-{
- if (ssl.GetError()) return;
-
- Finished fin;
- buildFinished(ssl, fin, side == client_end ? client : server);
- mySTL::auto_ptr out(NEW_YS output_buffer);
- cipherFinished(ssl, fin, *out.get()); // hashes handshake
-
- if (ssl.getSecurity().get_resuming()) {
- if (side == server_end)
- buildFinished(ssl, ssl.useHashes().use_verify(), client); // client
- }
- else {
- if (!ssl.getSecurity().GetContext()->GetSessionCacheOff())
- GetSessions().add(ssl); // store session
- if (side == client_end)
- buildFinished(ssl, ssl.useHashes().use_verify(), server); // server
- }
- ssl.useSecurity().use_connection().CleanMaster();
-
- if (buffer == buffered)
- ssl.addBuffer(out.release());
- else
- ssl.Send(out->get_buffer(), out->get_size());
-}
-
-
-// send data
-int sendData(SSL& ssl, const void* buffer, int sz)
-{
- if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))
- ssl.SetError(no_error);
-
- ssl.verfiyHandShakeComplete();
- if (ssl.GetError()) return -1;
- int sent = 0;
-
- for (;;) {
- int len = min(sz - sent, MAX_RECORD_SIZE);
- output_buffer out;
- input_buffer tmp;
-
- Data data;
-
- if (ssl.CompressionOn()) {
- if (Compress(static_cast(buffer) + sent, len,
- tmp) == -1) {
- ssl.SetError(compress_error);
- return -1;
- }
- data.SetData(tmp.get_size(), tmp.get_buffer());
- }
- else
- data.SetData(len, static_cast(buffer) + sent);
-
- buildMessage(ssl, out, data);
- ssl.Send(out.get_buffer(), out.get_size());
-
- if (ssl.GetError()) return -1;
- sent += len;
- if (sent == sz) break;
- }
- ssl.useLog().ShowData(sent, true);
- return sent;
-}
-
-
-// send alert
-int sendAlert(SSL& ssl, const Alert& alert)
-{
- output_buffer out;
- buildAlert(ssl, out, alert);
- ssl.Send(out.get_buffer(), out.get_size());
-
- return alert.get_length();
-}
-
-
-// process input data
-int receiveData(SSL& ssl, Data& data, bool peek)
-{
- if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))
- ssl.SetError(no_error);
-
- ssl.verfiyHandShakeComplete();
- if (ssl.GetError()) return -1;
-
- if (!ssl.HasData())
- processReply(ssl);
-
- if (peek)
- ssl.PeekData(data);
- else
- ssl.fillData(data);
-
- ssl.useLog().ShowData(data.get_length());
- if (ssl.GetError()) return -1;
-
- if (data.get_length() == 0 && ssl.getSocket().WouldBlock()) {
- ssl.SetError(YasslError(SSL_ERROR_WANT_READ));
- return SSL_WOULD_BLOCK;
- }
- return data.get_length();
-}
-
-
-// send server hello
-void sendServerHello(SSL& ssl, BufferOutput buffer)
-{
- if (ssl.getSecurity().get_resuming())
- ssl.verifyState(clientKeyExchangeComplete);
- else
- ssl.verifyState(clientHelloComplete);
- if (ssl.GetError()) return;
-
- ServerHello sh(ssl.getSecurity().get_connection().version_,
- ssl.getSecurity().get_connection().compression_);
- RecordLayerHeader rlHeader;
- HandShakeHeader hsHeader;
- mySTL::auto_ptr out(NEW_YS output_buffer);
-
- buildServerHello(ssl, sh);
- ssl.set_random(sh.get_random(), server_end);
- buildHeaders(ssl, hsHeader, rlHeader, sh);
- buildOutput(*out.get(), rlHeader, hsHeader, sh);
- hashHandShake(ssl, *out.get());
-
- if (buffer == buffered)
- ssl.addBuffer(out.release());
- else
- ssl.Send(out->get_buffer(), out->get_size());
-}
-
-
-// send server hello done
-void sendServerHelloDone(SSL& ssl, BufferOutput buffer)
-{
- if (ssl.GetError()) return;
-
- ServerHelloDone shd;
- RecordLayerHeader rlHeader;
- HandShakeHeader hsHeader;
- mySTL::auto_ptr out(NEW_YS output_buffer);
-
- buildHeaders(ssl, hsHeader, rlHeader, shd);
- buildOutput(*out.get(), rlHeader, hsHeader, shd);
- hashHandShake(ssl, *out.get());
-
- if (buffer == buffered)
- ssl.addBuffer(out.release());
- else
- ssl.Send(out->get_buffer(), out->get_size());
-}
-
-
-// send certificate
-void sendCertificate(SSL& ssl, BufferOutput buffer)
-{
- if (ssl.GetError()) return;
-
- Certificate cert(ssl.getCrypto().get_certManager().get_cert());
- RecordLayerHeader rlHeader;
- HandShakeHeader hsHeader;
- mySTL::auto_ptr out(NEW_YS output_buffer);
-
- buildHeaders(ssl, hsHeader, rlHeader, cert);
- buildOutput(*out.get(), rlHeader, hsHeader, cert);
- hashHandShake(ssl, *out.get());
-
- if (buffer == buffered)
- ssl.addBuffer(out.release());
- else
- ssl.Send(out->get_buffer(), out->get_size());
-}
-
-
-// send certificate request
-void sendCertificateRequest(SSL& ssl, BufferOutput buffer)
-{
- if (ssl.GetError()) return;
-
- CertificateRequest request;
- request.Build();
- RecordLayerHeader rlHeader;
- HandShakeHeader hsHeader;
- mySTL::auto_ptr out(NEW_YS output_buffer);
-
- buildHeaders(ssl, hsHeader, rlHeader, request);
- buildOutput(*out.get(), rlHeader, hsHeader, request);
- hashHandShake(ssl, *out.get());
-
- if (buffer == buffered)
- ssl.addBuffer(out.release());
- else
- ssl.Send(out->get_buffer(), out->get_size());
-}
-
-
-// send certificate verify
-void sendCertificateVerify(SSL& ssl, BufferOutput buffer)
-{
- if (ssl.GetError()) return;
-
- CertificateVerify verify;
- verify.Build(ssl);
- RecordLayerHeader rlHeader;
- HandShakeHeader hsHeader;
- mySTL::auto_ptr out(NEW_YS output_buffer);
-
- buildHeaders(ssl, hsHeader, rlHeader, verify);
- buildOutput(*out.get(), rlHeader, hsHeader, verify);
- hashHandShake(ssl, *out.get());
-
- if (buffer == buffered)
- ssl.addBuffer(out.release());
- else
- ssl.Send(out->get_buffer(), out->get_size());
-}
-
-
-} // namespace
diff --git a/externals/mysql/extlib/yassl/src/lock.cpp b/externals/mysql/extlib/yassl/src/lock.cpp
deleted file mode 100644
index 6d8e9c1747..0000000000
--- a/externals/mysql/extlib/yassl/src/lock.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* Locking functions
- */
-
-#include "runtime.hpp"
-#include "lock.hpp"
-
-
-namespace yaSSL {
-
-
-#ifdef MULTI_THREADED
- #ifdef _WIN32
-
- Mutex::Mutex()
- {
- InitializeCriticalSection(&cs_);
- }
-
-
- Mutex::~Mutex()
- {
- DeleteCriticalSection(&cs_);
- }
-
-
- Mutex::Lock::Lock(Mutex& lm) : mutex_(lm)
- {
- EnterCriticalSection(&mutex_.cs_);
- }
-
-
- Mutex::Lock::~Lock()
- {
- LeaveCriticalSection(&mutex_.cs_);
- }
-
- #else // _WIN32
-
- Mutex::Mutex()
- {
- pthread_mutex_init(&mutex_, 0);
- }
-
-
- Mutex::~Mutex()
- {
- pthread_mutex_destroy(&mutex_);
- }
-
-
- Mutex::Lock::Lock(Mutex& lm) : mutex_(lm)
- {
- pthread_mutex_lock(&mutex_.mutex_);
- }
-
-
- Mutex::Lock::~Lock()
- {
- pthread_mutex_unlock(&mutex_.mutex_);
- }
-
-
- #endif // _WIN32
-#endif // MULTI_THREADED
-
-
-
-} // namespace yaSSL
-
diff --git a/externals/mysql/extlib/yassl/src/log.cpp b/externals/mysql/extlib/yassl/src/log.cpp
deleted file mode 100644
index 35db4136a5..0000000000
--- a/externals/mysql/extlib/yassl/src/log.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* Debug logging functions
- */
-
-
-#include "runtime.hpp"
-#include "log.hpp"
-
-#ifdef YASSL_LOG
- #include
- #include
- #include
-#endif
-
-
-
-namespace yaSSL {
-
-
-#ifdef YASSL_LOG
-
- enum { MAX_MSG = 81 };
-
- Log::Log(const char* str)
- {
- log_ = fopen(str, "w");
- Trace("********** Logger Attached **********");
- }
-
-
- Log::~Log()
- {
- Trace("********** Logger Detached **********");
- fclose(log_);
- }
-
-
- // Trace a message
- void Log::Trace(const char* str)
- {
- if (!log_) return;
-
- time_t clicks = time(0);
- char timeStr[32];
-
- // get rid of newline
- strncpy(timeStr, ctime(&clicks), sizeof(timeStr));
- unsigned int len = strlen(timeStr);
- timeStr[len - 1] = 0;
-
- char msg[MAX_MSG];
-
- strncpy(msg, timeStr, sizeof(timeStr));
- strncat(msg, ":", 1);
- strncat(msg, str, MAX_MSG - sizeof(timeStr) - 2);
- strncat(msg, "\n", 1);
- msg[MAX_MSG - 1] = 0;
-
- fputs(msg, log_);
- }
-
-
- #if defined(_WIN32) || defined(__MACH__) || defined(__hpux__)
- typedef int socklen_t;
- #endif
-
-
- // write tcp address
- void Log::ShowTCP(socket_t fd, bool ended)
- {
- sockaddr_in peeraddr;
- socklen_t len = sizeof(peeraddr);
- if (getpeername(fd, (sockaddr*)&peeraddr, &len) != 0)
- return;
-
- const char* p = reinterpret_cast(&peeraddr.sin_addr);
- char msg[MAX_MSG];
- char number[16];
-
- if (ended)
- strncpy(msg, "yaSSL conn DONE w/ peer ", 26);
- else
- strncpy(msg, "yaSSL conn BEGUN w/ peer ", 26);
- for (int i = 0; i < 4; ++i) {
- sprintf(number, "%u", static_cast(p[i]));
- strncat(msg, number, 8);
- if (i < 3)
- strncat(msg, ".", 1);
- }
- strncat(msg, " port ", 8);
- sprintf(number, "%d", htons(peeraddr.sin_port));
- strncat(msg, number, 8);
-
- msg[MAX_MSG - 1] = 0;
- Trace(msg);
- }
-
-
- // log processed data
- void Log::ShowData(uint bytes, bool sent)
- {
- char msg[MAX_MSG];
- char number[16];
-
- if (sent)
- strncpy(msg, "Sent ", 10);
- else
- strncpy(msg, "Received ", 10);
- sprintf(number, "%u", bytes);
- strncat(msg, number, 8);
- strncat(msg, " bytes of application data", 27);
-
- msg[MAX_MSG - 1] = 0;
- Trace(msg);
- }
-
-
-#else // no YASSL_LOG
-
-
- Log::Log(const char*) {}
- Log::~Log() {}
- void Log::Trace(const char*) {}
- void Log::ShowTCP(socket_t, bool) {}
- void Log::ShowData(uint, bool) {}
-
-
-#endif // YASSL_LOG
-} // namespace
diff --git a/externals/mysql/extlib/yassl/src/socket_wrapper.cpp b/externals/mysql/extlib/yassl/src/socket_wrapper.cpp
deleted file mode 100644
index eee5d47377..0000000000
--- a/externals/mysql/extlib/yassl/src/socket_wrapper.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* The socket wrapper source implements a Socket class that hides the
- * differences between Berkely style sockets and Windows sockets, allowing
- * transparent TCP access.
- */
-
-
-#include "runtime.hpp"
-#include "socket_wrapper.hpp"
-
-#ifndef _WIN32
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
-#endif // _WIN32
-
-#if defined(__sun) || defined(__SCO_VERSION__) || defined(__NETWARE__)
- #include
-#endif
-
-#ifdef _WIN32
- const int SOCKET_EINVAL = WSAEINVAL;
- const int SOCKET_EWOULDBLOCK = WSAEWOULDBLOCK;
- const int SOCKET_EAGAIN = WSAEWOULDBLOCK;
-#else
- const int SOCKET_EINVAL = EINVAL;
- const int SOCKET_EWOULDBLOCK = EWOULDBLOCK;
- const int SOCKET_EAGAIN = EAGAIN;
-#endif // _WIN32
-
-
-namespace yaSSL {
-
-
-Socket::Socket(socket_t s)
- : socket_(s), wouldBlock_(false), nonBlocking_(false)
-{}
-
-
-void Socket::set_fd(socket_t s)
-{
- socket_ = s;
-}
-
-
-socket_t Socket::get_fd() const
-{
- return socket_;
-}
-
-
-Socket::~Socket()
-{
- // don't close automatically now
-}
-
-
-void Socket::closeSocket()
-{
- if (socket_ != INVALID_SOCKET) {
-#ifdef _WIN32
- closesocket(socket_);
-#else
- close(socket_);
-#endif
- socket_ = INVALID_SOCKET;
- }
-}
-
-
-uint Socket::get_ready() const
-{
-#ifdef _WIN32
- unsigned long ready = 0;
- ioctlsocket(socket_, FIONREAD, &ready);
-#else
- /*
- 64-bit Solaris requires the variable passed to
- FIONREAD be a 32-bit value.
- */
- unsigned int ready = 0;
- ioctl(socket_, FIONREAD, &ready);
-#endif
-
- return ready;
-}
-
-
-uint Socket::send(const byte* buf, unsigned int sz, int flags) const
-{
- const byte* pos = buf;
- const byte* end = pos + sz;
-
- while (pos != end) {
- int sent = ::send(socket_, reinterpret_cast(pos),
- static_cast(end - pos), flags);
-
- if (sent == -1)
- return 0;
-
- pos += sent;
- }
-
- return sz;
-}
-
-
-uint Socket::receive(byte* buf, unsigned int sz, int flags)
-{
- wouldBlock_ = false;
-
- int recvd = ::recv(socket_, reinterpret_cast(buf), sz, flags);
-
- // idea to seperate error from would block by arnetheduck@gmail.com
- if (recvd == -1) {
- if (get_lastError() == SOCKET_EWOULDBLOCK ||
- get_lastError() == SOCKET_EAGAIN) {
- wouldBlock_ = true; // would have blocked this time only
- nonBlocking_ = true; // socket nonblocking, win32 only way to tell
- return 0;
- }
- }
- else if (recvd == 0)
- return static_cast(-1);
-
- return recvd;
-}
-
-
-// wait if blocking for input, return false for error
-bool Socket::wait()
-{
- byte b;
- return receive(&b, 1, MSG_PEEK) != static_cast(-1);
-}
-
-
-void Socket::shutDown(int how)
-{
- shutdown(socket_, how);
-}
-
-
-int Socket::get_lastError()
-{
-#ifdef _WIN32
- return WSAGetLastError();
-#else
- return errno;
-#endif
-}
-
-
-bool Socket::WouldBlock() const
-{
- return wouldBlock_;
-}
-
-
-bool Socket::IsNonBlocking() const
-{
- return nonBlocking_;
-}
-
-
-void Socket::set_lastError(int errorCode)
-{
-#ifdef _WIN32
- WSASetLastError(errorCode);
-#else
- errno = errorCode;
-#endif
-}
-
-
-} // namespace
diff --git a/externals/mysql/extlib/yassl/src/ssl.cpp b/externals/mysql/extlib/yassl/src/ssl.cpp
deleted file mode 100644
index 29aa034f88..0000000000
--- a/externals/mysql/extlib/yassl/src/ssl.cpp
+++ /dev/null
@@ -1,1672 +0,0 @@
-/*
- Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-/* SSL source implements all openssl compatibility API functions
- *
- * TODO: notes are mostly api additions to allow compilation with mysql
- * they don't affect normal modes but should be provided for completeness
-
- * stunnel functions at end of file
- */
-
-
-
-
-/* see man pages for function descriptions */
-
-#include "runtime.hpp"
-#include "openssl/ssl.h"
-#include "handshake.hpp"
-#include "yassl_int.hpp"
-#include "md5.hpp" // for TaoCrypt MD5 size assert
-#include "md4.hpp" // for TaoCrypt MD4 size assert
-#include "file.hpp" // for TaoCrypt Source
-#include "coding.hpp" // HexDecoder
-#include "helpers.hpp" // for placement new hack
-#include
-
-#ifdef _WIN32
- #include // FindFirstFile etc..
-#else
- #include // file helper
- #include // stat
- #include // opendir
-#endif
-
-
-namespace yaSSL {
-
-
-
-int read_file(SSL_CTX* ctx, const char* file, int format, CertType type)
-{
- if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM)
- return SSL_BAD_FILETYPE;
-
- if (file == NULL || !file[0])
- return SSL_BAD_FILE;
-
- FILE* input = fopen(file, "rb");
- if (!input)
- return SSL_BAD_FILE;
-
- if (type == CA) {
- // may have a bunch of CAs
- x509* ptr;
- while ( (ptr = PemToDer(input, Cert)) )
- ctx->AddCA(ptr);
-
- if (!feof(input)) {
- fclose(input);
- return SSL_BAD_FILE;
- }
- }
- else {
- x509*& x = (type == Cert) ? ctx->certificate_ : ctx->privateKey_;
-
- if (format == SSL_FILETYPE_ASN1) {
- fseek(input, 0, SEEK_END);
- long sz = ftell(input);
- rewind(input);
- x = NEW_YS x509(sz); // takes ownership
- size_t bytes = fread(x->use_buffer(), sz, 1, input);
- if (bytes != 1) {
- fclose(input);
- return SSL_BAD_FILE;
- }
- }
- else {
- EncryptedInfo info;
- x = PemToDer(input, type, &info);
- if (!x) {
- fclose(input);
- return SSL_BAD_FILE;
- }
- if (info.set) {
- // decrypt
- char password[80];
- pem_password_cb cb = ctx->GetPasswordCb();
- if (!cb) {
- fclose(input);
- return SSL_BAD_FILE;
- }
- int passwordSz = cb(password, sizeof(password), 0,
- ctx->GetUserData());
- byte key[AES_256_KEY_SZ]; // max sizes
- byte iv[AES_IV_SZ];
-
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-
- mySTL::auto_ptr cipher;
- if (strncmp(info.name, "DES-CBC", 7) == 0)
- cipher.reset(NEW_YS DES);
- else if (strncmp(info.name, "DES-EDE3-CBC", 13) == 0)
- cipher.reset(NEW_YS DES_EDE);
- else if (strncmp(info.name, "AES-128-CBC", 13) == 0)
- cipher.reset(NEW_YS AES(AES_128_KEY_SZ));
- else if (strncmp(info.name, "AES-192-CBC", 13) == 0)
- cipher.reset(NEW_YS AES(AES_192_KEY_SZ));
- else if (strncmp(info.name, "AES-256-CBC", 13) == 0)
- cipher.reset(NEW_YS AES(AES_256_KEY_SZ));
- else {
- fclose(input);
- return SSL_BAD_FILE;
- }
- cipher->set_decryptKey(key, info.iv);
- mySTL::auto_ptr newx(NEW_YS x509(x->get_length()));
- cipher->decrypt(newx->use_buffer(), x->get_buffer(),
- x->get_length());
- ysDelete(x);
- x = newx.release();
- }
- }
- }
- fclose(input);
- return SSL_SUCCESS;
-}
-
-
-extern "C" {
-
-
-SSL_METHOD* SSLv3_method()
-{
- return SSLv3_client_method();
-}
-
-
-SSL_METHOD* SSLv3_server_method()
-{
- return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,0));
-}
-
-
-SSL_METHOD* SSLv3_client_method()
-{
- return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,0));
-}
-
-
-SSL_METHOD* TLSv1_server_method()
-{
- return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,1));
-}
-
-
-SSL_METHOD* TLSv1_client_method()
-{
- return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,1));
-}
-
-
-SSL_METHOD* TLSv1_1_server_method()
-{
- return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2));
-}
-
-
-SSL_METHOD* TLSv1_1_client_method()
-{
- return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2));
-}
-
-
-SSL_METHOD* SSLv23_server_method()
-{
- // compatibility only, no version 2 support, but does SSL 3 and TLS 1
- return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2), true);
-}
-
-
-SSL_METHOD* SSLv23_client_method()
-{
- // compatibility only, no version 2 support, but does SSL 3 and TLS 1
- // though it sends TLS1 hello not SSLv2 so SSLv3 only servers will decline
- // TODO: maybe add support to send SSLv2 hello ???
- return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2), true);
-}
-
-
-SSL_CTX* SSL_CTX_new(SSL_METHOD* method)
-{
- return NEW_YS SSL_CTX(method);
-}
-
-
-void SSL_CTX_free(SSL_CTX* ctx)
-{
- ysDelete(ctx);
-}
-
-
-SSL* SSL_new(SSL_CTX* ctx)
-{
- return NEW_YS SSL(ctx);
-}
-
-
-void SSL_free(SSL* ssl)
-{
- ysDelete(ssl);
-}
-
-
-int SSL_set_fd(SSL* ssl, YASSL_SOCKET_T fd)
-{
- ssl->useSocket().set_fd(fd);
- return SSL_SUCCESS;
-}
-
-
-YASSL_SOCKET_T SSL_get_fd(const SSL* ssl)
-{
- return ssl->getSocket().get_fd();
-}
-
-
-// if you get an error from connect see note at top of README
-int SSL_connect(SSL* ssl)
-{
- if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))
- ssl->SetError(no_error);
-
- ClientState neededState;
-
- switch (ssl->getStates().GetConnect()) {
-
- case CONNECT_BEGIN :
- sendClientHello(*ssl);
- if (!ssl->GetError())
- ssl->useStates().UseConnect() = CLIENT_HELLO_SENT;
-
- case CLIENT_HELLO_SENT :
- neededState = ssl->getSecurity().get_resuming() ?
- serverFinishedComplete : serverHelloDoneComplete;
- while (ssl->getStates().getClient() < neededState) {
- if (ssl->GetError()) break;
- processReply(*ssl);
- }
- if (!ssl->GetError())
- ssl->useStates().UseConnect() = FIRST_REPLY_DONE;
-
- case FIRST_REPLY_DONE :
- if(ssl->getCrypto().get_certManager().sendVerify())
- sendCertificate(*ssl);
-
- if (!ssl->getSecurity().get_resuming())
- sendClientKeyExchange(*ssl);
-
- if(ssl->getCrypto().get_certManager().sendVerify())
- sendCertificateVerify(*ssl);
-
- sendChangeCipher(*ssl);
- sendFinished(*ssl, client_end);
- ssl->flushBuffer();
-
- if (!ssl->GetError())
- ssl->useStates().UseConnect() = FINISHED_DONE;
-
- case FINISHED_DONE :
- if (!ssl->getSecurity().get_resuming())
- while (ssl->getStates().getClient() < serverFinishedComplete) {
- if (ssl->GetError()) break;
- processReply(*ssl);
- }
- if (!ssl->GetError())
- ssl->useStates().UseConnect() = SECOND_REPLY_DONE;
-
- case SECOND_REPLY_DONE :
- ssl->verifyState(serverFinishedComplete);
- ssl->useLog().ShowTCP(ssl->getSocket().get_fd());
-
- if (ssl->GetError()) {
- GetErrors().Add(ssl->GetError());
- return SSL_FATAL_ERROR;
- }
- return SSL_SUCCESS;
-
- default :
- return SSL_FATAL_ERROR; // unkown state
- }
-}
-
-
-int SSL_write(SSL* ssl, const void* buffer, int sz)
-{
- return sendData(*ssl, buffer, sz);
-}
-
-
-int SSL_read(SSL* ssl, void* buffer, int sz)
-{
- Data data(min(sz, MAX_RECORD_SIZE), static_cast(buffer));
- return receiveData(*ssl, data);
-}
-
-
-int SSL_accept(SSL* ssl)
-{
- if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))
- ssl->SetError(no_error);
-
- switch (ssl->getStates().GetAccept()) {
-
- case ACCEPT_BEGIN :
- processReply(*ssl);
- if (!ssl->GetError())
- ssl->useStates().UseAccept() = ACCEPT_FIRST_REPLY_DONE;
-
- case ACCEPT_FIRST_REPLY_DONE :
- sendServerHello(*ssl);
-
- if (!ssl->getSecurity().get_resuming()) {
- sendCertificate(*ssl);
-
- if (ssl->getSecurity().get_connection().send_server_key_)
- sendServerKeyExchange(*ssl);
-
- if(ssl->getCrypto().get_certManager().verifyPeer())
- sendCertificateRequest(*ssl);
-
- sendServerHelloDone(*ssl);
- ssl->flushBuffer();
- }
-
- if (!ssl->GetError())
- ssl->useStates().UseAccept() = SERVER_HELLO_DONE;
-
- case SERVER_HELLO_DONE :
- if (!ssl->getSecurity().get_resuming()) {
- while (ssl->getStates().getServer() < clientFinishedComplete) {
- if (ssl->GetError()) break;
- processReply(*ssl);
- }
- }
- if (!ssl->GetError())
- ssl->useStates().UseAccept() = ACCEPT_SECOND_REPLY_DONE;
-
- case ACCEPT_SECOND_REPLY_DONE :
- sendChangeCipher(*ssl);
- sendFinished(*ssl, server_end);
- ssl->flushBuffer();
-
- if (!ssl->GetError())
- ssl->useStates().UseAccept() = ACCEPT_FINISHED_DONE;
-
- case ACCEPT_FINISHED_DONE :
- if (ssl->getSecurity().get_resuming()) {
- while (ssl->getStates().getServer() < clientFinishedComplete) {
- if (ssl->GetError()) break;
- processReply(*ssl);
- }
- }
- if (!ssl->GetError())
- ssl->useStates().UseAccept() = ACCEPT_THIRD_REPLY_DONE;
-
- case ACCEPT_THIRD_REPLY_DONE :
- ssl->useLog().ShowTCP(ssl->getSocket().get_fd());
-
- if (ssl->GetError()) {
- GetErrors().Add(ssl->GetError());
- return SSL_FATAL_ERROR;
- }
- return SSL_SUCCESS;
-
- default:
- return SSL_FATAL_ERROR; // unknown state
- }
-}
-
-
-int SSL_do_handshake(SSL* ssl)
-{
- if (ssl->getSecurity().get_parms().entity_ == client_end)
- return SSL_connect(ssl);
- else
- return SSL_accept(ssl);
-}
-
-
-int SSL_clear(SSL* ssl)
-{
- GetErrors().Remove();
-
- return SSL_SUCCESS;
-}
-
-
-int SSL_shutdown(SSL* ssl)
-{
- if (!ssl->GetQuietShutdown()) {
- Alert alert(warning, close_notify);
- sendAlert(*ssl, alert);
- }
- ssl->useLog().ShowTCP(ssl->getSocket().get_fd(), true);
-
- GetErrors().Remove();
-
- return SSL_SUCCESS;
-}
-
-
-void SSL_set_quiet_shutdown(SSL *ssl,int mode)
-{
- ssl->SetQuietShutdown(mode != 0);
-}
-
-
-int SSL_get_quiet_shutdown(SSL *ssl)
-{
- return ssl->GetQuietShutdown();
-}
-
-
-/* on by default but allow user to turn off */
-long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode)
-{
- if (mode == SSL_SESS_CACHE_OFF)
- ctx->SetSessionCacheOff();
-
- if (mode == SSL_SESS_CACHE_NO_AUTO_CLEAR)
- ctx->SetSessionCacheFlushOff();
-
- return SSL_SUCCESS;
-}
-
-
-SSL_SESSION* SSL_get_session(SSL* ssl)
-{
- if (ssl->getSecurity().GetContext()->GetSessionCacheOff())
- return 0;
-
- return GetSessions().lookup(
- ssl->getSecurity().get_connection().sessionID_);
-}
-
-
-int SSL_set_session(SSL* ssl, SSL_SESSION* session)
-{
- if (ssl->getSecurity().GetContext()->GetSessionCacheOff())
- return SSL_FAILURE;
-
- ssl->set_session(session);
- return SSL_SUCCESS;
-}
-
-
-int SSL_session_reused(SSL* ssl)
-{
- return ssl->getSecurity().get_resuming();
-}
-
-
-long SSL_SESSION_set_timeout(SSL_SESSION* sess, long t)
-{
- if (!sess)
- return SSL_ERROR_NONE;
-
- sess->SetTimeOut(t);
- return SSL_SUCCESS;
-}
-
-
-long SSL_get_default_timeout(SSL* /*ssl*/)
-{
- return DEFAULT_TIMEOUT;
-}
-
-
-void SSL_flush_sessions(SSL_CTX *ctx, long /* tm */)
-{
- if (ctx->GetSessionCacheOff())
- return;
-
- GetSessions().Flush();
-}
-
-
-const char* SSL_get_cipher_name(SSL* ssl)
-{
- return SSL_get_cipher(ssl);
-}
-
-
-const char* SSL_get_cipher(SSL* ssl)
-{
- return ssl->getSecurity().get_parms().cipher_name_;
-}
-
-
-// SSLv2 only, not implemented
-char* SSL_get_shared_ciphers(SSL* /*ssl*/, char* buf, int len)
-{
- return strncpy(buf, "Not Implemented, SSLv2 only", len);
-}
-
-
-const char* SSL_get_cipher_list(SSL* ssl, int priority)
-{
- if (priority < 0 || priority >= MAX_CIPHERS)
- return 0;
-
- if (ssl->getSecurity().get_parms().cipher_list_[priority][0])
- return ssl->getSecurity().get_parms().cipher_list_[priority];
-
- return 0;
-}
-
-
-int SSL_CTX_set_cipher_list(SSL_CTX* ctx, const char* list)
-{
- if (ctx->SetCipherList(list))
- return SSL_SUCCESS;
- else
- return SSL_FAILURE;
-}
-
-
-const char* SSL_get_version(SSL* ssl)
-{
- static const char* version3 = "SSLv3";
- static const char* version31 = "TLSv1";
-
- return ssl->isTLS() ? version31 : version3;
-}
-
-const char* SSLeay_version(int)
-{
- static const char* version = "SSLeay yaSSL compatibility";
- return version;
-}
-
-
-int SSL_get_error(SSL* ssl, int /*previous*/)
-{
- return ssl->getStates().What();
-}
-
-
-
-/* turn on yaSSL zlib compression
- returns 0 for success, else error (not built in)
- only need to turn on for client, becuase server on by default if built in
- but calling for server will tell you whether it's available or not
-*/
-int SSL_set_compression(SSL* ssl) /* Chad didn't rename to ya~ because it is prob. bug. */
-{
- return ssl->SetCompression();
-}
-
-
-
-X509* SSL_get_peer_certificate(SSL* ssl)
-{
- return ssl->getCrypto().get_certManager().get_peerX509();
-}
-
-
-void X509_free(X509* /*x*/)
-{
- // peer cert set for deletion during destruction
- // no need to delete now
-}
-
-
-X509* X509_STORE_CTX_get_current_cert(X509_STORE_CTX* ctx)
-{
- return ctx->current_cert;
-}
-
-
-int X509_STORE_CTX_get_error(X509_STORE_CTX* ctx)
-{
- return ctx->error;
-}
-
-
-int X509_STORE_CTX_get_error_depth(X509_STORE_CTX* ctx)
-{
- return ctx->error_depth;
-}
-
-
-// copy name into buffer, at most sz bytes, if buffer is null
-// will malloc buffer, caller responsible for freeing
-char* X509_NAME_oneline(X509_NAME* name, char* buffer, int sz)
-{
- if (!name->GetName()) return buffer;
-
- int len = (int)strlen(name->GetName()) + 1;
- int copySz = min(len, sz);
-
- if (!buffer) {
- buffer = (char*)malloc(len);
- if (!buffer) return buffer;
- copySz = len;
- }
-
- if (copySz == 0)
- return buffer;
-
- memcpy(buffer, name->GetName(), copySz - 1);
- buffer[copySz - 1] = 0;
-
- return buffer;
-}
-
-
-X509_NAME* X509_get_issuer_name(X509* x)
-{
- return x->GetIssuer();
-}
-
-
-X509_NAME* X509_get_subject_name(X509* x)
-{
- return x->GetSubject();
-}
-
-
-void SSL_load_error_strings() // compatibility only
-{}
-
-
-void SSL_set_connect_state(SSL*)
-{
- // already a client by default
-}
-
-
-void SSL_set_accept_state(SSL* ssl)
-{
- ssl->useSecurity().use_parms().entity_ = server_end;
-}
-
-
-long SSL_get_verify_result(SSL*)
-{
- // won't get here if not OK
- return X509_V_OK;
-}
-
-
-long SSL_CTX_sess_set_cache_size(SSL_CTX* /*ctx*/, long /*sz*/)
-{
- // unlimited size, can't set for now
- return 0;
-}
-
-
-long SSL_CTX_get_session_cache_mode(SSL_CTX*)
-{
- // always 0, unlimited size for now
- return 0;
-}
-
-
-long SSL_CTX_set_tmp_dh(SSL_CTX* ctx, DH* dh)
-{
- if (ctx->SetDH(*dh))
- return SSL_SUCCESS;
- else
- return SSL_FAILURE;
-}
-
-
-int SSL_CTX_use_certificate_file(SSL_CTX* ctx, const char* file, int format)
-{
- return read_file(ctx, file, format, Cert);
-}
-
-
-int SSL_CTX_use_PrivateKey_file(SSL_CTX* ctx, const char* file, int format)
-{
- return read_file(ctx, file, format, PrivateKey);
-}
-
-
-void SSL_CTX_set_verify(SSL_CTX* ctx, int mode, VerifyCallback vc)
-{
- if (mode & SSL_VERIFY_PEER)
- ctx->setVerifyPeer();
-
- if (mode == SSL_VERIFY_NONE)
- ctx->setVerifyNone();
-
- if (mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
- ctx->setFailNoCert();
-
- ctx->setVerifyCallback(vc);
-}
-
-
-int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file,
- const char* path)
-{
- int ret = SSL_SUCCESS;
- const int HALF_PATH = 128;
-
- if (file) ret = read_file(ctx, file, SSL_FILETYPE_PEM, CA);
-
- if (ret == SSL_SUCCESS && path) {
- // call read_file for each reqular file in path
-#ifdef _WIN32
-
- WIN32_FIND_DATA FindFileData;
- HANDLE hFind;
-
- char name[MAX_PATH + 1]; // directory specification
- strncpy(name, path, MAX_PATH - 3);
- strncat(name, "\\*", 3);
-
- hFind = FindFirstFile(name, &FindFileData);
- if (hFind == INVALID_HANDLE_VALUE) return SSL_BAD_PATH;
-
- do {
- if (FindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) {
- strncpy(name, path, MAX_PATH - 2 - HALF_PATH);
- strncat(name, "\\", 2);
- strncat(name, FindFileData.cFileName, HALF_PATH);
- ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);
- }
- } while (ret == SSL_SUCCESS && FindNextFile(hFind, &FindFileData));
-
- FindClose(hFind);
-
-#else // _WIN32
-
- const int MAX_PATH = 260;
-
- DIR* dir = opendir(path);
- if (!dir) return SSL_BAD_PATH;
-
- struct dirent* entry;
- struct stat buf;
- char name[MAX_PATH + 1];
-
- while (ret == SSL_SUCCESS && (entry = readdir(dir))) {
- strncpy(name, path, MAX_PATH - 1 - HALF_PATH);
- strncat(name, "/", 1);
- strncat(name, entry->d_name, HALF_PATH);
- if (stat(name, &buf) < 0) return SSL_BAD_STAT;
-
- if (S_ISREG(buf.st_mode))
- ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);
- }
-
- closedir(dir);
-
-#endif
- }
-
- return ret;
-}
-
-
-int SSL_CTX_set_default_verify_paths(SSL_CTX* /*ctx*/)
-{
- // TODO: figure out way to set/store default path, then call load_verify
- return SSL_NOT_IMPLEMENTED;
-}
-
-
-int SSL_CTX_set_session_id_context(SSL_CTX*, const unsigned char*,
- unsigned int)
-{
- // No application specific context needed for yaSSL
- return SSL_SUCCESS;
-}
-
-
-int SSL_CTX_check_private_key(SSL_CTX* /*ctx*/)
-{
- // TODO: check private against public for RSA match
- return SSL_NOT_IMPLEMENTED;
-}
-
-
-// TODO: all session stats
-long SSL_CTX_sess_accept(SSL_CTX* ctx)
-{
- return ctx->GetStats().accept_;
-}
-
-
-long SSL_CTX_sess_connect(SSL_CTX* ctx)
-{
- return ctx->GetStats().connect_;
-}
-
-
-long SSL_CTX_sess_accept_good(SSL_CTX* ctx)
-{
- return ctx->GetStats().acceptGood_;
-}
-
-
-long SSL_CTX_sess_connect_good(SSL_CTX* ctx)
-{
- return ctx->GetStats().connectGood_;
-}
-
-
-long SSL_CTX_sess_accept_renegotiate(SSL_CTX* ctx)
-{
- return ctx->GetStats().acceptRenegotiate_;
-}
-
-
-long SSL_CTX_sess_connect_renegotiate(SSL_CTX* ctx)
-{
- return ctx->GetStats().connectRenegotiate_;
-}
-
-
-long SSL_CTX_sess_hits(SSL_CTX* ctx)
-{
- return ctx->GetStats().hits_;
-}
-
-
-long SSL_CTX_sess_cb_hits(SSL_CTX* ctx)
-{
- return ctx->GetStats().cbHits_;
-}
-
-
-long SSL_CTX_sess_cache_full(SSL_CTX* ctx)
-{
- return ctx->GetStats().cacheFull_;
-}
-
-
-long SSL_CTX_sess_misses(SSL_CTX* ctx)
-{
- return ctx->GetStats().misses_;
-}
-
-
-long SSL_CTX_sess_timeouts(SSL_CTX* ctx)
-{
- return ctx->GetStats().timeouts_;
-}
-
-
-long SSL_CTX_sess_number(SSL_CTX* ctx)
-{
- return ctx->GetStats().number_;
-}
-
-
-long SSL_CTX_sess_get_cache_size(SSL_CTX* ctx)
-{
- return ctx->GetStats().getCacheSize_;
-}
-// end session stats TODO:
-
-
-int SSL_CTX_get_verify_mode(SSL_CTX* ctx)
-{
- return ctx->GetStats().verifyMode_;
-}
-
-
-int SSL_get_verify_mode(SSL* ssl)
-{
- return ssl->getSecurity().GetContext()->GetStats().verifyMode_;
-}
-
-
-int SSL_CTX_get_verify_depth(SSL_CTX* ctx)
-{
- return ctx->GetStats().verifyDepth_;
-}
-
-
-int SSL_get_verify_depth(SSL* ssl)
-{
- return ssl->getSecurity().GetContext()->GetStats().verifyDepth_;
-}
-
-
-long SSL_CTX_set_options(SSL_CTX*, long)
-{
- // TDOD:
- return SSL_SUCCESS;
-}
-
-
-void SSL_CTX_set_info_callback(SSL_CTX*, void (*)())
-{
- // TDOD:
-}
-
-
-void OpenSSL_add_all_algorithms() // compatibility only
-{}
-
-
-int SSL_library_init() // compatiblity only
-{
- return 1;
-}
-
-
-DH* DH_new(void)
-{
- DH* dh = NEW_YS DH;
- if (dh)
- dh->p = dh->g = 0;
- return dh;
-}
-
-
-void DH_free(DH* dh)
-{
- ysDelete(dh->g);
- ysDelete(dh->p);
- ysDelete(dh);
-}
-
-
-// convert positive big-endian num of length sz into retVal, which may need to
-// be created
-BIGNUM* BN_bin2bn(const unsigned char* num, int sz, BIGNUM* retVal)
-{
- bool created = false;
- mySTL::auto_ptr bn;
-
- if (!retVal) {
- created = true;
- bn.reset(NEW_YS BIGNUM);
- retVal = bn.get();
- }
-
- retVal->assign(num, sz);
-
- if (created)
- return bn.release();
- else
- return retVal;
-}
-
-
-unsigned long ERR_get_error_line_data(const char**, int*, const char**, int *)
-{
- //return SSL_NOT_IMPLEMENTED;
- return 0;
-}
-
-
-void ERR_print_errors_fp(FILE* /*fp*/)
-{
- // need ssl access to implement TODO:
- //fprintf(fp, "%s", ssl.get_states().errorString_.c_str());
-}
-
-
-char* ERR_error_string(unsigned long errNumber, char* buffer)
-{
- static char* msg = (char*)"Please supply a buffer for error string";
-
- if (buffer) {
- SetErrorString(YasslError(errNumber), buffer);
- return buffer;
- }
-
- return msg;
-}
-
-
-const char* X509_verify_cert_error_string(long /* error */)
-{
- // TODO:
- static const char* msg = "Not Implemented";
- return msg;
-}
-
-
-const EVP_MD* EVP_md5(void)
-{
- static const char* type = "MD5";
- return type;
-}
-
-
-const EVP_CIPHER* EVP_des_ede3_cbc(void)
-{
- static const char* type = "DES-EDE3-CBC";
- return type;
-}
-
-
-int EVP_BytesToKey(const EVP_CIPHER* type, const EVP_MD* md, const byte* salt,
- const byte* data, int sz, int count, byte* key, byte* iv)
-{
- // only support MD5 for now
- if (strncmp(md, "MD5", 3)) return 0;
-
- int keyLen = 0;
- int ivLen = 0;
-
- // only support CBC DES and AES for now
- if (strncmp(type, "DES-CBC", 7) == 0) {
- keyLen = DES_KEY_SZ;
- ivLen = DES_IV_SZ;
- }
- else if (strncmp(type, "DES-EDE3-CBC", 12) == 0) {
- keyLen = DES_EDE_KEY_SZ;
- ivLen = DES_IV_SZ;
- }
- else if (strncmp(type, "AES-128-CBC", 11) == 0) {
- keyLen = AES_128_KEY_SZ;
- ivLen = AES_IV_SZ;
- }
- else if (strncmp(type, "AES-192-CBC", 11) == 0) {
- keyLen = AES_192_KEY_SZ;
- ivLen = AES_IV_SZ;
- }
- else if (strncmp(type, "AES-256-CBC", 11) == 0) {
- keyLen = AES_256_KEY_SZ;
- ivLen = AES_IV_SZ;
- }
- else
- return 0;
-
- yaSSL::MD5 myMD;
- uint digestSz = myMD.get_digestSize();
- byte digest[SHA_LEN]; // max size
-
- int keyLeft = keyLen;
- int ivLeft = ivLen;
- int keyOutput = 0;
-
- while (keyOutput < (keyLen + ivLen)) {
- int digestLeft = digestSz;
- // D_(i - 1)
- if (keyOutput) // first time D_0 is empty
- myMD.update(digest, digestSz);
- // data
- myMD.update(data, sz);
- // salt
- if (salt)
- myMD.update(salt, EVP_SALT_SZ);
- myMD.get_digest(digest);
- // count
- for (int j = 1; j < count; j++) {
- myMD.update(digest, digestSz);
- myMD.get_digest(digest);
- }
-
- if (keyLeft) {
- int store = min(keyLeft, static_cast(digestSz));
- memcpy(&key[keyLen - keyLeft], digest, store);
-
- keyOutput += store;
- keyLeft -= store;
- digestLeft -= store;
- }
-
- if (ivLeft && digestLeft) {
- int store = min(ivLeft, digestLeft);
- memcpy(&iv[ivLen - ivLeft], &digest[digestSz - digestLeft], store);
-
- keyOutput += store;
- ivLeft -= store;
- }
- }
- assert(keyOutput == (keyLen + ivLen));
- return keyOutput;
-}
-
-
-
-void DES_set_key_unchecked(const_DES_cblock* key, DES_key_schedule* schedule)
-{
- memcpy(schedule, key, sizeof(const_DES_cblock));
-}
-
-
-void DES_ede3_cbc_encrypt(const byte* input, byte* output, long sz,
- DES_key_schedule* ks1, DES_key_schedule* ks2,
- DES_key_schedule* ks3, DES_cblock* ivec, int enc)
-{
- DES_EDE des;
- byte key[DES_EDE_KEY_SZ];
-
- memcpy(key, *ks1, DES_BLOCK);
- memcpy(&key[DES_BLOCK], *ks2, DES_BLOCK);
- memcpy(&key[DES_BLOCK * 2], *ks3, DES_BLOCK);
-
- if (enc) {
- des.set_encryptKey(key, *ivec);
- des.encrypt(output, input, sz);
- }
- else {
- des.set_decryptKey(key, *ivec);
- des.decrypt(output, input, sz);
- }
-}
-
-
-// functions for libcurl
-int RAND_status()
-{
- return 1; /* TaoCrypt provides enough seed */
-}
-
-
-int DES_set_key(const_DES_cblock* key, DES_key_schedule* schedule)
-{
- memcpy(schedule, key, sizeof(const_DES_cblock));
- return 1;
-}
-
-
-void DES_set_odd_parity(DES_cblock* key)
-{
- // not needed now for TaoCrypt
-}
-
-
-void DES_ecb_encrypt(DES_cblock* input, DES_cblock* output,
- DES_key_schedule* key, int enc)
-{
- DES des;
-
- if (enc) {
- des.set_encryptKey(*key, 0);
- des.encrypt(*output, *input, DES_BLOCK);
- }
- else {
- des.set_decryptKey(*key, 0);
- des.decrypt(*output, *input, DES_BLOCK);
- }
-}
-
-
-void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX* ctx, void* userdata)
-{
- ctx->SetUserData(userdata);
-}
-
-
-X509* SSL_get_certificate(SSL* ssl)
-{
- // only used to pass to get_privatekey which isn't used
- return 0;
-}
-
-
-EVP_PKEY* SSL_get_privatekey(SSL* ssl)
-{
- // only called, not used
- return 0;
-}
-
-
-void SSL_SESSION_free(SSL_SESSION* session)
-{
- // managed by singleton
-}
-
-
-
-EVP_PKEY* X509_get_pubkey(X509* x)
-{
- // called, not used though
- return 0;
-}
-
-
-int EVP_PKEY_copy_parameters(EVP_PKEY* to, const EVP_PKEY* from)
-{
- // called, not used though
- return 0;
-}
-
-
-void EVP_PKEY_free(EVP_PKEY* pkey)
-{
- // never allocated from above
-}
-
-
-void ERR_error_string_n(unsigned long e, char *buf, size_t len)
-{
- if (len) ERR_error_string(e, buf);
-}
-
-
-void ERR_free_strings(void)
-{
- // handled internally
-}
-
-
-void EVP_cleanup(void)
-{
- // nothing to do yet
-}
-
-
-ASN1_TIME* X509_get_notBefore(X509* x)
-{
- if (x) return x->GetBefore();
- return 0;
-}
-
-
-ASN1_TIME* X509_get_notAfter(X509* x)
-{
- if (x) return x->GetAfter();
- return 0;
-}
-
-
-SSL_METHOD* SSLv2_client_method(void) /* will never work, no v 2 */
-{
- return 0;
-}
-
-
-SSL_SESSION* SSL_get1_session(SSL* ssl) /* what's ref count */
-{
- return SSL_get_session(ssl);
-}
-
-
-void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *x)
-{
- // no extension names supported yet
-}
-
-
-int sk_GENERAL_NAME_num(STACK_OF(GENERAL_NAME) *x)
-{
- // no extension names supported yet
- return 0;
-}
-
-
-GENERAL_NAME* sk_GENERAL_NAME_value(STACK_OF(GENERAL_NAME) *x, int i)
-{
- // no extension names supported yet
- return 0;
-}
-
-
-unsigned char* ASN1_STRING_data(ASN1_STRING* x)
-{
- if (x) return x->data;
- return 0;
-}
-
-
-int ASN1_STRING_length(ASN1_STRING* x)
-{
- if (x) return x->length;
- return 0;
-}
-
-
-int ASN1_STRING_type(ASN1_STRING *x)
-{
- if (x) return x->type;
- return 0;
-}
-
-
-int X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos)
-{
- int idx = -1; // not found
- const char* start = &name->GetName()[lastpos + 1];
-
- switch (nid) {
- case NID_commonName:
- const char* found = strstr(start, "/CN=");
- if (found) {
- found += 4; // advance to str
- idx = found - start + lastpos + 1;
- }
- break;
- }
-
- return idx;
-}
-
-
-ASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne)
-{
- // the same in yaSSL
- return ne;
-}
-
-
-X509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME* name, int loc)
-{
- return name->GetEntry(loc);
-}
-
-
-// already formatted, caller responsible for freeing *out
-int ASN1_STRING_to_UTF8(unsigned char** out, ASN1_STRING* in)
-{
- if (!in) return 0;
-
- *out = (unsigned char*)malloc(in->length + 1);
- if (*out) {
- memcpy(*out, in->data, in->length);
- (*out)[in->length] = 0;
- }
- return in->length;
-}
-
-
-void* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx)
-{
- // no extensions supported yet
- return 0;
-}
-
-
-void MD4_Init(MD4_CTX* md4)
-{
- // make sure we have a big enough buffer
- typedef char ok[sizeof(md4->buffer) >= sizeof(TaoCrypt::MD4) ? 1 : -1];
- (void) sizeof(ok);
-
- // using TaoCrypt since no dynamic memory allocated
- // and no destructor will be called
- new (reinterpret_cast(md4->buffer)) TaoCrypt::MD4();
-}
-
-
-void MD4_Update(MD4_CTX* md4, const void* data, unsigned long sz)
-{
- reinterpret_cast(md4->buffer)->Update(
- static_cast(data), static_cast(sz));
-}
-
-
-void MD4_Final(unsigned char* hash, MD4_CTX* md4)
-{
- reinterpret_cast(md4->buffer)->Final(hash);
-}
-
-
-void MD5_Init(MD5_CTX* md5)
-{
- // make sure we have a big enough buffer
- typedef char ok[sizeof(md5->buffer) >= sizeof(TaoCrypt::MD5) ? 1 : -1];
- (void) sizeof(ok);
-
- // using TaoCrypt since no dynamic memory allocated
- // and no destructor will be called
- new (reinterpret_cast(md5->buffer)) TaoCrypt::MD5();
-}
-
-
-void MD5_Update(MD5_CTX* md5, const void* data, unsigned long sz)
-{
- reinterpret_cast(md5->buffer)->Update(
- static_cast(data), static_cast(sz));
-}
-
-
-void MD5_Final(unsigned char* hash, MD5_CTX* md5)
-{
- reinterpret_cast(md5->buffer)->Final(hash);
-}
-
-
-int RAND_bytes(unsigned char* buf, int num)
-{
- RandomPool ran;
-
- if (ran.GetError()) return 0;
-
- ran.Fill(buf, num);
- return 1;
-}
-
-
-int SSL_peek(SSL* ssl, void* buffer, int sz)
-{
- Data data(min(sz, MAX_RECORD_SIZE), static_cast(buffer));
- return receiveData(*ssl, data, true);
-}
-
-
-int SSL_pending(SSL* ssl)
-{
- // Just in case there's pending data that hasn't been processed yet...
- char c;
- SSL_peek(ssl, &c, 1);
-
- return ssl->bufferedData();
-}
-
-
-void SSL_CTX_set_default_passwd_cb(SSL_CTX* ctx, pem_password_cb cb)
-{
- ctx->SetPasswordCb(cb);
-}
-
-
-int SSLeay_add_ssl_algorithms() // compatibility only
-{
- return 1;
-}
-
-
-void ERR_remove_state(unsigned long)
-{
- GetErrors().Remove();
-}
-
-
-int ERR_GET_REASON(int l)
-{
- return l & 0xfff;
-}
-
-
-unsigned long err_helper(bool peek = false)
-{
- int ysError = GetErrors().Lookup(peek);
-
- // translate cert error for libcurl, it uses OpenSSL hex code
- switch (ysError) {
- case TaoCrypt::SIG_OTHER_E:
- return CERTFICATE_ERROR;
- break;
- default :
- return 0;
- }
-
- return 0; // shut up compiler
-}
-
-
-unsigned long ERR_peek_error()
-{
- return err_helper(true);
-}
-
-
-unsigned long ERR_get_error()
-{
- return err_helper();
-}
-
-
- // functions for stunnel
-
- void RAND_screen()
- {
- // TODO:
- }
-
-
- const char* RAND_file_name(char*, size_t)
- {
- // TODO:
- return 0;
- }
-
-
- int RAND_write_file(const char*)
- {
- // TODO:
- return 0;
- }
-
-
- int RAND_load_file(const char*, long)
- {
- // TODO:
- return 0;
- }
-
-
- void RSA_free(RSA*)
- {
- // TODO:
- }
-
-
- RSA* RSA_generate_key(int, unsigned long, void(*)(int, int, void*), void*)
- {
- // TODO:
- return 0;
- }
-
-
- int X509_LOOKUP_add_dir(X509_LOOKUP*, const char*, long)
- {
- // TODO:
- return SSL_SUCCESS;
- }
-
-
- int X509_LOOKUP_load_file(X509_LOOKUP*, const char*, long)
- {
- // TODO:
- return SSL_SUCCESS;
- }
-
-
- X509_LOOKUP_METHOD* X509_LOOKUP_hash_dir(void)
- {
- // TODO:
- return 0;
- }
-
-
- X509_LOOKUP_METHOD* X509_LOOKUP_file(void)
- {
- // TODO:
- return 0;
- }
-
-
- X509_LOOKUP* X509_STORE_add_lookup(X509_STORE*, X509_LOOKUP_METHOD*)
- {
- // TODO:
- return 0;
- }
-
-
- int X509_STORE_get_by_subject(X509_STORE_CTX*, int, X509_NAME*, X509_OBJECT*)
- {
- // TODO:
- return SSL_SUCCESS;
- }
-
-
- X509_STORE* X509_STORE_new(void)
- {
- // TODO:
- return 0;
- }
-
- char* SSL_alert_type_string_long(int)
- {
- // TODO:
- return 0;
- }
-
-
- char* SSL_alert_desc_string_long(int)
- {
- // TODO:
- return 0;
- }
-
-
- char* SSL_state_string_long(SSL*)
- {
- // TODO:
- return 0;
- }
-
-
- void SSL_CTX_set_tmp_rsa_callback(SSL_CTX*, RSA*(*)(SSL*, int, int))
- {
- // TDOD:
- }
-
-
- long SSL_CTX_set_timeout(SSL_CTX*, long)
- {
- // TDOD:
- return SSL_SUCCESS;
- }
-
-
- int SSL_CTX_use_certificate_chain_file(SSL_CTX*, const char*)
- {
- // TDOD:
- return SSL_SUCCESS;
- }
-
-
- int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX*, const char*, int)
- {
- // TDOD:
- return SSL_SUCCESS;
- }
-
-
- int SSL_set_rfd(SSL*, int)
- {
- return SSL_SUCCESS; // TODO:
- }
-
-
- int SSL_set_wfd(SSL*, int)
- {
- return SSL_SUCCESS; // TODO:
- }
-
-
- int SSL_want_read(SSL*)
- {
- return 0; // TODO:
- }
-
-
- int SSL_want_write(SSL*)
- {
- return 0; // TODO:
- }
-
-
- void SSL_set_shutdown(SSL*, int)
- {
- // TODO:
- }
-
-
- SSL_CIPHER* SSL_get_current_cipher(SSL*)
- {
- // TODO:
- return 0;
- }
-
-
- char* SSL_CIPHER_description(SSL_CIPHER*, char*, int)
- {
- // TODO:
- return 0;
- }
-
-
-
- // end stunnel needs
-
-
-} // extern "C"
-} // namespace
diff --git a/externals/mysql/extlib/yassl/src/template_instnt.cpp b/externals/mysql/extlib/yassl/src/template_instnt.cpp
deleted file mode 100644
index fe3a251b86..0000000000
--- a/externals/mysql/extlib/yassl/src/template_instnt.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- Copyright (C) 2000-2007 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA.
-*/
-
-
-/* Explicit template instantiation requests
- */
-
-
-#include "runtime.hpp"
-#include "handshake.hpp"
-#include "yassl_int.hpp"
-#include "crypto_wrapper.hpp"
-#include "hmac.hpp"
-#include "md5.hpp"
-#include "sha.hpp"
-#include "ripemd.hpp"
-#include "openssl/ssl.h"
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-
-namespace mySTL {
-template class list;
-template yaSSL::del_ptr_zero for_each(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero);
-template pair* uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*);
-template pair* uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*);
-template void destroy*>(mySTL::pair*, mySTL::pair*);
-template void destroy*>(mySTL::pair*, mySTL::pair*);
-template pair* uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*);
-template void destroy*>(mySTL::pair*, mySTL::pair*);
-template pair* uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*);
-template class list;
-template class list;
-template class list;
-template class list;
-template class list;
-template class list;
-template class list;
-template void destroy*>(mySTL::pair*, mySTL::pair*);
-template yaSSL::del_ptr_zero for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero);
-template yaSSL::del_ptr_zero for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero);
-template yaSSL::del_ptr_zero for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list