celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [15/16] celix git commit: CELIX-237
Date Sat, 04 Jul 2015 11:21:07 GMT
CELIX-237

Added bundled Apache Licensed memstream for Mac support.
Refactored logging in dyn_type


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/fd7662c2
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/fd7662c2
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/fd7662c2

Branch: refs/heads/feature/CELIX-237_rsa-ffi
Commit: fd7662c2f928d5f8510d2dc776767921d224ce5e
Parents: bdeba2b
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Sat Jul 4 13:13:46 2015 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Sat Jul 4 13:13:46 2015 +0200

----------------------------------------------------------------------
 .../dynamic_function_interface/CMakeLists.txt   |  46 ++++---
 .../avro_descriptor_translator.c                |   5 +
 .../dynamic_function_interface/dyn_type.c       |  48 +++----
 .../dynamic_function_interface/dyn_type.h       |   9 +-
 .../memstream/fmemopen.c                        |  80 +++++++++++
 .../memstream/fmemopen.h                        |  52 +++++++
 .../memstream/open_memstream.c                  | 134 +++++++++++++++++++
 .../memstream/open_memstream.h                  |  19 +++
 .../tst/avro_descriptor_translator_tests.cpp    |   5 +
 .../tst/dyn_type_tests.cpp                      |  37 ++---
 10 files changed, 362 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/CMakeLists.txt b/remote_services/dynamic_function_interface/CMakeLists.txt
index 81e935e..bf3a628 100644
--- a/remote_services/dynamic_function_interface/CMakeLists.txt
+++ b/remote_services/dynamic_function_interface/CMakeLists.txt
@@ -3,38 +3,50 @@
 #
 find_package(Jansson REQUIRED)
 find_package(CppUTest REQUIRED)
-set(FFI_LIB /lib64/libffi.so) #TODO add findPackag for lib ffi
+
+#set(FFI_LIB /lib64/libffi.so) #TODO add findPackag for lib ffi
+set(FFI_LIB /opt/local/lib/libffi.dylib) 
+set(FFI_INCLUDE /opt/local/lib/libffi-3.2.1/include)
 
 include_directories( 
     ${CPPUTEST_INCLUDE_DIR}
     ${JANSSON_INCLUDE_DIRS}
     ${CMAKE_CURRENT_LIST_DIR}
+    ${FFI_INCLUDE}
+    memstream
 )
 
+set(MEMSTREAM_SOURCES "")
+if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") 
+	set(MEMSTREAM_SOURCES memstream/open_memstream.c memstream/fmemopen.c)
+endif()
+
 add_library(dfi
     dyn_type.c
     dyn_function.c
     json_serializer.c
     avro_descriptor_translator.c
+    ${MEMSTREAM_SOURCES}
 )
 target_link_libraries(dfi ${FFI_LIB} ${JANSSON_LIBRARY})
 
 
-add_executable(dfi_tests
-    tst/dyn_type_tests.cpp
-    tst/dyn_function_tests.cpp
-    tst/dyn_closure_tests.cpp
-    tst/json_serializer_tests.cpp
-    tst/avro_descriptor_translator_tests.cpp
-    tst/run_tests.cpp
-)
-target_link_libraries(dfi_tests dfi ${FFI_LIB} ${CPPUTEST_LIBRARY} ${JANSSON_LIBRARY}) 
-
-add_custom_target(copy-input 
-    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/schemas schemas
-)
-add_dependencies(dfi_tests copy-input)
+#if (FRAMEWORK_TESTS)
+	add_executable(dfi_tests
+	    tst/dyn_type_tests.cpp
+	    tst/dyn_function_tests.cpp
+	    tst/dyn_closure_tests.cpp
+	    tst/json_serializer_tests.cpp
+	    tst/avro_descriptor_translator_tests.cpp
+	    tst/run_tests.cpp
+	)
+	target_link_libraries(dfi_tests dfi ${FFI_LIB} ${CPPUTEST_LIBRARY} ${JANSSON_LIBRARY}) 
 
