summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorDaniel Glassey <wdg@debian.org>2015-09-07 11:14:57 +0100
committerDaniel Glassey <wdg@debian.org>2015-09-07 11:14:57 +0100
commit7b6c8b08e9d29332dcd0a1029e7421334bfb6f61 (patch)
treedc263ee8b6c923716a8e0fed64756b7af1238dc7 /bindings
parent7a00574163029c0c2b649878c95d5acbd083564a (diff)
Imported Upstream version 1.7.3+dfsg
Diffstat (limited to 'bindings')
-rw-r--r--bindings/csharp/AssemblyInfo.cs39
-rw-r--r--bindings/csharp/InstallManager.cs97
-rw-r--r--bindings/csharp/Makefile7
-rw-r--r--bindings/csharp/Manager.cs162
-rw-r--r--bindings/csharp/Module.cs214
-rw-r--r--bindings/csharp/NativeMethods.cs260
-rw-r--r--bindings/csharp/README24
-rw-r--r--bindings/csharp/Sword.csproj44
-rw-r--r--bindings/csharp/Sword.sln39
-rw-r--r--bindings/csharp/examples/LookupExample.cs117
-rw-r--r--bindings/csharp/examples/LookupExample.csproj45
-rw-r--r--bindings/csharp/examples/Makefile7
-rw-r--r--bindings/csharp/sword.snkbin0 -> 596 bytes
-rw-r--r--bindings/csharp/tests/AssemblyInfo.cs40
-rw-r--r--bindings/csharp/tests/InstallManagerTests.cs132
-rw-r--r--bindings/csharp/tests/Main.cs25
-rw-r--r--bindings/csharp/tests/ManagerTests.cs111
-rw-r--r--bindings/csharp/tests/ModuleTests.cs162
-rw-r--r--bindings/csharp/tests/Sword.Tests.csproj57
-rw-r--r--bindings/flatapi.cpp1578
-rw-r--r--bindings/java-jni/jni/swordstub.cpp13
-rw-r--r--bindings/swig/package/aclocal.m415
-rwxr-xr-xbindings/swig/package/config.guess151
-rwxr-xr-xbindings/swig/package/config.sub30
-rwxr-xr-xbindings/swig/package/configure4
-rw-r--r--bindings/swig/package/m4/libtool.m44
26 files changed, 3027 insertions, 350 deletions
diff --git a/bindings/csharp/AssemblyInfo.cs b/bindings/csharp/AssemblyInfo.cs
new file mode 100644
index 0000000..896a505
--- /dev/null
+++ b/bindings/csharp/AssemblyInfo.cs
@@ -0,0 +1,39 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("Sword")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("daniel")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
diff --git a/bindings/csharp/InstallManager.cs b/bindings/csharp/InstallManager.cs
new file mode 100644
index 0000000..186ad2f
--- /dev/null
+++ b/bindings/csharp/InstallManager.cs
@@ -0,0 +1,97 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System;
+using System.Collections.Generic;
+
+namespace Sword
+{
+ public class InstallManager : IDisposable
+ {
+ readonly IntPtr _handle;
+
+ public InstallManager (string baseDirectory)
+ {
+ _handle = NativeMethods.org_crosswire_sword_InstallMgr_new(baseDirectory, IntPtr.Zero);
+ }
+
+ public void SetUserDisclaimerConfirmed()
+ {
+ NativeMethods.org_crosswire_sword_InstallMgr_setUserDisclaimerConfirmed(_handle);
+ }
+
+ /// <summary>
+ /// Retrieves a list of sources from the master server.
+ /// </summary>
+ /// <returns>
+ /// True if successful
+ /// False if SetUserDisclaimerConfirmed has not been called.
+ /// False if the sync failed.
+ /// </returns>
+ public bool SyncConfig()
+ {
+ int result = NativeMethods.org_crosswire_sword_InstallMgr_syncConfig(_handle);
+ return result == 0 ? true : false;
+ }
+
+ /// <summary>
+ /// Gets the remote sources.
+ /// You may need to call SyncConfig before calling this
+ /// to get an upto date source list.
+ /// </summary>
+ public IEnumerable<string> RemoteSources
+ {
+ get
+ {
+ IntPtr remoteSourcesPtr = NativeMethods.org_crosswire_sword_InstallMgr_getRemoteSources(_handle);
+ return NativeMethods.MarshalStringArray(remoteSourcesPtr);
+ }
+ }
+
+ public bool RefreshRemoteSource(string sourceName)
+ {
+ int result = NativeMethods.org_crosswire_sword_InstallMgr_refreshRemoteSource(_handle, sourceName);
+ return result == 0 ? true : false;
+ }
+
+ public IEnumerable<ModInfo> GetRemoteModInfoList(Manager manager, string sourceName)
+ {
+ IntPtr pointer = NativeMethods.org_crosswire_sword_InstallMgr_getRemoteModInfoList(_handle, manager.Handle, sourceName);
+ return NativeMethods.MarshallModInfoArray(pointer);
+ }
+
+ public bool RemoteInstallModule(Manager to, string sourceName, string modName)
+ {
+ int result = NativeMethods.org_crosswire_sword_InstallMgr_remoteInstallModule(_handle, to.Handle, sourceName, modName);
+ return result == 0 ? true : false;
+ }
+
+ protected void Dispose(bool disposing)
+ {
+ if(disposing)
+ {
+ if(_handle != IntPtr.Zero)
+ {
+ NativeMethods.org_crosswire_sword_InstallMgr_delete(_handle);
+ }
+ }
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.Collect();
+ }
+ }
+}
+
diff --git a/bindings/csharp/Makefile b/bindings/csharp/Makefile
new file mode 100644
index 0000000..98047cd
--- /dev/null
+++ b/bindings/csharp/Makefile
@@ -0,0 +1,7 @@
+all: Sword.exe
+
+Sword.exe:
+ xbuild Sword.csproj /p:Configuration=Release
+
+clean:
+ xbuild Sword.csproj /p:Configuration=Release /t:Clean
diff --git a/bindings/csharp/Manager.cs b/bindings/csharp/Manager.cs
new file mode 100644
index 0000000..85d9a83
--- /dev/null
+++ b/bindings/csharp/Manager.cs
@@ -0,0 +1,162 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Sword
+{
+ public class Manager : IDisposable
+ {
+ IntPtr _handle;
+
+ public Manager ()
+ {
+ _handle = NativeMethods.org_crosswire_sword_SWMgr_new();
+ }
+
+ public Manager (string path)
+ {
+ _handle = NativeMethods.org_crosswire_sword_SWMgr_newWithPath(path);
+ }
+
+
+ internal IntPtr Handle
+ {
+ get
+ {
+ return _handle;
+ }
+ }
+
+ protected void Dispose(bool disposing)
+ {
+ if(disposing)
+ {
+ if(_handle != IntPtr.Zero)
+ {
+ NativeMethods.org_crosswire_sword_SWMgr_delete(_handle);
+ _handle = IntPtr.Zero;
+ }
+ }
+ }
+
+ public Module GetModuleByName(string name)
+ {
+ IntPtr modulePtr = NativeMethods.org_crosswire_sword_SWMgr_getModuleByName(_handle, name);
+ if(modulePtr == IntPtr.Zero)
+ {
+ return null;
+ }
+ return new Module(modulePtr);
+ }
+
+ /// <summary>
+ /// Gets a list of the installed modules
+ /// </summary>
+ public IEnumerable<ModInfo> GetModInfoList()
+ {
+ IntPtr modulesPointer = NativeMethods.org_crosswire_sword_SWMgr_getModInfoList(_handle);
+ ModInfo modInfo = (ModInfo)Marshal.PtrToStructure(modulesPointer, typeof(ModInfo));
+
+ while (modInfo.Name != null)
+ {
+ yield return modInfo;
+ modulesPointer = new IntPtr(modulesPointer.ToInt64() + Marshal.SizeOf(typeof(ModInfo)));
+ modInfo = (ModInfo)Marshal.PtrToStructure(modulesPointer, typeof(ModInfo));
+ }
+ }
+
+ public string Version
+ {
+ get
+ {
+ IntPtr versionPtr = NativeMethods.org_crosswire_sword_SWMgr_version(_handle);
+ return Marshal.PtrToStringAnsi(versionPtr);
+ }
+ }
+
+ public string PrefixPath
+ {
+ get
+ {
+ IntPtr prefixPathPtr = NativeMethods.org_crosswire_sword_SWMgr_getPrefixPath(_handle);
+ return Marshal.PtrToStringAnsi(prefixPathPtr);
+ }
+ }
+
+ public string ConfigPath
+ {
+ get
+ {
+ IntPtr configPathPtr = NativeMethods.org_crosswire_sword_SWMgr_getConfigPath(_handle);
+ return Marshal.PtrToStringAnsi(configPathPtr);
+ }
+ }
+
+ public void SetGlobalOption(string option, string @value)
+ {
+ NativeMethods.org_crosswire_sword_SWMgr_setGlobalOption(_handle, option, @value);
+ }
+
+ public IEnumerable<string> GetGlobalOptionValues(string option)
+ {
+ IntPtr optionsPtr = NativeMethods.org_crosswire_sword_SWMgr_getGlobalOptionValues(_handle, option);
+ return NativeMethods.MarshalStringArray(optionsPtr);
+ }
+
+ public void SetCipherKey(string modName, byte[] key)
+ {
+ NativeMethods.org_crosswire_sword_SWMgr_setCipherKey(_handle, modName, key);
+ }
+
+ public bool Javascript
+ {
+ set
+ {
+ NativeMethods.org_crosswire_sword_SWMgr_setJavascript(_handle, value);
+ }
+ }
+
+ public IEnumerable<string> AvailableLocales
+ {
+ get
+ {
+ IntPtr localesPtr = NativeMethods.org_crosswire_sword_SWMgr_getAvailableLocales(_handle);
+ return NativeMethods.MarshalStringArray(localesPtr);
+ }
+ }
+
+ public string DefaultLocale
+ {
+ set
+ {
+ NativeMethods.org_crosswire_sword_SWMgr_setDefaultLocale(_handle, value);
+ }
+ }
+
+ public string Translate(string text, string localeName)
+ {
+ IntPtr translatedPtr = NativeMethods.org_crosswire_sword_SWMgr_translate(_handle, text, localeName);
+ return Marshal.PtrToStringAnsi(translatedPtr);
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.Collect();
+ }
+ }
+}
+
diff --git a/bindings/csharp/Module.cs b/bindings/csharp/Module.cs
new file mode 100644
index 0000000..b9cb965
--- /dev/null
+++ b/bindings/csharp/Module.cs
@@ -0,0 +1,214 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+namespace Sword
+{
+ public class Module
+ {
+ IntPtr _handle;
+
+ internal Module(IntPtr handle)
+ {
+ _handle = handle;
+ }
+
+ public string Name
+ {
+ get
+ {
+ IntPtr namePtr = NativeMethods.org_crosswire_sword_SWModule_getName(_handle);
+ return Marshal.PtrToStringAnsi(namePtr);
+ }
+ }
+
+ public string Description
+ {
+ get
+ {
+ IntPtr descriptionPtr = NativeMethods.org_crosswire_sword_SWModule_getDescription(_handle);
+ return Marshal.PtrToStringAnsi(descriptionPtr);
+ }
+ }
+
+ public string Category
+ {
+ get
+ {
+ IntPtr categoryPtr = NativeMethods.org_crosswire_sword_SWModule_getCategory(_handle);
+ return Marshal.PtrToStringAnsi(categoryPtr);
+ }
+ }
+
+
+ /// <summary>
+ /// Special values handled for VerseKey modules:
+ /// [+-][book|chapter] - [de|in]crement by chapter or book
+ /// (e.g. "+chapter" will increment the VerseKey 1 chapter)
+ /// [=][key] - position absolutely and don't normalize
+ /// (e.g. "jn.1.0" for John Chapter 1 intro; "jn.0.0" For Book of John Intro)
+ /// </summary>
+ public string KeyText
+ {
+ get
+ {
+ IntPtr keyTextPtr = NativeMethods.org_crosswire_sword_SWModule_getKeyText(_handle);
+ return Marshal.PtrToStringAnsi(keyTextPtr);
+ }
+ set
+ {
+ NativeMethods.org_crosswire_sword_SWModule_setKeyText(_handle, value);
+ }
+ }
+
+ public string RenderText()
+ {
+ IntPtr keyTextPtr = NativeMethods.org_crosswire_sword_SWModule_renderText(_handle);
+ return Marshal.PtrToStringAnsi(keyTextPtr);
+ }
+
+ public string RawEntry
+ {
+ get
+ {
+ IntPtr keyTextPtr = NativeMethods.org_crosswire_sword_SWModule_getRawEntry(_handle);
+ return Marshal.PtrToStringAnsi(keyTextPtr);
+ }
+ set
+ {
+ NativeMethods.org_crosswire_sword_SWModule_setRawEntry(_handle, value);
+ }
+ }
+
+ public string StripText()
+ {
+ IntPtr keyTextPtr = NativeMethods.org_crosswire_sword_SWModule_stripText(_handle);
+ return Marshal.PtrToStringAnsi(keyTextPtr);
+ }
+
+ public IEnumerable<SearchHit> Search(string searchString, SearchType searchType, long flags, string scope)
+ {
+ IntPtr searchHitPtr = NativeMethods.org_crosswire_sword_SWModule_search(_handle, searchString, (int)searchType, flags, scope, IntPtr.Zero);
+ SearchHit searchHit = (SearchHit)Marshal.PtrToStructure(searchHitPtr, typeof(SearchHit));
+ while (!searchHit.IsNull())
+ {
+ yield return searchHit;
+ searchHitPtr = new IntPtr(searchHitPtr.ToInt64() + Marshal.SizeOf(typeof(SearchHit)));
+ searchHit = (SearchHit)Marshal.PtrToStructure(searchHitPtr, typeof(SearchHit));
+ }
+ }
+
+ public void TerminateSearch()
+ {
+ NativeMethods.org_crosswire_sword_SWModule_terminateSearch(_handle);
+ }
+
+ public char PopError()
+ {
+ return NativeMethods.org_crosswire_sword_SWModule_popError(_handle);
+ }
+
+ public long EntrySize
+ {
+ get
+ {
+ return NativeMethods.org_crosswire_sword_SWModule_getEntrySize(_handle);
+ }
+ }
+
+ public IEnumerable<string> GetEntryAttribute(string level1, string level2, string level3, char filteredBool)
+ {
+ IntPtr attributePtrs = NativeMethods.org_crosswire_sword_SWModule_getEntryAttribute(_handle, level1, level2, level3, filteredBool);
+ return NativeMethods.MarshalStringArray(attributePtrs);
+ }
+
+ public IEnumerable<string> ParseKeyList(string keyText)
+ {
+ IntPtr keyListPtrs = NativeMethods.org_crosswire_sword_SWModule_parseKeyList(_handle, keyText);
+ return NativeMethods.MarshalStringArray(keyListPtrs);
+ }
+
+ public bool HasKeyChildren()
+ {
+ char hasChildren = NativeMethods.org_crosswire_sword_SWModule_hasKeyChildren(_handle);
+ return hasChildren == 1 ? true : false;
+ }
+
+ /// <summary>
+ /// This method returns child nodes for a genbook,
+ /// but has special handling if called on a VerseKey module:
+ /// [0..7] [testament, book, chapter, verse, chapterMax, verseMax, bookName, osisRef]
+ /// </summary>
+ public IEnumerable<string> KeyChildren
+ {
+ get
+ {
+ IntPtr childrenPtr = NativeMethods.org_crosswire_sword_SWModule_getKeyChildren(_handle);
+ return NativeMethods.MarshalStringArray(childrenPtr);
+ }
+ }
+
+ public string KeyParent
+ {
+ get
+ {
+ IntPtr keyPtr = NativeMethods.org_crosswire_sword_SWModule_getKeyChildren(_handle);
+ return Marshal.PtrToStringAnsi(keyPtr);
+ }
+ }
+
+ public void Prevous()
+ {
+ NativeMethods.org_crosswire_sword_SWModule_previous(_handle);
+ }
+
+ public void Next()
+ {
+ NativeMethods.org_crosswire_sword_SWModule_next(_handle);
+ }
+
+ public void Begin()
+ {
+ NativeMethods.org_crosswire_sword_SWModule_begin(_handle);
+ }
+
+ public string RenderHeader
+ {
+ get
+ {
+ IntPtr headerPtr = NativeMethods.org_crosswire_sword_SWModule_getRenderHeader(_handle);
+ return Marshal.PtrToStringAnsi(headerPtr);
+ }
+ }
+
+ public string GetConfigEntry(string key)
+ {
+ IntPtr entryPtr = NativeMethods.org_crosswire_sword_SWModule_getConfigEntry(_handle, key);
+ return Marshal.PtrToStringAnsi(entryPtr);
+ }
+
+ public void DeleteSearchFramework()
+ {
+ NativeMethods.org_crosswire_sword_SWModule_deleteSearchFramework(_handle);
+ }
+
+ public bool HasSearchFramework()
+ {
+ return NativeMethods.org_crosswire_sword_SWModule_hasSearchFramework(_handle);
+ }
+ }
+}
+
diff --git a/bindings/csharp/NativeMethods.cs b/bindings/csharp/NativeMethods.cs
new file mode 100644
index 0000000..6a3c911
--- /dev/null
+++ b/bindings/csharp/NativeMethods.cs
@@ -0,0 +1,260 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+namespace Sword
+{
+ public enum SearchType
+ {
+ REGEX = 1,
+ PHRASE = -1,
+ MULTIWORD = -2,
+ ENTRYATTR = -3,
+ LUCENE = -4
+ };
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
+ public struct ModInfo
+ {
+ public string Name;
+ public string Description;
+ public string Category;
+ public string Language;
+ };
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct SearchHit
+ {
+ IntPtr _modName;
+ IntPtr _key;
+ long Score;
+
+ public bool IsNull()
+ {
+ return _key == IntPtr.Zero;
+ }
+ public string Key
+ {
+ get
+ {
+ if(_key == IntPtr.Zero)
+ {
+ return null;
+ }
+ return Marshal.PtrToStringAnsi(_key);
+ }
+ }
+
+ public string ModName
+ {
+ get
+ {
+ if(_modName == IntPtr.Zero)
+ {
+ return null;
+ }
+ return Marshal.PtrToStringAnsi(_modName);
+ }
+ }
+ };
+
+ public static class NativeMethods
+ {
+
+
+ public const string DLLNAME = "libsword.so";
+
+ [DllImport(DLLNAME)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_new();
+
+ [DllImport(DLLNAME)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_newWithPath(string path);
+
+ [DllImport(DLLNAME)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_getModuleByName(IntPtr hSWMgr, string moduleName);
+
+ [DllImport(DLLNAME)]
+ public static extern void org_crosswire_sword_SWModule_setKeyText(IntPtr hSWModule, string key);
+
+ [DllImport(DLLNAME)]
+ public static extern IntPtr org_crosswire_sword_SWModule_renderText(IntPtr hSWModule);
+
+ [DllImport(DLLNAME)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getRawEntry(IntPtr hSWModule);
+
+ [DllImport(DLLNAME)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getKeyText(IntPtr hSWModule);
+
+ [DllImport(DLLNAME)]
+ public static extern void org_crosswire_sword_SWMgr_delete(IntPtr hSWMgr);
+
+ [DllImport(DLLNAME)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_getModInfoList(IntPtr hSWMgr);
+
+ [DllImport(DLLNAME)]
+ public static extern IntPtr org_crosswire_sword_SWModule_stripText(IntPtr hSWModule);
+
+ [DllImport(DLLNAME)]
+ public static extern void org_crosswire_sword_SWModule_setRawEntry(IntPtr hSWModule, string entryBuffer);
+
+ [DllImport(DLLNAME)]
+ public static extern void org_crosswire_sword_SWModule_terminateSearch(IntPtr hSWModule);
+
+ [DllImport(DLLNAME)]
+ public static extern char org_crosswire_sword_SWModule_popError(IntPtr hSWModule);
+
+ [DllImport(DLLNAME)]
+ public static extern long org_crosswire_sword_SWModule_getEntrySize(IntPtr hSWModule);
+
+ [DllImport(DLLNAME)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getEntryAttribute(IntPtr hSWModule, string level1, string level2, string level3, char filteredBool);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWModule_parseKeyList(IntPtr hSWModule, string keyText);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWModule_search(IntPtr hSWModule, string searchString, int searchType, long flags, string scope, IntPtr progressReporter);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern char org_crosswire_sword_SWModule_hasKeyChildren(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getKeyChildren(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getName(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getDescription(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getCategory(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getKeyParent(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_SWModule_previous(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_SWModule_next(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_SWModule_begin(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getRenderHeader(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWModule_getConfigEntry(IntPtr hSWModule, string key);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_SWModule_deleteSearchFramework(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool org_crosswire_sword_SWModule_hasSearchFramework(IntPtr hSWModule);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_version(IntPtr hSWMgr);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_getPrefixPath(IntPtr hSWMgr);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_getConfigPath(IntPtr hSWMgr);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_SWMgr_setGlobalOption(IntPtr hSWMgr, string option, string val);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_getGlobalOptionValues(IntPtr hSWMgr, string option);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_SWMgr_setCipherKey(IntPtr hSWMgr, string modName, byte[] key);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_SWMgr_setJavascript(IntPtr hSWMgr, bool valueBool);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_getAvailableLocales(IntPtr hSWMgr);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_SWMgr_setDefaultLocale(IntPtr hSWMgr, string name);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_SWMgr_translate(IntPtr hSWMgr, string text, string localeName);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_InstallMgr_reInit(IntPtr hInstallMgr);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_InstallMgr_new(string baseDir, IntPtr statusReporter);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_InstallMgr_setUserDisclaimerConfirmed(IntPtr hInstallMgr);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int org_crosswire_sword_InstallMgr_syncConfig(IntPtr hInstallMgr);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_InstallMgr_getRemoteSources(IntPtr hInstallMgr);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr org_crosswire_sword_InstallMgr_getRemoteModInfoList(IntPtr hInstallMgr, IntPtr hSWMgr_deltaCompareTo, string sourceName);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int org_crosswire_sword_InstallMgr_refreshRemoteSource(IntPtr hInstallMgr, string sourceName);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int org_crosswire_sword_InstallMgr_remoteInstallModule(IntPtr hInstallMgr_from, IntPtr hSWMgr_to, string sourceName, string modName);
+
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void org_crosswire_sword_InstallMgr_delete(IntPtr hInstallMgr);
+
+ public static IEnumerable<string> MarshalStringArray(IntPtr arrayPtr)
+ {
+ if(arrayPtr == IntPtr.Zero)
+ {
+ yield break;
+ }
+
+ while(arrayPtr != IntPtr.Zero)
+ {
+ IntPtr ptr = Marshal.ReadIntPtr(arrayPtr);
+ if(ptr == IntPtr.Zero)
+ {
+ yield break;
+ }
+ string key = Marshal.PtrToStringAnsi(ptr);
+ yield return key;
+ arrayPtr = new IntPtr(arrayPtr.ToInt64() + IntPtr.Size);
+ }
+ }
+
+ public static IEnumerable<ModInfo> MarshallModInfoArray(IntPtr pointer)
+ {
+ ModInfo modInfo = (ModInfo)Marshal.PtrToStructure(pointer, typeof(ModInfo));
+
+ while (modInfo.Name != null)
+ {
+ yield return modInfo;
+ pointer = new IntPtr(pointer.ToInt64() + Marshal.SizeOf(typeof(ModInfo)));
+ modInfo = (ModInfo)Marshal.PtrToStructure(pointer, typeof(ModInfo));
+ }
+ }
+ }
+}
+
diff --git a/bindings/csharp/README b/bindings/csharp/README
new file mode 100644
index 0000000..11ad4c5
--- /dev/null
+++ b/bindings/csharp/README
@@ -0,0 +1,24 @@
+Building on debian/ubuntu the commandline way
+1. sudo apt-get install cli-common-dev
+2. sudo apt-get install mono-xbuild
+3. navigate to bindings/csharp
+4. make or xbuild Sword.csproj to build the bindings project only
+5. xbuild Sword.sln to build everything; bindings, unit tests and LookupExample.
+
+Building on debian/ubuntu the IDE way
+1. sudo apt-get install MonoDevelop
+2. launch MonoDevelop and open sword/bindings/csharp/Sword.sln
+3. Hit the run button
+
+Unit Tests
+MonoDevelop has a unit test runner built in.
+1. launch the Sword.sln file in monodevelop
+2. View->Unit Testing
+3. Right click on top level test (Sword)
+4. Run test
+
+LookupExample
+1. Navigate to sword/bindings/csharp/examples
+2. make
+3. output will be in bin/Release
+4. mono LookupExample.exe KJV john.3.16
diff --git a/bindings/csharp/Sword.csproj b/bindings/csharp/Sword.csproj
new file mode 100644
index 0000000..544703c
--- /dev/null
+++ b/bindings/csharp/Sword.csproj
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{EFEE3557-86F2-4E46-AF7E-8BADEE240764}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>Sword</RootNamespace>
+ <AssemblyName>CSSword</AssemblyName>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>sword.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyInfo.cs" />
+ <Compile Include="NativeMethods.cs" />
+ <Compile Include="Module.cs" />
+ <Compile Include="Manager.cs" />
+ <Compile Include="InstallManager.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/bindings/csharp/Sword.sln b/bindings/csharp/Sword.sln
new file mode 100644
index 0000000..9ff1ea6
--- /dev/null
+++ b/bindings/csharp/Sword.sln
@@ -0,0 +1,39 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sword", "Sword.csproj", "{EFEE3557-86F2-4E46-AF7E-8BADEE240764}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sword.Tests", "tests\Sword.Tests.csproj", "{72212684-1186-4F68-8FBD-BDBFDB8CC9BC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LookupExample", "examples\LookupExample.csproj", "{60F12DE9-FBC5-42B1-8341-9AB097D661AE}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {60F12DE9-FBC5-42B1-8341-9AB097D661AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {60F12DE9-FBC5-42B1-8341-9AB097D661AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {60F12DE9-FBC5-42B1-8341-9AB097D661AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {60F12DE9-FBC5-42B1-8341-9AB097D661AE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {72212684-1186-4F68-8FBD-BDBFDB8CC9BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {72212684-1186-4F68-8FBD-BDBFDB8CC9BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {72212684-1186-4F68-8FBD-BDBFDB8CC9BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {72212684-1186-4F68-8FBD-BDBFDB8CC9BC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EFEE3557-86F2-4E46-AF7E-8BADEE240764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EFEE3557-86F2-4E46-AF7E-8BADEE240764}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EFEE3557-86F2-4E46-AF7E-8BADEE240764}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EFEE3557-86F2-4E46-AF7E-8BADEE240764}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = Sword.csproj
+ Policies = $0
+ $0.DotNetNamingPolicy = $1
+ $1.DirectoryNamespaceAssociation = None
+ $1.ResourceNamePolicy = FileFormatDefault
+ $0.StandardHeader = $2
+ $2.Text = @Copyright 2002-2014 CrossWire Bible Society (http://www.crosswire.org)\n \tCrossWire Bible Society\n \tP. O. Box 2528\n \tTempe, AZ 85280-2528\n \n This program is free software; you can redistribute it and/or modify it\n under the terms of the GNU General Public License as published by the\n Free Software Foundation version 2.\n \n This program is distributed in the hope that it will be useful, but\n WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n General Public License for more details.
+ $2.IncludeInNewFiles = True
+ EndGlobalSection
+EndGlobal
diff --git a/bindings/csharp/examples/LookupExample.cs b/bindings/csharp/examples/LookupExample.cs
new file mode 100644
index 0000000..5a63e88
--- /dev/null
+++ b/bindings/csharp/examples/LookupExample.cs
@@ -0,0 +1,117 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System;
+
+namespace Sword.Tests
+{
+ class LookupExample
+ {
+ public static void Main (string[] args)
+ {
+ if (args.Length != 2)
+ {
+ Console.WriteLine ("usage: lookup <module> <key>");
+ return;
+ }
+ Lookup(args[0], args[1]);
+ return;
+ }
+
+ public static void Lookup(string modName, string key)
+ {
+ using(var manager = new Manager())
+ {
+ var module = manager.GetModuleByName(modName);
+
+ if (module == null)
+ {
+ Console.Error.WriteLine("Could not find module {0}. Available modules:", modName);
+ foreach(var modInfo in manager.GetModInfoList())
+ {
+ Console.WriteLine ("{0}\t - {1}", modInfo.Name, modInfo.Description);
+ }
+ return;
+ }
+
+ module.KeyText = key;
+
+ Console.WriteLine(module.KeyText);
+ Console.WriteLine("==Raw=Entry============");
+ Console.WriteLine(module.RawEntry);
+ Console.WriteLine("==Render=Text============");
+ Console.WriteLine(module.RenderText());
+ Console.WriteLine("==Strip=Text============");
+ Console.WriteLine(module.StripText());
+ Console.WriteLine("==========================");
+ }
+ }
+
+ public static void ParseKeyList()
+ {
+ using(var manager = new Manager())
+ {
+ var module = manager.GetModuleByName("ESV");
+
+ if (module == null)
+ {
+ Console.Error.WriteLine("Could not find module {0}. Available modules:", "ESV");
+ foreach(var modInfo in manager.GetModInfoList())
+ {
+ Console.WriteLine ("{0}\t - {1}", modInfo.Name, modInfo.Description);
+ }
+ return;
+ }
+
+ module.KeyText = "jn.3.16";
+
+ Console.WriteLine("==Render=Entry============");
+ Console.WriteLine(module.KeyText);
+ Console.WriteLine("RenderText: " + module.RenderText());
+ Console.WriteLine("StripText: " + module.StripText());
+
+ Console.WriteLine("RawText: " + module.RawEntry);
+ Console.WriteLine("==========================");
+
+ foreach(var key in module.ParseKeyList("James 1:19-30"))
+ {
+ Console.WriteLine (key);
+ }
+ }
+ }
+
+ public static void Search()
+ {
+ using(var manager = new Manager())
+ {
+ var module = manager.GetModuleByName("ESV");
+
+ if (module == null)
+ {
+ Console.Error.WriteLine("Could not find module {0}. Available modules:", "ESV");
+ foreach(var modInfo in manager.GetModInfoList())
+ {
+ Console.WriteLine ("{0}\t - {1}", modInfo.Name, modInfo.Description);
+ }
+ return;
+ }
+
+ foreach(var hit in module.Search("sin", SearchType.REGEX, 0, null))
+ {
+ Console.WriteLine(hit.Key);
+ }
+ module.TerminateSearch();
+ }
+ }
+ }
+}
diff --git a/bindings/csharp/examples/LookupExample.csproj b/bindings/csharp/examples/LookupExample.csproj
new file mode 100644
index 0000000..aad4e7e
--- /dev/null
+++ b/bindings/csharp/examples/LookupExample.csproj
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{60F12DE9-FBC5-42B1-8341-9AB097D661AE}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>LookupExample</RootNamespace>
+ <AssemblyName>LookupExample</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ <Commandlineparameters>ESV john.3.16</Commandlineparameters>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <Compile Include="LookupExample.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Sword.csproj">
+ <Project>{EFEE3557-86F2-4E46-AF7E-8BADEE240764}</Project>
+ <Name>Sword</Name>
+ </ProjectReference>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/bindings/csharp/examples/Makefile b/bindings/csharp/examples/Makefile
new file mode 100644
index 0000000..968a6c6
--- /dev/null
+++ b/bindings/csharp/examples/Makefile
@@ -0,0 +1,7 @@
+all: LookupExample.exe
+
+LookupExample.exe: LookupExample.cs
+ xbuild LookupExample.csproj /p:Configuration=Release
+
+clean:
+ xbuild LookupExample.csproj /p:Configuration=Release /t:Clean
diff --git a/bindings/csharp/sword.snk b/bindings/csharp/sword.snk
new file mode 100644
index 0000000..950b10c
--- /dev/null
+++ b/bindings/csharp/sword.snk
Binary files differ
diff --git a/bindings/csharp/tests/AssemblyInfo.cs b/bindings/csharp/tests/AssemblyInfo.cs
new file mode 100644
index 0000000..d6b8076
--- /dev/null
+++ b/bindings/csharp/tests/AssemblyInfo.cs
@@ -0,0 +1,40 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("Sword.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("daniel")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
diff --git a/bindings/csharp/tests/InstallManagerTests.cs b/bindings/csharp/tests/InstallManagerTests.cs
new file mode 100644
index 0000000..057c141
--- /dev/null
+++ b/bindings/csharp/tests/InstallManagerTests.cs
@@ -0,0 +1,132 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System;
+using NUnit.Framework;
+using System.Linq;
+
+namespace Sword.Tests
+{
+ [TestFixture]
+ public class InstallManagerTests
+ {
+ InstallManager _installManager;
+
+ [SetUp]
+ public void Setup()
+ {
+ _installManager = new InstallManager("baseDirectory");
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ _installManager.Dispose();
+ }
+
+ [Test]
+ public void SetUserDisclaimerConfirmed_Called_DoesntCrash()
+ {
+ _installManager.SetUserDisclaimerConfirmed();
+ }
+
+ [Test]
+ public void SyncConfig_UserDisclaimerConfirmed_ReturnsTrue()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+
+ //act
+ bool result = _installManager.SyncConfig();
+
+ //assert
+ Assert.That (result, Is.True);
+ }
+
+ [Test]
+ public void SyncConfig_UserDisclaimerNotConfirmed_ReturnsFalse()
+ {
+ //act
+ bool result = _installManager.SyncConfig();
+
+ //assert
+ Assert.That (result, Is.False);
+ }
+
+ [Test]
+ public void RemoteSources_Called_ReturnsRemoteSources()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+ _installManager.SyncConfig();
+
+ //act
+ var remoteSources = _installManager.RemoteSources.ToArray();
+
+ //assert
+ Assert.That (remoteSources.Length > 0);
+ }
+
+ [Test]
+ public void RefreshRemoteSource_Called_ReturnsTrue()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+ _installManager.SyncConfig();
+ string firstSource = _installManager.RemoteSources.First();
+ bool result = _installManager.RefreshRemoteSource(firstSource);
+
+ //act
+ Assert.That (result, Is.True);
+ }
+
+ [Test]
+ public void GetRemoteModInfoList_FirstSource_ReturnsModInfoList()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+ _installManager.SyncConfig();
+ string firstSource = _installManager.RemoteSources.First();
+ _installManager.RefreshRemoteSource(firstSource);
+
+ ModInfo[] remoteModInfos;
+ using(Manager manager = new Manager())
+ {
+ //act
+ remoteModInfos = _installManager.GetRemoteModInfoList(manager, firstSource).ToArray();
+ }
+
+ //assert
+ Assert.That (remoteModInfos.Length, Is.GreaterThan(0));
+ }
+
+ [Test]
+ public void RemoteInstallModule_KJV_ReturnsTrue()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+ Assert.That (_installManager.SyncConfig(), Is.True);
+ Assert.That (_installManager.RefreshRemoteSource("CrossWire"), Is.True);
+
+ using(Manager manager = new Manager("LocalManager"))
+ {
+ //act
+ bool result = _installManager.RemoteInstallModule(manager, "CrossWire", "KJV");
+
+ //assert
+ Assert.That (result, Is.True);
+ }
+ }
+ }
+}
+
diff --git a/bindings/csharp/tests/Main.cs b/bindings/csharp/tests/Main.cs
new file mode 100644
index 0000000..1f96c81
--- /dev/null
+++ b/bindings/csharp/tests/Main.cs
@@ -0,0 +1,25 @@
+// Copyright 2002-2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System;
+
+namespace Sword.Tests
+{
+ public class MainClass
+ {
+ public static void Main(string[] args)
+ {
+ }
+ }
+}
+
diff --git a/bindings/csharp/tests/ManagerTests.cs b/bindings/csharp/tests/ManagerTests.cs
new file mode 100644
index 0000000..6f71b33
--- /dev/null
+++ b/bindings/csharp/tests/ManagerTests.cs
@@ -0,0 +1,111 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System;
+using NUnit.Framework;
+using System.IO;
+using System.Linq;
+
+namespace Sword.Tests
+{
+ [TestFixture]
+ public class ManagerTests
+ {
+ Manager _manager;
+
+ [TestFixtureSetUp]
+ public void Setup()
+ {
+ _manager = new Manager();
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ _manager.Dispose();
+ }
+
+ [Test]
+ public void Version_Get_ReturnsAVersion()
+ {
+ //act
+ string swordVersion = _manager.Version;
+
+ //assert
+ Version version;
+ Assert.That (Version.TryParse(swordVersion, out version));
+ }
+
+ [Test]
+ public void PrefixPath_Get_ReturnsValidPath()
+ {
+ //act
+ string prefixPath = _manager.PrefixPath;
+
+ //assert
+ Assert.That (Directory.Exists(prefixPath), Is.True);
+ }
+
+ [Test]
+ public void ConfigPath_Get_ReturnsValidPath()
+ {
+ //act
+ string configPath = _manager.ConfigPath;
+
+ //assert
+ Assert.That (Directory.Exists(configPath), Is.True);
+ }
+
+ [Test]
+ public void SetCipherKey_Called_DoesntCrash()
+ {
+ //act
+ _manager.SetCipherKey("ESV", new byte[32]);
+ }
+
+ [Test]
+ public void Javascript_Set_DoesntCrash()
+ {
+ //act
+ _manager.Javascript = true;
+ }
+
+ [Test]
+ public void AvailableLocales_Get_DoesntCrash()
+ {
+ //act
+ var availableLocales = _manager.AvailableLocales.ToArray();
+
+ //Assert
+ Assert.That (availableLocales[0].Contains("en"));
+ }
+
+ [Test]
+ public void DefaultLocale_SetToEn_DoesntCrash()
+ {
+ //act
+ _manager.DefaultLocale = "en";
+ }
+
+ [Test]
+ public void Translate_EnglishToEnglish_ReturnsOrginal()
+ {
+ //act
+ var result = _manager.Translate("love", "en");
+
+ //assert
+ Assert.That (result, Is.EqualTo("love"));
+ }
+ }
+}
+
diff --git a/bindings/csharp/tests/ModuleTests.cs b/bindings/csharp/tests/ModuleTests.cs
new file mode 100644
index 0000000..71cbea8
--- /dev/null
+++ b/bindings/csharp/tests/ModuleTests.cs
@@ -0,0 +1,162 @@
+// Copyright 2014 CrossWire Bible Society (http://www.crosswire.org)
+// CrossWire Bible Society
+// P. O. Box 2528
+// Tempe, AZ 85280-2528
+//
+// 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.
+//
+// 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.
+using System;
+using NUnit.Framework;
+using System.IO;
+
+namespace Sword.Tests
+{
+ [TestFixture]
+ public class ModuleTests
+ {
+ Module _swordModule;
+ Manager _swordManager;
+
+ [TestFixtureSetUp]
+ public void Setup()
+ {
+ _swordManager = new Manager("LocalManager");
+ _swordModule = _swordManager.GetModuleByName("ESV");
+
+ if(_swordModule != null)
+ {
+ return;
+ }
+ using(var installManager = new InstallManager("baseDirectory"))
+ {
+ installManager.SetUserDisclaimerConfirmed();
+ installManager.SyncConfig();
+ installManager.RefreshRemoteSource("CrossWire");
+
+ installManager.RemoteInstallModule(_swordManager, "CrossWire", "ESV");
+ _swordModule = _swordManager.GetModuleByName("ESV");
+ }
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ _swordManager.Dispose();
+ }
+
+ [Test]
+ public void Name_Get_Esv()
+ {
+ //arrange
+ //act
+ string name =_swordModule.Name;
+
+ //assert
+ Assert.That (name, Is.EqualTo ("ESV"));
+ }
+
+ [Test]
+ public void Description_Get_DescriptionCorrect()
+ {
+ //arrange
+ //act
+ string description =_swordModule.Description;
+
+ //assert
+ Assert.That (description, Is.EqualTo ("English Standard Version"));
+ }
+
+ [Test]
+ public void Catagory_Get_CatagoryCorrect()
+ {
+ //arrange
+ //act
+ string catagory =_swordModule.Category;
+
+ //assert
+ Assert.That (catagory, Is.EqualTo ("Biblical Texts"));
+ }
+
+ [Test]
+ public void Previous_John3v16_John3v15()
+ {
+ //arrange
+ _swordModule.KeyText = "jn.3.16";
+
+ //act
+ _swordModule.Prevous();
+
+ //assert
+ Assert.That (_swordModule.KeyText, Is.EqualTo( "John 3:15"));
+ }
+
+ [Test]
+ public void Next_John3v15_John3v16()
+ {
+ //arrange
+ _swordModule.KeyText = "jn.3.15";
+
+ //act
+ _swordModule.Next();
+
+ //assert
+ Assert.That (_swordModule.KeyText, Is.EqualTo( "John 3:16"));
+ }
+
+ [Test]
+ public void Begin_John3v15_Genesis1v1()
+ {
+ //arrange
+ _swordModule.KeyText = "jn.3.15";
+
+ //act
+ _swordModule.Begin();
+
+ //assert
+ Assert.That (_swordModule.KeyText, Is.EqualTo( "Genesis 1:1"));
+ }
+
+ [Test]
+ public void RenderHeader_John3v16_ReturnsNonNullOrEmpty()
+ {
+ //arrange
+ _swordModule.KeyText = "jn.3.16";
+
+ //act
+ string header = _swordModule.RenderHeader;
+
+ //assert
+ Assert.That (!string.IsNullOrEmpty(header));
+ }
+
+ [Test]
+ public void RawEntry_Get_ContainsVerse()
+ {
+ //arrange
+ _swordModule.KeyText = "jn.3.16";
+
+ //act
+ string rawEntry = _swordModule.RawEntry;
+
+ //assert
+ Assert.That (rawEntry.Contains ("God so loved"));
+ }
+
+ public void HasSearchFramework_Doesnt_ReturnsFalse()
+ {
+ //arrange
+ //act
+ bool hasSearchFramework = _swordModule.HasSearchFramework();
+
+ //assert
+ Assert.That (hasSearchFramework, Is.False);
+ }
+ }
+}
+
diff --git a/bindings/csharp/tests/Sword.Tests.csproj b/bindings/csharp/tests/Sword.Tests.csproj
new file mode 100644
index 0000000..1e44fda
--- /dev/null
+++ b/bindings/csharp/tests/Sword.Tests.csproj
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{72212684-1186-4F68-8FBD-BDBFDB8CC9BC}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>Sword.Tests</RootNamespace>
+ <AssemblyName>CSSword.Tests</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ <Commandlineparameters>ESV jn.3.16</Commandlineparameters>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="nunit.core, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+ <Private>False</Private>
+ <Package>mono-nunit</Package>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+ <Private>False</Private>
+ <Package>mono-nunit</Package>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyInfo.cs" />
+ <Compile Include="ModuleTests.cs" />
+ <Compile Include="ManagerTests.cs" />
+ <Compile Include="InstallManagerTests.cs" />
+ <Compile Include="Main.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <ProjectReference Include="..\Sword.csproj">
+ <Project>{EFEE3557-86F2-4E46-AF7E-8BADEE240764}</Project>
+ <Name>Sword</Name>
+ </ProjectReference>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/bindings/flatapi.cpp b/bindings/flatapi.cpp
index 55cf083..1c6872c 100644
--- a/bindings/flatapi.cpp
+++ b/bindings/flatapi.cpp
@@ -3,9 +3,9 @@
* flatapi.cpp - This file contains an api usable by non-C++
* environments
*
- * $Id: flatapi.cpp 2921 2013-07-28 17:21:44Z scribe $
+ * $Id: flatapi.cpp 3226 2014-05-02 03:01:35Z greg.hellings $
*
- * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2014 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -21,361 +21,1461 @@
*
*/
-#include <stdio.h>
-
-#include <rawtext.h>
-#include <rawcom.h>
-#include <rawld.h>
-#include <strkey.h>
-#include <listkey.h>
-#include <versekey.h>
+#include <iostream>
+#include <vector>
+#include <map>
+
+#include <swversion.h>
#include <swmgr.h>
-#include <markupfiltmgr.h>
-#ifndef NO_SWORD_NAMESPACE
-using namespace sword;
-#endif
+#include <installmgr.h>
+#include <remotetrans.h>
+#include <versekey.h>
+#include <treekeyidx.h>
+#include <filemgr.h>
+#include <swbuf.h>
+#include <localemgr.h>
+#include <utilstr.h>
+#include "corba/orbitcpp/webmgr.hpp"
+
extern "C" {
-#include "flatapi.h"
+#include <flatapi.h>
}
-typedef struct {
- ModMap::iterator it;
-// void *it;
- ModMap::iterator end;
-// void *end;
-} ModItType;
+using sword::VerseKey;
+using sword::SWVersion;
+using sword::SWBuf;
+using sword::TreeKeyIdx;
-//-----------------------------------------------------------------
-// SWMgr methods
+#define GETSWMGR(handle, failReturn) HandleSWMgr *hmgr = (HandleSWMgr *)handle; if (!hmgr) return failReturn; WebMgr *mgr = hmgr->mgr; if (!mgr) return failReturn;
+
+#define GETSWMODULE(handle, failReturn) HandleSWModule *hmod = (HandleSWModule *)handle; if (!hmod) return failReturn; SWModule *module = hmod->mod; if (!module) return failReturn;
+
+#define GETINSTMGR(handle, failReturn) HandleInstMgr *hinstmgr = (HandleInstMgr *)handle; if (!hinstmgr) return failReturn; InstallMgr *installMgr = hinstmgr->installMgr; if (!installMgr) return failReturn;
+
+namespace {
+
+
+void clearStringArray(const char ***stringArray) {
+ if (*stringArray) {
+ for (int i = 0; true; ++i) {
+ if ((*stringArray)[i]) {
+ delete [] (*stringArray)[i];
+ }
+ else break;
+ }
+ free((*stringArray));
+ (*stringArray) = 0;
+ }
+}
+
+
+void clearModInfo(org_crosswire_sword_ModInfo **modInfo) {
+ if (*modInfo) {
+ for (int i = 0; true; ++i) {
+ if ((*modInfo)[i].name) {
+ delete [] (*modInfo)[i].name;
+ delete [] (*modInfo)[i].description;
+ delete [] (*modInfo)[i].category;
+ delete [] (*modInfo)[i].language;
+ delete [] (*modInfo)[i].version;
+ delete [] (*modInfo)[i].delta;
+ }
+ else break;
+ }
+ free((*modInfo));
+ (*modInfo) = 0;
+ }
+}
+
+
+struct pu {
+ char last;
+ SWHANDLE progressReporter;
+
+ void init(SWHANDLE pr) { progressReporter = pr; last = 0; }
+/*
+ pu(JNIEnv *env, jobject pr) : env(env), progressReporter(pr), last(0) {}
+ JNIEnv *env;
+ jobject progressReporter;
+*/
+};
+void percentUpdate(char percent, void *userData) {
+ struct pu *p = (struct pu *)userData;
+
+ if (percent != p->last) {
+ p->last = percent;
+/*
+ jclass cls = p->env->GetObjectClass(p->progressReporter);
+ jmethodID mid = p->env->GetMethodID(cls, "progressReport", "(I)V");
+ if (mid != 0) {
+ p->env->CallVoidMethod(p->progressReporter, mid, (jint)percent);
+ }
+*/
+ }
+}
+
+class MyStatusReporter : public StatusReporter {
+public:
+ int last;
+ SWHANDLE statusReporter;
+ MyStatusReporter() : last(0), statusReporter(0) {}
+ void init(SWHANDLE sr) { statusReporter = sr; last = 0; }
+ virtual void update(unsigned long totalBytes, unsigned long completedBytes) {
+ int p = (totalBytes > 0) ? (int)(74.0 * ((double)completedBytes / (double)totalBytes)) : 0;
+ for (;last < p; ++last) {
+ if (!last) {
+ SWBuf output;
+ output.setFormatted("[ File Bytes: %ld", totalBytes);
+ while (output.size() < 75) output += " ";
+ output += "]";
+// cout << output.c_str() << "\n ";
+ }
+// cout << "-";
+ }
+// cout.flush();
+ }
+ virtual void preStatus(long totalBytes, long completedBytes, const char *message) {
+ SWBuf output;
+ output.setFormatted("[ Total Bytes: %ld; Completed Bytes: %ld", totalBytes, completedBytes);
+ while (output.size() < 75) output += " ";
+ output += "]";
+// cout << "\n" << output.c_str() << "\n ";
+// int p = (int)(74.0 * (double)completedBytes/totalBytes);
+// for (int i = 0; i < p; ++i) { cout << "="; }
+// cout << "\n\n" << message << "\n";
+ last = 0;
+ }
+};
+
+class HandleSWModule {
+public:
+ SWModule *mod;
+ char *renderBuf;
+ char *stripBuf;
+ char *renderHeader;
+ char *rawEntry;
+ char *configEntry;
+ struct pu peeuuu;
+ // making searchHits cache static saves memory only having a single
+ // outstanding copy, but also is not threadsafe. Remove static here
+ // and fix compiling bugs and add clearSearchHits() to d-tor to change
+ static org_crosswire_sword_SearchHit *searchHits;
+ static const char **entryAttributes;
+ static const char **parseKeyList;
+ static const char **keyChildren;
+
+ HandleSWModule(SWModule *mod) {
+ this->mod = mod;
+ this->renderBuf = 0;
+ this->stripBuf = 0;
+ this->renderHeader = 0;
+ this->rawEntry = 0;
+ this->configEntry = 0;
+ }
+ ~HandleSWModule() {
+ delete [] renderBuf;
+ delete [] stripBuf;
+ delete [] renderHeader;
+ delete [] rawEntry;
+ delete [] configEntry;
+ }
+
+ static void clearSearchHits() {
+ if (searchHits) {
+ for (int i = 0; true; ++i) {
+ if (searchHits[i].modName) {
+ delete [] searchHits[i].key;
+ }
+ else break;
+ }
+ free(searchHits);
+ searchHits = 0;
+ }
+ }
+ static void clearEntryAttributes() {
+ clearStringArray(&entryAttributes);
+ }
+ static void clearParseKeyList() {
+ clearStringArray(&parseKeyList);
+ }
+ static void clearKeyChildren() {
+ clearStringArray(&keyChildren);
+ }
+};
+
+
+class HandleSWMgr {
+public:
+ WebMgr *mgr;
+ org_crosswire_sword_ModInfo *modInfo;
+ std::map<SWModule *, HandleSWModule *> moduleHandles;
+ SWBuf filterBuf;
+ static const char **globalOptions;
+ static const char **globalOptionValues;
+ static const char **availableLocales;
+
+ HandleSWMgr(WebMgr *mgr) {
+ this->mgr = mgr;
+ this->modInfo = 0;
+ }
+
+ void clearModInfo() {
+ ::clearModInfo(&modInfo);
+ }
+
+ ~HandleSWMgr() {
+ clearModInfo();
+ for (std::map<SWModule *, HandleSWModule *>::iterator it = moduleHandles.begin(); it != moduleHandles.end(); ++it) {
+ delete it->second;
+ }
+ delete mgr;
+ }
+
+ HandleSWModule *getModuleHandle(SWModule *mod) {
+ if (!mod) return 0;
+ if (moduleHandles.find(mod) == moduleHandles.end()) {
+ moduleHandles[mod] = new HandleSWModule(mod);
+ }
+ return moduleHandles[mod];
+ }
+
+ static void clearGlobalOptions() {
+ clearStringArray(&globalOptions);
+ }
+
+ static void clearGlobalOptionValues() {
+ clearStringArray(&globalOptionValues);
+ }
+
+ static void clearAvailableLocales() {
+ clearStringArray(&availableLocales);
+ }
+};
+
+
+class HandleInstMgr {
+public:
+ static const char **remoteSources;
+ InstallMgr *installMgr;
+ org_crosswire_sword_ModInfo *modInfo;
+ std::map<SWModule *, HandleSWModule *> moduleHandles;
+
+ MyStatusReporter statusReporter;
+ HandleInstMgr() : installMgr(0), modInfo(0) {}
+ HandleInstMgr(InstallMgr *mgr) {
+ this->installMgr = installMgr;
+ this->modInfo = 0;
+ }
+
+ ~HandleInstMgr() {
+ clearModInfo();
+ for (std::map<SWModule *, HandleSWModule *>::iterator it = moduleHandles.begin(); it != moduleHandles.end(); ++it) {
+ delete it->second;
+ }
+ delete installMgr;
+ }
+
+ HandleSWModule *getModuleHandle(SWModule *mod) {
+ if (!mod) return 0;
+ if (moduleHandles.find(mod) == moduleHandles.end()) {
+ moduleHandles[mod] = new HandleSWModule(mod);
+ }
+ return moduleHandles[mod];
+ }
+
+ static void clearRemoteSources() {
+ clearStringArray(&remoteSources);
+ }
+
+ void clearModInfo() {
+ ::clearModInfo(&modInfo);
+ }
+};
+
+
+org_crosswire_sword_SearchHit *HandleSWModule::searchHits = 0;
+const char **HandleSWModule::entryAttributes = 0;
+const char **HandleSWModule::parseKeyList = 0;
+const char **HandleSWModule::keyChildren = 0;
+
+const char **HandleSWMgr::globalOptions = 0;
+const char **HandleSWMgr::globalOptionValues = 0;
+const char **HandleSWMgr::availableLocales = 0;
+
+const char **HandleInstMgr::remoteSources = 0;
+
+class InitStatics {
+public:
+ InitStatics() {
+// these are redundant with the static declarations above, but ??? doesn't hurt
+ HandleSWModule::searchHits = 0;
+ HandleSWModule::entryAttributes = 0;
+ HandleSWModule::parseKeyList = 0;
+ HandleSWModule::keyChildren = 0;
+
+ HandleSWMgr::globalOptions = 0;
+ HandleSWMgr::globalOptionValues = 0;
+ HandleSWMgr::availableLocales = 0;
+
+ HandleInstMgr::remoteSources = 0;
+ }
+ ~InitStatics() {
+ HandleSWModule::clearSearchHits();
+ HandleSWModule::clearEntryAttributes();
+ HandleSWModule::clearParseKeyList();
+ HandleSWModule::clearKeyChildren();
+
+ HandleSWMgr::clearGlobalOptions();
+ HandleSWMgr::clearGlobalOptionValues();
+
+ HandleInstMgr::clearRemoteSources();
+ }
+} _initStatics;
+
+
+
+}
+
+
+
+
+//
+// SWModule methods
+//
//
-extern "C" SWHANDLE SWMgr_new(char filterType) {
- return (SWHANDLE) new SWMgr(new MarkupFilterMgr(filterType));
+
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: terminateSearch
+ * Signature: ()V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWModule_terminateSearch
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, );
+
+ module->terminateSearch = true;
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: search
+ * Signature: (Ljava/lang/String;IJLjava/lang/String;Lorg/crosswire/android/sword/SWModule/SearchProgressReporter;)[Lorg/crosswire/android/sword/SWModule/SearchHit;
+ */
+const struct org_crosswire_sword_SearchHit * SWDLLEXPORT org_crosswire_sword_SWModule_search
+ (SWHANDLE hSWModule, const char *searchString, int searchType, long flags, const char *scope, SWHANDLE progressReporter) {
-// SWConfig *, SWConfig *, bool, SWFilterMgr *
-SWHANDLE SWMgr_newEx(SWHANDLE hiconfig, SWHANDLE hisysconfig, char autoload, SWHANDLE hfilterMgr) {
- SWConfig *iconfig = (SWConfig *)hiconfig;
- SWConfig *isysconfig = (SWConfig *)hisysconfig;
- SWFilterMgr *filterMgr = (SWFilterMgr *)hfilterMgr;
+ GETSWMODULE(hSWModule, 0);
+
+ hmod->clearSearchHits();
+
+ sword::ListKey lscope;
+ sword::ListKey result;
+
+
+ hmod->peeuuu.init(progressReporter);
+ if ((scope) && (strlen(scope)) > 0) {
+ sword::SWKey *p = module->createKey();
+ sword::VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
+ if (!parser) {
+ delete p;
+ parser = new VerseKey();
+ }
+ *parser = module->getKeyText();
+ lscope = parser->parseVerseList(scope, *parser, true);
+ result = module->search(searchString, searchType, flags, &lscope, 0, &percentUpdate, &(hmod->peeuuu));
+ delete parser;
+ }
+ else result = module->search(searchString, searchType, flags, 0, 0, &percentUpdate, &(hmod->peeuuu));
+
+ int count = 0;
+ for (result = sword::TOP; !result.popError(); result++) count++;
+
+ // if we're sorted by score, let's re-sort by verse, because Java can always re-sort by score
+ result = sword::TOP;
+ if ((count) && (long)result.getElement()->userData)
+ result.sort();
+
+ struct org_crosswire_sword_SearchHit *retVal = (struct org_crosswire_sword_SearchHit *)calloc(count+1, sizeof(struct org_crosswire_sword_SearchHit));
- return (SWHANDLE) new SWMgr(iconfig, isysconfig, autoload, filterMgr);
+ int i = 0;
+ for (result = sword::TOP; !result.popError(); result++) {
+ // don't alloc this; we have a persistent const char * in SWModule we can just reference
+ retVal[i].modName = module->getName();
+ stdstr(&(retVal[i].key), assureValidUTF8(result.getShortText()));
+ retVal[i++].score = (long)result.getElement()->userData;
+ // in case we limit count to a max number of hits
+ if (i >= count) break;
+ }
+ hmod->searchHits = retVal;
+ return retVal;
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: error
+ * Signature: ()C
+ */
+char SWDLLEXPORT org_crosswire_sword_SWModule_popError
+ (SWHANDLE hSWModule) {
-void SWMgr_delete(SWHANDLE hmgr) {
- SWMgr *mgr = (SWMgr *)hmgr;
- if (mgr)
- delete mgr;
+ GETSWMODULE(hSWModule, -1);
+
+ return module->popError();
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getEntrySize
+ * Signature: ()J
+ */
+long SWDLLEXPORT org_crosswire_sword_SWModule_getEntrySize
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
-SWHANDLE SWMgr_getConfig(SWHANDLE hmgr) {
- SWMgr *mgr = (SWMgr *)hmgr;
- return (mgr) ? (SWHANDLE)mgr->config : 0;
+ return module->getEntrySize();
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getEntryAttribute
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)[Ljava/lang/String;
+ */
+const char ** SWDLLEXPORT org_crosswire_sword_SWModule_getEntryAttribute
+ (SWHANDLE hSWModule, const char *level1, const char *level2, const char *level3, char filteredBool) {
+
+ GETSWMODULE(hSWModule, 0);
-SWHANDLE SWMgr_getModulesIterator(SWHANDLE hmgr) {
- static ModItType it;
+ hmod->clearEntryAttributes();
- SWMgr *mgr = (SWMgr *)hmgr;
- if (mgr) {
- it.it = mgr->Modules.begin();
- it.end = mgr->Modules.end();
+ module->renderText(); // force parse
+ std::vector<SWBuf> results;
+
+ sword::AttributeTypeList &entryAttribs = module->getEntryAttributes();
+ sword::AttributeTypeList::iterator i1Start, i1End;
+ sword::AttributeList::iterator i2Start, i2End;
+ sword::AttributeValue::iterator i3Start, i3End;
+
+ if ((level1) && (*level1)) {
+ i1Start = entryAttribs.find(level1);
+ i1End = i1Start;
+ if (i1End != entryAttribs.end())
+ ++i1End;
+ }
+ else {
+ i1Start = entryAttribs.begin();
+ i1End = entryAttribs.end();
}
- return (SWHANDLE)&it;
+ for (;i1Start != i1End; ++i1Start) {
+ if ((level2) && (*level2)) {
+ i2Start = i1Start->second.find(level2);
+ i2End = i2Start;
+ if (i2End != i1Start->second.end())
+ ++i2End;
+ }
+ else {
+ i2Start = i1Start->second.begin();
+ i2End = i1Start->second.end();
+ }
+ for (;i2Start != i2End; ++i2Start) {
+ if ((level3) && (*level3)) {
+ i3Start = i2Start->second.find(level3);
+ i3End = i3Start;
+ if (i3End != i2Start->second.end())
+ ++i3End;
+ }
+ else {
+ i3Start = i2Start->second.begin();
+ i3End = i2Start->second.end();
+ }
+ for (;i3Start != i3End; ++i3Start) {
+ results.push_back(i3Start->second);
+ }
+ if (i3Start != i3End)
+ break;
+ }
+ if (i2Start != i2End)
+ break;
+ }
+
+ const char **retVal = (const char **)calloc(results.size()+1, sizeof(const char *));
+ for (int i = 0; i < (int)results.size(); i++) {
+ if (filteredBool) {
+ stdstr((char **)&(retVal[i]), assureValidUTF8(module->renderText(results[i].c_str())));
+ }
+ else {
+ stdstr((char **)&(retVal[i]), assureValidUTF8(results[i].c_str()));
+ }
+ }
+
+ hmod->entryAttributes = retVal;
+ return retVal;
+}
+
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: parseKeyList
+ * Signature: (Ljava/lang/String;)[Ljava/lang/String;
+ */
+const char ** SWDLLEXPORT org_crosswire_sword_SWModule_parseKeyList
+ (SWHANDLE hSWModule, const char *keyText) {
+
+ GETSWMODULE(hSWModule, 0);
+
+ hmod->clearParseKeyList();
+
+ sword::VerseKey *parser = dynamic_cast<VerseKey *>(module->getKey());
+ const char **retVal = 0;
+ if (parser) {
+ sword::ListKey result;
+ result = parser->parseVerseList(keyText, *parser, true);
+ int count = 0;
+ for (result = sword::TOP; !result.popError(); result++) {
+ count++;
+ }
+ retVal = (const char **)calloc(count+1, sizeof(const char *));
+ count = 0;
+ for (result = sword::TOP; !result.popError(); result++) {
+ stdstr((char **)&(retVal[count++]), assureValidUTF8(VerseKey(result).getOSISRef()));
+ }
+ }
+ else {
+ retVal = (const char **)calloc(2, sizeof(const char *));
+ stdstr((char **)&(retVal[0]), assureValidUTF8(keyText));
+ }
+
+ hmod->parseKeyList = retVal;
+ return retVal;
+}
+
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: setKeyText
+ * Signature: (Ljava/lang/String;)V
+ */
+// Special values handled for VerseKey modules:
+// [+-][book|chapter] - [de|in]crement by chapter or book
+// (e.g. "+chapter" will increment the VerseKey 1 chapter)
+// [=][key] - position absolutely and don't normalize
+// (e.g. "jn.1.0" for John Chapter 1 intro; "jn.0.0" For Book of John Intro)
+void SWDLLEXPORT org_crosswire_sword_SWModule_setKeyText
+ (SWHANDLE hSWModule, const char *keyText) {
+
+ GETSWMODULE(hSWModule, );
+
+ sword::SWKey *key = module->getKey();
+ sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
+ if (vkey) {
+ if ((*keyText=='+' || *keyText=='-')) {
+ if (!sword::stricmp(keyText+1, "book")) {
+ vkey->setBook(vkey->getBook() + ((*keyText=='+')?1:-1));
+ return;
+ }
+ else if (!sword::stricmp(keyText+1, "chapter")) {
+ vkey->setChapter(vkey->getChapter() + ((*keyText=='+')?1:-1));
+ return;
+ }
+ }
+ else if (*keyText=='=') {
+ vkey->setIntros(true);
+ vkey->setAutoNormalize(false);
+ vkey->setText(keyText+1);
+ return;
+ }
+ }
+
+ module->setKey(keyText);
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getKeyText
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_getKeyText
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
-SWHANDLE SWMgr_getModuleByName(SWHANDLE hmgr, const char *name) {
- SWMgr *mgr = (SWMgr *)hmgr;
- return (mgr) ? (SWHANDLE) mgr->Modules[name] : 0;
+ return module->getKeyText();
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: hasKeyChildren
+ * Signature: ()Z
+ */
+char SWDLLEXPORT org_crosswire_sword_SWModule_hasKeyChildren
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
+
+ sword::SWKey *key = module->getKey();
+ char retVal = 0;
-const char *SWMgr_getPrefixPath(SWHANDLE hmgr) {
- SWMgr *mgr = (SWMgr *)hmgr;
- return (mgr) ? mgr->prefixPath : 0;
+ TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+ if (tkey) {
+ retVal = tkey->hasChildren()?1:0;
+ }
+ return retVal;
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getKeyChildren
+ * Signature: ()[Ljava/lang/String;
+ */
+
+// This method returns child nodes for a genbook,
+// but has special handling if called on a VerseKey module:
+// [0..7] [testament, book, chapter, verse, chapterMax, verseMax, bookName, osisRef]
+const char ** SWDLLEXPORT org_crosswire_sword_SWModule_getKeyChildren
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
+
+ hmod->clearKeyChildren();
+
+ sword::SWKey *key = module->getKey();
+ const char **retVal = 0;
+ int count = 0;
+
+ sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
+ if (vkey) {
+ retVal = (const char **)calloc(9, sizeof(const char *));
+ SWBuf num;
+ num.appendFormatted("%d", vkey->getTestament());
+ stdstr((char **)&(retVal[0]), num.c_str());
+ num = "";
+ num.appendFormatted("%d", vkey->getBook());
+ stdstr((char **)&(retVal[1]), num.c_str());
+ num = "";
+ num.appendFormatted("%d", vkey->getChapter());
+ stdstr((char **)&(retVal[2]), num.c_str());
+ num = "";
+ num.appendFormatted("%d", vkey->getVerse());
+ stdstr((char **)&(retVal[3]), num.c_str());
+ num = "";
+ num.appendFormatted("%d", vkey->getChapterMax());
+ stdstr((char **)&(retVal[4]), num.c_str());
+ num = "";
+ num.appendFormatted("%d", vkey->getVerseMax());
+ stdstr((char **)&(retVal[5]), num.c_str());
+ stdstr((char **)&(retVal[6]), vkey->getBookName());
+ stdstr((char **)&(retVal[7]), vkey->getOSISRef());
+ }
+ else {
+ TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+ if (tkey) {
+ if (tkey->firstChild()) {
+ do {
+ count++;
+ }
+ while (tkey->nextSibling());
+ tkey->parent();
+ }
+ retVal = (const char **)calloc(count+1, sizeof(const char *));
+ count = 0;
+ if (tkey->firstChild()) {
+ do {
+ stdstr((char **)&(retVal[count++]), assureValidUTF8(tkey->getLocalName()));
+ }
+ while (tkey->nextSibling());
+ tkey->parent();
+ }
+ }
+ }
-const char *SWMgr_getConfigPath(SWHANDLE hmgr) {
- SWMgr *mgr = (SWMgr *)hmgr;
- return (mgr) ? mgr->configPath : 0;
+ hmod->keyChildren = retVal;
+ return retVal;
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getName
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_getName
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
-void SWMgr_setGlobalOption(SWHANDLE hmgr, const char *option, const char *value) {
- SWMgr *mgr = (SWMgr *)hmgr;
- if (mgr)
- mgr->setGlobalOption(option, value);
+ return module->getName();
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getDescription
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_getDescription
+ (SWHANDLE hSWModule) {
-const char *SWMgr_getGlobalOption(SWHANDLE hmgr, const char *option) {
- SWMgr *mgr = (SWMgr *)hmgr;
- return (mgr) ? (const char *)mgr->getGlobalOption(option) : 0;
+ GETSWMODULE(hSWModule, 0);
+
+ return module->getDescription();
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getCategory
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_getCategory
+ (SWHANDLE hSWModule) {
+
+ static SWBuf type;
+
+ GETSWMODULE(hSWModule, 0);
-const char *SWMgr_getGlobalOptionTip(SWHANDLE hmgr, const char *option) {
- SWMgr *mgr = (SWMgr *)hmgr;
- return (mgr) ? (const char *)mgr->getGlobalOptionTip(option) : 0;
+ type = module->getType();
+ SWBuf cat = module->getConfigEntry("Category");
+ if (cat.length() > 0)
+ type = cat;
+
+ return type.c_str();
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getKeyParent
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_getKeyParent
+ (SWHANDLE hSWModule) {
+
+ static SWBuf retVal;
+
+ GETSWMODULE(hSWModule, 0);
+
+ sword::SWKey *key = module->getKey();
-// ret: forward_iterator
-SWHANDLE SWMgr_getGlobalOptionsIterator(SWHANDLE hmgr) {
- SWMgr *mgr = (SWMgr *)hmgr;
- static StringList::iterator it;
- static StringList optionslist;
- if (mgr) {
- optionslist = mgr->getGlobalOptions();
- it = optionslist.begin();
+ retVal = "";
+
+ TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+ if (tkey) {
+ if (tkey->parent()) {
+ retVal = tkey->getText();
+ }
}
- return (SWHANDLE)&it;
+ return assureValidUTF8(retVal.c_str());
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: previous
+ * Signature: ()V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWModule_previous
+ (SWHANDLE hSWModule) {
-// ret: forward_iterator
-SWHANDLE SWMgr_getGlobalOptionValuesIterator(SWHANDLE hmgr, const char *option) {
- SWMgr *mgr = (SWMgr *)hmgr;
- static StringList::iterator it;
-
- if (mgr)
- it = mgr->getGlobalOptionValues(option).begin();
- return (SWHANDLE)&it;
+ GETSWMODULE(hSWModule, );
+
+ module->decrement();
}
-void SWMgr_setCipherKey(SWHANDLE hmgr, const char *modName, const char *key) {
- SWMgr *mgr = (SWMgr *)hmgr;
- if (mgr)
- mgr->setCipherKey(modName, key);
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: next
+ * Signature: ()V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWModule_next
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, );
+
+ module->increment();
}
-//-----------------------------------------------------------------
-// SWModule methods
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: begin
+ * Signature: ()V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWModule_begin
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, );
-// static void nullPercent (char percent, void *userData);
-void SWModule_terminateSearch(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- if (module)
- module->terminateSearch = true;
+ module->setPosition(sword::TOP);
}
-// SWModule (const const char *imodname = 0, const const char *imoddesc = 0, SWDisplay * idisp = 0, const char *imodtype = 0, SWTextEncoding encoding = ENC_UNKNOWN, SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN, const char* modlang = 0);
-// virtual ~ SWModule ();
-SWHANDLE SWModule_doSearch(SWHANDLE hmodule, const char *searchString, int type, int params ,void (*percent) (char, void *), void *percentUserData) {
-
- static ListKey results;
- SWKey * scope = 0;
- SWModule *module = (SWModule *)hmodule;
- if (!module)
- return -1;
-
- results.clear();
- results = module->search(searchString, type, params, scope, 0, percent, (void *) &percentUserData);
-
- return (SWHANDLE)&results;
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getStripText
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_stripText
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
+
+ stdstr(&(hmod->stripBuf), assureValidUTF8((const char *)module->stripText()));
+
+ return hmod->stripBuf;
+}
+
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getRenderText
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_renderText
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
+
+ stdstr(&(hmod->renderBuf), assureValidUTF8((const char *)module->renderText().c_str()));
+
+ return hmod->renderBuf;
+}
+
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getRenderHeader
+ * Signature: ()Ljava/lang/String;
+ */
+// CSS styles associated with this text
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_getRenderHeader
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
+
+ stdstr(&(hmod->renderHeader), assureValidUTF8(((const char *)(module->getRenderHeader() ? module->getRenderHeader():""))));
+
+ return hmod->renderHeader;
}
- /** Gets and clears error status
- *
- * @return error status
- */
-char SWModule_error(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- return (module) ? module->popError() : 0;
+
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getRawEntry
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_getRawEntry
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
+
+ stdstr(&(hmod->rawEntry), assureValidUTF8(((const char *)module->getRawEntry())));
+
+ return hmod->rawEntry;
}
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: setRawEntry
+ * Signature: (Ljava/lang/String;)V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWModule_setRawEntry
+ (SWHANDLE hSWModule, const char *entryBuffer) {
+
+ GETSWMODULE(hSWModule, );
-int SWModule_getEntrySize(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- return (module) ? module->getEntrySize() : 0;
+ module->setEntry(entryBuffer);
}
-void SWModule_setKeyText(SWHANDLE hmodule, const char *key) {
- SWModule *module = (SWModule *)hmodule;
- if (module)
- module->setKey(key);
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: getConfigEntry
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWModule_getConfigEntry
+ (SWHANDLE hSWModule, const char *key) {
+
+ GETSWMODULE(hSWModule, 0);
+
+ stdstr(&(hmod->configEntry), (module->getConfigEntry(key) ? assureValidUTF8(module->getConfigEntry(key)).c_str() : 0));
+
+ return hmod->configEntry;
}
-// virtual char setKey (const SWKey &ikey);
-// virtual SWKey & Key () const {
-
-const char *SWModule_getKeyText(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- return (const char *)((module) ? module->getKeyText() : 0);
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: deleteSearchFramework
+ * Signature: ()V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWModule_deleteSearchFramework
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, );
+
+ module->deleteSearchFramework();
}
-
-// virtual char Display ();
-// virtual SWDisplay *Disp (SWDisplay * idisp = 0);
-
-const char *SWModule_getName(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- return (const char *)((module) ? module->getName() : 0);
+
+/*
+ * Class: org_crosswire_sword_SWModule
+ * Method: hasSearchFramework
+ * Signature: ()Z
+ */
+char SWDLLEXPORT org_crosswire_sword_SWModule_hasSearchFramework
+ (SWHANDLE hSWModule) {
+
+ GETSWMODULE(hSWModule, 0);
+
+ return (module->hasSearchFramework() && module->isSearchOptimallySupported("God", -4, 0, 0));
}
-
-const char *SWModule_getDescription(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- return (const char *)((module) ? module->getDescription() : 0);
+
+
+
+//
+// SWMgr methods
+//
+//
+
+
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: new
+ * Signature: ()V
+ */
+SWHANDLE SWDLLEXPORT org_crosswire_sword_SWMgr_new() {
+ SWConfig *sysConf = 0;
+ return (SWHANDLE) new HandleSWMgr(new WebMgr(sysConf));
}
-const char *SWModule_getType(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- return (const char *)((module) ? module->getType() : 0);
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: delete
+ * Signature: ()V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWMgr_delete(SWHANDLE hSWMgr) {
+ HandleSWMgr *hmgr = (HandleSWMgr *)hSWMgr;
+ if (hmgr) delete hmgr;
}
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: version
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWMgr_version
+ (SWHANDLE hSWMgr) {
+ // we don't actually need an SWMgr to get version
+ static SWVersion v;
+ return v.currentVersion;
+}
+
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: getModInfoList
+ * Signature: ()[Lorg/crosswire/android/sword/SWMgr/ModInfo;
+ */
+const struct org_crosswire_sword_ModInfo * SWDLLEXPORT org_crosswire_sword_SWMgr_getModInfoList
+ (SWHANDLE hSWMgr) {
+
+ GETSWMGR(hSWMgr, 0);
+
+ sword::SWModule *module = 0;
+
+ hmgr->clearModInfo();
+
+ int size = 0;
+ for (sword::ModMap::iterator it = mgr->Modules.begin(); it != mgr->Modules.end(); ++it) {
+ if ((!(it->second->getConfigEntry("CipherKey"))) || (*(it->second->getConfigEntry("CipherKey"))))
+ size++;
+ }
-void SWModule_previous(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- if (module)
- (*module)--;
+ struct org_crosswire_sword_ModInfo *milist = (struct org_crosswire_sword_ModInfo *)calloc(size+1, sizeof(struct org_crosswire_sword_ModInfo));
+ int i = 0;
+ for (sword::ModMap::iterator it = mgr->Modules.begin(); it != mgr->Modules.end(); ++it) {
+ module = it->second;
+ if ((!(module->getConfigEntry("CipherKey"))) || (*(module->getConfigEntry("CipherKey")))) {
+ SWBuf type = module->getType();
+ SWBuf cat = module->getConfigEntry("Category");
+ SWBuf version = module->getConfigEntry("Version");
+ if (cat.length() > 0) type = cat;
+ stdstr(&(milist[i].name), assureValidUTF8(module->getName()));
+ stdstr(&(milist[i].description), assureValidUTF8(module->getDescription()));
+ stdstr(&(milist[i].category), assureValidUTF8(type.c_str()));
+ stdstr(&(milist[i++].language), assureValidUTF8(module->getLanguage()));
+ stdstr(&(milist[i++].version), assureValidUTF8(version.c_str()));
+ stdstr(&(milist[i++].delta), "");
+ if (i >= size) break;
+ }
+ }
+ hmgr->modInfo = milist;
+ return milist;
}
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: getModuleByName
+ * Signature: (Ljava/lang/String;)Lorg/crosswire/android/sword/SWModule;
+ */
+SWHANDLE SWDLLEXPORT org_crosswire_sword_SWMgr_getModuleByName
+ (SWHANDLE hSWMgr, const char *moduleName) {
+
+ GETSWMGR(hSWMgr, 0);
-void SWModule_next(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- if (module)
- (*module)++;
+ return (SWHANDLE)hmgr->getModuleHandle(hmgr->mgr->getModule(moduleName));
}
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: getPrefixPath
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWMgr_getPrefixPath
+ (SWHANDLE hSWMgr) {
+
+ GETSWMGR(hSWMgr, 0);
-void SWModule_begin(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- if (module)
- (*module) = TOP;
+ return mgr->prefixPath;
}
-
-
-const char *SWModule_getStripText(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- return (const char *)((module) ? module->stripText() : 0);
+
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: getConfigPath
+ * Signature: ()Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWMgr_getConfigPath
+ (SWHANDLE hSWMgr) {
+
+ GETSWMGR(hSWMgr, 0);
+
+ return mgr->configPath;
}
-
-
-const char *SWModule_getRenderText(SWHANDLE hmodule) {
- SWModule *module = (SWModule *)hmodule;
- return (const char *)((module) ? module->renderText().c_str() : 0);
+
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: setGlobalOption
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWMgr_setGlobalOption
+ (SWHANDLE hSWMgr, const char *option, const char *value) {
+
+ GETSWMGR(hSWMgr, );
+ mgr->setGlobalOption(option, value);
}
-const char *SWModule_getEntryAttributes(SWHANDLE hmodule, const char *level1, const char *level2, const char *level3) {
- SWModule *module = (SWModule *)hmodule;
- static SWBuf retval;
- module->renderText();
- retval = module->getEntryAttributes()[level1][level2][level3].c_str();
- return (retval.length()) ? (const char*)retval.c_str() : NULL;
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: getGlobalOption
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWMgr_getGlobalOption
+ (SWHANDLE hSWMgr, const char *option) {
+
+ GETSWMGR(hSWMgr, 0);
+
+ return mgr->getGlobalOption(option);
}
-const char *SWModule_getPreverseHeader(SWHANDLE hmodule, const char *key, int pvHeading) {
- SWModule *module = (SWModule *)hmodule;
- static SWBuf preverseHeading;
- char buf[12];
- sprintf(buf, "%i", pvHeading);
- module->setKey(key);
- module->renderText();
- preverseHeading = module->getEntryAttributes()["Heading"]["Preverse"][buf].c_str();
- return (preverseHeading.length()) ? (const char*)preverseHeading.c_str() : NULL;
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: getGlobalOptionTip
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWMgr_getGlobalOptionTip
+ (SWHANDLE hSWMgr, const char *option) {
+
+ GETSWMGR(hSWMgr, 0);
+
+ return mgr->getGlobalOptionTip(option);
}
-const char *SWModule_getFootnoteType(SWHANDLE hmodule, const char *key, const char *note) {
- SWModule *module = (SWModule *)hmodule;
- static SWBuf type;
- module->popError();
- module->setKey(key);
- module->renderText();
- type = module->getEntryAttributes()["Footnote"][note]["type"].c_str();
- return (type) ? (const char*)type.c_str() : NULL;
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: filterText
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWMgr_filterText
+ (SWHANDLE hSWMgr, const char *filterName, const char *text) {
+
+ GETSWMGR(hSWMgr, 0);
+
+ hmgr->filterBuf = text;
+
+// why was this in bindings/corba/omniorb?
+// mgr->setGlobalOption("Greek Accents", "Off");
+
+ char errStatus = mgr->filterText(filterName, hmgr->filterBuf);
+ (void)errStatus;
+ return hmgr->filterBuf.c_str();
}
-const char *SWModule_getFootnoteBody(SWHANDLE hmodule, const char *key, const char *note) {
- SWModule *module = (SWModule *)hmodule;
- static SWBuf body;
- module->popError();
- module->setKey(key);
- module->renderText();
- body = module->getEntryAttributes()["Footnote"][note]["body"].c_str();
- SWKey *keybuf = module->getKey();;
- module->renderFilter(body, keybuf);
- return (body) ? (const char*)body.c_str() : NULL;
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: getGlobalOptions
+ * Signature: ()[Ljava/lang/String;
+ */
+const char ** SWDLLEXPORT org_crosswire_sword_SWMgr_getGlobalOptions
+ (SWHANDLE hSWMgr) {
+
+ GETSWMGR(hSWMgr, 0);
+
+ const char **retVal;
+ hmgr->clearGlobalOptions();
+
+ sword::StringList options = mgr->getGlobalOptions();
+ int count = 0;
+ for (sword::StringList::iterator it = options.begin(); it != options.end(); ++it) {
+ count++;
+ }
+ retVal = (const char **)calloc(count+1, sizeof(const char *));
+ count = 0;
+ for (sword::StringList::iterator it = options.begin(); it != options.end(); ++it) {
+ stdstr((char **)&(retVal[count++]), it->c_str());
+ }
+
+ hmgr->globalOptions = retVal;
+ return retVal;
}
-const char *SWModule_getFootnoteRefList(SWHANDLE hmodule, const char *key, const char *note) {
- SWModule *module = (SWModule *)hmodule;
- static SWBuf refList;
- module->popError();
- module->setKey(key);
- module->renderText();
- refList = module->getEntryAttributes()["Footnote"][note]["refList"].c_str();
- return (refList) ? (const char*)refList.c_str() : NULL;
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: getGlobalOptionValues
+ * Signature: (Ljava/lang/String;)[Ljava/lang/String;
+ */
+const char ** SWDLLEXPORT org_crosswire_sword_SWMgr_getGlobalOptionValues
+ (SWHANDLE hSWMgr, const char *option) {
+
+ GETSWMGR(hSWMgr, 0);
+
+ const char **retVal = 0;
+ hmgr->clearGlobalOptionValues();
+
+ sword::StringList options = mgr->getGlobalOptionValues(option);
+ int count = 0;
+ for (sword::StringList::iterator it = options.begin(); it != options.end(); ++it) {
+ count++;
+ }
+ retVal = (const char **)calloc(count+1, sizeof(const char *));
+ count = 0;
+ for (sword::StringList::iterator it = options.begin(); it != options.end(); ++it) {
+ stdstr((char **)&(retVal[count++]), it->c_str());
+ }
+
+ hmgr->globalOptionValues = retVal;
+ return retVal;
}
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: setCipherKey
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWMgr_setCipherKey
+ (SWHANDLE hSWMgr, const char *modName, const char *key) {
+ GETSWMGR(hSWMgr, );
-SWHANDLE listkey_getVerselistIterator(const char *list, const char *key, const char *v11n) {
- VerseKey versekey;
- versekey.setVersificationSystem(v11n);
- static ListKey verses;
-
- versekey.setText(key);
- verses.clear();
- verses = versekey.parseVerseList(list, versekey);
- return (SWHANDLE)&verses;
+ mgr->setCipherKey(modName, key);
}
-//-----------------------------------------------------------------
-// stringlist_iterator methods
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: setJavascript
+ * Signature: (Z)V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWMgr_setJavascript
+ (SWHANDLE hSWMgr, char valueBool) {
-void stringlist_iterator_next(SWHANDLE hsli) {
- StringList::iterator *sli = (StringList::iterator *)hsli;
- (*sli)++;
+ GETSWMGR(hSWMgr, );
+
+ mgr->setJavascript(valueBool);
+}
+
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: getAvailableLocales
+ * Signature: ()[Ljava/lang/String;
+ */
+const char ** SWDLLEXPORT org_crosswire_sword_SWMgr_getAvailableLocales
+ (SWHANDLE hSWMgr) {
+
+ GETSWMGR(hSWMgr, 0);
+
+ hmgr->clearAvailableLocales();
+ sword::StringList localeNames = LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ const char **retVal = 0;
+ int count = 0;
+ for (sword::StringList::iterator it = localeNames.begin(); it != localeNames.end(); ++it) {
+ count++;
+ }
+ retVal = (const char **)calloc(count+1, sizeof(const char *));
+ count = 0;
+ for (sword::StringList::iterator it = localeNames.begin(); it != localeNames.end(); ++it) {
+ stdstr((char **)&(retVal[count++]), it->c_str());
+ }
+
+ hmgr->availableLocales = retVal;
+ return retVal;
+}
+
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: setDefaultLocale
+ * Signature: (Ljava/lang/String;)V
+ */
+void SWDLLEXPORT org_crosswire_sword_SWMgr_setDefaultLocale
+ (SWHANDLE hSWMgr, const char *name) {
+
+ // we don't actually need an SWMgr instance for this
+ GETSWMGR(hSWMgr, );
+
+ LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(name);
+}
+
+/*
+ * Class: org_crosswire_sword_SWMgr
+ * Method: translate
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
+ */
+const char * SWDLLEXPORT org_crosswire_sword_SWMgr_translate
+ (SWHANDLE hSWMgr, const char *text, const char *localeName) {
+
+ GETSWMGR(hSWMgr, 0);
+
+ return LocaleMgr::getSystemLocaleMgr()->translate(text, localeName);
+}
+
+
+
+
+//
+// InstallMgr methods
+//
+//
+
+
+/*
+ * Class: org_crosswire_sword_InstallMgr
+ * Method: new
+ * Signature: (Ljava/lang/String;Lorg/crosswire/android/sword/SWModule/SearchProgressReporter;)V
+ */
+SWHANDLE SWDLLEXPORT org_crosswire_sword_InstallMgr_new
+ (const char *baseDir, SWHANDLE statusReporter) {
+ SWBuf confPath = SWBuf(baseDir) + "/InstallMgr.conf";
+ // be sure we have at least some config file already out there
+ if (!FileMgr::existsFile(confPath.c_str())) {
+ FileMgr::createParent(confPath.c_str());
+// remove(confPath.c_str());
+
+ SWConfig config(confPath.c_str());
+ config["General"]["PassiveFTP"] = "true";
+ config.Save();
+ }
+ HandleInstMgr *hinstmgr = new HandleInstMgr();
+ hinstmgr->statusReporter.init(statusReporter);
+ hinstmgr->installMgr = new InstallMgr(baseDir, &(hinstmgr->statusReporter));
+ return (SWHANDLE) hinstmgr;
+}
+
+/*
+ * Class: org_crosswire_sword_InstallMgr
+ * Method: setUserDisclaimerConfirmed
+ * Signature: ()V
+ */
+void SWDLLEXPORT org_crosswire_sword_InstallMgr_setUserDisclaimerConfirmed
+ (SWHANDLE hInstallMgr) {
+
+ GETINSTMGR(hInstallMgr, );
+
+ installMgr->setUserDisclaimerConfirmed(true);
+}
+
+/*
+ * Class: org_crosswire_sword_InstallMgr
+ * Method: syncConfig
+ * Signature: ()I
+ */
+int SWDLLEXPORT org_crosswire_sword_InstallMgr_syncConfig
+ (SWHANDLE hInstallMgr) {
+
+ GETINSTMGR(hInstallMgr, -1);
+
+ return installMgr->refreshRemoteSourceConfiguration();
}
+/*
+ * Class: org_crosswire_sword_InstallMgr
+ * Method: uninstallModule
+ * Signature: (Lorg/crosswire/android/sword/SWMgr;Ljava/lang/String;)I
+ */
+int SWDLLEXPORT org_crosswire_sword_InstallMgr_uninstallModule
+ (SWHANDLE hInstallMgr, SWHANDLE hSWMgr_removeFrom, const char *modName) {
+
+ GETINSTMGR(hInstallMgr, -1);
+ GETSWMGR(hSWMgr_removeFrom, -1);
-const char *stringlist_iterator_val(SWHANDLE hsli) {
- StringList::iterator *sli = (StringList::iterator *)hsli;
- return (const char *)(*sli)->c_str();
+ SWModule *module;
+ ModMap::iterator it = mgr->Modules.find(modName);
+ if (it == mgr->Modules.end()) {
+ return -2;
+ }
+ module = it->second;
+ return installMgr->removeModule(mgr, module->getName());
}
+/*
+ * Class: org_crosswire_sword_InstallMgr
+ * Method: getRemoteSources
+ * Signature: ()[Ljava/lang/String;
+ */
+const char ** SWDLLEXPORT org_crosswire_sword_InstallMgr_getRemoteSources
+ (SWHANDLE hInstallMgr) {
+ GETINSTMGR(hInstallMgr, 0);
-//-----------------------------------------------------------------
-// listkey_iterator methods
+ hinstmgr->clearRemoteSources();
+ sword::StringList vals = LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ const char **retVal = 0;
+ int count = 0;
+ for (InstallSourceMap::iterator it = installMgr->sources.begin(); it != installMgr->sources.end(); ++it) {
+ count++;
+ }
+ retVal = (const char **)calloc(count+1, sizeof(const char *));
+ count = 0;
+ for (InstallSourceMap::iterator it = installMgr->sources.begin(); it != installMgr->sources.end(); ++it) {
+ stdstr((char **)&(retVal[count++]), it->second->caption.c_str());
+ }
-void listkey_iterator_next(SWHANDLE lki) {
- ListKey *lk = (ListKey*)lki;
- (*lk)++;
+ hinstmgr->remoteSources = retVal;
+ return retVal;
}
+/*
+ * Class: org_crosswire_sword_InstallMgr
+ * Method: refreshRemoteSource
+ * Signature: (Ljava/lang/String;)I
+ */
+int SWDLLEXPORT org_crosswire_sword_InstallMgr_refreshRemoteSource
+ (SWHANDLE hInstallMgr, const char *sourceName) {
+
+ GETINSTMGR(hInstallMgr, -1);
-const char *listkey_iterator_val(SWHANDLE lki) {
- ListKey *lk = (ListKey*)lki;
- if(!lk->popError())
- return (const char *) lk->getText();
- return NULL;
+ InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
+ if (source == installMgr->sources.end()) {
+ return -3;
+ }
+
+ return installMgr->refreshRemoteSource(source->second);
}
+/*
+ * Class: org_crosswire_sword_InstallMgr
+ * Method: getRemoteModInfoList
+ * Signature: (Lorg/crosswire/android/sword/SWMgr;Ljava/lang/String;)[Lorg/crosswire/android/sword/SWMgr/ModInfo;
+ */
+const struct org_crosswire_sword_ModInfo * SWDLLEXPORT org_crosswire_sword_InstallMgr_getRemoteModInfoList
+ (SWHANDLE hInstallMgr, SWHANDLE hSWMgr_deltaCompareTo, const char *sourceName) {
+ GETINSTMGR(hInstallMgr, 0);
+ GETSWMGR(hSWMgr_deltaCompareTo, 0);
-//-----------------------------------------------------------------
-// modmap methods
+ struct org_crosswire_sword_ModInfo *retVal = 0;
-void ModList_iterator_next(SWHANDLE hmmi) {
- ModItType *it = (ModItType *)hmmi;
- if (it->it != it->end)
- it->it++;
+ hinstmgr->clearModInfo();
+
+ InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
+ if (source == installMgr->sources.end()) {
+ retVal = (struct org_crosswire_sword_ModInfo *)calloc(1, sizeof(struct org_crosswire_sword_ModInfo));
+ hinstmgr->modInfo = retVal;
+ return retVal;
+ }
+
+ std::map<SWModule *, int> modStats = installMgr->getModuleStatus(*mgr, *source->second->getMgr());
+
+ int size = 0;
+ for (std::map<SWModule *, int>::iterator it = modStats.begin(); it != modStats.end(); ++it) {
+ size++;
+ }
+ retVal = (struct org_crosswire_sword_ModInfo *)calloc(size+1, sizeof(struct org_crosswire_sword_ModInfo));
+ int i = 0;
+ for (std::map<SWModule *, int>::iterator it = modStats.begin(); it != modStats.end(); ++it) {
+ SWModule *module = it->first;
+ int status = it->second;
+
+ SWBuf version = module->getConfigEntry("Version");
+ SWBuf statusString = " ";
+ if (status & InstallMgr::MODSTAT_NEW) statusString = "*";
+ if (status & InstallMgr::MODSTAT_OLDER) statusString = "-";
+ if (status & InstallMgr::MODSTAT_UPDATED) statusString = "+";
+
+ SWBuf type = module->getType();
+ SWBuf cat = module->getConfigEntry("Category");
+ if (cat.length() > 0) type = cat;
+
+ stdstr(&(retVal[i].name), assureValidUTF8(module->getName()));
+ stdstr(&(retVal[i].description), assureValidUTF8(module->getDescription()));
+ stdstr(&(retVal[i].category), assureValidUTF8(type.c_str()));
+ stdstr(&(retVal[i].language), assureValidUTF8(module->getLanguage()));
+ stdstr(&(retVal[i].version), assureValidUTF8(version.c_str()));
+ stdstr(&(retVal[i++].delta), assureValidUTF8(statusString.c_str()));
+ if (i >= size) break;
+ }
+ hinstmgr->modInfo = retVal;
+ return retVal;
}
+/*
+ * Class: org_crosswire_sword_InstallMgr
+ * Method: remoteInstallModule
+ * Signature: (Lorg/crosswire/android/sword/SWMgr;Ljava/lang/String;Ljava/lang/String;)I
+ */
+int SWDLLEXPORT org_crosswire_sword_InstallMgr_remoteInstallModule
+ (SWHANDLE hInstallMgr_from, SWHANDLE hSWMgr_to, const char *sourceName, const char *modName) {
+
+ GETINSTMGR(hInstallMgr_from, -1);
+ GETSWMGR(hSWMgr_to, -1);
+
+ InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
+
+ if (source == installMgr->sources.end()) {
+ return -3;
+ }
+
+ InstallSource *is = source->second;
+ SWMgr *rmgr = is->getMgr();
+ SWModule *module;
+
+ ModMap::iterator it = rmgr->Modules.find(modName);
+
+ if (it == rmgr->Modules.end()) {
+ return -4;
+ }
+
+ module = it->second;
+
+ int error = installMgr->installModule(mgr, 0, module->getName(), is);
+
+ return error;
+}
+
+/*
+ * Class: org_crosswire_sword_InstallMgr
+ * Method: getRemoteModuleByName
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)Lorg/crosswire/android/sword/SWModule;
+ */
+SWHANDLE SWDLLEXPORT org_crosswire_sword_InstallMgr_getRemoteModuleByName
+ (SWHANDLE hInstallMgr, const char *sourceName, const char *modName) {
+
+ GETINSTMGR(hInstallMgr, 0);
+
+ InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
+
+ if (source == installMgr->sources.end()) {
+ return 0;
+ }
+
+ SWMgr *mgr = source->second->getMgr();
+
+ sword::SWModule *module = mgr->getModule(modName);
+
+ if (!module) {
+ return 0;
+ }
+
+ return (SWHANDLE)hinstmgr->getModuleHandle(module);
-SWHANDLE ModList_iterator_val(SWHANDLE hmmi) {
- ModItType *it = (ModItType *)hmmi;
- return (it->it != it->end) ? (SWHANDLE)it->it->second : 0;
}
diff --git a/bindings/java-jni/jni/swordstub.cpp b/bindings/java-jni/jni/swordstub.cpp
index a8ddb16..435a3f1 100644
--- a/bindings/java-jni/jni/swordstub.cpp
+++ b/bindings/java-jni/jni/swordstub.cpp
@@ -2,7 +2,7 @@
*
* swordstub.cpp - JNI bindings
*
- * $Id: swordstub.cpp 2894 2013-07-16 04:38:43Z scribe $
+ * $Id: swordstub.cpp 3184 2014-04-17 04:30:54Z greg.hellings $
*
* Copyright 2009-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -1132,6 +1132,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWModule_search
SWModule *module = getModule(env, me);
+ // TODO: remove this from the stack
struct pu peeuuu(env, progressReporter);
if (module) {
@@ -1245,11 +1246,11 @@ SWLog::getSystemLog()->logDebug("uninstallModule %s\n", modName);
return -2;
}
module = it->second;
- installMgr->removeModule(mgr, module->getName());
+ int retVal = installMgr->removeModule(mgr, module->getName());
env->ReleaseStringUTFChars(modNameJS, modName);
- return 0;
+ return retVal;
}
@@ -1350,9 +1351,9 @@ SWLog::getSystemLog()->logDebug("remoteListModules returning %d length array\n",
SWBuf version = module->getConfigEntry("Version");
SWBuf statusString = " ";
- if (it->second & InstallMgr::MODSTAT_NEW) statusString = "*";
- if (it->second & InstallMgr::MODSTAT_OLDER) statusString = "-";
- if (it->second & InstallMgr::MODSTAT_UPDATED) statusString = "+";
+ if (status & InstallMgr::MODSTAT_NEW) statusString = "*";
+ if (status & InstallMgr::MODSTAT_OLDER) statusString = "-";
+ if (status & InstallMgr::MODSTAT_UPDATED) statusString = "+";
SWBuf type = module->getType();
SWBuf cat = module->getConfigEntry("Category");
diff --git a/bindings/swig/package/aclocal.m4 b/bindings/swig/package/aclocal.m4
index 0c2ed70..094585c 100644
--- a/bindings/swig/package/aclocal.m4
+++ b/bindings/swig/package/aclocal.m4
@@ -220,6 +220,21 @@ m4_popdef([pkg_default])
m4_popdef([pkg_description])
]) dnl PKG_NOARCH_INSTALLDIR
+
+# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------
+# Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])# PKG_CHECK_VAR
+
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
diff --git a/bindings/swig/package/config.guess b/bindings/swig/package/config.guess
index b79252d..1804e9f 100755
--- a/bindings/swig/package/config.guess
+++ b/bindings/swig/package/config.guess
@@ -1,8 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright 1992-2013 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+# 2011, 2012, 2013 Free Software Foundation, Inc.
-timestamp='2013-06-10'
+timestamp='2012-12-29'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -24,7 +26,7 @@ timestamp='2013-06-10'
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
#
-# Originally written by Per Bothner.
+# Originally written by Per Bothner.
#
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
@@ -50,7 +52,9 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+2012, 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -132,27 +136,6 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-case "${UNAME_SYSTEM}" in
-Linux|GNU|GNU/*)
- # If the system lacks a compiler, then just pick glibc.
- # We could probably try harder.
- LIBC=gnu
-
- eval $set_cc_for_build
- cat <<-EOF > $dummy.c
- #include <features.h>
- #if defined(__UCLIBC__)
- LIBC=uclibc
- #elif defined(__dietlibc__)
- LIBC=dietlibc
- #else
- LIBC=gnu
- #endif
- EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
- ;;
-esac
-
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
@@ -874,21 +857,21 @@ EOF
exit ;;
*:GNU:*:*)
# the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
aarch64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@@ -901,54 +884,59 @@ EOF
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
- if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
- exit ;;
- arc:Linux:*:* | arceb:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+ echo ${UNAME_MACHINE}-unknown-linux-gnueabi
else
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+ echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
cris:Linux:*:*)
- echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+ echo ${UNAME_MACHINE}-axis-linux-gnu
exit ;;
crisv32:Linux:*:*)
- echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+ echo ${UNAME_MACHINE}-axis-linux-gnu
exit ;;
frv:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
hexagon:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
- echo ${UNAME_MACHINE}-pc-linux-${LIBC}
+ LIBC=gnu
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit ;;
ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
@@ -967,63 +955,54 @@ EOF
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
- or1k:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
- exit ;;
or32:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
padre:Linux:*:*)
- echo sparc-unknown-linux-${LIBC}
+ echo sparc-unknown-linux-gnu
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-${LIBC}
+ echo hppa64-unknown-linux-gnu
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
- PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
- *) echo hppa-unknown-linux-${LIBC} ;;
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
esac
exit ;;
ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-${LIBC}
+ echo powerpc64-unknown-linux-gnu
exit ;;
ppc:Linux:*:*)
- echo powerpc-unknown-linux-${LIBC}
- exit ;;
- ppc64le:Linux:*:*)
- echo powerpc64le-unknown-linux-${LIBC}
- exit ;;
- ppcle:Linux:*:*)
- echo powerpcle-unknown-linux-${LIBC}
+ echo powerpc-unknown-linux-gnu
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+ echo ${UNAME_MACHINE}-ibm-linux
exit ;;
sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
tile*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
vax:Linux:*:*)
- echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+ echo ${UNAME_MACHINE}-dec-linux-gnu
exit ;;
x86_64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
xtensa*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -1256,21 +1235,19 @@ EOF
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- eval $set_cc_for_build
- if test "$UNAME_PROCESSOR" = unknown ; then
- UNAME_PROCESSOR=powerpc
- fi
- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
- if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
- (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
- grep IS_64BIT_ARCH >/dev/null
- then
- case $UNAME_PROCESSOR in
- i386) UNAME_PROCESSOR=x86_64 ;;
- powerpc) UNAME_PROCESSOR=powerpc64 ;;
- esac
- fi
- fi
+ case $UNAME_PROCESSOR in
+ i386)
+ eval $set_cc_for_build
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ UNAME_PROCESSOR="x86_64"
+ fi
+ fi ;;
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
diff --git a/bindings/swig/package/config.sub b/bindings/swig/package/config.sub
index c765b34..52f04bc 100755
--- a/bindings/swig/package/config.sub
+++ b/bindings/swig/package/config.sub
@@ -1,8 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright 1992-2013 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+# 2011, 2012, 2013 Free Software Foundation, Inc.
-timestamp='2013-04-24'
+timestamp='2012-12-29'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -68,7 +70,9 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+2012, 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -252,7 +256,7 @@ case $basic_machine in
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
- | arc | arceb \
+ | arc \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| be32 | be64 \
@@ -286,17 +290,16 @@ case $basic_machine in
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
- | mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
- | nios | nios2 | nios2eb | nios2el \
+ | nios | nios2 \
| ns16k | ns32k \
| open8 \
- | or1k | or32 \
+ | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
@@ -366,7 +369,7 @@ case $basic_machine in
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| be32-* | be64-* \
@@ -404,13 +407,12 @@ case $basic_machine in
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
- | nios-* | nios2-* | nios2eb-* | nios2el-* \
+ | nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| orion-* \
@@ -1352,7 +1354,7 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
- | -sym* | -kopensolaris* | -plan9* \
+ | -sym* | -kopensolaris* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
@@ -1498,6 +1500,9 @@ case $os in
-aros*)
os=-aros
;;
+ -kaos*)
+ os=-kaos
+ ;;
-zvmoe)
os=-zvmoe
;;
@@ -1589,9 +1594,6 @@ case $basic_machine in
mips*-*)
os=-elf
;;
- or1k-*)
- os=-elf
- ;;
or32-*)
os=-coff
;;
diff --git a/bindings/swig/package/configure b/bindings/swig/package/configure
index 7e38cc8..b05da08 100755
--- a/bindings/swig/package/configure
+++ b/bindings/swig/package/configure
@@ -6682,10 +6682,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
x86_64-*linux*)
LD="${LD-ld} -m elf_i386"
;;
- powerpcle-*linux*)
+ powerpc64le-*linux*)
LD="${LD-ld} -m elf32lppclinux"
;;
- powerpc-*linux*)
+ powerpc64-*linux*)
LD="${LD-ld} -m elf32ppclinux"
;;
s390x-*linux*)
diff --git a/bindings/swig/package/m4/libtool.m4 b/bindings/swig/package/m4/libtool.m4
index 126202f..f12cfdf 100644
--- a/bindings/swig/package/m4/libtool.m4
+++ b/bindings/swig/package/m4/libtool.m4
@@ -1326,10 +1326,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
x86_64-*linux*)
LD="${LD-ld} -m elf_i386"
;;
- powerpcle-*linux*)
+ powerpc64le-*linux*)
LD="${LD-ld} -m elf32lppclinux"
;;
- powerpc-*linux*)
+ powerpc64-*linux*)
LD="${LD-ld} -m elf32ppclinux"
;;
s390x-*linux*)