celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [04/10] celix git commit: CELIX-237: Moved dynamic function interface under remote_service_admin_dfi
Date Fri, 31 Jul 2015 20:57:33 GMT
http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/json_serializer.c
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/json_serializer.c b/remote_services/dynamic_function_interface/json_serializer.c
deleted file mode 100644
index 614e948..0000000
--- a/remote_services/dynamic_function_interface/json_serializer.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Licensed under Apache License v2. See LICENSE for more information.
- */
-#include "json_serializer.h"
-#include "dyn_type.h"
-
-#include <jansson.h>
-#include <assert.h>
-#include <stdint.h>
-#include <string.h>
-
-static int jsonSerializer_createObject(dyn_type *type, json_t *object, void **result);
-static int jsonSerializer_parseObject(dyn_type *type, json_t *object, void *inst);
-static int jsonSerializer_parseObjectMember(dyn_type *type, const char *name, json_t *val, void *inst);
-static int jsonSerializer_parseSequence(dyn_type *seq, json_t *array, void *seqLoc);
-static int jsonSerializer_parseAny(dyn_type *type, void *input, json_t *val);
-
-static int jsonSerializer_writeAny(dyn_type *type, void *input, json_t **val);
-
-static int jsonSerializer_writeComplex(dyn_type *type, void *input, json_t **val);
-
-static int jsonSerializer_writeSequence(dyn_type *type, void *input, json_t **out);
-
-static int OK = 0;
-static int ERROR = 1;
-
-DFI_SETUP_LOG(jsonSerializer);
-
-int jsonSerializer_deserialize(dyn_type *type, const char *input, void **result) {
-    assert(dynType_type(type) == DYN_TYPE_COMPLEX);
-    int status = 0;
-
-    json_error_t error;
-    json_t *root = json_loads(input, JSON_DECODE_ANY, &error);
-
-    if (root != NULL) {
-        if (json_is_object(root)) {
-            status = jsonSerializer_createObject(type, root, result);
-        } else {
-            status = ERROR;
-            LOG_ERROR("Error expected root element to be an object");
-        }
-        json_decref(root);
-    } else {
-        status = ERROR;
-        LOG_ERROR("Error parsing json input '%s'. Error is %s\n", input, error.text);
-    }
-
-    return status;
-}
-
-static int jsonSerializer_createObject(dyn_type *type, json_t *object, void **result) {
-    assert(object != NULL);
-    int status = OK;
-
-    void *inst = NULL;
-    status = dynType_alloc(type, &inst);
-
-    if (status == OK) {
-        assert(inst != NULL);
-        status = jsonSerializer_parseObject(type, object, inst);
-
-        if (status != OK) {
-            dynType_free(type, inst);
-        }
-    }
-
-    if (status == OK) {
-        *result = inst;
-    }
-
-    return status;
-}
-
-static int jsonSerializer_parseObject(dyn_type *type, json_t *object, void *inst) {
-    assert(object != NULL);
-    int status = 0;
-    json_t *value;
-    const char *key;
-
-    json_object_foreach(object, key, value) {
-        status = jsonSerializer_parseObjectMember(type, key, value, inst);
-        if (status != OK) {
-            break;
-        }
-    }
-
-    return status;
-}
-
-static int jsonSerializer_parseObjectMember(dyn_type *type, const char *name, json_t *val, void *inst) {
-    int status = OK;
-    int index = dynType_complex_indexForName(type, name);
-    void *valp = NULL;
-    dyn_type *valType = NULL;
-
-    status = dynType_complex_valLocAt(type, index, inst, &valp);
-
-    if (status == OK ) {
-        status = dynType_complex_dynTypeAt(type, index, &valType);
-    }
-
-    if (status == OK) {
-        status = jsonSerializer_parseAny(valType, valp, val);
-    }
-
-    return status;
-}
-
-static int jsonSerializer_parseAny(dyn_type *type, void *loc, json_t *val) {
-    int status = OK;
-
-    dyn_type *subType = NULL;
-    char c = dynType_descriptorType(type);
-
-    float *f;           //F
-    double *d;          //D
-    char *b;            //B
-    int *n;             //N
-    int16_t *s;         //S
-    int32_t *i;         //I
-    int64_t *l;         //J
-    uint16_t  *us;      //s
-    uint32_t  *ui;      //i
-    uint64_t  *ul;      //j
-
-    switch (c) {
-        case 'F' :
-            f = loc;
-            *f = (float) json_real_value(val);
-            break;
-        case 'D' :
-            d = loc;
-            *d = json_real_value(val);
-            break;
-        case 'N' :
-            n = loc;
-            *n = (int) json_real_value(val);
-            break;
-        case 'B' :
-            b = loc;
-            *b = (char) json_integer_value(val);
-            break;
-        case 'S' :
-            s = loc;
-            *s = (int16_t) json_integer_value(val);
-            break;
-        case 'I' :
-            i = loc;
-            *i = (int32_t) json_integer_value(val);
-            break;
-        case 'J' :
-            l = loc;
-            *l = (int64_t) json_integer_value(val);
-            break;
-        case 's' :
-            us = loc;
-            *us = (uint16_t) json_integer_value(val);
-            break;
-        case 'i' :
-            ui = loc;
-            *ui = (uint32_t) json_integer_value(val);
-            break;
-        case 'j' :
-            ul = loc;
-            *ul = (uint64_t) json_integer_value(val);
-            break;
-        case 't' :
-            if (json_is_string(val)) {
-                dynType_text_allocAndInit(type, loc, json_string_value(val));
-            } else {
-                status = ERROR;
-                LOG_ERROR("Expected json string type got %i", json_typeof(val));
-            }
-            break;
-        case '[' :
-            if (json_is_array(val)) {
-                status = jsonSerializer_parseSequence(type, val, loc);
-            } else {
-                status = ERROR;
-                LOG_ERROR("Expected json array type got '%i'", json_typeof(val));
-            }
-            break;
-        case '{' :
-            if (status == OK) {
-                status = jsonSerializer_parseObject(type, val, loc);
-            }
-            break;
-        case '*' :
-            status = dynType_typedPointer_getTypedType(type, &subType);
-            if (status == OK) {
-                status = jsonSerializer_createObject(subType, val, (void **)loc);
-            }
-            break;
-        case 'P' :
-            status = ERROR;
-            LOG_WARNING("Untyped pointer are not supported for serialization");
-            break;
-        default :
-            status = ERROR;
-            LOG_ERROR("Error provided type '%c' not supported for JSON\n", dynType_descriptorType(type));
-            break;
-    }
-
-    return status;
-}
-
-static int jsonSerializer_parseSequence(dyn_type *seq, json_t *array, void *seqLoc) {
-    assert(dynType_type(seq) == DYN_TYPE_SEQUENCE);
-    int status = OK;
-
-    size_t size = json_array_size(array);
-    LOG_DEBUG("Allocating sequence with capacity %zu", size);
-    status = dynType_sequence_alloc(seq, seqLoc, (int) size);
-
-    if (status == OK) {
-        dyn_type *itemType = dynType_sequence_itemType(seq);
-        size_t index;
-        json_t *val;
-        json_array_foreach(array, index, val) {
-            void *valLoc = NULL;
-            status = dynType_sequence_increaseLengthAndReturnLastLoc(seq, seqLoc, &valLoc);
-            LOG_DEBUG("Got sequence loc %p", valLoc);
-
-            if (status == OK) {
-                status = jsonSerializer_parseAny(itemType, valLoc, val);
-                if (status != OK) {
-                    break;
-                }
-            }
-        }
-    }
-
-    return status;
-}
-
-int jsonSerializer_serialize(dyn_type *type, void *input, char **output) {
-    int status = OK;
-
-    json_t *root = NULL;
-    status = jsonSerializer_writeAny(type, input, &root);
-
-    if (status == OK) {
-        *output = json_dumps(root, JSON_COMPACT);
-        json_decref(root);
-    }
-
-    return status;
-}
-
-static int jsonSerializer_writeAny(dyn_type *type, void *input, json_t **out) {
-    int status = OK;
-
-    int descriptor = dynType_descriptorType(type);
-    json_t *val = NULL;
-    dyn_type *subType = NULL;
-
-    float *f;           //F
-    double *d;          //D
-    char *b;            //B
-    int *n;             //N
-    int16_t *s;         //S
-    int32_t *i;         //I
-    int64_t *l;         //J
-    uint16_t  *us;      //s
-    uint32_t  *ui;      //i
-    uint64_t  *ul;      //j
-
-    switch (descriptor) {
-        case 'B' :
-            b = input;
-            val = json_integer((json_int_t)*b);
-            break;
-        case 'S' :
-            s = input;
-            val = json_integer((json_int_t)*s);
-            break;
-        case 'I' :
-            i = input;
-            val = json_integer((json_int_t)*i);
-            break;
-        case 'J' :
-            l = input;
-            val = json_integer((json_int_t)*l);
-            break;
-        case 's' :
-            us = input;
-            val = json_integer((json_int_t)*us);
-            break;
-        case 'i' :
-            ui = input;
-            val = json_integer((json_int_t)*ui);
-            break;
-        case 'j' :
-            ul = input;
-            val = json_integer((json_int_t)*ul);
-            break;
-        case 'N' :
-            n = input;
-            val = json_integer((json_int_t)*n);
-            break;
-        case 'F' :
-            f = input;
-            val = json_real((double) *f);
-            break;
-        case 'D' :
-            d = input;
-            val = json_real(*d);
-            break;
-        case 't' :
-            val = json_string(*(const char **) input);
-            break;
-        case '*' :
-            status = dynType_typedPointer_getTypedType(type, &subType);
-            if (status == OK) {
-                status = jsonSerializer_writeAny(subType, *(void **)input, &val);
-            }
-            break;
-        case '{' :
-            status = jsonSerializer_writeComplex(type, input, &val);
-            break;
-        case '[' :
-            status = jsonSerializer_writeSequence(type, input, &val);
-            break;
-        case 'P' :
-            LOG_WARNING("Untyped pointer not supported for serialization. ignoring");
-            break;
-        default :
-            LOG_ERROR("Unsupported descriptor '%c'", descriptor);
-            status = ERROR;
-            break;
-    }
-
-    if (status == OK && val != NULL) {
-        *out = val;
-    }
-
-    return status;
-}
-
-static int jsonSerializer_writeSequence(dyn_type *type, void *input, json_t **out) {
-    assert(dynType_type(type) == DYN_TYPE_SEQUENCE);
-    int status = OK;
-
-    json_t *array = json_array();
-    dyn_type *itemType = dynType_sequence_itemType(type);
-    uint32_t len = dynType_sequence_length(input);
-
-    int i = 0;
-    void *itemLoc = NULL;
-    json_t *item = NULL;
-    for (i = 0; i < len; i += 1) {
-        item = NULL;
-        status = dynType_sequence_locForIndex(type, input, i, &itemLoc);
-        if (status == OK) {
-            status = jsonSerializer_writeAny(itemType, itemLoc, &item);
-            if (status == OK) {
-                json_array_append(array, item);
-                json_decref(item);
-            }
-        }
-
-        if (status != OK) {
-            break;
-        }
-    }
-
-    if (status == OK && array != NULL) {
-        *out = array;
-    }
-
-    return status;
-}
-
-static int jsonSerializer_writeComplex(dyn_type *type, void *input, json_t **out) {
-    assert(dynType_type(type) == DYN_TYPE_COMPLEX);
-    int status = OK;
-
-    json_t *val = json_object();
-    struct complex_type_entry *entry = NULL;
-    struct complex_type_entries_head *entries = NULL;
-    int index = -1;
-
-    status = dynType_complex_entries(type, &entries);
-    if (status == OK) {
-        TAILQ_FOREACH(entry, entries, entries) {
-            void *subLoc = NULL;
-            json_t *subVal = NULL;
-            dyn_type *subType = NULL;
-            index = dynType_complex_indexForName(type, entry->name);
-            status = dynType_complex_valLocAt(type, index, input, &subLoc);
-            if (status == OK ) {
-                status = dynType_complex_dynTypeAt(type, index, &subType);
-            }
-            if (status == OK) {
-                status = jsonSerializer_writeAny(subType, subLoc, &subVal);
-            }
-            if (status == OK) {
-                json_object_set(val, entry->name, subVal);
-                json_decref(subVal);
-            }
-
-            if (status != OK) {
-                break;
-            }
-        }
-    }
-
-    if (status == OK && val != NULL) {
-        *out = val;
-    }
-
-    return status;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/json_serializer.h
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/json_serializer.h b/remote_services/dynamic_function_interface/json_serializer.h
deleted file mode 100644
index eb2e629..0000000
--- a/remote_services/dynamic_function_interface/json_serializer.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Licensed under Apache License v2. See LICENSE for more information.
- */
-#ifndef __JSON_SERIALIZER_H_
-#define __JSON_SERIALIZER_H_
-
-#include "dfi_log_util.h"
-#include "dyn_type.h"
-
-//logging
-DFI_SETUP_LOG_HEADER(jsonSerializer);
-
-int jsonSerializer_deserialize(dyn_type *type, const char *input, void **result);
-int jsonSerializer_serialize(dyn_type *type, void *input, char **output);
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/memstream/README.md
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/memstream/README.md b/remote_services/dynamic_function_interface/memstream/README.md
deleted file mode 100644
index 476810e..0000000
--- a/remote_services/dynamic_function_interface/memstream/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-fmemopen for Mac OS and iOS
-===========================
-
-Originally ported from [ingenuitas python-tesseract](https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c). Ported by Jeff Verkoeyen under the Apache 2.0 License.
-
-From the fmemopen man page:
-
-> FILE *fmemopen(void *buf, size_t size, const char *mode);
->
-> The fmemopen() function opens a stream that permits the access specified by mode. The stream
-> allows I/O to be performed on the string or memory buffer pointed to by buf. This buffer must be
-> at least size bytes long.
-
-Alas, this method does not exist on BSD operating systems (specifically Mac OS X and iOS). It is
-possible to recreate this functionality using a BSD-specific method called `funopen`.
-
-From the funopen man page:
-
-> FILE * funopen(const void *cookie, int (*readfn)(void *, char *, int),
->                int (*writefn)(void *, const char *, int), fpos_t (*seekfn)(void *, fpos_t, int),
->                int (*closefn)(void *));
->
-> The funopen() function associates a stream with up to four ``I/O functions''.  Either readfn or
-> writefn must be specified; the others can be given as an appropriately-typed NULL pointer.  These
-> I/O functions will be used to read, write, seek and close the new stream.
-
-fmemopen.c provides a simple implementation of fmemopen using funopen so that you can create FILE
-pointers to blocks of memory.
-
-Adding it to your Project
-=========================
-
-Drag fmemopen.h and fmemopen.c to your project and add them to your target. `#include "fmemopen.h"`
-wherever you need to use `fmemopen`.
-
-Examples
-========
-
-```obj-c
-#import "fmemopen.h"
-
-NSString* string = @"fmemopen in Objective-C";
-const char* cstr = [string UTF8String];
-FILE* file = fmemopen((void *)cstr, sizeof(char) * (string.length + 1), "r");
-
-// fread on file will now read the contents of the NSString
-
-fclose(file);
-```

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/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
deleted file mode 100644
index 926ce36..0000000
--- a/remote_services/dynamic_function_interface/memstream/fmemopen.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/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
deleted file mode 100644
index 3d06b20..0000000
--- a/remote_services/dynamic_function_interface/memstream/fmemopen.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// 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/bf76d213/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
deleted file mode 100644
index 6bc4f01..0000000
--- a/remote_services/dynamic_function_interface/memstream/open_memstream.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* 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);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/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
deleted file mode 100644
index e87bb0a..0000000
--- a/remote_services/dynamic_function_interface/memstream/open_memstream.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#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/bf76d213/remote_services/dynamic_function_interface/schemas/complex.avdl
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/schemas/complex.avdl b/remote_services/dynamic_function_interface/schemas/complex.avdl
deleted file mode 100644
index 0490dcd..0000000
--- a/remote_services/dynamic_function_interface/schemas/complex.avdl
+++ /dev/null
@@ -1,11 +0,0 @@
-protocol Complex {
-
-  record StatResult {
-    double sum;
-    double min;
-    double max;
-    array<double> input;
-  }
-
-  StatResult stats(array<double> input);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/schemas/complex.avpr
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/schemas/complex.avpr b/remote_services/dynamic_function_interface/schemas/complex.avpr
deleted file mode 100644
index 0577397..0000000
--- a/remote_services/dynamic_function_interface/schemas/complex.avpr
+++ /dev/null
@@ -1,36 +0,0 @@
-{
-  "protocol" : "Complex",
-  "namespace" : null,
-  "types" : [ {
-    "type" : "record",
-    "name" : "StatResult",
-    "fields" : [ {
-      "name" : "sum",
-      "type" : "double"
-    }, {
-      "name" : "min",
-      "type" : "double"
-    }, {
-      "name" : "max",
-      "type" : "double"
-    }, {
-      "name" : "input",
-      "type" : {
-        "type" : "array",
-        "items" : "double"
-      }
-    } ]
-  } ],
-  "messages" : {
-    "stats" : {
-      "request" : [ {
-        "name" : "input",
-        "type" : {
-          "type" : "array",
-          "items" : "double"
-        }
-      } ],
-      "response" : "StatResult"
-    }
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/schemas/invalid1.avpr
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/schemas/invalid1.avpr b/remote_services/dynamic_function_interface/schemas/invalid1.avpr
deleted file mode 100644
index c968c61..0000000
--- a/remote_services/dynamic_function_interface/schemas/invalid1.avpr
+++ /dev/null
@@ -1,29 +0,0 @@
-{
-  "protocol" : "Complex",
-  "namespace" : null,
-  "types" : [ {
-    "type" : "record",
-    "name" : "StatResult",
-    "fields" : [ {
-      "name" : "sum",
-      "type" : "double"
-    }, {
-      "name" : "min",
-      "type" : "double"
-    }, {
-      "name" : "max",
-      "type" : "double"
-    }, {
-      "name" : "input",
-      "type" : {
-        "type" : "array",
-        "items" : "double"
-      }
-    } ]
-  } ],
-  "messages" : {
-    "stats" : {
-      "response" : "StatResult"
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/schemas/invalid2.avpr
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/schemas/invalid2.avpr b/remote_services/dynamic_function_interface/schemas/invalid2.avpr
deleted file mode 100644
index fc48ca9..0000000
--- a/remote_services/dynamic_function_interface/schemas/invalid2.avpr
+++ /dev/null
@@ -1,31 +0,0 @@
-{
-  "protocol" : "Simple",
-  "types" : [ ],
-  "messages" : {
-    "sum" : {
-      "request" : [ {
-        "name" : "a"
-      }, {
-        "name" : "b",
-        "type" : "double"
-      } ],
-      "response" : "double"
-    },
-    "sub" : {
-      "request" : [ {
-        "name" : "a",
-        "type" : "double"
-      }, {
-        "name" : "b",
-        "type" : "double"
-      } ],
-      "response" : "double"
-    },
-    "sqrt" : {
-      "request" : [ {
-        "name" : "a"
-      } ],
-      "response" : "double"
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/schemas/simple.avdl
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/schemas/simple.avdl b/remote_services/dynamic_function_interface/schemas/simple.avdl
deleted file mode 100644
index cd5cafe..0000000
--- a/remote_services/dynamic_function_interface/schemas/simple.avdl
+++ /dev/null
@@ -1,6 +0,0 @@
-@namespace("org.apache.avro.test")
-protocol Simple {
-  double sum(double a, double b);
-  double sub(double a, double b);
-  double sqrt(double a);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/schemas/simple.avpr
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/schemas/simple.avpr b/remote_services/dynamic_function_interface/schemas/simple.avpr
deleted file mode 100644
index 8a90bb2..0000000
--- a/remote_services/dynamic_function_interface/schemas/simple.avpr
+++ /dev/null
@@ -1,33 +0,0 @@
-{
-  "protocol" : "Simple",
-  "types" : [ ],
-  "messages" : {
-    "sum" : {
-      "request" : [ {
-        "name" : "a",
-        "type" : "double"
-      }, {
-        "name" : "b",
-        "type" : "double"
-      } ],
-      "response" : "double"
-    },
-    "sub" : {
-      "request" : [ {
-        "name" : "a",
-        "type" : "double"
-      }, {
-        "name" : "b",
-        "type" : "double"
-      } ],
-      "response" : "double"
-    },
-    "sqrt" : {
-      "request" : [ {
-        "name" : "a",
-        "type" : "double"
-      } ],
-      "response" : "double"
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/schemas/simple_min.avpr
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/schemas/simple_min.avpr b/remote_services/dynamic_function_interface/schemas/simple_min.avpr
deleted file mode 100644
index c2bce19..0000000
--- a/remote_services/dynamic_function_interface/schemas/simple_min.avpr
+++ /dev/null
@@ -1 +0,0 @@
-{"protocol":"Simple","types":[],"messages":{"sum":{"request":[{"name":"a","type":"double"},{"name":"b","type":"double"}],"response":"double"},"sub":{"request":[{"name":"a","type":"double"},{"name":"b","type":"double"}],"response":"double"},"sqrt":{"request":[{"name":"a","type":"double"}],"response":"double"}}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/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
deleted file mode 100644
index 63401e5..0000000
--- a/remote_services/dynamic_function_interface/tst/avro_descriptor_translator_tests.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * Licensed under Apache License v2. See LICENSE for more information.
- */
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
-
-extern "C" {
-
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-
-#include "dyn_common.h"
-#include "descriptor_translator.h"
-
-#if defined(BSD) || defined(__APPLE__) 
-#include "open_memstream.h"
-#include "fmemopen.h"
-#endif
-
-    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 char *readSchema(const char *file) {
-        size_t size = 0;
-        char *ptr = NULL;
-
-        FILE *schema = fopen(file, "r");
-        FILE *stream = open_memstream(&ptr, &size);
-
-        assert(schema != NULL);
-        assert(stream != NULL);
-
-        int c = fgetc(schema);
-        while (c != EOF ) {
-            fputc(c, stream);
-            c = fgetc(schema);
-        }
-        fclose(schema);
-        fclose(stream);
-
-        assert(ptr != NULL);
-        return ptr;
-    }
-
-    static dyn_interface_type *createInterfaceInfo(const char *schemaFile) {
-        char *schema = readSchema(schemaFile);
-        dyn_interface_type *ift= NULL;
-
-        int status = descriptorTranslator_translate(schema, &ift);
-        CHECK_EQUAL(0, status);
-
-        free(schema);
-        return ift;
-    }
-
-    static int countMethodInfos(dyn_interface_type *info) {
-        int count = 0;
-        method_info_type *mInfo = NULL;
-        TAILQ_FOREACH(mInfo, &info->methodInfos, entries) {
-            count +=1;
-        }
-        return count;
-    }
-
-    static int countTypeInfos(dyn_interface_type *info) {
-        int count = 0;
-        type_info_type *tInfo = NULL;
-        TAILQ_FOREACH(tInfo, &info->typeInfos, entries) {
-            count +=1;
-        }
-        return count;
-    }
-
-    static void simple(void) {
-        //first argument void *handle, last argument output pointer for result and return int with status for exception handling
-        //sum(DD)D -> sum(PDD*D)N 
-        //sub(DD)D -> sub(PDD*D)N
-        //sqrt(D)D -> sqrt(PD*D)N
-
-        dyn_interface_type *intf = createInterfaceInfo("schemas/simple.avpr");
-
-        int count = countMethodInfos(intf);
-        CHECK_EQUAL(3, count);
-
-        count = countTypeInfos(intf);
-        CHECK_EQUAL(0, count);
-
-        method_info_type *mInfo = NULL;
-        TAILQ_FOREACH(mInfo, &intf->methodInfos, entries) {
-            if (strcmp("sum", mInfo->name) == 0) {
-                STRCMP_EQUAL("sum(PDD*D)N", mInfo->descriptor);
-            } else if (strcmp("add", mInfo->name) == 0) {
-                STRCMP_EQUAL("add(PDD*D)N", mInfo->descriptor);
-            } else if (strcmp("sqrt", mInfo->name) == 0) {
-                STRCMP_EQUAL("sqrt(PD*D)N", mInfo->descriptor);
-            }
-        }
-
-        dynInterface_destroy(intf);
-    }
-
-    static void complex(void) {
-        dyn_interface_type *intf = createInterfaceInfo("schemas/complex.avpr");
-
-        int count = countMethodInfos(intf);
-        CHECK_EQUAL(1, count);
-
-        method_info_type *mInfo = TAILQ_FIRST(&intf->methodInfos);
-        STRCMP_EQUAL("stats", mInfo->name);
-        STRCMP_EQUAL("stats(P[D*LStatResult;)N", mInfo->descriptor);
-
-        count = countTypeInfos(intf);
-        CHECK_EQUAL(1, count);
-
-        type_info_type *tInfo = TAILQ_FIRST(&intf->typeInfos);
-        STRCMP_EQUAL("StatResult", tInfo->name);
-        STRCMP_EQUAL("{DDD[D sum min max input}", tInfo->descriptor);
-
-        dynInterface_destroy(intf);
-    }
-
-    static void invalid(const char *file) {
-        char *schema = readSchema(file);
-        dyn_interface_type *ift= NULL;
-
-        int status = descriptorTranslator_translate(schema, &ift);
-        CHECK(status != 0);
-        
-        free(schema);
-    }
-}
-
-TEST_GROUP(AvroDescTranslatorTest) {
-    void setup() {
-        descriptorTranslator_logSetup(stdLog, NULL, 3);
-        dynInterface_logSetup(stdLog, NULL, 3);
-        dynType_logSetup(stdLog, NULL, 3);
-        dynCommon_logSetup(stdLog, NULL, 3);
-    }
-};
-
-TEST(AvroDescTranslatorTest, simple) {
-    simple();
-}
-
-TEST(AvroDescTranslatorTest, complex) {
-    complex();
-}
-
-TEST(AvroDescTranslatorTest, invalid1) {
-    invalid("schemas/invalid1.avpr");
-}
-
-TEST(AvroDescTranslatorTest, invalid2) {
-    invalid("schemas/invalid2.avpr");
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/tst/dyn_closure_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/tst/dyn_closure_tests.cpp b/remote_services/dynamic_function_interface/tst/dyn_closure_tests.cpp
deleted file mode 100644
index b2b11d7..0000000
--- a/remote_services/dynamic_function_interface/tst/dyn_closure_tests.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed under Apache License v2. See LICENSE for more information.
- */
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
-
-extern "C" {
-    
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "dyn_common.h"
-#include "dyn_function.h"
-
-static int g_count;
-
-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");
-}
-
-#define EXAMPLE1_DESCRIPTOR "example(III)I"
-static void example1_binding(void *userData, void* args[], void *out) {
-    int32_t a = *((int32_t *)args[0]);
-    int32_t b = *((int32_t *)args[1]);
-    int32_t c = *((int32_t *)args[2]);
-    int32_t *ret = (int32_t *)out;
-    *ret = a + b + c;
-    g_count += 1;
-}
-
-#define EXAMPLE2_DESCRIPTOR "example(I{DDD val1 val2 val3}I)D"
-struct example2_arg2 {
-    double val1;
-    double val2;
-    double val3;
-};
-void example2_binding(void *userData, void* args[], void *out) {
-    int32_t a = *((int32_t *)args[0]);
-    struct example2_arg2 b =  *((struct example2_arg2 *)args[1]);
-    int32_t c = *((int32_t *)args[2]);
-    double *ret = (double *)out;
-    *ret = a + b.val1 + b.val2 + b.val3 + c;
-    g_count += 1;
-}
-
-
-#define EXAMPLE3_DESCRIPTOR "example(III){III sum max min}"
-struct example3_ret {
-    int32_t sum;
-    int32_t max;
-    int32_t min;
-};
-
-static void example3_binding(void *userData, void* args[], void *out) {
-    int32_t a = *((int32_t *)args[0]);
-    int32_t b = *((int32_t *)args[1]);
-    int32_t c = *((int32_t *)args[2]);
-    struct example3_ret *result = (struct example3_ret *)calloc(1,sizeof(struct example3_ret));
-    result->sum = a + b + c;
-    result->min = a <= b ? a : b;
-    result->max = a >= b ? a : b;
-    result->min = result->min <= c ? result->min : c;
-    result->max = result->max >= c ? result->max : c;
-
-    struct example3_ret **ret = (struct example3_ret **)out;
-    (*ret) = result;
-    g_count += 1;
-}
-
-static void tests() {
-    dyn_function_type *dynFunction = NULL;
-    int rc = 0;
-
-    {
-        int32_t (*func)(int32_t a, int32_t b, int32_t c) = NULL;
-        rc = dynFunction_parseWithStr(EXAMPLE1_DESCRIPTOR, NULL, &dynFunction);
-        CHECK_EQUAL(0, rc);
-        rc = dynFunction_createClosure(dynFunction, example1_binding, NULL, (void(**)(void))&func);
-        CHECK_EQUAL(0, rc);
-        int32_t ret = func(2,3,4);
-        CHECK_EQUAL(1, g_count);
-        CHECK_EQUAL(9, ret);
-        dynFunction_destroy(dynFunction);
-    }
-
-    {
-        double (*func)(int32_t a, struct example2_arg2 b, int32_t c) = NULL;
-        double (*func2)(int32_t a, struct example2_arg2 b, int32_t c) = NULL;
-        dynFunction = NULL;
-        rc = dynFunction_parseWithStr(EXAMPLE2_DESCRIPTOR, NULL, &dynFunction);
-        CHECK_EQUAL(0, rc);
-        rc = dynFunction_createClosure(dynFunction, example2_binding, NULL, (void(**)(void))&func);
-        CHECK_EQUAL(0, rc);
-        rc = dynFunction_getFnPointer(dynFunction, (void(**)(void))&func2);
-        CHECK_EQUAL(0, rc);
-        CHECK(func == func2);
-        struct example2_arg2 b;
-        b.val1 = 1.0;
-        b.val2 = 1.5;
-        b.val3 = 2.0;
-        double ret = func(2,b,4);
-        CHECK_EQUAL(2, g_count);
-        CHECK_EQUAL(10.5, ret);
-        dynFunction_destroy(dynFunction);
-    }
-
-    {
-        struct example3_ret * (*func)(int32_t a, int32_t b, int32_t c) = NULL;
-        dynFunction = NULL;
-        rc = dynFunction_parseWithStr(EXAMPLE3_DESCRIPTOR, NULL, &dynFunction);
-        CHECK_EQUAL(0, rc);
-        rc = dynFunction_createClosure(dynFunction, example3_binding, NULL, (void(**)(void))&func);
-        CHECK_EQUAL(0, rc);
-        struct example3_ret *ret = func(2,8,4);
-        CHECK_EQUAL(3, g_count);
-        CHECK_EQUAL(14, ret->sum);
-        dynFunction_destroy(dynFunction);
-        free(ret);
-    }
-}
-
-}
-
-
-TEST_GROUP(DynClosureTests) {
-    void setup() {
-        dynFunction_logSetup(stdLog, NULL, 3);
-        dynType_logSetup(stdLog, NULL, 3);
-        //TODO dynType_logSetup(stdLog, NULL, 4);
-        dynCommon_logSetup(stdLog, NULL, 3);
-        g_count = 0;
-    }
-};
-
-TEST(DynClosureTests, DynCLosureTest1) {
-    //TODO split up
-    tests();
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/tst/dyn_function_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/tst/dyn_function_tests.cpp b/remote_services/dynamic_function_interface/tst/dyn_function_tests.cpp
deleted file mode 100644
index 410b3ec..0000000
--- a/remote_services/dynamic_function_interface/tst/dyn_function_tests.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed under Apache License v2. See LICENSE for more information.
- */
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
-
-extern "C" {
-    #include <stdio.h>
-    #include <stdint.h>
-    #include <stdlib.h>
-    #include <string.h>
-    #include <ctype.h>
-
-
-    #include "dyn_common.h"
-    #include "dyn_function.h"
-
-    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");
-    }
-
-    #define EXAMPLE1_DESCRIPTOR "example(III)I"
-    int32_t example1(int32_t a, int32_t b, int32_t c) {
-        CHECK_EQUAL(2, a);
-        CHECK_EQUAL(4, b);
-        CHECK_EQUAL(8, c);
-        return 1;
-    }
-
-    void test_example1(void) {
-        dyn_function_type *dynFunc = NULL;
-        int rc;
-        void (*fp)(void) = (void (*)(void)) example1;
-
-        rc = dynFunction_parseWithStr(EXAMPLE1_DESCRIPTOR, NULL, &dynFunc);
-        CHECK_EQUAL(0, rc);
-
-        int32_t a = 2;
-        int32_t b = 4;
-        int32_t c = 8;
-        void *values[3];
-        int32_t rVal = 0;
-        values[0] = &a;
-        values[1] = &b;
-        values[2] = &c;
-
-        rc = dynFunction_call(dynFunc, fp, &rVal, values);
-        CHECK_EQUAL(0, rc);
-        CHECK_EQUAL(1, rVal);
-        dynFunction_destroy(dynFunc);
-    }
-
-    #define EXAMPLE2_DESCRIPTOR "example(I{IID val1 val2 val3}D)D"
-    struct example2_arg {
-        int32_t val1;
-        int32_t val2;
-        double val3;
-    };
-
-    double example2(int32_t arg1, struct example2_arg arg2, double arg3) {
-        CHECK_EQUAL(2, arg1);
-        CHECK_EQUAL(2, arg2.val1);
-        CHECK_EQUAL(3, arg2.val2);
-        CHECK_EQUAL(4.1, arg2.val3);
-        CHECK_EQUAL(8.1, arg3);
-        return 2.2;
-    }
-
-    void test_example2(void) {
-        dyn_function_type *dynFunc = NULL;
-        int rc;
-        void (*fp)(void) = (void (*)(void)) example2;
-
-        rc = dynFunction_parseWithStr(EXAMPLE2_DESCRIPTOR, NULL, &dynFunc);
-        CHECK_EQUAL(0, rc);
-
-        int32_t arg1 = 2;
-        struct example2_arg arg2;
-        arg2.val1 = 2;
-        arg2.val2 = 3;
-        arg2.val3 = 4.1;
-        double arg3 = 8.1;
-        double returnVal = 0;
-        void *values[3];
-        values[0] = &arg1;
-        values[1] = &arg2;
-        values[2] = &arg3;
-
-        rc = dynFunction_call(dynFunc, fp, &returnVal, values);
-        CHECK_EQUAL(0, rc);
-        CHECK_EQUAL(2.2, returnVal);
-        dynFunction_destroy(dynFunc);
-    }
-}
-
-TEST_GROUP(DynFunctionTests) {
-    void setup() {
-        dynFunction_logSetup(stdLog, NULL, 3);
-        dynType_logSetup(stdLog, NULL, 3);
-        dynCommon_logSetup(stdLog, NULL, 3);
-    }
-};
-
-TEST(DynFunctionTests, DynFuncTest1) {
-    test_example1();
-}
-
-TEST(DynFunctionTests, DynFuncTest2) {
-    test_example2();
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/tst/dyn_interface_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/tst/dyn_interface_tests.cpp b/remote_services/dynamic_function_interface/tst/dyn_interface_tests.cpp
deleted file mode 100644
index 6453afd..0000000
--- a/remote_services/dynamic_function_interface/tst/dyn_interface_tests.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed under Apache License v2. See LICENSE for more information.
- */
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
-extern "C" {
-    
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <assert.h>
-
-#include "dyn_common.h"
-#include "dyn_interface.h"
-
-#if defined(BSD) || defined(__APPLE__) 
-#include "open_memstream.h"
-#include "fmemopen.h"
-#endif
-
-    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 test1(void) {
-        int status = 0;
-        dyn_interface_type *dynIntf = NULL;
-        FILE *desc = fopen("descriptors/example1.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        CHECK_EQUAL(0, status);
-        fclose(desc);
-
-        char *name = NULL;
-        status = dynInterface_getName(dynIntf, &name);
-        CHECK_EQUAL(0, status);
-        STRCMP_EQUAL("calculator", name);
-
-        char *version = NULL;
-        status = dynInterface_getVersion(dynIntf, &version);
-        CHECK_EQUAL(0, status);
-        STRCMP_EQUAL("1.0.0", version);
-
-        char *annVal = NULL;
-        status = dynInterface_getAnnotationEntry(dynIntf, "classname", &annVal);
-        CHECK_EQUAL(0, status);
-        STRCMP_EQUAL("org.example.Calculator", annVal);
-
-        char *nonExist = NULL;
-        status = dynInterface_getHeaderEntry(dynIntf, "nonExisting", &nonExist);
-        CHECK(status != 0);
-        CHECK(nonExist == NULL);
-        
-        dynInterface_destroy(dynIntf);
-    }
-
-}
-
-
-TEST_GROUP(DynInterfaceTests) {
-    void setup() {
-        int level = 1;
-        dynCommon_logSetup(stdLog, NULL, level);
-        dynType_logSetup(stdLog, NULL, level);
-        dynFunction_logSetup(stdLog, NULL, level);
-        dynInterface_logSetup(stdLog, NULL, level);
-    }
-};
-
-TEST(DynInterfaceTests, test1) {
-    test1();
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/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
deleted file mode 100644
index 96f64fa..0000000
--- a/remote_services/dynamic_function_interface/tst/dyn_type_tests.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed under Apache License v2. See LICENSE for more information.
- */
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
-
-extern "C" {
-    #include <string.h>
-    #include <stdarg.h>
-    
-    #include "dyn_common.h"
-    #include "dyn_type.h"
-
-	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;
-        //printf("\n-- example %s with descriptor string '%s' --\n", exName, descriptorStr);
-        int status = dynType_parseWithStr(descriptorStr, exName, NULL, &type);
-        CHECK_EQUAL(0, status);
-
-        FILE *stream = fopen("/dev/null", "w");
-        dynType_print(type, stream);
-        fclose(stream);
-        dynType_destroy(type);
-        //printf("--\n\n");
-    }
-}
-
-TEST_GROUP(DynTypeTests) {
-	void setup() {
-	    dynType_logSetup(stdLog, NULL, 0);
-	}
-};
-
-#define EX1 "{BbJjIiSsDFNN arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 arg10 arg11 arg12}"
-#define EX2 "{D{DD b_1 b_2}I a b c}"
-#define EX3 "Tsub={DD b_1 b_2};{DLsub;I a b c}"
-#define EX4 "{[I numbers}"
-#define EX5 "[[{DD{iii val3_1 val3_2 val3_3} val1 val2 val3}"
-#define EX6 "Tsample={DD vala valb};Lsample;"
-#define EX7 "Tsample={DD vala valb};[Lsample;"
-#define EX8 "[Tsample={DD a b};Lsample;"
-#define EX9 "*D"
-#define EX10 "Tsample={DD a b};******Lsample;"
-#define EX11 "Tsample=D;Lsample;"
-#define EX12 "Tnode={Lnode;Lnode; left right};{Lnode; head}" //note recursive example
-#define EX13 "Ttype={DDDDD a b c d e};{ltype;Ltype;ltype;Ltype; byVal1 byRef1 byVal2 ByRef2}" 
-#define EX14 "{DD{FF{JJ}{II*{ss}}}}"  //unnamed fields
-
-#define CREATE_EXAMPLES_TEST(DESC) \
-    TEST(DynTypeTests, ParseTestExample ## DESC) { \
-        runTest(DESC, #DESC); \
-    }    
-
-CREATE_EXAMPLES_TEST(EX1)
-CREATE_EXAMPLES_TEST(EX2)
-CREATE_EXAMPLES_TEST(EX3)
-CREATE_EXAMPLES_TEST(EX4)
-CREATE_EXAMPLES_TEST(EX5)
-CREATE_EXAMPLES_TEST(EX6)
-CREATE_EXAMPLES_TEST(EX7)
-CREATE_EXAMPLES_TEST(EX8)
-CREATE_EXAMPLES_TEST(EX9)
-CREATE_EXAMPLES_TEST(EX10)
-CREATE_EXAMPLES_TEST(EX11)
-CREATE_EXAMPLES_TEST(EX12)
-CREATE_EXAMPLES_TEST(EX13)
-CREATE_EXAMPLES_TEST(EX14)
-
-TEST(DynTypeTests, ParseRandomGarbageTest) {
-    /*
-    unsigned int seed = 4148;
-    char *testRandom = getenv("DYN_TYPE_TEST_RANDOM");
-    if (testRandom != NULL && strcmp("true", testRandom) == 0) {
-        seed = (unsigned int) time(NULL);
-    } 
-    srandom(seed);
-    size_t nrOfTests = 100;
-
-    printf("\nStarting test with random seed %i and nrOfTests %zu.\n", seed, nrOfTests);
-
-    int i;
-    int k;
-    int c;
-    int sucesses = 0;
-    char descriptorStr[32];
-    descriptorStr[31] = '\0';
-    for(i = 0; i < nrOfTests; i += 1) {  
-        for(k = 0; k < 31; k += 1) {
-            do {
-                c = (char) (((random() * 128) / RAND_MAX) - 1);
-            } while (!isprint(c));
-            descriptorStr[k] = c;
-            if (c == '\0') { 
-                break;
-            }
-        }
-
-        //printf("ParseRandomGarbageTest iteration %i with descriptor string '%s'\n", k, descriptorStr); 
-        dyn_type *type = NULL;	
-        int status = dynType_parseWithStr(descriptorStr, NULL, NULL, &type);
-        if (status == 0) {
-            dynType_destroy(type);
-        }
-    }
-     */
-}
-
-TEST(DynTypeTests, AssignTest1) {
-    struct ex1 {
-        int32_t a;
-        int32_t b;
-        int32_t c;
-    };
-    struct ex1 inst;
-    const char *desc = "{III a b c}";
-    dyn_type *type = NULL;
-    int status = dynType_parseWithStr(desc, NULL, NULL, &type);
-    CHECK_EQUAL(0, status);
-    int32_t val1 = 2;
-    int32_t val2 = 4;
-    int32_t val3 = 8;
-    dynType_complex_setValueAt(type, 0,  &inst, &val1);
-    CHECK_EQUAL(2, inst.a);
-    dynType_complex_setValueAt(type, 1,  &inst, &val2);
-    CHECK_EQUAL(4, inst.b);
-    dynType_complex_setValueAt(type, 2,  &inst, &val3);
-    CHECK_EQUAL(8, inst.c);
-
-    dynType_destroy(type);
-}
-
-TEST(DynTypeTests, AssignTest2) {
-    struct ex {
-        int32_t a;
-        struct {
-            double a;
-            double b;
-        } b;
-    };
-    struct ex inst;
-    const char *desc = "{I{DD a b} a b}";
-    dyn_type *type = NULL;
-    int status = dynType_parseWithStr(desc, NULL, NULL,  &type);
-    CHECK_EQUAL(0, status);
-    int32_t a = 2;
-    double b_a = 1.1;
-    double b_b = 1.2;
-
-    dynType_complex_setValueAt(type, 0,  &inst, &a);
-    CHECK_EQUAL(2, inst.a);
-
-    void *loc = NULL;
-    dyn_type *subType = NULL;
-    dynType_complex_valLocAt(type, 1, (void *)&inst, &loc);
-    dynType_complex_dynTypeAt(type, 1, &subType);
-
-    dynType_complex_setValueAt(subType, 0, &inst.b, &b_a);
-    CHECK_EQUAL(1.1, inst.b.a);
-
-    dynType_complex_setValueAt(subType, 1, &inst.b, &b_b);
-    CHECK_EQUAL(1.2, inst.b.b);
-
-    dynType_destroy(type);
-}
-
-TEST(DynTypeTests, AssignTest3) {
-    int simple = 1;
-    dyn_type *type = NULL;
-    int rc = dynType_parseWithStr("N", NULL, NULL, &type);
-    CHECK_EQUAL(0, rc);
-
-    int newValue = 42;
-    void *loc = &simple;
-    void *input = &newValue;
-    dynType_simple_setValue(type, loc, input);
-    CHECK_EQUAL(42, simple);
-    dynType_destroy(type);
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/tst/json_serializer_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/tst/json_serializer_tests.cpp b/remote_services/dynamic_function_interface/tst/json_serializer_tests.cpp
deleted file mode 100644
index c21d594..0000000
--- a/remote_services/dynamic_function_interface/tst/json_serializer_tests.cpp
+++ /dev/null
@@ -1,398 +0,0 @@
-/**
- * Licensed under Apache License v2. See LICENSE for more information.
- */
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
-
-extern "C" {
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include <ffi.h>
-
-#include "dyn_common.h"
-#include "dyn_type.h"
-#include "json_serializer.h"
-
-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");
-}
-
-/*********** example 1 ************************/
-/** struct type ******************************/
-const char *example1_descriptor = "{DJISF a b c d e}";
-
-const char *example1_input = "{ \
-    \"a\" : 1.0, \
-    \"b\" : 22, \
-    \"c\" : 32, \
-    \"d\" : 42, \
-    \"e\" : 4.4 \
-}";
-
-struct example1 {
-    double a;   //0
-    int64_t b;  //1
-    int32_t c;  //2
-    int16_t d;  //3
-    float e;    //4
-};
-
-static void check_example1(void *data) {
-    struct example1 *ex = (struct example1 *)data;
-    CHECK_EQUAL(1.0, ex->a);
-    CHECK_EQUAL(22, ex->b);
-    CHECK_EQUAL(32, ex->c);
-    CHECK_EQUAL(42, ex->d);
-    CHECK_EQUAL(4.4f, ex->e);
-}
-
-/*********** example 2 ************************/
-const char *example2_descriptor = "{BJJDFD byte long1 long2 double1 float1 double2}";
-
-const char *example2_input = "{ \
-    \"byte\" : 42, \
-    \"long1\" : 232, \
-    \"long2\" : 242, \
-    \"double1\" : 4.2, \
-    \"float1\" : 3.2, \
-    \"double2\" : 4.4 \
-}";
-
-struct example2 {
-    char byte;      //0
-    int64_t long1;     //1
-    int64_t long2;     //2
-    double double1; //3
-    float float1;   //4
-    double double2; //5
-};
-
-static void check_example2(void *data) {
-    struct example2 *ex = (struct example2 *)data;
-    CHECK_EQUAL(42, ex->byte);
-    CHECK_EQUAL(232, ex->long1);
-    CHECK_EQUAL(242, ex->long2);
-    CHECK_EQUAL(4.2, ex->double1);
-    CHECK_EQUAL(3.2f, ex->float1);
-    CHECK_EQUAL(4.4, ex->double2);
-}
-
-
-/*********** example 3 ************************/
-/** sequence with a simple type **************/
-const char *example3_descriptor = "{[I numbers}";
-
-const char *example3_input = "{ \
-    \"numbers\" : [22,32,42] \
-}";
-
-struct example3 {
-    struct {
-        uint32_t cap;
-        uint32_t len;
-        int32_t *buf;
-    } numbers;
-};
-
-static void check_example3(void *data) {
-    struct example3 *ex = (struct example3 *)data;
-    CHECK_EQUAL(3, ex->numbers.len);
-    CHECK_EQUAL(22, ex->numbers.buf[0]);
-    CHECK_EQUAL(32, ex->numbers.buf[1]);
-    CHECK_EQUAL(42, ex->numbers.buf[2]);
-}
-
-/*********** example 4 ************************/
-/** structs within a struct (by reference)*******/
-const char *example4_descriptor = "{{IDD index val1 val2}{IDD index val1 val2} left right}";
-
-static const char *example4_input =  "{ \
-    \"left\" : {\"index\":1, \"val1\":1.0, \"val2\":2.0 }, \
-    \"right\" : {\"index\":2, \"val1\":5.0, \"val2\":4.0 } \
-}";
-
-struct ex4_leaf {
-    int32_t index;
-    double val1;
-    double val2;
-};
-
-struct example4 {
-    struct ex4_leaf left;
-    struct ex4_leaf right;
-};
-
-static void check_example4(void *data) {
-    struct example4 *ex = (struct example4 *)data;
-    CHECK_EQUAL(1, ex->left.index);
-    CHECK_EQUAL(1.0, ex->left.val1);
-    CHECK_EQUAL(2.0, ex->left.val2);
-    CHECK_EQUAL(2, ex->right.index);
-    CHECK_EQUAL(5.0, ex->right.val1);
-    CHECK_EQUAL(4.0, ex->right.val2);
-}
-
-
-/*********** example 4 ************************/
-/** structs within a struct (by reference)*******/
-const char *example5_descriptor = "Tleaf={ts name age};Tnode={Lnode;Lnode;Lleaf; left right value};{Lnode; head}";
-
-static const char *example5_input =  "{ \
-    \"head\" : {\
-        \"left\" : {\
-            \"value\" : {\
-                \"name\" : \"John\",\
-                \"age\" : 44 \
-            }\
-        },\
-        \"right\" : {\
-            \"value\" : {\
-                \"name\" : \"Peter\", \
-                \"age\" : 55 \
-            }\
-        }\
-    }\
-}";
-
-struct leaf {
-    const char *name;
-    uint16_t age;
-};
-
-struct node {
-    struct node *left;
-    struct node *right;
-    struct leaf *value;
-};
-
-struct example5 {
-    struct node *head;
-};
-
-static void check_example5(void *data) {
-    struct example5 *ex = (struct example5 *)data;
-    CHECK_TRUE(ex->head != NULL);
-
-    CHECK(ex->head->left != NULL);
-    CHECK(ex->head->left->value != NULL);
-    STRCMP_EQUAL("John", ex->head->left->value->name);
-    CHECK_EQUAL(44, ex->head->left->value->age);
-    CHECK(ex->head->left->left == NULL);
-    CHECK(ex->head->left->right == NULL);
-
-    CHECK(ex->head->right != NULL);
-    CHECK(ex->head->right->value != NULL);
-    STRCMP_EQUAL("Peter", ex->head->right->value->name);
-    CHECK_EQUAL(55, ex->head->right->value->age);
-    CHECK(ex->head->right->left == NULL);
-    CHECK(ex->head->right->right == NULL);
-}
-
-static void parseTests(void) {
-    dyn_type *type;
-    void *inst;
-    int rc;
-
-    type = NULL;
-    inst = NULL;
-    rc = dynType_parseWithStr(example1_descriptor, NULL, NULL, &type);    
-    CHECK_EQUAL(0, rc);
-    rc = jsonSerializer_deserialize(type, example1_input, &inst);
-    CHECK_EQUAL(0, rc);
-    check_example1(inst);
-    dynType_free(type, inst);
-    dynType_destroy(type);
-
-    type = NULL;
-    inst = NULL;
-    rc = dynType_parseWithStr(example2_descriptor, NULL, NULL, &type);
-    CHECK_EQUAL(0, rc);
-    rc = jsonSerializer_deserialize(type, example2_input, &inst);
-    CHECK_EQUAL(0, rc);
-    check_example2(inst);
-    dynType_free(type, inst);
-    dynType_destroy(type);
-
-    type = NULL;
-    inst = NULL;
-    rc = dynType_parseWithStr(example3_descriptor, NULL, NULL, &type);
-    CHECK_EQUAL(0, rc);
-    rc = jsonSerializer_deserialize(type, example3_input, &inst);
-    CHECK_EQUAL(0, rc);
-    check_example3(inst);
-    dynType_free(type, inst);
-    dynType_destroy(type);
-
-    type = NULL;
-    inst = NULL;
-    rc = dynType_parseWithStr(example4_descriptor, NULL, NULL, &type);
-    CHECK_EQUAL(0, rc);
-    rc = jsonSerializer_deserialize(type, example4_input, &inst);
-    CHECK_EQUAL(0, rc);
-    check_example4(inst);
-    dynType_free(type, inst);
-    dynType_destroy(type);
-
-    type = NULL;
-    inst = NULL;
-    rc = dynType_parseWithStr(example5_descriptor, NULL, NULL, &type);
-    CHECK_EQUAL(0, rc);
-    rc = jsonSerializer_deserialize(type, example5_input, &inst);
-    CHECK_EQUAL(0, rc);
-    check_example5(inst);
-    dynType_free(type, inst);
-    dynType_destroy(type);
-}
-
-const char *write_example1_descriptor = "{BSIJsijFDN a b c d e f g h i j}";
-
-struct write_example1 {
-    char a;
-    int16_t b;
-    int32_t c;
-    int64_t d;
-    uint16_t e;
-    uint32_t f;
-    uint64_t g;
-    float h;
-    double i;
-    int j;
-};
-
-void writeTest1(void) {
-    struct write_example1 ex1 = {.a=1, .b=2, .c=3, .d=4, .e=5, .f=6, .g=7, .h=8.8f, .i=9.9, .j=10};
-    dyn_type *type = NULL;
-    char *result = NULL;
-    int rc = dynType_parseWithStr(write_example1_descriptor, "ex1", NULL, &type);
-    CHECK_EQUAL(0, rc);
-    rc = jsonSerializer_serialize(type, &ex1, &result);
-    CHECK_EQUAL(0, rc);
-    STRCMP_CONTAINS("\"a\":1", result);
-    STRCMP_CONTAINS("\"b\":2", result);
-    STRCMP_CONTAINS("\"c\":3", result);
-    STRCMP_CONTAINS("\"d\":4", result);
-    STRCMP_CONTAINS("\"e\":5", result);
-    STRCMP_CONTAINS("\"f\":6", result);
-    STRCMP_CONTAINS("\"g\":7", result);
-    STRCMP_CONTAINS("\"h\":8.8", result);
-    STRCMP_CONTAINS("\"i\":9.9", result);
-    STRCMP_CONTAINS("\"j\":10", result);
-    //printf("example 1 result: '%s'\n", result);
-    dynType_destroy(type);
-    free(result);
-}
-
-const char *write_example2_descriptor = "{*{JJ a b}{SS c d} sub1 sub2}";
-
-struct write_example2_sub {
-        int64_t a;
-        int64_t b;
-};
-
-struct write_example2 {
-    struct write_example2_sub *sub1;
-    struct {
-        int16_t c;
-        int16_t d;
-    } sub2;
-};
-
-void writeTest2(void) {
-    struct write_example2_sub sub1 = { .a = 1, .b = 2 };
-    struct write_example2 ex = { .sub1 = &sub1 };
-    ex.sub2.c = 3;
-    ex.sub2.d = 4;
-
-    dyn_type *type = NULL;
-    char *result = NULL;
-    int rc = dynType_parseWithStr(write_example2_descriptor, "ex2", NULL, &type);
-    CHECK_EQUAL(0, rc);
-    rc = jsonSerializer_serialize(type, &ex, &result);
-    CHECK_EQUAL(0, rc);
-    STRCMP_CONTAINS("\"a\":1", result);
-    STRCMP_CONTAINS("\"b\":2", result);
-    STRCMP_CONTAINS("\"c\":3", result);
-    STRCMP_CONTAINS("\"d\":4", result);
-    //printf("example 2 result: '%s'\n", result);
-    dynType_destroy(type);
-    free(result);
-}
-
-const char *write_example3_descriptor = "Tperson={ti name age};[Lperson;";
-
-struct write_example3_person {
-    const char *name;
-    uint32_t age;
-};
-
-struct write_example3 {
-    uint32_t cap;
-    uint32_t len;
-    struct write_example3_person **buf;
-};
-
-void writeTest3(void) {
-    struct write_example3_person p1 = {.name = "John", .age = 33};
-    struct write_example3_person p2 = {.name = "Peter", .age = 44};
-    struct write_example3_person p3 = {.name = "Carol", .age = 55};
-    struct write_example3_person p4 = {.name = "Elton", .age = 66};
-    struct write_example3 seq;
-    seq.buf = (struct write_example3_person **) calloc(4, sizeof(void *));
-    seq.len = seq.cap = 4;
-    seq.buf[0] = &p1;
-    seq.buf[1] = &p2;
-    seq.buf[2] = &p3;
-    seq.buf[3] = &p4;
-
-    dyn_type *type = NULL;
-    char *result = NULL;
-    int rc = dynType_parseWithStr(write_example3_descriptor, "ex3", NULL, &type);
-    CHECK_EQUAL(0, rc);
-    rc = jsonSerializer_serialize(type, &seq, &result);
-    CHECK_EQUAL(0, rc);
-    STRCMP_CONTAINS("\"age\":33", result);
-    STRCMP_CONTAINS("\"age\":44", result);
-    STRCMP_CONTAINS("\"age\":55", result);
-    STRCMP_CONTAINS("\"age\":66", result);
-    //printf("example 3 result: '%s'\n", result);
-    free(seq.buf);
-    dynType_destroy(type);
-    free(result);
-}
-
-}
-
-TEST_GROUP(JsonSerializerTests) {
-    void setup() {
-        int lvl = 1;
-        dynCommon_logSetup(stdLog, NULL, lvl);
-        dynType_logSetup(stdLog, NULL,lvl);
-        jsonSerializer_logSetup(stdLog, NULL, lvl);
-    }
-};
-
-TEST(JsonSerializerTests, ParseTests) {
-    //TODO split up
-    parseTests();
-}
-
-TEST(JsonSerializerTests, WriteTest1) {
-    writeTest1();
-}
-
-TEST(JsonSerializerTests, WriteTest2) {
-    writeTest2();
-}
-
-TEST(JsonSerializerTests, WriteTest3) {
-    writeTest3();
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/dynamic_function_interface/tst/run_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/dynamic_function_interface/tst/run_tests.cpp b/remote_services/dynamic_function_interface/tst/run_tests.cpp
deleted file mode 100644
index f405c9f..0000000
--- a/remote_services/dynamic_function_interface/tst/run_tests.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Licensed under Apache License v2. See LICENSE for more information.
- */
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
-
-int main(int argc, char** argv) {
-        return RUN_ALL_TESTS(argc, argv);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/remote_service_admin_dfi/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/CMakeLists.txt b/remote_services/remote_service_admin_dfi/CMakeLists.txt
new file mode 100644
index 0000000..f74cac1
--- /dev/null
+++ b/remote_services/remote_service_admin_dfi/CMakeLists.txt
@@ -0,0 +1,52 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+celix_subproject(RSA_REMOTE_SERVICE_ADMIN_DFI "Option to enable building the Remote Service Admin Service DFI" OFF)
+if (RSA_REMOTE_SERVICE_ADMIN_DFI)
+    find_package(CURL REQUIRED)
+    find_package(Jansson REQUIRED)
+    find_package(FFI REQUIRED)
+
+    add_subdirectory(dynamic_function_interface)
+
+    include_directories(${FFI_INCLUDE_DIRS})
+    include_directories(${CURL_INCLUDE_DIRS})
+    include_directories(${JANSSON_INCLUDE_DIRS})
+    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+    include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
+    include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/private/include")
+    include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/public/include")
+    include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include")
+    include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/include")
+    include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin_http/private/include")
+    include_directories("${PROJECT_SOURCE_DIR}/remote_services/endpoint_listener/public/include")
+    
+    #SET_HEADER(BUNDLE_SYMBOLICNAME "apache_celix_remote_service_admin_dfi")
+    #SET(BUNDLE_VERSION "0.0.1")
+    #SET_HEADERS("Bundle-Name: Apache Celix Remote Service Admin HTTP for dynamic function interface")
+    
+    #bundle(remote_service_admin_dfi SOURCES
+    #    private/src/remote_service_admin_impl
+    #    private/src/remote_service_admin_activator
+    #    ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/export_registration_impl
+    #    ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/import_registration_impl
+    #    ${PROJECT_SOURCE_DIR}/remote_services/utils/private/src/civetweb.c
+    #    ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
+    #)
+    #target_link_libraries(remote_service_admin_dfi celix_framework ${CURL_LIBRARIES} ${JANSSON_LIBRARIES} ${FFI_LIBRARIES})
+
+    #install_bundle(remote_service_admin_dfi)
+endif (RSA_REMOTE_SERVICE_ADMIN_DFI)

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/remote_service_admin_dfi/dynamic_function_interface/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/CMakeLists.txt b/remote_services/remote_service_admin_dfi/dynamic_function_interface/CMakeLists.txt
new file mode 100644
index 0000000..309176f
--- /dev/null
+++ b/remote_services/remote_service_admin_dfi/dynamic_function_interface/CMakeLists.txt
@@ -0,0 +1,53 @@
+#
+# Licensed under Apache License v2. See LICENSE for more information.
+#
+find_package(Jansson REQUIRED)
+find_package(CppUTest REQUIRED)
+find_package(FFI REQUIRED)
+
+include_directories( 
+    ${CPPUTEST_INCLUDE_DIR}
+    ${JANSSON_INCLUDE_DIRS}
+    ${CMAKE_CURRENT_LIST_DIR}
+    ${FFI_INCLUDE_DIRS}
+    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_common.c
+    dyn_type.c
+    dyn_function.c
+    dyn_interface.c
+    json_serializer.c
+#    avro_descriptor_translator.c
+    ${MEMSTREAM_SOURCES}
+)
+target_link_libraries(dfi ${FFI_LIBRARIES} ${JANSSON_LIBRARY})
+
+
+#if (FRAMEWORK_TESTS)
+	add_executable(dfi_tests
+	    tst/dyn_type_tests.cpp
+	    tst/dyn_function_tests.cpp
+	    tst/dyn_closure_tests.cpp
+        tst/dyn_interface_tests.cpp
+	    tst/json_serializer_tests.cpp
+#	    tst/avro_descriptor_translator_tests.cpp
+	    tst/run_tests.cpp
+	)
+	target_link_libraries(dfi_tests dfi ${FFI_LIBRARIES} ${CPPUTEST_LIBRARY} ${JANSSON_LIBRARY}) 
+
+	add_custom_target(copy-input 
+	    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/schemas schemas
+	    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/descriptors descriptors
+	)
+	add_dependencies(dfi_tests copy-input)
+
+    add_test(NAME run_dfi_tests COMMAND 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/bf76d213/remote_services/remote_service_admin_dfi/dynamic_function_interface/avro_descriptor_translator.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/avro_descriptor_translator.c b/remote_services/remote_service_admin_dfi/dynamic_function_interface/avro_descriptor_translator.c
new file mode 100644
index 0000000..a9fea1d
--- /dev/null
+++ b/remote_services/remote_service_admin_dfi/dynamic_function_interface/avro_descriptor_translator.c
@@ -0,0 +1,319 @@
+/**
+ * Licensed under Apache License v2. See LICENSE for more information.
+ */
+#include "descriptor_translator.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include <jansson.h>
+
+#if defined(BSD) || defined(__APPLE__) 
+#include "open_memstream.h"
+#include "fmemopen.h"
+#endif
+
+DFI_SETUP_LOG(descriptorTranslator)
+
+static const int OK = 0;
+static const int MEM_ERROR = 1;
+static const int PARSE_ERROR = 2;
+static const int INV_ARG_ERROR = 2;
+                   
+static int descriptorTranslator_createMethodInfo(dyn_interface_type *intf, json_t *schema, const char *name, int index, json_t *message); 
+static int descriptorTranslator_parseType(dyn_interface_type *intf, json_t *type);
+static int descriptorTranslator_parseMessage(json_t *schema, const char *name, json_t *message, bool asJavaSignature, char **descriptor); 
+static int descriptorTranslator_parseArgument(FILE *stream, json_t *type);
+
+int descriptorTranslator_translate(const char *schemaStr, dyn_interface_type **out) {
+    LOG_DEBUG("translating descriptor for schema '%s'\n", schemaStr);
+    int status = OK;
+
+    dyn_interface_type *intf = NULL;
+    status = dynInterface_create("TODO", &intf); //TODO parse json first retreive 'Protocol' string value
+    if (status == 0) {
+        json_error_t error;
+        json_t *schema = json_loads(schemaStr, JSON_DECODE_ANY, &error);
+
+        if (schema != NULL) {
+            json_t *types = json_object_get(schema, "types");
+            if (types != NULL) {
+                json_t *type = NULL;
+                int index = 0;
+                json_array_foreach(types, index, type) {
+                    status = descriptorTranslator_parseType(intf, type);
+                    if (status != OK) { 
+                        break;
+                    }
+                }
+            }
+            json_t *messages = json_object_get(schema, "messages");
+            if (status == OK && messages != NULL) {
+                const char *name;
+                json_t *message;
+                int index = 0;
+                json_object_foreach(messages, name, message) {
+                   status = descriptorTranslator_createMethodInfo(intf, schema, name, index++, message); 
+                   if (status != OK) {
+                       break;
+                   }
+                }
+            }
+            json_decref(schema);
+        } else {
+            status = PARSE_ERROR;
+            printf("AVRO_DESCRIPTOR_TRANSLATOR: error parsing json input '%s'. Error is %s\n", schemaStr, error.text);
+        }
+    } else { 
+        status = MEM_ERROR;
+    }
+
+
+    if (status == OK) { 
+        *out = intf;
+    } else {
+        dynInterface_destroy(intf);
+    }
+    return status;
+}
+
+static int descriptorTranslator_createMethodInfo(dyn_interface_type *intf, json_t *schema, const char *name, int index, json_t *message) {
+    int status = OK;
+
+    method_info_type *mInfo = calloc(1, sizeof(*mInfo));
+    if (mInfo != NULL) {
+        mInfo->identifier = index;
+        status = descriptorTranslator_parseMessage(schema, name, message, false, &mInfo->descriptor);
+        if (status == OK) {
+            mInfo->name = strdup(name);
+            if (mInfo->name == NULL) {
+                status = MEM_ERROR;
+            } else {
+                status = descriptorTranslator_parseMessage(schema, name, message, true, &mInfo->strIdentifier);
+            }
+        }
+    } else {
+        status = MEM_ERROR;
+    }
+
+    if (status == OK) {
+        TAILQ_INSERT_TAIL(&intf->methodInfos, mInfo, entries);
+    } else {
+        if (mInfo != NULL) {
+            if (mInfo->name != NULL) {
+                free(mInfo->name);
+            }
+            if (mInfo->descriptor != NULL) {
+                free(mInfo->descriptor);
+            }
+            if (mInfo->strIdentifier != NULL) {
+                free(mInfo->strIdentifier);
+            }
+            free(mInfo);
+        }
+    }
+
+    return status;
+} 
+
+static int descriptorTranslator_parseMessage(json_t *schema, const char *name, json_t *message, bool asJavaSignature, char **descriptor) {
+    int status = OK;
+    //message -> { "request" : [ {"name":"<name>", "type":"<type>"} * ], "response":"<type>" }
+    //array -> "type":"array", "items:"<type>"
+
+    char *ptr = NULL;
+    size_t ptrSize;
+    FILE *memStream = open_memstream(&ptr, &ptrSize);
+    
+    if (memStream != NULL) { 
+        json_t *request = json_object_get(message, "request");
+        fwrite(name, 1, strlen(name), memStream);
+        fputc('(', memStream);
+        if (!asJavaSignature) {
+            fputc('P', memStream); //handle
+        }
+    
+        if (request != NULL) {
+            size_t index;
+            json_t *arg;
+            json_array_foreach(request, index, arg) {
+                //json_t *name = json_object_get(arg, "name");
+                json_t *type = json_object_get(arg, "type");
+                if (type != NULL) {
+                    status = descriptorTranslator_parseArgument(memStream, type);
+                } else {
+                    LOG_ERROR("expected json object with name value for request argument %zu for message/method %s\n", index, name);
+                    status = PARSE_ERROR;
+                }
+                if (status != OK) { 
+                    break;
+                }
+            }
+        } else {
+            status = PARSE_ERROR;
+            LOG_ERROR("Expected request for message %s\n", name);    
+        }
+
+        json_t *response = json_object_get(message, "response");
+        if (status == OK && response != NULL) {
+            if (asJavaSignature) {
+                fputc(')', memStream);
+            } else {
+                fputc('*', memStream); //output parameter
+            }
+            status = descriptorTranslator_parseArgument(memStream, response);
+        } 
+
+        if (!asJavaSignature) {
+            fputc(')', memStream);
+            fputc('N', memStream); //error / exceptions
+        }
+   } else {
+       status = MEM_ERROR;
+   }
+
+    if (memStream != NULL) {
+        fclose(memStream);
+        if (status == OK) {
+            *descriptor = ptr;
+        } else {
+            free(ptr);
+        }
+    } 
+
+    return status;
+}
+
+static const char * const PRIMITIVE_INT = "int";
+static const char * const PRIMITIVE_LONG = "long";
+static const char * const PRIMITIVE_STRING = "string";
+static const char * const PRIMITIVE_BOOL = "boolean";
+static const char * const PRIMITIVE_FLOAT = "float";
+static const char * const PRIMITIVE_DOUBLE = "double";
+static const char * const PRIMITIVE_NULL = "null";
+static const char * const PRIMITIVE_BYTES = "bytes";
+
+static int descriptorTranslator_parseArgument(FILE *stream, json_t *type) {
+    int status = OK;
+    if (json_is_string(type)) {
+        const char *typeStr = json_string_value(type);
+        char t = '\0';
+        if (strcmp(typeStr, PRIMITIVE_INT) == 0) {
+            t = 'I';
+        } else if (strcmp(typeStr, PRIMITIVE_LONG) == 0) {
+            t = 'J';
+        } else if (strcmp(typeStr, PRIMITIVE_STRING) == 0) {
+            t = 'T';
+        } else if (strcmp(typeStr, PRIMITIVE_BOOL) == 0) {
+            t = 'Z';
+        } else if (strcmp(typeStr, PRIMITIVE_FLOAT) == 0) {
+            t = 'F';
+        } else if (strcmp(typeStr, PRIMITIVE_DOUBLE) == 0) {
+            t = 'D';
+        } else if (strcmp(typeStr, PRIMITIVE_NULL) == 0) {
+            t = 'V';
+        } else if (strcmp(typeStr, PRIMITIVE_BYTES) == 0) {
+            t = 'B';
+        } else {
+            fprintf(stream, "L%s;", typeStr);
+        }
+        if (t != '\0') {
+            fputc(t, stream);
+        }
+    } else {
+        json_t *subType = json_object_get(type, "type");
+        json_t *items = json_object_get(type, "items");
+        if (strcmp("array", json_string_value(subType)) == 0) {
+            //array
+            fputc('[', stream);
+            descriptorTranslator_parseArgument(stream, items);
+        } else {
+            LOG_ERROR("sub type %s not supported\n", json_string_value(subType));
+            status = PARSE_ERROR;
+        }
+    }
+    return status;
+}
+            
+static int descriptorTranslator_parseType(dyn_interface_type *intf, json_t *type) {
+    int status = OK;
+    const char *name = json_string_value(json_object_get(type, "name"));
+    type_info_type *tInfo = NULL;
+
+    char *ptr = NULL;
+    size_t ptrSize;
+    FILE *stream = open_memstream(&ptr, &ptrSize);
+
+    if (stream != NULL) {
+        fputc('{', stream);
+        json_t *fields = json_object_get(type, "fields");
+        if (json_is_array(fields)) {
+            int index = 0;
+            json_t *field = NULL;
+            json_array_foreach(fields, index, field) {
+                json_t *type = json_object_get(field, "type");
+                status = descriptorTranslator_parseArgument(stream, type);
+                if (status != OK) { 
+                    break;
+                }
+            }
+            if (status == OK) {
+                json_array_foreach(fields, index, field) {
+                    const char *fieldName = json_string_value(json_object_get(field, "name"));
+                    if (fieldName != NULL) { 
+                        fputc(' ', stream);
+                        fwrite(fieldName, 1, strlen(fieldName), stream);
+                    } else {
+                        status = PARSE_ERROR;
+                        printf("Expected name for field\n");
+                        break;
+                    }
+                }
+            }
+        } else {
+            status = PARSE_ERROR;
+            printf("Expected array type");
+        }
+        fputc('}', stream);
+        fclose(stream);
+    } else {
+        status = MEM_ERROR;
+        LOG_ERROR("Error creating memory stream");
+    }
+
+    if (status == OK) {
+        tInfo = calloc(1, sizeof(*tInfo));
+        if (tInfo != NULL) {
+           tInfo->name = strdup(name);
+           if (tInfo->name != NULL) {
+               tInfo->descriptor = ptr;
+           } else {
+               status = MEM_ERROR;
+               LOG_ERROR("Error allocating memory for type info name");
+           }
+        } else {
+            status = MEM_ERROR;
+            LOG_ERROR("Error allocating memory for type_info");
+        }
+    }
+
+    if (status != 0 ) {
+        if (tInfo != NULL) {
+            if (tInfo->name != NULL) {
+                free(tInfo->name);
+            }
+            free(tInfo);
+        }
+        if (ptr != NULL) {
+            free(ptr);
+        }
+    }
+
+    if (status == OK) {
+        TAILQ_INSERT_TAIL(&intf->typeInfos, tInfo, entries);
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/remote_service_admin_dfi/dynamic_function_interface/descriptor_translator.h
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/descriptor_translator.h b/remote_services/remote_service_admin_dfi/dynamic_function_interface/descriptor_translator.h
new file mode 100644
index 0000000..6473d0d
--- /dev/null
+++ b/remote_services/remote_service_admin_dfi/dynamic_function_interface/descriptor_translator.h
@@ -0,0 +1,18 @@
+/**
+ * Licensed under Apache License v2. See LICENSE for more information.
+ */
+#ifndef __DESCRIPTOR_TRANSLATOR_H_
+#define __DESCRIPTOR_TRANSLATOR_H_
+
+#include <stdio.h>
+#include  <sys/queue.h>
+
+#include "dfi_log_util.h"
+#include "dyn_interface.h"
+
+//logging
+DFI_SETUP_LOG_HEADER(descriptorTranslator);
+
+int descriptorTranslator_translate(const char *schemaStr, dyn_interface_type **out);
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/remote_service_admin_dfi/dynamic_function_interface/descriptors/example1.descriptor
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/descriptors/example1.descriptor b/remote_services/remote_service_admin_dfi/dynamic_function_interface/descriptors/example1.descriptor
new file mode 100644
index 0000000..97b1df8
--- /dev/null
+++ b/remote_services/remote_service_admin_dfi/dynamic_function_interface/descriptors/example1.descriptor
@@ -0,0 +1,13 @@
+:header
+type=interface
+name=calculator
+version=1.0.0
+:annotations
+classname=org.example.Calculator
+:types
+StatsResult={DDD[D average min max input}
+:methods
+add(DD)D=add(PDD*D)N
+sub(DD)D=sub(PDD*D)N
+sqrt(D)D=sqrt(PD*D)N
+stats([D)LStatsResult;=stats(P[D*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/bf76d213/remote_services/remote_service_admin_dfi/dynamic_function_interface/dfi_log_util.h
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dfi_log_util.h b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dfi_log_util.h
new file mode 100644
index 0000000..8dfd9bd
--- /dev/null
+++ b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dfi_log_util.h
@@ -0,0 +1,48 @@
+/**
+ * Licensed under Apache License v2. See LICENSE for more information.
+ */
+#ifndef _DFI_LOG_UTIL_H_
+#define _DFI_LOG_UTIL_H_
+
+typedef void (*logf_ft)(void *handle, int level, const char *file, int line, const char *format, ...); 
+
+#define DFI_SETUP_LOG_HEADER(cmp) \
+    void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel);
+
+#define DFI_SETUP_LOG(cmp) \
+    static logf_ft g_logf = NULL; \
+    static void *g_logHandle = NULL; \
+    static int g_currentLogLevel = 1; \
+    \
+    void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel) { \
+        g_currentLogLevel = currentLogLevel; \
+        g_logHandle = handle; \
+        g_logf = logf; \
+    }  
+
+#define LOG_LVL_ERROR    1
+#define LOG_LVL_WARNING  2
+#define LOG_LVL_INFO     3
+#define LOG_LVL_DEBUG    4
+
+#define LOG_ERROR(msg, ...) \
+    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_ERROR) { \
+        g_logf(g_logHandle, LOG_LVL_ERROR, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
+    } 
+
+#define LOG_WARNING(msg, ...) \
+    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_WARNING) { \
+        g_logf(g_logHandle, LOG_LVL_WARNING, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
+    } 
+
+#define LOG_INFO(msg, ...) \
+    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_INFO) { \
+        g_logf(g_logHandle, LOG_LVL_INFO, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
+    } 
+
+#define LOG_DEBUG(msg, ...) \
+    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_DEBUG) { \
+        g_logf(g_logHandle, LOG_LVL_DEBUG, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
+    } 
+
+#endif


Mime
View raw message