-ADD_TARGET_FOR_TEST(dfi_tests)
-SETUP_TARGET_FOR_COVERAGE(dfi_tests_cov dfi_tests ${CMAKE_BINARY_DIR}/coverage/dfi)
+	add_custom_target(copy-input 
+	    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/schemas schemas
+	)
+	add_dependencies(dfi_tests copy-input)
 
+	ADD_TARGET_FOR_TEST(dfi_tests)
+	SETUP_TARGET_FOR_COVERAGE(dfi_tests_cov dfi_tests ${CMAKE_BINARY_DIR}/coverage/dfi)
+#endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/avro_descriptor_translator.c
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/avro_descriptor_translator.c b/remote_services/dynamic_function_interface/avro_descriptor_translator.c
index 9d52926..06fad8b 100644
--- a/remote_services/dynamic_function_interface/avro_descriptor_translator.c
+++ b/remote_services/dynamic_function_interface/avro_descriptor_translator.c
@@ -10,6 +10,11 @@
 
 #include <jansson.h>
 
+#if defined(BSD) || defined(__APPLE__) 
+#include "open_memstream.h"
+#include "fmemopen.h"
+#endif
+
 static const int OK = 0;
 static const int MEM_ERROR = 1;
 static const int PARSE_ERROR = 2;

http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/dyn_type.c
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/dyn_type.c b/remote_services/dynamic_function_interface/dyn_type.c
index 5ad18f4..6df517b 100644
--- a/remote_services/dynamic_function_interface/dyn_type.c
+++ b/remote_services/dynamic_function_interface/dyn_type.c
@@ -13,6 +13,8 @@
 #include <assert.h>
 #include <errno.h>
 
+DFI_SETUP_LOG(dynType)
+
 static int dynType_createWithStream(FILE *stream, dyn_type *parent, dyn_type **type);
 static void dynType_clear(dyn_type *type);
 static void dynType_clearComplex(dyn_type *type);
@@ -55,22 +57,6 @@ static const int DT_ERROR = 1;
 static const int DT_MEM_ERROR = 2;
 static const int DT_PARSE_ERROR = 3;
 
-#define DT_LOG_ERROR    1
-#define DT_LOG_WARNING  2
-#define DT_LOG_INFO     3
-#define DT_LOG_DEBUG    4
-#define DT_LOG(lvl, msg, ...) if(g_logf != NULL) { \
-    g_logf(g_logHandle, (lvl), __FILE__, __LINE__, (msg),  ##__VA_ARGS__);  \
-}
-
-static void (*g_logf)(void *handle, int level, const char *file, int line, const char *msgFormat,
...) = NULL;
-static void *g_logHandle = NULL;
-
-void dynType_setupLogger(void (*logf)(void *handle, int level, const char *file, int line,
const char *msgFormat, ...), void *handle) {
-    g_logHandle = handle;
-    g_logf = logf;
-}
-
 int dynType_create(const char *descriptor, dyn_type **type) {
     int status = DT_OK;
     FILE *stream = fmemopen((char *)descriptor, strlen(descriptor), "r");
@@ -80,13 +66,13 @@ int dynType_create(const char *descriptor, dyn_type **type) {
             int c = fgetc(stream);
             if (c != '\0' && c != EOF) {
                 status = DT_PARSE_ERROR;
-                DT_LOG(DT_LOG_ERROR, "Expected EOF got %c", c);
+                LOG_ERROR("Expected EOF got %c", c);
             }
         } 
         fclose(stream);
     } else {
         status = DT_ERROR;
-        DT_LOG(DT_LOG_ERROR, "Error creating mem stream for descriptor string. %s", strerror(errno));

+        LOG_ERROR("Error creating mem stream for descriptor string. %s", strerror(errno));

     }
     return status;
 }
@@ -106,7 +92,7 @@ static int dynType_createWithStream(FILE *stream, dyn_type *parent, dyn_type
**r
         }
     } else {
         status = DT_MEM_ERROR;
-        DT_LOG(DT_LOG_ERROR, "Error allocating memory for type");
+        LOG_ERROR("Error allocating memory for type");
     }
     return status;
 }
@@ -165,7 +151,7 @@ static int dynType_parseComplex(FILE *stream, dyn_type *type) {
             status = dynType_parse(stream, &entry->type);
         } else {
             status = DT_MEM_ERROR;
-            DT_LOG(DT_LOG_ERROR, "Error allocating memory for type");
+            LOG_ERROR("Error allocating memory for type");
         }
         c = fgetc(stream);
     }
