[network-manager-openvpn/th/tmp] shared: move nm_utils_syslog_to_str() to "nm-vpn-plugin-utils.h"



commit 86e0ace18ed8a1f3d3c4c88adc638673eb8033bf
Author: Thomas Haller <thaller redhat com>
Date:   Wed May 25 08:51:38 2016 +0200

    shared: move nm_utils_syslog_to_str() to "nm-vpn-plugin-utils.h"
    
    All plugins should use the same approach to logging, thus it makes
    sense to move this file to a nm-vpn shared header.
    
    Instead of moving this inline function to "nm-vpn/nm-vpn-plugin-utils.h",
    create a new header-only file "nm-vpn/nm-vpn-plugin-macros.h".
    The difference between these two headers is, that the latter contains
    only defines that don't require linking against the nm-vpn-plugin-utils
    object.

 shared/Makefile.am                      |    3 +-
 shared/README                           |    1 +
 shared/nm-vpn/nm-vpn-plugin-macros.h    |   43 +++++++++++++++++++++++++++++++
 shared/utils.h                          |   17 ------------
 src/nm-openvpn-service-openvpn-helper.c |    2 +-
 src/nm-openvpn-service.c                |    1 +
 6 files changed, 48 insertions(+), 19 deletions(-)
---
diff --git a/shared/Makefile.am b/shared/Makefile.am
index 22d36c4..06dbb70 100644
--- a/shared/Makefile.am
+++ b/shared/Makefile.am
@@ -45,7 +45,8 @@ libnm_vpn_editor_utils_shared_la_CPPFLAGS = \
 
 libnm_vpn_editor_utils_shared_la_SOURCES = \
     nm-vpn/nm-vpn-plugin-utils.c \
-    nm-vpn/nm-vpn-plugin-utils.h
+    nm-vpn/nm-vpn-plugin-utils.h \
+    nm-vpn/nm-vpn-plugin-macros.h
 
 libnm_vpn_editor_utils_shared_la_LIBADD = \
     $(LIBNM_LIBS) \
diff --git a/shared/README b/shared/README
index e7a2dff..b57961e 100644
--- a/shared/README
+++ b/shared/README
@@ -14,6 +14,7 @@ are copied as-is from NetworkManager
 2) the files
     shared/nm-vpn/nm-vpn-plugin-utils.c
     shared/nm-vpn/nm-vpn-plugin-utils.h
+    shared/nm-vpn/nm-vpn-plugin-macros.h
 are copied as-is from nm-openvpn
   
https://git.gnome.org/browse/network-manager-openvpn/tree/shared?id=3d0ac3ca94b4bf24f77306cef5a95172ddaf5fc4
 
diff --git a/shared/nm-vpn/nm-vpn-plugin-macros.h b/shared/nm-vpn/nm-vpn-plugin-macros.h
new file mode 100644
index 0000000..d685934
--- /dev/null
+++ b/shared/nm-vpn/nm-vpn-plugin-macros.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2016 Red Hat, Inc.
+ */
+
+#ifndef __NM_VPN_PLUGIN_MACROS_H__
+#define __NM_VPN_PLUGIN_MACROS_H__
+
+#include <syslog.h>
+
+static inline const char *
+nm_utils_syslog_to_str (int syslog_level)
+{
+       /* Maps the levels the same way as NetworkManager's nm-logging.c does */
+       if (syslog_level >= LOG_DEBUG)
+               return "<trace>";
+       if (syslog_level >= LOG_INFO)
+               return "<debug>";
+       if (syslog_level >= LOG_NOTICE)
+               return "<info>";
+       if (syslog_level >= LOG_WARNING)
+               return "<warn>";
+       return "<error>";
+}
+
+#endif /* __NM_VPN_PLUGIN_MACROS_H__ */
+
diff --git a/shared/utils.h b/shared/utils.h
index 48653d1..6370871 100644
--- a/shared/utils.h
+++ b/shared/utils.h
@@ -22,8 +22,6 @@
 #ifndef UTILS_H
 #define UTILS_H
 
-#include <syslog.h>
-
 #define NMV_OVPN_TAG_AUTH               "auth"
 #define NMV_OVPN_TAG_AUTH_NOCACHE       "auth-nocache"
 #define NMV_OVPN_TAG_AUTH_USER_PASS     "auth-user-pass"
@@ -83,20 +81,5 @@ const char *nmv_utils_str_utf8safe_escape_c   (const char *str, char **out_clone
 char *      nmv_utils_str_utf8safe_unescape   (const char *str);
 const char *nmv_utils_str_utf8safe_unescape_c (const char *str, char **str_free);
 
-static inline const char *
-nm_utils_syslog_to_str (int syslog_level)
-{
-       /* Maps the levels the same way as NetworkManager's nm-logging.c does */
-       if (syslog_level >= LOG_DEBUG)
-               return "<trace>";
-       if (syslog_level >= LOG_INFO)
-               return "<debug>";
-       if (syslog_level >= LOG_NOTICE)
-               return "<info>";
-       if (syslog_level >= LOG_WARNING)
-               return "<warn>";
-       return "<error>";
-}
-
 #endif  /* UTILS_H */
 
diff --git a/src/nm-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index ff44884..9d5d444 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -40,8 +40,8 @@
 #include <netdb.h>
 #include <syslog.h>
 
-#include "utils.h"
 #include "nm-utils/nm-shared-utils.h"
+#include "nm-vpn/nm-vpn-plugin-macros.h"
 
 extern char **environ;
 
diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index 50d23bb..f6c6c12 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -48,6 +48,7 @@
 
 #include "utils.h"
 #include "nm-utils/nm-shared-utils.h"
+#include "nm-vpn/nm-vpn-plugin-macros.h"
 
 #if !defined(DIST_VERSION)
 # define DIST_VERSION VERSION


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]