فهرست منبع

make sure plugin code doesn't have its own instances of global variables but uses the ones from the main program

ambrop7 13 سال پیش
والد
کامیت
e1cda2fad8
5فایلهای تغییر یافته به همراه13 افزوده شده و 1 حذف شده
  1. 1 1
      CMakeLists.txt
  2. 4 0
      base/BLog.c
  3. 2 0
      base/DebugObject.c
  4. 4 0
      system/BNetwork.c
  5. 2 0
      system/BTime.c

+ 1 - 1
CMakeLists.txt

@@ -269,7 +269,7 @@ function(badvpn_add_library LIB_NAME LINK_BADVPN_LIBS LINK_SYS_LIBS LIB_SOURCES)
     add_library("${LIB_NAME}-plugin" STATIC ${LIB_SOURCES})
     add_library("${LIB_NAME}-plugin" STATIC ${LIB_SOURCES})
     target_link_libraries("${LIB_NAME}-plugin" ${BADVPN_LIBS_PLUGIN} ${LINK_SYS_LIBS})
     target_link_libraries("${LIB_NAME}-plugin" ${BADVPN_LIBS_PLUGIN} ${LINK_SYS_LIBS})
     set_target_properties("${LIB_NAME}-plugin" PROPERTIES POSITION_INDEPENDENT_CODE YES)
     set_target_properties("${LIB_NAME}-plugin" PROPERTIES POSITION_INDEPENDENT_CODE YES)
-    set_target_properties("${LIB_NAME}-plugin" PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+    set_target_properties("${LIB_NAME}-plugin" PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -DBADVPN_PLUGIN")
 endfunction()
 endfunction()
 
 
 # internal libraries
 # internal libraries

+ 4 - 0
base/BLog.c

@@ -32,6 +32,8 @@
 
 
 #include "BLog.h"
 #include "BLog.h"
 
 
+#ifndef BADVPN_PLUGIN
+
 struct _BLog_channel blog_channel_list[] = {
 struct _BLog_channel blog_channel_list[] = {
 #include <generated/blog_channels_list.h>
 #include <generated/blog_channels_list.h>
 };
 };
@@ -42,6 +44,8 @@ struct _BLog_global blog_global = {
     #endif
     #endif
 };
 };
 
 
+#endif
+
 // keep in sync with level numbers in BLog.h!
 // keep in sync with level numbers in BLog.h!
 static char *level_names[] = { NULL, "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG" };
 static char *level_names[] = { NULL, "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG" };
 
 

+ 2 - 0
base/DebugObject.c

@@ -29,9 +29,11 @@
 
 
 #include "DebugObject.h"
 #include "DebugObject.h"
 
 
+#ifndef BADVPN_PLUGIN
 #ifndef NDEBUG
 #ifndef NDEBUG
 DebugCounter debugobject_counter = DEBUGCOUNTER_STATIC;
 DebugCounter debugobject_counter = DEBUGCOUNTER_STATIC;
 #ifdef BADVPN_THREADWORK_USE_PTHREAD
 #ifdef BADVPN_THREADWORK_USE_PTHREAD
 pthread_mutex_t debugobject_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t debugobject_mutex = PTHREAD_MUTEX_INITIALIZER;
 #endif
 #endif
 #endif
 #endif
+#endif

+ 4 - 0
system/BNetwork.c

@@ -43,7 +43,11 @@
 
 
 #include <generated/blog_channel_BNetwork.h>
 #include <generated/blog_channel_BNetwork.h>
 
 
+extern int bnetwork_initialized;
+
+#ifndef BADVPN_PLUGIN
 int bnetwork_initialized = 0;
 int bnetwork_initialized = 0;
+#endif
 
 
 int BNetwork_GlobalInit (void)
 int BNetwork_GlobalInit (void)
 {
 {

+ 2 - 0
system/BTime.c

@@ -29,8 +29,10 @@
 
 
 #include <system/BTime.h>
 #include <system/BTime.h>
 
 
+#ifndef BADVPN_PLUGIN
 struct _BTime_global btime_global = {
 struct _BTime_global btime_global = {
     #ifndef NDEBUG
     #ifndef NDEBUG
     0
     0
     #endif
     #endif
 };
 };
+#endif