Rename native lib to libmpw & native library loading for eg. Android.
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
### CMAKE
 | 
			
		||||
project( mpw-cli C )
 | 
			
		||||
project( masterpassword-cli C )
 | 
			
		||||
cmake_minimum_required( VERSION 3.0.2 )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@ artifacts {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
library {
 | 
			
		||||
    baseName.set( "mpw" )
 | 
			
		||||
    linkage.set( [Linkage.STATIC, Linkage.SHARED] )
 | 
			
		||||
 | 
			
		||||
    // Reconfigure the toolchain from C++ to C.
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@ public class MPAlgorithmV0 extends MPAlgorithm {
 | 
			
		||||
    protected static final int    AES_BLOCKSIZE      = 128 /* bit */;
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
        Native.load( MPAlgorithmV0.class, "masterpassword-core" );
 | 
			
		||||
        Native.load( MPAlgorithmV0.class, "mpw" );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public final Version version = MPAlgorithm.Version.V0;
 | 
			
		||||
 
 | 
			
		||||
@@ -40,8 +40,16 @@ public final class Native {
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings({ "HardcodedFileSeparator", "LoadLibraryWithNonConstantString" })
 | 
			
		||||
    public static void load(final Class<?> context, final String name) {
 | 
			
		||||
 | 
			
		||||
        // Try to load the library using the native system.
 | 
			
		||||
        try {
 | 
			
		||||
            System.loadLibrary( name );
 | 
			
		||||
            return;
 | 
			
		||||
        } catch (@SuppressWarnings("ErrorNotRethrown") final UnsatisfiedLinkError ignored) {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Try to find and open a stream to the packaged library resource.
 | 
			
		||||
        try {
 | 
			
		||||
            // Find and open a stream to the packaged library resource.
 | 
			
		||||
            String      library          = System.mapLibraryName( name );
 | 
			
		||||
            int         libraryDot       = library.lastIndexOf( EXTENSION_SEPARATOR );
 | 
			
		||||
            String      libraryName      = (libraryDot > 0)? library.substring( 0, libraryDot ): library;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user