Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 1st, 2012  |  syntax: C  |  size: 1.01 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /* NB: PROTOTYPE SUGGESTION - NOT COMPILE TESTED */
  2.  
  3. /* openvpn-plugin.h */
  4. struct openvpn_plugin_args_open_in
  5. {
  6.   const int type_mask;
  7.   const char ** const argv;
  8.   const char ** const envp;
  9.   void (*plugin_function_log) (const char *plgname, openvpn_plugin_log_flags_t f, const char *m, ...);
  10. };
  11.  
  12. #ifdef PLUGIN_NAME
  13. static void (*_plugin_log) (const char *plgname, openvpn_plugin_log_flags_t f, const char *m, ...);
  14. #define OPENVPN_PREPARE_LOG_FUNCTION(plgargs_in) \
  15.         _plugin_log = (plgargs_in)->plugin_function_log;
  16. #define plugin_log(flags, fmt, logdata...) _plugin_log(PLUGIN_NAME, flags, fmt, ## logdata);
  17. #endif
  18.  
  19.  
  20. /* how to use it in a plug-in: */
  21.  
  22. #define PLUGIN_NAME "demo"
  23. #include <openvpn-plugin.h>
  24.  
  25. OPENVPN_EXPORT int
  26. openvpn_plugin_open_v3 (const int v3structver,
  27.                         struct openvpn_plugin_args_open_in const *args,
  28.                         struct openvpn_plugin_args_open_return *ret)
  29. {
  30.         OPENVPN_PREPARE_LOG_FUNCTION(args);
  31.  
  32.         plugin_log(PLOG_INFO, "Hello world!");
  33. }