Get the plugin registered with the browser
authorMark Donnelly <mark@painless-security.com>
Tue, 26 Nov 2013 21:09:08 +0000 (16:09 -0500)
committerMark Donnelly <mark@painless-security.com>
Tue, 26 Nov 2013 21:09:08 +0000 (16:09 -0500)
.gitignore [moved from npapi/Win/.gitignore with 100% similarity]
npapi/.gitignore [deleted file]
npapi/CMakeLists.txt
npapi/js_gss_api.c [new file with mode: 0644]
npapi/npapi.c [new file with mode: 0644]
test/npapi/test_dlopen.c [new file with mode: 0644]

similarity index 100%
rename from npapi/Win/.gitignore
rename to .gitignore
diff --git a/npapi/.gitignore b/npapi/.gitignore
deleted file mode 100644 (file)
index 787bf94..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-# CMake
-CMakeCache.txt
-CMakeFiles
-Makefile
-cmake_install.cmake
-install_manifest.txt
-
-##
-## C++ 
-################################
-# Compiled Object files
-*.slo
-*.lo
-*.o
-*.obj
-
-# Compiled Dynamic libraries
-*.so
-*.dylib
-*.dll
-
-# Compiled Static libraries
-*.lai
-*.la
-*.a
-*.lib
-
-# Executables
-*.exe
-*.out
-*.app
-
-##
-## C Files
-##############################
-# Object files
-*.o
-*.ko
-*.obj
-*.elf
-
-# Libraries
-*.lib
-*.a
-
-# Shared objects (inc. Windows DLLs)
-*.dll
-*.so
-*.so.*
-*.dylib
-
-# Executables
-*.exe
-*.out
-*.app
-*.hex
index e6c5f8d..7eaa6af 100644 (file)
@@ -2,6 +2,9 @@ cmake_minimum_required (VERSION 2.8)
 
 project (WebShot)
 
+#include_directories ("${PROJECT_SOURCE_DIR}/Win")
+#add_subdirectory (Win) 
+
 # add the library
-add_library (WebShot)
-target_link_libraries (WebShot Win
+add_library (WebShot SHARED js_gss_api.c npapi.c)
+#target_link_libraries (WebShot Win)
diff --git a/npapi/js_gss_api.c b/npapi/js_gss_api.c
new file mode 100644 (file)
index 0000000..8f1ec0e
--- /dev/null
@@ -0,0 +1,4 @@
+void example(void)
+{
+  return;
+}
diff --git a/npapi/npapi.c b/npapi/npapi.c
new file mode 100644 (file)
index 0000000..f6840e1
--- /dev/null
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <string.h>
+#include <firefox/npapi.h>
+#include <firefox/nptypes.h>
+#include <firefox/npfunctions.h>
+
+/*
+ * Loading and unloading the library 
+ */
+NPError NP_Initialize(NPNetscapeFuncs *aNPNFuncs, NPPluginFuncs *aNPPFuncs)
+{
+  return NPERR_NO_ERROR;
+}
+
+void NP_Shutdown(void)
+{
+  return;
+}
+
+/*
+ * Create and destroy an instance of the plugin
+ */
+NPError NPP_New(NPMIMEType    pluginType,
+                NPP instance, uint16_t mode,
+                int16_t argc, char *argn[],
+                char *argv[], NPSavedData *saved)
+{
+  return(NPERR_NO_ERROR);
+}
+
+NPError NPP_Destroy(NPP instance, NPSavedData **save)
+{
+  return(NPERR_NO_ERROR);
+}
+
+
+
+/*
+ * Register the plugin for MIME type, and name, etc.
+ */
+#define MIME_TYPES_DESCRIPTION "application/web-shot:wsht:Web plugin for the Moonshot libraries"
+const char* NP_GetMIMEDescription(void)
+{
+  return(MIME_TYPES_DESCRIPTION);
+}
+
+NPError NP_GetValue(void *instance, 
+                    NPPVariable variable, 
+                    void *value)
+{
+  switch(variable)
+  {
+  case NPPVpluginNameString:
+    *((char **)value) = "GSS-web Plugin\0";
+    break;
+  case NPPVpluginDescriptionString:
+    *((char **)value) = "This plugin facilitates identification of you and authorization to access web resources using GSS-EAP, a standards-compliant mechanism for establishing an identity and access rights within a sophisticated organization.\0";
+    break;
+  default:
+    return NPERR_GENERIC_ERROR;
+  }
+  
+  return NPERR_NO_ERROR;
+}
diff --git a/test/npapi/test_dlopen.c b/test/npapi/test_dlopen.c
new file mode 100644 (file)
index 0000000..bb34c62
--- /dev/null
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <firefox/npapi.h>
+
+int main(int argc, char **argv) 
+{
+   void *lib_handle;
+   int (*fn)(void);
+   int x;
+   char *error;
+   
+   char* funcs[4] = {"NP_Initialize", "NP_Shutdown", "NPP_New", "NPP_Destroy"};
+
+   lib_handle = dlopen("../../npapi/libWebShot.so", RTLD_LAZY);
+   if (!lib_handle) 
+   {
+      fprintf(stderr, "%s\n", dlerror());
+      exit(1);
+   }
+   
+   for (x=0; x<4; x++)
+   {
+     int retVal = 0;
+
+     fn = dlsym(lib_handle, funcs[x]);
+     if ((error = dlerror()) != NULL)  
+     {
+       fprintf(stderr, "Did not find function %s: %s\n", funcs[x], error);
+       exit(2);
+     }
+     
+     retVal = (*fn)();
+     printf("%s() => %i\n", funcs[x], retVal);
+   }
+
+
+   /*
+   (*fn)(&x);
+   printf("Valx=%d\n",x);
+   */
+
+   dlclose(lib_handle);
+   return 0;
+}