@@ -212,7 +198,7 @@ static int dynType_parseComplex(FILE *stream, dyn_type *type) {
             }
         } else {
             status = DT_MEM_ERROR;
-            DT_LOG(DT_LOG_ERROR, "Error allocating memory for type")
+            LOG_ERROR("Error allocating memory for type")
         }
     }
 
@@ -243,7 +229,7 @@ static int dynType_parseName(FILE *stream, char **result) {
         ungetc(c, stream);
     } else {
         status = DT_ERROR;
-        DT_LOG(DT_LOG_ERROR, "Error creating mem stream for name. %s", strerror(errno));
+        LOG_ERROR("Error creating mem stream for name. %s", strerror(errno));
     }
 
     return status;
@@ -270,7 +256,7 @@ static int dynType_parseNestedType(FILE *stream, dyn_type *type) {
         int c = fgetc(stream);
         if (c != '=') {
             status = DT_PARSE_ERROR;
-            DT_LOG(DT_LOG_ERROR, "Error parsing nested type expected '=' got '%c'", c);
+            LOG_ERROR("Error parsing nested type expected '=' got '%c'", c);
         }
     }
 
@@ -279,7 +265,7 @@ static int dynType_parseNestedType(FILE *stream, dyn_type *type) {
         int c = fgetc(stream);
         if (c != ';') {
             status = DT_PARSE_ERROR;
-            DT_LOG(DT_LOG_ERROR, "Expected ';' got '%c'\n", c);
+            LOG_ERROR("Expected ';' got '%c'\n", c);
         }
     }
 
@@ -304,7 +290,7 @@ static int dynType_parseReference(FILE *stream, dyn_type *type) {
         status = dynType_parseRefByValue(stream, subType);
     } else {
         status = DT_MEM_ERROR;
-        DT_LOG(DT_LOG_ERROR, "Error allocating memory for subtype\n");
+        LOG_ERROR("Error allocating memory for subtype\n");
     }
 
     return status;
@@ -324,7 +310,7 @@ static int dynType_parseRefByValue(FILE *stream, dyn_type *type) {
             type->ref.ref = ref;
         } else {
             status = DT_PARSE_ERROR;
-            DT_LOG(DT_LOG_ERROR, "Error cannot find type '%s'", name);
+            LOG_ERROR("Error cannot find type '%s'", name);
         }
     } 
 
@@ -332,7 +318,7 @@ static int dynType_parseRefByValue(FILE *stream, dyn_type *type) {
         int c = fgetc(stream);
         if (c != ';') {
             status = DT_PARSE_ERROR;
-            DT_LOG(DT_LOG_ERROR, "Error expected ';' got '%c'", c);
+            LOG_ERROR("Error expected ';' got '%c'", c);
         } 
     }
 
@@ -366,7 +352,7 @@ static int dynType_parseSimple(int c, dyn_type *type) {
         type->ffiType = ffiType;
     } else {
         status = DT_PARSE_ERROR;
-        DT_LOG(DT_LOG_ERROR, "Error unsupported type '%c'", c);
+        LOG_ERROR("Error unsupported type '%c'", c);
     }
 
     return status;
@@ -531,11 +517,11 @@ int dynType_sequence_alloc(dyn_type *type, void *inst, int cap, void
**out) {
         } else {
             seq->cap = 0;
             status = DT_MEM_ERROR;
-            DT_LOG(DT_LOG_ERROR, "Error allocating memory for buf")
+            LOG_ERROR("Error allocating memory for buf")
         }
     } else {
             status = DT_MEM_ERROR;
-            DT_LOG(DT_LOG_ERROR, "Error allocating memory for seq")
+            LOG_ERROR("Error allocating memory for seq")
     }
     return status;
 }
