IPACM: fix compilation issue
Fix the compilation issue of IPACM by refering to g_strlcpy and
g_strlcat.
Change-Id: I91026c1393aa082482362db95a34016f1cb9e2eb
diff --git a/ipacm/inc/IPACM_Defs.h b/ipacm/inc/IPACM_Defs.h
index 4472d6b..dbc8453 100644
--- a/ipacm/inc/IPACM_Defs.h
+++ b/ipacm/inc/IPACM_Defs.h
@@ -45,6 +45,12 @@
#include <linux/msm_ipa.h>
#include "IPACM_Log.h"
+#ifdef USE_GLIB
+#include <glib.h>
+#define strlcpy g_strlcpy
+#define strlcat g_strlcat
+#endif
+
extern "C"
{
#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
diff --git a/ipacm/inc/IPACM_Iface.h b/ipacm/inc/IPACM_Iface.h
index 37004ce..9f38325 100644
--- a/ipacm/inc/IPACM_Iface.h
+++ b/ipacm/inc/IPACM_Iface.h
@@ -126,12 +126,6 @@
/*Query the IPA endpoint property */
int query_iface_property(void);
- /*implement IPACM strlcpy */
- size_t strlcpy(char *dest, const char *src, size_t size);
-
- /*implement IPACM strlcat */
- size_t strlcat(char *dest, const char *src, size_t n);
-
/*Configure the initial filter rules */
virtual int init_fl_rule(ipa_ip_type iptype);
diff --git a/ipacm/src/IPACM_Iface.cpp b/ipacm/src/IPACM_Iface.cpp
index 5dc7647..7b5a795 100644
--- a/ipacm/src/IPACM_Iface.cpp
+++ b/ipacm/src/IPACM_Iface.cpp
@@ -968,48 +968,3 @@
close(fd);
return IPACM_SUCCESS;
}
-
-size_t IPACM_Iface::strlcpy(char *dest, const char *src, size_t n)
-{
- size_t ret = strlen(src);
- size_t len = 0;
- if (n > 0) {
- if(ret >= n)
- {
- len = n-1;
- IPACMERR(" overflow detected \n");
- }
- else
- {
- len = ret;
- }
- dest[len] = '\0';
- memcpy(dest, src, len);
- }
- return ret;
-}
-
-size_t IPACM_Iface::strlcat(char *dest, const char *src, size_t n)
-{
- size_t dsize = strlen(dest);
- size_t len = strlen(src);
- size_t ret = dsize + len;
-
- if (dsize < n)
- {
- dest += dsize;
- n -= dsize;
- if (len >= n)
- {
- len = n - 1;
- IPACMERR(" overflow detected \n");
- }
- dest[len] = '\0';
- memcpy(dest, src, len);
- }
- else
- {
- IPACMERR(" dest buffer full\n");
- }
- return ret;
-}
diff --git a/ipacm/src/Makefile.am b/ipacm/src/Makefile.am
index 2fdb3f8..7a62a75 100644
--- a/ipacm/src/Makefile.am
+++ b/ipacm/src/Makefile.am
@@ -31,10 +31,19 @@
requiredlibs = ${LIBXML_LIB} -lxml2 -lpthread -lnetfilter_conntrack -lnfnetlink\
../../ipanat/src/libipanat.la
-ipacm_LDADD = $(requiredlibs)
-
AM_CPPFLAGS += "-std=c++0x"
+if USE_GLIB
+ipacm_CFLAGS = $(AM_CFLAGS) -DUSE_GLIB @GLIB_CFLAGS@
+ipacm_LDFLAGS = -lpthread @GLIB_LIBS@
+ipacm_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
+else
+ipacm_CFLAGS = $(AM_CFLAGS)
+ipacm_LDFLAGS = -lpthread
+ipacm_CPPFLAGS = $(AM_CPPFLAGS)
+endif
+ipacm_LDADD = $(requiredlibs)
+
LOCAL_MODULE := libipanat
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)