@@ -554,7 +540,7 @@ int dynType_sequence_append(dyn_type *type, void *inst, void *in) {
         memcpy(buf + offset, in, elSize);
     } else {
         status = DT_ERROR;
-        DT_LOG(DT_LOG_ERROR, "Sequence out of capacity")
+        LOG_ERROR("Sequence out of capacity")
     }
     return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/dyn_type.h
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/dyn_type.h b/remote_services/dynamic_function_interface/dyn_type.h
index 2a3b445..1641bae 100644
--- a/remote_services/dynamic_function_interface/dyn_type.h
+++ b/remote_services/dynamic_function_interface/dyn_type.h
@@ -11,6 +11,13 @@
 
 #include <ffi.h>
 
+#include "dfi_log_util.h"
+
+#if defined(BSD) || defined(__APPLE__) 
+#include "open_memstream.h"
+#include "fmemopen.h"
+#endif
+
 /* Description string
  *
  * Type = [TypeDef]* (SimpleType | ComplexType | SequenceType | TypedPointer | PointerReference
) [TypeDef]*
@@ -108,7 +115,7 @@ struct nested_entry {
 
 
 //logging
-void dynType_setupLogger(void (*logf)(void *handle, int level, const char *file, int line,
const char *msgFormat, ...), void *handle);
+DFI_SETUP_LOG_HEADER(dynType);
 
 //generic
 int dynType_create(const char *descriptor, dyn_type **type);

http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/memstream/fmemopen.c
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/memstream/fmemopen.c b/remote_services/dynamic_function_interface/memstream/fmemopen.c
new file mode 100644
index 0000000..40c377d
--- /dev/null
+++ b/remote_services/dynamic_function_interface/memstream/fmemopen.c
@@ -0,0 +1,80 @@
+/*
+ * Licensed under Apache License v2. See LICENSE for more information.
+ *
+ * fmem.c : fmemopen() on top of BSD's funopen()
+ * 20081017 AF
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef linux
+struct fmem {
+    size_t pos;
+    size_t size;
+    char *buffer;
+};
+typedef struct fmem fmem_t;
+
+static int readfn(void *handler, char *buf, int size)
+{
+    int count = 0;
+    fmem_t *mem = handler;
+    size_t available = mem->size - mem->pos;
+
+    if(size > available) size = available;
+    for(count=0; count < size; mem->pos++, count++)
+        buf[count] = mem->buffer[mem->pos];
+
+    return count;
+}
+
+static int writefn(void *handler, const char *buf, int size)
+{
+    int count = 0;
+    fmem_t *mem = handler;
+    size_t available = mem->size - mem->pos;
+
+    if(size > available) size = available;
+    for(count=0; count < size; mem->pos++, count++)
+        mem->buffer[mem->pos] = buf[count];
+
+    return count; // ? count : size;
+}
+
+static fpos_t seekfn(void *handler, fpos_t offset, int whence)
+{
+    size_t pos;
+    fmem_t *mem = handler;
+
+    switch(whence) {
+        case SEEK_SET: pos = offset; break;
+        case SEEK_CUR: pos = mem->pos + offset; break;
+        case SEEK_END: pos = mem->size + offset; break;
+        default: return -1;
+    }
+
+    if(pos < 0 || pos > mem->size) return -1;
+
+    mem->pos = pos;
+    return (fpos_t) pos;
+}
+
+static int closefn(void *handler)
+{
+    free(handler);
+    return 0;
+}
+
+/* simple, but portable version of fmemopen for OS X / BSD */
+FILE *fmemopen(void *buf, size_t size, const char *mode)
+{
+    fmem_t *mem = (fmem_t *) malloc(sizeof(fmem_t));
+
+    memset(mem, 0, sizeof(fmem_t));
+    mem->size = size, mem->buffer = buf;
+    return funopen(mem, readfn, writefn, seekfn, closefn);
+}
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/memstream/fmemopen.h
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/memstream/fmemopen.h b/remote_services/dynamic_function_interface/memstream/fmemopen.h
new file mode 100644
index 0000000..3d06b20
--- /dev/null
+++ b/remote_services/dynamic_function_interface/memstream/fmemopen.h
@@ -0,0 +1,52 @@
+//
+// Copyright 2012 Jeff Verkoeyen
+// Originally ported from https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef FMEMOPEN_H_
+#define FMEMOPEN_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * A BSD port of the fmemopen Linux method using funopen.
+ *
+ * man docs for fmemopen:
+ * http://linux.die.net/man/3/fmemopen
+ *
+ * man docs for funopen:
+ * https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/funopen.3.html
+ *
+ * This method is ported from ingenuitas' python-tesseract project.
+ *
+ * You must call fclose on the returned file pointer or memory will be leaked.
+ *
+ *      @param buf The data that will be used to back the FILE* methods. Must be at least
+ *                 @c size bytes.
+ *      @param size The size of the @c buf data.
+ *      @param mode The permitted stream operation modes.
+ *      @returns A pointer that can be used in the fread/fwrite/fseek/fclose family of methods.
+ *               If a failure occurred NULL will be returned.
+ */
+FILE *fmemopen(void *buf, size_t size, const char *mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef FMEMOPEN_H_

http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/memstream/open_memstream.c
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/memstream/open_memstream.c b/remote_services/dynamic_function_interface/memstream/open_memstream.c
new file mode 100644
index 0000000..20bb93f
--- /dev/null
+++ b/remote_services/dynamic_function_interface/memstream/open_memstream.c
@@ -0,0 +1,134 @@
+/*
+ * Licensed under Apache License v2. See LICENSE for more information.
+ *
+ * Use funopen(3) to provide open_memstream(3) like functionality. 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+struct memstream {
+	char **cp;
+	size_t *lenp;
+	size_t offset;
+};
+
+static void
+memstream_grow(struct memstream *ms, size_t newsize)
+{
+	char *buf;
+
+	if (newsize > *ms->lenp) {
+		buf = realloc(*ms->cp, newsize + 1);
+		if (buf != NULL) {
+#ifdef DEBUG
+			fprintf(stderr, "MS: %p growing from %zd to %zd\n",
+			    ms, *ms->lenp, newsize);
+#endif
+			memset(buf + *ms->lenp + 1, 0, newsize - *ms->lenp);
+			*ms->cp = buf;
+			*ms->lenp = newsize;
+		}
+	}
+}
+
+static int
+memstream_read(void *cookie, char *buf, int len)
+{
+	struct memstream *ms;
+	int tocopy;
+
+	ms = cookie;
+	memstream_grow(ms, ms->offset + len);
+	tocopy = *ms->lenp - ms->offset;
+	if (len < tocopy)
+		tocopy = len;
+	memcpy(buf, *ms->cp + ms->offset, tocopy);
+	ms->offset += tocopy;
+#ifdef DEBUG
+	fprintf(stderr, "MS: read(%p, %d) = %d\n", ms, len, tocopy);
+#endif
+	return (tocopy);
+}
+
+static int
+memstream_write(void *cookie, const char *buf, int len)
+{
+	struct memstream *ms;
+	int tocopy;
+
+	ms = cookie;
+	memstream_grow(ms, ms->offset + len);
+	tocopy = *ms->lenp - ms->offset;
+	if (len < tocopy)
+		tocopy = len;
+	memcpy(*ms->cp + ms->offset, buf, tocopy);
+	ms->offset += tocopy;
+#ifdef DEBUG
+	fprintf(stderr, "MS: write(%p, %d) = %d\n", ms, len, tocopy);
+#endif
+	return (tocopy);
+}
+
+static fpos_t
+memstream_seek(void *cookie, fpos_t pos, int whence)
+{
+	struct memstream *ms;
+#ifdef DEBUG
+	size_t old;
+#endif
+
+	ms = cookie;
+#ifdef DEBUG
+	old = ms->offset;
+#endif
+	switch (whence) {
+	case SEEK_SET:
+		ms->offset = pos;
+		break;
+	case SEEK_CUR:
+		ms->offset += pos;
+		break;
+	case SEEK_END:
+		ms->offset = *ms->lenp + pos;
+		break;
+	}
+#ifdef DEBUG
+	fprintf(stderr, "MS: seek(%p, %zd, %d) %zd -> %zd\n", ms, pos, whence,
+	    old, ms->offset);
+#endif
+	return (ms->offset);
+}
+
+static int
+memstream_close(void *cookie)
+{
+
+	free(cookie);
+	return (0);
+}
+
+FILE *
+open_memstream(char **cp, size_t *lenp)
+{
+	struct memstream *ms;
+	int save_errno;
+	FILE *fp;
+
+	*cp = NULL;
+	*lenp = 0;
+	ms = malloc(sizeof(*ms));
+	ms->cp = cp;
+	ms->lenp = lenp;
+	ms->offset = 0;
+	fp = funopen(ms, memstream_read, memstream_write, memstream_seek,
+	    memstream_close);
+	if (fp == NULL) {
+		save_errno = errno;
+		free(ms);
+		errno = save_errno;
+	}
+	return (fp);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/memstream/open_memstream.h
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/memstream/open_memstream.h b/remote_services/dynamic_function_interface/memstream/open_memstream.h
new file mode 100644
index 0000000..2a38e12
--- /dev/null
+++ b/remote_services/dynamic_function_interface/memstream/open_memstream.h
@@ -0,0 +1,19 @@
+/*
+ * Licensed under Apache License v2. See LICENSE for more information.
+ *
+ */
+#ifndef OPEN_MEMSTREAM_H_
+#define OPEN_MEMSTREAM_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+FILE *open_memstream(char **cp, size_t *lenp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef FMEMOPEN_H_

http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/tst/avro_descriptor_translator_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/tst/avro_descriptor_translator_tests.cpp
b/remote_services/dynamic_function_interface/tst/avro_descriptor_translator_tests.cpp
index 4a63c16..32ba044 100644
--- a/remote_services/dynamic_function_interface/tst/avro_descriptor_translator_tests.cpp
+++ b/remote_services/dynamic_function_interface/tst/avro_descriptor_translator_tests.cpp
@@ -12,6 +12,11 @@ extern "C" {
 
 #include "descriptor_translator.h"
 
+#if defined(BSD) || defined(__APPLE__) 
+#include "open_memstream.h"
+#include "fmemopen.h"
+#endif
+
 void test1(void) {
     //TODO split up
     size_t size = 0;

http://git-wip-us.apache.org/repos/asf/celix/blob/fd7662c2/remote_services/dynamic_function_interface/tst/dyn_type_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/tst/dyn_type_tests.cpp b/remote_services/dynamic_function_interface/tst/dyn_type_tests.cpp
index 07c419b..7ea9ea7 100644
--- a/remote_services/dynamic_function_interface/tst/dyn_type_tests.cpp
+++ b/remote_services/dynamic_function_interface/tst/dyn_type_tests.cpp
@@ -10,7 +10,16 @@ extern "C" {
     
     #include "dyn_type.h"
 
-    void runTest(const char *descriptorStr, const char *exName) {
+	static void stdLog(void *handle, int level, const char *file, int line, const char *msg,
...) {
+	    va_list ap;
+	    const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
+	    fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
+	    va_start(ap, msg);
+	    vfprintf(stderr, msg, ap);
+	    fprintf(stderr, "\n");
+	}
+
+    static void runTest(const char *descriptorStr, const char *exName) {
         dyn_type *type;
         int i;
         type = NULL;
@@ -26,6 +35,9 @@ extern "C" {
 }
 
 TEST_GROUP(DynTypeTests) {
+	void setup() {
+	    dynType_logSetup(stdLog, NULL, 4);
+	}
 };
 
 #define EX1 "{BbJjIiSsDFNN arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 arg10 arg11 arg12}"
@@ -101,29 +113,6 @@ TEST(DynTypeTests, ParseRandomGarbageTest) {
     }
 }
 
-extern "C" {
-    static int logCount = 0;
-    static void logf_test(void *handle, int level, const char *file, int line, const char
*msg, ...) {
-        logCount += 1;
-        
-        /*
-        va_list ap;
-        const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
-        printf("%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
-        va_start(ap, msg);
-        vprintf(msg, ap);
-        printf("\n");
-        */
-    }
-}
-
-TEST(DynTypeTests, DynTypeLoggerTest) {
-    dyn_type *type = NULL;
-    dynType_setupLogger(logf_test, NULL);
-    dynType_create("*", &type);
-    CHECK_EQUAL(1, logCount);
-}
-
 TEST(DynTypeTests, AssignTest1) {
     struct ex1 {
         int32_t a;


Mime
View raw message