You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2017/11/20 20:32:58 UTC

[01/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Repository: celix
Updated Branches:
  refs/heads/feature/CELIX-417-cmake-refactor [created] a1c308879


http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/linked_list_iterator.c
----------------------------------------------------------------------
diff --git a/utils/src/linked_list_iterator.c b/utils/src/linked_list_iterator.c
new file mode 100644
index 0000000..dc0e5c4
--- /dev/null
+++ b/utils/src/linked_list_iterator.c
@@ -0,0 +1,153 @@
+/**
+ *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.
+ */
+/*
+ * linked_list_iterator.c
+ *
+ *  \date       Jul 16, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "linked_list_iterator.h"
+#include "linked_list_private.h"
+
+struct linkedListIterator {
+	linked_list_entry_pt lastReturned;
+	linked_list_entry_pt next;
+	int nextIndex;
+	linked_list_pt list;
+	int expectedModificationCount;
+};
+
+linked_list_iterator_pt linkedListIterator_create(linked_list_pt list, unsigned int index) {
+	linked_list_iterator_pt iterator;
+	if (index > list->size) {
+		return NULL;
+	}
+	iterator = (linked_list_iterator_pt) malloc(sizeof(*iterator));
+	iterator->lastReturned = list->header;
+	iterator->list = list;
+	iterator->expectedModificationCount = list->modificationCount;
+	if (index < (list->size >> 1)) {
+		iterator->next = iterator->list->header->next;
+		for (iterator->nextIndex = 0; iterator->nextIndex < index; iterator->nextIndex++) {
+			iterator->next = iterator->next->next;
+		}
+	} else {
+		iterator->next = list->header;
+		for (iterator->nextIndex = list->size; iterator->nextIndex > index; iterator->nextIndex--) {
+			iterator->next = iterator->next->previous;
+		}
+	}
+	return iterator;
+}
+
+void linkedListIterator_destroy(linked_list_iterator_pt iterator) {
+	iterator->expectedModificationCount = 0;
+	iterator->lastReturned = NULL;
+	iterator->list = NULL;
+	iterator->next = NULL;
+	iterator->nextIndex = 0;
+	free(iterator);
+}
+
+bool linkedListIterator_hasNext(linked_list_iterator_pt iterator) {
+	return iterator->nextIndex != iterator->list->size;
+}
+
+void * linkedListIterator_next(linked_list_iterator_pt iterator) {
+	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
+		return NULL;
+	}
+	if (iterator->nextIndex == iterator->list->size) {
+		return NULL;
+	}
+	iterator->lastReturned = iterator->next;
+	iterator->next = iterator->next->next;
+	iterator->nextIndex++;
+	return iterator->lastReturned->element;
+}
+
+bool linkedListIterator_hasPrevious(linked_list_iterator_pt iterator) {
+	return iterator->nextIndex != 0;
+}
+
+void * linkedListIterator_previous(linked_list_iterator_pt iterator) {
+	if (iterator->nextIndex == 0) {
+		return NULL;
+	}
+
+	iterator->lastReturned = iterator->next = iterator->next->previous;
+	iterator->nextIndex--;
+
+	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
+		return NULL;
+	}
+
+	return iterator->lastReturned->element;
+}
+
+int linkedListIterator_nextIndex(linked_list_iterator_pt iterator) {
+	return iterator->nextIndex;
+}
+
+int linkedListIterator_previousIndex(linked_list_iterator_pt iterator) {
+	return iterator->nextIndex-1;
+}
+
+void linkedListIterator_remove(linked_list_iterator_pt iterator) {
+	linked_list_entry_pt lastNext;
+	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
+		return;
+	}
+	lastNext = iterator->lastReturned->next;
+	if (linkedList_removeEntry(iterator->list, iterator->lastReturned) == NULL) {
+		return;
+	}
+	if (iterator->next == iterator->lastReturned) {
+		iterator->next = lastNext;
+	} else {
+		iterator->nextIndex--;
+	}
+	iterator->lastReturned = iterator->list->header;
+	iterator->expectedModificationCount++;
+}
+
+void linkedListIterator_set(linked_list_iterator_pt iterator, void * element) {
+	if (iterator->lastReturned == iterator->list->header) {
+		return;
+	}
+	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
+		return;
+	}
+	iterator->lastReturned->element = element;
+}
+
+void linkedListIterator_add(linked_list_iterator_pt iterator, void * element) {
+	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
+		return;
+	}
+	iterator->lastReturned = iterator->list->header;
+	linkedList_addBefore(iterator->list, element, iterator->next);
+	iterator->nextIndex++;
+	iterator->expectedModificationCount++;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/linked_list_private.h
----------------------------------------------------------------------
diff --git a/utils/src/linked_list_private.h b/utils/src/linked_list_private.h
new file mode 100644
index 0000000..dcb0a46
--- /dev/null
+++ b/utils/src/linked_list_private.h
@@ -0,0 +1,44 @@
+/**
+ *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.
+ */
+/*
+ * linked_list_private.h
+ *
+ *  \date       Jul 16, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LINKED_LIST_PRIVATE_H_
+#define LINKED_LIST_PRIVATE_H_
+
+#include "linked_list.h"
+
+struct linked_list_entry {
+	void * element;
+	struct linked_list_entry * next;
+	struct linked_list_entry * previous;
+};
+
+struct linked_list {
+	linked_list_entry_pt header;
+	size_t size;
+	int modificationCount;
+};
+
+#endif /* LINKED_LIST_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/memstream/fmemopen.c
----------------------------------------------------------------------
diff --git a/utils/src/memstream/fmemopen.c b/utils/src/memstream/fmemopen.c
new file mode 100644
index 0000000..cb1b0c0
--- /dev/null
+++ b/utils/src/memstream/fmemopen.c
@@ -0,0 +1,76 @@
+
+/*
+ * fmem.c : fmemopen() on top of BSD's funopen()
+ * 20081017 AF
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+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 > 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);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/memstream/open_memstream.c
----------------------------------------------------------------------
diff --git a/utils/src/memstream/open_memstream.c b/utils/src/memstream/open_memstream.c
new file mode 100644
index 0000000..6bc4f01
--- /dev/null
+++ b/utils/src/memstream/open_memstream.c
@@ -0,0 +1,130 @@
+/* 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/a1c30887/utils/src/properties.c
----------------------------------------------------------------------
diff --git a/utils/src/properties.c b/utils/src/properties.c
new file mode 100644
index 0000000..0bd6dc3
--- /dev/null
+++ b/utils/src/properties.c
@@ -0,0 +1,302 @@
+/**
+ *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.
+ */
+/*
+ * properties.c
+ *
+ *  \date       Apr 27, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "celixbool.h"
+#include "properties.h"
+#include "utils.h"
+
+#define MALLOC_BLOCK_SIZE		5
+
+static void parseLine(const char* line, properties_pt props);
+
+properties_pt properties_create(void) {
+	return hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
+}
+
+void properties_destroy(properties_pt properties) {
+	hash_map_iterator_pt iter = hashMapIterator_create(properties);
+	while (hashMapIterator_hasNext(iter)) {
+		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+		free(hashMapEntry_getKey(entry));
+		free(hashMapEntry_getValue(entry));
+	}
+	hashMapIterator_destroy(iter);
+	hashMap_destroy(properties, false, false);
+}
+
+properties_pt properties_load(const char* filename) {
+	FILE *file = fopen(filename, "r");
+	if(file==NULL){
+		return NULL;
+	}
+	properties_pt props = properties_loadWithStream(file);
+	fclose(file);
+	return props;
+}
+
+properties_pt properties_loadWithStream(FILE *file) {
+	properties_pt props = NULL;
+
+
+	if (file != NULL ) {
+		char *saveptr;
+		char *filebuffer = NULL;
+		char *line = NULL;
+		size_t file_size = 0;
+
+		props = properties_create();
+		fseek(file, 0, SEEK_END);
+		file_size = ftell(file);
+		fseek(file, 0, SEEK_SET);
+
+		if(file_size > 0){
+			filebuffer = calloc(file_size + 1, sizeof(char));
+			if(filebuffer) {
+				size_t rs = fread(filebuffer, sizeof(char), file_size, file);
+				if(rs != file_size){
+					fprintf(stderr,"fread read only %lu bytes out of %lu\n",rs,file_size);
+				}
+				filebuffer[file_size]='\0';
+				line = strtok_r(filebuffer, "\n", &saveptr);
+				while ( line != NULL ) {
+					parseLine(line, props);
+					line = strtok_r(NULL, "\n", &saveptr);
+				}
+				free(filebuffer);
+			}
+		}
+	}
+
+	return props;
+}
+
+
+/**
+ * Header is ignored for now, cannot handle comments yet
+ */
+void properties_store(properties_pt properties, const char* filename, const char* header) {
+	FILE *file = fopen ( filename, "w+" );
+	char *str;
+
+	if (file != NULL) {
+		if (hashMap_size(properties) > 0) {
+			hash_map_iterator_pt iterator = hashMapIterator_create(properties);
+			while (hashMapIterator_hasNext(iterator)) {
+				hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
+				str = hashMapEntry_getKey(entry);
+				for (int i = 0; i < strlen(str); i += 1) {
+					if (str[i] == '#' || str[i] == '!' || str[i] == '=' || str[i] == ':') {
+						fputc('\\', file);
+					}
+					fputc(str[i], file);
+				}
+
+				fputc('=', file);
+
+				str = hashMapEntry_getValue(entry);
+				for (int i = 0; i < strlen(str); i += 1) {
+					if (str[i] == '#' || str[i] == '!' || str[i] == '=' || str[i] == ':') {
+						fputc('\\', file);
+					}
+					fputc(str[i], file);
+				}
+
+				fputc('\n', file);
+
+			}
+			hashMapIterator_destroy(iterator);
+		}
+		fclose(file);
+	} else {
+		perror("File is null");
+	}
+}
+
+celix_status_t properties_copy(properties_pt properties, properties_pt *out) {
+	celix_status_t status = CELIX_SUCCESS;
+	properties_pt copy = properties_create();
+
+	if (copy != NULL) {
+		hash_map_iterator_pt iter = hashMapIterator_create(properties);
+		while (hashMapIterator_hasNext(iter)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+			char *key = hashMapEntry_getKey(entry);
+			char *value = hashMapEntry_getValue(entry);
+			properties_set(copy, key, value);
+		}
+		hashMapIterator_destroy(iter);
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*out = copy;
+	}
+
+	return status;
+}
+
+const char* properties_get(properties_pt properties, const char* key) {
+	return hashMap_get(properties, (void*)key);
+}
+
+const char* properties_getWithDefault(properties_pt properties, const char* key, const char* defaultValue) {
+	const char* value = properties_get(properties, key);
+	return value == NULL ? defaultValue : value;
+}
+
+void properties_set(properties_pt properties, const char* key, const char* value) {
+	hash_map_entry_pt entry = hashMap_getEntry(properties, key);
+	char* oldValue = NULL;
+	if (entry != NULL) {
+		char* oldKey = hashMapEntry_getKey(entry);
+		oldValue = hashMapEntry_getValue(entry);
+		hashMap_put(properties, oldKey, strndup(value, 1024*10));
+	} else {
+		hashMap_put(properties, strndup(key, 1024*10), strndup(value, 1024*10));
+	}
+	free(oldValue);
+}
+
+static void updateBuffers(char **key, char ** value, char **output, int outputPos, int *key_len, int *value_len) {
+	if (*output == *key) {
+		if (outputPos == (*key_len) - 1) {
+			(*key_len) += MALLOC_BLOCK_SIZE;
+			*key = realloc(*key, *key_len);
+			*output = *key;
+		}
+	}
+	else {
+		if (outputPos == (*value_len) - 1) {
+			(*value_len) += MALLOC_BLOCK_SIZE;
+			*value = realloc(*value, *value_len);
+			*output = *value;
+		}
+	}
+}
+
+static void parseLine(const char* line, properties_pt props) {
+	int linePos = 0;
+	bool precedingCharIsBackslash = false;
+	bool isComment = false;
+	int outputPos = 0;
+	char *output = NULL;
+	int key_len = MALLOC_BLOCK_SIZE;
+	int value_len = MALLOC_BLOCK_SIZE;
+	linePos = 0;
+	precedingCharIsBackslash = false;
+	isComment = false;
+	output = NULL;
+	outputPos = 0;
+
+	//Ignore empty lines
+	if (line[0] == '\n' && line[1] == '\0') {
+		return;
+	}
+
+	char *key = calloc(1, key_len);
+	char *value = calloc(1, value_len);
+	key[0] = '\0';
+	value[0] = '\0';
+
+	while (line[linePos] != '\0') {
+		if (line[linePos] == ' ' || line[linePos] == '\t') {
+			if (output == NULL) {
+				//ignore
+				linePos += 1;
+				continue;
+			}
+		}
+		else {
+			if (output == NULL) {
+				output = key;
+			}
+		}
+		if (line[linePos] == '=' || line[linePos] == ':' || line[linePos] == '#' || line[linePos] == '!') {
+			if (precedingCharIsBackslash) {
+				//escaped special character
+				output[outputPos++] = line[linePos];
+				updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+				precedingCharIsBackslash = false;
+			}
+			else {
+				if (line[linePos] == '#' || line[linePos] == '!') {
+					if (outputPos == 0) {
+						isComment = true;
+						break;
+					}
+					else {
+						output[outputPos++] = line[linePos];
+						updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+					}
+				}
+				else { // = or :
+					if (output == value) { //already have a seperator
+						output[outputPos++] = line[linePos];
+						updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+					}
+					else {
+						output[outputPos++] = '\0';
+						updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+						output = value;
+						outputPos = 0;
+					}
+				}
+			}
+		}
+		else if (line[linePos] == '\\') {
+			if (precedingCharIsBackslash) { //double backslash -> backslash
+				output[outputPos++] = '\\';
+				updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+			}
+			precedingCharIsBackslash = true;
+		}
+		else { //normal character
+			precedingCharIsBackslash = false;
+			output[outputPos++] = line[linePos];
+			updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+		}
+		linePos += 1;
+	}
+	if (output != NULL) {
+		output[outputPos] = '\0';
+	}
+
+	if (!isComment) {
+		//printf("putting 'key'/'value' '%s'/'%s' in properties\n", utils_stringTrim(key), utils_stringTrim(value));
+		properties_set(props, utils_stringTrim(key), utils_stringTrim(value));
+	}
+	if(key) {
+		free(key);
+	}
+	if(value) {
+		free(value);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/thpool.c
----------------------------------------------------------------------
diff --git a/utils/src/thpool.c b/utils/src/thpool.c
new file mode 100644
index 0000000..5121fca
--- /dev/null
+++ b/utils/src/thpool.c
@@ -0,0 +1,535 @@
+/* ********************************
+ * Author:       Johan Hanssen Seferidis
+ * License:	     MIT
+ * Description:  Library providing a threading pool where you can add
+ *               work. For usage, check the thpool.h file or README.md
+ *
+ *//** @file thpool.h *//*
+ * 
+ ********************************/
+
+
+#include <unistd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <errno.h>
+#include <time.h> 
+#include "thpool.h"
+
+#ifdef THPOOL_DEBUG
+#define THPOOL_DEBUG 1
+#else
+#define THPOOL_DEBUG 0
+#endif
+
+static volatile int threads_keepalive;
+static volatile int threads_on_hold;
+
+
+
+/* ========================== STRUCTURES ============================ */
+
+
+/* Binary semaphore */
+typedef struct bsem {
+	pthread_mutex_t mutex;
+	pthread_cond_t   cond;
+	int v;
+} bsem;
+
+
+/* Job */
+typedef struct job{
+	struct job*  prev;                   /* pointer to previous job   */
+	void*  (*function)(void* arg);       /* function pointer          */
+	void*  arg;                          /* function's argument       */
+} job;
+
+
+/* Job queue */
+typedef struct jobqueue{
+	pthread_mutex_t rwmutex;             /* used for queue r/w access */
+	job  *front;                         /* pointer to front of queue */
+	job  *rear;                          /* pointer to rear  of queue */
+	bsem *has_jobs;                      /* flag as binary semaphore  */
+	int   len;                           /* number of jobs in queue   */
+} jobqueue;
+
+
+/* Thread */
+typedef struct thread{
+	int       id;                        /* friendly id               */
+	pthread_t pthread;                   /* pointer to actual thread  */
+	struct thpool_* thpool_p;            /* access to thpool          */
+} thread;
+
+
+/* Threadpool */
+typedef struct thpool_{
+	thread**   threads;                  /* pointer to threads        */
+	volatile int num_threads_alive;      /* threads currently alive   */
+	volatile int num_threads_working;    /* threads currently working */
+	pthread_mutex_t  thcount_lock;       /* used for thread count etc */
+	pthread_cond_t  threads_all_idle;    /* signal to thpool_wait     */
+	jobqueue*  jobqueue_p;               /* pointer to the job queue  */    
+} thpool_;
+
+
+
+
+
+/* ========================== PROTOTYPES ============================ */
+
+
+static void  thread_init(thpool_* thpool_p, struct thread** thread_p, int id);
+static void* thread_do(struct thread* thread_p);
+static void  thread_hold();
+static void  thread_destroy(struct thread* thread_p);
+
+static int   jobqueue_init(thpool_* thpool_p);
+static void  jobqueue_clear(thpool_* thpool_p);
+static void  jobqueue_push(thpool_* thpool_p, struct job* newjob_p);
+static struct job* jobqueue_pull(thpool_* thpool_p);
+static void  jobqueue_destroy(thpool_* thpool_p);
+
+static void  bsem_init(struct bsem *bsem_p, int value);
+static void  bsem_reset(struct bsem *bsem_p);
+static void  bsem_post(struct bsem *bsem_p);
+static void  bsem_post_all(struct bsem *bsem_p);
+static void  bsem_wait(struct bsem *bsem_p);
+
+
+
+
+
+/* ========================== THREADPOOL ============================ */
+
+
+/* Initialise thread pool */
+struct thpool_* thpool_init(int num_threads){
+
+	threads_on_hold   = 0;
+	threads_keepalive = 1;
+
+	if ( num_threads < 0){
+		num_threads = 0;
+	}
+
+	/* Make new thread pool */
+	thpool_* thpool_p;
+	thpool_p = (struct thpool_*)malloc(sizeof(struct thpool_));
+	if (thpool_p == NULL){
+		fprintf(stderr, "thpool_init(): Could not allocate memory for thread pool\n");
+		return NULL;
+	}
+	thpool_p->num_threads_alive   = 0;
+	thpool_p->num_threads_working = 0;
+
+	/* Initialise the job queue */
+	if (jobqueue_init(thpool_p) == -1){
+		fprintf(stderr, "thpool_init(): Could not allocate memory for job queue\n");
+		free(thpool_p);
+		return NULL;
+	}
+
+	/* Make threads in pool */
+	thpool_p->threads = (struct thread**)malloc(num_threads * sizeof(struct thread*));
+	if (thpool_p->threads == NULL){
+		fprintf(stderr, "thpool_init(): Could not allocate memory for threads\n");
+		jobqueue_destroy(thpool_p);
+		free(thpool_p->jobqueue_p);
+		free(thpool_p);
+		return NULL;
+	}
+
+	pthread_mutex_init(&(thpool_p->thcount_lock), NULL);
+	pthread_cond_init(&thpool_p->threads_all_idle, NULL);
+	
+	/* Thread init */
+	int n;
+	for (n=0; n<num_threads; n++){
+		thread_init(thpool_p, &thpool_p->threads[n], n);
+		if (THPOOL_DEBUG)
+			printf("THPOOL_DEBUG: Created thread %d in pool \n", n);
+	}
+	
+	/* Wait for threads to initialize */
+	while (thpool_p->num_threads_alive != num_threads) {}
+
+	return thpool_p;
+}
+
+
+/* Add work to the thread pool */
+int thpool_add_work(thpool_* thpool_p, void *(*function_p)(void*), void* arg_p){
+	job* newjob;
+
+	newjob=(struct job*)malloc(sizeof(struct job));
+	if (newjob==NULL){
+		fprintf(stderr, "thpool_add_work(): Could not allocate memory for new job\n");
+		return -1;
+	}
+
+	/* add function and argument */
+	newjob->function=function_p;
+	newjob->arg=arg_p;
+
+	/* add job to queue */
+	pthread_mutex_lock(&thpool_p->jobqueue_p->rwmutex);
+	jobqueue_push(thpool_p, newjob);
+	pthread_mutex_unlock(&thpool_p->jobqueue_p->rwmutex);
+
+	return 0;
+}
+
+
+/* Wait until all jobs have finished */
+void thpool_wait(thpool_* thpool_p){
+	pthread_mutex_lock(&thpool_p->thcount_lock);
+	while (thpool_p->jobqueue_p->len || thpool_p->num_threads_working) {
+		pthread_cond_wait(&thpool_p->threads_all_idle, &thpool_p->thcount_lock);
+	}
+	pthread_mutex_unlock(&thpool_p->thcount_lock);
+}
+
+
+/* Destroy the threadpool */
+void thpool_destroy(thpool_* thpool_p){
+	
+	volatile int threads_total = thpool_p->num_threads_alive;
+
+	/* End each thread 's infinite loop */
+	threads_keepalive = 0;
+	
+	/* Give one second to kill idle threads */
+	double TIMEOUT = 1.0;
+	time_t start, end;
+	double tpassed = 0.0;
+	time (&start);
+	while (tpassed < TIMEOUT && thpool_p->num_threads_alive){
+		bsem_post_all(thpool_p->jobqueue_p->has_jobs);
+		time (&end);
+		tpassed = difftime(end,start);
+	}
+	
+	/* Poll remaining threads */
+	while (thpool_p->num_threads_alive){
+		bsem_post_all(thpool_p->jobqueue_p->has_jobs);
+		sleep(1);
+	}
+
+	/* Job queue cleanup */
+	jobqueue_destroy(thpool_p);
+	free(thpool_p->jobqueue_p);
+	
+	/* Deallocs */
+	int n;
+	for (n=0; n < threads_total; n++){
+		thread_destroy(thpool_p->threads[n]);
+	}
+	free(thpool_p->threads);
+	free(thpool_p);
+}
+
+
+/* Pause all threads in threadpool */
+void thpool_pause(thpool_* thpool_p) {
+	int n;
+	for (n=0; n < thpool_p->num_threads_alive; n++){
+		pthread_kill(thpool_p->threads[n]->pthread, SIGUSR1);
+	}
+}
+
+
+/* Resume all threads in threadpool */
+void thpool_resume(thpool_* thpool_p) {
+	threads_on_hold = 0;
+}
+
+
+
+
+
+/* ============================ THREAD ============================== */
+
+
+/* Initialize a thread in the thread pool
+ * 
+ * @param thread        address to the pointer of the thread to be created
+ * @param id            id to be given to the thread
+ * 
+ */
+static void thread_init (thpool_* thpool_p, struct thread** thread_p, int id){
+	
+	*thread_p = (struct thread*)malloc(sizeof(struct thread));
+	if (*thread_p == NULL){
+		fprintf(stderr, "thpool_init(): Could not allocate memory for thread\n");
+		exit(1);
+	}
+
+	(*thread_p)->thpool_p = thpool_p;
+	(*thread_p)->id       = id;
+
+	pthread_create(&(*thread_p)->pthread, NULL, (void *)thread_do, (*thread_p));
+	pthread_detach((*thread_p)->pthread);
+	
+}
+
+
+/* Sets the calling thread on hold */
+static void thread_hold () {
+	threads_on_hold = 1;
+	while (threads_on_hold){
+		sleep(1);
+	}
+}
+
+
+/* What each thread is doing
+* 
+* In principle this is an endless loop. The only time this loop gets interuppted is once
+* thpool_destroy() is invoked or the program exits.
+* 
+* @param  thread        thread that will run this function
+* @return nothing
+*/
+static void* thread_do(struct thread* thread_p){
+
+	/* Set thread name for profiling and debuging */
+	char thread_name[128] = {0};
+	sprintf(thread_name, "thread-pool-%d", thread_p->id);
+
+#if defined(__linux__)
+	pthread_setname_np(thread_p->pthread, thread_name);
+#elif defined(__APPLE__) && defined(__MACH__)
+	pthread_setname_np(thread_name);
+#else
+	fprintf(stderr, "thread_do(): pthread_setname_np is not supported on this system");
+#endif
+
+	/* Assure all threads have been created before starting serving */
+	thpool_* thpool_p = thread_p->thpool_p;
+	
+	/* Register signal handler */
+	struct sigaction act;
+	sigemptyset(&act.sa_mask);
+	act.sa_flags = 0;
+	act.sa_handler = thread_hold;
+	if (sigaction(SIGUSR1, &act, NULL) == -1) {
+		fprintf(stderr, "thread_do(): cannot handle SIGUSR1");
+	}
+	
+	/* Mark thread as alive (initialized) */
+	pthread_mutex_lock(&thpool_p->thcount_lock);
+	thpool_p->num_threads_alive += 1;
+	pthread_mutex_unlock(&thpool_p->thcount_lock);
+
+	while(threads_keepalive){
+
+		bsem_wait(thpool_p->jobqueue_p->has_jobs);
+
+		if (threads_keepalive){
+			
+			pthread_mutex_lock(&thpool_p->thcount_lock);
+			thpool_p->num_threads_working++;
+			pthread_mutex_unlock(&thpool_p->thcount_lock);
+			
+			/* Read job from queue and execute it */
+			void*(*func_buff)(void* arg);
+			void*  arg_buff;
+			job* job_p;
+			pthread_mutex_lock(&thpool_p->jobqueue_p->rwmutex);
+			job_p = jobqueue_pull(thpool_p);
+			pthread_mutex_unlock(&thpool_p->jobqueue_p->rwmutex);
+			if (job_p) {
+				func_buff = job_p->function;
+				arg_buff  = job_p->arg;
+				func_buff(arg_buff);
+				free(job_p);
+			}
+			
+			pthread_mutex_lock(&thpool_p->thcount_lock);
+			thpool_p->num_threads_working--;
+			if (!thpool_p->num_threads_working) {
+				pthread_cond_signal(&thpool_p->threads_all_idle);
+			}
+			pthread_mutex_unlock(&thpool_p->thcount_lock);
+
+		}
+	}
+	pthread_mutex_lock(&thpool_p->thcount_lock);
+	thpool_p->num_threads_alive --;
+	pthread_mutex_unlock(&thpool_p->thcount_lock);
+
+	return NULL;
+}
+
+
+/* Frees a thread  */
+static void thread_destroy (thread* thread_p){
+	free(thread_p);
+}
+
+
+
+
+
+/* ============================ JOB QUEUE =========================== */
+
+
+/* Initialize queue */
+static int jobqueue_init(thpool_* thpool_p){
+	
+	thpool_p->jobqueue_p = (struct jobqueue*)malloc(sizeof(struct jobqueue));
+	if (thpool_p->jobqueue_p == NULL){
+		return -1;
+	}
+	thpool_p->jobqueue_p->len = 0;
+	thpool_p->jobqueue_p->front = NULL;
+	thpool_p->jobqueue_p->rear  = NULL;
+
+	thpool_p->jobqueue_p->has_jobs = (struct bsem*)malloc(sizeof(struct bsem));
+	if (thpool_p->jobqueue_p->has_jobs == NULL){
+		return -1;
+	}
+
+	pthread_mutex_init(&(thpool_p->jobqueue_p->rwmutex), NULL);
+	bsem_init(thpool_p->jobqueue_p->has_jobs, 0);
+
+	return 0;
+}
+
+
+/* Clear the queue */
+static void jobqueue_clear(thpool_* thpool_p){
+
+	while(thpool_p->jobqueue_p->len){
+		free(jobqueue_pull(thpool_p));
+	}
+
+	thpool_p->jobqueue_p->front = NULL;
+	thpool_p->jobqueue_p->rear  = NULL;
+	bsem_reset(thpool_p->jobqueue_p->has_jobs);
+	thpool_p->jobqueue_p->len = 0;
+
+}
+
+
+/* Add (allocated) job to queue
+ *
+ * Notice: Caller MUST hold a mutex
+ */
+static void jobqueue_push(thpool_* thpool_p, struct job* newjob){
+
+	newjob->prev = NULL;
+
+	switch(thpool_p->jobqueue_p->len){
+
+		case 0:  /* if no jobs in queue */
+					thpool_p->jobqueue_p->front = newjob;
+					thpool_p->jobqueue_p->rear  = newjob;
+					break;
+
+		default: /* if jobs in queue */
+					thpool_p->jobqueue_p->rear->prev = newjob;
+					thpool_p->jobqueue_p->rear = newjob;
+					
+	}
+	thpool_p->jobqueue_p->len++;
+	
+	bsem_post(thpool_p->jobqueue_p->has_jobs);
+}
+
+
+/* Get first job from queue(removes it from queue)
+ * 
+ * Notice: Caller MUST hold a mutex
+ */
+static struct job* jobqueue_pull(thpool_* thpool_p){
+
+	job* job_p;
+	job_p = thpool_p->jobqueue_p->front;
+
+	switch(thpool_p->jobqueue_p->len){
+		
+		case 0:  /* if no jobs in queue */
+		  			break;
+		
+		case 1:  /* if one job in queue */
+					thpool_p->jobqueue_p->front = NULL;
+					thpool_p->jobqueue_p->rear  = NULL;
+					thpool_p->jobqueue_p->len = 0;
+					break;
+		
+		default: /* if >1 jobs in queue */
+					thpool_p->jobqueue_p->front = job_p->prev;
+					thpool_p->jobqueue_p->len--;
+					/* more than one job in queue -> post it */
+					bsem_post(thpool_p->jobqueue_p->has_jobs);
+					
+	}
+	
+	return job_p;
+}
+
+
+/* Free all queue resources back to the system */
+static void jobqueue_destroy(thpool_* thpool_p){
+	jobqueue_clear(thpool_p);
+	free(thpool_p->jobqueue_p->has_jobs);
+}
+
+
+
+
+
+/* ======================== SYNCHRONISATION ========================= */
+
+
+/* Init semaphore to 1 or 0 */
+static void bsem_init(bsem *bsem_p, int value) {
+	if (value < 0 || value > 1) {
+		fprintf(stderr, "bsem_init(): Binary semaphore can take only values 1 or 0");
+		exit(1);
+	}
+	pthread_mutex_init(&(bsem_p->mutex), NULL);
+	pthread_cond_init(&(bsem_p->cond), NULL);
+	bsem_p->v = value;
+}
+
+
+/* Reset semaphore to 0 */
+static void bsem_reset(bsem *bsem_p) {
+	bsem_init(bsem_p, 0);
+}
+
+
+/* Post to at least one thread */
+static void bsem_post(bsem *bsem_p) {
+	pthread_mutex_lock(&bsem_p->mutex);
+	bsem_p->v = 1;
+	pthread_cond_signal(&bsem_p->cond);
+	pthread_mutex_unlock(&bsem_p->mutex);
+}
+
+
+/* Post to all threads */
+static void bsem_post_all(bsem *bsem_p) {
+	pthread_mutex_lock(&bsem_p->mutex);
+	bsem_p->v = 1;
+	pthread_cond_broadcast(&bsem_p->cond);
+	pthread_mutex_unlock(&bsem_p->mutex);
+}
+
+
+/* Wait on semaphore until semaphore has value 0 */
+static void bsem_wait(bsem* bsem_p) {
+	pthread_mutex_lock(&bsem_p->mutex);
+	while (bsem_p->v != 1) {
+		pthread_cond_wait(&bsem_p->cond, &bsem_p->mutex);
+	}
+	bsem_p->v = 0;
+	pthread_mutex_unlock(&bsem_p->mutex);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/utils.c
----------------------------------------------------------------------
diff --git a/utils/src/utils.c b/utils/src/utils.c
new file mode 100644
index 0000000..fc4d538
--- /dev/null
+++ b/utils/src/utils.c
@@ -0,0 +1,141 @@
+/**
+ *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.
+ */
+/*
+ * utils.c
+ *
+ *  \date       Jul 27, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "utils.h"
+
+unsigned int utils_stringHash(const void* strPtr) {
+    const char* string = strPtr;
+    unsigned int hc = 5381;
+    char ch;
+    while((ch = *string++) != '\0'){
+        hc = (hc << 5) + hc + ch;
+    }
+
+    return hc;
+}
+
+int utils_stringEquals(const void* string, const void* toCompare) {
+	return strcmp((const char*)string, (const char*)toCompare) == 0;
+}
+
+char * string_ndup(const char *s, size_t n) {
+	size_t len = strlen(s);
+	char *ret;
+
+	if (len <= n) {
+		return strdup(s);
+	}
+
+	ret = malloc(n + 1);
+	strncpy(ret, s, n);
+	ret[n] = '\0';
+	return ret;
+}
+
+char * utils_stringTrim(char * string) {
+	char* copy = string;
+
+	char *end;
+	// Trim leading space
+	while (isspace(*copy)) {
+		copy++;
+	}
+
+	// Trim trailing space
+	end = copy + strlen(copy) - 1;
+	while(end > copy && isspace(*end)) {
+		*(end) = '\0';
+		end--;
+	}
+
+	if (copy != string) { 
+		//beginning whitespaces -> move char in copy to to begin string
+		//This to ensure free still works on the same pointer.
+		char* nstring = string;
+		while(*copy != '\0') {
+			*(nstring++) = *(copy++);
+		}
+		(*nstring) = '\0';
+	}
+
+	return string;
+}
+
+bool utils_isStringEmptyOrNull(const char * const str) {
+	bool empty = true;
+	if (str != NULL) {
+		int i;
+		for (i = 0; i < strnlen(str, 1024 * 1024); i += 1) {
+			if (!isspace(str[i])) {
+				empty = false;
+				break;
+			}
+		}
+	}
+
+	return empty;
+}
+
+celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	celix_thread_t self = celixThread_self();
+	if (status == CELIX_SUCCESS) {
+		*equals = celixThread_equals(self, thread);
+	}
+
+	return status;
+}
+
+celix_status_t utils_isNumeric(const char *number, bool *ret) {
+	celix_status_t status = CELIX_SUCCESS;
+	*ret = true;
+	while(*number) {
+		if(!isdigit(*number) && *number != '.') {
+			*ret = false;
+			break;
+		}
+		number++;
+	}
+	return status;
+}
+
+
+int utils_compareServiceIdsAndRanking(unsigned long servId, long servRank, unsigned long otherServId, long otherServRank) {
+	int result;
+
+	if (servId == otherServId) {
+		result = 0;
+	} else if (servRank != otherServRank) {
+		result = servRank < otherServRank ? -1 : 1;
+	} else { //equal service rank, compare service ids
+		result = servId < otherServId ? 1 : -1;
+	}
+
+	return result;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/version.c
----------------------------------------------------------------------
diff --git a/utils/src/version.c b/utils/src/version.c
new file mode 100644
index 0000000..cb2703d
--- /dev/null
+++ b/utils/src/version.c
@@ -0,0 +1,264 @@
+/**
+ *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.
+ */
+/*
+ * version.c
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "celix_errno.h"
+#include "version_private.h"
+
+celix_status_t version_createVersion(int major, int minor, int micro, char * qualifier, version_pt *version) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (*version != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*version = (version_pt) malloc(sizeof(**version));
+		if (!*version) {
+			status = CELIX_ENOMEM;
+		} else {
+			unsigned int i;
+
+			(*version)->major = major;
+			(*version)->minor = minor;
+			(*version)->micro = micro;
+			if (qualifier == NULL) {
+				qualifier = "";
+			}
+			(*version)->qualifier = strdup(qualifier);
+
+			if (major < 0) {
+				status = CELIX_ILLEGAL_ARGUMENT;
+			}
+			if (minor < 0) {
+				status = CELIX_ILLEGAL_ARGUMENT;
+			}
+			if (micro < 0) {
+				status = CELIX_ILLEGAL_ARGUMENT;
+			}
+
+			for (i = 0; i < strlen(qualifier); i++) {
+				char ch = qualifier[i];
+				if (('A' <= ch) && (ch <= 'Z')) {
+					continue;
+				}
+				if (('a' <= ch) && (ch <= 'z')) {
+					continue;
+				}
+				if (('0' <= ch) && (ch <= '9')) {
+					continue;
+				}
+				if ((ch == '_') || (ch == '-')) {
+					continue;
+				}
+				status = CELIX_ILLEGAL_ARGUMENT;
+				break;
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t version_clone(version_pt version, version_pt *clone) {
+	return version_createVersion(version->major, version->minor, version->micro, version->qualifier, clone);
+}
+
+celix_status_t version_destroy(version_pt version) {
+	version->major = 0;
+	version->minor = 0;
+	version->micro = 0;
+	free(version->qualifier);
+	version->qualifier = NULL;
+	free(version);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t version_createVersionFromString(const char * versionStr, version_pt *version) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	int major = 0;
+	int minor = 0;
+	int micro = 0;
+	char * qualifier = NULL;
+
+	char delims[] = ".";
+	char *token = NULL;
+	char *last = NULL;
+
+	int i = 0;
+
+	char* versionWrkStr = strdup(versionStr);
+
+	token = strtok_r(versionWrkStr, delims, &last);
+	if (token != NULL) {
+		for (i = 0; i < strlen(token); i++) {
+			char ch = token[i];
+			if (('0' <= ch) && (ch <= '9')) {
+				continue;
+			}
+			status = CELIX_ILLEGAL_ARGUMENT;
+			break;
+		}
+		major = atoi(token);
+		token = strtok_r(NULL, delims, &last);
+		if (token != NULL) {
+			for (i = 0; i < strlen(token); i++) {
+				char ch = token[i];
+				if (('0' <= ch) && (ch <= '9')) {
+					continue;
+				}
+				status = CELIX_ILLEGAL_ARGUMENT;
+				break;
+			}
+			minor = atoi(token);
+			token = strtok_r(NULL, delims, &last);
+			if (token != NULL) {
+				for (i = 0; i < strlen(token); i++) {
+					char ch = token[i];
+					if (('0' <= ch) && (ch <= '9')) {
+						continue;
+					}
+					status = CELIX_ILLEGAL_ARGUMENT;
+					break;
+				}
+				micro = atoi(token);
+				token = strtok_r(NULL, delims, &last);
+				if (token != NULL) {
+					qualifier = strdup(token);
+					token = strtok_r(NULL, delims, &last);
+					if (token != NULL) {
+						*version = NULL;
+						status = CELIX_ILLEGAL_ARGUMENT;
+					}
+				}
+			}
+		}
+	}
+
+	free(versionWrkStr);
+
+	if (status == CELIX_SUCCESS) {
+		status = version_createVersion(major, minor, micro, qualifier, version);
+	}
+
+	if (qualifier != NULL) {
+	    free(qualifier);
+	}
+
+	return status;
+}
+
+celix_status_t version_createEmptyVersion(version_pt *version) {
+	return version_createVersion(0, 0, 0, "", version);
+}
+
+celix_status_t version_getMajor(version_pt version, int *major) {
+	celix_status_t status = CELIX_SUCCESS;
+	*major = version->major;
+	return status;
+}
+
+celix_status_t version_getMinor(version_pt version, int *minor) {
+	celix_status_t status = CELIX_SUCCESS;
+	*minor = version->minor;
+	return status;
+}
+
+celix_status_t version_getMicro(version_pt version, int *micro) {
+	celix_status_t status = CELIX_SUCCESS;
+	*micro = version->micro;
+	return status;
+}
+
+celix_status_t version_getQualifier(version_pt version, const char **qualifier) {
+	celix_status_t status = CELIX_SUCCESS;
+	*qualifier = version->qualifier;
+	return status;
+}
+
+celix_status_t version_compareTo(version_pt version, version_pt compare, int *result) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (compare == version) {
+		*result = 0;
+	} else {
+		int res = version->major - compare->major;
+		if (res != 0) {
+			*result = res;
+		} else {
+			res = version->minor - compare->minor;
+			if (res != 0) {
+				*result = res;
+			} else {
+				res = version->micro - compare->micro;
+				if (res != 0) {
+					*result = res;
+				} else {
+					*result = strcmp(version->qualifier, compare->qualifier);
+				}
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t version_toString(version_pt version, char **string) {
+    celix_status_t status = CELIX_SUCCESS;
+	if (strlen(version->qualifier) > 0) {
+	    char str[512];
+	    int written = snprintf(str, 512, "%d.%d.%d.%s", version->major, version->minor, version->micro, version->qualifier);
+	    if (written >= 512 || written < 0) {
+	        status = CELIX_BUNDLE_EXCEPTION;
+	    }
+	    *string = strdup(str);
+	} else {
+	    char str[512];
+        int written = snprintf(str, 512, "%d.%d.%d", version->major, version->minor, version->micro);
+        if (written >= 512 || written < 0) {
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+        *string = strdup(str);
+	}
+	return status;
+}
+
+celix_status_t version_isCompatible(version_pt user, version_pt provider, bool* isCompatible) {
+    celix_status_t status = CELIX_SUCCESS;
+    bool result = false;
+
+    if (user == NULL || provider == NULL) {
+        return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (user->major == provider->major) {
+        result = (provider->minor >= user->minor);
+    }
+
+    *isCompatible = result;
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/version_private.h
----------------------------------------------------------------------
diff --git a/utils/src/version_private.h b/utils/src/version_private.h
new file mode 100644
index 0000000..15e5c89
--- /dev/null
+++ b/utils/src/version_private.h
@@ -0,0 +1,41 @@
+/**
+ *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.
+ */
+/*
+ * version_private.h
+ *
+ *  \date       Dec 18, 2012
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef VERSION_PRIVATE_H_
+#define VERSION_PRIVATE_H_
+
+#include "version.h"
+
+struct version {
+	int major;
+	int minor;
+	int micro;
+	char *qualifier;
+};
+
+
+#endif /* VERSION_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/version_range.c
----------------------------------------------------------------------
diff --git a/utils/src/version_range.c b/utils/src/version_range.c
new file mode 100644
index 0000000..ed681fd
--- /dev/null
+++ b/utils/src/version_range.c
@@ -0,0 +1,233 @@
+/**
+ *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.
+ */
+/*
+ * version_range.c
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "version_range_private.h"
+
+celix_status_t versionRange_createVersionRange(version_pt low, bool isLowInclusive,
+			version_pt high, bool isHighInclusive, version_range_pt *range) {
+	celix_status_t status = CELIX_SUCCESS;
+	*range = (version_range_pt) malloc(sizeof(**range));
+	if (!*range) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*range)->low = low;
+		(*range)->isLowInclusive = isLowInclusive;
+		(*range)->high = high;
+		(*range)->isHighInclusive = isHighInclusive;
+	}
+
+	return status;
+}
+
+celix_status_t versionRange_destroy(version_range_pt range) {
+    if (range->high != NULL) {
+        version_destroy(range->high);
+    }
+    if (range->low != NULL) {
+        version_destroy(range->low);
+    }
+
+	range->high = NULL;
+	range->isHighInclusive = false;
+	range->low = NULL;
+	range->isLowInclusive = false;
+
+	free(range);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t versionRange_createInfiniteVersionRange(version_range_pt *range) {
+	celix_status_t status;
+
+	version_pt version = NULL;
+	status = version_createEmptyVersion(&version);
+	if (status == CELIX_SUCCESS) {
+		status = versionRange_createVersionRange(version, true, NULL, true, range);
+	}
+
+	return status;
+}
+
+celix_status_t versionRange_isInRange(version_range_pt versionRange, version_pt version, bool *inRange) {
+	celix_status_t status;
+	if (versionRange->high == NULL) {
+		int cmp;
+		status = version_compareTo(version, versionRange->low, &cmp);
+		if (status == CELIX_SUCCESS) {
+			*inRange = (cmp >= 0);
+		}
+	} else if (versionRange->isLowInclusive && versionRange->isHighInclusive) {
+		int low, high;
+		status = version_compareTo(version, versionRange->low, &low);
+		if (status == CELIX_SUCCESS) {
+			status = version_compareTo(version, versionRange->high, &high);
+			if (status == CELIX_SUCCESS) {
+				*inRange = (low >= 0) && (high <= 0);
+			}
+		}
+	} else if (versionRange->isHighInclusive) {
+		int low, high;
+		status = version_compareTo(version, versionRange->low, &low);
+		if (status == CELIX_SUCCESS) {
+			status = version_compareTo(version, versionRange->high, &high);
+			if (status == CELIX_SUCCESS) {
+				*inRange = (low > 0) && (high <= 0);
+			}
+		}
+	} else if (versionRange->isLowInclusive) {
+		int low, high;
+		status = version_compareTo(version, versionRange->low, &low);
+		if (status == CELIX_SUCCESS) {
+			status = version_compareTo(version, versionRange->high, &high);
+			if (status == CELIX_SUCCESS) {
+				*inRange = (low >= 0) && (high < 0);
+			}
+		}
+	} else {
+		int low, high;
+		status = version_compareTo(version, versionRange->low, &low);
+		if (status == CELIX_SUCCESS) {
+			status = version_compareTo(version, versionRange->high, &high);
+			if (status == CELIX_SUCCESS) {
+				*inRange = (low > 0) && (high < 0);
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t versionRange_getLowVersion(version_range_pt versionRange, version_pt *lowVersion) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (versionRange == NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+    else {
+        *lowVersion = versionRange->low;
+    }
+
+    return status;
+}
+
+celix_status_t versionRange_isLowInclusive(version_range_pt versionRange, bool *isLowInclusive) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (versionRange == NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+    else {
+        *isLowInclusive = versionRange->isLowInclusive;
+    }
+
+    return status;
+}
+
+celix_status_t versionRange_getHighVersion(version_range_pt versionRange, version_pt *highVersion) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (versionRange == NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+    else {
+        *highVersion = versionRange->high;
+    }
+
+    return status;
+}
+
+celix_status_t versionRange_isHighInclusive(version_range_pt versionRange, bool *isHighInclusive) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (versionRange == NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+    else {
+        *isHighInclusive = versionRange->isHighInclusive;
+    }
+
+    return status;
+}
+
+
+celix_status_t versionRange_parse(const char * rangeStr, version_range_pt *range) {
+	celix_status_t status;
+	if (strchr(rangeStr, ',') != NULL) {
+			int vlowL = strcspn(rangeStr+1, ",");
+			char * vlow = (char *) malloc(sizeof(char) * (vlowL + 1));
+			if (!vlow) {
+				status = CELIX_ENOMEM;
+			} else {
+				int vhighL;
+				char * vhigh;
+				vlow = strncpy(vlow, rangeStr+1, vlowL);
+				vlow[vlowL] = '\0';
+				vhighL = strlen(rangeStr+1) - vlowL - 2;
+				vhigh = (char *) malloc(sizeof(char) * (vhighL+1));
+				if (!vhigh) {
+					status = CELIX_ENOMEM;
+				} else {					
+					version_pt versionLow = NULL;
+					int rangeL = strlen(rangeStr);
+					char start = rangeStr[0];
+					char end = rangeStr[rangeL-1];
+
+					vhigh = strncpy(vhigh, rangeStr+vlowL+2, vhighL);
+					vhigh[vhighL] = '\0';
+					status = version_createVersionFromString(vlow, &versionLow);
+					if (status == CELIX_SUCCESS) {
+						version_pt versionHigh = NULL;
+						status = version_createVersionFromString(vhigh, &versionHigh);
+						if (status == CELIX_SUCCESS) {
+							status = versionRange_createVersionRange(
+									versionLow,
+									start == '[',
+									versionHigh,
+									end ==']',
+									range
+								);
+						}
+					}
+					free(vhigh);
+				}
+				free(vlow);
+
+		}
+	} else {
+		version_pt version = NULL;
+		status = version_createVersionFromString(rangeStr, &version);
+		if (status == CELIX_SUCCESS) {
+			status = versionRange_createVersionRange(version, true, NULL, false, range);
+		}
+	}
+
+	return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/version_range_private.h
----------------------------------------------------------------------
diff --git a/utils/src/version_range_private.h b/utils/src/version_range_private.h
new file mode 100644
index 0000000..dfccd59
--- /dev/null
+++ b/utils/src/version_range_private.h
@@ -0,0 +1,41 @@
+/**
+ *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.
+ */
+/*
+ * version_range_private.h
+ *
+ *  \date       Dec 18, 2012
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef VERSION_RANGE_PRIVATE_H_
+#define VERSION_RANGE_PRIVATE_H_
+
+#include "version_range.h"
+
+struct versionRange {
+	version_pt low;
+	bool isLowInclusive;
+	version_pt high;
+	bool isHighInclusive;
+
+};
+
+#endif /* VERSION_RANGE_PRIVATE_H_ */


[19/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/bundle_activator.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle_activator.h b/framework/public/include/bundle_activator.h
deleted file mode 100644
index 1027351..0000000
--- a/framework/public/include/bundle_activator.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- *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.
- */
-/**
- *
- * @defgroup BundleActivator BundleActivator
- * @ingroup framework
- * @{
- *	\brief		Customizes the starting and stopping of a bundle.
- *	\details	\ref BundleActivator is a header that must be implemented by every
- * 				bundle. The Framework creates/starts/stops/destroys activator instances using the
- * 				functions described in this header. If the bundleActivator_start()
- * 				function executes successfully, it is guaranteed that the same instance's
- * 				bundleActivator_stop() function will be called when the bundle is
- * 				to be stopped. The same applies to the bundleActivator_create() and
- * 				bundleActivator_destroy() functions.
- * 				The Framework must not concurrently call the activator functions.
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \date      	March 18, 2010
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef BUNDLE_ACTIVATOR_H_
-#define BUNDLE_ACTIVATOR_H_
-
-#include "bundle_context.h"
-#include "framework_exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Called when this bundle is started so the bundle can create an instance for its activator.
- * The framework does not assume any type for the activator instance, this is implementation specific.
- * The activator instance is handle as a void pointer by the framework, the implementation must cast it to the
- * implementation specific type.
- *
- * @param context The execution context of the bundle being started.
- * @param[out] userData A pointer to the specific activator instance used by this bundle.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- Any other status code will mark the bundle as stopped and the framework will remove this
- * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
- */
-ACTIVATOR_EXPORT celix_status_t bundleActivator_create(bundle_context_pt context_ptr, void **userData);
-
-/**
- * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary
- * to start this bundle. This method can be used to register services or to allocate any resources that this
- * bundle needs.
- *
- * <p>
- * This method must complete and return to its caller in a timely manner.
- *
- * @param userData The activator instance to be used.
- * @param context The execution context of the bundle being started.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- Any other status code will mark the bundle as stopped and the framework will remove this
- * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
- */
-ACTIVATOR_EXPORT celix_status_t bundleActivator_start(void *userData, bundle_context_pt context);
-
-/**
- * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary
- * to stop the bundle. In general, this method should undo the work that the <code>bundleActivator_start()</code>
- * function started. There should be no active threads that were started by this bundle when this bundle returns.
- * A stopped bundle must not call any Framework objects.
- *
- * <p>
- * This method must complete and return to its caller in a timely manner.
- *
- * @param userData The activator instance to be used.
- * @param context The execution context of the bundle being stopped.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- Any other status code will mark the bundle as stopped and the framework will remove this
- * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
- */
-ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_context_pt context);
-
-/**
- * Called when this bundle is stopped so the bundle can destroy the instance of its activator. In general, this
- * method should undo the work that the <code>bundleActivator_create()</code> function initialized.
- *
- * <p>
- * This method must complete and return to its caller in a timely manner.
- *
- * @param userData The activator instance to be used.
- * @param context The execution context of the bundle being stopped.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- Any other status code will mark the bundle as stopped and the framework will remove this
- * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
- */
-ACTIVATOR_EXPORT celix_status_t
-bundleActivator_destroy(void *userData, bundle_context_pt  __attribute__((unused))  __attribute__((unused)) context);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BUNDLE_ACTIVATOR_H_ */
-
-/**
- * @}
- */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/bundle_archive.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle_archive.h b/framework/public/include/bundle_archive.h
deleted file mode 100644
index ff3cf16..0000000
--- a/framework/public/include/bundle_archive.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_archive.h
- *
- *  \date       Aug 8, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef BUNDLE_ARCHIVE_H_
-#define BUNDLE_ARCHIVE_H_
-
-#include <time.h>
-
-#include "bundle_revision.h"
-#include "bundle_state.h"
-#include "celix_errno.h"
-#include "celixbool.h"
-#include "framework_exports.h"
-#include "celix_log.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct bundleArchive *bundle_archive_pt;
-
-celix_status_t bundleArchive_create(const char *archiveRoot, long id, const char *location, const char *inputFile,
-                                    bundle_archive_pt *bundle_archive);
-
-celix_status_t bundleArchive_createSystemBundleArchive(bundle_archive_pt *bundle_archive);
-
-celix_status_t bundleArchive_recreate(const char *archiveRoot, bundle_archive_pt *bundle_archive);
-
-celix_status_t bundleArchive_destroy(bundle_archive_pt archive);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_getId(bundle_archive_pt archive, long *id);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_getLocation(bundle_archive_pt archive, const char **location);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_getArchiveRoot(bundle_archive_pt archive, const char **archiveRoot);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleArchive_revise(bundle_archive_pt archive, const char *location, const char *inputFile);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_rollbackRevise(bundle_archive_pt archive, bool *rolledback);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleArchive_getRevision(bundle_archive_pt archive, long revNr, bundle_revision_pt *revision);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleArchive_getCurrentRevision(bundle_archive_pt archive, bundle_revision_pt *revision);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_getCurrentRevisionNumber(bundle_archive_pt archive, long *revisionNumber);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_getRefreshCount(bundle_archive_pt archive, long *refreshCount);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_setRefreshCount(bundle_archive_pt archive);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_close(bundle_archive_pt archive);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_closeAndDelete(bundle_archive_pt archive);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_setLastModified(bundle_archive_pt archive, time_t lastModifiedTime);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_getLastModified(bundle_archive_pt archive, time_t *lastModified);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_setPersistentState(bundle_archive_pt archive, bundle_state_e state);
-
-FRAMEWORK_EXPORT celix_status_t bundleArchive_getPersistentState(bundle_archive_pt archive, bundle_state_e *state);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BUNDLE_ARCHIVE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/bundle_context.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle_context.h b/framework/public/include/bundle_context.h
deleted file mode 100644
index c674e9c..0000000
--- a/framework/public/include/bundle_context.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_context.h
- *
- *  \date       Mar 26, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef BUNDLE_CONTEXT_H_
-#define BUNDLE_CONTEXT_H_
-
-/**
- * A bundle's execution context within the Framework. The context is used to
- * grant access to other methods so that this bundle can interact with the
- * Framework.
- */
-typedef struct bundleContext *bundle_context_pt;
-typedef struct bundleContext bundle_context_t;
-
-
-#include "service_factory.h"
-#include "service_listener.h"
-#include "bundle_listener.h"
-#include "framework_listener.h"
-#include "properties.h"
-#include "array_list.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-celix_status_t
-bundleContext_create(framework_pt framework, framework_logger_pt, bundle_pt bundle, bundle_context_pt *bundle_context);
-
-celix_status_t bundleContext_destroy(bundle_context_pt context);
-
-FRAMEWORK_EXPORT celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_pt *framework);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_installBundle(bundle_context_pt context, const char *location, bundle_pt *bundle);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_installBundle2(bundle_context_pt context, const char *location, const char *inputFile, bundle_pt *bundle);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_registerService(bundle_context_pt context, const char *serviceName, const void *svcObj,
-                              properties_pt properties, service_registration_pt *service_registration);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_registerServiceFactory(bundle_context_pt context, const char *serviceName, service_factory_pt factory,
-                                     properties_pt properties, service_registration_pt *service_registration);
-
-/**
- * Get a service reference for the bundle context. When the service reference is no longer needed use bundleContext_ungetServiceReference.
- * ServiceReference are coupled to a bundle context. Do not share service reference between bundles. Exchange the service.id instead.
- * 
- * @param context The bundle context
- * @param serviceName The name of the service (objectClass) to get
- * @param service_reference _output_ The found service reference, or NULL when no service is found.
- * @return CELIX_SUCCESS on success
- */
-FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(bundle_context_pt context, const char *serviceName,
-                                                                  service_reference_pt *service_reference);
-
-/** Same as bundleContext_getServiceReference, but than for a optional serviceName combined with a optional filter.
- * The resulting array_list should be destroyed by the caller. For all service references return a unget should be called.
- * 
- * @param context the bundle context
- * @param serviceName the serviceName, can be NULL
- * @param filter the filter, can be NULL. If present will be combined (and) with the serviceName 
- * @param service_references _output_ a array list, can be size 0. 
- * @return CELIX_SUCCESS on success
- */
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_getServiceReferences(bundle_context_pt context, const char *serviceName, const char *filter,
-                                   array_list_pt *service_references);
-
-/**
- * Retains (increases the ref count) the provided service reference. Can be used to retain a service reference.
- * Note that this is a deviation from the OSGi spec, due to the fact that C has no garbage collect.
- * 
- * @param context the bundle context
- * @param reference the service reference to retain
- * @return CELIX_SUCCES on success
- */
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_retainServiceReference(bundle_context_pt context, service_reference_pt reference);
-
-/**
- * Ungets the service references. If the ref counter of the service refernce goes to 0, the reference will be destroyed.
- * This is coupled with the bundleContext_getServiceReference(s) and bundleContext_retainServiceReferenc.
- * Note: That this is a deviation from the OSGi standard, due to the fact that C has no garbage collect.
- * 
- * @param context The bundle context.
- * @param reference the service reference to unget
- * @return CELIX_SUCCESS on success.
- */
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_getService(bundle_context_pt context, service_reference_pt reference, void **service_instance);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_ungetService(bundle_context_pt context, service_reference_pt reference, bool *result);
-
-FRAMEWORK_EXPORT celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles);
-
-FRAMEWORK_EXPORT celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, bundle_pt *bundle);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_addServiceListener(bundle_context_pt context, service_listener_pt listener, const char *filter);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_removeServiceListener(bundle_context_pt context, service_listener_pt listener);
-
-FRAMEWORK_EXPORT celix_status_t bundleContext_addBundleListener(bundle_context_pt context, bundle_listener_pt listener);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_removeBundleListener(bundle_context_pt context, bundle_listener_pt listener);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_addFrameworkListener(bundle_context_pt context, framework_listener_pt listener);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_getProperty(bundle_context_pt context, const char *name, const char **value);
-
-FRAMEWORK_EXPORT celix_status_t
-bundleContext_getPropertyWithDefault(bundle_context_pt context, const char *name, const char *defaultValue,
-                                     const char **value);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BUNDLE_CONTEXT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/bundle_event.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle_event.h b/framework/public/include/bundle_event.h
deleted file mode 100644
index c4fc927..0000000
--- a/framework/public/include/bundle_event.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *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.
- */
-/*
- * bundle_event.h
- *
- *  \date       Jun 28, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef BUNDLE_EVENT_H_
-#define BUNDLE_EVENT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum bundle_event_type {
-	OSGI_FRAMEWORK_BUNDLE_EVENT_INSTALLED = 0x00000001,
-	OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED = 0x00000002,
-	OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPED = 0x00000004,
-	OSGI_FRAMEWORK_BUNDLE_EVENT_UPDATED = 0x00000008,
-	OSGI_FRAMEWORK_BUNDLE_EVENT_UNINSTALLED = 0x00000010,
-	OSGI_FRAMEWORK_BUNDLE_EVENT_RESOLVED = 0x00000020,
-	OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED = 0x00000040,
-	OSGI_FRAMEWORK_BUNDLE_EVENT_STARTING = 0x00000080,
-	OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING = 0x00000100,
-	OSGI_FRAMEWORK_BUNDLE_EVENT_LAZY_ACTIVATION = 0x00000200,
-};
-
-typedef enum bundle_event_type bundle_event_type_e;
-typedef struct bundle_event *bundle_event_pt;
-
-#include "service_reference.h"
-#include "bundle.h"
-
-struct bundle_event {
-	long bundleId;
-	char *bundleSymbolicName;
-	bundle_event_type_e type;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BUNDLE_EVENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/bundle_listener.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle_listener.h b/framework/public/include/bundle_listener.h
deleted file mode 100644
index a152393..0000000
--- a/framework/public/include/bundle_listener.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- *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.
- */
-/**
- *
- * @defgroup BundleListener Bundle Listener
- * @ingroup framework
- * @{
- *
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \date      	June 28, 2012
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef BUNDLE_LISTENER_H_
-#define BUNDLE_LISTENER_H_
-
-typedef struct bundle_listener *bundle_listener_pt;
-
-#include "celix_errno.h"
-#include "bundle_event.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct bundle_listener {
-	void *handle;
-
-	celix_status_t (*bundleChanged)(void *listener, bundle_event_pt event);
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* service_listener_t_H_ */
-
-/**
- * @}
- */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/bundle_revision.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle_revision.h b/framework/public/include/bundle_revision.h
deleted file mode 100644
index 9533eb6..0000000
--- a/framework/public/include/bundle_revision.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- *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.
- */
-/**
- *
- * @defgroup BundleRevision Bundle Revision
- * @ingroup framework
- * @{
- *
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \date      	April 12, 2011
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef BUNDLE_REVISION_H_
-#define BUNDLE_REVISION_H_
-
-#include <stdio.h>
-
-#include "celix_errno.h"
-#include "manifest.h"
-#include "celix_log.h"
-#include "array_list.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Typedef for bundle_revision_pt.
- *
- * A bundle revision represents the content of a bundle. A revision is associated with a bundle archive.
- * An archive can have multiple revisions, each update of a bundle results in a new one.
- *
- * In a revision the content of a bundle (ZIP file) is extracted to a specified location inside the archive.
- */
-typedef struct bundleRevision *bundle_revision_pt;
-
-/**
- * Creates a new revision for the given inputFile or location.
- * The location parameter is used to identify the bundle, in case of an update or download, the inputFile
- *  parameter can be used to point to the actual data. In the OSGi specification this is the inputstream.
- *
- * @param pool The pool on which this revision has to be allocated.
- * @param root The root for this revision in which the bundle is extracted and state is stored.
- * @param location The location associated with the revision
- * @param revisionNr The number of the revision
- * @param inputFile The (optional) location of the file to use as input for this revision
- * @param[out] bundle_revision The output parameter for the created revision.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ENOMEM If allocating memory for <code>bundle_revision</code> failed.
- */
-celix_status_t bundleRevision_create(const char *root, const char *location, long revisionNr, const char *inputFile,
-                                     bundle_revision_pt *bundle_revision);
-
-celix_status_t bundleRevision_destroy(bundle_revision_pt revision);
-
-/**
- * Retrieves the revision number of the given revision.
- *
- * @param revision The revision to get the number for.
- * @param[out] revisionNr The revision number.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
- */
-celix_status_t bundleRevision_getNumber(bundle_revision_pt revision, long *revisionNr);
-
-/**
- * Retrieves the location of the given revision.
- *
- * @param revision The revision to get the location for.
- * @param[out] location The location.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
- */
-celix_status_t bundleRevision_getLocation(bundle_revision_pt revision, const char **location);
-
-/**
- * Retrieves the root of the given revision.
- *
- * @param revision The revision to get the location for.
- * @param[out] root The root.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
- */
-celix_status_t bundleRevision_getRoot(bundle_revision_pt revision, const char **root);
-
-/**
- * Retrieves the manifest of the given revision.
- *
- * @param revision The revision to get the manifest for.
- * @param[out] manifest The manifest.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
- */
-celix_status_t bundleRevision_getManifest(bundle_revision_pt revision, manifest_pt *manifest);
-
-/**
- * Retrieves the handles of the installed libraries for this revision.
- *
- * @param revision The revision to get the manifest for.
- * @param[out] handles array_list_pt containing the handles.
- *
- * @return Status code indication failure or success:
- *      - CELIX_SUCCESS when no errors are encountered.
- *      - CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
- */
-celix_status_t bundleRevision_getHandles(bundle_revision_pt revision, array_list_pt *handles);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BUNDLE_REVISION_H_ */
-
-/**
- * @}
- */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/bundle_state.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle_state.h b/framework/public/include/bundle_state.h
deleted file mode 100644
index 8d451e4..0000000
--- a/framework/public/include/bundle_state.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_state.h
- *
- *  \date       Sep 27, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef BUNDLE_STATE_H_
-#define BUNDLE_STATE_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum bundleState {
-	OSGI_FRAMEWORK_BUNDLE_UNKNOWN = 0x00000000,
-	OSGI_FRAMEWORK_BUNDLE_UNINSTALLED = 0x00000001,
-	OSGI_FRAMEWORK_BUNDLE_INSTALLED = 0x00000002,
-	OSGI_FRAMEWORK_BUNDLE_RESOLVED = 0x00000004,
-	OSGI_FRAMEWORK_BUNDLE_STARTING = 0x00000008,
-	OSGI_FRAMEWORK_BUNDLE_STOPPING = 0x00000010,
-	OSGI_FRAMEWORK_BUNDLE_ACTIVE = 0x00000020,
-};
-
-typedef enum bundleState bundle_state_e;
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BUNDLE_STATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/capability.h
----------------------------------------------------------------------
diff --git a/framework/public/include/capability.h b/framework/public/include/capability.h
deleted file mode 100644
index b35d016..0000000
--- a/framework/public/include/capability.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- *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.
- */
-/*
- * capability.h
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef CAPABILITY_H_
-#define CAPABILITY_H_
-
-typedef struct capability *capability_pt;
-
-#include "hash_map.h"
-#include "module.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-celix_status_t
-capability_create(module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability);
-
-celix_status_t capability_destroy(capability_pt capability);
-
-celix_status_t capability_getServiceName(capability_pt capability, const char **serviceName);
-
-celix_status_t capability_getVersion(capability_pt capability, version_pt *version);
-
-celix_status_t capability_getModule(capability_pt capability, module_pt *module);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CAPABILITY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/celix_launcher.h
----------------------------------------------------------------------
diff --git a/framework/public/include/celix_launcher.h b/framework/public/include/celix_launcher.h
deleted file mode 100644
index 0d819c9..0000000
--- a/framework/public/include/celix_launcher.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- *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_launcher.h
- *
- *  \date       Jul 30, 2015
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef CELIX_LAUNCHER_H
-#define CELIX_LAUNCHER_H
-
-#include <stdio.h>
-#include "framework.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int celixLauncher_launchWithArgs(int argc, char *argv[]);
-
-int celixLauncher_launch(const char *configFile, framework_pt *framework);
-
-int celixLauncher_launchWithStream(FILE *config, framework_pt *framework);
-
-int celixLauncher_launchWithProperties(properties_pt config, framework_pt *framework);
-
-void celixLauncher_stop(framework_pt framework);
-
-void celixLauncher_destroy(framework_pt framework);
-
-void celixLauncher_waitForShutdown(framework_pt framework);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //CELIX_LAUNCHER_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/celix_log.h
----------------------------------------------------------------------
diff --git a/framework/public/include/celix_log.h b/framework/public/include/celix_log.h
deleted file mode 100644
index 08d096c..0000000
--- a/framework/public/include/celix_log.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *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_log.h
- *
- *  \date       Jan 12, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef CELIX_LOG_H_
-#define CELIX_LOG_H_
-
-#include <stdio.h>
-
-#include "celix_errno.h"
-#include "framework_exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum framework_log_level {
-    OSGI_FRAMEWORK_LOG_ERROR = 0x00000001,
-    OSGI_FRAMEWORK_LOG_WARNING = 0x00000002,
-    OSGI_FRAMEWORK_LOG_INFO = 0x00000003,
-    OSGI_FRAMEWORK_LOG_DEBUG = 0x00000004,
-};
-
-typedef enum framework_log_level framework_log_level_t;
-
-typedef struct framework_logger *framework_logger_pt;
-
-extern framework_logger_pt logger;
-
-typedef celix_status_t (*framework_log_function_pt)(framework_log_level_t level, const char *func, const char *file,
-                                                    int line, const char *msg);
-
-struct framework_logger {
-    framework_log_function_pt logFunction;
-};
-
-#define fw_log(logger, level, fmsg, args...) framework_log(logger, level, __func__, __FILE__, __LINE__, fmsg, ## args)
-#define fw_logCode(logger, level, code, fmsg, args...) framework_logCode(logger, level, __func__, __FILE__, __LINE__, code, fmsg, ## args)
-#define framework_logIfError(logger, status, error, fmsg, args...) \
-    if (status != CELIX_SUCCESS) { \
-        if (error != NULL) { \
-            fw_logCode(logger, OSGI_FRAMEWORK_LOG_ERROR, status, #fmsg";\n Cause: %s", ## args, error); \
-        } else { \
-            fw_logCode(logger, OSGI_FRAMEWORK_LOG_ERROR, status, #fmsg, ## args); \
-        } \
-    }
-
-FRAMEWORK_EXPORT celix_status_t
-frameworkLogger_log(framework_log_level_t level, const char *func, const char *file, int line, const char *fmsg);
-
-FRAMEWORK_EXPORT void
-framework_log(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line,
-              const char *fmsg, ...);
-
-FRAMEWORK_EXPORT void
-framework_logCode(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line,
-                  celix_status_t code, const char *fmsg, ...);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CELIX_LOG_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/constants.h
----------------------------------------------------------------------
diff --git a/framework/public/include/constants.h b/framework/public/include/constants.h
deleted file mode 100644
index 5a01016..0000000
--- a/framework/public/include/constants.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- *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.
- */
-/*
- * constants.h
- *
- *  \date       Apr 29, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef CONSTANTS_H_
-#define CONSTANTS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static const char *const OSGI_FRAMEWORK_OBJECTCLASS = "objectClass";
-static const char *const OSGI_FRAMEWORK_SERVICE_ID = "service.id";
-static const char *const OSGI_FRAMEWORK_SERVICE_PID = "service.pid";
-static const char *const OSGI_FRAMEWORK_SERVICE_RANKING = "service.ranking";
-
-static const char *const CELIX_FRAMEWORK_SERVICE_VERSION = "service.version";
-static const char *const CELIX_FRAMEWORK_SERVICE_LANGUAGE = "service.lang";
-static const char *const CELIX_FRAMEWORK_SERVICE_C_LANGUAGE = "C";
-static const char *const CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE = "C++";
-static const char *const CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE = "shared"; //e.g. marker services
-
-static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR = "Bundle-Activator";
-static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE = "bundleActivator_create";
-static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START = "bundleActivator_start";
-static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP = "bundleActivator_stop";
-static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY = "bundleActivator_destroy";
-
-static const char *const OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
-static const char *const OSGI_FRAMEWORK_BUNDLE_VERSION = "Bundle-Version";
-static const char *const OSGI_FRAMEWORK_PRIVATE_LIBRARY = "Private-Library";
-static const char *const OSGI_FRAMEWORK_EXPORT_LIBRARY = "Export-Library";
-static const char *const OSGI_FRAMEWORK_IMPORT_LIBRARY = "Import-Library";
-
-
-static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE = "org.osgi.framework.storage";
-static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN = "org.osgi.framework.storage.clean";
-static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT = "onFirstInit";
-static const char *const OSGI_FRAMEWORK_FRAMEWORK_UUID = "org.osgi.framework.uuid";
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CONSTANTS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/filter.h
----------------------------------------------------------------------
diff --git a/framework/public/include/filter.h b/framework/public/include/filter.h
deleted file mode 100644
index 687de2a..0000000
--- a/framework/public/include/filter.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- *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.
- */
-/*
- * filter.h
- *
- *  \date       Apr 28, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef FILTER_H_
-#define FILTER_H_
-
-#include "celix_errno.h"
-#include "properties.h"
-#include "celixbool.h"
-#include "framework_exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct filter *filter_pt;
-
-FRAMEWORK_EXPORT filter_pt filter_create(const char *filterString);
-
-FRAMEWORK_EXPORT void filter_destroy(filter_pt filter);
-
-FRAMEWORK_EXPORT celix_status_t filter_match(filter_pt filter, properties_pt properties, bool *result);
-
-FRAMEWORK_EXPORT celix_status_t filter_match_filter(filter_pt src, filter_pt dest, bool *result);
-
-FRAMEWORK_EXPORT celix_status_t filter_getString(filter_pt filter, const char **filterStr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* FILTER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/framework.h
----------------------------------------------------------------------
diff --git a/framework/public/include/framework.h b/framework/public/include/framework.h
deleted file mode 100644
index ec2306f..0000000
--- a/framework/public/include/framework.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *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.
- */
-/*
- * framework.h
- *
- *  \date       Mar 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef FRAMEWORK_H_
-#define FRAMEWORK_H_
-
-typedef struct activator * activator_pt;
-typedef struct framework * framework_pt;
-
-#include "celix_errno.h"
-#include "framework_exports.h"
-#include "bundle.h"
-#include "properties.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// #TODO: Move to FrameworkFactory according the OSGi Spec
-FRAMEWORK_EXPORT celix_status_t framework_create(framework_pt *framework, properties_pt config);
-
-FRAMEWORK_EXPORT celix_status_t framework_destroy(framework_pt framework);
-
-FRAMEWORK_EXPORT celix_status_t fw_init(framework_pt framework);
-
-FRAMEWORK_EXPORT celix_status_t framework_waitForStop(framework_pt framework);
-
-FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(framework_pt framework, bundle_pt *bundle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* FRAMEWORK_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/framework_event.h
----------------------------------------------------------------------
diff --git a/framework/public/include/framework_event.h b/framework/public/include/framework_event.h
deleted file mode 100644
index d48e64c..0000000
--- a/framework/public/include/framework_event.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *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.
- */
-/*
- * framework_event.h
- *
- *  \date       Oct 8, 2013
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef FRAMEWORK_EVENT_H_
-#define FRAMEWORK_EVENT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum framework_event_type {
-	OSGI_FRAMEWORK_EVENT_STARTED = 0x00000001,
-	OSGI_FRAMEWORK_EVENT_ERROR = 0x00000002,
-	OSGI_FRAMEWORK_EVENT_PACKAGES_REFRESHED = 0x00000004,
-	OSGI_FRAMEWORK_EVENT_STARTLEVEL_CHANGED = 0x00000008,
-	OSGI_FRAMEWORK_EVENT_WARNING = 0x00000010,
-	OSGI_FRAMEWORK_EVENT_INFO = 0x00000020,
-	OSGI_FRAMEWORK_EVENT_STOPPED = 0x00000040,
-	OSGI_FRAMEWORK_EVENT_STOPPED_UPDATE = 0x00000080,
-	OSGI_FRAMEWORK_EVENT_STOPPED_BOOTCLASSPATH_MODIFIED = 0x00000100,
-	OSGI_FRAMEWORK_EVENT_WAIT_TIMEDOUT = 0x00000200,
-};
-
-typedef enum framework_event_type framework_event_type_e;
-typedef struct framework_event *framework_event_pt;
-#ifdef __cplusplus
-}
-#endif
-
-#include "service_reference.h"
-#include "bundle.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct framework_event {
-	long bundleId;
-	char *bundleSymbolicName;
-	framework_event_type_e type;
-	celix_status_t errorCode;
-	char *error;
-};
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* FRAMEWORK_EVENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/framework_exports.h
----------------------------------------------------------------------
diff --git a/framework/public/include/framework_exports.h b/framework/public/include/framework_exports.h
deleted file mode 100644
index 50d7f6e..0000000
--- a/framework/public/include/framework_exports.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *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.
- */
-/*
- * exports.h
- */
-
-#ifndef FRAMEWORK_EXPORTS_H_
-#define FRAMEWORK_EXPORTS_H_
-
-/* Cmake will define celix_framework_EXPORTS on Windows when it
-configures to build a shared library. If you are going to use
-another build system on windows or create the visual studio
-projects by hand you need to define celix_framework_EXPORTS when
-building a DLL on windows.
-*/
-// We are using the Visual Studio Compiler and building Shared libraries
-
-#if defined _WIN32 || defined __CYGWIN__
-  #ifdef celix_framework_EXPORTS
-    #ifdef __GNUC__
-      #define FRAMEWORK_EXPORT __attribute__ ((dllexport))
-      #define ACTIVATOR_EXPORT __attribute__ ((dllexport))
-    #else
-      #define ACTIVATOR_EXPORT __declspec(dllexport)
-      #define FRAMEWORK_EXPORT __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
-    #endif
-  #else
-    #ifdef __GNUC__
-      #define ACTIVATOR_EXPORT __attribute__ ((dllexport))
-      #define FRAMEWORK_EXPORT __attribute__ ((dllimport))
-    #else
-      #define ACTIVATOR_EXPORT __declspec(dllexport)
-      #define FRAMEWORK_EXPORT __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
-    #endif
-  #endif
-  #define DLL_LOCAL
-#else
-  #if __GNUC__ >= 4
-    #define ACTIVATOR_EXPORT __attribute__ ((visibility ("default")))
-    #define FRAMEWORK_EXPORT __attribute__ ((visibility ("default")))
-    #define FRAMEWORK_LOCAL  __attribute__ ((visibility ("hidden")))
-  #else
-    #define ACTIVATOR_EXPORT
-    #define FRAMEWORK_EXPORT
-    #define FRAMEWORK_LOCAL
-  #endif
-#endif
-
-#endif /* FRAMEWORK_EXPORTS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/framework_listener.h
----------------------------------------------------------------------
diff --git a/framework/public/include/framework_listener.h b/framework/public/include/framework_listener.h
deleted file mode 100644
index f390e3b..0000000
--- a/framework/public/include/framework_listener.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *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.
- */
-/**
- *
- * @defgroup FrameworkListener Framework Listener
- * @ingroup framework
- * @{
- *
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \date      	Oct 8, 2013
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef FRAMEWORK_LISTENER_H_
-#define FRAMEWORK_LISTENER_H_
-
-typedef struct framework_listener *framework_listener_pt;
-
-#include "celix_errno.h"
-#include "framework_event.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct framework_listener {
-	void *handle;
-
-	celix_status_t (*frameworkEvent)(void *listener, framework_event_pt event);
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* FRAMEWORK_LISTENER_H_ */
-
-/**
- * @}
- */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/listener_hook_service.h
----------------------------------------------------------------------
diff --git a/framework/public/include/listener_hook_service.h b/framework/public/include/listener_hook_service.h
deleted file mode 100644
index 1f0c966..0000000
--- a/framework/public/include/listener_hook_service.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *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.
- */
-/*
- * listener_hook_service.h
- *
- *  \date       Oct 28, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LISTENER_HOOK_SERVICE_H_
-#define LISTENER_HOOK_SERVICE_H_
-
-
-typedef struct listener_hook *listener_hook_pt;
-typedef struct listener_hook_info *listener_hook_info_pt;
-typedef struct listener_hook_service *listener_hook_service_pt;
-
-#include "bundle_context.h"
-
-#define OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME "listener_hook_service"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct listener_hook_info {
-	bundle_context_pt context;
-	char *filter;
-	bool removed;
-};
-
-struct listener_hook_service {
-	void *handle;
-
-	celix_status_t (*added)(void *hook, array_list_pt listeners);
-
-	celix_status_t (*removed)(void *hook, array_list_pt listeners);
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LISTENER_HOOK_SERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/manifest.h
----------------------------------------------------------------------
diff --git a/framework/public/include/manifest.h b/framework/public/include/manifest.h
deleted file mode 100644
index eeccfbc..0000000
--- a/framework/public/include/manifest.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- *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.
- */
-/*
- * manifest.h
- *
- *  \date       Jul 5, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef MANIFEST_H_
-#define MANIFEST_H_
-
-#include "properties.h"
-#include "celix_errno.h"
-#include "framework_exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct manifest {
-	properties_pt mainAttributes;
-	hash_map_pt attributes;
-};
-
-typedef struct manifest *manifest_pt;
-
-FRAMEWORK_EXPORT celix_status_t manifest_create(manifest_pt *manifest);
-
-FRAMEWORK_EXPORT celix_status_t manifest_createFromFile(const char *filename, manifest_pt *manifest);
-
-FRAMEWORK_EXPORT celix_status_t manifest_destroy(manifest_pt manifest);
-
-FRAMEWORK_EXPORT void manifest_clear(manifest_pt manifest);
-
-FRAMEWORK_EXPORT properties_pt manifest_getMainAttributes(manifest_pt manifest);
-
-FRAMEWORK_EXPORT celix_status_t manifest_getEntries(manifest_pt manifest, hash_map_pt *map);
-
-FRAMEWORK_EXPORT celix_status_t manifest_read(manifest_pt manifest, const char *filename);
-
-FRAMEWORK_EXPORT void manifest_write(manifest_pt manifest, const char *filename);
-
-FRAMEWORK_EXPORT const char *manifest_getValue(manifest_pt manifest, const char *name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* MANIFEST_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/module.h
----------------------------------------------------------------------
diff --git a/framework/public/include/module.h b/framework/public/include/module.h
deleted file mode 100644
index bc85ef4..0000000
--- a/framework/public/include/module.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- *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.
- */
-/*
- * module.h
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef MODULE_H_
-#define MODULE_H_
-
-typedef struct module *module_pt;
-
-#include "celixbool.h"
-#include "linked_list.h"
-#include "manifest.h"
-#include "version.h"
-#include "array_list.h"
-#include "bundle.h"
-#include "framework_exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-module_pt module_create(manifest_pt headerMap, const char *moduleId, bundle_pt bundle);
-
-module_pt module_createFrameworkModule(bundle_pt bundle);
-
-void module_destroy(module_pt module);
-
-FRAMEWORK_EXPORT unsigned int module_hash(void *module);
-
-FRAMEWORK_EXPORT int module_equals(void *module, void *compare);
-
-FRAMEWORK_EXPORT wire_pt module_getWire(module_pt module, const char *serviceName);
-
-FRAMEWORK_EXPORT version_pt module_getVersion(module_pt module);
-
-FRAMEWORK_EXPORT celix_status_t module_getSymbolicName(module_pt module, const char **symbolicName);
-
-FRAMEWORK_EXPORT char *module_getId(module_pt module);
-
-FRAMEWORK_EXPORT linked_list_pt module_getWires(module_pt module);
-
-FRAMEWORK_EXPORT void module_setWires(module_pt module, linked_list_pt wires);
-
-FRAMEWORK_EXPORT bool module_isResolved(module_pt module);
-
-FRAMEWORK_EXPORT void module_setResolved(module_pt module);
-
-FRAMEWORK_EXPORT bundle_pt module_getBundle(module_pt module);
-
-FRAMEWORK_EXPORT linked_list_pt module_getRequirements(module_pt module);
-
-FRAMEWORK_EXPORT linked_list_pt module_getCapabilities(module_pt module);
-
-FRAMEWORK_EXPORT array_list_pt module_getDependentImporters(module_pt module);
-
-FRAMEWORK_EXPORT void module_addDependentImporter(module_pt module, module_pt importer);
-
-FRAMEWORK_EXPORT void module_removeDependentImporter(module_pt module, module_pt importer);
-
-FRAMEWORK_EXPORT array_list_pt module_getDependentRequirers(module_pt module);
-
-FRAMEWORK_EXPORT void module_addDependentRequirer(module_pt module, module_pt requirer);
-
-FRAMEWORK_EXPORT void module_removeDependentRequirer(module_pt module, module_pt requirer);
-
-FRAMEWORK_EXPORT array_list_pt module_getDependents(module_pt module);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* MODULE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/requirement.h
----------------------------------------------------------------------
diff --git a/framework/public/include/requirement.h b/framework/public/include/requirement.h
deleted file mode 100644
index febc62a..0000000
--- a/framework/public/include/requirement.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- *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.
- */
-/*
- * requirement.h
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef REQUIREMENT_H_
-#define REQUIREMENT_H_
-
-typedef struct requirement *requirement_pt;
-
-#include "capability.h"
-#include "hash_map.h"
-#include "version_range.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-celix_status_t requirement_create(hash_map_pt directives, hash_map_pt attributes, requirement_pt *requirement);
-
-celix_status_t requirement_destroy(requirement_pt requirement);
-
-celix_status_t requirement_getVersionRange(requirement_pt requirement, version_range_pt *range);
-
-celix_status_t requirement_getTargetName(requirement_pt requirement, const char **targetName);
-
-celix_status_t requirement_isSatisfied(requirement_pt requirement, capability_pt capability, bool *inRange);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* REQUIREMENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/service_event.h
----------------------------------------------------------------------
diff --git a/framework/public/include/service_event.h b/framework/public/include/service_event.h
deleted file mode 100644
index a018b07..0000000
--- a/framework/public/include/service_event.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *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.
- */
-/**
- *
- * @defgroup ServiceListener Service Listener
- * @ingroup framework
- * @{
- *
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \date      	January 11, 2012
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef SERVICE_EVENT_H_
-#define SERVICE_EVENT_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum serviceEventType {
-	OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED = 0x00000001,
-	OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED = 0x00000002,
-	OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING = 0x00000004,
-	OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH = 0x00000008,
-};
-
-typedef enum serviceEventType service_event_type_e;
-
-typedef struct serviceEvent *service_event_pt;
-#ifdef __cplusplus
-}
-#endif
-
-#include "service_reference.h"
-
-#include "service_reference.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct serviceEvent {
-	service_reference_pt reference;
-	service_event_type_e type;
-};
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SERVICE_EVENT_H_ */
-
-/**
- * @}
- */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/service_factory.h
----------------------------------------------------------------------
diff --git a/framework/public/include/service_factory.h b/framework/public/include/service_factory.h
deleted file mode 100644
index 84e383a..0000000
--- a/framework/public/include/service_factory.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- *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.
- */
-/*
- * service_factory.h
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef SERVICE_FACTORY_H_
-#define SERVICE_FACTORY_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct service_factory service_factory_t;
-typedef service_factory_t *service_factory_pt;
-#ifdef __cplusplus
-}
-#endif
-
-#include "celix_errno.h"
-#include "service_registration.h"
-#include "bundle.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct service_factory {
-    void *handle;
-
-    celix_status_t (*getService)(void *handle, bundle_pt bundle, service_registration_pt registration, void **service);
-
-    celix_status_t
-    (*ungetService)(void *handle, bundle_pt bundle, service_registration_pt registration, void **service);
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SERVICE_FACTORY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/service_listener.h
----------------------------------------------------------------------
diff --git a/framework/public/include/service_listener.h b/framework/public/include/service_listener.h
deleted file mode 100644
index c887ba1..0000000
--- a/framework/public/include/service_listener.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *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.
- */
-/**
- *
- * @defgroup ServiceListener Service Listener
- * @ingroup framework
- * @{
- *
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \date      	January 11, 2012
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef SERVICE_LISTENER_H_
-#define SERVICE_LISTENER_H_
-
-typedef struct serviceListener * service_listener_pt;
-
-#include "celix_errno.h"
-#include "service_event.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct serviceListener {
-	void *handle;
-
-	celix_status_t (*serviceChanged)(void *listener, service_event_pt event);
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* SERVICE_LISTENER_H_ */
-
-/**
- * @}
- */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/service_reference.h
----------------------------------------------------------------------
diff --git a/framework/public/include/service_reference.h b/framework/public/include/service_reference.h
deleted file mode 100644
index bb263f5..0000000
--- a/framework/public/include/service_reference.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- *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.
- */
-/*
- * service_reference.h
- *
- *  \date       Jul 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef SERVICE_REFERENCE_H_
-#define SERVICE_REFERENCE_H_
-
-typedef struct serviceReference * service_reference_pt;
-
-#include "celixbool.h"
-#include "array_list.h"
-#include "service_registration.h"
-#include "bundle.h"
-#include "framework_exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference, bundle_pt *bundle);
-
-FRAMEWORK_EXPORT bool
-serviceReference_isAssignableTo(service_reference_pt reference, bundle_pt requester, const char *serviceName);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceReference_getProperty(service_reference_pt reference, const char *key, const char **value);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceReference_getPropertyKeys(service_reference_pt reference, char **keys[], unsigned int *size);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceReference_getServiceRegistration(service_reference_pt reference, service_registration_pt *registration);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceReference_equals(service_reference_pt reference, service_reference_pt compareTo, bool *equal);
-
-FRAMEWORK_EXPORT unsigned int serviceReference_hashCode(const void *referenceP);
-
-FRAMEWORK_EXPORT int serviceReference_equals2(const void *reference1, const void *reference2);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceReference_compareTo(service_reference_pt reference, service_reference_pt compareTo, int *compare);
-
-FRAMEWORK_EXPORT celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, array_list_pt *out);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SERVICE_REFERENCE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/service_registration.h
----------------------------------------------------------------------
diff --git a/framework/public/include/service_registration.h b/framework/public/include/service_registration.h
deleted file mode 100644
index 9265a00..0000000
--- a/framework/public/include/service_registration.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- *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.
- */
-/*
- * service_registration.h
- *
- *  \date       Aug 6, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef SERVICE_REGISTRATION_H_
-#define SERVICE_REGISTRATION_H_
-
-#include "celixbool.h"
-
-typedef struct serviceRegistration * service_registration_pt;
-
-#include "service_registry.h"
-#include "array_list.h"
-#include "bundle.h"
-#include "framework_exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-FRAMEWORK_EXPORT celix_status_t serviceRegistration_unregister(service_registration_pt registration);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceRegistration_setProperties(service_registration_pt registration, properties_pt properties);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceRegistration_getServiceName(service_registration_pt registration, const char **serviceName);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SERVICE_REGISTRATION_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/service_registry.h
----------------------------------------------------------------------
diff --git a/framework/public/include/service_registry.h b/framework/public/include/service_registry.h
deleted file mode 100644
index 9a2ec48..0000000
--- a/framework/public/include/service_registry.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- *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.
- */
-/*
- * service_registry.h
- *
- *  \date       Aug 6, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef SERVICE_REGISTRY_H_
-#define SERVICE_REGISTRY_H_
-
-typedef struct serviceRegistry * service_registry_pt;
-
-#include "properties.h"
-#include "filter.h"
-#include "service_factory.h"
-#include "service_event.h"
-#include "array_list.h"
-#include "service_registration.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*serviceChanged_function_pt)(framework_pt, service_event_type_e, service_registration_pt, properties_pt);
-
-celix_status_t serviceRegistry_create(framework_pt framework, serviceChanged_function_pt serviceChanged,
-                                      service_registry_pt *registry);
-
-celix_status_t serviceRegistry_destroy(service_registry_pt registry);
-
-celix_status_t
-serviceRegistry_getRegisteredServices(service_registry_pt registry, bundle_pt bundle, array_list_pt *services);
-
-celix_status_t
-serviceRegistry_getServicesInUse(service_registry_pt registry, bundle_pt bundle, array_list_pt *services);
-
-celix_status_t serviceRegistry_registerService(service_registry_pt registry, bundle_pt bundle, const char *serviceName,
-                                               const void *serviceObject, properties_pt dictionary,
-                                               service_registration_pt *registration);
-
-celix_status_t
-serviceRegistry_registerServiceFactory(service_registry_pt registry, bundle_pt bundle, const char *serviceName,
-                                       service_factory_pt factory, properties_pt dictionary,
-                                       service_registration_pt *registration);
-
-celix_status_t
-serviceRegistry_unregisterService(service_registry_pt registry, bundle_pt bundle, service_registration_pt registration);
-
-celix_status_t serviceRegistry_clearServiceRegistrations(service_registry_pt registry, bundle_pt bundle);
-
-celix_status_t serviceRegistry_getServiceReference(service_registry_pt registry, bundle_pt bundle,
-                                                   service_registration_pt registration,
-                                                   service_reference_pt *reference);
-
-celix_status_t
-serviceRegistry_getServiceReferences(service_registry_pt registry, bundle_pt bundle, const char *serviceName,
-                                     filter_pt filter, array_list_pt *references);
-
-celix_status_t
-serviceRegistry_retainServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference);
-
-celix_status_t
-serviceRegistry_ungetServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference);
-
-celix_status_t
-serviceRegistry_getService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference,
-                           const void **service);
-
-celix_status_t
-serviceRegistry_ungetService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference,
-                             bool *result);
-
-celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry, bundle_pt bundle);
-
-celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, bundle_pt bundle, array_list_pt *hooks);
-
-celix_status_t
-serviceRegistry_servicePropertiesModified(service_registry_pt registry, service_registration_pt registration,
-                                          properties_pt oldprops);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SERVICE_REGISTRY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/service_tracker.h
----------------------------------------------------------------------
diff --git a/framework/public/include/service_tracker.h b/framework/public/include/service_tracker.h
deleted file mode 100644
index aa19d50..0000000
--- a/framework/public/include/service_tracker.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- *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.
- */
-/*
- * service_tracker.h
- *
- *  \date       Apr 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef SERVICE_TRACKER_H_
-#define SERVICE_TRACKER_H_
-
-#include "service_listener.h"
-#include "array_list.h"
-#include "bundle_context.h"
-#include "service_tracker_customizer.h"
-#include "framework_exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct serviceTracker *service_tracker_pt;
-
-FRAMEWORK_EXPORT celix_status_t
-serviceTracker_create(bundle_context_pt context, const char *service, service_tracker_customizer_pt customizer,
-                      service_tracker_pt *tracker);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceTracker_createWithFilter(bundle_context_pt context, const char *filter, service_tracker_customizer_pt customizer,
-                                service_tracker_pt *tracker);
-
-FRAMEWORK_EXPORT celix_status_t serviceTracker_open(service_tracker_pt tracker);
-
-FRAMEWORK_EXPORT celix_status_t serviceTracker_close(service_tracker_pt tracker);
-
-FRAMEWORK_EXPORT celix_status_t serviceTracker_destroy(service_tracker_pt tracker);
-
-FRAMEWORK_EXPORT service_reference_pt serviceTracker_getServiceReference(service_tracker_pt tracker);
-
-FRAMEWORK_EXPORT array_list_pt serviceTracker_getServiceReferences(service_tracker_pt tracker);
-
-FRAMEWORK_EXPORT void *serviceTracker_getService(service_tracker_pt tracker);
-
-FRAMEWORK_EXPORT array_list_pt serviceTracker_getServices(service_tracker_pt tracker);
-
-FRAMEWORK_EXPORT void *serviceTracker_getServiceByReference(service_tracker_pt tracker, service_reference_pt reference);
-
-FRAMEWORK_EXPORT void serviceTracker_serviceChanged(service_listener_pt listener, service_event_pt event);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SERVICE_TRACKER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/service_tracker_customizer.h
----------------------------------------------------------------------
diff --git a/framework/public/include/service_tracker_customizer.h b/framework/public/include/service_tracker_customizer.h
deleted file mode 100644
index 19672d8..0000000
--- a/framework/public/include/service_tracker_customizer.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- *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.
- */
-/*
- * service_tracker_customizer.h
- *
- *  \date       Nov 15, 2012
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef service_tracker_customizer_t_H_
-#define service_tracker_customizer_t_H_
-
-#include <celix_errno.h>
-#include <service_reference.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef celix_status_t (*adding_callback_pt)(void *handle, service_reference_pt reference, void **service);
-
-typedef celix_status_t (*added_callback_pt)(void *handle, service_reference_pt reference, void *service);
-
-typedef celix_status_t (*modified_callback_pt)(void *handle, service_reference_pt reference, void *service);
-
-typedef celix_status_t (*removed_callback_pt)(void *handle, service_reference_pt reference, void *service);
-
-typedef struct serviceTrackerCustomizer *service_tracker_customizer_pt;
-typedef struct serviceTrackerCustomizer service_tracker_customizer_t;
-
-
-FRAMEWORK_EXPORT celix_status_t serviceTrackerCustomizer_create(void *handle,
-																adding_callback_pt addingFunction,
-																added_callback_pt addedFunction,
-																modified_callback_pt modifiedFunction,
-																removed_callback_pt removedFunction,
-																service_tracker_customizer_pt *customizer);
-
-FRAMEWORK_EXPORT celix_status_t serviceTrackerCustomizer_destroy(service_tracker_customizer_pt customizer);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceTrackerCustomizer_getHandle(service_tracker_customizer_pt customizer, void **handle);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceTrackerCustomizer_getAddingFunction(service_tracker_customizer_pt customizer, adding_callback_pt *function);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceTrackerCustomizer_getAddedFunction(service_tracker_customizer_pt customizer, added_callback_pt *function);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceTrackerCustomizer_getModifiedFunction(service_tracker_customizer_pt customizer, modified_callback_pt *function);
-
-FRAMEWORK_EXPORT celix_status_t
-serviceTrackerCustomizer_getRemovedFunction(service_tracker_customizer_pt customizer, removed_callback_pt *function);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* service_tracker_customizer_t_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/wire.h
----------------------------------------------------------------------
diff --git a/framework/public/include/wire.h b/framework/public/include/wire.h
deleted file mode 100644
index 9bb9e02..0000000
--- a/framework/public/include/wire.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- *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.
- */
-/*
- * wire.h
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef WIRE_H_
-#define WIRE_H_
-
-typedef struct wire *wire_pt;
-
-#include "requirement.h"
-#include "capability.h"
-#include "module.h"
-#include "linked_list.h"
-#include "module.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup Version Version
- * @ingroup framework
- * @{
- */
-
-/**
- * Create a wire between two modules using a requirement and capability.
- *
- * @param importer The importer module of the wire.
- * @param requirement The requirement of the importer.
- * @param exporter The exporter module of the wire.
- * @param capability The capability of the wire.
- * @param wire The created wire.
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ENOMEM If allocating memory for <code>wire</code> failed.
- */
-celix_status_t wire_create(module_pt importer, requirement_pt requirement,
-						   module_pt exporter, capability_pt capability, wire_pt *wire);
-
-/**
- * Getter for the capability of the exporting module.
- *
- * @param wire The wire to get the capability from.
- * @param capability The capability
- * @return Status code indication failure or success:
- *      - CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t wire_destroy(wire_pt wire);
-
-/**
- * Getter for the capability of the exporting module.
- *
- * @param wire The wire to get the capability from.
- * @param capability The capability
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t wire_getCapability(wire_pt wire, capability_pt *capability);
-
-/**
- * Getter for the requirement of the importing module.
- *
- * @param wire The wire to get the requirement from.
- * @param requirement The requirement
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t wire_getRequirement(wire_pt wire, requirement_pt *requirement);
-
-/**
- * Getter for the importer of the wire.
- *
- * @param wire The wire to get the importer from.
- * @param importer The importing module.
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t wire_getImporter(wire_pt wire, module_pt *importer);
-
-/**
- * Getter for the exporter of the wire.
- *
- * @param wire The wire to get the exporter from.
- * @param exporter The exporting module.
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t wire_getExporter(wire_pt wire, module_pt *exporter);
-
-/**
- * @}
- */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* WIRE_H_ */


[02/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/exports.h
----------------------------------------------------------------------
diff --git a/utils/public/include/exports.h b/utils/public/include/exports.h
deleted file mode 100644
index b128c88..0000000
--- a/utils/public/include/exports.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *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.
- */
-/*
- * exports.h
- *
- *  \date       Jun 16, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef EXPORTS_H_
-#define EXPORTS_H_
-
-/* Cmake will define utils_EXPORTS on Windows when it
-configures to build a shared library. If you are going to use
-another build system on windows or create the visual studio
-projects by hand you need to define utils_EXPORTS when
-building a DLL on windows.
-
-We are using the Visual Studio Compiler and building Shared libraries
-*/
-
-#if defined (_WIN32)
-  #if defined(celix_utils_EXPORTS)
-    #define  UTILS_EXPORT __declspec(dllexport)
-  #else
-    #define  UTILS_EXPORT __declspec(dllimport)
-  #endif /* celix_utils_EXPORTS */
-#else /* defined (_WIN32) */
-  #define UTILS_EXPORT __attribute__((visibility("default")))
-#endif
-
-#endif /* EXPORTS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/hash_map.h
----------------------------------------------------------------------
diff --git a/utils/public/include/hash_map.h b/utils/public/include/hash_map.h
deleted file mode 100644
index 28d386b..0000000
--- a/utils/public/include/hash_map.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- *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.
- */
-/*
- * hash_map.h
- *
- *  \date       Jul 21, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef HASH_MAP_H_
-#define HASH_MAP_H_
-
-#include "celixbool.h"
-#include "exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct hashMapEntry* hash_map_entry_pt;
-typedef struct hasMapEntry hash_map_entry_t;
-
-typedef struct hashMap* hash_map_pt;
-typedef struct hashMap hash_map_t;
-
-struct hashMapIterator {
-	hash_map_pt map;
-	hash_map_entry_pt next;
-	hash_map_entry_pt current;
-	int expectedModCount;
-	int index;
-};
-
-typedef struct hashMapIterator hash_map_iterator_t;
-typedef hash_map_iterator_t *hash_map_iterator_pt;
-
-typedef struct hashMapKeySet *hash_map_key_set_pt;
-typedef struct hashMapValues *hash_map_values_pt;
-typedef struct hashMapEntrySet *hash_map_entry_set_pt;
-
-UTILS_EXPORT hash_map_pt hashMap_create(unsigned int (*keyHash)(const void *), unsigned int (*valueHash)(const void *),
-										int (*keyEquals)(const void *, const void *),
-										int (*valueEquals)(const void *, const void *));
-
-UTILS_EXPORT void hashMap_destroy(hash_map_pt map, bool freeKeys, bool freeValues);
-
-UTILS_EXPORT int hashMap_size(hash_map_pt map);
-
-UTILS_EXPORT bool hashMap_isEmpty(hash_map_pt map);
-
-UTILS_EXPORT void *hashMap_get(hash_map_pt map, const void *key);
-
-UTILS_EXPORT bool hashMap_containsKey(hash_map_pt map, const void *key);
-
-UTILS_EXPORT hash_map_entry_pt hashMap_getEntry(hash_map_pt map, const void *key);
-
-UTILS_EXPORT void *hashMap_put(hash_map_pt map, void *key, void *value);
-
-UTILS_EXPORT void *hashMap_remove(hash_map_pt map, const void *key);
-
-UTILS_EXPORT void hashMap_clear(hash_map_pt map, bool freeKey, bool freeValue);
-
-UTILS_EXPORT bool hashMap_containsValue(hash_map_pt map, const void *value);
-
-UTILS_EXPORT hash_map_iterator_pt hashMapIterator_create(hash_map_pt map);
-
-UTILS_EXPORT void hashMapIterator_destroy(hash_map_iterator_pt iterator);
-
-UTILS_EXPORT hash_map_iterator_pt hashMapIterator_alloc(void);
-
-UTILS_EXPORT void hashMapIterator_dealloc(hash_map_iterator_pt iterator);
-
-UTILS_EXPORT void hashMapIterator_init(hash_map_pt map, hash_map_iterator_pt iterator);
-
-UTILS_EXPORT void hashMapIterator_deinit(hash_map_iterator_pt iterator);
-
-UTILS_EXPORT hash_map_iterator_t hashMapIterator_construct(hash_map_pt map);
-
-
-UTILS_EXPORT bool hashMapIterator_hasNext(hash_map_iterator_pt iterator);
-
-UTILS_EXPORT void hashMapIterator_remove(hash_map_iterator_pt iterator);
-
-UTILS_EXPORT void *hashMapIterator_nextValue(hash_map_iterator_pt iterator);
-
-UTILS_EXPORT void *hashMapIterator_nextKey(hash_map_iterator_pt iterator);
-
-UTILS_EXPORT hash_map_entry_pt hashMapIterator_nextEntry(hash_map_iterator_pt iterator);
-
-UTILS_EXPORT hash_map_key_set_pt hashMapKeySet_create(hash_map_pt map);
-
-UTILS_EXPORT void hashMapKeySet_destroy(hash_map_key_set_pt keySet);
-
-UTILS_EXPORT int hashMapKeySet_size(hash_map_key_set_pt keySet);
-
-UTILS_EXPORT bool hashMapKeySet_contains(hash_map_key_set_pt keySet, const void *key);
-
-UTILS_EXPORT bool hashMapKeySet_remove(hash_map_key_set_pt keySet, const void *key);
-
-UTILS_EXPORT void hashMapKeySet_clear(hash_map_key_set_pt keySet);
-
-UTILS_EXPORT bool hashMapKeySet_isEmpty(hash_map_key_set_pt keySet);
-
-UTILS_EXPORT hash_map_values_pt hashMapValues_create(hash_map_pt map);
-
-UTILS_EXPORT void hashMapValues_destroy(hash_map_values_pt values);
-
-UTILS_EXPORT hash_map_iterator_pt hashMapValues_iterator(hash_map_values_pt values);
-
-UTILS_EXPORT int hashMapValues_size(hash_map_values_pt values);
-
-UTILS_EXPORT bool hashMapValues_contains(hash_map_values_pt values, const void *o);
-
-UTILS_EXPORT void hashMapValues_toArray(hash_map_values_pt values, void **array[], unsigned int *size);
-
-UTILS_EXPORT bool hashMapValues_remove(hash_map_values_pt values, const void *o);
-
-UTILS_EXPORT void hashMapValues_clear(hash_map_values_pt values);
-
-UTILS_EXPORT bool hashMapValues_isEmpty(hash_map_values_pt values);
-
-UTILS_EXPORT hash_map_entry_set_pt hashMapEntrySet_create(hash_map_pt map);
-
-UTILS_EXPORT void hashMapEntrySet_destroy(hash_map_entry_set_pt entrySet);
-
-UTILS_EXPORT int hashMapEntrySet_size(hash_map_entry_set_pt entrySet);
-
-UTILS_EXPORT bool hashMapEntrySet_contains(hash_map_entry_set_pt entrySet, hash_map_entry_pt entry);
-
-UTILS_EXPORT bool hashMapEntrySet_remove(hash_map_entry_set_pt entrySet, hash_map_entry_pt entry);
-
-UTILS_EXPORT void hashMapEntrySet_clear(hash_map_entry_set_pt entrySet);
-
-UTILS_EXPORT bool hashMapEntrySet_isEmpty(hash_map_entry_set_pt entrySet);
-
-UTILS_EXPORT void *hashMapEntry_getKey(hash_map_entry_pt entry);
-
-UTILS_EXPORT void *hashMapEntry_getValue(hash_map_entry_pt entry);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* HASH_MAP_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/linked_list.h
----------------------------------------------------------------------
diff --git a/utils/public/include/linked_list.h b/utils/public/include/linked_list.h
deleted file mode 100644
index cbf650c..0000000
--- a/utils/public/include/linked_list.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- *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.
- */
-/*
- * linked_list.h
- *
- *  \date       Jul 16, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LINKED_LIST_H_
-#define LINKED_LIST_H_
-
-
-#include "celixbool.h"
-#include "celix_errno.h"
-#include "exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef struct linked_list_entry *linked_list_entry_pt;
-typedef struct linked_list *linked_list_pt;
-
-UTILS_EXPORT celix_status_t linkedList_create(linked_list_pt *list);
-
-UTILS_EXPORT celix_status_t linkedList_destroy(linked_list_pt list);
-
-UTILS_EXPORT celix_status_t linkedList_clone(linked_list_pt list, linked_list_pt *clone);
-
-UTILS_EXPORT void *linkedList_getFirst(linked_list_pt list);
-
-UTILS_EXPORT void *linkedList_getLast(linked_list_pt list);
-
-UTILS_EXPORT void *linkedList_removeFirst(linked_list_pt list);
-
-UTILS_EXPORT void *linkedList_removeLast(linked_list_pt list);
-
-UTILS_EXPORT void linkedList_addFirst(linked_list_pt list, void *element);
-
-UTILS_EXPORT void linkedList_addLast(linked_list_pt list, void *element);
-
-UTILS_EXPORT bool linkedList_contains(linked_list_pt list, void *element);
-
-UTILS_EXPORT int linkedList_size(linked_list_pt list);
-
-UTILS_EXPORT bool linkedList_isEmpty(linked_list_pt list);
-
-UTILS_EXPORT bool linkedList_addElement(linked_list_pt list, void *element);
-
-UTILS_EXPORT bool linkedList_removeElement(linked_list_pt list, void *element);
-
-UTILS_EXPORT void linkedList_clear(linked_list_pt list);
-
-UTILS_EXPORT void *linkedList_get(linked_list_pt list, int index);
-
-UTILS_EXPORT void *linkedList_set(linked_list_pt list, int index, void *element);
-
-UTILS_EXPORT void linkedList_addIndex(linked_list_pt list, int index, void *element);
-
-UTILS_EXPORT void *linkedList_removeIndex(linked_list_pt list, int index);
-
-UTILS_EXPORT linked_list_entry_pt linkedList_entry(linked_list_pt list, int index);
-
-UTILS_EXPORT int linkedList_indexOf(linked_list_pt list, void *element);
-
-UTILS_EXPORT linked_list_entry_pt linkedList_addBefore(linked_list_pt list, void *element, linked_list_entry_pt entry);
-
-UTILS_EXPORT void *linkedList_removeEntry(linked_list_pt list, linked_list_entry_pt entry);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LINKED_LIST_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/linked_list_iterator.h
----------------------------------------------------------------------
diff --git a/utils/public/include/linked_list_iterator.h b/utils/public/include/linked_list_iterator.h
deleted file mode 100644
index f765d5d..0000000
--- a/utils/public/include/linked_list_iterator.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- *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.
- */
-/*
- * linked_list_iterator.h
- *
- *  \date       Jul 16, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LINKED_LIST_ITERATOR_H_
-#define LINKED_LIST_ITERATOR_H_
-
-#include "celixbool.h"
-
-#include "linked_list.h"
-#include "exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef struct linkedListIterator *linked_list_iterator_pt;
-
-UTILS_EXPORT linked_list_iterator_pt linkedListIterator_create(linked_list_pt list, unsigned int index);
-
-UTILS_EXPORT void linkedListIterator_destroy(linked_list_iterator_pt iterator);
-
-UTILS_EXPORT bool linkedListIterator_hasNext(linked_list_iterator_pt iterator);
-
-UTILS_EXPORT void *linkedListIterator_next(linked_list_iterator_pt iterator);
-
-UTILS_EXPORT bool linkedListIterator_hasPrevious(linked_list_iterator_pt iterator);
-
-UTILS_EXPORT void *linkedListIterator_previous(linked_list_iterator_pt iterator);
-
-UTILS_EXPORT int linkedListIterator_nextIndex(linked_list_iterator_pt iterator);
-
-UTILS_EXPORT int linkedListIterator_previousIndex(linked_list_iterator_pt iterator);
-
-UTILS_EXPORT void linkedListIterator_remove(linked_list_iterator_pt iterator);
-
-UTILS_EXPORT void linkedListIterator_set(linked_list_iterator_pt iterator, void *element);
-
-UTILS_EXPORT void linkedListIterator_add(linked_list_iterator_pt iterator, void *element);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LINKED_LIST_ITERATOR_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/memstream/README.md
----------------------------------------------------------------------
diff --git a/utils/public/include/memstream/README.md b/utils/public/include/memstream/README.md
deleted file mode 100644
index 476810e..0000000
--- a/utils/public/include/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/a1c30887/utils/public/include/memstream/fmemopen.h
----------------------------------------------------------------------
diff --git a/utils/public/include/memstream/fmemopen.h b/utils/public/include/memstream/fmemopen.h
deleted file mode 100644
index 3d06b20..0000000
--- a/utils/public/include/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/a1c30887/utils/public/include/memstream/open_memstream.h
----------------------------------------------------------------------
diff --git a/utils/public/include/memstream/open_memstream.h b/utils/public/include/memstream/open_memstream.h
deleted file mode 100644
index e87bb0a..0000000
--- a/utils/public/include/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/a1c30887/utils/public/include/properties.h
----------------------------------------------------------------------
diff --git a/utils/public/include/properties.h b/utils/public/include/properties.h
deleted file mode 100644
index cf93ca0..0000000
--- a/utils/public/include/properties.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- *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.
- */
-/*
- * properties.h
- *
- *  \date       Apr 27, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef PROPERTIES_H_
-#define PROPERTIES_H_
-
-#include <stdio.h>
-
-#include "hash_map.h"
-#include "exports.h"
-#include "celix_errno.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef hash_map_pt properties_pt;
-typedef hash_map_t properties_t;
-
-UTILS_EXPORT properties_pt properties_create(void);
-
-UTILS_EXPORT void properties_destroy(properties_pt properties);
-
-UTILS_EXPORT properties_pt properties_load(const char *filename);
-
-UTILS_EXPORT properties_pt properties_loadWithStream(FILE *stream);
-
-UTILS_EXPORT void properties_store(properties_pt properties, const char *file, const char *header);
-
-UTILS_EXPORT const char *properties_get(properties_pt properties, const char *key);
-
-UTILS_EXPORT const char *properties_getWithDefault(properties_pt properties, const char *key, const char *defaultValue);
-
-UTILS_EXPORT void properties_set(properties_pt properties, const char *key, const char *value);
-
-UTILS_EXPORT celix_status_t properties_copy(properties_pt properties, properties_pt *copy);
-
-#define PROPERTIES_FOR_EACH(props, key) \
-    for(hash_map_iterator_t iter = hashMapIterator_construct(props); \
-        hashMapIterator_hasNext(&iter), (key) = (const char*)hashMapIterator_nextKey(&iter);)
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PROPERTIES_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/thpool.h
----------------------------------------------------------------------
diff --git a/utils/public/include/thpool.h b/utils/public/include/thpool.h
deleted file mode 100644
index 0180aa6..0000000
--- a/utils/public/include/thpool.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/********************************** 
- * @author      Johan Hanssen Seferidis
- * License:     MIT
- * 
- **********************************/
-
-#ifndef _THPOOL_
-#define _THPOOL_
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* =================================== API ======================================= */
-
-
-typedef struct thpool_ *threadpool;
-
-
-/**
- * @brief  Initialize threadpool
- * 
- * Initializes a threadpool. This function will not return untill all
- * threads have initialized successfully.
- * 
- * @example
- * 
- *    ..
- *    threadpool thpool;                     //First we declare a threadpool
- *    thpool = thpool_init(4);               //then we initialize it to 4 threads
- *    ..
- * 
- * @param  num_threads   number of threads to be created in the threadpool
- * @return threadpool    created threadpool on success,
- *                       NULL on error
- */
-threadpool thpool_init(int num_threads);
-
-
-/**
- * @brief Add work to the job queue
- * 
- * Takes an action and its argument and adds it to the threadpool's job queue.
- * If you want to add to work a function with more than one arguments then
- * a way to implement this is by passing a pointer to a structure.
- * 
- * NOTICE: You have to cast both the function and argument to not get warnings.
- * 
- * @example
- * 
- *    void print_num(int num){
- *       printf("%d\n", num);
- *    }
- * 
- *    int main() {
- *       ..
- *       int a = 10;
- *       thpool_add_work(thpool, (void*)print_num, (void*)a);
- *       ..
- *    }
- * 
- * @param  threadpool    threadpool to which the work will be added
- * @param  function_p    pointer to function to add as work
- * @param  arg_p         pointer to an argument
- * @return nothing
- */
-int thpool_add_work(threadpool, void *(*function_p)(void *), void *arg_p);
-
-
-/**
- * @brief Wait for all queued jobs to finish
- * 
- * Will wait for all jobs - both queued and currently running to finish.
- * Once the queue is empty and all work has completed, the calling thread
- * (probably the main program) will continue.
- * 
- * Smart polling is used in wait. The polling is initially 0 - meaning that
- * there is virtually no polling at all. If after 1 seconds the threads
- * haven't finished, the polling interval starts growing exponentially 
- * untill it reaches max_secs seconds. Then it jumps down to a maximum polling
- * interval assuming that heavy processing is being used in the threadpool.
- *
- * @example
- * 
- *    ..
- *    threadpool thpool = thpool_init(4);
- *    ..
- *    // Add a bunch of work
- *    ..
- *    thpool_wait(thpool);
- *    puts("All added work has finished");
- *    ..
- * 
- * @param threadpool     the threadpool to wait for
- * @return nothing
- */
-void thpool_wait(threadpool);
-
-
-/**
- * @brief Pauses all threads immediately
- * 
- * The threads will be paused no matter if they are idle or working.
- * The threads return to their previous states once thpool_resume
- * is called.
- * 
- * While the thread is being paused, new work can be added.
- * 
- * @example
- * 
- *    threadpool thpool = thpool_init(4);
- *    thpool_pause(thpool);
- *    ..
- *    // Add a bunch of work
- *    ..
- *    thpool_resume(thpool); // Let the threads start their magic
- * 
- * @param threadpool    the threadpool where the threads should be paused
- * @return nothing
- */
-void thpool_pause(threadpool);
-
-
-/**
- * @brief Unpauses all threads if they are paused
- * 
- * @example
- *    ..
- *    thpool_pause(thpool);
- *    sleep(10);              // Delay execution 10 seconds
- *    thpool_resume(thpool);
- *    ..
- * 
- * @param threadpool     the threadpool where the threads should be unpaused
- * @return nothing
- */
-void thpool_resume(threadpool);
-
-
-/**
- * @brief Destroy the threadpool
- * 
- * This will wait for the currently active threads to finish and then 'kill'
- * the whole threadpool to free up memory.
- * 
- * @example
- * int main() {
- *    threadpool thpool1 = thpool_init(2);
- *    threadpool thpool2 = thpool_init(2);
- *    ..
- *    thpool_destroy(thpool1);
- *    ..
- *    return 0;
- * }
- * 
- * @param threadpool     the threadpool to destroy
- * @return nothing
- */
-void thpool_destroy(threadpool);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/utils.h
----------------------------------------------------------------------
diff --git a/utils/public/include/utils.h b/utils/public/include/utils.h
deleted file mode 100644
index 2fc7d44..0000000
--- a/utils/public/include/utils.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- *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.
- */
-/*
- * utils.h
- *
- *  \date       Jul 27, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef UTILS_H_
-#define UTILS_H_
-
-#include <ctype.h>
-
-#include "celix_errno.h"
-#include "celixbool.h"
-#include "exports.h"
-#include "celix_threads.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-UTILS_EXPORT unsigned int utils_stringHash(const void *string);
-
-UTILS_EXPORT int utils_stringEquals(const void *string, const void *toCompare);
-
-UTILS_EXPORT char *string_ndup(const char *s, size_t n);
-
-UTILS_EXPORT char *utils_stringTrim(char *string);
-
-UTILS_EXPORT bool utils_isStringEmptyOrNull(const char *const str);
-
-UTILS_EXPORT int
-utils_compareServiceIdsAndRanking(unsigned long servId, long servRank, unsigned long otherServId, long otherServRank);
-
-UTILS_EXPORT celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals);
-
-UTILS_EXPORT celix_status_t utils_isNumeric(const char *number, bool *ret);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* UTILS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/version.h
----------------------------------------------------------------------
diff --git a/utils/public/include/version.h b/utils/public/include/version.h
deleted file mode 100644
index 88e146a..0000000
--- a/utils/public/include/version.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/**
- *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.
- */
-/*
- * version.h
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef VERSION_H_
-#define VERSION_H_
-
-#include "celix_errno.h"
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * The definition of the version_pt abstract data type.
- */
-typedef struct version *version_pt;
-
-/**
- * Creates a new version_pt using the supplied arguments.
- *
- * @param major Major component of the version identifier.
- * @param minor Minor component of the version identifier.
- * @param micro Micro component of the version identifier.
- * @param qualifier Qualifier component of the version identifier. If
- *        <code>null</code> is specified, then the qualifier will be set to
- *        the empty string.
- * @param version The created version_pt
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
- * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative
- * 		  or the qualifier string is invalid.
- */
-celix_status_t version_createVersion(int major, int minor, int micro, char *qualifier, version_pt *version);
-
-celix_status_t version_destroy(version_pt version);
-
-/**
- * Creates a clone of <code>version</code>.
- *
- * @param version The version to clone
- * @param clone The cloned version
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
- * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative
- * 		  or the qualifier string is invalid.
- */
-celix_status_t version_clone(version_pt version, version_pt *clone);
-
-/**
- * Creates a version identifier from the specified string.
- *
- * <p>
- * Here is the grammar for version strings.
- *
- * <pre>
- * version ::= major('.'minor('.'micro('.'qualifier)?)?)?
- * major ::= digit+
- * minor ::= digit+
- * micro ::= digit+
- * qualifier ::= (alpha|digit|'_'|'-')+
- * digit ::= [0..9]
- * alpha ::= [a..zA..Z]
- * </pre>
- *
- * There must be no whitespace in version.
- *
- * @param versionStr String representation of the version identifier.
- * @param version The created version_pt
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
- * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
- * 		  	the qualifier string is invalid or <code>versionStr</code> is improperly formatted.
- */
-celix_status_t version_createVersionFromString(const char *versionStr, version_pt *version);
-
-/**
- * The empty version "0.0.0".
- *
- * @param version The created version_pt
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
- * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
- * 		  	the qualifier string is invalid or <code>versionStr</code> is improperly formatted.
- */
-celix_status_t version_createEmptyVersion(version_pt *version);
-
-celix_status_t version_getMajor(version_pt version, int *major);
-
-celix_status_t version_getMinor(version_pt version, int *minor);
-
-celix_status_t version_getMicro(version_pt version, int *micro);
-
-celix_status_t version_getQualifier(version_pt version, const char **qualifier);
-
-/**
- * Compares this <code>Version</code> object to another object.
- *
- * <p>
- * A version is considered to be <b>less than </b> another version if its
- * major component is less than the other version's major component, or the
- * major components are equal and its minor component is less than the other
- * version's minor component, or the major and minor components are equal
- * and its micro component is less than the other version's micro component,
- * or the major, minor and micro components are equal and it's qualifier
- * component is less than the other version's qualifier component (using
- * <code>String.compareTo</code>).
- *
- * <p>
- * A version is considered to be <b>equal to</b> another version if the
- * major, minor and micro components are equal and the qualifier component
- * is equal (using <code>String.compareTo</code>).
- *
- * @param version The <code>version_pt</code> to be compared with <code>compare</code>.
- * @param compare The <code>version_pt</code> to be compared with <code>version</code>.
- * @param result A negative integer, zero, or a positive integer if <code>version</code> is
- *         less than, equal to, or greater than the <code>compare</code>.
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t version_compareTo(version_pt version, version_pt compare, int *result);
-
-/**
- * Returns the string representation of <code>version</code> identifier.
- *
- * <p>
- * The format of the version string will be <code>major.minor.micro</code>
- * if qualifier is the empty string or
- * <code>major.minor.micro.qualifier</code> otherwise.
- *
- * @return The string representation of this version identifier.
- * @param version The <code>version_pt</code> to get the string representation from.
- * @param string Pointer to the string (char *) in which the result will be placed.
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t version_toString(version_pt version, char **string);
-
-/**
- * Check if two versions are semantically compatible.
- *
- * <p>
- * The user version is compatible with the provider version if the provider version is in the range
- * [user_version, next_macro_from_user_version)
- *
- * @return Boolean indicating if the versions are compatible
- * @param version The user <code>version_pt</code> .
- * @param version The reference provider <code>version_pt</code> .
- * @param Boolean indicating if the versions are compatible
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t version_isCompatible(version_pt user, version_pt provider, bool *isCompatible);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* VERSION_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/version_range.h
----------------------------------------------------------------------
diff --git a/utils/public/include/version_range.h b/utils/public/include/version_range.h
deleted file mode 100644
index b661cd3..0000000
--- a/utils/public/include/version_range.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- *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.
- */
-/*
- * version_range.h
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef VERSION_RANGE_H_
-#define VERSION_RANGE_H_
-
-/**
- * @defgroup VersionRange Version Range functions
- * @ingroup framework
- * @{
- */
-
-#include "celixbool.h"
-#include "celix_errno.h"
-#include "version.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/**
- * Type definition for the version_range_pt abstract data type.
- */
-typedef struct versionRange *version_range_pt;
-
-/**
- * Creates a new <code>version_range_pt</code>.
- *
- * @param low Lower bound version
- * @param isLowInclusive True if lower bound should be included in the range
- * @param high Upper bound version
- * @param isHighInclusive True if upper bound should be included in the range
- * @param versionRange The created range
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ENOMEM If allocating memory for <code>versionRange</code> failed.
- */
-celix_status_t
-versionRange_createVersionRange(version_pt low, bool isLowInclusive, version_pt high, bool isHighInclusive,
-                                version_range_pt *versionRange);
-
-/**
- * Creates an infinite version range using ::version_createEmptyVersion for the low version,
- * 	NULL for the high version and high and low inclusive set to true.
- *
- * @param range The created range
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ENOMEM If allocating memory for <code>range</code> failed.
- */
-celix_status_t versionRange_createInfiniteVersionRange(version_range_pt *range);
-
-celix_status_t versionRange_destroy(version_range_pt range);
-
-/**
- * Determine if the specified version is part of the version range or not.
- *
- * @param versionRange The range to check <code>version</code> against.
- * @param version The version to check.
- * @param inRange True if the specified version is included in this version range, false otherwise.
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t versionRange_isInRange(version_range_pt versionRange, version_pt version, bool *inRange);
-
-/**
- * Determines whether the lower bound is included in the given range
- *
- * @param versionRange The range to check
- * @param isLowInclusive is set to true in case, the lower bound the lower bound is included, otherwise false
- * @return Status code indication failure or success:
- *      - CELIX_SUCCESS when no errors are encountered.
- *      - CELIX_ILLEGAL_ARGUMENT in case the versionRange is NULL
- */
-celix_status_t versionRange_isLowInclusive(version_range_pt versionRange, bool *isLowInclusive);
-
-/**
- * Determines whether the higher bound is included in the given range
- *
- * @param versionRange The range to check
- * @param isHighInclusive is set to true in case, the lower bound the higher bound is included, otherwise false
- * @return Status code indication failure or success:
- *      - CELIX_SUCCESS when no errors are encountered.
- *      - CELIX_ILLEGAL_ARGUMENT in case the versionRange is NULL
- */
-celix_status_t versionRange_isHighInclusive(version_range_pt versionRange, bool *isHighInclusive);
-
-/**
- * Retrieves whether the lower bound version from the given range
- *
- * @param versionRange The range
- * @param highVersion is set to the lower bound version
- * @return Status code indication failure or success:
- *      - CELIX_SUCCESS when no errors are encountered.
- *      - CELIX_ILLEGAL_ARGUMENT in case the versionRange is NULL
- */
-celix_status_t versionRange_getLowVersion(version_range_pt versionRange, version_pt *lowVersion);
-
-/**
- * Retrieves whether the upper bound version from the given range
- *
- * @param versionRange The range
- * @param highVersion is set to the upper bound version
- * @return Status code indication failure or success:
- *      - CELIX_SUCCESS when no errors are encountered.
- *      - CELIX_ILLEGAL_ARGUMENT in case the versionRange is NULL
- */
-celix_status_t versionRange_getHighVersion(version_range_pt versionRange, version_pt *highVersion);
-
-/**
- * Parses a version range from the specified string.
- *
- * <p>
- * Here is the grammar for version range strings.
- *
- * <pre>
- * version-range ::= interval | atleast
- * interval ::= ( '[' | '(' ) floor ',' ceiling ( ']' | ')' )
- * atleast ::= version
- * floor ::= version
- * ceiling ::= version
- * </pre>
- *
- * @param rangeStr String representation of the version range.
- * @param range The created version_range_pt.
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ENOMEM If allocating memory for <code>versionRange</code> failed.
- * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
- * 		  	the qualifier string is invalid or <code>versionStr</code> is impropertly formatted.
- */
-celix_status_t versionRange_parse(const char *rangeStr, version_range_pt *range);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* VERSION_RANGE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/array_list.c
----------------------------------------------------------------------
diff --git a/utils/src/array_list.c b/utils/src/array_list.c
new file mode 100644
index 0000000..e7a2e30
--- /dev/null
+++ b/utils/src/array_list.c
@@ -0,0 +1,337 @@
+/**
+ *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.
+ */
+/*
+ * array_list.c
+ *
+ *  \date       Aug 4, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "array_list.h"
+#include "array_list_private.h"
+
+static celix_status_t arrayList_elementEquals(const void *a, const void *b, bool *equals);
+
+celix_status_t arrayList_create(array_list_pt *list) {
+	return arrayList_createWithEquals(arrayList_elementEquals, list);
+}
+
+ celix_status_t arrayList_createWithEquals(array_list_element_equals_pt equals, array_list_pt *list) {
+	*list = (array_list_pt) malloc(sizeof(**list));
+
+	(*list)->equals = equals;
+	(*list)->size = 0;
+	(*list)->capacity = 10;
+	(*list)->modCount = 0;
+	(*list)->elementData = (void **) malloc(sizeof(void*) * (*list)->capacity);
+
+	return CELIX_SUCCESS;
+}
+
+void arrayList_destroy(array_list_pt list) {
+	list->size = 0;
+	free(list->elementData);
+	list->elementData = NULL;
+	free(list);
+}
+
+static celix_status_t arrayList_elementEquals(const void *a, const void *b, bool *equals) {
+	*equals = (a == b);
+	return CELIX_SUCCESS;
+}
+
+void arrayList_trimToSize(array_list_pt list) {
+	unsigned int oldCapacity;
+	list->modCount++;
+	oldCapacity = list->capacity;
+	if (list->size < oldCapacity) {
+		void ** newList = (void **) realloc(list->elementData, sizeof(void *) * list->size);
+		list->capacity = list->size;
+		list->elementData = newList;
+	}
+}
+
+void arrayList_ensureCapacity(array_list_pt list, int capacity) {
+	void ** newList;
+	unsigned int oldCapacity;
+	list->modCount++;
+	oldCapacity = list->capacity;
+	if (capacity > oldCapacity) {
+		unsigned int newCapacity = (oldCapacity * 3) / 2 + 1;
+		if (newCapacity < capacity) {
+			newCapacity = capacity;
+		}
+		newList = (void **) realloc(list->elementData, sizeof(void *) * newCapacity);
+		list->capacity = newCapacity;
+		list->elementData = newList;
+	}
+}
+
+unsigned int arrayList_size(array_list_pt list) {
+	return list->size;
+}
+
+bool arrayList_isEmpty(array_list_pt list) {
+	return list->size == 0;
+}
+
+bool arrayList_contains(array_list_pt list, void * element) {
+	int index = arrayList_indexOf(list, element);
+	return index >= 0;
+}
+
+int arrayList_indexOf(array_list_pt list, void * element) {
+	if (element == NULL) {
+		unsigned int i = 0;
+		for (i = 0; i < list->size; i++) {
+			if (list->elementData[i] == NULL) {
+				return i;
+			}
+		}
+	} else {
+		unsigned int i = 0;
+		for (i = 0; i < list->size; i++) {
+			bool equals = false;
+			list->equals(element, list->elementData[i], &equals);
+			if (equals) {
+				return i;
+			}
+		}
+	}
+	return -1;
+}
+
+int arrayList_lastIndexOf(array_list_pt list, void * element) {
+	if (element == NULL) {
+		int i = 0;
+		for (i = list->size - 1; i >= 0; i--) {
+			if (list->elementData[i] == NULL) {
+				return i;
+			}
+		}
+	} else {
+		int i = 0;
+		for (i = list->size - 1; i >= 0; i--) {
+			bool equals = false;
+			list->equals(element, list->elementData[i], &equals);
+			if (equals) {
+				return i;
+			}
+		}
+	}
+	return -1;
+}
+
+void * arrayList_get(array_list_pt list, unsigned int index) {
+	if (index >= list->size) {
+		return NULL;
+	}
+
+	return list->elementData[index];
+}
+
+void * arrayList_set(array_list_pt list, unsigned int index, void * element) {
+	void * oldElement;
+	if (index >= list->size) {
+		return NULL;
+	}
+
+	oldElement = list->elementData[index];
+	list->elementData[index] = element;
+	return oldElement;
+}
+
+bool arrayList_add(array_list_pt list, void * element) {
+	arrayList_ensureCapacity(list, list->size + 1);
+	list->elementData[list->size++] = element;
+	return true;
+}
+
+int arrayList_addIndex(array_list_pt list, unsigned int index, void * element) {
+	unsigned int numMoved;
+	if (index > list->size) {
+		return -1;
+	}
+	arrayList_ensureCapacity(list, list->size+1);
+	numMoved = list->size - index;
+	memmove(list->elementData+(index+1), list->elementData+index, sizeof(void *) * numMoved);
+
+	list->elementData[index] = element;
+	list->size++;
+	return 0;
+}
+
+void * arrayList_remove(array_list_pt list, unsigned int index) {
+	void * oldElement;
+	unsigned int numMoved;
+	if (index >= list->size) {
+		return NULL;
+	}
+
+	list->modCount++;
+	oldElement = list->elementData[index];
+	numMoved = list->size - index - 1;
+	memmove(list->elementData+index, list->elementData+index+1, sizeof(void *) * numMoved);
+	list->elementData[--list->size] = NULL;
+
+	return oldElement;
+}
+
+void arrayList_fastRemove(array_list_pt list, unsigned int index) {
+	unsigned int numMoved;
+	list->modCount++;
+
+	numMoved = list->size - index - 1;
+	memmove(list->elementData+index, list->elementData+index+1, sizeof(void *) * numMoved);
+	list->elementData[--list->size] = NULL;
+}
+
+bool arrayList_removeElement(array_list_pt list, void * element) {
+	if (element == NULL) {
+		unsigned int i = 0;
+		for (i = 0; i < list->size; i++) {
+			if (list->elementData[i] == NULL) {
+				arrayList_fastRemove(list, i);
+				return true;
+			}
+		}
+	} else {
+		unsigned int i = 0;
+		for (i = 0; i < list->size; i++) {
+			bool equals = false;
+			list->equals(element, list->elementData[i], &equals);
+			if (equals) {
+				arrayList_fastRemove(list, i);
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+void arrayList_clear(array_list_pt list) {
+	unsigned int i;
+	list->modCount++;
+
+	for (i = 0; i < list->size; i++) {
+		// free(list->elementData[i]);
+		list->elementData[i] = NULL;
+	}
+	list->size = 0;
+}
+
+bool arrayList_addAll(array_list_pt list, array_list_pt toAdd) {
+    unsigned int i;
+    unsigned int size = arrayList_size(toAdd);
+    arrayList_ensureCapacity(list, list->size + size);
+//    memcpy(list->elementData+list->size, *toAdd->elementData, size);
+//    list->size += size;
+    for (i = 0; i < arrayList_size(toAdd); i++) {
+        arrayList_add(list, arrayList_get(toAdd, i));
+    }
+    return size != 0;
+}
+
+array_list_pt arrayList_clone(array_list_pt list) {
+	unsigned int i;
+	array_list_pt new = NULL;
+	arrayList_create(&new);
+//	arrayList_ensureCapacity(new, list->size);
+//	memcpy(new->elementData, list->elementData, list->size);
+//	new->size = list->size;
+	
+	for (i = 0; i < arrayList_size(list); i++) {
+		arrayList_add(new, arrayList_get(list, i));
+	}
+	new->modCount = 0;
+	return new;
+}
+
+array_list_iterator_pt arrayListIterator_create(array_list_pt list) {
+	array_list_iterator_pt iterator = (array_list_iterator_pt) malloc(sizeof(*iterator));
+
+	iterator->lastReturned = -1;
+	iterator->cursor = 0;
+	iterator->list = list;
+	iterator->expectedModificationCount = list->modCount;
+
+	return iterator;
+}
+
+void arrayListIterator_destroy(array_list_iterator_pt iterator) {
+	iterator->lastReturned = -1;
+	iterator->cursor = 0;
+	iterator->expectedModificationCount = 0;
+	iterator->list = NULL;
+	free(iterator);
+}
+
+bool arrayListIterator_hasNext(array_list_iterator_pt iterator) {
+	return iterator->cursor != iterator->list->size;
+}
+
+void * arrayListIterator_next(array_list_iterator_pt iterator) {
+	void * next;
+	if (iterator->expectedModificationCount != iterator->list->modCount) {
+		return NULL;
+	}
+	next = arrayList_get(iterator->list, iterator->cursor);
+	iterator->lastReturned = iterator->cursor++;
+	return next;
+}
+
+bool arrayListIterator_hasPrevious(array_list_iterator_pt iterator) {
+	return iterator->cursor != 0;
+}
+
+void * arrayListIterator_previous(array_list_iterator_pt iterator) {
+	int i;
+	void * previous;
+	if (iterator->expectedModificationCount != iterator->list->modCount) {
+		return NULL;
+	}
+	i = iterator->cursor - 1;
+	previous = arrayList_get(iterator->list, i);
+	iterator->lastReturned = iterator->cursor = i;
+	return previous;
+}
+
+void arrayListIterator_remove(array_list_iterator_pt iterator) {
+	if (iterator->lastReturned == -1) {
+		return;
+	}
+	if (iterator->expectedModificationCount != iterator->list->modCount) {
+		return;
+	}
+	if (arrayList_remove(iterator->list, iterator->lastReturned) != NULL) {
+		if (iterator->lastReturned < iterator->cursor) {
+			iterator->cursor--;
+		}
+		iterator->lastReturned = -1;
+		iterator->expectedModificationCount = iterator->list->modCount;
+	}
+}
+
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/array_list_private.h
----------------------------------------------------------------------
diff --git a/utils/src/array_list_private.h b/utils/src/array_list_private.h
new file mode 100644
index 0000000..bea2712
--- /dev/null
+++ b/utils/src/array_list_private.h
@@ -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.
+ */
+/*
+ * array_list_private.h
+ *
+ *  \date       Aug 4, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef array_list_t_PRIVATE_H_
+#define array_list_t_PRIVATE_H_
+
+#include "array_list.h"
+
+struct arrayList {
+	void ** elementData;
+	unsigned int size;
+	unsigned int capacity;
+
+	unsigned int modCount;
+
+	array_list_element_equals_pt equals;
+};
+
+struct arrayListIterator {
+	array_list_pt list;
+	unsigned int cursor;
+	int lastReturned;
+	unsigned int expectedModificationCount;
+};
+
+void * arrayList_remove(array_list_pt list, unsigned int index);
+
+
+#endif /* array_list_t_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/celix_threads.c
----------------------------------------------------------------------
diff --git a/utils/src/celix_threads.c b/utils/src/celix_threads.c
new file mode 100644
index 0000000..64bdf5b
--- /dev/null
+++ b/utils/src/celix_threads.c
@@ -0,0 +1,184 @@
+/**
+ *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_threads.c
+ *
+ *  \date       4 Jun 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include "signal.h"
+#include "celix_threads.h"
+
+
+celix_status_t celixThread_create(celix_thread_t *new_thread, celix_thread_attr_t *attr, celix_thread_start_t func, void *data) {
+    celix_status_t status = CELIX_SUCCESS;
+
+	if (pthread_create(&(*new_thread).thread, attr, func, data) != 0) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	}
+	else {
+		(*new_thread).threadInitialized = true;
+	}
+
+	return status;
+}
+
+// Returns void, since pthread_exit does exit the thread and never returns.
+void celixThread_exit(void *exitStatus) {
+    pthread_exit(exitStatus);
+}
+
+celix_status_t celixThread_detach(celix_thread_t thread) {
+    return pthread_detach(thread.thread);
+}
+
+celix_status_t celixThread_join(celix_thread_t thread, void **retVal) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (pthread_join(thread.thread, retVal) != 0) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	}
+
+    // #TODO make thread a pointer? Now this statement has no effect
+	// thread.threadInitialized = false;
+
+    return status;
+}
+
+celix_status_t celixThread_kill(celix_thread_t thread, int sig) {
+    return pthread_kill(thread.thread, sig);
+}
+
+celix_thread_t celixThread_self() {
+	celix_thread_t thread;
+
+	thread.thread = pthread_self();
+	thread.threadInitialized = true;
+
+	return thread;
+}
+
+int celixThread_equals(celix_thread_t thread1, celix_thread_t thread2) {
+    return pthread_equal(thread1.thread, thread2.thread);
+}
+
+bool celixThread_initalized(celix_thread_t thread) {
+    return thread.threadInitialized;
+}
+
+
+celix_status_t celixThreadMutex_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t *attr) {
+    return pthread_mutex_init(mutex, attr);
+}
+
+celix_status_t celixThreadMutex_destroy(celix_thread_mutex_t *mutex) {
+    return pthread_mutex_destroy(mutex);
+}
+
+celix_status_t celixThreadMutex_lock(celix_thread_mutex_t *mutex) {
+    return pthread_mutex_lock(mutex);
+}
+
+celix_status_t celixThreadMutex_unlock(celix_thread_mutex_t *mutex) {
+    return pthread_mutex_unlock(mutex);
+}
+
+celix_status_t celixThreadMutexAttr_create(celix_thread_mutexattr_t *attr) {
+	return pthread_mutexattr_init(attr);
+}
+
+celix_status_t celixThreadMutexAttr_destroy(celix_thread_mutexattr_t *attr) {
+	return pthread_mutexattr_destroy(attr);
+}
+
+celix_status_t celixThreadMutexAttr_settype(celix_thread_mutexattr_t *attr, int type) {
+	celix_status_t status;
+	switch(type) {
+		case CELIX_THREAD_MUTEX_NORMAL :
+			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_NORMAL);
+			break;
+		case CELIX_THREAD_MUTEX_RECURSIVE :
+			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE);
+			break;
+		case CELIX_THREAD_MUTEX_ERRORCHECK :
+			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_ERRORCHECK);
+			break;
+		case CELIX_THREAD_MUTEX_DEFAULT :
+			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_DEFAULT);
+			break;
+		default:
+			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_DEFAULT);
+			break;
+    }
+	return status;
+}
+
+celix_status_t celixThreadCondition_init(celix_thread_cond_t *condition, celix_thread_condattr_t *attr) {
+    return pthread_cond_init(condition, attr);
+}
+
+celix_status_t celixThreadCondition_destroy(celix_thread_cond_t *condition) {
+    return pthread_cond_destroy(condition);
+}
+
+celix_status_t celixThreadCondition_wait(celix_thread_cond_t *cond, celix_thread_mutex_t *mutex) {
+    return pthread_cond_wait(cond, mutex);
+}
+
+celix_status_t celixThreadCondition_broadcast(celix_thread_cond_t *cond) {
+    return pthread_cond_broadcast(cond);
+}
+
+celix_status_t celixThreadCondition_signal(celix_thread_cond_t *cond) {
+    return pthread_cond_signal(cond);
+}
+
+celix_status_t celixThreadRwlock_create(celix_thread_rwlock_t *lock, celix_thread_rwlockattr_t *attr) {
+	return pthread_rwlock_init(lock, attr);
+}
+
+celix_status_t celixThreadRwlock_destroy(celix_thread_rwlock_t *lock) {
+	return pthread_rwlock_destroy(lock);
+}
+
+celix_status_t celixThreadRwlock_readLock(celix_thread_rwlock_t *lock) {
+	return pthread_rwlock_rdlock(lock);
+}
+
+celix_status_t celixThreadRwlock_writeLock(celix_thread_rwlock_t *lock) {
+	return pthread_rwlock_wrlock(lock);
+}
+
+celix_status_t celixThreadRwlock_unlock(celix_thread_rwlock_t *lock) {
+	return pthread_rwlock_unlock(lock);
+}
+
+celix_status_t celixThreadRwlockAttr_create(celix_thread_rwlockattr_t *attr) {
+	return pthread_rwlockattr_init(attr);
+}
+
+celix_status_t celixThreadRwlockAttr_destroy(celix_thread_rwlockattr_t *attr) {
+	return pthread_rwlockattr_destroy(attr);
+}
+
+celix_status_t celixThread_once(celix_thread_once_t *once_control, void (*init_routine)(void)) {
+	return pthread_once(once_control, init_routine);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/hash_map.c
----------------------------------------------------------------------
diff --git a/utils/src/hash_map.c b/utils/src/hash_map.c
new file mode 100644
index 0000000..bc514a7
--- /dev/null
+++ b/utils/src/hash_map.c
@@ -0,0 +1,607 @@
+/**
+ *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.
+ */
+/*
+ * hash_map.c
+ *
+ *  \date       Jul 21, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include "celixbool.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "hash_map.h"
+#include "hash_map_private.h"
+
+static unsigned int DEFAULT_INITIAL_CAPACITY = 16;
+static float DEFAULT_LOAD_FACTOR = 0.75f;
+static unsigned int MAXIMUM_CAPACITY = 1 << 30;
+
+unsigned int hashMap_hashCode(const void * toHash) {
+	intptr_t address = (intptr_t) toHash;
+	return address;
+}
+
+int hashMap_equals(const void * toCompare, const void * compare) {
+	return toCompare == compare;
+}
+
+int hashMap_entryEquals(hash_map_pt map, hash_map_entry_pt entry, hash_map_entry_pt compare) {
+	if (entry->key == compare->key || map->equalsKey(entry->key, compare->key)) {
+		if (entry->value == compare->value || map->equalsValue(entry->value, compare->value)) {
+			return true;
+		}
+	}
+	return false;
+}
+
+static unsigned int hashMap_hash(unsigned int h) {
+	h += ~(h << 9);
+	h ^=  ((h >> 14) | (h << 18)); /* >>> */
+	h +=  (h << 4);
+	h ^=  ((h >> 10) | (h << 22)); /* >>> */
+	return h;
+}
+
+static unsigned int hashMap_indexFor(unsigned int h, unsigned int length) {
+	return h & (length - 1);
+}
+
+hash_map_pt hashMap_create(unsigned int (*keyHash)(const void *), unsigned int (*valueHash)(const void *),
+		int (*keyEquals)(const void *, const void *), int (*valueEquals)(const void *, const void *)) {
+	hash_map_pt map = (hash_map_pt) malloc(sizeof(*map));
+	map->treshold = (unsigned int) (DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR);
+	map->table = (hash_map_entry_pt *) calloc(DEFAULT_INITIAL_CAPACITY, sizeof(hash_map_entry_pt));
+	map->size = 0;
+	map->modificationCount = 0;
+	map->tablelength = DEFAULT_INITIAL_CAPACITY;
+	map->hashKey = hashMap_hashCode;
+	map->hashValue = hashMap_hashCode;
+	map->equalsKey = hashMap_equals;
+	map->equalsValue = hashMap_equals;
+
+	if (keyHash != NULL) {
+		map->hashKey = keyHash;
+	}
+	if (valueHash != NULL) {
+		map->hashValue = valueHash;
+	}
+	if (keyEquals != NULL) {
+		map->equalsKey = keyEquals;
+	}
+	if (valueEquals != NULL) {
+		map->equalsValue = valueEquals;
+	}
+
+	return map;
+}
+
+void hashMap_destroy(hash_map_pt map, bool freeKeys, bool freeValues) {
+	hashMap_clear(map, freeKeys, freeValues);
+	free(map->table);
+	free(map);
+}
+
+int hashMap_size(hash_map_pt map) {
+	return map->size;
+}
+
+bool hashMap_isEmpty(hash_map_pt map) {
+	return hashMap_size(map) == 0;
+}
+
+void * hashMap_get(hash_map_pt map, const void* key) {
+	unsigned int hash;
+	if (key == NULL) {
+		hash_map_entry_pt entry;
+		for (entry = map->table[0]; entry != NULL; entry = entry->next) {
+			if (entry->key == NULL) {
+				return entry->value;
+			}
+		}
+		return NULL;
+	}
+
+	hash = hashMap_hash(map->hashKey(key));
+	hash_map_entry_pt entry = NULL;
+	for (entry = map->table[hashMap_indexFor(hash, map->tablelength)]; entry != NULL; entry = entry->next) {
+		if (entry->hash == hash && (entry->key == key || map->equalsKey(key, entry->key))) {
+			return entry->value;
+		}
+	}
+	return NULL;
+}
+
+bool hashMap_containsKey(hash_map_pt map, const void* key) {
+	return hashMap_getEntry(map, key) != NULL;
+}
+
+hash_map_entry_pt hashMap_getEntry(hash_map_pt map, const void* key) {
+	unsigned int hash = (key == NULL) ? 0 : hashMap_hash(map->hashKey(key));
+	hash_map_entry_pt entry;
+	int index = hashMap_indexFor(hash, map->tablelength);
+	for (entry = map->table[index]; entry != NULL; entry = entry->next) {
+		if (entry->hash == hash && (entry->key == key || map->equalsKey(key, entry->key))) {
+			return entry;
+		}
+	}
+	return NULL;
+}
+
+void * hashMap_put(hash_map_pt map, void * key, void * value) {
+	unsigned int hash;
+	int i;
+	if (key == NULL) {
+		hash_map_entry_pt entry;
+		for (entry = map->table[0]; entry != NULL; entry = entry->next) {
+			if (entry->key == NULL) {
+				void * oldValue = entry->value;
+				entry->value = value;
+				return oldValue;
+			}
+		}
+		map->modificationCount++;
+		hashMap_addEntry(map, 0, NULL, value, 0);
+		return NULL;
+	}
+	hash = hashMap_hash(map->hashKey(key));
+	i = hashMap_indexFor(hash, map->tablelength);
+
+	hash_map_entry_pt entry;
+	for (entry = map->table[i]; entry != NULL; entry = entry->next) {
+		if (entry->hash == hash && (entry->key == key || map->equalsKey(key, entry->key))) {
+			void * oldValue = entry->value;
+			entry->value = value;
+			return oldValue;
+		}
+	}
+	map->modificationCount++;
+	hashMap_addEntry(map, hash, key, value, i);
+	return NULL;
+}
+
+void hashMap_resize(hash_map_pt map, int newCapacity) {
+	hash_map_entry_pt * newTable;
+	unsigned int j;
+	if (map->tablelength == MAXIMUM_CAPACITY) {
+		return;
+	}
+
+	newTable = (hash_map_entry_pt *) calloc(newCapacity, sizeof(hash_map_entry_pt));
+
+	for (j = 0; j < map->tablelength; j++) {
+		hash_map_entry_pt entry = map->table[j];
+		if (entry != NULL) {
+			map->table[j] = NULL;
+			do {
+				hash_map_entry_pt next = entry->next;
+				int i = hashMap_indexFor(entry->hash, newCapacity);
+				entry->next = newTable[i];
+				newTable[i] = entry;
+				entry = next;
+			} while (entry != NULL);
+		}
+	}
+	free(map->table);
+	map->table = newTable;
+	map->tablelength = newCapacity;
+	map->treshold = (unsigned int) ceil(newCapacity * DEFAULT_LOAD_FACTOR);
+}
+
+void * hashMap_remove(hash_map_pt map, const void* key) {
+	hash_map_entry_pt entry = hashMap_removeEntryForKey(map, key);
+	void * value = (entry == NULL ? NULL : entry->value);
+	if (entry != NULL) {
+		entry->key = NULL;
+		entry->value = NULL;
+		free(entry);
+	}
+	return value;
+}
+
+hash_map_entry_pt hashMap_removeEntryForKey(hash_map_pt map, const void* key) {
+	unsigned int hash = (key == NULL) ? 0 : hashMap_hash(map->hashKey(key));
+	int i = hashMap_indexFor(hash, map->tablelength);
+	hash_map_entry_pt prev = map->table[i];
+	hash_map_entry_pt entry = prev;
+
+	while (entry != NULL) {
+		hash_map_entry_pt next = entry->next;
+		if (entry->hash == hash && (entry->key == key || (key != NULL && map->equalsKey(key, entry->key)))) {
+			map->modificationCount++;
+			map->size--;
+			if (prev == entry) {
+				map->table[i] = next;
+			} else {
+				prev->next = next;
+			}
+			return entry;
+		}
+		prev = entry;
+		entry = next;
+	}
+
+	return entry;
+}
+
+hash_map_entry_pt hashMap_removeMapping(hash_map_pt map, hash_map_entry_pt entry) {
+	unsigned int hash;
+	hash_map_entry_pt prev;
+	hash_map_entry_pt e;
+	int i;
+	if (entry == NULL) {
+		return NULL;
+	}
+	hash = (entry->key == NULL) ? 0 : hashMap_hash(map->hashKey(entry->key));
+	i = hashMap_indexFor(hash, map->tablelength);
+	prev = map->table[i];
+	e = prev;
+
+	while (e != NULL) {
+		hash_map_entry_pt next = e->next;
+		if (e->hash == hash && hashMap_entryEquals(map, e, entry)) {
+			map->modificationCount++;
+			map->size--;
+			if (prev == e) {
+				map->table[i] = next;
+			} else {
+				prev->next = next;
+			}
+			return e;
+		}
+		prev = e;
+		e = next;
+	}
+
+	return e;
+}
+
+void hashMap_clear(hash_map_pt map, bool freeKey, bool freeValue) {
+	unsigned int i;
+	hash_map_entry_pt * table;
+	map->modificationCount++;
+	table = map->table;
+
+	for (i = 0; i < map->tablelength; i++) {
+		hash_map_entry_pt entry = table[i];
+		while (entry != NULL) {
+			hash_map_entry_pt f = entry;
+			entry = entry->next;
+			if (freeKey && f->key != NULL)
+				free(f->key);
+			if (freeValue && f->value != NULL)
+				free(f->value);
+			free(f);
+		}
+		table[i] = NULL;
+	}
+	map->size = 0;
+}
+
+bool hashMap_containsValue(hash_map_pt map, const void* value) {
+	unsigned int i;
+	if (value == NULL) {
+		for (i = 0; i < map->tablelength; i++) {
+			hash_map_entry_pt entry;
+			for (entry = map->table[i]; entry != NULL; entry = entry->next) {
+				if (entry->value == NULL) {
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+	for (i = 0; i < map->tablelength; i++) {
+		hash_map_entry_pt entry;
+		for (entry = map->table[i]; entry != NULL; entry = entry->next) {
+			if (entry->value == value || map->equalsValue(entry->value, value)) {
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+void hashMap_addEntry(hash_map_pt map, int hash, void* key, void* value, int bucketIndex) {
+	hash_map_entry_pt entry = map->table[bucketIndex];
+	hash_map_entry_pt new = (hash_map_entry_pt) malloc(sizeof(*new));
+	new->hash = hash;
+	new->key = key;
+	new->value = value;
+	new->next = entry;
+	map->table[bucketIndex] = new;
+	if (map->size++ >= map->treshold) {
+		hashMap_resize(map, 2 * map->tablelength);
+	}
+}
+
+hash_map_iterator_pt hashMapIterator_alloc(void) {
+    return calloc(1, sizeof(hash_map_iterator_t));
+}
+
+void hashMapIterator_dealloc(hash_map_iterator_pt iterator) {
+    free(iterator);
+}
+
+hash_map_iterator_pt hashMapIterator_create(hash_map_pt map) {
+	hash_map_iterator_pt iterator = hashMapIterator_alloc();
+    hashMapIterator_init(map, iterator);
+    return iterator;
+}
+
+UTILS_EXPORT hash_map_iterator_t hashMapIterator_construct(hash_map_pt map) {
+    hash_map_iterator_t iter;
+    memset(&iter, 0, sizeof(iter));
+    hashMapIterator_init(map, &iter);
+    return iter;
+}
+
+void hashMapIterator_init(hash_map_pt map, hash_map_iterator_pt iterator) {
+	iterator->map = map;
+	iterator->expectedModCount = map->modificationCount;
+	iterator->index = 0;
+	iterator->next = NULL;
+	iterator->current = NULL;
+	if (map->size > 0) {
+		while (iterator->index < map->tablelength && (iterator->next = map->table[iterator->index++]) == NULL) {
+		}
+	}
+}
+
+void hashMapIterator_deinit(hash_map_iterator_pt iterator) {
+    iterator->current = NULL;
+    iterator->expectedModCount = 0;
+    iterator->index = 0;
+    iterator->map = NULL;
+    iterator->next = NULL;
+}
+
+void hashMapIterator_destroy(hash_map_iterator_pt iterator) {
+	hashMapIterator_deinit(iterator);
+    hashMapIterator_dealloc(iterator);
+}
+
+bool hashMapIterator_hasNext(hash_map_iterator_pt iterator) {
+	return iterator->next != NULL;
+}
+
+void hashMapIterator_remove(hash_map_iterator_pt iterator) {
+	void * key;
+	hash_map_entry_pt entry;
+	if (iterator->current == NULL) {
+		return;
+	}
+	if (iterator->expectedModCount != iterator->map->modificationCount) {
+		return;
+	}
+	key = iterator->current->key;
+	iterator->current = NULL;
+	entry = hashMap_removeEntryForKey(iterator->map, key);
+	free(entry);
+	iterator->expectedModCount = iterator->map->modificationCount;
+}
+
+void * hashMapIterator_nextValue(hash_map_iterator_pt iterator) {
+	hash_map_entry_pt entry;
+	if (iterator->expectedModCount != iterator->map->modificationCount) {
+		return NULL;
+	}
+	entry = iterator->next;
+	if (entry == NULL) {
+		return NULL;
+	}
+	if ((iterator->next = entry->next) == NULL) {
+		while (iterator->index < iterator->map->tablelength && (iterator->next = iterator->map->table[iterator->index++]) == NULL) {
+		}
+	}
+	iterator->current = entry;
+	return entry->value;
+}
+
+void * hashMapIterator_nextKey(hash_map_iterator_pt iterator) {
+	hash_map_entry_pt entry;
+	if (iterator->expectedModCount != iterator->map->modificationCount) {
+		return NULL;
+	}
+	entry = iterator->next;
+	if (entry == NULL) {
+		return NULL;
+	}
+	if ((iterator->next = entry->next) == NULL) {
+		while (iterator->index < iterator->map->tablelength && (iterator->next = iterator->map->table[iterator->index++]) == NULL) {
+		}
+	}
+	iterator->current = entry;
+	return entry->key;
+}
+
+hash_map_entry_pt hashMapIterator_nextEntry(hash_map_iterator_pt iterator) {
+	hash_map_entry_pt entry;
+	if (iterator->expectedModCount != iterator->map->modificationCount) {
+		return NULL;
+	}
+	entry = iterator->next;
+	if (entry == NULL) {
+		return NULL;
+	}
+	if ((iterator->next = entry->next) == NULL) {
+		while (iterator->index < iterator->map->tablelength && (iterator->next = iterator->map->table[iterator->index++]) == NULL) {
+		}
+	}
+	iterator->current = entry;
+	return entry;
+}
+
+hash_map_key_set_pt hashMapKeySet_create(hash_map_pt map) {
+	hash_map_key_set_pt keySet = (hash_map_key_set_pt) malloc(sizeof(*keySet));
+	keySet->map = map;
+
+	return keySet;
+}
+
+void hashMapKeySet_destroy(hash_map_key_set_pt keySet){
+	keySet->map = NULL;
+	free(keySet);
+}
+
+int hashMapKeySet_size(hash_map_key_set_pt keySet) {
+	return keySet->map->size;
+}
+
+bool hashMapKeySet_contains(hash_map_key_set_pt keySet, const void* key) {
+	return hashMap_containsKey(keySet->map, key);
+}
+
+bool hashMapKeySet_remove(hash_map_key_set_pt keySet, const void* key) {
+	hash_map_entry_pt entry = hashMap_removeEntryForKey(keySet->map, key);
+	bool removed = entry != NULL;
+	free(entry);
+	return removed;
+}
+
+void hashMapKeySet_clear(hash_map_key_set_pt keySet) {
+	hashMap_clear(keySet->map, false, false);
+}
+
+bool hashMapKeySet_isEmpty(hash_map_key_set_pt keySet) {
+	return hashMapKeySet_size(keySet) == 0;
+}
+
+hash_map_values_pt hashMapValues_create(hash_map_pt map) {
+	hash_map_values_pt values = (hash_map_values_pt) malloc(sizeof(*values));
+	values->map = map;
+
+	return values;
+}
+
+void hashMapValues_destroy(hash_map_values_pt values) {
+	values->map = NULL;
+	free(values);
+}
+
+hash_map_iterator_pt hashMapValues_iterator(hash_map_values_pt values) {
+	return hashMapIterator_create(values->map);
+}
+
+int hashMapValues_size(hash_map_values_pt values) {
+	return values->map->size;
+}
+
+bool hashMapValues_contains(hash_map_values_pt values, const void* value) {
+	return hashMap_containsValue(values->map, value);
+}
+
+void hashMapValues_toArray(hash_map_values_pt values, void* *array[], unsigned int *size) {
+	hash_map_iterator_pt it;
+	int i = 0;
+	int vsize = hashMapValues_size(values);
+	*size = vsize;
+	*array = malloc(vsize * sizeof(**array));
+	it = hashMapValues_iterator(values);
+	while(hashMapIterator_hasNext(it) && i<vsize){
+		(*array)[i++] = hashMapIterator_nextValue(it);
+	}
+	hashMapIterator_destroy(it);
+}
+
+bool hashMapValues_remove(hash_map_values_pt values, const void* value) {
+	hash_map_iterator_pt iterator = hashMapValues_iterator(values);
+	if (value == NULL) {
+		while (hashMapIterator_hasNext(iterator)) {
+			if (hashMapIterator_nextValue(iterator) == NULL) {
+				hashMapIterator_remove(iterator);
+				hashMapIterator_destroy(iterator);
+				return true;
+			}
+		}
+	} else {
+		while (hashMapIterator_hasNext(iterator)) {
+			if (values->map->equalsValue(value, hashMapIterator_nextValue(iterator))) {
+				hashMapIterator_remove(iterator);
+				hashMapIterator_destroy(iterator);
+				return true;
+			}
+		}
+	}
+	hashMapIterator_destroy(iterator);
+	return false;
+}
+
+void hashMapValues_clear(hash_map_values_pt values) {
+	hashMap_clear(values->map, false, false);
+}
+
+bool hashMapValues_isEmpty(hash_map_values_pt values) {
+	return hashMapValues_size(values) == 0;
+}
+
+hash_map_entry_set_pt hashMapEntrySet_create(hash_map_pt map) {
+	hash_map_entry_set_pt entrySet = (hash_map_entry_set_pt) malloc(sizeof(*entrySet));
+	entrySet->map = map;
+
+	return entrySet;
+}
+
+void hashMapEntrySet_destroy(hash_map_entry_set_pt entrySet){
+	entrySet->map = NULL;
+	free(entrySet);
+}
+
+int hashMapEntrySet_size(hash_map_entry_set_pt entrySet) {
+	return entrySet->map->size;
+}
+
+bool hashMapEntrySet_contains(hash_map_entry_set_pt entrySet, hash_map_entry_pt entry) {
+	return hashMap_containsValue(entrySet->map, entry);
+}
+
+bool hashMapEntrySet_remove(hash_map_entry_set_pt entrySet, hash_map_entry_pt entry) {
+	hash_map_entry_pt temp = hashMap_removeMapping(entrySet->map, entry);
+	if (temp != NULL) {
+		free(temp);
+		return true;
+	} else {
+		return false;
+	}
+}
+
+void hashMapEntrySet_clear(hash_map_entry_set_pt entrySet) {
+	hashMap_clear(entrySet->map, false, false);
+}
+
+bool hashMapEntrySet_isEmpty(hash_map_entry_set_pt entrySet) {
+	return hashMapEntrySet_size(entrySet) == 0;
+}
+
+void * hashMapEntry_getKey(hash_map_entry_pt entry) {
+	return entry->key;
+}
+
+void * hashMapEntry_getValue(hash_map_entry_pt entry) {
+	return entry->value;
+}
+
+
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/hash_map_private.h
----------------------------------------------------------------------
diff --git a/utils/src/hash_map_private.h b/utils/src/hash_map_private.h
new file mode 100644
index 0000000..cddf7a1
--- /dev/null
+++ b/utils/src/hash_map_private.h
@@ -0,0 +1,74 @@
+/**
+ *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.
+ */
+/*
+ * hash_map_private.h
+ *
+ *  \date       Jul 21, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef HASH_MAP_PRIVATE_H_
+#define HASH_MAP_PRIVATE_H_
+
+#include "exports.h"
+#include "hash_map.h"
+
+UTILS_EXPORT unsigned int hashMap_hashCode(const void* toHash);
+UTILS_EXPORT int hashMap_equals(const void* toCompare, const void* compare);
+
+void hashMap_resize(hash_map_pt map, int newCapacity);
+hash_map_entry_pt hashMap_removeEntryForKey(hash_map_pt map, const void* key);
+UTILS_EXPORT hash_map_entry_pt hashMap_removeMapping(hash_map_pt map, hash_map_entry_pt entry);
+void hashMap_addEntry(hash_map_pt map, int hash, void* key, void* value, int bucketIndex);
+
+struct hashMapEntry {
+	void* key;
+	void* value;
+	hash_map_entry_pt next;
+	unsigned int hash;
+};
+
+struct hashMap {
+	hash_map_entry_pt * table;
+	unsigned int size;
+	unsigned int treshold;
+	unsigned int modificationCount;
+	unsigned int tablelength;
+
+	unsigned int (*hashKey)(const void* key);
+	unsigned int (*hashValue)(const void* value);
+	int (*equalsKey)(const void* key1, const void* key2);
+	int (*equalsValue)(const void* value1, const void* value2);
+};
+
+struct hashMapKeySet {
+	hash_map_pt map;
+};
+
+struct hashMapValues {
+	hash_map_pt map;
+};
+
+struct hashMapEntrySet {
+	hash_map_pt map;
+};
+
+
+#endif /* HASH_MAP_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/src/linked_list.c
----------------------------------------------------------------------
diff --git a/utils/src/linked_list.c b/utils/src/linked_list.c
new file mode 100644
index 0000000..235c3e7
--- /dev/null
+++ b/utils/src/linked_list.c
@@ -0,0 +1,268 @@
+/**
+ *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.
+ */
+/*
+ * linked_list.c
+ *
+ *  \date       Jul 16, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include "celixbool.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "linked_list.h"
+#include "linked_list_private.h"
+
+celix_status_t linkedList_create(linked_list_pt *list) {
+	linked_list_pt linked_list = malloc(sizeof(*linked_list));
+	if (linked_list) {
+        linked_list->header = (linked_list_entry_pt) malloc(sizeof(*(linked_list->header)));
+        if (linked_list->header) {
+            linked_list->header->element = NULL;
+            linked_list->header->next = linked_list->header;
+            linked_list->header->previous = linked_list->header;
+            linked_list->size = 0;
+            linked_list->modificationCount = 0;
+
+            *list = linked_list;
+
+            return CELIX_SUCCESS;
+        }
+	}
+
+	return CELIX_ENOMEM;
+}
+
+UTILS_EXPORT celix_status_t linkedList_destroy(linked_list_pt list) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	linked_list_entry_pt current = NULL;
+	linked_list_entry_pt next = NULL;
+
+	current = list->header->next;
+
+	while (current != list->header) {
+		next = current->next;
+		free(current);
+		current = next;
+	}
+
+	free(list->header);
+	free(list);
+
+	return status;
+}
+
+celix_status_t linkedList_clone(linked_list_pt list, linked_list_pt *clone) {
+	celix_status_t status;
+
+	status = linkedList_create(clone);
+	if (status == CELIX_SUCCESS) {
+		struct linked_list_entry *e;
+        for (e = list->header->next; e != list->header; e = e->next) {
+            linkedList_addElement(*clone, e->element);
+        }
+	}
+
+	return status;
+}
+
+void * linkedList_getFirst(linked_list_pt list) {
+	if (list->size == 0) {
+		return NULL;
+	}
+	return list->header->next->element;
+}
+
+void * linkedList_getLast(linked_list_pt list) {
+	if (list->size == 0) {
+		return NULL;
+	}
+	return list->header->previous->element;
+}
+
+void * linkedList_removeFirst(linked_list_pt list) {
+	return linkedList_removeEntry(list, list->header->next);
+}
+
+void * linkedList_removeLast(linked_list_pt list) {
+	return linkedList_removeEntry(list, list->header->previous);
+}
+
+void linkedList_addFirst(linked_list_pt list, void * element) {
+	linkedList_addBefore(list, element, list->header->next);
+}
+
+void linkedList_addLast(linked_list_pt list, void * element) {
+	linkedList_addBefore(list, element, list->header);
+}
+
+bool linkedList_contains(linked_list_pt list, void * element) {
+	return linkedList_indexOf(list, element) != -1;
+}
+
+int linkedList_size(linked_list_pt list) {
+	return list->size;
+}
+
+bool linkedList_isEmpty(linked_list_pt list) {
+	return linkedList_size(list) == 0;
+}
+
+bool linkedList_addElement(linked_list_pt list, void * element) {
+	linkedList_addBefore(list, element, list->header);
+	return true;
+}
+
+bool linkedList_removeElement(linked_list_pt list, void * element) {
+	if (element == NULL) {
+		linked_list_entry_pt entry;
+		for (entry = list->header->next; entry != list->header; entry = entry->next) {
+			if (entry->element == NULL) {
+				linkedList_removeEntry(list, entry);
+				return true;
+			}
+		}
+	} else {
+		linked_list_entry_pt entry;
+		for (entry = list->header->next; entry != list->header; entry = entry->next) {
+			if (element == entry->element) {
+				linkedList_removeEntry(list, entry);
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+void linkedList_clear(linked_list_pt list) {
+	linked_list_entry_pt entry = list->header->next;
+	while (entry != list->header) {
+		linked_list_entry_pt next = entry->next;
+		entry->next = entry->previous = NULL;
+		// free(entry->element);
+		entry->element = NULL;
+		free(entry);
+		entry = next;
+	}
+	list->header->next = list->header->previous = list->header;
+	list->size = 0;
+	list->modificationCount++;
+}
+
+void * linkedList_get(linked_list_pt list, int index) {
+	return linkedList_entry(list, index)->element;
+}
+void * linkedList_set(linked_list_pt list, int index, void * element) {
+	linked_list_entry_pt entry = linkedList_entry(list, index);
+	void * old = entry->element;
+	entry->element = element;
+	return old;
+}
+
+void linkedList_addIndex(linked_list_pt list, int index, void * element) {
+	linkedList_addBefore(list, element, (index == list->size ? list->header : linkedList_entry(list, index)));
+}
+
+void * linkedList_removeIndex(linked_list_pt list, int index) {
+	return linkedList_removeEntry(list, linkedList_entry(list, index));
+}
+
+linked_list_entry_pt linkedList_entry(linked_list_pt list, int index) {
+	linked_list_entry_pt entry;
+	int i;
+	if (index < 0 || index >= list->size) {
+		return NULL;
+	}
+
+	entry = list->header;
+	if (index < (list->size >> 1)) {
+		for (i = 0; i <= index; i++) {
+			entry = entry->next;
+		}
+	} else {
+		for (i = list->size; i > index; i--) {
+			entry = entry->previous;
+		}
+	}
+	return entry;
+}
+
+int linkedList_indexOf(linked_list_pt list, void * element) {
+	int index = 0;
+	if (element == NULL) {
+		linked_list_entry_pt entry;
+		for (entry = list->header->next; entry != list->header; entry = entry->next) {
+			if (entry->element == NULL) {
+				return index;
+			}
+			index++;
+		}
+	} else {
+		linked_list_entry_pt entry;
+		for (entry = list->header->next; entry != list->header; entry = entry->next) {
+			if (element == entry->element) {
+				return index;
+			}
+			index++;
+		}
+	}
+	return -1;
+}
+
+linked_list_entry_pt linkedList_addBefore(linked_list_pt list, void * element, linked_list_entry_pt entry) {
+    linked_list_entry_pt new = NULL;
+
+    new = malloc(sizeof(*new));
+    if (new != NULL) {
+
+        new->element = element;
+        new->next = entry;
+        new->previous = entry->previous;
+
+        new->previous->next = new;
+        new->next->previous = new;
+
+        list->size++;
+        list->modificationCount++;
+    }
+
+	return new;
+}
+
+void * linkedList_removeEntry(linked_list_pt list, linked_list_entry_pt entry) {
+    void * result;
+	if (entry == list->header) {
+		return NULL;
+	}
+
+	result = entry->element;
+
+	entry->previous->next = entry->next;
+	entry->next->previous = entry->previous;
+
+	entry->next = entry->previous = NULL;
+	free(entry);
+
+	list->size--;
+	list->modificationCount++;
+
+	return result;
+}


[46/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
CELIX-417: Initial refactoring for CMake usage


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

Branch: refs/heads/feature/CELIX-417-cmake-refactor
Commit: a1c308879bb4f2834334f120ca6d5d6dabecc4d4
Parents: 78e435b
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Mon Nov 20 21:40:38 2017 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Mon Nov 20 21:40:38 2017 +0100

----------------------------------------------------------------------
 CMakeLists.txt                                  |   31 +-
 cmake/CMakeCelix-local.cmake                    |   31 +
 cmake/CMakeCelix.cmake                          |   32 -
 cmake/FindCELIX.cmake                           |   44 +-
 cmake/cmake_celix/BundlePackaging.cmake         |   53 +-
 cmake/cmake_celix/DeployPackaging.cmake         |   43 +-
 cmake/cmake_celix/UseCelix.cmake                |   22 +
 config_admin/CMakeLists.txt                     |    7 +-
 config_admin/config_admin_tst/CMakeLists.txt    |    2 +-
 .../example_test/CMakeLists.txt                 |    2 +-
 .../example_test2/CMakeLists.txt                |    2 +-
 config_admin/example/CMakeLists.txt             |    2 -
 config_admin/service/CMakeLists.txt             |    3 -
 dependency_manager/CMakeLists.txt               |   96 +-
 dependency_manager/api/dm_activator.h           |   65 +
 dependency_manager/api/dm_component.h           |  158 ++
 dependency_manager/api/dm_dependency_manager.h  |   79 +
 dependency_manager/api/dm_info.h                |   81 +
 dependency_manager/api/dm_service_dependency.h  |  171 ++
 .../private/include/dm_component_impl.h         |   48 -
 .../private/include/dm_dependency.h             |   41 -
 .../include/dm_dependency_manager_impl.h        |   45 -
 dependency_manager/private/include/dm_event.h   |   72 -
 .../include/dm_service_dependency_impl.h        |  104 -
 .../private/include/dm_shell_list_command.h     |   42 -
 dependency_manager/private/src/dm_activator.c   |  119 -
 .../private/src/dm_component_impl.c             | 1442 ----------
 .../private/src/dm_dependency_manager_impl.c    |  129 -
 dependency_manager/private/src/dm_event.c       |  105 -
 .../private/src/dm_service_dependency.c         |  811 ------
 .../private/src/dm_shell_activator.c            |   94 -
 .../private/src/dm_shell_list_command.c         |  126 -
 .../public/include/dm_activator.h               |   65 -
 .../public/include/dm_component.h               |  158 --
 .../public/include/dm_dependency_manager.h      |   79 -
 dependency_manager/public/include/dm_info.h     |   81 -
 .../public/include/dm_service_dependency.h      |  171 --
 dependency_manager/readme.md                    |   18 +-
 dependency_manager/src/dm_activator.c           |  119 +
 dependency_manager/src/dm_component_impl.c      | 1442 ++++++++++
 dependency_manager/src/dm_component_impl.h      |   48 +
 dependency_manager/src/dm_dependency.h          |   41 +
 .../src/dm_dependency_manager_impl.c            |  129 +
 .../src/dm_dependency_manager_impl.h            |   45 +
 dependency_manager/src/dm_event.c               |  105 +
 dependency_manager/src/dm_event.h               |   72 +
 dependency_manager/src/dm_service_dependency.c  |  811 ++++++
 .../src/dm_service_dependency_impl.h            |  104 +
 dependency_manager/src/dm_shell_activator.c     |   94 +
 dependency_manager/src/dm_shell_list_command.c  |  126 +
 dependency_manager/src/dm_shell_list_command.h  |   42 +
 dependency_manager_cxx/CMakeLists.txt           |   32 +-
 dependency_manager_cxx/readme.md                |    6 +
 deployment_admin/CMakeLists.txt                 |   59 +-
 deployment_admin/README.md                      |   20 +-
 deployment_admin/api/resource_processor.h       |   54 +
 .../private/include/deployment_admin.h          |   57 -
 .../private/include/deployment_package.h        |   76 -
 deployment_admin/private/include/ioapi.h        |  200 --
 deployment_admin/private/include/log.h          |   44 -
 deployment_admin/private/include/log_event.h    |   43 -
 deployment_admin/private/include/log_store.h    |   45 -
 deployment_admin/private/include/log_sync.h     |   36 -
 deployment_admin/private/include/miniunz.h      |   34 -
 deployment_admin/private/include/unzip.h        |  437 ---
 deployment_admin/private/src/deployment_admin.c |  809 ------
 .../private/src/deployment_admin_activator.c    |   78 -
 .../private/src/deployment_package.c            |  219 --
 deployment_admin/private/src/ioapi.c            |  235 --
 deployment_admin/private/src/log.c              |   73 -
 deployment_admin/private/src/log_store.c        |   94 -
 deployment_admin/private/src/log_sync.c         |  209 --
 deployment_admin/private/src/miniunz.c          |  402 ---
 deployment_admin/private/src/unzip.c            | 2128 --------------
 .../public/include/resource_processor.h         |   54 -
 deployment_admin/src/deployment_admin.c         |  809 ++++++
 deployment_admin/src/deployment_admin.h         |   57 +
 .../src/deployment_admin_activator.c            |   78 +
 deployment_admin/src/deployment_package.c       |  219 ++
 deployment_admin/src/deployment_package.h       |   76 +
 deployment_admin/src/ioapi.c                    |  235 ++
 deployment_admin/src/ioapi.h                    |  200 ++
 deployment_admin/src/log.c                      |   73 +
 deployment_admin/src/log.h                      |   44 +
 deployment_admin/src/log_event.h                |   43 +
 deployment_admin/src/log_store.c                |   94 +
 deployment_admin/src/log_store.h                |   45 +
 deployment_admin/src/log_sync.c                 |  209 ++
 deployment_admin/src/log_sync.h                 |   36 +
 deployment_admin/src/miniunz.c                  |  402 +++
 deployment_admin/src/miniunz.h                  |   34 +
 deployment_admin/src/unzip.c                    | 2128 ++++++++++++++
 deployment_admin/src/unzip.h                    |  437 +++
 device_access/README.md                         |   11 +-
 device_access/device_access/CMakeLists.txt      |   42 +-
 device_access/device_access/include/device.h    |   47 +
 device_access/device_access/include/driver.h    |   45 +
 .../device_access/include/driver_locator.h      |   46 +
 .../device_access/include/driver_selector.h     |   41 +
 device_access/device_access/include/match.h     |   38 +
 .../private/include/device_manager.h            |   56 -
 .../private/include/driver_attributes.h         |   46 -
 .../private/include/driver_loader.h             |   48 -
 .../private/include/driver_matcher.h            |   42 -
 .../device_access/private/src/activator.c       |  194 --
 .../device_access/private/src/device_manager.c  |  570 ----
 .../private/src/driver_attributes.c             |  169 --
 .../device_access/private/src/driver_loader.c   |  185 --
 .../device_access/private/src/driver_matcher.c  |  274 --
 .../device_access/public/include/device.h       |   47 -
 .../device_access/public/include/driver.h       |   45 -
 .../public/include/driver_locator.h             |   46 -
 .../public/include/driver_selector.h            |   41 -
 .../device_access/public/include/match.h        |   38 -
 device_access/device_access/src/activator.c     |  194 ++
 .../device_access/src/device_manager.c          |  570 ++++
 .../device_access/src/device_manager.h          |   56 +
 .../device_access/src/driver_attributes.c       |  169 ++
 .../device_access/src/driver_attributes.h       |   46 +
 device_access/device_access/src/driver_loader.c |  185 ++
 device_access/device_access/src/driver_loader.h |   48 +
 .../device_access/src/driver_matcher.c          |  274 ++
 .../device_access/src/driver_matcher.h          |   42 +
 device_access/driver_locator/CMakeLists.txt     |   14 +-
 .../private/include/driver_locator_private.h    |   39 -
 .../driver_locator/private/src/activator.c      |   89 -
 .../driver_locator/private/src/driver_locator.c |   91 -
 device_access/driver_locator/src/activator.c    |   89 +
 .../driver_locator/src/driver_locator.c         |   91 +
 .../driver_locator/src/driver_locator_private.h |   39 +
 device_access/example/CMakeLists.txt            |    2 +-
 .../example/base_driver/CMakeLists.txt          |   15 +-
 .../base_driver/include/base_driver_device.h    |   44 +
 .../private/include/base_driver_private.h       |   41 -
 .../example/base_driver/private/src/activator.c |  140 -
 .../base_driver/private/src/base_driver.c       |  111 -
 .../public/include/base_driver_device.h         |   44 -
 .../example/base_driver/src/activator.c         |  140 +
 .../example/base_driver/src/base_driver.c       |  111 +
 .../base_driver/src/base_driver_private.h       |   41 +
 .../example/consuming_driver/CMakeLists.txt     |   12 +-
 .../private/include/consuming_driver_private.h  |   43 -
 .../consuming_driver/private/src/activator.c    |  104 -
 .../private/src/consuming_driver.c              |  125 -
 .../example/consuming_driver/src/activator.c    |  104 +
 .../consuming_driver/src/consuming_driver.c     |  125 +
 .../src/consuming_driver_private.h              |   43 +
 .../example/refining_driver/CMakeLists.txt      |   15 +-
 .../include/refining_driver_device.h            |   45 +
 .../private/include/refining_driver_private.h   |   58 -
 .../refining_driver/private/src/activator.c     |  104 -
 .../private/src/refining_driver.c               |  281 --
 .../public/include/refining_driver_device.h     |   45 -
 .../example/refining_driver/src/activator.c     |  104 +
 .../refining_driver/src/refining_driver.c       |  281 ++
 .../src/refining_driver_private.h               |   58 +
 dfi/CMakeLists.txt                              |   88 +-
 dfi/include/dfi_log_util.h                      |   63 +
 dfi/include/dyn_common.h                        |   47 +
 dfi/include/dyn_function.h                      |   60 +
 dfi/include/dyn_interface.h                     |   66 +
 dfi/include/dyn_message.h                       |   56 +
 dfi/include/dyn_type.h                          |  155 ++
 dfi/include/json_rpc.h                          |   37 +
 dfi/include/json_serializer.h                   |   37 +
 dfi/private/src/dyn_common.c                    |  151 -
 dfi/private/src/dyn_function.c                  |  331 ---
 dfi/private/src/dyn_interface.c                 |  444 ---
 dfi/private/src/dyn_message.c                   |  358 ---
 dfi/private/src/dyn_type.c                      | 1160 --------
 dfi/private/src/json_rpc.c                      |  341 ---
 dfi/private/src/json_serializer.c               |  484 ----
 .../test/avro_descriptor_translator_tests.cpp   |  180 --
 .../test/descriptors/example1.descriptor        |   13 -
 .../test/descriptors/example2.descriptor        |    9 -
 .../test/descriptors/example3.descriptor        |   11 -
 .../test/descriptors/example4.descriptor        |    8 -
 .../descriptors/invalids/invalid.descriptor     |   13 -
 .../invalids/invalidMetaType.descriptor         |    8 -
 .../invalids/invalidMethod.descriptor           |    8 -
 .../invalids/invalidMethodReturnType.descriptor |    8 -
 .../invalids/invalidMsgHdr.descriptor           |    9 -
 .../invalids/invalidMsgInvalidName.descriptor   |    9 -
 .../invalidMsgInvalidSection.descriptor         |   10 -
 .../invalids/invalidMsgInvalidType.descriptor   |    9 -
 .../invalidMsgInvalidVersion.descriptor         |   10 -
 .../invalidMsgMissingVersion.descriptor         |   10 -
 .../invalids/invalidSection.descriptor          |    6 -
 .../descriptors/invalids/invalidType.descriptor |   10 -
 .../invalids/invalidVersion.descriptor          |    9 -
 .../descriptors/invalids/noVersion.descriptor   |   12 -
 .../test/descriptors/msg_example1.descriptor    |   10 -
 .../test/descriptors/msg_example2.descriptor    |   12 -
 .../test/descriptors/msg_example3.descriptor    |   10 -
 .../test/descriptors/msg_example4.descriptor    |   10 -
 dfi/private/test/dyn_closure_tests.cpp          |  162 --
 dfi/private/test/dyn_function_tests.cpp         |  274 --
 dfi/private/test/dyn_interface_tests.cpp        |  207 --
 dfi/private/test/dyn_message_tests.cpp          |  253 --
 dfi/private/test/dyn_type_tests.cpp             |  297 --
 dfi/private/test/json_rpc_tests.cpp             |  433 ---
 dfi/private/test/json_serializer_tests.cpp      |  558 ----
 dfi/private/test/run_tests.cpp                  |   24 -
 dfi/private/test/schemas/complex.avdl           |   30 -
 dfi/private/test/schemas/complex.avpr           |   55 -
 dfi/private/test/schemas/invalid1.avpr          |   47 -
 dfi/private/test/schemas/invalid2.avpr          |   49 -
 dfi/private/test/schemas/simple.avdl            |   24 -
 dfi/private/test/schemas/simple.avpr            |   51 -
 dfi/private/test/schemas/simple_min.avpr        |   19 -
 dfi/public/include/dfi_log_util.h               |   63 -
 dfi/public/include/dyn_common.h                 |   47 -
 dfi/public/include/dyn_function.h               |   60 -
 dfi/public/include/dyn_interface.h              |   66 -
 dfi/public/include/dyn_message.h                |   56 -
 dfi/public/include/dyn_type.h                   |  155 --
 dfi/public/include/json_rpc.h                   |   37 -
 dfi/public/include/json_serializer.h            |   37 -
 dfi/src/dyn_common.c                            |  151 +
 dfi/src/dyn_function.c                          |  331 +++
 dfi/src/dyn_interface.c                         |  444 +++
 dfi/src/dyn_message.c                           |  358 +++
 dfi/src/dyn_type.c                              | 1160 ++++++++
 dfi/src/json_rpc.c                              |  341 +++
 dfi/src/json_serializer.c                       |  484 ++++
 dfi/test/avro_descriptor_translator_tests.cpp   |  180 ++
 dfi/test/descriptors/example1.descriptor        |   13 +
 dfi/test/descriptors/example2.descriptor        |    9 +
 dfi/test/descriptors/example3.descriptor        |   11 +
 dfi/test/descriptors/example4.descriptor        |    8 +
 .../descriptors/invalids/invalid.descriptor     |   13 +
 .../invalids/invalidMetaType.descriptor         |    8 +
 .../invalids/invalidMethod.descriptor           |    8 +
 .../invalids/invalidMethodReturnType.descriptor |    8 +
 .../invalids/invalidMsgHdr.descriptor           |    9 +
 .../invalids/invalidMsgInvalidName.descriptor   |    9 +
 .../invalidMsgInvalidSection.descriptor         |   10 +
 .../invalids/invalidMsgInvalidType.descriptor   |    9 +
 .../invalidMsgInvalidVersion.descriptor         |   10 +
 .../invalidMsgMissingVersion.descriptor         |   10 +
 .../invalids/invalidSection.descriptor          |    6 +
 .../descriptors/invalids/invalidType.descriptor |   10 +
 .../invalids/invalidVersion.descriptor          |    9 +
 .../descriptors/invalids/noVersion.descriptor   |   12 +
 dfi/test/descriptors/msg_example1.descriptor    |   10 +
 dfi/test/descriptors/msg_example2.descriptor    |   12 +
 dfi/test/descriptors/msg_example3.descriptor    |   10 +
 dfi/test/descriptors/msg_example4.descriptor    |   10 +
 dfi/test/dyn_closure_tests.cpp                  |  162 ++
 dfi/test/dyn_function_tests.cpp                 |  274 ++
 dfi/test/dyn_interface_tests.cpp                |  207 ++
 dfi/test/dyn_message_tests.cpp                  |  253 ++
 dfi/test/dyn_type_tests.cpp                     |  297 ++
 dfi/test/json_rpc_tests.cpp                     |  433 +++
 dfi/test/json_serializer_tests.cpp              |  558 ++++
 dfi/test/run_tests.cpp                          |   24 +
 dfi/test/schemas/complex.avdl                   |   30 +
 dfi/test/schemas/complex.avpr                   |   55 +
 dfi/test/schemas/invalid1.avpr                  |   47 +
 dfi/test/schemas/invalid2.avpr                  |   49 +
 dfi/test/schemas/simple.avdl                    |   24 +
 dfi/test/schemas/simple.avpr                    |   51 +
 dfi/test/schemas/simple_min.avpr                |   19 +
 doap/doap_Celix.rdf                             |    2 +-
 etcdlib/CMakeLists.txt                          |   30 +-
 etcdlib/api/etcd.h                              |  110 +
 etcdlib/private/src/etcd.c                      |  487 ----
 etcdlib/public/include/etcd.h                   |  110 -
 etcdlib/src/etcd.c                              |  487 ++++
 event_admin/event_admin/CMakeLists.txt          |    2 +-
 event_admin/event_handler/CMakeLists.txt        |    2 +-
 event_admin/event_publisher/CMakeLists.txt      |    2 +-
 examples/CMakeLists.txt                         |    1 -
 examples/dm_example/CMakeLists.txt              |    8 +-
 examples/dm_example/phase1/CMakeLists.txt       |    9 +-
 examples/dm_example/phase2a/CMakeLists.txt      |    6 +-
 examples/dm_example/phase2b/CMakeLists.txt      |    6 +-
 examples/dm_example/phase3/CMakeLists.txt       |    6 +-
 examples/dm_example_cxx/CMakeLists.txt          |    9 +-
 examples/dm_example_cxx/phase1/CMakeLists.txt   |    6 +-
 examples/dm_example_cxx/phase2a/CMakeLists.txt  |   19 +-
 examples/dm_example_cxx/phase2b/CMakeLists.txt  |   16 +-
 examples/dm_example_cxx/phase3/CMakeLists.txt   |    6 +-
 .../phase3_locking/CMakeLists.txt               |    6 +-
 examples/embedding/CMakeLists.txt               |    2 +-
 examples/hello_world/CMakeLists.txt             |    4 +-
 examples/hello_world_test/CMakeLists.txt        |   10 +-
 examples/log_service_example/CMakeLists.txt     |   15 +-
 .../log_service_example/private/src/activator.c |   85 -
 examples/log_service_example/src/activator.c    |   85 +
 examples/mongoose/CMakeLists.txt                |    4 +-
 examples/service_hook_example/CMakeLists.txt    |   27 +-
 .../private/src/activator.c                     |  137 -
 examples/service_hook_example/src/activator.c   |  137 +
 examples/services_example_c/CMakeLists.txt      |    4 +-
 examples/services_example_c/bar/CMakeLists.txt  |    6 +-
 examples/services_example_c/foo1/CMakeLists.txt |    6 +-
 examples/services_example_c/foo2/CMakeLists.txt |    6 +-
 examples/services_example_cxx/CMakeLists.txt    |    4 +-
 .../services_example_cxx/bar/CMakeLists.txt     |    6 +-
 .../services_example_cxx/baz/CMakeLists.txt     |    6 +-
 .../services_example_cxx/foo/CMakeLists.txt     |    6 +-
 examples/whiteboard/CMakeLists.txt              |   24 -
 examples/whiteboard/publisherA/CMakeLists.txt   |   23 -
 .../publisherA/private/src/activator.c          |   83 -
 .../publisherA/private/src/publisher.c          |   33 -
 examples/whiteboard/publisherB/CMakeLists.txt   |   22 -
 .../publisherB/private/src/activator.c          |   77 -
 .../publisherB/private/src/publisher.c          |   33 -
 .../private/include/publisher_private.h         |   38 -
 .../publisherService/public/include/publisher.h |   42 -
 examples/whiteboard/tracker/CMakeLists.txt      |   21 -
 .../whiteboard/tracker/private/src/activator.c  |  126 -
 .../whiteboard/tracker_depman/CMakeLists.txt    |   36 -
 .../tracker_depman/private/include/tracker.h    |   63 -
 .../private/src/dependency_activator.c          |  116 -
 .../tracker_depman/private/src/tracker.c        |  142 -
 framework/CMakeLists.txt                        |  628 ++---
 framework/include/archive.h                     |   58 +
 framework/include/bundle.h                      |  139 +
 framework/include/bundle_activator.h            |  126 +
 framework/include/bundle_archive.h              |   93 +
 framework/include/bundle_context.h              |  175 ++
 framework/include/bundle_event.h                |   63 +
 framework/include/bundle_listener.h             |   57 +
 framework/include/bundle_revision.h             |  142 +
 framework/include/bundle_state.h                |   49 +
 framework/include/capability.h                  |   54 +
 framework/include/celix_launcher.h              |   55 +
 framework/include/celix_log.h                   |   85 +
 framework/include/constants.h                   |   67 +
 framework/include/filter.h                      |   55 +
 framework/include/framework.h                   |   57 +
 framework/include/framework_event.h             |   71 +
 framework/include/framework_exports.h           |   65 +
 framework/include/framework_listener.h          |   55 +
 framework/include/listener_hook_service.h       |   60 +
 framework/include/manifest.h                    |   67 +
 framework/include/module.h                      |   94 +
 framework/include/requirement.h                 |   53 +
 framework/include/service_event.h               |   68 +
 framework/include/service_factory.h             |   60 +
 framework/include/service_listener.h            |   55 +
 framework/include/service_reference.h           |   72 +
 framework/include/service_registration.h        |   58 +
 framework/include/service_registry.h            |  103 +
 framework/include/service_tracker.h             |   72 +
 framework/include/service_tracker_customizer.h  |   78 +
 framework/include/wire.h                        |  120 +
 framework/private/include/attribute.h           |   39 -
 framework/private/include/attribute_private.h   |   39 -
 framework/private/include/bundle_cache.h        |  115 -
 .../private/include/bundle_cache_private.h      |   39 -
 .../private/include/bundle_context_private.h    |   43 -
 framework/private/include/bundle_private.h      |   48 -
 .../private/include/bundle_revision_private.h   |   42 -
 framework/private/include/capability_private.h  |   41 -
 framework/private/include/filter_private.h      |   57 -
 framework/private/include/framework_private.h   |  145 -
 framework/private/include/ioapi.h               |  200 --
 framework/private/include/iowin32.h             |   28 -
 .../private/include/listener_hook_info_impl.h   |   34 -
 framework/private/include/manifest_parser.h     |   45 -
 .../private/include/registry_callback_private.h |   42 -
 framework/private/include/requirement_private.h |   40 -
 framework/private/include/resolver.h            |   45 -
 .../private/include/service_reference_private.h |   69 -
 .../include/service_registration_private.h      |   71 -
 .../private/include/service_registry_private.h  |   67 -
 .../service_tracker_customizer_private.h        |   49 -
 .../private/include/service_tracker_private.h   |   52 -
 framework/private/include/unzip.h               |  437 ---
 framework/private/src/attribute.c               |   71 -
 framework/private/src/bundle.c                  |  695 -----
 framework/private/src/bundle_archive.c          |  792 ------
 framework/private/src/bundle_cache.c            |  218 --
 framework/private/src/bundle_context.c          |  384 ---
 framework/private/src/bundle_revision.c         |  153 -
 framework/private/src/capability.c              |  100 -
 framework/private/src/celix_errorcodes.c        |   64 -
 framework/private/src/celix_launcher.c          |  242 --
 framework/private/src/celix_log.c               |   83 -
 framework/private/src/filter.c                  |  687 -----
 framework/private/src/framework.c               | 2620 ------------------
 framework/private/src/ioapi.c                   |  235 --
 framework/private/src/iowin32.c                 |  389 ---
 framework/private/src/manifest.c                |  271 --
 framework/private/src/manifest_parser.c         |  490 ----
 framework/private/src/miniunz.c                 |  382 ---
 framework/private/src/module.c                  |  281 --
 framework/private/src/requirement.c             |  114 -
 framework/private/src/resolver.c                |  495 ----
 framework/private/src/service_reference.c       |  378 ---
 framework/private/src/service_registration.c    |  291 --
 framework/private/src/service_registry.c        |  800 ------
 framework/private/src/service_tracker.c         |  449 ---
 .../private/src/service_tracker_customizer.c    |  107 -
 framework/private/src/unzip.c                   | 2128 --------------
 framework/private/src/wire.c                    |   87 -
 framework/public/include/archive.h              |   58 -
 framework/public/include/bundle.h               |  139 -
 framework/public/include/bundle_activator.h     |  126 -
 framework/public/include/bundle_archive.h       |   93 -
 framework/public/include/bundle_context.h       |  159 --
 framework/public/include/bundle_event.h         |   63 -
 framework/public/include/bundle_listener.h      |   57 -
 framework/public/include/bundle_revision.h      |  142 -
 framework/public/include/bundle_state.h         |   49 -
 framework/public/include/capability.h           |   54 -
 framework/public/include/celix_launcher.h       |   55 -
 framework/public/include/celix_log.h            |   85 -
 framework/public/include/constants.h            |   67 -
 framework/public/include/filter.h               |   55 -
 framework/public/include/framework.h            |   57 -
 framework/public/include/framework_event.h      |   71 -
 framework/public/include/framework_exports.h    |   65 -
 framework/public/include/framework_listener.h   |   55 -
 .../public/include/listener_hook_service.h      |   60 -
 framework/public/include/manifest.h             |   67 -
 framework/public/include/module.h               |   94 -
 framework/public/include/requirement.h          |   53 -
 framework/public/include/service_event.h        |   68 -
 framework/public/include/service_factory.h      |   60 -
 framework/public/include/service_listener.h     |   55 -
 framework/public/include/service_reference.h    |   72 -
 framework/public/include/service_registration.h |   58 -
 framework/public/include/service_registry.h     |  103 -
 framework/public/include/service_tracker.h      |   72 -
 .../public/include/service_tracker_customizer.h |   78 -
 framework/public/include/wire.h                 |  120 -
 framework/src/attribute.c                       |   71 +
 framework/src/attribute.h                       |   39 +
 framework/src/attribute_private.h               |   39 +
 framework/src/bundle.c                          |  695 +++++
 framework/src/bundle_archive.c                  |  792 ++++++
 framework/src/bundle_cache.c                    |  218 ++
 framework/src/bundle_cache.h                    |  115 +
 framework/src/bundle_cache_private.h            |   39 +
 framework/src/bundle_context.c                  |  384 +++
 framework/src/bundle_context_private.h          |   43 +
 framework/src/bundle_private.h                  |   48 +
 framework/src/bundle_revision.c                 |  153 +
 framework/src/bundle_revision_private.h         |   42 +
 framework/src/capability.c                      |  100 +
 framework/src/capability_private.h              |   41 +
 framework/src/celix_errorcodes.c                |   64 +
 framework/src/celix_launcher.c                  |  242 ++
 framework/src/celix_log.c                       |   83 +
 framework/src/filter.c                          |  687 +++++
 framework/src/filter_private.h                  |   57 +
 framework/src/framework.c                       | 2620 ++++++++++++++++++
 framework/src/framework_private.h               |  145 +
 framework/src/ioapi.c                           |  235 ++
 framework/src/ioapi.h                           |  200 ++
 framework/src/iowin32.c                         |  389 +++
 framework/src/iowin32.h                         |   28 +
 framework/src/listener_hook_info_impl.h         |   34 +
 framework/src/manifest.c                        |  271 ++
 framework/src/manifest_parser.c                 |  490 ++++
 framework/src/manifest_parser.h                 |   45 +
 framework/src/miniunz.c                         |  382 +++
 framework/src/module.c                          |  281 ++
 framework/src/registry_callback_private.h       |   42 +
 framework/src/requirement.c                     |  114 +
 framework/src/requirement_private.h             |   40 +
 framework/src/resolver.c                        |  495 ++++
 framework/src/resolver.h                        |   45 +
 framework/src/service_reference.c               |  378 +++
 framework/src/service_reference_private.h       |   69 +
 framework/src/service_registration.c            |  291 ++
 framework/src/service_registration_private.h    |   71 +
 framework/src/service_registry.c                |  800 ++++++
 framework/src/service_registry_private.h        |   67 +
 framework/src/service_tracker.c                 |  449 +++
 framework/src/service_tracker_customizer.c      |  107 +
 .../src/service_tracker_customizer_private.h    |   49 +
 framework/src/service_tracker_private.h         |   52 +
 framework/src/unzip.c                           | 2128 ++++++++++++++
 framework/src/unzip.h                           |  437 +++
 framework/src/wire.c                            |   87 +
 framework/tst/CMakeLists.txt                    |   12 +-
 launcher/CMakeLists.txt                         |   33 +-
 launcher/private/src/celix_test_runner.cpp      |   73 -
 launcher/private/src/main.c                     |   24 -
 launcher/src/celix_test_runner.cpp              |   73 +
 launcher/src/main.c                             |   24 +
 log_service/CMakeLists.txt                      |   49 +-
 log_service/README.md                           |   13 +-
 log_service/include/log_entry.h                 |   55 +
 log_service/include/log_listener.h              |   43 +
 log_service/include/log_reader_service.h        |   50 +
 log_service/include/log_service.h               |   58 +
 log_service/loghelper_include/log_helper.h      |   35 +
 log_service/private/include/log.h               |   48 -
 log_service/private/include/log_factory.h       |   40 -
 .../private/include/log_reader_service_impl.h   |   43 -
 log_service/private/include/log_service_impl.h  |   39 -
 log_service/private/src/log.c                   |  375 ---
 log_service/private/src/log_entry.c             |   94 -
 log_service/private/src/log_factory.c           |  100 -
 .../private/src/log_reader_service_impl.c       |   82 -
 log_service/private/src/log_service_activator.c |  198 --
 log_service/private/src/log_service_impl.c      |   96 -
 log_service/public/include/log_entry.h          |   55 -
 log_service/public/include/log_helper.h         |   35 -
 log_service/public/include/log_listener.h       |   43 -
 log_service/public/include/log_reader_service.h |   50 -
 log_service/public/include/log_service.h        |   58 -
 log_service/public/src/log_helper.c             |  211 --
 log_service/src/log.c                           |  375 +++
 log_service/src/log.h                           |   48 +
 log_service/src/log_entry.c                     |   94 +
 log_service/src/log_factory.c                   |  100 +
 log_service/src/log_factory.h                   |   40 +
 log_service/src/log_helper.c                    |  211 ++
 log_service/src/log_reader_service_impl.c       |   82 +
 log_service/src/log_reader_service_impl.h       |   43 +
 log_service/src/log_service_activator.c         |  198 ++
 log_service/src/log_service_impl.c              |   96 +
 log_service/src/log_service_impl.h              |   39 +
 log_writer/CMakeLists.txt                       |    1 +
 log_writer/log_writer/CMakeLists.txt            |   24 +
 log_writer/log_writer/include/log_writer.h      |   53 +
 .../log_writer/private/include/log_writer.h     |   54 -
 log_writer/log_writer/private/src/log_writer.c  |  122 -
 .../private/src/log_writer_activator.c          |   57 -
 log_writer/log_writer/src/log_writer.c          |  122 +
 .../log_writer/src/log_writer_activator.c       |   57 +
 log_writer/log_writer_stdout/CMakeLists.txt     |   16 +-
 .../private/src/log_writer_stdout.c             |   49 -
 .../log_writer_stdout/src/log_writer_stdout.c   |   49 +
 log_writer/log_writer_syslog/CMakeLists.txt     |   16 +-
 pubsub/CMakeLists.txt                           |   11 +-
 pubsub/deploy/CMakeLists.txt                    |  176 +-
 remote_services/CMakeLists.txt                  |   15 +-
 .../discovery_configured/CMakeLists.txt         |    5 +-
 remote_services/discovery_etcd/CMakeLists.txt   |   10 +-
 .../private/include/discovery_impl.h            |   66 -
 .../private/include/etcd_watcher.h              |   40 -
 .../discovery_etcd/private/src/discovery_impl.c |  183 --
 .../discovery_etcd/private/src/etcd_watcher.c   |  397 ---
 .../discovery_etcd/src/discovery_impl.c         |  183 ++
 .../discovery_etcd/src/discovery_impl.h         |   66 +
 .../discovery_etcd/src/etcd_watcher.c           |  397 +++
 .../discovery_etcd/src/etcd_watcher.h           |   40 +
 remote_services/examples/CMakeLists.txt         |   99 +-
 .../examples/calculator_endpoint/CMakeLists.txt |   35 -
 .../private/include/calculator_endpoint_impl.h  |   46 -
 .../private/src/calculator_endpoint_activator.c |   96 -
 .../private/src/calculator_endpoint_impl.c      |  184 --
 .../calculator_endpoint2/CMakeLists.txt         |   35 -
 .../private/include/calculator_endpoint_impl.h  |   46 -
 .../private/src/calculator_endpoint_activator.c |   96 -
 .../private/src/calculator_endpoint_impl.c      |  184 --
 .../examples/calculator_proxy/CMakeLists.txt    |   37 -
 .../private/include/calculator_proxy_impl.h     |   59 -
 .../private/src/calculator_proxy_activator.c    |  124 -
 .../private/src/calculator_proxy_impl.c         |  173 --
 .../examples/calculator_proxy2/CMakeLists.txt   |   37 -
 .../private/include/calculator_proxy_impl.h     |   59 -
 .../private/src/calculator_proxy_activator.c    |  124 -
 .../private/src/calculator_proxy_impl.c         |  173 --
 .../examples/calculator_service/CMakeLists.txt  |    2 -
 .../examples/calculator_shell/CMakeLists.txt    |    3 +-
 .../remote_service_admin_dfi/rsa/CMakeLists.txt |    3 +-
 .../rsa_tst/CMakeLists.txt                      |    5 +-
 .../rsa_tst/bundle/CMakeLists.txt               |    2 +-
 .../remote_service_admin_http/CMakeLists.txt    |   55 -
 .../include/remote_service_admin_http_impl.h    |   52 -
 .../src/remote_service_admin_activator.c        |  123 -
 .../private/src/remote_service_admin_impl.c     |  822 ------
 .../private/test/CMakeLists.txt                 |   58 -
 .../private/test/client.properties.in           |   26 -
 .../private/test/rsa_client_server_tests.cpp    |  495 ----
 .../private/test/run_tests.cpp                  |   24 -
 .../private/test/server.properties.in           |   25 -
 remote_services/topology_manager/CMakeLists.txt |    5 +-
 .../topology_manager/tms_tst/CMakeLists.txt     |    2 +-
 .../tms_tst/bundle/CMakeLists.txt               |    2 +-
 .../tms_tst/disc_mock/CMakeLists.txt            |    2 +-
 remote_shell/CMakeLists.txt                     |   28 +-
 .../private/include/connection_listener.h       |   42 -
 remote_shell/private/include/remote_shell.h     |   50 -
 remote_shell/private/include/shell_mediator.h   |   54 -
 remote_shell/private/src/activator.c            |  153 -
 remote_shell/private/src/connection_listener.c  |  221 --
 remote_shell/private/src/remote_shell.c         |  242 --
 remote_shell/private/src/shell_mediator.c       |  139 -
 remote_shell/src/activator.c                    |  153 +
 remote_shell/src/connection_listener.c          |  221 ++
 remote_shell/src/connection_listener.h          |   42 +
 remote_shell/src/remote_shell.c                 |  242 ++
 remote_shell/src/remote_shell.h                 |   50 +
 remote_shell/src/shell_mediator.c               |  139 +
 remote_shell/src/shell_mediator.h               |   54 +
 shell/CMakeLists.txt                            |   49 +-
 shell/README.md                                 |   11 +-
 shell/include/command.h                         |   57 +
 shell/include/shell.h                           |   51 +
 shell/include/shell_constants.h                 |   27 +
 shell/private/include/shell_private.h           |   51 -
 shell/private/include/std_commands.h            |   44 -
 shell/private/src/activator.c                   |  269 --
 shell/private/src/help_command.c                |  112 -
 shell/private/src/inspect_command.c             |  277 --
 shell/private/src/install_command.c             |   76 -
 shell/private/src/lb_command.c                  |  205 --
 shell/private/src/log_command.c                 |   94 -
 shell/private/src/shell.c                       |  305 --
 shell/private/src/start_command.c               |   84 -
 shell/private/src/stop_command.c                |   82 -
 shell/private/src/uninstall_command.c           |   58 -
 shell/private/src/update_command.c              |  117 -
 shell/public/include/command.h                  |   57 -
 shell/public/include/shell.h                    |   51 -
 shell/public/include/shell_constants.h          |   27 -
 shell/src/activator.c                           |  269 ++
 shell/src/help_command.c                        |  112 +
 shell/src/inspect_command.c                     |  277 ++
 shell/src/install_command.c                     |   76 +
 shell/src/lb_command.c                          |  205 ++
 shell/src/log_command.c                         |   94 +
 shell/src/shell.c                               |  305 ++
 shell/src/shell_private.h                       |   51 +
 shell/src/start_command.c                       |   84 +
 shell/src/std_commands.h                        |   44 +
 shell/src/stop_command.c                        |   82 +
 shell/src/uninstall_command.c                   |   58 +
 shell/src/update_command.c                      |  117 +
 shell_bonjour/CMakeLists.txt                    |   26 +-
 shell_tui/CMakeLists.txt                        |   14 +-
 shell_tui/README.md                             |    5 +
 utils/CMakeLists.txt                            |  179 +-
 utils/include/array_list.h                      |   99 +
 utils/include/celix_errno.h                     |  119 +
 utils/include/celix_threads.h                   |  135 +
 utils/include/celixbool.h                       |   61 +
 utils/include/exports.h                         |   49 +
 utils/include/hash_map.h                        |  161 ++
 utils/include/linked_list.h                     |   91 +
 utils/include/linked_list_iterator.h            |   66 +
 utils/include/memstream/README.md               |   49 +
 utils/include/memstream/fmemopen.h              |   52 +
 utils/include/memstream/open_memstream.h        |   15 +
 utils/include/properties.h                      |   66 +
 utils/include/thpool.h                          |  168 ++
 utils/include/utils.h                           |   61 +
 utils/include/version.h                         |  186 ++
 utils/include/version_range.h                   |  160 ++
 utils/private/include/array_list_private.h      |   52 -
 utils/private/include/hash_map_private.h        |   74 -
 utils/private/include/linked_list_private.h     |   44 -
 utils/private/include/version_private.h         |   41 -
 utils/private/include/version_range_private.h   |   41 -
 utils/private/src/array_list.c                  |  337 ---
 utils/private/src/celix_threads.c               |  184 --
 utils/private/src/hash_map.c                    |  607 ----
 utils/private/src/linked_list.c                 |  268 --
 utils/private/src/linked_list_iterator.c        |  153 -
 utils/private/src/memstream/fmemopen.c          |   76 -
 utils/private/src/memstream/open_memstream.c    |  130 -
 utils/private/src/properties.c                  |  302 --
 utils/private/src/thpool.c                      |  535 ----
 utils/private/src/utils.c                       |  141 -
 utils/private/src/version.c                     |  264 --
 utils/private/src/version_range.c               |  233 --
 utils/public/include/array_list.h               |   99 -
 utils/public/include/celix_errno.h              |  119 -
 utils/public/include/celix_threads.h            |  135 -
 utils/public/include/celixbool.h                |   61 -
 utils/public/include/exports.h                  |   49 -
 utils/public/include/hash_map.h                 |  161 --
 utils/public/include/linked_list.h              |   91 -
 utils/public/include/linked_list_iterator.h     |   66 -
 utils/public/include/memstream/README.md        |   49 -
 utils/public/include/memstream/fmemopen.h       |   52 -
 utils/public/include/memstream/open_memstream.h |   15 -
 utils/public/include/properties.h               |   66 -
 utils/public/include/thpool.h                   |  168 --
 utils/public/include/utils.h                    |   61 -
 utils/public/include/version.h                  |  186 --
 utils/public/include/version_range.h            |  160 --
 utils/src/array_list.c                          |  337 +++
 utils/src/array_list_private.h                  |   52 +
 utils/src/celix_threads.c                       |  184 ++
 utils/src/hash_map.c                            |  607 ++++
 utils/src/hash_map_private.h                    |   74 +
 utils/src/linked_list.c                         |  268 ++
 utils/src/linked_list_iterator.c                |  153 +
 utils/src/linked_list_private.h                 |   44 +
 utils/src/memstream/fmemopen.c                  |   76 +
 utils/src/memstream/open_memstream.c            |  130 +
 utils/src/properties.c                          |  302 ++
 utils/src/thpool.c                              |  535 ++++
 utils/src/utils.c                               |  141 +
 utils/src/version.c                             |  264 ++
 utils/src/version_private.h                     |   41 +
 utils/src/version_range.c                       |  233 ++
 utils/src/version_range_private.h               |   41 +
 699 files changed, 48465 insertions(+), 52553 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dec1dff..9697da9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,27 +21,11 @@ cmake_policy(SET CMP0042 NEW)
 
 project (Celix C CXX)
 
-include(GNUInstallDirs)                                                                                                                                                                             
-
+include(GNUInstallDirs)
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
-
-#Setup vars conform the FindCelix setup, so that examples and supporting cmake command can assume these variables are set
-#TODO move this to a seperate cmake file or integrate in the FindCelix.cmake file
-set(CELIX_FOUND true)
-set(CELIX_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/framework/public/include ${CMAKE_SOURCE_DIR}/utils/public/include)
-set(CELIX_LIBRARIES celix_framework celix_utils celix_dfi)
-set(CELIX_LAUNCHER celix)
-set(CELIX_FRAMEWORK_LIBRARY celix_framework)
-set(CELIX_UTILS_LIBRARY celix_utils)
-set(CELIX_DFI_LIBRARY celix_dfi)
-#TODO CELIX_BUNDLES_DIR this will not work, maybe only use var (e.g. ${CELIX_SHELL_BUNDLE}) for bundles
-set(CELIX_DM_LIB dependency_manager_so)
-set(CELIX_DM_STATIC_LIB dependency_manager_static)
-set(CELIX_DM_STATIC_CXX_LIB dependency_manager_cxx_static)
-set(CELIX_PROJECT true) #Note this var is not set by FindCelix and can be used to test if this is the celix project or a project using celix
-
 set(CMAKE_BUILD_TYPE "Debug")
 
+
 # see https://public.kitware.com/Bug/view.php?id=15696
 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} EQUAL 3.3 AND ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
     message( FATAL_ERROR "Building Celix using CMake 3.3 and makefiles is not supported due to a bug in the Makefile Generator (see Bug 15696). Please change the used CMake version - both, CMake 3.2 and CMake 3.4 are working fine. Or use a different generator (e.g. Ninja)." )
@@ -77,22 +61,25 @@ if (ENABLE_TESTING)
 endif()
 
 
-include(CMakeCelix)
+include(CMakeCelix-local)
 include(UseDoxygen)  
 
 # Default bundle version
 set(DEFAULT_VERSION 1.0.0)
 
+#libraries
 #utils, dfi and etcdlib are standalone
 #(e.g. no dependency on celix framework
 add_subdirectory(utils)
 add_subdirectory(dfi)
 add_subdirectory(etcdlib)
-
 add_subdirectory(framework)
-
 include_directories(framework/public/include)
+
+#launcher
 add_subdirectory(launcher)
+
+#Bundles
 add_subdirectory(config_admin)
 add_subdirectory(device_access)
 add_subdirectory(deployment_admin)
@@ -104,8 +91,8 @@ add_subdirectory(shell)
 add_subdirectory(log_writer)
 add_subdirectory(log_service)
 add_subdirectory(pubsub)
-
 #add_subdirectory(event_admin)# event_admin is unstable
+
 add_subdirectory(dependency_manager)
 add_subdirectory(dependency_manager_cxx)
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/cmake/CMakeCelix-local.cmake
----------------------------------------------------------------------
diff --git a/cmake/CMakeCelix-local.cmake b/cmake/CMakeCelix-local.cmake
new file mode 100644
index 0000000..f67648b
--- /dev/null
+++ b/cmake/CMakeCelix-local.cmake
@@ -0,0 +1,31 @@
+# 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.
+
+set(CELIX_CMAKE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
+
+include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/Dependencies.cmake)
+include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/ApacheRat.cmake)
+include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/CodeCoverage.cmake)
+include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/BuildOptions.cmake)
+
+include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/UseCelix.cmake)
+
+#UseCelix includes:
+#include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/BundlePackaging.cmake)
+#include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/DeployPackaging.cmake)
+#include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/DockerPackaging.cmake)
+#include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/Runtimes.cmake)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/cmake/CMakeCelix.cmake
----------------------------------------------------------------------
diff --git a/cmake/CMakeCelix.cmake b/cmake/CMakeCelix.cmake
deleted file mode 100644
index 8c14577..0000000
--- a/cmake/CMakeCelix.cmake
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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.
-
-
-set(CELIX_CMAKE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
-
-if (ANDROID)
-	add_definitions( -DANDROID )
-endif ()
-
-include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/Dependencies.cmake)
-include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/BundlePackaging.cmake)
-include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/DeployPackaging.cmake)
-include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/DockerPackaging.cmake)
-include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/Runtimes.cmake)
-include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/ApacheRat.cmake)
-include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/CodeCoverage.cmake)
-include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/BuildOptions.cmake)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/cmake/FindCELIX.cmake
----------------------------------------------------------------------
diff --git a/cmake/FindCELIX.cmake b/cmake/FindCELIX.cmake
index 3f67c50..ce31bc9 100644
--- a/cmake/FindCELIX.cmake
+++ b/cmake/FindCELIX.cmake
@@ -37,6 +37,8 @@
 set(CELIX_DIR_FROM_FINDCELIX "${CMAKE_CURRENT_LIST_DIR}/../../../..")
 
 
+#Find libraries celix_framework, celix_utils, etcdlib and celix_dfi
+#Find celix launcher
 find_path(CELIX_INCLUDE_DIR NAMES celix_errno.h
 		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
 		PATH_SUFFIXES include include/celix
@@ -67,37 +69,53 @@ find_program(CELIX_LAUNCHER NAMES celix
 		PATH_SUFFIXES bin
 )
 
-find_file(CELIX_CMAKECELIX_FILE NAMES CMakeCelix.cmake
+find_file(CELIX_USECELIX_FILE NAMES UseCelix.cmake
              	PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
-             	PATH_SUFFIXES share/celix/cmake/modules
+             	PATH_SUFFIXES share/celix/cmake/modules/cmake_celix
 )
 
-#NOTE assuming shell.zip is always installed.
-find_path(CELIX_BUNDLES_DIR shell.zip
-		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
-		PATH_SUFFIXES share/celix/bundles
-)
 
+
+
+#Finding dependency manager libraries for C and C++
 find_library(CELIX_DM_LIB NAMES dependency_manager_so
 		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
 		PATH_SUFFIXES lib lib64
-)
+		)
 
 find_library(CELIX_DM_STATIC_LIB NAMES dependency_manager_static
 		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
 		PATH_SUFFIXES lib lib64
-)
+		)
 
 find_library(CELIX_DM_STATIC_CXX_LIB NAMES dependency_manager_cxx_static
 		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
 		PATH_SUFFIXES lib lib64
-)
+		)
 
 find_library(CELIX_ETCD_LIB NAMES etcdlib
 		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
 		PATH_SUFFIXES lib lib64
 		)
 
+
+#Finding bundles dir.
+find_path(CELIX_BUNDLES_DIR shell.zip #NOTE assuming shell.zip is always installed.
+		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
+		PATH_SUFFIXES share/celix/bundles
+)
+
+#Finding bundles. If not found the <BUNDLEVAR>_BUNDLE var will be set to <BUNDLEVAR>-NOTFOUND
+find_file(CELIX_SHELL_BUNDLE shell.zip
+		PATHS ${CELIX_BUNDLES_DIR}
+		NO_DEFAULT_PATH
+		)
+find_file(CELIX_SHELL_TUI_BUNDLE shell_tui.zip
+		PATHS ${CELIX_BUNDLES_DIR}
+		NO_DEFAULT_PATH
+		)
+
+
 if (CELIX_DM_STATIC_LIB)
     set(CELIX_DM_INCLUDE_DIR ${CELIX_INCLUDE_DIR}/dependency_manager)
 endif()
@@ -114,12 +132,12 @@ include(FindPackageHandleStandardArgs)
 # if all listed variables are TRUE
 find_package_handle_standard_args(CELIX  DEFAULT_MSG
 	CELIX_FRAMEWORK_LIBRARY CELIX_UTILS_LIBRARY CELIX_DFI_LIBRARY CELIX_DM_LIB CELIX_DM_STATIC_LIB CELIX_DM_STATIC_CXX_LIB CELIX_INCLUDE_DIR CELIX_LAUNCHER CELIX_CMAKECELIX_FILE)
-mark_as_advanced(CELIX_INCLUDE_DIR CELIX_ETCD_INCLUDE_DIR CELIX_CMAKECELIX_FILE)
+mark_as_advanced(CELIX_INCLUDE_DIR CELIX_ETCD_INCLUDE_DIR CELIX_USECELIX_FILE)
 
 if(CELIX_FOUND)
 	set(CELIX_LIBRARIES ${CELIX_FRAMEWORK_LIBRARY} ${CELIX_UTILS_LIBRARY} ${CELIX_DFI_LIBRARY})
 	set(CELIX_INCLUDE_DIRS ${CELIX_INCLUDE_DIR} ${CELIX_ETCD_INCLUDE_DIR} ${CELIX_DM_INCLUDE_DIR} ${CELIX_DM_CXX_INCLUDE_DIR})
-	include(${CELIX_CMAKECELIX_FILE})
-	include_directories(${CELIX_INCLUDE_DIRS})
+
+	include(${CELIX_USECELIX_FILE})
 endif()
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/cmake/cmake_celix/BundlePackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/BundlePackaging.cmake b/cmake/cmake_celix/BundlePackaging.cmake
index 7eb42fa..2071fca 100644
--- a/cmake/cmake_celix/BundlePackaging.cmake
+++ b/cmake/cmake_celix/BundlePackaging.cmake
@@ -94,36 +94,40 @@ function(add_bundle)
     list(REMOVE_AT ARGN 0)
 
     set(OPTIONS NO_ACTIVATOR)
-    set(ONE_VAL_ARGS VERSION ACTIVATOR SYMBOLIC_NAME NAME DESCRIPTION) 
+    set(ONE_VAL_ARGS VERSION ACTIVATOR SYMBOLIC_NAME NAME DESCRIPTION FILENAME)
     set(MULTI_VAL_ARGS SOURCES PRIVATE_LIBRARIES EXPORT_LIBRARIES IMPORT_LIBRARIES HEADERS)
     cmake_parse_arguments(BUNDLE "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN})
 
     ##check arguments
-    if(NOT BUNDLE_TARGET_NAME)
+    if (NOT BUNDLE_TARGET_NAME)
         message(FATAL_ERROR "add_bunde function requires first target name argument")
-    endif()
-    if((NOT (BUNDLE_SOURCES OR BUNDLE_ACTIVATOR)) AND (NOT BUNDLE_NO_ACTIVATOR))
+    endif ()
+    if ((NOT (BUNDLE_SOURCES OR BUNDLE_ACTIVATOR)) AND (NOT BUNDLE_NO_ACTIVATOR))
         message(FATAL_ERROR "Bundle contain no SOURCES or ACTIVATOR target and the option NO_ACTIVATOR is not set")
-    endif()
-    if(BUNDLE_SOURCES AND BUNDLE_ACTIVATOR)
+    endif ()
+    if (BUNDLE_SOURCES AND BUNDLE_ACTIVATOR)
         message(FATAL_ERROR "add_bundle function requires a value for SOURCES or ACTIVATOR not both")
-    endif()
-    if(BUNDLE_ACTIVATOR)
+    endif ()
+    if (BUNDLE_ACTIVATOR)
         check_lib(${BUNDLE_ACTIVATOR})
-    endif()
+    endif ()
 
     #setting defaults
     if(NOT BUNDLE_VERSION) 
         set(BUNDLE_VERSION "0.0.0")
         message(WARNING "Bundle version for ${BUNDLE_NAME} not provided. Using 0.0.0")
-    endif()
+    endif ()
     if (NOT BUNDLE_NAME)
         set(BUNDLE_NAME ${BUNDLE_TARGET_NAME})
-    endif()
+    endif ()
     if (NOT BUNDLE_SYMBOLIC_NAME)
         set(BUNDLE_SYMBOLIC_NAME ${BUNDLE_TARGET_NAME})
-    endif()
-    set(BUNDLE_FILE "${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_TARGET_NAME}.zip") 
+    endif ()
+    if (NOT BUNDLE_FILENAME)
+        set(BUNDLE_FILENAME ${BUNDLE_TARGET_NAME}.zip)
+    endif ()
+
+    set(BUNDLE_FILE "${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_FILENAME}")
     set(BUNDLE_CONTENT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_TARGET_NAME}_content")
     set(BUNDLE_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/${BUNDLE_TARGET_NAME}_gen")
 
@@ -139,12 +143,20 @@ function(add_bundle)
         #create lib from sources
         add_library(${BUNDLE_TARGET_NAME} SHARED ${BUNDLE_SOURCES})
         set_library_version(${BUNDLE_TARGET_NAME} ${BUNDLE_VERSION})
-        set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_TARGET_IS_LIB" TRUE)
+        set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES
+                "BUNDLE_TARGET_IS_LIB" TRUE
+                "BUNDLE_BUILD_BUNDLE_TARGET" "${BUNDLE_TARGET_NAME}_bundle"
+        )
+        target_link_libraries(${BUNDLE_TARGET_NAME} PRIVATE Celix::framework)
     else()
         add_custom_target(${BUNDLE_TARGET_NAME})
+        set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES
+                "BUNDLE_TARGET_IS_LIB" FALSE
+                "BUNDLE_BUILD_BUNDLE_TARGET" "${BUNDLE_TARGET_NAME}_bundle"
+        )
     endif()
     add_custom_target(${BUNDLE_TARGET_NAME}_bundle
-        DEPENDS "$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_FILE>"
+        DEPENDS ${BUNDLE_TARGET_NAME} "$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_FILE>"
     )
     add_dependencies(bundles ${BUNDLE_TARGET_NAME}_bundle)
     #######################################################################
@@ -199,13 +211,18 @@ function(add_bundle)
     #############################
     ### BUNDLE TARGET PROPERTIES
     #############################
+    #alreadyer set
+    #   BUNDLE_TARGET_IS_LIB -> true (can be use to test if target is bundle target
+    #   BUNDLE_BUILD_BUNDLE_TARGET -> refers to the _bundle target which is responsible for building the zip file
     #internal use
+    set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_IS_BUNDLE_TARGET" TRUE) #indicate that this is a bundle target
     set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_DEPEND_TARGETS" "") #bundle target dependencies. Note can be extended after the add_bundle call
     set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_GEN_DIR" ${BUNDLE_GEN_DIR}) #location for generated output. 
 
     #bundle specific
-    set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_CONTENT_DIR" ${BUNDLE_CONTENT_DIR}) #location where the content to be jar/zipped. 
-    set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_FILE" ${BUNDLE_FILE}) #target bundle file (.zip)
+    set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_CONTENT_DIR" ${BUNDLE_CONTENT_DIR}) #location where the content to be jar/zipped.
+    set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_FILENAME" ${BUNDLE_FILENAME}) #target bundle filename (.zip)
+    set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_FILE" ${BUNDLE_FILE}) #target bundle abs file path (.zip)
 
     #name and version
     set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES "BUNDLE_NAME" ${BUNDLE_NAME}) #The bundle name default target name
@@ -326,7 +343,7 @@ function(bundle_libs)
         if ("${LIB}" STREQUAL "${BUNDLE}")
             #ignore. Do not have to link agaist own lib
         elseif(IS_LIB)
-            target_link_libraries(${BUNDLE} ${LIB})
+            target_link_libraries(${BUNDLE} PRIVATE ${LIB})
         endif()
     endforeach()
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/cmake/cmake_celix/DeployPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DeployPackaging.cmake b/cmake/cmake_celix/DeployPackaging.cmake
index 21944c9..e7f8dc6 100644
--- a/cmake/cmake_celix/DeployPackaging.cmake
+++ b/cmake/cmake_celix/DeployPackaging.cmake
@@ -102,7 +102,7 @@ function(add_celix_container)
         include_directories(${CELIX_INCLUDE_DIRS})
         add_executable(${CONTAINER_TARGET} ${LAUNCHER_SRC})
         set_target_properties(${CONTAINER_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CONTAINER_LOC})
-        target_link_libraries(${CONTAINER_TARGET} ${CELIX_FRAMEWORK_LIBRARY} ${CELIX_UTILS_LIBRARY})
+        target_link_libraries(${CONTAINER_TARGET} PRIVATE Celix::framework)
         set(LAUNCHER "$<TARGET_FILE:${CONTAINER_TARGET}>")
     endif ()
 
@@ -122,10 +122,10 @@ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_PROPERTIES>,
 
     #needed in the release.sh & run.sh files
     #Setting CELIX_LIB_DIRS, CELIX_BIN_DIR and CELIX_LAUNCHER
-    if (TARGET celix_framework)
+    if (TARGET framework)
         #Celix Main Project
-        set(CELIX_LIB_DIRS "$<TARGET_FILE_DIR:celix_framework>:$<TARGET_FILE_DIR:celix_utils>:$<TARGET_FILE_DIR:celix_dfi>")
-        set(CELIX_BIN_DIR  "$<TARGET_FILE_DIR:celix>")
+        set(CELIX_LIB_DIRS "$<TARGET_FILE_DIR:Celix::framework>:$<TARGET_FILE_DIR:Celix::utils>:$<TARGET_FILE_DIR:Celix::dfi>")
+        set(CELIX_BIN_DIR  "$<TARGET_FILE_DIR:Celix::launcher>")
     else ()
         #CELIX_FRAMEWORK_LIBRARY and CELIX_LAUNCHER set by FindCelix.cmake -> Celix Based Project
         get_filename_component(CELIX_LIB_DIR ${CELIX_FRAMEWORK_LIBRARY} DIRECTORY) #Note assuming all celix libs are in the same dir
@@ -214,17 +214,21 @@ function(celix_container_bundles_dir)
             set(OUT "${CONTAINER_LOC}/${BD_DIR_NAME}/${BUNDLE_FILENAME}")
             add_custom_command(OUTPUT ${OUT}
                 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BUNDLE} ${OUT}
-		COMMENT "Copying bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'"
+		        COMMENT "Copying bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'"
                 DEPENDS ${BUNDLE}
             )
         else()
-            set(OUT "${CONTAINER_LOC}/${BD_DIR_NAME}/${BUNDLE}.zip")
+            string(MAKE_C_IDENTIFIER ${BUNDLE} BUNDLE_ID) #Create id with no special chars (e.g. for target like Celix::shell)
+            set(OUT "${CMAKE_BINARY_DIR}/celix/gen/${CONTAINER_TARGET}-copy-bundle-for-target-${BUNDLE_ID}.timestamp")
+            set(DEST "${CONTAINER_LOC}/${BD_DIR_NAME}/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
             add_custom_command(OUTPUT ${OUT}
-                COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>" ${OUT}
+                COMMAND ${CMAKE_COMMAND} -E touch ${OUT}
+                COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>" ${DEST}
                 COMMENT "Copying bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'"
-                DEPENDS ${BUNDLE}
+                DEPENDS $<TARGET_PROPERTY:${BUNDLE},BUNDLE_BUILD_BUNDLE_TARGET>
             )
-            add_dependencies(${CONTAINER_TARGET} ${BUNDLE}_bundle) #ensure the the deploy depends on the _bundle target, custom_command depends on add_library
+            get_target_property(BUILD_BUNDLE_TARGET ${BUNDLE} BUNDLE_BUILD_BUNDLE_TARGET)
+            add_dependencies(${CONTAINER_TARGET} ${BUILD_BUNDLE_TARGET}) #ensure the the deploy depends on the _bundle target, custom_command depends on add_library
 
         endif()
         list(APPEND DEPS "${OUT}")
@@ -247,19 +251,18 @@ function(celix_container_bundles)
     get_target_property(COPY ${CONTAINER_TARGET} "CONTAINER_COPY_BUNDLES")
 
     foreach(BUNDLE IN ITEMS ${ARGN})
+           if (IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE})
+               get_filename_component(BUNDLE_FILENAME ${BUNDLE} NAME)
+               set(COPY_LOC "bundles/${BUNDLE_FILENAME}")
+               set(ABS_LOC "${BUNDLE}")
+           else () #assume target (could be a future target -> if (TARGET ...) not possible
+               set(COPY_LOC "bundles/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
+               set(ABS_LOC "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>")
+           endif ()
            if(COPY)
-                if(IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE})
-                    get_filename_component(BUNDLE_FILENAME ${BUNDLE} NAME) 
-                    list(APPEND BUNDLES "bundles/${BUNDLE_FILENAME}")
-                else() #assuming target
-                    list(APPEND BUNDLES "bundles/${BUNDLE}.zip")
-                endif()
+                list(APPEND BUNDLES ${COPY_LOC})
            else()
-                if(IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE})
-                    list(APPEND BUNDLES ${BUNDLE})
-                else() #assuming target
-                    list(APPEND BUNDLES "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>")
-                endif()
+                list(APPEND BUNDLES ${ABS_LOC})
            endif()
    endforeach()
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/cmake/cmake_celix/UseCelix.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/UseCelix.cmake b/cmake/cmake_celix/UseCelix.cmake
new file mode 100644
index 0000000..db3f109
--- /dev/null
+++ b/cmake/cmake_celix/UseCelix.cmake
@@ -0,0 +1,22 @@
+# 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.
+
+set(CELIX_CMAKE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/..)
+include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/BundlePackaging.cmake)
+include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/DeployPackaging.cmake)
+include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/DockerPackaging.cmake)
+include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/Runtimes.cmake)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/config_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/CMakeLists.txt b/config_admin/CMakeLists.txt
index 8087662..e1db68e 100644
--- a/config_admin/CMakeLists.txt
+++ b/config_admin/CMakeLists.txt
@@ -16,7 +16,9 @@
 # under the License.
 
 
-celix_subproject(CONFIG_ADMIN "Option to enable building the Config Admin Service bundle and its examples" OFF DEPS framework launcher shell_tui log_writer)
+#TODO refactor and improve impl
+#celix_subproject(CONFIG_ADMIN "Option to enable building the Config Admin Service bundle and its examples" OFF DEPS framework launcher shell_tui log_writer)
+set(CONFIG_AMDIN FALSE)
 if (CONFIG_ADMIN)
 
 	add_subdirectory(service)
@@ -49,7 +51,8 @@ if (CONFIG_ADMIN)
        NAME "config_admin"
        BUNDLES 
         config_admin 
-        shell shell_tui 
+        Celix::shell
+	    Celix::shell_tui
         log_service 
         log_writer 
         config_admin_example

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/config_admin/config_admin_tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/CMakeLists.txt b/config_admin/config_admin_tst/CMakeLists.txt
index e74e7bd..f0abb8c 100644
--- a/config_admin/config_admin_tst/CMakeLists.txt
+++ b/config_admin/config_admin_tst/CMakeLists.txt
@@ -32,7 +32,7 @@ SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) #TODO needed?
 SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/framework" "${PROJECT_BINARY_DIR}/utils" )
 
 add_executable(config_admin_test config_admin_test.cpp)
-target_link_libraries(config_admin_test celix_framework ${CELIX_LIBRARIES} ${CPPUTEST_LIBRARY} pthread)
+target_link_libraries(config_admin_test Celix::framework ${CELIX_LIBRARIES} ${CPPUTEST_LIBRARY} pthread)
 
 
 get_property(config_admin_bundle_file TARGET config_admin PROPERTY BUNDLE_FILE)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/config_admin/config_admin_tst/example_test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test/CMakeLists.txt b/config_admin/config_admin_tst/example_test/CMakeLists.txt
index d4c4b3d..2f87ca3 100644
--- a/config_admin/config_admin_tst/example_test/CMakeLists.txt
+++ b/config_admin/config_admin_tst/example_test/CMakeLists.txt
@@ -28,4 +28,4 @@ add_bundle(example_test
 	private/src/example_managed_service_impl
 )
 
-target_link_libraries(example_test celix_framework celix_utils config_admin)
+target_link_libraries(example_test PRIVATE Celix::framework celix_utils config_admin)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/config_admin/config_admin_tst/example_test2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test2/CMakeLists.txt b/config_admin/config_admin_tst/example_test2/CMakeLists.txt
index d312673..25bc27a 100644
--- a/config_admin/config_admin_tst/example_test2/CMakeLists.txt
+++ b/config_admin/config_admin_tst/example_test2/CMakeLists.txt
@@ -27,4 +27,4 @@ add_bundle(example_test2 SOURCES
     VERSION 0.1.0
 )
 
-target_link_libraries(example_test2 celix_framework celix_utils config_admin)
+target_link_libraries(example_test2 Celix::framework celix_utils config_admin)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/config_admin/example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/example/CMakeLists.txt b/config_admin/example/CMakeLists.txt
index c1c80bd..6848073 100644
--- a/config_admin/example/CMakeLists.txt
+++ b/config_admin/example/CMakeLists.txt
@@ -23,5 +23,3 @@ add_bundle(config_admin_example
 		private/src/bundle_activator
 		private/src/example
 )
-
-target_link_libraries(config_admin_example ${CELIX_FRAMEWORK_LIBRARY} ${CELIX_UTILS_LIBRARY})

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/config_admin/service/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/service/CMakeLists.txt b/config_admin/service/CMakeLists.txt
index e194081..ba119e4 100644
--- a/config_admin/service/CMakeLists.txt
+++ b/config_admin/service/CMakeLists.txt
@@ -34,6 +34,3 @@ add_bundle(config_admin
 	private/src/updated_thread_pool.c
 )
 
-target_link_libraries(config_admin celix_framework celix_utils ${APR_LIBRARY} ${APRUTIL_LIBRARY})
-	
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager/CMakeLists.txt b/dependency_manager/CMakeLists.txt
index 842f608..477a163 100644
--- a/dependency_manager/CMakeLists.txt
+++ b/dependency_manager/CMakeLists.txt
@@ -25,67 +25,75 @@ if (DEPENDENCY_MANAGER)
         exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
         set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64)")
          if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
-          add_definitions(-fPIC)
+             set(DM_COMP_OPT "-fPIC")
         endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
       endif(CMAKE_UNAME)
     endif(UNIX AND NOT WIN32)
 
-    add_bundle(dm_shell
-        SYMBOLIC_NAME "apache_celix_dm_shell"
-        VERSION "1.0.0"
-        NAME "Apache Celix DM Shell Commands"
-        SOURCES
-            private/src/dm_shell_activator
-            private/src/dm_shell_list_command
-    )
-    target_link_libraries(dm_shell celix_framework celix_utils)
-
-
     add_library(dependency_manager_static STATIC 
-    	private/src/dm_component_impl
-    	private/src/dm_service_dependency
-    	private/src/dm_event
-    	private/src/dm_dependency_manager_impl
-        private/src/dm_activator
+    	src/dm_component_impl
+    	src/dm_service_dependency
+    	src/dm_event
+    	src/dm_dependency_manager_impl
+        src/dm_activator
     )
-    set_target_properties(dependency_manager_static PROPERTIES SOVERSION 1)
+    target_link_libraries(dependency_manager_static Celix::framework)
+    target_compile_options(dependency_manager_static PRIVATE ${DM_COMP_OPT})
 
     add_library(dependency_manager_so SHARED
-    	private/src/dm_component_impl
-    	private/src/dm_service_dependency
-     	private/src/dm_event
-        private/src/dm_dependency_manager_impl
-        private/src/dm_activator
+    	src/dm_component_impl
+    	src/dm_service_dependency
+     	src/dm_event
+        src/dm_dependency_manager_impl
+        src/dm_activator
     )
     set_target_properties(dependency_manager_so PROPERTIES SOVERSION 1)
 
     if (APPLE)
-        target_link_libraries(dependency_manager_so celix_framework "-undefined dynamic_lookup")
+        target_link_libraries(dependency_manager_so Celix::framework "-undefined dynamic_lookup")
     else()
-        target_link_libraries(dependency_manager_so celix_framework)
+        target_link_libraries(dependency_manager_so Celix::framework)
     endif()
 
-   	include_directories("public/include")
-   	include_directories("private/include")
-    include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    target_link_libraries(dependency_manager_static celix_framework)
-    
-    install(
-    	FILES
-    	    public/include/dm_activator.h
-            private/src/dm_activator.c
-            public/include/dm_component.h
-            public/include/dm_dependency_manager.h
-            public/include/dm_service_dependency.h
-            public/include/dm_info.h
-		DESTINATION 
-	    	include/celix/dependency_manager
-		COMPONENT
-			dependency_manager
-	)
+    target_include_directories(dependency_manager_static PUBLIC api)
+    target_include_directories(dependency_manager_static PRIVATE src)
+    target_include_directories(dependency_manager_so PUBLIC api)
+    target_include_directories(dependency_manager_so PRIVATE src)
+
+    add_bundle(dm_shell
+        SYMBOLIC_NAME "apache_celix_dm_shell"
+        VERSION "1.0.0"
+        NAME "Apache Celix DM Shell Commands"
+        SOURCES
+            src/dm_shell_activator
+            src/dm_shell_list_command
+    )
+    target_include_directories(dm_shell PRIVATE api src)
+    target_link_libraries(dm_shell PRIVATE Celix::shell_api)
+
+#TODO check
+#    install(
+#    	FILES
+#    	    api/dm_activator.h
+#            src/dm_activator.c
+#            api/dm_component.h
+#            api/dm_dependency_manager.h
+#            apidm_service_dependency.h
+#            apidm_info.h
+#		DESTINATION
+#	    	include/celix/dependency_manager
+#		COMPONENT
+#			dependency_manager
+#	)
     install_bundle(dm_shell)
     install(TARGETS dependency_manager_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager)
     install(TARGETS dependency_manager_so DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager)
 
+    unset(DM_COMP_OPT)
+
+
+    #Setup target aliases to match external usage
+    add_library(Celix::dm_shell ALIAS dm_shell)
+    add_library(Celix::dependency_manager_static ALIAS dependency_manager_static)
+    add_library(Celix::dependency_manager_so ALIAS dependency_manager_so)
 endif (DEPENDENCY_MANAGER)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/api/dm_activator.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_activator.h b/dependency_manager/api/dm_activator.h
new file mode 100644
index 0000000..bba62e6
--- /dev/null
+++ b/dependency_manager/api/dm_activator.h
@@ -0,0 +1,65 @@
+/**
+ * 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.
+ */
+
+/*
+ * dm_activator_base.h
+ *
+ *  \date       26 Jul 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef DM_ACTIVATOR_BASE_H_
+#define DM_ACTIVATOR_BASE_H_
+
+
+#include "bundle_context.h"
+#include "celix_errno.h"
+#include "dm_dependency_manager.h"
+#include "bundle_activator.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Should be implemented by a bundle specific DM activator.
+ * Should allocate and initialize a bundle specific activator struct.
+ */
+celix_status_t dm_create(bundle_context_pt context, void ** userData);
+
+/**
+ * Should be implemented by a bundle specific DM activator.
+ * Will be called after the dm_create function.
+ * Can be used to specify with use of the provided dependency manager the bundle specific components.
+ */
+celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager);
+
+/**
+ * Should be implemented by a bundle specific DM activator.
+ * Should deinitialize and deallocate the undle specific activator struct.
+ */
+celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_ACTIVATOR_BASE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/api/dm_component.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_component.h b/dependency_manager/api/dm_component.h
new file mode 100644
index 0000000..2cdad6d
--- /dev/null
+++ b/dependency_manager/api/dm_component.h
@@ -0,0 +1,158 @@
+/**
+ *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.
+ */
+/*
+ * dm_component.h
+ *
+ *  \date       8 Oct 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef COMPONENT_H_
+#define COMPONENT_H_
+
+
+#include <bundle_context.h>
+#include <celix_errno.h>
+
+#include "dm_service_dependency.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct dm_component_struct *dm_component_pt;
+
+typedef enum dm_component_state_enum {
+    DM_CMP_STATE_INACTIVE = 1,
+    DM_CMP_STATE_WAITING_FOR_REQUIRED = 2,
+    DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED = 3,
+    DM_CMP_STATE_TRACKING_OPTIONAL = 4,
+} dm_component_state_t;
+
+#define DM_COMPONENT_MAX_ID_LENGTH 64
+#define DM_COMPONENT_MAX_NAME_LENGTH 128
+
+typedef int (*init_fpt)(void *userData);
+typedef int (*start_fpt)(void *userData);
+typedef int (*stop_fpt)(void *userData);
+typedef int (*deinit_fpt)(void *userData);
+
+/**
+ * Creates a DM Component
+ * Caller has ownership.
+ */
+celix_status_t component_create(bundle_context_pt context, const char* name, dm_component_pt *component);
+
+/**
+ * Destroys a DM Component
+ */
+void component_destroy(dm_component_pt component);
+
+
+/**
+ * Specify if a default 'service.lang=C' should be added to the properties of interfaces if no 'service.lang' has been
+ * provided. Default is false. Note that this should be set before using component_addInterface.
+ */
+celix_status_t component_setCLanguageProperty(dm_component_pt component, bool setCLangProp);
+
+
+/**
+ * Adds a C interface to provide as service to the Celix framework.
+ *
+ * @param serviceName the service name.
+ * @param version The version of the interface (e.g. "1.0.0"), Can be a NULL pointer.
+ * @param properties To (meta) properties to provide with the service. Can be a NULL pointer.
+ */
+celix_status_t component_addInterface(dm_component_pt component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties);
+
+/**
+ * Sets the implementation of the component. e.g. the component handle/self/this pointer.
+ */
+celix_status_t component_setImplementation(dm_component_pt component, void* implementation);
+
+/**
+ * Returns an arraylist of service names. The caller owns the arraylist and strings (char *)
+ */
+celix_status_t component_getInterfaces(dm_component_pt component, array_list_pt *servicesNames);
+
+/**
+ * Adds a C service dependency to the component
+ */
+celix_status_t component_addServiceDependency(dm_component_pt component, dm_service_dependency_pt dep);
+
+/**
+ * Removes a C service dependency to the component
+ */
+celix_status_t component_removeServiceDependency(dm_component_pt component, dm_service_dependency_pt dependency);
+
+/**
+ * Returns the current state of the component.
+ */
+dm_component_state_t component_currentState(dm_component_pt cmp);
+
+/**
+ * Returns the implementation of the component. e.g. the component handle/self/this pointer.
+ */
+void * component_getImplementation(dm_component_pt cmp);
+
+/**
+ * Returns the DM component name. This is used when printing information about the component.
+ */
+const char * component_getName(dm_component_pt cmp);
+
+/**
+ * Returns bundle context for the bundle where this DM component is part of.
+ */
+celix_status_t component_getBundleContext(dm_component_pt component, bundle_context_pt *out);
+
+/**
+ * Set the component life cycle callbacks.
+ * The first argument will be the component implementation (@see component_getImplementation)
+ */
+celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit);
+
+/**
+ * Set the component life cycle callbacks using a MACRO for improving the type safety.
+ */
+#define component_setCallbacksSafe(dmCmp, type, init, start, stop, deinit) \
+    do {  \
+        int (*tmp_init)(type)   = (init); \
+        int (*tmp_start)(type)  = (start); \
+        int (*tmp_stop)(type)   = (stop); \
+        int (*tmp_deinit)(type) = (deinit); \
+        component_setCallbacks((dmCmp), (init_fpt)tmp_init, (start_fpt)tmp_start, (stop_fpt)tmp_stop, (deinit_fpt)tmp_deinit); \
+    } while(0)
+
+/**
+ * Create a DM Component info struct. Containing information about the component.
+ * Caller has ownership.
+ */
+celix_status_t component_getComponentInfo(dm_component_pt component, dm_component_info_pt *info);
+
+/**
+ * Destroys a DM Component info struct.
+ */
+void component_destroyComponentInfo(dm_component_info_pt info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* COMPONENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/api/dm_dependency_manager.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_dependency_manager.h b/dependency_manager/api/dm_dependency_manager.h
new file mode 100644
index 0000000..89fe51d
--- /dev/null
+++ b/dependency_manager/api/dm_dependency_manager.h
@@ -0,0 +1,79 @@
+/**
+ *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.
+ */
+/*
+ * dm_dependency_manager.h
+ *
+ *  \date       22 Feb 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef DM_DEPENDENCY_MANAGER_H_
+#define DM_DEPENDENCY_MANAGER_H_
+
+
+#include "bundle_context.h"
+#include "celix_errno.h"
+#include "array_list.h"
+#include "dm_info.h"
+#include "dm_component.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct dm_dependency_manager *dm_dependency_manager_pt;
+
+/**
+ * Creates a dependency manager.
+ * Caller has ownership.
+ */
+celix_status_t dependencyManager_create(bundle_context_pt context, dm_dependency_manager_pt *manager);
+
+/**
+ * Destroys the provided dependency manager
+ */
+void dependencyManager_destroy(dm_dependency_manager_pt manager);
+
+/**
+ * Adds a DM component to the dependency manager
+ */
+celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component);
+
+/**
+ * Removes all DM components from the dependency manager
+ */
+celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager);
+
+/**
+ * Create and returns a DM Info struct. Which contains information about the state of the DM components
+ * Caller has ownership.
+ */
+celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt *info);
+
+/**
+ * Destroys a DM info struct.
+ */
+void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_DEPENDENCY_MANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/api/dm_info.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_info.h b/dependency_manager/api/dm_info.h
new file mode 100644
index 0000000..f5e6b47
--- /dev/null
+++ b/dependency_manager/api/dm_info.h
@@ -0,0 +1,81 @@
+/**
+ *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.
+ */
+/*
+ * dm_server.h
+ *
+ *  \date       15 Oct 2015
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+#ifndef CELIX_DM_INFO_SERVICE_H
+#define CELIX_DM_INFO_SERVICE_H
+
+
+
+#include <stdbool.h>
+#include "array_list.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DM_INFO_SERVICE_NAME "dm_info"
+
+
+typedef struct dm_interface_info_struct {
+    char* name;
+    properties_pt properties;
+} * dm_interface_info_pt;
+
+typedef struct dm_service_dependency_info_struct {
+    char *filter;
+    bool available;
+    bool required;
+    size_t count;
+} * dm_service_dependency_info_pt;
+
+typedef struct dm_component_info_struct {
+    char id[64];
+    char name[128];
+    bool active;
+    char * state;
+    array_list_pt interfaces;   // type dm_interface_info_pt
+    array_list_pt dependency_list;  // type dm_service_dependency_info_pt
+} * dm_component_info_pt;
+
+typedef struct dm_dependency_manager_info_struct {
+    array_list_pt  components;      // type dm_component_info
+} * dm_dependency_manager_info_pt;
+
+struct dm_info_service_struct {
+    void *handle;
+
+    /*Note: dm_caller has the ownership of the result.*/
+    celix_status_t (*getInfo)(void *handle, dm_dependency_manager_info_pt *info);
+    void (*destroyInfo)(void *handle, dm_dependency_manager_info_pt info);
+};
+
+typedef struct dm_info_service_struct dm_info_service_t;
+typedef dm_info_service_t* dm_info_service_pt;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //CELIX_DM_INFO_SERVICE_H


[37/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/unzip.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/unzip.h b/deployment_admin/src/unzip.h
new file mode 100644
index 0000000..3183968
--- /dev/null
+++ b/deployment_admin/src/unzip.h
@@ -0,0 +1,437 @@
+/* unzip.h -- IO for uncompress .zip files using zlib
+   Version 1.1, February 14h, 2010
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications of Unzip for Zip64
+         Copyright (C) 2007-2008 Even Rouault
+
+         Modifications for Zip64 support on both zip and unzip
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+         ---------------------------------------------------------------------------------
+
+        Condition of use and distribution are the same than zlib :
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  ---------------------------------------------------------------------------------
+
+        Changes
+
+        See header of unzip64.c
+
+*/
+
+#ifndef _unz64_H
+#define _unz64_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _ZLIB_H
+#include "zlib.h"
+#endif
+
+#ifndef  _ZLIBIOAPI_H
+#include "ioapi.h"
+#endif
+
+#ifdef HAVE_BZIP2
+#include "bzlib.h"
+#endif
+
+#define Z_BZIP2ED 12
+
+#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
+/* like the STRICT of WIN32, we define a pointer that cannot be converted
+    from (void*) without cast */
+typedef struct TagunzFile__ { int unused; } unzFile__;
+typedef unzFile__ *unzFile;
+#else
+typedef voidp unzFile;
+#endif
+
+
+#define UNZ_OK                          (0)
+#define UNZ_END_OF_LIST_OF_FILE         (-100)
+#define UNZ_ERRNO                       (Z_ERRNO)
+#define UNZ_EOF                         (0)
+#define UNZ_PARAMERROR                  (-102)
+#define UNZ_BADZIPFILE                  (-103)
+#define UNZ_INTERNALERROR               (-104)
+#define UNZ_CRCERROR                    (-105)
+
+/* tm_unz contain date/time info */
+typedef struct tm_unz_s
+{
+    uInt tm_sec;            /* seconds after the minute - [0,59] */
+    uInt tm_min;            /* minutes after the hour - [0,59] */
+    uInt tm_hour;           /* hours since midnight - [0,23] */
+    uInt tm_mday;           /* day of the month - [1,31] */
+    uInt tm_mon;            /* months since January - [0,11] */
+    uInt tm_year;           /* years - [1980..2044] */
+} tm_unz;
+
+/* unz_global_info structure contain global data about the ZIPfile
+   These data comes from the end of central dir */
+typedef struct unz_global_info64_s
+{
+    ZPOS64_T number_entry;         /* total number of entries in
+                                     the central dir on this disk */
+    uLong size_comment;         /* size of the global comment of the zipfile */
+} unz_global_info64;
+
+typedef struct unz_global_info_s
+{
+    uLong number_entry;         /* total number of entries in
+                                     the central dir on this disk */
+    uLong size_comment;         /* size of the global comment of the zipfile */
+} unz_global_info;
+
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_info64_s
+{
+    uLong version;              /* version made by                 2 bytes */
+    uLong version_needed;       /* version needed to extract       2 bytes */
+    uLong flag;                 /* general purpose bit flag        2 bytes */
+    uLong compression_method;   /* compression method              2 bytes */
+    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
+    uLong crc;                  /* crc-32                          4 bytes */
+    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */
+    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */
+    uLong size_filename;        /* filename length                 2 bytes */
+    uLong size_file_extra;      /* extra field length              2 bytes */
+    uLong size_file_comment;    /* file comment length             2 bytes */
+
+    uLong disk_num_start;       /* disk number start               2 bytes */
+    uLong internal_fa;          /* internal file attributes        2 bytes */
+    uLong external_fa;          /* external file attributes        4 bytes */
+
+    tm_unz tmu_date;
+} unz_file_info64;
+
+typedef struct unz_file_info_s
+{
+    uLong version;              /* version made by                 2 bytes */
+    uLong version_needed;       /* version needed to extract       2 bytes */
+    uLong flag;                 /* general purpose bit flag        2 bytes */
+    uLong compression_method;   /* compression method              2 bytes */
+    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
+    uLong crc;                  /* crc-32                          4 bytes */
+    uLong compressed_size;      /* compressed size                 4 bytes */
+    uLong uncompressed_size;    /* uncompressed size               4 bytes */
+    uLong size_filename;        /* filename length                 2 bytes */
+    uLong size_file_extra;      /* extra field length              2 bytes */
+    uLong size_file_comment;    /* file comment length             2 bytes */
+
+    uLong disk_num_start;       /* disk number start               2 bytes */
+    uLong internal_fa;          /* internal file attributes        2 bytes */
+    uLong external_fa;          /* external file attributes        4 bytes */
+
+    tm_unz tmu_date;
+} unz_file_info;
+
+extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
+                                                 const char* fileName2,
+                                                 int iCaseSensitivity));
+/*
+   Compare two filename (fileName1,fileName2).
+   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
+   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
+                                or strcasecmp)
+   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
+    (like 1 on Unix, 2 on Windows)
+*/
+
+
+extern unzFile ZEXPORT unzOpen OF((const char *path));
+extern unzFile ZEXPORT unzOpen64 OF((const void *path));
+/*
+  Open a Zip file. path contain the full pathname (by example,
+     on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
+     "zlib/zlib113.zip".
+     If the zipfile cannot be opened (file don't exist or in not valid), the
+       return value is NULL.
+     Else, the return value is a unzFile Handle, usable with other function
+       of this unzip package.
+     the "64" function take a const void* pointer, because the path is just the
+       value passed to the open64_file_func callback.
+     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
+       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
+       does not describe the reality
+*/
+
+
+extern unzFile ZEXPORT unzOpen2 OF((const char *path,
+                                    zlib_filefunc_def* pzlib_filefunc_def));
+/*
+   Open a Zip file, like unzOpen, but provide a set of file low level API
+      for read/write the zip file (see ioapi.h)
+*/
+
+extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
+                                    zlib_filefunc64_def* pzlib_filefunc_def));
+/*
+   Open a Zip file, like unz64Open, but provide a set of file low level API
+      for read/write the zip file (see ioapi.h)
+*/
+
+extern int ZEXPORT unzClose OF((unzFile file));
+/*
+  Close a ZipFile opened with unzipOpen.
+  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
+    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+  return UNZ_OK if there is no problem. */
+
+extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
+                                        unz_global_info *pglobal_info));
+
+extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
+                                        unz_global_info64 *pglobal_info));
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem. */
+
+
+extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
+                                           char *szComment,
+                                           uLong uSizeBuf));
+/*
+  Get the global comment string of the ZipFile, in the szComment buffer.
+  uSizeBuf is the size of the szComment buffer.
+  return the number of byte copied or an error code <0
+*/
+
+
+/***************************************************************************/
+/* Unzip package allow you browse the directory of the zipfile */
+
+extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
+/*
+  Set the current file of the zipfile to the first file.
+  return UNZ_OK if there is no problem
+*/
+
+extern int ZEXPORT unzGoToNextFile OF((unzFile file));
+/*
+  Set the current file of the zipfile to the next file.
+  return UNZ_OK if there is no problem
+  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
+*/
+
+extern int ZEXPORT unzLocateFile OF((unzFile file,
+                     const char *szFileName,
+                     int iCaseSensitivity));
+/*
+  Try locate the file szFileName in the zipfile.
+  For the iCaseSensitivity signification, see unzStringFileNameCompare
+
+  return value :
+  UNZ_OK if the file is found. It becomes the current file.
+  UNZ_END_OF_LIST_OF_FILE if the file is not found
+*/
+
+
+/* ****************************************** */
+/* Ryan supplied functions */
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_pos_s
+{
+    uLong pos_in_zip_directory;   /* offset in zip file directory */
+    uLong num_of_file;            /* # of file */
+} unz_file_pos;
+
+extern int ZEXPORT unzGetFilePos(
+    unzFile file,
+    unz_file_pos* file_pos);
+
+extern int ZEXPORT unzGoToFilePos(
+    unzFile file,
+    unz_file_pos* file_pos);
+
+typedef struct unz64_file_pos_s
+{
+    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */
+    ZPOS64_T num_of_file;            /* # of file */
+} unz64_file_pos;
+
+extern int ZEXPORT unzGetFilePos64(
+    unzFile file,
+    unz64_file_pos* file_pos);
+
+extern int ZEXPORT unzGoToFilePos64(
+    unzFile file,
+    const unz64_file_pos* file_pos);
+
+/* ****************************************** */
+
+extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
+                         unz_file_info64 *pfile_info,
+                         char *szFileName,
+                         uLong fileNameBufferSize,
+                         void *extraField,
+                         uLong extraFieldBufferSize,
+                         char *szComment,
+                         uLong commentBufferSize));
+
+extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
+                         unz_file_info *pfile_info,
+                         char *szFileName,
+                         uLong fileNameBufferSize,
+                         void *extraField,
+                         uLong extraFieldBufferSize,
+                         char *szComment,
+                         uLong commentBufferSize));
+/*
+  Get Info about the current file
+  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
+        the current file
+  if szFileName!=NULL, the filemane string will be copied in szFileName
+            (fileNameBufferSize is the size of the buffer)
+  if extraField!=NULL, the extra field information will be copied in extraField
+            (extraFieldBufferSize is the size of the buffer).
+            This is the Central-header version of the extra field
+  if szComment!=NULL, the comment string of the file will be copied in szComment
+            (commentBufferSize is the size of the buffer)
+*/
+
+
+/** Addition for GDAL : START */
+
+extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
+
+/** Addition for GDAL : END */
+
+
+/***************************************************************************/
+/* for reading the content of the current zipfile, you can open it, read data
+   from it, and close it (you can close it before reading all the file)
+   */
+
+extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
+/*
+  Open for reading data the current file in the zipfile.
+  If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
+                                                  const char* password));
+/*
+  Open for reading data the current file in the zipfile.
+  password is a crypting password
+  If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
+                                           int* method,
+                                           int* level,
+                                           int raw));
+/*
+  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+    if raw==1
+  *method will receive method of compression, *level will receive level of
+     compression
+  note : you can set level parameter as NULL (if you did not want known level,
+         but you CANNOT set method parameter as NULL
+*/
+
+extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
+                                           int* method,
+                                           int* level,
+                                           int raw,
+                                           const char* password));
+/*
+  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+    if raw==1
+  *method will receive method of compression, *level will receive level of
+     compression
+  note : you can set level parameter as NULL (if you did not want known level,
+         but you CANNOT set method parameter as NULL
+*/
+
+
+extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
+/*
+  Close the file in zip opened with unzOpenCurrentFile
+  Return UNZ_CRCERROR if all the file was read but the CRC is not good
+*/
+
+extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
+                      voidp buf,
+                      unsigned len));
+/*
+  Read bytes from the current file (opened by unzOpenCurrentFile)
+  buf contain buffer where data must be copied
+  len the size of buf.
+
+  return the number of byte copied if somes bytes are copied
+  return 0 if the end of file was reached
+  return <0 with error code if there is an error
+    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+*/
+
+extern z_off_t ZEXPORT unztell OF((unzFile file));
+
+extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
+/*
+  Give the current position in uncompressed data
+*/
+
+extern int ZEXPORT unzeof OF((unzFile file));
+/*
+  return 1 if the end of file was reached, 0 elsewhere
+*/
+
+extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
+                                             voidp buf,
+                                             unsigned len));
+/*
+  Read extra field from the current file (opened by unzOpenCurrentFile)
+  This is the local-header version of the extra field (sometimes, there is
+    more info in the local-header version than in the central-header)
+
+  if buf==NULL, it return the size of the local extra field
+
+  if buf!=NULL, len is the size of the buffer, the extra header is copied in
+    buf.
+  the return value is the number of bytes copied in buf, or (if <0)
+    the error code
+*/
+
+/***************************************************************************/
+
+/* Get the current file offset */
+extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
+extern uLong ZEXPORT unzGetOffset (unzFile file);
+
+/* Set the current file offset */
+extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
+extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _unz64_H */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/README.md
----------------------------------------------------------------------
diff --git a/device_access/README.md b/device_access/README.md
index d58601d..f0c7785 100644
--- a/device_access/README.md
+++ b/device_access/README.md
@@ -2,9 +2,16 @@
 
 The Device Access contains a for Celix adapted implementation of the OSGi Compendium Device Access Specification.
 
-###### Properties
+## Properties
     DRIVER_LOCATOR_PATH     Path to the directory containing the driver bundles, defaults to "drivers".
                             The Driver Locator uses this path to find drivers.
 
-###### CMake option
+## CMake option
     BUILD_DEVICE_ACCESS=ON
+
+## Using info
+
+If the Celix Device Access is installed The `FindCelix.cmake` will set:
+ - The `Celix::device_access_api` interface (i.e. headers only) library target
+ - The `Celix::device_manager` bundle target
+ - The `Celix::driver_locator` bundle target
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/device_access/device_access/CMakeLists.txt b/device_access/device_access/CMakeLists.txt
index 9668156..5f19293 100644
--- a/device_access/device_access/CMakeLists.txt
+++ b/device_access/device_access/CMakeLists.txt
@@ -15,39 +15,37 @@
 # specific language governing permissions and limitations
 # under the License.
 
+
+add_library(device_access_api INTERFACE)
+target_include_directories(device_access_api INTERFACE include)
+
 add_bundle(device_manager
 	SYMBOLIC_NAME "apache_celix_device_manager"
 	VERSION "0.0.2"
 	NAME "Apache Celix Device Access Device Manager"
 	SOURCES
-		private/src/activator
-		private/src/driver_attributes
-		private/src/device_manager
-		private/src/driver_loader
-		private/src/driver_matcher
-
-		${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
-
-		private/include/device_manager.h
-		private/include/driver_attributes.h
-		private/include/driver_loader.h
-		private/include/driver_matcher.h
+		src/activator
+		src/driver_attributes
+		src/device_manager
+		src/driver_loader
+		src/driver_matcher
 )
+target_link_libraries(device_manager PRIVATE Celix::log_helper)
 
 install_bundle(device_manager
 	HEADERS
-		public/include/device.h
-		public/include/driver_locator.h
-		public/include/driver_selector.h
-		public/include/driver.h
-		public/include/match.h
+		include/device.h
+		include/driver_locator.h
+		include/driver_selector.h
+		include/driver.h
+		include/match.h
 )
+target_include_directories(device_manager PRIVATE src)
+target_link_libraries(device_manager PRIVATE device_access_api)
 
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
 
-include_directories("public/include")
-include_directories("private/include")
+#Setup target aliases to match external usage
+add_library(Celix::device_access_api ALIAS device_access_api)
+add_library(Celix::device_manager ALIAS device_manager)
 
-target_link_libraries(device_manager celix_framework celix_utils)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/device.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/device.h b/device_access/device_access/include/device.h
new file mode 100644
index 0000000..28032ba
--- /dev/null
+++ b/device_access/device_access/include/device.h
@@ -0,0 +1,47 @@
+/**
+ *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.
+ */
+/*
+ * device.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DEVICE_H_
+#define DEVICE_H_
+
+#include "celix_errno.h"
+
+#define OSGI_DEVICEACCESS_DEVICE_CATEGORY	"DEVICE_CATEGORY"
+#define OSGI_DEVICEACCESS_DEVICE_SERIAL	"DEVICE_SERIAL"
+
+#define OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME "device"
+
+static const int OSGI_DEVICEACCESS_DEVICE_MATCH_NONE	= 0;
+
+typedef struct device * device_pt;
+
+struct device_service {
+	device_pt device;
+	celix_status_t (*noDriverFound)(device_pt device);
+};
+
+typedef struct device_service * device_service_pt;
+
+#endif /* DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/driver.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/driver.h b/device_access/device_access/include/driver.h
new file mode 100644
index 0000000..7e70e06
--- /dev/null
+++ b/device_access/device_access/include/driver.h
@@ -0,0 +1,45 @@
+/**
+ *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.
+ */
+/*
+ * driver.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_H_
+#define DRIVER_H_
+
+#include "celix_errno.h"
+#include "service_reference.h"
+
+#define OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME "driver"
+
+#define OSGI_DEVICEACCESS_DRIVER_ID "DRIVER_ID"
+
+struct driver_service {
+	void *driver;
+	celix_status_t (*attach)(void *driver, service_reference_pt reference, char **result);
+	celix_status_t (*match)(void *driver, service_reference_pt reference, int *value);
+};
+
+typedef struct driver_service *driver_service_pt;
+
+
+#endif /* DRIVER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/driver_locator.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/driver_locator.h b/device_access/device_access/include/driver_locator.h
new file mode 100644
index 0000000..405e33a
--- /dev/null
+++ b/device_access/device_access/include/driver_locator.h
@@ -0,0 +1,46 @@
+/**
+ *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.
+ */
+/*
+ * driver_locator.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_LOCATOR_H_
+#define DRIVER_LOCATOR_H_
+
+#include "celix_errno.h"
+#include "properties.h"
+#include "array_list.h"
+
+#define OSGI_DEVICEACCESS_DRIVER_LOCATOR_SERVICE_NAME "driver_locator"
+
+typedef struct driver_locator *driver_locator_pt;
+
+struct driver_locator_service {
+	driver_locator_pt locator;
+	celix_status_t(*findDrivers)(driver_locator_pt loc, properties_pt props, array_list_pt *drivers);
+	celix_status_t(*loadDriver)(driver_locator_pt loc, char *id, char **driver);
+};
+
+typedef struct driver_locator_service *driver_locator_service_pt;
+
+
+#endif /* DRIVER_LOCATOR_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/driver_selector.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/driver_selector.h b/device_access/device_access/include/driver_selector.h
new file mode 100644
index 0000000..a088d05
--- /dev/null
+++ b/device_access/device_access/include/driver_selector.h
@@ -0,0 +1,41 @@
+/**
+ *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.
+ */
+/*
+ * driver_selector.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_SELECTOR_H_
+#define DRIVER_SELECTOR_H_
+
+#define OSGI_DEVICEACCESS_DRIVER_SELECTOR_SERVICE_NAME "driver_selector"
+
+typedef struct driver_selector *driver_selector_pt;
+
+struct driver_selector_service {
+	driver_selector_pt selector;
+	celix_status_t (*driverSelector_select)(driver_selector_pt selector, service_reference_pt reference, array_list_pt matches, int *select);
+};
+
+typedef struct driver_selector_service *driver_selector_service_pt;
+
+
+#endif /* DRIVER_SELECTOR_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/match.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/match.h b/device_access/device_access/include/match.h
new file mode 100644
index 0000000..dd8906d
--- /dev/null
+++ b/device_access/device_access/include/match.h
@@ -0,0 +1,38 @@
+/**
+ *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.
+ */
+/*
+ * match.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef MATCH_H_
+#define MATCH_H_
+
+#include <service_reference.h>
+
+struct match {
+	service_reference_pt reference;
+	int matchValue;
+};
+
+typedef struct match *match_pt;
+
+#endif /* MATCH_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/include/device_manager.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/include/device_manager.h b/device_access/device_access/private/include/device_manager.h
deleted file mode 100644
index 00a4f2c..0000000
--- a/device_access/device_access/private/include/device_manager.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- *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.
- */
-/*
- * device_manager.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DEVICE_MANAGER_H_
-#define DEVICE_MANAGER_H_
-
-#include "log_helper.h"
-
-#include "driver_loader.h"
-
-typedef struct device_manager *device_manager_pt;
-
-celix_status_t deviceManager_create(bundle_context_pt context, log_helper_pt logHelper, device_manager_pt *manager);
-celix_status_t deviceManager_destroy(device_manager_pt manager);
-
-celix_status_t deviceManager_matchAttachDriver(device_manager_pt manager, driver_loader_pt loader,
-			array_list_pt driverIds, array_list_pt included, array_list_pt excluded, void *service, service_reference_pt reference);
-celix_status_t deviceManager_noDriverFound(device_manager_pt manager, void *service, service_reference_pt reference);
-
-celix_status_t deviceManager_locatorAdded(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_locatorModified(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_locatorRemoved(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_deviceAdded(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_deviceModified(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_deviceRemoved(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_driverAdded(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_driverModified(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_driverRemoved(void * handle, service_reference_pt ref, void * service);
-
-celix_status_t deviceManager_getBundleContext(device_manager_pt manager, bundle_context_pt *context);
-
-// celix_status_t deviceManager_match(device_manager_pt manager, ...);
-
-#endif /* DEVICE_MANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/include/driver_attributes.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/include/driver_attributes.h b/device_access/device_access/private/include/driver_attributes.h
deleted file mode 100644
index bdb12a2..0000000
--- a/device_access/device_access/private/include/driver_attributes.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_attributes.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_ATTRIBUTES_H_
-#define DRIVER_ATTRIBUTES_H_
-
-#include "driver.h"
-
-typedef struct driver_attributes *driver_attributes_pt;
-
-celix_status_t driverAttributes_create(service_reference_pt reference, driver_service_pt driver, driver_attributes_pt *attributes);
-celix_status_t driverAttributes_destroy(driver_attributes_pt attributes);
-
-celix_status_t driverAttributes_getReference(driver_attributes_pt driverAttributes, service_reference_pt *reference);
-celix_status_t driverAttributes_getDriverId(driver_attributes_pt driverAttributes, char **driverId);
-
-celix_status_t driverAttributes_match(driver_attributes_pt driverAttributes, service_reference_pt reference, int *match);
-celix_status_t driverAttributes_attach(driver_attributes_pt driverAttributes, service_reference_pt reference, char **attach);
-
-celix_status_t driverAttributes_isInUse(driver_attributes_pt driverAttributes, bool *inUse);
-
-celix_status_t driverAttributes_tryUninstall(driver_attributes_pt driverAttributes);
-
-#endif /* DRIVER_ATTRIBUTES_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/include/driver_loader.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/include/driver_loader.h b/device_access/device_access/private/include/driver_loader.h
deleted file mode 100644
index fde9c88..0000000
--- a/device_access/device_access/private/include/driver_loader.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_loader.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_LOADER_H_
-#define DRIVER_LOADER_H_
-
-#include "driver_locator.h"
-#include "driver_attributes.h"
-
-#define DRIVER_LOCATION_PREFIX "_DD_"
-
-typedef struct driver_loader *driver_loader_pt;
-
-celix_status_t driverLoader_create(bundle_context_pt context, driver_loader_pt *loader);
-celix_status_t driverLoader_destroy(driver_loader_pt *loader);
-
-celix_status_t driverLoader_findDrivers(driver_loader_pt loader, array_list_pt locators, properties_pt properties, array_list_pt *driversIds);
-celix_status_t driverLoader_findDriversForLocator(driver_loader_pt loader, driver_locator_service_pt locator, properties_pt properties, array_list_pt *driversIds);
-
-celix_status_t driverLoader_loadDrivers(driver_loader_pt loader, array_list_pt locators, array_list_pt driverIds, array_list_pt *references);
-celix_status_t driverLoader_loadDriver(driver_loader_pt loader, array_list_pt locators, char *driverId, array_list_pt *references);
-celix_status_t driverLoader_loadDriverForLocator(driver_loader_pt loader, driver_locator_service_pt locator, char *driverId, array_list_pt *references);
-
-celix_status_t driverLoader_unloadDrivers(driver_loader_pt loader, driver_attributes_pt finalDriver);
-
-#endif /* DRIVER_LOADER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/include/driver_matcher.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/include/driver_matcher.h b/device_access/device_access/private/include/driver_matcher.h
deleted file mode 100644
index d6cdb22..0000000
--- a/device_access/device_access/private/include/driver_matcher.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_matcher.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_MATCHER_H_
-#define DRIVER_MATCHER_H_
-
-#include "match.h"
-#include "driver_selector.h"
-#include "driver_attributes.h"
-
-typedef struct driver_matcher *driver_matcher_pt;
-
-celix_status_t driverMatcher_create(bundle_context_pt context, driver_matcher_pt *matcher);
-celix_status_t driverMatcher_destroy(driver_matcher_pt *matcher);
-
-celix_status_t driverMatcher_add(driver_matcher_pt matcher, int match, driver_attributes_pt attributes);
-
-celix_status_t driverMatcher_getBestMatch(driver_matcher_pt matcher, service_reference_pt reference, match_pt *match);
-
-#endif /* DRIVER_MATCHER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/activator.c b/device_access/device_access/private/src/activator.c
deleted file mode 100755
index 007e725..0000000
--- a/device_access/device_access/private/src/activator.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <service_tracker.h>
-
-#include "driver_locator.h"
-#include "device_manager.h"
-#include "log_service.h"
-#include "log_helper.h"
-
-struct device_manager_bundle_instance {
-	log_helper_pt loghelper;
-	bundle_context_pt context;
-	device_manager_pt deviceManager;
-	service_tracker_pt driverLocatorTracker;
-	service_tracker_pt driverTracker;
-	service_tracker_pt deviceTracker;
-};
-
-typedef struct device_manager_bundle_instance *device_manager_bundle_instance_pt;
-
-static celix_status_t deviceManagerBundle_createDriverLocatorTracker(device_manager_bundle_instance_pt bundleData);
-static celix_status_t deviceManagerBundle_createDriverTracker(device_manager_bundle_instance_pt bundleData);
-static celix_status_t deviceManagerBundle_createDeviceTracker(device_manager_bundle_instance_pt bundleData);
-
-celix_status_t addingService_dummy_func(void * handle, service_reference_pt reference, void **service) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_pt dm = handle;
-	bundle_context_pt context = NULL;
-	status = deviceManager_getBundleContext(dm, &context);
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getService(context, reference, service);
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_bundle_instance_pt bi = calloc(1, sizeof(struct device_manager_bundle_instance));
-	if (bi == NULL) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*userData) = bi;
-		bi->context = context;
-
-		logHelper_create(context, &bi->loghelper);
-		logHelper_start(bi->loghelper);
-
-		status = deviceManager_create(context, bi->loghelper, &bi->deviceManager);
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_bundle_instance_pt bundleData = userData;
-
-	status = deviceManagerBundle_createDriverLocatorTracker(bundleData);
-	if (status == CELIX_SUCCESS) {
-		status = deviceManagerBundle_createDriverTracker(bundleData);
-		if (status == CELIX_SUCCESS) {
-				status = deviceManagerBundle_createDeviceTracker(bundleData);
-				if (status == CELIX_SUCCESS) {
-					status = serviceTracker_open(bundleData->driverLocatorTracker);
-					if (status == CELIX_SUCCESS) {
-						status = serviceTracker_open(bundleData->driverTracker);
-						if (status == CELIX_SUCCESS) {
-							status = serviceTracker_open(bundleData->deviceTracker);
-						}
-					}
-				}
-		}
-	}
-
-	if (status != CELIX_SUCCESS) {
-		logHelper_log(bundleData->loghelper, OSGI_LOGSERVICE_ERROR, "DEVICE_MANAGER: Error while starting bundle got error num %d", status);
-	}
-
-	logHelper_log(bundleData->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Started");
-
-	return status;
-}
-
-static celix_status_t deviceManagerBundle_createDriverLocatorTracker(device_manager_bundle_instance_pt bundleData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_tracker_customizer_pt customizer = NULL;
-
-	status = serviceTrackerCustomizer_create(bundleData->deviceManager, addingService_dummy_func,
-			deviceManager_locatorAdded, deviceManager_locatorModified, deviceManager_locatorRemoved, &customizer);
-
-	if (status == CELIX_SUCCESS) {
-		service_tracker_pt tracker = NULL;
-		status = serviceTracker_create(bundleData->context, "driver_locator", customizer, &tracker);
-		if (status == CELIX_SUCCESS) {
-			bundleData->driverLocatorTracker=tracker;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-static celix_status_t deviceManagerBundle_createDriverTracker(device_manager_bundle_instance_pt bundleData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_tracker_customizer_pt customizer = NULL;
-
-	status = serviceTrackerCustomizer_create(bundleData->deviceManager, addingService_dummy_func,
-			deviceManager_driverAdded, deviceManager_driverModified, deviceManager_driverRemoved, &customizer);
-
-	if (status == CELIX_SUCCESS) {
-		service_tracker_pt tracker = NULL;
-		status = serviceTracker_createWithFilter(bundleData->context, "(objectClass=driver)", customizer, &tracker);
-		if (status == CELIX_SUCCESS) {
-			bundleData->driverTracker=tracker;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-static celix_status_t deviceManagerBundle_createDeviceTracker(device_manager_bundle_instance_pt bundleData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_tracker_customizer_pt customizer = NULL;
-
-	status = serviceTrackerCustomizer_create(bundleData->deviceManager, addingService_dummy_func,
-			deviceManager_deviceAdded, deviceManager_deviceModified, deviceManager_deviceRemoved, &customizer);
-
-	if (status == CELIX_SUCCESS) {
-		service_tracker_pt tracker = NULL;
-		status = serviceTracker_createWithFilter(bundleData->context, "(|(objectClass=device)(DEVICE_CATEGORY=*))", customizer, &tracker);
-		if (status == CELIX_SUCCESS) {
-			bundleData->deviceTracker=tracker;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_bundle_instance_pt bundleData = userData;
-//	status = serviceTracker_close(bundleData->driverLocatorTracker);
-	if (status == CELIX_SUCCESS) {
-		status = serviceTracker_close(bundleData->driverTracker);
-		if (status == CELIX_SUCCESS) {
-			status = serviceTracker_close(bundleData->deviceTracker);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_bundle_instance_pt bundleData = userData;
-	status = deviceManager_destroy(bundleData->deviceManager);
-
-	logHelper_stop(bundleData->loghelper);
-	logHelper_destroy(&bundleData->loghelper);
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/device_manager.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/device_manager.c b/device_access/device_access/private/src/device_manager.c
deleted file mode 100644
index 6e7cfd9..0000000
--- a/device_access/device_access/private/src/device_manager.c
+++ /dev/null
@@ -1,570 +0,0 @@
-/**
- *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.
- */
-/*
- * device_manager.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <constants.h>
-#include <string.h>
-
-#include "device_manager.h"
-#include "driver_locator.h"
-#include "driver_matcher.h"
-#include "driver_attributes.h"
-#include "driver_loader.h"
-#include "driver.h"
-#include "device.h"
-#include "log_service.h"
-
-
-#include <bundle.h>
-#include <module.h>
-#include <array_list.h>
-#include <service_registry.h>
-#include <service_reference.h>
-
-struct device_manager {
-	bundle_context_pt context;
-	hash_map_pt devices;
-	hash_map_pt drivers;
-	array_list_pt locators;
-	driver_selector_service_pt selector;
-	log_helper_pt loghelper;
-};
-
-static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, service_reference_pt ref, void *service);
-static celix_status_t deviceManager_getIdleDevices(device_manager_pt manager, array_list_pt *idleDevices);
-static celix_status_t deviceManager_isDriverBundle(device_manager_pt manager, bundle_pt bundle, bool *isDriver);
-
-celix_status_t deviceManager_create(bundle_context_pt context, log_helper_pt logHelper, device_manager_pt *manager) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*manager = calloc(1, sizeof(**manager));
-	if (!*manager) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*manager)->context = context;
-		(*manager)->devices = NULL;
-		(*manager)->drivers = NULL;
-		(*manager)->locators = NULL;
-		(*manager)->selector = NULL;
-
-		(*manager)->devices = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
-		(*manager)->drivers = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
-
-		(*manager)->loghelper = logHelper;
-
-		status = arrayList_create(&(*manager)->locators);
-
-		logHelper_log((*manager)->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Initialized");
-	}
-
-
-	return status;
-}
-
-celix_status_t deviceManager_destroy(device_manager_pt manager) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Stop");
-
-	hashMap_destroy(manager->devices, false, false);
-	hashMap_destroy(manager->drivers, false, false);
-	arrayList_destroy(manager->locators);
-
-	return status;
-}
-
-celix_status_t deviceManager_selectorAdded(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add selector");
-
-	manager->selector = (driver_selector_service_pt) service;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_selectorModified(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify selector");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_selectorRemoved(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove selector");
-	manager->selector = NULL;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_locatorAdded(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add locator");
-	arrayList_add(manager->locators, service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_locatorModified(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify locator");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_locatorRemoved(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove locator");
-	arrayList_removeElement(manager->locators, service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_deviceAdded(void * handle, service_reference_pt ref, void * service) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add device");
-	status = deviceManager_attachAlgorithm(manager, ref, service);
-
-	return status;
-}
-
-static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, service_reference_pt ref, void *service) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	driver_loader_pt loader = NULL;
-	status = driverLoader_create(manager->context, &loader);
-	if (status == CELIX_SUCCESS) {
-		array_list_pt included = NULL;
-		array_list_pt excluded = NULL;
-
-		array_list_pt driverIds = NULL;
-
-		hashMap_put(manager->devices, ref, service);
-
-		status = arrayList_create(&included);
-		if (status == CELIX_SUCCESS) {
-			status = arrayList_create(&excluded);
-			if (status == CELIX_SUCCESS) {
-				properties_pt properties = properties_create();
-
-				unsigned int size = 0;
-				char **keys;
-
-				serviceReference_getPropertyKeys(ref, &keys, &size);
-				for (int i = 0; i < size; i++) {
-					char* key = keys[i];
-					const char* value = NULL;
-					serviceReference_getProperty(ref, key, &value);
-					properties_set(properties, key, value);
-				}
-
-				status = driverLoader_findDrivers(loader, manager->locators, properties, &driverIds);
-				if (status == CELIX_SUCCESS) {
-					hash_map_iterator_pt iter = hashMapIterator_create(manager->drivers);
-					while (hashMapIterator_hasNext(iter)) {
-						driver_attributes_pt driverAttributes = hashMapIterator_nextValue(iter);
-						arrayList_add(included, driverAttributes);
-
-						// Each driver that already is installed can be removed from the list
-						char *id = NULL;
-						celix_status_t substatus = driverAttributes_getDriverId(driverAttributes, &id);
-						if (substatus == CELIX_SUCCESS) {
-							// arrayList_removeElement(driverIds, id);
-							array_list_iterator_pt idsIter = arrayListIterator_create(driverIds);
-							while (arrayListIterator_hasNext(idsIter)) {
-								char *value = arrayListIterator_next(idsIter);
-								if (strcmp(value, id) == 0) {
-									arrayListIterator_remove(idsIter);
-								}
-							}
-							arrayListIterator_destroy(idsIter);
-						}
-						if(id != NULL){
-							free(id);
-						}
-					}
-					hashMapIterator_destroy(iter);
-
-					status = deviceManager_matchAttachDriver(manager, loader, driverIds, included, excluded, service, ref);
-
-				}
-				arrayList_destroy(driverIds);
-				properties_destroy(properties);
-				arrayList_destroy(excluded);
-			}
-			arrayList_destroy(included);
-		}
-
-	}
-
-	driverLoader_destroy(&loader);
-	return status;
-}
-
-celix_status_t deviceManager_matchAttachDriver(device_manager_pt manager, driver_loader_pt loader,
-		array_list_pt driverIds, array_list_pt included, array_list_pt excluded, void *service, service_reference_pt reference) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt references = NULL;
-
-	int i;
-	for (i = 0; i < arrayList_size(excluded); i++) {
-		void *exclude = arrayList_get(excluded, i);
-		arrayList_removeElement(included, exclude);
-	}
-
-	for (i = 0; i < arrayList_size(driverIds); i++) {
-		char *id = arrayList_get(driverIds, i);
-		logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Driver found: %s", id);
-	}
-
-	status = driverLoader_loadDrivers(loader, manager->locators, driverIds, &references);
-	if (status == CELIX_SUCCESS) {
-		for (i = 0; i < arrayList_size(references); i++) {
-			service_reference_pt reference = arrayList_get(references, i);
-			driver_attributes_pt attributes = hashMap_get(manager->drivers, reference);
-			if (attributes != NULL) {
-				arrayList_add(included, attributes);
-			}
-		}
-
-		driver_matcher_pt matcher = NULL;
-		status = driverMatcher_create(manager->context, &matcher);
-		if (status == CELIX_SUCCESS) {
-			for (i = 0; i < arrayList_size(included); i++) {
-				driver_attributes_pt attributes = arrayList_get(included, i);
-
-				int match = 0;
-				celix_status_t substatus = driverAttributes_match(attributes, reference, &match);
-				if (substatus == CELIX_SUCCESS) {
-					logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Found match: %d", match);
-					if (match <= OSGI_DEVICEACCESS_DEVICE_MATCH_NONE) {
-						continue;
-					}
-					driverMatcher_add(matcher, match, attributes);
-				} else {
-					// Ignore
-				}
-			}
-
-			match_pt match = NULL;
-			status = driverMatcher_getBestMatch(matcher, reference, &match);
-			if (status == CELIX_SUCCESS) {
-				if (match == NULL) {
-					status = deviceManager_noDriverFound(manager, service, reference);
-				} else {
-                    driver_attributes_pt finalAttributes = hashMap_get(manager->drivers, match->reference);
-                    if (finalAttributes == NULL) {
-                        status = deviceManager_noDriverFound(manager, service, reference);
-                    } else {
-                        char *newDriverId = NULL;
-                        status = driverAttributes_attach(finalAttributes, reference, &newDriverId);
-                        if (status == CELIX_SUCCESS) {
-                            if (newDriverId != NULL) {
-                                array_list_pt ids = NULL;
-                                arrayList_create(&ids);
-                                arrayList_add(ids, newDriverId);
-                                arrayList_add(excluded, finalAttributes);
-                                status = deviceManager_matchAttachDriver(manager, loader,
-                                        ids, included, excluded, service, reference);
-                            } else {
-                                // Attached, unload unused drivers
-                                status = driverLoader_unloadDrivers(loader, finalAttributes);
-                            }
-                        }
-					}
-				}
-			}
-		}
-
-		driverMatcher_destroy(&matcher);
-
-	}
-
-	if (references != NULL) {
-		arrayList_destroy(references);
-	}
-
-	return status;
-}
-
-celix_status_t deviceManager_noDriverFound(device_manager_pt manager, void *service, service_reference_pt reference) {
-	celix_status_t status = CELIX_SUCCESS;
-    const char* objectClass = NULL;
-    serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &objectClass);
-    if (strcmp(objectClass, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME) == 0) {
-        device_service_pt device = service;
-        status = device->noDriverFound(device->device);
-    }
-	return status;
-}
-
-celix_status_t deviceManager_deviceModified(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify device");
-	// #TODO the device properties could be changed
-	//hashMap_put(manager->devices, ref, service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_deviceRemoved(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove device");
-	hashMap_remove(manager->devices, ref);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_driverAdded(void * handle, service_reference_pt ref, void * service) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add driver");
-	driver_attributes_pt attributes = NULL;
-
-	status = driverAttributes_create(ref, service, &attributes);
-	if (status == CELIX_SUCCESS) {
-		hashMap_put(manager->drivers, ref, attributes);
-	}
-	else{
-		driverAttributes_destroy(attributes);
-	}
-	return status;
-}
-
-celix_status_t deviceManager_driverModified(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify driver");
-	// #TODO the driver properties could be changed?
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_driverRemoved(void * handle, service_reference_pt ref, void * service) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove driver");
-
-	hashMap_remove(manager->drivers, ref);
-
-	array_list_pt idleDevices = NULL;
-	status = deviceManager_getIdleDevices(manager, &idleDevices);
-	if (status == CELIX_SUCCESS) {
-		int i;
-		for (i = 0; i < arrayList_size(idleDevices); i++) {
-			celix_status_t forStatus = CELIX_SUCCESS;
-			service_reference_pt ref = arrayList_get(idleDevices, i);
-			const char *bsn = NULL;
-			bundle_pt bundle = NULL;
-			forStatus = serviceReference_getBundle(ref, &bundle);
-			if (forStatus == CELIX_SUCCESS) {
-				module_pt module = NULL;
-				forStatus = bundle_getCurrentModule(bundle, &module);
-				if (forStatus == CELIX_SUCCESS) {
-					forStatus = module_getSymbolicName(module, &bsn);
-					if (forStatus == CELIX_SUCCESS) {
-						logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: IDLE: %s", bsn);
-						// #TODO attachDriver (idle device)
-						// #TODO this can result in a loop?
-						//		Locate and install a driver
-						//		Let the match fail, the device is idle
-						//		The driver is removed, idle check is performed
-						//		Attach is tried again
-						//		.. loop ..
-						void *device = hashMap_get(manager->devices, ref);
-						forStatus = deviceManager_attachAlgorithm(manager, ref, device);
-					}
-				}
-			}
-
-			if (forStatus != CELIX_SUCCESS) {
-				break; //Got error, stop loop and return status
-			}
-		}
-
-
-		hash_map_iterator_pt iter = hashMapIterator_create(manager->drivers);
-		while (hashMapIterator_hasNext(iter)) {
-			hashMapIterator_nextValue(iter);
-//			driver_attributes_pt da = hashMapIterator_nextValue(iter);
-//			driverAttributes_tryUninstall(da);
-		}
-		hashMapIterator_destroy(iter);
-	}
-
-	if (idleDevices != NULL) {
-		arrayList_destroy(idleDevices);
-	}
-
-	return status;
-}
-
-
-celix_status_t deviceManager_getIdleDevices(device_manager_pt manager, array_list_pt *idleDevices) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = arrayList_create(idleDevices);
-	if (status == CELIX_SUCCESS) {
-		hash_map_iterator_pt iter = hashMapIterator_create(manager->devices);
-		while (hashMapIterator_hasNext(iter)) {
-			celix_status_t substatus = CELIX_SUCCESS;
-			service_reference_pt ref = hashMapIterator_nextKey(iter);
-			const char *bsn = NULL;
-			module_pt module = NULL;
-			bundle_pt bundle = NULL;
-			substatus = serviceReference_getBundle(ref, &bundle);
-			if (substatus == CELIX_SUCCESS) {
-				substatus = bundle_getCurrentModule(bundle, &module);
-				if (substatus == CELIX_SUCCESS) {
-					substatus = module_getSymbolicName(module, &bsn);
-					if (substatus == CELIX_SUCCESS) {
-						logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Check idle device: %s", bsn);
-						array_list_pt bundles = NULL;
-						substatus = serviceReference_getUsingBundles(ref, &bundles);
-						if (substatus == CELIX_SUCCESS) {
-							bool inUse = false;
-							int i;
-							for (i = 0; i < arrayList_size(bundles); i++) {
-								bundle_pt bundle = arrayList_get(bundles, i);
-								bool isDriver;
-								celix_status_t sstatus = deviceManager_isDriverBundle(manager, bundle, &isDriver);
-								if (sstatus == CELIX_SUCCESS) {
-									if (isDriver) {
-										const char *bsn = NULL;
-										module_pt module = NULL;
-										bundle_getCurrentModule(bundle, &module);
-										module_getSymbolicName(module, &bsn);
-
-										logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Not idle, used by driver: %s", bsn);
-
-										inUse = true;
-										break;
-									}
-								}
-							}
-
-							if (!inUse) {
-								arrayList_add(*idleDevices, ref);
-							}
-						}
-
-						if(bundles!=NULL){
-							arrayList_destroy(bundles);
-						}
-					}
-				}
-			}
-		}
-		hashMapIterator_destroy(iter);
-	}
-
-	return status;
-}
-
-//TODO examply for discussion only, remove after discussion
-#define DO_IF_SUCCESS(status, call_func) ((status) == CELIX_SUCCESS) ? (call_func) : (status)
-celix_status_t deviceManager_getIdleDevices_exmaple(device_manager_pt manager, array_list_pt *idleDevices) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = arrayList_create(idleDevices);
-	if (status == CELIX_SUCCESS) {
-		hash_map_iterator_pt iter = hashMapIterator_create(manager->devices);
-		while (hashMapIterator_hasNext(iter)) {
-			celix_status_t substatus = CELIX_SUCCESS;
-			service_reference_pt ref = hashMapIterator_nextKey(iter);
-			const char *bsn = NULL;
-			module_pt module = NULL;
-			bundle_pt bundle = NULL;
-			array_list_pt bundles = NULL;
-			substatus = serviceReference_getBundle(ref, &bundle);
-			substatus = DO_IF_SUCCESS(substatus, bundle_getCurrentModule(bundle, &module));
-			substatus = DO_IF_SUCCESS(substatus, module_getSymbolicName(module, &bsn));
-			substatus = DO_IF_SUCCESS(substatus, serviceReference_getUsingBundles(ref, &bundles));
-
-			if (substatus == CELIX_SUCCESS) {
-				logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Check idle device: %s", bsn);
-				bool inUse = false;
-				int i;
-				for (i = 0; i < arrayList_size(bundles); i++) {
-					bundle_pt bundle = arrayList_get(bundles, i);
-					bool isDriver;
-					celix_status_t sstatus = deviceManager_isDriverBundle(manager, bundle, &isDriver);
-					if (sstatus == CELIX_SUCCESS) {
-						if (isDriver) {
-							const char *bsn = NULL;
-							module_pt module = NULL;
-							bundle_getCurrentModule(bundle, &module);
-							module_getSymbolicName(module, &bsn);
-
-							logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Not idle, used by driver: %s", bsn);
-
-							inUse = true;
-							break;
-						}
-					}
-				}
-
-				if (!inUse) {
-					arrayList_add(*idleDevices, ref);
-				}
-			}
-		}
-		hashMapIterator_destroy(iter);
-	}
-	return status;
-}
-
-celix_status_t deviceManager_isDriverBundle(device_manager_pt manager, bundle_pt bundle, bool *isDriver) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*isDriver) = false;
-
-	array_list_pt refs = NULL;
-		status = bundle_getRegisteredServices(bundle, &refs);
-		if (status == CELIX_SUCCESS) {
-			if (refs != NULL) {
-				int i;
-				for (i = 0; i < arrayList_size(refs); i++) {
-					service_reference_pt ref = arrayList_get(refs, i);
-                    const char* object = NULL;
-                    serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &object);
-                    if (strcmp(object, "driver") == 0) {
-                        *isDriver = true;
-                        break;
-                    }
-				}
-				arrayList_destroy(refs);
-			}
-		}
-
-	return status;
-}
-
-
-celix_status_t deviceManager_getBundleContext(device_manager_pt manager, bundle_context_pt *context) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (manager->context != NULL) {
-		(*context) = manager->context;
-	} else {
-		status = CELIX_INVALID_BUNDLE_CONTEXT;
-	}
-	return status;
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/driver_attributes.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/driver_attributes.c b/device_access/device_access/private/src/driver_attributes.c
deleted file mode 100644
index 5ac7fda..0000000
--- a/device_access/device_access/private/src/driver_attributes.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_attributes.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "driver_attributes.h"
-#include "bundle.h"
-#include "celixbool.h"
-#include "driver_loader.h"
-#include "device.h"
-#include "constants.h"
-
-struct driver_attributes {
-	bundle_pt bundle;
-	service_reference_pt reference;
-	driver_service_pt driver;
-	bool dynamic;
-};
-
-celix_status_t driverAttributes_create(service_reference_pt reference, driver_service_pt driver, driver_attributes_pt *attributes) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*attributes = calloc(1, sizeof(**attributes));
-	if (!*attributes) {
-		status = CELIX_ENOMEM;
-	} else {
-		bundle_pt bundle = NULL;
-		bundle_archive_pt bundleArchive = NULL;
-		status = serviceReference_getBundle(reference, &bundle);
-
-		if (status == CELIX_SUCCESS) {
-			status = bundle_getArchive(bundle, &bundleArchive);
-
-			if (status == CELIX_SUCCESS) {
-				(*attributes)->reference = reference;
-				(*attributes)->driver = driver;
-				(*attributes)->bundle = bundle;
-
-				const char *location;
-				status = bundleArchive_getLocation(bundleArchive, &location);
-				if (status == CELIX_SUCCESS) {
-					(*attributes)->dynamic = strncmp(location, DRIVER_LOCATION_PREFIX, 4) == 0 ? true : false;
-				}
-
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverAttributes_destroy(driver_attributes_pt attributes){
-	if(attributes != NULL){
-		free(attributes);
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t driverAttributes_getReference(driver_attributes_pt driverAttributes, service_reference_pt *reference) {
-	*reference = driverAttributes->reference;
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t driverAttributes_getDriverId(driver_attributes_pt driverAttributes, char **driverId) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    const char* id_prop = NULL;
-    status = serviceReference_getProperty(driverAttributes->reference, "DRIVER_ID", &id_prop);
-    if (status == CELIX_SUCCESS) {
-        if (!id_prop) {
-            status = CELIX_ENOMEM;
-        } else {
-            *driverId = strdup(id_prop);
-
-            if (*driverId == NULL) {
-                status = CELIX_ENOMEM;
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverAttributes_match(driver_attributes_pt driverAttributes, service_reference_pt reference, int *match) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = driverAttributes->driver->match(driverAttributes->driver->driver, reference, match);
-
-	return status;
-}
-
-celix_status_t driverAttributes_isInUse(driver_attributes_pt driverAttributes, bool *inUse) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt references = NULL;
-	status = bundle_getServicesInUse(driverAttributes->bundle, &references);
-	if (status == CELIX_SUCCESS) {
-		if (references == NULL || arrayList_size(references) == 0) {
-			*inUse = false;
-		} else {
-			int i;
-			for (i = 0; i < arrayList_size(references); i++) {
-				service_reference_pt ref = arrayList_get(references, i);
-				const char *object = NULL;
-				status = serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &object);
-
-				if (status == CELIX_SUCCESS) {
-					const char* category = NULL;
-					status = serviceReference_getProperty(ref, "DEVICE_CATEGORY", &category);
-
-					if (status == CELIX_SUCCESS) {
-						if ((object != NULL && strcmp(object, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME) == 0) || (category != NULL)) {
-							*inUse = true;
-						}
-					}
-				}
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverAttributes_attach(driver_attributes_pt driverAttributes, service_reference_pt reference, char **attach) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = driverAttributes->driver->attach(driverAttributes->driver->driver, reference, attach);
-
-	return status;
-}
-
-celix_status_t driverAttributes_tryUninstall(driver_attributes_pt driverAttributes) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bool inUse = false;
-
-	status = driverAttributes_isInUse(driverAttributes, &inUse);
-	if (status == CELIX_SUCCESS) {
-		if (!inUse && driverAttributes->dynamic) {
-			status = bundle_uninstall(driverAttributes->bundle);
-		}
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/driver_loader.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/driver_loader.c b/device_access/device_access/private/src/driver_loader.c
deleted file mode 100644
index c4caa65..0000000
--- a/device_access/device_access/private/src/driver_loader.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_loader.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "driver_loader.h"
-#include "bundle_context.h"
-#include "bundle.h"
-
-struct driver_loader {
-	bundle_context_pt context;
-	array_list_pt loadedDrivers;
-};
-
-celix_status_t driverLoader_create(bundle_context_pt context, driver_loader_pt *loader) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*loader = calloc(1, sizeof(**loader));
-	if (!*loader) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*loader)->context = context;
-		(*loader)->loadedDrivers = NULL;
-		status = arrayList_create(&(*loader)->loadedDrivers);
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_destroy(driver_loader_pt *loader) {
-	if((*loader) != NULL){
-		arrayList_destroy((*loader)->loadedDrivers);
-		free((*loader));
-		(*loader)=NULL;
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t driverLoader_findDrivers(driver_loader_pt loader, array_list_pt locators, properties_pt properties, array_list_pt *driversIds) {
-	celix_status_t status = CELIX_SUCCESS;
-	arrayList_create(driversIds);
-
-	int i;
-	for (i = 0; i < arrayList_size(locators); i++) {
-		array_list_pt drivers;
-		driver_locator_service_pt locator = arrayList_get(locators, i);
-
-		status = driverLoader_findDriversForLocator(loader, locator, properties, &drivers);
-		if (status == CELIX_SUCCESS) {
-			arrayList_addAll(*driversIds, drivers);
-		}
-		arrayList_destroy(drivers);
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_findDriversForLocator(driver_loader_pt loader, driver_locator_service_pt locator, properties_pt properties, array_list_pt *driversIds) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = locator->findDrivers(locator->locator, properties, driversIds);
-
-	return status;
-}
-
-celix_status_t driverLoader_loadDrivers(driver_loader_pt loader, array_list_pt locators, array_list_pt driverIds, array_list_pt *references) {
-	celix_status_t status = CELIX_SUCCESS;
-	status = arrayList_create(references);
-	if (status == CELIX_SUCCESS) {
-		int i;
-		for (i = 0; i < arrayList_size(driverIds); i++) {
-			array_list_pt refs = NULL;
-			char *id = arrayList_get(driverIds, i);
-
-			status = driverLoader_loadDriver(loader, locators, id, &refs);
-			if (status == CELIX_SUCCESS) {
-				arrayList_addAll(*references, refs);
-			}
-			if (refs != NULL) {
-				arrayList_destroy(refs);
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_loadDriver(driver_loader_pt loader, array_list_pt locators, char *driverId, array_list_pt *references) {
-	celix_status_t status = CELIX_SUCCESS;
-	status = arrayList_create(references);
-	if (status == CELIX_SUCCESS) {
-		int i;
-		for (i = 0; i < arrayList_size(locators); i++) {
-			array_list_pt refs = NULL;
-			driver_locator_service_pt locator = arrayList_get(locators, i);
-
-			status = driverLoader_loadDriverForLocator(loader, locator, driverId, &refs);
-			if (status == CELIX_SUCCESS) {
-				arrayList_addAll(*references, refs);
-			}
-
-			if (refs != NULL) {
-				arrayList_destroy(refs);
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_loadDriverForLocator(driver_loader_pt loader, driver_locator_service_pt locator, char *driverId, array_list_pt *references) {
-	celix_status_t status = CELIX_SUCCESS;
-	//The list is created in the bundle_getRegisteredServices chain
-	//arrayList_create(references);
-
-	char *filename = NULL;
-	status = locator->loadDriver(locator->locator, driverId, &filename);
-	if (status == CELIX_SUCCESS) {
-		bundle_pt bundle = NULL;
-		int length = strlen(DRIVER_LOCATION_PREFIX) + strlen(driverId);
-		char location[length+2];
-		snprintf(location, length+2, "%s%s", DRIVER_LOCATION_PREFIX, driverId);
-		status = bundleContext_installBundle2(loader->context, location, filename, &bundle);
-		if (status == CELIX_SUCCESS) {
-			status = bundle_start(bundle);
-			if (status == CELIX_SUCCESS) {
-				status = bundle_getRegisteredServices(bundle, references);
-				if (status == CELIX_SUCCESS) {
-					arrayList_addAll(loader->loadedDrivers, *references);
-				}
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_unloadDrivers(driver_loader_pt loader, driver_attributes_pt finalDriver) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_reference_pt finalReference = NULL;
-	if (finalDriver != NULL) {
-		status = driverAttributes_getReference(finalDriver, &finalReference);
-	}
-	if (status == CELIX_SUCCESS) {
-		int i;
-		for (i = 0; i < arrayList_size(loader->loadedDrivers); i++) {
-			service_reference_pt reference = arrayList_get(loader->loadedDrivers, i);
-			bool equal = false;
-			status = serviceReference_equals(reference, finalReference, &equal);
-			if (status == CELIX_SUCCESS && !equal) {
-				bundle_pt bundle = NULL;
-				status = serviceReference_getBundle(reference, &bundle);
-				if (status == CELIX_SUCCESS) {
-					bundle_uninstall(bundle); // Ignore status
-				}
-			}
-		}
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/driver_matcher.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/driver_matcher.c b/device_access/device_access/private/src/driver_matcher.c
deleted file mode 100644
index c7597d3..0000000
--- a/device_access/device_access/private/src/driver_matcher.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_matcher.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "hash_map.h"
-#include "constants.h"
-
-#include "driver_matcher.h"
-#include "log_helper.h"
-#include "log_service.h"
-
-
-struct driver_matcher {
-	hash_map_pt attributes;
-	array_list_pt matches;
-	log_helper_pt loghelper;
-
-	bundle_context_pt context;
-};
-
-typedef struct match_key {
-	int matchValue;
-}*match_key_t;
-
-static celix_status_t driverMatcher_get(driver_matcher_pt matcher, int key, array_list_pt *attributesV);
-static celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, match_pt *match);
-
-unsigned int driverMatcher_matchKeyHash(const void* match_key) {
-	match_key_t key = (match_key_t) match_key;
-
-	return key->matchValue;
-}
-
-int driverMatcher_matchKeyEquals(const void* key, const void* toCompare) {
-	return ((match_key_t) key)->matchValue == ((match_key_t) toCompare)->matchValue;
-}
-
-celix_status_t driverMatcher_create(bundle_context_pt context, driver_matcher_pt *matcher) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*matcher = calloc(1, sizeof(**matcher));
-	if (!*matcher) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*matcher)->matches = NULL;
-		(*matcher)->context = context;
-		(*matcher)->attributes = hashMap_create(driverMatcher_matchKeyHash, NULL, driverMatcher_matchKeyEquals, NULL);
-
-		arrayList_create(&(*matcher)->matches);
-
-		if(logHelper_create(context, &(*matcher)->loghelper) == CELIX_SUCCESS) {
-			logHelper_start((*matcher)->loghelper);
-		}
-
-	}
-
-	return status;
-}
-
-celix_status_t driverMatcher_destroy(driver_matcher_pt *matcher) {
-
-	if((*matcher) != NULL){
-
-		int i = 0;
-
-		for(;i<arrayList_size((*matcher)->matches);i++){
-			free(arrayList_get((*matcher)->matches,i));
-		}
-		arrayList_destroy((*matcher)->matches);
-
-		hash_map_iterator_pt iter = hashMapIterator_create((*matcher)->attributes);
-		while (hashMapIterator_hasNext(iter)) {
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-			match_key_t match = (match_key_t)hashMapEntry_getKey(entry);
-			array_list_pt list = (array_list_pt)hashMapEntry_getValue(entry);
-			free(match);
-			if (list != NULL) {
-				arrayList_destroy(list);
-			}
-		}
-		hashMapIterator_destroy(iter);
-		hashMap_destroy((*matcher)->attributes, false, false);
-
-		logHelper_stop((*matcher)->loghelper);
-		logHelper_destroy(&(*matcher)->loghelper);
-
-		free(*matcher);
-	}
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t driverMatcher_add(driver_matcher_pt matcher, int matchValue, driver_attributes_pt attributes) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt da = NULL;
-	status = driverMatcher_get(matcher, matchValue, &da);
-	if (status == CELIX_SUCCESS) {
-		arrayList_add(da, attributes);
-
-		match_pt match = NULL;
-		match = calloc(1, sizeof(*match));
-		if (!match) {
-			status = CELIX_ENOMEM;
-		} else {
-			match->matchValue = matchValue;
-			match->reference = NULL;
-			driverAttributes_getReference(attributes, &match->reference);
-			arrayList_add(matcher->matches, match);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverMatcher_get(driver_matcher_pt matcher, int key, array_list_pt *attributes) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	match_key_t matchKeyS = calloc(1, sizeof(*matchKeyS));
-	matchKeyS->matchValue = key;
-
-	*attributes = hashMap_get(matcher->attributes, matchKeyS);
-	if (*attributes == NULL) {
-		arrayList_create(attributes);
-		match_key_t matchKey = calloc(1, sizeof(*matchKey));
-		matchKey->matchValue = key;
-		hashMap_put(matcher->attributes, matchKey, *attributes);
-	}
-
-	free(matchKeyS);
-
-	return status;
-}
-
-celix_status_t driverMatcher_getBestMatch(driver_matcher_pt matcher, service_reference_pt reference, match_pt *match) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (*match != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		service_reference_pt selectorRef = NULL;
-		status = bundleContext_getServiceReference(matcher->context, OSGI_DEVICEACCESS_DRIVER_SELECTOR_SERVICE_NAME, &selectorRef);
-		if (status == CELIX_SUCCESS) {
-			int index = -1;
-			if (selectorRef != NULL) {
-				driver_selector_service_pt selector = NULL;
-				status = bundleContext_getService(matcher->context, selectorRef, (void **) &selector);
-				if (status == CELIX_SUCCESS) {
-					if (selector != NULL) {
-						int size = -1;
-						status = selector->driverSelector_select(selector->selector, reference, matcher->matches, &index);
-						if (status == CELIX_SUCCESS) {
-							size = arrayList_size(matcher->matches);
-							if (index != -1 && index >= 0 && index < size) {
-								*match = arrayList_get(matcher->matches, index);
-							}
-						}
-					}
-				}
-			}
-			if (status == CELIX_SUCCESS && *match == NULL) {
-				status = driverMatcher_getBestMatchInternal(matcher, match);
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, match_pt *match) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!hashMap_isEmpty(matcher->attributes)) {
-		match_key_t matchKey = NULL;
-		hash_map_iterator_pt iter = hashMapIterator_create(matcher->attributes);
-		while (hashMapIterator_hasNext(iter)) {
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-			match_key_t key = hashMapEntry_getKey(entry);
-			if (matchKey == NULL || matchKey->matchValue < key->matchValue) {
-				matchKey = key;
-			}
-		}
-		hashMapIterator_destroy(iter);
-
-		array_list_pt das = hashMap_get(matcher->attributes, matchKey);
-		service_reference_pt best = NULL;
-		int i;
-		for (i = 0; i < arrayList_size(das); i++) {
-			driver_attributes_pt attributes = arrayList_get(das, i);
-			service_reference_pt reference = NULL;
-
-			celix_status_t substatus = driverAttributes_getReference(attributes, &reference);
-			if (substatus == CELIX_SUCCESS) {
-				if (best != NULL) {
-					const char* rank1Str;
-					const char* rank2Str;
-					int rank1, rank2;
-
-					rank1Str = "0";
-					rank2Str = "0";
-
-					logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare ranking");
-
-					serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank1Str);
-					serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank2Str);
-
-					rank1 = atoi(rank1Str);
-					rank2 = atoi(rank2Str);
-
-					if (rank1 != rank2) {
-						if (rank1 > rank2) {
-							best = reference;
-						}
-					} else {
-						const char* id1Str;
-						const char* id2Str;
-						long id1, id2;
-
-						id1Str = NULL;
-						id2Str = NULL;
-
-						logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare id's");
-
-						serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &id1Str);
-						serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &id2Str);
-
-						id1 = atol(id1Str);
-						id2 = atol(id2Str);
-
-						if (id1 < id2) {
-							best = reference;
-						}
-					}
-				} else {
-					best = reference;
-				}
-			}
-
-		}
-
-		*match = calloc(1, sizeof(**match));
-		if (!*match) {
-			status = CELIX_ENOMEM;
-		} else {
-			(*match)->matchValue = matchKey->matchValue;
-			(*match)->reference = best;
-		}
-	}
-
-	return status;
-}


[09/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/pubsub/deploy/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/pubsub/deploy/CMakeLists.txt b/pubsub/deploy/CMakeLists.txt
index 5039aea..6f9234d 100644
--- a/pubsub/deploy/CMakeLists.txt
+++ b/pubsub/deploy/CMakeLists.txt
@@ -22,53 +22,53 @@ find_program(XTERM_CMD NAMES xterm)
 add_deploy(pubsub_publisher_udp_mc
 	GROUP pubsub
 	BUNDLES
-	   shell
-	   shell_tui
-	   org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	   org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	   org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	   org.apache.celix.pubsub_admin.PubSubAdminUdpMc
-	   org.apache.celix.pubsub_publisher.PoiPublisher
-	   org.apache.celix.pubsub_publisher.PoiPublisher2
+		Celix::shell
+	   	Celix::shell_tui
+	   	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	   	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	   	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	   	org.apache.celix.pubsub_admin.PubSubAdminUdpMc
+	   	org.apache.celix.pubsub_publisher.PoiPublisher
+	   	org.apache.celix.pubsub_publisher.PoiPublisher2
 )
 
 add_deploy("pubsub_subscriber_udp_mc"
 	GROUP "pubsub"
 	BUNDLES
-	   shell
-	   shell_tui
-	   org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	   org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	   org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	   org.apache.celix.pubsub_admin.PubSubAdminUdpMc
-	   org.apache.celix.pubsub_subscriber.PoiSubscriber
+		Celix::shell
+		Celix::shell_tui
+	   	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	  	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	   	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	   	org.apache.celix.pubsub_admin.PubSubAdminUdpMc
+	   	org.apache.celix.pubsub_subscriber.PoiSubscriber
 )
 
 add_deploy("pubsub_subscriber2_udp_mc"
 	GROUP "pubsub"
 	BUNDLES
-	   shell
-	   shell_tui
-	   org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	   org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	   org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	   org.apache.celix.pubsub_admin.PubSubAdminUdpMc
-	   org.apache.celix.pubsub_subscriber.PoiSubscriber
+		Celix::shell
+		Celix::shell_tui
+	   	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	   	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	   	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	   	org.apache.celix.pubsub_admin.PubSubAdminUdpMc
+	   	org.apache.celix.pubsub_subscriber.PoiSubscriber
 )
 
 if (ETCD_CMD AND XTERM_CMD)
 	#Runtime starting a publish and subscriber for udp mc
 	add_runtime(pubsub_rt_upd_mc
-			NAME udp_mc
-			GROUP pubsub
-			DEPLOYMENTS
+		NAME udp_mc
+		GROUP pubsub
+		DEPLOYMENTS
 			pubsub_publisher_udp_mc
 			pubsub_subscriber_udp_mc
 			pubsub_subscriber2_udp_mc
-			COMMANDS
+		COMMANDS
 			etcd
-			USE_TERM
-			)
+		USE_TERM
+	)
 endif ()
 
 if (BUILD_PUBSUB_PSA_ZMQ)
@@ -77,61 +77,61 @@ if (BUILD_PUBSUB_PSA_ZMQ)
 	add_deploy("pubsub_publisher"
 	    GROUP "pubsub"
 	    BUNDLES
-	       shell
-	       shell_tui
-	       org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	       org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	       org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	       org.apache.celix.pubsub_admin.PubSubAdminZmq
-	       org.apache.celix.pubsub_admin.PubSubAdminUdpMc
-	       org.apache.celix.pubsub_publisher.PoiPublisher
-	       org.apache.celix.pubsub_publisher.PoiPublisher2
+			Celix::shell
+			Celix::shell_tui
+	      	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	       	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	       	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	       	org.apache.celix.pubsub_admin.PubSubAdminZmq
+	       	org.apache.celix.pubsub_admin.PubSubAdminUdpMc
+	       	org.apache.celix.pubsub_publisher.PoiPublisher
+	       	org.apache.celix.pubsub_publisher.PoiPublisher2
 	    PROPERTIES
-	       poi1.psa=zmq
-	       poi2.psa=udp
+	       	poi1.psa=zmq
+	       	poi2.psa=udp
 	)
 
 	add_deploy("pubsub_subscriber"
 	    GROUP "pubsub"
 	    BUNDLES
-	       shell
-	       shell_tui
-	       org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	       org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	       org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	       org.apache.celix.pubsub_admin.PubSubAdminZmq
-	       org.apache.celix.pubsub_admin.PubSubAdminUdpMc
-	       org.apache.celix.pubsub_subscriber.PoiSubscriber
+			Celix::shell
+			Celix::shell_tui
+	       	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	       	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	       	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	       	org.apache.celix.pubsub_admin.PubSubAdminZmq
+	       	org.apache.celix.pubsub_admin.PubSubAdminUdpMc
+	       	org.apache.celix.pubsub_subscriber.PoiSubscriber
 	    PROPERTIES
-	       poi1.psa=zmq
-	       poi2.psa=udp
+	       	poi1.psa=zmq
+	       	poi2.psa=udp
 	)
 
 	# ZMQ
 	add_deploy("pubsub_zmq"
 	    GROUP "pubsub"
 	    BUNDLES
-	       shell
-	       shell_tui
-	       org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	       org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	       org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	       org.apache.celix.pubsub_admin.PubSubAdminZmq
-	       org.apache.celix.pubsub_publisher.PoiPublisher
-	       org.apache.celix.pubsub_subscriber.PoiSubscriber
+			Celix::shell
+			Celix::shell_tui
+	       	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	       	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	       	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	       	org.apache.celix.pubsub_admin.PubSubAdminZmq
+	       	org.apache.celix.pubsub_publisher.PoiPublisher
+	       	org.apache.celix.pubsub_subscriber.PoiSubscriber
 	)
 
 	add_deploy("pubsub_publisher_zmq"
 	    GROUP "pubsub"
 	    BUNDLES
-	       shell
-	       shell_tui
-	       org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	       org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	       org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	       org.apache.celix.pubsub_admin.PubSubAdminZmq
-	       org.apache.celix.pubsub_publisher.PoiPublisher
-	       org.apache.celix.pubsub_publisher.PoiPublisher2
+			Celix::shell
+			Celix::shell_tui
+	       	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	       	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	       	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	       	org.apache.celix.pubsub_admin.PubSubAdminZmq
+	       	org.apache.celix.pubsub_publisher.PoiPublisher
+	       	org.apache.celix.pubsub_publisher.PoiPublisher2
 	   	PROPERTIES
 		    pubsub.scope=my_small_scope
 	)
@@ -139,25 +139,25 @@ if (BUILD_PUBSUB_PSA_ZMQ)
 	add_deploy("pubsub_subscriber_zmq"
 	    GROUP "pubsub"
 	    BUNDLES
-	       shell
-	       shell_tui
-	       org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	       org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	       org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	       org.apache.celix.pubsub_admin.PubSubAdminZmq
-	       org.apache.celix.pubsub_subscriber.PoiSubscriber
+			Celix::shell
+			Celix::shell_tui
+	       	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	       	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	       	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	       	org.apache.celix.pubsub_admin.PubSubAdminZmq
+	       	org.apache.celix.pubsub_subscriber.PoiSubscriber
 	)
 
 	add_deploy("pubsub_subscriber2_zmq"
 	    GROUP "pubsub"
 	    BUNDLES
-	       shell
-	       shell_tui
-	       org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	       org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	       org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	       org.apache.celix.pubsub_admin.PubSubAdminZmq
-	       org.apache.celix.pubsub_subscriber.PoiSubscriber
+			Celix::shell
+			Celix::shell_tui
+	       	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	       	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	       	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	       	org.apache.celix.pubsub_admin.PubSubAdminZmq
+	       	org.apache.celix.pubsub_subscriber.PoiSubscriber
 
 	)
 
@@ -165,20 +165,20 @@ if (BUILD_PUBSUB_PSA_ZMQ)
 	add_deploy("pubsub_mp_subscriber_zmq"
 	    GROUP "pubsub"
 	    BUNDLES
-	       shell
-	       shell_tui
-	       org.apache.celix.pubsub_serializer.PubSubSerializerJson
-	       org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
-	       org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
-	       org.apache.celix.pubsub_admin.PubSubAdminZmq
-	       org.apache.celix.pubsub_subscriber.MpSubscriber
+			Celix::hell
+			Celix::shell_tui
+	       	org.apache.celix.pubsub_serializer.PubSubSerializerJson
+	       	org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+	       	org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+	       	org.apache.celix.pubsub_admin.PubSubAdminZmq
+	       	org.apache.celix.pubsub_subscriber.MpSubscriber
 	)
 
 	add_deploy("pubsub_mp_publisher_zmq"
 	    GROUP "pubsub"
 	    BUNDLES
-	   		shell
-	   		shell_tui
+			Celix::shell
+			Celix::shell_tui
 	   		org.apache.celix.pubsub_serializer.PubSubSerializerJson
 	   		org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
 	   		org.apache.celix.pubsub_topology_manager.PubSubTopologyManager

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/CMakeLists.txt b/remote_services/CMakeLists.txt
index d5d07a3..767ece7 100644
--- a/remote_services/CMakeLists.txt
+++ b/remote_services/CMakeLists.txt
@@ -17,17 +17,6 @@
 
 celix_subproject(REMOTE_SERVICE_ADMIN "Option to enable building the Remote Service Admin Service bundles" OFF)
 if (REMOTE_SERVICE_ADMIN)
-    # Add -fPIC for x86_64 Unix platforms; this lib will be linked to a shared lib
-    if(UNIX AND NOT WIN32)
-      find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
-      if(CMAKE_UNAME)
-        exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
-        set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64)")
-         if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
-          add_definitions(-fPIC)
-        endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
-      endif(CMAKE_UNAME)
-    endif(UNIX AND NOT WIN32)
 
     add_subdirectory(examples)
 
@@ -37,8 +26,8 @@ if (REMOTE_SERVICE_ADMIN)
     add_subdirectory(discovery_etcd)
     add_subdirectory(discovery_shm)
 
-    add_subdirectory(remote_service_admin_http)
-    add_subdirectory(remote_service_admin_shm)
+    #TODO refactor shm rsa to use dfi
+    #add_subdirectory(remote_service_admin_shm)
     add_subdirectory(remote_service_admin)
     add_subdirectory(remote_service_admin_dfi)
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_configured/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/discovery_configured/CMakeLists.txt b/remote_services/discovery_configured/CMakeLists.txt
index edbbc13..b9f849d 100644
--- a/remote_services/discovery_configured/CMakeLists.txt
+++ b/remote_services/discovery_configured/CMakeLists.txt
@@ -46,13 +46,12 @@ if (RSA_DISCOVERY_CONFIGURED)
 	${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_server.c
 	${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
 	${PROJECT_SOURCE_DIR}/remote_services/utils/private/src/civetweb.c
-
-	${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
     )
+    target_link_libraries(discovery_configured PRIVATE Celix::log_helper)
 
     install_bundle(discovery_configured)
 
-    target_link_libraries(discovery_configured celix_framework ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES})
+    target_link_libraries(discovery_configured PRIVATE ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES})
 
     if (RSA_ENDPOINT_TEST_READER)
         add_executable(descparser

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_etcd/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/CMakeLists.txt b/remote_services/discovery_etcd/CMakeLists.txt
index 442d486..b8955de 100644
--- a/remote_services/discovery_etcd/CMakeLists.txt
+++ b/remote_services/discovery_etcd/CMakeLists.txt
@@ -40,8 +40,8 @@ if (RSA_DISCOVERY_ETCD)
         SYMBOLIC_NAME "apache_celix_rsa_discovery_etcd"
         NAME "Apache Celix RSA Discovery ETCD"
         SOURCES
-		private/src/discovery_impl.c
-	    private/src/etcd_watcher.c
+		src/discovery_impl.c
+	    src/etcd_watcher.c
 		${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/discovery_activator.c
 		${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/discovery.c
 		${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_descriptor_reader.c
@@ -50,12 +50,12 @@ if (RSA_DISCOVERY_ETCD)
 		${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_server.c
 	    ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
 	    ${PROJECT_SOURCE_DIR}/remote_services/utils/private/src/civetweb.c
-	    
-	    ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
 	)
+	target_link_libraries(discovery_etcd PRIVATE Celix::log_helper)
+	target_include_directories(discovery_etcd PRIVATE src ../discovery/private/include)
 
 	install_bundle(discovery_etcd)
 		
-	target_link_libraries(discovery_etcd celix_framework etcdlib ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES} ${JANSSON_LIBRARIES})
+	target_link_libraries(discovery_etcd PRIVATE Celix::etcdlib ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES} ${JANSSON_LIBRARIES})
 
 endif (RSA_DISCOVERY_ETCD)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_etcd/private/include/discovery_impl.h
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/private/include/discovery_impl.h b/remote_services/discovery_etcd/private/include/discovery_impl.h
deleted file mode 100644
index a19b145..0000000
--- a/remote_services/discovery_etcd/private/include/discovery_impl.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- *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.
- */
-/*
- * discovery_impl.h
- *
- *  \date       Sep 29, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef DISCOVERY_IMPL_H_
-#define DISCOVERY_IMPL_H_
-
-#include "bundle_context.h"
-#include "service_reference.h"
-
-#include "endpoint_description.h"
-#include "endpoint_listener.h"
-
-#include "endpoint_discovery_poller.h"
-#include "endpoint_discovery_server.h"
-#include "etcd_watcher.h"
-
-#include "log_helper.h"
-
-#define DEFAULT_SERVER_IP 	"127.0.0.1"
-#define DEFAULT_SERVER_PORT "9999"
-#define DEFAULT_SERVER_PATH "/org.apache.celix.discovery.etcd"
-
-#define DEFAULT_POLL_ENDPOINTS ""
-
-#define FREE_MEM(ptr) if(ptr) {free(ptr); ptr = NULL;}
-
-struct discovery {
-	bundle_context_pt context;
-
-	celix_thread_mutex_t listenerReferencesMutex;
-	celix_thread_mutex_t discoveredServicesMutex;
-
-	hash_map_pt listenerReferences; //key=serviceReference, value=nop
-	hash_map_pt discoveredServices; //key=endpointId (string), value=endpoint_description_pt
-
-	etcd_watcher_pt watcher;
-	endpoint_discovery_poller_pt poller;
-	endpoint_discovery_server_pt server;
-
-	log_helper_pt loghelper;
-};
-
-#endif /* DISCOVERY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_etcd/private/include/etcd_watcher.h
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/private/include/etcd_watcher.h b/remote_services/discovery_etcd/private/include/etcd_watcher.h
deleted file mode 100644
index b4dbf40..0000000
--- a/remote_services/discovery_etcd/private/include/etcd_watcher.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.
- */
-/*
- * etcd_watcher.h
- *
- * \date       17 Sep 2014
- * \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright  Apache License, Version 2.0
- */
-
-#ifndef ETCD_WATCHER_H_
-#define ETCD_WATCHER_H_
-
-#include "celix_errno.h"
-#include "discovery.h"
-#include "endpoint_discovery_poller.h"
-
-typedef struct etcd_watcher *etcd_watcher_pt;
-
-celix_status_t etcdWatcher_create(discovery_pt discovery,  bundle_context_pt context, etcd_watcher_pt *watcher);
-celix_status_t etcdWatcher_destroy(etcd_watcher_pt watcher);
-
-
-#endif /* ETCD_WATCHER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_etcd/private/src/discovery_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/private/src/discovery_impl.c b/remote_services/discovery_etcd/private/src/discovery_impl.c
deleted file mode 100644
index 8087d95..0000000
--- a/remote_services/discovery_etcd/private/src/discovery_impl.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * 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.
- */
-/*
- * discovery_impl.c
- *
- * \date        Aug 8, 2014
- * \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <netdb.h>
-#include <netinet/in.h>
-
-#include "constants.h"
-#include "celix_threads.h"
-#include "bundle_context.h"
-#include "array_list.h"
-#include "utils.h"
-#include "celix_errno.h"
-#include "filter.h"
-#include "service_reference.h"
-#include "service_registration.h"
-#include "remote_constants.h"
-
-
-#include "discovery.h"
-#include "discovery_impl.h"
-#include "etcd_watcher.h"
-#include "endpoint_discovery_poller.h"
-#include "endpoint_discovery_server.h"
-
-
-
-celix_status_t discovery_create(bundle_context_pt context, discovery_pt *discovery) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*discovery = malloc(sizeof(struct discovery));
-	if (!*discovery) {
-		return CELIX_ENOMEM;
-	}
-
-	(*discovery)->context = context;
-	(*discovery)->poller = NULL;
-	(*discovery)->server = NULL;
-
-	(*discovery)->listenerReferences = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
-	(*discovery)->discoveredServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-
-	status = celixThreadMutex_create(&(*discovery)->listenerReferencesMutex, NULL);
-	status = celixThreadMutex_create(&(*discovery)->discoveredServicesMutex, NULL);
-
-	logHelper_create(context, &(*discovery)->loghelper);
-
-	return status;
-}
-
-
-
-celix_status_t discovery_destroy(discovery_pt discovery) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	discovery->context = NULL;
-	discovery->poller = NULL;
-	discovery->server = NULL;
-
-	celixThreadMutex_lock(&discovery->discoveredServicesMutex);
-
-	hashMap_destroy(discovery->discoveredServices, false, false);
-	discovery->discoveredServices = NULL;
-
-	celixThreadMutex_unlock(&discovery->discoveredServicesMutex);
-
-	celixThreadMutex_destroy(&discovery->discoveredServicesMutex);
-
-	celixThreadMutex_lock(&discovery->listenerReferencesMutex);
-
-	hashMap_destroy(discovery->listenerReferences, false, false);
-	discovery->listenerReferences = NULL;
-
-	celixThreadMutex_unlock(&discovery->listenerReferencesMutex);
-
-	celixThreadMutex_destroy(&discovery->listenerReferencesMutex);
-
-	logHelper_destroy(&discovery->loghelper);
-
-	free(discovery);
-
-	return status;
-}
-
-celix_status_t discovery_start(discovery_pt discovery) {
-    celix_status_t status = CELIX_SUCCESS;
-	const char *port = NULL;
-	const char *path = NULL;
-
-	logHelper_start(discovery->loghelper);
-
-	bundleContext_getProperty(discovery->context, DISCOVERY_SERVER_PORT, &port);
-	if (port == NULL) {
-		port = DEFAULT_SERVER_PORT;
-	}
-
-	bundleContext_getProperty(discovery->context, DISCOVERY_SERVER_PATH, &path);
-	if (path == NULL) {
-		path = DEFAULT_SERVER_PATH;
-	}
-
-    status = endpointDiscoveryPoller_create(discovery, discovery->context, &discovery->poller);
-    if (status != CELIX_SUCCESS) {
-    	return CELIX_BUNDLE_EXCEPTION;
-    }
-
-    status = endpointDiscoveryServer_create(discovery, discovery->context, &discovery->server);
-    if (status != CELIX_SUCCESS) {
-		return CELIX_BUNDLE_EXCEPTION;
-    }
-
-    status = etcdWatcher_create(discovery, discovery->context, &discovery->watcher);
-    if (status != CELIX_SUCCESS) {
-    	return CELIX_BUNDLE_EXCEPTION;
-    }
-    return status;
-}
-
-celix_status_t discovery_stop(discovery_pt discovery) {
-	celix_status_t status;
-
-	status = etcdWatcher_destroy(discovery->watcher);
-	if (status != CELIX_SUCCESS) {
-		return CELIX_BUNDLE_EXCEPTION;
-	}
-
-	status = endpointDiscoveryServer_destroy(discovery->server);
-	if (status != CELIX_SUCCESS) {
-		return CELIX_BUNDLE_EXCEPTION;
-	}
-
-	status = endpointDiscoveryPoller_destroy(discovery->poller);
-	if (status != CELIX_SUCCESS) {
-		return CELIX_BUNDLE_EXCEPTION;
-	}
-	hash_map_iterator_pt iter;
-
-	celixThreadMutex_lock(&discovery->discoveredServicesMutex);
-
-	iter = hashMapIterator_create(discovery->discoveredServices);
-	while (hashMapIterator_hasNext(iter)) {
-		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-		endpoint_description_pt endpoint = hashMapEntry_getValue(entry);
-
-		discovery_informEndpointListeners(discovery, endpoint, false);
-	}
-	hashMapIterator_destroy(iter);
-
-	celixThreadMutex_unlock(&discovery->discoveredServicesMutex);
-
-
-	logHelper_stop(discovery->loghelper);
-
-	return status;
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_etcd/private/src/etcd_watcher.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/private/src/etcd_watcher.c b/remote_services/discovery_etcd/private/src/etcd_watcher.c
deleted file mode 100644
index ebeac4f..0000000
--- a/remote_services/discovery_etcd/private/src/etcd_watcher.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/**
- * 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.
- */
-/*
- * etcd_watcher.c
- *
- * \date       16 Sep 2014
- * \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright  Apache License, Version 2.0
- */
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "log_helper.h"
-#include "log_service.h"
-#include "constants.h"
-#include "utils.h"
-#include "discovery.h"
-#include "discovery_impl.h"
-
-#include <curl/curl.h>
-#include "etcd.h"
-#include "etcd_watcher.h"
-
-#include "endpoint_discovery_poller.h"
-
-struct etcd_watcher {
-    discovery_pt discovery;
-    log_helper_pt* loghelper;
-    hash_map_pt entries;
-
-	celix_thread_mutex_t watcherLock;
-	celix_thread_t watcherThread;
-
-	volatile bool running;
-};
-
-
-#define MAX_ROOTNODE_LENGTH			128
-#define MAX_LOCALNODE_LENGTH		4096
-#define MAX_VALUE_LENGTH			256
-
-#define CFG_ETCD_ROOT_PATH			"DISCOVERY_ETCD_ROOT_PATH"
-#define DEFAULT_ETCD_ROOTPATH		"discovery"
-
-#define CFG_ETCD_SERVER_IP			"DISCOVERY_ETCD_SERVER_IP"
-#define DEFAULT_ETCD_SERVER_IP		"127.0.0.1"
-
-#define CFG_ETCD_SERVER_PORT		"DISCOVERY_ETCD_SERVER_PORT"
-#define DEFAULT_ETCD_SERVER_PORT 	2379
-
-// be careful - this should be higher than the curl timeout
-#define CFG_ETCD_TTL   				"DISCOVERY_ETCD_TTL"
-#define DEFAULT_ETCD_TTL 			30
-
-
-// note that the rootNode shouldn't have a leading slash
-static celix_status_t etcdWatcher_getRootPath(bundle_context_pt context, char* rootNode) {
-	celix_status_t status = CELIX_SUCCESS;
-	const char* rootPath = NULL;
-
-	if (((bundleContext_getProperty(context, CFG_ETCD_ROOT_PATH, &rootPath)) != CELIX_SUCCESS) || (!rootPath)) {
-		strncpy(rootNode, DEFAULT_ETCD_ROOTPATH, MAX_ROOTNODE_LENGTH);
-	}
-	else {
-		strncpy(rootNode, rootPath, MAX_ROOTNODE_LENGTH);
-	}
-
-	return status;
-}
-
-static celix_status_t etcdWatcher_getLocalNodePath(bundle_context_pt context, char* localNodePath) {
-	celix_status_t status = CELIX_SUCCESS;
-	char rootPath[MAX_ROOTNODE_LENGTH];
-    const char* uuid = NULL;
-
-    if ((etcdWatcher_getRootPath(context, rootPath) != CELIX_SUCCESS)) {
-		status = CELIX_ILLEGAL_STATE;
-    }
-	else if (((bundleContext_getProperty(context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid)) != CELIX_SUCCESS) || (!uuid)) {
-		status = CELIX_ILLEGAL_STATE;
-	}
-	else if (rootPath[strlen(rootPath) - 1] == '/') {
-    	snprintf(localNodePath, MAX_LOCALNODE_LENGTH, "%s%s", rootPath, uuid);
-    }
-    else {
-    	snprintf(localNodePath, MAX_LOCALNODE_LENGTH, "%s/%s", rootPath, uuid);
-    }
-
-    return status;
-}
-
-static void add_node(const char *key, const char *value, void* arg) {
-	discovery_pt discovery = (discovery_pt) arg;
-	endpointDiscoveryPoller_addDiscoveryEndpoint(discovery->poller, (char *) value);
-}
-
-/*
- * retrieves all already existing discovery endpoints
- * from etcd and adds them to the poller.
- *
- * returns the modifiedIndex of the last modified
- * discovery endpoint (see etcd documentation).
- */
-static celix_status_t etcdWatcher_addAlreadyExistingWatchpoints(discovery_pt discovery, long long* highestModified) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	char rootPath[MAX_ROOTNODE_LENGTH];
-	status = etcdWatcher_getRootPath(discovery->context, rootPath);
-
-	if (status == CELIX_SUCCESS) {
-		if(etcd_get_directory(rootPath, add_node, discovery, highestModified)) {
-			    status = CELIX_ILLEGAL_ARGUMENT;
-		}
-	}
-
-	return status;
-}
-
-
-static celix_status_t etcdWatcher_addOwnFramework(etcd_watcher_pt watcher)
-{
-    celix_status_t status = CELIX_BUNDLE_EXCEPTION;
-    char localNodePath[MAX_LOCALNODE_LENGTH];
-    char *value;
- 	char url[MAX_VALUE_LENGTH];
-    int modIndex;
-    char* endpoints = NULL;
-    const char* ttlStr = NULL;
-    int ttl;
-
-	bundle_context_pt context = watcher->discovery->context;
-	endpoint_discovery_server_pt server = watcher->discovery->server;
-
-    // register own framework
-    if ((status = etcdWatcher_getLocalNodePath(context, localNodePath)) != CELIX_SUCCESS) {
-        return status;
-    }
-
-	if (endpointDiscoveryServer_getUrl(server, url) != CELIX_SUCCESS) {
-		snprintf(url, MAX_VALUE_LENGTH, "http://%s:%s/%s", DEFAULT_SERVER_IP, DEFAULT_SERVER_PORT, DEFAULT_SERVER_PATH);
-	}
-
-	endpoints = url;
-
-    if ((bundleContext_getProperty(context, CFG_ETCD_TTL, &ttlStr) != CELIX_SUCCESS) || !ttlStr) {
-        ttl = DEFAULT_ETCD_TTL;
-    }
-    else
-    {
-        char* endptr = (char *) ttlStr;
-        errno = 0;
-        ttl = strtol(ttlStr, &endptr, 10);
-        if (*endptr || errno != 0) {
-            ttl = DEFAULT_ETCD_TTL;
-        }
-    }
-
-	if (etcd_get(localNodePath, &value, &modIndex) != true) {
-		etcd_set(localNodePath, endpoints, ttl, false);
-	}
-	else if (etcd_set(localNodePath, endpoints, ttl, true) == false)  {
-		logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_WARNING, "Cannot register local discovery");
-    }
-    else {
-        status = CELIX_SUCCESS;
-    }
-
-	FREE_MEM(value);
-
-    return status;
-}
-
-
-
-
-static celix_status_t etcdWatcher_addEntry(etcd_watcher_pt watcher, char* key, char* value) {
-	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
-	endpoint_discovery_poller_pt poller = watcher->discovery->poller;
-
-	if (!hashMap_containsKey(watcher->entries, key)) {
-		status = endpointDiscoveryPoller_addDiscoveryEndpoint(poller, value);
-
-		if (status == CELIX_SUCCESS) {
-			hashMap_put(watcher->entries, strdup(key), strdup(value));
-		}
-	}
-
-	return status;
-}
-
-static celix_status_t etcdWatcher_removeEntry(etcd_watcher_pt watcher, char* key, char* value) {
-	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
-	endpoint_discovery_poller_pt poller = watcher->discovery->poller;
-
-	hash_map_entry_pt entry = hashMap_getEntry(watcher->entries, key);
-
-	if (entry != NULL) {
-		void* origKey = hashMapEntry_getKey(entry);
-		void* value = hashMap_remove(watcher->entries, key);
-
-		free(origKey);
-
-		// check if there is another entry with the same value
-		hash_map_iterator_pt iter = hashMapIterator_create(watcher->entries);
-		unsigned int valueFound = 0;
-
-		while (hashMapIterator_hasNext(iter) && valueFound <= 1) {
-			if (strcmp(value, hashMapIterator_nextValue(iter)) == 0)
-				valueFound++;
-		}
-
-		hashMapIterator_destroy(iter);
-
-		if (valueFound == 0)
-			status = endpointDiscoveryPoller_removeDiscoveryEndpoint(poller, value);
-
-		free(value);
-
-	}
-
-	return status;
-
-}
-
-
-/*
- * performs (blocking) etcd_watch calls to check for
- * changing discovery endpoint information within etcd.
- */
-static void* etcdWatcher_run(void* data) {
-	etcd_watcher_pt watcher = (etcd_watcher_pt) data;
-	time_t timeBeforeWatch = time(NULL);
-	char rootPath[MAX_ROOTNODE_LENGTH];
-	long long highestModified = 0;
-
-	bundle_context_pt context = watcher->discovery->context;
-
-	etcdWatcher_addAlreadyExistingWatchpoints(watcher->discovery, &highestModified);
-	etcdWatcher_getRootPath(context, rootPath);
-
-	while (watcher->running) {
-
-		char *rkey = NULL;
-		char *value = NULL;
-		char *preValue = NULL;
-		char *action = NULL;
-		long long modIndex;
-
-        if (etcd_watch(rootPath, highestModified + 1, &action, &preValue, &value, &rkey, &modIndex) == 0 && action != NULL) {
-			if (strcmp(action, "set") == 0) {
-				etcdWatcher_addEntry(watcher, rkey, value);
-			} else if (strcmp(action, "delete") == 0) {
-				etcdWatcher_removeEntry(watcher, rkey, value);
-			} else if (strcmp(action, "expire") == 0) {
-				etcdWatcher_removeEntry(watcher, rkey, value);
-			} else if (strcmp(action, "update") == 0) {
-				etcdWatcher_addEntry(watcher, rkey, value);
-			} else {
-				logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_INFO, "Unexpected action: %s", action);
-			}
-
-			highestModified = modIndex;
-        } else if (time(NULL) - timeBeforeWatch <= (DEFAULT_ETCD_TTL / 4)) {
-			sleep(DEFAULT_ETCD_TTL / 4);
-        }
-
-        FREE_MEM(action);
-        FREE_MEM(value);
-        FREE_MEM(preValue);
-        FREE_MEM(rkey);
-
-		// update own framework uuid
-		if (time(NULL) - timeBeforeWatch > (DEFAULT_ETCD_TTL / 4)) {
-			etcdWatcher_addOwnFramework(watcher);
-			timeBeforeWatch = time(NULL);
-		}
-	}
-
-	return NULL;
-}
-
-/*
- * the ectdWatcher needs to have access to the endpoint_discovery_poller and therefore is only
- * allowed to be created after the endpoint_discovery_poller
- */
-celix_status_t etcdWatcher_create(discovery_pt discovery, bundle_context_pt context,
-		etcd_watcher_pt *watcher)
-{
-	celix_status_t status = CELIX_SUCCESS;
-
-	const char* etcd_server = NULL;
-	const char* etcd_port_string = NULL;
-	int etcd_port = 0;
-
-	if (discovery == NULL) {
-		return CELIX_BUNDLE_EXCEPTION;
-	}
-
-	(*watcher) = calloc(1, sizeof(struct etcd_watcher));
-	if (!*watcher) {
-		return CELIX_ENOMEM;
-	}
-	else
-	{
-		(*watcher)->discovery = discovery;
-		(*watcher)->loghelper = &discovery->loghelper;
-		(*watcher)->entries = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-	}
-
-	if ((bundleContext_getProperty(context, CFG_ETCD_SERVER_IP, &etcd_server) != CELIX_SUCCESS) || !etcd_server) {
-		etcd_server = DEFAULT_ETCD_SERVER_IP;
-	}
-
-	if ((bundleContext_getProperty(context, CFG_ETCD_SERVER_PORT, &etcd_port_string) != CELIX_SUCCESS) || !etcd_port_string) {
-		etcd_port = DEFAULT_ETCD_SERVER_PORT;
-	}
-	else
-	{
-		char* endptr = (char*)etcd_port_string;
-		errno = 0;
-		etcd_port =  strtol(etcd_port_string, &endptr, 10);
-		if (*endptr || errno != 0) {
-			etcd_port = DEFAULT_ETCD_SERVER_PORT;
-		}
-	}
-
-	if (etcd_init((char*) etcd_server, etcd_port, CURL_GLOBAL_DEFAULT) != 0) {
-		status = CELIX_BUNDLE_EXCEPTION;
-	} else {
-		status = CELIX_SUCCESS;
-	}
-
-    if (status == CELIX_SUCCESS) {
-        etcdWatcher_addOwnFramework(*watcher);
-        status = celixThreadMutex_create(&(*watcher)->watcherLock, NULL);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        if (celixThreadMutex_lock(&(*watcher)->watcherLock) == CELIX_SUCCESS) {
-            status = celixThread_create(&(*watcher)->watcherThread, NULL, etcdWatcher_run, *watcher);
-            if (status == CELIX_SUCCESS) {
-                (*watcher)->running = true;
-            }
-            celixThreadMutex_unlock(&(*watcher)->watcherLock);
-        }
-    }
-
-    return status;
-}
-
-
-celix_status_t etcdWatcher_destroy(etcd_watcher_pt watcher) {
-	celix_status_t status = CELIX_SUCCESS;
-	char localNodePath[MAX_LOCALNODE_LENGTH];
-
-	celixThreadMutex_lock(&watcher->watcherLock);
-	watcher->running = false;
-	celixThreadMutex_unlock(&watcher->watcherLock);
-
-	celixThread_join(watcher->watcherThread, NULL);
-
-	// register own framework
-	status = etcdWatcher_getLocalNodePath(watcher->discovery->context, localNodePath);
-
-	if (status != CELIX_SUCCESS || etcd_del(localNodePath) == false)
-	{
-		logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_WARNING, "Cannot remove local discovery registration.");
-	}
-
-	watcher->loghelper = NULL;
-
-	hashMap_destroy(watcher->entries, true, true);
-
-	free(watcher);
-
-	return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_etcd/src/discovery_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/src/discovery_impl.c b/remote_services/discovery_etcd/src/discovery_impl.c
new file mode 100644
index 0000000..8087d95
--- /dev/null
+++ b/remote_services/discovery_etcd/src/discovery_impl.c
@@ -0,0 +1,183 @@
+/**
+ * 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.
+ */
+/*
+ * discovery_impl.c
+ *
+ * \date        Aug 8, 2014
+ * \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <netdb.h>
+#include <netinet/in.h>
+
+#include "constants.h"
+#include "celix_threads.h"
+#include "bundle_context.h"
+#include "array_list.h"
+#include "utils.h"
+#include "celix_errno.h"
+#include "filter.h"
+#include "service_reference.h"
+#include "service_registration.h"
+#include "remote_constants.h"
+
+
+#include "discovery.h"
+#include "discovery_impl.h"
+#include "etcd_watcher.h"
+#include "endpoint_discovery_poller.h"
+#include "endpoint_discovery_server.h"
+
+
+
+celix_status_t discovery_create(bundle_context_pt context, discovery_pt *discovery) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*discovery = malloc(sizeof(struct discovery));
+	if (!*discovery) {
+		return CELIX_ENOMEM;
+	}
+
+	(*discovery)->context = context;
+	(*discovery)->poller = NULL;
+	(*discovery)->server = NULL;
+
+	(*discovery)->listenerReferences = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
+	(*discovery)->discoveredServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+
+	status = celixThreadMutex_create(&(*discovery)->listenerReferencesMutex, NULL);
+	status = celixThreadMutex_create(&(*discovery)->discoveredServicesMutex, NULL);
+
+	logHelper_create(context, &(*discovery)->loghelper);
+
+	return status;
+}
+
+
+
+celix_status_t discovery_destroy(discovery_pt discovery) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	discovery->context = NULL;
+	discovery->poller = NULL;
+	discovery->server = NULL;
+
+	celixThreadMutex_lock(&discovery->discoveredServicesMutex);
+
+	hashMap_destroy(discovery->discoveredServices, false, false);
+	discovery->discoveredServices = NULL;
+
+	celixThreadMutex_unlock(&discovery->discoveredServicesMutex);
+
+	celixThreadMutex_destroy(&discovery->discoveredServicesMutex);
+
+	celixThreadMutex_lock(&discovery->listenerReferencesMutex);
+
+	hashMap_destroy(discovery->listenerReferences, false, false);
+	discovery->listenerReferences = NULL;
+
+	celixThreadMutex_unlock(&discovery->listenerReferencesMutex);
+
+	celixThreadMutex_destroy(&discovery->listenerReferencesMutex);
+
+	logHelper_destroy(&discovery->loghelper);
+
+	free(discovery);
+
+	return status;
+}
+
+celix_status_t discovery_start(discovery_pt discovery) {
+    celix_status_t status = CELIX_SUCCESS;
+	const char *port = NULL;
+	const char *path = NULL;
+
+	logHelper_start(discovery->loghelper);
+
+	bundleContext_getProperty(discovery->context, DISCOVERY_SERVER_PORT, &port);
+	if (port == NULL) {
+		port = DEFAULT_SERVER_PORT;
+	}
+
+	bundleContext_getProperty(discovery->context, DISCOVERY_SERVER_PATH, &path);
+	if (path == NULL) {
+		path = DEFAULT_SERVER_PATH;
+	}
+
+    status = endpointDiscoveryPoller_create(discovery, discovery->context, &discovery->poller);
+    if (status != CELIX_SUCCESS) {
+    	return CELIX_BUNDLE_EXCEPTION;
+    }
+
+    status = endpointDiscoveryServer_create(discovery, discovery->context, &discovery->server);
+    if (status != CELIX_SUCCESS) {
+		return CELIX_BUNDLE_EXCEPTION;
+    }
+
+    status = etcdWatcher_create(discovery, discovery->context, &discovery->watcher);
+    if (status != CELIX_SUCCESS) {
+    	return CELIX_BUNDLE_EXCEPTION;
+    }
+    return status;
+}
+
+celix_status_t discovery_stop(discovery_pt discovery) {
+	celix_status_t status;
+
+	status = etcdWatcher_destroy(discovery->watcher);
+	if (status != CELIX_SUCCESS) {
+		return CELIX_BUNDLE_EXCEPTION;
+	}
+
+	status = endpointDiscoveryServer_destroy(discovery->server);
+	if (status != CELIX_SUCCESS) {
+		return CELIX_BUNDLE_EXCEPTION;
+	}
+
+	status = endpointDiscoveryPoller_destroy(discovery->poller);
+	if (status != CELIX_SUCCESS) {
+		return CELIX_BUNDLE_EXCEPTION;
+	}
+	hash_map_iterator_pt iter;
+
+	celixThreadMutex_lock(&discovery->discoveredServicesMutex);
+
+	iter = hashMapIterator_create(discovery->discoveredServices);
+	while (hashMapIterator_hasNext(iter)) {
+		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+		endpoint_description_pt endpoint = hashMapEntry_getValue(entry);
+
+		discovery_informEndpointListeners(discovery, endpoint, false);
+	}
+	hashMapIterator_destroy(iter);
+
+	celixThreadMutex_unlock(&discovery->discoveredServicesMutex);
+
+
+	logHelper_stop(discovery->loghelper);
+
+	return status;
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_etcd/src/discovery_impl.h
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/src/discovery_impl.h b/remote_services/discovery_etcd/src/discovery_impl.h
new file mode 100644
index 0000000..a19b145
--- /dev/null
+++ b/remote_services/discovery_etcd/src/discovery_impl.h
@@ -0,0 +1,66 @@
+/**
+ *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.
+ */
+/*
+ * discovery_impl.h
+ *
+ *  \date       Sep 29, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef DISCOVERY_IMPL_H_
+#define DISCOVERY_IMPL_H_
+
+#include "bundle_context.h"
+#include "service_reference.h"
+
+#include "endpoint_description.h"
+#include "endpoint_listener.h"
+
+#include "endpoint_discovery_poller.h"
+#include "endpoint_discovery_server.h"
+#include "etcd_watcher.h"
+
+#include "log_helper.h"
+
+#define DEFAULT_SERVER_IP 	"127.0.0.1"
+#define DEFAULT_SERVER_PORT "9999"
+#define DEFAULT_SERVER_PATH "/org.apache.celix.discovery.etcd"
+
+#define DEFAULT_POLL_ENDPOINTS ""
+
+#define FREE_MEM(ptr) if(ptr) {free(ptr); ptr = NULL;}
+
+struct discovery {
+	bundle_context_pt context;
+
+	celix_thread_mutex_t listenerReferencesMutex;
+	celix_thread_mutex_t discoveredServicesMutex;
+
+	hash_map_pt listenerReferences; //key=serviceReference, value=nop
+	hash_map_pt discoveredServices; //key=endpointId (string), value=endpoint_description_pt
+
+	etcd_watcher_pt watcher;
+	endpoint_discovery_poller_pt poller;
+	endpoint_discovery_server_pt server;
+
+	log_helper_pt loghelper;
+};
+
+#endif /* DISCOVERY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_etcd/src/etcd_watcher.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/src/etcd_watcher.c b/remote_services/discovery_etcd/src/etcd_watcher.c
new file mode 100644
index 0000000..ebeac4f
--- /dev/null
+++ b/remote_services/discovery_etcd/src/etcd_watcher.c
@@ -0,0 +1,397 @@
+/**
+ * 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.
+ */
+/*
+ * etcd_watcher.c
+ *
+ * \date       16 Sep 2014
+ * \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright  Apache License, Version 2.0
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "log_helper.h"
+#include "log_service.h"
+#include "constants.h"
+#include "utils.h"
+#include "discovery.h"
+#include "discovery_impl.h"
+
+#include <curl/curl.h>
+#include "etcd.h"
+#include "etcd_watcher.h"
+
+#include "endpoint_discovery_poller.h"
+
+struct etcd_watcher {
+    discovery_pt discovery;
+    log_helper_pt* loghelper;
+    hash_map_pt entries;
+
+	celix_thread_mutex_t watcherLock;
+	celix_thread_t watcherThread;
+
+	volatile bool running;
+};
+
+
+#define MAX_ROOTNODE_LENGTH			128
+#define MAX_LOCALNODE_LENGTH		4096
+#define MAX_VALUE_LENGTH			256
+
+#define CFG_ETCD_ROOT_PATH			"DISCOVERY_ETCD_ROOT_PATH"
+#define DEFAULT_ETCD_ROOTPATH		"discovery"
+
+#define CFG_ETCD_SERVER_IP			"DISCOVERY_ETCD_SERVER_IP"
+#define DEFAULT_ETCD_SERVER_IP		"127.0.0.1"
+
+#define CFG_ETCD_SERVER_PORT		"DISCOVERY_ETCD_SERVER_PORT"
+#define DEFAULT_ETCD_SERVER_PORT 	2379
+
+// be careful - this should be higher than the curl timeout
+#define CFG_ETCD_TTL   				"DISCOVERY_ETCD_TTL"
+#define DEFAULT_ETCD_TTL 			30
+
+
+// note that the rootNode shouldn't have a leading slash
+static celix_status_t etcdWatcher_getRootPath(bundle_context_pt context, char* rootNode) {
+	celix_status_t status = CELIX_SUCCESS;
+	const char* rootPath = NULL;
+
+	if (((bundleContext_getProperty(context, CFG_ETCD_ROOT_PATH, &rootPath)) != CELIX_SUCCESS) || (!rootPath)) {
+		strncpy(rootNode, DEFAULT_ETCD_ROOTPATH, MAX_ROOTNODE_LENGTH);
+	}
+	else {
+		strncpy(rootNode, rootPath, MAX_ROOTNODE_LENGTH);
+	}
+
+	return status;
+}
+
+static celix_status_t etcdWatcher_getLocalNodePath(bundle_context_pt context, char* localNodePath) {
+	celix_status_t status = CELIX_SUCCESS;
+	char rootPath[MAX_ROOTNODE_LENGTH];
+    const char* uuid = NULL;
+
+    if ((etcdWatcher_getRootPath(context, rootPath) != CELIX_SUCCESS)) {
+		status = CELIX_ILLEGAL_STATE;
+    }
+	else if (((bundleContext_getProperty(context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid)) != CELIX_SUCCESS) || (!uuid)) {
+		status = CELIX_ILLEGAL_STATE;
+	}
+	else if (rootPath[strlen(rootPath) - 1] == '/') {
+    	snprintf(localNodePath, MAX_LOCALNODE_LENGTH, "%s%s", rootPath, uuid);
+    }
+    else {
+    	snprintf(localNodePath, MAX_LOCALNODE_LENGTH, "%s/%s", rootPath, uuid);
+    }
+
+    return status;
+}
+
+static void add_node(const char *key, const char *value, void* arg) {
+	discovery_pt discovery = (discovery_pt) arg;
+	endpointDiscoveryPoller_addDiscoveryEndpoint(discovery->poller, (char *) value);
+}
+
+/*
+ * retrieves all already existing discovery endpoints
+ * from etcd and adds them to the poller.
+ *
+ * returns the modifiedIndex of the last modified
+ * discovery endpoint (see etcd documentation).
+ */
+static celix_status_t etcdWatcher_addAlreadyExistingWatchpoints(discovery_pt discovery, long long* highestModified) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	char rootPath[MAX_ROOTNODE_LENGTH];
+	status = etcdWatcher_getRootPath(discovery->context, rootPath);
+
+	if (status == CELIX_SUCCESS) {
+		if(etcd_get_directory(rootPath, add_node, discovery, highestModified)) {
+			    status = CELIX_ILLEGAL_ARGUMENT;
+		}
+	}
+
+	return status;
+}
+
+
+static celix_status_t etcdWatcher_addOwnFramework(etcd_watcher_pt watcher)
+{
+    celix_status_t status = CELIX_BUNDLE_EXCEPTION;
+    char localNodePath[MAX_LOCALNODE_LENGTH];
+    char *value;
+ 	char url[MAX_VALUE_LENGTH];
+    int modIndex;
+    char* endpoints = NULL;
+    const char* ttlStr = NULL;
+    int ttl;
+
+	bundle_context_pt context = watcher->discovery->context;
+	endpoint_discovery_server_pt server = watcher->discovery->server;
+
+    // register own framework
+    if ((status = etcdWatcher_getLocalNodePath(context, localNodePath)) != CELIX_SUCCESS) {
+        return status;
+    }
+
+	if (endpointDiscoveryServer_getUrl(server, url) != CELIX_SUCCESS) {
+		snprintf(url, MAX_VALUE_LENGTH, "http://%s:%s/%s", DEFAULT_SERVER_IP, DEFAULT_SERVER_PORT, DEFAULT_SERVER_PATH);
+	}
+
+	endpoints = url;
+
+    if ((bundleContext_getProperty(context, CFG_ETCD_TTL, &ttlStr) != CELIX_SUCCESS) || !ttlStr) {
+        ttl = DEFAULT_ETCD_TTL;
+    }
+    else
+    {
+        char* endptr = (char *) ttlStr;
+        errno = 0;
+        ttl = strtol(ttlStr, &endptr, 10);
+        if (*endptr || errno != 0) {
+            ttl = DEFAULT_ETCD_TTL;
+        }
+    }
+
+	if (etcd_get(localNodePath, &value, &modIndex) != true) {
+		etcd_set(localNodePath, endpoints, ttl, false);
+	}
+	else if (etcd_set(localNodePath, endpoints, ttl, true) == false)  {
+		logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_WARNING, "Cannot register local discovery");
+    }
+    else {
+        status = CELIX_SUCCESS;
+    }
+
+	FREE_MEM(value);
+
+    return status;
+}
+
+
+
+
+static celix_status_t etcdWatcher_addEntry(etcd_watcher_pt watcher, char* key, char* value) {
+	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
+	endpoint_discovery_poller_pt poller = watcher->discovery->poller;
+
+	if (!hashMap_containsKey(watcher->entries, key)) {
+		status = endpointDiscoveryPoller_addDiscoveryEndpoint(poller, value);
+
+		if (status == CELIX_SUCCESS) {
+			hashMap_put(watcher->entries, strdup(key), strdup(value));
+		}
+	}
+
+	return status;
+}
+
+static celix_status_t etcdWatcher_removeEntry(etcd_watcher_pt watcher, char* key, char* value) {
+	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
+	endpoint_discovery_poller_pt poller = watcher->discovery->poller;
+
+	hash_map_entry_pt entry = hashMap_getEntry(watcher->entries, key);
+
+	if (entry != NULL) {
+		void* origKey = hashMapEntry_getKey(entry);
+		void* value = hashMap_remove(watcher->entries, key);
+
+		free(origKey);
+
+		// check if there is another entry with the same value
+		hash_map_iterator_pt iter = hashMapIterator_create(watcher->entries);
+		unsigned int valueFound = 0;
+
+		while (hashMapIterator_hasNext(iter) && valueFound <= 1) {
+			if (strcmp(value, hashMapIterator_nextValue(iter)) == 0)
+				valueFound++;
+		}
+
+		hashMapIterator_destroy(iter);
+
+		if (valueFound == 0)
+			status = endpointDiscoveryPoller_removeDiscoveryEndpoint(poller, value);
+
+		free(value);
+
+	}
+
+	return status;
+
+}
+
+
+/*
+ * performs (blocking) etcd_watch calls to check for
+ * changing discovery endpoint information within etcd.
+ */
+static void* etcdWatcher_run(void* data) {
+	etcd_watcher_pt watcher = (etcd_watcher_pt) data;
+	time_t timeBeforeWatch = time(NULL);
+	char rootPath[MAX_ROOTNODE_LENGTH];
+	long long highestModified = 0;
+
+	bundle_context_pt context = watcher->discovery->context;
+
+	etcdWatcher_addAlreadyExistingWatchpoints(watcher->discovery, &highestModified);
+	etcdWatcher_getRootPath(context, rootPath);
+
+	while (watcher->running) {
+
+		char *rkey = NULL;
+		char *value = NULL;
+		char *preValue = NULL;
+		char *action = NULL;
+		long long modIndex;
+
+        if (etcd_watch(rootPath, highestModified + 1, &action, &preValue, &value, &rkey, &modIndex) == 0 && action != NULL) {
+			if (strcmp(action, "set") == 0) {
+				etcdWatcher_addEntry(watcher, rkey, value);
+			} else if (strcmp(action, "delete") == 0) {
+				etcdWatcher_removeEntry(watcher, rkey, value);
+			} else if (strcmp(action, "expire") == 0) {
+				etcdWatcher_removeEntry(watcher, rkey, value);
+			} else if (strcmp(action, "update") == 0) {
+				etcdWatcher_addEntry(watcher, rkey, value);
+			} else {
+				logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_INFO, "Unexpected action: %s", action);
+			}
+
+			highestModified = modIndex;
+        } else if (time(NULL) - timeBeforeWatch <= (DEFAULT_ETCD_TTL / 4)) {
+			sleep(DEFAULT_ETCD_TTL / 4);
+        }
+
+        FREE_MEM(action);
+        FREE_MEM(value);
+        FREE_MEM(preValue);
+        FREE_MEM(rkey);
+
+		// update own framework uuid
+		if (time(NULL) - timeBeforeWatch > (DEFAULT_ETCD_TTL / 4)) {
+			etcdWatcher_addOwnFramework(watcher);
+			timeBeforeWatch = time(NULL);
+		}
+	}
+
+	return NULL;
+}
+
+/*
+ * the ectdWatcher needs to have access to the endpoint_discovery_poller and therefore is only
+ * allowed to be created after the endpoint_discovery_poller
+ */
+celix_status_t etcdWatcher_create(discovery_pt discovery, bundle_context_pt context,
+		etcd_watcher_pt *watcher)
+{
+	celix_status_t status = CELIX_SUCCESS;
+
+	const char* etcd_server = NULL;
+	const char* etcd_port_string = NULL;
+	int etcd_port = 0;
+
+	if (discovery == NULL) {
+		return CELIX_BUNDLE_EXCEPTION;
+	}
+
+	(*watcher) = calloc(1, sizeof(struct etcd_watcher));
+	if (!*watcher) {
+		return CELIX_ENOMEM;
+	}
+	else
+	{
+		(*watcher)->discovery = discovery;
+		(*watcher)->loghelper = &discovery->loghelper;
+		(*watcher)->entries = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+	}
+
+	if ((bundleContext_getProperty(context, CFG_ETCD_SERVER_IP, &etcd_server) != CELIX_SUCCESS) || !etcd_server) {
+		etcd_server = DEFAULT_ETCD_SERVER_IP;
+	}
+
+	if ((bundleContext_getProperty(context, CFG_ETCD_SERVER_PORT, &etcd_port_string) != CELIX_SUCCESS) || !etcd_port_string) {
+		etcd_port = DEFAULT_ETCD_SERVER_PORT;
+	}
+	else
+	{
+		char* endptr = (char*)etcd_port_string;
+		errno = 0;
+		etcd_port =  strtol(etcd_port_string, &endptr, 10);
+		if (*endptr || errno != 0) {
+			etcd_port = DEFAULT_ETCD_SERVER_PORT;
+		}
+	}
+
+	if (etcd_init((char*) etcd_server, etcd_port, CURL_GLOBAL_DEFAULT) != 0) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	} else {
+		status = CELIX_SUCCESS;
+	}
+
+    if (status == CELIX_SUCCESS) {
+        etcdWatcher_addOwnFramework(*watcher);
+        status = celixThreadMutex_create(&(*watcher)->watcherLock, NULL);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        if (celixThreadMutex_lock(&(*watcher)->watcherLock) == CELIX_SUCCESS) {
+            status = celixThread_create(&(*watcher)->watcherThread, NULL, etcdWatcher_run, *watcher);
+            if (status == CELIX_SUCCESS) {
+                (*watcher)->running = true;
+            }
+            celixThreadMutex_unlock(&(*watcher)->watcherLock);
+        }
+    }
+
+    return status;
+}
+
+
+celix_status_t etcdWatcher_destroy(etcd_watcher_pt watcher) {
+	celix_status_t status = CELIX_SUCCESS;
+	char localNodePath[MAX_LOCALNODE_LENGTH];
+
+	celixThreadMutex_lock(&watcher->watcherLock);
+	watcher->running = false;
+	celixThreadMutex_unlock(&watcher->watcherLock);
+
+	celixThread_join(watcher->watcherThread, NULL);
+
+	// register own framework
+	status = etcdWatcher_getLocalNodePath(watcher->discovery->context, localNodePath);
+
+	if (status != CELIX_SUCCESS || etcd_del(localNodePath) == false)
+	{
+		logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_WARNING, "Cannot remove local discovery registration.");
+	}
+
+	watcher->loghelper = NULL;
+
+	hashMap_destroy(watcher->entries, true, true);
+
+	free(watcher);
+
+	return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/discovery_etcd/src/etcd_watcher.h
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/src/etcd_watcher.h b/remote_services/discovery_etcd/src/etcd_watcher.h
new file mode 100644
index 0000000..b4dbf40
--- /dev/null
+++ b/remote_services/discovery_etcd/src/etcd_watcher.h
@@ -0,0 +1,40 @@
+/**
+ * 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.
+ */
+/*
+ * etcd_watcher.h
+ *
+ * \date       17 Sep 2014
+ * \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright  Apache License, Version 2.0
+ */
+
+#ifndef ETCD_WATCHER_H_
+#define ETCD_WATCHER_H_
+
+#include "celix_errno.h"
+#include "discovery.h"
+#include "endpoint_discovery_poller.h"
+
+typedef struct etcd_watcher *etcd_watcher_pt;
+
+celix_status_t etcdWatcher_create(discovery_pt discovery,  bundle_context_pt context, etcd_watcher_pt *watcher);
+celix_status_t etcdWatcher_destroy(etcd_watcher_pt watcher);
+
+
+#endif /* ETCD_WATCHER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/examples/CMakeLists.txt b/remote_services/examples/CMakeLists.txt
index 44b7733..c7c5444 100644
--- a/remote_services/examples/CMakeLists.txt
+++ b/remote_services/examples/CMakeLists.txt
@@ -18,97 +18,42 @@
 celix_subproject(RSA_EXAMPLES "Option to enable building the RSA examples" ON DEPS LAUNCHER shell_tui log_writer RSA_TOPOLOGY_MANAGER)
 if (RSA_EXAMPLES)
     add_subdirectory(calculator_service)
-
-    add_subdirectory(calculator_endpoint)
-    add_subdirectory(calculator_endpoint2)
-
-    add_subdirectory(calculator_proxy)
-    add_subdirectory(calculator_proxy2)
-
     add_subdirectory(calculator_shell)
 
-    if(BUILD_RSA_REMOTE_SERVICE_ADMIN_HTTP AND BUILD_RSA_DISCOVERY_CONFIGURED)
-        add_deploy(remote-services-cfg-server 
-            NAME "server"
-            GROUP "remote-services/remote-services-cfg"
-            BUNDLES discovery_configured topology_manager remote_service_admin_http calculator shell shell_tui log_service log_writer
-            PROPERTIES
-                RSA_PORT=8001
-                DISCOVERY_CFG_POLL_ENDPOINTS=http://localhost:8082/org.apache.celix.discovery.configured
-                DISCOVERY_CFG_SERVER_PORT=8081
-        )
-        deploy_bundles_dir(remote-services-cfg-server DIR_NAME "endpoints" BUNDLES
-            org.apache.celix.calc.api.Calculator_endpoint
-            org.apache.celix.calc.api.Calculator2_endpoint
-        )
-
-        add_deploy(remote-services-cfg-client
-            NAME "client"
-            GROUP "remote-services/remote-services-cfg"
-            BUNDLES topology_manager remote_service_admin_http shell shell_tui log_service log_writer calculator_shell discovery_configured
-            PROPERTIES
-                RSA_PORT=8002
-                DISCOVERY_CFG_POLL_ENDPOINTS=http://localhost:8081/org.apache.celix.discovery.configured
-                DISCOVERY_CFG_SERVER_PORT=8082
-        )
-        deploy_bundles_dir(remote-services-cfg-client DIR_NAME "endpoints"
-            BUNDLES org.apache.celix.calc.api.Calculator_proxy org.apache.celix.calc.api.Calculator2_proxy
-        )
-    endif()
-
-    if (BUILD_RSA_REMOTE_SERVICE_ADMIN_SHM AND BUILD_RSA_DISCOVERY_SHM)
-        add_deploy(remote-services-shm 
-            NAME "server"
-            GROUP "remote-services/remote-services-shm"
-            BUNDLES discovery_shm topology_manager remote_service_admin_shm calculator shell shell_tui log_service log_writer
-        )
-        deploy_bundles_dir(remote-services-shm DIR_NAME "endpoints"
-            BUNDLES org.apache.celix.calc.api.Calculator_endpoint
-        )
-
-        add_deploy(remote-services-shm-client 
-            NAME "client"
-            GROUP "remote-services/remote-services-shm"
-            BUNDLES topology_manager remote_service_admin_shm shell shell_tui log_service log_writer calculator_shell discovery_shm
-        )
-        deploy_bundles_dir(remote-services-shm-client DIR_NAME "endpoints"
-            BUNDLES org.apache.celix.calc.api.Calculator_proxy
-        )
-    endif ()
 
-    if (BUILD_RSA_DISCOVERY_ETCD AND BUILD_RSA_REMOTE_SERVICE_ADMIN_HTTP)
-        add_deploy(remote-services-etcd 
-            NAME "server"
-            GROUP "remote-services/remote-services-etcd"
-            BUNDLES discovery_etcd topology_manager remote_service_admin_http calculator shell shell_tui log_service log_writer
-        )
-        deploy_bundles_dir(remote-services-etcd DIR_NAME "endpoints"
-            BUNDLES
-            	org.apache.celix.calc.api.Calculator_endpoint
-            	org.apache.celix.calc.api.Calculator2_endpoint
-        )
+#    TODO refactor shm remote service admin to use dfi
+#    if (BUILD_RSA_REMOTE_SERVICE_ADMIN_SHM AND BUILD_RSA_DISCOVERY_SHM)
+#        add_deploy(remote-services-shm
+#            NAME "server"
+#            GROUP "remote-services/remote-services-shm"
+#            BUNDLES discovery_shm topology_manager remote_service_admin_shm calculator shell shell_tui log_service log_writer
+#        )
+#        deploy_bundles_dir(remote-services-shm DIR_NAME "endpoints"
+#            BUNDLES org.apache.celix.calc.api.Calculator_endpoint
+#        )
+#
+#        add_deploy(remote-services-shm-client
+#            NAME "client"
+#            GROUP "remote-services/remote-services-shm"
+#            BUNDLES topology_manager remote_service_admin_shm shell shell_tui log_service log_writer calculator_shell discovery_shm
+#        )
+#        deploy_bundles_dir(remote-services-shm-client DIR_NAME "endpoints"
+#            BUNDLES org.apache.celix.calc.api.Calculator_proxy
+#        )
+#    endif ()
 
-        add_deploy("remote-services-etcd-client" 
-            NAME "client"
-            GROUP "remote-services/remote-services-etcd"
-            BUNDLES topology_manager remote_service_admin_http shell shell_tui log_service log_writer calculator_shell discovery_etcd
-        )
-        deploy_bundles_dir(remote-services-etcd-client DIR_NAME "endpoints"
-            BUNDLES org.apache.celix.calc.api.Calculator_proxy
-        )
-    endif ()
 
     if (BUILD_RSA_DISCOVERY_ETCD AND BUILD_RSA_REMOTE_SERVICE_ADMIN_DFI)
         add_deploy(remote-services-dfi 
             NAME "server"
             GROUP "remote-services/remote-services-dfi"
-            BUNDLES discovery_etcd topology_manager remote_service_admin_dfi calculator shell shell_tui log_service log_writer
+            BUNDLES discovery_etcd topology_manager remote_service_admin_dfi calculator Celix::shell Celix::shell_tui log_service log_writer
         )
 
         add_deploy("remote-services-dfi-client" 
             NAME "client"
             GROUP "remote-services/remote-services-dfi"
-            BUNDLES topology_manager remote_service_admin_dfi shell shell_tui log_service log_writer calculator_shell discovery_etcd
+            BUNDLES topology_manager remote_service_admin_dfi Celix::shell Celix::shell_tui log_service log_writer calculator_shell discovery_etcd
         )
     endif ()
 endif (RSA_EXAMPLES)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_endpoint/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_endpoint/CMakeLists.txt b/remote_services/examples/calculator_endpoint/CMakeLists.txt
deleted file mode 100644
index 6e9c928..0000000
--- a/remote_services/examples/calculator_endpoint/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# 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.
-
-find_package(Jansson REQUIRED)
-
-include_directories("${JANSSON_INCLUDE_DIRS}")
-include_directories("../../../utils/public/include")
-include_directories("../../remote_service_admin/public/include")
-include_directories("../calculator_service/public/include")
-include_directories("private/include")
-
-add_bundle(org.apache.celix.calc.api.Calculator_endpoint SOURCES
-	private/src/calculator_endpoint_activator
-	private/src/calculator_endpoint_impl.c
-    
-    private/include/calculator_endpoint_impl.h
-    VERSION 0.0.1
-    SYMBOLIC_NAME "apache_celix_remoting_calculator_endpoint"
-)
-
-target_link_libraries(org.apache.celix.calc.api.Calculator_endpoint celix_framework ${JANSSON_LIBRARIES})

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_endpoint/private/include/calculator_endpoint_impl.h
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_endpoint/private/include/calculator_endpoint_impl.h b/remote_services/examples/calculator_endpoint/private/include/calculator_endpoint_impl.h
deleted file mode 100644
index dbeda2d..0000000
--- a/remote_services/examples/calculator_endpoint/private/include/calculator_endpoint_impl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_endpoint_impl.h
- *
- *  \date       Oct 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef CALCULATOR_ENDPOINT_IMPL_H_
-#define CALCULATOR_ENDPOINT_IMPL_H_
-
-#include "celix_errno.h"
-#include "remote_endpoint_impl.h"
-
-#include "calculator_service.h"
-
-celix_status_t calculatorEndpoint_create(remote_endpoint_pt *endpoint);
-celix_status_t calculatorEndpoint_destroy(remote_endpoint_pt *endpoint);
-
-celix_status_t calculatorEndpoint_setService(remote_endpoint_pt endpoint, void *service);
-
-celix_status_t calculatorEndpoint_handleRequest(remote_endpoint_pt endpoint, char *data, char **reply);
-
-celix_status_t calculatorEndpoint_add(remote_endpoint_pt endpoint, char *data, char **reply);
-celix_status_t calculatorEndpoint_sub(remote_endpoint_pt endpoint, char *data, char **reply);
-celix_status_t calculatorEndpoint_sqrt(remote_endpoint_pt endpoint, char *data, char **reply);
-
-#endif /* CALCULATOR_ENDPOINT_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_endpoint/private/src/calculator_endpoint_activator.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_endpoint/private/src/calculator_endpoint_activator.c b/remote_services/examples/calculator_endpoint/private/src/calculator_endpoint_activator.c
deleted file mode 100644
index 319ecb0..0000000
--- a/remote_services/examples/calculator_endpoint/private/src/calculator_endpoint_activator.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_endpoint_activator.c
- *
- *  \date       Oct 10, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-
-#include "calculator_endpoint_impl.h"
-#include "service_registration.h"
-
-struct activator {
-	remote_endpoint_service_pt endpointService;
-	service_registration_pt endpointServiceRegistration;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	struct activator *activator;
-
-	activator = calloc(1, sizeof(*activator));
-	if (!activator) {
-		status = CELIX_ENOMEM;
-	} else {
-		activator->endpointService = NULL;
-		activator->endpointServiceRegistration = NULL;
-
-		*userData = activator;
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-	remote_endpoint_pt endpoint = NULL;
-	remote_endpoint_service_pt endpointService = NULL;
-
-	calculatorEndpoint_create(&endpoint);
-	endpointService = calloc(1, sizeof(*endpointService));
-	endpointService->endpoint = endpoint;
-	endpointService->handleRequest = calculatorEndpoint_handleRequest;
-	endpointService->setService = calculatorEndpoint_setService;
-
-	properties_pt props = properties_create();
-	properties_set(props, (char *) "remote.interface", (char *) CALCULATOR_SERVICE);
-
-	bundleContext_registerService(context, OSGI_RSA_REMOTE_ENDPOINT, endpointService, props, &activator->endpointServiceRegistration);
-
-	activator->endpointService = endpointService;
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	serviceRegistration_unregister(activator->endpointServiceRegistration);
-
-	calculatorEndpoint_destroy(&activator->endpointService->endpoint);
-	free(activator->endpointService);
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	free(activator);
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_endpoint/private/src/calculator_endpoint_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_endpoint/private/src/calculator_endpoint_impl.c b/remote_services/examples/calculator_endpoint/private/src/calculator_endpoint_impl.c
deleted file mode 100644
index b9a973f..0000000
--- a/remote_services/examples/calculator_endpoint/private/src/calculator_endpoint_impl.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_endpoint_impl.c
- *
- *  \date       Oct 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <jansson.h>
-#include <string.h>
-
-#include "celix_errno.h"
-
-#include "calculator_endpoint_impl.h"
-
-celix_status_t calculatorEndpoint_create(remote_endpoint_pt *endpoint) {
-	celix_status_t status = CELIX_SUCCESS;
-	*endpoint = calloc(1, sizeof(**endpoint));
-	if (!*endpoint) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*endpoint)->service = NULL;
-	}
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_destroy(remote_endpoint_pt *endpoint) {
-	celix_status_t status = CELIX_SUCCESS;
-	free(*endpoint);
-	*endpoint = NULL;
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_setService(remote_endpoint_pt endpoint, void *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	endpoint->service = service;
-	return status;
-}
-
-/**
- * Request: http://host:port/services/{service}
- */
-celix_status_t calculatorEndpoint_handleRequest(remote_endpoint_pt endpoint, char *data, char **reply) {
-	celix_status_t status = CELIX_SUCCESS;
-	json_error_t jsonError;
-    json_t *root = json_loads(data, 0, &jsonError);
-    const char *sig;
-    json_unpack(root, "{s:s}", "m", &sig);
-
-	printf("CALCULATOR_ENDPOINT: Handle request \"%s\" with data \"%s\"\n", sig, data);
-	if (strcmp(sig, "add(DD)D") == 0) {
-		calculatorEndpoint_add(endpoint, data, reply);
-	} else if (strcmp(sig, "sub(DD)D") == 0) {
-		calculatorEndpoint_sub(endpoint, data, reply);
-	} else if (strcmp(sig, "sqrt(D)D") == 0) {
-		calculatorEndpoint_sqrt(endpoint, data, reply);
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	json_decref(root);
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_add(remote_endpoint_pt endpoint, char *data, char **reply) {
-	celix_status_t status = CELIX_SUCCESS;
-	json_error_t jsonError;
-	json_t *root;
-
-	root = json_loads(data, 0, &jsonError);
-	if (!root) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		double a;
-		double b;
-		json_unpack(root, "{s:[ff]}", "a", &a, &b);
-
-		if (endpoint->service != NULL) {
-			double result;
-			json_t *resultRoot;
-			calculator_service_pt service = endpoint->service;
-			service->add(service->calculator, a, b, &result);
-			resultRoot = json_pack("{s:f}", "r", result);
-
-			char *c = json_dumps(resultRoot, 0);
-			*reply = c;
-
-			json_decref(resultRoot);
-		} else {
-			printf("CALCULATOR_ENDPOINT: No service available");
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-		json_decref(root);
-	}
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_sub(remote_endpoint_pt endpoint, char *data, char **reply) {
-	celix_status_t status = CELIX_SUCCESS;
-	json_error_t jsonError;
-	json_t *root;
-
-	root = json_loads(data, 0, &jsonError);
-	if (!root) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		double a;
-		double b;
-		json_unpack(root, "{s:[ff]}", "a", &a, &b);
-
-		if (endpoint->service != NULL) {
-			double result;
-			json_t *resultRoot;
-			calculator_service_pt service = endpoint->service;
-			service->sub(service->calculator, a, b, &result);
-			resultRoot = json_pack("{s:f}", "r", result);
-
-			char *c = json_dumps(resultRoot, JSON_ENCODE_ANY);
-			*reply = c;
-
-			json_decref(resultRoot);
-		} else {
-			printf("CALCULATOR_ENDPOINT: No service available");
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-		json_decref(root);
-	}
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_sqrt(remote_endpoint_pt endpoint, char *data, char **reply) {
-	celix_status_t status = CELIX_SUCCESS;
-	json_error_t jsonError;
-	json_t *root;
-
-	root = json_loads(data, 0, &jsonError);
-	if (!root) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		double a;
-		json_unpack(root, "{s:[f]}", "a", &a);
-
-		if (endpoint->service != NULL) {
-			double result;
-			json_t *resultRoot;
-			calculator_service_pt service = endpoint->service;
-			service->sqrt(service->calculator, a, &result);
-			resultRoot = json_pack("{s:f}", "r", result);
-
-			char *c = json_dumps(resultRoot, JSON_ENCODE_ANY);
-			*reply = c;
-
-			json_decref(resultRoot);
-		} else {
-			printf("CALCULATOR_ENDPOINT: No service available");
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-		json_decref(root);
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_endpoint2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_endpoint2/CMakeLists.txt b/remote_services/examples/calculator_endpoint2/CMakeLists.txt
deleted file mode 100644
index b75e6df..0000000
--- a/remote_services/examples/calculator_endpoint2/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# 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.
-
-find_package(Jansson REQUIRED)
-
-include_directories("${JANSSON_INCLUDE_DIRS}")
-include_directories("../../../utils/public/include")
-include_directories("../../remote_service_admin/public/include")
-include_directories("../calculator_service/public/include")
-include_directories("private/include")
-
-add_bundle(org.apache.celix.calc.api.Calculator2_endpoint SOURCES
-	private/src/calculator_endpoint_activator
-	private/src/calculator_endpoint_impl.c
-    
-    private/include/calculator_endpoint_impl.h
-    SYMBOLIC_NAME "apache_celix_remoting_calculator2_endpoint"
-    VERSION "0.0.1"
-)
-
-target_link_libraries(org.apache.celix.calc.api.Calculator2_endpoint celix_framework ${JANSSON_LIBRARIES})

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_endpoint2/private/include/calculator_endpoint_impl.h
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_endpoint2/private/include/calculator_endpoint_impl.h b/remote_services/examples/calculator_endpoint2/private/include/calculator_endpoint_impl.h
deleted file mode 100644
index dbeda2d..0000000
--- a/remote_services/examples/calculator_endpoint2/private/include/calculator_endpoint_impl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_endpoint_impl.h
- *
- *  \date       Oct 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef CALCULATOR_ENDPOINT_IMPL_H_
-#define CALCULATOR_ENDPOINT_IMPL_H_
-
-#include "celix_errno.h"
-#include "remote_endpoint_impl.h"
-
-#include "calculator_service.h"
-
-celix_status_t calculatorEndpoint_create(remote_endpoint_pt *endpoint);
-celix_status_t calculatorEndpoint_destroy(remote_endpoint_pt *endpoint);
-
-celix_status_t calculatorEndpoint_setService(remote_endpoint_pt endpoint, void *service);
-
-celix_status_t calculatorEndpoint_handleRequest(remote_endpoint_pt endpoint, char *data, char **reply);
-
-celix_status_t calculatorEndpoint_add(remote_endpoint_pt endpoint, char *data, char **reply);
-celix_status_t calculatorEndpoint_sub(remote_endpoint_pt endpoint, char *data, char **reply);
-celix_status_t calculatorEndpoint_sqrt(remote_endpoint_pt endpoint, char *data, char **reply);
-
-#endif /* CALCULATOR_ENDPOINT_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_endpoint2/private/src/calculator_endpoint_activator.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_endpoint2/private/src/calculator_endpoint_activator.c b/remote_services/examples/calculator_endpoint2/private/src/calculator_endpoint_activator.c
deleted file mode 100644
index 9f89d91..0000000
--- a/remote_services/examples/calculator_endpoint2/private/src/calculator_endpoint_activator.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_endpoint_activator.c
- *
- *  \date       Oct 10, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-
-#include "calculator_endpoint_impl.h"
-#include "service_registration.h"
-
-struct activator {
-	remote_endpoint_service_pt endpointService;
-	service_registration_pt endpointServiceRegistration;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	struct activator *activator;
-
-	activator = calloc(1, sizeof(*activator));
-	if (!activator) {
-		status = CELIX_ENOMEM;
-	} else {
-		activator->endpointService = NULL;
-		activator->endpointServiceRegistration = NULL;
-
-		*userData = activator;
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-	remote_endpoint_pt endpoint = NULL;
-	remote_endpoint_service_pt endpointService = NULL;
-
-	calculatorEndpoint_create(&endpoint);
-	endpointService = calloc(1, sizeof(*endpointService));
-	endpointService->endpoint = endpoint;
-	endpointService->handleRequest = calculatorEndpoint_handleRequest;
-        endpointService->setService = calculatorEndpoint_setService;
-
-        properties_pt props = properties_create();
-        properties_set(props, (char *) "remote.interface", (char *) CALCULATOR2_SERVICE);
-
-        bundleContext_registerService(context, OSGI_RSA_REMOTE_ENDPOINT, endpointService, props, &activator->endpointServiceRegistration);
-
-	activator->endpointService = endpointService;
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	serviceRegistration_unregister(activator->endpointServiceRegistration);
-
-	calculatorEndpoint_destroy(&activator->endpointService->endpoint);
-	free(activator->endpointService);
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	free(activator);
-	return status;
-}


[43/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_component_impl.c b/dependency_manager/src/dm_component_impl.c
new file mode 100644
index 0000000..13a2ee0
--- /dev/null
+++ b/dependency_manager/src/dm_component_impl.c
@@ -0,0 +1,1442 @@
+/**
+ *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.
+ */
+/*
+ * dm_component_impl.c
+ *
+ *  \date       9 Oct 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "constants.h"
+#include "filter.h"
+#include "dm_component_impl.h"
+
+
+typedef struct dm_executor_struct * dm_executor_pt;
+
+struct dm_component_struct {
+    char id[DM_COMPONENT_MAX_ID_LENGTH];
+    char name[DM_COMPONENT_MAX_NAME_LENGTH];
+    bundle_context_pt context;
+    array_list_pt dm_interfaces;
+
+    void* implementation;
+
+    init_fpt callbackInit;
+    start_fpt callbackStart;
+    stop_fpt callbackStop;
+    deinit_fpt callbackDeinit;
+
+    array_list_pt dependencies; //protected by mutex
+    pthread_mutex_t mutex;
+
+    dm_component_state_t state;
+    bool isStarted;
+    bool active;
+
+    bool setCLanguageProperty;
+
+    hash_map_pt dependencyEvents; //protected by mutex
+
+    dm_executor_pt executor;
+};
+
+typedef struct dm_interface_struct {
+    char* serviceName;
+    const void* service;
+    properties_pt properties;
+    service_registration_pt registration;
+} dm_interface_t;
+
+struct dm_executor_struct {
+    pthread_t runningThread;
+    bool runningThreadSet;
+    linked_list_pt workQueue;
+    pthread_mutex_t mutex;
+};
+
+typedef struct dm_executor_task_struct {
+    dm_component_pt component;
+    void (*command)(void *command_ptr, void *data);
+    void *data;
+} dm_executor_task_t;
+
+typedef struct dm_handle_event_type_struct {
+	dm_service_dependency_pt dependency;
+	dm_event_pt event;
+	dm_event_pt newEvent;
+} *dm_handle_event_type_pt;
+
+static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t  currentThread __attribute__((unused)));
+static celix_status_t executor_execute(dm_executor_pt executor);
+static celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt component, void (*command), void *data);
+static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt component, void (*command), void *data);
+static celix_status_t executor_create(dm_component_pt component __attribute__((unused)), dm_executor_pt *executor);
+static void executor_destroy(dm_executor_pt executor);
+
+static celix_status_t component_invokeRemoveRequiredDependencies(dm_component_pt component);
+static celix_status_t component_invokeRemoveInstanceBoundDependencies(dm_component_pt component);
+static celix_status_t component_invokeRemoveOptionalDependencies(dm_component_pt component);
+static celix_status_t component_registerServices(dm_component_pt component);
+static celix_status_t component_unregisterServices(dm_component_pt component);
+static celix_status_t component_invokeAddOptionalDependencies(dm_component_pt component);
+static celix_status_t component_invokeAddRequiredInstanceBoundDependencies(dm_component_pt component);
+static celix_status_t component_invokeAddRequiredDependencies(dm_component_pt component);
+static celix_status_t component_invokeAutoConfigInstanceBoundDependencies(dm_component_pt component);
+static celix_status_t component_invokeAutoConfigDependencies(dm_component_pt component);
+static celix_status_t component_configureImplementation(dm_component_pt component, dm_service_dependency_pt dependency);
+static celix_status_t component_allInstanceBoundAvailable(dm_component_pt component, bool *available);
+static celix_status_t component_allRequiredAvailable(dm_component_pt component, bool *available);
+static celix_status_t component_performTransition(dm_component_pt component, dm_component_state_t oldState, dm_component_state_t newState, bool *transition);
+static celix_status_t component_calculateNewState(dm_component_pt component, dm_component_state_t currentState, dm_component_state_t *newState);
+static celix_status_t component_handleChange(dm_component_pt component);
+static celix_status_t component_startDependencies(dm_component_pt component __attribute__((unused)), array_list_pt dependencies);
+static celix_status_t component_getDependencyEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt *event_pptr);
+static celix_status_t component_updateInstance(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, bool update, bool add);
+
+static celix_status_t component_addTask(dm_component_pt component, dm_service_dependency_pt dep);
+static celix_status_t component_startTask(dm_component_pt component, void * data __attribute__((unused)));
+static celix_status_t component_stopTask(dm_component_pt component, void * data __attribute__((unused)));
+static celix_status_t component_removeTask(dm_component_pt component, dm_service_dependency_pt dependency);
+static celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_event_type_pt data);
+
+static celix_status_t component_handleAdded(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
+static celix_status_t component_handleChanged(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
+static celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
+static celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent);
+
+static celix_status_t component_suspend(dm_component_pt component, dm_service_dependency_pt dependency);
+static celix_status_t component_resume(dm_component_pt component, dm_service_dependency_pt dependency);
+
+celix_status_t component_create(bundle_context_pt context, const char *name, dm_component_pt *out) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    dm_component_pt component = calloc(1, sizeof(*component));
+
+    if (!component) {
+        status = CELIX_ENOMEM;
+    } else {
+        snprintf(component->id, DM_COMPONENT_MAX_ID_LENGTH, "%p", component);
+        snprintf(component->name, DM_COMPONENT_MAX_NAME_LENGTH, "%s", name == NULL ? "n/a" : name);
+
+        component->context = context;
+
+	    arrayList_create(&component->dm_interfaces);
+        arrayList_create(&(component)->dependencies);
+        pthread_mutex_init(&(component)->mutex, NULL);
+
+        component->implementation = NULL;
+
+        component->callbackInit = NULL;
+        component->callbackStart = NULL;
+        component->callbackStop = NULL;
+        component->callbackDeinit = NULL;
+
+        component->state = DM_CMP_STATE_INACTIVE;
+        component->isStarted = false;
+        component->active = false;
+
+        component->setCLanguageProperty = false;
+
+        component->dependencyEvents = hashMap_create(NULL, NULL, NULL, NULL);
+
+        component->executor = NULL;
+        executor_create(component, &component->executor);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        *out = component;
+    }
+
+    return status;
+}
+
+void component_destroy(dm_component_pt component) {
+	if (component) {
+		unsigned int i;
+
+		for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
+		    dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
+
+			if(interface->properties!=NULL){
+				properties_destroy(interface->properties);
+			}
+		    free (interface->serviceName);
+            free (interface);
+		}
+		arrayList_destroy(component->dm_interfaces);
+
+		executor_destroy(component->executor);
+
+		hash_map_iterator_pt iter = hashMapIterator_create(component->dependencyEvents);
+		while(hashMapIterator_hasNext(iter)){
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+			dm_service_dependency_pt sdep = (dm_service_dependency_pt)hashMapEntry_getKey(entry);
+			array_list_pt eventList = (array_list_pt)hashMapEntry_getValue(entry);
+			serviceDependency_destroy(&sdep);
+			arrayList_destroy(eventList);
+		}
+		hashMapIterator_destroy(iter);
+
+		hashMap_destroy(component->dependencyEvents, false, false);
+
+		arrayList_destroy(component->dependencies);
+		pthread_mutex_destroy(&component->mutex);
+
+		free(component);
+	}
+}
+
+celix_status_t component_addServiceDependency(dm_component_pt component, dm_service_dependency_pt dep) {
+    celix_status_t status = CELIX_SUCCESS;
+
+	executor_executeTask(component->executor, component, component_addTask, dep);
+
+    return status;
+}
+
+
+static celix_status_t component_addTask(dm_component_pt component, dm_service_dependency_pt dep) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    array_list_pt bounds = NULL;
+    arrayList_create(&bounds);
+
+    array_list_pt events = NULL;
+    arrayList_createWithEquals(event_equals, &events);
+
+    pthread_mutex_lock(&component->mutex);
+    hashMap_put(component->dependencyEvents, dep, events);
+    arrayList_add(component->dependencies, dep);
+    pthread_mutex_unlock(&component->mutex);
+
+    serviceDependency_setComponent(dep, component);
+
+    if (component->state != DM_CMP_STATE_INACTIVE) {
+        serviceDependency_setInstanceBound(dep, true);
+        arrayList_add(bounds, dep);
+    }
+    component_startDependencies(component, bounds);
+    component_handleChange(component);
+
+    arrayList_destroy(bounds);
+
+    return status;
+}
+
+dm_component_state_t component_currentState(dm_component_pt cmp) {
+    return cmp->state;
+}
+
+void * component_getImplementation(dm_component_pt cmp) {
+    return cmp->implementation;
+}
+
+const char * component_getName(dm_component_pt cmp) {
+    return cmp->name;
+}
+
+celix_status_t component_removeServiceDependency(dm_component_pt component, dm_service_dependency_pt dependency) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    executor_executeTask(component->executor, component, component_removeTask, dependency);
+
+    return status;
+}
+
+celix_status_t component_removeTask(dm_component_pt component, dm_service_dependency_pt dependency) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    arrayList_removeElement(component->dependencies, dependency);
+    pthread_mutex_unlock(&component->mutex);
+
+    if (component->state != DM_CMP_STATE_INACTIVE) {
+        serviceDependency_stop(dependency);
+    }
+
+    pthread_mutex_lock(&component->mutex);
+    array_list_pt events = hashMap_remove(component->dependencyEvents, dependency);
+    pthread_mutex_unlock(&component->mutex);
+
+	serviceDependency_destroy(&dependency);
+
+    while (!arrayList_isEmpty(events)) {
+    	dm_event_pt event = arrayList_remove(events, 0);
+    	event_destroy(&event);
+    }
+    arrayList_destroy(events);
+
+    component_handleChange(component);
+
+    return status;
+}
+
+celix_status_t component_start(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    component->active = true;
+    executor_executeTask(component->executor, component, component_startTask, NULL);
+
+    return status;
+}
+
+celix_status_t component_startTask(dm_component_pt component, void  *data __attribute__((unused))) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    component->isStarted = true;
+    component_handleChange(component);
+
+    return status;
+}
+
+celix_status_t component_stop(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    component->active = false;
+    executor_executeTask(component->executor, component, component_stopTask, NULL);
+
+    return status;
+}
+
+celix_status_t component_stopTask(dm_component_pt component, void *data __attribute__((unused))) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    component->isStarted = false;
+    component_handleChange(component);
+    component->active = false;
+
+    return status;
+}
+
+celix_status_t component_setCLanguageProperty(dm_component_pt component, bool setCLangProp) {
+    component->setCLanguageProperty = setCLangProp;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t component_addInterface(dm_component_pt component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (component->active) {
+        return CELIX_ILLEGAL_STATE;
+    } else {
+        dm_interface_t *interface = (dm_interface_t *) calloc(1, sizeof(*interface));
+        char *name = strdup(serviceName);
+
+        if (properties == NULL) {
+            properties = properties_create();
+        }
+
+        if ((properties_get(properties, CELIX_FRAMEWORK_SERVICE_VERSION) == NULL) && (serviceVersion != NULL)) {
+            properties_set(properties, CELIX_FRAMEWORK_SERVICE_VERSION, serviceVersion);
+        }
+
+        if (component->setCLanguageProperty && properties_get(properties, CELIX_FRAMEWORK_SERVICE_LANGUAGE) == NULL) { //always set default lang to C
+            properties_set(properties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+        }
+
+        if (interface && name) {
+            interface->serviceName = name;
+            interface->service = service;
+            interface->properties = properties;
+            interface->registration = NULL;
+            arrayList_add(component->dm_interfaces, interface);
+        } else {
+            free(interface);
+            free(name);
+            status = CELIX_ENOMEM;
+        }
+    }
+
+    return status;
+}
+
+celix_status_t component_getInterfaces(dm_component_pt component, array_list_pt *out) {
+    celix_status_t status = CELIX_SUCCESS;
+    array_list_pt names = NULL;
+    arrayList_create(&names);
+    celixThreadMutex_lock(&component->mutex);
+    int size = arrayList_size(component->dm_interfaces);
+    int i;
+    for (i = 0; i < size; i += 1) {
+        dm_interface_info_pt info = calloc(1, sizeof(*info));
+        dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
+        info->name = strdup(interface->serviceName);
+        properties_copy(interface->properties, &info->properties);
+        arrayList_add(names, info);
+    }
+    celixThreadMutex_unlock(&component->mutex);
+
+    if (status == CELIX_SUCCESS) {
+        *out = names;
+    }
+
+    return status;
+}
+
+celix_status_t component_handleEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	dm_handle_event_type_pt data = calloc(1, sizeof(*data));
+	data->dependency = dependency;
+	data->event = event;
+	data->newEvent = NULL;
+
+	status = executor_executeTask(component->executor, component, component_handleEventTask, data);
+//	component_handleEventTask(component, data);
+
+	return status;
+}
+
+celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_event_type_pt data) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	switch (data->event->event_type) {
+		case DM_EVENT_ADDED:
+			component_handleAdded(component,data->dependency, data->event);
+			break;
+		case DM_EVENT_CHANGED:
+			component_handleChanged(component,data->dependency, data->event);
+			break;
+		case DM_EVENT_REMOVED:
+			component_handleRemoved(component,data->dependency, data->event);
+			break;
+		case DM_EVENT_SWAPPED:
+			component_handleSwapped(component,data->dependency, data->event, data->newEvent);
+			break;
+		default:
+			break;
+	}
+
+	free(data);
+
+	return status;
+}
+
+static celix_status_t component_suspend(dm_component_pt component, dm_service_dependency_pt dependency) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	dm_service_dependency_strategy_t strategy;
+	serviceDependency_getStrategy(dependency, &strategy);
+	if (strategy == DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND &&  component->callbackStop != NULL) {
+		status = component->callbackStop(component->implementation);
+	}
+
+	return status;
+}
+
+static celix_status_t component_resume(dm_component_pt component, dm_service_dependency_pt dependency) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	dm_service_dependency_strategy_t strategy;
+	serviceDependency_getStrategy(dependency, &strategy);
+	if (strategy == DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND &&  component->callbackStop != NULL) {
+		status = component->callbackStart(component->implementation);
+	}
+
+	return status;
+}
+
+celix_status_t component_handleAdded(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+    arrayList_add(events, event);
+    pthread_mutex_unlock(&component->mutex);
+
+    serviceDependency_setAvailable(dependency, true);
+
+    switch (component->state) {
+        case DM_CMP_STATE_WAITING_FOR_REQUIRED: {
+            serviceDependency_invokeSet(dependency, event);
+            bool required = false;
+            serviceDependency_isRequired(dependency, &required);
+            if (required) {
+                component_handleChange(component);
+            }
+            break;
+        }
+        case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
+            bool instanceBound = false;
+            serviceDependency_isInstanceBound(dependency, &instanceBound);
+            bool required = false;
+            serviceDependency_isRequired(dependency, &required);
+            if (!instanceBound) {
+                if (required) {
+                    serviceDependency_invokeSet(dependency, event);
+                    serviceDependency_invokeAdd(dependency, event);
+                }
+                dm_event_pt event = NULL;
+                component_getDependencyEvent(component, dependency, &event);
+                component_updateInstance(component, dependency, event, false, true);
+            }
+
+            if (required) {
+                component_handleChange(component);
+            }
+            break;
+        }
+        case DM_CMP_STATE_TRACKING_OPTIONAL:
+		    component_suspend(component,dependency);
+            serviceDependency_invokeSet(dependency, event);
+            serviceDependency_invokeAdd(dependency, event);
+		    component_resume(component,dependency);
+            dm_event_pt event = NULL;
+            component_getDependencyEvent(component, dependency, &event);
+            component_updateInstance(component, dependency, event, false, true);
+            break;
+        default:
+            break;
+    }
+
+    return status;
+}
+
+celix_status_t component_handleChanged(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+    int index = arrayList_indexOf(events, event);
+    if (index < 0) {
+	pthread_mutex_unlock(&component->mutex);
+        status = CELIX_BUNDLE_EXCEPTION;
+    } else {
+        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
+        arrayList_add(events, event);
+        pthread_mutex_unlock(&component->mutex);
+
+        serviceDependency_invokeSet(dependency, event);
+        switch (component->state) {
+            case DM_CMP_STATE_TRACKING_OPTIONAL:
+			    component_suspend(component,dependency);
+                serviceDependency_invokeChange(dependency, event);
+			    component_resume(component,dependency);
+                dm_event_pt hevent = NULL;
+                component_getDependencyEvent(component, dependency, &hevent);
+                component_updateInstance(component, dependency, hevent, true, false);
+                break;
+            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
+                bool instanceBound = false;
+                serviceDependency_isInstanceBound(dependency, &instanceBound);
+                if (!instanceBound) {
+                    serviceDependency_invokeChange(dependency, event);
+                    dm_event_pt hevent = NULL;
+                    component_getDependencyEvent(component, dependency, &hevent);
+                    component_updateInstance(component, dependency, hevent, true, false);
+                }
+                break;
+            }
+            default:
+                break;
+        }
+
+        event_destroy(&old);
+    }
+
+    return status;
+}
+
+celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+    int size = arrayList_size(events);
+    if (arrayList_contains(events, event)) {
+        size--;
+    }
+    pthread_mutex_unlock(&component->mutex);
+    serviceDependency_setAvailable(dependency, size > 0);
+    component_handleChange(component);
+
+    pthread_mutex_lock(&component->mutex);
+    int index = arrayList_indexOf(events, event);
+    if (index < 0) {
+	pthread_mutex_unlock(&component->mutex);
+        status = CELIX_BUNDLE_EXCEPTION;
+    } else {
+        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
+        pthread_mutex_unlock(&component->mutex);
+
+
+        switch (component->state) {
+            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
+                serviceDependency_invokeSet(dependency, event);
+                bool instanceBound = false;
+                serviceDependency_isInstanceBound(dependency, &instanceBound);
+                if (!instanceBound) {
+                    bool required = false;
+                    serviceDependency_isRequired(dependency, &required);
+                    if (required) {
+                        serviceDependency_invokeRemove(dependency, event);
+                    }
+                    dm_event_pt hevent = NULL;
+                    component_getDependencyEvent(component, dependency, &hevent);
+                    component_updateInstance(component, dependency, hevent, false, false);
+                }
+                break;
+            }
+            case DM_CMP_STATE_TRACKING_OPTIONAL:
+			    component_suspend(component,dependency);
+                serviceDependency_invokeSet(dependency, event);
+                serviceDependency_invokeRemove(dependency, event);
+			    component_resume(component,dependency);
+                dm_event_pt hevent = NULL;
+                component_getDependencyEvent(component, dependency, &hevent);
+                component_updateInstance(component, dependency, hevent, false, false);
+                break;
+            default:
+                break;
+        }
+
+        event_destroy(&event);
+        if (old) {
+            event_destroy(&old);
+        }
+    }
+
+    return status;
+}
+
+celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+    int index = arrayList_indexOf(events, event);
+    if (index < 0) {
+	pthread_mutex_unlock(&component->mutex);
+        status = CELIX_BUNDLE_EXCEPTION;
+    } else {
+        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
+        arrayList_add(events, newEvent);
+        pthread_mutex_unlock(&component->mutex);
+
+        serviceDependency_invokeSet(dependency, event);
+
+        switch (component->state) {
+            case DM_CMP_STATE_WAITING_FOR_REQUIRED:
+                break;
+            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
+                bool instanceBound = false;
+                serviceDependency_isInstanceBound(dependency, &instanceBound);
+                if (!instanceBound) {
+                    bool required = false;
+                    serviceDependency_isRequired(dependency, &required);
+                    if (required) {
+                        serviceDependency_invokeSwap(dependency, event, newEvent);
+                    }
+                }
+                break;
+            }
+            case DM_CMP_STATE_TRACKING_OPTIONAL:
+			    component_suspend(component,dependency);
+                serviceDependency_invokeSwap(dependency, event, newEvent);
+			    component_resume(component,dependency);
+                break;
+            default:
+                break;
+        }
+
+        event_destroy(&event);
+        if (old) {
+            event_destroy(&old);
+        }
+    }
+
+    return status;
+}
+
+celix_status_t component_updateInstance(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, bool update, bool add) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    bool autoConfig = false;
+
+    serviceDependency_isAutoConfig(dependency, &autoConfig);
+
+    if (autoConfig) {
+        const void *service = NULL;
+        const void **field = NULL;
+
+        if (event != NULL) {
+            event_getService(event, &service);
+        }
+        serviceDependency_getAutoConfig(dependency, &field);
+        serviceDependency_lock(dependency);
+        *field = service;
+        serviceDependency_unlock(dependency);
+    }
+
+    return status;
+}
+
+celix_status_t component_startDependencies(dm_component_pt component __attribute__((unused)), array_list_pt dependencies) {
+    celix_status_t status = CELIX_SUCCESS;
+    array_list_pt required_dependencies = NULL;
+    arrayList_create(&required_dependencies);
+
+    for (unsigned int i = 0; i < arrayList_size(dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(dependencies, i);
+        bool required = false;
+        serviceDependency_isRequired(dependency, &required);
+        if (required) {
+            arrayList_add(required_dependencies, dependency);
+            continue;
+        }
+
+        serviceDependency_start(dependency);
+    }
+
+    for (unsigned int i = 0; i < arrayList_size(required_dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(required_dependencies, i);
+        serviceDependency_start(dependency);
+    }
+
+    arrayList_destroy(required_dependencies);
+
+    return status;
+}
+
+celix_status_t component_stopDependencies(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+        pthread_mutex_unlock(&component->mutex);
+        serviceDependency_stop(dependency);
+        pthread_mutex_lock(&component->mutex);
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_handleChange(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    dm_component_state_t oldState;
+    dm_component_state_t newState;
+
+    bool transition = false;
+    do {
+        oldState = component->state;
+        status = component_calculateNewState(component, oldState, &newState);
+        if (status == CELIX_SUCCESS) {
+            component->state = newState;
+            status = component_performTransition(component, oldState, newState, &transition);
+        }
+
+        if (status != CELIX_SUCCESS) {
+            break;
+        }
+    } while (transition);
+
+    return status;
+}
+
+celix_status_t component_calculateNewState(dm_component_pt component, dm_component_state_t currentState, dm_component_state_t *newState) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (currentState == DM_CMP_STATE_INACTIVE) {
+        if (component->isStarted) {
+            *newState = DM_CMP_STATE_WAITING_FOR_REQUIRED;
+        } else {
+            *newState = currentState;
+        }
+    } else if (currentState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
+        if (!component->isStarted) {
+            *newState = DM_CMP_STATE_INACTIVE;
+        } else {
+            bool available = false;
+            component_allRequiredAvailable(component, &available);
+
+            if (available) {
+                *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
+            } else {
+                *newState = currentState;
+            }
+        }
+    } else if (currentState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
+        if (!component->isStarted) {
+            *newState = DM_CMP_STATE_WAITING_FOR_REQUIRED;
+        } else {
+            bool available = false;
+            component_allRequiredAvailable(component, &available);
+
+            if (available) {
+                bool instanceBoundAvailable = false;
+                component_allInstanceBoundAvailable(component, &instanceBoundAvailable);
+
+                if (instanceBoundAvailable) {
+                    *newState = DM_CMP_STATE_TRACKING_OPTIONAL;
+                } else {
+                    *newState = currentState;
+                }
+            } else {
+                *newState = currentState;
+            }
+        }
+    } else if (currentState == DM_CMP_STATE_TRACKING_OPTIONAL) {
+        bool instanceBoundAvailable = false;
+        bool available = false;
+
+        component_allInstanceBoundAvailable(component, &instanceBoundAvailable);
+        component_allRequiredAvailable(component, &available);
+
+        if (component->isStarted && available && instanceBoundAvailable) {
+            *newState = currentState;
+        } else {
+            *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
+        }
+    } else {
+        //should not reach
+        *newState = DM_CMP_STATE_INACTIVE;
+        status = CELIX_BUNDLE_EXCEPTION;
+    }
+
+    return status;
+}
+
+celix_status_t component_performTransition(dm_component_pt component, dm_component_state_t oldState, dm_component_state_t newState, bool *transition) {
+    celix_status_t status = CELIX_SUCCESS;
+    //printf("performing transition for %s in thread %i from %i to %i\n", component->name, (int) pthread_self(), oldState, newState);
+
+    if (oldState == newState) {
+        *transition = false;
+    } else if (oldState == DM_CMP_STATE_INACTIVE && newState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
+        component_startDependencies(component, component->dependencies);
+        *transition = true;
+    } else if (oldState == DM_CMP_STATE_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
+        component_invokeAddRequiredDependencies(component);
+        component_invokeAutoConfigDependencies(component);
+        if (component->callbackInit) {
+        	status = component->callbackInit(component->implementation);
+        }
+        *transition = true;
+    } else if (oldState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_TRACKING_OPTIONAL) {
+        component_invokeAddRequiredInstanceBoundDependencies(component);
+        component_invokeAutoConfigInstanceBoundDependencies(component);
+		component_invokeAddOptionalDependencies(component);
+        if (component->callbackStart) {
+        	status = component->callbackStart(component->implementation);
+        }
+        component_registerServices(component);
+        *transition = true;
+    } else if (oldState == DM_CMP_STATE_TRACKING_OPTIONAL && newState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
+        component_unregisterServices(component);
+        if (component->callbackStop) {
+        	status = component->callbackStop(component->implementation);
+        }
+		component_invokeRemoveOptionalDependencies(component);
+        component_invokeRemoveInstanceBoundDependencies(component);
+        *transition = true;
+    } else if (oldState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
+    	if (component->callbackDeinit) {
+    		status = component->callbackDeinit(component->implementation);
+    	}
+        component_invokeRemoveRequiredDependencies(component);
+        *transition = true;
+    } else if (oldState == DM_CMP_STATE_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_INACTIVE) {
+        component_stopDependencies(component);
+        *transition = true;
+    }
+
+    return status;
+}
+
+celix_status_t component_allRequiredAvailable(dm_component_pt component, bool *available) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    *available = true;
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+        bool required = false;
+        bool instanceBound = false;
+
+        serviceDependency_isRequired(dependency, &required);
+        serviceDependency_isInstanceBound(dependency, &instanceBound);
+
+        if (required && !instanceBound) {
+            bool isAvailable = false;
+            serviceDependency_isAvailable(dependency, &isAvailable);
+            if (!isAvailable) {
+                *available = false;
+                break;
+            }
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_allInstanceBoundAvailable(dm_component_pt component, bool *available) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    *available = true;
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+        bool required = false;
+        bool instanceBound = false;
+
+        serviceDependency_isRequired(dependency, &required);
+        serviceDependency_isInstanceBound(dependency, &instanceBound);
+
+        if (required && instanceBound) {
+            bool isAvailable = false;
+            serviceDependency_isAvailable(dependency, &isAvailable);
+            if (!isAvailable) {
+                *available = false;
+                break;
+            }
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_invokeAddRequiredDependencies(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+
+        bool required = false;
+        bool instanceBound = false;
+
+        serviceDependency_isRequired(dependency, &required);
+        serviceDependency_isInstanceBound(dependency, &instanceBound);
+
+        if (required && !instanceBound) {
+            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+            if (events) {
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
+					serviceDependency_invokeAdd(dependency, event);
+				}
+            }
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_invokeAutoConfigDependencies(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+
+        bool autoConfig = false;
+        bool instanceBound = false;
+
+        serviceDependency_isAutoConfig(dependency, &autoConfig);
+        serviceDependency_isInstanceBound(dependency, &instanceBound);
+
+        if (autoConfig && !instanceBound) {
+            component_configureImplementation(component, dependency);
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_invokeAutoConfigInstanceBoundDependencies(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+
+        bool autoConfig = false;
+        bool instanceBound = false;
+
+        serviceDependency_isAutoConfig(dependency, &autoConfig);
+        serviceDependency_isInstanceBound(dependency, &instanceBound);
+
+        if (autoConfig && instanceBound) {
+            component_configureImplementation(component, dependency);
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_invokeAddRequiredInstanceBoundDependencies(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+
+        bool required = false;
+        bool instanceBound = false;
+
+        serviceDependency_isRequired(dependency, &required);
+        serviceDependency_isInstanceBound(dependency, &instanceBound);
+
+        if (instanceBound && required) {
+            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+            if (events) {
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
+					serviceDependency_invokeAdd(dependency, event);
+				}
+            }
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_invokeAddOptionalDependencies(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+
+        bool required = false;
+
+        serviceDependency_isRequired(dependency, &required);
+
+        if (!required) {
+            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+            if (events) {
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
+					serviceDependency_invokeAdd(dependency, event);
+				}
+            }
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_invokeRemoveOptionalDependencies(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+
+        bool required = false;
+
+        serviceDependency_isRequired(dependency, &required);
+
+        if (!required) {
+            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+            if (events) {
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
+					serviceDependency_invokeRemove(dependency, event);
+				}
+            }
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_invokeRemoveInstanceBoundDependencies(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+
+        bool instanceBound = false;
+
+        serviceDependency_isInstanceBound(dependency, &instanceBound);
+
+        if (instanceBound) {
+            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+            if (events) {
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
+					serviceDependency_invokeRemove(dependency, event);
+				}
+            }
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_invokeRemoveRequiredDependencies(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_mutex_lock(&component->mutex);
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+
+        bool required = false;
+        bool instanceBound = false;
+
+        serviceDependency_isRequired(dependency, &required);
+        serviceDependency_isInstanceBound(dependency, &instanceBound);
+
+        if (!instanceBound && required) {
+            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+            if (events) {
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
+					serviceDependency_invokeRemove(dependency, event);
+				}
+            }
+        }
+    }
+    pthread_mutex_unlock(&component->mutex);
+
+    return status;
+}
+
+celix_status_t component_getDependencyEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt *event_pptr) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+    *event_pptr = NULL;
+
+    if (events) {
+        for (unsigned int j = 0; j < arrayList_size(events); j++) {
+            dm_event_pt event_ptr = arrayList_get(events, j);
+            if (*event_pptr != NULL) {
+                int compare = 0;
+                event_compareTo(event_ptr, *event_pptr, &compare);
+                if (compare > 0) {
+                    *event_pptr = event_ptr;
+                }
+            } else {
+                *event_pptr = event_ptr;
+            }
+        }
+    }
+
+    return status;
+}
+
+celix_status_t component_configureImplementation(dm_component_pt component, dm_service_dependency_pt dependency) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    const void **field = NULL;
+
+    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
+    if (events) {
+        const void *service = NULL;
+        dm_event_pt event = NULL;
+        component_getDependencyEvent(component, dependency, &event);
+        if (event != NULL) {
+            event_getService(event, &service);
+            serviceDependency_getAutoConfig(dependency, &field);
+            serviceDependency_lock(dependency);
+            *field = service;
+            serviceDependency_unlock(dependency);
+        }
+    }
+
+    return status;
+}
+
+celix_status_t component_registerServices(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (component->context != NULL) {
+	    unsigned int i;
+        for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
+            dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
+                properties_pt regProps = NULL;
+                properties_copy(interface->properties, &regProps);
+                bundleContext_registerService(component->context, interface->serviceName, interface->service, regProps, &interface->registration);
+        }
+    }
+
+    return status;
+}
+
+celix_status_t component_unregisterServices(dm_component_pt component) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    unsigned int i;
+
+    for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
+	dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
+
+	serviceRegistration_unregister(interface->registration);
+	interface->registration = NULL;
+    }
+
+    return status;
+}
+
+celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit) {
+	if (component->active) {
+		return CELIX_ILLEGAL_STATE;
+	}
+	component->callbackInit = init;
+	component->callbackStart = start;
+	component->callbackStop = stop;
+	component->callbackDeinit = deinit;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t component_isAvailable(dm_component_pt component, bool *available) {
+    *available = component->state == DM_CMP_STATE_TRACKING_OPTIONAL;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t component_setImplementation(dm_component_pt component, void *implementation) {
+    component->implementation = implementation;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t component_getBundleContext(dm_component_pt component, bundle_context_pt *context) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!component) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*context = component->context;
+	}
+
+	return status;
+}
+
+
+static celix_status_t executor_create(dm_component_pt component __attribute__((unused)), dm_executor_pt *executor) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *executor = malloc(sizeof(**executor));
+    if (!*executor) {
+        status = CELIX_ENOMEM;
+    } else {
+        linkedList_create(&(*executor)->workQueue);
+        pthread_mutex_init(&(*executor)->mutex, NULL);
+        (*executor)->runningThreadSet = false;
+    }
+
+    return status;
+}
+
+static void executor_destroy(dm_executor_pt executor) {
+
+	if (executor) {
+		pthread_mutex_destroy(&executor->mutex);
+		linkedList_destroy(executor->workQueue);
+
+		free(executor);
+	}
+}
+
+static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt component, void (*command), void *data) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    dm_executor_task_t *task = NULL;
+    task = malloc(sizeof(*task));
+    if (!task) {
+        status = CELIX_ENOMEM;
+    } else {
+        task->component = component;
+        task->command = command;
+        task->data = data;
+
+        pthread_mutex_lock(&executor->mutex);
+        linkedList_addLast(executor->workQueue, task);
+        pthread_mutex_unlock(&executor->mutex);
+    }
+
+    return status;
+}
+
+static celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt component, void (*command), void *data) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    // Check thread and executor thread, if the same, execute immediately.
+//    bool execute = false;
+//    pthread_mutex_lock(&executor->mutex);
+//    pthread_t currentThread = pthread_self();
+//    if (pthread_equal(executor->runningThread, currentThread)) {
+//        execute = true;
+//    }
+//    pthread_mutex_unlock(&executor->mutex);
+
+    // For now, just schedule.
+    executor_schedule(executor, component, command, data);
+    executor_execute(executor);
+
+    return status;
+}
+
+static celix_status_t executor_execute(dm_executor_pt executor) {
+    celix_status_t status = CELIX_SUCCESS;
+    pthread_t currentThread = pthread_self();
+
+    pthread_mutex_lock(&executor->mutex);
+    bool execute = false;
+    if (!executor->runningThreadSet) {
+        executor->runningThread = currentThread;
+        executor->runningThreadSet = true;
+        execute = true;
+    }
+    pthread_mutex_unlock(&executor->mutex);
+    if (execute) {
+        executor_runTasks(executor, currentThread);
+    }
+
+    return status;
+}
+
+static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t currentThread __attribute__((unused))) {
+    celix_status_t status = CELIX_SUCCESS;
+//    bool execute = false;
+
+    do {
+        dm_executor_task_t *entry = NULL;
+        pthread_mutex_lock(&executor->mutex);
+        while ((entry = linkedList_removeFirst(executor->workQueue)) != NULL) {
+            pthread_mutex_unlock(&executor->mutex);
+
+            entry->command(entry->component, entry->data);
+
+            pthread_mutex_lock(&executor->mutex);
+
+            free(entry);
+        }
+        executor->runningThreadSet = false;
+        pthread_mutex_unlock(&executor->mutex);
+
+//        pthread_mutex_lock(&executor->mutex);
+//        if (executor->runningThread == NULL) {
+//            executor->runningThread = currentThread;
+//            execute = true;
+//        }
+//        pthread_mutex_unlock(&executor->mutex);
+    } while (!linkedList_isEmpty(executor->workQueue)); // && execute
+
+    return status;
+}
+
+celix_status_t component_getComponentInfo(dm_component_pt component, dm_component_info_pt *out) {
+    celix_status_t status = CELIX_SUCCESS;
+    int i;
+    int size;
+    dm_component_info_pt info = NULL;
+    info = calloc(1, sizeof(*info));
+
+    if (info == NULL) {
+        return CELIX_ENOMEM;
+    }
+
+    arrayList_create(&info->dependency_list);
+    component_getInterfaces(component, &info->interfaces);
+    info->active = false;
+    memcpy(info->id, component->id, DM_COMPONENT_MAX_ID_LENGTH);
+    memcpy(info->name, component->name, DM_COMPONENT_MAX_NAME_LENGTH);
+
+    switch (component->state) {
+        case DM_CMP_STATE_INACTIVE :
+            info->state = strdup("INACTIVE");
+            break;
+        case DM_CMP_STATE_WAITING_FOR_REQUIRED :
+            info->state = strdup("WAITING_FOR_REQUIRED");
+            break;
+        case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED :
+            info->state = strdup("INSTANTIATED_AND_WAITING_FOR_REQUIRED");
+            break;
+        case DM_CMP_STATE_TRACKING_OPTIONAL :
+            info->state = strdup("TRACKING_OPTIONAL");
+            info->active = true;
+            break;
+        default :
+            info->state = strdup("UNKNOWN");
+            break;
+    }
+
+    celixThreadMutex_lock(&component->mutex);
+    size = arrayList_size(component->dependencies);
+    for (i = 0; i < size; i += 1) {
+        dm_service_dependency_pt dep = arrayList_get(component->dependencies, i);
+        dm_service_dependency_info_pt depInfo = NULL;
+        status = serviceDependency_getServiceDependencyInfo(dep, &depInfo);
+        if (status == CELIX_SUCCESS) {
+            arrayList_add(info->dependency_list, depInfo);
+        } else {
+            break;
+        }
+    }
+    celixThreadMutex_unlock(&component->mutex);
+
+    if (status == CELIX_SUCCESS) {
+        *out = info;
+    } else if (info != NULL) {
+        component_destroyComponentInfo(info);
+    }
+
+    return status;
+}
+
+void component_destroyComponentInfo(dm_component_info_pt info) {
+    int i;
+    int size;
+    if (info != NULL) {
+        free(info->state);
+
+        if (info->interfaces != NULL) {
+            size = arrayList_size(info->interfaces);
+            for (i = 0; i < size; i += 1) {
+                dm_interface_info_pt intfInfo = arrayList_get(info->interfaces, i);
+                free(intfInfo->name);
+                properties_destroy(intfInfo->properties);
+                free(intfInfo);
+            }
+            arrayList_destroy(info->interfaces);
+        }
+        if (info->dependency_list != NULL) {
+            size = arrayList_size(info->dependency_list);
+            for (i = 0; i < size; i += 1) {
+                dm_service_dependency_info_pt depInfo = arrayList_get(info->dependency_list, i);
+                dependency_destroyDependencyInfo(depInfo);
+            }
+            arrayList_destroy(info->dependency_list);
+        }
+    }
+    free(info);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_component_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_component_impl.h b/dependency_manager/src/dm_component_impl.h
new file mode 100644
index 0000000..495197c
--- /dev/null
+++ b/dependency_manager/src/dm_component_impl.h
@@ -0,0 +1,48 @@
+/**
+ *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.
+ */
+/*
+ * dm_component_impl.h
+ *
+ *  \date       22 Feb 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef COMPONENT_IMPL_H_
+#define COMPONENT_IMPL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "dm_component.h"
+#include "dm_service_dependency_impl.h"
+#include "dm_event.h"
+
+celix_status_t component_start(dm_component_pt component);
+
+celix_status_t component_stop(dm_component_pt component);
+
+celix_status_t component_handleEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* COMPONENT_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_dependency.h b/dependency_manager/src/dm_dependency.h
new file mode 100644
index 0000000..6923239
--- /dev/null
+++ b/dependency_manager/src/dm_dependency.h
@@ -0,0 +1,41 @@
+/**
+ *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.
+ */
+/*
+ * dm_dependency.h
+ *
+ *  \date       22 Feb 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef DM_DEPENDENCY_H_
+#define DM_DEPENDENCY_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_DEPENDENCY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_dependency_manager_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_dependency_manager_impl.c b/dependency_manager/src/dm_dependency_manager_impl.c
new file mode 100644
index 0000000..4864be1
--- /dev/null
+++ b/dependency_manager/src/dm_dependency_manager_impl.c
@@ -0,0 +1,129 @@
+/**
+ * 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.
+ */
+
+/*
+ * dm_dependency_manager_impl.c
+ *
+ *  \date       26 Jul 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <dm_dependency_manager.h>
+
+#include "bundle_context.h"
+#include "dm_component_impl.h"
+#include "dm_dependency_manager_impl.h"
+
+
+celix_status_t dependencyManager_create(bundle_context_pt context __attribute__((unused)), dm_dependency_manager_pt *manager) {
+	celix_status_t status = CELIX_ENOMEM;
+
+	(*manager) = calloc(1, sizeof(**manager));
+
+	if (*manager) {
+		arrayList_create(&(*manager)->components);
+
+		status = CELIX_SUCCESS;
+	}
+
+	return status;
+
+}
+
+void dependencyManager_destroy(dm_dependency_manager_pt manager) {
+	if (manager != NULL) {
+		arrayList_destroy(manager->components);
+		free(manager);
+	}
+}
+
+celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component) {
+	celix_status_t status;
+
+	arrayList_add(manager->components, component);
+	status = component_start(component);
+
+	return status;
+}
+
+celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	unsigned int i=0;
+	unsigned int size = arrayList_size(manager->components);
+
+	for(;i<size;i++){
+		dm_component_pt cmp = arrayList_get(manager->components, i);
+//		printf("Stopping comp %s\n", component_getName(cmp));
+		component_stop(cmp);
+	}
+
+	while (!arrayList_isEmpty(manager->components)) {
+		dm_component_pt cmp = arrayList_remove(manager->components, 0);
+//        printf("Removing comp %s\n", component_getName(cmp));
+        component_destroy(cmp);
+	}
+
+	return status;
+}
+
+celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt *out) {
+	celix_status_t status = CELIX_SUCCESS;
+	int i;
+	int size;
+	dm_component_info_pt cmpInfo = NULL;
+	dm_dependency_manager_info_pt info = calloc(1, sizeof(*info));
+
+	celixThreadMutex_lock(&manager->mutex);
+
+	if (info != NULL) {
+		arrayList_create(&info->components);
+		size = arrayList_size(manager->components);
+		for (i = 0; i < size; i += 1) {
+			dm_component_pt cmp = arrayList_get(manager->components, i);
+			cmpInfo = NULL;
+			component_getComponentInfo(cmp, &cmpInfo);
+			arrayList_add(info->components, cmpInfo);
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	celixThreadMutex_unlock(&manager->mutex);
+
+	if (status == CELIX_SUCCESS) {
+		*out = info;
+	}
+
+	return status;
+}
+
+void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt info) {
+    unsigned int i = 0;
+    for (; i < arrayList_size(info->components); i += 1) {
+        dm_component_info_pt cmpinfo = (dm_component_info_pt)arrayList_get(info->components, i);
+        component_destroyComponentInfo(cmpinfo);
+    }
+    arrayList_destroy(info->components);
+    free(info);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_dependency_manager_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_dependency_manager_impl.h b/dependency_manager/src/dm_dependency_manager_impl.h
new file mode 100644
index 0000000..c673605
--- /dev/null
+++ b/dependency_manager/src/dm_dependency_manager_impl.h
@@ -0,0 +1,45 @@
+/**
+ *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.
+ */
+/*
+ * dm_dependency_manager_impl.h
+ *
+ *  \date       15 Oct 2015
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
+#define CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct dm_dependency_manager {
+    array_list_pt components;
+
+    pthread_mutex_t mutex;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //CELIX_DM_DEPENDENCY_MANAGER_IMPL_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_event.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_event.c b/dependency_manager/src/dm_event.c
new file mode 100644
index 0000000..9341832
--- /dev/null
+++ b/dependency_manager/src/dm_event.c
@@ -0,0 +1,105 @@
+/**
+ * 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.
+ */
+
+/*
+ * dm_event.c
+ *
+ *  \date       18 Dec 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <constants.h>
+#include <utils.h>
+
+#include "dm_event.h"
+
+celix_status_t event_create(dm_event_type_e event_type, bundle_pt bundle, bundle_context_pt context, service_reference_pt reference, const void *service, dm_event_pt *event) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*event = calloc(1, sizeof(**event));
+	if (!*event) {
+		status = CELIX_ENOMEM;
+	}
+
+	const char* serviceIdStr = NULL;
+	serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &serviceIdStr);
+	unsigned long servId = strtoul(serviceIdStr,NULL,10);
+
+	//FIXME service ranking can dynamicly change, but service reference can be removed at any time.
+	const char* rankingStr = NULL;
+	serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rankingStr);
+	long ranking = rankingStr == NULL ? 0 : atol(rankingStr);
+
+	if (status == CELIX_SUCCESS) {
+		(*event)->bundle = bundle;
+		(*event)->event_type = event_type;
+		(*event)->context = context;
+		(*event)->reference = reference;
+		(*event)->service = service;
+		(*event)->serviceId = servId;
+		(*event)->ranking = ranking;
+	}
+
+	return status;
+}
+
+celix_status_t event_destroy(dm_event_pt *event) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!*event) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		free(*event);
+		*event = NULL;
+	}
+
+	return status;
+}
+
+celix_status_t event_equals(const void *a, const void *b, bool *equals) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!a || !b) {
+		*equals = false;
+	} else {
+		dm_event_pt a_ptr = (dm_event_pt)a;
+		dm_event_pt b_ptr = (dm_event_pt)b;
+
+		*equals = a_ptr->serviceId == b_ptr->serviceId;
+	}
+
+	return status;
+}
+
+celix_status_t event_compareTo(dm_event_pt event, dm_event_pt compareTo, int *compare) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*compare = utils_compareServiceIdsAndRanking(event->serviceId, event->ranking, compareTo->serviceId, compareTo->ranking);
+
+	return status;
+}
+
+celix_status_t event_getService(dm_event_pt event, const void **service) {
+	*service = event->service;
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_event.h
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_event.h b/dependency_manager/src/dm_event.h
new file mode 100644
index 0000000..1cccd47
--- /dev/null
+++ b/dependency_manager/src/dm_event.h
@@ -0,0 +1,72 @@
+/**
+ *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.
+ */
+/*
+ * dm_event.h
+ *
+ *  \date       17 Oct 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef DM_EVENT_H_
+#define DM_EVENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "service_reference.h"
+#include "bundle_context.h"
+#include "bundle.h"
+
+enum dm_event_type {
+	DM_EVENT_ADDED,
+	DM_EVENT_CHANGED,
+	DM_EVENT_REMOVED,
+	DM_EVENT_SWAPPED,
+};
+
+typedef enum dm_event_type dm_event_type_e;
+
+struct dm_event {
+	const void* service;
+	unsigned long serviceId;
+	long ranking;
+	service_reference_pt reference;
+	bundle_context_pt context;
+	bundle_pt bundle;
+	dm_event_type_e event_type;
+};
+
+typedef struct dm_event *dm_event_pt;
+
+
+celix_status_t event_create(dm_event_type_e event_type, bundle_pt bundle, bundle_context_pt context, service_reference_pt reference, const void* service, dm_event_pt *event);
+celix_status_t event_destroy(dm_event_pt* event);
+
+celix_status_t event_equals(const void* a, const void* b, bool* equals);
+
+celix_status_t event_getService(dm_event_pt event, const void** service);
+celix_status_t event_compareTo(dm_event_pt event, dm_event_pt compareTo, int* compare);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_EVENT_H_ */


[23/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/framework.c
----------------------------------------------------------------------
diff --git a/framework/private/src/framework.c b/framework/private/src/framework.c
deleted file mode 100644
index b1db384..0000000
--- a/framework/private/src/framework.c
+++ /dev/null
@@ -1,2620 +0,0 @@
-/**
- *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.
- */
-/*
- * framework.c
- *
- *  \date       Mar 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include "celixbool.h"
-
-#ifdef _WIN32
-#include <winbase.h>
-#include <windows.h>
-#else
-#include <dlfcn.h>
-#endif
-#include <uuid/uuid.h>
-
-#include "framework_private.h"
-#include "constants.h"
-#include "resolver.h"
-#include "utils.h"
-#include "linked_list_iterator.h"
-#include "service_reference_private.h"
-#include "listener_hook_service.h"
-#include "service_registration_private.h"
-
-typedef celix_status_t (*create_function_pt)(bundle_context_pt context, void **userData);
-typedef celix_status_t (*start_function_pt)(void * handle, bundle_context_pt context);
-typedef celix_status_t (*stop_function_pt)(void * handle, bundle_context_pt context);
-typedef celix_status_t (*destroy_function_pt)(void * handle, bundle_context_pt context);
-
-struct activator {
-    void * userData;
-    start_function_pt start;
-    stop_function_pt stop;
-    destroy_function_pt destroy;
-};
-
-celix_status_t framework_setBundleStateAndNotify(framework_pt framework, bundle_pt bundle, int state);
-celix_status_t framework_markBundleResolved(framework_pt framework, module_pt module);
-
-celix_status_t framework_acquireBundleLock(framework_pt framework, bundle_pt bundle, int desiredStates);
-bool framework_releaseBundleLock(framework_pt framework, bundle_pt bundle);
-
-bool framework_acquireGlobalLock(framework_pt framework);
-celix_status_t framework_releaseGlobalLock(framework_pt framework);
-
-celix_status_t framework_acquireInstallLock(framework_pt framework, const char* location);
-celix_status_t framework_releaseInstallLock(framework_pt framework, const char* location);
-
-long framework_getNextBundleId(framework_pt framework);
-
-celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char * location, const char *inputFile, bundle_archive_pt archive);
-
-celix_status_t fw_refreshBundles(framework_pt framework, bundle_pt bundles[], int size);
-celix_status_t fw_refreshBundle(framework_pt framework, bundle_pt bundle);
-
-celix_status_t fw_populateDependentGraph(framework_pt framework, bundle_pt exporter, hash_map_pt *map);
-
-celix_status_t fw_fireBundleEvent(framework_pt framework, bundle_event_type_e, bundle_pt bundle);
-celix_status_t fw_fireFrameworkEvent(framework_pt framework, framework_event_type_e eventType, bundle_pt bundle, celix_status_t errorCode);
-static void *fw_eventDispatcher(void *fw);
-
-celix_status_t fw_invokeBundleListener(framework_pt framework, bundle_listener_pt listener, bundle_event_pt event, bundle_pt bundle);
-celix_status_t fw_invokeFrameworkListener(framework_pt framework, framework_listener_pt listener, framework_event_pt event, bundle_pt bundle);
-
-static celix_status_t framework_loadBundleLibraries(framework_pt framework, bundle_pt bundle);
-static celix_status_t framework_loadLibraries(framework_pt framework, const char* libraries, const char* activator, bundle_archive_pt archive, void **activatorHandle);
-static celix_status_t framework_loadLibrary(framework_pt framework, const char* library, bundle_archive_pt archive, void **handle);
-
-static celix_status_t frameworkActivator_start(void * userData, bundle_context_pt context);
-static celix_status_t frameworkActivator_stop(void * userData, bundle_context_pt context);
-static celix_status_t frameworkActivator_destroy(void * userData, bundle_context_pt context);
-
-
-struct fw_refreshHelper {
-    framework_pt framework;
-    bundle_pt bundle;
-    bundle_state_e oldState;
-};
-
-celix_status_t fw_refreshHelper_refreshOrRemove(struct fw_refreshHelper * refreshHelper);
-celix_status_t fw_refreshHelper_restart(struct fw_refreshHelper * refreshHelper);
-celix_status_t fw_refreshHelper_stop(struct fw_refreshHelper * refreshHelper);
-
-struct fw_serviceListener {
-	bundle_pt bundle;
-	service_listener_pt listener;
-	filter_pt filter;
-    array_list_pt retainedReferences;
-};
-
-typedef struct fw_serviceListener * fw_service_listener_pt;
-
-struct fw_bundleListener {
-	bundle_pt bundle;
-	bundle_listener_pt listener;
-};
-
-typedef struct fw_bundleListener * fw_bundle_listener_pt;
-
-struct fw_frameworkListener {
-	bundle_pt bundle;
-	framework_listener_pt listener;
-};
-
-typedef struct fw_frameworkListener * fw_framework_listener_pt;
-
-enum event_type {
-	FRAMEWORK_EVENT_TYPE,
-	BUNDLE_EVENT_TYPE,
-	EVENT_TYPE_SERVICE,
-};
-
-typedef enum event_type event_type_e;
-
-struct request {
-	event_type_e type;
-	array_list_pt listeners;
-
-	int eventType;
-	long bundleId;
-	char* bundleSymbolicName;
-	celix_status_t errorCode;
-	char *error;
-
-	char *filter;
-};
-
-typedef struct request *request_pt;
-
-framework_logger_pt logger;
-
-//TODO introduce a counter + mutex to control the freeing of the logger when mutiple threads are running a framework.
-static celix_thread_once_t loggerInit = CELIX_THREAD_ONCE_INIT;
-static void framework_loggerInit(void) {
-    logger = malloc(sizeof(*logger));
-    logger->logFunction = frameworkLogger_log;
-}
-
-/* Note: RTLD_NODELETE flag is needed in order to obtain a readable valgrind output.
- * Valgrind output is written when the application terminates, so symbols resolving
- * is impossible if dlopened libraries are unloaded before the application ends.
- * RTLD_NODELETE closes the dynamic library but does not unload it from the memory space,
- * so that symbols will be available until the application terminates.
- * On the other hand, since the memory mapping is not destroyed after dlclose, calling again
- * dlopen for the same library clashes with the previous mapping: this breaks the memory layout
- * in case the user, for example, uninstall (dlclose) and install the bundle again (dlopen)
- * So, RTLD_NODELETE should be used only for debugging purposes.
- * Refer to dlopen manpage for additional details about libraries dynamic loading.
- */
-#ifdef _WIN32
-    #define handle_t HMODULE
-    #define fw_openLibrary(path) LoadLibrary(path)
-    #define fw_closeLibrary(handle) FreeLibrary(handle)
-
-    #define fw_getSymbol(handle, name) GetProcAddress(handle, name)
-
-    #define fw_getLastError() GetLastError()
-
-    HMODULE fw_getCurrentModule() {
-        HMODULE hModule = NULL;
-        GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)fw_getCurrentModule, &hModule);
-        return hModule;
-    }
-#else
-    #define handle_t void *
-    #if defined(DEBUG) && !defined(ANDROID)
-	#define fw_openLibrary(path) dlopen(path, RTLD_LAZY|RTLD_LOCAL|RTLD_NODELETE)
-    #else
-	#define fw_openLibrary(path) dlopen(path, RTLD_LAZY|RTLD_LOCAL)
-    #endif
-    #define fw_closeLibrary(handle) dlclose(handle)
-    #define fw_getSymbol(handle, name) dlsym(handle, name)
-    #define fw_getLastError() dlerror()
-#endif
-
-celix_status_t framework_create(framework_pt *framework, properties_pt config) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    logger = hashMap_get(config, "logger");
-    if (logger == NULL) {
-        celixThread_once(&loggerInit, framework_loggerInit);
-    }
-
-    *framework = (framework_pt) malloc(sizeof(**framework));
-    if (*framework != NULL) {
-        status = CELIX_DO_IF(status, celixThreadCondition_init(&(*framework)->condition, NULL));
-        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->mutex, NULL));
-        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->installedBundleMapLock, NULL));
-        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->bundleLock, NULL));
-        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->installRequestLock, NULL));
-        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->dispatcherLock, NULL));
-        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->bundleListenerLock, NULL));
-        status = CELIX_DO_IF(status, celixThreadCondition_init(&(*framework)->dispatcher, NULL));
-        if (status == CELIX_SUCCESS) {
-            (*framework)->bundle = NULL;
-            (*framework)->installedBundleMap = NULL;
-            (*framework)->registry = NULL;
-            (*framework)->interrupted = false;
-            (*framework)->shutdown = false;
-            (*framework)->globalLockWaitersList = NULL;
-            (*framework)->globalLockCount = 0;
-            (*framework)->globalLockThread = celix_thread_default;
-            (*framework)->nextBundleId = 1l;
-            (*framework)->cache = NULL;
-            (*framework)->installRequestMap = hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
-            (*framework)->serviceListeners = NULL;
-            (*framework)->bundleListeners = NULL;
-            (*framework)->frameworkListeners = NULL;
-            (*framework)->requests = NULL;
-            (*framework)->configurationMap = config;
-            (*framework)->logger = logger;
-
-
-            status = CELIX_DO_IF(status, bundle_create(&(*framework)->bundle));
-            status = CELIX_DO_IF(status, arrayList_create(&(*framework)->globalLockWaitersList));
-            status = CELIX_DO_IF(status, bundle_setFramework((*framework)->bundle, (*framework)));
-            if (status == CELIX_SUCCESS) {
-                //
-            } else {
-                status = CELIX_FRAMEWORK_EXCEPTION;
-                fw_logCode((*framework)->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not create framework");
-            }
-        } else {
-            status = CELIX_FRAMEWORK_EXCEPTION;
-            fw_logCode((*framework)->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not create framework");
-        }
-    } else {
-        status = CELIX_FRAMEWORK_EXCEPTION;
-        fw_logCode(logger, OSGI_FRAMEWORK_LOG_ERROR, CELIX_ENOMEM, "Could not create framework");
-    }
-
-    return status;
-}
-
-celix_status_t framework_destroy(framework_pt framework) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    celixThreadMutex_lock(&framework->installedBundleMapLock);
-
-    if (framework->installedBundleMap != NULL) {
-        hash_map_iterator_pt iterator = hashMapIterator_create(framework->installedBundleMap);
-        while (hashMapIterator_hasNext(iterator)) {
-            hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
-            bundle_pt bundle = (bundle_pt) hashMapEntry_getValue(entry);
-            char * key = hashMapEntry_getKey(entry);
-            bundle_archive_pt archive = NULL;
-
-            bool systemBundle = false;
-            bundle_isSystemBundle(bundle, &systemBundle);
-            if (systemBundle) {
-                bundle_context_pt context = NULL;
-                bundle_getContext(framework->bundle, &context);
-                bundleContext_destroy(context);
-            }
-
-            if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
-                if (!systemBundle) {
-                    bundle_revision_pt revision = NULL;
-                    array_list_pt handles = NULL;
-                    status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
-                    status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
-                    if (handles != NULL) {
-                        for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
-                            void *handle = arrayList_get(handles, i);
-                            fw_closeLibrary(handle);
-                        }
-                    }
-                }
-
-                bundleArchive_destroy(archive);
-            }
-            bundle_destroy(bundle);
-            hashMapIterator_remove(iterator);
-            free(key);
-        }
-        hashMapIterator_destroy(iterator);
-    }
-
-    celixThreadMutex_unlock(&framework->installedBundleMapLock);
-
-	hashMap_destroy(framework->installRequestMap, false, false);
-
-	serviceRegistry_destroy(framework->registry);
-
-	arrayList_destroy(framework->globalLockWaitersList);
-
-    if (framework->serviceListeners != NULL) {
-        arrayList_destroy(framework->serviceListeners);
-    }
-    if (framework->bundleListeners) {
-        arrayList_destroy(framework->bundleListeners);
-    }
-    if (framework->frameworkListeners) {
-        arrayList_destroy(framework->frameworkListeners);
-    }
-
-	if(framework->requests){
-	    int i;
-	    for (i = 0; i < arrayList_size(framework->requests); i++) {
-	        request_pt request = arrayList_get(framework->requests, i);
-	        free(request);
-	    }
-	    arrayList_destroy(framework->requests);
-	}
-	if(framework->installedBundleMap!=NULL){
-		hashMap_destroy(framework->installedBundleMap, true, false);
-	}
-
-	bundleCache_destroy(&framework->cache);
-
-	celixThreadCondition_destroy(&framework->dispatcher);
-	celixThreadMutex_destroy(&framework->bundleListenerLock);
-	celixThreadMutex_destroy(&framework->dispatcherLock);
-	celixThreadMutex_destroy(&framework->installRequestLock);
-	celixThreadMutex_destroy(&framework->bundleLock);
-	celixThreadMutex_destroy(&framework->installedBundleMapLock);
-	celixThreadMutex_destroy(&framework->mutex);
-	celixThreadCondition_destroy(&framework->condition);
-
-    logger = hashMap_get(framework->configurationMap, "logger");
-    if (logger == NULL) {
-        free(framework->logger);
-    }
-
-    properties_destroy(framework->configurationMap);
-
-    free(framework);
-
-	return status;
-}
-
-celix_status_t fw_init(framework_pt framework) {
-	bundle_state_e state;
-	const char *location = NULL;
-	module_pt module = NULL;
-	linked_list_pt wires = NULL;
-	array_list_pt archives = NULL;
-	bundle_archive_pt archive = NULL;
-
-	celix_status_t status = CELIX_SUCCESS;
-	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-	status = CELIX_DO_IF(status, arrayList_create(&framework->serviceListeners));
-	status = CELIX_DO_IF(status, arrayList_create(&framework->bundleListeners));
-	status = CELIX_DO_IF(status, arrayList_create(&framework->frameworkListeners));
-	status = CELIX_DO_IF(status, arrayList_create(&framework->requests));
-	status = CELIX_DO_IF(status, celixThread_create(&framework->dispatcherThread, NULL, fw_eventDispatcher, framework));
-	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
-	if (status == CELIX_SUCCESS) {
-	    if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
-	        bundle_state_e state;
-	        status = CELIX_DO_IF(status, bundleCache_create(framework->configurationMap,&framework->cache));
-	        status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
-	        if (status == CELIX_SUCCESS) {
-	            if (state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) {
-	                const char *clean = properties_get(framework->configurationMap, OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN);
-	                if (clean != NULL && (strcmp(clean, OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT) == 0)) {
-	                    bundleCache_delete(framework->cache);
-	                }
-	            }
-            }
-        }
-	}
-
-	if (status == CELIX_SUCCESS) {
-        /*create and store framework uuid*/
-        char uuid[37];
-
-	    uuid_t uid;
-        uuid_generate(uid);
-        uuid_unparse(uid, uuid);
-
-        properties_set(framework->configurationMap, (char*) OSGI_FRAMEWORK_FRAMEWORK_UUID, uuid);
-
-        framework->installedBundleMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-	}
-
-    status = CELIX_DO_IF(status, bundle_getArchive(framework->bundle, &archive));
-    status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
-    if (status == CELIX_SUCCESS) {
-        hashMap_put(framework->installedBundleMap, strdup(location), framework->bundle);
-    }
-    status = CELIX_DO_IF(status, bundle_getCurrentModule(framework->bundle, &module));
-    if (status == CELIX_SUCCESS) {
-        wires = resolver_resolve(module);
-        if (wires != NULL) {
-            framework_markResolvedModules(framework, wires);
-        } else {
-            status = CELIX_BUNDLE_EXCEPTION;
-            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Unresolved constraints in System Bundle");
-        }
-    }
-
-    status = CELIX_DO_IF(status, bundleCache_getArchives(framework->cache, &archives));
-    if (status == CELIX_SUCCESS) {
-        unsigned int arcIdx;
-        for (arcIdx = 0; arcIdx < arrayList_size(archives); arcIdx++) {
-            bundle_archive_pt archive1 = (bundle_archive_pt) arrayList_get(archives, arcIdx);
-            long id;
-            bundle_state_e bundleState;
-            bundleArchive_getId(archive1, &id);
-            framework->nextBundleId = framework->nextBundleId > id + 1 ? framework->nextBundleId : id + 1;
-
-            bundleArchive_getPersistentState(archive1, &bundleState);
-            if (bundleState == OSGI_FRAMEWORK_BUNDLE_UNINSTALLED) {
-                bundleArchive_closeAndDelete(archive1);
-            } else {
-                bundle_pt bundle = NULL;
-                const char *location1 = NULL;
-                status = bundleArchive_getLocation(archive1, &location1);
-                fw_installBundle2(framework, &bundle, id, location1, NULL, archive1);
-            }
-        }
-        arrayList_destroy(archives);
-    }
-
-    status = CELIX_DO_IF(status, serviceRegistry_create(framework, fw_serviceChanged, &framework->registry));
-    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_STARTING));
-    status = CELIX_DO_IF(status, celixThreadCondition_init(&framework->shutdownGate, NULL));
-
-    bundle_context_pt context = NULL;
-    status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, framework->bundle, &context));
-    status = CELIX_DO_IF(status, bundle_setContext(framework->bundle, context));
-    if (status == CELIX_SUCCESS) {
-        activator_pt activator = NULL;
-        activator = (activator_pt) calloc(1,(sizeof(*activator)));
-        if (activator != NULL) {
-            bundle_context_pt context = NULL;
-            void * userData = NULL;
-
-			//create_function_pt create = NULL;
-			start_function_pt start = (start_function_pt) frameworkActivator_start;
-			stop_function_pt stop = (stop_function_pt) frameworkActivator_stop;
-			destroy_function_pt destroy = (destroy_function_pt) frameworkActivator_destroy;
-
-            activator->start = start;
-            activator->stop = stop;
-            activator->destroy = destroy;
-            status = CELIX_DO_IF(status, bundle_setActivator(framework->bundle, activator));
-            status = CELIX_DO_IF(status, bundle_getContext(framework->bundle, &context));
-
-            if (status == CELIX_SUCCESS) {
-                /* This code part is in principle dead, but in future it may do something.
-                 * That's why it's outcommented and not deleted
-		if (create != NULL) {
-                    create(context, &userData);
-                }
-                */
-                activator->userData = userData;
-
-                if (start != NULL) {
-                    start(userData, context);
-                }
-            }
-            else{
-            	free(activator);
-            }
-        } else {
-            status = CELIX_ENOMEM;
-        }
-    }
-
-    if (status != CELIX_SUCCESS) {
-       fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not init framework");
-    }
-
-    framework_releaseBundleLock(framework, framework->bundle);
-
-	return status;
-}
-
-celix_status_t framework_start(framework_pt framework) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
-
-	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
-	if (status == CELIX_SUCCESS) {
-	    if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
-	        status = CELIX_DO_IF(status, fw_init(framework));
-        }
-	}
-
-	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
-	if (status == CELIX_SUCCESS) {
-	    if (state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
-	        status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-	    }
-
-	    framework_releaseBundleLock(framework, framework->bundle);
-	}
-
-	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED, framework->bundle));
-	status = CELIX_DO_IF(status, fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_STARTED, framework->bundle, 0));
-
-	if (status != CELIX_SUCCESS) {
-       status = CELIX_BUNDLE_EXCEPTION;
-       fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start framework");
-       fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_ERROR, framework->bundle, status);
-    }
-
-	return status;
-}
-
-void framework_stop(framework_pt framework) {
-	fw_stopBundle(framework, framework->bundle, true);
-}
-
-celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** value) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (framework == NULL || name == NULL || *value != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		if (framework->configurationMap != NULL) {
-			*value = properties_get(framework->configurationMap, name);
-		}
-		if (*value == NULL) {
-			*value = getenv(name);
-		}
-        if (*value == NULL) {
-            *value = defaultValue;
-        }
-	}
-
-	return status;
-}
-
-celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, const char * location, const char *inputFile) {
-	return fw_installBundle2(framework, bundle, -1, location, inputFile, NULL);
-}
-
-celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char * location, const char *inputFile, bundle_archive_pt archive) {
-    celix_status_t status = CELIX_SUCCESS;
-//    bundle_archive_pt bundle_archive = NULL;
-    bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
-  	bool locked;
-
-  	status = CELIX_DO_IF(status, framework_acquireInstallLock(framework, location));
-  	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
-  	if (status == CELIX_SUCCESS) {
-        if (state == OSGI_FRAMEWORK_BUNDLE_STOPPING || state == OSGI_FRAMEWORK_BUNDLE_UNINSTALLED) {
-            fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO,  "The framework is being shutdown");
-            status = CELIX_DO_IF(status, framework_releaseInstallLock(framework, location));
-            status = CELIX_FRAMEWORK_SHUTDOWN;
-        }
-  	}
-
-    if (status == CELIX_SUCCESS) {
-        *bundle = framework_getBundle(framework, location);
-        if (*bundle != NULL) {
-            framework_releaseInstallLock(framework, location);
-            return CELIX_SUCCESS;
-        }
-
-        if (archive == NULL) {
-            id = framework_getNextBundleId(framework);
-
-            status = CELIX_DO_IF(status, bundleCache_createArchive(framework->cache, id, location, inputFile, &archive));
-
-            if (status != CELIX_SUCCESS) {
-            	bundleArchive_destroy(archive);
-            }
-        } else {
-            // purge revision
-            // multiple revisions not yet implemented
-        }
-
-        if (status == CELIX_SUCCESS) {
-            locked = framework_acquireGlobalLock(framework);
-            if (!locked) {
-                status = CELIX_BUNDLE_EXCEPTION;
-            } else {
-                status = CELIX_DO_IF(status, bundle_createFromArchive(bundle, framework, archive));
-
-                framework_releaseGlobalLock(framework);
-                if (status == CELIX_SUCCESS) {
-                    celixThreadMutex_lock(&framework->installedBundleMapLock);
-                    hashMap_put(framework->installedBundleMap, strdup(location), *bundle);
-                    celixThreadMutex_unlock(&framework->installedBundleMapLock);
-
-                } else {
-                    status = CELIX_BUNDLE_EXCEPTION;
-                    status = CELIX_DO_IF(status, bundleArchive_closeAndDelete(archive));
-                }
-            }
-        }
-    }
-
-    framework_releaseInstallLock(framework, location);
-
-    if (status != CELIX_SUCCESS) {
-    	fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not install bundle");
-    } else {
-        status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_INSTALLED, *bundle));
-    }
-
-  	return status;
-}
-
-celix_status_t framework_getBundleEntry(framework_pt framework, bundle_pt bundle, const char* name, char** entry) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bundle_revision_pt revision;
-	bundle_archive_pt archive = NULL;
-    const char *root;
-
-	status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
-    status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
-    status = CELIX_DO_IF(status, bundleRevision_getRoot(revision, &root));
-    if (status == CELIX_SUCCESS) {
-        char e[strlen(name) + strlen(root) + 2];
-        strcpy(e, root);
-        if ((strlen(name) > 0) && (name[0] == '/')) {
-            strcat(e, name);
-        } else {
-            strcat(e, "/");
-            strcat(e, name);
-        }
-
-        if (access(e, F_OK) == 0) {
-            (*entry) = strndup(e, 1024*10);
-        } else {
-            (*entry) = NULL;
-        }
-    }
-
-	return status;
-}
-
-celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int options) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	linked_list_pt wires = NULL;
-	bundle_context_pt context = NULL;
-	bundle_state_e state;
-	module_pt module = NULL;
-	activator_pt activator = NULL;
-	char *error = NULL;
-	const char *name = NULL;
-
-	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-	status = CELIX_DO_IF(status, bundle_getState(bundle, &state));
-
-	if (status == CELIX_SUCCESS) {
-	    switch (state) {
-            case OSGI_FRAMEWORK_BUNDLE_UNKNOWN:
-                error = "state is unknown";
-                status = CELIX_ILLEGAL_STATE;
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_UNINSTALLED:
-                error = "bundle is uninstalled";
-                status = CELIX_ILLEGAL_STATE;
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_STARTING:
-                error = "bundle is starting";
-                status = CELIX_BUNDLE_EXCEPTION;
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_STOPPING:
-                error = "bundle is stopping";
-                status = CELIX_BUNDLE_EXCEPTION;
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_INSTALLED:
-                bundle_getCurrentModule(bundle, &module);
-                module_getSymbolicName(module, &name);
-                if (!module_isResolved(module)) {
-                    wires = resolver_resolve(module);
-                    if (wires == NULL) {
-                        framework_releaseBundleLock(framework, bundle);
-                        return CELIX_BUNDLE_EXCEPTION;
-                    }
-                    framework_markResolvedModules(framework, wires);
-
-                }
-                /* no break */
-            case OSGI_FRAMEWORK_BUNDLE_RESOLVED:
-                module = NULL;
-                name = NULL;
-                bundle_getCurrentModule(bundle, &module);
-                module_getSymbolicName(module, &name);
-                status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, bundle, &context));
-                status = CELIX_DO_IF(status, bundle_setContext(bundle, context));
-
-                if (status == CELIX_SUCCESS) {
-                    activator = (activator_pt) calloc(1,(sizeof(*activator)));
-                    if (activator == NULL) {
-                        status = CELIX_ENOMEM;
-                    } else {
-                        void * userData = NULL;
-                        bundle_context_pt context;
-                        create_function_pt create = (create_function_pt) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE);
-                        start_function_pt start = (start_function_pt) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START);
-                        stop_function_pt stop = (stop_function_pt) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP);
-                        destroy_function_pt destroy = (destroy_function_pt) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY);
-
-                        activator->start = start;
-                        activator->stop = stop;
-                        activator->destroy = destroy;
-                        status = CELIX_DO_IF(status, bundle_setActivator(bundle, activator));
-
-                        status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STARTING));
-                        status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTING, bundle));
-
-                        status = CELIX_DO_IF(status, bundle_getContext(bundle, &context));
-
-                        if (status == CELIX_SUCCESS) {
-                            if (create != NULL) {
-                                status = CELIX_DO_IF(status, create(context, &userData));
-                                if (status == CELIX_SUCCESS) {
-                                    activator->userData = userData;
-                                }
-                            }
-                        }
-                        if (status == CELIX_SUCCESS) {
-                            if (start != NULL) {
-                                status = CELIX_DO_IF(status, start(userData, context));
-                            }
-                        }
-
-                        status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-                        status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED, bundle));
-                    }
-                }
-
-            break;
-        }
-	}
-
-	framework_releaseBundleLock(framework, bundle);
-
-	if (status != CELIX_SUCCESS) {
-	    module_pt module = NULL;
-	    const char *symbolicName = NULL;
-	    long id = 0;
-	    bundle_getCurrentModule(bundle, &module);
-	    module_getSymbolicName(module, &symbolicName);
-	    bundle_getBundleId(bundle, &id);
-	    if (error != NULL) {
-	        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]; cause: %s", symbolicName, id, error);
-	    } else {
-	        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]", symbolicName, id);
-	    }
-	    if(activator!=NULL){
-	    	free(activator);
-	    }
-	}
-
-	return status;
-}
-
-celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle, const char *inputFile) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_state_e oldState;
-	const char *location;
-	bundle_archive_pt archive = NULL;
-	char *error = NULL;
-
-	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-	status = CELIX_DO_IF(status, bundle_getState(bundle, &oldState));
-	if (status == CELIX_SUCCESS) {
-        if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
-            fw_stopBundle(framework, bundle, false);
-        }
-	}
-	status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
-	status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
-
-	if (status == CELIX_SUCCESS) {
-	    bool locked = framework_acquireGlobalLock(framework);
-	    if (!locked) {
-	        status = CELIX_BUNDLE_EXCEPTION;
-	        error = "Unable to acquire the global lock to update the bundle";
-	    }
-	}
-
-	status = CELIX_DO_IF(status, bundle_revise(bundle, location, inputFile));
-	status = CELIX_DO_IF(status, framework_releaseGlobalLock(framework));
-
-	status = CELIX_DO_IF(status, bundleArchive_setLastModified(archive, time(NULL)));
-	status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED));
-
-	bundle_revision_pt revision = NULL;
-	array_list_pt handles = NULL;
-	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
-    status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
-    if (handles != NULL) {
-        int i;
-	    for (i = arrayList_size(handles) - 1; i >= 0; i--) {
-	        void* handle = arrayList_get(handles, i);
-	        fw_closeLibrary(handle);
-	    }
-    }
-
-
-	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
-	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UPDATED, bundle));
-
-    // Refresh packages?
-
-	if (status == CELIX_SUCCESS) {
-	    if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
-	        status = CELIX_DO_IF(status, fw_startBundle(framework, bundle, 1));
-	    }
-	}
-
-	framework_releaseBundleLock(framework, bundle);
-
-	if (status != CELIX_SUCCESS) {
-	    module_pt module = NULL;
-        const char *symbolicName = NULL;
-        long id = 0;
-        bundle_getCurrentModule(bundle, &module);
-        module_getSymbolicName(module, &symbolicName);
-        bundle_getBundleId(bundle, &id);
-        if (error != NULL) {
-            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot update bundle: %s [%ld]; cause: %s", symbolicName, id, error);
-        } else {
-            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot update bundle: %s [%ld]", symbolicName, id);
-        }
-	}
-
-	return status;
-}
-
-celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle, bool record) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_state_e state;
-    activator_pt activator = NULL;
-    bundle_context_pt context = NULL;
-    bool wasActive = false;
-    long id = 0;
-    char *error = NULL;
-
-	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-
-	if (record) {
-	    status = CELIX_DO_IF(status, bundle_setPersistentStateInactive(bundle));
-    }
-
-	status = CELIX_DO_IF(status, bundle_getState(bundle, &state));
-	if (status == CELIX_SUCCESS) {
-	    switch (state) {
-            case OSGI_FRAMEWORK_BUNDLE_UNKNOWN:
-                status = CELIX_ILLEGAL_STATE;
-                error = "state is unknown";
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_UNINSTALLED:
-                status = CELIX_ILLEGAL_STATE;
-                error = "bundle is uninstalled";
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_STARTING:
-                status = CELIX_BUNDLE_EXCEPTION;
-                error = "bundle is starting";
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_STOPPING:
-                status = CELIX_BUNDLE_EXCEPTION;
-                error = "bundle is stopping";
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_INSTALLED:
-            case OSGI_FRAMEWORK_BUNDLE_RESOLVED:
-                break;
-            case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
-                wasActive = true;
-                break;
-        }
-	}
-
-
-	status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STOPPING));
-	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING, bundle));
-    status = CELIX_DO_IF(status, bundle_getBundleId(bundle, &id));
-	if (status == CELIX_SUCCESS) {
-	    if (wasActive || (id == 0)) {
-	        activator = bundle_getActivator(bundle);
-
-	        status = CELIX_DO_IF(status, bundle_getContext(bundle, &context));
-	        if (status == CELIX_SUCCESS) {
-                if (activator->stop != NULL) {
-                    status = CELIX_DO_IF(status, activator->stop(activator->userData, context));
-                }
-	        }
-            if (status == CELIX_SUCCESS) {
-                if (activator->destroy != NULL) {
-                    status = CELIX_DO_IF(status, activator->destroy(activator->userData, context));
-                }
-	        }
-
-            if (id != 0) {
-                status = CELIX_DO_IF(status, serviceRegistry_clearServiceRegistrations(framework->registry, bundle));
-                if (status == CELIX_SUCCESS) {
-                    module_pt module = NULL;
-                    const char *symbolicName = NULL;
-                    long id = 0;
-                    bundle_getCurrentModule(bundle, &module);
-                    module_getSymbolicName(module, &symbolicName);
-                    bundle_getBundleId(bundle, &id);
-
-                    serviceRegistry_clearReferencesFor(framework->registry, bundle);
-                }
-                // #TODO remove listeners for bundle
-
-                if (context != NULL) {
-                    status = CELIX_DO_IF(status, bundleContext_destroy(context));
-                    status = CELIX_DO_IF(status, bundle_setContext(bundle, NULL));
-                }
-
-                status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_RESOLVED));
-            }
-	    }
-
-	    if (activator != NULL) {
-	        bundle_setActivator(bundle, NULL);
-	        free(activator);
-	    }
-	}
-
-	framework_releaseBundleLock(framework, bundle);
-
-	if (status != CELIX_SUCCESS) {
-	    module_pt module = NULL;
-        const char *symbolicName = NULL;
-        long id = 0;
-        bundle_getCurrentModule(bundle, &module);
-        module_getSymbolicName(module, &symbolicName);
-        bundle_getBundleId(bundle, &id);
-        if (error != NULL) {
-            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot stop bundle: %s [%ld]; cause: %s", symbolicName, id, error);
-        } else {
-            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot stop bundle: %s [%ld]", symbolicName, id);
-        }
- 	} else {
-        fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPED, bundle);
- 	}
-
-	return status;
-}
-
-celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle) {
-    celix_status_t status = CELIX_SUCCESS;
-    bool locked;
-    bundle_archive_pt archive = NULL;
-    const char * location = NULL;
-    bundle_pt target = NULL;
-    char *error = NULL;
-
-    status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE|OSGI_FRAMEWORK_BUNDLE_STOPPING));
-    status = CELIX_DO_IF(status, fw_stopBundle(framework, bundle, true));
-    if (status == CELIX_SUCCESS) {
-        locked = framework_acquireGlobalLock(framework);
-        if (!locked) {
-            status = CELIX_ILLEGAL_STATE;
-            error = "Unable to acquire the global lock to uninstall the bundle";
-        }
-    }
-
-    status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
-    status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
-    if (status == CELIX_SUCCESS) {
-
-        celixThreadMutex_lock(&framework->installedBundleMapLock);
-
-        hash_map_entry_pt entry = hashMap_getEntry(framework->installedBundleMap, location);
-        char* entryLocation = hashMapEntry_getKey(entry);
-
-        target = (bundle_pt) hashMap_remove(framework->installedBundleMap, location);
-
-        free(entryLocation);
-        if (target != NULL) {
-            status = CELIX_DO_IF(status, bundle_setPersistentStateUninstalled(target));
-            // fw_rememberUninstalledBundle(framework, target);
-        }
-        celixThreadMutex_unlock(&framework->installedBundleMapLock);
-
-    }
-
-    framework_releaseGlobalLock(framework);
-
-    if (status == CELIX_SUCCESS) {
-        if (target == NULL) {
-            fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Could not remove bundle from installed map");
-        }
-    }
-
-    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED));
-
-    // TODO Unload all libraries for transition to unresolved
-    bundle_revision_pt revision = NULL;
-	array_list_pt handles = NULL;
-	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
-	status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
-	if(handles != NULL){
-		for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
-			void *handle = arrayList_get(handles, i);
-			fw_closeLibrary(handle);
-		}
-	}
-
-    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
-
-    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED));
-    status = CELIX_DO_IF(status, bundleArchive_setLastModified(archive, time(NULL)));
-
-    framework_releaseBundleLock(framework, bundle);
-
-    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNINSTALLED, bundle));
-
-    if (status == CELIX_SUCCESS) {
-        locked = framework_acquireGlobalLock(framework);
-        if (locked) {
-            bundle_pt bundles[] = { bundle };
-            celix_status_t refreshStatus = fw_refreshBundles(framework, bundles, 1);
-            if (refreshStatus != CELIX_SUCCESS) {
-                printf("Could not refresh bundle");
-            } else {
-                bundleArchive_destroy(archive);
-                status = CELIX_DO_IF(status, bundle_destroy(bundle));
-            }
-
-            status = CELIX_DO_IF(status, framework_releaseGlobalLock(framework));
-        }
-    }
-
-
-    if (status != CELIX_SUCCESS) {
-//        module_pt module = NULL;
-//        char *symbolicName = NULL;
-//        long id = 0;
-//        bundle_getCurrentModule(bundle, &module);
-//        module_getSymbolicName(module, &symbolicName);
-//        bundle_getBundleId(bundle, &id);
-
-        framework_logIfError(framework->logger, status, error, "Cannot uninstall bundle");
-    }
-
-    return status;
-}
-
-celix_status_t fw_refreshBundles(framework_pt framework, bundle_pt bundles[], int size) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    bool locked = framework_acquireGlobalLock(framework);
-    if (!locked) {
-        framework_releaseGlobalLock(framework);
-        status = CELIX_ILLEGAL_STATE;
-    } else {
-		hash_map_values_pt values;
-        bundle_pt *newTargets;
-        unsigned int nrofvalues;
-		bool restart = false;
-        hash_map_pt map = hashMap_create(NULL, NULL, NULL, NULL);
-        int targetIdx = 0;
-        for (targetIdx = 0; targetIdx < size; targetIdx++) {
-            bundle_pt bundle = bundles[targetIdx];
-            hashMap_put(map, bundle, bundle);
-            fw_populateDependentGraph(framework, bundle, &map);
-        }
-        values = hashMapValues_create(map);
-        hashMapValues_toArray(values, (void ***) &newTargets, &nrofvalues);
-        hashMapValues_destroy(values);
-
-        hashMap_destroy(map, false, false);
-
-        if (newTargets != NULL) {
-            int i = 0;
-			struct fw_refreshHelper * helpers;
-            for (i = 0; i < nrofvalues && !restart; i++) {
-                bundle_pt bundle = (bundle_pt) newTargets[i];
-                if (framework->bundle == bundle) {
-                    restart = true;
-                }
-            }
-
-            helpers = (struct fw_refreshHelper * )malloc(nrofvalues * sizeof(struct fw_refreshHelper));
-            for (i = 0; i < nrofvalues && !restart; i++) {
-                bundle_pt bundle = (bundle_pt) newTargets[i];
-                helpers[i].framework = framework;
-                helpers[i].bundle = bundle;
-                helpers[i].oldState = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
-            }
-
-            for (i = 0; i < nrofvalues; i++) {
-                struct fw_refreshHelper helper = helpers[i];
-                fw_refreshHelper_stop(&helper);
-                fw_refreshHelper_refreshOrRemove(&helper);
-            }
-
-            for (i = 0; i < nrofvalues; i++) {
-                struct fw_refreshHelper helper = helpers[i];
-                fw_refreshHelper_restart(&helper);
-            }
-
-            if (restart) {
-                bundle_update(framework->bundle, NULL);
-            }
-			free(helpers);
-			free(newTargets);
-        }
-
-        framework_releaseGlobalLock(framework);
-    }
-
-    framework_logIfError(framework->logger, status, NULL, "Cannot refresh bundles");
-
-    return status;
-}
-
-celix_status_t fw_refreshBundle(framework_pt framework, bundle_pt bundle) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_state_e state;
-
-    status = framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED | OSGI_FRAMEWORK_BUNDLE_RESOLVED);
-    if (status != CELIX_SUCCESS) {
-        printf("Cannot refresh bundle");
-        framework_releaseBundleLock(framework, bundle);
-    } else {
-    	bool fire;
-		bundle_getState(bundle, &state);
-        fire = (state != OSGI_FRAMEWORK_BUNDLE_INSTALLED);
-        bundle_refresh(bundle);
-
-        if (fire) {
-            framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
-            fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle);
-        }
-
-        framework_releaseBundleLock(framework, bundle);
-    }
-
-    framework_logIfError(framework->logger, status, NULL, "Cannot refresh bundle");
-
-    return status;
-}
-
-celix_status_t fw_refreshHelper_stop(struct fw_refreshHelper * refreshHelper) {
-	bundle_state_e state;
-	bundle_getState(refreshHelper->bundle, &state);
-    if (state == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
-        refreshHelper->oldState = OSGI_FRAMEWORK_BUNDLE_ACTIVE;
-        fw_stopBundle(refreshHelper->framework, refreshHelper->bundle, false);
-    }
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t fw_refreshHelper_refreshOrRemove(struct fw_refreshHelper * refreshHelper) {
-	bundle_state_e state;
-	bundle_getState(refreshHelper->bundle, &state);
-    if (state == OSGI_FRAMEWORK_BUNDLE_UNINSTALLED) {
-        bundle_closeAndDelete(refreshHelper->bundle);
-        refreshHelper->bundle = NULL;
-    } else {
-        fw_refreshBundle(refreshHelper->framework, refreshHelper->bundle);
-    }
-    return CELIX_SUCCESS;
-}
-
-celix_status_t fw_refreshHelper_restart(struct fw_refreshHelper * refreshHelper) {
-    if ((refreshHelper->bundle != NULL) && (refreshHelper->oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE)) {
-        fw_startBundle(refreshHelper->framework, refreshHelper->bundle, 0);
-    }
-    return CELIX_SUCCESS;
-}
-
-celix_status_t fw_getDependentBundles(framework_pt framework, bundle_pt exporter, array_list_pt *list) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (*list != NULL || exporter == NULL || framework == NULL) {
-	return CELIX_ILLEGAL_ARGUMENT;
-    }
-
-	 array_list_pt modules;
-	 unsigned int modIdx = 0;
-	 arrayList_create(list);
-
-	 modules = bundle_getModules(exporter);
-	 for (modIdx = 0; modIdx < arrayList_size(modules); modIdx++) {
-				module_pt module = (module_pt) arrayList_get(modules, modIdx);
-				array_list_pt dependents = module_getDependents(module);
-			if(dependents!=NULL){
-					unsigned int depIdx = 0;
-					for (depIdx = 0; depIdx < arrayList_size(dependents); depIdx++) {
-							  module_pt dependent = (module_pt) arrayList_get(dependents, depIdx);
-							  arrayList_add(*list, module_getBundle(dependent));
-					}
-					arrayList_destroy(dependents);
-				}
-	 }
-
-    framework_logIfError(framework->logger, status, NULL, "Cannot get dependent bundles");
-
-    return status;
-}
-
-celix_status_t fw_populateDependentGraph(framework_pt framework, bundle_pt exporter, hash_map_pt *map) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if(framework == NULL || exporter == NULL){
-	return CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    array_list_pt dependents = NULL;
-    if ((status = fw_getDependentBundles(framework, exporter, &dependents)) == CELIX_SUCCESS) {
-		  if(dependents!=NULL){
-         unsigned int depIdx = 0;
-		for (depIdx = 0; depIdx < arrayList_size(dependents); depIdx++) {
-		    if (!hashMap_containsKey(*map, arrayList_get(dependents, depIdx))) {
-		        hashMap_put(*map, arrayList_get(dependents, depIdx), arrayList_get(dependents, depIdx));
-		        fw_populateDependentGraph(framework, (bundle_pt) arrayList_get(dependents, depIdx), map);
-		    }
-		}
-		arrayList_destroy(dependents);
-		  }
-    }
-
-    framework_logIfError(framework->logger, status, NULL, "Cannot populate dependent graph");
-
-    return status;
-}
-
-celix_status_t fw_registerService(framework_pt framework, service_registration_pt *registration, bundle_pt bundle, const char* serviceName, const void* svcObj, properties_pt properties) {
-	celix_status_t status = CELIX_SUCCESS;
-	char *error = NULL;
-	if (serviceName == NULL || svcObj == NULL) {
-	    status = CELIX_ILLEGAL_ARGUMENT;
-	    error = "ServiceName and SvcObj cannot be null";
-	}
-
-	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-	status = CELIX_DO_IF(status, serviceRegistry_registerService(framework->registry, bundle, serviceName, svcObj, properties, registration));
-	bool res = framework_releaseBundleLock(framework, bundle);
-	if (!res) {
-	    status = CELIX_ILLEGAL_STATE;
-	    error = "Could not release bundle lock";
-	}
-
-	if (status == CELIX_SUCCESS) {
-	    // If this is a listener hook, invoke the callback with all current listeners
-        if (strcmp(serviceName, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME) == 0) {
-            unsigned int i;
-            array_list_pt infos = NULL;
-            service_reference_pt ref = NULL;
-            listener_hook_service_pt hook = NULL;
-
-            status = CELIX_DO_IF(status, arrayList_create(&infos));
-
-            if (status == CELIX_SUCCESS) {
-                celix_status_t subs = CELIX_SUCCESS;
-
-                for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
-                    fw_service_listener_pt listener =(fw_service_listener_pt) arrayList_get(framework->serviceListeners, i);
-                    bundle_context_pt context = NULL;
-                    listener_hook_info_pt info = NULL;
-                    bundle_context_pt lContext = NULL;
-
-                    subs = CELIX_DO_IF(subs, bundle_getContext(bundle, &context));
-                    if (subs == CELIX_SUCCESS) {
-                        info = (listener_hook_info_pt) malloc(sizeof(*info));
-                        if (info == NULL) {
-                            subs = CELIX_ENOMEM;
-                        }
-                    }
-
-                    subs = CELIX_DO_IF(subs, bundle_getContext(listener->bundle, &lContext));
-                    if (subs == CELIX_SUCCESS) {
-                        info->context = lContext;
-                        info->removed = false;
-                    }
-                    subs = CELIX_DO_IF(subs, filter_getString(listener->filter, (const char**)&info->filter));
-
-                    if (subs == CELIX_SUCCESS) {
-                        arrayList_add(infos, info);
-                    }
-                    else{
-                        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not pass all listeners to the hook: %s", serviceName);
-                        free(info);
-                    }
-                }
-
-                status = CELIX_DO_IF(status, serviceRegistry_getServiceReference(framework->registry, framework->bundle,
-                                                                                 *registration, &ref));
-                status = CELIX_DO_IF(status, fw_getService(framework,framework->bundle, ref, (const void **) &hook));
-                if (status == CELIX_SUCCESS) {
-                    hook->added(hook->handle, infos);
-                }
-                status = CELIX_DO_IF(status, serviceRegistry_ungetService(framework->registry, framework->bundle, ref, NULL));
-                status = CELIX_DO_IF(status, serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref));
-
-                int i = 0;
-                for (i = 0; i < arrayList_size(infos); i++) {
-                    listener_hook_info_pt info = arrayList_get(infos, i);
-                    free(info);
-                }
-                arrayList_destroy(infos);
-             }
-        }
-	}
-
-    framework_logIfError(framework->logger, status, error, "Cannot register service: %s", serviceName);
-
-	return status;
-}
-
-celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt *registration, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt properties) {
-    celix_status_t status = CELIX_SUCCESS;
-    char *error = NULL;
-	if (serviceName == NULL || factory == NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-        error = "Service name and factory cannot be null";
-    }
-
-	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-	status = CELIX_DO_IF(status, serviceRegistry_registerServiceFactory(framework->registry, bundle, serviceName, factory, properties, registration));
-    if (!framework_releaseBundleLock(framework, bundle)) {
-        status = CELIX_ILLEGAL_STATE;
-        error = "Could not release bundle lock";
-    }
-
-    framework_logIfError(framework->logger, status, error, "Cannot register service factory: %s", serviceName);
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *references, bundle_pt bundle, const char * serviceName, const char * sfilter) {
-    celix_status_t status = CELIX_SUCCESS;
-
-	filter_pt filter = NULL;
-	unsigned int refIdx = 0;
-
-    if (sfilter != NULL) {
-        filter = filter_create(sfilter);
-	}
-
-	status = CELIX_DO_IF(status, serviceRegistry_getServiceReferences(framework->registry, bundle, serviceName, filter, references));
-
-	if (filter != NULL) {
-		filter_destroy(filter);
-	}
-
-	if (status == CELIX_SUCCESS) {
-        for (refIdx = 0; (*references != NULL) && refIdx < arrayList_size(*references); refIdx++) {
-            service_reference_pt ref = (service_reference_pt) arrayList_get(*references, refIdx);
-            service_registration_pt reg = NULL;
-            const char* serviceName;
-            properties_pt props = NULL;
-            status = CELIX_DO_IF(status, serviceReference_getServiceRegistration(ref, &reg));
-            status = CELIX_DO_IF(status, serviceRegistration_getProperties(reg, &props));
-            if (status == CELIX_SUCCESS) {
-                serviceName = properties_get(props, OSGI_FRAMEWORK_OBJECTCLASS);
-                if (!serviceReference_isAssignableTo(ref, bundle, serviceName)) {
-                    arrayList_remove(*references, refIdx);
-                    refIdx--;
-                }
-            }
-        }
-	}
-
-	framework_logIfError(framework->logger, status, NULL, "Failed to get service references");
-
-	return status;
-}
-
-celix_status_t framework_ungetServiceReference(framework_pt framework, bundle_pt bundle, service_reference_pt reference) {
-    return serviceRegistry_ungetServiceReference(framework->registry, bundle, reference);
-}
-
-celix_status_t fw_getService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, const void **service) {
-	return serviceRegistry_getService(framework->registry, bundle, reference, service);
-}
-
-celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, array_list_pt *services) {
-	return serviceRegistry_getRegisteredServices(framework->registry, bundle, services);
-}
-
-celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, array_list_pt *services) {
-	celix_status_t status = CELIX_SUCCESS;
-	status = serviceRegistry_getServicesInUse(framework->registry, bundle, services);
-	return status;
-}
-
-celix_status_t framework_ungetService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, bool *result) {
-	return serviceRegistry_ungetService(framework->registry, bundle, reference, result);
-}
-
-void fw_addServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener, const char* sfilter) {
-	array_list_pt listenerHooks = NULL;
-	listener_hook_info_pt info;
-	unsigned int i;
-
-	fw_service_listener_pt fwListener = (fw_service_listener_pt) calloc(1, sizeof(*fwListener));
-	bundle_context_pt context = NULL;
-
-	fwListener->bundle = bundle;
-    arrayList_create(&fwListener->retainedReferences);
-	if (sfilter != NULL) {
-		filter_pt filter = filter_create(sfilter);
-		fwListener->filter = filter;
-	} else {
-		fwListener->filter = NULL;
-	}
-	fwListener->listener = listener;
-
-	arrayList_add(framework->serviceListeners, fwListener);
-
-	serviceRegistry_getListenerHooks(framework->registry, framework->bundle, &listenerHooks);
-
-	info = (listener_hook_info_pt) malloc(sizeof(*info));
-
-	bundle_getContext(bundle, &context);
-	info->context = context;
-
-	info->removed = false;
-	info->filter = sfilter == NULL ? NULL : strdup(sfilter);
-
-	for (i = 0; i < arrayList_size(listenerHooks); i++) {
-		service_reference_pt ref = (service_reference_pt) arrayList_get(listenerHooks, i);
-		listener_hook_service_pt hook = NULL;
-		array_list_pt infos = NULL;
-		bool ungetResult = false;
-
-		fw_getService(framework, framework->bundle, ref, (const void **) &hook);
-
-		arrayList_create(&infos);
-		arrayList_add(infos, info);
-		hook->added(hook->handle, infos);
-		serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
-		serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
-		arrayList_destroy(infos);
-	}
-
-	if (info->filter != NULL) {
-	    free(info->filter);
-	}
-	free(info);
-
-	arrayList_destroy(listenerHooks);
-}
-
-void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener) {
-	listener_hook_info_pt info = NULL;
-	unsigned int i;
-	fw_service_listener_pt element;
-
-	bundle_context_pt context;
-	bundle_getContext(bundle, &context);
-
-	for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
-		element = (fw_service_listener_pt) arrayList_get(framework->serviceListeners, i);
-		if (element->listener == listener && element->bundle == bundle) {
-			bundle_context_pt lContext = NULL;
-
-			info = (listener_hook_info_pt) malloc(sizeof(*info));
-
-			bundle_getContext(element->bundle, &lContext);
-			info->context = lContext;
-
-			// TODO Filter toString;
-			filter_getString(element->filter, (const char**)&info->filter);
-			info->removed = true;
-
-			arrayList_remove(framework->serviceListeners, i);
-			i--;
-            
-            //unregistering retained service references. For these refs a unregister event will not be triggered.
-            int k;
-            int rSize = arrayList_size(element->retainedReferences);
-            for (k = 0; k < rSize; k += 1) {
-                service_reference_pt ref = arrayList_get(element->retainedReferences, k);
-                if (ref != NULL) {
-                    serviceRegistry_ungetServiceReference(framework->registry, element->bundle, ref); // decrease retain counter                                       
-                } 
-            }
-
-			element->bundle = NULL;
-			filter_destroy(element->filter);
-            arrayList_destroy(element->retainedReferences);
-			element->filter = NULL;
-			element->listener = NULL;
-			free(element);
-			element = NULL;
-			break;
-		}
-	}
-
-	if (info != NULL) {
-		unsigned int i;
-		array_list_pt listenerHooks = NULL;
-		serviceRegistry_getListenerHooks(framework->registry, framework->bundle, &listenerHooks);
-
-		for (i = 0; i < arrayList_size(listenerHooks); i++) {
-			service_reference_pt ref = (service_reference_pt) arrayList_get(listenerHooks, i);
-			listener_hook_service_pt hook = NULL;
-			array_list_pt infos = NULL;
-			bool ungetResult;
-
-			fw_getService(framework, framework->bundle, ref, (const void **) &hook);
-
-			arrayList_create(&infos);
-			arrayList_add(infos, info);
-			hook->removed(hook->handle, infos);
-			serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
-			serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
-			arrayList_destroy(infos);
-		}
-
-		arrayList_destroy(listenerHooks);
-        free(info);
-	}
-}
-
-celix_status_t fw_addBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener) {
-	celix_status_t status = CELIX_SUCCESS;
-	fw_bundle_listener_pt bundleListener = NULL;
-
-	bundleListener = (fw_bundle_listener_pt) malloc(sizeof(*bundleListener));
-	if (!bundleListener) {
-		status = CELIX_ENOMEM;
-	} else {
-		bundleListener->listener = listener;
-		bundleListener->bundle = bundle;
-
-		if (celixThreadMutex_lock(&framework->bundleListenerLock) != CELIX_SUCCESS) {
-			status = CELIX_FRAMEWORK_EXCEPTION;
-		} else {
-			arrayList_add(framework->bundleListeners, bundleListener);
-
-			if (celixThreadMutex_unlock(&framework->bundleListenerLock)) {
-				status = CELIX_FRAMEWORK_EXCEPTION;
-			}
-		}
-	}
-
-	framework_logIfError(framework->logger, status, NULL, "Failed to add bundle listener");
-
-	return status;
-}
-
-celix_status_t fw_removeBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	unsigned int i;
-	fw_bundle_listener_pt bundleListener;
-
-	if (celixThreadMutex_lock(&framework->bundleListenerLock) != CELIX_SUCCESS) {
-		status = CELIX_FRAMEWORK_EXCEPTION;
-	}
-	else {
-		for (i = 0; i < arrayList_size(framework->bundleListeners); i++) {
-			bundleListener = (fw_bundle_listener_pt) arrayList_get(framework->bundleListeners, i);
-			if (bundleListener->listener == listener && bundleListener->bundle == bundle) {
-				arrayList_remove(framework->bundleListeners, i);
-
-				bundleListener->bundle = NULL;
-				bundleListener->listener = NULL;
-				free(bundleListener);
-			}
-		}
-		if (celixThreadMutex_unlock(&framework->bundleListenerLock)) {
-			status = CELIX_FRAMEWORK_EXCEPTION;
-		}
-	}
-
-	framework_logIfError(framework->logger, status, NULL, "Failed to remove bundle listener");
-
-	return status;
-}
-
-celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener) {
-	celix_status_t status = CELIX_SUCCESS;
-	fw_framework_listener_pt frameworkListener = NULL;
-
-	frameworkListener = (fw_framework_listener_pt) malloc(sizeof(*frameworkListener));
-	if (!frameworkListener) {
-		status = CELIX_ENOMEM;
-	} else {
-		frameworkListener->listener = listener;
-		frameworkListener->bundle = bundle;
-
-		arrayList_add(framework->frameworkListeners, frameworkListener);
-	}
-
-	framework_logIfError(framework->logger, status, NULL, "Failed to add framework listener");
-
-	return status;
-}
-
-celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	unsigned int i;
-	fw_framework_listener_pt frameworkListener;
-
-	for (i = 0; i < arrayList_size(framework->frameworkListeners); i++) {
-		frameworkListener = (fw_framework_listener_pt) arrayList_get(framework->frameworkListeners, i);
-		if (frameworkListener->listener == listener && frameworkListener->bundle == bundle) {
-			arrayList_remove(framework->frameworkListeners, i);
-
-			frameworkListener->bundle = NULL;
-            frameworkListener->listener = NULL;
-            free(frameworkListener);
-		}
-	}
-
-	framework_logIfError(framework->logger, status, NULL, "Failed to remove framework listener");
-
-	return status;
-}
-
-void fw_serviceChanged(framework_pt framework, service_event_type_e eventType, service_registration_pt registration, properties_pt oldprops) {
-    unsigned int i;
-    fw_service_listener_pt element;
-
-    if (arrayList_size(framework->serviceListeners) > 0) {
-        for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
-            int matched = 0;
-            properties_pt props = NULL;
-            bool matchResult = false;
-
-            element = (fw_service_listener_pt) arrayList_get(framework->serviceListeners, i);
-            serviceRegistration_getProperties(registration, &props);
-            if (element->filter != NULL) {
-                filter_match(element->filter, props, &matchResult);
-            }
-            matched = (element->filter == NULL) || matchResult;
-            if (matched) {
-                service_reference_pt reference = NULL;
-                service_event_pt event;
-
-                event = (service_event_pt) malloc(sizeof (*event));
-
-                serviceRegistry_getServiceReference(framework->registry, element->bundle, registration, &reference);
-                
-                //NOTE: that you are never sure that the UNREGISTERED event will by handle by an service_listener. listener could be gone
-                //Every reference retained is therefore stored and called when a service listener is removed from the framework.
-                if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED) {
-                    serviceRegistry_retainServiceReference(framework->registry, element->bundle, reference);
-                    arrayList_add(element->retainedReferences, reference); //TODO improve by using set (or hashmap) instead of list
-                }
-
-                event->type = eventType;
-                event->reference = reference;
-
-                element->listener->serviceChanged(element->listener, event);
-
-                serviceRegistry_ungetServiceReference(framework->registry, element->bundle, reference);
-                
-                if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
-                    //if service listener was active when service was registered, release the retained reference
-                    if (arrayList_removeElement(element->retainedReferences, reference)) {
-                        serviceRegistry_ungetServiceReference(framework->registry, element->bundle, reference); // decrease retain counter
-                    }
-                }
-                
-                free(event);
-
-            } else if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED) {
-                bool matchResult = false;
-                int matched = 0;
-                if (element->filter != NULL) {
-                    filter_match(element->filter, oldprops, &matchResult);
-                }
-                matched = (element->filter == NULL) || matchResult;
-                if (matched) {
-                    service_reference_pt reference = NULL;
-                    service_event_pt endmatch = (service_event_pt) malloc(sizeof (*endmatch));
-
-                    serviceRegistry_getServiceReference(framework->registry, element->bundle, registration, &reference);
-
-                    endmatch->reference = reference;
-                    endmatch->type = OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH;
-                    element->listener->serviceChanged(element->listener, endmatch);
-
-                    serviceRegistry_ungetServiceReference(framework->registry, element->bundle, reference);
-                    free(endmatch);
-
-                }
-            }
-        }
-    }
-
-}
-
-//celix_status_t fw_isServiceAssignable(framework_pt fw, bundle_pt requester, service_reference_pt reference, bool *assignable) {
-//	celix_status_t status = CELIX_SUCCESS;
-//
-//	*assignable = true;
-//	service_registration_pt registration = NULL;
-//	status = serviceReference_getServiceRegistration(reference, &registration);
-//	if (status == CELIX_SUCCESS) {
-//		char *serviceName = properties_get(registration->properties, (char *) OBJECTCLASS);
-//		if (!serviceReference_isAssignableTo(reference, requester, serviceName)) {
-//			*assignable = false;
-//		}
-//	}
-//
-//	return status;
-//}
-
-long framework_getNextBundleId(framework_pt framework) {
-	long id = framework->nextBundleId;
-	framework->nextBundleId++;
-	return id;
-}
-
-celix_status_t framework_markResolvedModules(framework_pt framework, linked_list_pt resolvedModuleWireMap) {
-	if (resolvedModuleWireMap != NULL) {
-		// hash_map_iterator_pt iterator = hashMapIterator_create(resolvedModuleWireMap);
-		linked_list_iterator_pt iterator = linkedListIterator_create(resolvedModuleWireMap, linkedList_size(resolvedModuleWireMap));
-		while (linkedListIterator_hasPrevious(iterator)) {
-		    importer_wires_pt iw = linkedListIterator_previous(iterator);
-			// hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
-			module_pt module = iw->importer;
-
-//			bundle_pt bundle = module_getBundle(module);
-//			bundle_archive_pt archive = NULL;
-//			bundle_getArchive(bundle, &archive);
-//			bundle_revision_pt revision = NULL;
-//			bundleArchive_getCurrentRevision(archive, &revision);
-//			char *root = NULL;
-//			bundleRevision_getRoot(revision, &root);
-//			manifest_pt manifest = NULL;
-//			bundleRevision_getManifest(revision, &manifest);
-//
-//			char *private = manifest_getValue(manifest, OSGI_FRAMEWORK_PRIVATE_LIBRARY);
-//			char *export = manifest_getValue(manifest, OSGI_FRAMEWORK_EXPORT_LIBRARY);
-//
-//			printf("Root %s\n", root);
-
-			// for each library update the reference to the wires, if there are any
-
-			linked_list_pt wires = iw->wires;
-
-//			linked_list_iterator_pt wit = linkedListIterator_create(wires, 0);
-//			while (linkedListIterator_hasNext(wit)) {
-//			    wire_pt wire = linkedListIterator_next(wit);
-//			    module_pt importer = NULL;
-//			    requirement_pt requirement = NULL;
-//			    module_pt exporter = NULL;
-//                capability_pt capability = NULL;
-//			    wire_getImporter(wire, &importer);
-//			    wire_getRequirement(wire, &requirement);
-//
-//			    wire_getExporter(wire, &exporter);
-//			    wire_getCapability(wire, &capability);
-//
-//			    char *importerName = NULL;
-//			    module_getSymbolicName(importer, &importerName);
-//
-//			    char *exporterName = NULL;
-//                module_getSymbolicName(exporter, &exporterName);
-//
-//                version_pt version = NULL;
-//                char *name = NULL;
-//                capability_getServiceName(capability, &name);
-//                capability_getVersion(capability, &version);
-//                char *versionString = NULL;
-//                version_toString(version, framework->mp, &versionString);
-//
-//                printf("Module %s imports library %s:%s from %s\n", importerName, name, versionString, exporterName);
-//			}
-
-			module_setWires(module, wires);
-
-			module_setResolved(module);
-			resolver_moduleResolved(module);
-
-			const char *mname = NULL;
-			module_getSymbolicName(module, &mname);
-			framework_markBundleResolved(framework, module);
-			linkedListIterator_remove(iterator);
-			free(iw);
-		}
-		linkedListIterator_destroy(iterator);
-		linkedList_destroy(resolvedModuleWireMap);
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t framework_markBundleResolved(framework_pt framework, module_pt module) {
-    celix_status_t status = CELIX_SUCCESS;
-	bundle_pt bundle = module_getBundle(module);
-	bundle_state_e state;
-	char *error = NULL;
-
-	if (bundle != NULL) {
-		framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_ACTIVE);
-		bundle_getState(bundle, &state);
-		if (state != OSGI_FRAMEWORK_BUNDLE_INSTALLED) {
-			printf("Trying to resolve a resolved bundle");
-			status = CELIX_ILLEGAL_STATE;
-		} else {
-		    // Load libraries of this module
-		    bool isSystemBundle = false;
-		    bundle_isSystemBundle(bundle, &isSystemBundle);
-		    if (!isSystemBundle) {
-                status = CELIX_DO_IF(status, framework_loadBundleLibraries(framework, bundle));
-		    }
-
-		    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_RESOLVED));
-			status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_RESOLVED, bundle));
-		}
-
-		if (status != CELIX_SUCCESS) {
-            module_pt module = NULL;
-            const char *symbolicName = NULL;
-            long id = 0;
-            module_getSymbolicName(module, &symbolicName);
-            bundle_getBundleId(bundle, &id);
-            if (error != NULL) {
-                fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]; cause: %s", symbolicName, id, error);
-            } else {
-                fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]", symbolicName, id);
-            }
-        }
-
-		framework_releaseBundleLock(framework, bundle);
-	}
-
-	return CELIX_SUCCESS;
-}
-
-array_list_pt framework_getBundles(framework_pt framework) {
-	array_list_pt bundles = NULL;
-	hash_map_iterator_pt iterator;
-	arrayList_create(&bundles);
-
-	celixThreadMutex_lock(&framework->installedBundleMapLock);
-
-	iterator = hashMapIterator_create(framework->installedBundleMap);
-	while (hashMapIterator_hasNext(iterator)) {
-		bundle_pt bundle = (bundle_pt) hashMapIterator_nextValue(iterator);
-		arrayList_add(bundles, bundle);
-	}
-	hashMapIterator_destroy(iterator);
-
-	celixThreadMutex_unlock(&framework->installedBundleMapLock);
-
-	return bundles;
-}
-
-bundle_pt framework_getBundle(framework_pt framework, const char* location) {
-	celixThreadMutex_lock(&framework->installedBundleMapLock);
-	bundle_pt bundle = (bundle_pt) hashMap_get(framework->installedBundleMap, location);
-	celixThreadMutex_unlock(&framework->installedBundleMapLock);
-	return bundle;
-}
-
-bundle_pt framework_getBundleById(framework_pt framework, long id) {
-	celixThreadMutex_lock(&framework->installedBundleMapLock);
-	hash_map_iterator_pt iter = hashMapIterator_create(framework->installedBundleMap);
-	bundle_pt bundle = NULL;
-	while (hashMapIterator_hasNext(iter)) {
-		bundle_pt b = (bundle_pt) hashMapIterator_nextValue(iter);
-		bundle_archive_pt archive = NULL;
-		long bid;
-		bundle_getArchive(b, &archive);
-		bundleArchive_getId(archive, &bid);
-		if (bid == id) {
-			bundle = b;
-			break;
-		}
-	}
-	hashMapIterator_destroy(iter);
-	celixThreadMutex_unlock(&framework->installedBundleMapLock);
-
-	return bundle;
-}
-
-celix_status_t framework_acquireInstallLock(framework_pt framework, const char * location) {
-    celixThreadMutex_lock(&framework->installRequestLock);
-
-	while (hashMap_get(framework->installRequestMap, location) != NULL) {
-	    celixThreadCondition_wait(&framework->condition, &framework->installRequestLock);
-	}
-	hashMap_put(framework->installRequestMap, (char*)location, (char*)location);
-
-	celixThreadMutex_unlock(&framework->installRequestLock);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t framework_releaseInstallLock(framework_pt framework, const char* location) {
-    celixThreadMutex_lock(&framework->installRequestLock);
-
-	hashMap_remove(framework->installRequestMap, location);
-	celixThreadCondition_broadcast(&framework->condition);
-
-	celixThreadMutex_unlock(&framework->installRequestLock);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t framework_setBundleStateAndNotify(framework_pt framework, bundle_pt bundle, int state) {
-	int ret = CELIX_SUCCESS;
-
-	int err = celixThreadMutex_lock(&framework->bundleLock);
-	if (err != 0) {
-		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to lock");
-		return CELIX_BUNDLE_EXCEPTION;
-	}
-
-	bundle_setState(bundle, state);
-	err = celixThreadCondition_broadcast(&framework->condition);
-	if (err != 0) {
-		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to broadcast");
-		ret = CELIX_BUNDLE_EXCEPTION;
-	}
-
-	err = celixThreadMutex_unlock(&framework->bundleLock);
-	if (err != 0) {
-		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to unlock");
-		return CELIX_BUNDLE_EXCEPTION;
-	}
-	return ret;
-}
-
-celix_status_t framework_acquireBundleLock(framework_pt framework, bundle_pt bundle, int desiredStates) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bool locked;
-	celix_thread_t lockingThread = celix_thread_default;
-
-	int err = celixThreadMutex_lock(&framework->bundleLock);
-	if (err != CELIX_SUCCESS) {
-		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to lock");
-		status = CELIX_BUNDLE_EXCEPTION;
-	} else {
-		bool lockable = false;
-		bool isSelf = false;
-
-		bundle_isLockable(bundle, &lockable);
-		thread_equalsSelf(framework->globalLockThread, &isSelf);
-
-		while (!lockable
-				|| (( celixThread_initalized(framework->globalLockThread) == true)
-				&& !isSelf))
-		{
-			bundle_state_e state;
-			bundle_getState(bundle, &state);
-			if ((desiredStates & state) == 0) {
-				status = CELIX_ILLEGAL_STATE;
-				break;
-			}
-
-			bundle_getLockingThread(bundle, &lockingThread);
-			if (isSelf && (celixThread_initalized(lockingThread) == true)
-					&& arrayList_contains(framework->globalLockWaitersList, &lockingThread)) {
-				framework->interrupted = true;
-//				celixThreadCondition_signal_thread_np(&framework->condition, bundle_getLockingThread(bundle));
-				celixThreadCondition_signal(&framework->condition);
-			}
-
-            celixThreadCondition_wait(&framework->condition, &framework->bundleLock);
-
-			status = bundle_isLockable(bundle, &lockable);
-			if (status != CELIX_SUCCESS) {
-				break;
-			}
-	}
-
-		if (status == CELIX_SUCCESS) {
-			bundle_state_e state;
-			bundle_getState(bundle, &state);
-			if ((desiredStates & state) == 0) {
-				status = CELIX_ILLEGAL_STATE;
-			} else {
-				if (bundle_lock(bundle, &locked)) {
-					if (!locked) {
-						status = CELIX_ILLEGAL_STATE;
-					}
-				}
-			}
-		}
-		celixThreadMutex_unlock(&framework->bundleLock);
-	}
-
-	framework_logIfError(framework->logger, status, NULL, "Failed to get bundle lock");
-
-	return status;
-}
-
-bool framework_releaseBundleLock(framework_pt framework, bundle_pt bundle) {
-    bool unlocked;
-    celix_thread_t lockingThread = celix_thread_default;
-
-    celixThreadMutex_lock(&framework->bundleLock);
-
-    bundle_unlock(bundle, &unlocked);
-	if (!unlocked) {
-	    celixThreadMutex_unlock(&framework->bundleLock);
-		return false;
-	}
-	bundle_getLockingThread(bundle, &lockingThread);
-	if (celixThread_initalized(lockingThread) == false) {
-	    celixThreadCondition_broadcast(&framework->condition);
-	}
-
-	celixThreadMutex_unlock(&framework->bundleLock);
-
-	return true;
-}
-
-bool framework_acquireGlobalLock(framework_pt framework) {
-    bool interrupted = false;
-	bool isSelf = false;
-
-	celixThreadMutex_lock(&framework->bundleLock);
-
-	thread_equalsSelf(framework->globalLockThread, &isSelf);
-
-	while (!interrupted
-			&& (celixThread_initalized(framework->globalLockThread) == true)
-			&& (!isSelf)) {
-		celix_thread_t currentThread = celixThread_self();
-		arrayList_add(framework->globalLockWaitersList, &currentThread);
-		celixThreadCondition_broadcast(&framework->condition);
-
-		celixThreadCondition_wait(&framework->condition, &framework->bundleLock);
-		if (framework->interrupted) {
-			interrupted = true;
-			framework->interrupted = false;
-		}
-
-		arrayList_removeElement(framework->globalLockWaitersList, &currentThread);
-	}
-
-	if (!interrupted) {
-		framework->globalLockCount++;
-		framework->globalLockThread = celixThread_self();
-	}
-
-	celixThreadMutex_unlock(&framework->bundleLock);
-
-	return !interrupted;
-}
-
-celix_status_t framework_releaseGlobalLock(framework_pt framework) {
-	int status = CELIX_SUCCESS;
-	if (celixThreadMutex_lock(&framework->bundleLock) != 0) {
-		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking framework bundle lock");
-		return CELIX_FRAMEWORK_EXCEPTION;
-	}
-
-	if (celixThread_equals(framework->globalLockThread, celixThread_self())) {
-		framework->globalLockCount--;
-		if (framework->globalLockCount == 0) {
-			framework->globalLockThread = celix_thread_default;
- 			if (celixThreadCondition_broadcast(&framework->condition) != 0) {
-				fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to broadcast global lock release.");
-				status = CELIX_FRAMEWORK_EXCEPTION;
-				// still need to unlock before returning
-			}
-		}
-	} else {
-		printf("The current thread does not own the global lock");
-	}
-
-	if (celixThreadMutex_unlock(&framework->bundleLock) != 0) {
-		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking framework bundle lock");
-		return CELIX_FRAMEWORK_EXCEPTION;
-	}
-
-	framework_logIfError(framework->logger, status, NULL, "Failed to release global lock");
-
-	return status;
-}
-
-celix_status_t framework_waitForStop(framework_pt framework) {
-	if (celixThreadMutex_lock(&framework->mutex) != 0) {
-		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error locking the framework, shutdown gate not set.");
-		return CELIX_FRAMEWORK_EXCEPTION;
-	}
-	while (!framework->shutdown) {
-	    celix_status_t status = celixThreadCondition_wait(&framework->shutdownGate, &framework->mutex);
-		if (status != 0) {
-			fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error waiting for shutdown gate.");
-			return CELIX_FRAMEWORK_EXCEPTION;
-		}
-	}
-	if (celixThreadMutex_unlock(&framework->mutex) != 0) {
-		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error unlocking the framework.");
-		return CELIX_FRAMEWORK_EXCEPTION;
-	}
-
-	celixThread_join(framework->shutdownThread, NULL);
-
-	fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Successful shutdown");
-	return CELIX_SUCCESS;
-}
-
-static void *framework_shutdown(void *framework) {
-	framework_pt fw = (framework_pt) framework;
-	int err;
-
-	fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown");
-	celixThreadMutex_lock(&fw->installedBundleMapLock);
-
-	hash_map_iterator_pt iter = hashMapIterator_create(fw->installedBundleMap);
-	bundle_pt bundle = NULL;
-	while ((bundle = hashMapIterator_nextValue(iter)) != NULL) {
-        bundle_state_e state;
-        bundle_getState(bundle, &state);
-        if (state == OSGI_FRAMEWORK_BUNDLE_ACTIVE || state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
-            celixThreadMutex_unlock(&fw->installedBundleMapLock);
-            fw_stopBundle(fw, bundle, 0);
-            celixThreadMutex_lock(&fw->installedBundleMapLock);
-            hashMapIterator_destroy(iter);
-            iter = hashMapIterator_create(fw->installedBundleMap);
-        }
-	}
-    hashMapIterator_destroy(iter);
-
-    iter = hashMapIterator_create(fw->installedBundleMap);
-	bundle = NULL;
-	while ((bundle = hashMapIterator_nextValue(iter)) != NULL) {
-		bundle_close(bundle);
-	}
-	hashMapIterator_destroy(iter);
-	celixThreadMutex_unlock(&fw->installedBundleMapLock);
-
-    err = celixThreadMutex_lock(&fw->mutex);
-    if (err != 0) {
-        fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking the framework, cannot exit clean.");
-        celixThread_exit(NULL);
-        return NULL;
-    }
-
-	if (celixThreadMutex_lock(&fw->dispatcherLock) != CELIX_SUCCESS) {
-		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error locking the dispatcherThread.");
-	}
-	else {
-		fw->shutdown = true;
-
-		if (celixThreadCondition_broadcast(&fw->dispatcher)) {
-			fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error broadcasting .");
-		}
-
-		if (celixThreadMutex_unlock(&fw->dispatcherLock)) {
-			fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error unlocking the dispatcherThread.");
-		}
-
-		celixThread_join(fw->dispatcherThread, NULL);
-	}
-
-
-	err = celixThreadCondition_broadcast(&fw->shutdownGate);
-	if (err != 0) {
-		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error waking the shutdown gate, cannot exit clean.");
-		err = celixThreadMutex_unlock(&fw->mutex);
-		if (err != 0) {
-			fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot exit clean.");
-		}
-
-		celixThread_exit(NULL);
-		return NULL;
-	}
-	err = celixThreadMutex_unlock(&fw->mutex);
-	if (err != 0) {
-//		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot exit clean.");
-	}
-
-//	fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown done\n");
-	celixThread_exit((void *) CELIX_SUCCESS);
-
-	return NULL;
-}
-
-celix_status_t framework_getFrameworkBundle(framework_pt framework, bundle_pt *bundle) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (framework != NULL && *bundle == NULL) {
-		*bundle = framework->bundle;
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	return status;
-}
-
-celix_status_t fw_fireBundleEvent(framework_pt framework, bundle_event_type_e eventType, bundle_pt bundle) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if ((eventType != OSGI_FRAMEWORK_BUNDLE_EVENT_STARTING)
-			&& (eventType != OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING)
-			&& (eventType != OSGI_FRAMEWORK_BUNDLE_EVENT_LAZY_ACTIVATION)) {
-		request_pt request = (request_pt) calloc(1, sizeof(*request));
-		if (!request) {
-			status = CELIX_ENOMEM;
-        } else {
-            bundle_archive_pt archive = NULL;
-            module_pt module = NULL;
-
-            request->eventType = eventType;
-            request->filter = NULL;
-            request->listeners = framework->bundleListeners;
-            request->type = BUNDLE_EVENT_TYPE;
-            request->error = NULL;
-            request->bundleId = -1;
-
-            status = bundle_getArchive(bundle, &archive);
-
-            if (status == CELIX_SUCCESS) {
-                long bundleId;
-
-                status = bundleArchive_getId(archive, &bundleId);
-
-                if (status == CELIX_SUCCESS) {
-                    request->bundleId = bundleId;
-                }
-            }
-
-            if (status == CELIX_SUCCESS) {
-                status = bundle_getCurrentModule(bundle, &module);
-
-                if (status == CELIX_SUCCESS) {
-                    const char *symbolicName = NULL;
-                    status = module_getSymbolicName(module, &symbolicName);
-                    if (status == CELIX_SUCCESS) {
-                        request->bundleSymbolicName = strdup(symbolicName);
-                    }
-                }
-            }
-
-            if (celixThreadMutex_lock(&framework->dispatcherLock) != CELIX_SUCCESS) {
-                status = CELIX_FRAMEWORK_EXCEPTION;
-            } else {
-                arrayList_

<TRUNCATED>

[11/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/unzip.h
----------------------------------------------------------------------
diff --git a/framework/src/unzip.h b/framework/src/unzip.h
new file mode 100644
index 0000000..3183968
--- /dev/null
+++ b/framework/src/unzip.h
@@ -0,0 +1,437 @@
+/* unzip.h -- IO for uncompress .zip files using zlib
+   Version 1.1, February 14h, 2010
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications of Unzip for Zip64
+         Copyright (C) 2007-2008 Even Rouault
+
+         Modifications for Zip64 support on both zip and unzip
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+         ---------------------------------------------------------------------------------
+
+        Condition of use and distribution are the same than zlib :
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  ---------------------------------------------------------------------------------
+
+        Changes
+
+        See header of unzip64.c
+
+*/
+
+#ifndef _unz64_H
+#define _unz64_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _ZLIB_H
+#include "zlib.h"
+#endif
+
+#ifndef  _ZLIBIOAPI_H
+#include "ioapi.h"
+#endif
+
+#ifdef HAVE_BZIP2
+#include "bzlib.h"
+#endif
+
+#define Z_BZIP2ED 12
+
+#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
+/* like the STRICT of WIN32, we define a pointer that cannot be converted
+    from (void*) without cast */
+typedef struct TagunzFile__ { int unused; } unzFile__;
+typedef unzFile__ *unzFile;
+#else
+typedef voidp unzFile;
+#endif
+
+
+#define UNZ_OK                          (0)
+#define UNZ_END_OF_LIST_OF_FILE         (-100)
+#define UNZ_ERRNO                       (Z_ERRNO)
+#define UNZ_EOF                         (0)
+#define UNZ_PARAMERROR                  (-102)
+#define UNZ_BADZIPFILE                  (-103)
+#define UNZ_INTERNALERROR               (-104)
+#define UNZ_CRCERROR                    (-105)
+
+/* tm_unz contain date/time info */
+typedef struct tm_unz_s
+{
+    uInt tm_sec;            /* seconds after the minute - [0,59] */
+    uInt tm_min;            /* minutes after the hour - [0,59] */
+    uInt tm_hour;           /* hours since midnight - [0,23] */
+    uInt tm_mday;           /* day of the month - [1,31] */
+    uInt tm_mon;            /* months since January - [0,11] */
+    uInt tm_year;           /* years - [1980..2044] */
+} tm_unz;
+
+/* unz_global_info structure contain global data about the ZIPfile
+   These data comes from the end of central dir */
+typedef struct unz_global_info64_s
+{
+    ZPOS64_T number_entry;         /* total number of entries in
+                                     the central dir on this disk */
+    uLong size_comment;         /* size of the global comment of the zipfile */
+} unz_global_info64;
+
+typedef struct unz_global_info_s
+{
+    uLong number_entry;         /* total number of entries in
+                                     the central dir on this disk */
+    uLong size_comment;         /* size of the global comment of the zipfile */
+} unz_global_info;
+
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_info64_s
+{
+    uLong version;              /* version made by                 2 bytes */
+    uLong version_needed;       /* version needed to extract       2 bytes */
+    uLong flag;                 /* general purpose bit flag        2 bytes */
+    uLong compression_method;   /* compression method              2 bytes */
+    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
+    uLong crc;                  /* crc-32                          4 bytes */
+    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */
+    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */
+    uLong size_filename;        /* filename length                 2 bytes */
+    uLong size_file_extra;      /* extra field length              2 bytes */
+    uLong size_file_comment;    /* file comment length             2 bytes */
+
+    uLong disk_num_start;       /* disk number start               2 bytes */
+    uLong internal_fa;          /* internal file attributes        2 bytes */
+    uLong external_fa;          /* external file attributes        4 bytes */
+
+    tm_unz tmu_date;
+} unz_file_info64;
+
+typedef struct unz_file_info_s
+{
+    uLong version;              /* version made by                 2 bytes */
+    uLong version_needed;       /* version needed to extract       2 bytes */
+    uLong flag;                 /* general purpose bit flag        2 bytes */
+    uLong compression_method;   /* compression method              2 bytes */
+    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
+    uLong crc;                  /* crc-32                          4 bytes */
+    uLong compressed_size;      /* compressed size                 4 bytes */
+    uLong uncompressed_size;    /* uncompressed size               4 bytes */
+    uLong size_filename;        /* filename length                 2 bytes */
+    uLong size_file_extra;      /* extra field length              2 bytes */
+    uLong size_file_comment;    /* file comment length             2 bytes */
+
+    uLong disk_num_start;       /* disk number start               2 bytes */
+    uLong internal_fa;          /* internal file attributes        2 bytes */
+    uLong external_fa;          /* external file attributes        4 bytes */
+
+    tm_unz tmu_date;
+} unz_file_info;
+
+extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
+                                                 const char* fileName2,
+                                                 int iCaseSensitivity));
+/*
+   Compare two filename (fileName1,fileName2).
+   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
+   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
+                                or strcasecmp)
+   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
+    (like 1 on Unix, 2 on Windows)
+*/
+
+
+extern unzFile ZEXPORT unzOpen OF((const char *path));
+extern unzFile ZEXPORT unzOpen64 OF((const void *path));
+/*
+  Open a Zip file. path contain the full pathname (by example,
+     on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
+     "zlib/zlib113.zip".
+     If the zipfile cannot be opened (file don't exist or in not valid), the
+       return value is NULL.
+     Else, the return value is a unzFile Handle, usable with other function
+       of this unzip package.
+     the "64" function take a const void* pointer, because the path is just the
+       value passed to the open64_file_func callback.
+     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
+       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
+       does not describe the reality
+*/
+
+
+extern unzFile ZEXPORT unzOpen2 OF((const char *path,
+                                    zlib_filefunc_def* pzlib_filefunc_def));
+/*
+   Open a Zip file, like unzOpen, but provide a set of file low level API
+      for read/write the zip file (see ioapi.h)
+*/
+
+extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
+                                    zlib_filefunc64_def* pzlib_filefunc_def));
+/*
+   Open a Zip file, like unz64Open, but provide a set of file low level API
+      for read/write the zip file (see ioapi.h)
+*/
+
+extern int ZEXPORT unzClose OF((unzFile file));
+/*
+  Close a ZipFile opened with unzipOpen.
+  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
+    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+  return UNZ_OK if there is no problem. */
+
+extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
+                                        unz_global_info *pglobal_info));
+
+extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
+                                        unz_global_info64 *pglobal_info));
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem. */
+
+
+extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
+                                           char *szComment,
+                                           uLong uSizeBuf));
+/*
+  Get the global comment string of the ZipFile, in the szComment buffer.
+  uSizeBuf is the size of the szComment buffer.
+  return the number of byte copied or an error code <0
+*/
+
+
+/***************************************************************************/
+/* Unzip package allow you browse the directory of the zipfile */
+
+extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
+/*
+  Set the current file of the zipfile to the first file.
+  return UNZ_OK if there is no problem
+*/
+
+extern int ZEXPORT unzGoToNextFile OF((unzFile file));
+/*
+  Set the current file of the zipfile to the next file.
+  return UNZ_OK if there is no problem
+  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
+*/
+
+extern int ZEXPORT unzLocateFile OF((unzFile file,
+                     const char *szFileName,
+                     int iCaseSensitivity));
+/*
+  Try locate the file szFileName in the zipfile.
+  For the iCaseSensitivity signification, see unzStringFileNameCompare
+
+  return value :
+  UNZ_OK if the file is found. It becomes the current file.
+  UNZ_END_OF_LIST_OF_FILE if the file is not found
+*/
+
+
+/* ****************************************** */
+/* Ryan supplied functions */
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_pos_s
+{
+    uLong pos_in_zip_directory;   /* offset in zip file directory */
+    uLong num_of_file;            /* # of file */
+} unz_file_pos;
+
+extern int ZEXPORT unzGetFilePos(
+    unzFile file,
+    unz_file_pos* file_pos);
+
+extern int ZEXPORT unzGoToFilePos(
+    unzFile file,
+    unz_file_pos* file_pos);
+
+typedef struct unz64_file_pos_s
+{
+    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */
+    ZPOS64_T num_of_file;            /* # of file */
+} unz64_file_pos;
+
+extern int ZEXPORT unzGetFilePos64(
+    unzFile file,
+    unz64_file_pos* file_pos);
+
+extern int ZEXPORT unzGoToFilePos64(
+    unzFile file,
+    const unz64_file_pos* file_pos);
+
+/* ****************************************** */
+
+extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
+                         unz_file_info64 *pfile_info,
+                         char *szFileName,
+                         uLong fileNameBufferSize,
+                         void *extraField,
+                         uLong extraFieldBufferSize,
+                         char *szComment,
+                         uLong commentBufferSize));
+
+extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
+                         unz_file_info *pfile_info,
+                         char *szFileName,
+                         uLong fileNameBufferSize,
+                         void *extraField,
+                         uLong extraFieldBufferSize,
+                         char *szComment,
+                         uLong commentBufferSize));
+/*
+  Get Info about the current file
+  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
+        the current file
+  if szFileName!=NULL, the filemane string will be copied in szFileName
+            (fileNameBufferSize is the size of the buffer)
+  if extraField!=NULL, the extra field information will be copied in extraField
+            (extraFieldBufferSize is the size of the buffer).
+            This is the Central-header version of the extra field
+  if szComment!=NULL, the comment string of the file will be copied in szComment
+            (commentBufferSize is the size of the buffer)
+*/
+
+
+/** Addition for GDAL : START */
+
+extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
+
+/** Addition for GDAL : END */
+
+
+/***************************************************************************/
+/* for reading the content of the current zipfile, you can open it, read data
+   from it, and close it (you can close it before reading all the file)
+   */
+
+extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
+/*
+  Open for reading data the current file in the zipfile.
+  If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
+                                                  const char* password));
+/*
+  Open for reading data the current file in the zipfile.
+  password is a crypting password
+  If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
+                                           int* method,
+                                           int* level,
+                                           int raw));
+/*
+  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+    if raw==1
+  *method will receive method of compression, *level will receive level of
+     compression
+  note : you can set level parameter as NULL (if you did not want known level,
+         but you CANNOT set method parameter as NULL
+*/
+
+extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
+                                           int* method,
+                                           int* level,
+                                           int raw,
+                                           const char* password));
+/*
+  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+    if raw==1
+  *method will receive method of compression, *level will receive level of
+     compression
+  note : you can set level parameter as NULL (if you did not want known level,
+         but you CANNOT set method parameter as NULL
+*/
+
+
+extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
+/*
+  Close the file in zip opened with unzOpenCurrentFile
+  Return UNZ_CRCERROR if all the file was read but the CRC is not good
+*/
+
+extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
+                      voidp buf,
+                      unsigned len));
+/*
+  Read bytes from the current file (opened by unzOpenCurrentFile)
+  buf contain buffer where data must be copied
+  len the size of buf.
+
+  return the number of byte copied if somes bytes are copied
+  return 0 if the end of file was reached
+  return <0 with error code if there is an error
+    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+*/
+
+extern z_off_t ZEXPORT unztell OF((unzFile file));
+
+extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
+/*
+  Give the current position in uncompressed data
+*/
+
+extern int ZEXPORT unzeof OF((unzFile file));
+/*
+  return 1 if the end of file was reached, 0 elsewhere
+*/
+
+extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
+                                             voidp buf,
+                                             unsigned len));
+/*
+  Read extra field from the current file (opened by unzOpenCurrentFile)
+  This is the local-header version of the extra field (sometimes, there is
+    more info in the local-header version than in the central-header)
+
+  if buf==NULL, it return the size of the local extra field
+
+  if buf!=NULL, len is the size of the buffer, the extra header is copied in
+    buf.
+  the return value is the number of bytes copied in buf, or (if <0)
+    the error code
+*/
+
+/***************************************************************************/
+
+/* Get the current file offset */
+extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
+extern uLong ZEXPORT unzGetOffset (unzFile file);
+
+/* Set the current file offset */
+extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
+extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _unz64_H */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/wire.c
----------------------------------------------------------------------
diff --git a/framework/src/wire.c b/framework/src/wire.c
new file mode 100644
index 0000000..508c865
--- /dev/null
+++ b/framework/src/wire.c
@@ -0,0 +1,87 @@
+/**
+ *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.
+ */
+/*
+ * wire.c
+ *
+ *  \date       Jul 19, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "wire.h"
+
+struct wire {
+	module_pt importer;
+	requirement_pt requirement;
+	module_pt exporter;
+	capability_pt capability;
+};
+
+celix_status_t wire_create(module_pt importer, requirement_pt requirement,
+		module_pt exporter, capability_pt capability, wire_pt *wire) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (*wire != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		(*wire) = (wire_pt) malloc(sizeof(**wire));
+		if (!*wire) {
+			status = CELIX_ENOMEM;
+		} else {
+			(*wire)->importer = importer;
+			(*wire)->requirement = requirement;
+			(*wire)->exporter = exporter;
+			(*wire)->capability = capability;
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot create wire");
+
+	return status;
+}
+
+celix_status_t wire_destroy(wire_pt wire) {
+	wire->importer = NULL;
+	wire->requirement = NULL;
+	wire->exporter = NULL;
+	wire->capability = NULL;
+	free(wire);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t wire_getCapability(wire_pt wire, capability_pt *capability) {
+	*capability = wire->capability;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t wire_getRequirement(wire_pt wire, requirement_pt *requirement) {
+	*requirement = wire->requirement;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t wire_getImporter(wire_pt wire, module_pt *importer) {
+	*importer = wire->importer;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t wire_getExporter(wire_pt wire, module_pt *exporter) {
+	*exporter = wire->exporter;
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/framework/tst/CMakeLists.txt b/framework/tst/CMakeLists.txt
index 672fd99..169e828 100644
--- a/framework/tst/CMakeLists.txt
+++ b/framework/tst/CMakeLists.txt
@@ -15,23 +15,13 @@
 # specific language governing permissions and limitations
 # under the License.
 
-include_directories(
-    ${PROJECT_SOURCE_DIR}/framework/public/include
-    ${PROJECT_SOURCE_DIR}/utils/public/include
-    ${PROJECT_SOURCE_DIR}/utils/public/include
-)
-
-
-SET(CMAKE_SKIP_BUILD_RPATH  FALSE) #TODO needed?
-SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) #TODO needed?
-SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/framework" "${PROJECT_BINARY_DIR}/utils")
 
 add_executable(test_framework
     run_tests.cpp
     single_framework_test.cpp
     multiple_frameworks_test.cpp
 )
-target_link_libraries(test_framework celix_framework celix_utils ${CURL_LIBRARIES} ${CPPUTEST_LIBRARY})
+target_link_libraries(test_framework Celix::framework ${CURL_LIBRARIES} ${CPPUTEST_LIBRARY})
 
 configure_file(config.properties.in config.properties @ONLY)
 configure_file(framework1.properties.in framework1.properties @ONLY)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/launcher/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 8d4ba36..33e6e6e 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -21,36 +21,35 @@ if (LAUNCHER)
     include_directories(public/include)
 
     #celix launcher linked to libc
-    add_executable(celix
-        private/src/main.c
+    add_executable(launcher
+        src/main.c
     )
+    set_target_properties(launcher PROPERTIES OUTPUT_NAME "celix")
+    set_target_properties(launcher PROPERTIES "INSTALL_RPATH" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+    target_include_directories(launcher PRIVATE src)
 
-    set_target_properties(celix     PROPERTIES "INSTALL_RPATH" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
-    
-    target_link_libraries(celix     celix_framework ${CURL_LIBRARIES})
+    target_link_libraries(launcher PRIVATE Celix::framework)
     if (NOT ANDROID)
-        target_link_libraries(celix celix_dfi) #note not strictly needed, but ensure libdfi is a dep for the framework, useful when create docker images
+        target_link_libraries(launcher PRIVATE Celix::dfi) #note not strictly needed, but ensure libdfi is a dep for the framework, useful when create docker images
     endif()
-
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-    include_directories("${CURL_INCLUDE_DIRS}")
     
-    install(TARGETS celix RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT framework)
+    install(TARGETS launcher RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT framework)
+
+    #Setup target aliases to match external usage
+    add_executable(Celix::launcher ALIAS launcher)
 
     find_package(CppUTest QUIET)
     if (CPPUTEST_FOUND)
         #Test running which start celix and run CppUTest RUN_ALL_TESTS.
         #Using this test running it is possible to create bundles containing CppUTests.
-	include_directories(celix_test_runner)
-	include_directories(SYSTEM ${CPPUTEST_INCLUDE_DIRS})
+	    include_directories(celix_test_runner)
+	    include_directories(SYSTEM ${CPPUTEST_INCLUDE_DIRS})
         add_executable(celix_test_runner
-                private/src/celix_test_runner.cpp
+                src/celix_test_runner.cpp
         )
         set_target_properties(celix_test_runner PROPERTIES "INSTALL_RPATH" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
-        target_link_libraries(celix_test_runner
-            celix_framework
-            ${CURL_LIBRARIES}
+        target_link_libraries(celix_test_runner PRIVATE
+            Celix::framework
             ${CPPUTEST_LIBRARIES}
             ${CPPUTEST_EXT_LIBRARIES}
         )

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/launcher/private/src/celix_test_runner.cpp
----------------------------------------------------------------------
diff --git a/launcher/private/src/celix_test_runner.cpp b/launcher/private/src/celix_test_runner.cpp
deleted file mode 100644
index 1855e9f..0000000
--- a/launcher/private/src/celix_test_runner.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- *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.
- */
-
-
-#include <signal.h>
-
-#include "celix_launcher.h"
-
-#include <CppUTest/CommandLineTestRunner.h>
-
-static void shutdown_framework(int signal);
-static void ignore(int signal);
-
-#define DEFAULT_CONFIG_FILE "config.properties"
-
-static framework_pt framework = NULL;
-
-int main(int argc, char *argv[]) {
-    // Perform some minimal command-line option parsing...
-    const char *cfg = DEFAULT_CONFIG_FILE;
-
-    // Set signal handler
-    (void) signal(SIGINT, shutdown_framework);
-    (void) signal(SIGUSR1, ignore);
-    (void) signal(SIGUSR2, ignore);
-
-    int rc = celixLauncher_launch(cfg, &framework);
-    if (rc != 0) {
-        printf("Error starting Celix\n");
-    }
-
-    if (rc == 0 && framework != NULL) {
-        rc = RUN_ALL_TESTS(argc, argv);
-
-        celixLauncher_stop(framework);
-        celixLauncher_waitForShutdown(framework);
-        celixLauncher_destroy(framework);
-    }
-
-    if (rc != 0) {
-        printf("*** FAILURE ***\n");
-    } else {
-        printf("*** SUCCESS ***\n");
-    }
-
-    return rc;
-}
-
-static void shutdown_framework(int __attribute__((unused)) signal) {
-    if (framework != NULL) {
-        celixLauncher_stop(framework); //NOTE main thread will destroy
-    }
-}
-
-static void ignore(int __attribute__((unused)) signal) {
-    //ignoring for signal SIGUSR1, SIGUSR2. Can be used to interrupt sleep, etc
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/launcher/private/src/main.c
----------------------------------------------------------------------
diff --git a/launcher/private/src/main.c b/launcher/private/src/main.c
deleted file mode 100644
index bd26e8b..0000000
--- a/launcher/private/src/main.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- *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.
- */
-
-#include "celix_launcher.h"
-
-int main(int argc, char *argv[]) {
-    return celixLauncher_launchWithArgs(argc, argv);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/launcher/src/celix_test_runner.cpp
----------------------------------------------------------------------
diff --git a/launcher/src/celix_test_runner.cpp b/launcher/src/celix_test_runner.cpp
new file mode 100644
index 0000000..1855e9f
--- /dev/null
+++ b/launcher/src/celix_test_runner.cpp
@@ -0,0 +1,73 @@
+/**
+ *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.
+ */
+
+
+#include <signal.h>
+
+#include "celix_launcher.h"
+
+#include <CppUTest/CommandLineTestRunner.h>
+
+static void shutdown_framework(int signal);
+static void ignore(int signal);
+
+#define DEFAULT_CONFIG_FILE "config.properties"
+
+static framework_pt framework = NULL;
+
+int main(int argc, char *argv[]) {
+    // Perform some minimal command-line option parsing...
+    const char *cfg = DEFAULT_CONFIG_FILE;
+
+    // Set signal handler
+    (void) signal(SIGINT, shutdown_framework);
+    (void) signal(SIGUSR1, ignore);
+    (void) signal(SIGUSR2, ignore);
+
+    int rc = celixLauncher_launch(cfg, &framework);
+    if (rc != 0) {
+        printf("Error starting Celix\n");
+    }
+
+    if (rc == 0 && framework != NULL) {
+        rc = RUN_ALL_TESTS(argc, argv);
+
+        celixLauncher_stop(framework);
+        celixLauncher_waitForShutdown(framework);
+        celixLauncher_destroy(framework);
+    }
+
+    if (rc != 0) {
+        printf("*** FAILURE ***\n");
+    } else {
+        printf("*** SUCCESS ***\n");
+    }
+
+    return rc;
+}
+
+static void shutdown_framework(int __attribute__((unused)) signal) {
+    if (framework != NULL) {
+        celixLauncher_stop(framework); //NOTE main thread will destroy
+    }
+}
+
+static void ignore(int __attribute__((unused)) signal) {
+    //ignoring for signal SIGUSR1, SIGUSR2. Can be used to interrupt sleep, etc
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/launcher/src/main.c
----------------------------------------------------------------------
diff --git a/launcher/src/main.c b/launcher/src/main.c
new file mode 100644
index 0000000..bd26e8b
--- /dev/null
+++ b/launcher/src/main.c
@@ -0,0 +1,24 @@
+/**
+ *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.
+ */
+
+#include "celix_launcher.h"
+
+int main(int argc, char *argv[]) {
+    return celixLauncher_launchWithArgs(argc, argv);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/log_service/CMakeLists.txt b/log_service/CMakeLists.txt
index 131a986..b9af374 100644
--- a/log_service/CMakeLists.txt
+++ b/log_service/CMakeLists.txt
@@ -18,37 +18,40 @@
 celix_subproject(LOG_SERVICE "Option to enable building the Log Service bundles" ON DEPS framework)
 if (LOG_SERVICE)
 
+	add_library(log_service_api INTERFACE)
+	target_include_directories(log_service_api INTERFACE include)
+
+	add_library(log_helper STATIC src/log_helper.c)
+	target_include_directories(log_helper PUBLIC loghelper_include)
+	target_link_libraries(log_helper PUBLIC Celix::framework log_service_api)
+	#TODO install log helper
+
     add_bundle(log_service
     	SYMBOLIC_NAME "apache_celix_log_service"
     	NAME "Apache Celix Log Service"
     	VERSION "1.1.0"
     	SOURCES
-			private/src/log
-			private/src/log_entry
-			private/src/log_factory  
-			private/src/log_service_impl 
-			private/src/log_service_activator
-			private/src/log_reader_service_impl
-		    
-		    private/include/log.h
-		    private/include/log_factory.h
-		    private/include/log_reader_service_impl.h
-		    private/include/log_service_impl.h
+			src/log
+			src/log_entry
+			src/log_factory
+			src/log_service_impl
+			src/log_service_activator
+			src/log_reader_service_impl
     )
     
     install_bundle(log_service
         HEADERS
-        	public/include/log_service.h
-        	public/include/log_reader_service.h
-        	public/include/log_listener.h
-        	public/include/log_entry.h
-        	public/include/log_helper.h
-        RESOURCES
-            public/src/log_helper.c
+        	include/log_service.h
+        	include/log_reader_service.h
+        	include/log_listener.h
+        	include/log_entry.h
     )
-    
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/log_service/private/include")
-    target_link_libraries(log_service celix_framework)
+
+	target_include_directories(log_service PRIVATE src)
+	target_link_libraries(log_service PRIVATE log_service_api)
+
+	#Setup target aliases to match external usage
+	add_library(Celix::log_service_api ALIAS log_service_api)
+	add_library(Celix::log_service ALIAS log_service)
+	add_library(Celix::log_helper ALIAS log_helper)
 endif (LOG_SERVICE)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/README.md
----------------------------------------------------------------------
diff --git a/log_service/README.md b/log_service/README.md
index 32ee520..384a00e 100644
--- a/log_service/README.md
+++ b/log_service/README.md
@@ -1,12 +1,19 @@
-## Log Service
+# Log Service
 
 The Celix Log Service realizes an adapted implementation of the OSGi Compendium Log Service. This is a very simple implementation which only stores the log in memory. It can be combined with one of the available Log Writers to forward the buffered entries to e.g. stdout or syslog.
 
 To ease the use of the Log Service, the [Log Helper](public/include/log_helper.h) can be used. It wraps and therefore simplifies the log service usage.
 
-###### Properties
+## Properties
     LOGHELPER_ENABLE_STDOUT_FALLBACK      If set to any value and in case no Log Service is found the logs
                                           are still printed on stdout. 
 
-###### CMake option
+## CMake option
     BUILD_LOG_SERVICE=ON
+
+## Using info
+
+If the Celix Log Service is installed The `FindCelix.cmake` will set:
+ - The `Celix::log_service_api` interface (i.e. header only) library target
+ - The `Celix::log_service` bundle target
+ - The `Celix::log_helper` static library target

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/include/log_entry.h
----------------------------------------------------------------------
diff --git a/log_service/include/log_entry.h b/log_service/include/log_entry.h
new file mode 100644
index 0000000..e588774
--- /dev/null
+++ b/log_service/include/log_entry.h
@@ -0,0 +1,55 @@
+/**
+ *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.
+ */
+/*
+ * log_entry.h
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_ENTRY_H_
+#define LOG_ENTRY_H_
+
+#include "log_service.h"
+
+struct log_entry {
+    int errorCode;
+    log_level_t level;
+    char *message;
+    time_t time;
+
+    long bundleId;
+    char* bundleSymbolicName;
+};
+
+typedef struct log_entry * log_entry_pt;
+
+celix_status_t logEntry_create(long bundleId, const char* bundleSymbolicName , service_reference_pt reference,
+        log_level_t level, char *message, int errorCode,
+        log_entry_pt *entry);
+celix_status_t logEntry_destroy(log_entry_pt *entry);
+celix_status_t logEntry_getBundleSymbolicName(log_entry_pt entry, const char** bundleSymbolicName);
+celix_status_t logEntry_getBundleId(log_entry_pt entry, long *bundleId);
+celix_status_t logEntry_getErrorCode(log_entry_pt entry, int *errorCode);
+celix_status_t logEntry_getLevel(log_entry_pt entry, log_level_t *level);
+celix_status_t logEntry_getMessage(log_entry_pt entry, const char** message);
+celix_status_t logEntry_getTime(log_entry_pt entry, time_t *time);
+
+#endif /* LOG_ENTRY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/include/log_listener.h
----------------------------------------------------------------------
diff --git a/log_service/include/log_listener.h b/log_service/include/log_listener.h
new file mode 100644
index 0000000..b726994
--- /dev/null
+++ b/log_service/include/log_listener.h
@@ -0,0 +1,43 @@
+/**
+ *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.
+ */
+/*
+ * log_listener.h
+ *
+ *  \date       Jul 4, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_LISTENER_H_
+#define LOG_LISTENER_H_
+
+#include "log_entry.h"
+#include "celix_errno.h"
+
+struct log_listener {
+    void *handle;
+    celix_status_t (*logged)(struct log_listener *listener, log_entry_pt entry);
+};
+
+typedef struct log_listener log_listener_t;
+typedef log_listener_t* log_listener_pt;
+
+celix_status_t logListener_logged(log_listener_pt listener, log_entry_pt entry);
+
+#endif /* LOG_LISTENER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/include/log_reader_service.h
----------------------------------------------------------------------
diff --git a/log_service/include/log_reader_service.h b/log_service/include/log_reader_service.h
new file mode 100644
index 0000000..6815123
--- /dev/null
+++ b/log_service/include/log_reader_service.h
@@ -0,0 +1,50 @@
+/**
+ *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.
+ */
+/*
+ * log_reader_service.h
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_READER_SERVICE_H_
+#define LOG_READER_SERVICE_H_
+
+
+#include "celix_errno.h"
+#include "linked_list.h"
+#include "log_listener.h"
+
+static const char * const OSGI_LOGSERVICE_READER_SERVICE_NAME = "log_reader_service";
+
+typedef struct log_reader_data log_reader_data_t;
+typedef log_reader_data_t* log_reader_data_pt;
+
+struct log_reader_service {
+    log_reader_data_pt reader;
+    celix_status_t (*getLog)(log_reader_data_pt reader, linked_list_pt *list);
+    celix_status_t (*addLogListener)(log_reader_data_pt reader, log_listener_pt listener);
+    celix_status_t (*removeLogListener)(log_reader_data_pt reader, log_listener_pt listener);
+    celix_status_t (*removeAllLogListener)(log_reader_data_pt reader);
+};
+
+typedef struct log_reader_service * log_reader_service_pt;
+
+#endif /* LOG_READER_SERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/include/log_service.h
----------------------------------------------------------------------
diff --git a/log_service/include/log_service.h b/log_service/include/log_service.h
new file mode 100644
index 0000000..2691e35
--- /dev/null
+++ b/log_service/include/log_service.h
@@ -0,0 +1,58 @@
+/**
+ *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.
+ */
+/*
+ * log_service.h
+ *
+ *  \date       Jun 22, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_SERVICE_H_
+#define LOG_SERVICE_H_
+
+#include "celix_errno.h"
+#include "service_reference.h"
+
+static const char * const OSGI_LOGSERVICE_NAME = "log_service";
+
+typedef struct log_service_data *log_service_data_pt;
+
+enum log_level
+{
+    OSGI_LOGSERVICE_ERROR = 0x00000001,
+    OSGI_LOGSERVICE_WARNING = 0x00000002,
+    OSGI_LOGSERVICE_INFO = 0x00000003,
+    OSGI_LOGSERVICE_DEBUG = 0x00000004,
+};
+
+typedef enum log_level log_level_t;
+
+struct log_service {
+    log_service_data_pt logger;
+    celix_status_t (*log)(log_service_data_pt logger, log_level_t level, char * message);
+    celix_status_t (*logSr)(log_service_data_pt logger, service_reference_pt reference, log_level_t level, char * message);
+};
+
+typedef struct log_service log_service_t;
+typedef log_service_t* log_service_pt;
+
+
+
+#endif /* LOG_SERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/loghelper_include/log_helper.h
----------------------------------------------------------------------
diff --git a/log_service/loghelper_include/log_helper.h b/log_service/loghelper_include/log_helper.h
new file mode 100644
index 0000000..04e4bb2
--- /dev/null
+++ b/log_service/loghelper_include/log_helper.h
@@ -0,0 +1,35 @@
+/**
+ *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.
+ */
+
+
+#ifndef LOGHELPER_H_
+#define LOGHELPER_H_
+
+#include "bundle_context.h"
+#include "log_service.h"
+
+typedef struct log_helper* log_helper_pt;
+
+celix_status_t logHelper_create(bundle_context_pt context, log_helper_pt* log_helper);
+celix_status_t logHelper_start(log_helper_pt loghelper);
+celix_status_t logHelper_stop(log_helper_pt loghelper);
+celix_status_t logHelper_destroy(log_helper_pt* loghelper);
+celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* message, ... );
+
+#endif /* LOGHELPER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/include/log.h
----------------------------------------------------------------------
diff --git a/log_service/private/include/log.h b/log_service/private/include/log.h
deleted file mode 100644
index e0d7b87..0000000
--- a/log_service/private/include/log.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *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.
- */
-/*
- * log.h
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_H_
-#define LOG_H_
-
-#include "linked_list.h"
-#include "log_entry.h"
-#include "log_listener.h"
-
-typedef struct log * log_pt;
-
-celix_status_t log_create(int max_size, bool store_debug, log_pt *logger);
-celix_status_t log_destroy(log_pt logger);
-celix_status_t log_addEntry(log_pt log, log_entry_pt entry);
-celix_status_t log_getEntries(log_pt log, linked_list_pt *list);
-
-celix_status_t log_bundleChanged(void *listener, bundle_event_pt event);
-celix_status_t log_frameworkEvent(void *listener, framework_event_pt event);
-
-celix_status_t log_addLogListener(log_pt logger, log_listener_pt listener);
-celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener);
-celix_status_t log_removeAllLogListener(log_pt logger);
-
-#endif /* LOG_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/include/log_factory.h
----------------------------------------------------------------------
diff --git a/log_service/private/include/log_factory.h b/log_service/private/include/log_factory.h
deleted file mode 100644
index 8ebe5f8..0000000
--- a/log_service/private/include/log_factory.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- *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.
- */
-/*
- * log_factory.h
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_FACTORY_H_
-#define LOG_FACTORY_H_
-
-#include "log.h"
-
-typedef struct log_service_factory * log_service_factory_pt;
-
-celix_status_t logFactory_create(log_pt log, service_factory_pt *factory);
-celix_status_t logFactory_destroy(service_factory_pt *factory);
-celix_status_t logFactory_getService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service);
-celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service);
-
-
-#endif /* LOG_FACTORY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/include/log_reader_service_impl.h
----------------------------------------------------------------------
diff --git a/log_service/private/include/log_reader_service_impl.h b/log_service/private/include/log_reader_service_impl.h
deleted file mode 100644
index 71829f2..0000000
--- a/log_service/private/include/log_reader_service_impl.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *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.
- */
-/*
- * log_reader_service_impl.h
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_READER_SERVICE_IMPL_H_
-#define LOG_READER_SERVICE_IMPL_H_
-
-#include "log_reader_service.h"
-#include "log.h"
-
-celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader);
-celix_status_t logReaderService_destroy(log_reader_data_pt *reader);
-
-celix_status_t logReaderService_getLog(log_reader_data_pt reader, linked_list_pt *list);
-
-celix_status_t logReaderService_addLogListener(log_reader_data_pt reader, log_listener_pt listener);
-celix_status_t logReaderService_removeLogListener(log_reader_data_pt reader, log_listener_pt listener);
-celix_status_t logReaderService_removeAllLogListener(log_reader_data_pt reader);
-
-
-#endif /* LOG_READER_SERVICE_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/include/log_service_impl.h
----------------------------------------------------------------------
diff --git a/log_service/private/include/log_service_impl.h b/log_service/private/include/log_service_impl.h
deleted file mode 100644
index 04c986e..0000000
--- a/log_service/private/include/log_service_impl.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *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.
- */
-/*
- * log_service_impl.h
- *
- *  \date       Jun 22, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_SERVICE_IMPL_H_
-#define LOG_SERVICE_IMPL_H_
-
-#include "log_service.h"
-#include "log.h"
-
-celix_status_t logService_create(log_pt log, bundle_pt bundle, log_service_data_pt *logger);
-celix_status_t logService_destroy(log_service_data_pt *logger);
-celix_status_t logService_log(log_service_data_pt logger, log_level_t level, char * message);
-celix_status_t logService_logSr(log_service_data_pt logger, service_reference_pt reference, log_level_t level, char * message);
-
-
-#endif /* LOG_SERVICE_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/src/log.c
----------------------------------------------------------------------
diff --git a/log_service/private/src/log.c b/log_service/private/src/log.c
deleted file mode 100644
index 5b29318..0000000
--- a/log_service/private/src/log.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/**
- *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.
- */
-/*
- * log.c
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "log.h"
-#include "linked_list_iterator.h"
-#include "array_list.h"
-
-struct log {
-	linked_list_pt entries;
-	celix_thread_mutex_t lock;
-
-	array_list_pt listeners;
-	array_list_pt listenerEntries;
-
-	celix_thread_t listenerThread;
-	bool running;
-
-	celix_thread_cond_t entriesToDeliver;
-	celix_thread_mutex_t deliverLock;
-	celix_thread_mutex_t listenerLock;
-
-	int max_size;
-	bool store_debug;
-};
-
-static celix_status_t log_startListenerThread(log_pt logger);
-static celix_status_t log_stopListenerThread(log_pt logger);
-
-
-static void *log_listenerThread(void *data);
-
-celix_status_t log_create(int max_size, bool store_debug, log_pt *logger) {
-	celix_status_t status = CELIX_ENOMEM;
-
-	*logger = calloc(1, sizeof(**logger));
-
-	if (*logger != NULL) {
-		linkedList_create(&(*logger)->entries);
-
-		status = celixThreadMutex_create(&(*logger)->lock, NULL);
-
-		(*logger)->listeners = NULL;
-		(*logger)->listenerEntries = NULL;
-		(*logger)->listenerThread = celix_thread_default;
-		(*logger)->running = false;
-
-		(*logger)->max_size = max_size;
-		(*logger)->store_debug = store_debug;
-
-		arrayList_create(&(*logger)->listeners);
-		arrayList_create(&(*logger)->listenerEntries);
-
-		if (celixThreadCondition_init(&(*logger)->entriesToDeliver, NULL) != CELIX_SUCCESS) {
-			status = CELIX_INVALID_SYNTAX;
-		}
-		else if (celixThreadMutex_create(&(*logger)->deliverLock, NULL) != CELIX_SUCCESS) {
-			status = CELIX_INVALID_SYNTAX;
-		}
-		else if (celixThreadMutex_create(&(*logger)->listenerLock, NULL) != CELIX_SUCCESS) {
-			status = CELIX_INVALID_SYNTAX;
-		}
-		else {
-			status = CELIX_SUCCESS;
-		}
-	}
-
-	return status;
-}
-
-celix_status_t log_destroy(log_pt logger) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	celixThreadMutex_destroy(&logger->listenerLock);
-	celixThreadMutex_destroy(&logger->deliverLock);
-	celixThreadCondition_destroy(&logger->entriesToDeliver);
-
-	arrayList_destroy(logger->listeners);
-	linked_list_iterator_pt iter = linkedListIterator_create(logger->entries, 0);
-	while (linkedListIterator_hasNext(iter)) {
-        	log_entry_pt entry = linkedListIterator_next(iter);
-        	if (arrayList_contains(logger->listenerEntries, entry)) {
-            		arrayList_removeElement(logger->listenerEntries, entry);
-        	}
-        	logEntry_destroy(&entry);
-    	}
-    	linkedListIterator_destroy(iter);
-
-    	array_list_iterator_pt entryIter = arrayListIterator_create(logger->listenerEntries);
-
-    	while (arrayListIterator_hasNext(entryIter)) {
-        	log_entry_pt entry = arrayListIterator_next(entryIter);
-        	logEntry_destroy(&entry);
-    	}
-    	arrayListIterator_destroy(entryIter);
-
-    	arrayList_destroy(logger->listenerEntries);
-	linkedList_destroy(logger->entries);
-
-	celixThreadMutex_destroy(&logger->lock);
-
-	free(logger);
-
-	return status;
-}
-
-celix_status_t log_addEntry(log_pt log, log_entry_pt entry) {
-	celixThreadMutex_lock(&log->lock);
-
-	if (log->max_size != 0) {
-		if (log->store_debug || entry->level != OSGI_LOGSERVICE_DEBUG) {
-			linkedList_addElement(log->entries, entry);
-		}
-	}
-
-	celixThreadMutex_lock(&log->deliverLock);
-	arrayList_add(log->listenerEntries, entry);
-	celixThreadMutex_unlock(&log->deliverLock);
-
-	celixThreadCondition_signal(&log->entriesToDeliver);
-
-	if (log->max_size != 0) {
-		if (log->max_size != -1) {
-			if (linkedList_size(log->entries) > log->max_size) {
-				log_entry_pt rentry = linkedList_removeFirst(log->entries);
-				if (rentry) {
-					celixThreadMutex_lock(&log->deliverLock);
-					arrayList_removeElement(log->listenerEntries, rentry);
-					logEntry_destroy(&rentry);
-					celixThreadMutex_unlock(&log->deliverLock);
-				}
-			}
-		}
-	}
-
-	celixThreadMutex_unlock(&log->lock);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t log_getEntries(log_pt log, linked_list_pt *list) {
-	linked_list_pt entries = NULL;
-	if (linkedList_create(&entries) == CELIX_SUCCESS) {
-		linked_list_iterator_pt iter = NULL;
-
-		celixThreadMutex_lock(&log->lock);
-
-		iter = linkedListIterator_create(log->entries, 0);
-		while (linkedListIterator_hasNext(iter)) {
-			linkedList_addElement(entries, linkedListIterator_next(iter));
-		}
-		linkedListIterator_destroy(iter);
-
-		*list = entries;
-
-		celixThreadMutex_unlock(&log->lock);
-
-		return CELIX_SUCCESS;
-	} else {
-		return CELIX_ENOMEM;
-	}
-}
-
-celix_status_t log_bundleChanged(void *listener, bundle_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-	log_pt logger = ((bundle_listener_pt) listener)->handle;
-	log_entry_pt entry = NULL;
-
-	int messagesLength = 10;
-	char *messages[] = {
-		"BUNDLE_EVENT_INSTALLED",
-		"BUNDLE_EVENT_STARTED",
-		"BUNDLE_EVENT_STOPPED",
-		"BUNDLE_EVENT_UPDATED",
-		"BUNDLE_EVENT_UNINSTALLED",
-		"BUNDLE_EVENT_RESOLVED",
-		"BUNDLE_EVENT_UNRESOLVED",
-		"BUNDLE_EVENT_STARTING",
-		"BUNDLE_EVENT_STOPPING",
-		"BUNDLE_EVENT_LAZY_ACTIVATION"
-	};
-
-	char *message = NULL;
-	int i = 0;
-	for (i = 0; i < messagesLength; i++) {
-		if (event->type >> i == 1) {
-			message = messages[i];
-		}
-	}
-
-	if (message != NULL) {
-		status = logEntry_create(event->bundleId, event->bundleSymbolicName, NULL, OSGI_LOGSERVICE_INFO, message, 0, &entry);
-		if (status == CELIX_SUCCESS) {
-			status = log_addEntry(logger, entry);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t log_frameworkEvent(void *listener, framework_event_pt event) {
-	celix_status_t status;
-	log_pt logger = ((framework_listener_pt) listener)->handle;
-	log_entry_pt entry = NULL;
-
-	status = logEntry_create(event->bundleId, event->bundleSymbolicName, NULL, (event->type == OSGI_FRAMEWORK_EVENT_ERROR) ? OSGI_LOGSERVICE_ERROR : OSGI_LOGSERVICE_INFO, event->error, event->errorCode, &entry);
-	if (status == CELIX_SUCCESS) {
-		status = log_addEntry(logger, entry);
-	}
-
-	return status;
-}
-
-celix_status_t log_addLogListener(log_pt logger, log_listener_pt listener) {
-	celix_status_t status;
-
-	status = celixThreadMutex_lock(&logger->listenerLock);
-
-	if (status == CELIX_SUCCESS) {
-		arrayList_add(logger->listeners, listener);
-		log_startListenerThread(logger);
-
-		status = celixThreadMutex_unlock(&logger->listenerLock);
-	}
-
-	return status;
-}
-
-celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    status += celixThreadMutex_lock(&logger->deliverLock);
-    status += celixThreadMutex_lock(&logger->listenerLock);
-
-	if (status == CELIX_SUCCESS) {
-	    bool last = false;
-
-		arrayList_removeElement(logger->listeners, listener);
-		if (arrayList_size(logger->listeners) == 0) {
-			status = log_stopListenerThread(logger);
-			last = true;
-		}
-
-        status += celixThreadMutex_unlock(&logger->listenerLock);
-        status += celixThreadMutex_unlock(&logger->deliverLock);
-
-		if (last) {
-		    status += celixThread_join(logger->listenerThread, NULL);
-		}
-	}
-
-	if (status != CELIX_SUCCESS) {
-		status = CELIX_SERVICE_EXCEPTION;
-	}
-
-	return status;
-}
-
-celix_status_t log_removeAllLogListener(log_pt logger) {
-	celix_status_t status;
-
-	status = celixThreadMutex_lock(&logger->listenerLock);
-
-    if (status == CELIX_SUCCESS) {
-    	arrayList_clear(logger->listeners);
-
-    	status = celixThreadMutex_unlock(&logger->listenerLock);
-    }
-
-	return status;
-}
-
-static celix_status_t log_startListenerThread(log_pt logger) {
-	celix_status_t status;
-
-	logger->running = true;
-    logger->running = true;
-    status = celixThread_create(&logger->listenerThread, NULL, log_listenerThread, logger);
-
-	return status;
-}
-
-static celix_status_t log_stopListenerThread(log_pt logger) {
-	celix_status_t status;
-
-	logger->running = false;
-
-	status = celixThreadCondition_signal(&logger->entriesToDeliver);
-
-	return status;
-}
-
-static void * log_listenerThread(void *data) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	log_pt logger = data;
-
-	while (logger->running) {
-
-		status = celixThreadMutex_lock(&logger->deliverLock);
-
-		if ( status != CELIX_SUCCESS) {
-			logger->running = false;
-		}
-		else {
-			if (!arrayList_isEmpty(logger->listenerEntries)) {
-				log_entry_pt entry = (log_entry_pt) arrayList_remove(logger->listenerEntries, 0);
-
-				if (entry) {
-					status = celixThreadMutex_lock(&logger->listenerLock);
-					if (status != CELIX_SUCCESS) {
-						logger->running = false;
-						break;
-					} else {
-						array_list_iterator_pt it = arrayListIterator_create(logger->listeners);
-						while (arrayListIterator_hasNext(it)) {
-							log_listener_pt listener = arrayListIterator_next(it);
-							listener->logged(listener, entry);
-						}
-						arrayListIterator_destroy(it);
-
-						// destroy not-stored entries
-						if (!(logger->store_debug || entry->level != OSGI_LOGSERVICE_DEBUG)) {
-							logEntry_destroy(&entry);
-						}
-
-						status = celixThreadMutex_unlock(&logger->listenerLock);
-						if (status != CELIX_SUCCESS) {
-							logger->running = false;
-							break;
-						}
-					}
-				}
-			}
-
-			if (arrayList_isEmpty(logger->listenerEntries) && logger->running) {
-				celixThreadCondition_wait(&logger->entriesToDeliver, &logger->deliverLock);
-			}
-
-			status = celixThreadMutex_unlock(&logger->deliverLock);
-
-			if (status != CELIX_SUCCESS) {
-				logger->running = false;
-				break;
-			}
-		}
-
-	}
-
-    celixThread_exit(NULL);
-    return NULL;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/src/log_entry.c
----------------------------------------------------------------------
diff --git a/log_service/private/src/log_entry.c b/log_service/private/src/log_entry.c
deleted file mode 100644
index 3a8603a..0000000
--- a/log_service/private/src/log_entry.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- *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.
- */
-/*
- * log_entry.c
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "celix_errno.h"
-#include "log_service.h"
-#include "log_entry.h"
-
-celix_status_t logEntry_create(long bundleId, const char* bundleSymbolicName , service_reference_pt reference,
-        log_level_t level, char *message, int errorCode,
-        log_entry_pt *entry) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    *entry = malloc(sizeof(**entry));
-    if (*entry == NULL) {
-        status = CELIX_ENOMEM;
-    } else {
-        (*entry)->level = level;
-        (*entry)->message = strdup(message);
-        (*entry)->errorCode = errorCode;
-        (*entry)->time = time(NULL);
-
-        (*entry)->bundleSymbolicName = strdup(bundleSymbolicName);
-        (*entry)->bundleId = bundleId;
-    }
-
-    return status;
-}
-
-celix_status_t logEntry_destroy(log_entry_pt *entry) {
-    if (*entry) {
-    	free((*entry)->bundleSymbolicName);
-        free((*entry)->message);
-        free(*entry);
-        *entry = NULL;
-    }
-    return CELIX_SUCCESS;
-}
-
-celix_status_t logEntry_getBundleSymbolicName(log_entry_pt entry, const char** bundleSymbolicName) {
-    *bundleSymbolicName = entry->bundleSymbolicName;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t logEntry_getBundleId(log_entry_pt entry, long *bundleId) {
-    *bundleId = entry->bundleId;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t logEntry_getErrorCode(log_entry_pt entry, int *errorCode) {
-    *errorCode = entry->errorCode;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t logEntry_getLevel(log_entry_pt entry, log_level_t *level) {
-    *level = entry->level;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t logEntry_getMessage(log_entry_pt entry, const char **message) {
-    *message = entry->message;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t logEntry_getTime(log_entry_pt entry, time_t *time) {
-    *time = entry->time;
-    return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/src/log_factory.c
----------------------------------------------------------------------
diff --git a/log_service/private/src/log_factory.c b/log_service/private/src/log_factory.c
deleted file mode 100644
index 1c0a17a..0000000
--- a/log_service/private/src/log_factory.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- *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.
- */
-/*
- * log_factory.c
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-
-
-#include "service_factory.h"
-#include "log_factory.h"
-#include "log_service_impl.h"
-
-struct log_service_factory {
-    log_pt log;
-};
-
-celix_status_t logFactory_create(log_pt log, service_factory_pt *factory) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    *factory = calloc(1, sizeof(**factory));
-    if (*factory == NULL) {
-        status = CELIX_ENOMEM;
-    } else {
-        log_service_factory_pt factoryData = calloc(1, sizeof(*factoryData));
-        if (factoryData == NULL) {
-            status = CELIX_ENOMEM;
-        } else {
-            factoryData->log = log;
-
-            (*factory)->handle = factoryData;
-            (*factory)->getService = logFactory_getService;
-            (*factory)->ungetService = logFactory_ungetService;
-        }
-    }
-
-    return status;
-}
-
-celix_status_t logFactory_destroy(service_factory_pt *factory) {
-    celix_status_t status = CELIX_SUCCESS;
-
-
-    free((*factory)->handle);
-    free(*factory);
-
-    factory = NULL;
-
-    return status;
-}
-
-
-celix_status_t logFactory_getService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service) {
-    log_service_factory_pt log_factory = factory;
-    log_service_pt log_service = NULL;
-    log_service_data_pt log_service_data = NULL;
-
-    logService_create(log_factory->log, bundle, &log_service_data);
-
-    log_service = calloc(1, sizeof(*log_service));
-    log_service->logger = log_service_data;
-    log_service->log = logService_log;
-  //  log_service->logSr = logService_logSr;
-
-    (*service) = log_service;
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service) {
-	log_service_pt log_service = *service;
-
-	logService_destroy(&log_service->logger);
-
-	free(*service);
-	*service = NULL;
-
-    return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/src/log_reader_service_impl.c
----------------------------------------------------------------------
diff --git a/log_service/private/src/log_reader_service_impl.c b/log_service/private/src/log_reader_service_impl.c
deleted file mode 100644
index 2a46ea7..0000000
--- a/log_service/private/src/log_reader_service_impl.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *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.
- */
- /*
- * log_reader_service_impl.c
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <stddef.h>
-
-#include "log_reader_service_impl.h"
-#include "celixbool.h"
-
-struct log_reader_data {
-    log_pt log;
-};
-
-celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    *reader = (log_reader_data_pt) calloc(1, sizeof(**reader));
-
-    if (*reader == NULL) {
-        status = CELIX_ENOMEM;
-    } else {
-        (*reader)->log = log;
-    }
-
-    return status;
-}
-
-celix_status_t logReaderService_destroy(log_reader_data_pt *reader) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    free(*reader);
-    reader = NULL;
-
-    return status;
-}
-
-
-
-celix_status_t logReaderService_getLog(log_reader_data_pt reader, linked_list_pt *list) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    status = log_getEntries(reader->log, list);
-
-    return status;
-}
-
-celix_status_t logReaderService_addLogListener(log_reader_data_pt reader, log_listener_pt listener) {
-    return log_addLogListener(reader->log, listener);
-}
-
-celix_status_t logReaderService_removeLogListener(log_reader_data_pt reader, log_listener_pt listener) {
-    return log_removeLogListener(reader->log, listener);
-}
-
-celix_status_t logReaderService_removeAllLogListener(log_reader_data_pt reader) {
-    return log_removeAllLogListener(reader->log);
-}
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/src/log_service_activator.c
----------------------------------------------------------------------
diff --git a/log_service/private/src/log_service_activator.c b/log_service/private/src/log_service_activator.c
deleted file mode 100644
index 8c72fb1..0000000
--- a/log_service/private/src/log_service_activator.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- *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.
- */
-/*
- * log_service_activator.c
- *
- *  \date       Jun 25, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <constants.h>
-
-#include "bundle_activator.h"
-#include "log_service_impl.h"
-#include "service_factory.h"
-#include "log_factory.h"
-#include "log.h"
-#include "log_reader_service_impl.h"
-#include "service_registration.h"
-
-#define DEFAULT_MAX_SIZE 100
-#define DEFAULT_STORE_DEBUG false
-
-#define MAX_SIZE_PROPERTY "CELIX_LOG_MAX_SIZE"
-#define STORE_DEBUG_PROPERTY "CELIX_LOG_STORE_DEBUG"
-
-struct logActivator {
-    bundle_context_pt bundleContext;
-    service_registration_pt logServiceFactoryReg;
-    service_registration_pt logReaderServiceReg;
-
-    bundle_listener_pt bundleListener;
-    framework_listener_pt frameworkListener;
-
-    log_pt logger;
-    service_factory_pt factory;
-    log_reader_data_pt reader;
-    log_reader_service_pt reader_service;
-};
-
-static celix_status_t bundleActivator_getMaxSize(struct logActivator *activator, int *max_size);
-static celix_status_t bundleActivator_getStoreDebug(struct logActivator *activator, bool *store_debug);
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-    celix_status_t status = CELIX_SUCCESS;
-	struct logActivator * activator = NULL;
-
-    activator = (struct logActivator *) calloc(1, sizeof(struct logActivator));
-
-    if (activator == NULL) {
-        status = CELIX_ENOMEM;
-    } else {
-		activator->bundleContext = context;
-		activator->logServiceFactoryReg = NULL;
-		activator->logReaderServiceReg = NULL;
-
-		activator->logger = NULL;
-		activator->factory = NULL;
-		activator->reader = NULL;
-		activator->reader_service = NULL;
-
-        *userData = activator;
-    }
-
-    return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    struct logActivator * activator = (struct logActivator *) userData;
-    celix_status_t status = CELIX_SUCCESS;
-
-    int max_size = 0;
-    bool store_debug = false;
-
-    bundleActivator_getMaxSize(activator, &max_size);
-    bundleActivator_getStoreDebug(activator, &store_debug);
-
-    log_create(max_size, store_debug, &activator->logger);
-
-    // Add logger as Bundle- and FrameworkEvent listener
-    activator->bundleListener = calloc(1, sizeof(*activator->bundleListener));
-    activator->bundleListener->handle = activator->logger;
-    activator->bundleListener->bundleChanged = log_bundleChanged;
-    bundleContext_addBundleListener(context, activator->bundleListener);
-
-    activator->frameworkListener = calloc(1, sizeof(*activator->frameworkListener));
-    activator->frameworkListener->handle = activator->logger;
-    activator->frameworkListener->frameworkEvent = log_frameworkEvent;
-    bundleContext_addFrameworkListener(context, activator->frameworkListener);
-
-    logFactory_create(activator->logger, &activator->factory);
-
-	properties_pt props = properties_create();
-	properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-
-
-	bundleContext_registerServiceFactory(context, (char *) OSGI_LOGSERVICE_NAME, activator->factory, props, &activator->logServiceFactoryReg);
-
-    logReaderService_create(activator->logger, &activator->reader);
-
-    activator->reader_service = calloc(1, sizeof(*activator->reader_service));
-    activator->reader_service->reader = activator->reader;
-    activator->reader_service->getLog = logReaderService_getLog;
-    activator->reader_service->addLogListener = logReaderService_addLogListener;
-    activator->reader_service->removeLogListener = logReaderService_removeLogListener;
-    activator->reader_service->removeAllLogListener = logReaderService_removeAllLogListener;
-
-	props = properties_create();
-	properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-
-    bundleContext_registerService(context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, activator->reader_service, props, &activator->logReaderServiceReg);
-
-    return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	struct logActivator * activator = (struct logActivator *) userData;
-
-	serviceRegistration_unregister(activator->logReaderServiceReg);
-	activator->logReaderServiceReg = NULL;
-	serviceRegistration_unregister(activator->logServiceFactoryReg);
-	activator->logServiceFactoryReg = NULL;
-
-    logReaderService_destroy(&activator->reader);
-	free(activator->reader_service);
-
-	logFactory_destroy(&activator->factory);
-
-	bundleContext_removeBundleListener(context, activator->bundleListener);
-	bundleContext_removeFrameworkListener(context, activator->frameworkListener);
-
-	free(activator->bundleListener);
-	free(activator->frameworkListener);
-
-	log_destroy(activator->logger);
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	struct logActivator * activator = (struct logActivator *) userData;
-
-	free(activator);
-
-    return CELIX_SUCCESS;
-}
-
-static celix_status_t bundleActivator_getMaxSize(struct logActivator *activator, int *max_size) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	const char *max_size_str = NULL;
-
-	*max_size = DEFAULT_MAX_SIZE;
-
-	bundleContext_getProperty(activator->bundleContext, MAX_SIZE_PROPERTY, &max_size_str);
-	if (max_size_str) {
-		*max_size = atoi(max_size_str);
-	}
-
-	return status;
-}
-
-static celix_status_t bundleActivator_getStoreDebug(struct logActivator *activator, bool *store_debug) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	const char *store_debug_str = NULL;
-
-	*store_debug = DEFAULT_STORE_DEBUG;
-
-	bundleContext_getProperty(activator->bundleContext, STORE_DEBUG_PROPERTY, &store_debug_str);
-	if (store_debug_str) {
-		if (strcasecmp(store_debug_str, "true") == 0) {
-			*store_debug = true;
-		} else if (strcasecmp(store_debug_str, "false") == 0) {
-			*store_debug = false;
-		}
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/private/src/log_service_impl.c
----------------------------------------------------------------------
diff --git a/log_service/private/src/log_service_impl.c b/log_service/private/src/log_service_impl.c
deleted file mode 100644
index a77e9ad..0000000
--- a/log_service/private/src/log_service_impl.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *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.
- */
-/*
- * log_service_impl.c
- *
- *  \date       Jun 22, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "log_service_impl.h"
-#include "module.h"
-#include "bundle.h"
-
-struct log_service_data {
-    log_pt log;
-    bundle_pt bundle;
-};
-
-celix_status_t logService_create(log_pt log, bundle_pt bundle, log_service_data_pt *logger) {
-    celix_status_t status = CELIX_SUCCESS;
-    *logger = calloc(1, sizeof(struct log_service_data));
-    if (*logger == NULL) {
-        status = CELIX_ENOMEM;
-    } else {
-        (*logger)->bundle = bundle;
-        (*logger)->log = log;
-    }
-
-    return status;
-}
-
-celix_status_t logService_destroy(log_service_data_pt *logger) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    free(*logger);
-    logger = NULL;
-
-    return status;
-}
-
-celix_status_t logService_log(log_service_data_pt logger, log_level_t level, char * message) {
-    return logService_logSr(logger, NULL, level, message);
-}
-
-celix_status_t logService_logSr(log_service_data_pt logger, service_reference_pt reference, log_level_t level, char * message) {
-    celix_status_t status;
-    log_entry_pt entry = NULL;
-    bundle_pt bundle = logger->bundle;
-    bundle_archive_pt archive = NULL;
-    module_pt module = NULL;
-    const char *symbolicName = NULL;
-    long bundleId = -1;
-
-    if (reference != NULL) {
-    	serviceReference_getBundle(reference, &bundle);
-    }
-
-    status = bundle_getArchive(bundle, &archive);
-
-    if (status == CELIX_SUCCESS) {
-        status = bundleArchive_getId(archive, &bundleId);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        status = bundle_getCurrentModule(bundle, &module);
-
-        if (status == CELIX_SUCCESS) {
-            status = module_getSymbolicName(module, &symbolicName);
-        }
-    }
-
-    if(status == CELIX_SUCCESS && symbolicName != NULL && message != NULL){
-	status = logEntry_create(bundleId, symbolicName, reference, level, message, 0, &entry);
-	log_addEntry(logger->log, entry);
-    }
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/include/log_entry.h
----------------------------------------------------------------------
diff --git a/log_service/public/include/log_entry.h b/log_service/public/include/log_entry.h
deleted file mode 100644
index e588774..0000000
--- a/log_service/public/include/log_entry.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- *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.
- */
-/*
- * log_entry.h
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_ENTRY_H_
-#define LOG_ENTRY_H_
-
-#include "log_service.h"
-
-struct log_entry {
-    int errorCode;
-    log_level_t level;
-    char *message;
-    time_t time;
-
-    long bundleId;
-    char* bundleSymbolicName;
-};
-
-typedef struct log_entry * log_entry_pt;
-
-celix_status_t logEntry_create(long bundleId, const char* bundleSymbolicName , service_reference_pt reference,
-        log_level_t level, char *message, int errorCode,
-        log_entry_pt *entry);
-celix_status_t logEntry_destroy(log_entry_pt *entry);
-celix_status_t logEntry_getBundleSymbolicName(log_entry_pt entry, const char** bundleSymbolicName);
-celix_status_t logEntry_getBundleId(log_entry_pt entry, long *bundleId);
-celix_status_t logEntry_getErrorCode(log_entry_pt entry, int *errorCode);
-celix_status_t logEntry_getLevel(log_entry_pt entry, log_level_t *level);
-celix_status_t logEntry_getMessage(log_entry_pt entry, const char** message);
-celix_status_t logEntry_getTime(log_entry_pt entry, time_t *time);
-
-#endif /* LOG_ENTRY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/include/log_helper.h
----------------------------------------------------------------------
diff --git a/log_service/public/include/log_helper.h b/log_service/public/include/log_helper.h
deleted file mode 100644
index 04e4bb2..0000000
--- a/log_service/public/include/log_helper.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- *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.
- */
-
-
-#ifndef LOGHELPER_H_
-#define LOGHELPER_H_
-
-#include "bundle_context.h"
-#include "log_service.h"
-
-typedef struct log_helper* log_helper_pt;
-
-celix_status_t logHelper_create(bundle_context_pt context, log_helper_pt* log_helper);
-celix_status_t logHelper_start(log_helper_pt loghelper);
-celix_status_t logHelper_stop(log_helper_pt loghelper);
-celix_status_t logHelper_destroy(log_helper_pt* loghelper);
-celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* message, ... );
-
-#endif /* LOGHELPER_H_ */


[45/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/api/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_service_dependency.h b/dependency_manager/api/dm_service_dependency.h
new file mode 100644
index 0000000..fb34230
--- /dev/null
+++ b/dependency_manager/api/dm_service_dependency.h
@@ -0,0 +1,171 @@
+/**
+ *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.
+ */
+/*
+ * dm_service_dependency.h
+ *
+ *  \date       8 Oct 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef DM_SERVICE_DEPENDENCY_H_
+#define DM_SERVICE_DEPENDENCY_H_
+
+#include "service_reference.h"
+#include "celix_errno.h"
+#include "dm_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct dm_service_dependency *dm_service_dependency_pt;
+
+typedef enum dm_service_dependency_strategy_enum {
+	DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING,
+	DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
+} dm_service_dependency_strategy_t;
+
+typedef int (*service_set_fpt)(void *handle, const void* service);
+typedef int (*service_add_fpt)(void *handle, const void* service);
+typedef int (*service_change_fpt)(void *handle, const void* service);
+typedef int (*service_remove_fpt)(void *handle, const void* service);
+typedef int (*service_swap_fpt)(void *handle, const void* oldService, const void* newService);
+
+typedef celix_status_t (*service_set_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_add_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_change_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_remove_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_swap_with_ref_fpt)(void *handle, service_reference_pt oldReference, const void* oldService, service_reference_pt newReference, const void* newService);
+
+/**
+ * Create a service dependency.
+ * Caller has ownership.
+ */
+celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr);
+
+/**
+ * Destroys a service dependency.
+ * Caller has ownership.
+ */
+celix_status_t serviceDependency_destroy(dm_service_dependency_pt *dependency_ptr);
+
+/**
+ * Specify if the service dependency is required. default is false
+ */
+celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency, bool required);
+
+/**
+ * Specify if the servide dependency should add a C language filter for this dependency if no "service.lang" part if found the in the provided filter.
+ * Default is false
+ */
+celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_pt dependency, bool addCLangFilter);
+
+
+/**
+ * Specify if the service dependency update strategy.
+ *
+ * The DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING strategy notifies the component in case the dependencies set
+ * changes (e.g. a dependency is added/removed): the component is responsible for protecting via locks
+ * the dependencies list and check (always under lock) if the service he's depending on is still available.
+ *
+ * The DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND (default when no strategy is explicitly set) reliefs the programmer
+ * from dealing with service dependencies' consistency issues: in case this strategy is adopted, the component
+ * is stopped and restarted (i.e. temporarily suspended) upon service dependencies' changes.
+ *
+ * Default strategy is DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
+ */
+celix_status_t serviceDependency_setStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t strategy);
+
+/**
+ * Return the service dependency update strategy.
+ */
+celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t* strategy);
+
+/**
+ * Set the service name, version range and filter.
+ *
+ * @param serviceName The service name. Must have a value.
+ * @param serviceVersionRange The service version range, can be a NULL pointer.
+ * @param filter The (additional) filter to use (e.g. "(location=front)"). Can be a NULL pointer.
+ */
+celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, const char* serviceName, const char* serviceVersionRange, const char* filter);
+
+/**
+ * Returns the service depenendy filter.
+ */
+celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, const char** filter);
+
+/**
+ * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
+ * are (respectively) set, added, changed, removed or swapped.
+ * The first argument of the callbacks will be the component implement (@see component_getImplementation)
+ * The second the argument a pointer to an instance of a service struct of the specified service dependency.
+ */
+celix_status_t serviceDependency_setCallbacks(dm_service_dependency_pt dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap);
+
+/**
+ * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
+ * are (respectively) set, added, changed, removed or swapped.
+ * The first argument of the callbacks will be the component implement (@see component_getImplementation)
+ * The second argument of th callbacks will be a pointer to an instance of a service struct of the specified service dependency.
+ * The third argument of th callbacks will be a pointer to a service reference of the a service instance of the specified service dependency.
+ */
+celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_pt dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove, service_swap_with_ref_fpt swap);
+
+/**
+ * Specifies which field member (pointer to) to update when a service dependencies is set.
+ * If provided the provided service_lock will be used for locking when updating the service instance.
+ */
+celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt dependency, celix_thread_mutex_t *service_lock, const void** field);
+
+#define serviceDependency_setCallbacksSafe(dep, cmpType, servType, set, add, change, remove, swap) \
+	do { \
+		int (*tmpSet)(cmpType, servType) = set; \
+		int (*tmpAdd)(cmpType, servType) = add; \
+		int (*tmpChange)(cmpType, servType) = change; \
+		int (*tmpRemove)(cmpType, servType) = remove; \
+		int (*tmpSwap)(cmpType, servType, servType) = swap; \
+		serviceDependency_setCallbacks((dep), (service_set_fpt)tmpSet, (service_add_fpt)tmpAdd, (service_change_fpt)tmpChange, (service_remove_fpt)tmpRemove, (service_swap_fpt)tmpSwap); \
+	} while(0)
+
+/**
+ * Set the callback handle to be used in the callbacks. Note that this normally should not be set, because the
+ * result of component_getImplementation() is used
+ * This can be used in rare cases when the callbacks are actually interceptors. e.g. in the case of C++ support.
+ */
+celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_pt dependency, void* handle);
+
+/**
+ * Creates a service dependency info. The service dependency info struct contains information about the service dependency.
+ * The caller is the owner
+ */
+celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt, dm_service_dependency_info_pt *info);
+
+/**
+ * Destroy a provided service dependency info struct.
+ */
+void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_SERVICE_DEPENDENCY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_component_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_component_impl.h b/dependency_manager/private/include/dm_component_impl.h
deleted file mode 100644
index 495197c..0000000
--- a/dependency_manager/private/include/dm_component_impl.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_component_impl.h
- *
- *  \date       22 Feb 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef COMPONENT_IMPL_H_
-#define COMPONENT_IMPL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "dm_component.h"
-#include "dm_service_dependency_impl.h"
-#include "dm_event.h"
-
-celix_status_t component_start(dm_component_pt component);
-
-celix_status_t component_stop(dm_component_pt component);
-
-celix_status_t component_handleEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* COMPONENT_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_dependency.h b/dependency_manager/private/include/dm_dependency.h
deleted file mode 100644
index 6923239..0000000
--- a/dependency_manager/private/include/dm_dependency.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_dependency.h
- *
- *  \date       22 Feb 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef DM_DEPENDENCY_H_
-#define DM_DEPENDENCY_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_DEPENDENCY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_dependency_manager_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_dependency_manager_impl.h b/dependency_manager/private/include/dm_dependency_manager_impl.h
deleted file mode 100644
index c673605..0000000
--- a/dependency_manager/private/include/dm_dependency_manager_impl.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_dependency_manager_impl.h
- *
- *  \date       15 Oct 2015
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
-#define CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct dm_dependency_manager {
-    array_list_pt components;
-
-    pthread_mutex_t mutex;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //CELIX_DM_DEPENDENCY_MANAGER_IMPL_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_event.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_event.h b/dependency_manager/private/include/dm_event.h
deleted file mode 100644
index 1cccd47..0000000
--- a/dependency_manager/private/include/dm_event.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_event.h
- *
- *  \date       17 Oct 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef DM_EVENT_H_
-#define DM_EVENT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "service_reference.h"
-#include "bundle_context.h"
-#include "bundle.h"
-
-enum dm_event_type {
-	DM_EVENT_ADDED,
-	DM_EVENT_CHANGED,
-	DM_EVENT_REMOVED,
-	DM_EVENT_SWAPPED,
-};
-
-typedef enum dm_event_type dm_event_type_e;
-
-struct dm_event {
-	const void* service;
-	unsigned long serviceId;
-	long ranking;
-	service_reference_pt reference;
-	bundle_context_pt context;
-	bundle_pt bundle;
-	dm_event_type_e event_type;
-};
-
-typedef struct dm_event *dm_event_pt;
-
-
-celix_status_t event_create(dm_event_type_e event_type, bundle_pt bundle, bundle_context_pt context, service_reference_pt reference, const void* service, dm_event_pt *event);
-celix_status_t event_destroy(dm_event_pt* event);
-
-celix_status_t event_equals(const void* a, const void* b, bool* equals);
-
-celix_status_t event_getService(dm_event_pt event, const void** service);
-celix_status_t event_compareTo(dm_event_pt event, dm_event_pt compareTo, int* compare);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_EVENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_service_dependency_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_service_dependency_impl.h b/dependency_manager/private/include/dm_service_dependency_impl.h
deleted file mode 100644
index 7026ebf..0000000
--- a/dependency_manager/private/include/dm_service_dependency_impl.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_service_dependency_impl.h
- *
- *  \date       16 Oct 2015
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef DM_SERVICE_DEPENDENCY_IMPL_H_
-#define DM_SERVICE_DEPENDENCY_IMPL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdbool.h>
-
-#include "dm_event.h"
-#include "service_tracker.h"
-#include "service_tracker_customizer.h"
-
-#include "dm_service_dependency.h"
-#include "dm_component.h"
-
-struct dm_service_dependency {
-	dm_component_pt component;
-	bool available;
-	bool instanceBound;
-	bool required;
-	dm_service_dependency_strategy_t strategy;
-
-	void* callbackHandle; //This handle can be set to be used instead of the component implementation
-	service_set_fpt set;
-	service_add_fpt add;
-	service_change_fpt change;
-	service_remove_fpt remove;
-	service_swap_fpt swap;
-
-	service_set_with_ref_fpt set_with_ref;
-	service_add_with_ref_fpt add_with_ref;
-	service_change_with_ref_fpt change_with_ref;
-	service_remove_with_ref_fpt remove_with_ref;
-	service_swap_with_ref_fpt swap_with_ref;
-
-	const void **autoConfigure;
-	celix_thread_mutex_t lock;
-
-	bool isStarted;
-
-	bool addCLanguageFilter;
-	char *tracked_service;
-	char *tracked_filter_unmodified;
-	char *tracked_filter;
-
-	service_tracker_pt tracker;
-	service_tracker_customizer_pt tracker_customizer;
-};
-
-celix_status_t serviceDependency_start(dm_service_dependency_pt dependency);
-celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency);
-celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt dependency, bool instanceBound);
-celix_status_t serviceDependency_setAutoConfig(dm_service_dependency_pt dependency, void **autoConfigure);
-celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependency, bool available);
-
-celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependency, dm_component_pt component);
-//celix_status_t serviceDependency_removeComponent(dm_service_dependency_pt dependency, dm_component_pt component);
-
-celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent);
-celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency, bool *available);
-celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency, bool *required);
-celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt dependency, bool *instanceBound);
-celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependency, bool *autoConfig);
-
-celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependency, const void*** autoConfigure);
-celix_status_t serviceDependency_unlock(dm_service_dependency_pt dependency);
-celix_status_t serviceDependency_lock(dm_service_dependency_pt dependency);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_SERVICE_DEPENDENCY_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_shell_list_command.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_shell_list_command.h b/dependency_manager/private/include/dm_shell_list_command.h
deleted file mode 100644
index 6ab0581..0000000
--- a/dependency_manager/private/include/dm_shell_list_command.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *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.
- */
-
-#ifndef DM_SHELL_LIST_COMMAND_H_
-#define DM_SHELL_LIST_COMMAND_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include "command.h"
-
-typedef struct dm_command_handle {
-    bundle_context_pt context;
-    bool useColors;
-} dm_command_handle_t;
-
-void dmListCommand_execute(dm_command_handle_t* handle, char * line, FILE *out, FILE *err);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //DM_SHELL_LSIT_COMMAND_H_
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_activator.c b/dependency_manager/private/src/dm_activator.c
deleted file mode 100644
index 8de3bf1..0000000
--- a/dependency_manager/private/src/dm_activator.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * 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.
- */
-
-#include "dm_activator.h"
-
-#include <stdlib.h>
-
-struct dm_dependency_activator_base {
-    dm_dependency_manager_pt manager;
-    bundle_context_pt context;
-    service_registration_pt reg;
-    dm_info_service_pt info;
-    void* userData;
-};
-
-typedef struct dm_dependency_activator_base * dependency_activator_base_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-    celix_status_t status = CELIX_ENOMEM;
-
-    dependency_activator_base_pt dependency_activator = calloc(1, sizeof(struct dm_dependency_activator_base));
-    dm_info_service_pt serv = calloc(1, sizeof(*serv));
-
-    if (dependency_activator != NULL && serv != NULL) {
-        dependency_activator->context = context;
-        dm_create(context, &dependency_activator->userData);
-        dependency_activator->info = serv;
-
-        status = dependencyManager_create(dependency_activator->context, &dependency_activator->manager);
-    } else {
-        status = CELIX_ENOMEM;
-
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *userData = dependency_activator;
-    } else {
-        if (dependency_activator != NULL) {
-            dependencyManager_destroy(dependency_activator->manager);
-        }
-        free(dependency_activator);
-        free(serv);
-    }
-
-    return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    celix_status_t status;
-    dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
-
-
-    status = dm_init(dependency_activator->userData, context, dependency_activator->manager);
-
-    if (status == CELIX_SUCCESS) {
-        //Create the service
-        dependency_activator->info->handle = dependency_activator->manager;
-        dependency_activator->info->getInfo = (void *) dependencyManager_getInfo;
-        dependency_activator->info->destroyInfo = (void *) dependencyManager_destroyInfo;
-
-        status = bundleContext_registerService(context, DM_INFO_SERVICE_NAME, dependency_activator->info, NULL,
-                                               &(dependency_activator->reg));
-    }
-
-    return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-    dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
-
-    // Remove the service
-    status = serviceRegistration_unregister(dependency_activator->reg);
-    dependencyManager_removeAllComponents(dependency_activator->manager);
-
-    return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-    dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
-
-    if(dependency_activator==NULL){
-        return CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    status = dm_destroy(dependency_activator->userData, dependency_activator->context,
-                        dependency_activator->manager);
-
-    if (status == CELIX_SUCCESS) {
-        dependencyManager_destroy(dependency_activator->manager);
-    }
-
-    dependency_activator->userData = NULL;
-    dependency_activator->manager = NULL;
-
-    if (dependency_activator != NULL) {
-        free(dependency_activator->info);
-    }
-    free(dependency_activator);
-
-    return status;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_component_impl.c b/dependency_manager/private/src/dm_component_impl.c
deleted file mode 100644
index 13a2ee0..0000000
--- a/dependency_manager/private/src/dm_component_impl.c
+++ /dev/null
@@ -1,1442 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_component_impl.c
- *
- *  \date       9 Oct 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "constants.h"
-#include "filter.h"
-#include "dm_component_impl.h"
-
-
-typedef struct dm_executor_struct * dm_executor_pt;
-
-struct dm_component_struct {
-    char id[DM_COMPONENT_MAX_ID_LENGTH];
-    char name[DM_COMPONENT_MAX_NAME_LENGTH];
-    bundle_context_pt context;
-    array_list_pt dm_interfaces;
-
-    void* implementation;
-
-    init_fpt callbackInit;
-    start_fpt callbackStart;
-    stop_fpt callbackStop;
-    deinit_fpt callbackDeinit;
-
-    array_list_pt dependencies; //protected by mutex
-    pthread_mutex_t mutex;
-
-    dm_component_state_t state;
-    bool isStarted;
-    bool active;
-
-    bool setCLanguageProperty;
-
-    hash_map_pt dependencyEvents; //protected by mutex
-
-    dm_executor_pt executor;
-};
-
-typedef struct dm_interface_struct {
-    char* serviceName;
-    const void* service;
-    properties_pt properties;
-    service_registration_pt registration;
-} dm_interface_t;
-
-struct dm_executor_struct {
-    pthread_t runningThread;
-    bool runningThreadSet;
-    linked_list_pt workQueue;
-    pthread_mutex_t mutex;
-};
-
-typedef struct dm_executor_task_struct {
-    dm_component_pt component;
-    void (*command)(void *command_ptr, void *data);
-    void *data;
-} dm_executor_task_t;
-
-typedef struct dm_handle_event_type_struct {
-	dm_service_dependency_pt dependency;
-	dm_event_pt event;
-	dm_event_pt newEvent;
-} *dm_handle_event_type_pt;
-
-static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t  currentThread __attribute__((unused)));
-static celix_status_t executor_execute(dm_executor_pt executor);
-static celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt component, void (*command), void *data);
-static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt component, void (*command), void *data);
-static celix_status_t executor_create(dm_component_pt component __attribute__((unused)), dm_executor_pt *executor);
-static void executor_destroy(dm_executor_pt executor);
-
-static celix_status_t component_invokeRemoveRequiredDependencies(dm_component_pt component);
-static celix_status_t component_invokeRemoveInstanceBoundDependencies(dm_component_pt component);
-static celix_status_t component_invokeRemoveOptionalDependencies(dm_component_pt component);
-static celix_status_t component_registerServices(dm_component_pt component);
-static celix_status_t component_unregisterServices(dm_component_pt component);
-static celix_status_t component_invokeAddOptionalDependencies(dm_component_pt component);
-static celix_status_t component_invokeAddRequiredInstanceBoundDependencies(dm_component_pt component);
-static celix_status_t component_invokeAddRequiredDependencies(dm_component_pt component);
-static celix_status_t component_invokeAutoConfigInstanceBoundDependencies(dm_component_pt component);
-static celix_status_t component_invokeAutoConfigDependencies(dm_component_pt component);
-static celix_status_t component_configureImplementation(dm_component_pt component, dm_service_dependency_pt dependency);
-static celix_status_t component_allInstanceBoundAvailable(dm_component_pt component, bool *available);
-static celix_status_t component_allRequiredAvailable(dm_component_pt component, bool *available);
-static celix_status_t component_performTransition(dm_component_pt component, dm_component_state_t oldState, dm_component_state_t newState, bool *transition);
-static celix_status_t component_calculateNewState(dm_component_pt component, dm_component_state_t currentState, dm_component_state_t *newState);
-static celix_status_t component_handleChange(dm_component_pt component);
-static celix_status_t component_startDependencies(dm_component_pt component __attribute__((unused)), array_list_pt dependencies);
-static celix_status_t component_getDependencyEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt *event_pptr);
-static celix_status_t component_updateInstance(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, bool update, bool add);
-
-static celix_status_t component_addTask(dm_component_pt component, dm_service_dependency_pt dep);
-static celix_status_t component_startTask(dm_component_pt component, void * data __attribute__((unused)));
-static celix_status_t component_stopTask(dm_component_pt component, void * data __attribute__((unused)));
-static celix_status_t component_removeTask(dm_component_pt component, dm_service_dependency_pt dependency);
-static celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_event_type_pt data);
-
-static celix_status_t component_handleAdded(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-static celix_status_t component_handleChanged(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-static celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-static celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent);
-
-static celix_status_t component_suspend(dm_component_pt component, dm_service_dependency_pt dependency);
-static celix_status_t component_resume(dm_component_pt component, dm_service_dependency_pt dependency);
-
-celix_status_t component_create(bundle_context_pt context, const char *name, dm_component_pt *out) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    dm_component_pt component = calloc(1, sizeof(*component));
-
-    if (!component) {
-        status = CELIX_ENOMEM;
-    } else {
-        snprintf(component->id, DM_COMPONENT_MAX_ID_LENGTH, "%p", component);
-        snprintf(component->name, DM_COMPONENT_MAX_NAME_LENGTH, "%s", name == NULL ? "n/a" : name);
-
-        component->context = context;
-
-	    arrayList_create(&component->dm_interfaces);
-        arrayList_create(&(component)->dependencies);
-        pthread_mutex_init(&(component)->mutex, NULL);
-
-        component->implementation = NULL;
-
-        component->callbackInit = NULL;
-        component->callbackStart = NULL;
-        component->callbackStop = NULL;
-        component->callbackDeinit = NULL;
-
-        component->state = DM_CMP_STATE_INACTIVE;
-        component->isStarted = false;
-        component->active = false;
-
-        component->setCLanguageProperty = false;
-
-        component->dependencyEvents = hashMap_create(NULL, NULL, NULL, NULL);
-
-        component->executor = NULL;
-        executor_create(component, &component->executor);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *out = component;
-    }
-
-    return status;
-}
-
-void component_destroy(dm_component_pt component) {
-	if (component) {
-		unsigned int i;
-
-		for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
-		    dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
-
-			if(interface->properties!=NULL){
-				properties_destroy(interface->properties);
-			}
-		    free (interface->serviceName);
-            free (interface);
-		}
-		arrayList_destroy(component->dm_interfaces);
-
-		executor_destroy(component->executor);
-
-		hash_map_iterator_pt iter = hashMapIterator_create(component->dependencyEvents);
-		while(hashMapIterator_hasNext(iter)){
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-			dm_service_dependency_pt sdep = (dm_service_dependency_pt)hashMapEntry_getKey(entry);
-			array_list_pt eventList = (array_list_pt)hashMapEntry_getValue(entry);
-			serviceDependency_destroy(&sdep);
-			arrayList_destroy(eventList);
-		}
-		hashMapIterator_destroy(iter);
-
-		hashMap_destroy(component->dependencyEvents, false, false);
-
-		arrayList_destroy(component->dependencies);
-		pthread_mutex_destroy(&component->mutex);
-
-		free(component);
-	}
-}
-
-celix_status_t component_addServiceDependency(dm_component_pt component, dm_service_dependency_pt dep) {
-    celix_status_t status = CELIX_SUCCESS;
-
-	executor_executeTask(component->executor, component, component_addTask, dep);
-
-    return status;
-}
-
-
-static celix_status_t component_addTask(dm_component_pt component, dm_service_dependency_pt dep) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    array_list_pt bounds = NULL;
-    arrayList_create(&bounds);
-
-    array_list_pt events = NULL;
-    arrayList_createWithEquals(event_equals, &events);
-
-    pthread_mutex_lock(&component->mutex);
-    hashMap_put(component->dependencyEvents, dep, events);
-    arrayList_add(component->dependencies, dep);
-    pthread_mutex_unlock(&component->mutex);
-
-    serviceDependency_setComponent(dep, component);
-
-    if (component->state != DM_CMP_STATE_INACTIVE) {
-        serviceDependency_setInstanceBound(dep, true);
-        arrayList_add(bounds, dep);
-    }
-    component_startDependencies(component, bounds);
-    component_handleChange(component);
-
-    arrayList_destroy(bounds);
-
-    return status;
-}
-
-dm_component_state_t component_currentState(dm_component_pt cmp) {
-    return cmp->state;
-}
-
-void * component_getImplementation(dm_component_pt cmp) {
-    return cmp->implementation;
-}
-
-const char * component_getName(dm_component_pt cmp) {
-    return cmp->name;
-}
-
-celix_status_t component_removeServiceDependency(dm_component_pt component, dm_service_dependency_pt dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    executor_executeTask(component->executor, component, component_removeTask, dependency);
-
-    return status;
-}
-
-celix_status_t component_removeTask(dm_component_pt component, dm_service_dependency_pt dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    arrayList_removeElement(component->dependencies, dependency);
-    pthread_mutex_unlock(&component->mutex);
-
-    if (component->state != DM_CMP_STATE_INACTIVE) {
-        serviceDependency_stop(dependency);
-    }
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_remove(component->dependencyEvents, dependency);
-    pthread_mutex_unlock(&component->mutex);
-
-	serviceDependency_destroy(&dependency);
-
-    while (!arrayList_isEmpty(events)) {
-    	dm_event_pt event = arrayList_remove(events, 0);
-    	event_destroy(&event);
-    }
-    arrayList_destroy(events);
-
-    component_handleChange(component);
-
-    return status;
-}
-
-celix_status_t component_start(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    component->active = true;
-    executor_executeTask(component->executor, component, component_startTask, NULL);
-
-    return status;
-}
-
-celix_status_t component_startTask(dm_component_pt component, void  *data __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    component->isStarted = true;
-    component_handleChange(component);
-
-    return status;
-}
-
-celix_status_t component_stop(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    component->active = false;
-    executor_executeTask(component->executor, component, component_stopTask, NULL);
-
-    return status;
-}
-
-celix_status_t component_stopTask(dm_component_pt component, void *data __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    component->isStarted = false;
-    component_handleChange(component);
-    component->active = false;
-
-    return status;
-}
-
-celix_status_t component_setCLanguageProperty(dm_component_pt component, bool setCLangProp) {
-    component->setCLanguageProperty = setCLangProp;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t component_addInterface(dm_component_pt component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (component->active) {
-        return CELIX_ILLEGAL_STATE;
-    } else {
-        dm_interface_t *interface = (dm_interface_t *) calloc(1, sizeof(*interface));
-        char *name = strdup(serviceName);
-
-        if (properties == NULL) {
-            properties = properties_create();
-        }
-
-        if ((properties_get(properties, CELIX_FRAMEWORK_SERVICE_VERSION) == NULL) && (serviceVersion != NULL)) {
-            properties_set(properties, CELIX_FRAMEWORK_SERVICE_VERSION, serviceVersion);
-        }
-
-        if (component->setCLanguageProperty && properties_get(properties, CELIX_FRAMEWORK_SERVICE_LANGUAGE) == NULL) { //always set default lang to C
-            properties_set(properties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-        }
-
-        if (interface && name) {
-            interface->serviceName = name;
-            interface->service = service;
-            interface->properties = properties;
-            interface->registration = NULL;
-            arrayList_add(component->dm_interfaces, interface);
-        } else {
-            free(interface);
-            free(name);
-            status = CELIX_ENOMEM;
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_getInterfaces(dm_component_pt component, array_list_pt *out) {
-    celix_status_t status = CELIX_SUCCESS;
-    array_list_pt names = NULL;
-    arrayList_create(&names);
-    celixThreadMutex_lock(&component->mutex);
-    int size = arrayList_size(component->dm_interfaces);
-    int i;
-    for (i = 0; i < size; i += 1) {
-        dm_interface_info_pt info = calloc(1, sizeof(*info));
-        dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
-        info->name = strdup(interface->serviceName);
-        properties_copy(interface->properties, &info->properties);
-        arrayList_add(names, info);
-    }
-    celixThreadMutex_unlock(&component->mutex);
-
-    if (status == CELIX_SUCCESS) {
-        *out = names;
-    }
-
-    return status;
-}
-
-celix_status_t component_handleEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	dm_handle_event_type_pt data = calloc(1, sizeof(*data));
-	data->dependency = dependency;
-	data->event = event;
-	data->newEvent = NULL;
-
-	status = executor_executeTask(component->executor, component, component_handleEventTask, data);
-//	component_handleEventTask(component, data);
-
-	return status;
-}
-
-celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_event_type_pt data) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	switch (data->event->event_type) {
-		case DM_EVENT_ADDED:
-			component_handleAdded(component,data->dependency, data->event);
-			break;
-		case DM_EVENT_CHANGED:
-			component_handleChanged(component,data->dependency, data->event);
-			break;
-		case DM_EVENT_REMOVED:
-			component_handleRemoved(component,data->dependency, data->event);
-			break;
-		case DM_EVENT_SWAPPED:
-			component_handleSwapped(component,data->dependency, data->event, data->newEvent);
-			break;
-		default:
-			break;
-	}
-
-	free(data);
-
-	return status;
-}
-
-static celix_status_t component_suspend(dm_component_pt component, dm_service_dependency_pt dependency) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	dm_service_dependency_strategy_t strategy;
-	serviceDependency_getStrategy(dependency, &strategy);
-	if (strategy == DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND &&  component->callbackStop != NULL) {
-		status = component->callbackStop(component->implementation);
-	}
-
-	return status;
-}
-
-static celix_status_t component_resume(dm_component_pt component, dm_service_dependency_pt dependency) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	dm_service_dependency_strategy_t strategy;
-	serviceDependency_getStrategy(dependency, &strategy);
-	if (strategy == DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND &&  component->callbackStop != NULL) {
-		status = component->callbackStart(component->implementation);
-	}
-
-	return status;
-}
-
-celix_status_t component_handleAdded(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    arrayList_add(events, event);
-    pthread_mutex_unlock(&component->mutex);
-
-    serviceDependency_setAvailable(dependency, true);
-
-    switch (component->state) {
-        case DM_CMP_STATE_WAITING_FOR_REQUIRED: {
-            serviceDependency_invokeSet(dependency, event);
-            bool required = false;
-            serviceDependency_isRequired(dependency, &required);
-            if (required) {
-                component_handleChange(component);
-            }
-            break;
-        }
-        case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-            bool instanceBound = false;
-            serviceDependency_isInstanceBound(dependency, &instanceBound);
-            bool required = false;
-            serviceDependency_isRequired(dependency, &required);
-            if (!instanceBound) {
-                if (required) {
-                    serviceDependency_invokeSet(dependency, event);
-                    serviceDependency_invokeAdd(dependency, event);
-                }
-                dm_event_pt event = NULL;
-                component_getDependencyEvent(component, dependency, &event);
-                component_updateInstance(component, dependency, event, false, true);
-            }
-
-            if (required) {
-                component_handleChange(component);
-            }
-            break;
-        }
-        case DM_CMP_STATE_TRACKING_OPTIONAL:
-		    component_suspend(component,dependency);
-            serviceDependency_invokeSet(dependency, event);
-            serviceDependency_invokeAdd(dependency, event);
-		    component_resume(component,dependency);
-            dm_event_pt event = NULL;
-            component_getDependencyEvent(component, dependency, &event);
-            component_updateInstance(component, dependency, event, false, true);
-            break;
-        default:
-            break;
-    }
-
-    return status;
-}
-
-celix_status_t component_handleChanged(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    int index = arrayList_indexOf(events, event);
-    if (index < 0) {
-	pthread_mutex_unlock(&component->mutex);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else {
-        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
-        arrayList_add(events, event);
-        pthread_mutex_unlock(&component->mutex);
-
-        serviceDependency_invokeSet(dependency, event);
-        switch (component->state) {
-            case DM_CMP_STATE_TRACKING_OPTIONAL:
-			    component_suspend(component,dependency);
-                serviceDependency_invokeChange(dependency, event);
-			    component_resume(component,dependency);
-                dm_event_pt hevent = NULL;
-                component_getDependencyEvent(component, dependency, &hevent);
-                component_updateInstance(component, dependency, hevent, true, false);
-                break;
-            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-                bool instanceBound = false;
-                serviceDependency_isInstanceBound(dependency, &instanceBound);
-                if (!instanceBound) {
-                    serviceDependency_invokeChange(dependency, event);
-                    dm_event_pt hevent = NULL;
-                    component_getDependencyEvent(component, dependency, &hevent);
-                    component_updateInstance(component, dependency, hevent, true, false);
-                }
-                break;
-            }
-            default:
-                break;
-        }
-
-        event_destroy(&old);
-    }
-
-    return status;
-}
-
-celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    int size = arrayList_size(events);
-    if (arrayList_contains(events, event)) {
-        size--;
-    }
-    pthread_mutex_unlock(&component->mutex);
-    serviceDependency_setAvailable(dependency, size > 0);
-    component_handleChange(component);
-
-    pthread_mutex_lock(&component->mutex);
-    int index = arrayList_indexOf(events, event);
-    if (index < 0) {
-	pthread_mutex_unlock(&component->mutex);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else {
-        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
-        pthread_mutex_unlock(&component->mutex);
-
-
-        switch (component->state) {
-            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-                serviceDependency_invokeSet(dependency, event);
-                bool instanceBound = false;
-                serviceDependency_isInstanceBound(dependency, &instanceBound);
-                if (!instanceBound) {
-                    bool required = false;
-                    serviceDependency_isRequired(dependency, &required);
-                    if (required) {
-                        serviceDependency_invokeRemove(dependency, event);
-                    }
-                    dm_event_pt hevent = NULL;
-                    component_getDependencyEvent(component, dependency, &hevent);
-                    component_updateInstance(component, dependency, hevent, false, false);
-                }
-                break;
-            }
-            case DM_CMP_STATE_TRACKING_OPTIONAL:
-			    component_suspend(component,dependency);
-                serviceDependency_invokeSet(dependency, event);
-                serviceDependency_invokeRemove(dependency, event);
-			    component_resume(component,dependency);
-                dm_event_pt hevent = NULL;
-                component_getDependencyEvent(component, dependency, &hevent);
-                component_updateInstance(component, dependency, hevent, false, false);
-                break;
-            default:
-                break;
-        }
-
-        event_destroy(&event);
-        if (old) {
-            event_destroy(&old);
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    int index = arrayList_indexOf(events, event);
-    if (index < 0) {
-	pthread_mutex_unlock(&component->mutex);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else {
-        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
-        arrayList_add(events, newEvent);
-        pthread_mutex_unlock(&component->mutex);
-
-        serviceDependency_invokeSet(dependency, event);
-
-        switch (component->state) {
-            case DM_CMP_STATE_WAITING_FOR_REQUIRED:
-                break;
-            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-                bool instanceBound = false;
-                serviceDependency_isInstanceBound(dependency, &instanceBound);
-                if (!instanceBound) {
-                    bool required = false;
-                    serviceDependency_isRequired(dependency, &required);
-                    if (required) {
-                        serviceDependency_invokeSwap(dependency, event, newEvent);
-                    }
-                }
-                break;
-            }
-            case DM_CMP_STATE_TRACKING_OPTIONAL:
-			    component_suspend(component,dependency);
-                serviceDependency_invokeSwap(dependency, event, newEvent);
-			    component_resume(component,dependency);
-                break;
-            default:
-                break;
-        }
-
-        event_destroy(&event);
-        if (old) {
-            event_destroy(&old);
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_updateInstance(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, bool update, bool add) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    bool autoConfig = false;
-
-    serviceDependency_isAutoConfig(dependency, &autoConfig);
-
-    if (autoConfig) {
-        const void *service = NULL;
-        const void **field = NULL;
-
-        if (event != NULL) {
-            event_getService(event, &service);
-        }
-        serviceDependency_getAutoConfig(dependency, &field);
-        serviceDependency_lock(dependency);
-        *field = service;
-        serviceDependency_unlock(dependency);
-    }
-
-    return status;
-}
-
-celix_status_t component_startDependencies(dm_component_pt component __attribute__((unused)), array_list_pt dependencies) {
-    celix_status_t status = CELIX_SUCCESS;
-    array_list_pt required_dependencies = NULL;
-    arrayList_create(&required_dependencies);
-
-    for (unsigned int i = 0; i < arrayList_size(dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(dependencies, i);
-        bool required = false;
-        serviceDependency_isRequired(dependency, &required);
-        if (required) {
-            arrayList_add(required_dependencies, dependency);
-            continue;
-        }
-
-        serviceDependency_start(dependency);
-    }
-
-    for (unsigned int i = 0; i < arrayList_size(required_dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(required_dependencies, i);
-        serviceDependency_start(dependency);
-    }
-
-    arrayList_destroy(required_dependencies);
-
-    return status;
-}
-
-celix_status_t component_stopDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-        pthread_mutex_unlock(&component->mutex);
-        serviceDependency_stop(dependency);
-        pthread_mutex_lock(&component->mutex);
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_handleChange(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    dm_component_state_t oldState;
-    dm_component_state_t newState;
-
-    bool transition = false;
-    do {
-        oldState = component->state;
-        status = component_calculateNewState(component, oldState, &newState);
-        if (status == CELIX_SUCCESS) {
-            component->state = newState;
-            status = component_performTransition(component, oldState, newState, &transition);
-        }
-
-        if (status != CELIX_SUCCESS) {
-            break;
-        }
-    } while (transition);
-
-    return status;
-}
-
-celix_status_t component_calculateNewState(dm_component_pt component, dm_component_state_t currentState, dm_component_state_t *newState) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (currentState == DM_CMP_STATE_INACTIVE) {
-        if (component->isStarted) {
-            *newState = DM_CMP_STATE_WAITING_FOR_REQUIRED;
-        } else {
-            *newState = currentState;
-        }
-    } else if (currentState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
-        if (!component->isStarted) {
-            *newState = DM_CMP_STATE_INACTIVE;
-        } else {
-            bool available = false;
-            component_allRequiredAvailable(component, &available);
-
-            if (available) {
-                *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
-            } else {
-                *newState = currentState;
-            }
-        }
-    } else if (currentState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
-        if (!component->isStarted) {
-            *newState = DM_CMP_STATE_WAITING_FOR_REQUIRED;
-        } else {
-            bool available = false;
-            component_allRequiredAvailable(component, &available);
-
-            if (available) {
-                bool instanceBoundAvailable = false;
-                component_allInstanceBoundAvailable(component, &instanceBoundAvailable);
-
-                if (instanceBoundAvailable) {
-                    *newState = DM_CMP_STATE_TRACKING_OPTIONAL;
-                } else {
-                    *newState = currentState;
-                }
-            } else {
-                *newState = currentState;
-            }
-        }
-    } else if (currentState == DM_CMP_STATE_TRACKING_OPTIONAL) {
-        bool instanceBoundAvailable = false;
-        bool available = false;
-
-        component_allInstanceBoundAvailable(component, &instanceBoundAvailable);
-        component_allRequiredAvailable(component, &available);
-
-        if (component->isStarted && available && instanceBoundAvailable) {
-            *newState = currentState;
-        } else {
-            *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
-        }
-    } else {
-        //should not reach
-        *newState = DM_CMP_STATE_INACTIVE;
-        status = CELIX_BUNDLE_EXCEPTION;
-    }
-
-    return status;
-}
-
-celix_status_t component_performTransition(dm_component_pt component, dm_component_state_t oldState, dm_component_state_t newState, bool *transition) {
-    celix_status_t status = CELIX_SUCCESS;
-    //printf("performing transition for %s in thread %i from %i to %i\n", component->name, (int) pthread_self(), oldState, newState);
-
-    if (oldState == newState) {
-        *transition = false;
-    } else if (oldState == DM_CMP_STATE_INACTIVE && newState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
-        component_startDependencies(component, component->dependencies);
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
-        component_invokeAddRequiredDependencies(component);
-        component_invokeAutoConfigDependencies(component);
-        if (component->callbackInit) {
-        	status = component->callbackInit(component->implementation);
-        }
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_TRACKING_OPTIONAL) {
-        component_invokeAddRequiredInstanceBoundDependencies(component);
-        component_invokeAutoConfigInstanceBoundDependencies(component);
-		component_invokeAddOptionalDependencies(component);
-        if (component->callbackStart) {
-        	status = component->callbackStart(component->implementation);
-        }
-        component_registerServices(component);
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_TRACKING_OPTIONAL && newState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
-        component_unregisterServices(component);
-        if (component->callbackStop) {
-        	status = component->callbackStop(component->implementation);
-        }
-		component_invokeRemoveOptionalDependencies(component);
-        component_invokeRemoveInstanceBoundDependencies(component);
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
-    	if (component->callbackDeinit) {
-    		status = component->callbackDeinit(component->implementation);
-    	}
-        component_invokeRemoveRequiredDependencies(component);
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_INACTIVE) {
-        component_stopDependencies(component);
-        *transition = true;
-    }
-
-    return status;
-}
-
-celix_status_t component_allRequiredAvailable(dm_component_pt component, bool *available) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    *available = true;
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (required && !instanceBound) {
-            bool isAvailable = false;
-            serviceDependency_isAvailable(dependency, &isAvailable);
-            if (!isAvailable) {
-                *available = false;
-                break;
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_allInstanceBoundAvailable(dm_component_pt component, bool *available) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    *available = true;
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (required && instanceBound) {
-            bool isAvailable = false;
-            serviceDependency_isAvailable(dependency, &isAvailable);
-            if (!isAvailable) {
-                *available = false;
-                break;
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAddRequiredDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (required && !instanceBound) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeAdd(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAutoConfigDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool autoConfig = false;
-        bool instanceBound = false;
-
-        serviceDependency_isAutoConfig(dependency, &autoConfig);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (autoConfig && !instanceBound) {
-            component_configureImplementation(component, dependency);
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAutoConfigInstanceBoundDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool autoConfig = false;
-        bool instanceBound = false;
-
-        serviceDependency_isAutoConfig(dependency, &autoConfig);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (autoConfig && instanceBound) {
-            component_configureImplementation(component, dependency);
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAddRequiredInstanceBoundDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (instanceBound && required) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeAdd(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAddOptionalDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-
-        serviceDependency_isRequired(dependency, &required);
-
-        if (!required) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeAdd(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeRemoveOptionalDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-
-        serviceDependency_isRequired(dependency, &required);
-
-        if (!required) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeRemove(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeRemoveInstanceBoundDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool instanceBound = false;
-
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (instanceBound) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeRemove(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeRemoveRequiredDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (!instanceBound && required) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeRemove(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_getDependencyEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt *event_pptr) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    *event_pptr = NULL;
-
-    if (events) {
-        for (unsigned int j = 0; j < arrayList_size(events); j++) {
-            dm_event_pt event_ptr = arrayList_get(events, j);
-            if (*event_pptr != NULL) {
-                int compare = 0;
-                event_compareTo(event_ptr, *event_pptr, &compare);
-                if (compare > 0) {
-                    *event_pptr = event_ptr;
-                }
-            } else {
-                *event_pptr = event_ptr;
-            }
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_configureImplementation(dm_component_pt component, dm_service_dependency_pt dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    const void **field = NULL;
-
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    if (events) {
-        const void *service = NULL;
-        dm_event_pt event = NULL;
-        component_getDependencyEvent(component, dependency, &event);
-        if (event != NULL) {
-            event_getService(event, &service);
-            serviceDependency_getAutoConfig(dependency, &field);
-            serviceDependency_lock(dependency);
-            *field = service;
-            serviceDependency_unlock(dependency);
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_registerServices(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (component->context != NULL) {
-	    unsigned int i;
-        for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
-            dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
-                properties_pt regProps = NULL;
-                properties_copy(interface->properties, &regProps);
-                bundleContext_registerService(component->context, interface->serviceName, interface->service, regProps, &interface->registration);
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_unregisterServices(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    unsigned int i;
-
-    for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
-	dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
-
-	serviceRegistration_unregister(interface->registration);
-	interface->registration = NULL;
-    }
-
-    return status;
-}
-
-celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit) {
-	if (component->active) {
-		return CELIX_ILLEGAL_STATE;
-	}
-	component->callbackInit = init;
-	component->callbackStart = start;
-	component->callbackStop = stop;
-	component->callbackDeinit = deinit;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t component_isAvailable(dm_component_pt component, bool *available) {
-    *available = component->state == DM_CMP_STATE_TRACKING_OPTIONAL;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t component_setImplementation(dm_component_pt component, void *implementation) {
-    component->implementation = implementation;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t component_getBundleContext(dm_component_pt component, bundle_context_pt *context) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!component) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*context = component->context;
-	}
-
-	return status;
-}
-
-
-static celix_status_t executor_create(dm_component_pt component __attribute__((unused)), dm_executor_pt *executor) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    *executor = malloc(sizeof(**executor));
-    if (!*executor) {
-        status = CELIX_ENOMEM;
-    } else {
-        linkedList_create(&(*executor)->workQueue);
-        pthread_mutex_init(&(*executor)->mutex, NULL);
-        (*executor)->runningThreadSet = false;
-    }
-
-    return status;
-}
-
-static void executor_destroy(dm_executor_pt executor) {
-
-	if (executor) {
-		pthread_mutex_destroy(&executor->mutex);
-		linkedList_destroy(executor->workQueue);
-
-		free(executor);
-	}
-}
-
-static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt component, void (*command), void *data) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    dm_executor_task_t *task = NULL;
-    task = malloc(sizeof(*task));
-    if (!task) {
-        status = CELIX_ENOMEM;
-    } else {
-        task->component = component;
-        task->command = command;
-        task->data = data;
-
-        pthread_mutex_lock(&executor->mutex);
-        linkedList_addLast(executor->workQueue, task);
-        pthread_mutex_unlock(&executor->mutex);
-    }
-
-    return status;
-}
-
-static celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt component, void (*command), void *data) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    // Check thread and executor thread, if the same, execute immediately.
-//    bool execute = false;
-//    pthread_mutex_lock(&executor->mutex);
-//    pthread_t currentThread = pthread_self();
-//    if (pthread_equal(executor->runningThread, currentThread)) {
-//        execute = true;
-//    }
-//    pthread_mutex_unlock(&executor->mutex);
-
-    // For now, just schedule.
-    executor_schedule(executor, component, command, data);
-    executor_execute(executor);
-
-    return status;
-}
-
-static celix_status_t executor_execute(dm_executor_pt executor) {
-    celix_status_t status = CELIX_SUCCESS;
-    pthread_t currentThread = pthread_self();
-
-    pthread_mutex_lock(&executor->mutex);
-    bool execute = false;
-    if (!executor->runningThreadSet) {
-        executor->runningThread = currentThread;
-        executor->runningThreadSet = true;
-        execute = true;
-    }
-    pthread_mutex_unlock(&executor->mutex);
-    if (execute) {
-        executor_runTasks(executor, currentThread);
-    }
-
-    return status;
-}
-
-static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t currentThread __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-//    bool execute = false;
-
-    do {
-        dm_executor_task_t *entry = NULL;
-        pthread_mutex_lock(&executor->mutex);
-        while ((entry = linkedList_removeFirst(executor->workQueue)) != NULL) {
-            pthread_mutex_unlock(&executor->mutex);
-
-            entry->command(entry->component, entry->data);
-
-            pthread_mutex_lock(&executor->mutex);
-
-            free(entry);
-        }
-        executor->runningThreadSet = false;
-        pthread_mutex_unlock(&executor->mutex);
-
-//        pthread_mutex_lock(&executor->mutex);
-//        if (executor->runningThread == NULL) {
-//            executor->runningThread = currentThread;
-//            execute = true;
-//        }
-//        pthread_mutex_unlock(&executor->mutex);
-    } while (!linkedList_isEmpty(executor->workQueue)); // && execute
-
-    return status;
-}
-
-celix_status_t component_getComponentInfo(dm_component_pt component, dm_component_info_pt *out) {
-    celix_status_t status = CELIX_SUCCESS;
-    int i;
-    int size;
-    dm_component_info_pt info = NULL;
-    info = calloc(1, sizeof(*info));
-
-    if (info == NULL) {
-        return CELIX_ENOMEM;
-    }
-
-    arrayList_create(&info->dependency_list);
-    component_getInterfaces(component, &info->interfaces);
-    info->active = false;
-    memcpy(info->id, component->id, DM_COMPONENT_MAX_ID_LENGTH);
-    memcpy(info->name, component->name, DM_COMPONENT_MAX_NAME_LENGTH);
-
-    switch (component->state) {
-        case DM_CMP_STATE_INACTIVE :
-            info->state = strdup("INACTIVE");
-            break;
-        case DM_CMP_STATE_WAITING_FOR_REQUIRED :
-            info->state = strdup("WAITING_FOR_REQUIRED");
-            break;
-        case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED :
-            info->state = strdup("INSTANTIATED_AND_WAITING_FOR_REQUIRED");
-            break;
-        case DM_CMP_STATE_TRACKING_OPTIONAL :
-            info->state = strdup("TRACKING_OPTIONAL");
-            info->active = true;
-            break;
-        default :
-            info->state = strdup("UNKNOWN");
-            break;
-    }
-
-    celixThreadMutex_lock(&component->mutex);
-    size = arrayList_size(component->dependencies);
-    for (i = 0; i < size; i += 1) {
-        dm_service_dependency_pt dep = arrayList_get(component->dependencies, i);
-        dm_service_dependency_info_pt depInfo = NULL;
-        status = serviceDependency_getServiceDependencyInfo(dep, &depInfo);
-        if (status == CELIX_SUCCESS) {
-            arrayList_add(info->dependency_list, depInfo);
-        } else {
-            break;
-        }
-    }
-    celixThreadMutex_unlock(&component->mutex);
-
-    if (status == CELIX_SUCCESS) {
-        *out = info;
-    } else if (info != NULL) {
-        component_destroyComponentInfo(info);
-    }
-
-    return status;
-}
-
-void component_destroyComponentInfo(dm_component_info_pt info) {
-    int i;
-    int size;
-    if (info != NULL) {
-        free(info->state);
-
-        if (info->interfaces != NULL) {
-            size = arrayList_size(info->interfaces);
-            for (i = 0; i < size; i += 1) {
-                dm_interface_info_pt intfInfo = arrayList_get(info->interfaces, i);
-                free(intfInfo->name);
-                properties_destroy(intfInfo->properties);
-                free(intfInfo);
-            }
-            arrayList_destroy(info->interfaces);
-        }
-        if (info->dependency_list != NULL) {
-            size = arrayList_size(info->dependency_list);
-            for (i = 0; i < size; i += 1) {
-                dm_service_dependency_info_pt depInfo = arrayList_get(info->dependency_list, i);
-                dependency_destroyDependencyInfo(depInfo);
-            }
-            arrayList_destroy(info->dependency_list);
-        }
-    }
-    free(info);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_dependency_manager_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_dependency_manager_impl.c b/dependency_manager/private/src/dm_dependency_manager_impl.c
deleted file mode 100644
index 4864be1..0000000
--- a/dependency_manager/private/src/dm_dependency_manager_impl.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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.
- */
-
-/*
- * dm_dependency_manager_impl.c
- *
- *  \date       26 Jul 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <dm_dependency_manager.h>
-
-#include "bundle_context.h"
-#include "dm_component_impl.h"
-#include "dm_dependency_manager_impl.h"
-
-
-celix_status_t dependencyManager_create(bundle_context_pt context __attribute__((unused)), dm_dependency_manager_pt *manager) {
-	celix_status_t status = CELIX_ENOMEM;
-
-	(*manager) = calloc(1, sizeof(**manager));
-
-	if (*manager) {
-		arrayList_create(&(*manager)->components);
-
-		status = CELIX_SUCCESS;
-	}
-
-	return status;
-
-}
-
-void dependencyManager_destroy(dm_dependency_manager_pt manager) {
-	if (manager != NULL) {
-		arrayList_destroy(manager->components);
-		free(manager);
-	}
-}
-
-celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component) {
-	celix_status_t status;
-
-	arrayList_add(manager->components, component);
-	status = component_start(component);
-
-	return status;
-}
-
-celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	unsigned int i=0;
-	unsigned int size = arrayList_size(manager->components);
-
-	for(;i<size;i++){
-		dm_component_pt cmp = arrayList_get(manager->components, i);
-//		printf("Stopping comp %s\n", component_getName(cmp));
-		component_stop(cmp);
-	}
-
-	while (!arrayList_isEmpty(manager->components)) {
-		dm_component_pt cmp = arrayList_remove(manager->components, 0);
-//        printf("Removing comp %s\n", component_getName(cmp));
-        component_destroy(cmp);
-	}
-
-	return status;
-}
-
-celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt *out) {
-	celix_status_t status = CELIX_SUCCESS;
-	int i;
-	int size;
-	dm_component_info_pt cmpInfo = NULL;
-	dm_dependency_manager_info_pt info = calloc(1, sizeof(*info));
-
-	celixThreadMutex_lock(&manager->mutex);
-
-	if (info != NULL) {
-		arrayList_create(&info->components);
-		size = arrayList_size(manager->components);
-		for (i = 0; i < size; i += 1) {
-			dm_component_pt cmp = arrayList_get(manager->components, i);
-			cmpInfo = NULL;
-			component_getComponentInfo(cmp, &cmpInfo);
-			arrayList_add(info->components, cmpInfo);
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	celixThreadMutex_unlock(&manager->mutex);
-
-	if (status == CELIX_SUCCESS) {
-		*out = info;
-	}
-
-	return status;
-}
-
-void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt info) {
-    unsigned int i = 0;
-    for (; i < arrayList_size(info->components); i += 1) {
-        dm_component_info_pt cmpinfo = (dm_component_info_pt)arrayList_get(info->components, i);
-        component_destroyComponentInfo(cmpinfo);
-    }
-    arrayList_destroy(info->components);
-    free(info);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_event.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_event.c b/dependency_manager/private/src/dm_event.c
deleted file mode 100644
index 9341832..0000000
--- a/dependency_manager/private/src/dm_event.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * 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.
- */
-
-/*
- * dm_event.c
- *
- *  \date       18 Dec 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <constants.h>
-#include <utils.h>
-
-#include "dm_event.h"
-
-celix_status_t event_create(dm_event_type_e event_type, bundle_pt bundle, bundle_context_pt context, service_reference_pt reference, const void *service, dm_event_pt *event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*event = calloc(1, sizeof(**event));
-	if (!*event) {
-		status = CELIX_ENOMEM;
-	}
-
-	const char* serviceIdStr = NULL;
-	serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &serviceIdStr);
-	unsigned long servId = strtoul(serviceIdStr,NULL,10);
-
-	//FIXME service ranking can dynamicly change, but service reference can be removed at any time.
-	const char* rankingStr = NULL;
-	serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rankingStr);
-	long ranking = rankingStr == NULL ? 0 : atol(rankingStr);
-
-	if (status == CELIX_SUCCESS) {
-		(*event)->bundle = bundle;
-		(*event)->event_type = event_type;
-		(*event)->context = context;
-		(*event)->reference = reference;
-		(*event)->service = service;
-		(*event)->serviceId = servId;
-		(*event)->ranking = ranking;
-	}
-
-	return status;
-}
-
-celix_status_t event_destroy(dm_event_pt *event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!*event) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		free(*event);
-		*event = NULL;
-	}
-
-	return status;
-}
-
-celix_status_t event_equals(const void *a, const void *b, bool *equals) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!a || !b) {
-		*equals = false;
-	} else {
-		dm_event_pt a_ptr = (dm_event_pt)a;
-		dm_event_pt b_ptr = (dm_event_pt)b;
-
-		*equals = a_ptr->serviceId == b_ptr->serviceId;
-	}
-
-	return status;
-}
-
-celix_status_t event_compareTo(dm_event_pt event, dm_event_pt compareTo, int *compare) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*compare = utils_compareServiceIdsAndRanking(event->serviceId, event->ranking, compareTo->serviceId, compareTo->ranking);
-
-	return status;
-}
-
-celix_status_t event_getService(dm_event_pt event, const void **service) {
-	*service = event->service;
-	return CELIX_SUCCESS;
-}


[16/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/framework.c
----------------------------------------------------------------------
diff --git a/framework/src/framework.c b/framework/src/framework.c
new file mode 100644
index 0000000..b1db384
--- /dev/null
+++ b/framework/src/framework.c
@@ -0,0 +1,2620 @@
+/**
+ *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.
+ */
+/*
+ * framework.c
+ *
+ *  \date       Mar 23, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "celixbool.h"
+
+#ifdef _WIN32
+#include <winbase.h>
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+#include <uuid/uuid.h>
+
+#include "framework_private.h"
+#include "constants.h"
+#include "resolver.h"
+#include "utils.h"
+#include "linked_list_iterator.h"
+#include "service_reference_private.h"
+#include "listener_hook_service.h"
+#include "service_registration_private.h"
+
+typedef celix_status_t (*create_function_pt)(bundle_context_pt context, void **userData);
+typedef celix_status_t (*start_function_pt)(void * handle, bundle_context_pt context);
+typedef celix_status_t (*stop_function_pt)(void * handle, bundle_context_pt context);
+typedef celix_status_t (*destroy_function_pt)(void * handle, bundle_context_pt context);
+
+struct activator {
+    void * userData;
+    start_function_pt start;
+    stop_function_pt stop;
+    destroy_function_pt destroy;
+};
+
+celix_status_t framework_setBundleStateAndNotify(framework_pt framework, bundle_pt bundle, int state);
+celix_status_t framework_markBundleResolved(framework_pt framework, module_pt module);
+
+celix_status_t framework_acquireBundleLock(framework_pt framework, bundle_pt bundle, int desiredStates);
+bool framework_releaseBundleLock(framework_pt framework, bundle_pt bundle);
+
+bool framework_acquireGlobalLock(framework_pt framework);
+celix_status_t framework_releaseGlobalLock(framework_pt framework);
+
+celix_status_t framework_acquireInstallLock(framework_pt framework, const char* location);
+celix_status_t framework_releaseInstallLock(framework_pt framework, const char* location);
+
+long framework_getNextBundleId(framework_pt framework);
+
+celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char * location, const char *inputFile, bundle_archive_pt archive);
+
+celix_status_t fw_refreshBundles(framework_pt framework, bundle_pt bundles[], int size);
+celix_status_t fw_refreshBundle(framework_pt framework, bundle_pt bundle);
+
+celix_status_t fw_populateDependentGraph(framework_pt framework, bundle_pt exporter, hash_map_pt *map);
+
+celix_status_t fw_fireBundleEvent(framework_pt framework, bundle_event_type_e, bundle_pt bundle);
+celix_status_t fw_fireFrameworkEvent(framework_pt framework, framework_event_type_e eventType, bundle_pt bundle, celix_status_t errorCode);
+static void *fw_eventDispatcher(void *fw);
+
+celix_status_t fw_invokeBundleListener(framework_pt framework, bundle_listener_pt listener, bundle_event_pt event, bundle_pt bundle);
+celix_status_t fw_invokeFrameworkListener(framework_pt framework, framework_listener_pt listener, framework_event_pt event, bundle_pt bundle);
+
+static celix_status_t framework_loadBundleLibraries(framework_pt framework, bundle_pt bundle);
+static celix_status_t framework_loadLibraries(framework_pt framework, const char* libraries, const char* activator, bundle_archive_pt archive, void **activatorHandle);
+static celix_status_t framework_loadLibrary(framework_pt framework, const char* library, bundle_archive_pt archive, void **handle);
+
+static celix_status_t frameworkActivator_start(void * userData, bundle_context_pt context);
+static celix_status_t frameworkActivator_stop(void * userData, bundle_context_pt context);
+static celix_status_t frameworkActivator_destroy(void * userData, bundle_context_pt context);
+
+
+struct fw_refreshHelper {
+    framework_pt framework;
+    bundle_pt bundle;
+    bundle_state_e oldState;
+};
+
+celix_status_t fw_refreshHelper_refreshOrRemove(struct fw_refreshHelper * refreshHelper);
+celix_status_t fw_refreshHelper_restart(struct fw_refreshHelper * refreshHelper);
+celix_status_t fw_refreshHelper_stop(struct fw_refreshHelper * refreshHelper);
+
+struct fw_serviceListener {
+	bundle_pt bundle;
+	service_listener_pt listener;
+	filter_pt filter;
+    array_list_pt retainedReferences;
+};
+
+typedef struct fw_serviceListener * fw_service_listener_pt;
+
+struct fw_bundleListener {
+	bundle_pt bundle;
+	bundle_listener_pt listener;
+};
+
+typedef struct fw_bundleListener * fw_bundle_listener_pt;
+
+struct fw_frameworkListener {
+	bundle_pt bundle;
+	framework_listener_pt listener;
+};
+
+typedef struct fw_frameworkListener * fw_framework_listener_pt;
+
+enum event_type {
+	FRAMEWORK_EVENT_TYPE,
+	BUNDLE_EVENT_TYPE,
+	EVENT_TYPE_SERVICE,
+};
+
+typedef enum event_type event_type_e;
+
+struct request {
+	event_type_e type;
+	array_list_pt listeners;
+
+	int eventType;
+	long bundleId;
+	char* bundleSymbolicName;
+	celix_status_t errorCode;
+	char *error;
+
+	char *filter;
+};
+
+typedef struct request *request_pt;
+
+framework_logger_pt logger;
+
+//TODO introduce a counter + mutex to control the freeing of the logger when mutiple threads are running a framework.
+static celix_thread_once_t loggerInit = CELIX_THREAD_ONCE_INIT;
+static void framework_loggerInit(void) {
+    logger = malloc(sizeof(*logger));
+    logger->logFunction = frameworkLogger_log;
+}
+
+/* Note: RTLD_NODELETE flag is needed in order to obtain a readable valgrind output.
+ * Valgrind output is written when the application terminates, so symbols resolving
+ * is impossible if dlopened libraries are unloaded before the application ends.
+ * RTLD_NODELETE closes the dynamic library but does not unload it from the memory space,
+ * so that symbols will be available until the application terminates.
+ * On the other hand, since the memory mapping is not destroyed after dlclose, calling again
+ * dlopen for the same library clashes with the previous mapping: this breaks the memory layout
+ * in case the user, for example, uninstall (dlclose) and install the bundle again (dlopen)
+ * So, RTLD_NODELETE should be used only for debugging purposes.
+ * Refer to dlopen manpage for additional details about libraries dynamic loading.
+ */
+#ifdef _WIN32
+    #define handle_t HMODULE
+    #define fw_openLibrary(path) LoadLibrary(path)
+    #define fw_closeLibrary(handle) FreeLibrary(handle)
+
+    #define fw_getSymbol(handle, name) GetProcAddress(handle, name)
+
+    #define fw_getLastError() GetLastError()
+
+    HMODULE fw_getCurrentModule() {
+        HMODULE hModule = NULL;
+        GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)fw_getCurrentModule, &hModule);
+        return hModule;
+    }
+#else
+    #define handle_t void *
+    #if defined(DEBUG) && !defined(ANDROID)
+	#define fw_openLibrary(path) dlopen(path, RTLD_LAZY|RTLD_LOCAL|RTLD_NODELETE)
+    #else
+	#define fw_openLibrary(path) dlopen(path, RTLD_LAZY|RTLD_LOCAL)
+    #endif
+    #define fw_closeLibrary(handle) dlclose(handle)
+    #define fw_getSymbol(handle, name) dlsym(handle, name)
+    #define fw_getLastError() dlerror()
+#endif
+
+celix_status_t framework_create(framework_pt *framework, properties_pt config) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    logger = hashMap_get(config, "logger");
+    if (logger == NULL) {
+        celixThread_once(&loggerInit, framework_loggerInit);
+    }
+
+    *framework = (framework_pt) malloc(sizeof(**framework));
+    if (*framework != NULL) {
+        status = CELIX_DO_IF(status, celixThreadCondition_init(&(*framework)->condition, NULL));
+        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->mutex, NULL));
+        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->installedBundleMapLock, NULL));
+        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->bundleLock, NULL));
+        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->installRequestLock, NULL));
+        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->dispatcherLock, NULL));
+        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->bundleListenerLock, NULL));
+        status = CELIX_DO_IF(status, celixThreadCondition_init(&(*framework)->dispatcher, NULL));
+        if (status == CELIX_SUCCESS) {
+            (*framework)->bundle = NULL;
+            (*framework)->installedBundleMap = NULL;
+            (*framework)->registry = NULL;
+            (*framework)->interrupted = false;
+            (*framework)->shutdown = false;
+            (*framework)->globalLockWaitersList = NULL;
+            (*framework)->globalLockCount = 0;
+            (*framework)->globalLockThread = celix_thread_default;
+            (*framework)->nextBundleId = 1l;
+            (*framework)->cache = NULL;
+            (*framework)->installRequestMap = hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
+            (*framework)->serviceListeners = NULL;
+            (*framework)->bundleListeners = NULL;
+            (*framework)->frameworkListeners = NULL;
+            (*framework)->requests = NULL;
+            (*framework)->configurationMap = config;
+            (*framework)->logger = logger;
+
+
+            status = CELIX_DO_IF(status, bundle_create(&(*framework)->bundle));
+            status = CELIX_DO_IF(status, arrayList_create(&(*framework)->globalLockWaitersList));
+            status = CELIX_DO_IF(status, bundle_setFramework((*framework)->bundle, (*framework)));
+            if (status == CELIX_SUCCESS) {
+                //
+            } else {
+                status = CELIX_FRAMEWORK_EXCEPTION;
+                fw_logCode((*framework)->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not create framework");
+            }
+        } else {
+            status = CELIX_FRAMEWORK_EXCEPTION;
+            fw_logCode((*framework)->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not create framework");
+        }
+    } else {
+        status = CELIX_FRAMEWORK_EXCEPTION;
+        fw_logCode(logger, OSGI_FRAMEWORK_LOG_ERROR, CELIX_ENOMEM, "Could not create framework");
+    }
+
+    return status;
+}
+
+celix_status_t framework_destroy(framework_pt framework) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    celixThreadMutex_lock(&framework->installedBundleMapLock);
+
+    if (framework->installedBundleMap != NULL) {
+        hash_map_iterator_pt iterator = hashMapIterator_create(framework->installedBundleMap);
+        while (hashMapIterator_hasNext(iterator)) {
+            hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
+            bundle_pt bundle = (bundle_pt) hashMapEntry_getValue(entry);
+            char * key = hashMapEntry_getKey(entry);
+            bundle_archive_pt archive = NULL;
+
+            bool systemBundle = false;
+            bundle_isSystemBundle(bundle, &systemBundle);
+            if (systemBundle) {
+                bundle_context_pt context = NULL;
+                bundle_getContext(framework->bundle, &context);
+                bundleContext_destroy(context);
+            }
+
+            if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
+                if (!systemBundle) {
+                    bundle_revision_pt revision = NULL;
+                    array_list_pt handles = NULL;
+                    status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+                    status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
+                    if (handles != NULL) {
+                        for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
+                            void *handle = arrayList_get(handles, i);
+                            fw_closeLibrary(handle);
+                        }
+                    }
+                }
+
+                bundleArchive_destroy(archive);
+            }
+            bundle_destroy(bundle);
+            hashMapIterator_remove(iterator);
+            free(key);
+        }
+        hashMapIterator_destroy(iterator);
+    }
+
+    celixThreadMutex_unlock(&framework->installedBundleMapLock);
+
+	hashMap_destroy(framework->installRequestMap, false, false);
+
+	serviceRegistry_destroy(framework->registry);
+
+	arrayList_destroy(framework->globalLockWaitersList);
+
+    if (framework->serviceListeners != NULL) {
+        arrayList_destroy(framework->serviceListeners);
+    }
+    if (framework->bundleListeners) {
+        arrayList_destroy(framework->bundleListeners);
+    }
+    if (framework->frameworkListeners) {
+        arrayList_destroy(framework->frameworkListeners);
+    }
+
+	if(framework->requests){
+	    int i;
+	    for (i = 0; i < arrayList_size(framework->requests); i++) {
+	        request_pt request = arrayList_get(framework->requests, i);
+	        free(request);
+	    }
+	    arrayList_destroy(framework->requests);
+	}
+	if(framework->installedBundleMap!=NULL){
+		hashMap_destroy(framework->installedBundleMap, true, false);
+	}
+
+	bundleCache_destroy(&framework->cache);
+
+	celixThreadCondition_destroy(&framework->dispatcher);
+	celixThreadMutex_destroy(&framework->bundleListenerLock);
+	celixThreadMutex_destroy(&framework->dispatcherLock);
+	celixThreadMutex_destroy(&framework->installRequestLock);
+	celixThreadMutex_destroy(&framework->bundleLock);
+	celixThreadMutex_destroy(&framework->installedBundleMapLock);
+	celixThreadMutex_destroy(&framework->mutex);
+	celixThreadCondition_destroy(&framework->condition);
+
+    logger = hashMap_get(framework->configurationMap, "logger");
+    if (logger == NULL) {
+        free(framework->logger);
+    }
+
+    properties_destroy(framework->configurationMap);
+
+    free(framework);
+
+	return status;
+}
+
+celix_status_t fw_init(framework_pt framework) {
+	bundle_state_e state;
+	const char *location = NULL;
+	module_pt module = NULL;
+	linked_list_pt wires = NULL;
+	array_list_pt archives = NULL;
+	bundle_archive_pt archive = NULL;
+
+	celix_status_t status = CELIX_SUCCESS;
+	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+	status = CELIX_DO_IF(status, arrayList_create(&framework->serviceListeners));
+	status = CELIX_DO_IF(status, arrayList_create(&framework->bundleListeners));
+	status = CELIX_DO_IF(status, arrayList_create(&framework->frameworkListeners));
+	status = CELIX_DO_IF(status, arrayList_create(&framework->requests));
+	status = CELIX_DO_IF(status, celixThread_create(&framework->dispatcherThread, NULL, fw_eventDispatcher, framework));
+	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+	if (status == CELIX_SUCCESS) {
+	    if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
+	        bundle_state_e state;
+	        status = CELIX_DO_IF(status, bundleCache_create(framework->configurationMap,&framework->cache));
+	        status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+	        if (status == CELIX_SUCCESS) {
+	            if (state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) {
+	                const char *clean = properties_get(framework->configurationMap, OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN);
+	                if (clean != NULL && (strcmp(clean, OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT) == 0)) {
+	                    bundleCache_delete(framework->cache);
+	                }
+	            }
+            }
+        }
+	}
+
+	if (status == CELIX_SUCCESS) {
+        /*create and store framework uuid*/
+        char uuid[37];
+
+	    uuid_t uid;
+        uuid_generate(uid);
+        uuid_unparse(uid, uuid);
+
+        properties_set(framework->configurationMap, (char*) OSGI_FRAMEWORK_FRAMEWORK_UUID, uuid);
+
+        framework->installedBundleMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+	}
+
+    status = CELIX_DO_IF(status, bundle_getArchive(framework->bundle, &archive));
+    status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
+    if (status == CELIX_SUCCESS) {
+        hashMap_put(framework->installedBundleMap, strdup(location), framework->bundle);
+    }
+    status = CELIX_DO_IF(status, bundle_getCurrentModule(framework->bundle, &module));
+    if (status == CELIX_SUCCESS) {
+        wires = resolver_resolve(module);
+        if (wires != NULL) {
+            framework_markResolvedModules(framework, wires);
+        } else {
+            status = CELIX_BUNDLE_EXCEPTION;
+            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Unresolved constraints in System Bundle");
+        }
+    }
+
+    status = CELIX_DO_IF(status, bundleCache_getArchives(framework->cache, &archives));
+    if (status == CELIX_SUCCESS) {
+        unsigned int arcIdx;
+        for (arcIdx = 0; arcIdx < arrayList_size(archives); arcIdx++) {
+            bundle_archive_pt archive1 = (bundle_archive_pt) arrayList_get(archives, arcIdx);
+            long id;
+            bundle_state_e bundleState;
+            bundleArchive_getId(archive1, &id);
+            framework->nextBundleId = framework->nextBundleId > id + 1 ? framework->nextBundleId : id + 1;
+
+            bundleArchive_getPersistentState(archive1, &bundleState);
+            if (bundleState == OSGI_FRAMEWORK_BUNDLE_UNINSTALLED) {
+                bundleArchive_closeAndDelete(archive1);
+            } else {
+                bundle_pt bundle = NULL;
+                const char *location1 = NULL;
+                status = bundleArchive_getLocation(archive1, &location1);
+                fw_installBundle2(framework, &bundle, id, location1, NULL, archive1);
+            }
+        }
+        arrayList_destroy(archives);
+    }
+
+    status = CELIX_DO_IF(status, serviceRegistry_create(framework, fw_serviceChanged, &framework->registry));
+    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_STARTING));
+    status = CELIX_DO_IF(status, celixThreadCondition_init(&framework->shutdownGate, NULL));
+
+    bundle_context_pt context = NULL;
+    status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, framework->bundle, &context));
+    status = CELIX_DO_IF(status, bundle_setContext(framework->bundle, context));
+    if (status == CELIX_SUCCESS) {
+        activator_pt activator = NULL;
+        activator = (activator_pt) calloc(1,(sizeof(*activator)));
+        if (activator != NULL) {
+            bundle_context_pt context = NULL;
+            void * userData = NULL;
+
+			//create_function_pt create = NULL;
+			start_function_pt start = (start_function_pt) frameworkActivator_start;
+			stop_function_pt stop = (stop_function_pt) frameworkActivator_stop;
+			destroy_function_pt destroy = (destroy_function_pt) frameworkActivator_destroy;
+
+            activator->start = start;
+            activator->stop = stop;
+            activator->destroy = destroy;
+            status = CELIX_DO_IF(status, bundle_setActivator(framework->bundle, activator));
+            status = CELIX_DO_IF(status, bundle_getContext(framework->bundle, &context));
+
+            if (status == CELIX_SUCCESS) {
+                /* This code part is in principle dead, but in future it may do something.
+                 * That's why it's outcommented and not deleted
+		if (create != NULL) {
+                    create(context, &userData);
+                }
+                */
+                activator->userData = userData;
+
+                if (start != NULL) {
+                    start(userData, context);
+                }
+            }
+            else{
+            	free(activator);
+            }
+        } else {
+            status = CELIX_ENOMEM;
+        }
+    }
+
+    if (status != CELIX_SUCCESS) {
+       fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not init framework");
+    }
+
+    framework_releaseBundleLock(framework, framework->bundle);
+
+	return status;
+}
+
+celix_status_t framework_start(framework_pt framework) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
+
+	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+	if (status == CELIX_SUCCESS) {
+	    if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
+	        status = CELIX_DO_IF(status, fw_init(framework));
+        }
+	}
+
+	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+	if (status == CELIX_SUCCESS) {
+	    if (state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
+	        status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+	    }
+
+	    framework_releaseBundleLock(framework, framework->bundle);
+	}
+
+	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED, framework->bundle));
+	status = CELIX_DO_IF(status, fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_STARTED, framework->bundle, 0));
+
+	if (status != CELIX_SUCCESS) {
+       status = CELIX_BUNDLE_EXCEPTION;
+       fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start framework");
+       fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_ERROR, framework->bundle, status);
+    }
+
+	return status;
+}
+
+void framework_stop(framework_pt framework) {
+	fw_stopBundle(framework, framework->bundle, true);
+}
+
+celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** value) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (framework == NULL || name == NULL || *value != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		if (framework->configurationMap != NULL) {
+			*value = properties_get(framework->configurationMap, name);
+		}
+		if (*value == NULL) {
+			*value = getenv(name);
+		}
+        if (*value == NULL) {
+            *value = defaultValue;
+        }
+	}
+
+	return status;
+}
+
+celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, const char * location, const char *inputFile) {
+	return fw_installBundle2(framework, bundle, -1, location, inputFile, NULL);
+}
+
+celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char * location, const char *inputFile, bundle_archive_pt archive) {
+    celix_status_t status = CELIX_SUCCESS;
+//    bundle_archive_pt bundle_archive = NULL;
+    bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
+  	bool locked;
+
+  	status = CELIX_DO_IF(status, framework_acquireInstallLock(framework, location));
+  	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+  	if (status == CELIX_SUCCESS) {
+        if (state == OSGI_FRAMEWORK_BUNDLE_STOPPING || state == OSGI_FRAMEWORK_BUNDLE_UNINSTALLED) {
+            fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO,  "The framework is being shutdown");
+            status = CELIX_DO_IF(status, framework_releaseInstallLock(framework, location));
+            status = CELIX_FRAMEWORK_SHUTDOWN;
+        }
+  	}
+
+    if (status == CELIX_SUCCESS) {
+        *bundle = framework_getBundle(framework, location);
+        if (*bundle != NULL) {
+            framework_releaseInstallLock(framework, location);
+            return CELIX_SUCCESS;
+        }
+
+        if (archive == NULL) {
+            id = framework_getNextBundleId(framework);
+
+            status = CELIX_DO_IF(status, bundleCache_createArchive(framework->cache, id, location, inputFile, &archive));
+
+            if (status != CELIX_SUCCESS) {
+            	bundleArchive_destroy(archive);
+            }
+        } else {
+            // purge revision
+            // multiple revisions not yet implemented
+        }
+
+        if (status == CELIX_SUCCESS) {
+            locked = framework_acquireGlobalLock(framework);
+            if (!locked) {
+                status = CELIX_BUNDLE_EXCEPTION;
+            } else {
+                status = CELIX_DO_IF(status, bundle_createFromArchive(bundle, framework, archive));
+
+                framework_releaseGlobalLock(framework);
+                if (status == CELIX_SUCCESS) {
+                    celixThreadMutex_lock(&framework->installedBundleMapLock);
+                    hashMap_put(framework->installedBundleMap, strdup(location), *bundle);
+                    celixThreadMutex_unlock(&framework->installedBundleMapLock);
+
+                } else {
+                    status = CELIX_BUNDLE_EXCEPTION;
+                    status = CELIX_DO_IF(status, bundleArchive_closeAndDelete(archive));
+                }
+            }
+        }
+    }
+
+    framework_releaseInstallLock(framework, location);
+
+    if (status != CELIX_SUCCESS) {
+    	fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not install bundle");
+    } else {
+        status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_INSTALLED, *bundle));
+    }
+
+  	return status;
+}
+
+celix_status_t framework_getBundleEntry(framework_pt framework, bundle_pt bundle, const char* name, char** entry) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bundle_revision_pt revision;
+	bundle_archive_pt archive = NULL;
+    const char *root;
+
+	status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
+    status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+    status = CELIX_DO_IF(status, bundleRevision_getRoot(revision, &root));
+    if (status == CELIX_SUCCESS) {
+        char e[strlen(name) + strlen(root) + 2];
+        strcpy(e, root);
+        if ((strlen(name) > 0) && (name[0] == '/')) {
+            strcat(e, name);
+        } else {
+            strcat(e, "/");
+            strcat(e, name);
+        }
+
+        if (access(e, F_OK) == 0) {
+            (*entry) = strndup(e, 1024*10);
+        } else {
+            (*entry) = NULL;
+        }
+    }
+
+	return status;
+}
+
+celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int options) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	linked_list_pt wires = NULL;
+	bundle_context_pt context = NULL;
+	bundle_state_e state;
+	module_pt module = NULL;
+	activator_pt activator = NULL;
+	char *error = NULL;
+	const char *name = NULL;
+
+	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+	status = CELIX_DO_IF(status, bundle_getState(bundle, &state));
+
+	if (status == CELIX_SUCCESS) {
+	    switch (state) {
+            case OSGI_FRAMEWORK_BUNDLE_UNKNOWN:
+                error = "state is unknown";
+                status = CELIX_ILLEGAL_STATE;
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_UNINSTALLED:
+                error = "bundle is uninstalled";
+                status = CELIX_ILLEGAL_STATE;
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_STARTING:
+                error = "bundle is starting";
+                status = CELIX_BUNDLE_EXCEPTION;
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_STOPPING:
+                error = "bundle is stopping";
+                status = CELIX_BUNDLE_EXCEPTION;
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_INSTALLED:
+                bundle_getCurrentModule(bundle, &module);
+                module_getSymbolicName(module, &name);
+                if (!module_isResolved(module)) {
+                    wires = resolver_resolve(module);
+                    if (wires == NULL) {
+                        framework_releaseBundleLock(framework, bundle);
+                        return CELIX_BUNDLE_EXCEPTION;
+                    }
+                    framework_markResolvedModules(framework, wires);
+
+                }
+                /* no break */
+            case OSGI_FRAMEWORK_BUNDLE_RESOLVED:
+                module = NULL;
+                name = NULL;
+                bundle_getCurrentModule(bundle, &module);
+                module_getSymbolicName(module, &name);
+                status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, bundle, &context));
+                status = CELIX_DO_IF(status, bundle_setContext(bundle, context));
+
+                if (status == CELIX_SUCCESS) {
+                    activator = (activator_pt) calloc(1,(sizeof(*activator)));
+                    if (activator == NULL) {
+                        status = CELIX_ENOMEM;
+                    } else {
+                        void * userData = NULL;
+                        bundle_context_pt context;
+                        create_function_pt create = (create_function_pt) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE);
+                        start_function_pt start = (start_function_pt) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START);
+                        stop_function_pt stop = (stop_function_pt) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP);
+                        destroy_function_pt destroy = (destroy_function_pt) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY);
+
+                        activator->start = start;
+                        activator->stop = stop;
+                        activator->destroy = destroy;
+                        status = CELIX_DO_IF(status, bundle_setActivator(bundle, activator));
+
+                        status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STARTING));
+                        status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTING, bundle));
+
+                        status = CELIX_DO_IF(status, bundle_getContext(bundle, &context));
+
+                        if (status == CELIX_SUCCESS) {
+                            if (create != NULL) {
+                                status = CELIX_DO_IF(status, create(context, &userData));
+                                if (status == CELIX_SUCCESS) {
+                                    activator->userData = userData;
+                                }
+                            }
+                        }
+                        if (status == CELIX_SUCCESS) {
+                            if (start != NULL) {
+                                status = CELIX_DO_IF(status, start(userData, context));
+                            }
+                        }
+
+                        status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+                        status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED, bundle));
+                    }
+                }
+
+            break;
+        }
+	}
+
+	framework_releaseBundleLock(framework, bundle);
+
+	if (status != CELIX_SUCCESS) {
+	    module_pt module = NULL;
+	    const char *symbolicName = NULL;
+	    long id = 0;
+	    bundle_getCurrentModule(bundle, &module);
+	    module_getSymbolicName(module, &symbolicName);
+	    bundle_getBundleId(bundle, &id);
+	    if (error != NULL) {
+	        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]; cause: %s", symbolicName, id, error);
+	    } else {
+	        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]", symbolicName, id);
+	    }
+	    if(activator!=NULL){
+	    	free(activator);
+	    }
+	}
+
+	return status;
+}
+
+celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle, const char *inputFile) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_state_e oldState;
+	const char *location;
+	bundle_archive_pt archive = NULL;
+	char *error = NULL;
+
+	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+	status = CELIX_DO_IF(status, bundle_getState(bundle, &oldState));
+	if (status == CELIX_SUCCESS) {
+        if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
+            fw_stopBundle(framework, bundle, false);
+        }
+	}
+	status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
+	status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
+
+	if (status == CELIX_SUCCESS) {
+	    bool locked = framework_acquireGlobalLock(framework);
+	    if (!locked) {
+	        status = CELIX_BUNDLE_EXCEPTION;
+	        error = "Unable to acquire the global lock to update the bundle";
+	    }
+	}
+
+	status = CELIX_DO_IF(status, bundle_revise(bundle, location, inputFile));
+	status = CELIX_DO_IF(status, framework_releaseGlobalLock(framework));
+
+	status = CELIX_DO_IF(status, bundleArchive_setLastModified(archive, time(NULL)));
+	status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED));
+
+	bundle_revision_pt revision = NULL;
+	array_list_pt handles = NULL;
+	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+    status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
+    if (handles != NULL) {
+        int i;
+	    for (i = arrayList_size(handles) - 1; i >= 0; i--) {
+	        void* handle = arrayList_get(handles, i);
+	        fw_closeLibrary(handle);
+	    }
+    }
+
+
+	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
+	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UPDATED, bundle));
+
+    // Refresh packages?
+
+	if (status == CELIX_SUCCESS) {
+	    if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
+	        status = CELIX_DO_IF(status, fw_startBundle(framework, bundle, 1));
+	    }
+	}
+
+	framework_releaseBundleLock(framework, bundle);
+
+	if (status != CELIX_SUCCESS) {
+	    module_pt module = NULL;
+        const char *symbolicName = NULL;
+        long id = 0;
+        bundle_getCurrentModule(bundle, &module);
+        module_getSymbolicName(module, &symbolicName);
+        bundle_getBundleId(bundle, &id);
+        if (error != NULL) {
+            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot update bundle: %s [%ld]; cause: %s", symbolicName, id, error);
+        } else {
+            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot update bundle: %s [%ld]", symbolicName, id);
+        }
+	}
+
+	return status;
+}
+
+celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle, bool record) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_state_e state;
+    activator_pt activator = NULL;
+    bundle_context_pt context = NULL;
+    bool wasActive = false;
+    long id = 0;
+    char *error = NULL;
+
+	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+
+	if (record) {
+	    status = CELIX_DO_IF(status, bundle_setPersistentStateInactive(bundle));
+    }
+
+	status = CELIX_DO_IF(status, bundle_getState(bundle, &state));
+	if (status == CELIX_SUCCESS) {
+	    switch (state) {
+            case OSGI_FRAMEWORK_BUNDLE_UNKNOWN:
+                status = CELIX_ILLEGAL_STATE;
+                error = "state is unknown";
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_UNINSTALLED:
+                status = CELIX_ILLEGAL_STATE;
+                error = "bundle is uninstalled";
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_STARTING:
+                status = CELIX_BUNDLE_EXCEPTION;
+                error = "bundle is starting";
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_STOPPING:
+                status = CELIX_BUNDLE_EXCEPTION;
+                error = "bundle is stopping";
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_INSTALLED:
+            case OSGI_FRAMEWORK_BUNDLE_RESOLVED:
+                break;
+            case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
+                wasActive = true;
+                break;
+        }
+	}
+
+
+	status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STOPPING));
+	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING, bundle));
+    status = CELIX_DO_IF(status, bundle_getBundleId(bundle, &id));
+	if (status == CELIX_SUCCESS) {
+	    if (wasActive || (id == 0)) {
+	        activator = bundle_getActivator(bundle);
+
+	        status = CELIX_DO_IF(status, bundle_getContext(bundle, &context));
+	        if (status == CELIX_SUCCESS) {
+                if (activator->stop != NULL) {
+                    status = CELIX_DO_IF(status, activator->stop(activator->userData, context));
+                }
+	        }
+            if (status == CELIX_SUCCESS) {
+                if (activator->destroy != NULL) {
+                    status = CELIX_DO_IF(status, activator->destroy(activator->userData, context));
+                }
+	        }
+
+            if (id != 0) {
+                status = CELIX_DO_IF(status, serviceRegistry_clearServiceRegistrations(framework->registry, bundle));
+                if (status == CELIX_SUCCESS) {
+                    module_pt module = NULL;
+                    const char *symbolicName = NULL;
+                    long id = 0;
+                    bundle_getCurrentModule(bundle, &module);
+                    module_getSymbolicName(module, &symbolicName);
+                    bundle_getBundleId(bundle, &id);
+
+                    serviceRegistry_clearReferencesFor(framework->registry, bundle);
+                }
+                // #TODO remove listeners for bundle
+
+                if (context != NULL) {
+                    status = CELIX_DO_IF(status, bundleContext_destroy(context));
+                    status = CELIX_DO_IF(status, bundle_setContext(bundle, NULL));
+                }
+
+                status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_RESOLVED));
+            }
+	    }
+
+	    if (activator != NULL) {
+	        bundle_setActivator(bundle, NULL);
+	        free(activator);
+	    }
+	}
+
+	framework_releaseBundleLock(framework, bundle);
+
+	if (status != CELIX_SUCCESS) {
+	    module_pt module = NULL;
+        const char *symbolicName = NULL;
+        long id = 0;
+        bundle_getCurrentModule(bundle, &module);
+        module_getSymbolicName(module, &symbolicName);
+        bundle_getBundleId(bundle, &id);
+        if (error != NULL) {
+            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot stop bundle: %s [%ld]; cause: %s", symbolicName, id, error);
+        } else {
+            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot stop bundle: %s [%ld]", symbolicName, id);
+        }
+ 	} else {
+        fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPED, bundle);
+ 	}
+
+	return status;
+}
+
+celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+    bool locked;
+    bundle_archive_pt archive = NULL;
+    const char * location = NULL;
+    bundle_pt target = NULL;
+    char *error = NULL;
+
+    status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE|OSGI_FRAMEWORK_BUNDLE_STOPPING));
+    status = CELIX_DO_IF(status, fw_stopBundle(framework, bundle, true));
+    if (status == CELIX_SUCCESS) {
+        locked = framework_acquireGlobalLock(framework);
+        if (!locked) {
+            status = CELIX_ILLEGAL_STATE;
+            error = "Unable to acquire the global lock to uninstall the bundle";
+        }
+    }
+
+    status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
+    status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
+    if (status == CELIX_SUCCESS) {
+
+        celixThreadMutex_lock(&framework->installedBundleMapLock);
+
+        hash_map_entry_pt entry = hashMap_getEntry(framework->installedBundleMap, location);
+        char* entryLocation = hashMapEntry_getKey(entry);
+
+        target = (bundle_pt) hashMap_remove(framework->installedBundleMap, location);
+
+        free(entryLocation);
+        if (target != NULL) {
+            status = CELIX_DO_IF(status, bundle_setPersistentStateUninstalled(target));
+            // fw_rememberUninstalledBundle(framework, target);
+        }
+        celixThreadMutex_unlock(&framework->installedBundleMapLock);
+
+    }
+
+    framework_releaseGlobalLock(framework);
+
+    if (status == CELIX_SUCCESS) {
+        if (target == NULL) {
+            fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Could not remove bundle from installed map");
+        }
+    }
+
+    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED));
+
+    // TODO Unload all libraries for transition to unresolved
+    bundle_revision_pt revision = NULL;
+	array_list_pt handles = NULL;
+	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+	status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
+	if(handles != NULL){
+		for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
+			void *handle = arrayList_get(handles, i);
+			fw_closeLibrary(handle);
+		}
+	}
+
+    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
+
+    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED));
+    status = CELIX_DO_IF(status, bundleArchive_setLastModified(archive, time(NULL)));
+
+    framework_releaseBundleLock(framework, bundle);
+
+    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNINSTALLED, bundle));
+
+    if (status == CELIX_SUCCESS) {
+        locked = framework_acquireGlobalLock(framework);
+        if (locked) {
+            bundle_pt bundles[] = { bundle };
+            celix_status_t refreshStatus = fw_refreshBundles(framework, bundles, 1);
+            if (refreshStatus != CELIX_SUCCESS) {
+                printf("Could not refresh bundle");
+            } else {
+                bundleArchive_destroy(archive);
+                status = CELIX_DO_IF(status, bundle_destroy(bundle));
+            }
+
+            status = CELIX_DO_IF(status, framework_releaseGlobalLock(framework));
+        }
+    }
+
+
+    if (status != CELIX_SUCCESS) {
+//        module_pt module = NULL;
+//        char *symbolicName = NULL;
+//        long id = 0;
+//        bundle_getCurrentModule(bundle, &module);
+//        module_getSymbolicName(module, &symbolicName);
+//        bundle_getBundleId(bundle, &id);
+
+        framework_logIfError(framework->logger, status, error, "Cannot uninstall bundle");
+    }
+
+    return status;
+}
+
+celix_status_t fw_refreshBundles(framework_pt framework, bundle_pt bundles[], int size) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    bool locked = framework_acquireGlobalLock(framework);
+    if (!locked) {
+        framework_releaseGlobalLock(framework);
+        status = CELIX_ILLEGAL_STATE;
+    } else {
+		hash_map_values_pt values;
+        bundle_pt *newTargets;
+        unsigned int nrofvalues;
+		bool restart = false;
+        hash_map_pt map = hashMap_create(NULL, NULL, NULL, NULL);
+        int targetIdx = 0;
+        for (targetIdx = 0; targetIdx < size; targetIdx++) {
+            bundle_pt bundle = bundles[targetIdx];
+            hashMap_put(map, bundle, bundle);
+            fw_populateDependentGraph(framework, bundle, &map);
+        }
+        values = hashMapValues_create(map);
+        hashMapValues_toArray(values, (void ***) &newTargets, &nrofvalues);
+        hashMapValues_destroy(values);
+
+        hashMap_destroy(map, false, false);
+
+        if (newTargets != NULL) {
+            int i = 0;
+			struct fw_refreshHelper * helpers;
+            for (i = 0; i < nrofvalues && !restart; i++) {
+                bundle_pt bundle = (bundle_pt) newTargets[i];
+                if (framework->bundle == bundle) {
+                    restart = true;
+                }
+            }
+
+            helpers = (struct fw_refreshHelper * )malloc(nrofvalues * sizeof(struct fw_refreshHelper));
+            for (i = 0; i < nrofvalues && !restart; i++) {
+                bundle_pt bundle = (bundle_pt) newTargets[i];
+                helpers[i].framework = framework;
+                helpers[i].bundle = bundle;
+                helpers[i].oldState = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
+            }
+
+            for (i = 0; i < nrofvalues; i++) {
+                struct fw_refreshHelper helper = helpers[i];
+                fw_refreshHelper_stop(&helper);
+                fw_refreshHelper_refreshOrRemove(&helper);
+            }
+
+            for (i = 0; i < nrofvalues; i++) {
+                struct fw_refreshHelper helper = helpers[i];
+                fw_refreshHelper_restart(&helper);
+            }
+
+            if (restart) {
+                bundle_update(framework->bundle, NULL);
+            }
+			free(helpers);
+			free(newTargets);
+        }
+
+        framework_releaseGlobalLock(framework);
+    }
+
+    framework_logIfError(framework->logger, status, NULL, "Cannot refresh bundles");
+
+    return status;
+}
+
+celix_status_t fw_refreshBundle(framework_pt framework, bundle_pt bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+    bundle_state_e state;
+
+    status = framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED | OSGI_FRAMEWORK_BUNDLE_RESOLVED);
+    if (status != CELIX_SUCCESS) {
+        printf("Cannot refresh bundle");
+        framework_releaseBundleLock(framework, bundle);
+    } else {
+    	bool fire;
+		bundle_getState(bundle, &state);
+        fire = (state != OSGI_FRAMEWORK_BUNDLE_INSTALLED);
+        bundle_refresh(bundle);
+
+        if (fire) {
+            framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
+            fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle);
+        }
+
+        framework_releaseBundleLock(framework, bundle);
+    }
+
+    framework_logIfError(framework->logger, status, NULL, "Cannot refresh bundle");
+
+    return status;
+}
+
+celix_status_t fw_refreshHelper_stop(struct fw_refreshHelper * refreshHelper) {
+	bundle_state_e state;
+	bundle_getState(refreshHelper->bundle, &state);
+    if (state == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
+        refreshHelper->oldState = OSGI_FRAMEWORK_BUNDLE_ACTIVE;
+        fw_stopBundle(refreshHelper->framework, refreshHelper->bundle, false);
+    }
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t fw_refreshHelper_refreshOrRemove(struct fw_refreshHelper * refreshHelper) {
+	bundle_state_e state;
+	bundle_getState(refreshHelper->bundle, &state);
+    if (state == OSGI_FRAMEWORK_BUNDLE_UNINSTALLED) {
+        bundle_closeAndDelete(refreshHelper->bundle);
+        refreshHelper->bundle = NULL;
+    } else {
+        fw_refreshBundle(refreshHelper->framework, refreshHelper->bundle);
+    }
+    return CELIX_SUCCESS;
+}
+
+celix_status_t fw_refreshHelper_restart(struct fw_refreshHelper * refreshHelper) {
+    if ((refreshHelper->bundle != NULL) && (refreshHelper->oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE)) {
+        fw_startBundle(refreshHelper->framework, refreshHelper->bundle, 0);
+    }
+    return CELIX_SUCCESS;
+}
+
+celix_status_t fw_getDependentBundles(framework_pt framework, bundle_pt exporter, array_list_pt *list) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (*list != NULL || exporter == NULL || framework == NULL) {
+	return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+	 array_list_pt modules;
+	 unsigned int modIdx = 0;
+	 arrayList_create(list);
+
+	 modules = bundle_getModules(exporter);
+	 for (modIdx = 0; modIdx < arrayList_size(modules); modIdx++) {
+				module_pt module = (module_pt) arrayList_get(modules, modIdx);
+				array_list_pt dependents = module_getDependents(module);
+			if(dependents!=NULL){
+					unsigned int depIdx = 0;
+					for (depIdx = 0; depIdx < arrayList_size(dependents); depIdx++) {
+							  module_pt dependent = (module_pt) arrayList_get(dependents, depIdx);
+							  arrayList_add(*list, module_getBundle(dependent));
+					}
+					arrayList_destroy(dependents);
+				}
+	 }
+
+    framework_logIfError(framework->logger, status, NULL, "Cannot get dependent bundles");
+
+    return status;
+}
+
+celix_status_t fw_populateDependentGraph(framework_pt framework, bundle_pt exporter, hash_map_pt *map) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if(framework == NULL || exporter == NULL){
+	return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    array_list_pt dependents = NULL;
+    if ((status = fw_getDependentBundles(framework, exporter, &dependents)) == CELIX_SUCCESS) {
+		  if(dependents!=NULL){
+         unsigned int depIdx = 0;
+		for (depIdx = 0; depIdx < arrayList_size(dependents); depIdx++) {
+		    if (!hashMap_containsKey(*map, arrayList_get(dependents, depIdx))) {
+		        hashMap_put(*map, arrayList_get(dependents, depIdx), arrayList_get(dependents, depIdx));
+		        fw_populateDependentGraph(framework, (bundle_pt) arrayList_get(dependents, depIdx), map);
+		    }
+		}
+		arrayList_destroy(dependents);
+		  }
+    }
+
+    framework_logIfError(framework->logger, status, NULL, "Cannot populate dependent graph");
+
+    return status;
+}
+
+celix_status_t fw_registerService(framework_pt framework, service_registration_pt *registration, bundle_pt bundle, const char* serviceName, const void* svcObj, properties_pt properties) {
+	celix_status_t status = CELIX_SUCCESS;
+	char *error = NULL;
+	if (serviceName == NULL || svcObj == NULL) {
+	    status = CELIX_ILLEGAL_ARGUMENT;
+	    error = "ServiceName and SvcObj cannot be null";
+	}
+
+	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+	status = CELIX_DO_IF(status, serviceRegistry_registerService(framework->registry, bundle, serviceName, svcObj, properties, registration));
+	bool res = framework_releaseBundleLock(framework, bundle);
+	if (!res) {
+	    status = CELIX_ILLEGAL_STATE;
+	    error = "Could not release bundle lock";
+	}
+
+	if (status == CELIX_SUCCESS) {
+	    // If this is a listener hook, invoke the callback with all current listeners
+        if (strcmp(serviceName, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME) == 0) {
+            unsigned int i;
+            array_list_pt infos = NULL;
+            service_reference_pt ref = NULL;
+            listener_hook_service_pt hook = NULL;
+
+            status = CELIX_DO_IF(status, arrayList_create(&infos));
+
+            if (status == CELIX_SUCCESS) {
+                celix_status_t subs = CELIX_SUCCESS;
+
+                for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
+                    fw_service_listener_pt listener =(fw_service_listener_pt) arrayList_get(framework->serviceListeners, i);
+                    bundle_context_pt context = NULL;
+                    listener_hook_info_pt info = NULL;
+                    bundle_context_pt lContext = NULL;
+
+                    subs = CELIX_DO_IF(subs, bundle_getContext(bundle, &context));
+                    if (subs == CELIX_SUCCESS) {
+                        info = (listener_hook_info_pt) malloc(sizeof(*info));
+                        if (info == NULL) {
+                            subs = CELIX_ENOMEM;
+                        }
+                    }
+
+                    subs = CELIX_DO_IF(subs, bundle_getContext(listener->bundle, &lContext));
+                    if (subs == CELIX_SUCCESS) {
+                        info->context = lContext;
+                        info->removed = false;
+                    }
+                    subs = CELIX_DO_IF(subs, filter_getString(listener->filter, (const char**)&info->filter));
+
+                    if (subs == CELIX_SUCCESS) {
+                        arrayList_add(infos, info);
+                    }
+                    else{
+                        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not pass all listeners to the hook: %s", serviceName);
+                        free(info);
+                    }
+                }
+
+                status = CELIX_DO_IF(status, serviceRegistry_getServiceReference(framework->registry, framework->bundle,
+                                                                                 *registration, &ref));
+                status = CELIX_DO_IF(status, fw_getService(framework,framework->bundle, ref, (const void **) &hook));
+                if (status == CELIX_SUCCESS) {
+                    hook->added(hook->handle, infos);
+                }
+                status = CELIX_DO_IF(status, serviceRegistry_ungetService(framework->registry, framework->bundle, ref, NULL));
+                status = CELIX_DO_IF(status, serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref));
+
+                int i = 0;
+                for (i = 0; i < arrayList_size(infos); i++) {
+                    listener_hook_info_pt info = arrayList_get(infos, i);
+                    free(info);
+                }
+                arrayList_destroy(infos);
+             }
+        }
+	}
+
+    framework_logIfError(framework->logger, status, error, "Cannot register service: %s", serviceName);
+
+	return status;
+}
+
+celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt *registration, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt properties) {
+    celix_status_t status = CELIX_SUCCESS;
+    char *error = NULL;
+	if (serviceName == NULL || factory == NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+        error = "Service name and factory cannot be null";
+    }
+
+	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+	status = CELIX_DO_IF(status, serviceRegistry_registerServiceFactory(framework->registry, bundle, serviceName, factory, properties, registration));
+    if (!framework_releaseBundleLock(framework, bundle)) {
+        status = CELIX_ILLEGAL_STATE;
+        error = "Could not release bundle lock";
+    }
+
+    framework_logIfError(framework->logger, status, error, "Cannot register service factory: %s", serviceName);
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *references, bundle_pt bundle, const char * serviceName, const char * sfilter) {
+    celix_status_t status = CELIX_SUCCESS;
+
+	filter_pt filter = NULL;
+	unsigned int refIdx = 0;
+
+    if (sfilter != NULL) {
+        filter = filter_create(sfilter);
+	}
+
+	status = CELIX_DO_IF(status, serviceRegistry_getServiceReferences(framework->registry, bundle, serviceName, filter, references));
+
+	if (filter != NULL) {
+		filter_destroy(filter);
+	}
+
+	if (status == CELIX_SUCCESS) {
+        for (refIdx = 0; (*references != NULL) && refIdx < arrayList_size(*references); refIdx++) {
+            service_reference_pt ref = (service_reference_pt) arrayList_get(*references, refIdx);
+            service_registration_pt reg = NULL;
+            const char* serviceName;
+            properties_pt props = NULL;
+            status = CELIX_DO_IF(status, serviceReference_getServiceRegistration(ref, &reg));
+            status = CELIX_DO_IF(status, serviceRegistration_getProperties(reg, &props));
+            if (status == CELIX_SUCCESS) {
+                serviceName = properties_get(props, OSGI_FRAMEWORK_OBJECTCLASS);
+                if (!serviceReference_isAssignableTo(ref, bundle, serviceName)) {
+                    arrayList_remove(*references, refIdx);
+                    refIdx--;
+                }
+            }
+        }
+	}
+
+	framework_logIfError(framework->logger, status, NULL, "Failed to get service references");
+
+	return status;
+}
+
+celix_status_t framework_ungetServiceReference(framework_pt framework, bundle_pt bundle, service_reference_pt reference) {
+    return serviceRegistry_ungetServiceReference(framework->registry, bundle, reference);
+}
+
+celix_status_t fw_getService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, const void **service) {
+	return serviceRegistry_getService(framework->registry, bundle, reference, service);
+}
+
+celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, array_list_pt *services) {
+	return serviceRegistry_getRegisteredServices(framework->registry, bundle, services);
+}
+
+celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, array_list_pt *services) {
+	celix_status_t status = CELIX_SUCCESS;
+	status = serviceRegistry_getServicesInUse(framework->registry, bundle, services);
+	return status;
+}
+
+celix_status_t framework_ungetService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, bool *result) {
+	return serviceRegistry_ungetService(framework->registry, bundle, reference, result);
+}
+
+void fw_addServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener, const char* sfilter) {
+	array_list_pt listenerHooks = NULL;
+	listener_hook_info_pt info;
+	unsigned int i;
+
+	fw_service_listener_pt fwListener = (fw_service_listener_pt) calloc(1, sizeof(*fwListener));
+	bundle_context_pt context = NULL;
+
+	fwListener->bundle = bundle;
+    arrayList_create(&fwListener->retainedReferences);
+	if (sfilter != NULL) {
+		filter_pt filter = filter_create(sfilter);
+		fwListener->filter = filter;
+	} else {
+		fwListener->filter = NULL;
+	}
+	fwListener->listener = listener;
+
+	arrayList_add(framework->serviceListeners, fwListener);
+
+	serviceRegistry_getListenerHooks(framework->registry, framework->bundle, &listenerHooks);
+
+	info = (listener_hook_info_pt) malloc(sizeof(*info));
+
+	bundle_getContext(bundle, &context);
+	info->context = context;
+
+	info->removed = false;
+	info->filter = sfilter == NULL ? NULL : strdup(sfilter);
+
+	for (i = 0; i < arrayList_size(listenerHooks); i++) {
+		service_reference_pt ref = (service_reference_pt) arrayList_get(listenerHooks, i);
+		listener_hook_service_pt hook = NULL;
+		array_list_pt infos = NULL;
+		bool ungetResult = false;
+
+		fw_getService(framework, framework->bundle, ref, (const void **) &hook);
+
+		arrayList_create(&infos);
+		arrayList_add(infos, info);
+		hook->added(hook->handle, infos);
+		serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
+		serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
+		arrayList_destroy(infos);
+	}
+
+	if (info->filter != NULL) {
+	    free(info->filter);
+	}
+	free(info);
+
+	arrayList_destroy(listenerHooks);
+}
+
+void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener) {
+	listener_hook_info_pt info = NULL;
+	unsigned int i;
+	fw_service_listener_pt element;
+
+	bundle_context_pt context;
+	bundle_getContext(bundle, &context);
+
+	for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
+		element = (fw_service_listener_pt) arrayList_get(framework->serviceListeners, i);
+		if (element->listener == listener && element->bundle == bundle) {
+			bundle_context_pt lContext = NULL;
+
+			info = (listener_hook_info_pt) malloc(sizeof(*info));
+
+			bundle_getContext(element->bundle, &lContext);
+			info->context = lContext;
+
+			// TODO Filter toString;
+			filter_getString(element->filter, (const char**)&info->filter);
+			info->removed = true;
+
+			arrayList_remove(framework->serviceListeners, i);
+			i--;
+            
+            //unregistering retained service references. For these refs a unregister event will not be triggered.
+            int k;
+            int rSize = arrayList_size(element->retainedReferences);
+            for (k = 0; k < rSize; k += 1) {
+                service_reference_pt ref = arrayList_get(element->retainedReferences, k);
+                if (ref != NULL) {
+                    serviceRegistry_ungetServiceReference(framework->registry, element->bundle, ref); // decrease retain counter                                       
+                } 
+            }
+
+			element->bundle = NULL;
+			filter_destroy(element->filter);
+            arrayList_destroy(element->retainedReferences);
+			element->filter = NULL;
+			element->listener = NULL;
+			free(element);
+			element = NULL;
+			break;
+		}
+	}
+
+	if (info != NULL) {
+		unsigned int i;
+		array_list_pt listenerHooks = NULL;
+		serviceRegistry_getListenerHooks(framework->registry, framework->bundle, &listenerHooks);
+
+		for (i = 0; i < arrayList_size(listenerHooks); i++) {
+			service_reference_pt ref = (service_reference_pt) arrayList_get(listenerHooks, i);
+			listener_hook_service_pt hook = NULL;
+			array_list_pt infos = NULL;
+			bool ungetResult;
+
+			fw_getService(framework, framework->bundle, ref, (const void **) &hook);
+
+			arrayList_create(&infos);
+			arrayList_add(infos, info);
+			hook->removed(hook->handle, infos);
+			serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
+			serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
+			arrayList_destroy(infos);
+		}
+
+		arrayList_destroy(listenerHooks);
+        free(info);
+	}
+}
+
+celix_status_t fw_addBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener) {
+	celix_status_t status = CELIX_SUCCESS;
+	fw_bundle_listener_pt bundleListener = NULL;
+
+	bundleListener = (fw_bundle_listener_pt) malloc(sizeof(*bundleListener));
+	if (!bundleListener) {
+		status = CELIX_ENOMEM;
+	} else {
+		bundleListener->listener = listener;
+		bundleListener->bundle = bundle;
+
+		if (celixThreadMutex_lock(&framework->bundleListenerLock) != CELIX_SUCCESS) {
+			status = CELIX_FRAMEWORK_EXCEPTION;
+		} else {
+			arrayList_add(framework->bundleListeners, bundleListener);
+
+			if (celixThreadMutex_unlock(&framework->bundleListenerLock)) {
+				status = CELIX_FRAMEWORK_EXCEPTION;
+			}
+		}
+	}
+
+	framework_logIfError(framework->logger, status, NULL, "Failed to add bundle listener");
+
+	return status;
+}
+
+celix_status_t fw_removeBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	unsigned int i;
+	fw_bundle_listener_pt bundleListener;
+
+	if (celixThreadMutex_lock(&framework->bundleListenerLock) != CELIX_SUCCESS) {
+		status = CELIX_FRAMEWORK_EXCEPTION;
+	}
+	else {
+		for (i = 0; i < arrayList_size(framework->bundleListeners); i++) {
+			bundleListener = (fw_bundle_listener_pt) arrayList_get(framework->bundleListeners, i);
+			if (bundleListener->listener == listener && bundleListener->bundle == bundle) {
+				arrayList_remove(framework->bundleListeners, i);
+
+				bundleListener->bundle = NULL;
+				bundleListener->listener = NULL;
+				free(bundleListener);
+			}
+		}
+		if (celixThreadMutex_unlock(&framework->bundleListenerLock)) {
+			status = CELIX_FRAMEWORK_EXCEPTION;
+		}
+	}
+
+	framework_logIfError(framework->logger, status, NULL, "Failed to remove bundle listener");
+
+	return status;
+}
+
+celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener) {
+	celix_status_t status = CELIX_SUCCESS;
+	fw_framework_listener_pt frameworkListener = NULL;
+
+	frameworkListener = (fw_framework_listener_pt) malloc(sizeof(*frameworkListener));
+	if (!frameworkListener) {
+		status = CELIX_ENOMEM;
+	} else {
+		frameworkListener->listener = listener;
+		frameworkListener->bundle = bundle;
+
+		arrayList_add(framework->frameworkListeners, frameworkListener);
+	}
+
+	framework_logIfError(framework->logger, status, NULL, "Failed to add framework listener");
+
+	return status;
+}
+
+celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	unsigned int i;
+	fw_framework_listener_pt frameworkListener;
+
+	for (i = 0; i < arrayList_size(framework->frameworkListeners); i++) {
+		frameworkListener = (fw_framework_listener_pt) arrayList_get(framework->frameworkListeners, i);
+		if (frameworkListener->listener == listener && frameworkListener->bundle == bundle) {
+			arrayList_remove(framework->frameworkListeners, i);
+
+			frameworkListener->bundle = NULL;
+            frameworkListener->listener = NULL;
+            free(frameworkListener);
+		}
+	}
+
+	framework_logIfError(framework->logger, status, NULL, "Failed to remove framework listener");
+
+	return status;
+}
+
+void fw_serviceChanged(framework_pt framework, service_event_type_e eventType, service_registration_pt registration, properties_pt oldprops) {
+    unsigned int i;
+    fw_service_listener_pt element;
+
+    if (arrayList_size(framework->serviceListeners) > 0) {
+        for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
+            int matched = 0;
+            properties_pt props = NULL;
+            bool matchResult = false;
+
+            element = (fw_service_listener_pt) arrayList_get(framework->serviceListeners, i);
+            serviceRegistration_getProperties(registration, &props);
+            if (element->filter != NULL) {
+                filter_match(element->filter, props, &matchResult);
+            }
+            matched = (element->filter == NULL) || matchResult;
+            if (matched) {
+                service_reference_pt reference = NULL;
+                service_event_pt event;
+
+                event = (service_event_pt) malloc(sizeof (*event));
+
+                serviceRegistry_getServiceReference(framework->registry, element->bundle, registration, &reference);
+                
+                //NOTE: that you are never sure that the UNREGISTERED event will by handle by an service_listener. listener could be gone
+                //Every reference retained is therefore stored and called when a service listener is removed from the framework.
+                if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED) {
+                    serviceRegistry_retainServiceReference(framework->registry, element->bundle, reference);
+                    arrayList_add(element->retainedReferences, reference); //TODO improve by using set (or hashmap) instead of list
+                }
+
+                event->type = eventType;
+                event->reference = reference;
+
+                element->listener->serviceChanged(element->listener, event);
+
+                serviceRegistry_ungetServiceReference(framework->registry, element->bundle, reference);
+                
+                if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
+                    //if service listener was active when service was registered, release the retained reference
+                    if (arrayList_removeElement(element->retainedReferences, reference)) {
+                        serviceRegistry_ungetServiceReference(framework->registry, element->bundle, reference); // decrease retain counter
+                    }
+                }
+                
+                free(event);
+
+            } else if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED) {
+                bool matchResult = false;
+                int matched = 0;
+                if (element->filter != NULL) {
+                    filter_match(element->filter, oldprops, &matchResult);
+                }
+                matched = (element->filter == NULL) || matchResult;
+                if (matched) {
+                    service_reference_pt reference = NULL;
+                    service_event_pt endmatch = (service_event_pt) malloc(sizeof (*endmatch));
+
+                    serviceRegistry_getServiceReference(framework->registry, element->bundle, registration, &reference);
+
+                    endmatch->reference = reference;
+                    endmatch->type = OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH;
+                    element->listener->serviceChanged(element->listener, endmatch);
+
+                    serviceRegistry_ungetServiceReference(framework->registry, element->bundle, reference);
+                    free(endmatch);
+
+                }
+            }
+        }
+    }
+
+}
+
+//celix_status_t fw_isServiceAssignable(framework_pt fw, bundle_pt requester, service_reference_pt reference, bool *assignable) {
+//	celix_status_t status = CELIX_SUCCESS;
+//
+//	*assignable = true;
+//	service_registration_pt registration = NULL;
+//	status = serviceReference_getServiceRegistration(reference, &registration);
+//	if (status == CELIX_SUCCESS) {
+//		char *serviceName = properties_get(registration->properties, (char *) OBJECTCLASS);
+//		if (!serviceReference_isAssignableTo(reference, requester, serviceName)) {
+//			*assignable = false;
+//		}
+//	}
+//
+//	return status;
+//}
+
+long framework_getNextBundleId(framework_pt framework) {
+	long id = framework->nextBundleId;
+	framework->nextBundleId++;
+	return id;
+}
+
+celix_status_t framework_markResolvedModules(framework_pt framework, linked_list_pt resolvedModuleWireMap) {
+	if (resolvedModuleWireMap != NULL) {
+		// hash_map_iterator_pt iterator = hashMapIterator_create(resolvedModuleWireMap);
+		linked_list_iterator_pt iterator = linkedListIterator_create(resolvedModuleWireMap, linkedList_size(resolvedModuleWireMap));
+		while (linkedListIterator_hasPrevious(iterator)) {
+		    importer_wires_pt iw = linkedListIterator_previous(iterator);
+			// hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
+			module_pt module = iw->importer;
+
+//			bundle_pt bundle = module_getBundle(module);
+//			bundle_archive_pt archive = NULL;
+//			bundle_getArchive(bundle, &archive);
+//			bundle_revision_pt revision = NULL;
+//			bundleArchive_getCurrentRevision(archive, &revision);
+//			char *root = NULL;
+//			bundleRevision_getRoot(revision, &root);
+//			manifest_pt manifest = NULL;
+//			bundleRevision_getManifest(revision, &manifest);
+//
+//			char *private = manifest_getValue(manifest, OSGI_FRAMEWORK_PRIVATE_LIBRARY);
+//			char *export = manifest_getValue(manifest, OSGI_FRAMEWORK_EXPORT_LIBRARY);
+//
+//			printf("Root %s\n", root);
+
+			// for each library update the reference to the wires, if there are any
+
+			linked_list_pt wires = iw->wires;
+
+//			linked_list_iterator_pt wit = linkedListIterator_create(wires, 0);
+//			while (linkedListIterator_hasNext(wit)) {
+//			    wire_pt wire = linkedListIterator_next(wit);
+//			    module_pt importer = NULL;
+//			    requirement_pt requirement = NULL;
+//			    module_pt exporter = NULL;
+//                capability_pt capability = NULL;
+//			    wire_getImporter(wire, &importer);
+//			    wire_getRequirement(wire, &requirement);
+//
+//			    wire_getExporter(wire, &exporter);
+//			    wire_getCapability(wire, &capability);
+//
+//			    char *importerName = NULL;
+//			    module_getSymbolicName(importer, &importerName);
+//
+//			    char *exporterName = NULL;
+//                module_getSymbolicName(exporter, &exporterName);
+//
+//                version_pt version = NULL;
+//                char *name = NULL;
+//                capability_getServiceName(capability, &name);
+//                capability_getVersion(capability, &version);
+//                char *versionString = NULL;
+//                version_toString(version, framework->mp, &versionString);
+//
+//                printf("Module %s imports library %s:%s from %s\n", importerName, name, versionString, exporterName);
+//			}
+
+			module_setWires(module, wires);
+
+			module_setResolved(module);
+			resolver_moduleResolved(module);
+
+			const char *mname = NULL;
+			module_getSymbolicName(module, &mname);
+			framework_markBundleResolved(framework, module);
+			linkedListIterator_remove(iterator);
+			free(iw);
+		}
+		linkedListIterator_destroy(iterator);
+		linkedList_destroy(resolvedModuleWireMap);
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t framework_markBundleResolved(framework_pt framework, module_pt module) {
+    celix_status_t status = CELIX_SUCCESS;
+	bundle_pt bundle = module_getBundle(module);
+	bundle_state_e state;
+	char *error = NULL;
+
+	if (bundle != NULL) {
+		framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_ACTIVE);
+		bundle_getState(bundle, &state);
+		if (state != OSGI_FRAMEWORK_BUNDLE_INSTALLED) {
+			printf("Trying to resolve a resolved bundle");
+			status = CELIX_ILLEGAL_STATE;
+		} else {
+		    // Load libraries of this module
+		    bool isSystemBundle = false;
+		    bundle_isSystemBundle(bundle, &isSystemBundle);
+		    if (!isSystemBundle) {
+                status = CELIX_DO_IF(status, framework_loadBundleLibraries(framework, bundle));
+		    }
+
+		    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_RESOLVED));
+			status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_RESOLVED, bundle));
+		}
+
+		if (status != CELIX_SUCCESS) {
+            module_pt module = NULL;
+            const char *symbolicName = NULL;
+            long id = 0;
+            module_getSymbolicName(module, &symbolicName);
+            bundle_getBundleId(bundle, &id);
+            if (error != NULL) {
+                fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]; cause: %s", symbolicName, id, error);
+            } else {
+                fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]", symbolicName, id);
+            }
+        }
+
+		framework_releaseBundleLock(framework, bundle);
+	}
+
+	return CELIX_SUCCESS;
+}
+
+array_list_pt framework_getBundles(framework_pt framework) {
+	array_list_pt bundles = NULL;
+	hash_map_iterator_pt iterator;
+	arrayList_create(&bundles);
+
+	celixThreadMutex_lock(&framework->installedBundleMapLock);
+
+	iterator = hashMapIterator_create(framework->installedBundleMap);
+	while (hashMapIterator_hasNext(iterator)) {
+		bundle_pt bundle = (bundle_pt) hashMapIterator_nextValue(iterator);
+		arrayList_add(bundles, bundle);
+	}
+	hashMapIterator_destroy(iterator);
+
+	celixThreadMutex_unlock(&framework->installedBundleMapLock);
+
+	return bundles;
+}
+
+bundle_pt framework_getBundle(framework_pt framework, const char* location) {
+	celixThreadMutex_lock(&framework->installedBundleMapLock);
+	bundle_pt bundle = (bundle_pt) hashMap_get(framework->installedBundleMap, location);
+	celixThreadMutex_unlock(&framework->installedBundleMapLock);
+	return bundle;
+}
+
+bundle_pt framework_getBundleById(framework_pt framework, long id) {
+	celixThreadMutex_lock(&framework->installedBundleMapLock);
+	hash_map_iterator_pt iter = hashMapIterator_create(framework->installedBundleMap);
+	bundle_pt bundle = NULL;
+	while (hashMapIterator_hasNext(iter)) {
+		bundle_pt b = (bundle_pt) hashMapIterator_nextValue(iter);
+		bundle_archive_pt archive = NULL;
+		long bid;
+		bundle_getArchive(b, &archive);
+		bundleArchive_getId(archive, &bid);
+		if (bid == id) {
+			bundle = b;
+			break;
+		}
+	}
+	hashMapIterator_destroy(iter);
+	celixThreadMutex_unlock(&framework->installedBundleMapLock);
+
+	return bundle;
+}
+
+celix_status_t framework_acquireInstallLock(framework_pt framework, const char * location) {
+    celixThreadMutex_lock(&framework->installRequestLock);
+
+	while (hashMap_get(framework->installRequestMap, location) != NULL) {
+	    celixThreadCondition_wait(&framework->condition, &framework->installRequestLock);
+	}
+	hashMap_put(framework->installRequestMap, (char*)location, (char*)location);
+
+	celixThreadMutex_unlock(&framework->installRequestLock);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t framework_releaseInstallLock(framework_pt framework, const char* location) {
+    celixThreadMutex_lock(&framework->installRequestLock);
+
+	hashMap_remove(framework->installRequestMap, location);
+	celixThreadCondition_broadcast(&framework->condition);
+
+	celixThreadMutex_unlock(&framework->installRequestLock);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t framework_setBundleStateAndNotify(framework_pt framework, bundle_pt bundle, int state) {
+	int ret = CELIX_SUCCESS;
+
+	int err = celixThreadMutex_lock(&framework->bundleLock);
+	if (err != 0) {
+		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to lock");
+		return CELIX_BUNDLE_EXCEPTION;
+	}
+
+	bundle_setState(bundle, state);
+	err = celixThreadCondition_broadcast(&framework->condition);
+	if (err != 0) {
+		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to broadcast");
+		ret = CELIX_BUNDLE_EXCEPTION;
+	}
+
+	err = celixThreadMutex_unlock(&framework->bundleLock);
+	if (err != 0) {
+		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to unlock");
+		return CELIX_BUNDLE_EXCEPTION;
+	}
+	return ret;
+}
+
+celix_status_t framework_acquireBundleLock(framework_pt framework, bundle_pt bundle, int desiredStates) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bool locked;
+	celix_thread_t lockingThread = celix_thread_default;
+
+	int err = celixThreadMutex_lock(&framework->bundleLock);
+	if (err != CELIX_SUCCESS) {
+		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to lock");
+		status = CELIX_BUNDLE_EXCEPTION;
+	} else {
+		bool lockable = false;
+		bool isSelf = false;
+
+		bundle_isLockable(bundle, &lockable);
+		thread_equalsSelf(framework->globalLockThread, &isSelf);
+
+		while (!lockable
+				|| (( celixThread_initalized(framework->globalLockThread) == true)
+				&& !isSelf))
+		{
+			bundle_state_e state;
+			bundle_getState(bundle, &state);
+			if ((desiredStates & state) == 0) {
+				status = CELIX_ILLEGAL_STATE;
+				break;
+			}
+
+			bundle_getLockingThread(bundle, &lockingThread);
+			if (isSelf && (celixThread_initalized(lockingThread) == true)
+					&& arrayList_contains(framework->globalLockWaitersList, &lockingThread)) {
+				framework->interrupted = true;
+//				celixThreadCondition_signal_thread_np(&framework->condition, bundle_getLockingThread(bundle));
+				celixThreadCondition_signal(&framework->condition);
+			}
+
+            celixThreadCondition_wait(&framework->condition, &framework->bundleLock);
+
+			status = bundle_isLockable(bundle, &lockable);
+			if (status != CELIX_SUCCESS) {
+				break;
+			}
+	}
+
+		if (status == CELIX_SUCCESS) {
+			bundle_state_e state;
+			bundle_getState(bundle, &state);
+			if ((desiredStates & state) == 0) {
+				status = CELIX_ILLEGAL_STATE;
+			} else {
+				if (bundle_lock(bundle, &locked)) {
+					if (!locked) {
+						status = CELIX_ILLEGAL_STATE;
+					}
+				}
+			}
+		}
+		celixThreadMutex_unlock(&framework->bundleLock);
+	}
+
+	framework_logIfError(framework->logger, status, NULL, "Failed to get bundle lock");
+
+	return status;
+}
+
+bool framework_releaseBundleLock(framework_pt framework, bundle_pt bundle) {
+    bool unlocked;
+    celix_thread_t lockingThread = celix_thread_default;
+
+    celixThreadMutex_lock(&framework->bundleLock);
+
+    bundle_unlock(bundle, &unlocked);
+	if (!unlocked) {
+	    celixThreadMutex_unlock(&framework->bundleLock);
+		return false;
+	}
+	bundle_getLockingThread(bundle, &lockingThread);
+	if (celixThread_initalized(lockingThread) == false) {
+	    celixThreadCondition_broadcast(&framework->condition);
+	}
+
+	celixThreadMutex_unlock(&framework->bundleLock);
+
+	return true;
+}
+
+bool framework_acquireGlobalLock(framework_pt framework) {
+    bool interrupted = false;
+	bool isSelf = false;
+
+	celixThreadMutex_lock(&framework->bundleLock);
+
+	thread_equalsSelf(framework->globalLockThread, &isSelf);
+
+	while (!interrupted
+			&& (celixThread_initalized(framework->globalLockThread) == true)
+			&& (!isSelf)) {
+		celix_thread_t currentThread = celixThread_self();
+		arrayList_add(framework->globalLockWaitersList, &currentThread);
+		celixThreadCondition_broadcast(&framework->condition);
+
+		celixThreadCondition_wait(&framework->condition, &framework->bundleLock);
+		if (framework->interrupted) {
+			interrupted = true;
+			framework->interrupted = false;
+		}
+
+		arrayList_removeElement(framework->globalLockWaitersList, &currentThread);
+	}
+
+	if (!interrupted) {
+		framework->globalLockCount++;
+		framework->globalLockThread = celixThread_self();
+	}
+
+	celixThreadMutex_unlock(&framework->bundleLock);
+
+	return !interrupted;
+}
+
+celix_status_t framework_releaseGlobalLock(framework_pt framework) {
+	int status = CELIX_SUCCESS;
+	if (celixThreadMutex_lock(&framework->bundleLock) != 0) {
+		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking framework bundle lock");
+		return CELIX_FRAMEWORK_EXCEPTION;
+	}
+
+	if (celixThread_equals(framework->globalLockThread, celixThread_self())) {
+		framework->globalLockCount--;
+		if (framework->globalLockCount == 0) {
+			framework->globalLockThread = celix_thread_default;
+ 			if (celixThreadCondition_broadcast(&framework->condition) != 0) {
+				fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to broadcast global lock release.");
+				status = CELIX_FRAMEWORK_EXCEPTION;
+				// still need to unlock before returning
+			}
+		}
+	} else {
+		printf("The current thread does not own the global lock");
+	}
+
+	if (celixThreadMutex_unlock(&framework->bundleLock) != 0) {
+		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking framework bundle lock");
+		return CELIX_FRAMEWORK_EXCEPTION;
+	}
+
+	framework_logIfError(framework->logger, status, NULL, "Failed to release global lock");
+
+	return status;
+}
+
+celix_status_t framework_waitForStop(framework_pt framework) {
+	if (celixThreadMutex_lock(&framework->mutex) != 0) {
+		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error locking the framework, shutdown gate not set.");
+		return CELIX_FRAMEWORK_EXCEPTION;
+	}
+	while (!framework->shutdown) {
+	    celix_status_t status = celixThreadCondition_wait(&framework->shutdownGate, &framework->mutex);
+		if (status != 0) {
+			fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error waiting for shutdown gate.");
+			return CELIX_FRAMEWORK_EXCEPTION;
+		}
+	}
+	if (celixThreadMutex_unlock(&framework->mutex) != 0) {
+		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error unlocking the framework.");
+		return CELIX_FRAMEWORK_EXCEPTION;
+	}
+
+	celixThread_join(framework->shutdownThread, NULL);
+
+	fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Successful shutdown");
+	return CELIX_SUCCESS;
+}
+
+static void *framework_shutdown(void *framework) {
+	framework_pt fw = (framework_pt) framework;
+	int err;
+
+	fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown");
+	celixThreadMutex_lock(&fw->installedBundleMapLock);
+
+	hash_map_iterator_pt iter = hashMapIterator_create(fw->installedBundleMap);
+	bundle_pt bundle = NULL;
+	while ((bundle = hashMapIterator_nextValue(iter)) != NULL) {
+        bundle_state_e state;
+        bundle_getState(bundle, &state);
+        if (state == OSGI_FRAMEWORK_BUNDLE_ACTIVE || state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
+            celixThreadMutex_unlock(&fw->installedBundleMapLock);
+            fw_stopBundle(fw, bundle, 0);
+            celixThreadMutex_lock(&fw->installedBundleMapLock);
+            hashMapIterator_destroy(iter);
+            iter = hashMapIterator_create(fw->installedBundleMap);
+        }
+	}
+    hashMapIterator_destroy(iter);
+
+    iter = hashMapIterator_create(fw->installedBundleMap);
+	bundle = NULL;
+	while ((bundle = hashMapIterator_nextValue(iter)) != NULL) {
+		bundle_close(bundle);
+	}
+	hashMapIterator_destroy(iter);
+	celixThreadMutex_unlock(&fw->installedBundleMapLock);
+
+    err = celixThreadMutex_lock(&fw->mutex);
+    if (err != 0) {
+        fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking the framework, cannot exit clean.");
+        celixThread_exit(NULL);
+        return NULL;
+    }
+
+	if (celixThreadMutex_lock(&fw->dispatcherLock) != CELIX_SUCCESS) {
+		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error locking the dispatcherThread.");
+	}
+	else {
+		fw->shutdown = true;
+
+		if (celixThreadCondition_broadcast(&fw->dispatcher)) {
+			fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error broadcasting .");
+		}
+
+		if (celixThreadMutex_unlock(&fw->dispatcherLock)) {
+			fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error unlocking the dispatcherThread.");
+		}
+
+		celixThread_join(fw->dispatcherThread, NULL);
+	}
+
+
+	err = celixThreadCondition_broadcast(&fw->shutdownGate);
+	if (err != 0) {
+		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error waking the shutdown gate, cannot exit clean.");
+		err = celixThreadMutex_unlock(&fw->mutex);
+		if (err != 0) {
+			fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot exit clean.");
+		}
+
+		celixThread_exit(NULL);
+		return NULL;
+	}
+	err = celixThreadMutex_unlock(&fw->mutex);
+	if (err != 0) {
+//		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot exit clean.");
+	}
+
+//	fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown done\n");
+	celixThread_exit((void *) CELIX_SUCCESS);
+
+	return NULL;
+}
+
+celix_status_t framework_getFrameworkBundle(framework_pt framework, bundle_pt *bundle) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (framework != NULL && *bundle == NULL) {
+		*bundle = framework->bundle;
+	} else {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	return status;
+}
+
+celix_status_t fw_fireBundleEvent(framework_pt framework, bundle_event_type_e eventType, bundle_pt bundle) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if ((eventType != OSGI_FRAMEWORK_BUNDLE_EVENT_STARTING)
+			&& (eventType != OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING)
+			&& (eventType != OSGI_FRAMEWORK_BUNDLE_EVENT_LAZY_ACTIVATION)) {
+		request_pt request = (request_pt) calloc(1, sizeof(*request));
+		if (!request) {
+			status = CELIX_ENOMEM;
+        } else {
+            bundle_archive_pt archive = NULL;
+            module_pt module = NULL;
+
+            request->eventType = eventType;
+            request->filter = NULL;
+            request->listeners = framework->bundleListeners;
+            request->type = BUNDLE_EVENT_TYPE;
+            request->error = NULL;
+            request->bundleId = -1;
+
+            status = bundle_getArchive(bundle, &archive);
+
+            if (status == CELIX_SUCCESS) {
+                long bundleId;
+
+                status = bundleArchive_getId(archive, &bundleId);
+
+                if (status == CELIX_SUCCESS) {
+                    request->bundleId = bundleId;
+                }
+            }
+
+            if (status == CELIX_SUCCESS) {
+                status = bundle_getCurrentModule(bundle, &module);
+
+                if (status == CELIX_SUCCESS) {
+                    const char *symbolicName = NULL;
+                    status = module_getSymbolicName(module, &symbolicName);
+                    if (status == CELIX_SUCCESS) {
+                        request->bundleSymbolicName = strdup(symbolicName);
+                    }
+                }
+            }
+
+            if (celixThreadMutex_lock(&framework->dispatcherLock) != CELIX_SUCCESS) {
+                status = CELIX_FRAMEWORK_EXCEPTION;
+            } else {
+                arrayList_add(framework->requests, request);
+

<TRUNCATED>

[27/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
index 2ded2fb..a92910c 100644
--- a/framework/CMakeLists.txt
+++ b/framework/CMakeLists.txt
@@ -15,213 +15,197 @@
 # specific language governing permissions and limitations
 # under the License.
 
-celix_subproject(FRAMEWORK "Option to build the framework shared library" "ON" DEPS UTILS)
-if (FRAMEWORK) 
-    cmake_minimum_required(VERSION 2.6)
-    
-    find_package(ZLIB REQUIRED)
-    find_package(UUID REQUIRED)
-    find_package(CURL REQUIRED)
-
-    include(CPackComponent)
-    
-    #cpack_add_component(framework
-    #	DISPLAY_NAME Framework
-    #    DESCRIPTION "The Apache Celix framework library"
-    #    REQUIRED
-    #)
-
-    #TODO setup intall framework
-    #CELIX_ADD_COMPONENT(framework
-    #	DISPLAY_NAME Framework
-    #    DESCRIPTION "The Apache Celix framework library"
-    #    GROUP all
-    #)
-    
-    add_definitions(-DUSE_FILE32API)
-    include_directories(${ZLIB_INCLUDE_DIR})
-    include_directories(${CURL_INCLUDE_DIR})
-    include_directories(${UUID_INCLUDE_DIR})
-    include_directories("private/include")
-    include_directories("public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-
-	if(WIN32)
-	  set(IO private/src/iowin32.c)
-	endif(WIN32)
-
-    add_library(celix_framework SHARED
-	 private/src/attribute.c private/src/bundle.c private/src/bundle_archive.c private/src/bundle_cache.c
-	 private/src/bundle_context.c private/src/bundle_revision.c private/src/capability.c private/src/celix_errorcodes.c
-	 private/src/filter.c private/src/framework.c private/src/manifest.c private/src/ioapi.c
-	 private/src/manifest_parser.c private/src/miniunz.c private/src/module.c  
-	 private/src/requirement.c private/src/resolver.c private/src/service_reference.c private/src/service_registration.c 
-	 private/src/service_registry.c private/src/service_tracker.c private/src/service_tracker_customizer.c
-	 private/src/unzip.c private/src/wire.c
-	 private/src/celix_log.c private/src/celix_launcher.c
-
-	 private/include/attribute.h public/include/framework_exports.h
-
-	 public/include/bundle_context.h public/include/bundle.h
-	 public/include/bundle_activator.h public/include/service_registration.h public/include/service_reference.h
-	 public/include/bundle_archive.h public/include/module.h public/include/service_tracker.h
-	 public/include/service_tracker_customizer.h public/include/requirement.h
-	 
-		${IO}
-	 
-	)
-    set_target_properties(celix_framework PROPERTIES "SOVERSION" 2)
-	if(NOT APPLE)
-      set(UUID ${UUID_LIBRARY})
-    endif()
-    target_link_libraries(celix_framework celix_utils ${UUID} ${ZLIB_LIBRARY} ${CURL_LIBRARIES})
-
-    install(TARGETS celix_framework DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework)
-    FILE(GLOB files "public/include/*.h")
-    INSTALL(FILES ${files} DESTINATION include/celix COMPONENT framework)
-    INSTALL(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/" DESTINATION share/celix/cmake/modules COMPONENT framework) 
-
-
-    if (ENABLE_TESTING)
-        find_package(CppUTest REQUIRED)
-        include_directories(${CPPUTEST_INCLUDE_DIR})
-        add_subdirectory(tst)
-    endif()
-
-
-	celix_subproject(FRAMEWORK_TESTS "Option to build the framework tests" "OFF" DEPS)
-    if (ENABLE_TESTING AND FRAMEWORK_TESTS)
-    	find_package(CppUTest REQUIRED)
-    	
-	    include_directories(${CPPUTEST_INCLUDE_DIR})
-	    include_directories(${CPPUTEST_EXT_INCLUDE_DIR})
-	    include_directories(${PROJECT_SOURCE_DIR}/utils/private/include)
-	    
-        add_executable(attribute_test 
-            private/test/attribute_test.cpp
-            private/src/attribute.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(attribute_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-        
+find_package(ZLIB REQUIRED)
+find_package(UUID REQUIRED)
+find_package(CURL REQUIRED)
+
+if(WIN32)
+    set(IO src/iowin32.c)
+endif(WIN32)
+
+set(SOURCES
+        src/attribute.c src/bundle.c src/bundle_archive.c src/bundle_cache.c
+        src/bundle_context.c src/bundle_revision.c src/capability.c src/celix_errorcodes.c
+        src/filter.c src/framework.c src/manifest.c src/ioapi.c
+        src/manifest_parser.c src/miniunz.c src/module.c
+        src/requirement.c src/resolver.c src/service_reference.c src/service_registration.c
+        src/service_registry.c src/service_tracker.c src/service_tracker_customizer.c
+        src/unzip.c src/wire.c
+        src/celix_log.c src/celix_launcher.c
+        ${IO}
+)
+add_library(framework SHARED ${SOURCES})
+set_target_properties(framework PROPERTIES OUTPUT_NAME "celix_framework")
+target_include_directories(framework PUBLIC include)
+target_include_directories(framework PRIVATE
+        src
+        ${ZLIB_INCLUDE_DIR}
+        ${CURL_INCLUDE_DIR}
+        ${UUID_INCLUDE_DIR}
+)
+target_compile_definitions(framework PRIVATE -DUSE_FILE32API)
+
+include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+set_target_properties(framework PROPERTIES "SOVERSION" 2)
+
+if(NOT APPLE)
+  set(UUID ${UUID_LIBRARY})
+endif()
+target_link_libraries(framework PUBLIC Celix::utils)
+target_link_libraries(framework PRIVATE ${UUID} ${ZLIB_LIBRARY} ${CURL_LIBRARIES})
+
+install(TARGETS framework DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework)
+
+#Alias setup to match external usage
+add_library(Celix::framework ALIAS framework)
+
+install(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/" DESTINATION share/celix/cmake/modules
+        COMPONENT framework
+        PATTERN "CMakeCelix-local.cmake" EXCLUDE
+)
+
+
+if (ENABLE_TESTING)
+    find_package(CppUTest REQUIRED)
+    include_directories(${CPPUTEST_INCLUDE_DIR})
+    add_subdirectory(tst)
+endif()
+
+
+celix_subproject(FRAMEWORK_TESTS "Option to build the framework tests" "OFF" DEPS)
+if (ENABLE_TESTING AND FRAMEWORK_TESTS)
+    find_package(CppUTest REQUIRED)
+
+    include_directories(${CPPUTEST_INCLUDE_DIR})
+    include_directories(${CPPUTEST_EXT_INCLUDE_DIR})
+    include_directories(include src)
+
+
+    add_executable(attribute_test
+        private/test/attribute_test.cpp
+        src/attribute.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(attribute_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
 #        add_executable(bundle_archive_test 
 #            private/mock/celix_log_mock.c
 #            private/test/bundle_archive_test.cpp
-#            private/src/bundle_revision.c
-#            private/src/manifest.c
-#            private/src/miniunz.c
-#            private/src/unzip.c
-#            private/src/ioapi.c
-#            private/src/properties.c
-#            private/src/bundle_archive.c
-#            private/src/celix_errorcodes.c
-#            private/src/utils.c)
-#        target_link_libraries(bundle_archive_test celix_utils ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} ${ZLIB_LIBRARY} pthread)
-        
-        
-        add_executable(bundle_cache_test 
-            private/test/bundle_cache_test.cpp
-            private/mock/bundle_archive_mock.c
-            private/mock/properties_mock.c
-            private/src/bundle_cache.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(bundle_cache_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-        add_executable(bundle_context_test 
-            private/test/bundle_context_test.cpp
-            private/mock/bundle_mock.c
-            private/mock/framework_mock.c
-            private/mock/service_registry_mock.c
-            private/src/bundle_context.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(bundle_context_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-        add_executable(bundle_revision_test 
-            private/test/bundle_revision_test.cpp
-            private/mock/miniunz_mock.c
-            private/mock/manifest_mock.c
-            private/src/bundle_revision.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(bundle_revision_test ${ZLIB_LIBRARY} ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-        add_executable(bundle_test 
-            private/test/bundle_test.cpp
-            private/mock/framework_mock.c
-            private/mock/module_mock.c
-            private/mock/bundle_archive_mock.c
-            private/mock/bundle_revision_mock.c
-            private/mock/resolver_mock.c
-            private/mock/version_mock.c
-            private/src/bundle.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(bundle_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-        add_executable(capability_test 
-            private/test/capability_test.cpp
-            private/mock/attribute_mock.c
-            private/mock/version_mock.c
-            private/src/capability.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(capability_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-        
-        add_executable(celix_errorcodes_test 
-            private/test/celix_errorcodes_test.cpp
-            private/src/celix_errorcodes.c)
-	   	target_link_libraries(celix_errorcodes_test ${CPPUTEST_LIBRARY})
-	    
-        add_executable(filter_test 
-            private/test/filter_test.cpp
-            private/src/filter.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(filter_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-        add_executable(framework_test 
-            private/test/framework_test.cpp
-            #private/mock/properties_mock.c
-            private/mock/resolver_mock.c
-            private/mock/service_reference_mock.c
-            private/mock/service_registry_mock.c
-            private/mock/service_registration_mock.c
-            private/mock/filter_mock.c
-            private/mock/bundle_mock.c
-            private/mock/bundle_context_mock.c
-            private/mock/module_mock.c
-            private/mock/bundle_archive_mock.c
-            private/mock/bundle_revision_mock.c
-            private/mock/bundle_cache_mock.c
-            private/mock/manifest_mock.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c
-            private/src/framework.c)
-        target_link_libraries(framework_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} ${UUID} celix_utils pthread dl)
-    
-        add_executable(manifest_parser_test 
-            private/test/manifest_parser_test.cpp
-            private/mock/manifest_mock.c
-            private/mock/version_mock.c
-            private/mock/version_range_mock.c
-            private/src/attribute.c
-            private/src/capability.c
-            private/src/requirement.c
-            private/src/manifest_parser.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(manifest_parser_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-        add_executable(manifest_test 
-            private/test/manifest_test.cpp
-            private/mock/properties_mock.c
-            private/src/manifest.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(manifest_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
+#            src/bundle_revision.c
+#            src/manifest.c
+#            src/miniunz.c
+#            src/unzip.c
+#            src/ioapi.c
+#            src/properties.c
+#            src/bundle_archive.c
+#            src/celix_errorcodes.c
+#            src/utils.c)
+#        target_link_libraries(bundle_archive_test Celix::utils ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} ${ZLIB_LIBRARY} pthread)
+
+
+    add_executable(bundle_cache_test
+        private/test/bundle_cache_test.cpp
+        private/mock/bundle_archive_mock.c
+        private/mock/properties_mock.c
+        src/bundle_cache.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(bundle_cache_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(bundle_context_test
+        private/test/bundle_context_test.cpp
+        private/mock/bundle_mock.c
+        private/mock/framework_mock.c
+        private/mock/service_registry_mock.c
+        src/bundle_context.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(bundle_context_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(bundle_revision_test
+        private/test/bundle_revision_test.cpp
+        private/mock/miniunz_mock.c
+        private/mock/manifest_mock.c
+        src/bundle_revision.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(bundle_revision_test ${ZLIB_LIBRARY} ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(bundle_test
+        private/test/bundle_test.cpp
+        private/mock/framework_mock.c
+        private/mock/module_mock.c
+        private/mock/bundle_archive_mock.c
+        private/mock/bundle_revision_mock.c
+        private/mock/resolver_mock.c
+        private/mock/version_mock.c
+        src/bundle.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(bundle_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(capability_test
+        private/test/capability_test.cpp
+        private/mock/attribute_mock.c
+        private/mock/version_mock.c
+        src/capability.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(capability_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(celix_errorcodes_test
+        private/test/celix_errorcodes_test.cpp
+        src/celix_errorcodes.c)
+    target_link_libraries(celix_errorcodes_test ${CPPUTEST_LIBRARY} Celix::utils)
+
+    add_executable(filter_test
+        private/test/filter_test.cpp
+        src/filter.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(filter_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(framework_test
+        private/test/framework_test.cpp
+        #private/mock/properties_mock.c
+        private/mock/resolver_mock.c
+        private/mock/service_reference_mock.c
+        private/mock/service_registry_mock.c
+        private/mock/service_registration_mock.c
+        private/mock/filter_mock.c
+        private/mock/bundle_mock.c
+        private/mock/bundle_context_mock.c
+        private/mock/module_mock.c
+        private/mock/bundle_archive_mock.c
+        private/mock/bundle_revision_mock.c
+        private/mock/bundle_cache_mock.c
+        private/mock/manifest_mock.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c
+        src/framework.c)
+    target_link_libraries(framework_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} ${UUID} Celix::utils pthread dl)
+
+    add_executable(manifest_parser_test
+        private/test/manifest_parser_test.cpp
+        private/mock/manifest_mock.c
+        private/mock/version_mock.c
+        private/mock/version_range_mock.c
+        src/attribute.c
+        src/capability.c
+        src/requirement.c
+        src/manifest_parser.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(manifest_parser_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(manifest_test
+        private/test/manifest_test.cpp
+        private/mock/properties_mock.c
+        src/manifest.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(manifest_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
 #        add_executable(module_test 
 #            private/test/module_test.cpp
 #            private/mock/bundle_mock.c
@@ -231,19 +215,19 @@ if (FRAMEWORK)
 #            private/mock/capability_mock.c
 #            private/mock/requirement_mock.c
 #            private/mock/wire_mock.c
-#            private/src/module.c)
-#        target_link_libraries(module_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-        add_executable(requirement_test 
-            private/test/requirement_test.cpp
-            private/mock/attribute_mock.c
-            private/mock/capability_mock.c
-            private/mock/version_range_mock.c
-            private/src/requirement.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(requirement_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
+#            src/module.c)
+#        target_link_libraries(module_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(requirement_test
+        private/test/requirement_test.cpp
+        private/mock/attribute_mock.c
+        private/mock/capability_mock.c
+        private/mock/version_range_mock.c
+        src/requirement.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(requirement_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
 #        add_executable(resolver_test 
 #            private/test/resolver_test.cpp
 #            private/mock/bundle_mock.c
@@ -251,123 +235,123 @@ if (FRAMEWORK)
 #            private/mock/capability_mock.c
 #            private/mock/manifest_parser_mock.c
 #            private/mock/version_mock.c
-#            private/src/wire.c
-#            private/src/module.c
-#            private/src/resolver.c
-#            private/src/celix_errorcodes.c
+#            src/wire.c
+#            src/module.c
+#            src/resolver.c
+#            src/celix_errorcodes.c
 #            private/mock/celix_log_mock.c)
-#        target_link_libraries(resolver_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-        add_executable(service_reference_test 
-            private/test/service_reference_test.cpp
-            private/mock/properties_mock.c
-            private/mock/service_registration_mock.c
-            private/mock/service_registry_mock.c
-            private/src/service_reference.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(service_reference_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-	     add_executable(service_registration_test 
-            private/test/service_registration_test.cpp
-            private/mock/service_registry_mock.c
-            private/src/service_registration.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(service_registration_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-	    
-        add_executable(service_registry_test
-            private/test/service_registry_test.cpp
-            private/mock/framework_mock.c
-            private/mock/bundle_mock.c
-            private/mock/filter_mock.c
-            private/mock/service_reference_mock.c
-            private/mock/service_registration_mock.c
-            private/mock/properties_mock.c
-            private/src/service_registry.c
-            private/mock/module_mock.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c)
-        target_link_libraries(service_registry_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
-        add_executable(service_tracker_customizer_test 
-            private/test/service_tracker_customizer_test.cpp
-            private/mock/service_reference_mock.c
-            private/src/service_tracker_customizer.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c) 
-        target_link_libraries(service_tracker_customizer_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-	    
+#        target_link_libraries(resolver_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(service_reference_test
+        private/test/service_reference_test.cpp
+        private/mock/properties_mock.c
+        private/mock/service_registration_mock.c
+        private/mock/service_registry_mock.c
+        src/service_reference.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(service_reference_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+     add_executable(service_registration_test
+        private/test/service_registration_test.cpp
+        private/mock/service_registry_mock.c
+        src/service_registration.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(service_registration_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+
+    add_executable(service_registry_test
+        private/test/service_registry_test.cpp
+        private/mock/framework_mock.c
+        private/mock/bundle_mock.c
+        private/mock/filter_mock.c
+        private/mock/service_reference_mock.c
+        private/mock/service_registration_mock.c
+        private/mock/properties_mock.c
+        src/service_registry.c
+        private/mock/module_mock.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(service_registry_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+    add_executable(service_tracker_customizer_test
+        private/test/service_tracker_customizer_test.cpp
+        private/mock/service_reference_mock.c
+        src/service_tracker_customizer.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c)
+    target_link_libraries(service_tracker_customizer_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
 #        add_executable(service_tracker_test 
 #            private/test/service_tracker_test.cpp 
 #            private/mock/bundle_context_mock.c
 #            private/mock/service_reference_mock.c 
 #            private/mock/service_tracker_customizer_mock.c
-#            private/src/service_tracker.c
-#            private/src/celix_errorcodes.c
+#            src/service_tracker.c
+#            src/celix_errorcodes.c
 #            private/mock/celix_log_mock.c)
-#        target_link_libraries(service_tracker_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-        
-	    
-	    add_executable(wire_test
-	       private/mock/requirement_mock.c
-	       private/mock/capability_mock.c
-	       private/mock/module_mock.c
-            private/src/celix_errorcodes.c
-            private/mock/celix_log_mock.c
-            private/src/wire.c
-	        private/test/wire_test.cpp) 
-		target_link_libraries(wire_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY})
-		
-		configure_file(private/resources-test/manifest_sections.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest_sections.txt COPYONLY)
-		configure_file(private/resources-test/manifest.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest.txt COPYONLY)
-				
-		#set_target_properties(wire_test PROPERTIES COMPILE_FLAGS "-include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorMallocMacros.h -include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorNewMacros.h")
-			
-        add_test(NAME attribute_test COMMAND attribute_test)
+#        target_link_libraries(service_tracker_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
+
+
+    add_executable(wire_test
+       private/mock/requirement_mock.c
+       private/mock/capability_mock.c
+       private/mock/module_mock.c
+        src/celix_errorcodes.c
+        private/mock/celix_log_mock.c
+        src/wire.c
+        private/test/wire_test.cpp)
+    target_link_libraries(wire_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils)
+
+    configure_file(private/resources-test/manifest_sections.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest_sections.txt COPYONLY)
+    configure_file(private/resources-test/manifest.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest.txt COPYONLY)
+
+    #set_target_properties(wire_test PROPERTIES COMPILE_FLAGS "-include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorMallocMacros.h -include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorNewMacros.h")
+
+    add_test(NAME attribute_test COMMAND attribute_test)
 #        add_test(NAME bundle_archive_test COMMAND bundle_archive_test)
-        add_test(NAME bundle_cache_test COMMAND bundle_cache_test)
-        add_test(NAME bundle_context_test COMMAND bundle_context_test)
-        add_test(NAME bundle_revision_test  COMMAND bundle_revision_test)
-        add_test(NAME bundle_test COMMAND bundle_test)
-        add_test(NAME capability_test COMMAND capability_test)
-        add_test(NAME celix_errorcodes_test COMMAND celix_errorcodes_test)
-        add_test(NAME filter_test COMMAND filter_test)
-        add_test(NAME framework_test COMMAND framework_test)
-        add_test(NAME manifest_parser_test COMMAND manifest_parser_test)
-        add_test(NAME manifest_test COMMAND manifest_test)
+    add_test(NAME bundle_cache_test COMMAND bundle_cache_test)
+    add_test(NAME bundle_context_test COMMAND bundle_context_test)
+    add_test(NAME bundle_revision_test  COMMAND bundle_revision_test)
+    add_test(NAME bundle_test COMMAND bundle_test)
+    add_test(NAME capability_test COMMAND capability_test)
+    add_test(NAME celix_errorcodes_test COMMAND celix_errorcodes_test)
+    add_test(NAME filter_test COMMAND filter_test)
+    add_test(NAME framework_test COMMAND framework_test)
+    add_test(NAME manifest_parser_test COMMAND manifest_parser_test)
+    add_test(NAME manifest_test COMMAND manifest_test)
 #        add_test(NAME module_test COMMAND module_test)
-        add_test(NAME requirement_test COMMAND requirement_test)
+    add_test(NAME requirement_test COMMAND requirement_test)
 #        add_test(NAME resolver_test COMMAND resolver_test)
-        add_test(NAME service_reference_test COMMAND service_reference_test)
-        add_test(NAME service_registration_test COMMAND service_registration_test)
-        add_test(NAME service_registry_test COMMAND service_registry_test)
-        add_test(NAME service_tracker_customizer_test COMMAND service_tracker_customizer_test)
+    add_test(NAME service_reference_test COMMAND service_reference_test)
+    add_test(NAME service_registration_test COMMAND service_registration_test)
+    add_test(NAME service_registry_test COMMAND service_registry_test)
+    add_test(NAME service_tracker_customizer_test COMMAND service_tracker_customizer_test)
 #        add_test(NAME service_tracker_test COMMAND service_tracker_test)
-	add_test(NAME wire_test COMMAND wire_test)
-	    
-	SETUP_TARGET_FOR_COVERAGE(attribute_test attribute_test ${CMAKE_BINARY_DIR}/coverage/attribute_test/attribute_test)
+add_test(NAME wire_test COMMAND wire_test)
+
+SETUP_TARGET_FOR_COVERAGE(attribute_test attribute_test ${CMAKE_BINARY_DIR}/coverage/attribute_test/attribute_test)
 #        SETUP_TARGET_FOR_COVERAGE(bundle_archive_test bundle_archive_test ${CMAKE_BINARY_DIR}/coverage/bundle_archive_test/bundle_archive_test)
-        SETUP_TARGET_FOR_COVERAGE(bundle_cache_test bundle_cache_test ${CMAKE_BINARY_DIR}/coverage/bundle_cache_test/bundle_cache_test)
-        SETUP_TARGET_FOR_COVERAGE(bundle_context_test bundle_context_test ${CMAKE_BINARY_DIR}/coverage/bundle_context_test/bundle_context_test)
-        SETUP_TARGET_FOR_COVERAGE(bundle_revision_test bundle_revision_test ${CMAKE_BINARY_DIR}/coverage/bundle_revision_test/bundle_revision_test)
-        SETUP_TARGET_FOR_COVERAGE(bundle_test bundle_test ${CMAKE_BINARY_DIR}/coverage/bundle_test/bundle_test)
-        SETUP_TARGET_FOR_COVERAGE(capability_test capability_test ${CMAKE_BINARY_DIR}/coverage/capability_test/capability_test)
-        SETUP_TARGET_FOR_COVERAGE(celix_errorcodes_test celix_errorcodes_test ${CMAKE_BINARY_DIR}/coverage/celix_errorcodes_test/celix_errorcodes_test)
-        SETUP_TARGET_FOR_COVERAGE(filter_test filter_test ${CMAKE_BINARY_DIR}/coverage/filter_test/filter_test)
-        SETUP_TARGET_FOR_COVERAGE(framework_test framework_test ${CMAKE_BINARY_DIR}/coverage/framework_test/framework_test)
-        SETUP_TARGET_FOR_COVERAGE(manifest_parser_test manifest_parser_test ${CMAKE_BINARY_DIR}/coverage/manifest_parser_test/manifest_parser_test)
-        SETUP_TARGET_FOR_COVERAGE(manifest_test manifest_test ${CMAKE_BINARY_DIR}/coverage/manifest_test/manifest_test)
+    SETUP_TARGET_FOR_COVERAGE(bundle_cache_test bundle_cache_test ${CMAKE_BINARY_DIR}/coverage/bundle_cache_test/bundle_cache_test)
+    SETUP_TARGET_FOR_COVERAGE(bundle_context_test bundle_context_test ${CMAKE_BINARY_DIR}/coverage/bundle_context_test/bundle_context_test)
+    SETUP_TARGET_FOR_COVERAGE(bundle_revision_test bundle_revision_test ${CMAKE_BINARY_DIR}/coverage/bundle_revision_test/bundle_revision_test)
+    SETUP_TARGET_FOR_COVERAGE(bundle_test bundle_test ${CMAKE_BINARY_DIR}/coverage/bundle_test/bundle_test)
+    SETUP_TARGET_FOR_COVERAGE(capability_test capability_test ${CMAKE_BINARY_DIR}/coverage/capability_test/capability_test)
+    SETUP_TARGET_FOR_COVERAGE(celix_errorcodes_test celix_errorcodes_test ${CMAKE_BINARY_DIR}/coverage/celix_errorcodes_test/celix_errorcodes_test)
+    SETUP_TARGET_FOR_COVERAGE(filter_test filter_test ${CMAKE_BINARY_DIR}/coverage/filter_test/filter_test)
+    SETUP_TARGET_FOR_COVERAGE(framework_test framework_test ${CMAKE_BINARY_DIR}/coverage/framework_test/framework_test)
+    SETUP_TARGET_FOR_COVERAGE(manifest_parser_test manifest_parser_test ${CMAKE_BINARY_DIR}/coverage/manifest_parser_test/manifest_parser_test)
+    SETUP_TARGET_FOR_COVERAGE(manifest_test manifest_test ${CMAKE_BINARY_DIR}/coverage/manifest_test/manifest_test)
 #        SETUP_TARGET_FOR_COVERAGE(module_test module_test ${CMAKE_BINARY_DIR}/coverage/module_test/module_test)
-        SETUP_TARGET_FOR_COVERAGE(requirement_test requirement_test ${CMAKE_BINARY_DIR}/coverage/requirement_test/requirement_test)
+    SETUP_TARGET_FOR_COVERAGE(requirement_test requirement_test ${CMAKE_BINARY_DIR}/coverage/requirement_test/requirement_test)
 #        SETUP_TARGET_FOR_COVERAGE(resolver_test resolver_test ${CMAKE_BINARY_DIR}/coverage/resolver_test/resolver_test)
-        SETUP_TARGET_FOR_COVERAGE(service_reference_test service_reference_test ${CMAKE_BINARY_DIR}/coverage/service_reference_test/service_reference_test)
-        SETUP_TARGET_FOR_COVERAGE(service_registration_test service_registration_test ${CMAKE_BINARY_DIR}/coverage/service_registration_test/service_registration_test)
-        SETUP_TARGET_FOR_COVERAGE(service_registry_test service_registry_test ${CMAKE_BINARY_DIR}/coverage/service_registry_test/service_registry_test)
-        SETUP_TARGET_FOR_COVERAGE(service_tracker_customizer_test service_tracker_customizer_test ${CMAKE_BINARY_DIR}/coverage/service_tracker_customizer_test/service_tracker_customizer_test)
+    SETUP_TARGET_FOR_COVERAGE(service_reference_test service_reference_test ${CMAKE_BINARY_DIR}/coverage/service_reference_test/service_reference_test)
+    SETUP_TARGET_FOR_COVERAGE(service_registration_test service_registration_test ${CMAKE_BINARY_DIR}/coverage/service_registration_test/service_registration_test)
+    SETUP_TARGET_FOR_COVERAGE(service_registry_test service_registry_test ${CMAKE_BINARY_DIR}/coverage/service_registry_test/service_registry_test)
+    SETUP_TARGET_FOR_COVERAGE(service_tracker_customizer_test service_tracker_customizer_test ${CMAKE_BINARY_DIR}/coverage/service_tracker_customizer_test/service_tracker_customizer_test)
 #        SETUP_TARGET_FOR_COVERAGE(service_tracker_test service_tracker_test ${CMAKE_BINARY_DIR}/coverage/service_tracker_test/service_tracker_test)
-		SETUP_TARGET_FOR_COVERAGE(wire_test wire_test ${CMAKE_BINARY_DIR}/coverage/wire_test/wire_test)
-		
-	endif (ENABLE_TESTING AND FRAMEWORK_TESTS)
-endif (FRAMEWORK)
+    SETUP_TARGET_FOR_COVERAGE(wire_test wire_test ${CMAKE_BINARY_DIR}/coverage/wire_test/wire_test)
+
+endif (ENABLE_TESTING AND FRAMEWORK_TESTS)
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/archive.h
----------------------------------------------------------------------
diff --git a/framework/include/archive.h b/framework/include/archive.h
new file mode 100644
index 0000000..f51b960
--- /dev/null
+++ b/framework/include/archive.h
@@ -0,0 +1,58 @@
+/*
+ *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.
+ */
+/**
+ *
+ * @defgroup Archive Archive
+ * @ingroup framework
+ * @{
+ *
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \date      	May 31, 2010
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef ARCHIVE_H_
+#define ARCHIVE_H_
+
+#include "celix_errno.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Extracts the bundle pointed to by bundleName to the given root.
+ *
+ * @param bundleName location of the bundle to extract.
+ * @param revisionRoot directory to where the bundle must be extracted.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_FILE_IO_EXCEPTION If the zip file cannot be extracted.
+ */
+celix_status_t extractBundle(const char *bundleName, const char *revisionRoot);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ARCHIVE_H_ */
+
+/**
+ * @}
+ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/bundle.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle.h b/framework/include/bundle.h
new file mode 100644
index 0000000..3d93bbd
--- /dev/null
+++ b/framework/include/bundle.h
@@ -0,0 +1,139 @@
+/**
+ *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.
+ */
+/*
+ * bundle.h
+ *
+ *  \date       Mar 23, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef BUNDLE_H_
+#define BUNDLE_H_
+
+typedef struct bundle * bundle_pt;
+
+#include "celix_errno.h"
+#include "bundle_state.h"
+#include "bundle_archive.h"
+#include "framework.h"
+#include "wire.h"
+#include "module.h"
+#include "service_reference.h"
+#include "bundle_context.h"
+#include "celix_log.h"
+#include "celix_threads.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+FRAMEWORK_EXPORT celix_status_t bundle_create(bundle_pt *bundle);
+
+FRAMEWORK_EXPORT celix_status_t
+bundle_createFromArchive(bundle_pt *bundle, framework_pt framework, bundle_archive_pt archive);
+
+FRAMEWORK_EXPORT celix_status_t bundle_destroy(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_isSystemBundle(bundle_pt bundle, bool *systemBundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getArchive(bundle_pt bundle, bundle_archive_pt *archive);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getCurrentModule(bundle_pt bundle, module_pt *module);
+
+FRAMEWORK_EXPORT array_list_pt bundle_getModules(bundle_pt bundle);
+
+FRAMEWORK_EXPORT void *bundle_getHandle(bundle_pt bundle);
+
+FRAMEWORK_EXPORT void bundle_setHandle(bundle_pt bundle, void *handle);
+
+FRAMEWORK_EXPORT activator_pt bundle_getActivator(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context);
+
+FRAMEWORK_EXPORT celix_status_t bundle_setContext(bundle_pt bundle, bundle_context_pt context);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getEntry(bundle_pt bundle, const char *name, char **entry);
+
+FRAMEWORK_EXPORT celix_status_t bundle_start(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_startWithOptions(bundle_pt bundle, int options);
+
+FRAMEWORK_EXPORT celix_status_t bundle_update(bundle_pt bundle, const char *inputFile);
+
+FRAMEWORK_EXPORT celix_status_t bundle_stop(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_stopWithOptions(bundle_pt bundle, int options);
+
+FRAMEWORK_EXPORT celix_status_t bundle_uninstall(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_setState(bundle_pt bundle, bundle_state_e state);
+
+FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateInactive(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateUninstalled(bundle_pt bundle);
+
+FRAMEWORK_EXPORT void uninstallBundle(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_revise(bundle_pt bundle, const char *location, const char *inputFile);
+
+FRAMEWORK_EXPORT celix_status_t bundle_addModule(bundle_pt bundle, module_pt module);
+
+FRAMEWORK_EXPORT celix_status_t bundle_closeModules(bundle_pt bundle);
+
+// Service Reference Functions
+FRAMEWORK_EXPORT array_list_pt getUsingBundles(service_reference_pt reference);
+
+FRAMEWORK_EXPORT int compareTo(service_reference_pt a, service_reference_pt b);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getState(bundle_pt bundle, bundle_state_e *state);
+
+FRAMEWORK_EXPORT celix_status_t bundle_isLockable(bundle_pt bundle, bool *lockable);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getLockingThread(bundle_pt bundle, celix_thread_t *thread);
+
+FRAMEWORK_EXPORT celix_status_t bundle_lock(bundle_pt bundle, bool *locked);
+
+FRAMEWORK_EXPORT celix_status_t bundle_unlock(bundle_pt bundle, bool *unlocked);
+
+FRAMEWORK_EXPORT celix_status_t bundle_closeAndDelete(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_close(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_refresh(bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getBundleId(bundle_pt bundle, long *id);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *list);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list);
+
+FRAMEWORK_EXPORT celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework);
+
+FRAMEWORK_EXPORT celix_status_t bundle_getBundleLocation(bundle_pt bundle, const char **location);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BUNDLE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/bundle_activator.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_activator.h b/framework/include/bundle_activator.h
new file mode 100644
index 0000000..1027351
--- /dev/null
+++ b/framework/include/bundle_activator.h
@@ -0,0 +1,126 @@
+/*
+ *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.
+ */
+/**
+ *
+ * @defgroup BundleActivator BundleActivator
+ * @ingroup framework
+ * @{
+ *	\brief		Customizes the starting and stopping of a bundle.
+ *	\details	\ref BundleActivator is a header that must be implemented by every
+ * 				bundle. The Framework creates/starts/stops/destroys activator instances using the
+ * 				functions described in this header. If the bundleActivator_start()
+ * 				function executes successfully, it is guaranteed that the same instance's
+ * 				bundleActivator_stop() function will be called when the bundle is
+ * 				to be stopped. The same applies to the bundleActivator_create() and
+ * 				bundleActivator_destroy() functions.
+ * 				The Framework must not concurrently call the activator functions.
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \date      	March 18, 2010
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef BUNDLE_ACTIVATOR_H_
+#define BUNDLE_ACTIVATOR_H_
+
+#include "bundle_context.h"
+#include "framework_exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Called when this bundle is started so the bundle can create an instance for its activator.
+ * The framework does not assume any type for the activator instance, this is implementation specific.
+ * The activator instance is handle as a void pointer by the framework, the implementation must cast it to the
+ * implementation specific type.
+ *
+ * @param context The execution context of the bundle being started.
+ * @param[out] userData A pointer to the specific activator instance used by this bundle.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- Any other status code will mark the bundle as stopped and the framework will remove this
+ * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
+ */
+ACTIVATOR_EXPORT celix_status_t bundleActivator_create(bundle_context_pt context_ptr, void **userData);
+
+/**
+ * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary
+ * to start this bundle. This method can be used to register services or to allocate any resources that this
+ * bundle needs.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * @param userData The activator instance to be used.
+ * @param context The execution context of the bundle being started.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- Any other status code will mark the bundle as stopped and the framework will remove this
+ * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
+ */
+ACTIVATOR_EXPORT celix_status_t bundleActivator_start(void *userData, bundle_context_pt context);
+
+/**
+ * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary
+ * to stop the bundle. In general, this method should undo the work that the <code>bundleActivator_start()</code>
+ * function started. There should be no active threads that were started by this bundle when this bundle returns.
+ * A stopped bundle must not call any Framework objects.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * @param userData The activator instance to be used.
+ * @param context The execution context of the bundle being stopped.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- Any other status code will mark the bundle as stopped and the framework will remove this
+ * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
+ */
+ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_context_pt context);
+
+/**
+ * Called when this bundle is stopped so the bundle can destroy the instance of its activator. In general, this
+ * method should undo the work that the <code>bundleActivator_create()</code> function initialized.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * @param userData The activator instance to be used.
+ * @param context The execution context of the bundle being stopped.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- Any other status code will mark the bundle as stopped and the framework will remove this
+ * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
+ */
+ACTIVATOR_EXPORT celix_status_t
+bundleActivator_destroy(void *userData, bundle_context_pt  __attribute__((unused))  __attribute__((unused)) context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BUNDLE_ACTIVATOR_H_ */
+
+/**
+ * @}
+ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/bundle_archive.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_archive.h b/framework/include/bundle_archive.h
new file mode 100644
index 0000000..ff3cf16
--- /dev/null
+++ b/framework/include/bundle_archive.h
@@ -0,0 +1,93 @@
+/**
+ *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.
+ */
+/*
+ * bundle_archive.h
+ *
+ *  \date       Aug 8, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef BUNDLE_ARCHIVE_H_
+#define BUNDLE_ARCHIVE_H_
+
+#include <time.h>
+
+#include "bundle_revision.h"
+#include "bundle_state.h"
+#include "celix_errno.h"
+#include "celixbool.h"
+#include "framework_exports.h"
+#include "celix_log.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct bundleArchive *bundle_archive_pt;
+
+celix_status_t bundleArchive_create(const char *archiveRoot, long id, const char *location, const char *inputFile,
+                                    bundle_archive_pt *bundle_archive);
+
+celix_status_t bundleArchive_createSystemBundleArchive(bundle_archive_pt *bundle_archive);
+
+celix_status_t bundleArchive_recreate(const char *archiveRoot, bundle_archive_pt *bundle_archive);
+
+celix_status_t bundleArchive_destroy(bundle_archive_pt archive);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_getId(bundle_archive_pt archive, long *id);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_getLocation(bundle_archive_pt archive, const char **location);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_getArchiveRoot(bundle_archive_pt archive, const char **archiveRoot);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleArchive_revise(bundle_archive_pt archive, const char *location, const char *inputFile);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_rollbackRevise(bundle_archive_pt archive, bool *rolledback);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleArchive_getRevision(bundle_archive_pt archive, long revNr, bundle_revision_pt *revision);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleArchive_getCurrentRevision(bundle_archive_pt archive, bundle_revision_pt *revision);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_getCurrentRevisionNumber(bundle_archive_pt archive, long *revisionNumber);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_getRefreshCount(bundle_archive_pt archive, long *refreshCount);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_setRefreshCount(bundle_archive_pt archive);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_close(bundle_archive_pt archive);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_closeAndDelete(bundle_archive_pt archive);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_setLastModified(bundle_archive_pt archive, time_t lastModifiedTime);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_getLastModified(bundle_archive_pt archive, time_t *lastModified);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_setPersistentState(bundle_archive_pt archive, bundle_state_e state);
+
+FRAMEWORK_EXPORT celix_status_t bundleArchive_getPersistentState(bundle_archive_pt archive, bundle_state_e *state);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BUNDLE_ARCHIVE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/bundle_context.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_context.h b/framework/include/bundle_context.h
new file mode 100644
index 0000000..b8d3f45
--- /dev/null
+++ b/framework/include/bundle_context.h
@@ -0,0 +1,175 @@
+/**
+ *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.
+ */
+/*
+ * bundle_context.h
+ *
+ *  \date       Mar 26, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef BUNDLE_CONTEXT_H_
+#define BUNDLE_CONTEXT_H_
+
+/**
+ * A bundle's execution context within the Framework. The context is used to
+ * grant access to other methods so that this bundle can interact with the
+ * Framework.
+ */
+typedef struct bundleContext *bundle_context_pt;
+typedef struct bundleContext bundle_context_t;
+
+
+#include "service_factory.h"
+#include "service_listener.h"
+#include "bundle_listener.h"
+#include "framework_listener.h"
+#include "properties.h"
+#include "array_list.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+celix_status_t
+bundleContext_create(framework_pt framework, framework_logger_pt, bundle_pt bundle, bundle_context_pt *bundle_context);
+
+celix_status_t bundleContext_destroy(bundle_context_pt context);
+
+FRAMEWORK_EXPORT celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *bundle);
+
+FRAMEWORK_EXPORT celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_pt *framework);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_installBundle(bundle_context_pt context, const char *location, bundle_pt *bundle);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_installBundle2(bundle_context_pt context, const char *location, const char *inputFile, bundle_pt *bundle);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_registerService(bundle_context_pt context, const char *serviceName, const void *svcObj,
+                              properties_pt properties, service_registration_pt *service_registration);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_registerServiceFactory(bundle_context_pt context, const char *serviceName, service_factory_pt factory,
+                                     properties_pt properties, service_registration_pt *service_registration);
+
+/**
+ * Get a service reference for the bundle context. When the service reference is no longer needed use bundleContext_ungetServiceReference.
+ * ServiceReference are coupled to a bundle context. Do not share service reference between bundles. Exchange the service.id instead.
+ * 
+ * @param context The bundle context
+ * @param serviceName The name of the service (objectClass) to get
+ * @param service_reference _output_ The found service reference, or NULL when no service is found.
+ * @return CELIX_SUCCESS on success
+ */
+FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(bundle_context_pt context, const char *serviceName,
+                                                                  service_reference_pt *service_reference);
+
+/** Same as bundleContext_getServiceReference, but than for a optional serviceName combined with a optional filter.
+ * The resulting array_list should be destroyed by the caller. For all service references return a unget should be called.
+ * 
+ * @param context the bundle context
+ * @param serviceName the serviceName, can be NULL
+ * @param filter the filter, can be NULL. If present will be combined (and) with the serviceName 
+ * @param service_references _output_ a array list, can be size 0. 
+ * @return CELIX_SUCCESS on success
+ */
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_getServiceReferences(bundle_context_pt context, const char *serviceName, const char *filter,
+                                   array_list_pt *service_references);
+
+/**
+ * Retains (increases the ref count) the provided service reference. Can be used to retain a service reference.
+ * Note that this is a deviation from the OSGi spec, due to the fact that C has no garbage collect.
+ * 
+ * @param context the bundle context
+ * @param reference the service reference to retain
+ * @return CELIX_SUCCES on success
+ */
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_retainServiceReference(bundle_context_pt context, service_reference_pt reference);
+
+/**
+ * Ungets the service references. If the ref counter of the service refernce goes to 0, the reference will be destroyed.
+ * This is coupled with the bundleContext_getServiceReference(s) and bundleContext_retainServiceReferenc.
+ * Note: That this is a deviation from the OSGi standard, due to the fact that C has no garbage collect.
+ * 
+ * @param context The bundle context.
+ * @param reference the service reference to unget
+ * @return CELIX_SUCCESS on success.
+ */
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_getService(bundle_context_pt context, service_reference_pt reference, void **service_instance);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_ungetService(bundle_context_pt context, service_reference_pt reference, bool *result);
+
+FRAMEWORK_EXPORT celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles);
+
+FRAMEWORK_EXPORT celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, bundle_pt *bundle);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_addServiceListener(bundle_context_pt context, service_listener_pt listener, const char *filter);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_removeServiceListener(bundle_context_pt context, service_listener_pt listener);
+
+FRAMEWORK_EXPORT celix_status_t bundleContext_addBundleListener(bundle_context_pt context, bundle_listener_pt listener);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_removeBundleListener(bundle_context_pt context, bundle_listener_pt listener);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_addFrameworkListener(bundle_context_pt context, framework_listener_pt listener);
+
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener);
+
+/**
+ * Gets the config property - or environment variable if the config property does not exist - for the provided name.
+ *
+ * @param context The bundle context.
+ * @param name The name of the config property / environment variable to get.
+ * @param value A ptr to the output value. This will be set when a value is found or else will be set to NULL.
+ * @return 0 if successful.
+ */
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_getProperty(bundle_context_pt context, const char *name, const char **value);
+
+/**
+ * Gets the config property - or environment variable if the config property does not exist - for the provided name.
+ *
+ * @param context The bundle context.
+ * @param name The name of the config property / environment variable to get.
+ * @param defaultValue The default value to return if no value is found.
+ * @param value A ptr to the output value. This will be set when a value is found or else will be set to NULL.
+ * @return 0 if successful.
+ */
+FRAMEWORK_EXPORT celix_status_t
+bundleContext_getPropertyWithDefault(bundle_context_pt context, const char *name, const char *defaultValue, const char **value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BUNDLE_CONTEXT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/bundle_event.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_event.h b/framework/include/bundle_event.h
new file mode 100644
index 0000000..c4fc927
--- /dev/null
+++ b/framework/include/bundle_event.h
@@ -0,0 +1,63 @@
+/*
+ *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.
+ */
+/*
+ * bundle_event.h
+ *
+ *  \date       Jun 28, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef BUNDLE_EVENT_H_
+#define BUNDLE_EVENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum bundle_event_type {
+	OSGI_FRAMEWORK_BUNDLE_EVENT_INSTALLED = 0x00000001,
+	OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED = 0x00000002,
+	OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPED = 0x00000004,
+	OSGI_FRAMEWORK_BUNDLE_EVENT_UPDATED = 0x00000008,
+	OSGI_FRAMEWORK_BUNDLE_EVENT_UNINSTALLED = 0x00000010,
+	OSGI_FRAMEWORK_BUNDLE_EVENT_RESOLVED = 0x00000020,
+	OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED = 0x00000040,
+	OSGI_FRAMEWORK_BUNDLE_EVENT_STARTING = 0x00000080,
+	OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING = 0x00000100,
+	OSGI_FRAMEWORK_BUNDLE_EVENT_LAZY_ACTIVATION = 0x00000200,
+};
+
+typedef enum bundle_event_type bundle_event_type_e;
+typedef struct bundle_event *bundle_event_pt;
+
+#include "service_reference.h"
+#include "bundle.h"
+
+struct bundle_event {
+	long bundleId;
+	char *bundleSymbolicName;
+	bundle_event_type_e type;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BUNDLE_EVENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/bundle_listener.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_listener.h b/framework/include/bundle_listener.h
new file mode 100644
index 0000000..a152393
--- /dev/null
+++ b/framework/include/bundle_listener.h
@@ -0,0 +1,57 @@
+/*
+ *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.
+ */
+/**
+ *
+ * @defgroup BundleListener Bundle Listener
+ * @ingroup framework
+ * @{
+ *
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \date      	June 28, 2012
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef BUNDLE_LISTENER_H_
+#define BUNDLE_LISTENER_H_
+
+typedef struct bundle_listener *bundle_listener_pt;
+
+#include "celix_errno.h"
+#include "bundle_event.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct bundle_listener {
+	void *handle;
+
+	celix_status_t (*bundleChanged)(void *listener, bundle_event_pt event);
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* service_listener_t_H_ */
+
+/**
+ * @}
+ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/bundle_revision.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_revision.h b/framework/include/bundle_revision.h
new file mode 100644
index 0000000..9533eb6
--- /dev/null
+++ b/framework/include/bundle_revision.h
@@ -0,0 +1,142 @@
+/*
+ *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.
+ */
+/**
+ *
+ * @defgroup BundleRevision Bundle Revision
+ * @ingroup framework
+ * @{
+ *
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \date      	April 12, 2011
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef BUNDLE_REVISION_H_
+#define BUNDLE_REVISION_H_
+
+#include <stdio.h>
+
+#include "celix_errno.h"
+#include "manifest.h"
+#include "celix_log.h"
+#include "array_list.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Typedef for bundle_revision_pt.
+ *
+ * A bundle revision represents the content of a bundle. A revision is associated with a bundle archive.
+ * An archive can have multiple revisions, each update of a bundle results in a new one.
+ *
+ * In a revision the content of a bundle (ZIP file) is extracted to a specified location inside the archive.
+ */
+typedef struct bundleRevision *bundle_revision_pt;
+
+/**
+ * Creates a new revision for the given inputFile or location.
+ * The location parameter is used to identify the bundle, in case of an update or download, the inputFile
+ *  parameter can be used to point to the actual data. In the OSGi specification this is the inputstream.
+ *
+ * @param pool The pool on which this revision has to be allocated.
+ * @param root The root for this revision in which the bundle is extracted and state is stored.
+ * @param location The location associated with the revision
+ * @param revisionNr The number of the revision
+ * @param inputFile The (optional) location of the file to use as input for this revision
+ * @param[out] bundle_revision The output parameter for the created revision.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>bundle_revision</code> failed.
+ */
+celix_status_t bundleRevision_create(const char *root, const char *location, long revisionNr, const char *inputFile,
+                                     bundle_revision_pt *bundle_revision);
+
+celix_status_t bundleRevision_destroy(bundle_revision_pt revision);
+
+/**
+ * Retrieves the revision number of the given revision.
+ *
+ * @param revision The revision to get the number for.
+ * @param[out] revisionNr The revision number.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
+ */
+celix_status_t bundleRevision_getNumber(bundle_revision_pt revision, long *revisionNr);
+
+/**
+ * Retrieves the location of the given revision.
+ *
+ * @param revision The revision to get the location for.
+ * @param[out] location The location.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
+ */
+celix_status_t bundleRevision_getLocation(bundle_revision_pt revision, const char **location);
+
+/**
+ * Retrieves the root of the given revision.
+ *
+ * @param revision The revision to get the location for.
+ * @param[out] root The root.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
+ */
+celix_status_t bundleRevision_getRoot(bundle_revision_pt revision, const char **root);
+
+/**
+ * Retrieves the manifest of the given revision.
+ *
+ * @param revision The revision to get the manifest for.
+ * @param[out] manifest The manifest.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
+ */
+celix_status_t bundleRevision_getManifest(bundle_revision_pt revision, manifest_pt *manifest);
+
+/**
+ * Retrieves the handles of the installed libraries for this revision.
+ *
+ * @param revision The revision to get the manifest for.
+ * @param[out] handles array_list_pt containing the handles.
+ *
+ * @return Status code indication failure or success:
+ *      - CELIX_SUCCESS when no errors are encountered.
+ *      - CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
+ */
+celix_status_t bundleRevision_getHandles(bundle_revision_pt revision, array_list_pt *handles);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BUNDLE_REVISION_H_ */
+
+/**
+ * @}
+ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/bundle_state.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_state.h b/framework/include/bundle_state.h
new file mode 100644
index 0000000..8d451e4
--- /dev/null
+++ b/framework/include/bundle_state.h
@@ -0,0 +1,49 @@
+/**
+ *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.
+ */
+/*
+ * bundle_state.h
+ *
+ *  \date       Sep 27, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef BUNDLE_STATE_H_
+#define BUNDLE_STATE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum bundleState {
+	OSGI_FRAMEWORK_BUNDLE_UNKNOWN = 0x00000000,
+	OSGI_FRAMEWORK_BUNDLE_UNINSTALLED = 0x00000001,
+	OSGI_FRAMEWORK_BUNDLE_INSTALLED = 0x00000002,
+	OSGI_FRAMEWORK_BUNDLE_RESOLVED = 0x00000004,
+	OSGI_FRAMEWORK_BUNDLE_STARTING = 0x00000008,
+	OSGI_FRAMEWORK_BUNDLE_STOPPING = 0x00000010,
+	OSGI_FRAMEWORK_BUNDLE_ACTIVE = 0x00000020,
+};
+
+typedef enum bundleState bundle_state_e;
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BUNDLE_STATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/capability.h
----------------------------------------------------------------------
diff --git a/framework/include/capability.h b/framework/include/capability.h
new file mode 100644
index 0000000..b35d016
--- /dev/null
+++ b/framework/include/capability.h
@@ -0,0 +1,54 @@
+/**
+ *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.
+ */
+/*
+ * capability.h
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef CAPABILITY_H_
+#define CAPABILITY_H_
+
+typedef struct capability *capability_pt;
+
+#include "hash_map.h"
+#include "module.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+celix_status_t
+capability_create(module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability);
+
+celix_status_t capability_destroy(capability_pt capability);
+
+celix_status_t capability_getServiceName(capability_pt capability, const char **serviceName);
+
+celix_status_t capability_getVersion(capability_pt capability, version_pt *version);
+
+celix_status_t capability_getModule(capability_pt capability, module_pt *module);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CAPABILITY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/celix_launcher.h
----------------------------------------------------------------------
diff --git a/framework/include/celix_launcher.h b/framework/include/celix_launcher.h
new file mode 100644
index 0000000..0d819c9
--- /dev/null
+++ b/framework/include/celix_launcher.h
@@ -0,0 +1,55 @@
+/**
+ *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_launcher.h
+ *
+ *  \date       Jul 30, 2015
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef CELIX_LAUNCHER_H
+#define CELIX_LAUNCHER_H
+
+#include <stdio.h>
+#include "framework.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int celixLauncher_launchWithArgs(int argc, char *argv[]);
+
+int celixLauncher_launch(const char *configFile, framework_pt *framework);
+
+int celixLauncher_launchWithStream(FILE *config, framework_pt *framework);
+
+int celixLauncher_launchWithProperties(properties_pt config, framework_pt *framework);
+
+void celixLauncher_stop(framework_pt framework);
+
+void celixLauncher_destroy(framework_pt framework);
+
+void celixLauncher_waitForShutdown(framework_pt framework);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //CELIX_LAUNCHER_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/celix_log.h
----------------------------------------------------------------------
diff --git a/framework/include/celix_log.h b/framework/include/celix_log.h
new file mode 100644
index 0000000..08d096c
--- /dev/null
+++ b/framework/include/celix_log.h
@@ -0,0 +1,85 @@
+/*
+ *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_log.h
+ *
+ *  \date       Jan 12, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef CELIX_LOG_H_
+#define CELIX_LOG_H_
+
+#include <stdio.h>
+
+#include "celix_errno.h"
+#include "framework_exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum framework_log_level {
+    OSGI_FRAMEWORK_LOG_ERROR = 0x00000001,
+    OSGI_FRAMEWORK_LOG_WARNING = 0x00000002,
+    OSGI_FRAMEWORK_LOG_INFO = 0x00000003,
+    OSGI_FRAMEWORK_LOG_DEBUG = 0x00000004,
+};
+
+typedef enum framework_log_level framework_log_level_t;
+
+typedef struct framework_logger *framework_logger_pt;
+
+extern framework_logger_pt logger;
+
+typedef celix_status_t (*framework_log_function_pt)(framework_log_level_t level, const char *func, const char *file,
+                                                    int line, const char *msg);
+
+struct framework_logger {
+    framework_log_function_pt logFunction;
+};
+
+#define fw_log(logger, level, fmsg, args...) framework_log(logger, level, __func__, __FILE__, __LINE__, fmsg, ## args)
+#define fw_logCode(logger, level, code, fmsg, args...) framework_logCode(logger, level, __func__, __FILE__, __LINE__, code, fmsg, ## args)
+#define framework_logIfError(logger, status, error, fmsg, args...) \
+    if (status != CELIX_SUCCESS) { \
+        if (error != NULL) { \
+            fw_logCode(logger, OSGI_FRAMEWORK_LOG_ERROR, status, #fmsg";\n Cause: %s", ## args, error); \
+        } else { \
+            fw_logCode(logger, OSGI_FRAMEWORK_LOG_ERROR, status, #fmsg, ## args); \
+        } \
+    }
+
+FRAMEWORK_EXPORT celix_status_t
+frameworkLogger_log(framework_log_level_t level, const char *func, const char *file, int line, const char *fmsg);
+
+FRAMEWORK_EXPORT void
+framework_log(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line,
+              const char *fmsg, ...);
+
+FRAMEWORK_EXPORT void
+framework_logCode(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line,
+                  celix_status_t code, const char *fmsg, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CELIX_LOG_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/constants.h
----------------------------------------------------------------------
diff --git a/framework/include/constants.h b/framework/include/constants.h
new file mode 100644
index 0000000..5a01016
--- /dev/null
+++ b/framework/include/constants.h
@@ -0,0 +1,67 @@
+/**
+ *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.
+ */
+/*
+ * constants.h
+ *
+ *  \date       Apr 29, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef CONSTANTS_H_
+#define CONSTANTS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static const char *const OSGI_FRAMEWORK_OBJECTCLASS = "objectClass";
+static const char *const OSGI_FRAMEWORK_SERVICE_ID = "service.id";
+static const char *const OSGI_FRAMEWORK_SERVICE_PID = "service.pid";
+static const char *const OSGI_FRAMEWORK_SERVICE_RANKING = "service.ranking";
+
+static const char *const CELIX_FRAMEWORK_SERVICE_VERSION = "service.version";
+static const char *const CELIX_FRAMEWORK_SERVICE_LANGUAGE = "service.lang";
+static const char *const CELIX_FRAMEWORK_SERVICE_C_LANGUAGE = "C";
+static const char *const CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE = "C++";
+static const char *const CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE = "shared"; //e.g. marker services
+
+static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR = "Bundle-Activator";
+static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE = "bundleActivator_create";
+static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START = "bundleActivator_start";
+static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP = "bundleActivator_stop";
+static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY = "bundleActivator_destroy";
+
+static const char *const OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
+static const char *const OSGI_FRAMEWORK_BUNDLE_VERSION = "Bundle-Version";
+static const char *const OSGI_FRAMEWORK_PRIVATE_LIBRARY = "Private-Library";
+static const char *const OSGI_FRAMEWORK_EXPORT_LIBRARY = "Export-Library";
+static const char *const OSGI_FRAMEWORK_IMPORT_LIBRARY = "Import-Library";
+
+
+static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE = "org.osgi.framework.storage";
+static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN = "org.osgi.framework.storage.clean";
+static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT = "onFirstInit";
+static const char *const OSGI_FRAMEWORK_FRAMEWORK_UUID = "org.osgi.framework.uuid";
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CONSTANTS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/filter.h
----------------------------------------------------------------------
diff --git a/framework/include/filter.h b/framework/include/filter.h
new file mode 100644
index 0000000..687de2a
--- /dev/null
+++ b/framework/include/filter.h
@@ -0,0 +1,55 @@
+/**
+ *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.
+ */
+/*
+ * filter.h
+ *
+ *  \date       Apr 28, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef FILTER_H_
+#define FILTER_H_
+
+#include "celix_errno.h"
+#include "properties.h"
+#include "celixbool.h"
+#include "framework_exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct filter *filter_pt;
+
+FRAMEWORK_EXPORT filter_pt filter_create(const char *filterString);
+
+FRAMEWORK_EXPORT void filter_destroy(filter_pt filter);
+
+FRAMEWORK_EXPORT celix_status_t filter_match(filter_pt filter, properties_pt properties, bool *result);
+
+FRAMEWORK_EXPORT celix_status_t filter_match_filter(filter_pt src, filter_pt dest, bool *result);
+
+FRAMEWORK_EXPORT celix_status_t filter_getString(filter_pt filter, const char **filterStr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FILTER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/framework.h
----------------------------------------------------------------------
diff --git a/framework/include/framework.h b/framework/include/framework.h
new file mode 100644
index 0000000..ec2306f
--- /dev/null
+++ b/framework/include/framework.h
@@ -0,0 +1,57 @@
+/**
+ *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.
+ */
+/*
+ * framework.h
+ *
+ *  \date       Mar 23, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef FRAMEWORK_H_
+#define FRAMEWORK_H_
+
+typedef struct activator * activator_pt;
+typedef struct framework * framework_pt;
+
+#include "celix_errno.h"
+#include "framework_exports.h"
+#include "bundle.h"
+#include "properties.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// #TODO: Move to FrameworkFactory according the OSGi Spec
+FRAMEWORK_EXPORT celix_status_t framework_create(framework_pt *framework, properties_pt config);
+
+FRAMEWORK_EXPORT celix_status_t framework_destroy(framework_pt framework);
+
+FRAMEWORK_EXPORT celix_status_t fw_init(framework_pt framework);
+
+FRAMEWORK_EXPORT celix_status_t framework_waitForStop(framework_pt framework);
+
+FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(framework_pt framework, bundle_pt *bundle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FRAMEWORK_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/framework_event.h
----------------------------------------------------------------------
diff --git a/framework/include/framework_event.h b/framework/include/framework_event.h
new file mode 100644
index 0000000..d48e64c
--- /dev/null
+++ b/framework/include/framework_event.h
@@ -0,0 +1,71 @@
+/*
+ *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.
+ */
+/*
+ * framework_event.h
+ *
+ *  \date       Oct 8, 2013
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef FRAMEWORK_EVENT_H_
+#define FRAMEWORK_EVENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum framework_event_type {
+	OSGI_FRAMEWORK_EVENT_STARTED = 0x00000001,
+	OSGI_FRAMEWORK_EVENT_ERROR = 0x00000002,
+	OSGI_FRAMEWORK_EVENT_PACKAGES_REFRESHED = 0x00000004,
+	OSGI_FRAMEWORK_EVENT_STARTLEVEL_CHANGED = 0x00000008,
+	OSGI_FRAMEWORK_EVENT_WARNING = 0x00000010,
+	OSGI_FRAMEWORK_EVENT_INFO = 0x00000020,
+	OSGI_FRAMEWORK_EVENT_STOPPED = 0x00000040,
+	OSGI_FRAMEWORK_EVENT_STOPPED_UPDATE = 0x00000080,
+	OSGI_FRAMEWORK_EVENT_STOPPED_BOOTCLASSPATH_MODIFIED = 0x00000100,
+	OSGI_FRAMEWORK_EVENT_WAIT_TIMEDOUT = 0x00000200,
+};
+
+typedef enum framework_event_type framework_event_type_e;
+typedef struct framework_event *framework_event_pt;
+#ifdef __cplusplus
+}
+#endif
+
+#include "service_reference.h"
+#include "bundle.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct framework_event {
+	long bundleId;
+	char *bundleSymbolicName;
+	framework_event_type_e type;
+	celix_status_t errorCode;
+	char *error;
+};
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FRAMEWORK_EVENT_H_ */


[42/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_service_dependency.c b/dependency_manager/src/dm_service_dependency.c
new file mode 100644
index 0000000..65a0593
--- /dev/null
+++ b/dependency_manager/src/dm_service_dependency.c
@@ -0,0 +1,811 @@
+/**
+ *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.
+ */
+/*
+ * dm_service_dependency.c
+ *
+ *  \date       17 Oct 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <assert.h>
+
+#include "constants.h"
+
+#include "dm_service_dependency_impl.h"
+#include "dm_component_impl.h"
+
+#define DEFAULT_RANKING     0
+#define DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
+
+static celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt reference, void *service);
+static celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_pt reference, void *service);
+static celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt reference, void *service);
+static void* serviceDependency_getCallbackHandle(dm_service_dependency_pt dep);
+
+celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*dependency_ptr = calloc(1, sizeof(**dependency_ptr));
+	if (!*dependency_ptr) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*dependency_ptr)->component = NULL;
+		(*dependency_ptr)->available = false;
+		(*dependency_ptr)->instanceBound = false;
+		(*dependency_ptr)->required = false;
+		(*dependency_ptr)->strategy = DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY;
+
+		(*dependency_ptr)->callbackHandle = NULL;
+		(*dependency_ptr)->set = NULL;
+		(*dependency_ptr)->add = NULL;
+		(*dependency_ptr)->change = NULL;
+		(*dependency_ptr)->remove = NULL;
+		(*dependency_ptr)->swap = NULL;
+
+		(*dependency_ptr)->add_with_ref = NULL;
+		(*dependency_ptr)->change_with_ref = NULL;
+		(*dependency_ptr)->remove_with_ref = NULL;
+		(*dependency_ptr)->swap_with_ref = NULL;
+
+		(*dependency_ptr)->autoConfigure = NULL;
+
+		(*dependency_ptr)->isStarted = false;
+
+        (*dependency_ptr)->addCLanguageFilter = false;
+		(*dependency_ptr)->tracked_service = NULL;
+		(*dependency_ptr)->tracked_filter_unmodified = NULL;
+		(*dependency_ptr)->tracked_filter = NULL;
+
+		(*dependency_ptr)->tracker = NULL;
+		(*dependency_ptr)->tracker_customizer = NULL;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_destroy(dm_service_dependency_pt *dependency_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!*dependency_ptr) {
+		status = CELIX_ENOMEM;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		free((*dependency_ptr)->tracked_service);
+		free((*dependency_ptr)->tracked_filter);
+		free((*dependency_ptr)->tracked_filter_unmodified);
+		free(*dependency_ptr);
+		*dependency_ptr = NULL;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_lock(dm_service_dependency_pt dependency) {
+	celixThreadMutex_lock(&dependency->lock);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceDependency_unlock(dm_service_dependency_pt dependency) {
+	celixThreadMutex_unlock(&dependency->lock);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency, bool required) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->required = required;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_pt dependency, bool addCLangFilter) {
+    dependency->addCLanguageFilter = addCLangFilter;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t serviceDependency_setStrategy(dm_service_dependency_pt dependency, dm_service_dependency_strategy_t strategy) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		dependency->strategy = strategy;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency, dm_service_dependency_strategy_t* strategy) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*strategy = dependency->strategy;
+	}
+
+	return status;
+
+}
+
+celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, const char* serviceName, const char* serviceVersionRange, const char* filter) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (!dependency || !serviceName) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		array_list_pt filterElements = NULL;
+		arrayList_create(&filterElements);
+
+		free(dependency->tracked_service);
+		dependency->tracked_service = strdup(serviceName);
+
+		if (serviceVersionRange != NULL) {
+			version_range_pt versionRange = NULL;
+
+			if (versionRange_parse(serviceVersionRange, &versionRange) == CELIX_SUCCESS) {
+				version_pt lowVersion = NULL;
+				version_pt highVersion = NULL;
+
+				if ((versionRange_getHighVersion(versionRange, &highVersion) == CELIX_SUCCESS) && (highVersion != NULL)) {
+					bool isHighInclusive;
+					char* highOperator;
+					char* highVersionStr = NULL;
+
+					versionRange_isHighInclusive(versionRange, &isHighInclusive);
+					version_toString(highVersion, &highVersionStr);
+
+					highOperator = isHighInclusive ? "<=" : "<";
+
+					if(highVersionStr != NULL){
+						size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(highVersionStr) + strlen(highOperator) + 3;
+						char serviceVersionFilter[len];
+						snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, highOperator, highVersionStr);
+						arrayList_add(filterElements, strdup(serviceVersionFilter));
+						free(highVersionStr);
+					}
+				}
+
+				if ((versionRange_getLowVersion(versionRange, &lowVersion) == CELIX_SUCCESS) && (lowVersion != NULL)) {
+					bool isLowInclusive;
+					char* lowOperator;
+					char* lowVersionStr = NULL;
+
+					versionRange_isLowInclusive(versionRange, &isLowInclusive);
+					version_toString(lowVersion, &lowVersionStr);
+
+					lowOperator = isLowInclusive ? ">=" : ">";
+
+					if(lowVersionStr != NULL){
+						size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(lowVersionStr) + strlen(lowOperator) + 3;
+						char serviceVersionFilter[len];
+						snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, lowOperator, lowVersionStr);
+						arrayList_add(filterElements, strdup(serviceVersionFilter));
+						free(lowVersionStr);
+					}
+				}
+			}
+
+			if(versionRange!=NULL){
+				versionRange_destroy(versionRange);
+			}
+		}
+
+		if (filter != NULL) {
+			free(dependency->tracked_filter_unmodified);
+			dependency->tracked_filter_unmodified = strdup(filter);
+			arrayList_add(filterElements, strdup(filter));
+		}
+
+
+
+        bool needLangFilter = true;
+		if (filter != NULL) {
+            char needle[128];
+            snprintf(needle, sizeof(needle), "(%s=", CELIX_FRAMEWORK_SERVICE_LANGUAGE);
+            if (strstr(filter, needle) != NULL) {
+                needLangFilter = false;
+            }
+        }
+
+        if (needLangFilter && dependency->addCLanguageFilter) {
+			char langFilter[128];
+			snprintf(langFilter, sizeof(langFilter), "(%s=%s)", CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+            arrayList_add(filterElements, strdup(langFilter));
+		}
+
+		if (arrayList_size(filterElements) > 0) {
+			array_list_iterator_pt filterElementsIter = arrayListIterator_create(filterElements);
+
+			size_t len = strlen(serviceName) + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + 4;
+			free(dependency->tracked_filter);
+			dependency->tracked_filter = calloc(len, sizeof(*dependency->tracked_filter));
+			snprintf(dependency->tracked_filter, len, "(%s=%s)", OSGI_FRAMEWORK_OBJECTCLASS, serviceName);
+
+			while (arrayListIterator_hasNext(filterElementsIter) == true) {
+				char* filterElement = (char*) arrayListIterator_next(filterElementsIter);
+				size_t len = strnlen(dependency->tracked_filter, 1024*1024) + strnlen(filterElement, 1024*1024) + 4;
+				char* newFilter = calloc(len, sizeof(*newFilter));
+
+				if (dependency->tracked_filter[0] == '(' && dependency->tracked_filter[1] == '&') {
+					//already have an & (AND) can combine with additional filter -> easier to read
+					size_t orgLen = strnlen(dependency->tracked_filter, 1024*1024);
+					snprintf(newFilter, len, "%.*s%s)", (int)orgLen -1, dependency->tracked_filter, filterElement);
+				} else {
+					snprintf(newFilter, len, "(&%s%s)", dependency->tracked_filter, filterElement);
+				}
+
+				free(dependency->tracked_filter);
+				free(filterElement);
+
+				dependency->tracked_filter = newFilter;
+			}
+
+			arrayListIterator_destroy(filterElementsIter);
+		}
+		else {
+			free(dependency->tracked_filter);
+			dependency->tracked_filter = NULL;
+		}
+
+		arrayList_destroy(filterElements);
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, const char** filter) {
+	*filter = (const char*)dependency->tracked_filter;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceDependency_setCallbacks(dm_service_dependency_pt dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    //printf("Setting callbacks set %p, add %p, change %p, remove %p and swap %p\n", set, add, change, remove, swap);
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->set = set;
+		dependency->add = add;
+		dependency->change = change;
+		dependency->remove = remove;
+		dependency->swap = swap;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_pt dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove,
+		service_swap_with_ref_fpt swap) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->set_with_ref = set;
+		dependency->add_with_ref = add;
+		dependency->change_with_ref = change;
+		dependency->remove_with_ref = remove;
+		dependency->swap_with_ref = swap;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt dependency, celix_thread_mutex_t *service_lock, const void **field) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	celix_thread_mutex_t lock;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->autoConfigure = field;
+		celixThreadMutex_create(&lock, NULL);
+		*service_lock = lock;
+		dependency->lock = lock;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependency, dm_component_pt component) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->component = component;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_start(dm_service_dependency_pt dependency) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = NULL;
+
+	if (!dependency || !dependency->component || (!dependency->tracked_service && !dependency->tracked_filter)) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+	if (status == CELIX_SUCCESS) {
+		status = component_getBundleContext(dependency->component, &context);
+		if (!context) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+	if (status == CELIX_SUCCESS) {
+		dependency->tracker_customizer = NULL;
+		status = serviceTrackerCustomizer_create(dependency, NULL, serviceDependency_addedService, serviceDependency_modifiedService, serviceDependency_removedService, &dependency->tracker_customizer);
+	}
+	if (status == CELIX_SUCCESS) {
+		if (dependency->tracked_filter) {
+			status = serviceTracker_createWithFilter(context, dependency->tracked_filter, dependency->tracker_customizer, &dependency->tracker);
+		} else if (dependency->tracked_service) {
+			status = serviceTracker_create(context, dependency->tracked_service, dependency->tracker_customizer, &dependency->tracker);
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = serviceTracker_open(dependency->tracker);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->isStarted = true;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->isStarted = false;
+	}
+
+	if (status == CELIX_SUCCESS && dependency->tracker) {
+		status = serviceTracker_close(dependency->tracker);
+		if (status == CELIX_SUCCESS) {
+			serviceTracker_destroy(dependency->tracker);
+			dependency->tracker = NULL;
+		}
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt dependency, bool instanceBound) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->instanceBound = instanceBound;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependency, bool available) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->available = available;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, dm_event_pt event) {
+	celix_status_t status = CELIX_SUCCESS;
+	assert(dependency->isStarted == true);
+	array_list_pt serviceReferences = NULL;
+	int i;
+	int curRanking = INT_MIN;
+	service_reference_pt curServRef = NULL;
+	void *service = NULL;
+
+	serviceReferences = serviceTracker_getServiceReferences(dependency->tracker);
+
+	/* Find the service with the higest ranking */
+	for (i = 0; i < arrayList_size(serviceReferences); i++) {
+		service_reference_pt serviceReference = arrayList_get(serviceReferences, i);
+		const char* ranking_value;
+		int ranking = 0;
+
+		status = serviceReference_getProperty(serviceReference, ((char *) OSGI_FRAMEWORK_SERVICE_RANKING), &ranking_value);
+
+		if (status == CELIX_SUCCESS) {
+			if (ranking_value == NULL) {
+				ranking = DEFAULT_RANKING;
+			} else {
+				char *end;
+				ranking = strtol(ranking_value, &end, 10);
+				if (end == ranking_value) {
+					ranking = DEFAULT_RANKING;
+				}
+			}
+
+			if (ranking > curRanking) {
+				curRanking = ranking;
+				curServRef = serviceReference;
+			}
+		} else {
+			break;
+		}
+
+	}
+
+	arrayList_destroy(serviceReferences);
+
+	if (status == CELIX_SUCCESS) {
+		if (curServRef) {
+			status = bundleContext_getService(event->context, curServRef, &service);
+		} else {
+			service = NULL;
+		}
+
+		if (dependency->set) {
+			dependency->set(serviceDependency_getCallbackHandle(dependency), service);
+		}
+		if (dependency->set_with_ref) {
+			dependency->set_with_ref(serviceDependency_getCallbackHandle(dependency), curServRef, service);
+		}
+
+		if (curServRef) {
+			bundleContext_ungetService(event->context, curServRef, NULL);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency, dm_event_pt event) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		if (dependency->add) {
+			dependency->add(serviceDependency_getCallbackHandle(dependency), event->service);
+		}
+		if (dependency->add_with_ref) {
+			dependency->add_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependency, dm_event_pt event) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		if (dependency->change) {
+			dependency->change(serviceDependency_getCallbackHandle(dependency), event->service);
+		}
+		if (dependency->change_with_ref) {
+			dependency->change_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependency, dm_event_pt event) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		if (dependency->remove) {
+			dependency->remove(serviceDependency_getCallbackHandle(dependency), event->service);
+		}
+		if (dependency->remove_with_ref) {
+			dependency->remove_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		if (dependency->swap) {
+			dependency->swap(serviceDependency_getCallbackHandle(dependency), event->service, newEvent->service);
+		}
+		if (dependency->swap_with_ref) {
+			dependency->swap_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service, newEvent->reference, newEvent->service);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency, bool *available) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*available = dependency->available;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency, bool *required) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*required = dependency->required;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt dependency, bool *instanceBound) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*instanceBound = dependency->instanceBound;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependency, bool *autoConfig) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*autoConfig = dependency->autoConfigure != NULL;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependency, const void*** autoConfigure) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*autoConfigure = dependency->autoConfigure;
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt reference, void *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = NULL;
+	bundle_pt bundle = NULL;
+	dm_event_pt event = NULL;
+	dm_service_dependency_pt dependency = _ptr;
+
+	if (!dependency || !reference || !service) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = component_getBundleContext(dependency->component, &context);
+		if (!context) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getBundle(context, &bundle);
+		if (!bundle) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = event_create(DM_EVENT_ADDED, bundle, context, reference, service, &event);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		component_handleEvent(dependency->component, dependency, event);
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_pt reference, void *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = NULL;
+	bundle_pt bundle = NULL;
+	dm_event_pt event = NULL;
+	dm_service_dependency_pt dependency = _ptr;
+
+	if (!dependency || !reference || !service) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = component_getBundleContext(dependency->component, &context);
+		if (!context) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getBundle(context, &bundle);
+		if (!bundle) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = event_create(DM_EVENT_CHANGED, bundle, context, reference, service, &event);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		component_handleEvent(dependency->component, dependency, event);
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt reference, void *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = NULL;
+	bundle_pt bundle = NULL;
+	dm_event_pt event = NULL;
+	dm_service_dependency_pt dependency = _ptr;
+
+	if (!dependency || !reference || !service) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = component_getBundleContext(dependency->component, &context);
+		if (!context) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getBundle(context, &bundle);
+		if (!bundle) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = event_create(DM_EVENT_REMOVED, bundle, context, reference, service, &event);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		component_handleEvent(dependency->component, dependency, event);
+	}
+
+	return status;
+}
+
+celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt dep, dm_service_dependency_info_pt *out) {
+	celix_status_t status = CELIX_SUCCESS;
+	dm_service_dependency_info_pt info = calloc(1, sizeof(*info));
+	if (info != NULL) {
+		celixThreadMutex_lock(&dep->lock);
+		info->available = dep->available;
+		info->filter = dep->tracked_filter != NULL ? strdup(dep->tracked_filter) : NULL;
+		if (info->filter == NULL) {
+			info->filter = dep->tracked_service != NULL ? strdup(dep->tracked_service) : NULL;
+		}
+		info->required = dep->required;
+
+		array_list_pt refs = serviceTracker_getServiceReferences(dep->tracker);
+		if (refs != NULL) {
+			info->count = arrayList_size(refs);
+		}
+		arrayList_destroy(refs);
+
+		celixThreadMutex_unlock(&dep->lock);
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*out = info;
+	}
+
+	return status;
+}
+
+void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info) {
+	if (info != NULL) {
+		free(info->filter);
+	}
+	free(info);
+}
+
+celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_pt dependency, void* handle) {
+	dependency->callbackHandle = handle;
+    return CELIX_SUCCESS;
+}
+
+static void* serviceDependency_getCallbackHandle(dm_service_dependency_pt dependency) {
+    return dependency->callbackHandle == NULL ? component_getImplementation(dependency->component) : dependency->callbackHandle;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_service_dependency_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_service_dependency_impl.h b/dependency_manager/src/dm_service_dependency_impl.h
new file mode 100644
index 0000000..7026ebf
--- /dev/null
+++ b/dependency_manager/src/dm_service_dependency_impl.h
@@ -0,0 +1,104 @@
+/**
+ *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.
+ */
+/*
+ * dm_service_dependency_impl.h
+ *
+ *  \date       16 Oct 2015
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef DM_SERVICE_DEPENDENCY_IMPL_H_
+#define DM_SERVICE_DEPENDENCY_IMPL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+
+#include "dm_event.h"
+#include "service_tracker.h"
+#include "service_tracker_customizer.h"
+
+#include "dm_service_dependency.h"
+#include "dm_component.h"
+
+struct dm_service_dependency {
+	dm_component_pt component;
+	bool available;
+	bool instanceBound;
+	bool required;
+	dm_service_dependency_strategy_t strategy;
+
+	void* callbackHandle; //This handle can be set to be used instead of the component implementation
+	service_set_fpt set;
+	service_add_fpt add;
+	service_change_fpt change;
+	service_remove_fpt remove;
+	service_swap_fpt swap;
+
+	service_set_with_ref_fpt set_with_ref;
+	service_add_with_ref_fpt add_with_ref;
+	service_change_with_ref_fpt change_with_ref;
+	service_remove_with_ref_fpt remove_with_ref;
+	service_swap_with_ref_fpt swap_with_ref;
+
+	const void **autoConfigure;
+	celix_thread_mutex_t lock;
+
+	bool isStarted;
+
+	bool addCLanguageFilter;
+	char *tracked_service;
+	char *tracked_filter_unmodified;
+	char *tracked_filter;
+
+	service_tracker_pt tracker;
+	service_tracker_customizer_pt tracker_customizer;
+};
+
+celix_status_t serviceDependency_start(dm_service_dependency_pt dependency);
+celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency);
+celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt dependency, bool instanceBound);
+celix_status_t serviceDependency_setAutoConfig(dm_service_dependency_pt dependency, void **autoConfigure);
+celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependency, bool available);
+
+celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependency, dm_component_pt component);
+//celix_status_t serviceDependency_removeComponent(dm_service_dependency_pt dependency, dm_component_pt component);
+
+celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, dm_event_pt event);
+celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency, dm_event_pt event);
+celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependency, dm_event_pt event);
+celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependency, dm_event_pt event);
+celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent);
+celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency, bool *available);
+celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency, bool *required);
+celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt dependency, bool *instanceBound);
+celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependency, bool *autoConfig);
+
+celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependency, const void*** autoConfigure);
+celix_status_t serviceDependency_unlock(dm_service_dependency_pt dependency);
+celix_status_t serviceDependency_lock(dm_service_dependency_pt dependency);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_SERVICE_DEPENDENCY_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_shell_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_shell_activator.c b/dependency_manager/src/dm_shell_activator.c
new file mode 100644
index 0000000..4d6f507
--- /dev/null
+++ b/dependency_manager/src/dm_shell_activator.c
@@ -0,0 +1,94 @@
+/**
+ *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.
+ */
+/*
+ * dm_shell_activator.c
+ *
+ *  \date       16 Oct 2015
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include <constants.h>
+#include "bundle_context.h"
+#include "command.h"
+
+#include "dm_shell_list_command.h"
+#include "shell_constants.h"
+
+struct bundle_instance {
+    service_registration_pt reg;
+    command_service_t  dmCommand;
+    dm_command_handle_t dmHandle;
+};
+
+typedef struct bundle_instance * bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+
+	if(userData==NULL){
+		return CELIX_ILLEGAL_ARGUMENT;
+	}
+
+    struct bundle_instance *bi = calloc(sizeof (struct bundle_instance), 1);
+
+    if (bi==NULL) {
+        return CELIX_ENOMEM;
+    }
+
+    bi->dmHandle.context = context;
+    const char* config = NULL;
+    bundleContext_getPropertyWithDefault(context, SHELL_USE_ANSI_COLORS, SHELL_USE_ANSI_COLORS_DEFAULT_VALUE, &config);
+    bi->dmHandle.useColors = config != NULL && strncmp("true", config, 5) == 0;
+
+    (*userData) = bi;
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+    celix_status_t status = CELIX_SUCCESS;
+    bundle_instance_pt bi = (bundle_instance_pt) userData;
+
+    bi->dmCommand.handle = &bi->dmHandle;
+    bi->dmCommand.executeCommand = (void *)dmListCommand_execute;
+
+    properties_pt props = properties_create();
+    properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+    properties_set(props, OSGI_SHELL_COMMAND_NAME, "dm");
+    properties_set(props, OSGI_SHELL_COMMAND_USAGE, "dm");
+    properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION,
+                   "Gives an overview of the component managemend by a dependency manager.");
+
+    status = bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, &bi->dmCommand, props, &bi->reg);
+
+    return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+    bundle_instance_pt bi = (bundle_instance_pt) userData;
+    serviceRegistration_unregister(bi->reg);
+    return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+    bundle_instance_pt bi = (bundle_instance_pt) userData;
+    free(bi);
+    return CELIX_SUCCESS;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_shell_list_command.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_shell_list_command.c b/dependency_manager/src/dm_shell_list_command.c
new file mode 100644
index 0000000..1600710
--- /dev/null
+++ b/dependency_manager/src/dm_shell_list_command.c
@@ -0,0 +1,126 @@
+/**
+ *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.
+ */
+/*
+ * dm_shell_list_command.c
+ *
+ *  \date       Oct 16, 2015
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <dm_dependency_manager.h>
+#include <dm_shell_list_command.h>
+#include "dm_info.h"
+#include "service_reference.h"
+#include "array_list.h"
+#include "bundle_context.h"
+#include "bundle.h"
+#include "shell.h"
+
+
+static const char * const OK_COLOR = "\033[92m";
+static const char * const WARNING_COLOR = "\033[93m";
+static const char * const NOK_COLOR = "\033[91m";
+static const char * const END_COLOR = "\033[m";
+
+void dmListCommand_execute(dm_command_handle_t* handle, char * line, FILE *out, FILE *err) {
+
+    array_list_pt servRefs = NULL;
+    int i;
+    bundleContext_getServiceReferences(handle->context, DM_INFO_SERVICE_NAME ,NULL, &servRefs);
+
+    if(servRefs==NULL){
+	fprintf(out, "Invalid dm_info ServiceReferences List\n");
+	return;
+    }
+
+    bool colors = handle->useColors;
+
+    for(i = 0; i < arrayList_size(servRefs); i++) {
+        dm_dependency_manager_info_pt info = NULL;
+        dm_info_service_pt infoServ = NULL;
+        service_reference_pt servRef = NULL;
+        servRef = arrayList_get(servRefs, i);
+        bundleContext_getService(handle->context,  servRef, (void**)&infoServ);
+        infoServ->getInfo(infoServ->handle, &info);
+
+        int cmpCnt;
+        for (cmpCnt = 0; cmpCnt < arrayList_size(info->components); cmpCnt++) {
+            dm_component_info_pt compInfo = arrayList_get(info->components, cmpCnt);
+            const char *startColors = "";
+            const char *endColors = "";
+            if (colors) {
+                startColors = compInfo->active ? OK_COLOR : NOK_COLOR;
+                endColors = END_COLOR;
+            }
+            fprintf(out, "Component: Name=%s\n|- ID=%s, %sActive=%s%s, State=%s\n", compInfo->name, compInfo->id, startColors, compInfo->active ?  "true " : "false", endColors, compInfo->state);
+
+            int interfCnt;
+            fprintf(out, "|- Interfaces (%d):\n", arrayList_size(compInfo->interfaces));
+            for(interfCnt = 0 ;interfCnt < arrayList_size(compInfo->interfaces); interfCnt++) {
+                dm_interface_info_pt intfInfo= arrayList_get(compInfo->interfaces, interfCnt);
+                fprintf(out, "   |- Interface: %s\n", intfInfo->name);
+
+                hash_map_iterator_t iter = hashMapIterator_construct((hash_map_pt) intfInfo->properties);
+                char* key = NULL;
+                while((key = hashMapIterator_nextKey(&iter)) != NULL) {
+                    fprintf(out, "      | %15s = %s\n", key, properties_get(intfInfo->properties, key));
+                }
+            }
+
+            int depCnt;
+            fprintf(out, "|- Dependencies (%d):\n", arrayList_size(compInfo->dependency_list));
+            for(depCnt = 0 ;depCnt < arrayList_size(compInfo->dependency_list); depCnt++) {
+                dm_service_dependency_info_pt dependency;
+                dependency = arrayList_get(compInfo->dependency_list, depCnt);
+                const char *startColors = "";
+                const char *endColors = "";
+                if (colors) {
+                    if (dependency->required) {
+                        startColors = dependency->available ? OK_COLOR : NOK_COLOR;
+                    } else {
+                        startColors = dependency->available ? OK_COLOR : WARNING_COLOR;
+                    }
+
+                    endColors = END_COLOR;
+                }
+                fprintf(out, "   |- Dependency: %sAvailable = %s%s, Required = %s, Filter = %s\n",
+                        startColors,
+                        dependency->available ? "true " : "false" ,
+                        endColors,
+                        dependency->required ? "true " : "false",
+                        dependency->filter
+                );
+            }
+            fprintf(out, "\n");
+
+		}
+
+            infoServ->destroyInfo(infoServ->handle, info);
+
+		bundleContext_ungetService(handle->context, servRef, NULL);
+		bundleContext_ungetServiceReference(handle->context, servRef);
+
+    }
+
+	if(servRefs!=NULL){
+		arrayList_destroy(servRefs);
+    }
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_shell_list_command.h
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_shell_list_command.h b/dependency_manager/src/dm_shell_list_command.h
new file mode 100644
index 0000000..6ab0581
--- /dev/null
+++ b/dependency_manager/src/dm_shell_list_command.h
@@ -0,0 +1,42 @@
+/**
+ *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.
+ */
+
+#ifndef DM_SHELL_LIST_COMMAND_H_
+#define DM_SHELL_LIST_COMMAND_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include "command.h"
+
+typedef struct dm_command_handle {
+    bundle_context_pt context;
+    bool useColors;
+} dm_command_handle_t;
+
+void dmListCommand_execute(dm_command_handle_t* handle, char * line, FILE *out, FILE *err);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //DM_SHELL_LSIT_COMMAND_H_
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/CMakeLists.txt b/dependency_manager_cxx/CMakeLists.txt
index c113fa3..65c158d 100644
--- a/dependency_manager_cxx/CMakeLists.txt
+++ b/dependency_manager_cxx/CMakeLists.txt
@@ -24,31 +24,26 @@ if (DEPENDENCY_MANAGER_CXX)
             exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
             set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64)")
             if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
-                add_definitions(-fPIC)
+                set(DM_COMP_OPT -fPIC)
             endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
         endif(CMAKE_UNAME)
     endif(UNIX AND NOT WIN32)
 
-    include_directories(
-            include
-            ${PROJECT_SOURCE_DIR}/dependency_manager/public/include
-            ${PROJECT_SOURCE_DIR}/dependency_manager/private/include
-            ${PROJECT_SOURCE_DIR}/utils/public/include
-    )
-
-    add_library( dependency_manager_cxx_static STATIC
-            ${CMAKE_SOURCE_DIR}/dependency_manager/private/src/dm_component_impl
-            ${CMAKE_SOURCE_DIR}/dependency_manager/private/src/dm_service_dependency
-            ${CMAKE_SOURCE_DIR}/dependency_manager/private/src/dm_event
-            ${CMAKE_SOURCE_DIR}/dependency_manager/private/src/dm_dependency_manager_impl
+    add_library(dependency_manager_cxx_static STATIC
+            ${CMAKE_SOURCE_DIR}/dependency_manager/src/dm_component_impl
+            ${CMAKE_SOURCE_DIR}/dependency_manager/src/dm_service_dependency
+            ${CMAKE_SOURCE_DIR}/dependency_manager/src/dm_event
+            ${CMAKE_SOURCE_DIR}/dependency_manager/src/dm_dependency_manager_impl
             src/dm_activator.cc
     )
-    #set_target_properties(dependency_manager_cxx_static PROPERTIES SOVERSION 1)
+    target_include_directories(dependency_manager_cxx_static PUBLIC include ${CMAKE_SOURCE_DIR}/dependency_manager/api)
+    target_include_directories(dependency_manager_cxx_static PRIVATE src)
+    target_compile_options(dependency_manager_cxx_static PRIVATE ${DM_COMP_OPT})
 
     if (APPLE)
-        target_link_libraries(dependency_manager_cxx_static celix_framework "-undefined dynamic_lookup")
+        target_link_libraries(dependency_manager_cxx_static Celix::framework "-undefined dynamic_lookup")
     else()
-        target_link_libraries(dependency_manager_cxx_static celix_framework)
+        target_link_libraries(dependency_manager_cxx_static Celix::framework)
     endif()
 
     install(
@@ -61,4 +56,9 @@ if (DEPENDENCY_MANAGER_CXX)
     )
     install(TARGETS dependency_manager_cxx_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager_cxx)
 
+    unset(DM_COMP_OPT)
+
+
+    #Setup target aliases to match external usage
+    add_library(Celix::dependency_manager_cxx_static ALIAS dependency_manager_cxx_static)
 endif (DEPENDENCY_MANAGER_CXX)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager_cxx/readme.md
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/readme.md b/dependency_manager_cxx/readme.md
index 80de7af..63dc5b3 100644
--- a/dependency_manager_cxx/readme.md
+++ b/dependency_manager_cxx/readme.md
@@ -59,3 +59,9 @@ For more information examples please see
 - [The C++ Dependency Manager API](include/celix/dm): The c++ dependency manager header files
 - [Dm C++ example](../examples/dm_example_cxx): A DM C++ example.
 - [Getting Started: Using Services with C++](../documents/getting_started/using_services_with_cxx.md): A introduction how to work with services using the C++ dependency manager
+
+## Using info
+
+If the Celix C++ Dependency Manager is installed The `FindCelix.cmake` will set:
+ - The `Celix::shell_api` interface (i.e. headers only) library target
+ - The `Celix::shell` bundle target

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/deployment_admin/CMakeLists.txt b/deployment_admin/CMakeLists.txt
index a6094ad..4a06be5 100644
--- a/deployment_admin/CMakeLists.txt
+++ b/deployment_admin/CMakeLists.txt
@@ -20,55 +20,48 @@ if (DEPLOYMENT_ADMIN)
 	
     find_package(CURL REQUIRED)
     find_package(UUID REQUIRED)
+    find_package(ZLIB REQUIRED)
 
-    add_definitions(-DUSE_FILE32API)
+    add_library(deployment_admin_api INTERFACE)
+    target_include_directories(deployment_admin_api INTERFACE api)
 
-    include_directories("${CURL_INCLUDE_DIR}")
-    include_directories("${UUID_INCLUDE_DIR}")
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/deployment_admin/private/include")
-    include_directories("${PROJECT_SOURCE_DIR}/deployment_admin/public/include")
-    
     add_bundle(deployment_admin
         SYMBOLIC_NAME "apache_celix_deployment_admin"
         VERSION "0.0.2"
         NAME "Apache Celix Deployment Admin"
         SOURCES
-            private/src/deployment_package
-            private/src/deployment_admin
-            private/src/deployment_admin_activator
-            private/src/ioapi
-            private/src/miniunz
-            private/src/unzip
-            private/src/log
-            private/src/log_store
-            private/src/log_sync
+            src/deployment_package
+            src/deployment_admin
+            src/deployment_admin_activator
+            src/ioapi
+            src/miniunz
+            src/unzip
+            src/log
+            src/log_store
+            src/log_sync
+    )
 
-            private/include/deployment_admin.h
-            private/include/deployment_package.h
-            private/include/ioapi.h
-            private/include/log.h
-            private/include/log_event.h
-            private/include/log_store.h
-            private/include/log_sync.h
-            private/include/miniunz.h
-            private/include/unzip.h
+    target_compile_definitions(deployment_admin PRIVATE -DUSE_FILE32API)
+    target_include_directories(deployment_admin PRIVATE
+            src
+            ${CURL_INCLUDE_DIRS}
+            ${UUID_INCLUDE_DIRS}
+            ${ZLIB_INCLUDE_DIRS}
     )
+    target_link_libraries(deployment_admin PRIVATE ${CURL_LIBRARIES} ${UUID_LIBRARIES} ${ZLIB_LIBRARIES} deployment_admin_api)
 
-    
-    install_bundle(deployment_admin
-    	HEADERS
-    		public/include/resource_processor.h
-	)
-    
-    target_link_libraries(deployment_admin celix_framework ${CURL_LIBRARIES})
+    install_bundle(deployment_admin)
 
+    #Setup target aliases to match external usage
+    add_library(Celix::deployment_admin_api ALIAS deployment_admin_api)
+    add_library(Celix::deployment_admin ALIAS deployment_admin)
 
     add_deploy(deployment-admin
-        BUNDLES deployment_admin shell shell_tui log_service log_writer
+        BUNDLES Celix::deployment_admin Celix::shell Celix::shell_tui log_service log_writer
         PROPERTIES
     		"deployment_admin_url=http://localhost:8080"
     		"deployment_admin_identification=celix"
     		"org.osgi.framework.storage.clean=onFirstInit"
     )
+
 endif (DEPLOYMENT_ADMIN)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/README.md
----------------------------------------------------------------------
diff --git a/deployment_admin/README.md b/deployment_admin/README.md
index d28559c..6716415 100644
--- a/deployment_admin/README.md
+++ b/deployment_admin/README.md
@@ -5,10 +5,20 @@ The Celix Deployment Admin implements the OSGi Deployment Admin specification, w
 It can be used for example with Apache Ace, which allows you to centrally manage and distribute software components, configuration data and other artifacts.
 
 ###### Properties
-    deployment_admin_identification     id used by the deployment admin to identify itself
-    deployment_admin_url                url of the deployment server
-    deployment_cache_dir                possible cache dir for the deployment admin update
-    deployment_tags                     tags used by the deployment admin
+                  tags used by the deployment admin
 
-###### CMake option
+## CMake option
     BUILD_DEPLOYMENT_ADMIN=ON
+
+## Deployment Admin Config Options
+
+- deployment_admin_identification     id used by the deployment admin to identify itself
+- deployment_admin_url                url of the deployment server
+- deployment_cache_dir                possible cache dir for the deployment admin update
+- deployment_tags
+
+## Using info
+
+If the Celix Deployment Admin is installed The `FindCelix.cmake` will set:
+ - The `Celix::deployment_admin_api` interface (i.e. headers only) library target
+ - The `Celix::deployment_admin` bundle target

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/api/resource_processor.h
----------------------------------------------------------------------
diff --git a/deployment_admin/api/resource_processor.h b/deployment_admin/api/resource_processor.h
new file mode 100644
index 0000000..f91e13b
--- /dev/null
+++ b/deployment_admin/api/resource_processor.h
@@ -0,0 +1,54 @@
+/**
+ *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.
+ */
+/*
+ * resource_processor.h
+ *
+ *  \date       Feb 13, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef RESOURCE_PROCESSOR_H_
+#define RESOURCE_PROCESSOR_H_
+
+#include "celix_errno.h"
+
+#define DEPLOYMENTADMIN_RESOURCE_PROCESSOR_SERVICE "resource_processor"
+
+typedef struct resource_processor *resource_processor_pt;
+
+typedef struct resource_processor_service *resource_processor_service_pt;
+
+struct resource_processor_service {
+	resource_processor_pt processor;
+	celix_status_t (*begin)(resource_processor_pt processor, char *packageName);
+
+	celix_status_t (*process)(resource_processor_pt processor, char *name, char *path);
+
+	celix_status_t (*dropped)(resource_processor_pt processor, char *name);
+	celix_status_t (*dropAllResources)(resource_processor_pt processor);
+
+	//celix_status_t (*prepare)(resource_processor_pt processor);
+	//celix_status_t (*commit)(resource_processor_pt processor);
+	//celix_status_t (*rollback)(resource_processor_pt processor);
+
+	//celix_status_t (*cancel)(resource_processor_pt processor);
+};
+
+#endif /* RESOURCE_PROCESSOR_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/include/deployment_admin.h
----------------------------------------------------------------------
diff --git a/deployment_admin/private/include/deployment_admin.h b/deployment_admin/private/include/deployment_admin.h
deleted file mode 100644
index a7e3a39..0000000
--- a/deployment_admin/private/include/deployment_admin.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *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.
- */
-/*
- * deployment_admin.h
- *
- *  \date       Nov 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef DEPLOYMENT_ADMIN_H_
-#define DEPLOYMENT_ADMIN_H_
-
-#include "bundle_context.h"
-
-typedef struct deployment_admin *deployment_admin_pt;
-
-struct deployment_admin {
-	celix_thread_t poller;
-	bundle_context_pt context;
-
-	bool running;
-	char *current;
-	hash_map_pt packages;
-	char *targetIdentification;
-	char *pollUrl;
-	char *auditlogUrl;
-	unsigned long long auditlogId;
-	unsigned int aditlogSeqNr;
-};
-
-typedef enum {
-	DEPLOYMENT_ADMIN_AUDIT_EVENT__FRAMEWORK_STARTED = 1005,
-	DEPLOYMENT_ADMIN_AUDIT_EVENT__TARGETPROPERTIES_SET = 4001
-
-} DEPLOYMENT_ADMIN_AUDIT_EVENT;
-
-celix_status_t deploymentAdmin_create(bundle_context_pt context, deployment_admin_pt *admin);
-celix_status_t deploymentAdmin_destroy(deployment_admin_pt admin);
-
-#endif /* DEPLOYMENT_ADMIN_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/include/deployment_package.h
----------------------------------------------------------------------
diff --git a/deployment_admin/private/include/deployment_package.h b/deployment_admin/private/include/deployment_package.h
deleted file mode 100644
index 06c1767..0000000
--- a/deployment_admin/private/include/deployment_package.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *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.
- */
-/*
- * deployment_package.h
- *
- *  \date       Nov 8, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef DEPLOYMENT_PACKAGE_H_
-#define DEPLOYMENT_PACKAGE_H_
-
-#include "version.h"
-#include "bundle_context.h"
-
-#include "array_list.h"
-
-struct bundle_info {
-	char *path;
-	version_pt version;
-	char *symbolicName;
-	bool customizer;
-
-	properties_pt attributes;
-};
-
-typedef struct bundle_info *bundle_info_pt;
-
-struct resource_info {
-	char *path;
-	properties_pt attributes;
-
-	char *resourceProcessor;
-};
-
-typedef struct resource_info *resource_info_pt;
-
-struct deployment_package {
-	bundle_context_pt context;
-	manifest_pt manifest;
-	array_list_pt bundleInfos;
-	array_list_pt resourceInfos;
-	hash_map_pt nameToBundleInfo;
-	hash_map_pt pathToEntry;
-};
-
-typedef struct deployment_package *deployment_package_pt;
-
-celix_status_t deploymentPackage_create(bundle_context_pt context, manifest_pt manifest, deployment_package_pt *package);
-celix_status_t deploymentPackage_destroy(deployment_package_pt package);
-celix_status_t deploymentPackage_getName(deployment_package_pt package, const char** name);
-celix_status_t deploymentPackage_getBundleInfos(deployment_package_pt package, array_list_pt *infos);
-celix_status_t deploymentPackage_getBundleInfoByName(deployment_package_pt package, const char* name, bundle_info_pt *info);
-celix_status_t deploymentPackage_getResourceInfos(deployment_package_pt package, array_list_pt *infos);
-celix_status_t deploymentPackage_getResourceInfoByPath(deployment_package_pt package, const char* path, resource_info_pt *info);
-celix_status_t deploymentPackage_getBundle(deployment_package_pt package, const char* name, bundle_pt *bundle);
-celix_status_t deploymentPackage_getVersion(deployment_package_pt package, version_pt *version);
-
-#endif /* DEPLOYMENT_PACKAGE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/include/ioapi.h
----------------------------------------------------------------------
diff --git a/deployment_admin/private/include/ioapi.h b/deployment_admin/private/include/ioapi.h
deleted file mode 100644
index 8309c4c..0000000
--- a/deployment_admin/private/include/ioapi.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/* ioapi.h -- IO base function header for compress/uncompress .zip
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications for Zip64 support
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-         Changes
-
-    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
-    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
-               More if/def section may be needed to support other platforms
-    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
-                          (but you should use iowin32.c for windows instead)
-
-*/
-
-#ifndef _ZLIBIOAPI64_H
-#define _ZLIBIOAPI64_H
-
-#if (!defined(_WIN32)) && (!defined(WIN32))
-
-  // Linux needs this to support file operation on files larger then 4+GB
-  // But might need better if/def to select just the platforms that needs them.
-
-        #ifndef __USE_FILE_OFFSET64
-                #define __USE_FILE_OFFSET64
-        #endif
-        #ifndef __USE_LARGEFILE64
-                #define __USE_LARGEFILE64
-        #endif
-        #ifndef _LARGEFILE64_SOURCE
-                #define _LARGEFILE64_SOURCE
-        #endif
-        #ifndef _FILE_OFFSET_BIT
-                #define _FILE_OFFSET_BIT 64
-        #endif
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "zlib.h"
-
-#if defined(USE_FILE32API)
-#define fopen64 fopen
-#define ftello64 ftell
-#define fseeko64 fseek
-#else
-#ifdef _MSC_VER
- #define fopen64 fopen
- #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
-  #define ftello64 _ftelli64
-  #define fseeko64 _fseeki64
- #else // old MSC
-  #define ftello64 ftell
-  #define fseeko64 fseek
- #endif
-#endif
-#endif
-
-/*
-#ifndef ZPOS64_T
-  #ifdef _WIN32
-                #define ZPOS64_T fpos_t
-  #else
-    #include <stdint.h>
-    #define ZPOS64_T uint64_t
-  #endif
-#endif
-*/
-
-#ifdef HAVE_MINIZIP64_CONF_H
-#include "mz64conf.h"
-#endif
-
-/* a type choosen by DEFINE */
-#ifdef HAVE_64BIT_INT_CUSTOM
-typedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;
-#else
-#ifdef HAS_STDINT_H
-#include "stdint.h"
-typedef uint64_t ZPOS64_T;
-#else
-
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-typedef unsigned __int64 ZPOS64_T;
-#else
-typedef unsigned long long int ZPOS64_T;
-#endif
-#endif
-#endif
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define ZLIB_FILEFUNC_SEEK_CUR (1)
-#define ZLIB_FILEFUNC_SEEK_END (2)
-#define ZLIB_FILEFUNC_SEEK_SET (0)
-
-#define ZLIB_FILEFUNC_MODE_READ      (1)
-#define ZLIB_FILEFUNC_MODE_WRITE     (2)
-#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
-
-#define ZLIB_FILEFUNC_MODE_EXISTING (4)
-#define ZLIB_FILEFUNC_MODE_CREATE   (8)
-
-
-#ifndef ZCALLBACK
- #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
-   #define ZCALLBACK CALLBACK
- #else
-   #define ZCALLBACK
- #endif
-#endif
-
-
-
-
-typedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));
-typedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-typedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
-typedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));
-typedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
-
-typedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));
-typedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));
-
-
-/* here is the "old" 32 bits structure structure */
-typedef struct zlib_filefunc_def_s
-{
-    open_file_func      zopen_file;
-    read_file_func      zread_file;
-    write_file_func     zwrite_file;
-    tell_file_func      ztell_file;
-    seek_file_func      zseek_file;
-    close_file_func     zclose_file;
-    testerror_file_func zerror_file;
-    voidpf              opaque;
-} zlib_filefunc_def;
-
-typedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));
-typedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
-typedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));
-
-typedef struct zlib_filefunc64_def_s
-{
-    open64_file_func    zopen64_file;
-    read_file_func      zread_file;
-    write_file_func     zwrite_file;
-    tell64_file_func    ztell64_file;
-    seek64_file_func    zseek64_file;
-    close_file_func     zclose_file;
-    testerror_file_func zerror_file;
-    voidpf              opaque;
-} zlib_filefunc64_def;
-
-void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
-void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
-
-/* now internal definition, only for zip.c and unzip.h */
-typedef struct zlib_filefunc64_32_def_s
-{
-    zlib_filefunc64_def zfile_func64;
-    open_file_func      zopen32_file;
-    tell_file_func      ztell32_file;
-    seek_file_func      zseek32_file;
-} zlib_filefunc64_32_def;
-
-
-#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))
-#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))
-//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
-//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
-#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))
-#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))
-
-voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
-long    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
-ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
-
-void    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
-
-#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))
-#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))
-#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/include/log.h
----------------------------------------------------------------------
diff --git a/deployment_admin/private/include/log.h b/deployment_admin/private/include/log.h
deleted file mode 100644
index fa77911..0000000
--- a/deployment_admin/private/include/log.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *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.
- */
-/*
- * log.h
- *
- *  \date       Apr 18, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_H_
-#define LOG_H_
-
-#include "log_event.h"
-#include "log_store.h"
-
-#include "bundle_event.h"
-#include "framework_event.h"
-
-typedef struct log *log_pt;
-
-celix_status_t log_create(log_store_pt store, log_pt *log);
-celix_status_t log_log(log_pt log, unsigned int type, properties_pt properties);
-
-celix_status_t log_bundleChanged(void * listener, bundle_event_pt event);
-celix_status_t log_frameworkEvent(void * listener, framework_event_pt event);
-
-#endif /* LOG_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/include/log_event.h
----------------------------------------------------------------------
diff --git a/deployment_admin/private/include/log_event.h b/deployment_admin/private/include/log_event.h
deleted file mode 100644
index c1a76a9..0000000
--- a/deployment_admin/private/include/log_event.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *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.
- */
-/*
- * log_event.h
- *
- *  \date       Apr 19, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_EVENT_H_
-#define LOG_EVENT_H_
-
-#include "properties.h"
-
-struct log_event {
-	char *targetId;
-	unsigned long logId;
-	unsigned long id;
-	unsigned long time;
-	unsigned int type;
-	properties_pt properties;
-};
-
-typedef struct log_event *log_event_pt;
-
-#endif /* LOG_EVENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/include/log_store.h
----------------------------------------------------------------------
diff --git a/deployment_admin/private/include/log_store.h b/deployment_admin/private/include/log_store.h
deleted file mode 100644
index 84299b3..0000000
--- a/deployment_admin/private/include/log_store.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *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.
- */
-/*
- * log_store.h
- *
- *  \date       Apr 18, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_STORE_H_
-#define LOG_STORE_H_
-
-#include "log_event.h"
-
-#include "properties.h"
-#include "array_list.h"
-
-typedef struct log_store *log_store_pt;
-
-celix_status_t logStore_create(log_store_pt *store);
-celix_status_t logStore_put(log_store_pt store, unsigned int type, properties_pt properties, log_event_pt *event);
-
-celix_status_t logStore_getLogId(log_store_pt store, unsigned long *id);
-celix_status_t logStore_getEvents(log_store_pt store, array_list_pt *events);
-
-celix_status_t logStore_getHighestId(log_store_pt store, long *id);
-
-#endif /* LOG_STORE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/include/log_sync.h
----------------------------------------------------------------------
diff --git a/deployment_admin/private/include/log_sync.h b/deployment_admin/private/include/log_sync.h
deleted file mode 100644
index 7cd10d9..0000000
--- a/deployment_admin/private/include/log_sync.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- *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.
- */
-/*
- * log_sync.h
- *
- *  \date       Apr 19, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_SYNC_H_
-#define LOG_SYNC_H_
-
-#include "log_store.h"
-
-typedef struct log_sync *log_sync_pt;
-
-celix_status_t logSync_create(char *targetId, log_store_pt store, log_sync_pt *logSync);
-
-#endif /* LOG_SYNC_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/include/miniunz.h
----------------------------------------------------------------------
diff --git a/deployment_admin/private/include/miniunz.h b/deployment_admin/private/include/miniunz.h
deleted file mode 100644
index f54b1fa..0000000
--- a/deployment_admin/private/include/miniunz.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- *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.
- */
-/*
- * miniunz.h
- *
- *  \date       Aug 8, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef MINIUNZ_H_
-#define MINIUNZ_H_
-
-#include "celix_errno.h"
-
-celix_status_t unzip_extractDeploymentPackage(char * packageName, char * destination);
-
-#endif /* MINIUNZ_H_ */


[07/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_http/private/test/rsa_client_server_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/test/rsa_client_server_tests.cpp b/remote_services/remote_service_admin_http/private/test/rsa_client_server_tests.cpp
deleted file mode 100644
index 19cf103..0000000
--- a/remote_services/remote_service_admin_http/private/test/rsa_client_server_tests.cpp
+++ /dev/null
@@ -1,495 +0,0 @@
-/**
- *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.
- */
-#include <CppUTest/TestHarness.h>
-#include <remote_constants.h>
-#include <constants.h>
-#include "CppUTest/CommandLineTestRunner.h"
-#include "../../../examples/calculator_service/public/include/calculator_service.h"
-
-extern "C" {
-
-	#include <stdio.h>
-	#include <stdint.h>
-	#include <stdlib.h>
-	#include <string.h>
-	#include <ctype.h>
-	#include <unistd.h>
-
-	#include "celix_launcher.h"
-	#include "framework.h"
-	#include "remote_service_admin.h"
-	#include "calculator_service.h"
-	#include "bundle.h"
-
-	#define DISCOVERY_CFG_NAME      "apache_celix_rsa_discovery_configured"
-	#define RSA_HTTP_NAME           "apache_celix_remote_service_admin_http"
-	#define TOPOLOGY_MANAGER_NAME   "apache_celix_rs_topology_manager"
-	#define CALCULATOR_PROXY   		"apache_celix_remoting_calculator_proxy"
-	#define CALCULATOR_ENDPOINT   	"apache_celix_remoting_calculator_endpoint"
-
-
-	static framework_pt	serverFramework = NULL;
-	static bundle_context_pt serverContext = NULL;
-
-	static framework_pt clientFramework = NULL;
-	static bundle_context_pt clientContext = NULL;
-
-	static void setupFm(void) {
-		int rc = 0;
-		bundle_pt bundle = NULL;
-
-		//server
-		rc = celixLauncher_launch("server.properties", &serverFramework);
-		CHECK_EQUAL(CELIX_SUCCESS, rc);
-
-		bundle = NULL;
-		rc = framework_getFrameworkBundle(serverFramework, &bundle);
-		CHECK_EQUAL(CELIX_SUCCESS, rc);
-
-		rc = bundle_getContext(bundle, &serverContext);
-		CHECK_EQUAL(CELIX_SUCCESS, rc);
-
-		//client
-		rc = celixLauncher_launch("client.properties", &clientFramework);
-		CHECK_EQUAL(CELIX_SUCCESS, rc);
-
-		bundle = NULL;
-		rc = framework_getFrameworkBundle(clientFramework, &bundle);
-		CHECK_EQUAL(CELIX_SUCCESS, rc);
-
-		rc = bundle_getContext(bundle, &clientContext);
-		CHECK_EQUAL(CELIX_SUCCESS, rc);
-	}
-
-	static void teardownFm(void) {
-		celixLauncher_stop(serverFramework);
-		celixLauncher_waitForShutdown(serverFramework);
-		celixLauncher_destroy(serverFramework);
-
-		celixLauncher_stop(clientFramework);
-		celixLauncher_waitForShutdown(clientFramework);
-		celixLauncher_destroy(clientFramework);
-
-		serverContext = NULL;
-		serverFramework = NULL;
-		clientContext = NULL;
-		clientFramework = NULL;
-	}
-
-	static void test1(void) {
-		celix_status_t status;
-		service_reference_pt ref = NULL;
-		calculator_service_pt calcService = NULL;
-        int retries = 4;
-
-        while (ref == NULL && retries > 0) {
-            printf("Waiting for service .. %d\n", retries);
-            status = bundleContext_getServiceReference(clientContext, (char *) CALCULATOR_SERVICE, &ref);
-            usleep(1000000);
-            --retries;
-        }
-
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-		CHECK(ref != NULL);
-
-		status = bundleContext_getService(clientContext, ref, (void **) &calcService);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-		CHECK(calcService != NULL);
-
-		double result = 0;
-		status = calcService->add(calcService->calculator, 2.0, 5.0, &result);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-		CHECK_EQUAL(7.0, result);
-
-		bundleContext_ungetService(clientContext, ref, NULL);
-		bundleContext_ungetServiceReference(clientContext, ref);
-	}
-
-
-	static celix_status_t getPermutations(array_list_pt bundleIds, int from, int to, array_list_pt permutations) {
-		celix_status_t status = CELIX_SUCCESS;
-		int i = 0;
-
-		if (from == to) {
-			long* permutation = (long*) calloc(to + 1, sizeof(*permutation));
-
-			if (!permutation) {
-				status = CELIX_ENOMEM;
-			} else {
-				for (; i <= to; i++) {
-					permutation[i] = (long) arrayList_get(bundleIds, i);
-				}
-
-				arrayList_add(permutations, permutation);
-			}
-		} else {
-			for (i = from; i <= to; i++) {
-				long fromOrg = (long) arrayList_get(bundleIds, from);
-				long iOrg = (long) arrayList_get(bundleIds, i);
-
-				arrayList_set(bundleIds, from, (void*) iOrg);
-				arrayList_set(bundleIds, i, (void*) fromOrg);
-
-				status = getPermutations(bundleIds, from + 1, to, permutations);
-
-				arrayList_set(bundleIds, from, (void*) fromOrg);
-				arrayList_set(bundleIds, i, (void*) iOrg);
-			}
-		}
-
-		return status;
-	}
-
-	static celix_status_t getSpecifiedBundles(bundle_context_pt context, array_list_pt bundleNames, array_list_pt retrievedBundles) {
-		celix_status_t status;
-		array_list_pt bundles = NULL;
-
-		status = bundleContext_getBundles(context, &bundles);
-
-		if (status == CELIX_SUCCESS) {
-			unsigned int size = arrayList_size(bundles);
-			unsigned int i;
-
-			for (i = 0; i < size; i++) {
-				module_pt module = NULL;
-				const char *name = NULL;
-
-				bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
-
-				status = bundle_getCurrentModule(bundle, &module);
-
-				if (status == CELIX_SUCCESS) {
-					status = module_getSymbolicName(module, &name);
-				}
-
-				if (status == CELIX_SUCCESS) {
-
-					printf("FOUND %s\n", name);
-
-					array_list_iterator_pt iter = arrayListIterator_create(bundleNames);
-
-					while(arrayListIterator_hasNext(iter)) {
-						char* bundleName = (char*) arrayListIterator_next(iter);
-
-						if ((strcmp(name, bundleName) == 0)) {
-
-							bundle_archive_pt bundleArchive = NULL;
-							long bundleId = -1;
-
-							status = bundle_getArchive(bundle, &bundleArchive);
-
-							if (status == CELIX_SUCCESS) {
-								status = bundleArchive_getId(bundleArchive, &bundleId);
-							}
-
-							if (status == CELIX_SUCCESS) {
-								arrayList_add(retrievedBundles, (void*) bundleId);
-								break;
-							}
-						}
-					}
-
-					arrayListIterator_destroy(iter);
-
-				}
-			}
-
-			arrayList_destroy(bundles);
-		}
-
-		return status;
-	}
-
-	static celix_status_t stopStartPermutation(bundle_context_pt context, long* permutation, int size) {
-		celix_status_t status = CELIX_SUCCESS;
-		int y = 0;
-
-		printf("Test stop/start permutation: ");
-
-		for (y = 0; (y < size) && (status == CELIX_SUCCESS); y++) {
-			bundle_pt bundle = NULL;
-
-			status = bundleContext_getBundleById(context, permutation[y], &bundle);
-
-			if (status == CELIX_SUCCESS) {
-				module_pt module = NULL;
-				const char *name = NULL;
-
-				status = bundle_getCurrentModule(bundle, &module);
-
-				if (status == CELIX_SUCCESS) {
-					status = module_getSymbolicName(module, &name);
-					printf("%s (%ld) ", name, permutation[y]);
-				}
-			}
-		}
-		printf("\n");
-
-		// stop all bundles
-		if (status == CELIX_SUCCESS) {
-			for (y = 0; (y < size) && (status == CELIX_SUCCESS); y++) {
-				bundle_pt bundle = NULL;
-
-				status = bundleContext_getBundleById(context, permutation[y], &bundle);
-
-				if (status == CELIX_SUCCESS) {
-					printf("stop bundle: %ld\n", permutation[y]);
-					status = bundle_stop(bundle);
-				}
-			}
-		}
-
-		// verify stop state
-		if (status == CELIX_SUCCESS) {
-			for (y = 0; (y < size) && (status == CELIX_SUCCESS); y++) {
-				bundle_pt bundle = NULL;
-
-				status = bundleContext_getBundleById(context, permutation[y], &bundle);
-
-				if (status == CELIX_SUCCESS) {
-					bundle_state_e state;
-					status = bundle_getState(bundle, &state);
-
-					if (state != OSGI_FRAMEWORK_BUNDLE_RESOLVED) {
-						printf("bundle %ld has state %d (should be %d) \n", permutation[y], state, OSGI_FRAMEWORK_BUNDLE_RESOLVED);
-						status = CELIX_ILLEGAL_STATE;
-					}
-				}
-			}
-		}
-
-		// start all bundles
-		if (status == CELIX_SUCCESS) {
-
-			for (y = 0; (y < size) && (status == CELIX_SUCCESS); y++) {
-				bundle_pt bundle = NULL;
-
-				status = bundleContext_getBundleById(context, permutation[y], &bundle);
-
-				if (status == CELIX_SUCCESS) {
-					printf("start bundle: %ld\n", permutation[y]);
-					status = bundle_start(bundle);
-				}
-			}
-		}
-
-		// verify started state
-		if (status == CELIX_SUCCESS) {
-			for (y = 0; (y < size) && (status == CELIX_SUCCESS); y++) {
-				bundle_pt bundle = NULL;
-
-				status = bundleContext_getBundleById(context, permutation[y], &bundle);
-
-				if (status == CELIX_SUCCESS) {
-					bundle_state_e state;
-					status = bundle_getState(bundle, &state);
-
-					if (state != OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
-						printf("bundle %ld has state %d (should be %d) \n", permutation[y], state, OSGI_FRAMEWORK_BUNDLE_ACTIVE);
-						status = CELIX_ILLEGAL_STATE;
-					}
-				}
-			}
-		}
-
-		return status;
-	}
-
-	static void testImport(void) {
-		celix_status_t status;
-		array_list_pt bundleNames = NULL;
-		array_list_pt bundlePermutations = NULL;
-		array_list_pt rsaBundles = NULL;
-		unsigned int i, size;
-
-		arrayList_create(&bundleNames);
-		arrayList_create(&bundlePermutations);
-		arrayList_create(&rsaBundles);
-
-		arrayList_add(bundleNames, (void*) DISCOVERY_CFG_NAME);
-		arrayList_add(bundleNames, (void*) RSA_HTTP_NAME);
-		arrayList_add(bundleNames, (void*) TOPOLOGY_MANAGER_NAME);
-
-		status = getSpecifiedBundles(clientContext, bundleNames, rsaBundles);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-		CHECK_EQUAL(arrayList_size(rsaBundles), arrayList_size(bundleNames));
-
-		status = getPermutations(rsaBundles, 0, arrayList_size(rsaBundles) - 1, bundlePermutations);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-
-		size = arrayList_size(bundlePermutations);
-
-		for (i = 0; i < size; ++i) {
-			long* singlePermutation = (long*) arrayList_get(bundlePermutations, i);
-
-			status = stopStartPermutation(clientContext, singlePermutation, arrayList_size(rsaBundles));
-			CHECK_EQUAL(CELIX_SUCCESS, status);
-
-			// check whether calc service is available
-			test1();
-
-			free(singlePermutation);
-		}
-
-		arrayList_destroy(bundlePermutations);
-		arrayList_destroy(bundleNames);
-		arrayList_destroy(rsaBundles);
-	}
-
-	static void testExport(void) {
-		celix_status_t status;
-		array_list_pt bundleNames = NULL;
-		array_list_pt bundlePermutations = NULL;
-		array_list_pt rsaBundles = NULL;
-
-		unsigned int i, size;
-
-		arrayList_create(&bundleNames);
-		arrayList_create(&bundlePermutations);
-		arrayList_create(&rsaBundles);
-
-		arrayList_add(bundleNames, (void*) DISCOVERY_CFG_NAME);
-		arrayList_add(bundleNames, (void*) RSA_HTTP_NAME);
-		arrayList_add(bundleNames, (void*) TOPOLOGY_MANAGER_NAME);
-
-		status = getSpecifiedBundles(serverContext, bundleNames, rsaBundles);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-		CHECK_EQUAL(arrayList_size(rsaBundles), arrayList_size(bundleNames));
-
-		status = getPermutations(rsaBundles, 0, arrayList_size(rsaBundles) - 1, bundlePermutations);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-
-		size = arrayList_size(bundlePermutations);
-
-		for (i = 0; i < size; ++i) {
-			long* singlePermutation = (long*) arrayList_get(bundlePermutations, i);
-
-			status = stopStartPermutation(serverContext, singlePermutation, arrayList_size(rsaBundles));
-			CHECK_EQUAL(CELIX_SUCCESS, status);
-
-			/* we need to sleep here for a bit to ensure
-			 * that the client has flushed the old discovery
-			 * values
-			 */
-			sleep(2);
-
-			// check whether calc service is available
-			test1();
-
-			free(singlePermutation);
-		}
-
-		arrayList_destroy(bundlePermutations);
-		arrayList_destroy(bundleNames);
-		arrayList_destroy(rsaBundles);
-	}
-
-	static void testProxyRemoval(void) {
-		celix_status_t status;
-		bundle_pt bundle = NULL;
-		array_list_pt bundleNames = NULL;
-		array_list_pt proxyBundle = NULL;
-		service_reference_pt ref = NULL;
-
-		arrayList_create(&bundleNames);
-		arrayList_create(&proxyBundle);
-
-		arrayList_add(bundleNames, (void*) CALCULATOR_PROXY);
-		status = getSpecifiedBundles(clientContext, bundleNames, proxyBundle);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-		CHECK_EQUAL(arrayList_size(proxyBundle), arrayList_size(bundleNames));
-
-		status = bundleContext_getBundleById(clientContext, (long) arrayList_get(proxyBundle, 0), &bundle);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-
-		status = bundle_stop(bundle);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-
-		status = bundleContext_getServiceReference(clientContext, (char *) CALCULATOR_SERVICE, &ref);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-		CHECK(ref == NULL);
-
-		arrayList_destroy(bundleNames);
-		arrayList_destroy(proxyBundle);
-	}
-
-	/*
-	static void testEndpointRemoval(void) {
-		celix_status_t status;
-		bundle_pt bundle = NULL;
-		array_list_pt bundleNames = NULL;
-		array_list_pt endpointBundle = NULL;
-		service_reference_pt ref = NULL;
-
-		arrayList_create(&bundleNames);
-		arrayList_create(&endpointBundle);
-
-		arrayList_add(bundleNames, (void*) CALCULATOR_ENDPOINT);
-		status = getSpecifiedBundles(serverContext, bundleNames, endpointBundle);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-		CHECK_EQUAL(arrayList_size(endpointBundle), arrayList_size(bundleNames));
-
-		status = bundleContext_getBundleById(serverContext, (long) arrayList_get(endpointBundle, 0), &bundle);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-
-		status = bundle_stop(bundle);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-
-		status = bundleContext_getServiceReference(serverContext, (char *) CALCULATOR_SERVICE, &ref);
-		CHECK_EQUAL(CELIX_SUCCESS, status);
-		CHECK(ref == NULL);
-
-		arrayList_destroy(bundleNames);
-		arrayList_destroy(endpointBundle);
-	}
-	*/
-}
-
-TEST_GROUP(RsaHttpClientServerTests) {
-	void setup() {
-		setupFm();
-	}
-
-	void teardown() {
-		teardownFm();
-	}
-};
-
-TEST(RsaHttpClientServerTests, Test1) {
-	test1();
-}
-
-TEST(RsaHttpClientServerTests, TestImport) {
-	testImport();
-}
-
-TEST(RsaHttpClientServerTests, TestExport) {
-	testExport();
-}
-
-TEST(RsaHttpClientServerTests, TestProxyRemoval) {
-	testProxyRemoval();
-}
-/*
-TEST(RsaHttpClientServerTests, TestEndpointRemoval) {
-	// test is currenlty failing
-	testEndpointRemoval();
-}
-*/
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_http/private/test/run_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/test/run_tests.cpp b/remote_services/remote_service_admin_http/private/test/run_tests.cpp
deleted file mode 100644
index fb6ca3a..0000000
--- a/remote_services/remote_service_admin_http/private/test/run_tests.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- *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.
- */
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"
-
-int main(int argc, char** argv) {
-    return RUN_ALL_TESTS(argc, argv);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_http/private/test/server.properties.in
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/test/server.properties.in b/remote_services/remote_service_admin_http/private/test/server.properties.in
deleted file mode 100644
index e7d48ab..0000000
--- a/remote_services/remote_service_admin_http/private/test/server.properties.in
+++ /dev/null
@@ -1,25 +0,0 @@
-# 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.
-
-cosgi.auto.start.1=@rsa_bundle_file@ @calc_bundle_file@ @discovery_configured_bundle_file@ @topology_manager_bundle_file@
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-ENDPOINTS=@server_endpoints@
-RSA_PORT=50882
-DISCOVERY_CFG_SERVER_PORT=50992
-org.osgi.framework.storage.clean=onFirstInit
-org.osgi.framework.storage=.cacheServer
-DISCOVERY_CFG_POLL_INTERVAL=1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/topology_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/topology_manager/CMakeLists.txt b/remote_services/topology_manager/CMakeLists.txt
index 46a3bac..4bac4fd 100644
--- a/remote_services/topology_manager/CMakeLists.txt
+++ b/remote_services/topology_manager/CMakeLists.txt
@@ -29,8 +29,6 @@ if (RSA_TOPOLOGY_MANAGER)
         private/src/scope
         private/src/activator
 
-        ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
-
         private/include/topology_manager.h
         public/include/tm_scope.h
         VERSION 0.9.0
@@ -38,6 +36,7 @@ if (RSA_TOPOLOGY_MANAGER)
         NAME
             "Apache Celix RS Topology Manager"
     )
+    target_link_libraries(topology_manager PRIVATE Celix::log_helper)
 
     install_bundle(topology_manager)
 
@@ -50,6 +49,4 @@ if (RSA_TOPOLOGY_MANAGER)
         include_directories(${CPPUTEST_EXT_INCLUDE_DIR})
         add_subdirectory(tms_tst)
    endif (ENABLE_TESTING)
-
-   target_link_libraries(topology_manager celix_framework celix_utils)
 endif (RSA_TOPOLOGY_MANAGER)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/topology_manager/tms_tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/topology_manager/tms_tst/CMakeLists.txt b/remote_services/topology_manager/tms_tst/CMakeLists.txt
index 16ad011..dc671e4 100644
--- a/remote_services/topology_manager/tms_tst/CMakeLists.txt
+++ b/remote_services/topology_manager/tms_tst/CMakeLists.txt
@@ -39,7 +39,7 @@ add_executable(test_tm_scoped
     
    ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
 )
-target_link_libraries(test_tm_scoped celix_framework celix_utils ${CPPUTEST_LIBRARY} ${JANSSON_LIBRARY})
+target_link_libraries(test_tm_scoped Celix::framework ${CPPUTEST_LIBRARY} ${JANSSON_LIBRARY} Celix::log_helper)
 
 add_dependencies(test_tm_scoped remote_service_admin_dfi topology_manager calculator)
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/topology_manager/tms_tst/bundle/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/topology_manager/tms_tst/bundle/CMakeLists.txt b/remote_services/topology_manager/tms_tst/bundle/CMakeLists.txt
index 6e269f5..9e36e4c 100644
--- a/remote_services/topology_manager/tms_tst/bundle/CMakeLists.txt
+++ b/remote_services/topology_manager/tms_tst/bundle/CMakeLists.txt
@@ -32,4 +32,4 @@ bundle_files(topology_manager_test_bundle
     DESTINATION .
 )
 
-target_link_libraries(topology_manager_test_bundle ${CPPUTEST_LIBRARY} celix_framework celix_utils)
+target_link_libraries(topology_manager_test_bundle PRIVATE ${CPPUTEST_LIBRARY})

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/topology_manager/tms_tst/disc_mock/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/topology_manager/tms_tst/disc_mock/CMakeLists.txt b/remote_services/topology_manager/tms_tst/disc_mock/CMakeLists.txt
index a19efc7..b961de7 100644
--- a/remote_services/topology_manager/tms_tst/disc_mock/CMakeLists.txt
+++ b/remote_services/topology_manager/tms_tst/disc_mock/CMakeLists.txt
@@ -30,4 +30,4 @@ add_bundle(topology_manager_disc_mock_bundle
         disc_mock_service.c
 
 )
-target_link_libraries(topology_manager_disc_mock_bundle ${CPPUTEST_LIBRARY} celix_framework celix_utils)
+target_link_libraries(topology_manager_disc_mock_bundle PRIVATE ${CPPUTEST_LIBRARY} Celix::framework)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_shell/CMakeLists.txt b/remote_shell/CMakeLists.txt
index 7c37d13..a7f5d36 100644
--- a/remote_shell/CMakeLists.txt
+++ b/remote_shell/CMakeLists.txt
@@ -22,25 +22,23 @@ if (REMOTE_SHELL)
      	VERSION "0.0.2"
      	NAME: "Apache Celix Remote Shell"
 		SOURCES
-			private/src/activator
-			private/src/connection_listener
-			private/src/shell_mediator
-			private/src/remote_shell
-
-			${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
-
-			private/include/remote_shell.h
-			private/include/connection_listener.h
+			src/activator
+			src/connection_listener
+			src/shell_mediator
+			src/remote_shell
 	)
-	
+
+	target_include_directories(remote_shell PRIVATE src)
+	target_link_libraries(remote_shell PRIVATE log_helper)
 	install_bundle(remote_shell)
- 
-    include_directories("private/include")
+
     include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
     include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
     
-    target_link_libraries(remote_shell celix_framework)
+    target_link_libraries(remote_shell PRIVATE Celix::shell_api)
+
+	#Alias setup to match external usage
+	add_library(Celix::remote_shell ALIAS remote_shell)
 
-    add_deploy("remote_shell_deploy" NAME "remote_shell"  BUNDLES shell remote_shell shell_tui log_service)
+    add_deploy("remote_shell_deploy" NAME "remote_shell"  BUNDLES Celix::shell Celix::remote_shell Celix::shell_tui log_service)
 endif (REMOTE_SHELL)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/private/include/connection_listener.h
----------------------------------------------------------------------
diff --git a/remote_shell/private/include/connection_listener.h b/remote_shell/private/include/connection_listener.h
deleted file mode 100644
index 392d6ec..0000000
--- a/remote_shell/private/include/connection_listener.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *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.
- */
-/*
- * connection_listener.h
- *
- *  \date       Nov 4, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef connectionListener_H_
-#define connectionListener_H_
-
-#include <bundle_context.h>
-#include <celix_errno.h>
-
-#include "remote_shell.h"
-
-typedef struct connection_listener *connection_listener_pt;
-
-celix_status_t connectionListener_create(remote_shell_pt remoteShell, int port, connection_listener_pt *instance);
-celix_status_t connectionListener_destroy(connection_listener_pt instance);
-celix_status_t connectionListener_start(connection_listener_pt instance);
-celix_status_t connectionListener_stop(connection_listener_pt instance);
-
-#endif /* connectionListener_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/private/include/remote_shell.h
----------------------------------------------------------------------
diff --git a/remote_shell/private/include/remote_shell.h b/remote_shell/private/include/remote_shell.h
deleted file mode 100644
index 55249a8..0000000
--- a/remote_shell/private/include/remote_shell.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- *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.
- */
-/*
- * remote_shell.h
- *
- *  \date       Nov 4, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef REMOTE_SHELL_H_
-#define REMOTE_SHELL_H_
-
-#include <bundle_context.h>
-#include <celix_errno.h>
-
-#include "shell_mediator.h"
-
-struct remote_shell {
-	log_helper_pt* loghelper;
-	shell_mediator_pt mediator;
-	celix_thread_mutex_t mutex;
-	int maximumConnections;
-
-	array_list_pt connections;
-};
-typedef struct remote_shell *remote_shell_pt;
-
-celix_status_t remoteShell_create(shell_mediator_pt mediator, int maximumConnections, remote_shell_pt *instance);
-celix_status_t remoteShell_destroy(remote_shell_pt instance);
-celix_status_t remoteShell_addConnection(remote_shell_pt instance, int socket);
-celix_status_t remoteShell_stopConnections(remote_shell_pt instance);
-
-#endif /* REMOTE_SHELL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/private/include/shell_mediator.h
----------------------------------------------------------------------
diff --git a/remote_shell/private/include/shell_mediator.h b/remote_shell/private/include/shell_mediator.h
deleted file mode 100644
index 24e8250..0000000
--- a/remote_shell/private/include/shell_mediator.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- *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.
- */
-/*
- * shell_mediator.h
- *
- *  \date       Nov 4, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-
-#ifndef shellMediator_H_
-#define shellMediator_H_
-
-#include <bundle_context.h>
-#include <service_tracker.h>
-#include <celix_errno.h>
-
-#include <shell.h>
-
-struct shell_mediator {
-
-	log_helper_pt loghelper;
-	bundle_context_pt context;
-	service_tracker_pt tracker;
-	celix_thread_mutex_t mutex;
-
-	//protected by mutex
-	shell_service_pt shellService;
-};
-typedef struct shell_mediator *shell_mediator_pt;
-
-celix_status_t shellMediator_create(bundle_context_pt context, shell_mediator_pt *instance);
-celix_status_t shellMediator_stop(shell_mediator_pt instance);
-celix_status_t shellMediator_destroy(shell_mediator_pt instance);
-celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, FILE *out, FILE *err);
-
-#endif /* shellMediator_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/private/src/activator.c
----------------------------------------------------------------------
diff --git a/remote_shell/private/src/activator.c b/remote_shell/private/src/activator.c
deleted file mode 100644
index 541eda6..0000000
--- a/remote_shell/private/src/activator.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Nov 4, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <celix_errno.h>
-
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-#include "bundle_context.h"
-
-#include "log_helper.h"
-#include "connection_listener.h"
-#include "shell_mediator.h"
-#include "remote_shell.h"
-
-#define REMOTE_SHELL_TELNET_PORT_PROPERTY_NAME 	"remote.shell.telnet.port"
-#define DEFAULT_REMOTE_SHELL_TELNET_PORT 		6666
-
-#define REMOTE_SHELL_TELNET_MAXCONN_PROPERTY_NAME 	"remote.shell.telnet.maxconn"
-#define DEFAULT_REMOTE_SHELL_TELNET_MAXCONN 		2
-
-struct bundle_instance {
-	log_helper_pt loghelper;
-	shell_mediator_pt shellMediator;
-	remote_shell_pt remoteShell;
-	connection_listener_pt connectionListener;
-};
-
-typedef struct bundle_instance *bundle_instance_pt;
-
-static int bundleActivator_getPort(bundle_instance_pt bi, bundle_context_pt context);
-static int bundleActivator_getMaximumConnections(bundle_instance_pt bi, bundle_context_pt context);
-static int bundleActivator_getProperty(bundle_instance_pt bi, bundle_context_pt context, char * propertyName, int defaultValue);
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bundle_instance_pt bi = (bundle_instance_pt) calloc(1, sizeof(struct bundle_instance));
-
-	if (!bi)
-	{
-		status = CELIX_ENOMEM;
-	}
-	else if (userData != NULL) {
-		bi->shellMediator = NULL;
-		bi->remoteShell = NULL;
-		bi->connectionListener = NULL;
-
-		status = logHelper_create(context, &bi->loghelper);
-
-		(*userData) = bi;
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-		free(bi);
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_instance_pt bi = (bundle_instance_pt) userData;
-
-	int port = bundleActivator_getPort(bi, context);
-	int maxConn = bundleActivator_getMaximumConnections(bi, context);
-
-	status = logHelper_start(bi->loghelper);
-
-	status = CELIX_DO_IF(status, shellMediator_create(context, &bi->shellMediator));
-	status = CELIX_DO_IF(status, remoteShell_create(bi->shellMediator, maxConn, &bi->remoteShell));
-	status = CELIX_DO_IF(status, connectionListener_create(bi->remoteShell, port, &bi->connectionListener));
-	status = CELIX_DO_IF(status, connectionListener_start(bi->connectionListener));
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_instance_pt bi = (bundle_instance_pt) userData;
-
-	connectionListener_stop(bi->connectionListener);
-	shellMediator_stop(bi->shellMediator);
-	shellMediator_destroy(bi->shellMediator);
-
-	remoteShell_stopConnections(bi->remoteShell);
-
-	status = logHelper_stop(bi->loghelper);
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_instance_pt bi = (bundle_instance_pt) userData;
-
-	connectionListener_destroy(bi->connectionListener);
-	status = logHelper_destroy(&bi->loghelper);
-
-	return status;
-}
-
-static int bundleActivator_getPort(bundle_instance_pt bi, bundle_context_pt context) {
-	return bundleActivator_getProperty(bi, context, REMOTE_SHELL_TELNET_PORT_PROPERTY_NAME, DEFAULT_REMOTE_SHELL_TELNET_PORT);
-}
-
-static int bundleActivator_getMaximumConnections(bundle_instance_pt bi, bundle_context_pt context) {
-	return bundleActivator_getProperty(bi, context, REMOTE_SHELL_TELNET_MAXCONN_PROPERTY_NAME, DEFAULT_REMOTE_SHELL_TELNET_MAXCONN);
-}
-
-static int bundleActivator_getProperty(bundle_instance_pt bi, bundle_context_pt context, char* propertyName, int defaultValue) {
-	const char *strValue = NULL;
-	int value;
-
-	bundleContext_getProperty(context, propertyName, &strValue);
-	if (strValue != NULL) {
-		char* endptr = (char*)strValue;
-
-		errno = 0;
-		value = strtol(strValue, &endptr, 10);
-		if (*endptr || errno != 0) {
-			logHelper_log(bi->loghelper, OSGI_LOGSERVICE_WARNING, "incorrect format for %s", propertyName);
-			value = defaultValue;
-		}
-	}
-	else {
-		value = defaultValue;
-	}
-
-	return value;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/private/src/connection_listener.c
----------------------------------------------------------------------
diff --git a/remote_shell/private/src/connection_listener.c b/remote_shell/private/src/connection_listener.c
deleted file mode 100644
index 3bef9e5..0000000
--- a/remote_shell/private/src/connection_listener.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/**
- *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.
- */
-/*
- * connection_listener.c
- *
- *  \date       Nov 4, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <celix_errno.h>
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <fcntl.h>
-
-#include "log_service.h"
-#include "log_helper.h"
-
-#include "connection_listener.h"
-
-#include "shell_mediator.h"
-#include "remote_shell.h"
-
-#define CONNECTION_LISTENER_TIMEOUT_SEC		5
-
-struct connection_listener {
-	//constant
-	int port;
-	log_helper_pt* loghelper;
-	remote_shell_pt remoteShell;
-	celix_thread_mutex_t mutex;
-
-	//protected by mutex
-	bool running;
-	celix_thread_t thread;
-	fd_set pollset;
-};
-
-static void* connection_listener_thread(void *data);
-
-celix_status_t connectionListener_create(remote_shell_pt remoteShell, int port, connection_listener_pt *instance) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*instance) = calloc(1, sizeof(**instance));
-
-	if ((*instance) != NULL) {
-		(*instance)->port = port;
-		(*instance)->remoteShell = remoteShell;
-		(*instance)->running = false;
-		(*instance)->loghelper = remoteShell->loghelper;
-
-		FD_ZERO(&(*instance)-> pollset);
-
-		status = celixThreadMutex_create(&(*instance)->mutex, NULL);
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t connectionListener_start(connection_listener_pt instance) {
-	celix_status_t status = CELIX_SUCCESS;
-	celixThreadMutex_lock(&instance->mutex);
-	celixThread_create(&instance->thread, NULL, connection_listener_thread, instance);
-	celixThreadMutex_unlock(&instance->mutex);
-	return status;
-}
-
-celix_status_t connectionListener_stop(connection_listener_pt instance) {
-	celix_status_t status = CELIX_SUCCESS;
-	celix_thread_t thread;
-	fd_set pollset;
-
-	instance->running = false;
-	FD_ZERO(&pollset);
-
-	logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_INFO, "CONNECTION_LISTENER: Stopping thread\n");
-
-	celixThreadMutex_lock(&instance->mutex);
-	thread = instance->thread;
-
-	pollset = instance->pollset;
-	celixThreadMutex_unlock(&instance->mutex);
-
-	celixThread_join(thread, NULL);
-	return status;
-}
-
-celix_status_t connectionListener_destroy(connection_listener_pt instance) {
-	free(instance);
-
-	return CELIX_SUCCESS;
-}
-
-static void* connection_listener_thread(void *data) {
-	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
-	connection_listener_pt instance = data;
-	struct timeval timeout; /* Timeout for select */
-	fd_set active_fd_set;
-	FD_ZERO(&active_fd_set);
-	int listenSocket = 0;
-	int on = 1;
-
-	struct addrinfo *result, *rp;
-	struct addrinfo hints;
-
-	memset(&hints, 0, sizeof(struct addrinfo));
-	hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
-	hints.ai_socktype = SOCK_STREAM; /* Datagram socket */
-	hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */
-	hints.ai_protocol = 0; /* Any protocol */
-	hints.ai_canonname = NULL;
-	hints.ai_addr = NULL;
-	hints.ai_next = NULL;
-
-	char portStr[10];
-	snprintf(&portStr[0], 10, "%d", instance->port);
-
-	getaddrinfo(NULL, portStr, &hints, &result);
-
-	for (rp = result; rp != NULL && status == CELIX_BUNDLE_EXCEPTION; rp = rp->ai_next) {
-
-		status = CELIX_BUNDLE_EXCEPTION;
-
-		/* Create socket */
-		listenSocket = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
-		if (listenSocket < 0) {
-			logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "Error creating socket: %s", strerror(errno));
-		}
-		else if (setsockopt(listenSocket, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)) < 0) {
-			logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "cannot set socket option: %s", strerror(errno));
-		}
-		else if (bind(listenSocket, rp->ai_addr, rp->ai_addrlen) < 0) {
-			logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "cannot bind: %s", strerror(errno));
-		}
-		else if (listen(listenSocket, 5) < 0) {
-			logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "listen failed: %s", strerror(errno));
-		}
-		else {
-			status = CELIX_SUCCESS;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-
-		logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_INFO, "Remote Shell accepting connections on port %d", instance->port);
-
-		celixThreadMutex_lock(&instance->mutex);
-		instance->pollset = active_fd_set;
-		celixThreadMutex_unlock(&instance->mutex);
-
-		instance->running = true;
-
-		while (status == CELIX_SUCCESS && instance->running) {
-			int selectRet = -1;
-			do {
-				timeout.tv_sec = CONNECTION_LISTENER_TIMEOUT_SEC;
-				timeout.tv_usec = 0;
-
-				FD_ZERO(&active_fd_set);
-				FD_SET(listenSocket, &active_fd_set);
-
-				selectRet = select(listenSocket + 1, &active_fd_set, NULL, NULL, &timeout);
-			} while (selectRet == -1 && errno == EINTR && instance->running == true);
-			if (selectRet < 0) {
-				logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "select on listenSocket failed: %s", strerror(errno));
-				status = CELIX_BUNDLE_EXCEPTION;
-			}
-			else if (selectRet == 0) {
-				/* do nothing here */
-			}
-			else if (FD_ISSET(listenSocket, &active_fd_set)) {
-				int acceptedSocket = accept(listenSocket, NULL, NULL);
-
-				if (acceptedSocket < 0) {
-					logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "REMOTE_SHELL: accept failed: %s.", strerror(errno));
-					status = CELIX_BUNDLE_EXCEPTION;
-				}
-				else {
-					logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_INFO, "REMOTE_SHELL: connection established.");
-					remoteShell_addConnection(instance->remoteShell, acceptedSocket);
-				}
-			}
-			else {
-				logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_DEBUG, "REMOTE_SHELL: received data on a not-expected file-descriptor?");
-			}
-		}
-	}
-
-	if (listenSocket >= 0) {
-		close(listenSocket);
-	}
-
-	freeaddrinfo(result);
-
-	return NULL;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/private/src/remote_shell.c
----------------------------------------------------------------------
diff --git a/remote_shell/private/src/remote_shell.c b/remote_shell/private/src/remote_shell.c
deleted file mode 100644
index 8f42778..0000000
--- a/remote_shell/private/src/remote_shell.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/**
- *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.
- */
-/*
- * remote_shell.c
- *
- *  \date       Nov 4, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <utils.h>
-#include <array_list.h>
-#include <sys/socket.h>
-
-#include "log_helper.h"
-
-#include "log_service.h"
-#include "remote_shell.h"
-
-#define COMMAND_BUFF_SIZE (256)
-
-#define RS_PROMPT ("-> ")
-#define RS_WELCOME ("\n---- Apache Celix Remote Shell ----\n---- Type exit to disconnect   ----\n\n-> ")
-#define RS_GOODBYE ("Goobye!\n")
-#define RS_ERROR ("Error executing command!\n")
-#define RS_MAXIMUM_CONNECTIONS_REACHED ("Maximum number of connections  reached. Disconnecting ...\n")
-
-#define CONNECTION_LISTENER_TIMEOUT_SEC		5
-
-
-
-struct connection {
-	remote_shell_pt parent;
-	FILE *socketStream;
-	fd_set pollset;
-	bool threadRunning;
-};
-
-typedef struct connection *connection_pt;
-
-static celix_status_t remoteShell_connection_print(connection_pt connection, char * text);
-static celix_status_t remoteShell_connection_execute(connection_pt connection, char *command);
-static void* remoteShell_connection_run(void *data);
-
-celix_status_t remoteShell_create(shell_mediator_pt mediator, int maximumConnections, remote_shell_pt *instance) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*instance) = calloc(1, sizeof(**instance));
-	if ((*instance) != NULL) {
-		(*instance)->mediator = mediator;
-		(*instance)->maximumConnections = maximumConnections;
-		(*instance)->connections = NULL;
-		(*instance)->loghelper = &mediator->loghelper;
-
-		status = celixThreadMutex_create(&(*instance)->mutex, NULL);
-
-		if (status == CELIX_SUCCESS) {
-			status = arrayList_create(&(*instance)->connections);
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t remoteShell_destroy(remote_shell_pt instance) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	remoteShell_stopConnections(instance);
-
-	celixThreadMutex_lock(&instance->mutex);
-	arrayList_destroy(instance->connections);
-	celixThreadMutex_unlock(&instance->mutex);
-
-	return status;
-}
-
-celix_status_t remoteShell_addConnection(remote_shell_pt instance, int socket) {
-	celix_status_t status = CELIX_SUCCESS;
-	connection_pt connection = calloc(1, sizeof(struct connection));
-
-	if (connection != NULL) {
-		connection->parent = instance;
-		connection->threadRunning = false;
-		connection->socketStream = fdopen(socket, "w");
-
-		if (connection->socketStream != NULL) {
-
-			celixThreadMutex_lock(&instance->mutex);
-
-			if (arrayList_size(instance->connections) < instance->maximumConnections) {
-				celix_thread_t connectionRunThread = celix_thread_default;
-				arrayList_add(instance->connections, connection);
-				status = celixThread_create(&connectionRunThread, NULL, &remoteShell_connection_run, connection);
-			} else {
-				status = CELIX_BUNDLE_EXCEPTION;
-				remoteShell_connection_print(connection, RS_MAXIMUM_CONNECTIONS_REACHED);
-			}
-			celixThreadMutex_unlock(&instance->mutex);
-
-		} else {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	if (status != CELIX_SUCCESS && connection != NULL) {
-		if (connection->socketStream != NULL) {
-			fclose(connection->socketStream);
-		}
-		free(connection);
-	}
-
-	return status;
-}
-
-celix_status_t remoteShell_stopConnections(remote_shell_pt instance) {
-	celix_status_t status = CELIX_SUCCESS;
-	int length = 0;
-	int i = 0;
-
-	celixThreadMutex_lock(&instance->mutex);
-	length = arrayList_size(instance->connections);
-
-	for (i = 0; i < length; i += 1) {
-		connection_pt connection = arrayList_get(instance->connections, i);
-		connection->threadRunning = false;
-	}
-
-	celixThreadMutex_unlock(&instance->mutex);
-
-	return status;
-}
-
-void *remoteShell_connection_run(void *data) {
-	celix_status_t status = CELIX_SUCCESS;
-	connection_pt connection = data;
-	size_t len;
-	int result;
-	struct timeval timeout; /* Timeout for select */
-
-	int fd = fileno(connection->socketStream);
-
-	connection->threadRunning = true;
-	status = remoteShell_connection_print(connection, RS_WELCOME);
-
-	while (status == CELIX_SUCCESS && connection->threadRunning == true) {
-		do {
-			timeout.tv_sec = CONNECTION_LISTENER_TIMEOUT_SEC;
-			timeout.tv_usec = 0;
-
-			FD_ZERO(&connection->pollset);
-			FD_SET(fd, &connection->pollset);
-			result = select(fd + 1, &connection->pollset, NULL, NULL, &timeout);
-		} while (result == -1 && errno == EINTR && connection->threadRunning == true);
-
-		/* The socket_fd has data available to be read */
-		if (result > 0 && FD_ISSET(fd, &connection->pollset)) {
-			char buff[COMMAND_BUFF_SIZE];
-
-			len = recv(fd, buff, COMMAND_BUFF_SIZE - 1, 0);
-			if (len < COMMAND_BUFF_SIZE) {
-				celix_status_t commandStatus = CELIX_SUCCESS;
-				buff[len] = '\0';
-
-				commandStatus = remoteShell_connection_execute(connection, buff);
-
-				if (commandStatus == CELIX_SUCCESS) {
-					remoteShell_connection_print(connection, RS_PROMPT);
-				} else if (commandStatus == CELIX_FILE_IO_EXCEPTION) {
-					//exit command
-					break;
-				} else { //error
-					remoteShell_connection_print(connection, RS_ERROR);
-					remoteShell_connection_print(connection, RS_PROMPT);
-				}
-
-			} else {
-				logHelper_log(*connection->parent->loghelper, OSGI_LOGSERVICE_ERROR, "REMOTE_SHELL: Error while retrieving data");
-			}
-		}
-	}
-
-	remoteShell_connection_print(connection, RS_GOODBYE);
-
-	logHelper_log(*connection->parent->loghelper, OSGI_LOGSERVICE_INFO, "REMOTE_SHELL: Closing socket");
-	celixThreadMutex_lock(&connection->parent->mutex);
-	arrayList_removeElement(connection->parent->connections, connection);
-	celixThreadMutex_unlock(&connection->parent->mutex);
-
-	fclose(connection->socketStream);
-
-	return NULL;
-}
-
-static celix_status_t remoteShell_connection_execute(connection_pt connection, char *command) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (status == CELIX_SUCCESS) {
-		char *dline = strdup(command);
-		char *line = utils_stringTrim(dline);
-		int len = strlen(line);
-
-		if (len == 0) {
-			//ignore
-		} else if (len == 4 && strncmp("exit", line, 4) == 0) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		} else {
-			status = shellMediator_executeCommand(connection->parent->mediator, line, connection->socketStream, connection->socketStream);
-            fflush(connection->socketStream);
-		}
-
-		free(dline);
-	}
-
-	return status;
-}
-
-celix_status_t remoteShell_connection_print(connection_pt connection, char *text) {
-	size_t len = strlen(text);
-    int fd = fileno(connection->socketStream);
-	return (send(fd, text, len, 0) > 0) ? CELIX_SUCCESS : CELIX_FILE_IO_EXCEPTION;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/private/src/shell_mediator.c
----------------------------------------------------------------------
diff --git a/remote_shell/private/src/shell_mediator.c b/remote_shell/private/src/shell_mediator.c
deleted file mode 100644
index d9722a9..0000000
--- a/remote_shell/private/src/shell_mediator.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- *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.
- */
-/*
- * shell_mediator.c
- *
- *  \date       Nov 4, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <utils.h>
-#include <shell.h>
-#include <service_tracker.h>
-#include <command.h>
-#include <sys/socket.h>
-
-#include "log_helper.h"
-#include "log_service.h"
-#include "shell_mediator.h"
-
-static celix_status_t shellMediator_addedService(void *handler, service_reference_pt reference, void * service);
-static celix_status_t shellMediator_removedService(void *handler, service_reference_pt reference, void * service);
-
-celix_status_t shellMediator_create(bundle_context_pt context, shell_mediator_pt *instance) {
-	celix_status_t status = CELIX_SUCCESS;
-	service_tracker_customizer_pt customizer = NULL;
-
-	(*instance) = (shell_mediator_pt) calloc(1, sizeof(**instance));
-	if ((*instance) != NULL) {
-
-		(*instance)->context = context;
-		(*instance)->tracker = NULL;
-		(*instance)->shellService = NULL;
-
-		status = logHelper_create(context, &(*instance)->loghelper);
-
-		status = CELIX_DO_IF(status, celixThreadMutex_create(&(*instance)->mutex, NULL));
-
-		status = CELIX_DO_IF(status, serviceTrackerCustomizer_create((*instance), NULL, shellMediator_addedService,
-				NULL, shellMediator_removedService, &customizer));
-		status = CELIX_DO_IF(status, serviceTracker_create(context, (char * )OSGI_SHELL_SERVICE_NAME, customizer, &(*instance)->tracker));
-
-		if (status == CELIX_SUCCESS) {
-			logHelper_start((*instance)->loghelper);
-			serviceTracker_open((*instance)->tracker);
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	if ((status != CELIX_SUCCESS) && ((*instance) != NULL)){
-		logHelper_log((*instance)->loghelper, OSGI_LOGSERVICE_ERROR, "Error creating shell_mediator, error code is %i\n", status);
-	}
-	return status;
-}
-
-celix_status_t shellMediator_stop(shell_mediator_pt instance) {
-	service_tracker_pt tracker;
-	celixThreadMutex_lock(&instance->mutex);
-	tracker = instance->tracker;
-	celixThreadMutex_unlock(&instance->mutex);
-
-	if (tracker != NULL) {
-		serviceTracker_close(tracker);
-	}
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t shellMediator_destroy(shell_mediator_pt instance) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	celixThreadMutex_lock(&instance->mutex);
-
-	instance->shellService = NULL;
-	serviceTracker_destroy(instance->tracker);
-	logHelper_stop(instance->loghelper);
-	status = logHelper_destroy(&instance->loghelper);
-	celixThreadMutex_destroy(&instance->mutex);
-
-
-	free(instance);
-
-
-	return status;
-}
-
-celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, FILE *out, FILE *err) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	celixThreadMutex_lock(&instance->mutex);
-
-
-	if (instance->shellService != NULL) {
-		instance->shellService->executeCommand(instance->shellService->shell, command, out, err);
-	}
-
-	celixThreadMutex_unlock(&instance->mutex);
-
-	return status;
-}
-
-static celix_status_t shellMediator_addedService(void *handler, service_reference_pt reference, void * service) {
-	celix_status_t status = CELIX_SUCCESS;
-	shell_mediator_pt instance = (shell_mediator_pt) handler;
-	celixThreadMutex_lock(&instance->mutex);
-	instance->shellService = (shell_service_pt) service;
-	celixThreadMutex_unlock(&instance->mutex);
-	return status;
-}
-
-
-static celix_status_t shellMediator_removedService(void *handler, service_reference_pt reference, void * service) {
-	celix_status_t status = CELIX_SUCCESS;
-	shell_mediator_pt instance = (shell_mediator_pt) handler;
-	celixThreadMutex_lock(&instance->mutex);
-	instance->shellService = NULL;
-	celixThreadMutex_unlock(&instance->mutex);
-	return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/src/activator.c
----------------------------------------------------------------------
diff --git a/remote_shell/src/activator.c b/remote_shell/src/activator.c
new file mode 100644
index 0000000..541eda6
--- /dev/null
+++ b/remote_shell/src/activator.c
@@ -0,0 +1,153 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Nov 4, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <celix_errno.h>
+
+#include <stdlib.h>
+
+#include "bundle_activator.h"
+#include "bundle_context.h"
+
+#include "log_helper.h"
+#include "connection_listener.h"
+#include "shell_mediator.h"
+#include "remote_shell.h"
+
+#define REMOTE_SHELL_TELNET_PORT_PROPERTY_NAME 	"remote.shell.telnet.port"
+#define DEFAULT_REMOTE_SHELL_TELNET_PORT 		6666
+
+#define REMOTE_SHELL_TELNET_MAXCONN_PROPERTY_NAME 	"remote.shell.telnet.maxconn"
+#define DEFAULT_REMOTE_SHELL_TELNET_MAXCONN 		2
+
+struct bundle_instance {
+	log_helper_pt loghelper;
+	shell_mediator_pt shellMediator;
+	remote_shell_pt remoteShell;
+	connection_listener_pt connectionListener;
+};
+
+typedef struct bundle_instance *bundle_instance_pt;
+
+static int bundleActivator_getPort(bundle_instance_pt bi, bundle_context_pt context);
+static int bundleActivator_getMaximumConnections(bundle_instance_pt bi, bundle_context_pt context);
+static int bundleActivator_getProperty(bundle_instance_pt bi, bundle_context_pt context, char * propertyName, int defaultValue);
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bundle_instance_pt bi = (bundle_instance_pt) calloc(1, sizeof(struct bundle_instance));
+
+	if (!bi)
+	{
+		status = CELIX_ENOMEM;
+	}
+	else if (userData != NULL) {
+		bi->shellMediator = NULL;
+		bi->remoteShell = NULL;
+		bi->connectionListener = NULL;
+
+		status = logHelper_create(context, &bi->loghelper);
+
+		(*userData) = bi;
+	} else {
+		status = CELIX_ILLEGAL_ARGUMENT;
+		free(bi);
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_instance_pt bi = (bundle_instance_pt) userData;
+
+	int port = bundleActivator_getPort(bi, context);
+	int maxConn = bundleActivator_getMaximumConnections(bi, context);
+
+	status = logHelper_start(bi->loghelper);
+
+	status = CELIX_DO_IF(status, shellMediator_create(context, &bi->shellMediator));
+	status = CELIX_DO_IF(status, remoteShell_create(bi->shellMediator, maxConn, &bi->remoteShell));
+	status = CELIX_DO_IF(status, connectionListener_create(bi->remoteShell, port, &bi->connectionListener));
+	status = CELIX_DO_IF(status, connectionListener_start(bi->connectionListener));
+
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_instance_pt bi = (bundle_instance_pt) userData;
+
+	connectionListener_stop(bi->connectionListener);
+	shellMediator_stop(bi->shellMediator);
+	shellMediator_destroy(bi->shellMediator);
+
+	remoteShell_stopConnections(bi->remoteShell);
+
+	status = logHelper_stop(bi->loghelper);
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_instance_pt bi = (bundle_instance_pt) userData;
+
+	connectionListener_destroy(bi->connectionListener);
+	status = logHelper_destroy(&bi->loghelper);
+
+	return status;
+}
+
+static int bundleActivator_getPort(bundle_instance_pt bi, bundle_context_pt context) {
+	return bundleActivator_getProperty(bi, context, REMOTE_SHELL_TELNET_PORT_PROPERTY_NAME, DEFAULT_REMOTE_SHELL_TELNET_PORT);
+}
+
+static int bundleActivator_getMaximumConnections(bundle_instance_pt bi, bundle_context_pt context) {
+	return bundleActivator_getProperty(bi, context, REMOTE_SHELL_TELNET_MAXCONN_PROPERTY_NAME, DEFAULT_REMOTE_SHELL_TELNET_MAXCONN);
+}
+
+static int bundleActivator_getProperty(bundle_instance_pt bi, bundle_context_pt context, char* propertyName, int defaultValue) {
+	const char *strValue = NULL;
+	int value;
+
+	bundleContext_getProperty(context, propertyName, &strValue);
+	if (strValue != NULL) {
+		char* endptr = (char*)strValue;
+
+		errno = 0;
+		value = strtol(strValue, &endptr, 10);
+		if (*endptr || errno != 0) {
+			logHelper_log(bi->loghelper, OSGI_LOGSERVICE_WARNING, "incorrect format for %s", propertyName);
+			value = defaultValue;
+		}
+	}
+	else {
+		value = defaultValue;
+	}
+
+	return value;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/src/connection_listener.c
----------------------------------------------------------------------
diff --git a/remote_shell/src/connection_listener.c b/remote_shell/src/connection_listener.c
new file mode 100644
index 0000000..3bef9e5
--- /dev/null
+++ b/remote_shell/src/connection_listener.c
@@ -0,0 +1,221 @@
+/**
+ *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.
+ */
+/*
+ * connection_listener.c
+ *
+ *  \date       Nov 4, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <celix_errno.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <fcntl.h>
+
+#include "log_service.h"
+#include "log_helper.h"
+
+#include "connection_listener.h"
+
+#include "shell_mediator.h"
+#include "remote_shell.h"
+
+#define CONNECTION_LISTENER_TIMEOUT_SEC		5
+
+struct connection_listener {
+	//constant
+	int port;
+	log_helper_pt* loghelper;
+	remote_shell_pt remoteShell;
+	celix_thread_mutex_t mutex;
+
+	//protected by mutex
+	bool running;
+	celix_thread_t thread;
+	fd_set pollset;
+};
+
+static void* connection_listener_thread(void *data);
+
+celix_status_t connectionListener_create(remote_shell_pt remoteShell, int port, connection_listener_pt *instance) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*instance) = calloc(1, sizeof(**instance));
+
+	if ((*instance) != NULL) {
+		(*instance)->port = port;
+		(*instance)->remoteShell = remoteShell;
+		(*instance)->running = false;
+		(*instance)->loghelper = remoteShell->loghelper;
+
+		FD_ZERO(&(*instance)-> pollset);
+
+		status = celixThreadMutex_create(&(*instance)->mutex, NULL);
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t connectionListener_start(connection_listener_pt instance) {
+	celix_status_t status = CELIX_SUCCESS;
+	celixThreadMutex_lock(&instance->mutex);
+	celixThread_create(&instance->thread, NULL, connection_listener_thread, instance);
+	celixThreadMutex_unlock(&instance->mutex);
+	return status;
+}
+
+celix_status_t connectionListener_stop(connection_listener_pt instance) {
+	celix_status_t status = CELIX_SUCCESS;
+	celix_thread_t thread;
+	fd_set pollset;
+
+	instance->running = false;
+	FD_ZERO(&pollset);
+
+	logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_INFO, "CONNECTION_LISTENER: Stopping thread\n");
+
+	celixThreadMutex_lock(&instance->mutex);
+	thread = instance->thread;
+
+	pollset = instance->pollset;
+	celixThreadMutex_unlock(&instance->mutex);
+
+	celixThread_join(thread, NULL);
+	return status;
+}
+
+celix_status_t connectionListener_destroy(connection_listener_pt instance) {
+	free(instance);
+
+	return CELIX_SUCCESS;
+}
+
+static void* connection_listener_thread(void *data) {
+	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
+	connection_listener_pt instance = data;
+	struct timeval timeout; /* Timeout for select */
+	fd_set active_fd_set;
+	FD_ZERO(&active_fd_set);
+	int listenSocket = 0;
+	int on = 1;
+
+	struct addrinfo *result, *rp;
+	struct addrinfo hints;
+
+	memset(&hints, 0, sizeof(struct addrinfo));
+	hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
+	hints.ai_socktype = SOCK_STREAM; /* Datagram socket */
+	hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */
+	hints.ai_protocol = 0; /* Any protocol */
+	hints.ai_canonname = NULL;
+	hints.ai_addr = NULL;
+	hints.ai_next = NULL;
+
+	char portStr[10];
+	snprintf(&portStr[0], 10, "%d", instance->port);
+
+	getaddrinfo(NULL, portStr, &hints, &result);
+
+	for (rp = result; rp != NULL && status == CELIX_BUNDLE_EXCEPTION; rp = rp->ai_next) {
+
+		status = CELIX_BUNDLE_EXCEPTION;
+
+		/* Create socket */
+		listenSocket = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
+		if (listenSocket < 0) {
+			logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "Error creating socket: %s", strerror(errno));
+		}
+		else if (setsockopt(listenSocket, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)) < 0) {
+			logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "cannot set socket option: %s", strerror(errno));
+		}
+		else if (bind(listenSocket, rp->ai_addr, rp->ai_addrlen) < 0) {
+			logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "cannot bind: %s", strerror(errno));
+		}
+		else if (listen(listenSocket, 5) < 0) {
+			logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "listen failed: %s", strerror(errno));
+		}
+		else {
+			status = CELIX_SUCCESS;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+
+		logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_INFO, "Remote Shell accepting connections on port %d", instance->port);
+
+		celixThreadMutex_lock(&instance->mutex);
+		instance->pollset = active_fd_set;
+		celixThreadMutex_unlock(&instance->mutex);
+
+		instance->running = true;
+
+		while (status == CELIX_SUCCESS && instance->running) {
+			int selectRet = -1;
+			do {
+				timeout.tv_sec = CONNECTION_LISTENER_TIMEOUT_SEC;
+				timeout.tv_usec = 0;
+
+				FD_ZERO(&active_fd_set);
+				FD_SET(listenSocket, &active_fd_set);
+
+				selectRet = select(listenSocket + 1, &active_fd_set, NULL, NULL, &timeout);
+			} while (selectRet == -1 && errno == EINTR && instance->running == true);
+			if (selectRet < 0) {
+				logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "select on listenSocket failed: %s", strerror(errno));
+				status = CELIX_BUNDLE_EXCEPTION;
+			}
+			else if (selectRet == 0) {
+				/* do nothing here */
+			}
+			else if (FD_ISSET(listenSocket, &active_fd_set)) {
+				int acceptedSocket = accept(listenSocket, NULL, NULL);
+
+				if (acceptedSocket < 0) {
+					logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_ERROR, "REMOTE_SHELL: accept failed: %s.", strerror(errno));
+					status = CELIX_BUNDLE_EXCEPTION;
+				}
+				else {
+					logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_INFO, "REMOTE_SHELL: connection established.");
+					remoteShell_addConnection(instance->remoteShell, acceptedSocket);
+				}
+			}
+			else {
+				logHelper_log(*instance->loghelper, OSGI_LOGSERVICE_DEBUG, "REMOTE_SHELL: received data on a not-expected file-descriptor?");
+			}
+		}
+	}
+
+	if (listenSocket >= 0) {
+		close(listenSocket);
+	}
+
+	freeaddrinfo(result);
+
+	return NULL;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/src/connection_listener.h
----------------------------------------------------------------------
diff --git a/remote_shell/src/connection_listener.h b/remote_shell/src/connection_listener.h
new file mode 100644
index 0000000..392d6ec
--- /dev/null
+++ b/remote_shell/src/connection_listener.h
@@ -0,0 +1,42 @@
+/**
+ *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.
+ */
+/*
+ * connection_listener.h
+ *
+ *  \date       Nov 4, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef connectionListener_H_
+#define connectionListener_H_
+
+#include <bundle_context.h>
+#include <celix_errno.h>
+
+#include "remote_shell.h"
+
+typedef struct connection_listener *connection_listener_pt;
+
+celix_status_t connectionListener_create(remote_shell_pt remoteShell, int port, connection_listener_pt *instance);
+celix_status_t connectionListener_destroy(connection_listener_pt instance);
+celix_status_t connectionListener_start(connection_listener_pt instance);
+celix_status_t connectionListener_stop(connection_listener_pt instance);
+
+#endif /* connectionListener_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/src/remote_shell.c
----------------------------------------------------------------------
diff --git a/remote_shell/src/remote_shell.c b/remote_shell/src/remote_shell.c
new file mode 100644
index 0000000..8f42778
--- /dev/null
+++ b/remote_shell/src/remote_shell.c
@@ -0,0 +1,242 @@
+/**
+ *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.
+ */
+/*
+ * remote_shell.c
+ *
+ *  \date       Nov 4, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <utils.h>
+#include <array_list.h>
+#include <sys/socket.h>
+
+#include "log_helper.h"
+
+#include "log_service.h"
+#include "remote_shell.h"
+
+#define COMMAND_BUFF_SIZE (256)
+
+#define RS_PROMPT ("-> ")
+#define RS_WELCOME ("\n---- Apache Celix Remote Shell ----\n---- Type exit to disconnect   ----\n\n-> ")
+#define RS_GOODBYE ("Goobye!\n")
+#define RS_ERROR ("Error executing command!\n")
+#define RS_MAXIMUM_CONNECTIONS_REACHED ("Maximum number of connections  reached. Disconnecting ...\n")
+
+#define CONNECTION_LISTENER_TIMEOUT_SEC		5
+
+
+
+struct connection {
+	remote_shell_pt parent;
+	FILE *socketStream;
+	fd_set pollset;
+	bool threadRunning;
+};
+
+typedef struct connection *connection_pt;
+
+static celix_status_t remoteShell_connection_print(connection_pt connection, char * text);
+static celix_status_t remoteShell_connection_execute(connection_pt connection, char *command);
+static void* remoteShell_connection_run(void *data);
+
+celix_status_t remoteShell_create(shell_mediator_pt mediator, int maximumConnections, remote_shell_pt *instance) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*instance) = calloc(1, sizeof(**instance));
+	if ((*instance) != NULL) {
+		(*instance)->mediator = mediator;
+		(*instance)->maximumConnections = maximumConnections;
+		(*instance)->connections = NULL;
+		(*instance)->loghelper = &mediator->loghelper;
+
+		status = celixThreadMutex_create(&(*instance)->mutex, NULL);
+
+		if (status == CELIX_SUCCESS) {
+			status = arrayList_create(&(*instance)->connections);
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t remoteShell_destroy(remote_shell_pt instance) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	remoteShell_stopConnections(instance);
+
+	celixThreadMutex_lock(&instance->mutex);
+	arrayList_destroy(instance->connections);
+	celixThreadMutex_unlock(&instance->mutex);
+
+	return status;
+}
+
+celix_status_t remoteShell_addConnection(remote_shell_pt instance, int socket) {
+	celix_status_t status = CELIX_SUCCESS;
+	connection_pt connection = calloc(1, sizeof(struct connection));
+
+	if (connection != NULL) {
+		connection->parent = instance;
+		connection->threadRunning = false;
+		connection->socketStream = fdopen(socket, "w");
+
+		if (connection->socketStream != NULL) {
+
+			celixThreadMutex_lock(&instance->mutex);
+
+			if (arrayList_size(instance->connections) < instance->maximumConnections) {
+				celix_thread_t connectionRunThread = celix_thread_default;
+				arrayList_add(instance->connections, connection);
+				status = celixThread_create(&connectionRunThread, NULL, &remoteShell_connection_run, connection);
+			} else {
+				status = CELIX_BUNDLE_EXCEPTION;
+				remoteShell_connection_print(connection, RS_MAXIMUM_CONNECTIONS_REACHED);
+			}
+			celixThreadMutex_unlock(&instance->mutex);
+
+		} else {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	if (status != CELIX_SUCCESS && connection != NULL) {
+		if (connection->socketStream != NULL) {
+			fclose(connection->socketStream);
+		}
+		free(connection);
+	}
+
+	return status;
+}
+
+celix_status_t remoteShell_stopConnections(remote_shell_pt instance) {
+	celix_status_t status = CELIX_SUCCESS;
+	int length = 0;
+	int i = 0;
+
+	celixThreadMutex_lock(&instance->mutex);
+	length = arrayList_size(instance->connections);
+
+	for (i = 0; i < length; i += 1) {
+		connection_pt connection = arrayList_get(instance->connections, i);
+		connection->threadRunning = false;
+	}
+
+	celixThreadMutex_unlock(&instance->mutex);
+
+	return status;
+}
+
+void *remoteShell_connection_run(void *data) {
+	celix_status_t status = CELIX_SUCCESS;
+	connection_pt connection = data;
+	size_t len;
+	int result;
+	struct timeval timeout; /* Timeout for select */
+
+	int fd = fileno(connection->socketStream);
+
+	connection->threadRunning = true;
+	status = remoteShell_connection_print(connection, RS_WELCOME);
+
+	while (status == CELIX_SUCCESS && connection->threadRunning == true) {
+		do {
+			timeout.tv_sec = CONNECTION_LISTENER_TIMEOUT_SEC;
+			timeout.tv_usec = 0;
+
+			FD_ZERO(&connection->pollset);
+			FD_SET(fd, &connection->pollset);
+			result = select(fd + 1, &connection->pollset, NULL, NULL, &timeout);
+		} while (result == -1 && errno == EINTR && connection->threadRunning == true);
+
+		/* The socket_fd has data available to be read */
+		if (result > 0 && FD_ISSET(fd, &connection->pollset)) {
+			char buff[COMMAND_BUFF_SIZE];
+
+			len = recv(fd, buff, COMMAND_BUFF_SIZE - 1, 0);
+			if (len < COMMAND_BUFF_SIZE) {
+				celix_status_t commandStatus = CELIX_SUCCESS;
+				buff[len] = '\0';
+
+				commandStatus = remoteShell_connection_execute(connection, buff);
+
+				if (commandStatus == CELIX_SUCCESS) {
+					remoteShell_connection_print(connection, RS_PROMPT);
+				} else if (commandStatus == CELIX_FILE_IO_EXCEPTION) {
+					//exit command
+					break;
+				} else { //error
+					remoteShell_connection_print(connection, RS_ERROR);
+					remoteShell_connection_print(connection, RS_PROMPT);
+				}
+
+			} else {
+				logHelper_log(*connection->parent->loghelper, OSGI_LOGSERVICE_ERROR, "REMOTE_SHELL: Error while retrieving data");
+			}
+		}
+	}
+
+	remoteShell_connection_print(connection, RS_GOODBYE);
+
+	logHelper_log(*connection->parent->loghelper, OSGI_LOGSERVICE_INFO, "REMOTE_SHELL: Closing socket");
+	celixThreadMutex_lock(&connection->parent->mutex);
+	arrayList_removeElement(connection->parent->connections, connection);
+	celixThreadMutex_unlock(&connection->parent->mutex);
+
+	fclose(connection->socketStream);
+
+	return NULL;
+}
+
+static celix_status_t remoteShell_connection_execute(connection_pt connection, char *command) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (status == CELIX_SUCCESS) {
+		char *dline = strdup(command);
+		char *line = utils_stringTrim(dline);
+		int len = strlen(line);
+
+		if (len == 0) {
+			//ignore
+		} else if (len == 4 && strncmp("exit", line, 4) == 0) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else {
+			status = shellMediator_executeCommand(connection->parent->mediator, line, connection->socketStream, connection->socketStream);
+            fflush(connection->socketStream);
+		}
+
+		free(dline);
+	}
+
+	return status;
+}
+
+celix_status_t remoteShell_connection_print(connection_pt connection, char *text) {
+	size_t len = strlen(text);
+    int fd = fileno(connection->socketStream);
+	return (send(fd, text, len, 0) > 0) ? CELIX_SUCCESS : CELIX_FILE_IO_EXCEPTION;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/src/remote_shell.h
----------------------------------------------------------------------
diff --git a/remote_shell/src/remote_shell.h b/remote_shell/src/remote_shell.h
new file mode 100644
index 0000000..55249a8
--- /dev/null
+++ b/remote_shell/src/remote_shell.h
@@ -0,0 +1,50 @@
+/**
+ *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.
+ */
+/*
+ * remote_shell.h
+ *
+ *  \date       Nov 4, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef REMOTE_SHELL_H_
+#define REMOTE_SHELL_H_
+
+#include <bundle_context.h>
+#include <celix_errno.h>
+
+#include "shell_mediator.h"
+
+struct remote_shell {
+	log_helper_pt* loghelper;
+	shell_mediator_pt mediator;
+	celix_thread_mutex_t mutex;
+	int maximumConnections;
+
+	array_list_pt connections;
+};
+typedef struct remote_shell *remote_shell_pt;
+
+celix_status_t remoteShell_create(shell_mediator_pt mediator, int maximumConnections, remote_shell_pt *instance);
+celix_status_t remoteShell_destroy(remote_shell_pt instance);
+celix_status_t remoteShell_addConnection(remote_shell_pt instance, int socket);
+celix_status_t remoteShell_stopConnections(remote_shell_pt instance);
+
+#endif /* REMOTE_SHELL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/src/shell_mediator.c
----------------------------------------------------------------------
diff --git a/remote_shell/src/shell_mediator.c b/remote_shell/src/shell_mediator.c
new file mode 100644
index 0000000..d9722a9
--- /dev/null
+++ b/remote_shell/src/shell_mediator.c
@@ -0,0 +1,139 @@
+/**
+ *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.
+ */
+/*
+ * shell_mediator.c
+ *
+ *  \date       Nov 4, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <utils.h>
+#include <shell.h>
+#include <service_tracker.h>
+#include <command.h>
+#include <sys/socket.h>
+
+#include "log_helper.h"
+#include "log_service.h"
+#include "shell_mediator.h"
+
+static celix_status_t shellMediator_addedService(void *handler, service_reference_pt reference, void * service);
+static celix_status_t shellMediator_removedService(void *handler, service_reference_pt reference, void * service);
+
+celix_status_t shellMediator_create(bundle_context_pt context, shell_mediator_pt *instance) {
+	celix_status_t status = CELIX_SUCCESS;
+	service_tracker_customizer_pt customizer = NULL;
+
+	(*instance) = (shell_mediator_pt) calloc(1, sizeof(**instance));
+	if ((*instance) != NULL) {
+
+		(*instance)->context = context;
+		(*instance)->tracker = NULL;
+		(*instance)->shellService = NULL;
+
+		status = logHelper_create(context, &(*instance)->loghelper);
+
+		status = CELIX_DO_IF(status, celixThreadMutex_create(&(*instance)->mutex, NULL));
+
+		status = CELIX_DO_IF(status, serviceTrackerCustomizer_create((*instance), NULL, shellMediator_addedService,
+				NULL, shellMediator_removedService, &customizer));
+		status = CELIX_DO_IF(status, serviceTracker_create(context, (char * )OSGI_SHELL_SERVICE_NAME, customizer, &(*instance)->tracker));
+
+		if (status == CELIX_SUCCESS) {
+			logHelper_start((*instance)->loghelper);
+			serviceTracker_open((*instance)->tracker);
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	if ((status != CELIX_SUCCESS) && ((*instance) != NULL)){
+		logHelper_log((*instance)->loghelper, OSGI_LOGSERVICE_ERROR, "Error creating shell_mediator, error code is %i\n", status);
+	}
+	return status;
+}
+
+celix_status_t shellMediator_stop(shell_mediator_pt instance) {
+	service_tracker_pt tracker;
+	celixThreadMutex_lock(&instance->mutex);
+	tracker = instance->tracker;
+	celixThreadMutex_unlock(&instance->mutex);
+
+	if (tracker != NULL) {
+		serviceTracker_close(tracker);
+	}
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t shellMediator_destroy(shell_mediator_pt instance) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	celixThreadMutex_lock(&instance->mutex);
+
+	instance->shellService = NULL;
+	serviceTracker_destroy(instance->tracker);
+	logHelper_stop(instance->loghelper);
+	status = logHelper_destroy(&instance->loghelper);
+	celixThreadMutex_destroy(&instance->mutex);
+
+
+	free(instance);
+
+
+	return status;
+}
+
+celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, FILE *out, FILE *err) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	celixThreadMutex_lock(&instance->mutex);
+
+
+	if (instance->shellService != NULL) {
+		instance->shellService->executeCommand(instance->shellService->shell, command, out, err);
+	}
+
+	celixThreadMutex_unlock(&instance->mutex);
+
+	return status;
+}
+
+static celix_status_t shellMediator_addedService(void *handler, service_reference_pt reference, void * service) {
+	celix_status_t status = CELIX_SUCCESS;
+	shell_mediator_pt instance = (shell_mediator_pt) handler;
+	celixThreadMutex_lock(&instance->mutex);
+	instance->shellService = (shell_service_pt) service;
+	celixThreadMutex_unlock(&instance->mutex);
+	return status;
+}
+
+
+static celix_status_t shellMediator_removedService(void *handler, service_reference_pt reference, void * service) {
+	celix_status_t status = CELIX_SUCCESS;
+	shell_mediator_pt instance = (shell_mediator_pt) handler;
+	celixThreadMutex_lock(&instance->mutex);
+	instance->shellService = NULL;
+	celixThreadMutex_unlock(&instance->mutex);
+	return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_shell/src/shell_mediator.h
----------------------------------------------------------------------
diff --git a/remote_shell/src/shell_mediator.h b/remote_shell/src/shell_mediator.h
new file mode 100644
index 0000000..24e8250
--- /dev/null
+++ b/remote_shell/src/shell_mediator.h
@@ -0,0 +1,54 @@
+/**
+ *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.
+ */
+/*
+ * shell_mediator.h
+ *
+ *  \date       Nov 4, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+
+#ifndef shellMediator_H_
+#define shellMediator_H_
+
+#include <bundle_context.h>
+#include <service_tracker.h>
+#include <celix_errno.h>
+
+#include <shell.h>
+
+struct shell_mediator {
+
+	log_helper_pt loghelper;
+	bundle_context_pt context;
+	service_tracker_pt tracker;
+	celix_thread_mutex_t mutex;
+
+	//protected by mutex
+	shell_service_pt shellService;
+};
+typedef struct shell_mediator *shell_mediator_pt;
+
+celix_status_t shellMediator_create(bundle_context_pt context, shell_mediator_pt *instance);
+celix_status_t shellMediator_stop(shell_mediator_pt instance);
+celix_status_t shellMediator_destroy(shell_mediator_pt instance);
+celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, FILE *out, FILE *err);
+
+#endif /* shellMediator_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 974d2ff..31822c4 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -18,38 +18,35 @@ celix_subproject(SHELL "Option to enable building the Shell bundles" ON DEPS LAU
 if (SHELL)
 	find_package(CURL REQUIRED)
 
+	add_library(shell_api INTERFACE)
+	target_include_directories(shell_api INTERFACE include)
+
     add_bundle(shell
         SYMBOLIC_NAME "apache_celix_shell"
         VERSION "2.0.0"
         NAME "Apache Celix Shell"
-
         SOURCES
+          src/activator
+          src/shell
+          src/lb_command
+          src/start_command
+          src/stop_command
+          src/install_command
+          src/update_command
+          src/uninstall_command
+          src/log_command
+          src/inspect_command
+          src/help_command
+	)
+	target_include_directories(shell PRIVATE src ${CURL_INCLUDE_DIRS})
+	target_link_libraries(shell PRIVATE Celix::shell_api ${CURL_LIBRARIES} Celix::log_service_api log_helper)
 
-          private/src/activator
-          private/src/shell
-          private/src/lb_command
-          private/src/start_command
-          private/src/stop_command
-          private/src/install_command
-          private/src/update_command
-          private/src/uninstall_command
-          private/src/log_command
-          private/src/inspect_command
-          private/src/help_command
-
-          ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
-
-    )
-    
-    install_bundle(shell
+	install_bundle(shell
     	HEADERS
-    		public/include/shell.h public/include/command.h public/include/shell_constants.h
-	)
+    		include/shell.h include/command.h include/shell_constants.h
+    )
 
-	include_directories("public/include")
-	include_directories("private/include")
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-	include_directories(${CURL_INCLUDE_DIRS})
-    target_link_libraries(shell celix_framework ${CURL_LIBRARIES})
+	#Setup target aliases to match external usage
+	add_library(Celix::shell_api ALIAS shell_api)
+	add_library(Celix::shell ALIAS shell)
 endif (SHELL)


[22/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/ioapi.c
----------------------------------------------------------------------
diff --git a/framework/private/src/ioapi.c b/framework/private/src/ioapi.c
deleted file mode 100644
index 49958f6..0000000
--- a/framework/private/src/ioapi.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* ioapi.h -- IO base function header for compress/uncompress .zip
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications for Zip64 support
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-*/
-
-#if (defined(_WIN32))
-        #define _CRT_SECURE_NO_WARNINGS
-#endif
-
-#include "ioapi.h"
-
-voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
-{
-    if (pfilefunc->zfile_func64.zopen64_file != NULL)
-        return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
-    else
-    {
-        return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
-    }
-}
-
-long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
-{
-    if (pfilefunc->zfile_func64.zseek64_file != NULL)
-        return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
-    else
-    {
-        uLong offsetTruncated = (uLong)offset;
-        if (offsetTruncated != offset)
-            return -1;
-        else
-            return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
-    }
-}
-
-ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
-{
-    if (pfilefunc->zfile_func64.zseek64_file != NULL)
-        return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
-    else
-    {
-        uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
-        if ((tell_uLong) == ((uLong)-1))
-            return (ZPOS64_T)-1;
-        else
-            return tell_uLong;
-    }
-}
-
-void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
-{
-    p_filefunc64_32->zfile_func64.zopen64_file = NULL;
-    p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
-    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
-    p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
-    p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
-    p_filefunc64_32->zfile_func64.ztell64_file = NULL;
-    p_filefunc64_32->zfile_func64.zseek64_file = NULL;
-    p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
-    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
-    p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
-    p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
-    p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
-}
-
-
-
-static voidpf  ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
-static uLong   ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-static uLong   ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
-static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
-static long    ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
-static int     ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
-static int     ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
-
-static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
-{
-    FILE* file = NULL;
-    const char* mode_fopen = NULL;
-    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
-        mode_fopen = "rb";
-    else
-    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
-        mode_fopen = "r+b";
-    else
-    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
-        mode_fopen = "wb";
-
-    if ((filename!=NULL) && (mode_fopen != NULL))
-        file = fopen(filename, mode_fopen);
-    return file;
-}
-
-static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
-{
-    FILE* file = NULL;
-    const char* mode_fopen = NULL;
-    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
-        mode_fopen = "rb";
-    else
-    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
-        mode_fopen = "r+b";
-    else
-    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
-        mode_fopen = "wb";
-
-    if ((filename!=NULL) && (mode_fopen != NULL))
-        file = fopen64((const char*)filename, mode_fopen);
-    return file;
-}
-
-
-static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
-{
-    uLong ret;
-    ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
-    return ret;
-}
-
-static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
-{
-    uLong ret;
-    ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
-    return ret;
-}
-
-static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
-{
-    long ret;
-    ret = ftell((FILE *)stream);
-    return ret;
-}
-
-
-static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
-{
-    ZPOS64_T ret;
-    ret = ftello64((FILE *)stream);
-    return ret;
-}
-
-static long ZCALLBACK fseek_file_func (voidpf  opaque, voidpf stream, uLong offset, int origin)
-{
-    int fseek_origin=0;
-    long ret;
-    switch (origin)
-    {
-    case ZLIB_FILEFUNC_SEEK_CUR :
-        fseek_origin = SEEK_CUR;
-        break;
-    case ZLIB_FILEFUNC_SEEK_END :
-        fseek_origin = SEEK_END;
-        break;
-    case ZLIB_FILEFUNC_SEEK_SET :
-        fseek_origin = SEEK_SET;
-        break;
-    default: return -1;
-    }
-    ret = 0;
-    if (fseek((FILE *)stream, offset, fseek_origin) != 0)
-        ret = -1;
-    return ret;
-}
-
-static long ZCALLBACK fseek64_file_func (voidpf  opaque, voidpf stream, ZPOS64_T offset, int origin)
-{
-    int fseek_origin=0;
-    long ret;
-    switch (origin)
-    {
-    case ZLIB_FILEFUNC_SEEK_CUR :
-        fseek_origin = SEEK_CUR;
-        break;
-    case ZLIB_FILEFUNC_SEEK_END :
-        fseek_origin = SEEK_END;
-        break;
-    case ZLIB_FILEFUNC_SEEK_SET :
-        fseek_origin = SEEK_SET;
-        break;
-    default: return -1;
-    }
-    ret = 0;
-
-    if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)
-                        ret = -1;
-
-    return ret;
-}
-
-
-static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
-{
-    int ret;
-    ret = fclose((FILE *)stream);
-    return ret;
-}
-
-static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
-{
-    int ret;
-    ret = ferror((FILE *)stream);
-    return ret;
-}
-
-void fill_fopen_filefunc (pzlib_filefunc_def)
-  zlib_filefunc_def* pzlib_filefunc_def;
-{
-    pzlib_filefunc_def->zopen_file = fopen_file_func;
-    pzlib_filefunc_def->zread_file = fread_file_func;
-    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
-    pzlib_filefunc_def->ztell_file = ftell_file_func;
-    pzlib_filefunc_def->zseek_file = fseek_file_func;
-    pzlib_filefunc_def->zclose_file = fclose_file_func;
-    pzlib_filefunc_def->zerror_file = ferror_file_func;
-    pzlib_filefunc_def->opaque = NULL;
-}
-
-void fill_fopen64_filefunc (zlib_filefunc64_def*  pzlib_filefunc_def)
-{
-    pzlib_filefunc_def->zopen64_file = fopen64_file_func;
-    pzlib_filefunc_def->zread_file = fread_file_func;
-    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
-    pzlib_filefunc_def->ztell64_file = ftell64_file_func;
-    pzlib_filefunc_def->zseek64_file = fseek64_file_func;
-    pzlib_filefunc_def->zclose_file = fclose_file_func;
-    pzlib_filefunc_def->zerror_file = ferror_file_func;
-    pzlib_filefunc_def->opaque = NULL;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/iowin32.c
----------------------------------------------------------------------
diff --git a/framework/private/src/iowin32.c b/framework/private/src/iowin32.c
deleted file mode 100644
index 6a2a883..0000000
--- a/framework/private/src/iowin32.c
+++ /dev/null
@@ -1,389 +0,0 @@
-/* iowin32.c -- IO base function header for compress/uncompress .zip
-     Version 1.1, February 14h, 2010
-     part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications for Zip64 support
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-     For more info read MiniZip_info.txt
-
-*/
-
-#include <stdlib.h>
-
-#include "zlib.h"
-#include "ioapi.h"
-#include "iowin32.h"
-
-#ifndef INVALID_HANDLE_VALUE
-#define INVALID_HANDLE_VALUE (0xFFFFFFFF)
-#endif
-
-#ifndef INVALID_SET_FILE_POINTER
-#define INVALID_SET_FILE_POINTER ((DWORD)-1)
-#endif
-
-voidpf  ZCALLBACK win32_open_file_func  OF((voidpf opaque, const char* filename, int mode));
-uLong   ZCALLBACK win32_read_file_func  OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-uLong   ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
-ZPOS64_T ZCALLBACK win32_tell64_file_func  OF((voidpf opaque, voidpf stream));
-long    ZCALLBACK win32_seek64_file_func  OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
-int     ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
-int     ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
-
-typedef struct
-{
-    HANDLE hf;
-    int error;
-} WIN32FILE_IOWIN;
-
-
-static void win32_translate_open_mode(int mode,
-                                      DWORD* lpdwDesiredAccess,
-                                      DWORD* lpdwCreationDisposition,
-                                      DWORD* lpdwShareMode,
-                                      DWORD* lpdwFlagsAndAttributes)
-{
-    *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
-
-    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
-    {
-        *lpdwDesiredAccess = GENERIC_READ;
-        *lpdwCreationDisposition = OPEN_EXISTING;
-        *lpdwShareMode = FILE_SHARE_READ;
-    }
-    else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
-    {
-        *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
-        *lpdwCreationDisposition = OPEN_EXISTING;
-    }
-    else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
-    {
-        *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
-        *lpdwCreationDisposition = CREATE_ALWAYS;
-    }
-}
-
-static voidpf win32_build_iowin(HANDLE hFile)
-{
-    voidpf ret=NULL;
-
-    if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
-    {
-        WIN32FILE_IOWIN w32fiow;
-        w32fiow.hf = hFile;
-        w32fiow.error = 0;
-        ret = malloc(sizeof(WIN32FILE_IOWIN));
-
-        if (ret==NULL)
-            CloseHandle(hFile);
-        else
-            *((WIN32FILE_IOWIN*)ret) = w32fiow;
-    }
-    return ret;
-}
-
-voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode)
-{
-    const char* mode_fopen = NULL;
-    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
-    HANDLE hFile = NULL;
-
-    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
-
-    if ((filename!=NULL) && (dwDesiredAccess != 0))
-        hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
-
-    return win32_build_iowin(hFile);
-}
-
-
-voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode)
-{
-    const char* mode_fopen = NULL;
-    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
-    HANDLE hFile = NULL;
-
-    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
-
-    if ((filename!=NULL) && (dwDesiredAccess != 0))
-        hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
-
-    return win32_build_iowin(hFile);
-}
-
-
-voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
-{
-    const char* mode_fopen = NULL;
-    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
-    HANDLE hFile = NULL;
-
-    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
-
-    if ((filename!=NULL) && (dwDesiredAccess != 0))
-        hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
-
-    return win32_build_iowin(hFile);
-}
-
-
-voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
-{
-    const char* mode_fopen = NULL;
-    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
-    HANDLE hFile = NULL;
-
-    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
-
-    if ((filename!=NULL) && (dwDesiredAccess != 0))
-        hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
-
-    return win32_build_iowin(hFile);
-}
-
-
-uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
-{
-    uLong ret=0;
-    HANDLE hFile = NULL;
-    if (stream!=NULL)
-        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
-
-    if (hFile != NULL)
-    {
-        if (!ReadFile(hFile, buf, size, &ret, NULL))
-        {
-            DWORD dwErr = GetLastError();
-            if (dwErr == ERROR_HANDLE_EOF)
-                dwErr = 0;
-            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
-        }
-    }
-
-    return ret;
-}
-
-
-uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
-{
-    uLong ret=0;
-    HANDLE hFile = NULL;
-    if (stream!=NULL)
-        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
-
-    if (hFile != NULL)
-    {
-        if (!WriteFile(hFile, buf, size, &ret, NULL))
-        {
-            DWORD dwErr = GetLastError();
-            if (dwErr == ERROR_HANDLE_EOF)
-                dwErr = 0;
-            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
-        }
-    }
-
-    return ret;
-}
-
-long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
-{
-    long ret=-1;
-    HANDLE hFile = NULL;
-    if (stream!=NULL)
-        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
-    if (hFile != NULL)
-    {
-        DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
-        if (dwSet == INVALID_SET_FILE_POINTER)
-        {
-            DWORD dwErr = GetLastError();
-            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
-            ret = -1;
-        }
-        else
-            ret=(long)dwSet;
-    }
-    return ret;
-}
-
-ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
-{
-    ZPOS64_T ret= (ZPOS64_T)-1;
-    HANDLE hFile = NULL;
-    if (stream!=NULL)
-        hFile = ((WIN32FILE_IOWIN*)stream)->hf;
-
-    if (hFile)
-    {
-        LARGE_INTEGER li;
-        li.QuadPart = 0;
-        li.u.LowPart = SetFilePointer(hFile, li.u.LowPart, &li.u.HighPart, FILE_CURRENT);
-        if ( (li.LowPart == 0xFFFFFFFF) && (GetLastError() != NO_ERROR))
-        {
-            DWORD dwErr = GetLastError();
-            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
-            ret = (ZPOS64_T)-1;
-        }
-        else
-            ret=li.QuadPart;
-    }
-    return ret;
-}
-
-
-long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
-{
-    DWORD dwMoveMethod=0xFFFFFFFF;
-    HANDLE hFile = NULL;
-
-    long ret=-1;
-    if (stream!=NULL)
-        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
-    switch (origin)
-    {
-    case ZLIB_FILEFUNC_SEEK_CUR :
-        dwMoveMethod = FILE_CURRENT;
-        break;
-    case ZLIB_FILEFUNC_SEEK_END :
-        dwMoveMethod = FILE_END;
-        break;
-    case ZLIB_FILEFUNC_SEEK_SET :
-        dwMoveMethod = FILE_BEGIN;
-        break;
-    default: return -1;
-    }
-
-    if (hFile != NULL)
-    {
-        DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod);
-        if (dwSet == INVALID_SET_FILE_POINTER)
-        {
-            DWORD dwErr = GetLastError();
-            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
-            ret = -1;
-        }
-        else
-            ret=0;
-    }
-    return ret;
-}
-
-long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
-{
-    DWORD dwMoveMethod=0xFFFFFFFF;
-    HANDLE hFile = NULL;
-    long ret=-1;
-
-    if (stream!=NULL)
-        hFile = ((WIN32FILE_IOWIN*)stream)->hf;
-
-    switch (origin)
-    {
-        case ZLIB_FILEFUNC_SEEK_CUR :
-            dwMoveMethod = FILE_CURRENT;
-            break;
-        case ZLIB_FILEFUNC_SEEK_END :
-            dwMoveMethod = FILE_END;
-            break;
-        case ZLIB_FILEFUNC_SEEK_SET :
-            dwMoveMethod = FILE_BEGIN;
-            break;
-        default: return -1;
-    }
-
-    if (hFile)
-    {
-        LARGE_INTEGER* li = (LARGE_INTEGER*)&offset;
-        DWORD dwSet = SetFilePointer(hFile, li->u.LowPart, &li->u.HighPart, dwMoveMethod);
-        if (dwSet == INVALID_SET_FILE_POINTER)
-        {
-            DWORD dwErr = GetLastError();
-            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
-            ret = -1;
-        }
-        else
-            ret=0;
-    }
-    return ret;
-}
-
-int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
-{
-    int ret=-1;
-
-    if (stream!=NULL)
-    {
-        HANDLE hFile;
-        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
-        if (hFile != NULL)
-        {
-            CloseHandle(hFile);
-            ret=0;
-        }
-        free(stream);
-    }
-    return ret;
-}
-
-int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
-{
-    int ret=-1;
-    if (stream!=NULL)
-    {
-        ret = ((WIN32FILE_IOWIN*)stream) -> error;
-    }
-    return ret;
-}
-
-void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
-{
-    pzlib_filefunc_def->zopen_file = win32_open_file_func;
-    pzlib_filefunc_def->zread_file = win32_read_file_func;
-    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
-    pzlib_filefunc_def->ztell_file = win32_tell_file_func;
-    pzlib_filefunc_def->zseek_file = win32_seek_file_func;
-    pzlib_filefunc_def->zclose_file = win32_close_file_func;
-    pzlib_filefunc_def->zerror_file = win32_error_file_func;
-    pzlib_filefunc_def->opaque = NULL;
-}
-
-void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
-{
-    pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
-    pzlib_filefunc_def->zread_file = win32_read_file_func;
-    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
-    pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
-    pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
-    pzlib_filefunc_def->zclose_file = win32_close_file_func;
-    pzlib_filefunc_def->zerror_file = win32_error_file_func;
-    pzlib_filefunc_def->opaque = NULL;
-}
-
-
-void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
-{
-    pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
-    pzlib_filefunc_def->zread_file = win32_read_file_func;
-    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
-    pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
-    pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
-    pzlib_filefunc_def->zclose_file = win32_close_file_func;
-    pzlib_filefunc_def->zerror_file = win32_error_file_func;
-    pzlib_filefunc_def->opaque = NULL;
-}
-
-
-void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
-{
-    pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
-    pzlib_filefunc_def->zread_file = win32_read_file_func;
-    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
-    pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
-    pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
-    pzlib_filefunc_def->zclose_file = win32_close_file_func;
-    pzlib_filefunc_def->zerror_file = win32_error_file_func;
-    pzlib_filefunc_def->opaque = NULL;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/manifest.c
----------------------------------------------------------------------
diff --git a/framework/private/src/manifest.c b/framework/private/src/manifest.c
deleted file mode 100644
index 29b155a..0000000
--- a/framework/private/src/manifest.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/**
- *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.
- */
-/*
- * manifest.c
- *
- *  \date       Jul 5, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "celixbool.h"
-
-#include "manifest.h"
-#include "utils.h"
-#include "celix_log.h"
-
-int fpeek(FILE *stream);
-celix_status_t manifest_readAttributes(manifest_pt manifest, properties_pt properties, FILE *file);
-
-celix_status_t manifest_create(manifest_pt *manifest) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*manifest = malloc(sizeof(**manifest));
-	if (!*manifest) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*manifest)->mainAttributes = properties_create();
-		(*manifest)->attributes = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot create manifest");
-
-	return status;
-}
-
-celix_status_t manifest_destroy(manifest_pt manifest) {
-	if (manifest != NULL) {
-	    properties_destroy(manifest->mainAttributes);
-		hashMap_destroy(manifest->attributes, true, false);
-		manifest->mainAttributes = NULL;
-		manifest->attributes = NULL;
-		free(manifest);
-		manifest = NULL;
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t manifest_createFromFile(const char *filename, manifest_pt *manifest) {
-	celix_status_t status;
-
-	status = manifest_create(manifest);
-
-	if (status == CELIX_SUCCESS) {
-		manifest_read(*manifest, filename);
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot create manifest from file");
-
-	return status;
-}
-
-void manifest_clear(manifest_pt manifest) {
-
-}
-
-properties_pt manifest_getMainAttributes(manifest_pt manifest) {
-	return manifest->mainAttributes;
-}
-
-celix_status_t manifest_getEntries(manifest_pt manifest, hash_map_pt *map) {
-	*map = manifest->attributes;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t manifest_read(manifest_pt manifest, const char *filename) {
-    celix_status_t status = CELIX_SUCCESS;
-
-	FILE *file = fopen ( filename, "r" );
-	if (file != NULL) {
-		char lbuf[512];
-		char name[512];
-		bool skipEmptyLines = true;
-		char lastline[512];
-		memset(lbuf,0,512);
-		memset(name,0,512);
-		memset(lastline,0,512);
-
-		manifest_readAttributes(manifest, manifest->mainAttributes, file);
-		
-		while (status==CELIX_SUCCESS && fgets(lbuf, sizeof(lbuf), file) != NULL) {
-			properties_pt attributes;
-			int len = strlen(lbuf);
-
-			if (lbuf[--len] != '\n') {
-				status = CELIX_FILE_IO_EXCEPTION;
-				framework_logIfError(logger, status, NULL, "Manifest '%s' line too long", filename);
-				break;
-			}
-			if (len > 0 && lbuf[len - 1] == '\r') {
-				--len;
-			}
-			if (len == 0 && skipEmptyLines) {
-				continue;
-			}
-			skipEmptyLines = false;
-
-			if (strlen(name) == 0) {
-				
-				if ((tolower(lbuf[0]) == 'n') && (tolower(lbuf[1]) == 'a') &&
-					(tolower(lbuf[2]) == 'm') && (tolower(lbuf[3]) == 'e') &&
-					(lbuf[4] == ':') && (lbuf[5] == ' ')) {
-					name[0] = '\0';
-					strncpy(name, lbuf+6, len - 6);
-					name[len - 6] = '\0';
-				} else {
-					status = CELIX_FILE_IO_EXCEPTION;
-					framework_logIfError(logger, status, NULL, "Manifest '%s' invalid format", filename);
-					break;
-				}
-
-				if (fpeek(file) == ' ') {
-					int newlen = len - 6;
-					lastline[0] = '\0';
-					strncpy(lastline, lbuf+6, len - 6);
-					lastline[newlen] = '\0';
-					continue;
-				}
-			} else {
-				int newlen = strlen(lastline) + len;
-				char buf[512];
-				buf[0] = '\0';
-				strcpy(buf, lastline);
-				strncat(buf, lbuf+1, len - 1);
-				buf[newlen] = '\0';
-
-				if (fpeek(file) == ' ') {
-//					lastline = realloc(lastline, strlen(buf) + 1);
-					lastline[0] = '\0';
-					strcpy(lastline, buf);
-					continue;
-				}
-				name[0] = '\0';
-				strcpy(name, buf);
-				name[strlen(buf)] = '\0';
-			}
-
-			attributes = hashMap_get(manifest->attributes, name);
-			if (attributes == NULL) {
-				attributes = properties_create();
-				hashMap_put(manifest->attributes, strdup(name), attributes);
-			}
-			manifest_readAttributes(manifest, attributes, file);
-
-			name[0] = '\0';
-			skipEmptyLines = true;
-		}
-		fclose(file);
-	} else {
-		status = CELIX_FILE_IO_EXCEPTION;
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot read manifest");
-
-	return status;
-}
-
-void manifest_write(manifest_pt manifest, const char * filename) {
-
-}
-
-const char* manifest_getValue(manifest_pt manifest, const char* name) {
-	const char* val = properties_get(manifest->mainAttributes, name);
-	bool isEmpty = utils_isStringEmptyOrNull(val);
-	return isEmpty ? NULL : val;
-}
-
-int fpeek(FILE *stream) {
-	int c;
-	c = fgetc(stream);
-	ungetc(c, stream);
-	return c;
-}
-
-celix_status_t manifest_readAttributes(manifest_pt manifest, properties_pt properties, FILE *file) {
-	char name[512]; memset(name,0,512);
-	char value[512]; memset(value,0,512);
-	char lastLine[512]; memset(lastLine,0,512);
-	char lbuf[512]; memset(lbuf,0,512);
-
-
-	while (fgets(lbuf, sizeof(lbuf), file ) != NULL ) {
-		int len = strlen(lbuf);
-
-		if (lbuf[--len] != '\n') {
-			printf("MANIFEST: Line too long\n");
-			return CELIX_FILE_IO_EXCEPTION;
-		}
-		if (len > 0 && lbuf[len - 1] == '\r') {
-			--len;
-		}
-		if (len == 0) {
-			break;
-		}
-		
-		if (lbuf[0] == ' ') {
-			char buf[512];
-			buf[0] = '\0';
-
-			// Line continued
-			strcat(buf, lastLine);
-			strncat(buf, lbuf+1, len - 1);
-
-			if (fpeek(file) == ' ') {
-//				lastLine = realloc(lastLine, strlen(buf) + 1);
-				lastLine[0] = '\0';
-				strcpy(lastLine, buf);
-				continue;
-			}
-			value[0] = '\0';
-			strcpy(value, buf);
-		} else {
-	        int i = 0;
-			while (lbuf[i++] != ':') {
-				if (i >= len) {
-					printf("MANIFEST: Invalid header\n");
-					return CELIX_FILE_IO_EXCEPTION;
-				}
-			}
-			if (lbuf[i++] != ' ') {
-				printf("MANIFEST: Invalid header\n");
-				return CELIX_FILE_IO_EXCEPTION;
-			}
-			name[0] = '\0';
-			strncpy(name, lbuf, i - 2);
-			name[i - 2] = '\0';
-			if (fpeek(file) == ' ') {
-				int newlen = len - i;
-				lastLine[0] = '\0';
-				strncpy(lastLine, lbuf+i, len -i);
-				lastLine[newlen] = '\0';
-				continue;
-			}
-			value[0] = '\0';
-			strncpy(value, lbuf+i, len - i);
-			value[len - i] = '\0';
-		}
-
-		properties_set(properties, name, value);
-	}
-
-	return CELIX_SUCCESS;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/manifest_parser.c
----------------------------------------------------------------------
diff --git a/framework/private/src/manifest_parser.c b/framework/private/src/manifest_parser.c
deleted file mode 100644
index 07b40a8..0000000
--- a/framework/private/src/manifest_parser.c
+++ /dev/null
@@ -1,490 +0,0 @@
-/**
- *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.
- */
-/*
- * manifest_parser.c
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "utils.h"
-#include "constants.h"
-#include "manifest_parser.h"
-#include "capability.h"
-#include "requirement.h"
-#include "attribute.h"
-#include "hash_map.h"
-#include "celix_errno.h"
-#include "linked_list_iterator.h"
-#include "celix_log.h"
-
-//FIXME the manifest parser has no destroy function and as result contains memory leaks.
-
-struct manifestParser {
-	module_pt owner;
-	manifest_pt manifest;
-
-	version_pt bundleVersion;
-	char * bundleSymbolicName;
-	linked_list_pt capabilities;
-	linked_list_pt requirements;
-};
-
-static linked_list_pt manifestParser_parseImportHeader(const char* header);
-static linked_list_pt manifestParser_parseExportHeader(module_pt module, const char* header);
-static linked_list_pt manifestParser_parseDelimitedString(const char* value, const char* delim);
-static linked_list_pt manifestParser_parseStandardHeaderClause(const char* clauseString);
-static linked_list_pt manifestParser_parseStandardHeader(const char* header);
-
-celix_status_t manifestParser_create(module_pt owner, manifest_pt manifest, manifest_parser_pt *manifest_parser) {
-	celix_status_t status;
-	manifest_parser_pt parser;
-
-	status = CELIX_SUCCESS;
-	parser = (manifest_parser_pt) malloc(sizeof(*parser));
-	if (parser) {
-		const char * bundleVersion = NULL;
-		const char * bundleSymbolicName = NULL;
-		parser->manifest = manifest;
-		parser->owner = owner;
-
-		bundleVersion = manifest_getValue(manifest, OSGI_FRAMEWORK_BUNDLE_VERSION);
-		if (bundleVersion != NULL) {
-			parser->bundleVersion = NULL;
-			version_createVersionFromString(bundleVersion, &parser->bundleVersion);
-		} else {
-			parser->bundleVersion = NULL;
-			version_createEmptyVersion(&parser->bundleVersion);
-		}
-		bundleSymbolicName = manifest_getValue(manifest, OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME);
-		if (bundleSymbolicName != NULL) {
-			parser->bundleSymbolicName = (char*)bundleSymbolicName;
-		}
-
-		parser->capabilities = manifestParser_parseExportHeader(owner, manifest_getValue(manifest, OSGI_FRAMEWORK_EXPORT_LIBRARY));
-		parser->requirements = manifestParser_parseImportHeader(manifest_getValue(manifest, OSGI_FRAMEWORK_IMPORT_LIBRARY));
-
-		*manifest_parser = parser;
-
-		status = CELIX_SUCCESS;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot create manifest parser");
-
-	return status;
-}
-
-celix_status_t manifestParser_destroy(manifest_parser_pt mp) {
-	linkedList_destroy(mp->capabilities);
-	mp->capabilities = NULL;
-	linkedList_destroy(mp->requirements);
-	mp->requirements = NULL;
-	mp->bundleSymbolicName = NULL;
-	version_destroy(mp->bundleVersion);
-	mp->bundleVersion = NULL;
-	mp->manifest = NULL;
-	mp->owner = NULL;
-
-	free(mp);
-
-	return CELIX_SUCCESS;
-}
-
-static linked_list_pt manifestParser_parseDelimitedString(const char * value, const char * delim) {
-	linked_list_pt list;
-
-	if (linkedList_create(&list) == CELIX_SUCCESS) {
-		if (value != NULL) {
-			int CHAR = 1;
-			int DELIMITER = 2;
-			int STARTQUOTE = 4;
-			int ENDQUOTE = 8;
-
-			char buffer[512];
-			int expecting = (CHAR | DELIMITER | STARTQUOTE);
-			unsigned int i;
-
-			buffer[0] = '\0';
-
-			for (i = 0; i < strlen(value); i++) {
-				char c = value[i];
-
-				bool isDelimiter = (strchr(delim, c) != NULL);
-				bool isQuote = (c == '"');
-
-				if (isDelimiter && ((expecting & DELIMITER) > 0)) {
-					linkedList_addElement(list, strdup(buffer));
-					buffer[0] = '\0';
-					expecting = (CHAR | DELIMITER | STARTQUOTE);
-				} else if (isQuote && ((expecting & STARTQUOTE) > 0)) {
-					char tmp[2];
-					tmp[0] = c;
-					tmp[1] = '\0';
-					strcat(buffer, tmp);
-					expecting = CHAR | ENDQUOTE;
-				} else if (isQuote && ((expecting & ENDQUOTE) > 0)) {
-					char tmp[2];
-					tmp[0] = c;
-					tmp[1] = '\0';
-					strcat(buffer, tmp);
-					expecting = (CHAR | STARTQUOTE | DELIMITER);
-				} else if ((expecting & CHAR) > 0) {
-					char tmp[2];
-					tmp[0] = c;
-					tmp[1] = '\0';
-					strcat(buffer, tmp);
-				} else {
-					linkedList_destroy(list);
-					return NULL;
-				}
-			}
-
-			if (strlen(buffer) > 0) {
-				linkedList_addElement(list, strdup(utils_stringTrim(buffer)));
-			}
-		}
-	}
-
-	return list;
-}
-
-static linked_list_pt manifestParser_parseStandardHeaderClause(const char * clauseString) {
-	linked_list_pt paths = NULL;
-	linked_list_pt clause = NULL;
-	linked_list_pt pieces = NULL;
-
-	if(linkedList_create(&paths) != CELIX_SUCCESS){
-		return NULL;
-	}
-
-	pieces = manifestParser_parseDelimitedString(clauseString, ";");
-
-	if (pieces != NULL) {
-		int pathCount = 0;
-		int pieceIdx;
-		hash_map_pt dirsMap = NULL;
-		hash_map_pt attrsMap = NULL;
-		char * sep;
-
-		for (pieceIdx = 0; pieceIdx < linkedList_size(pieces); pieceIdx++) {
-			char * piece = linkedList_get(pieces, pieceIdx);
-			if (strchr(piece, '=') != NULL) {
-				break;
-			} else {
-				linkedList_addElement(paths, strdup(piece));
-				pathCount++;
-			}
-		}
-
-		if (pathCount != 0) {
-
-			dirsMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-			attrsMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-
-			bool failure = false;
-			char *key = NULL;
-			char *value = NULL;
-
-			for (pieceIdx = pathCount; pieceIdx < linkedList_size(pieces) && !failure ; pieceIdx++) {
-				char * sepPtr;
-				char * DIRECTIVE_SEP = ":=";
-				char * ATTRIBUTE_SEP = "=";
-				char * piece = linkedList_get(pieces, pieceIdx);
-				if ((sepPtr = strstr(piece, DIRECTIVE_SEP)) != NULL) {
-					sep = DIRECTIVE_SEP;
-				} else if ((sepPtr = strstr(piece, ATTRIBUTE_SEP)) != NULL) {
-					sep = ATTRIBUTE_SEP;
-				} else {
-					failure=true;
-					break;
-				}
-
-				if (strcmp(sep, DIRECTIVE_SEP) == 0) {
-					// Not implemented
-				}
-				else {
-
-					key = string_ndup(piece, sepPtr - piece);
-					value = strdup(sepPtr+strlen(sep));
-
-					if (value[0] == '"' && value[strlen(value) -1] == '"') {
-						char * oldV = strdup(value);
-						int len = strlen(oldV) - 2;
-						value = (char *) realloc(value, (sizeof(char) * len+1));
-						value[0] = '\0';
-						value = strncpy(value, oldV+1, strlen(oldV) - 2);
-						value[len] = '\0';
-						//check if correct
-						free(oldV);
-					}
-
-					attribute_pt attr = NULL;
-					if (hashMap_containsKey(attrsMap, key)) {
-						failure=true;
-						break;
-					}
-
-					if (attribute_create(key, value, &attr) == CELIX_SUCCESS) {
-						hashMap_put(attrsMap, key, attr);
-					}
-				}
-			}
-
-			if(linkedList_create(&clause) != CELIX_SUCCESS){
-				failure=true;
-			}
-
-			if(failure){
-				hashMap_destroy(dirsMap,false,false);
-
-				hash_map_iterator_pt attrIter = hashMapIterator_create(attrsMap);
-				while(hashMapIterator_hasNext(attrIter)){
-					hash_map_entry_pt entry = hashMapIterator_nextEntry(attrIter);
-					char *mkey = (char*)hashMapEntry_getKey(entry);
-					attribute_pt mattr = (attribute_pt)hashMapEntry_getValue(entry);
-					free(mkey);
-					attribute_destroy(mattr);
-				}
-				hashMapIterator_destroy(attrIter);
-				hashMap_destroy(attrsMap,false,false);
-
-				if(key!=NULL){
-					free(key);
-				}
-				if(value!=NULL){
-					free(value);
-				}
-
-				linked_list_iterator_pt piter = linkedListIterator_create(paths,0);
-				while(linkedListIterator_hasNext(piter)){
-					free(linkedListIterator_next(piter));
-				}
-				linkedListIterator_destroy(piter);
-				linkedList_destroy(paths);
-
-				if(clause!=NULL){
-					linkedList_destroy(clause);
-					clause = NULL;
-				}
-			}
-			else{
-				linkedList_addElement(clause, paths);
-				linkedList_addElement(clause, dirsMap);
-				linkedList_addElement(clause, attrsMap);
-			}
-
-		}
-		else{
-			linkedList_destroy(paths);
-		}
-
-		for(int listIdx = 0; listIdx < linkedList_size(pieces); listIdx++){
-			void * element = linkedList_get(pieces, listIdx);
-			free(element);
-		}
-		linkedList_destroy(pieces);
-	}
-	else{
-		linkedList_destroy(paths);
-	}
-
-	return clause;
-}
-
-static linked_list_pt manifestParser_parseStandardHeader(const char * header) {
-	linked_list_pt clauseStrings = NULL;
-	linked_list_pt completeList = NULL;
-
-	if(header != NULL && strlen(header)==0){
-		return NULL;
-	}
-
-	if (linkedList_create(&completeList) == CELIX_SUCCESS) {
-		if(header!=NULL){
-			char *hdr = strdup(header);
-			clauseStrings = manifestParser_parseDelimitedString(hdr, ",");
-			free(hdr);
-			if (clauseStrings != NULL) {
-				int i;
-				for (i = 0; i < linkedList_size(clauseStrings); i++) {
-					char *clauseString = (char *) linkedList_get(clauseStrings, i);
-					linkedList_addElement(completeList, manifestParser_parseStandardHeaderClause(clauseString));
-					free(clauseString);
-				}
-				linkedList_destroy(clauseStrings);
-			}
-		}
-
-	}
-
-	return completeList;
-}
-
-static linked_list_pt manifestParser_parseImportHeader(const char * header) {
-	linked_list_pt clauses = NULL;
-	linked_list_pt requirements = NULL;
-	bool failure = false;
-
-	int clauseIdx;
-	linked_list_iterator_pt iter;
-	clauses = manifestParser_parseStandardHeader(header);
-	linkedList_create(&requirements);
-
-	for (clauseIdx = 0; clauseIdx < linkedList_size(clauses) && !failure ; clauseIdx++) {
-		linked_list_pt clause = linkedList_get(clauses, clauseIdx);
-
-		linked_list_pt paths = linkedList_get(clause, 0);
-		hash_map_pt directives = linkedList_get(clause, 1);
-		hash_map_pt attributes = linkedList_get(clause, 2);
-
-		int pathIdx;
-		for (pathIdx = 0; pathIdx < linkedList_size(paths) && !failure ; pathIdx++) {
-			attribute_pt name = NULL;
-			requirement_pt req = NULL;
-			char * path = (char *) linkedList_get(paths, pathIdx);
-			if (strlen(path) == 0) {
-				failure = true;
-				break;
-			}
-
-			if (attribute_create(strdup("service"), path, &name) == CELIX_SUCCESS) {
-				char *key = NULL;
-				attribute_getKey(name, &key);
-				hashMap_put(attributes, key, name);
-			}
-
-			requirement_create(directives, attributes, &req);
-			linkedList_addElement(requirements, req);
-		}
-	}
-
-	if(!failure){
-		iter = linkedListIterator_create(clauses, 0);
-		while(linkedListIterator_hasNext(iter)) {
-			linked_list_pt clause = linkedListIterator_next(iter);
-
-			linked_list_pt paths = linkedList_get(clause, 0);
-			linkedList_destroy(paths);
-
-			linkedListIterator_remove(iter);
-			linkedList_destroy(clause);
-		}
-		linkedListIterator_destroy(iter);
-	}
-
-	linkedList_destroy(clauses);
-
-	if(failure){
-		linkedList_destroy(requirements);
-		requirements = NULL;
-	}
-
-	return requirements;
-}
-
-static linked_list_pt manifestParser_parseExportHeader(module_pt module, const char * header) {
-	linked_list_pt clauses = NULL;
-	linked_list_pt capabilities = NULL;
-	int clauseIdx;
-	linked_list_iterator_pt iter;
-	bool failure = false;
-
-	clauses = manifestParser_parseStandardHeader(header);
-	linkedList_create(&capabilities);
-
-	for (clauseIdx = 0; clauseIdx < linkedList_size(clauses) && !failure ; clauseIdx++) {
-		linked_list_pt clause = linkedList_get(clauses, clauseIdx);
-
-		linked_list_pt paths = linkedList_get(clause, 0);
-		hash_map_pt directives = linkedList_get(clause, 1);
-		hash_map_pt attributes = linkedList_get(clause, 2);
-
-		int pathIdx;
-		for (pathIdx = 0; pathIdx < linkedList_size(paths) && !failure ; pathIdx++) {
-			char * path = (char *) linkedList_get(paths, pathIdx);
-			attribute_pt name = NULL;
-			capability_pt cap = NULL;
-			if (strlen(path) == 0) {
-				failure=true;
-				break;
-			}
-
-			if (attribute_create(strdup("service"), path, &name) == CELIX_SUCCESS) {
-				char *key = NULL;
-				attribute_getKey(name, &key);
-				hashMap_put(attributes, key, name);
-			}
-
-			capability_create(module, directives, attributes, &cap);
-			linkedList_addElement(capabilities, cap);
-		}
-	}
-
-	if(!failure){
-		iter = linkedListIterator_create(clauses, 0);
-		while(linkedListIterator_hasNext(iter)) {
-			linked_list_pt clause = linkedListIterator_next(iter);
-
-			linked_list_pt paths = linkedList_get(clause, 0);
-			linkedList_destroy(paths);
-
-			linkedListIterator_remove(iter);
-			linkedList_destroy(clause);
-		}
-		linkedListIterator_destroy(iter);
-	}
-
-	linkedList_destroy(clauses);
-	if(failure){
-		linkedList_destroy(capabilities);
-		capabilities = NULL;
-	}
-
-	return capabilities;
-}
-
-celix_status_t manifestParser_getAndDuplicateSymbolicName(manifest_parser_pt parser, char **symbolicName) {
-	*symbolicName = strndup(parser->bundleSymbolicName, 1024*10);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, version_pt *version) {
-	return version_clone(parser->bundleVersion, version);
-}
-
-celix_status_t manifestParser_getCapabilities(manifest_parser_pt parser, linked_list_pt *capabilities) {
-	celix_status_t status;
-
-	status = linkedList_clone(parser->capabilities, capabilities);
-
-	return status;
-}
-
-celix_status_t manifestParser_getRequirements(manifest_parser_pt parser, linked_list_pt *requirements) {
-	celix_status_t status;
-
-	status = linkedList_clone(parser->requirements, requirements);
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/miniunz.c
----------------------------------------------------------------------
diff --git a/framework/private/src/miniunz.c b/framework/private/src/miniunz.c
deleted file mode 100644
index c3a9bd1..0000000
--- a/framework/private/src/miniunz.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
-   miniunz.c
-   Version 1.1, February 14h, 2010
-   sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications of Unzip for Zip64
-         Copyright (C) 2007-2008 Even Rouault
-
-         Modifications for Zip64 support on both zip and unzip
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-*/
-
-#ifndef _WIN32
-        #ifndef __USE_FILE_OFFSET64
-                #define __USE_FILE_OFFSET64
-        #endif
-        #ifndef __USE_LARGEFILE64
-                #define __USE_LARGEFILE64
-        #endif
-        #ifndef _LARGEFILE64_SOURCE
-                #define _LARGEFILE64_SOURCE
-        #endif
-        #ifndef _FILE_OFFSET_BIT
-                #define _FILE_OFFSET_BIT 64
-        #endif
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#ifdef _WIN32
-#include <sys/utime.h>
-#else
-#include <utime.h>
-#endif
-#include <sys/stat.h>
-
-#include "unzip.h"
-#include "archive.h"
-
-#define CASESENSITIVITY (0)
-#define WRITEBUFFERSIZE (8192)
-#define MAXFILENAME (256)
-
-#ifdef _WIN32
-#define USEWIN32IOAPI
-#include "iowin32.h"
-#include <direct.h>
-#endif
-/*
-  mini unzip, demo of unzip package
-
-  usage :
-  Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir]
-
-  list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT
-    if it exists
-*/
-
-
-/* change_file_date : change the date/time of a file
-    filename : the filename of the file where date/time must be modified
-    dosdate : the new date at the MSDos format (4 bytes)
-    tmu_date : the SAME new date at the tm_unz format */
-void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date)
-{
-#ifdef _WIN32
-  HANDLE hFile;
-  FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
-
-  hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
-                      0,NULL,OPEN_EXISTING,0,NULL);
-  GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
-  DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
-  LocalFileTimeToFileTime(&ftLocal,&ftm);
-  SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
-  CloseHandle(hFile);
-#else
-#if defined(unix) || defined(__APPLE__)
-  struct utimbuf ut;
-  struct tm newdate;
-  newdate.tm_sec = tmu_date.tm_sec;
-  newdate.tm_min=tmu_date.tm_min;
-  newdate.tm_hour=tmu_date.tm_hour;
-  newdate.tm_mday=tmu_date.tm_mday;
-  newdate.tm_mon=tmu_date.tm_mon;
-  if (tmu_date.tm_year > 1900)
-      newdate.tm_year=tmu_date.tm_year - 1900;
-  else
-      newdate.tm_year=tmu_date.tm_year ;
-  newdate.tm_isdst=-1;
-
-  ut.actime=ut.modtime=mktime(&newdate);
-  utime(filename,&ut);
-#endif
-#endif
-}
-
-
-/* mymkdir and change_file_date are not 100 % portable
-   As I don't know well Unix, I wait feedback for the unix portion */
-
-int mymkdir(const char *dirname)
-{
-    int ret=0;
-#ifdef _WIN32
-    ret = _mkdir(dirname);
-#else
-#if defined unix || defined __APPLE__
-    ret = mkdir(dirname,0775);
-#endif
-#endif
-    return ret;
-}
-
-int makedir (char *newdir)
-{
-  char *buffer ;
-  char *p;
-  int  len = (int)strlen(newdir);
-
-  if (len <= 0)
-    return 0;
-
-  buffer = (char*)malloc(len+1);
-        if (buffer==NULL)
-        {
-                printf("Error allocating memory\n");
-                return UNZ_INTERNALERROR;
-        }
-  strcpy(buffer,newdir);
-
-  if (buffer[len-1] == '/') {
-    buffer[len-1] = '\0';
-  }
-  if (mymkdir(buffer) == 0)
-    {
-      free(buffer);
-      return 1;
-    }
-
-  p = buffer+1;
-  while (1)
-    {
-      char hold;
-
-      while(*p && *p != '\\' && *p != '/')
-        p++;
-      hold = *p;
-      *p = 0;
-      if ((mymkdir(buffer) == -1) && (errno == ENOENT))
-        {
-          printf("couldn't create directory %s\n",buffer);
-          free(buffer);
-          return 0;
-        }
-      if (hold == 0)
-        break;
-      *p++ = hold;
-    }
-  free(buffer);
-  return 1;
-}
-
-int do_extract_currentfile(unzFile uf, char * revisionRoot) {
-    char filename_inzip[256];
-    char* filename_withoutpath;
-    char* p;
-    int err=UNZ_OK;
-    FILE *fout=NULL;
-    void* buf;
-    uInt size_buf;
-
-    unz_file_info64 file_info;
-    err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
-
-    if (err!=UNZ_OK)
-    {
-        printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
-        return err;
-    }
-
-    size_buf = WRITEBUFFERSIZE;
-    buf = (void*)malloc(size_buf);
-    if (buf==NULL)
-    {
-        printf("Error allocating memory\n");
-        return UNZ_INTERNALERROR;
-    }
-
-    p = filename_withoutpath = filename_inzip;
-    while ((*p) != '\0')
-    {
-        if (((*p)=='/') || ((*p)=='\\'))
-            filename_withoutpath = p+1;
-        p++;
-    }
-
-    if ((*filename_withoutpath)=='\0') {
-		char * dir;
-		dir = (char *)malloc(strlen(revisionRoot) + strlen(filename_inzip) + 2);
-		strcpy(dir, revisionRoot);
-		strcat(dir, "/");
-		strcat(dir, filename_inzip);
-		mymkdir(dir);
-		free(dir);
-    }
-    else
-    {
-        const char* write_filename;
-        int skip=0;
-		int length;
-		char * fWFN;
-        write_filename = filename_inzip;
-
-        length = strlen(write_filename) + strlen(revisionRoot) + 2;
-        fWFN = (char *)malloc(length);
-        strcpy(fWFN, revisionRoot);
-        strcat(fWFN, "/");
-        strcat(fWFN, write_filename);
-
-        err = unzOpenCurrentFile(uf);
-        if (err!=UNZ_OK)
-        {
-            printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err);
-        }
-
-        if ((skip==0) && (err==UNZ_OK))
-        {
-            fout=fopen64(fWFN,"wb");
-
-            /* some zipfile don't contain directory alone before file */
-            if ((fout==NULL) && (filename_withoutpath!=(char*)filename_inzip))
-            {
-				char * dir;
-				int length;
-                char c=*(filename_withoutpath-1);
-                *(filename_withoutpath-1)='\0';
-                length = strlen(write_filename) + strlen(revisionRoot) + 2;
-                dir = (char *)malloc(length);
-				strcpy(dir, revisionRoot);
-				strcat(dir, "/");
-				strcat(dir, write_filename);
-                makedir(dir);
-                *(filename_withoutpath-1)=c;
-				free(dir);
-                fout=fopen64(fWFN,"wb");
-            }
-
-            if (fout==NULL)
-            {
-                printf("error opening %s\n",write_filename);
-            }
-        }
-
-        if (fout!=NULL)
-        {
-            do
-            {
-                err = unzReadCurrentFile(uf,buf,size_buf);
-                if (err<0)
-                {
-                    printf("error %d with zipfile in unzReadCurrentFile\n",err);
-                    break;
-                }
-                if (err>0)
-                    if (fwrite(buf,err,1,fout)!=1)
-                    {
-                        printf("error in writing extracted file\n");
-                        err=UNZ_ERRNO;
-                        break;
-                    }
-            }
-            while (err>0);
-            if (fout)
-                    fclose(fout);
-
-            if (err==0)
-                change_file_date(fWFN,file_info.dosDate,
-                                 file_info.tmu_date);
-        }
-
-        if (err==UNZ_OK)
-        {
-            err = unzCloseCurrentFile (uf);
-            if (err!=UNZ_OK)
-            {
-                printf("error %d with zipfile in unzCloseCurrentFile\n",err);
-            }
-        }
-        else
-            unzCloseCurrentFile(uf); /* don't lose the error */
-
-		free(fWFN);
-    }
-
-    free(buf);
-    return err;
-}
-
-
-int do_extract(unzFile uf, char * revisionRoot) {
-    uLong i;
-    unz_global_info64 gi;
-    int err;
-
-    err = unzGetGlobalInfo64(uf,&gi);
-    if (err!=UNZ_OK)
-        printf("error %d with zipfile in unzGetGlobalInfo \n",err);
-
-    for (i=0;i<gi.number_entry;i++)
-    {
-        if (do_extract_currentfile(uf, revisionRoot) != UNZ_OK)
-            break;
-
-        if ((i+1)<gi.number_entry)
-        {
-            err = unzGoToNextFile(uf);
-            if (err!=UNZ_OK)
-            {
-                printf("error %d with zipfile in unzGoToNextFile\n",err);
-                break;
-            }
-        }
-    }
-
-    return 0;
-}
-
-celix_status_t extractBundle(const char* bundleName, const char* revisionRoot) {
-    celix_status_t status = CELIX_SUCCESS;
-    char filename_try[MAXFILENAME+16] = "";
-    unzFile uf=NULL;
-
-    if (bundleName!=NULL)
-    {
-
-#        ifdef USEWIN32IOAPI
-        zlib_filefunc64_def ffunc;
-#        endif
-
-        strncpy(filename_try, bundleName,MAXFILENAME-1);
-        /* strncpy doesnt append the trailing NULL, of the string is too long. */
-        filename_try[ MAXFILENAME ] = '\0';
-
-#        ifdef USEWIN32IOAPI
-        fill_win32_filefunc64A(&ffunc);
-        uf = unzOpen2_64(bundleName,&ffunc);
-#        else
-        uf = unzOpen64(bundleName);
-#        endif
-        if (uf==NULL)
-        {
-            strcat(filename_try,".zip");
-#            ifdef USEWIN32IOAPI
-            uf = unzOpen2_64(filename_try,&ffunc);
-#            else
-            uf = unzOpen64(filename_try);
-#            endif
-        }
-    }
-
-    if (uf==NULL)
-    {
-        printf("Cannot open %s or %s.zip\n",bundleName,bundleName);
-        status = CELIX_FILE_IO_EXCEPTION;
-    } else {
-        if (do_extract(uf, (char*)revisionRoot) != 0) {
-            status = CELIX_FILE_IO_EXCEPTION;
-        }
-
-        unzClose(uf);
-    }
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/module.c
----------------------------------------------------------------------
diff --git a/framework/private/src/module.c b/framework/private/src/module.c
deleted file mode 100644
index e81a1ee..0000000
--- a/framework/private/src/module.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- *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.
- */
-/*
- * module.c
- *
- *  \date       Jul 19, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "module.h"
-#include "manifest_parser.h"
-#include "linked_list_iterator.h"
-
-struct module {
-	linked_list_pt capabilities;
-	linked_list_pt requirements;
-	linked_list_pt wires;
-
-	array_list_pt dependentImporters;
-
-	version_pt version;
-	char * symbolicName;
-	bool resolved;
-
-	manifest_pt headerMap;
-	char * id;
-
-	struct bundle * bundle;
-};
-
-module_pt module_create(manifest_pt headerMap, const char * moduleId, bundle_pt bundle) {
-    module_pt module = NULL;
-    manifest_parser_pt mp;
-
-    if (headerMap != NULL) {
-        module = (module_pt) malloc(sizeof(*module));
-        module->headerMap = headerMap;
-        module->id = strdup(moduleId);
-        module->bundle = bundle;
-        module->resolved = false;
-
-        module->dependentImporters = NULL;
-        arrayList_create(&module->dependentImporters);
-
-        if (manifestParser_create(module, headerMap, &mp) == CELIX_SUCCESS) {
-            module->symbolicName = NULL;
-            manifestParser_getAndDuplicateSymbolicName(mp, &module->symbolicName);
-
-            module->version = NULL;
-            manifestParser_getBundleVersion(mp, &module->version);
-
-            module->capabilities = NULL;
-            manifestParser_getCapabilities(mp, &module->capabilities);
-
-            module->requirements = NULL;
-            manifestParser_getRequirements(mp, &module->requirements);
-
-            module->wires = NULL;
-
-            manifestParser_destroy(mp);
-        }
-    }
-
-    return module;
-}
-
-module_pt module_createFrameworkModule(bundle_pt bundle) {
-    module_pt module;
-
-	module = (module_pt) malloc(sizeof(*module));
-	if (module) {
-        module->id = strdup("0");
-        module->symbolicName = strdup("framework");
-        module->version = NULL;
-        version_createVersion(1, 0, 0, "", &module->version);
-
-        linkedList_create(&module->capabilities);
-        linkedList_create(&module->requirements);
-        module->dependentImporters = NULL;
-        arrayList_create(&module->dependentImporters);
-        module->wires = NULL;
-        module->headerMap = NULL;
-        module->resolved = false;
-        module->bundle = bundle;
-	}
-	return module;
-}
-
-void module_destroy(module_pt module) {
-	arrayList_destroy(module->dependentImporters);
-
-	version_destroy(module->version);
-
-	if (module->wires != NULL) {
-        linked_list_iterator_pt iter = linkedListIterator_create(module->wires, 0);
-        while (linkedListIterator_hasNext(iter)) {
-            wire_pt next = linkedListIterator_next(iter);
-            linkedListIterator_remove(iter);
-            wire_destroy(next);
-        }
-        linkedListIterator_destroy(iter);
-        linkedList_destroy(module->wires);
-	}
-
-	if (module->requirements != NULL) {
-	    linked_list_iterator_pt iter = linkedListIterator_create(module->requirements, 0);
-        while (linkedListIterator_hasNext(iter)) {
-            requirement_pt next = linkedListIterator_next(iter);
-            linkedListIterator_remove(iter);
-            requirement_destroy(next);
-        }
-        linkedListIterator_destroy(iter);
-        linkedList_destroy(module->requirements);
-	}
-
-	if (module->capabilities != NULL) {
-	    linked_list_iterator_pt iter = linkedListIterator_create(module->capabilities, 0);
-        while (linkedListIterator_hasNext(iter)) {
-            capability_pt next = linkedListIterator_next(iter);
-            linkedListIterator_remove(iter);
-            capability_destroy(next);
-        }
-        linkedListIterator_destroy(iter);
-        linkedList_destroy(module->capabilities);
-    }
-
-	module->headerMap = NULL;
-
-	free(module->id);
-	free(module->symbolicName);
-	free(module);
-}
-
-wire_pt module_getWire(module_pt module, const char * serviceName) {
-	wire_pt wire = NULL;
-	if (module->wires != NULL) {
-		linked_list_iterator_pt iterator = linkedListIterator_create(module->wires, 0);
-		while (linkedListIterator_hasNext(iterator)) {
-			const char* name;
-			wire_pt next = linkedListIterator_next(iterator);
-			capability_pt cap = NULL;
-			wire_getCapability(next, &cap);
-			capability_getServiceName(cap, &name);
-			if (strcasecmp(name, serviceName) == 0) {
-				wire = next;
-			}
-		}
-		linkedListIterator_destroy(iterator);
-	}
-	return wire;
-}
-
-version_pt module_getVersion(module_pt module) {
-	return module->version;
-}
-
-celix_status_t module_getSymbolicName(module_pt module, const char **symbolicName) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (module == NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*symbolicName = module->symbolicName;
-	}
-
-	return status;
-}
-
-char * module_getId(module_pt module) {
-	return module->id;
-}
-
-linked_list_pt module_getWires(module_pt module) {
-	return module->wires;
-}
-
-void module_setWires(module_pt module, linked_list_pt wires) {
-    int i = 0;
-    for (i = 0; (module->wires != NULL) && (i < linkedList_size(module->wires)); i++) {
-        wire_pt wire = (wire_pt) linkedList_get(module->wires, i);
-        module_pt exporter = NULL;
-        wire_getExporter(wire, &exporter);
-        module_removeDependentImporter(exporter, module);
-    }
-
-    if (module->wires != NULL) {
-		linked_list_iterator_pt iter = linkedListIterator_create(module->wires, 0);
-		while (linkedListIterator_hasNext(iter)) {
-			wire_pt next = linkedListIterator_next(iter);
-			linkedListIterator_remove(iter);
-			wire_destroy(next);
-		}
-		linkedListIterator_destroy(iter);
-		linkedList_destroy(module->wires);
-	}
-
-	module->wires = wires;
-
-	for (i = 0; (module->wires != NULL) && (i < linkedList_size(module->wires)); i++) {
-        wire_pt wire = (wire_pt) linkedList_get(module->wires, i);
-        module_pt exporter = NULL;
-        wire_getExporter(wire, &exporter);
-        module_addDependentImporter(exporter, module);
-    }
-}
-
-bool module_isResolved(module_pt module) {
-	return module->resolved;
-}
-
-void module_setResolved(module_pt module) {
-	module->resolved = true;
-}
-
-bundle_pt module_getBundle(module_pt module) {
-	return module->bundle;
-}
-
-linked_list_pt module_getRequirements(module_pt module) {
-	return module->requirements;
-}
-
-linked_list_pt module_getCapabilities(module_pt module) {
-	return module->capabilities;
-}
-
-array_list_pt module_getDependentImporters(module_pt module) {
-    return module->dependentImporters;
-}
-
-void module_addDependentImporter(module_pt module, module_pt importer) {
-    if (!arrayList_contains(module->dependentImporters, importer)) {
-        arrayList_add(module->dependentImporters, importer);
-    }
-}
-
-void module_removeDependentImporter(module_pt module, module_pt importer) {
-    arrayList_removeElement(module->dependentImporters, importer);
-}
-
-//----------------------------------------------------
-//TODO add implementation (functions not implemented but already exported)
-array_list_pt module_getDependentRequirers(module_pt module) {
-	return NULL;
-}
-
-void module_addDependentRequirer(module_pt module, module_pt requirer) {
-}
-
-void module_removeDependentRequirer(module_pt module, module_pt requirer) {
-}
-//----------------------------------------------------
-
-array_list_pt module_getDependents(module_pt module) {
-    array_list_pt dependents = NULL;
-    arrayList_create(&dependents);
-
-    arrayList_addAll(dependents, module->dependentImporters);
-
-    return dependents;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/requirement.c
----------------------------------------------------------------------
diff --git a/framework/private/src/requirement.c b/framework/private/src/requirement.c
deleted file mode 100644
index 7ce585c..0000000
--- a/framework/private/src/requirement.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- *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.
- */
-/*
- * requirement.c
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "requirement_private.h"
-#include "version_range.h"
-#include "attribute.h"
-#include "celix_log.h"
-
-celix_status_t requirement_create(hash_map_pt directives, hash_map_pt attributes, requirement_pt *requirement) {
-	celix_status_t status;
-
-	*requirement = (requirement_pt) malloc(sizeof(**requirement));
-	if (!*requirement) {
-		status = CELIX_ENOMEM;
-	} else {
-		attribute_pt serviceAttribute = NULL;
-		attribute_pt versionAttribute = NULL;
-
-		(*requirement)->attributes = attributes;
-		(*requirement)->directives = directives;
-		(*requirement)->versionRange = NULL;
-
-		serviceAttribute = (attribute_pt) hashMap_get(attributes, "service");
-		status = attribute_getValue(serviceAttribute, &(*requirement)->targetName);
-		if (status == CELIX_SUCCESS) {
-			versionAttribute = (attribute_pt) hashMap_get(attributes, "version");
-			if (versionAttribute != NULL) {
-				char *versionStr = NULL;
-				attribute_getValue(versionAttribute, &versionStr);
-				status = versionRange_parse(versionStr, &(*requirement)->versionRange);
-			} else {
-				status = versionRange_createInfiniteVersionRange(&(*requirement)->versionRange);
-			}
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot create requirement");
-
-	return status;
-}
-
-celix_status_t requirement_destroy(requirement_pt requirement) {
-	hash_map_iterator_pt attrIter = hashMapIterator_create(requirement->attributes);
-	while (hashMapIterator_hasNext(attrIter)) {
-		attribute_pt attr = hashMapIterator_nextValue(attrIter);
-		hashMapIterator_remove(attrIter);
-		attribute_destroy(attr);
-	}
-	hashMapIterator_destroy(attrIter);
-	hashMap_destroy(requirement->attributes, false, false);
-	hashMap_destroy(requirement->directives, false, false);
-
-	requirement->attributes = NULL;
-	requirement->directives = NULL;
-
-	versionRange_destroy(requirement->versionRange);
-	requirement->versionRange = NULL;
-
-	free(requirement);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t requirement_getVersionRange(requirement_pt requirement, version_range_pt *range) {
-	*range = requirement->versionRange;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t requirement_getTargetName(requirement_pt requirement, const char **targetName) {
-	*targetName = requirement->targetName;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t requirement_isSatisfied(requirement_pt requirement, capability_pt capability, bool *inRange) {
-	celix_status_t status;
-	version_pt version = NULL;
-	version_range_pt range = NULL;
-
-	status = capability_getVersion(capability, &version);
-	if (status == CELIX_SUCCESS) {
-		status = requirement_getVersionRange(requirement, &range);
-		if (status == CELIX_SUCCESS) {
-			status = versionRange_isInRange(range, version, inRange);
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot check if requirement is satisfied");
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/resolver.c
----------------------------------------------------------------------
diff --git a/framework/private/src/resolver.c b/framework/private/src/resolver.c
deleted file mode 100644
index 256eff5..0000000
--- a/framework/private/src/resolver.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/**
- *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.
- */
-/*
- * resolver.c
- *
- *  \date       Jul 13, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "resolver.h"
-#include "linked_list_iterator.h"
-#include "bundle.h"
-#include "celix_log.h"
-
-struct capabilityList {
-    char * serviceName;
-    linked_list_pt capabilities;
-};
-
-typedef struct capabilityList * capability_list_pt;
-
-struct candidateSet {
-    module_pt module;
-    requirement_pt requirement;
-    linked_list_pt candidates;
-};
-
-typedef struct candidateSet * candidate_set_pt;
-
-// List containing module_ts
-linked_list_pt m_modules = NULL;
-// List containing capability_t_LISTs
-linked_list_pt m_unresolvedServices = NULL;
-// List containing capability_t_LISTs
-linked_list_pt m_resolvedServices = NULL;
-
-int resolver_populateCandidatesMap(hash_map_pt candidatesMap, module_pt targetModule);
-capability_list_pt resolver_getCapabilityList(linked_list_pt list, const char* name);
-void resolver_removeInvalidCandidate(module_pt module, hash_map_pt candidates, linked_list_pt invalid);
-linked_list_pt resolver_populateWireMap(hash_map_pt candidates, module_pt importer, linked_list_pt wireMap);
-
-linked_list_pt resolver_resolve(module_pt root) {
-    hash_map_pt candidatesMap = NULL;
-    linked_list_pt wireMap = NULL;
-    linked_list_pt resolved = NULL;
-    hash_map_iterator_pt iter = NULL;
-
-    if (module_isResolved(root)) {
-        return NULL;
-    }
-
-    candidatesMap = hashMap_create(NULL, NULL, NULL, NULL);
-
-    if (resolver_populateCandidatesMap(candidatesMap, root) != 0) {
-        hash_map_iterator_pt iter = hashMapIterator_create(candidatesMap);
-        while (hashMapIterator_hasNext(iter)) {
-            hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-            linked_list_pt value = hashMapEntry_getValue(entry);
-            hashMapIterator_remove(iter);
-            if (value != NULL) {
-                linked_list_iterator_pt candSetIter = linkedListIterator_create(value, 0);
-                while (linkedListIterator_hasNext(candSetIter)) {
-                    candidate_set_pt set = linkedListIterator_next(candSetIter);
-                    linkedList_destroy(set->candidates);
-                    free(set);
-                    linkedListIterator_remove(candSetIter);
-                }
-                linkedListIterator_destroy(candSetIter);
-                linkedList_destroy(value);
-            }
-        }
-        hashMapIterator_destroy(iter);
-        hashMap_destroy(candidatesMap, false, false);
-        return NULL;
-    }
-
-    linkedList_create(&wireMap);
-    resolved = resolver_populateWireMap(candidatesMap, root, wireMap);
-    iter = hashMapIterator_create(candidatesMap);
-    while (hashMapIterator_hasNext(iter)) {
-        hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-        linked_list_pt value = hashMapEntry_getValue(entry);
-        hashMapIterator_remove(iter);
-        if (value != NULL) {
-            linked_list_iterator_pt candSetIter = linkedListIterator_create(value, 0);
-            while (linkedListIterator_hasNext(candSetIter)) {
-                candidate_set_pt set = linkedListIterator_next(candSetIter);
-                linkedList_destroy(set->candidates);
-                free(set);
-                linkedListIterator_remove(candSetIter);
-            }
-            linkedListIterator_destroy(candSetIter);
-            linkedList_destroy(value);
-        }
-    }
-    hashMapIterator_destroy(iter);
-    hashMap_destroy(candidatesMap, false, false);
-    return resolved;
-}
-
-int resolver_populateCandidatesMap(hash_map_pt candidatesMap, module_pt targetModule) {
-    linked_list_pt candSetList;
-    linked_list_pt candidates;
-    linked_list_pt invalid;
-
-    if (hashMap_containsKey(candidatesMap, targetModule)) {
-        return 0;
-    }
-
-    hashMap_put(candidatesMap, targetModule, NULL);
-
-    if (linkedList_create(&candSetList) == CELIX_SUCCESS) {
-        int i;
-        for (i = 0; i < linkedList_size(module_getRequirements(targetModule)); i++) {
-            capability_list_pt capList;
-            requirement_pt req;
-            const char *targetName = NULL;
-            req = (requirement_pt) linkedList_get(module_getRequirements(targetModule), i);
-            requirement_getTargetName(req, &targetName);
-            capList = resolver_getCapabilityList(m_resolvedServices, targetName);
-
-            if (linkedList_create(&candidates) == CELIX_SUCCESS) {
-                int c;
-                for (c = 0; (capList != NULL) && (c < linkedList_size(capList->capabilities)); c++) {
-                    capability_pt cap = (capability_pt) linkedList_get(capList->capabilities, c);
-                    bool satisfied = false;
-                    requirement_isSatisfied(req, cap, &satisfied);
-                    if (satisfied) {
-                        linkedList_addElement(candidates, cap);
-                    }
-                }
-                capList = resolver_getCapabilityList(m_unresolvedServices, targetName);
-                for (c = 0; (capList != NULL) && (c < linkedList_size(capList->capabilities)); c++) {
-                    capability_pt cap = (capability_pt) linkedList_get(capList->capabilities, c);
-                    bool satisfied = false;
-                    requirement_isSatisfied(req, cap, &satisfied);
-                    if (satisfied) {
-                        linkedList_addElement(candidates, cap);
-                    }
-                }
-
-                if (linkedList_size(candidates) > 0) {
-                    linked_list_iterator_pt iterator = NULL;
-                    for (iterator = linkedListIterator_create(candidates, 0); linkedListIterator_hasNext(iterator);) {
-                        capability_pt candidate = (capability_pt) linkedListIterator_next(iterator);
-                        module_pt module = NULL;
-                        capability_getModule(candidate, &module);
-                        if (!module_isResolved(module)) {
-                            if (resolver_populateCandidatesMap(candidatesMap, module) != 0) {
-                                linkedListIterator_remove(iterator);
-                            }
-                        }
-                    }
-                    linkedListIterator_destroy(iterator);
-                }
-
-                if (linkedList_size(candidates) == 0) {
-                    if (linkedList_create(&invalid) == CELIX_SUCCESS) {
-                        const char *name = NULL;
-                        resolver_removeInvalidCandidate(targetModule, candidatesMap, invalid);
-
-                        module_getSymbolicName(targetModule, &name);
-
-                        linkedList_destroy(invalid);
-                        fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Unable to resolve: %s, %s\n", name, targetName);
-                    }
-                    linkedList_destroy(candidates);
-                    linkedList_destroy(candSetList);
-                    return -1;
-                } else if (linkedList_size(candidates) > 0) {
-                    candidate_set_pt cs = (candidate_set_pt) malloc(sizeof(*cs));
-                    cs->candidates = candidates;
-                    cs->module = targetModule;
-                    cs->requirement = req;
-                    linkedList_addElement(candSetList, cs);
-                }
-
-            }
-        }
-        hashMap_put(candidatesMap, targetModule, candSetList);
-    }
-    return 0;
-}
-
-void resolver_removeInvalidCandidate(module_pt invalidModule, hash_map_pt candidates, linked_list_pt invalid) {
-    hash_map_iterator_pt iterator;
-    hashMap_remove(candidates, invalidModule);
-
-    for (iterator = hashMapIterator_create(candidates); hashMapIterator_hasNext(iterator);) {
-        hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
-        linked_list_pt candSetList = (linked_list_pt) hashMapEntry_getValue(entry);
-        if (candSetList != NULL) {
-            linked_list_iterator_pt itCandSetList;
-            for (itCandSetList = linkedListIterator_create(candSetList, 0); linkedListIterator_hasNext(itCandSetList);) {
-                candidate_set_pt set = (candidate_set_pt) linkedListIterator_next(itCandSetList);
-                linked_list_iterator_pt candIter;
-                for (candIter = linkedListIterator_create(set->candidates, 0); linkedListIterator_hasNext(candIter);) {
-                    capability_pt candCap = (capability_pt) linkedListIterator_next(candIter);
-                    module_pt module = NULL;
-                    capability_getModule(candCap, &module);
-                    if (module == invalidModule) {
-                        linkedListIterator_remove(candIter);
-                        if (linkedList_size(set->candidates) == 0) {
-                            linkedListIterator_remove(itCandSetList);
-                            if (module != invalidModule && linkedList_contains(invalid, module)) {
-                                linkedList_addElement(invalid, module);
-                            }
-                        }
-                        break;
-                    }
-                }
-                linkedListIterator_destroy(candIter);
-            }
-            linkedListIterator_destroy(itCandSetList);
-        }
-    }
-    hashMapIterator_destroy(iterator);
-
-    if (linkedList_size(invalid) > 0) {
-        while (!linkedList_isEmpty(invalid)) {
-            module_pt m = (module_pt) linkedList_removeIndex(invalid, 0);
-            resolver_removeInvalidCandidate(m, candidates, invalid);
-        }
-    }
-}
-
-void resolver_addModule(module_pt module) {
-
-    if (m_modules == NULL) {
-        linkedList_create(&m_modules);
-        linkedList_create(&m_unresolvedServices);
-        linkedList_create(&m_resolvedServices);
-    }
-
-    if (m_modules != NULL && m_unresolvedServices != NULL) {
-        int i;
-
-        linkedList_addElement(m_modules, module);
-
-        for (i = 0; i < linkedList_size(module_getCapabilities(module)); i++) {
-            const char *serviceName = NULL;
-            capability_list_pt list = NULL;
-            capability_pt cap;
-
-            cap = (capability_pt) linkedList_get(module_getCapabilities(module), i);
-            capability_getServiceName(cap, &serviceName);
-            list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
-            if (list == NULL) {
-                list = (capability_list_pt) malloc(sizeof(*list));
-                if (list != NULL) {
-                    list->serviceName = strdup(serviceName);
-                    if (linkedList_create(&list->capabilities) == CELIX_SUCCESS) {
-                        linkedList_addElement(m_unresolvedServices, list);
-                    }
-                    else{
-                    	free(list->serviceName);
-                    	free(list);
-			list=NULL;
-                    }
-                }
-            }
-            if(list != NULL){
-		linkedList_addElement(list->capabilities, cap);
-            }
-        }
-    }
-}
-
-void resolver_removeModule(module_pt module) {
-    linked_list_pt caps = NULL;
-    linkedList_removeElement(m_modules, module);
-    caps = module_getCapabilities(module);
-    if (caps != NULL) {
-        int i = 0;
-        for (i = 0; i < linkedList_size(caps); i++) {
-            capability_pt cap = (capability_pt) linkedList_get(caps, i);
-            const char *serviceName = NULL;
-            capability_list_pt list;
-            capability_getServiceName(cap, &serviceName);
-            list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
-            if (list != NULL) {
-                linkedList_removeElement(list->capabilities, cap);
-
-                if (linkedList_isEmpty(list->capabilities)) {
-                    linkedList_removeElement(m_unresolvedServices, list);
-                    linkedList_destroy(list->capabilities);
-                    free(list->serviceName);
-                    free(list);
-                }
-            }
-            list = resolver_getCapabilityList(m_resolvedServices, serviceName);
-            if (list != NULL) {
-                linkedList_removeElement(list->capabilities, cap);
-
-                if (linkedList_isEmpty(list->capabilities)) {
-                    linkedList_removeElement(m_resolvedServices, list);
-                    linkedList_destroy(list->capabilities);
-                    free(list->serviceName);
-                    free(list);
-                }
-            }
-        }
-    }
-    if (linkedList_isEmpty(m_modules)) {
-        linkedList_destroy(m_modules);
-        m_modules = NULL;
-
-        if (!linkedList_isEmpty(m_unresolvedServices)) {
-            // #TODO: Something is wrong, not all modules have been removed from the resolver
-            fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Unexpected entries in unresolved module list");
-        }
-        linkedList_destroy(m_unresolvedServices);
-        m_unresolvedServices = NULL;
-        if (!linkedList_isEmpty(m_resolvedServices)) {
-            // #TODO: Something is wrong, not all modules have been removed from the resolver
-            fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Unexpected entries in resolved module list");
-        }
-        linkedList_destroy(m_resolvedServices);
-        m_resolvedServices = NULL;
-    }
-}
-
-void resolver_moduleResolved(module_pt module) {
-
-    if (module_isResolved(module)) {
-        linked_list_pt capsCopy = NULL;
-
-        if (linkedList_create(&capsCopy) == CELIX_SUCCESS) {
-            linked_list_pt wires = NULL;
-            int capIdx;
-
-            for (capIdx = 0; (module_getCapabilities(module) != NULL) && (capIdx < linkedList_size(module_getCapabilities(module))); capIdx++) {
-                capability_pt cap = (capability_pt) linkedList_get(module_getCapabilities(module), capIdx);
-                const char *serviceName = NULL;
-                capability_list_pt list;
-                capability_getServiceName(cap, &serviceName);
-                list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
-                if(list != NULL){
-			linkedList_removeElement(list->capabilities, cap);
-                }
-
-                linkedList_addElement(capsCopy, cap);
-            }
-
-            wires = module_getWires(module);
-            for (capIdx = 0; (capsCopy != NULL) && (capIdx < linkedList_size(capsCopy)); capIdx++) {
-                capability_pt cap = linkedList_get(capsCopy, capIdx);
-
-                int wireIdx = 0;
-                for (wireIdx = 0; (wires != NULL) && (wireIdx < linkedList_size(wires)); wireIdx++) {
-                    wire_pt wire = (wire_pt) linkedList_get(wires, wireIdx);
-                    requirement_pt req = NULL;
-                    bool satisfied = false;
-                    wire_getRequirement(wire, &req);
-                    requirement_isSatisfied(req, cap, &satisfied);
-                    if (satisfied) {
-                        linkedList_set(capsCopy, capIdx, NULL);
-                        break;
-                    }
-                }
-            }
-
-            for (capIdx = 0; (capsCopy != NULL) && (capIdx < linkedList_size(capsCopy)); capIdx++) {
-                capability_pt cap = linkedList_get(capsCopy, capIdx);
-
-                if (cap != NULL) {
-                    const char *serviceName = NULL;
-                    capability_list_pt list = NULL;
-                    capability_getServiceName(cap, &serviceName);
-
-                    list = resolver_getCapabilityList(m_resolvedServices, serviceName);
-                    if (list == NULL) {
-                        list = (capability_list_pt) malloc(sizeof(*list));
-                        if (list != NULL) {
-                            list->serviceName = strdup(serviceName);
-                            if (linkedList_create(&list->capabilities) == CELIX_SUCCESS) {
-                                linkedList_addElement(m_resolvedServices, list);
-                            }
-                            else{
-                            	free(list->serviceName);
-                            	free(list);
-				list=NULL;
-                            }
-                        }
-                    }
-                    if(list != NULL){
-			linkedList_addElement(list->capabilities, cap);
-                    }
-                }
-            }
-
-            linkedList_destroy(capsCopy);
-        }
-    }
-}
-
-capability_list_pt resolver_getCapabilityList(linked_list_pt list, const char * name) {
-    capability_list_pt capabilityList = NULL;
-    linked_list_iterator_pt iterator = linkedListIterator_create(list, 0);
-    while (linkedListIterator_hasNext(iterator)) {
-        capability_list_pt services = (capability_list_pt) linkedListIterator_next(iterator);
-        if (strcmp(services->serviceName, name) == 0) {
-            capabilityList = services;
-            break;
-        }
-    }
-    linkedListIterator_destroy(iterator);
-    return capabilityList;
-}
-
-linked_list_pt resolver_populateWireMap(hash_map_pt candidates, module_pt importer, linked_list_pt wireMap) {
-    linked_list_pt serviceWires;
-
-    if (candidates && importer && wireMap) {
-        linked_list_pt candSetList = NULL;
-        bool resolved = false;
-
-        if (module_isResolved(importer)) {
-            // already resolved
-            resolved = true;
-        }
-        if (!resolved) {
-            bool self = false;
-            linked_list_iterator_pt wit = linkedListIterator_create(wireMap, 0);
-            while (linkedListIterator_hasNext(wit)) {
-                importer_wires_pt iw = linkedListIterator_next(wit);
-                if (iw->importer == importer) {
-                    // Do not resolve yourself
-                    self = true;
-                    break;
-                }
-            }
-            linkedListIterator_destroy(wit);
-
-            if (!self) {
-                candSetList = (linked_list_pt) hashMap_get(candidates, importer);
-
-                if (linkedList_create(&serviceWires) == CELIX_SUCCESS) {
-//                    if (linkedList_create(&emptyWires) == CELIX_SUCCESS) {
-                    int candSetIdx = 0;
-
-                    // hashMap_put(wireMap, importer, emptyWires);
-
-                    const char *mname = NULL;
-                    module_getSymbolicName(importer, &mname);
-
-                    importer_wires_pt importerWires = malloc(sizeof(*importerWires));
-                    importerWires->importer = importer;
-                    importerWires->wires = NULL;
-                    linkedList_addElement(wireMap, importerWires);
-
-                    for (candSetIdx = 0; candSetIdx < linkedList_size(candSetList); candSetIdx++) {
-                        candidate_set_pt cs = (candidate_set_pt) linkedList_get(candSetList, candSetIdx);
-
-                        module_pt module = NULL;
-                        capability_getModule(((capability_pt) linkedList_get(cs->candidates, 0)), &module);
-                        if (importer != module) {
-                            wire_pt wire = NULL;
-                            wire_create(importer, cs->requirement, module, ((capability_pt) linkedList_get(cs->candidates, 0)), &wire);
-                            linkedList_addElement(serviceWires, wire);
-                        }
-
-                        wireMap = resolver_populateWireMap(candidates, module, wireMap);
-                    }
-
-                    importerWires->wires = serviceWires;
-                    // hashMap_put(wireMap, importer, serviceWires);
-//                    }
-                }
-            }
-        }
-    }
-
-    return wireMap;
-}


[33/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/dyn_type.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_type.c b/dfi/private/src/dyn_type.c
deleted file mode 100644
index 4fc79ff..0000000
--- a/dfi/private/src/dyn_type.c
+++ /dev/null
@@ -1,1160 +0,0 @@
-/**
- *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.
- */
-#include "dyn_type.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-#include <ffi.h>
-
-#include "dyn_common.h"
-
-DFI_SETUP_LOG(dynType)
-
-static int dynType_parseWithStream(FILE *stream, const char *name, dyn_type *parent, struct types_head *refTypes, dyn_type **result);
-static void dynType_clear(dyn_type *type);
-static void dynType_clearComplex(dyn_type *type);
-static void dynType_clearSequence(dyn_type *type);
-static void dynType_clearTypedPointer(dyn_type *type);
-ffi_type * dynType_ffiType(dyn_type *type);
-
-static struct type_entry *dynType_allocTypeEntry(void);
-
-static ffi_type * dynType_ffiTypeFor(int c);
-static dyn_type * dynType_findType(dyn_type *type, char *name);
-static int dynType_parseAny(FILE *stream, dyn_type *type);
-static int dynType_parseComplex(FILE *stream, dyn_type *type);
-static int dynType_parseNestedType(FILE *stream, dyn_type *type);
-static int dynType_parseReference(FILE *stream, dyn_type *type);
-static int dynType_parseRefByValue(FILE *stream, dyn_type *type);
-static int dynType_parseSequence(FILE *stream, dyn_type *type);
-static int dynType_parseSimple(int c, dyn_type *type);
-static int dynType_parseTypedPointer(FILE *stream, dyn_type *type);
-static void dynType_prepCif(ffi_type *type);
-static unsigned short dynType_getOffset(dyn_type *type, int index);
-
-static void dynType_printAny(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printComplex(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printSequence(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printSimple(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printTypedPointer(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printDepth(int depth, FILE *stream);
-
-static void dynType_printTypes(dyn_type *type, FILE *stream);
-static void dynType_printComplexType(dyn_type *type, FILE *stream);
-static void dynType_printSimpleType(dyn_type *type, FILE *stream);
-
-static int dynType_parseText(FILE *stream, dyn_type *type);
-void dynType_freeComplexType(dyn_type *type, void *loc);
-void dynType_deepFree(dyn_type *type, void *loc, bool alsoDeleteSelf);
-void dynType_freeSequenceType(dyn_type *type, void *seqLoc);
-
-static int dynType_parseMetaInfo(FILE *stream, dyn_type *type);
-
-struct generic_sequence {
-    uint32_t cap;
-    uint32_t len;
-    void *buf;
-};
-
-TAILQ_HEAD(meta_properties_head, meta_entry);
-struct meta_entry {
-    char *name;
-    char *value;
-    TAILQ_ENTRY(meta_entry) entries;
-};
-
-
-struct _dyn_type {
-    char *name;
-    char descriptor;
-    int type;
-    ffi_type *ffiType;
-    dyn_type *parent;
-    struct types_head *referenceTypes; //NOTE: not owned
-    struct types_head nestedTypesHead;
-    struct meta_properties_head metaProperties;
-    union {
-        struct {
-            struct complex_type_entries_head entriesHead;
-            ffi_type structType; //dyn_type.ffiType points to this
-            dyn_type **types; //based on entriesHead for fast access
-        } complex;
-        struct {
-            ffi_type seqType; //dyn_type.ffiType points to this
-            dyn_type *itemType;
-        } sequence;
-        struct {
-            dyn_type *typedType;
-        } typedPointer;
-        struct {
-            dyn_type *ref;
-        } ref;
-    };
-};
-
-static const int OK = 0;
-static const int ERROR = 1;
-static const int MEM_ERROR = 2;
-static const int PARSE_ERROR = 3;
-
-int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *refTypes, dyn_type **type) {
-    return dynType_parseWithStream(descriptorStream, name, NULL, refTypes, type);
-}
-
-int dynType_parseWithStr(const char *descriptor, const char *name, struct types_head *refTypes, dyn_type **type) {
-    int status = OK;
-    FILE *stream = fmemopen((char *)descriptor, strlen(descriptor), "r");
-    if (stream != NULL) {
-        status = dynType_parseWithStream(stream, name, NULL, refTypes, type);
-        if (status == OK) {
-            int c = fgetc(stream);
-            if (c != '\0' && c != EOF) {
-                status = PARSE_ERROR;
-                LOG_ERROR("Expected EOF got %c", c);
-            }
-        } 
-        fclose(stream);
-    } else {
-        status = ERROR;
-        LOG_ERROR("Error creating mem stream for descriptor string. %s", strerror(errno)); 
-    }
-    return status;
-}
-
-static int dynType_parseWithStream(FILE *stream, const char *name, dyn_type *parent, struct types_head *refTypes, dyn_type **result) {
-    int status = OK;
-    dyn_type *type = calloc(1, sizeof(*type));
-    if (type != NULL) {
-        type->parent = parent;
-        type->type = DYN_TYPE_INVALID;
-        type->referenceTypes = refTypes;
-        TAILQ_INIT(&type->nestedTypesHead);
-        TAILQ_INIT(&type->metaProperties);
-        if (name != NULL) {
-            type->name = strdup(name);
-            if (type->name == NULL) {
-                status = MEM_ERROR;
-                LOG_ERROR("Error strdup'ing name '%s'\n", name);			
-            } 
-        }
-        if (status == OK) {
-            status = dynType_parseAny(stream, type);        
-        }
-        if (status == OK) {
-            *result = type;
-        } else {
-            dynType_destroy(type);
-        }
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error allocating memory for type");
-    }
-    return status;
-}
-
-static int dynType_parseAny(FILE *stream, dyn_type *type) {
-    int status = OK;
-
-    int c = fgetc(stream);
-    switch(c) {
-        case 'T' :
-            status = dynType_parseNestedType(stream, type);
-            if (status == OK) {
-                status = dynType_parseAny(stream, type);
-            } 
-            break;
-        case 'L' :
-            status = dynType_parseReference(stream, type);
-            break;
-        case 'l' :
-            status = dynType_parseRefByValue(stream, type);
-            break;
-        case '{' :
-            status = dynType_parseComplex(stream, type);
-            break;
-        case '[' :
-            status = dynType_parseSequence(stream, type);
-            break;
-        case '*' :
-            status = dynType_parseTypedPointer(stream, type);
-            break;
-        case 't' :
-            status = dynType_parseText(stream, type);
-            break;
-        case '#' :
-            status = dynType_parseMetaInfo(stream, type);
-            if (status == OK) {
-                status = dynType_parseAny(stream, type);
-            }
-            break;
-        default :
-            status = dynType_parseSimple(c, type);
-            break;
-    }
-
-    return status;
-}
-
-static int dynType_parseMetaInfo(FILE *stream, dyn_type *type) {
-    int status = OK;
-    char *name = NULL;
-    char *value = NULL;
-
-    struct meta_entry *entry = calloc(1, sizeof(*entry));
-    if (entry == NULL) {
-        status = ERROR;
-    }
-
-    if (status == OK) {
-        status = dynCommon_parseName(stream, &name);
-    }
-
-    if (status == OK) {
-        status = dynCommon_eatChar(stream, '=');
-    }
-
-    if (status == OK) {
-        status = dynCommon_parseName(stream, &value);
-    }
-
-    if (status == OK) {
-        status = dynCommon_eatChar(stream, ';');
-    }
-
-    if (status == OK) {
-        entry->name = name;
-        entry->value = value;
-        TAILQ_INSERT_TAIL(&type->metaProperties, entry, entries);
-        LOG_DEBUG("Added meta properties '%s':'%s'", name, value)
-    } else {
-        free(name);
-        free(value);
-        free(entry);
-    }
-
-    return status;
-}
-
-static int dynType_parseText(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_TEXT;
-    type->descriptor = 't';
-    type->ffiType = &ffi_type_pointer;
-    return status;
-}
-
-static int dynType_parseComplex(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_COMPLEX;
-    type->descriptor = '{';
-    type->ffiType = &type->complex.structType;
-    TAILQ_INIT(&type->complex.entriesHead);
-
-    int c = fgetc(stream);
-    struct complex_type_entry *entry = NULL;
-    while (c != ' ' && c != '}') {
-        ungetc(c,stream);
-        entry = calloc(1, sizeof(*entry));
-        if (entry != NULL) {
-            entry->type = calloc(1, sizeof(*entry->type));
-        }
-        if (entry != NULL && entry->type != NULL) {
-            entry->type->parent = type;
-            entry->type->type = DYN_TYPE_INVALID;
-            TAILQ_INIT(&entry->type->nestedTypesHead);
-            TAILQ_INIT(&entry->type->metaProperties);
-            TAILQ_INSERT_TAIL(&type->complex.entriesHead, entry, entries);
-            status = dynType_parseAny(stream, entry->type);
-        } else {
-            free(entry);
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for type");
-        }
-
-        if (status != OK) {
-            break;
-        }
-
-        c = fgetc(stream);
-    }
-
-
-    if (status == OK) {
-        entry = TAILQ_FIRST(&type->complex.entriesHead);
-        char *name = NULL;
-        while (c == ' ' && entry != NULL) {
-            status = dynCommon_parseName(stream, &name);
-            if (status == OK) {
-                entry->name = name;
-                entry = TAILQ_NEXT(entry, entries);
-            } else {
-                break;
-            }
-            c = getc(stream); 
-        }
-    }
-
-    int count = 0;
-    if (status == OK) {
-        TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-            count +=1;
-        }
-    }
-
-    if (status == OK) {
-        type->complex.structType.type =  FFI_TYPE_STRUCT;
-        type->complex.structType.elements = calloc(count + 1, sizeof(ffi_type*));
-        if (type->complex.structType.elements != NULL) {
-            type->complex.structType.elements[count] = NULL;
-            int index = 0;
-            TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-                type->complex.structType.elements[index++] = dynType_ffiType(entry->type);
-            }
-        } else {
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for elements")
-        }
-    }
-
-    if (status == OK) {
-        type->complex.types = calloc(count, sizeof(dyn_type *));
-        if (type->complex.types != NULL) {
-            int index = 0;
-            TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-                type->complex.types[index++] = entry->type;
-            }
-        } else {
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for type")
-        }
-    }
-
-    if (status == OK) {
-        dynType_prepCif(type->ffiType);
-    }
-
-
-    return status;
-}
-
-static int dynType_parseNestedType(FILE *stream, dyn_type *type) {
-    int status = OK;
-    char *name = NULL;
-    struct type_entry *entry = NULL;
-
-    entry = dynType_allocTypeEntry();
-    if (entry != NULL) {
-        entry->type->parent = type;
-        entry->type->type = DYN_TYPE_INVALID;
-        TAILQ_INIT(&entry->type->nestedTypesHead);
-        TAILQ_INIT(&entry->type->metaProperties);
-        TAILQ_INSERT_TAIL(&type->nestedTypesHead, entry, entries);
-        status = dynCommon_parseName(stream, &name);
-        entry->type->name = name;
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error allocating entry");
-    }     
-
-    if (status == OK) {
-        int c = fgetc(stream);
-        if (c != '=') {
-            status = PARSE_ERROR;
-            LOG_ERROR("Error parsing nested type expected '=' got '%c'", c);
-        }
-    }
-
-    if (status == OK) {
-        status = dynType_parseAny(stream, entry->type);
-        int c = fgetc(stream);
-        if (c != ';') {
-            status = PARSE_ERROR;
-            LOG_ERROR("Expected ';' got '%c'\n", c);
-        }
-    }
-
-    return status;
-}
-
-static int dynType_parseReference(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_TYPED_POINTER;
-    type->descriptor = '*';
-
-    type->ffiType = &ffi_type_pointer;
-    type->typedPointer.typedType =  NULL;
-
-    dyn_type *subType = calloc(1, sizeof(*subType));
-
-    if (subType != NULL) {
-        type->typedPointer.typedType = subType;
-        subType->parent = type;
-        subType->type = DYN_TYPE_INVALID;
-        TAILQ_INIT(&subType->nestedTypesHead);
-        TAILQ_INIT(&subType->metaProperties);
-        status = dynType_parseRefByValue(stream, subType);
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error allocating memory for subtype\n");
-    }
-
-    return status;
-}
-
-static int dynType_parseRefByValue(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_REF;
-    type->descriptor = 'l';
-
-    char *name = NULL;
-    status = dynCommon_parseName(stream, &name);
-    if (status == OK) {
-        dyn_type *ref = dynType_findType(type, name);
-        if (ref != NULL) {
-            type->ref.ref = ref;
-        } else {
-            status = PARSE_ERROR;
-            LOG_ERROR("Error cannot find type '%s'", name);
-        }
-        free(name);
-    } 
-
-    if (status ==OK) {
-        int c = fgetc(stream);
-        if (c != ';') {
-            status = PARSE_ERROR;
-            LOG_ERROR("Error expected ';' got '%c'", c);
-        } 
-    }
-
-    return status;
-}
-
-static struct type_entry *dynType_allocTypeEntry(void) {
-    struct type_entry *entry = calloc(1, sizeof(*entry));
-    if (entry != NULL) {
-        entry->type = calloc(1, sizeof(*entry->type));
-        if (entry->type == NULL) {
-            free(entry);
-            entry = NULL;
-        }
-    }
-    return entry;
-}
-
-static ffi_type *seq_types[] = {&ffi_type_uint32, &ffi_type_uint32, &ffi_type_pointer, NULL};
-
-static int dynType_parseSequence(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_SEQUENCE;
-    type->descriptor = '[';
-
-    type->sequence.seqType.elements = seq_types;
-    type->sequence.seqType.type = FFI_TYPE_STRUCT;
-    type->sequence.seqType.size = 0;
-    type->sequence.seqType.alignment = 0;
-
-    status = dynType_parseWithStream(stream, NULL, type, NULL, &type->sequence.itemType);
-
-    if (status == OK) {
-        type->ffiType = &type->sequence.seqType;
-        dynType_prepCif(&type->sequence.seqType);
-    }
-
-    return status;
-}
-
-static int dynType_parseSimple(int c, dyn_type *type) {
-    int status = OK;
-    ffi_type *ffiType = dynType_ffiTypeFor(c);
-    if (ffiType != NULL) {
-        type->type = DYN_TYPE_SIMPLE;
-        type->descriptor = c;
-        type->ffiType = ffiType;
-    } else {
-        status = PARSE_ERROR;
-        LOG_ERROR("Error unsupported type '%c'", c);
-    }
-
-    return status;
-}
-
-static int dynType_parseTypedPointer(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_TYPED_POINTER;
-    type->descriptor = '*';
-    type->ffiType = &ffi_type_pointer;
-
-    status = dynType_parseWithStream(stream, NULL, type, NULL, &type->typedPointer.typedType);
-
-    return status;
-}
-
-static void dynType_prepCif(ffi_type *type) {
-    ffi_cif cif;
-    ffi_type *args[1];
-    args[0] = type;
-    ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint, args);
-}
-
-void dynType_destroy(dyn_type *type) {
-    if (type != NULL) {          
-        dynType_clear(type);
-        free(type);
-    }
-}
-
-static void dynType_clear(dyn_type *type) {
-    struct type_entry *entry = TAILQ_FIRST(&type->nestedTypesHead);
-    struct type_entry *tmp = NULL;
-    while (entry != NULL) {
-        tmp = entry;
-        entry = TAILQ_NEXT(entry, entries);
-        if (tmp->type != NULL) {
-            dynType_destroy(tmp->type);
-            tmp->type = NULL;
-        }
-        free(tmp);
-    }
-
-    struct meta_entry *mEntry = TAILQ_FIRST(&type->metaProperties);;
-    struct meta_entry *next = NULL;
-    while (mEntry != NULL) {
-        next = TAILQ_NEXT(mEntry, entries);
-        if (mEntry != NULL) {
-            free(mEntry->name);
-            free(mEntry->value);
-            free(mEntry);
-        }
-        mEntry = next;
-    }
-
-    switch (type->type) {
-        case DYN_TYPE_COMPLEX :
-            dynType_clearComplex(type);
-            break;
-        case DYN_TYPE_SEQUENCE :
-            dynType_clearSequence(type);
-            break;
-        case DYN_TYPE_TYPED_POINTER :
-            dynType_clearTypedPointer(type);
-            break;
-    } 
-
-    if (type->name != NULL) {
-        free(type->name);
-    }
-}
-
-static void dynType_clearComplex(dyn_type *type) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    struct complex_type_entry *entry = TAILQ_FIRST(&type->complex.entriesHead);
-    struct complex_type_entry *tmp = NULL;
-    while (entry != NULL) {
-        dynType_destroy(entry->type);
-        if (entry->name != NULL) {
-            free(entry->name);
-        }
-        tmp = entry;
-        entry = TAILQ_NEXT(entry, entries);
-        free(tmp);
-    }
-    if (type->complex.types != NULL) {
-        free(type->complex.types);
-    }
-    if (type->complex.structType.elements != NULL) {
-        free(type->complex.structType.elements);
-    }
-}
-
-static void dynType_clearSequence(dyn_type *type) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    if (type->sequence.itemType != NULL) {
-        dynType_destroy(type->sequence.itemType);
-    }
-}
-
-static void dynType_clearTypedPointer(dyn_type *type) {
-    assert(type->type == DYN_TYPE_TYPED_POINTER);
-    if (type->typedPointer.typedType != NULL) {
-        dynType_destroy(type->typedPointer.typedType);
-    }
-}
-
-int dynType_alloc(dyn_type *type, void **bufLoc) {
-    assert(type->type != DYN_TYPE_REF);
-    assert(type->ffiType->size != 0);
-    int status = OK;
-
-    void *inst = calloc(1, type->ffiType->size);
-    if (inst != NULL) {
-        if (type->type == DYN_TYPE_TYPED_POINTER) {
-            void *ptr = NULL;
-            dyn_type *sub = NULL;
-            status = dynType_typedPointer_getTypedType(type, &sub);
-            if (status == OK) {
-                status = dynType_alloc(sub, &ptr);
-                if (status == OK) {
-                    *(void **)inst = ptr;
-                }
-            }
-        }
-        *bufLoc = inst;
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error allocating memory for type '%c'", type->descriptor);
-    }
-
-    return status;
-}
-
-
-int dynType_complex_indexForName(dyn_type *type, const char *name) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    int i = 0;
-    int index = -1;
-    struct complex_type_entry *entry = NULL;
-    TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-        if (strcmp(name, entry->name) == 0) {
-            index = i;
-        }
-        i +=1;
-    }
-    return index;
-}
-
-int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **result) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    assert(index >= 0);
-    dyn_type *sub = type->complex.types[index];
-    if (sub->type == DYN_TYPE_REF) {
-        sub = sub->ref.ref;
-    }
-    *result = sub;
-    return 0;
-}
-
-int dynType_complex_setValueAt(dyn_type *type, int index, void *start, void *in) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    char *loc = ((char *)start) + dynType_getOffset(type, index);
-    size_t size = type->complex.structType.elements[index]->size;
-    memcpy(loc, in, size);
-    return 0;
-}
-
-int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **result) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    char *l = (char *)inst;
-    void *loc = (void *)(l + dynType_getOffset(type, index));
-    *result = loc;
-    return OK;
-}
-
-int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    int status = OK;
-    *entries = &type->complex.entriesHead;
-    return status;
-}
-
-//sequence
-int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    int status = OK;
-    struct generic_sequence *seq = inst;
-    if (seq != NULL) {
-        size_t size = dynType_size(type->sequence.itemType);
-        seq->buf = calloc(cap, size);
-        if (seq->buf != NULL) {
-            seq->cap = cap;
-            seq->len = 0;;
-        } else {
-            seq->cap = 0;
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for buf")
-        }
-    } else {
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for seq")
-    }
-    return status;
-}
-
-void dynType_free(dyn_type *type, void *loc) {
-    dynType_deepFree(type, loc, true);
-}
-
-void dynType_deepFree(dyn_type *type, void *loc, bool alsoDeleteSelf) {
-    if (loc != NULL) {
-        dyn_type *subType = NULL;
-        char *text = NULL;
-        switch (type->type) {
-            case DYN_TYPE_COMPLEX :
-                dynType_freeComplexType(type, loc);
-                break;
-            case DYN_TYPE_SEQUENCE :
-                dynType_freeSequenceType(type, loc);
-                break;
-            case DYN_TYPE_TYPED_POINTER:
-                dynType_typedPointer_getTypedType(type, &subType);
-                dynType_deepFree(subType, *(void **)loc, true);
-                break;
-            case DYN_TYPE_TEXT :
-                text = *(char **)loc;
-                free(text);
-                break;
-        }
-
-        if (alsoDeleteSelf) {
-            free(loc);
-        }
-    }
-}
-
-void dynType_freeSequenceType(dyn_type *type, void *seqLoc) {
-    struct generic_sequence *seq = seqLoc;
-    dyn_type *itemType = dynType_sequence_itemType(type);
-    void *itemLoc = NULL;
-    int i;
-    for (i = 0; i < seq->len; i += 1) {
-        dynType_sequence_locForIndex(type, seqLoc, i, &itemLoc);
-        dynType_deepFree(itemType, itemLoc, false);
-    }
-    free(seq->buf);
-}
-
-void dynType_freeComplexType(dyn_type *type, void *loc) {
-    struct complex_type_entry *entry = NULL;
-    int index = 0;
-    void *entryLoc = NULL;
-    TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-        dynType_complex_valLocAt(type, index++, loc, &entryLoc);
-        dynType_deepFree(entry->type, entryLoc, false);
-    }
-}
-
-
-uint32_t dynType_sequence_length(void *seqLoc) {
-    struct generic_sequence *seq = seqLoc;
-    return seq->len;
-}
-
-int dynType_sequence_locForIndex(dyn_type *type, void *seqLoc, int index, void **out) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    int status = OK;
-
-    struct generic_sequence *seq = seqLoc;
-    char *valLoc = seq->buf;
-
-    size_t itemSize = dynType_size(type->sequence.itemType);
-
-    if (index >= seq->cap) {
-        status = ERROR;
-        LOG_ERROR("Requested index (%i) is greater than capacity (%u) of sequence", index, seq->cap);
-    }
-
-    if (index >= seq->len) {
-        LOG_WARNING("Requesting index (%i) outsize defined length (%u) but within capacity", index, seq->len);
-    }
-
-    if (status == OK) { }
-    int i;
-    for (i = 0; i < seq->cap; i += 1) {
-        if (index == i) {
-            break;
-        } else {
-            valLoc += itemSize;
-        }
-    }
-
-    (*out) = valLoc;
-
-    return status;
-}
-
-int dynType_sequence_increaseLengthAndReturnLastLoc(dyn_type *type, void *seqLoc, void **valLoc) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    int status = OK;
-    struct generic_sequence *seq = seqLoc;
-
-    int lastIndex = seq->len;
-    if (seq->len < seq->cap) {
-        seq->len += 1;
-    } else {
-        status = ERROR;
-        LOG_ERROR("Cannot increase sequence length beyond capacity (%u)", seq->cap);
-    }
-
-    if (status == OK) {
-        status = dynType_sequence_locForIndex(type, seqLoc, lastIndex, valLoc);
-    }
-
-    return status;
-}
-
-dyn_type * dynType_sequence_itemType(dyn_type *type) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    dyn_type *itemType = type->sequence.itemType;
-    if (itemType->type == DYN_TYPE_REF) {
-        itemType = itemType->ref.ref;
-    }
-    return itemType;
-}
-
-void dynType_simple_setValue(dyn_type *type, void *inst, void *in) {
-    size_t size = dynType_size(type);
-    memcpy(inst, in, size);
-}
-
-
-int dynType_descriptorType(dyn_type *type) {
-    return type->descriptor;
-}
-
-const char * dynType_getMetaInfo(dyn_type *type, const char *name) {
-    const char *result = NULL;
-    struct meta_entry *entry = NULL;
-    TAILQ_FOREACH(entry, &type->metaProperties, entries) {
-        LOG_DEBUG("Checking '%s'", entry->name);
-        if (strcmp(entry->name, name) == 0) {
-            result = entry->value;
-            break;
-        }
-    }
-    return result;
-}
-
-ffi_type *dynType_ffiType(dyn_type *type) {
-    if (type->type == DYN_TYPE_REF) {
-        if (type->ref.ref == NULL) {
-            LOG_ERROR("Error. Ref for %s is not (yet) initialized", type->name);
-            return NULL;
-        }
-        return type->ref.ref->ffiType;
-    }
-    return type->ffiType;
-}
-
-static ffi_type * dynType_ffiTypeFor(int c) {
-    ffi_type *type = NULL;
-    switch (c) {
-        case 'Z' :
-            type = &ffi_type_uint8;
-            break;
-        case 'F' :
-            type = &ffi_type_float;
-            break;
-        case 'D' :
-            type = &ffi_type_double;
-            break;
-        case 'B' :
-            type = &ffi_type_sint8;
-            break;
-        case 'b' :
-            type = &ffi_type_uint8;
-            break;
-        case 'S' :
-            type = &ffi_type_sint16;
-            break;
-        case 's' :
-            type = &ffi_type_uint16;
-            break;
-        case 'I' :
-            type = &ffi_type_sint32;
-            break;
-        case 'i' :
-            type = &ffi_type_uint32;
-            break;
-        case 'J' :
-            type = &ffi_type_sint64;
-            break;
-        case 'j' :
-            type = &ffi_type_sint64;
-            break;
-        case 'N' :
-            type = &ffi_type_sint;
-            break;
-        case 'P' :
-            type = &ffi_type_pointer;
-            break;
-        case 'V' :
-            type = &ffi_type_void;
-            break;
-    }
-    return type;
-}
-
-static dyn_type * dynType_findType(dyn_type *type, char *name) {
-    dyn_type *result = NULL;
-
-    struct type_entry *entry = NULL;
-    if (type->referenceTypes != NULL) {
-        TAILQ_FOREACH(entry, type->referenceTypes, entries) {
-            LOG_DEBUG("checking ref type '%s' with name '%s'", entry->type->name, name);
-            if (strcmp(name, entry->type->name) == 0) {
-                result = entry->type;
-                break;
-            }
-        }
-    }
-
-    if (result == NULL) {
-        struct type_entry *nEntry = NULL;
-        TAILQ_FOREACH(nEntry, &type->nestedTypesHead, entries) {
-            LOG_DEBUG("checking nested type '%s' with name '%s'", nEntry->type->name, name);
-            if (strcmp(name, nEntry->type->name) == 0) {
-                result = nEntry->type;
-                break;
-            }
-        }
-    }
-
-    if (result == NULL && type->parent != NULL) {
-        result = dynType_findType(type->parent, name);
-    }
-
-    return result;
-}
-
-static unsigned short dynType_getOffset(dyn_type *type, int index) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    unsigned short offset = 0;
-
-    ffi_type *ffiType = &type->complex.structType;
-    int i;
-    for (i = 0;  i <= index && ffiType->elements[i] != NULL; i += 1) {
-        size_t size = ffiType->elements[i]->size;
-        unsigned short alignment = ffiType->elements[i]->alignment;
-        int alignment_diff = offset % alignment;
-        if (alignment_diff > 0) {
-            offset += (alignment - alignment_diff);
-        }
-        if (i < index) {
-            offset += size;
-        }
-    }
-
-    return offset;
-}
-
-size_t dynType_size(dyn_type *type) {
-    dyn_type *rType = type;
-    if (type->type == DYN_TYPE_REF) {
-        rType = type->ref.ref;
-    }
-    return rType->ffiType->size;
-}
-
-int dynType_type(dyn_type *type) {
-    return type->type;
-}
-
-
-int dynType_typedPointer_getTypedType(dyn_type *type, dyn_type **out) {
-    assert(type->type == DYN_TYPE_TYPED_POINTER);
-    int status = 0;
-
-    dyn_type *typedType = type->typedPointer.typedType;
-    if (typedType->type == DYN_TYPE_REF) {
-        typedType = typedType->ref.ref;
-    }
-
-    *out = typedType;
-    return status;
-}
-
-
-int dynType_text_allocAndInit(dyn_type *type, void *textLoc, const char *value) {
-    assert(type->type == DYN_TYPE_TEXT);
-    int status = 0;
-    const char *str = strdup(value);
-    char const **loc = textLoc;
-    if (str != NULL) {
-        *loc = str;
-    } else {
-        status = ERROR;
-        LOG_ERROR("Cannot allocate memory for string");
-    }
-    return status;
-}
-
-
-
-
-
-void dynType_print(dyn_type *type, FILE *stream) {
-    if (type != NULL) {
-        dynType_printTypes(type, stream);
-
-        fprintf(stream, "main type:\n");
-        dynType_printAny("root", type, 0, stream);
-    } else {
-        fprintf(stream, "invalid type\n");
-    }
-}
-
-static void dynType_printDepth(int depth, FILE *stream) {
-    int i;
-    for (i = 0; i < depth; i +=1 ) {
-        fprintf(stream, "\t");
-    }
-}
-
-static void dynType_printAny(char *name, dyn_type *type, int depth, FILE *stream) {
-    dyn_type *toPrint = type;
-    if (toPrint->type == DYN_TYPE_REF) {
-        toPrint = toPrint->ref.ref;
-    }
-    switch(toPrint->type) {
-        case DYN_TYPE_COMPLEX :
-            dynType_printComplex(name, toPrint, depth, stream);
-            break;
-        case DYN_TYPE_SIMPLE :
-            dynType_printSimple(name, toPrint, depth, stream);
-            break;
-        case DYN_TYPE_SEQUENCE :
-            dynType_printSequence(name, toPrint, depth, stream);
-            break;
-        case DYN_TYPE_TYPED_POINTER :
-            dynType_printTypedPointer(name, toPrint, depth, stream);
-            break;
-        default :
-            fprintf(stream, "TODO Unsupported type %i\n", toPrint->type);
-            break;
-    }
-}
-
-static void dynType_printComplex(char *name, dyn_type *type, int depth, FILE *stream) {
-    if (type->name == NULL) {
-        dynType_printDepth(depth, stream);
-        fprintf(stream, "%s: complex type (anon), size is %zu, alignment is %i, descriptor is '%c'. fields:\n", name,  type->ffiType->size, type->ffiType->alignment, type->descriptor);
-
-        struct complex_type_entry *entry = NULL;
-        TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-            dynType_printAny(entry->name, entry->type, depth + 1, stream);
-        }
-
-        dynType_printDepth(depth, stream);
-        fprintf(stream, "}\n");
-    } else {
-        dynType_printDepth(depth, stream);
-        fprintf(stream, "%s: complex type ('%s'), size is %zu, alignment is %i, descriptor is '%c'.\n", name, type->name, type->ffiType->size, type->ffiType->alignment, type->descriptor);
-    }
-}
-
-static void dynType_printSequence(char *name, dyn_type *type, int depth, FILE *stream) {
-    dynType_printDepth(depth, stream);
-    fprintf(stream, "sequence, size is %zu, alignment is %i, descriptor is '%c'. fields:\n", type->ffiType->size, type->ffiType->alignment, type->descriptor);
-
-    dynType_printDepth(depth + 1, stream);
-    fprintf(stream, "cap: simple type, size is %zu, alignment is %i.\n", type->sequence.seqType.elements[0]->size, type->sequence.seqType.elements[0]->alignment);
-
-    dynType_printDepth(depth + 1, stream);
-    fprintf(stream, "len: simple type, size is %zu, alignment is %i.\n", type->sequence.seqType.elements[1]->size, type->sequence.seqType.elements[1]->alignment);
-
-    dynType_printDepth(depth + 1, stream);
-    fprintf(stream, "buf: array, size is %zu, alignment is %i. points to ->\n", type->sequence.seqType.elements[2]->size, type->sequence.seqType.elements[2]->alignment);
-    dynType_printAny("element", type->sequence.itemType, depth + 1, stream);
-}
-
-static void dynType_printSimple(char *name, dyn_type *type, int depth, FILE *stream) {
-    dynType_printDepth(depth, stream);
-    fprintf(stream, "%s: simple type, size is %zu, alignment is %i, descriptor is '%c'.\n", name, type->ffiType->size, type->ffiType->alignment, type->descriptor);
-}
-
-static void dynType_printTypedPointer(char *name, dyn_type *type, int depth, FILE *stream) {
-    dynType_printDepth(depth, stream);
-    fprintf(stream, "%s: typed pointer, size is %zu, alignment is %i, points to ->\n", name, type->ffiType->size, type->ffiType->alignment);
-    char *subName = NULL;
-    char buf[128];
-    memset(buf,0,128);
-    if (name != NULL) {
-        snprintf(buf, 128, "*%s", name);
-        subName = buf;
-    }
-    dynType_printAny(subName, type->typedPointer.typedType, depth + 1, stream);
-}
-
-static void dynType_printTypes(dyn_type *type, FILE *stream) {
-
-    dyn_type *parent = type->parent;
-    struct type_entry *pentry = NULL;
-    while (parent != NULL) {
-        TAILQ_FOREACH(pentry, &parent->nestedTypesHead, entries) {
-            if (pentry->type == type) {
-                return;
-            }
-        }
-        parent = parent->parent;
-    }
-
-    struct type_entry *entry = NULL;
-    TAILQ_FOREACH(entry, &type->nestedTypesHead, entries) {
-        dyn_type *toPrint = entry->type;
-        if (toPrint->type == DYN_TYPE_REF) {
-            toPrint = toPrint->ref.ref;
-        }
-
-        switch(toPrint->type) {
-            case DYN_TYPE_COMPLEX :
-                dynType_printComplexType(toPrint, stream);
-                break;
-            case DYN_TYPE_SIMPLE :
-                dynType_printSimpleType(toPrint, stream);
-                break;
-            default :
-                printf("TODO Print Type\n");
-                break;
-        }
-    }
-
-
-    struct complex_type_entry *centry = NULL;
-    switch(type->type) {
-        case DYN_TYPE_COMPLEX :
-            TAILQ_FOREACH(centry, &type->complex.entriesHead, entries) {
-                dynType_printTypes(centry->type, stream);
-            }
-            break;
-        case DYN_TYPE_SEQUENCE :
-            dynType_printTypes(type->sequence.itemType, stream);
-            break;
-        case DYN_TYPE_TYPED_POINTER :
-            dynType_printTypes(type->typedPointer.typedType, stream);
-            break;
-    }
-}
-
-static void dynType_printComplexType(dyn_type *type, FILE *stream) {
-    fprintf(stream, "type '%s': complex type, size is %zu, alignment is %i, descriptor is '%c'. fields:\n", type->name,  type->ffiType->size, type->ffiType->alignment, type->descriptor);
-
-    struct complex_type_entry *entry = NULL;
-    TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-        dynType_printAny(entry->name, entry->type, 2, stream);
-    }
-
-    fprintf(stream, "}\n");
-}
-
-static void dynType_printSimpleType(dyn_type *type, FILE *stream) {
-    fprintf(stream, "\ttype '%s': simple type, size is %zu, alignment is %i, descriptor is '%c'\n", type->name, type->ffiType->size, type->ffiType->alignment, type->descriptor);
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/json_rpc.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/json_rpc.c b/dfi/private/src/json_rpc.c
deleted file mode 100644
index f2b0c56..0000000
--- a/dfi/private/src/json_rpc.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/**
- *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.
- */
-#include "json_rpc.h"
-#include "json_serializer.h"
-#include "dyn_type.h"
-#include "dyn_interface.h"
-#include <jansson.h>
-#include <assert.h>
-#include <stdint.h>
-#include <string.h>
-#include <ffi.h>
-
-
-static int OK = 0;
-static int ERROR = 1;
-
-DFI_SETUP_LOG(jsonRpc);
-
-typedef void (*gen_func_type)(void);
-
-struct generic_service_layout {
-	void *handle;
-	gen_func_type methods[];
-};
-
-int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, char **out) {
-	int status = OK;
-
-	dyn_type* returnType = NULL;
-
-	LOG_DEBUG("Parsing data: %s\n", request);
-	json_error_t error;
-	json_t *js_request = json_loads(request, 0, &error);
-	json_t *arguments = NULL;
-	const char *sig;
-	if (js_request) {
-		if (json_unpack(js_request, "{s:s}", "m", &sig) != 0) {
-			LOG_ERROR("Got json error '%s'\n", error.text);
-		} else {
-			arguments = json_object_get(js_request, "a");
-		}
-	} else {
-		LOG_ERROR("Got json error '%s' for '%s'\n", error.text, request);
-		return 0;
-	}
-
-	LOG_DEBUG("Looking for method %s\n", sig);
-	struct methods_head *methods = NULL;
-	dynInterface_methods(intf, &methods);
-	struct method_entry *entry = NULL;
-	struct method_entry *method = NULL;
-	TAILQ_FOREACH(entry, methods, entries) {
-		if (strcmp(sig, entry->id) == 0) {
-			method = entry;
-			break;
-		}
-	}
-
-	if (method == NULL) {
-		status = ERROR;
-		LOG_ERROR("Cannot find method with sig '%s'", sig);
-	}
-	else if (status == OK) {
-		LOG_DEBUG("RSA: found method '%s'\n", entry->id);
-		returnType = dynFunction_returnType(method->dynFunc);
-	}
-
-	void (*fp)(void) = NULL;
-	void *handle = NULL;
-	if (status == OK) {
-		struct generic_service_layout *serv = service;
-		handle = serv->handle;
-		fp = serv->methods[method->index];
-	}
-
-	dyn_function_type *func = NULL;
-	int nrOfArgs = 0;
-	if (status == OK) {
-		nrOfArgs = dynFunction_nrOfArguments(entry->dynFunc);
-		func = entry->dynFunc;
-	}
-
-	void *args[nrOfArgs];
-
-	json_t *value = NULL;
-
-	int i;
-	int index = 0;
-
-	void *ptr = NULL;
-	void *ptrToPtr = &ptr;
-
-	for (i = 0; i < nrOfArgs; i += 1) {
-		dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
-			value = json_array_get(arguments, index++);
-			status = jsonSerializer_deserializeJson(argType, value, &(args[i]));
-		} else if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
-			dynType_alloc(argType, &args[i]);
-		} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-			args[i] = &ptrToPtr;
-		} else if (meta == DYN_FUNCTION_ARGUMENT_META__HANDLE) {
-			args[i] = &handle;
-		}
-
-		if (status != OK) {
-			break;
-		}
-	}
-	json_decref(js_request);
-
-	if (status == OK) {
-		if (dynType_descriptorType(returnType) != 'N') {
-			//NOTE To be able to handle exception only N as returnType is supported
-			LOG_ERROR("Only interface methods with a native int are supported. Found type '%c'", (char)dynType_descriptorType(returnType));
-			status = ERROR;
-		}
-	}
-
-	ffi_sarg returnVal = 1;
-
-	if (status == OK) {
-		status = dynFunction_call(func, fp, (void *) &returnVal, args);
-	}
-
-	int funcCallStatus = (int)returnVal;
-	if (funcCallStatus != 0) {
-		LOG_WARNING("Error calling remote endpoint function, got error code %i", funcCallStatus);
-	}
-
-	json_t *jsonResult = NULL;
-	for(i = 0; i < nrOfArgs; i += 1) {
-		dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
-			dynType_free(argType, args[i]);
-		}
-	}
-
-	if (funcCallStatus == 0 && status == OK) {
-		for (i = 0; i < nrOfArgs; i += 1) {
-			dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-			enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-			if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
-				if (status == OK) {
-					status = jsonSerializer_serializeJson(argType, args[i], &jsonResult);
-				}
-				dynType_free(argType, args[i]);
-			} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-				if (ptr != NULL) {
-					dyn_type *typedType = NULL;
-					if (status == OK) {
-						status = dynType_typedPointer_getTypedType(argType, &typedType);
-					}
-					if (dynType_descriptorType(typedType) == 't') {
-						status = jsonSerializer_serializeJson(typedType, (void*) &ptr, &jsonResult);
-						free(ptr);
-					} else {
-						dyn_type *typedTypedType = NULL;
-						if (status == OK) {
-							status = dynType_typedPointer_getTypedType(typedType, &typedTypedType);
-						}
-
-						if(status == OK){
-							status = jsonSerializer_serializeJson(typedTypedType, ptr, &jsonResult);
-						}
-
-						if (status == OK) {
-							dynType_free(typedTypedType, ptr);
-						}
-					}
-
-				} else {
-					LOG_DEBUG("Output ptr is null");
-				}
-			}
-
-			if (status != OK) {
-				break;
-			}
-		}
-	}
-
-	char *response = NULL;
-	if (status == OK) {
-		LOG_DEBUG("creating payload\n");
-		json_t *payload = json_object();
-		if (funcCallStatus == 0) {
-			if (jsonResult == NULL) {
-				//ignore -> no result
-			} else {
-				LOG_DEBUG("Setting result payload");
-				json_object_set_new(payload, "r", jsonResult);
-			}
-		} else {
-			LOG_DEBUG("Setting error payload");
-			json_object_set_new(payload, "e", json_integer(funcCallStatus));
-		}
-		response = json_dumps(payload, JSON_DECODE_ANY);
-		json_decref(payload);
-		LOG_DEBUG("status ptr is %p. response is '%s'\n", status, response);
-	}
-
-	if (status == OK) {
-		*out = response;
-	} else {
-		free(response);
-	}
-
-	return status;
-}
-
-int jsonRpc_prepareInvokeRequest(dyn_function_type *func, const char *id, void *args[], char **out) {
-	int status = OK;
-
-
-	LOG_DEBUG("Calling remote function '%s'\n", id);
-	json_t *invoke = json_object();
-	json_object_set_new(invoke, "m", json_string(id));
-
-	json_t *arguments = json_array();
-	json_object_set_new(invoke, "a", arguments);
-
-	int i;
-	int nrOfArgs = dynFunction_nrOfArguments(func);
-	for (i = 0; i < nrOfArgs; i +=1) {
-		dyn_type *type = dynFunction_argumentTypeForIndex(func, i);
-		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
-			json_t *val = NULL;
-
-			int rc = jsonSerializer_serializeJson(type, args[i], &val);
-			if (rc == 0) {
-				json_array_append_new(arguments, val);
-			} else {
-				status = ERROR;
-				break;
-			}
-		} else {
-			//skip handle / output types
-		}
-	}
-
-	char *invokeStr = json_dumps(invoke, JSON_DECODE_ANY);
-	json_decref(invoke);
-
-	if (status == OK) {
-		*out = invokeStr;
-	}
-
-	return status;
-}
-
-int jsonRpc_handleReply(dyn_function_type *func, const char *reply, void *args[]) {
-	int status = OK;
-
-	json_error_t error;
-	json_t *replyJson = json_loads(reply, JSON_DECODE_ANY, &error);
-	if (replyJson == NULL) {
-		status = ERROR;
-		LOG_ERROR("Error parsing json '%s', got error '%s'", reply, error.text);
-	}
-
-	json_t *result = NULL;
-	if (status == OK) {
-		result = json_object_get(replyJson, "r"); //TODO check
-		if (result == NULL) {
-			status = ERROR;
-			LOG_ERROR("Cannot find r entry in json reply '%s'", reply);
-		}
-	}
-
-	if (status == OK) {
-		int nrOfArgs = dynFunction_nrOfArguments(func);
-		int i;
-		for (i = 0; i < nrOfArgs; i += 1) {
-			dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-			enum dyn_function_argument_meta meta = dynFunction_argumentMetaForIndex(func, i);
-			if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
-				void *tmp = NULL;
-				void **out = (void **) args[i];
-
-				size_t size = 0;
-
-				if (dynType_descriptorType(argType) == 't') {
-					status = jsonSerializer_deserializeJson(argType, result, &tmp);
-					if(tmp!=NULL){
-						size = strnlen(((char *) *(char**) tmp), 1024 * 1024);
-						memcpy(*out, *(void**) tmp, size);
-					}
-				} else {
-					dynType_typedPointer_getTypedType(argType, &argType);
-					status = jsonSerializer_deserializeJson(argType, result, &tmp);
-					if(tmp!=NULL){
-						size = dynType_size(argType);
-						memcpy(*out, tmp, size);
-					}
-				}
-
-				dynType_free(argType, tmp);
-			} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-				dyn_type *subType = NULL;
-
-				dynType_typedPointer_getTypedType(argType, &subType);
-
-				if (dynType_descriptorType(subType) == 't') {
-					void ***out = (void ***) args[i];
-					status = jsonSerializer_deserializeJson(subType, result, *out);
-				} else {
-					dyn_type *subSubType = NULL;
-					dynType_typedPointer_getTypedType(subType, &subSubType);
-					void ***out = (void ***) args[i];
-					status = jsonSerializer_deserializeJson(subSubType, result, *out);
-				}
-			} else {
-				//skip
-			}
-		}
-	}
-
-	json_decref(replyJson);
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/json_serializer.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/json_serializer.c b/dfi/private/src/json_serializer.c
deleted file mode 100644
index 4b78aeb..0000000
--- a/dfi/private/src/json_serializer.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/**
- *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.
- */
-#include "json_serializer.h"
-#include "dyn_type.h"
-#include "dyn_interface.h"
-
-#include <jansson.h>
-#include <assert.h>
-#include <stdint.h>
-#include <string.h>
-
-static int jsonSerializer_createType(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 || dynType_type(type) == DYN_TYPE_SEQUENCE);
-    int status = 0;
-
-    json_error_t error;
-    json_t *root = json_loads(input, JSON_DECODE_ANY, &error);
-
-    if (root != NULL) {
-        status = jsonSerializer_deserializeJson(type, root, result);
-        json_decref(root);
-    } else {
-        status = ERROR;
-        LOG_ERROR("Error parsing json input '%s'. Error is: %s\n", input, error.text);
-    }
-
-    if (status != OK) {
-        LOG_ERROR("Error cannot deserialize json. Input is '%s'\n", input);
-    }
-    return status;
-}
-
-int jsonSerializer_deserializeJson(dyn_type *type, json_t *input, void **out) {
-    return jsonSerializer_createType(type, input, out);
-}
-
-static int jsonSerializer_createType(dyn_type *type, json_t *val, void **result) {
-    assert(val != NULL);
-    int status = OK;
-    void *inst = NULL;
-
-    if (dynType_descriptorType(type) == 't') {
-        if (json_typeof(val) == JSON_STRING) {
-            inst = strdup(json_string_value(val));
-        } else {
-            status = ERROR;
-            LOG_ERROR("Expected json_string type got %i\n", json_typeof(val));
-        }
-    } else {
-        status = dynType_alloc(type, &inst);
-
-        if (status == OK) {
-            assert(inst != NULL);
-            status = jsonSerializer_parseAny(type, inst, val);
-        }
-    }
-
-    if (status == OK) {
-        *result = inst;
-    }
-    else{
-    	dynType_free(type, 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;
-    void *valp = NULL;
-    dyn_type *valType = NULL;
-
-    int index = dynType_complex_indexForName(type, name);
-    if (index < 0) {
-        LOG_ERROR("Cannot find index for member '%s'", name);
-        status = ERROR;
-    }
-
-    if (status == OK) {
-        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);
-
-    /*
-    printf("parseAny with descriptor '%c' :", c);
-    json_dumpf(val, stdout, 0); //TODO remove
-    printf("\n");
-     */
-
-    bool *z;            //Z
-    float *f;           //F
-    double *d;          //D
-    char *b;            //B
-    int *n;             //N
-    int16_t *s;         //S
-    int32_t *i;         //I
-    int64_t *l;         //J
-    uint8_t   *ub;      //b
-    uint16_t  *us;      //s
-    uint32_t  *ui;      //i
-    uint64_t  *ul;      //j
-
-    switch (c) {
-        case 'Z' :
-            z = loc;
-            *z = (bool) json_is_true(val);
-            break;
-        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_integer_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 'b' :
-            ub = loc;
-            *ub = (uint8_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_createType(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 for index %zu", valLoc, index);
-
-            if (status == OK) {
-                status = jsonSerializer_parseAny(itemType, valLoc, val);
-                if (status != OK) {
-                    break;
-                }
-            }
-        }
-    }
-
-    return status;
-}
-
-int jsonSerializer_serialize(dyn_type *type, const void* input, char **output) {
-    int status = OK;
-
-    json_t *root = NULL;
-    status = jsonSerializer_serializeJson(type, input, &root);
-
-    if (status == OK) {
-        *output = json_dumps(root, JSON_COMPACT);
-        json_decref(root);
-    }
-
-    return status;
-}
-
-int jsonSerializer_serializeJson(dyn_type *type, const void* input, json_t **out) {
-    return jsonSerializer_writeAny(type, (void*)input /*TODO update static function to take const void**/, out);
-}
-
-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;
-
-    bool *z;            //Z
-    float *f;           //F
-    double *d;          //D
-    char *b;            //B
-    int *n;             //N
-    int16_t *s;         //S
-    int32_t *i;         //I
-    int64_t *l;         //J
-    uint8_t   *ub;      //b
-    uint16_t  *us;      //s
-    uint32_t  *ui;      //i
-    uint64_t  *ul;      //j
-
-    switch (descriptor) {
-        case 'Z' :
-            z = input;
-            val = json_boolean((bool)*z);
-            break;
-        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 'b' :
-            ub = input;
-            val = json_integer((json_int_t)*ub);
-            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);
-            if (index < 0) {
-		LOG_ERROR("Cannot find index for member '%s'", entry->name);
-                status = ERROR;
-            }
-            if(status == OK){
-		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;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/avro_descriptor_translator_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/avro_descriptor_translator_tests.cpp b/dfi/private/test/avro_descriptor_translator_tests.cpp
deleted file mode 100644
index 5bab518..0000000
--- a/dfi/private/test/avro_descriptor_translator_tests.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- *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.
- */
-#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");
-        va_end(ap);
-    }
-
-
-    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/a1c30887/dfi/private/test/descriptors/example1.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/example1.descriptor b/dfi/private/test/descriptors/example1.descriptor
deleted file mode 100644
index 771dc5e..0000000
--- a/dfi/private/test/descriptors/example1.descriptor
+++ /dev/null
@@ -1,13 +0,0 @@
-: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(#am=handle;PDD#am=pre;*D)N
-sub(DD)D=sub(#am=handle;PDD*#am=pre;D)N
-sqrt(D)D=sqrt(#am=handle;PD*#am=pre;D)N
-stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/example2.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/example2.descriptor b/dfi/private/test/descriptors/example2.descriptor
deleted file mode 100644
index 38bf442..0000000
--- a/dfi/private/test/descriptors/example2.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=interface
-name=example
-version=1.0.0
-:annotations
-:types
-item={DD a b}
-:methods
-example1=items(#am=handle;P#am=out;**[Litem;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/example3.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/example3.descriptor b/dfi/private/test/descriptors/example3.descriptor
deleted file mode 100644
index c89d969..0000000
--- a/dfi/private/test/descriptors/example3.descriptor
+++ /dev/null
@@ -1,11 +0,0 @@
-:header
-type=interface
-name=detection_provider
-version=1.0.0
-:annotations
-:types
-location={DD lat lon}
-target={Jllocation;DDJ id location speed heading lastUpdated}
-detection={Jllocation;Dltarget; id center range simulated}
-:methods
-getDetections()Ljava/util/List;=getDetections(#am=handle;P#am=out;**[Ldetection;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/example4.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/example4.descriptor b/dfi/private/test/descriptors/example4.descriptor
deleted file mode 100644
index 4c959c4..0000000
--- a/dfi/private/test/descriptors/example4.descriptor
+++ /dev/null
@@ -1,8 +0,0 @@
-:header
-type=interface
-name=example4
-version=1.0.0
-:annotations
-:types
-:methods
-getName(V)t=getName(#am=handle;P#am=out;*t)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalid.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalid.descriptor b/dfi/private/test/descriptors/invalids/invalid.descriptor
deleted file mode 100644
index fead964..0000000
--- a/dfi/private/test/descriptors/invalids/invalid.descriptor
+++ /dev/null
@@ -1,13 +0,0 @@
-:header
-type=interface
-name=calculator X
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:types
-StatsResult={DDD[D average min max input}
-:methods
-add(DD)D=add(#am=handle;PDD#am=pre;*D)N
-sub(DD)D=sub(#am=handle;PDD*#am=pre;D)N
-sqrt(D)D=sqrt(#am=handle;PD*#am=pre;D)N
-stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMetaType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMetaType.descriptor b/dfi/private/test/descriptors/invalids/invalidMetaType.descriptor
deleted file mode 100644
index 2d17c47..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMetaType.descriptor
+++ /dev/null
@@ -1,8 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:methods
-add(DD)D=add(#am=invalid;PDD#am=pre;*D)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMethod.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMethod.descriptor b/dfi/private/test/descriptors/invalids/invalidMethod.descriptor
deleted file mode 100644
index eaef7b1..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMethod.descriptor
+++ /dev/null
@@ -1,8 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:methods
-add(DD)D=add(#am=handle;PDD#am=pre;*D)N X

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMethodReturnType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMethodReturnType.descriptor b/dfi/private/test/descriptors/invalids/invalidMethodReturnType.descriptor
deleted file mode 100644
index 26f75f8..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMethodReturnType.descriptor
+++ /dev/null
@@ -1,8 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:methods
-add(DD)D=add(#am=handle;PDD#am=pre;*D)D

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgHdr.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgHdr.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgHdr.descriptor
deleted file mode 100644
index ae9b131..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgHdr.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=message
-name=poi
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgInvalidName.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgInvalidName.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgInvalidName.descriptor
deleted file mode 100644
index 787dd4c..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgInvalidName.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=message
-name=poi X
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgInvalidSection.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgInvalidSection.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgInvalidSection.descriptor
deleted file mode 100644
index 02a593c..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgInvalidSection.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=poi
-version=1.0.0
-:invalid
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgInvalidType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgInvalidType.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgInvalidType.descriptor
deleted file mode 100644
index 5008311..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgInvalidType.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=message
-name=poi
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long} X
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor
deleted file mode 100644
index 6cffbdc..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=poi
-version=1.0.f
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgMissingVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgMissingVersion.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgMissingVersion.descriptor
deleted file mode 100644
index 1fd3595..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgMissingVersion.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:head
-type=message
-name=poi
-version=1.0.0
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidSection.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidSection.descriptor b/dfi/private/test/descriptors/invalids/invalidSection.descriptor
deleted file mode 100644
index b8a11a6..0000000
--- a/dfi/private/test/descriptors/invalids/invalidSection.descriptor
+++ /dev/null
@@ -1,6 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:invalidSection
-invalidKey=invalidValue
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidType.descriptor b/dfi/private/test/descriptors/invalids/invalidType.descriptor
deleted file mode 100644
index 7b7ce1c..0000000
--- a/dfi/private/test/descriptors/invalids/invalidType.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:types
-StatsResult={DDD[D average min max input} X
-:methods
-stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidVersion.descriptor b/dfi/private/test/descriptors/invalids/invalidVersion.descriptor
deleted file mode 100644
index bfe4d38..0000000
--- a/dfi/private/test/descriptors/invalids/invalidVersion.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=interface
-name=example
-version=q.0.0
-:annotations
-:types
-item={DD a b}
-:methods
-example1=items(#am=handle;P#am=out;**[Litem;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/noVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/noVersion.descriptor b/dfi/private/test/descriptors/invalids/noVersion.descriptor
deleted file mode 100644
index 731a9e6..0000000
--- a/dfi/private/test/descriptors/invalids/noVersion.descriptor
+++ /dev/null
@@ -1,12 +0,0 @@
-:header
-type=interface
-name=calculator
-:annotations
-classname=org.example.Calculator
-:types
-StatsResult={DDD[D average min max input}
-:methods
-add(DD)D=add(#am=handle;PDD#am=pre;*D)N
-sub(DD)D=sub(#am=handle;PDD*#am=pre;D)N
-sqrt(D)D=sqrt(#am=handle;PD*#am=pre;D)N
-stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/msg_example1.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/msg_example1.descriptor b/dfi/private/test/descriptors/msg_example1.descriptor
deleted file mode 100644
index 576523a..0000000
--- a/dfi/private/test/descriptors/msg_example1.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=poi
-version=1.0.0
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/msg_example2.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/msg_example2.descriptor b/dfi/private/test/descriptors/msg_example2.descriptor
deleted file mode 100644
index 128049d..0000000
--- a/dfi/private/test/descriptors/msg_example2.descriptor
+++ /dev/null
@@ -1,12 +0,0 @@
-:header
-type=message
-name=track
-version=0.0.1
-:annotations
-classname=org.example.Track
-:types
-timestamp={SSSSSSI day month year hour minute second microseconds}
-latlonpos={DD lat lon}
-polarpos={DDD azimuth elevation range}
-:message
-{Iltimestamp;llatlonpos;lpolarpos;SS trackid lastupdate abspos relpos classification identity}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/msg_example3.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/msg_example3.descriptor b/dfi/private/test/descriptors/msg_example3.descriptor
deleted file mode 100644
index 7b69380..0000000
--- a/dfi/private/test/descriptors/msg_example3.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=logEntry
-version=1.0.0
-:annotations
-classname=org.example.LogEntry
-:types
-timestamp={SSSSSSI day month year hour minute second microseconds}
-:message
-{ltimestamp;St timestamp severity eventdescription}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/msg_example4.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/msg_example4.descriptor b/dfi/private/test/descriptors/msg_example4.descriptor
deleted file mode 100644
index e99e443..0000000
--- a/dfi/private/test/descriptors/msg_example4.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=exmpl4
-version=1.1.0
-:annotations
-:types
-info={Jladditional_info; id info}
-additional_info={Jt; id descr}
-:message
-{Jlinfo; id info}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/dyn_closure_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_closure_tests.cpp b/dfi/private/test/dyn_closure_tests.cpp
deleted file mode 100644
index 9c1abe6..0000000
--- a/dfi/private/test/dyn_closure_tests.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- *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.
- */
-#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*, 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");
-    va_end(ap);
-}
-
-#define EXAMPLE1_DESCRIPTOR "example(III)I"
-static void example1_binding(void*, 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*, 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*, 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() {
-        int lvl = 1;
-        dynFunction_logSetup(stdLog, NULL, lvl);
-        dynType_logSetup(stdLog, NULL, lvl);
-        dynCommon_logSetup(stdLog, NULL, lvl);
-        g_count = 0;
-    }
-};
-
-TEST(DynClosureTests, DynCLosureTest1) {
-    //TODO split up
-    tests();
-}


[13/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_tracker.c
----------------------------------------------------------------------
diff --git a/framework/src/service_tracker.c b/framework/src/service_tracker.c
new file mode 100644
index 0000000..2631058
--- /dev/null
+++ b/framework/src/service_tracker.c
@@ -0,0 +1,449 @@
+/**
+ *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.
+ */
+/*
+ * service_tracker.c
+ *
+ *  \date       Apr 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <service_reference_private.h>
+#include <framework_private.h>
+#include <assert.h>
+
+#include "service_tracker_private.h"
+#include "bundle_context.h"
+#include "constants.h"
+#include "service_reference.h"
+#include "celix_log.h"
+
+static celix_status_t serviceTracker_invokeAddingService(service_tracker_pt tracker, service_reference_pt reference,
+                                                         void **service);
+static celix_status_t serviceTracker_track(service_tracker_pt tracker, service_reference_pt reference, service_event_pt event);
+static celix_status_t serviceTracker_untrack(service_tracker_pt tracker, service_reference_pt reference, service_event_pt event);
+static celix_status_t serviceTracker_invokeAddService(service_tracker_pt tracker, service_reference_pt ref, void *service);
+static celix_status_t serviceTracker_invokeModifiedService(service_tracker_pt tracker, service_reference_pt ref, void *service);
+
+static celix_status_t serviceTracker_invokeRemovingService(service_tracker_pt tracker, service_reference_pt ref,
+                                                           void *service);
+
+celix_status_t serviceTracker_create(bundle_context_pt context, const char * service, service_tracker_customizer_pt customizer, service_tracker_pt *tracker) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (service == NULL || *tracker != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		if (status == CELIX_SUCCESS) {
+			char filter[512];
+			snprintf(filter, sizeof(filter), "(%s=%s)", OSGI_FRAMEWORK_OBJECTCLASS, service);
+            serviceTracker_createWithFilter(context, filter, customizer, tracker);
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot create service tracker");
+
+	return status;
+}
+
+celix_status_t serviceTracker_createWithFilter(bundle_context_pt context, const char * filter, service_tracker_customizer_pt customizer, service_tracker_pt *tracker) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*tracker = (service_tracker_pt) malloc(sizeof(**tracker));
+	if (!*tracker) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*tracker)->context = context;
+		(*tracker)->filter = strdup(filter);
+
+		(*tracker)->tracker = *tracker;
+        celixThreadRwlock_create(&(*tracker)->lock, NULL);
+		(*tracker)->trackedServices = NULL;
+		arrayList_create(&(*tracker)->trackedServices);
+		(*tracker)->customizer = customizer;
+		(*tracker)->listener = NULL;
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot create service tracker [filter=%s]", filter);
+
+	return status;
+}
+
+celix_status_t serviceTracker_destroy(service_tracker_pt tracker) {
+	if (tracker->listener != NULL) {
+		bundleContext_removeServiceListener(tracker->context, tracker->listener);
+	}
+	if (tracker->customizer != NULL) {
+	    serviceTrackerCustomizer_destroy(tracker->customizer);
+	}
+
+    celixThreadRwlock_writeLock(&tracker->lock);
+	arrayList_destroy(tracker->trackedServices);
+    celixThreadRwlock_unlock(&tracker->lock);
+
+
+	if (tracker->listener != NULL) {
+		free (tracker->listener);
+	}
+
+    celixThreadRwlock_destroy(&tracker->lock);
+
+	free(tracker->filter);
+	free(tracker);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceTracker_open(service_tracker_pt tracker) {
+	service_listener_pt listener;
+	array_list_pt initial = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+	listener = (service_listener_pt) malloc(sizeof(*listener));
+	
+	status = bundleContext_getServiceReferences(tracker->context, NULL, tracker->filter, &initial); //REF COUNT to 1
+	if (status == CELIX_SUCCESS && listener != NULL) {
+		service_reference_pt initial_reference;
+		unsigned int i;
+
+		listener->handle = tracker;
+		listener->serviceChanged = (void *) serviceTracker_serviceChanged;
+		status = bundleContext_addServiceListener(tracker->context, listener, tracker->filter);
+		if (status == CELIX_SUCCESS) {
+			tracker->listener = listener;
+
+			for (i = 0; i < arrayList_size(initial); i++) {
+				initial_reference = (service_reference_pt) arrayList_get(initial, i);
+				serviceTracker_track(tracker, initial_reference, NULL); //REF COUNT to 2
+                bundleContext_ungetServiceReference(tracker->context, initial_reference); //REF COUNT to 1
+			}
+
+			arrayList_destroy(initial);
+
+			initial = NULL;
+		}
+	}
+
+	if(status != CELIX_SUCCESS && listener != NULL){
+		free(listener);
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot open tracker");
+
+	return status;
+}
+
+celix_status_t serviceTracker_close(service_tracker_pt tracker) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (status == CELIX_SUCCESS) {
+		array_list_pt refs = serviceTracker_getServiceReferences(tracker);
+		if (refs != NULL) {
+			unsigned int i;
+			for (i = 0; i < arrayList_size(refs); i++) {
+				service_reference_pt ref = (service_reference_pt) arrayList_get(refs, i);
+				status = serviceTracker_untrack(tracker, ref, NULL);
+			}
+		}
+		arrayList_destroy(refs);
+	}
+    if (status == CELIX_SUCCESS) {
+        status = bundleContext_removeServiceListener(tracker->context, tracker->listener);
+        if(status == CELIX_SUCCESS) {
+            free(tracker->listener);
+            tracker->listener = NULL;
+        }
+    }
+	framework_logIfError(logger, status, NULL, "Cannot close tracker");
+
+	return status;
+}
+
+service_reference_pt serviceTracker_getServiceReference(service_tracker_pt tracker) {
+	tracked_pt tracked;
+    service_reference_pt result = NULL;
+	unsigned int i;
+
+    celixThreadRwlock_readLock(&tracker->lock);
+	for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
+		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
+		result = tracked->reference;
+        break;
+	}
+    celixThreadRwlock_unlock(&tracker->lock);
+
+	return result;
+}
+
+array_list_pt serviceTracker_getServiceReferences(service_tracker_pt tracker) {
+	tracked_pt tracked;
+	unsigned int i;
+	array_list_pt references = NULL;
+	arrayList_create(&references);
+
+    celixThreadRwlock_readLock(&tracker->lock);
+	for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
+		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
+		arrayList_add(references, tracked->reference);
+	}
+    celixThreadRwlock_unlock(&tracker->lock);
+
+	return references;
+}
+
+void *serviceTracker_getService(service_tracker_pt tracker) {
+	tracked_pt tracked;
+    void *service = NULL;
+	unsigned int i;
+
+    celixThreadRwlock_readLock(&tracker->lock);
+    for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
+		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
+		service = tracked->service;
+        break;
+	}
+    celixThreadRwlock_unlock(&tracker->lock);
+
+    return service;
+}
+
+array_list_pt serviceTracker_getServices(service_tracker_pt tracker) {
+	tracked_pt tracked;
+	unsigned int i;
+	array_list_pt references = NULL;
+	arrayList_create(&references);
+
+    celixThreadRwlock_readLock(&tracker->lock);
+    for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
+		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
+		arrayList_add(references, tracked->service);
+	}
+    celixThreadRwlock_unlock(&tracker->lock);
+
+    return references;
+}
+
+void *serviceTracker_getServiceByReference(service_tracker_pt tracker, service_reference_pt reference) {
+	tracked_pt tracked;
+    void *service = NULL;
+	unsigned int i;
+
+    celixThreadRwlock_readLock(&tracker->lock);
+	for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
+		bool equals = false;
+		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
+		serviceReference_equals(reference, tracked->reference, &equals);
+		if (equals) {
+			service = tracked->service;
+            break;
+		}
+	}
+    celixThreadRwlock_unlock(&tracker->lock);
+
+	return service;
+}
+
+void serviceTracker_serviceChanged(service_listener_pt listener, service_event_pt event) {
+	service_tracker_pt tracker = listener->handle;
+	switch (event->type) {
+		case OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED:
+			serviceTracker_track(tracker, event->reference, event);
+			break;
+		case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED:
+			serviceTracker_track(tracker, event->reference, event);
+			break;
+		case OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING:
+			serviceTracker_untrack(tracker, event->reference, event);
+			break;
+		case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH:
+            //TODO
+			break;
+	}
+}
+
+static celix_status_t serviceTracker_track(service_tracker_pt tracker, service_reference_pt reference, service_event_pt event) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    tracked_pt tracked = NULL;
+    bool found = false;
+    unsigned int i;
+    
+    bundleContext_retainServiceReference(tracker->context, reference);
+
+    celixThreadRwlock_readLock(&tracker->lock);
+    for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
+        bool equals = false;
+        tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
+        status = serviceReference_equals(reference, tracked->reference, &equals);
+        if (status != CELIX_SUCCESS) {
+            break;
+        }
+        if (equals) {
+            found = true;
+            break;
+        }
+    }
+    celixThreadRwlock_unlock(&tracker->lock);
+
+    if (status == CELIX_SUCCESS && !found /*new*/) {
+        void * service = NULL;
+        status = serviceTracker_invokeAddingService(tracker, reference, &service);
+        if (status == CELIX_SUCCESS) {
+            if (service != NULL) {
+                tracked = (tracked_pt) calloc(1, sizeof (*tracked));
+                assert(reference != NULL);
+                tracked->reference = reference;
+                tracked->service = service;
+
+                celixThreadRwlock_writeLock(&tracker->lock);
+                arrayList_add(tracker->trackedServices, tracked);
+                celixThreadRwlock_unlock(&tracker->lock);
+
+                serviceTracker_invokeAddService(tracker, reference, service);
+            }
+        }
+
+    } else {
+        status = serviceTracker_invokeModifiedService(tracker, reference, tracked->service);
+    }
+
+    framework_logIfError(logger, status, NULL, "Cannot track reference");
+
+    return status;
+}
+
+static celix_status_t serviceTracker_invokeModifiedService(service_tracker_pt tracker, service_reference_pt ref, void *service) {
+    celix_status_t status = CELIX_SUCCESS;
+    if (tracker->customizer != NULL) {
+        void *handle = NULL;
+        modified_callback_pt function = NULL;
+
+        serviceTrackerCustomizer_getHandle(tracker->customizer, &handle);
+        serviceTrackerCustomizer_getModifiedFunction(tracker->customizer, &function);
+
+        if (function != NULL) {
+            function(handle, ref, service);
+        }
+    }
+    return status;
+}
+
+static celix_status_t serviceTracker_invokeAddService(service_tracker_pt tracker, service_reference_pt ref, void *service) {
+    celix_status_t status = CELIX_SUCCESS;
+    if (tracker->customizer != NULL) {
+        void *handle = NULL;
+        added_callback_pt function = NULL;
+
+        serviceTrackerCustomizer_getHandle(tracker->customizer, &handle);
+        serviceTrackerCustomizer_getAddedFunction(tracker->customizer, &function);
+        if (function != NULL) {
+            function(handle, ref, service);
+        }
+    }
+    return status;
+}
+
+static celix_status_t serviceTracker_invokeAddingService(service_tracker_pt tracker, service_reference_pt reference,
+                                                          void **service) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    if (tracker->customizer != NULL) {
+    	void *handle = NULL;
+		adding_callback_pt function = NULL;
+
+		status =  serviceTrackerCustomizer_getHandle(tracker->customizer, &handle);
+
+        if (status == CELIX_SUCCESS) {
+            status = serviceTrackerCustomizer_getAddingFunction(tracker->customizer, &function);
+        }
+
+		if (status == CELIX_SUCCESS) {
+            if (function != NULL) {
+                status = function(handle, reference, service);
+            } else {
+                status = bundleContext_getService(tracker->context, reference, service);
+            }
+		}
+	} else {
+        status = bundleContext_getService(tracker->context, reference, service);
+    }
+
+    framework_logIfError(logger, status, NULL, "Cannot handle addingService");
+
+    return status;
+}
+
+static celix_status_t serviceTracker_untrack(service_tracker_pt tracker, service_reference_pt reference, service_event_pt event) {
+    celix_status_t status = CELIX_SUCCESS;
+    tracked_pt tracked = NULL;
+    unsigned int i;
+    bool found = false;
+
+    celixThreadRwlock_writeLock(&tracker->lock);
+    for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
+        bool equals;
+        tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
+        serviceReference_equals(reference, tracked->reference, &equals);
+        if (equals) {
+            found = true;
+            arrayList_remove(tracker->trackedServices, i);
+            break;
+        }
+    }
+    celixThreadRwlock_unlock(&tracker->lock);
+
+    if (found && tracked != NULL) {
+        serviceTracker_invokeRemovingService(tracker, tracked->reference, tracked->service);
+        bundleContext_ungetServiceReference(tracker->context, reference);
+        free(tracked);
+    }
+   
+    framework_logIfError(logger, status, NULL, "Cannot untrack reference");
+
+    return status;
+}
+
+static celix_status_t serviceTracker_invokeRemovingService(service_tracker_pt tracker, service_reference_pt ref,  void *service) {
+    celix_status_t status = CELIX_SUCCESS;
+    bool ungetSuccess = true;
+    if (tracker->customizer != NULL) {
+        void *handle = NULL;
+        removed_callback_pt function = NULL;
+
+        serviceTrackerCustomizer_getHandle(tracker->customizer, &handle);
+        serviceTrackerCustomizer_getRemovedFunction(tracker->customizer, &function);
+
+        if (function != NULL) {
+            status = function(handle, ref, service);
+        }
+        if (status == CELIX_SUCCESS) {
+            status = bundleContext_ungetService(tracker->context, ref, &ungetSuccess);
+        }
+    } else {
+        status = bundleContext_ungetService(tracker->context, ref, &ungetSuccess);
+    }
+
+    if (!ungetSuccess) {
+        framework_log(logger, OSGI_FRAMEWORK_LOG_ERROR, __FUNCTION__, __FILE__, __LINE__, "Error ungetting service");
+        status = CELIX_BUNDLE_EXCEPTION;
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_tracker_customizer.c
----------------------------------------------------------------------
diff --git a/framework/src/service_tracker_customizer.c b/framework/src/service_tracker_customizer.c
new file mode 100644
index 0000000..b62a23a
--- /dev/null
+++ b/framework/src/service_tracker_customizer.c
@@ -0,0 +1,107 @@
+/**
+ *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.
+ */
+/*
+ * service_tracker_customizer.c
+ *
+ *  \date       Nov 15, 2012
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+
+#include "service_tracker_customizer_private.h"
+#include "celix_log.h"
+
+celix_status_t serviceTrackerCustomizer_create(void *handle,
+		adding_callback_pt addingFunction, added_callback_pt addedFunction,
+		modified_callback_pt modifiedFunction, removed_callback_pt removedFunction, service_tracker_customizer_pt *customizer) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (handle == NULL || *customizer != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*customizer = malloc(sizeof(**customizer));
+		if (!*customizer) {
+			status = CELIX_ENOMEM;
+		} else {
+			(*customizer)->handle = handle;
+			(*customizer)->addingService = addingFunction;
+			(*customizer)->addedService = addedFunction;
+			(*customizer)->modifiedService = modifiedFunction;
+			(*customizer)->removedService = removedFunction;
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot create customizer");
+
+	return status;
+}
+
+celix_status_t serviceTrackerCustomizer_destroy(service_tracker_customizer_pt customizer) {
+	customizer->handle = NULL;
+	customizer->addingService = NULL;
+	customizer->addedService = NULL;
+	customizer->modifiedService = NULL;
+	customizer->removedService = NULL;
+
+	free(customizer);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceTrackerCustomizer_getHandle(service_tracker_customizer_pt customizer, void **handle) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*handle = customizer->handle;
+
+	return status;
+}
+
+celix_status_t serviceTrackerCustomizer_getAddingFunction(service_tracker_customizer_pt customizer, adding_callback_pt *function) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*function = customizer->addingService;
+
+	return status;
+}
+
+celix_status_t serviceTrackerCustomizer_getAddedFunction(service_tracker_customizer_pt customizer, added_callback_pt *function) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*function = customizer->addedService;
+
+	return status;
+}
+
+celix_status_t serviceTrackerCustomizer_getModifiedFunction(service_tracker_customizer_pt customizer, modified_callback_pt *function) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*function = customizer->modifiedService;
+
+	return status;
+}
+
+celix_status_t serviceTrackerCustomizer_getRemovedFunction(service_tracker_customizer_pt customizer, removed_callback_pt *function) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*function = customizer->removedService;
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_tracker_customizer_private.h
----------------------------------------------------------------------
diff --git a/framework/src/service_tracker_customizer_private.h b/framework/src/service_tracker_customizer_private.h
new file mode 100644
index 0000000..61fb52f
--- /dev/null
+++ b/framework/src/service_tracker_customizer_private.h
@@ -0,0 +1,49 @@
+/**
+ *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.
+ */
+/*
+ * service_tracker_customizer_private.h
+ *
+ *  \date       Feb 7, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef SERVICE_TRACKER_CUSTOMIZER_PRIVATE_H_
+#define SERVICE_TRACKER_CUSTOMIZER_PRIVATE_H_
+
+#include "service_reference.h"
+
+#include "service_tracker_customizer.h"
+
+
+struct serviceTrackerCustomizer {
+	void * handle;
+	celix_status_t (*addingService)(void * handle, service_reference_pt reference, void **service);
+	celix_status_t (*addedService)(void * handle, service_reference_pt reference, void * service);
+	celix_status_t (*modifiedService)(void * handle, service_reference_pt reference, void * service);
+
+	/*TODO rename to removingService. because it is invoke during remove not after!*/
+	celix_status_t (*removedService)(void * handle, service_reference_pt reference, void * service);
+
+	/*TODO add removed function ? invoked after the remove ?? */
+};
+
+
+#endif /* SERVICE_TRACKER_CUSTOMIZER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_tracker_private.h
----------------------------------------------------------------------
diff --git a/framework/src/service_tracker_private.h b/framework/src/service_tracker_private.h
new file mode 100644
index 0000000..1d80ba1
--- /dev/null
+++ b/framework/src/service_tracker_private.h
@@ -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.
+ */
+/*
+ * service_tracker_private.h
+ *
+ *  \date       Feb 6, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef SERVICE_TRACKER_PRIVATE_H_
+#define SERVICE_TRACKER_PRIVATE_H_
+
+#include "service_tracker.h"
+
+struct serviceTracker {
+	bundle_context_pt context;
+	char * filter;
+
+	service_tracker_pt tracker;
+	service_tracker_customizer_pt customizer;
+	service_listener_pt listener;
+
+	celix_thread_rwlock_t lock; //projects trackedServices
+	array_list_pt trackedServices;
+};
+
+struct tracked {
+	service_reference_pt reference;
+	void * service;
+};
+
+typedef struct tracked * tracked_pt;
+
+#endif /* SERVICE_TRACKER_PRIVATE_H_ */


[08/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_endpoint2/private/src/calculator_endpoint_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_endpoint2/private/src/calculator_endpoint_impl.c b/remote_services/examples/calculator_endpoint2/private/src/calculator_endpoint_impl.c
deleted file mode 100644
index b9a973f..0000000
--- a/remote_services/examples/calculator_endpoint2/private/src/calculator_endpoint_impl.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_endpoint_impl.c
- *
- *  \date       Oct 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <jansson.h>
-#include <string.h>
-
-#include "celix_errno.h"
-
-#include "calculator_endpoint_impl.h"
-
-celix_status_t calculatorEndpoint_create(remote_endpoint_pt *endpoint) {
-	celix_status_t status = CELIX_SUCCESS;
-	*endpoint = calloc(1, sizeof(**endpoint));
-	if (!*endpoint) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*endpoint)->service = NULL;
-	}
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_destroy(remote_endpoint_pt *endpoint) {
-	celix_status_t status = CELIX_SUCCESS;
-	free(*endpoint);
-	*endpoint = NULL;
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_setService(remote_endpoint_pt endpoint, void *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	endpoint->service = service;
-	return status;
-}
-
-/**
- * Request: http://host:port/services/{service}
- */
-celix_status_t calculatorEndpoint_handleRequest(remote_endpoint_pt endpoint, char *data, char **reply) {
-	celix_status_t status = CELIX_SUCCESS;
-	json_error_t jsonError;
-    json_t *root = json_loads(data, 0, &jsonError);
-    const char *sig;
-    json_unpack(root, "{s:s}", "m", &sig);
-
-	printf("CALCULATOR_ENDPOINT: Handle request \"%s\" with data \"%s\"\n", sig, data);
-	if (strcmp(sig, "add(DD)D") == 0) {
-		calculatorEndpoint_add(endpoint, data, reply);
-	} else if (strcmp(sig, "sub(DD)D") == 0) {
-		calculatorEndpoint_sub(endpoint, data, reply);
-	} else if (strcmp(sig, "sqrt(D)D") == 0) {
-		calculatorEndpoint_sqrt(endpoint, data, reply);
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	json_decref(root);
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_add(remote_endpoint_pt endpoint, char *data, char **reply) {
-	celix_status_t status = CELIX_SUCCESS;
-	json_error_t jsonError;
-	json_t *root;
-
-	root = json_loads(data, 0, &jsonError);
-	if (!root) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		double a;
-		double b;
-		json_unpack(root, "{s:[ff]}", "a", &a, &b);
-
-		if (endpoint->service != NULL) {
-			double result;
-			json_t *resultRoot;
-			calculator_service_pt service = endpoint->service;
-			service->add(service->calculator, a, b, &result);
-			resultRoot = json_pack("{s:f}", "r", result);
-
-			char *c = json_dumps(resultRoot, 0);
-			*reply = c;
-
-			json_decref(resultRoot);
-		} else {
-			printf("CALCULATOR_ENDPOINT: No service available");
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-		json_decref(root);
-	}
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_sub(remote_endpoint_pt endpoint, char *data, char **reply) {
-	celix_status_t status = CELIX_SUCCESS;
-	json_error_t jsonError;
-	json_t *root;
-
-	root = json_loads(data, 0, &jsonError);
-	if (!root) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		double a;
-		double b;
-		json_unpack(root, "{s:[ff]}", "a", &a, &b);
-
-		if (endpoint->service != NULL) {
-			double result;
-			json_t *resultRoot;
-			calculator_service_pt service = endpoint->service;
-			service->sub(service->calculator, a, b, &result);
-			resultRoot = json_pack("{s:f}", "r", result);
-
-			char *c = json_dumps(resultRoot, JSON_ENCODE_ANY);
-			*reply = c;
-
-			json_decref(resultRoot);
-		} else {
-			printf("CALCULATOR_ENDPOINT: No service available");
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-		json_decref(root);
-	}
-
-	return status;
-}
-
-celix_status_t calculatorEndpoint_sqrt(remote_endpoint_pt endpoint, char *data, char **reply) {
-	celix_status_t status = CELIX_SUCCESS;
-	json_error_t jsonError;
-	json_t *root;
-
-	root = json_loads(data, 0, &jsonError);
-	if (!root) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		double a;
-		json_unpack(root, "{s:[f]}", "a", &a);
-
-		if (endpoint->service != NULL) {
-			double result;
-			json_t *resultRoot;
-			calculator_service_pt service = endpoint->service;
-			service->sqrt(service->calculator, a, &result);
-			resultRoot = json_pack("{s:f}", "r", result);
-
-			char *c = json_dumps(resultRoot, JSON_ENCODE_ANY);
-			*reply = c;
-
-			json_decref(resultRoot);
-		} else {
-			printf("CALCULATOR_ENDPOINT: No service available");
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-		json_decref(root);
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_proxy/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_proxy/CMakeLists.txt b/remote_services/examples/calculator_proxy/CMakeLists.txt
deleted file mode 100644
index 9bbf089..0000000
--- a/remote_services/examples/calculator_proxy/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# 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.
-
-find_package(Jansson REQUIRED)
-
-include_directories("${JANSSON_INCLUDE_DIRS}")
-include_directories("../../../utils/public/include")
-include_directories("../../remote_service_admin/public/include")
-include_directories("private/include")
-include_directories("../calculator_service/public/include")
-include_directories("../../endpoint_listener/public/include")
-
-add_bundle(org.apache.celix.calc.api.Calculator_proxy SOURCES
-	private/src/calculator_proxy_activator
-	private/src/calculator_proxy_impl.c
-    ../../remote_service_admin/private/src/remote_proxy_factory_impl.c
-    
-    private/include/calculator_proxy_impl.h
-    VERSION 0.0.1
-    SYMBOLIC_NAME "apache_celix_remoting_calculator_proxy"
-)
-
-target_link_libraries(org.apache.celix.calc.api.Calculator_proxy celix_framework ${JANSSON_LIBRARIES})

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_proxy/private/include/calculator_proxy_impl.h
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_proxy/private/include/calculator_proxy_impl.h b/remote_services/examples/calculator_proxy/private/include/calculator_proxy_impl.h
deleted file mode 100644
index 86f97b4..0000000
--- a/remote_services/examples/calculator_proxy/private/include/calculator_proxy_impl.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_proxy_impl.h
- *
- *  \date       Oct 13, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef CALCULATOR_PROXY_IMPL_H_
-#define CALCULATOR_PROXY_IMPL_H_
-
-#include "celix_errno.h"
-
-#include "calculator_service.h"
-#include "remote_proxy.h"
-#include "constants.h"
-#include "bundle_context.h"
-#include "hash_map.h"
-
-#include "endpoint_listener.h"
-
-
-struct calculator {
-	bundle_context_pt context;
-
-	endpoint_description_pt endpoint;
-	sendToHandle sendToCallback;
-	void * sendToHandler;
-};
-
-
-celix_status_t calculatorProxy_create(bundle_context_pt context, calculator_pt *endpoint);
-celix_status_t calculatorProxy_destroy(calculator_pt *endpoint);
-celix_status_t calculatorProxy_add(calculator_pt calculator, double a, double b, double *result);
-celix_status_t calculatorProxy_sub(calculator_pt calculator, double a, double b, double *result);
-celix_status_t calculatorProxy_sqrt(calculator_pt calculator, double a, double *result);
-
-celix_status_t calculatorProxy_registerProxyService(void* proxyFactoryService, endpoint_description_pt endpoint, void* handler, sendToHandle callback);
-celix_status_t calculatorProxy_unregisterProxyService(void* proxyFactoryService, endpoint_description_pt endpoint);
-
-#endif /* CALCULATOR_PROXY_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_proxy/private/src/calculator_proxy_activator.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_proxy/private/src/calculator_proxy_activator.c b/remote_services/examples/calculator_proxy/private/src/calculator_proxy_activator.c
deleted file mode 100644
index acc0651..0000000
--- a/remote_services/examples/calculator_proxy/private/src/calculator_proxy_activator.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_proxy_activator.c
- *
- *  \date       Oct 10, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-#include "service_registration.h"
-#include "remote_proxy.h"
-
-#include "calculator_proxy_impl.h"
-
-struct activator {
-	bundle_context_pt context;
-	remote_proxy_factory_pt factory_ptr;
-};
-
-static celix_status_t calculatorProxyFactory_create(void *handle, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback, properties_pt properties, void **service);
-static celix_status_t calculatorProxyFactory_destroy(void *handle, void *service);
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	struct activator *activator;
-
-	activator = calloc(1, sizeof(*activator));
-	if (!activator) {
-		status = CELIX_ENOMEM;
-	} else {
-		activator->factory_ptr = NULL;
-		activator->context = context;
-
-		*userData = activator;
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	remoteProxyFactory_create(context, (char *) CALCULATOR_SERVICE, activator,
-			calculatorProxyFactory_create, calculatorProxyFactory_destroy,
-			&activator->factory_ptr);
-	remoteProxyFactory_register(activator->factory_ptr);
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	remoteProxyFactory_unregister(activator->factory_ptr);
-	remoteProxyFactory_destroy(&activator->factory_ptr);
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	free(activator);
-
-	return status;
-}
-
-static celix_status_t calculatorProxyFactory_create(void *handle, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback, properties_pt properties, void **service) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = handle;
-
-	calculator_service_pt calculatorService = calloc(1, sizeof(*calculatorService));
-	calculatorProxy_create(activator->context, &calculatorService->calculator);
-	calculatorService->add = calculatorProxy_add;
-	calculatorService->sub = calculatorProxy_sub;
-	calculatorService->sqrt = calculatorProxy_sqrt;
-
-	calculatorService->calculator->endpoint = endpointDescription;
-	calculatorService->calculator->sendToHandler = rsa;
-	calculatorService->calculator->sendToCallback = sendToCallback;
-
-	*service = calculatorService;
-
-	return status;
-}
-
-static celix_status_t calculatorProxyFactory_destroy(void *handle, void *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	calculator_service_pt calculatorService = service;
-
-	if (!calculatorService) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		calculatorProxy_destroy(&calculatorService->calculator);
-		free(calculatorService);
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_proxy/private/src/calculator_proxy_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_proxy/private/src/calculator_proxy_impl.c b/remote_services/examples/calculator_proxy/private/src/calculator_proxy_impl.c
deleted file mode 100644
index fc21412..0000000
--- a/remote_services/examples/calculator_proxy/private/src/calculator_proxy_impl.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_proxy_impl.c
- *
- *  \date       Oct 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <jansson.h>
-
-#include <string.h>
-#include <stddef.h>
-
-#include "celix_errno.h"
-#include "array_list.h"
-#include "calculator_proxy_impl.h"
-
-/* Allows the use of Jansson < 2.3 */
-#ifndef JSON_DECODE_ANY
-#define JSON_DECODE_ANY 0
-#endif
-
-celix_status_t calculatorProxy_create(bundle_context_pt context, calculator_pt *calculator)  {
-	celix_status_t status = CELIX_SUCCESS;
-	*calculator = calloc(1, sizeof(**calculator));
-	if (!*calculator) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*calculator)->context = context;
-		(*calculator)->endpoint = NULL;
-		(*calculator)->sendToCallback=NULL;
-		(*calculator)->sendToHandler=NULL;
-	}
-
-	return status;
-}
-
-
-celix_status_t calculatorProxy_destroy(calculator_pt *calculator)  {
-	celix_status_t status = CELIX_SUCCESS;
-
-	free(*calculator);
-	*calculator = NULL;
-
-	return status;
-}
-
-// { "m": "" "a":["arg1", "arg2"] }
-celix_status_t calculatorProxy_add(calculator_pt calculator, double a, double b, double *result) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (calculator->endpoint != NULL) {
-		json_t *root;
-		root = json_pack("{s:s, s:[ff]}", "m", "add(DD)D", "a", a, b);
-
-		char *data = json_dumps(root, 0);
-		char *reply = NULL;
-		int replyStatus = 0;
-
-		calculator->sendToCallback(calculator->sendToHandler, calculator->endpoint, data, &reply, &replyStatus);
-
-		if (status == CELIX_SUCCESS) {
-		    printf("Handle reply: %s\n", reply);
-			json_error_t error;
-			json_t *js_reply = json_loads(reply, 0, &error);
-			if (js_reply) {
-				json_unpack(js_reply, "{s:f}", "r", result);
-				json_decref(js_reply);
-			} else {
-				printf("PROXY: got error '%s' for '%s'\n", error.text, reply);
-				status = CELIX_BUNDLE_EXCEPTION;
-			}
-		}
-		json_decref(root);
-
-		free(data);
-		free(reply);
-	} else {
-		printf("CALCULATOR_PROXY: No endpoint information available\n");
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-
-	return status;
-}
-
-celix_status_t calculatorProxy_sub(calculator_pt calculator, double a, double b, double *result) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (calculator->endpoint != NULL) {
-		json_t *root;
-		root = json_pack("{s:s, s:[ff]}", "m", "sub(DD)D", "a", a, b);
-
-		char *data = json_dumps(root, 0);
-		char *reply = NULL;
-		int replyStatus = 0;
-
-		calculator->sendToCallback(calculator->sendToHandler, calculator->endpoint, data, &reply, &replyStatus);
-
-		if (status == CELIX_SUCCESS) {
-			json_error_t error;
-			json_t *js_reply = json_loads(reply, 0, &error);
-			if (js_reply) {
-			    json_unpack(js_reply, "{s:f}", "r", result);
-			    json_decref(js_reply);
-			} else {
-				printf("PROXY: got error '%s' for '%s'\n", error.text, reply);
-				status = CELIX_BUNDLE_EXCEPTION;
-			}
-		}
-
-		json_decref(root);
-
-		free(data);
-		free(reply);
-	} else {
-		printf("CALCULATOR_PROXY: No endpoint information available\n");
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-
-	return status;
-}
-
-celix_status_t calculatorProxy_sqrt(calculator_pt calculator, double a, double *result) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (calculator->endpoint != NULL) {
-		json_t *root;
-		root = json_pack("{s:s, s:[f]}", "m", "sqrt(D)D", "a", a);
-
-		char *data = json_dumps(root, 0);
-		char *reply = NULL;
-		int replyStatus;
-
-		calculator->sendToCallback(calculator->sendToHandler, calculator->endpoint, data, &reply, &replyStatus);
-
-		if (status == CELIX_SUCCESS) {
-			json_error_t error;
-			json_t *js_reply = json_loads(reply, JSON_DECODE_ANY, &error);
-			if (js_reply) {
-			    json_unpack(js_reply, "{s:f}", "r", result);
-			    json_decref(js_reply);
-			} else {
-				printf("PROXY: got error '%s' for '%s'\n", error.text, reply);
-				status = CELIX_BUNDLE_EXCEPTION;
-			}
-		}
-
-		json_decref(root);
-
-		free(data);
-		free(reply);
-	} else {
-		printf("CALCULATOR_PROXY: No endpoint information available\n");
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_proxy2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_proxy2/CMakeLists.txt b/remote_services/examples/calculator_proxy2/CMakeLists.txt
deleted file mode 100644
index 01556e3..0000000
--- a/remote_services/examples/calculator_proxy2/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# 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.
-
-find_package(Jansson REQUIRED)
-
-include_directories("${JANSSON_INCLUDE_DIRS}")
-include_directories("../../../utils/public/include")
-include_directories("../../remote_service_admin/public/include")
-include_directories("private/include")
-include_directories("../calculator_service/public/include")
-include_directories("../../endpoint_listener/public/include")
-
-add_bundle(org.apache.celix.calc.api.Calculator2_proxy SOURCES
-	private/src/calculator_proxy_activator
-	private/src/calculator_proxy_impl.c
-    ../../remote_service_admin/private/src/remote_proxy_factory_impl.c
-    
-    private/include/calculator_proxy_impl.h
-    VERSION 0.0.1
-    SYMBOLIC_NAME "apache_celix_remoting_calculator2_proxy"
-)
-
-target_link_libraries(org.apache.celix.calc.api.Calculator2_proxy celix_framework ${JANSSON_LIBRARIES})

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_proxy2/private/include/calculator_proxy_impl.h
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_proxy2/private/include/calculator_proxy_impl.h b/remote_services/examples/calculator_proxy2/private/include/calculator_proxy_impl.h
deleted file mode 100644
index 86f97b4..0000000
--- a/remote_services/examples/calculator_proxy2/private/include/calculator_proxy_impl.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_proxy_impl.h
- *
- *  \date       Oct 13, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef CALCULATOR_PROXY_IMPL_H_
-#define CALCULATOR_PROXY_IMPL_H_
-
-#include "celix_errno.h"
-
-#include "calculator_service.h"
-#include "remote_proxy.h"
-#include "constants.h"
-#include "bundle_context.h"
-#include "hash_map.h"
-
-#include "endpoint_listener.h"
-
-
-struct calculator {
-	bundle_context_pt context;
-
-	endpoint_description_pt endpoint;
-	sendToHandle sendToCallback;
-	void * sendToHandler;
-};
-
-
-celix_status_t calculatorProxy_create(bundle_context_pt context, calculator_pt *endpoint);
-celix_status_t calculatorProxy_destroy(calculator_pt *endpoint);
-celix_status_t calculatorProxy_add(calculator_pt calculator, double a, double b, double *result);
-celix_status_t calculatorProxy_sub(calculator_pt calculator, double a, double b, double *result);
-celix_status_t calculatorProxy_sqrt(calculator_pt calculator, double a, double *result);
-
-celix_status_t calculatorProxy_registerProxyService(void* proxyFactoryService, endpoint_description_pt endpoint, void* handler, sendToHandle callback);
-celix_status_t calculatorProxy_unregisterProxyService(void* proxyFactoryService, endpoint_description_pt endpoint);
-
-#endif /* CALCULATOR_PROXY_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_proxy2/private/src/calculator_proxy_activator.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_proxy2/private/src/calculator_proxy_activator.c b/remote_services/examples/calculator_proxy2/private/src/calculator_proxy_activator.c
deleted file mode 100644
index 6b9af72..0000000
--- a/remote_services/examples/calculator_proxy2/private/src/calculator_proxy_activator.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_proxy_activator.c
- *
- *  \date       Oct 10, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-#include "service_registration.h"
-#include "remote_proxy.h"
-
-#include "calculator_proxy_impl.h"
-
-struct activator {
-	bundle_context_pt context;
-	remote_proxy_factory_pt factory_ptr;
-};
-
-static celix_status_t calculatorProxyFactory_create(void *handle, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback, properties_pt properties, void **service);
-static celix_status_t calculatorProxyFactory_destroy(void *handle, void *service);
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	struct activator *activator;
-
-	activator = calloc(1, sizeof(*activator));
-	if (!activator) {
-		status = CELIX_ENOMEM;
-	} else {
-		activator->factory_ptr = NULL;
-		activator->context = context;
-
-		*userData = activator;
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-        celix_status_t status = CELIX_SUCCESS;
-        struct activator *activator = userData;
-
-        remoteProxyFactory_create(context, CALCULATOR2_SERVICE, activator,
-                        calculatorProxyFactory_create, calculatorProxyFactory_destroy,
-                        &activator->factory_ptr);
-        remoteProxyFactory_register(activator->factory_ptr);
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	remoteProxyFactory_unregister(activator->factory_ptr);
-	remoteProxyFactory_destroy(&activator->factory_ptr);
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	free(activator);
-
-	return status;
-}
-
-static celix_status_t calculatorProxyFactory_create(void *handle, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback, properties_pt properties, void **service) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = handle;
-
-	calculator_service_pt calculatorService = calloc(1, sizeof(*calculatorService));
-	calculatorProxy_create(activator->context, &calculatorService->calculator);
-	calculatorService->add = calculatorProxy_add;
-	calculatorService->sub = calculatorProxy_sub;
-	calculatorService->sqrt = calculatorProxy_sqrt;
-
-	calculatorService->calculator->endpoint = endpointDescription;
-	calculatorService->calculator->sendToHandler = rsa;
-	calculatorService->calculator->sendToCallback = sendToCallback;
-
-	*service = calculatorService;
-
-	return status;
-}
-
-static celix_status_t calculatorProxyFactory_destroy(void *handle, void *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	calculator_service_pt calculatorService = service;
-
-	if (!calculatorService) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		calculatorProxy_destroy(&calculatorService->calculator);
-		free(calculatorService);
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_proxy2/private/src/calculator_proxy_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_proxy2/private/src/calculator_proxy_impl.c b/remote_services/examples/calculator_proxy2/private/src/calculator_proxy_impl.c
deleted file mode 100644
index fc21412..0000000
--- a/remote_services/examples/calculator_proxy2/private/src/calculator_proxy_impl.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- *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.
- */
-/*
- * calculator_proxy_impl.c
- *
- *  \date       Oct 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <jansson.h>
-
-#include <string.h>
-#include <stddef.h>
-
-#include "celix_errno.h"
-#include "array_list.h"
-#include "calculator_proxy_impl.h"
-
-/* Allows the use of Jansson < 2.3 */
-#ifndef JSON_DECODE_ANY
-#define JSON_DECODE_ANY 0
-#endif
-
-celix_status_t calculatorProxy_create(bundle_context_pt context, calculator_pt *calculator)  {
-	celix_status_t status = CELIX_SUCCESS;
-	*calculator = calloc(1, sizeof(**calculator));
-	if (!*calculator) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*calculator)->context = context;
-		(*calculator)->endpoint = NULL;
-		(*calculator)->sendToCallback=NULL;
-		(*calculator)->sendToHandler=NULL;
-	}
-
-	return status;
-}
-
-
-celix_status_t calculatorProxy_destroy(calculator_pt *calculator)  {
-	celix_status_t status = CELIX_SUCCESS;
-
-	free(*calculator);
-	*calculator = NULL;
-
-	return status;
-}
-
-// { "m": "" "a":["arg1", "arg2"] }
-celix_status_t calculatorProxy_add(calculator_pt calculator, double a, double b, double *result) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (calculator->endpoint != NULL) {
-		json_t *root;
-		root = json_pack("{s:s, s:[ff]}", "m", "add(DD)D", "a", a, b);
-
-		char *data = json_dumps(root, 0);
-		char *reply = NULL;
-		int replyStatus = 0;
-
-		calculator->sendToCallback(calculator->sendToHandler, calculator->endpoint, data, &reply, &replyStatus);
-
-		if (status == CELIX_SUCCESS) {
-		    printf("Handle reply: %s\n", reply);
-			json_error_t error;
-			json_t *js_reply = json_loads(reply, 0, &error);
-			if (js_reply) {
-				json_unpack(js_reply, "{s:f}", "r", result);
-				json_decref(js_reply);
-			} else {
-				printf("PROXY: got error '%s' for '%s'\n", error.text, reply);
-				status = CELIX_BUNDLE_EXCEPTION;
-			}
-		}
-		json_decref(root);
-
-		free(data);
-		free(reply);
-	} else {
-		printf("CALCULATOR_PROXY: No endpoint information available\n");
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-
-	return status;
-}
-
-celix_status_t calculatorProxy_sub(calculator_pt calculator, double a, double b, double *result) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (calculator->endpoint != NULL) {
-		json_t *root;
-		root = json_pack("{s:s, s:[ff]}", "m", "sub(DD)D", "a", a, b);
-
-		char *data = json_dumps(root, 0);
-		char *reply = NULL;
-		int replyStatus = 0;
-
-		calculator->sendToCallback(calculator->sendToHandler, calculator->endpoint, data, &reply, &replyStatus);
-
-		if (status == CELIX_SUCCESS) {
-			json_error_t error;
-			json_t *js_reply = json_loads(reply, 0, &error);
-			if (js_reply) {
-			    json_unpack(js_reply, "{s:f}", "r", result);
-			    json_decref(js_reply);
-			} else {
-				printf("PROXY: got error '%s' for '%s'\n", error.text, reply);
-				status = CELIX_BUNDLE_EXCEPTION;
-			}
-		}
-
-		json_decref(root);
-
-		free(data);
-		free(reply);
-	} else {
-		printf("CALCULATOR_PROXY: No endpoint information available\n");
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-
-	return status;
-}
-
-celix_status_t calculatorProxy_sqrt(calculator_pt calculator, double a, double *result) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (calculator->endpoint != NULL) {
-		json_t *root;
-		root = json_pack("{s:s, s:[f]}", "m", "sqrt(D)D", "a", a);
-
-		char *data = json_dumps(root, 0);
-		char *reply = NULL;
-		int replyStatus;
-
-		calculator->sendToCallback(calculator->sendToHandler, calculator->endpoint, data, &reply, &replyStatus);
-
-		if (status == CELIX_SUCCESS) {
-			json_error_t error;
-			json_t *js_reply = json_loads(reply, JSON_DECODE_ANY, &error);
-			if (js_reply) {
-			    json_unpack(js_reply, "{s:f}", "r", result);
-			    json_decref(js_reply);
-			} else {
-				printf("PROXY: got error '%s' for '%s'\n", error.text, reply);
-				status = CELIX_BUNDLE_EXCEPTION;
-			}
-		}
-
-		json_decref(root);
-
-		free(data);
-		free(reply);
-	} else {
-		printf("CALCULATOR_PROXY: No endpoint information available\n");
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_service/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_service/CMakeLists.txt b/remote_services/examples/calculator_service/CMakeLists.txt
index a18f22b..5e8040c 100644
--- a/remote_services/examples/calculator_service/CMakeLists.txt
+++ b/remote_services/examples/calculator_service/CMakeLists.txt
@@ -33,5 +33,3 @@ add_bundle(calculator SOURCES
 
 bundle_files(calculator public/include/org.apache.celix.calc.api.Calculator2.descriptor
     DESTINATION .)
-
-target_link_libraries(calculator celix_framework)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/examples/calculator_shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/CMakeLists.txt b/remote_services/examples/calculator_shell/CMakeLists.txt
index 361b688..980fa1a 100644
--- a/remote_services/examples/calculator_shell/CMakeLists.txt
+++ b/remote_services/examples/calculator_shell/CMakeLists.txt
@@ -18,7 +18,6 @@
 include_directories("private/include")
 include_directories("../../../utils/public/include")
 include_directories("../calculator_service/public/include")
-include_directories("../../../shell/public/include")
 
 add_bundle(calculator_shell SOURCES
     private/src/add_command 
@@ -40,4 +39,4 @@ bundle_files(calculator_shell
     DESTINATION .
 )
 
-target_link_libraries(calculator_shell celix_framework)
+target_link_libraries(calculator_shell PRIVATE Celix::shell_api)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_dfi/rsa/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/rsa/CMakeLists.txt b/remote_services/remote_service_admin_dfi/rsa/CMakeLists.txt
index 7e2675c..01ab9bd 100644
--- a/remote_services/remote_service_admin_dfi/rsa/CMakeLists.txt
+++ b/remote_services/remote_service_admin_dfi/rsa/CMakeLists.txt
@@ -41,8 +41,7 @@ add_bundle(remote_service_admin_dfi
     ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
 
     ${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 celix_utils celix_dfi ${CURL_LIBRARIES} ${JANSSON_LIBRARIES})
+target_link_libraries(remote_service_admin_dfi PRIVATE Celix::dfi Celix::log_helper ${CURL_LIBRARIES} ${JANSSON_LIBRARIES})
 
 install_bundle(remote_service_admin_dfi)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt b/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt
index d28ad0b..543d5a1 100644
--- a/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt
+++ b/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt
@@ -16,9 +16,6 @@
 # under the License.
 
 include_directories(
-    ${PROJECT_SOURCE_DIR}/framework/public/include
-    ${PROJECT_SOURCE_DIR}/utils/public/include
-    ${PROJECT_SOURCE_DIR}/utils/public/include
     ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include
     ${PROJECT_SOURCE_DIR}/remote_services/examples/calculator_service/public/include
     bundle
@@ -37,7 +34,7 @@ add_executable(test_rsa_dfi
 
     ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
 )
-target_link_libraries(test_rsa_dfi celix_framework celix_utils ${CURL_LIBRARIES} ${CPPUTEST_LIBRARY})
+target_link_libraries(test_rsa_dfi Celix::framework ${CURL_LIBRARIES} ${CPPUTEST_LIBRARY})
 
 get_property(rsa_bundle_file TARGET remote_service_admin_dfi PROPERTY BUNDLE_FILE)
 get_property(calc_bundle_file TARGET calculator PROPERTY BUNDLE_FILE)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_dfi/rsa_tst/bundle/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/rsa_tst/bundle/CMakeLists.txt b/remote_services/remote_service_admin_dfi/rsa_tst/bundle/CMakeLists.txt
index d172087..27c3804 100644
--- a/remote_services/remote_service_admin_dfi/rsa_tst/bundle/CMakeLists.txt
+++ b/remote_services/remote_service_admin_dfi/rsa_tst/bundle/CMakeLists.txt
@@ -34,4 +34,4 @@ bundle_files(rsa_dfi_tst_bundle
     DESTINATION .
 )
 
-target_link_libraries(rsa_dfi_tst_bundle ${CPPUTEST_LIBRARY} celix_framework celix_utils)
+target_link_libraries(rsa_dfi_tst_bundle PRIVATE ${CPPUTEST_LIBRARY} )

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_http/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/CMakeLists.txt b/remote_services/remote_service_admin_http/CMakeLists.txt
deleted file mode 100644
index cc1b99a..0000000
--- a/remote_services/remote_service_admin_http/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# 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_HTTP "Option to enable building the Remote Service Admin Service HTTP bundle" ON)
-if (RSA_REMOTE_SERVICE_ADMIN_HTTP)
-	find_package(CURL REQUIRED)
-	find_package(UUID REQUIRED)
-
-	include_directories(${CURL_INCLUDE_DIRS})
-	include_directories(${UUID_INCLUDE_DIR})
-	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")
-
-	add_bundle(remote_service_admin_http 
-        VERSION 0.9.0
-        SYMBOLIC_NAME "apache_celix_remote_service_admin_http"
-        NAME "Apache Celix Remote Service Admin HTTP"
-        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
-	)
-
-	install_bundle(remote_service_admin_http)
-
-	target_link_libraries(remote_service_admin_http celix_framework ${CURL_LIBRARIES} ${UUID})
-
-	if (ENABLE_TESTING)
-             find_package(CppUTest REQUIRED)
-	     include_directories(${CPPUTEST_INCLUDE_DIR})
-	     add_subdirectory(private/test)
-         endif()
-endif (RSA_REMOTE_SERVICE_ADMIN_HTTP)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_http/private/include/remote_service_admin_http_impl.h
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/include/remote_service_admin_http_impl.h b/remote_services/remote_service_admin_http/private/include/remote_service_admin_http_impl.h
deleted file mode 100644
index dbf71c9..0000000
--- a/remote_services/remote_service_admin_http/private/include/remote_service_admin_http_impl.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- *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.
- */
-/*
- * remote_service_admin_http_impl.h
- *
- *  \date       Sep 30, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef REMOTE_SERVICE_ADMIN_HTTP_IMPL_H_
-#define REMOTE_SERVICE_ADMIN_HTTP_IMPL_H_
-
-#include "remote_service_admin_impl.h"
-#include "log_helper.h"
-#include "civetweb.h"
-
-struct remote_service_admin {
-	bundle_context_pt context;
-	log_helper_pt loghelper;
-
-	celix_thread_mutex_t exportedServicesLock;
-	hash_map_pt exportedServices;
-
-	celix_thread_mutex_t importedServicesLock;
-	hash_map_pt importedServices;
-
-	char *port;
-	char *ip;
-
-	struct mg_context *ctx;
-};
-
-celix_status_t remoteServiceAdmin_stop(remote_service_admin_pt admin);
-
-#endif /* REMOTE_SERVICE_ADMIN_HTTP_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_http/private/src/remote_service_admin_activator.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/src/remote_service_admin_activator.c b/remote_services/remote_service_admin_http/private/src/remote_service_admin_activator.c
deleted file mode 100644
index 2851a29..0000000
--- a/remote_services/remote_service_admin_http/private/src/remote_service_admin_activator.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- *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.
- */
-/*
- * remote_service_admin_activator.c
- *
- *  \date       Sep 30, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-#include "service_registration.h"
-
-#include "remote_service_admin_http_impl.h"
-#include "export_registration_impl.h"
-#include "import_registration_impl.h"
-
-struct activator {
-	remote_service_admin_pt admin;
-	remote_service_admin_service_pt adminService;
-	service_registration_pt registration;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator;
-
-	activator = calloc(1, sizeof(*activator));
-	if (!activator) {
-		status = CELIX_ENOMEM;
-	} else {
-		activator->admin = NULL;
-		activator->registration = NULL;
-
-		*userData = activator;
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-	remote_service_admin_service_pt remoteServiceAdmin = NULL;
-
-	status = remoteServiceAdmin_create(context, &activator->admin);
-	if (status == CELIX_SUCCESS) {
-		remoteServiceAdmin = calloc(1, sizeof(*remoteServiceAdmin));
-		if (!remoteServiceAdmin) {
-			status = CELIX_ENOMEM;
-		} else {
-			remoteServiceAdmin->admin = activator->admin;
-			remoteServiceAdmin->exportService = remoteServiceAdmin_exportService;
-
-			remoteServiceAdmin->getExportedServices = remoteServiceAdmin_getExportedServices;
-			remoteServiceAdmin->getImportedEndpoints = remoteServiceAdmin_getImportedEndpoints;
-			remoteServiceAdmin->importService = remoteServiceAdmin_importService;
-
-			remoteServiceAdmin->exportReference_getExportedEndpoint = exportReference_getExportedEndpoint;
-			remoteServiceAdmin->exportReference_getExportedService = exportReference_getExportedService;
-
-			remoteServiceAdmin->exportRegistration_close = remoteServiceAdmin_removeExportedService;
-			remoteServiceAdmin->exportRegistration_getException = exportRegistration_getException;
-			remoteServiceAdmin->exportRegistration_getExportReference = exportRegistration_getExportReference;
-
-			remoteServiceAdmin->importReference_getImportedEndpoint = importReference_getImportedEndpoint;
-			remoteServiceAdmin->importReference_getImportedService = importReference_getImportedService;
-
-			remoteServiceAdmin->importRegistration_close = remoteServiceAdmin_removeImportedService;
-			remoteServiceAdmin->importRegistration_getException = importRegistration_getException;
-			remoteServiceAdmin->importRegistration_getImportReference = importRegistration_getImportReference;
-
-			status = bundleContext_registerService(context, OSGI_RSA_REMOTE_SERVICE_ADMIN, remoteServiceAdmin, NULL, &activator->registration);
-			activator->adminService = remoteServiceAdmin;
-		}
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-    struct activator *activator = userData;
-
-    serviceRegistration_unregister(activator->registration);
-    activator->registration = NULL;
-
-    remoteServiceAdmin_stop(activator->admin);
-
-    remoteServiceAdmin_destroy(&activator->admin);
-
-    free(activator->adminService);
-
-    return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = userData;
-
-	free(activator);
-
-	return status;
-}
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c b/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
deleted file mode 100644
index 0b05c1f..0000000
--- a/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
+++ /dev/null
@@ -1,822 +0,0 @@
-/**
- *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.
- */
-/*
- * remote_service_admin_impl.c
- *
- *  \date       Sep 30, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
-#ifndef ANDROID
-#include <ifaddrs.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <uuid/uuid.h>
-
-#include <curl/curl.h>
-
-#include "remote_service_admin_http_impl.h"
-#include "export_registration_impl.h"
-#include "import_registration_impl.h"
-#include "remote_constants.h"
-#include "constants.h"
-#include "utils.h"
-#include "bundle_context.h"
-#include "bundle.h"
-#include "service_reference.h"
-#include "service_registration.h"
-#include "log_helper.h"
-#include "log_service.h"
-#include "celix_threads.h"
-
-// defines how often the webserver is restarted (with an increased port number)
-#define MAX_NUMBER_OF_RESTARTS 	5
-
-struct post {
-    const char *readptr;
-    int size;
-};
-
-struct get {
-    char *writeptr;
-    int size;
-};
-
-static const char *data_response_headers =
-  "HTTP/1.1 200 OK\r\n"
-  "Cache: no-cache\r\n"
-  "Content-Type: application/json\r\n"
-  "\r\n";
-
-static const char *no_content_response_headers =
-  "HTTP/1.1 204 OK\r\n";
-
-// TODO do we need to specify a non-Amdatu specific configuration type?!
-static const char * const CONFIGURATION_TYPE = "org.amdatu.remote.admin.http";
-static const char * const ENDPOINT_URL = "org.amdatu.remote.admin.http.url";
-
-static const char *DEFAULT_PORT = "8888";
-static const char *DEFAULT_IP = "127.0.0.1";
-
-static const unsigned int DEFAULT_TIMEOUT = 0;
-
-static int remoteServiceAdmin_callback(struct mg_connection *conn);
-
-celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, export_registration_pt registration, service_reference_pt reference, char *interface);
-celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_pt admin, service_reference_pt reference, properties_pt endpointProperties, char *interface, endpoint_description_pt *description);
-
-static celix_status_t remoteServiceAdmin_getIpAdress(char* interface, char** ip);
-
-static size_t remoteServiceAdmin_readCallback(void *ptr, size_t size, size_t nmemb, void *userp);
-static size_t remoteServiceAdmin_write(void *contents, size_t size, size_t nmemb, void *userp);
-
-celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_service_admin_pt *admin) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*admin = calloc(1, sizeof(**admin));
-
-	if (!*admin) {
-		status = CELIX_ENOMEM;
-	} else {
-		unsigned int port_counter = 0;
-		const char *port = NULL;
-		const char *ip = NULL;
-		char *detectedIp = NULL;
-		(*admin)->context = context;
-		(*admin)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL);
-		(*admin)->importedServices = hashMap_create(NULL, NULL, NULL, NULL);
-
-		celixThreadMutex_create(&(*admin)->exportedServicesLock, NULL);
-		celixThreadMutex_create(&(*admin)->importedServicesLock, NULL);
-
-		if (logHelper_create(context, &(*admin)->loghelper) == CELIX_SUCCESS) {
-			logHelper_start((*admin)->loghelper);
-		}
-
-		bundleContext_getProperty(context, "RSA_PORT", &port);
-		if (port == NULL) {
-			port = (char *)DEFAULT_PORT;
-		}
-
-		bundleContext_getProperty(context, "RSA_IP", &ip);
-
-		#ifndef ANDROID
-		if (ip == NULL) {
-			const char *interface = NULL;
-
-			bundleContext_getProperty(context, "RSA_INTERFACE", &interface);
-			if ((interface != NULL) && (remoteServiceAdmin_getIpAdress((char*)interface, &detectedIp) != CELIX_SUCCESS)) {
-				logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: Could not retrieve IP adress for interface %s", interface);
-			}
-
-			if (ip == NULL) {
-				remoteServiceAdmin_getIpAdress(NULL, &detectedIp);
-			}
-
-			ip = detectedIp;
-		}
-		#endif
-
-		if (ip != NULL) {
-			logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Using %s for service annunciation", ip);
-			(*admin)->ip = strdup(ip);
-		}
-		else {
-			logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: No IP address for service annunciation set. Using %s", DEFAULT_IP);
-			(*admin)->ip = strdup((char*) DEFAULT_IP);
-		}
-
-		if (detectedIp != NULL) {
-			free(detectedIp);
-		}
-
-		// Prepare callbacks structure. We have only one callback, the rest are NULL.
-		struct mg_callbacks callbacks;
-		memset(&callbacks, 0, sizeof(callbacks));
-		callbacks.begin_request = remoteServiceAdmin_callback;
-
-		char newPort[10];
-		do {
-
-			const char *options[] = { "listening_ports", port, NULL};
-
-			(*admin)->ctx = mg_start(&callbacks, (*admin), options);
-
-			if ((*admin)->ctx != NULL) {
-				logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Start webserver: %s", port);
-				(*admin)->port = strdup(port);
-			}
-			else {
-		        char* endptr = (char*)port;
-		        int currentPort = strtol(port, &endptr, 10);
-
-				errno = 0;
-
-		        if (*endptr || errno != 0) {
-		            currentPort = strtol(DEFAULT_PORT, NULL, 10);
-		        }
-
-		        port_counter++;
-				snprintf(&newPort[0], 6,  "%d", (currentPort+1));
-
-				logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_ERROR, "Error while starting rsa server on port %s - retrying on port %s...", port, newPort);
-				port = newPort;
-			}
-		} while(((*admin)->ctx == NULL) && (port_counter < MAX_NUMBER_OF_RESTARTS));
-
-	}
-	return status;
-}
-
-
-celix_status_t remoteServiceAdmin_destroy(remote_service_admin_pt *admin)
-{
-    celix_status_t status = CELIX_SUCCESS;
-
-    free((*admin)->ip);
-    free((*admin)->port);
-    free(*admin);
-
-    *admin = NULL;
-
-    return status;
-}
-
-celix_status_t remoteServiceAdmin_stop(remote_service_admin_pt admin) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    celixThreadMutex_lock(&admin->exportedServicesLock);
-
-    array_list_pt exportRegistrationList = NULL;
-
-    arrayList_create(&exportRegistrationList);
-
-	hash_map_iterator_pt iter = hashMapIterator_create(admin->exportedServices);
-	while (hashMapIterator_hasNext(iter)) {
-		array_list_pt exports = hashMapIterator_nextValue(iter);
-		int i;
-
-		for (i = 0; i < arrayList_size(exports); i++) {
-			export_registration_pt export = arrayList_get(exports, i);
-			arrayList_add(exportRegistrationList, export);
-		}
-	}
-    hashMapIterator_destroy(iter);
-    celixThreadMutex_unlock(&admin->exportedServicesLock);
-
-	int i;
-
-	for (i = 0; i < arrayList_size(exportRegistrationList); i++) {
-		export_registration_pt export = arrayList_get(exportRegistrationList, i);
-		exportRegistration_stopTracking(export);
-	}
-
-	arrayList_destroy(exportRegistrationList);
-
-    celixThreadMutex_lock(&admin->importedServicesLock);
-
-    iter = hashMapIterator_create(admin->importedServices);
-    while (hashMapIterator_hasNext(iter))
-    {
-    	hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-
-    	import_registration_factory_pt importFactory = hashMapEntry_getValue(entry);
-
-        if (importFactory != NULL) {
-            int i;
-            for (i = 0; i < arrayList_size(importFactory->registrations); i++)
-            {
-                import_registration_pt importRegistration = arrayList_get(importFactory->registrations, i);
-
-                if (importFactory->trackedFactory != NULL)
-                {
-                    importFactory->trackedFactory->unregisterProxyService(importFactory->trackedFactory->factory, importRegistration->endpointDescription);
-                }
-            }
-
-            serviceTracker_close(importFactory->proxyFactoryTracker);
-            importRegistrationFactory_close(importFactory);
-
-            hashMapIterator_remove(iter);
-            importRegistrationFactory_destroy(&importFactory);
-            }
-    }
-    hashMapIterator_destroy(iter);
-    celixThreadMutex_unlock(&admin->importedServicesLock);
-
-	if (admin->ctx != NULL) {
-		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Stopping webserver...");
-		mg_stop(admin->ctx);
-		admin->ctx = NULL;
-	}
-
-	hashMap_destroy(admin->exportedServices, false, false);
-	hashMap_destroy(admin->importedServices, false, false);
-
-	logHelper_stop(admin->loghelper);
-	logHelper_destroy(&admin->loghelper);
-
-	return status;
-}
-
-/**
- * Request: http://host:port/services/{service}/{request}
- */
-//void *remoteServiceAdmin_callback(enum mg_event event, struct mg_connection *conn, const struct mg_request_info *request_info) {
-
-static int remoteServiceAdmin_callback(struct mg_connection *conn) {
-	int result = 0; // zero means: let civetweb handle it further, any non-zero value means it is handled by us...
-
-	const struct mg_request_info *request_info = mg_get_request_info(conn);
-	if (request_info->uri != NULL) {
-		remote_service_admin_pt rsa = request_info->user_data;
-
-
-		if (strncmp(request_info->uri, "/service/", 9) == 0 && strcmp("POST", request_info->request_method) == 0) {
-
-			// uri = /services/myservice/call
-			const char *uri = request_info->uri;
-			// rest = myservice/call
-
-			const char *rest = uri+9;
-			char *interfaceStart = strchr(rest, '/');
-			int pos = interfaceStart - rest;
-			char service[pos+1];
-			strncpy(service, rest, pos);
-			service[pos] = '\0';
-
-			celixThreadMutex_lock(&rsa->exportedServicesLock);
-
-			hash_map_iterator_pt iter = hashMapIterator_create(rsa->exportedServices);
-			while (hashMapIterator_hasNext(iter)) {
-				hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-				array_list_pt exports = hashMapEntry_getValue(entry);
-				int expIt = 0;
-				for (expIt = 0; expIt < arrayList_size(exports); expIt++) {
-					export_registration_pt export = arrayList_get(exports, expIt);
-					unsigned long serviceId = strtoul(service,NULL,10);
-					if (serviceId == export->endpointDescription->serviceId && export->endpoint != NULL) {
-						uint64_t datalength = request_info->content_length;
-						char* data = malloc(datalength + 1);
-						mg_read(conn, data, datalength);
-						data[datalength] = '\0';
-
-						char *response = NULL;
-						export->endpoint->handleRequest(export->endpoint->endpoint, data, &response);
-
-						if (response != NULL) {
-						    mg_write(conn, data_response_headers, strlen(data_response_headers));
-							mg_write(conn, response, strlen(response));
-
-							free(response);
-						} else {
-						    mg_write(conn, no_content_response_headers, strlen(no_content_response_headers));
-						}
-                        result = 1;
-
-						free(data);
-					}
-				}
-			}
-			celixThreadMutex_unlock(&rsa->exportedServicesLock);
-
-            hashMapIterator_destroy(iter);
-		}
-	}
-
-	return result;
-}
-
-celix_status_t remoteServiceAdmin_handleRequest(remote_service_admin_pt rsa, char *service, char *data, char **reply) {
-	celixThreadMutex_lock(&rsa->exportedServicesLock);
-
-	hash_map_iterator_pt iter = hashMapIterator_create(rsa->exportedServices);
-	while (hashMapIterator_hasNext(iter)) {
-		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-		array_list_pt exports = hashMapEntry_getValue(entry);
-		int expIt = 0;
-		for (expIt = 0; expIt < arrayList_size(exports); expIt++) {
-			export_registration_pt export = arrayList_get(exports, expIt);
-			if (strcmp(service, export->endpointDescription->service) == 0) {
-				export->endpoint->handleRequest(export->endpoint->endpoint, data, reply);
-			}
-		}
-	}
-    hashMapIterator_destroy(iter);
-
-	celixThreadMutex_unlock(&rsa->exportedServicesLock);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, char *serviceId, properties_pt properties, array_list_pt *registrations) {
-	celix_status_t status = CELIX_SUCCESS;
-	arrayList_create(registrations);
-	array_list_pt references = NULL;
-	service_reference_pt reference = NULL;
-	char filter [256];
-
-	snprintf(filter, 256, "(%s=%s)", (char *)OSGI_FRAMEWORK_SERVICE_ID, serviceId);
-
-	bundleContext_getServiceReferences(admin->context, NULL, filter, &references);
-
-	if(references!=NULL){
-		if (arrayList_size(references) >= 1) {
-			reference = arrayList_get(references, 0);
-		}
-		arrayList_destroy(references);
-    }
-
-	if (reference == NULL) {
-		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "ERROR: expected a reference for service id %s.", serviceId);
-		return CELIX_ILLEGAL_STATE;
-	}
-
-	const char *exportsProp = NULL;
-	const char *providedProp = NULL;
-	serviceReference_getProperty(reference, OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exportsProp);
-	serviceReference_getProperty(reference, OSGI_FRAMEWORK_OBJECTCLASS, &providedProp);
-	
-	if (exportsProp == NULL || providedProp == NULL) {
-		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: No Services to export.");
-	} else {
-		char *exports = strndup(exportsProp, 1024*10);
-		char *provided = strndup(providedProp, 1024*10);
-
-		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Export services (%s)", exports);
-		array_list_pt interfaces = NULL;
-		arrayList_create(&interfaces);
-		if (strcmp(utils_stringTrim(exports), "*") == 0) {
-			char *save_ptr = NULL;
-			char *interface = strtok_r(provided, ",", &save_ptr);
-			while (interface != NULL) {
-				arrayList_add(interfaces, utils_stringTrim(interface));
-				interface = strtok_r(NULL, ",", &save_ptr);
-			}
-		} else {
-			char *provided_save_ptr = NULL;
-			char *pinterface = strtok_r(provided, ",", &provided_save_ptr);
-			while (pinterface != NULL) {
-				char *exports_save_ptr = NULL;
-				char *einterface = strtok_r(exports, ",", &exports_save_ptr);
-				while (einterface != NULL) {
-					if (strcmp(einterface, pinterface) == 0) {
-						arrayList_add(interfaces, einterface);
-					}
-					einterface = strtok_r(NULL, ",", &exports_save_ptr);
-				}
-				pinterface = strtok_r(NULL, ",", &provided_save_ptr);
-			}
-		}
-
-		if (arrayList_size(interfaces) != 0) {
-			int iter = 0;
-			for (iter = 0; iter < arrayList_size(interfaces); iter++) {
-				char *interface = arrayList_get(interfaces, iter);
-				export_registration_pt registration = NULL;
-
-				exportRegistration_create(admin->loghelper, reference, NULL, admin, admin->context, &registration);
-				arrayList_add(*registrations, registration);
-
-				remoteServiceAdmin_installEndpoint(admin, registration, reference, interface);
-				exportRegistration_open(registration);
-				exportRegistration_startTracking(registration);
-			}
-
-			celixThreadMutex_lock(&admin->exportedServicesLock);
-			hashMap_put(admin->exportedServices, reference, *registrations);
-			celixThreadMutex_unlock(&admin->exportedServicesLock);
-
-		}
-		arrayList_destroy(interfaces);
-		free(exports);
-		free(provided);
-	}
-
-	
-
-	return status;
-}
-
-celix_status_t remoteServiceAdmin_removeExportedService(remote_service_admin_pt admin, export_registration_pt registration) {
-    celix_status_t status;
-    export_reference_pt ref = NULL;
-
-    logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA_HTTP: Removing exported service");
-
-    status = exportRegistration_getExportReference(registration, &ref);
-
-    if (status == CELIX_SUCCESS && ref != NULL) {
-    	service_reference_pt servRef;
-        celixThreadMutex_lock(&admin->exportedServicesLock);
-    	exportReference_getExportedService(ref, &servRef);
-
-    	array_list_pt registrations = (array_list_pt)hashMap_remove(admin->exportedServices, servRef);
-    	if(registrations!=NULL){
-    		arrayList_destroy(registrations);
-    	}
-
-        exportRegistration_close(registration);
-        exportRegistration_destroy(&registration);
-
-        celixThreadMutex_unlock(&admin->exportedServicesLock);
-
-        free(ref);
-
-    } else {
-    	 logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Cannot find reference for registration");
-    }
-
-    return status;
-}
-
-celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, export_registration_pt registration, service_reference_pt reference, char *interface) {
-	celix_status_t status = CELIX_SUCCESS;
-	properties_pt endpointProperties = properties_create();
-
-
-	unsigned int size = 0;
-    char **keys;
-
-    serviceReference_getPropertyKeys(reference, &keys, &size);
-    for (int i = 0; i < size; i++) {
-        char *key = keys[i];
-        const char *value = NULL;
-
-        if (serviceReference_getProperty(reference, key, &value) == CELIX_SUCCESS
-        		&& strcmp(key, (char*) OSGI_RSA_SERVICE_EXPORTED_INTERFACES) != 0
-        		&& strcmp(key, (char*) OSGI_FRAMEWORK_OBJECTCLASS) != 0) {
-        	properties_set(endpointProperties, key, value);
-        }
-	}
-
-	hash_map_entry_pt entry = hashMap_getEntry(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID);
-
-	char* key = hashMapEntry_getKey(entry);
-	char *serviceId = (char *) hashMap_remove(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID);
-	const char *uuid = NULL;
-
-	char buf[512];
-	snprintf(buf, 512,  "/service/%s/%s", serviceId, interface);
-
-	char url[1024];
-	snprintf(url, 1024, "http://%s:%s%s", admin->ip, admin->port, buf);
-
-	uuid_t endpoint_uid;
-	uuid_generate(endpoint_uid);
-	char endpoint_uuid[37];
-	uuid_unparse_lower(endpoint_uid, endpoint_uuid);
-
-	bundleContext_getProperty(admin->context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid);
-	properties_set(endpointProperties, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID, uuid);
-	properties_set(endpointProperties, (char*) OSGI_FRAMEWORK_OBJECTCLASS, interface);
-	properties_set(endpointProperties, (char*) OSGI_RSA_ENDPOINT_SERVICE_ID, serviceId);
-	properties_set(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID, endpoint_uuid);
-	properties_set(endpointProperties, (char*) OSGI_RSA_SERVICE_IMPORTED, "true");
-    properties_set(endpointProperties, (char*) OSGI_RSA_SERVICE_IMPORTED_CONFIGS, (char*) CONFIGURATION_TYPE);
-    properties_set(endpointProperties, (char*) ENDPOINT_URL, url);
-
-	endpoint_description_pt endpointDescription = NULL;
-	remoteServiceAdmin_createEndpointDescription(admin, reference, endpointProperties, interface, &endpointDescription);
-	exportRegistration_setEndpointDescription(registration, endpointDescription);
-
-	free(key);
-	free(serviceId);
-	free(keys);
-
-	return status;
-}
-#ifndef ANDROID
-static celix_status_t remoteServiceAdmin_getIpAdress(char* interface, char** ip) {
-	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
-
-	struct ifaddrs *ifaddr, *ifa;
-
-    if (getifaddrs(&ifaddr) != -1)
-    {
-		for (ifa = ifaddr; ifa != NULL && status != CELIX_SUCCESS; ifa = ifa->ifa_next)
-		{
-		    char host[NI_MAXHOST];
-
-			if (ifa->ifa_addr == NULL)
-				continue;
-
-			if ((getnameinfo(ifa->ifa_addr,sizeof(struct sockaddr_in), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) {
-				if (interface == NULL) {
-					*ip = strdup(host);
-					status = CELIX_SUCCESS;
-				}
-				else if (strcmp(ifa->ifa_name, interface) == 0) {
-					*ip = strdup(host);
-					status = CELIX_SUCCESS;
-				}
-			}
-		}
-
-		freeifaddrs(ifaddr);
-    }
-
-    return status;
-}
-#endif
-
-
-celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_pt admin, service_reference_pt reference,
-		properties_pt endpointProperties, char *interface, endpoint_description_pt *description) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*description = calloc(1, sizeof(**description));
-	if (!*description) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*description)->id = (char*)properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID);
-		const char *serviceId = NULL;
-		serviceReference_getProperty(reference, (char*)OSGI_FRAMEWORK_SERVICE_ID, &serviceId);
-		(*description)->serviceId = strtoull(serviceId, NULL, 0);
-		(*description)->frameworkUUID = (char*)properties_get(endpointProperties, OSGI_RSA_ENDPOINT_FRAMEWORK_UUID);
-		(*description)->service = strndup(interface, 1024*10);
-		(*description)->properties = endpointProperties;
-	}
-
-	return status;
-}
-
-
-celix_status_t remoteServiceAdmin_destroyEndpointDescription(endpoint_description_pt *description)
-{
-	celix_status_t status = CELIX_SUCCESS;
-
-	properties_destroy((*description)->properties);
-	free((*description)->service);
-	free(*description);
-
-	return status;
-}
-
-
-celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_pt admin, array_list_pt *services) {
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_pt admin, array_list_pt *services) {
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-
-
-celix_status_t remoteServiceAdmin_importService(remote_service_admin_pt admin, endpoint_description_pt endpointDescription, import_registration_pt *registration) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Import service %s", endpointDescription->service);
-
-	celixThreadMutex_lock(&admin->importedServicesLock);
-
-   import_registration_factory_pt registration_factory = (import_registration_factory_pt) hashMap_get(admin->importedServices, endpointDescription->service);
-
-	// check whether we already have a registration_factory registered in the hashmap
-	if (registration_factory == NULL)
-	{
-		status = importRegistrationFactory_install(admin->loghelper, endpointDescription->service, admin->context, &registration_factory);
-		if (status == CELIX_SUCCESS) {
-		    hashMap_put(admin->importedServices, endpointDescription->service, registration_factory);
-		}
-	}
-
-	 // factory available
-	if (status != CELIX_SUCCESS || (registration_factory->trackedFactory == NULL))
-	{
-		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: no proxyFactory available.");
-		if (status == CELIX_SUCCESS) {
-			status = CELIX_SERVICE_EXCEPTION;
-		}
-	}
-	else
-	{
-		// we create an importRegistration per imported service
-		importRegistration_create(endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send, admin->context, registration);
-		registration_factory->trackedFactory->registerProxyService(registration_factory->trackedFactory->factory,  endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send);
-
-		arrayList_add(registration_factory->registrations, *registration);
-	}
-
-    celixThreadMutex_unlock(&admin->importedServicesLock);
-
-
-	return status;
-}
-
-
-celix_status_t remoteServiceAdmin_removeImportedService(remote_service_admin_pt admin, import_registration_pt registration) {
-	celix_status_t status = CELIX_SUCCESS;
-	endpoint_description_pt endpointDescription = (endpoint_description_pt) registration->endpointDescription;
-	import_registration_factory_pt registration_factory = NULL;
-
-    celixThreadMutex_lock(&admin->importedServicesLock);
-
-    registration_factory = (import_registration_factory_pt) hashMap_get(admin->importedServices, endpointDescription->service);
-
-    // factory available
-    if (registration_factory == NULL)
-    {
-    	logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "RSA: Error while retrieving registration factory for imported service %s", endpointDescription->service);
-    }
-    else
-    {
-        if (registration_factory->trackedFactory != NULL) {
-            registration_factory->trackedFactory->unregisterProxyService(registration_factory->trackedFactory->factory, endpointDescription);
-        }
-		arrayList_removeElement(registration_factory->registrations, registration);
-		importRegistration_destroy(registration);
-
-		if (arrayList_isEmpty(registration_factory->registrations))
-		{
-			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: closing proxy.");
-
-			serviceTracker_close(registration_factory->proxyFactoryTracker);
-			importRegistrationFactory_close(registration_factory);
-
-			hashMap_remove(admin->importedServices, endpointDescription->service);
-
-			importRegistrationFactory_destroy(&registration_factory);
-		}
-    }
-
-    celixThreadMutex_unlock(&admin->importedServicesLock);
-
-	return status;
-}
-
-
-celix_status_t remoteServiceAdmin_send(remote_service_admin_pt rsa, endpoint_description_pt endpointDescription, char *request, char **reply, int* replyStatus) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	struct post post;
-	struct get get;
-	char url[256];
-	if (request != NULL) {
-
-
-		post.readptr = request;
-		post.size = strlen(request);
-
-		get.size = 0;
-		get.writeptr = malloc(1);
-
-		const char* serviceUrl = properties_get(endpointDescription->properties, ENDPOINT_URL);
-		if (serviceUrl != NULL) {
-			snprintf(url, 256, "%s", serviceUrl);
-		} else {
-			status = CELIX_BUNDLE_EXCEPTION;
-			logHelper_log(rsa->loghelper, OSGI_LOGSERVICE_INFO, "Endpoint Description does not contain mandatory property '%s'", ENDPOINT_URL);
-		}
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	// assume the default timeout
-	int timeout = DEFAULT_TIMEOUT;
-
-	if (status == CELIX_SUCCESS) {
-		const char *timeoutStr = NULL;
-
-		// Check if the endpoint has a timeout, if so, use it.
-		timeoutStr = (char*)properties_get(endpointDescription->properties, OSGI_RSA_REMOTE_PROXY_TIMEOUT);
-		if (timeoutStr == NULL) {
-			// If not, get the global variable and use that one.
-			status = bundleContext_getProperty(rsa->context, OSGI_RSA_REMOTE_PROXY_TIMEOUT, &timeoutStr);
-		}
-
-		// Update timeout if a property is used to set it.
-		if (timeoutStr != NULL) {
-			timeout = atoi(timeoutStr);
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-
-		CURL *curl;
-		CURLcode res;
-
-		curl = curl_easy_init();
-		if (!curl) {
-			status = CELIX_ILLEGAL_STATE;
-		} else {
-		    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-			curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
-			curl_easy_setopt(curl, CURLOPT_URL, url);
-			curl_easy_setopt(curl, CURLOPT_POST, 1L);
-			curl_easy_setopt(curl, CURLOPT_READFUNCTION, remoteServiceAdmin_readCallback);
-			curl_easy_setopt(curl, CURLOPT_READDATA, &post);
-			curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, remoteServiceAdmin_write);
-			curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &get);
-			curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (curl_off_t) post.size);
-			res = curl_easy_perform(curl);
-			curl_easy_cleanup(curl);
-
-			*reply = get.writeptr;
-			*replyStatus = res;
-		}
-	}
-
-    return status;
-}
-
-static size_t remoteServiceAdmin_readCallback(void *ptr, size_t size, size_t nmemb, void *userp) {
-    struct post *post = userp;
-
-    if (post->size) {
-        *(char *) ptr = post->readptr[0];
-        post->readptr++;
-        post->size--;
-        return 1;
-    }
-
-    return 0;
-}
-
-static size_t remoteServiceAdmin_write(void *contents, size_t size, size_t nmemb, void *userp) {
-  size_t realsize = size * nmemb;
-  struct get *mem = (struct get *)userp;
-
-  mem->writeptr = realloc(mem->writeptr, mem->size + realsize + 1);
-  if (mem->writeptr == NULL) {
-    /* out of memory! */
-	printf("not enough memory (realloc returned NULL)");
-    exit(EXIT_FAILURE);
-  }
-
-  memcpy(&(mem->writeptr[mem->size]), contents, realsize);
-  mem->size += realsize;
-  mem->writeptr[mem->size] = 0;
-
-  return realsize;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_http/private/test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/test/CMakeLists.txt b/remote_services/remote_service_admin_http/private/test/CMakeLists.txt
deleted file mode 100644
index a199bc2..0000000
--- a/remote_services/remote_service_admin_http/private/test/CMakeLists.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-# 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.
-
-include_directories(
-    ${PROJECT_SOURCE_DIR}/framework/public/include
-    ${PROJECT_SOURCE_DIR}/utils/public/include
-    ${PROJECT_SOURCE_DIR}/utils/public/include
-    ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include
-    ${PROJECT_SOURCE_DIR}/remote_services/examples/calculator_service/public/include
-    bundle
-)
-
-
-SET(CMAKE_SKIP_BUILD_RPATH  FALSE) #TODO needed?
-SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) #TODO needed?
-SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/framework" "${PROJECT_BINARY_DIR}/utils")
-
-add_executable(test_rsa_http
-    run_tests.cpp
-    rsa_client_server_tests.cpp
-
-    ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
-)
-target_link_libraries(test_rsa_http celix_framework celix_utils ${CURL_LIBRARIES} ${CPPUTEST_LIBRARY})
-
-get_property(rsa_bundle_file TARGET remote_service_admin_http PROPERTY BUNDLE_FILE)
-get_property(calc_bundle_file TARGET calculator PROPERTY BUNDLE_FILE)
-get_property(calculator_shell_bundle_file TARGET calculator_shell PROPERTY BUNDLE_FILE)
-get_property(discovery_configured_bundle_file TARGET discovery_configured PROPERTY BUNDLE_FILE)
-get_property(topology_manager_bundle_file TARGET topology_manager PROPERTY BUNDLE_FILE)
-get_property(calc_proxy_bundle_file TARGET org.apache.celix.calc.api.Calculator_proxy PROPERTY BUNDLE_FILE)
-get_property(calc_endpoint_bundle_file TARGET  org.apache.celix.calc.api.Calculator_endpoint PROPERTY BUNDLE_FILE)
-
-get_filename_component(client_endpoints ${calc_proxy_bundle_file} PATH)
-get_filename_component(server_endpoints ${calc_endpoint_bundle_file} PATH)
-
-configure_file(client.properties.in client.properties @ONLY)
-configure_file(server.properties.in server.properties @ONLY)
-
-add_dependencies(test_rsa_http remote_service_admin_http calculator org.apache.celix.calc.api.Calculator_proxy org.apache.celix.calc.api.Calculator_endpoint)
- 
-add_test(NAME run_test_rsa_http COMMAND test_rsa_http)
-SETUP_TARGET_FOR_COVERAGE(test_rsa_http_cov test_rsa_http ${CMAKE_BINARY_DIR}/coverage/test_rsa_http/test_rsa_http)
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/remote_services/remote_service_admin_http/private/test/client.properties.in
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/test/client.properties.in b/remote_services/remote_service_admin_http/private/test/client.properties.in
deleted file mode 100644
index b923a1e..0000000
--- a/remote_services/remote_service_admin_http/private/test/client.properties.in
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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.
-
-cosgi.auto.start.1=@rsa_bundle_file@ @calculator_shell_bundle_file@ @discovery_configured_bundle_file@ @topology_manager_bundle_file@ @tst_bundle_file@
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-ENDPOINTS=@client_endpoints@
-RSA_PORT=50881
-DISCOVERY_CFG_SERVER_PORT=50991
-DISCOVERY_CFG_POLL_ENDPOINTS=http://127.0.0.1:50992/org.apache.celix.discovery.configured
-org.osgi.framework.storage.clean=onFirstInit
-org.osgi.framework.storage=.cacheClient
-DISCOVERY_CFG_POLL_INTERVAL=1
\ No newline at end of file


[35/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/include/base_driver_device.h
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/include/base_driver_device.h b/device_access/example/base_driver/include/base_driver_device.h
new file mode 100644
index 0000000..78c4f46
--- /dev/null
+++ b/device_access/example/base_driver/include/base_driver_device.h
@@ -0,0 +1,44 @@
+/**
+ *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.
+ */
+/*
+ * base_driver_device.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef BASE_DRIVER_DEVICE_H_
+#define BASE_DRIVER_DEVICE_H_
+
+#include "device.h"
+
+#define BASE_DRIVER_SERVICE_NAME "base_driver_device_service"
+#define BASE_DRIVER_DEVICE_CATEGORY "char"
+
+typedef struct base_driver_device *base_driver_device_pt;
+
+struct base_driver_device_service {
+	struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/
+	base_driver_device_pt baseDriverDevice;
+	celix_status_t (*getNextChar)(base_driver_device_pt baseDriverDevice, char *c);
+};
+
+typedef struct base_driver_device_service * base_driver_device_service_pt;
+
+#endif /* BASE_DRIVER_DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/private/include/base_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/private/include/base_driver_private.h b/device_access/example/base_driver/private/include/base_driver_private.h
deleted file mode 100644
index 3ee5814..0000000
--- a/device_access/example/base_driver/private/include/base_driver_private.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *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.
- */
-/*
- * base_driver_private.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef BASE_DRIVER_PRIVATE_H_
-#define BASE_DRIVER_PRIVATE_H_
-
-#include "base_driver_device.h"
-
-celix_status_t baseDriver_create(base_driver_device_pt *service);
-celix_status_t baseDriver_createService(base_driver_device_pt device, base_driver_device_service_pt *service);
-
-celix_status_t baseDriver_noDriverFound(device_pt device);
-
-celix_status_t baseDriver_getNextChar(base_driver_device_pt service, char *c);
-
-celix_status_t baseDriver_destroy(base_driver_device_pt device);
-celix_status_t baseDriver_destroyService(base_driver_device_service_pt service);
-
-#endif /* BASE_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/private/src/activator.c b/device_access/example/base_driver/private/src/activator.c
deleted file mode 100644
index a6b9d62..0000000
--- a/device_access/example/base_driver/private/src/activator.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include <celix_errno.h>
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <device.h>
-
-#include "base_driver_private.h"
-#include "base_driver_device.h"
-
-struct base_driver_bundle_instance {
-	bundle_context_pt context;
-	array_list_pt serviceRegistrations;
-};
-
-typedef struct base_driver_bundle_instance *base_driver_bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	printf("BASE_DRIVER: creating bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-		base_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
-		if (instance != NULL) {
-			instance->context = context;
-			status = arrayList_create(&instance->serviceRegistrations);
-			if (status == CELIX_SUCCESS) {
-				(*userData) = instance;
-			}
-		} else {
-			status = CELIX_ENOMEM;
-		}
-	return status;
-}
-
-static celix_status_t bundleActivator_registerBaseDriverDevice(base_driver_bundle_instance_pt bi, char *serial) {
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_device_pt device = NULL;
-	base_driver_device_service_pt service = NULL;
-	status = baseDriver_create(&device);
-	if (status == CELIX_SUCCESS) {
-		status = baseDriver_createService(device, &service);
-		if (status == CELIX_SUCCESS) {
-			properties_pt props = properties_create();
-			properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, BASE_DRIVER_DEVICE_CATEGORY);
-			properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
-			service_registration_pt service_registration = NULL;
-			status = bundleContext_registerService(bi->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &service_registration);
-			if (status == CELIX_SUCCESS) {
-				arrayList_add(bi->serviceRegistrations, service_registration);
-			}
-			else{
-				properties_destroy(props);
-			}
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		printf("BASE_DRIVER: Successfully registered device service with serial %s.\n", serial);
-	} else {
-		char error[256];
-		printf("BASE_DRIVER: Unsuccessfully registered device service with serial %s. Got error: %s\n",
-				serial, celix_strerror(status, error, 256));
-		if(service != NULL){
-			baseDriver_destroyService(service);
-		}
-		if(device != NULL){
-			baseDriver_destroy(device);
-		}
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	printf("BASE_DRIVER: starting bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_bundle_instance_pt bundleInstance = userData;
-	status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0001");
-//	if (status == CELIX_SUCCESS) {
-//		status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0002");
-//	}
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	printf("BASE_DRIVER: stopping bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_bundle_instance_pt bundleInstance = userData;
-
-	array_list_iterator_pt iterator = arrayListIterator_create(bundleInstance->serviceRegistrations);
-	while (arrayListIterator_hasNext(iterator)) {
-		service_registration_pt reg = arrayListIterator_next(iterator);
-		printf("BASE_DRIVER: unregistering service\n");
-		celix_status_t unregStatus = serviceRegistration_unregister(reg);
-		if (unregStatus != CELIX_SUCCESS) {
-			char error[256];
-			status = CELIX_ILLEGAL_STATE;
-			fprintf(stderr, "Cannot unregister service. Got error %s\n", celix_strerror(unregStatus, error, 256));
-		} else {
-			printf("BASE_DRIVER: unregistered base device service\n");
-		}
-	}
-	arrayListIterator_destroy(iterator);
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	printf("BASE_DRIVER: destroying bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_bundle_instance_pt bundleInstance = userData;
-
-	arrayList_destroy(bundleInstance->serviceRegistrations);
-	return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/private/src/base_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/private/src/base_driver.c b/device_access/example/base_driver/private/src/base_driver.c
deleted file mode 100644
index a48c7de..0000000
--- a/device_access/example/base_driver/private/src/base_driver.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- *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.
- */
-/*
- * base_driver.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <celix_errno.h>
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <device.h>
-
-#include "base_driver_device.h"
-#include "base_driver_private.h"
-
-static const char * INPUT_STRING = "Lorem ipsum dolor sit amet consectetur adipiscing elit ";
-
-struct device {
-	/*NOTE: for this example we use a empty device structure*/
-};
-
-struct base_driver_device {
-	device_pt device;
-	char *input;
-	int inputLength;
-	int currentChar;
-};
-
-celix_status_t baseDriver_noDriverFound(device_pt device) {
-	printf("BASE_DRIVER: No driver found\n");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t baseDriver_create(base_driver_device_pt *baseDriverDevice) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*baseDriverDevice) = calloc(1, sizeof(struct base_driver_device));
-	if (*baseDriverDevice != NULL) {
-		(*baseDriverDevice)->currentChar = 0;
-		(*baseDriverDevice)->input = (char *)INPUT_STRING;
-		(*baseDriverDevice)->inputLength=strlen(INPUT_STRING);
-		(*baseDriverDevice)->device = calloc(1, sizeof(*(*baseDriverDevice)->device));
-		if ((*baseDriverDevice)->device == NULL) {
-			status = CELIX_ENOMEM;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t baseDriver_createService(base_driver_device_pt baseDriverDevice, base_driver_device_service_pt *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*service) = calloc(1, sizeof(struct base_driver_device_service));
-	if ((*service) != NULL) {
-		(*service)->deviceService.noDriverFound = baseDriver_noDriverFound;
-		(*service)->deviceService.device = baseDriverDevice->device;
-		(*service)->getNextChar=baseDriver_getNextChar;
-		(*service)->baseDriverDevice = baseDriverDevice;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t baseDriver_getNextChar(base_driver_device_pt device, char *c) {
-	(*c) = device->input[device->currentChar];
-	device->currentChar+=1;
-	if (device->currentChar >= device->inputLength) {
-		device->currentChar = 0;
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t baseDriver_destroy(base_driver_device_pt device){
-	if(device != NULL){
-		if(device->device != NULL){
-			free(device->device);
-		}
-		free(device);
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t baseDriver_destroyService(base_driver_device_service_pt service){
-	if(service != NULL){
-		free(service);
-	}
-
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/public/include/base_driver_device.h
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/public/include/base_driver_device.h b/device_access/example/base_driver/public/include/base_driver_device.h
deleted file mode 100644
index 78c4f46..0000000
--- a/device_access/example/base_driver/public/include/base_driver_device.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *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.
- */
-/*
- * base_driver_device.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef BASE_DRIVER_DEVICE_H_
-#define BASE_DRIVER_DEVICE_H_
-
-#include "device.h"
-
-#define BASE_DRIVER_SERVICE_NAME "base_driver_device_service"
-#define BASE_DRIVER_DEVICE_CATEGORY "char"
-
-typedef struct base_driver_device *base_driver_device_pt;
-
-struct base_driver_device_service {
-	struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/
-	base_driver_device_pt baseDriverDevice;
-	celix_status_t (*getNextChar)(base_driver_device_pt baseDriverDevice, char *c);
-};
-
-typedef struct base_driver_device_service * base_driver_device_service_pt;
-
-#endif /* BASE_DRIVER_DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/src/activator.c b/device_access/example/base_driver/src/activator.c
new file mode 100644
index 0000000..a6b9d62
--- /dev/null
+++ b/device_access/example/base_driver/src/activator.c
@@ -0,0 +1,140 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include <celix_errno.h>
+#include <bundle_activator.h>
+#include <bundle_context.h>
+#include <celixbool.h>
+#include <device.h>
+
+#include "base_driver_private.h"
+#include "base_driver_device.h"
+
+struct base_driver_bundle_instance {
+	bundle_context_pt context;
+	array_list_pt serviceRegistrations;
+};
+
+typedef struct base_driver_bundle_instance *base_driver_bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	printf("BASE_DRIVER: creating bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+		base_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
+		if (instance != NULL) {
+			instance->context = context;
+			status = arrayList_create(&instance->serviceRegistrations);
+			if (status == CELIX_SUCCESS) {
+				(*userData) = instance;
+			}
+		} else {
+			status = CELIX_ENOMEM;
+		}
+	return status;
+}
+
+static celix_status_t bundleActivator_registerBaseDriverDevice(base_driver_bundle_instance_pt bi, char *serial) {
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_device_pt device = NULL;
+	base_driver_device_service_pt service = NULL;
+	status = baseDriver_create(&device);
+	if (status == CELIX_SUCCESS) {
+		status = baseDriver_createService(device, &service);
+		if (status == CELIX_SUCCESS) {
+			properties_pt props = properties_create();
+			properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, BASE_DRIVER_DEVICE_CATEGORY);
+			properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
+			service_registration_pt service_registration = NULL;
+			status = bundleContext_registerService(bi->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &service_registration);
+			if (status == CELIX_SUCCESS) {
+				arrayList_add(bi->serviceRegistrations, service_registration);
+			}
+			else{
+				properties_destroy(props);
+			}
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		printf("BASE_DRIVER: Successfully registered device service with serial %s.\n", serial);
+	} else {
+		char error[256];
+		printf("BASE_DRIVER: Unsuccessfully registered device service with serial %s. Got error: %s\n",
+				serial, celix_strerror(status, error, 256));
+		if(service != NULL){
+			baseDriver_destroyService(service);
+		}
+		if(device != NULL){
+			baseDriver_destroy(device);
+		}
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	printf("BASE_DRIVER: starting bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_bundle_instance_pt bundleInstance = userData;
+	status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0001");
+//	if (status == CELIX_SUCCESS) {
+//		status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0002");
+//	}
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	printf("BASE_DRIVER: stopping bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_bundle_instance_pt bundleInstance = userData;
+
+	array_list_iterator_pt iterator = arrayListIterator_create(bundleInstance->serviceRegistrations);
+	while (arrayListIterator_hasNext(iterator)) {
+		service_registration_pt reg = arrayListIterator_next(iterator);
+		printf("BASE_DRIVER: unregistering service\n");
+		celix_status_t unregStatus = serviceRegistration_unregister(reg);
+		if (unregStatus != CELIX_SUCCESS) {
+			char error[256];
+			status = CELIX_ILLEGAL_STATE;
+			fprintf(stderr, "Cannot unregister service. Got error %s\n", celix_strerror(unregStatus, error, 256));
+		} else {
+			printf("BASE_DRIVER: unregistered base device service\n");
+		}
+	}
+	arrayListIterator_destroy(iterator);
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	printf("BASE_DRIVER: destroying bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_bundle_instance_pt bundleInstance = userData;
+
+	arrayList_destroy(bundleInstance->serviceRegistrations);
+	return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/src/base_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/src/base_driver.c b/device_access/example/base_driver/src/base_driver.c
new file mode 100644
index 0000000..a48c7de
--- /dev/null
+++ b/device_access/example/base_driver/src/base_driver.c
@@ -0,0 +1,111 @@
+/**
+ *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.
+ */
+/*
+ * base_driver.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <celix_errno.h>
+#include <bundle_activator.h>
+#include <bundle_context.h>
+#include <celixbool.h>
+#include <device.h>
+
+#include "base_driver_device.h"
+#include "base_driver_private.h"
+
+static const char * INPUT_STRING = "Lorem ipsum dolor sit amet consectetur adipiscing elit ";
+
+struct device {
+	/*NOTE: for this example we use a empty device structure*/
+};
+
+struct base_driver_device {
+	device_pt device;
+	char *input;
+	int inputLength;
+	int currentChar;
+};
+
+celix_status_t baseDriver_noDriverFound(device_pt device) {
+	printf("BASE_DRIVER: No driver found\n");
+	return CELIX_SUCCESS;
+}
+
+celix_status_t baseDriver_create(base_driver_device_pt *baseDriverDevice) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*baseDriverDevice) = calloc(1, sizeof(struct base_driver_device));
+	if (*baseDriverDevice != NULL) {
+		(*baseDriverDevice)->currentChar = 0;
+		(*baseDriverDevice)->input = (char *)INPUT_STRING;
+		(*baseDriverDevice)->inputLength=strlen(INPUT_STRING);
+		(*baseDriverDevice)->device = calloc(1, sizeof(*(*baseDriverDevice)->device));
+		if ((*baseDriverDevice)->device == NULL) {
+			status = CELIX_ENOMEM;
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t baseDriver_createService(base_driver_device_pt baseDriverDevice, base_driver_device_service_pt *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*service) = calloc(1, sizeof(struct base_driver_device_service));
+	if ((*service) != NULL) {
+		(*service)->deviceService.noDriverFound = baseDriver_noDriverFound;
+		(*service)->deviceService.device = baseDriverDevice->device;
+		(*service)->getNextChar=baseDriver_getNextChar;
+		(*service)->baseDriverDevice = baseDriverDevice;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t baseDriver_getNextChar(base_driver_device_pt device, char *c) {
+	(*c) = device->input[device->currentChar];
+	device->currentChar+=1;
+	if (device->currentChar >= device->inputLength) {
+		device->currentChar = 0;
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t baseDriver_destroy(base_driver_device_pt device){
+	if(device != NULL){
+		if(device->device != NULL){
+			free(device->device);
+		}
+		free(device);
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t baseDriver_destroyService(base_driver_device_service_pt service){
+	if(service != NULL){
+		free(service);
+	}
+
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/src/base_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/src/base_driver_private.h b/device_access/example/base_driver/src/base_driver_private.h
new file mode 100644
index 0000000..3ee5814
--- /dev/null
+++ b/device_access/example/base_driver/src/base_driver_private.h
@@ -0,0 +1,41 @@
+/**
+ *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.
+ */
+/*
+ * base_driver_private.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef BASE_DRIVER_PRIVATE_H_
+#define BASE_DRIVER_PRIVATE_H_
+
+#include "base_driver_device.h"
+
+celix_status_t baseDriver_create(base_driver_device_pt *service);
+celix_status_t baseDriver_createService(base_driver_device_pt device, base_driver_device_service_pt *service);
+
+celix_status_t baseDriver_noDriverFound(device_pt device);
+
+celix_status_t baseDriver_getNextChar(base_driver_device_pt service, char *c);
+
+celix_status_t baseDriver_destroy(base_driver_device_pt device);
+celix_status_t baseDriver_destroyService(base_driver_device_service_pt service);
+
+#endif /* BASE_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/CMakeLists.txt b/device_access/example/consuming_driver/CMakeLists.txt
index 061d350..a9a9281 100644
--- a/device_access/example/consuming_driver/CMakeLists.txt
+++ b/device_access/example/consuming_driver/CMakeLists.txt
@@ -20,14 +20,10 @@ add_bundle(word_consumingdriver
  	VERSION "0.0.1"
  	NAME "Apache Celix Device Access Word Consuming Driver Example"
 	SOURCES
-		private/src/activator
-		private/src/consuming_driver
+		src/activator
+		src/consuming_driver
 )
 
-include_directories(${PROJECT_SOURCE_DIR}/device_access/device_access/public/include)
-include_directories(${PROJECT_SOURCE_DIR}/device_access/example/refining_driver/public/include)
-include_directories(private/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+target_include_directories(word_consumingdriver PRIVATE src)
 
-target_link_libraries(word_consumingdriver celix_utils celix_framework)
+target_link_libraries(word_consumingdriver PRIVATE Celix::device_access_api base_driver char_refiningdriver)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/private/include/consuming_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/private/include/consuming_driver_private.h b/device_access/example/consuming_driver/private/include/consuming_driver_private.h
deleted file mode 100644
index 261bb52..0000000
--- a/device_access/example/consuming_driver/private/include/consuming_driver_private.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *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.
- */
-/*
- * consuming_driver_private.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef CONSUMING_DRIVER_PRIVATE_H_
-#define CONSUMING_DRIVER_PRIVATE_H_
-
-#include <celix_errno.h>
-#include <service_reference.h>
-#include <driver.h>
-
-#define CONSUMING_DRIVER_ID "CONSUMING_DRIVER"
-
-typedef struct consuming_driver *consuming_driver_pt;
-
-celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver);
-celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service);
-
-celix_status_t consumingDriver_attach(void *driver, service_reference_pt reference, char **result);
-celix_status_t consumingDriver_match(void *driver, service_reference_pt reference, int *value);
-
-#endif /* CONSUMING_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/private/src/activator.c b/device_access/example/consuming_driver/private/src/activator.c
deleted file mode 100644
index 2004657..0000000
--- a/device_access/example/consuming_driver/private/src/activator.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include <celix_errno.h>
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <device.h>
-
-#include "consuming_driver_private.h"
-
-struct consuming_driver_bundle_instance {
-	bundle_context_pt context;
-	service_registration_pt registration;
-};
-
-typedef struct consuming_driver_bundle_instance *consuming_driver_bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	printf("CONSUMING_DRIVER: creating bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	consuming_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
-	if (instance != NULL) {
-		instance->context = context;
-		instance->registration = NULL;
-		(*userData) = instance;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	printf("CONSUMING_DRIVER: starting bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	consuming_driver_bundle_instance_pt bi = userData;
-
-	consuming_driver_pt driver = NULL;
-	status = consumingDriver_create(context, &driver);
-	if (status == CELIX_SUCCESS) {
-		driver_service_pt service = NULL;
-		status = consumingDriver_createService(driver, &service);
-		if (status == CELIX_SUCCESS) {
-			properties_pt props = properties_create();
-			properties_set(props, "DRIVER_ID", CONSUMING_DRIVER_ID);
-			status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration);
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		printf("CONSUMING_DRIVER: registered driver service.\n");
-	} else {
-		char error[256];
-		printf("CONSUMING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256));
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	printf("CONSUMING_DRIVER: stopping bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	consuming_driver_bundle_instance_pt bi = userData;
-
-	if (bi->registration != NULL) {
-		serviceRegistration_unregister(bi->registration);
-		printf("CONSUMING_DRIVER: unregistered driver service\n");
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	printf("CONSUMING_DRIVER: destroying bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/private/src/consuming_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/private/src/consuming_driver.c b/device_access/example/consuming_driver/private/src/consuming_driver.c
deleted file mode 100644
index 9106dbd..0000000
--- a/device_access/example/consuming_driver/private/src/consuming_driver.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- *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.
- */
-/*
- * consuming_driver.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include <device.h>
-#include <service_tracker.h>
-#include <service_reference.h>
-
-#include "celixbool.h"
-#include "consuming_driver_private.h"
-#include "refining_driver_device.h"
-
-
-struct consuming_driver {
-	bundle_context_pt context;
-	array_list_pt references;
-};
-
-celix_status_t consumingDriver_destroy(consuming_driver_pt driver) {
-	printf("CONSUMING_DRIVER: cleanup\n");
-	if (driver->references != NULL) {
-		array_list_iterator_pt iterator = arrayListIterator_create(driver->references);
-		while (arrayListIterator_hasNext(iterator)) {
-			service_reference_pt reference = arrayListIterator_next(iterator);
-			bool result;
-			bundleContext_ungetService(driver->context, reference, &result);
-		}
-		arrayListIterator_destroy(iterator);
-
-		arrayList_destroy(driver->references);
-		driver->references=NULL;
-	}
-
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*driver) = calloc(1, sizeof(**driver));
-	if ((*driver) != NULL) {
-		(*driver)->context=context;
-		(*driver)->references=NULL;
-
-		status = arrayList_create(&(*driver)->references);
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*service) = calloc(1, sizeof(**service));
-	if ((*service) != NULL) {
-		(*service)->driver = driver;
-		(*service)->attach = consumingDriver_attach;
-		(*service)->match = consumingDriver_match;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t consumingDriver_attach(void * driverHandler, service_reference_pt reference, char **result) {
-	printf("CONSUMING_DRIVER: attached called\n");
-	celix_status_t status = CELIX_SUCCESS;
-	consuming_driver_pt driver = driverHandler;
-	(*result) = NULL;
-	refining_driver_device_service_pt device_service = NULL;
-
-	status = bundleContext_getService(driver->context, reference, (void **)&device_service);
-	if (status == CELIX_SUCCESS) {
-		arrayList_add(driver->references, reference);
-		//consume the device
-		for (int i=0; i<15; i++) {
-			char *str = NULL;
-			device_service->getNextWord(device_service->refiningDriverDevice, &str);
-			printf("CONSUMING_DEVICE: Word Device result is %s\n", str);
-		}
-	}
-	return status;
-}
-
-celix_status_t consumingDriver_match(void *driverHandler, service_reference_pt reference, int *value) {
-	printf("CONSUMING_DRIVER: match called\n");
-	int match=0;
-	celix_status_t status = CELIX_SUCCESS;
-
-    const char* category = NULL;
-    status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
-    if (status == CELIX_SUCCESS) {
-        if (strcmp(category, REFINING_DRIVER_DEVICE_CATEGORY) == 0) {
-            match = 10;
-        }
-    }
-
-	(*value) = match;
-	return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/src/activator.c b/device_access/example/consuming_driver/src/activator.c
new file mode 100644
index 0000000..2004657
--- /dev/null
+++ b/device_access/example/consuming_driver/src/activator.c
@@ -0,0 +1,104 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include <celix_errno.h>
+#include <bundle_activator.h>
+#include <bundle_context.h>
+#include <celixbool.h>
+#include <device.h>
+
+#include "consuming_driver_private.h"
+
+struct consuming_driver_bundle_instance {
+	bundle_context_pt context;
+	service_registration_pt registration;
+};
+
+typedef struct consuming_driver_bundle_instance *consuming_driver_bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	printf("CONSUMING_DRIVER: creating bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	consuming_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
+	if (instance != NULL) {
+		instance->context = context;
+		instance->registration = NULL;
+		(*userData) = instance;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	printf("CONSUMING_DRIVER: starting bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	consuming_driver_bundle_instance_pt bi = userData;
+
+	consuming_driver_pt driver = NULL;
+	status = consumingDriver_create(context, &driver);
+	if (status == CELIX_SUCCESS) {
+		driver_service_pt service = NULL;
+		status = consumingDriver_createService(driver, &service);
+		if (status == CELIX_SUCCESS) {
+			properties_pt props = properties_create();
+			properties_set(props, "DRIVER_ID", CONSUMING_DRIVER_ID);
+			status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration);
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		printf("CONSUMING_DRIVER: registered driver service.\n");
+	} else {
+		char error[256];
+		printf("CONSUMING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256));
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	printf("CONSUMING_DRIVER: stopping bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	consuming_driver_bundle_instance_pt bi = userData;
+
+	if (bi->registration != NULL) {
+		serviceRegistration_unregister(bi->registration);
+		printf("CONSUMING_DRIVER: unregistered driver service\n");
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	printf("CONSUMING_DRIVER: destroying bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/src/consuming_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/src/consuming_driver.c b/device_access/example/consuming_driver/src/consuming_driver.c
new file mode 100644
index 0000000..9106dbd
--- /dev/null
+++ b/device_access/example/consuming_driver/src/consuming_driver.c
@@ -0,0 +1,125 @@
+/**
+ *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.
+ */
+/*
+ * consuming_driver.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include <device.h>
+#include <service_tracker.h>
+#include <service_reference.h>
+
+#include "celixbool.h"
+#include "consuming_driver_private.h"
+#include "refining_driver_device.h"
+
+
+struct consuming_driver {
+	bundle_context_pt context;
+	array_list_pt references;
+};
+
+celix_status_t consumingDriver_destroy(consuming_driver_pt driver) {
+	printf("CONSUMING_DRIVER: cleanup\n");
+	if (driver->references != NULL) {
+		array_list_iterator_pt iterator = arrayListIterator_create(driver->references);
+		while (arrayListIterator_hasNext(iterator)) {
+			service_reference_pt reference = arrayListIterator_next(iterator);
+			bool result;
+			bundleContext_ungetService(driver->context, reference, &result);
+		}
+		arrayListIterator_destroy(iterator);
+
+		arrayList_destroy(driver->references);
+		driver->references=NULL;
+	}
+
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*driver) = calloc(1, sizeof(**driver));
+	if ((*driver) != NULL) {
+		(*driver)->context=context;
+		(*driver)->references=NULL;
+
+		status = arrayList_create(&(*driver)->references);
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*service) = calloc(1, sizeof(**service));
+	if ((*service) != NULL) {
+		(*service)->driver = driver;
+		(*service)->attach = consumingDriver_attach;
+		(*service)->match = consumingDriver_match;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t consumingDriver_attach(void * driverHandler, service_reference_pt reference, char **result) {
+	printf("CONSUMING_DRIVER: attached called\n");
+	celix_status_t status = CELIX_SUCCESS;
+	consuming_driver_pt driver = driverHandler;
+	(*result) = NULL;
+	refining_driver_device_service_pt device_service = NULL;
+
+	status = bundleContext_getService(driver->context, reference, (void **)&device_service);
+	if (status == CELIX_SUCCESS) {
+		arrayList_add(driver->references, reference);
+		//consume the device
+		for (int i=0; i<15; i++) {
+			char *str = NULL;
+			device_service->getNextWord(device_service->refiningDriverDevice, &str);
+			printf("CONSUMING_DEVICE: Word Device result is %s\n", str);
+		}
+	}
+	return status;
+}
+
+celix_status_t consumingDriver_match(void *driverHandler, service_reference_pt reference, int *value) {
+	printf("CONSUMING_DRIVER: match called\n");
+	int match=0;
+	celix_status_t status = CELIX_SUCCESS;
+
+    const char* category = NULL;
+    status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
+    if (status == CELIX_SUCCESS) {
+        if (strcmp(category, REFINING_DRIVER_DEVICE_CATEGORY) == 0) {
+            match = 10;
+        }
+    }
+
+	(*value) = match;
+	return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/src/consuming_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/src/consuming_driver_private.h b/device_access/example/consuming_driver/src/consuming_driver_private.h
new file mode 100644
index 0000000..261bb52
--- /dev/null
+++ b/device_access/example/consuming_driver/src/consuming_driver_private.h
@@ -0,0 +1,43 @@
+/**
+ *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.
+ */
+/*
+ * consuming_driver_private.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef CONSUMING_DRIVER_PRIVATE_H_
+#define CONSUMING_DRIVER_PRIVATE_H_
+
+#include <celix_errno.h>
+#include <service_reference.h>
+#include <driver.h>
+
+#define CONSUMING_DRIVER_ID "CONSUMING_DRIVER"
+
+typedef struct consuming_driver *consuming_driver_pt;
+
+celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver);
+celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service);
+
+celix_status_t consumingDriver_attach(void *driver, service_reference_pt reference, char **result);
+celix_status_t consumingDriver_match(void *driver, service_reference_pt reference, int *value);
+
+#endif /* CONSUMING_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/CMakeLists.txt b/device_access/example/refining_driver/CMakeLists.txt
index d16584f..c339b73 100644
--- a/device_access/example/refining_driver/CMakeLists.txt
+++ b/device_access/example/refining_driver/CMakeLists.txt
@@ -20,15 +20,10 @@ add_bundle(char_refiningdriver
  	NAME "Apache Celix Device Access Char Refining Driver Example"
  	VERSION "0.0.1"
 	SOURCES
-		private/src/activator
-		private/src/refining_driver
+		src/activator
+		src/refining_driver
 )
 
-include_directories(${PROJECT_SOURCE_DIR}/device_access/device_access/public/include)
-include_directories(${PROJECT_SOURCE_DIR}/device_access/example/base_driver/public/include)
-include_directories(private/include)
-include_directories(public/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-
-target_link_libraries(char_refiningdriver celix_utils celix_framework)
+target_include_directories(char_refiningdriver PRIVATE src)
+target_include_directories(char_refiningdriver PUBLIC include)
+target_link_libraries(char_refiningdriver PRIVATE Celix::device_access_api base_driver)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/include/refining_driver_device.h
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/include/refining_driver_device.h b/device_access/example/refining_driver/include/refining_driver_device.h
new file mode 100644
index 0000000..728725e
--- /dev/null
+++ b/device_access/example/refining_driver/include/refining_driver_device.h
@@ -0,0 +1,45 @@
+/**
+ *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.
+ */
+/*
+ * refining_driver_device.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef REFINING_DRIVER_DEVICE_H_
+#define REFINING_DRIVER_DEVICE_H_
+
+#include "device.h"
+
+#define REFINING_DRIVER_SERVICE_NAME "refining_driver_device_service"
+#define REFINING_DRIVER_DEVICE_CATEGORY "word"
+#define REFINING_DRIVER_DEVICE_SERVIC_NAME "refining_driver_device"
+
+typedef struct refining_driver_device *refining_driver_device_pt;
+
+struct refining_driver_device_service {
+	struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/
+	refining_driver_device_pt refiningDriverDevice;
+	celix_status_t (*getNextWord)(refining_driver_device_pt refiningDriverDevice, char **c);
+};
+
+typedef struct refining_driver_device_service * refining_driver_device_service_pt;
+
+#endif /* REFINING_DRIVER_DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/private/include/refining_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/private/include/refining_driver_private.h b/device_access/example/refining_driver/private/include/refining_driver_private.h
deleted file mode 100644
index 37f15a5..0000000
--- a/device_access/example/refining_driver/private/include/refining_driver_private.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- *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.
- */
-/*
- * refining_driver_private.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef REFINING_DRIVER_PRIVATE_H_
-#define REFINING_DRIVER_PRIVATE_H_
-
-#include <celix_errno.h>
-#include <service_reference.h>
-#include <driver.h>
-
-#include "refining_driver_device.h"
-#include "base_driver_device.h"
-
-#define REFINING_DRIVER_ID "REFINING_DRIVER"
-
-typedef struct refining_driver *refining_driver_pt;
-
-celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver);
-celix_status_t refiningDriver_destroy(refining_driver_pt driver);
-
-celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service);
-
-celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseDevice, refining_driver_device_pt *device);
-celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device);
-
-
-celix_status_t refiningDriver_attach(void *driver, service_reference_pt reference, char **result);
-celix_status_t refiningDriver_match(void *driver, service_reference_pt reference, int *value);
-
-
-celix_status_t refiningDriverDevice_noDriverFound(device_pt device);
-celix_status_t refiningDriverDevice_createService(refining_driver_device_pt, refining_driver_device_service_pt *service);
-celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service);
-celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word);
-
-#endif /* REFINING_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/private/src/activator.c b/device_access/example/refining_driver/private/src/activator.c
deleted file mode 100644
index 233b150..0000000
--- a/device_access/example/refining_driver/private/src/activator.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include <celix_errno.h>
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <device.h>
-
-#include "refining_driver_private.h"
-
-struct refining_driver_bundle_instance {
-	bundle_context_pt context;
-	service_registration_pt registration;
-};
-
-typedef struct refining_driver_bundle_instance *refining_driver_bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	printf("REFINING_DRIVER: creating bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
-	if (instance != NULL) {
-		instance->context = context;
-		instance->registration = NULL;
-		(*userData) = instance;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	printf("REFINING_DRIVER: starting bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_bundle_instance_pt bi = userData;
-
-	refining_driver_pt driver = NULL;
-	status = refiningDriver_create(context, &driver);
-	if (status == CELIX_SUCCESS) {
-		driver_service_pt service = NULL;
-		status = refiningDriver_createService(driver, &service);
-		if (status == CELIX_SUCCESS) {
-			properties_pt props = properties_create();
-			properties_set(props, "DRIVER_ID", REFINING_DRIVER_ID);
-			status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration);
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		printf("REFINING_DRIVER: registered driver service.\n");
-	} else {
-		char error[256];
-		printf("REFINING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256));
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	printf("REFINING_DRIVER: stopping bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_bundle_instance_pt bi = userData;
-
-	if (bi->registration != NULL) {
-		serviceRegistration_unregister(bi->registration);
-		printf("REFINING_DRIVER: unregistered driver service\n");
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	printf("REFINING_DRIVER: destroying bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/private/src/refining_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/private/src/refining_driver.c b/device_access/example/refining_driver/private/src/refining_driver.c
deleted file mode 100644
index 404bc42..0000000
--- a/device_access/example/refining_driver/private/src/refining_driver.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- *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.
- */
-/*
- * refining_driver.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include <device.h>
-#include <bundle_context.h>
-#include <service_event.h>
-
-#include "refining_driver_private.h"
-#include "base_driver_device.h"
-
-static const int MAX_BUFF_SIZE = 1024;
-
-struct refining_driver {
-	device_pt device;
-	bundle_context_pt context;
-	int deviceCount;
-	array_list_pt devices;
-};
-
-struct device {
-	/*NOTE: for this example we use a empty device structure*/
-};
-
-struct refining_driver_device {
-	device_pt device;
-	base_driver_device_service_pt baseDriverDeviceService;
-	refining_driver_pt driver;
-	service_reference_pt baseServiceReference;
-	service_registration_pt deviceRegistration;
-	service_listener_pt listener;
-};
-
-celix_status_t refiningDriver_destroy(refining_driver_pt driver) {
-	if (driver != NULL) {
-		if (driver->devices != NULL) {
-			arrayList_destroy(driver->devices);
-			driver->devices=NULL;
-		}
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*driver) = calloc(1, sizeof(**driver));
-	if ((*driver) != NULL) {
-		(*driver)->context=context;
-		(*driver)->deviceCount=0;
-		(*driver)->device = calloc(1, sizeof(*(*driver)->device));
-		(*driver)->devices=NULL;
-		status = arrayList_create(&(*driver)->devices);
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*service) = calloc(1, sizeof(**service));
-	if ((*service) != NULL) {
-		(*service)->driver = driver;
-		(*service)->attach = refiningDriver_attach;
-		(*service)->match = refiningDriver_match;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-static celix_status_t refiningDriver_stopDevice(refining_driver_device_pt device) {
-	printf("REFINING_DRIVER: stopping device, parent device is unregistered\n");
-	celix_status_t status =  CELIX_SUCCESS;
-
-	if (device->deviceRegistration != NULL) {
-		status = serviceRegistration_unregister(device->deviceRegistration);
-		if (status == CELIX_SUCCESS) {
-			printf("unregistered refining device\n");
-		}
-	}
-
-	arrayList_removeElement(device->driver->devices, device);
-	return status;
-}
-
-
-static celix_status_t refiningDriver_serviceChanged(service_listener_pt listener, service_event_pt event) {
-	celix_status_t status =  CELIX_SUCCESS;
-	refining_driver_device_pt device = listener->handle;
-	if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
-		bool equal = false;
-		status = serviceReference_equals(device->baseServiceReference, event->reference, &equal);
-		if (status == CELIX_SUCCESS && equal) {
-			refiningDriver_stopDevice(device);
-		}
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device) {
-	return CELIX_SUCCESS;
-}
-
-celix_status_t refining_driver_cleanup_device(refining_driver_device_pt handler) {
-	celix_status_t status = CELIX_SUCCESS;;
-	refining_driver_device_pt device = handler;
-	if (device != NULL) {
-		if (device->listener != NULL) {
-			bundleContext_removeServiceListener(device->driver->context, device->listener);
-		}
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseService, refining_driver_device_pt *device) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	(*device) = calloc(1, sizeof(**device));
-	if ((*device) != NULL) {
-		(*device)->driver=driver;
-		(*device)->baseDriverDeviceService=baseService;
-		(*device)->baseServiceReference=reference;
-		(*device)->deviceRegistration=NULL;
-		(*device)->listener=NULL;
-
-		service_listener_pt listener = calloc(1, sizeof(*listener));
-		listener->handle=(void *)(*device);
-		listener->serviceChanged=(celix_status_t (*)(void * listener, service_event_pt event))refiningDriver_serviceChanged;
-		bundleContext_addServiceListener(driver->context, listener, NULL);
-		(*device)->listener=listener;
-
-		arrayList_add(driver->devices, (*device));
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	return status;
-}
-
-
-static celix_status_t refiningDriver_registerDevice(refining_driver_pt driver, refining_driver_device_pt device, char *serial) {
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_device_service_pt service = NULL;
-	status = refiningDriverDevice_createService(device, &service);
-	properties_pt props = properties_create();
-
-	if (status == CELIX_SUCCESS) {
-		properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, REFINING_DRIVER_DEVICE_CATEGORY);
-		properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
-		status = bundleContext_registerService(driver->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &device->deviceRegistration);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		printf("REFINING_DRIVER: registered refining device with serial %s\n", serial);
-	}
-	else{
-		properties_destroy(props);
-		refiningDriverDevice_destroyService(service);
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_attach(void * driverHandler, service_reference_pt reference, char **result) {
-	printf("REFINING_DRIVER: attached called\n");
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_pt driver = driverHandler;
-	(*result) = NULL;
-	base_driver_device_service_pt device_service = NULL;
-	status = bundleContext_getService(driver->context, reference, (void **)&device_service);
-	if (status == CELIX_SUCCESS) {
-		refining_driver_device_pt refiningDevice = NULL;
-		status = refiningDriver_createDevice(driver, reference, device_service, &refiningDevice);
-		if (status == CELIX_SUCCESS) {
-			driver->deviceCount+=1;
-			char serial[5];
-			sprintf(serial, "%4i", driver->deviceCount);
-			status = refiningDriver_registerDevice(driver, refiningDevice, serial);
-		}
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_match(void *driverHandler, service_reference_pt reference, int *value) {
-	printf("REFINING_DRIVER: match called\n");
-	int match = 0;
-	celix_status_t status = CELIX_SUCCESS;
-
-    const char* category = NULL;
-    status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
-    if (status == CELIX_SUCCESS) {
-        if (strcmp(category, BASE_DRIVER_DEVICE_CATEGORY) == 0) {
-            match = 10;
-        }
-    }
-
-	(*value) = match;
-	return status;
-}
-
-celix_status_t refiningDriverDevice_createService(refining_driver_device_pt device, refining_driver_device_service_pt *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*service) = calloc(1, sizeof(**service));
-	if ((*service) != NULL) {
-		(*service)->deviceService.device=calloc(1, sizeof(*(*service)->deviceService.device));
-		if ((*service)->deviceService.device != NULL) {
-			(*service)->deviceService.noDriverFound=refiningDriverDevice_noDriverFound;
-			(*service)->refiningDriverDevice=device;
-			(*service)->getNextWord=refiningDriverDevice_getNextWord;
-		} else {
-			status = CELIX_ENOMEM;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service){
-	if(service != NULL){
-		if(service->deviceService.device != NULL){
-			free(service->deviceService.device);
-		}
-		free(service);
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word) {
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_device_pt baseDevice = refiningDriverDevice->baseDriverDeviceService->baseDriverDevice;
-	char buff[MAX_BUFF_SIZE];
-	int i=0;
-	status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]);
-	while (buff[i] != ' ' && i < (MAX_BUFF_SIZE-1) && status == CELIX_SUCCESS) {
-		i+=1;
-		status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]);
-	}
-	if (status == CELIX_SUCCESS) {
-		buff[i] = '\0';
-		char *copy = calloc(1, (i+1));
-		if (copy != NULL) {
-			strcpy(copy, buff);
-			(*word)=copy;
-		} else {
-			status = CELIX_ENOMEM;
-		}
-	}
-
-	return status;
-}
-
-celix_status_t refiningDriverDevice_noDriverFound(device_pt device) {
-	printf("REFINING_DRIVER: no driver found");
-	return CELIX_SUCCESS;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/public/include/refining_driver_device.h
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/public/include/refining_driver_device.h b/device_access/example/refining_driver/public/include/refining_driver_device.h
deleted file mode 100644
index 728725e..0000000
--- a/device_access/example/refining_driver/public/include/refining_driver_device.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *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.
- */
-/*
- * refining_driver_device.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef REFINING_DRIVER_DEVICE_H_
-#define REFINING_DRIVER_DEVICE_H_
-
-#include "device.h"
-
-#define REFINING_DRIVER_SERVICE_NAME "refining_driver_device_service"
-#define REFINING_DRIVER_DEVICE_CATEGORY "word"
-#define REFINING_DRIVER_DEVICE_SERVIC_NAME "refining_driver_device"
-
-typedef struct refining_driver_device *refining_driver_device_pt;
-
-struct refining_driver_device_service {
-	struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/
-	refining_driver_device_pt refiningDriverDevice;
-	celix_status_t (*getNextWord)(refining_driver_device_pt refiningDriverDevice, char **c);
-};
-
-typedef struct refining_driver_device_service * refining_driver_device_service_pt;
-
-#endif /* REFINING_DRIVER_DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/src/activator.c b/device_access/example/refining_driver/src/activator.c
new file mode 100644
index 0000000..233b150
--- /dev/null
+++ b/device_access/example/refining_driver/src/activator.c
@@ -0,0 +1,104 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include <celix_errno.h>
+#include <bundle_activator.h>
+#include <bundle_context.h>
+#include <celixbool.h>
+#include <device.h>
+
+#include "refining_driver_private.h"
+
+struct refining_driver_bundle_instance {
+	bundle_context_pt context;
+	service_registration_pt registration;
+};
+
+typedef struct refining_driver_bundle_instance *refining_driver_bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	printf("REFINING_DRIVER: creating bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
+	if (instance != NULL) {
+		instance->context = context;
+		instance->registration = NULL;
+		(*userData) = instance;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	printf("REFINING_DRIVER: starting bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_bundle_instance_pt bi = userData;
+
+	refining_driver_pt driver = NULL;
+	status = refiningDriver_create(context, &driver);
+	if (status == CELIX_SUCCESS) {
+		driver_service_pt service = NULL;
+		status = refiningDriver_createService(driver, &service);
+		if (status == CELIX_SUCCESS) {
+			properties_pt props = properties_create();
+			properties_set(props, "DRIVER_ID", REFINING_DRIVER_ID);
+			status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration);
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		printf("REFINING_DRIVER: registered driver service.\n");
+	} else {
+		char error[256];
+		printf("REFINING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256));
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	printf("REFINING_DRIVER: stopping bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_bundle_instance_pt bi = userData;
+
+	if (bi->registration != NULL) {
+		serviceRegistration_unregister(bi->registration);
+		printf("REFINING_DRIVER: unregistered driver service\n");
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	printf("REFINING_DRIVER: destroying bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/src/refining_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/src/refining_driver.c b/device_access/example/refining_driver/src/refining_driver.c
new file mode 100644
index 0000000..404bc42
--- /dev/null
+++ b/device_access/example/refining_driver/src/refining_driver.c
@@ -0,0 +1,281 @@
+/**
+ *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.
+ */
+/*
+ * refining_driver.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include <device.h>
+#include <bundle_context.h>
+#include <service_event.h>
+
+#include "refining_driver_private.h"
+#include "base_driver_device.h"
+
+static const int MAX_BUFF_SIZE = 1024;
+
+struct refining_driver {
+	device_pt device;
+	bundle_context_pt context;
+	int deviceCount;
+	array_list_pt devices;
+};
+
+struct device {
+	/*NOTE: for this example we use a empty device structure*/
+};
+
+struct refining_driver_device {
+	device_pt device;
+	base_driver_device_service_pt baseDriverDeviceService;
+	refining_driver_pt driver;
+	service_reference_pt baseServiceReference;
+	service_registration_pt deviceRegistration;
+	service_listener_pt listener;
+};
+
+celix_status_t refiningDriver_destroy(refining_driver_pt driver) {
+	if (driver != NULL) {
+		if (driver->devices != NULL) {
+			arrayList_destroy(driver->devices);
+			driver->devices=NULL;
+		}
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*driver) = calloc(1, sizeof(**driver));
+	if ((*driver) != NULL) {
+		(*driver)->context=context;
+		(*driver)->deviceCount=0;
+		(*driver)->device = calloc(1, sizeof(*(*driver)->device));
+		(*driver)->devices=NULL;
+		status = arrayList_create(&(*driver)->devices);
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*service) = calloc(1, sizeof(**service));
+	if ((*service) != NULL) {
+		(*service)->driver = driver;
+		(*service)->attach = refiningDriver_attach;
+		(*service)->match = refiningDriver_match;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+static celix_status_t refiningDriver_stopDevice(refining_driver_device_pt device) {
+	printf("REFINING_DRIVER: stopping device, parent device is unregistered\n");
+	celix_status_t status =  CELIX_SUCCESS;
+
+	if (device->deviceRegistration != NULL) {
+		status = serviceRegistration_unregister(device->deviceRegistration);
+		if (status == CELIX_SUCCESS) {
+			printf("unregistered refining device\n");
+		}
+	}
+
+	arrayList_removeElement(device->driver->devices, device);
+	return status;
+}
+
+
+static celix_status_t refiningDriver_serviceChanged(service_listener_pt listener, service_event_pt event) {
+	celix_status_t status =  CELIX_SUCCESS;
+	refining_driver_device_pt device = listener->handle;
+	if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
+		bool equal = false;
+		status = serviceReference_equals(device->baseServiceReference, event->reference, &equal);
+		if (status == CELIX_SUCCESS && equal) {
+			refiningDriver_stopDevice(device);
+		}
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device) {
+	return CELIX_SUCCESS;
+}
+
+celix_status_t refining_driver_cleanup_device(refining_driver_device_pt handler) {
+	celix_status_t status = CELIX_SUCCESS;;
+	refining_driver_device_pt device = handler;
+	if (device != NULL) {
+		if (device->listener != NULL) {
+			bundleContext_removeServiceListener(device->driver->context, device->listener);
+		}
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseService, refining_driver_device_pt *device) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	(*device) = calloc(1, sizeof(**device));
+	if ((*device) != NULL) {
+		(*device)->driver=driver;
+		(*device)->baseDriverDeviceService=baseService;
+		(*device)->baseServiceReference=reference;
+		(*device)->deviceRegistration=NULL;
+		(*device)->listener=NULL;
+
+		service_listener_pt listener = calloc(1, sizeof(*listener));
+		listener->handle=(void *)(*device);
+		listener->serviceChanged=(celix_status_t (*)(void * listener, service_event_pt event))refiningDriver_serviceChanged;
+		bundleContext_addServiceListener(driver->context, listener, NULL);
+		(*device)->listener=listener;
+
+		arrayList_add(driver->devices, (*device));
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	return status;
+}
+
+
+static celix_status_t refiningDriver_registerDevice(refining_driver_pt driver, refining_driver_device_pt device, char *serial) {
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_device_service_pt service = NULL;
+	status = refiningDriverDevice_createService(device, &service);
+	properties_pt props = properties_create();
+
+	if (status == CELIX_SUCCESS) {
+		properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, REFINING_DRIVER_DEVICE_CATEGORY);
+		properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
+		status = bundleContext_registerService(driver->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &device->deviceRegistration);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		printf("REFINING_DRIVER: registered refining device with serial %s\n", serial);
+	}
+	else{
+		properties_destroy(props);
+		refiningDriverDevice_destroyService(service);
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_attach(void * driverHandler, service_reference_pt reference, char **result) {
+	printf("REFINING_DRIVER: attached called\n");
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_pt driver = driverHandler;
+	(*result) = NULL;
+	base_driver_device_service_pt device_service = NULL;
+	status = bundleContext_getService(driver->context, reference, (void **)&device_service);
+	if (status == CELIX_SUCCESS) {
+		refining_driver_device_pt refiningDevice = NULL;
+		status = refiningDriver_createDevice(driver, reference, device_service, &refiningDevice);
+		if (status == CELIX_SUCCESS) {
+			driver->deviceCount+=1;
+			char serial[5];
+			sprintf(serial, "%4i", driver->deviceCount);
+			status = refiningDriver_registerDevice(driver, refiningDevice, serial);
+		}
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_match(void *driverHandler, service_reference_pt reference, int *value) {
+	printf("REFINING_DRIVER: match called\n");
+	int match = 0;
+	celix_status_t status = CELIX_SUCCESS;
+
+    const char* category = NULL;
+    status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
+    if (status == CELIX_SUCCESS) {
+        if (strcmp(category, BASE_DRIVER_DEVICE_CATEGORY) == 0) {
+            match = 10;
+        }
+    }
+
+	(*value) = match;
+	return status;
+}
+
+celix_status_t refiningDriverDevice_createService(refining_driver_device_pt device, refining_driver_device_service_pt *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*service) = calloc(1, sizeof(**service));
+	if ((*service) != NULL) {
+		(*service)->deviceService.device=calloc(1, sizeof(*(*service)->deviceService.device));
+		if ((*service)->deviceService.device != NULL) {
+			(*service)->deviceService.noDriverFound=refiningDriverDevice_noDriverFound;
+			(*service)->refiningDriverDevice=device;
+			(*service)->getNextWord=refiningDriverDevice_getNextWord;
+		} else {
+			status = CELIX_ENOMEM;
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service){
+	if(service != NULL){
+		if(service->deviceService.device != NULL){
+			free(service->deviceService.device);
+		}
+		free(service);
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word) {
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_device_pt baseDevice = refiningDriverDevice->baseDriverDeviceService->baseDriverDevice;
+	char buff[MAX_BUFF_SIZE];
+	int i=0;
+	status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]);
+	while (buff[i] != ' ' && i < (MAX_BUFF_SIZE-1) && status == CELIX_SUCCESS) {
+		i+=1;
+		status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]);
+	}
+	if (status == CELIX_SUCCESS) {
+		buff[i] = '\0';
+		char *copy = calloc(1, (i+1));
+		if (copy != NULL) {
+			strcpy(copy, buff);
+			(*word)=copy;
+		} else {
+			status = CELIX_ENOMEM;
+		}
+	}
+
+	return status;
+}
+
+celix_status_t refiningDriverDevice_noDriverFound(device_pt device) {
+	printf("REFINING_DRIVER: no driver found");
+	return CELIX_SUCCESS;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/src/refining_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/src/refining_driver_private.h b/device_access/example/refining_driver/src/refining_driver_private.h
new file mode 100644
index 0000000..37f15a5
--- /dev/null
+++ b/device_access/example/refining_driver/src/refining_driver_private.h
@@ -0,0 +1,58 @@
+/**
+ *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.
+ */
+/*
+ * refining_driver_private.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef REFINING_DRIVER_PRIVATE_H_
+#define REFINING_DRIVER_PRIVATE_H_
+
+#include <celix_errno.h>
+#include <service_reference.h>
+#include <driver.h>
+
+#include "refining_driver_device.h"
+#include "base_driver_device.h"
+
+#define REFINING_DRIVER_ID "REFINING_DRIVER"
+
+typedef struct refining_driver *refining_driver_pt;
+
+celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver);
+celix_status_t refiningDriver_destroy(refining_driver_pt driver);
+
+celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service);
+
+celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseDevice, refining_driver_device_pt *device);
+celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device);
+
+
+celix_status_t refiningDriver_attach(void *driver, service_reference_pt reference, char **result);
+celix_status_t refiningDriver_match(void *driver, service_reference_pt reference, int *value);
+
+
+celix_status_t refiningDriverDevice_noDriverFound(device_pt device);
+celix_status_t refiningDriverDevice_createService(refining_driver_device_pt, refining_driver_device_service_pt *service);
+celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service);
+celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word);
+
+#endif /* REFINING_DRIVER_PRIVATE_H_ */


[24/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_context.c b/framework/private/src/bundle_context.c
deleted file mode 100644
index face85d..0000000
--- a/framework/private/src/bundle_context.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_context.c
- *
- *  \date       Mar 26, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "bundle_context_private.h"
-#include "framework_private.h"
-#include "bundle.h"
-#include "celix_log.h"
-
-celix_status_t bundleContext_create(framework_pt framework, framework_logger_pt logger, bundle_pt bundle, bundle_context_pt *bundle_context) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_context_pt context = NULL;
-
-	if (*bundle_context != NULL && framework == NULL && bundle == NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-        context = malloc(sizeof(*context));
-        if (!context) {
-            status = CELIX_ENOMEM;
-        } else {
-            context->framework = framework;
-            context->bundle = bundle;
-
-            *bundle_context = context;
-        }
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to create context");
-
-	return status;
-}
-
-celix_status_t bundleContext_destroy(bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (context != NULL) {
-	    free(context);
-		context = NULL;
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to destroy context");
-
-	return status;
-}
-
-celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *bundle) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (context == NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*bundle = context->bundle;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get bundle");
-
-	return status;
-}
-
-celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_pt *framework) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (context == NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*framework = context->framework;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get framework");
-
-	return status;
-}
-
-celix_status_t bundleContext_installBundle(bundle_context_pt context, const char * location, bundle_pt *bundle) {
-	return bundleContext_installBundle2(context, location, NULL, bundle);
-}
-
-celix_status_t bundleContext_installBundle2(bundle_context_pt context, const char * location, const char *inputFile, bundle_pt *bundle) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_pt b = NULL;
-
-	if (context != NULL && *bundle == NULL) {
-		if (fw_installBundle(context->framework, &b, location, inputFile) != CELIX_SUCCESS) {
-            status = CELIX_FRAMEWORK_EXCEPTION;
-		} else {
-			*bundle = b;
-		}
-	} else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to install bundle");
-
-	return status;
-}
-
-celix_status_t bundleContext_registerService(bundle_context_pt context, const char * serviceName, const void * svcObj,
-        properties_pt properties, service_registration_pt *service_registration) {
-	service_registration_pt registration = NULL;
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (context != NULL) {
-	    fw_registerService(context->framework, &registration, context->bundle, serviceName, svcObj, properties);
-	    *service_registration = registration;
-	} else {
-	    status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to register service. serviceName '%s'", serviceName);
-
-	return status;
-}
-
-celix_status_t bundleContext_registerServiceFactory(bundle_context_pt context, const char * serviceName, service_factory_pt factory,
-        properties_pt properties, service_registration_pt *service_registration) {
-    service_registration_pt registration = NULL;
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && *service_registration == NULL) {
-        fw_registerServiceFactory(context->framework, &registration, context->bundle, serviceName, factory, properties);
-        *service_registration = registration;
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to register service factory");
-
-    return status;
-}
-
-celix_status_t bundleContext_getServiceReferences(bundle_context_pt context, const char * serviceName, const char * filter, array_list_pt *service_references) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && *service_references == NULL) {
-        fw_getServiceReferences(context->framework, service_references, context->bundle, serviceName, filter);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to get service references");
-
-	return status;
-}
-
-celix_status_t bundleContext_getServiceReference(bundle_context_pt context, const char * serviceName, service_reference_pt *service_reference) {
-    service_reference_pt reference = NULL;
-    array_list_pt services = NULL;
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (serviceName != NULL) {
-        if (bundleContext_getServiceReferences(context, serviceName, NULL, &services) == CELIX_SUCCESS) {
-            reference = (arrayList_size(services) > 0) ? arrayList_get(services, 0) : NULL;
-            arrayList_destroy(services);
-            *service_reference = reference;
-        } else {
-            status = CELIX_ILLEGAL_ARGUMENT;
-        }
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to get service reference");
-
-	return status;
-}
-
-FRAMEWORK_EXPORT celix_status_t bundleContext_retainServiceReference(bundle_context_pt context, service_reference_pt ref) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && ref != NULL) {
-        serviceRegistry_retainServiceReference(context->framework->registry, context->bundle, ref);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to get service references");
-
-    return status;
-}
-
-celix_status_t bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && reference != NULL) {
-        status = framework_ungetServiceReference(context->framework, context->bundle, reference);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to unget service_reference");
-
-    return status;
-}
-
-celix_status_t bundleContext_getService(bundle_context_pt context, service_reference_pt reference, void** service_instance) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && reference != NULL && *service_instance == NULL) {
-        /*NOTE argument service_instance should be considerd a 'const void**'. 
-        To ensure backwards compatiblity a cast is made instead.
-        */
-	    status = fw_getService(context->framework, context->bundle, reference, (const void**) service_instance);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to get service");
-
-    return status;
-}
-
-celix_status_t bundleContext_ungetService(bundle_context_pt context, service_reference_pt reference, bool *result) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && reference != NULL) {
-        status = framework_ungetService(context->framework, context->bundle, reference, result);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to unget service");
-
-    return status;
-}
-
-celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (context == NULL || *bundles != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*bundles = framework_getBundles(context->framework);
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get bundles");
-
-	return status;
-}
-
-celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, bundle_pt *bundle) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context == NULL || *bundle != NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-        *bundle = framework_getBundleById(context->framework, id);
-        if (*bundle == NULL) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to get bundle [id=%ld]", id);
-
-	return status;
-}
-
-celix_status_t bundleContext_addServiceListener(bundle_context_pt context, service_listener_pt listener, const char* filter) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && listener != NULL) {
-        fw_addServiceListener(context->framework, context->bundle, listener, filter);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to add service listener");
-
-    return status;
-}
-
-celix_status_t bundleContext_removeServiceListener(bundle_context_pt context, service_listener_pt listener) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && listener != NULL) {
-        fw_removeServiceListener(context->framework, context->bundle, listener);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to remove service listener");
-
-    return status;
-}
-
-celix_status_t bundleContext_addBundleListener(bundle_context_pt context, bundle_listener_pt listener) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && listener != NULL) {
-        fw_addBundleListener(context->framework, context->bundle, listener);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to add bundle listener");
-
-    return status;
-}
-
-celix_status_t bundleContext_removeBundleListener(bundle_context_pt context, bundle_listener_pt listener) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && listener != NULL) {
-        fw_removeBundleListener(context->framework, context->bundle, listener);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to remove bundle listener");
-
-    return status;
-}
-
-celix_status_t bundleContext_addFrameworkListener(bundle_context_pt context, framework_listener_pt listener) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && listener != NULL) {
-        fw_addFrameworkListener(context->framework, context->bundle, listener);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to add framework listener");
-
-    return status;
-}
-
-celix_status_t bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context != NULL && listener != NULL) {
-        fw_removeFrameworkListener(context->framework, context->bundle, listener);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to remove framework listener");
-
-    return status;
-}
-
-celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *name, const char** value) {
-	return bundleContext_getPropertyWithDefault(context, name, NULL, value);
-}
-
-celix_status_t bundleContext_getPropertyWithDefault(bundle_context_pt context, const char* name, const char* defaultValue, const char** value) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context == NULL || name == NULL || *value != NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-        fw_getProperty(context->framework, name, defaultValue, value);
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to get property [name=%s]", name);
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/bundle_revision.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_revision.c b/framework/private/src/bundle_revision.c
deleted file mode 100644
index cfa10aa..0000000
--- a/framework/private/src/bundle_revision.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_revision.c
- *
- *  \date       Apr 12, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <archive.h>
-#include <string.h>
-
-#include "bundle_revision_private.h"
-
-celix_status_t bundleRevision_create(const char *root, const char *location, long revisionNr, const char *inputFile, bundle_revision_pt *bundle_revision) {
-    celix_status_t status = CELIX_SUCCESS;
-	bundle_revision_pt revision = NULL;
-
-	revision = (bundle_revision_pt) malloc(sizeof(*revision));
-    if (!revision) {
-    	status = CELIX_ENOMEM;
-    } else {
-    	// TODO: This overwrites an existing revision, is this supposed to happen?
-        int state = mkdir(root, S_IRWXU);
-        if ((state != 0) && (errno != EEXIST)) {
-            free(revision);
-            status = CELIX_FILE_IO_EXCEPTION;
-        } else {
-            if (inputFile != NULL) {
-                status = extractBundle(inputFile, root);
-            } else if (strcmp(location, "inputstream:") != 0) {
-            	// TODO how to handle this correctly?
-            	// If location != inputstream, extract it, else ignore it and assume this is a cache entry.
-                status = extractBundle(location, root);
-            }
-
-            status = CELIX_DO_IF(status, arrayList_create(&(revision->libraryHandles)));
-            if (status == CELIX_SUCCESS) {
-                revision->revisionNr = revisionNr;
-                revision->root = strdup(root);
-                revision->location = strdup(location);
-
-                *bundle_revision = revision;
-
-                char manifest[512];
-                snprintf(manifest, sizeof(manifest), "%s/META-INF/MANIFEST.MF", revision->root);
-				status = manifest_createFromFile(manifest, &revision->manifest);
-            }
-            else {
-            	free(revision);
-            }
-
-        }
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to create revision");
-
-	return status;
-}
-
-celix_status_t bundleRevision_destroy(bundle_revision_pt revision) {
-    arrayList_destroy(revision->libraryHandles);
-    manifest_destroy(revision->manifest);
-    free(revision->root);
-    free(revision->location);
-    free(revision);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleRevision_getNumber(bundle_revision_pt revision, long *revisionNr) {
-	celix_status_t status = CELIX_SUCCESS;
-    if (revision == NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-    	*revisionNr = revision->revisionNr;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to get revision number");
-
-	return status;
-}
-
-celix_status_t bundleRevision_getLocation(bundle_revision_pt revision, const char **location) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (revision == NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*location = revision->location;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get revision location");
-
-	return status;
-}
-
-celix_status_t bundleRevision_getRoot(bundle_revision_pt revision, const char **root) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (revision == NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*root = revision->root;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get revision root");
-
-	return status;
-}
-
-celix_status_t bundleRevision_getManifest(bundle_revision_pt revision, manifest_pt *manifest) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (revision == NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*manifest = revision->manifest;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get manifest");
-
-	return status;
-}
-
-celix_status_t bundleRevision_getHandles(bundle_revision_pt revision, array_list_pt *handles) {
-    celix_status_t status = CELIX_SUCCESS;
-    if (revision == NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-        *handles = revision->libraryHandles;
-    }
-
-    framework_logIfError(logger, status, NULL, "Failed to get handles");
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/capability.c
----------------------------------------------------------------------
diff --git a/framework/private/src/capability.c b/framework/private/src/capability.c
deleted file mode 100644
index 9e4dc3a..0000000
--- a/framework/private/src/capability.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- *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.
- */
-/*
- * capability.c
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "capability_private.h"
-#include "attribute.h"
-#include "celix_log.h"
-
-celix_status_t capability_create(module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability) {
-	celix_status_t status;
-	*capability = (capability_pt) malloc(sizeof(**capability));
-	if (!*capability) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*capability)->module = module;
-		(*capability)->attributes = attributes;
-		(*capability)->directives = directives;
-		(*capability)->version = NULL;
-
-		attribute_pt versionAttribute = NULL;
-		attribute_pt serviceAttribute = (attribute_pt) hashMap_get(attributes, "service");
-		status = attribute_getValue(serviceAttribute, &(*capability)->serviceName);
-		if (status == CELIX_SUCCESS) {
-			versionAttribute = (attribute_pt) hashMap_get(attributes, "version");
-			if (versionAttribute != NULL) {
-				char *versionStr = NULL;
-				attribute_getValue(versionAttribute, &versionStr);
-				status = version_createVersionFromString(versionStr, &(*capability)->version);
-			} else {
-				status = version_createEmptyVersion(&(*capability)->version);
-			}
-		}
-
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to create capability");
-
-	return status;
-}
-
-celix_status_t capability_destroy(capability_pt capability) {
-	hash_map_iterator_pt attrIter = hashMapIterator_create(capability->attributes);
-	while (hashMapIterator_hasNext(attrIter)) {
-		attribute_pt attr = hashMapIterator_nextValue(attrIter);
-		hashMapIterator_remove(attrIter);
-		attribute_destroy(attr);
-	}
-	hashMapIterator_destroy(attrIter);
-	hashMap_destroy(capability->attributes, false, false);
-	hashMap_destroy(capability->directives, false, false);
-
-	capability->attributes = NULL;
-	capability->directives = NULL;
-	capability->module = NULL;
-
-	version_destroy(capability->version);
-	capability->version = NULL;
-
-	free(capability);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t capability_getServiceName(capability_pt capability, const char **serviceName) {
-	*serviceName = capability->serviceName;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t capability_getVersion(capability_pt capability, version_pt *version) {
-	*version = capability->version;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t capability_getModule(capability_pt capability, module_pt *module) {
-	*module = capability->module;
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/celix_errorcodes.c
----------------------------------------------------------------------
diff --git a/framework/private/src/celix_errorcodes.c b/framework/private/src/celix_errorcodes.c
deleted file mode 100644
index 80323e7..0000000
--- a/framework/private/src/celix_errorcodes.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- *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_errorcodes.c
- *
- *  \date       Aug 30, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <string.h>
-
-#include "celix_errno.h"
-
-static char* celix_error_string(celix_status_t statcode) {
-	switch (statcode) {
-        case CELIX_BUNDLE_EXCEPTION:
-            return "Bundle exception";
-        case CELIX_INVALID_BUNDLE_CONTEXT:
-            return "Invalid bundle context";
-        case CELIX_ILLEGAL_ARGUMENT:
-            return "Illegal argument";
-        case CELIX_INVALID_SYNTAX:
-            return "Invalid syntax";
-        case CELIX_FRAMEWORK_SHUTDOWN:
-            return "Framework shutdown";
-        case CELIX_ILLEGAL_STATE:
-            return "Illegal state";
-        case CELIX_FRAMEWORK_EXCEPTION:
-            return "Framework exception";
-        case CELIX_FILE_IO_EXCEPTION:
-            return "File I/O exception";
-        case CELIX_SERVICE_EXCEPTION:
-            return "Service exception";
-        default:
-            return "Unknown code";
-	}
-}
-
-char* celix_strerror(celix_status_t errorcode, char *buffer, size_t bufferSize) {
-    if (errorcode < CELIX_START_ERROR) {
-        return strerror(errorcode);
-    } else {
-    	char * str = celix_error_string(errorcode);
-    	strncpy(buffer, str, bufferSize);
-        return buffer;
-    }
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/celix_launcher.c
----------------------------------------------------------------------
diff --git a/framework/private/src/celix_launcher.c b/framework/private/src/celix_launcher.c
deleted file mode 100644
index ba83f25..0000000
--- a/framework/private/src/celix_launcher.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/**
- *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_launcher.c
- *
- *  \date       Mar 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include "celix_launcher.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <libgen.h>
-#include <signal.h>
-
-#ifndef CELIX_NO_CURLINIT
-#include <curl/curl.h>
-#endif
-
-#include <string.h>
-#include <curl/curl.h>
-#include <signal.h>
-#include <libgen.h>
-#include "celix_launcher.h"
-#include "framework.h"
-#include "linked_list_iterator.h"
-
-static void show_usage(char* prog_name);
-static void shutdown_framework(int signal);
-static void ignore(int signal);
-
-#define DEFAULT_CONFIG_FILE "config.properties"
-
-static framework_pt framework = NULL;
-
-int celixLauncher_launchWithArgs(int argc, char *argv[]) {
-	// Perform some minimal command-line option parsing...
-	char *opt = NULL;
-	if (argc > 1) {
-		opt = argv[1];
-	}
-
-	char *config_file = NULL;
-
-	if (opt) {
-		// Check whether the user wants some help...
-		if (strcmp("-h", opt) == 0 || strcmp("-help", opt) == 0) {
-			show_usage(argv[0]);
-			return 0;
-		} else {
-			config_file = opt;
-		}
-	} else {
-		config_file = DEFAULT_CONFIG_FILE;
-	}
-
-	struct sigaction sigact;
-	memset(&sigact, 0, sizeof(sigact));
-	sigact.sa_handler = shutdown_framework;
-	sigaction(SIGINT,  &sigact, NULL);
-	sigaction(SIGTERM, &sigact, NULL);
-
-	memset(&sigact, 0, sizeof(sigact));
-	sigact.sa_handler = ignore;
-	sigaction(SIGUSR1,  &sigact, NULL);
-	sigaction(SIGUSR2,  &sigact, NULL);
-
-	int rc = celixLauncher_launch(config_file, &framework);
-	if (rc == 0) {
-		celixLauncher_waitForShutdown(framework);
-		celixLauncher_destroy(framework);
-	}
-	return rc;
-}
-
-static void show_usage(char* prog_name) {
-	printf("Usage:\n  %s [path/to/config.properties]\n\n", basename(prog_name));
-}
-
-static void shutdown_framework(int signal) {
-	if (framework != NULL) {
-		celixLauncher_stop(framework); //NOTE main thread will destroy
-	}
-}
-
-static void ignore(int signal) {
-	//ignoring for signal SIGUSR1, SIGUSR2. Can be used on threads
-}
-
-int celixLauncher_launch(const char *configFile, framework_pt *framework) {
-	int status = 0;
-	FILE *config = fopen(configFile, "r");
-	if (config != NULL) {
-		status = celixLauncher_launchWithStream(config, framework);
-	} else {
-		fprintf(stderr, "Error: invalid or non-existing configuration file: '%s'.", configFile);
-		perror("");
-		status = 1;
-	}
-	return status;
-}
-
-int celixLauncher_launchWithStream(FILE *stream, framework_pt *framework) {
-	int status = 0;
-
-	properties_pt config = properties_loadWithStream(stream);
-	fclose(stream);
-	// Make sure we've read it and that nothing went wrong with the file access...
-	if (config == NULL) {
-		fprintf(stderr, "Error: invalid configuration file");
-		perror(NULL);
-		status = 1;
-	}
-	else {
-		status = celixLauncher_launchWithProperties(config, framework);
-	}
-
-	return status;
-}
-
-
-int celixLauncher_launchWithProperties(properties_pt config, framework_pt *framework) {
-	celix_status_t status;
-#ifndef CELIX_NO_CURLINIT
-	// Before doing anything else, let's setup Curl
-	curl_global_init(CURL_GLOBAL_NOTHING);
-#endif
-
-	const char* autoStartProp = properties_get(config, "cosgi.auto.start.1");
-	char* autoStart = NULL;
-	if (autoStartProp != NULL) {
-		autoStart = strndup(autoStartProp, 1024*10);
-	}
-
-	status = framework_create(framework, config);
-	bundle_pt fwBundle = NULL;
-	if (status == CELIX_SUCCESS) {
-		status = fw_init(*framework);
-		if (status == CELIX_SUCCESS) {
-			// Start the system bundle
-			status = framework_getFrameworkBundle(*framework, &fwBundle);
-
-			if(status == CELIX_SUCCESS){
-				bundle_start(fwBundle);
-
-				char delims[] = " ";
-				char *result = NULL;
-				char *save_ptr = NULL;
-				linked_list_pt bundles;
-				array_list_pt installed = NULL;
-				bundle_context_pt context = NULL;
-				linked_list_iterator_pt iter = NULL;
-				unsigned int i;
-
-				linkedList_create(&bundles);
-				result = strtok_r(autoStart, delims, &save_ptr);
-				while (result != NULL) {
-					char *location = strdup(result);
-					linkedList_addElement(bundles, location);
-					result = strtok_r(NULL, delims, &save_ptr);
-				}
-				// First install all bundles
-				// Afterwards start them
-				arrayList_create(&installed);
-				bundle_getContext(fwBundle, &context);
-				iter = linkedListIterator_create(bundles, 0);
-				while (linkedListIterator_hasNext(iter)) {
-					bundle_pt current = NULL;
-					char *location = (char *) linkedListIterator_next(iter);
-					if (bundleContext_installBundle(context, location, &current) == CELIX_SUCCESS) {
-						// Only add bundle if it is installed correctly
-						arrayList_add(installed, current);
-					} else {
-						printf("Could not install bundle from %s\n", location);
-					}
-					linkedListIterator_remove(iter);
-					free(location);
-				}
-				linkedListIterator_destroy(iter);
-				linkedList_destroy(bundles);
-
-				for (i = 0; i < arrayList_size(installed); i++) {
-					bundle_pt installedBundle = (bundle_pt) arrayList_get(installed, i);
-					bundle_startWithOptions(installedBundle, 0);
-				}
-
-				arrayList_destroy(installed);
-			}
-		}
-	}
-
-	if (status != CELIX_SUCCESS) {
-		printf("Problem creating framework\n");
-	}
-
-	printf("Launcher: Framework Started\n");
-
-	free(autoStart);
-	
-	return status;
-}
-
-void celixLauncher_waitForShutdown(framework_pt framework) {
-	framework_waitForStop(framework);
-}
-
-void celixLauncher_destroy(framework_pt framework) {
-	framework_destroy(framework);
-
-#ifndef CELIX_NO_CURLINIT
-	// Cleanup Curl
-	curl_global_cleanup();
-#endif
-
-	printf("Launcher: Exit\n");
-}
-
-void celixLauncher_stop(framework_pt framework) {
-	bundle_pt fwBundle = NULL;
-	if( framework_getFrameworkBundle(framework, &fwBundle) == CELIX_SUCCESS){
-		bundle_stop(fwBundle);
-	}
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/celix_log.c
----------------------------------------------------------------------
diff --git a/framework/private/src/celix_log.c b/framework/private/src/celix_log.c
deleted file mode 100644
index c4d51e2..0000000
--- a/framework/private/src/celix_log.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- *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_log.c
- *
- *  \date       6 Oct 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-#include <stdarg.h>
-
-#include "celix_errno.h"
-#include "celix_log.h"
-
-void framework_log(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line, const char *fmsg, ...) {
-    char msg[512];
-    va_list listPointer;
-    va_start(listPointer, fmsg);
-    vsprintf(msg, fmsg, listPointer);
-
-    //FIXME logger and/or logger->logFucntion can be null. But this solution is not thread safe!
-    if (logger != NULL && logger->logFunction != NULL) {
-        logger->logFunction(level, func, file, line, msg);
-    }
-
-    va_end(listPointer);
-}
-
-void framework_logCode(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line, celix_status_t code, const char *fmsg, ...) {
-    char message[256];
-    celix_strerror(code, message, 256);
-    char msg[512];
-    va_list listPointer;
-    va_start(listPointer, fmsg);
-    vsprintf(msg, fmsg, listPointer);
-
-    framework_log(logger, level, func, file, line, "%s [%d]: %s", message, code, msg);
-
-    va_end(listPointer);
-}
-
-celix_status_t frameworkLogger_log(framework_log_level_t level, const char *func, const char *file, int line, const char *msg) {
-    char *levelStr = NULL;
-    switch (level) {
-        case OSGI_FRAMEWORK_LOG_ERROR:
-            levelStr = "ERROR";
-            break;
-        case OSGI_FRAMEWORK_LOG_WARNING:
-            levelStr = "WARNING";
-            break;
-        case OSGI_FRAMEWORK_LOG_INFO:
-            levelStr = "INFO";
-            break;
-        case OSGI_FRAMEWORK_LOG_DEBUG:
-        default:
-            levelStr = "DEBUG";
-            break;
-    }
-
-    if (level == OSGI_FRAMEWORK_LOG_ERROR) {
-        printf("%s: %s\n\tat %s(%s:%d)\n", levelStr, msg, func, file, line);
-    } else {
-        printf("%s: %s\n", levelStr, msg);
-    }
-
-    return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/filter.c
----------------------------------------------------------------------
diff --git a/framework/private/src/filter.c b/framework/private/src/filter.c
deleted file mode 100644
index f06d6e8..0000000
--- a/framework/private/src/filter.c
+++ /dev/null
@@ -1,687 +0,0 @@
-/**
- *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.
- */
-/*
- * filter.c
- *
- *  \date       Apr 28, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "celix_log.h"
-#include "filter_private.h"
-
-static void filter_skipWhiteSpace(char* filterString, int* pos);
-static filter_pt filter_parseFilter(char* filterString, int* pos);
-static filter_pt filter_parseFilterComp(char* filterString, int* pos);
-static filter_pt filter_parseAnd(char* filterString, int* pos);
-static filter_pt filter_parseOr(char* filterString, int* pos);
-static filter_pt filter_parseNot(char* filterString, int* pos);
-static filter_pt filter_parseItem(char* filterString, int* pos);
-static char * filter_parseAttr(char* filterString, int* pos);
-static char * filter_parseValue(char* filterString, int* pos);
-static array_list_pt filter_parseSubstring(char* filterString, int* pos);
-
-static celix_status_t filter_compare(OPERAND operand, char * string, void * value2, bool *result);
-static celix_status_t filter_compareString(OPERAND operand, char * string, void * value2, bool *result);
-
-static void filter_skipWhiteSpace(char * filterString, int * pos) {
-	int length;
-	for (length = strlen(filterString); (*pos < length) && isspace(filterString[*pos]);) {
-		(*pos)++;
-	}
-}
-
-filter_pt filter_create(const char* filterString) {
-	filter_pt filter = NULL;
-	char* filterStr = (char*) filterString;
-	int pos = 0;
-	filter = filter_parseFilter(filterStr, &pos);
-	if (pos != strlen(filterStr)) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error: Extraneous trailing characters.");
-		filter_destroy(filter);
-		return NULL;
-	}
-	if(filter != NULL){
-		filter->filterStr = filterStr;
-	} 
-
-	return filter;
-}
-
-void filter_destroy(filter_pt filter) {
-	if (filter != NULL) {
-		if(filter->value!=NULL){
-			if (filter->operand == SUBSTRING) {
-				int size = arrayList_size(filter->value);
-				for (; size > 0; --size) {
-					char* operand = (char*) arrayList_remove(filter->value, 0);
-					free(operand);
-				}
-				arrayList_destroy(filter->value);
-				filter->value = NULL;
-			} else if ( (filter->operand == OR) || (filter->operand == AND) ) {
-				int size = arrayList_size(filter->value);
-				unsigned int i = 0;
-				for (i = 0; i < size; i++) {
-					filter_pt f = arrayList_get(filter->value, i);
-					filter_destroy(f);
-				}
-				arrayList_destroy(filter->value);
-				filter->value = NULL;
-			} else  if (filter->operand == NOT) {
-				filter_destroy(filter->value);
-				filter->value = NULL;
-			} else {
-				free(filter->value);
-				filter->value = NULL;
-			}
-		}
-		free(filter->attribute);
-		filter->attribute = NULL;
-		free(filter);
-		filter = NULL;
-	}
-}
-
-static filter_pt filter_parseFilter(char * filterString, int * pos) {
-	filter_pt filter;
-	filter_skipWhiteSpace(filterString, pos);
-	if (filterString[*pos] != '(') {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing '(' in filter string '%s'.", filterString);
-		return NULL;
-	}
-	(*pos)++;
-
-	filter = filter_parseFilterComp(filterString, pos);
-
-	filter_skipWhiteSpace(filterString, pos);
-
-	if (filterString[*pos] != ')') {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing ')' in filter string '%s'.", filterString);
-		if(filter!=NULL){
-			filter_destroy(filter);
-		}
-		return NULL;
-	}
-	(*pos)++;
-	filter_skipWhiteSpace(filterString, pos);
-
-	if(filter != NULL){
-		if(filter->value == NULL && filter->operand!=PRESENT){
-			filter_destroy(filter);
-			return NULL;
-		}
-	}
-
-	return filter;
-}
-
-static filter_pt filter_parseFilterComp(char * filterString, int * pos) {
-	char c;
-	filter_skipWhiteSpace(filterString, pos);
-
-	c = filterString[*pos];
-
-	switch (c) {
-		case '&': {
-			(*pos)++;
-			return filter_parseAnd(filterString, pos);
-		}
-		case '|': {
-			(*pos)++;
-			return filter_parseOr(filterString, pos);
-		}
-		case '!': {
-			(*pos)++;
-			return filter_parseNot(filterString, pos);
-		}
-	}
-	return filter_parseItem(filterString, pos);
-}
-
-static filter_pt filter_parseAnd(char * filterString, int * pos) {
-
-	array_list_pt operands = NULL;
-	filter_skipWhiteSpace(filterString, pos);
-	bool failure = false;
-
-	if (filterString[*pos] != '(') {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing '('.");
-		return NULL;
-	}
-
-	arrayList_create(&operands);
-	while(filterString[*pos] == '(') {
-		filter_pt child = filter_parseFilter(filterString, pos);
-		if(child == NULL){
-			failure = true;
-			break;
-		}
-		arrayList_add(operands, child);
-	}
-
-	if(failure == true){
-		array_list_iterator_pt listIt = arrayListIterator_create(operands);
-		while(arrayListIterator_hasNext(listIt)){
-			filter_pt f = arrayListIterator_next(listIt);
-			filter_destroy(f);
-		}
-		arrayListIterator_destroy(listIt);
-		arrayList_destroy(operands);
-		operands = NULL;
-	}
-
-	filter_pt filter = (filter_pt) malloc(sizeof(*filter));
-	filter->operand = AND;
-	filter->attribute = NULL;
-	filter->value = operands;
-
-	return filter;
-}
-
-static filter_pt filter_parseOr(char * filterString, int * pos) {
-
-	array_list_pt operands = NULL;
-
-	filter_skipWhiteSpace(filterString, pos);
-	bool failure = false;
-
-	if (filterString[*pos] != '(') {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing '('.");
-		return NULL;
-	}
-
-	arrayList_create(&operands);
-	while(filterString[*pos] == '(') {
-		filter_pt child = filter_parseFilter(filterString, pos);
-		if(child == NULL){
-			failure = true;
-			break;
-		}
-		arrayList_add(operands, child);
-	}
-
-	if(failure == true){
-		array_list_iterator_pt listIt = arrayListIterator_create(operands);
-		while(arrayListIterator_hasNext(listIt)){
-			filter_pt f = arrayListIterator_next(listIt);
-			filter_destroy(f);
-		}
-		arrayListIterator_destroy(listIt);
-		arrayList_destroy(operands);
-		operands = NULL;
-	}
-
-	filter_pt filter = (filter_pt) malloc(sizeof(*filter));
-	filter->operand = OR;
-	filter->attribute = NULL;
-	filter->value = operands;
-
-	return filter;
-}
-
-static filter_pt filter_parseNot(char * filterString, int * pos) {
-	filter_pt child = NULL;
-	filter_skipWhiteSpace(filterString, pos);
-
-	if (filterString[*pos] != '(') {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing '('.");
-		return NULL;
-	}
-
-	child = filter_parseFilter(filterString, pos);
-
-
-	filter_pt filter = (filter_pt) malloc(sizeof(*filter));
-	filter->operand = NOT;
-	filter->attribute = NULL;
-	filter->value = child;
-
-	return filter;
-}
-
-static filter_pt filter_parseItem(char * filterString, int * pos) {
-	char * attr = filter_parseAttr(filterString, pos);
-	if(attr == NULL){
-		return NULL;
-	}
-
-	filter_skipWhiteSpace(filterString, pos);
-	switch(filterString[*pos]) {
-		case '~': {
-			if (filterString[*pos + 1] == '=') {
-				filter_pt filter = (filter_pt) malloc(sizeof(*filter));
-				*pos += 2;
-				filter->operand = APPROX;
-				filter->attribute = attr;
-				filter->value = filter_parseValue(filterString, pos);
-				return filter;
-			}
-			break;
-		}
-		case '>': {
-			if (filterString[*pos + 1] == '=') {
-				filter_pt filter = (filter_pt) malloc(sizeof(*filter));
-				*pos += 2;
-				filter->operand = GREATEREQUAL;
-				filter->attribute = attr;
-				filter->value = filter_parseValue(filterString, pos);
-				return filter;
-			}
-			else {
-                filter_pt filter = (filter_pt) malloc(sizeof(*filter));
-                *pos += 1;
-                filter->operand = GREATER;
-                filter->attribute = attr;
-                filter->value = filter_parseValue(filterString, pos);
-                return filter;
-			}
-			break;
-		}
-		case '<': {
-			if (filterString[*pos + 1] == '=') {
-				filter_pt filter = (filter_pt) malloc(sizeof(*filter));
-				*pos += 2;
-				filter->operand = LESSEQUAL;
-				filter->attribute = attr;
-				filter->value = filter_parseValue(filterString, pos);
-				return filter;
-			}
-			else {
-                filter_pt filter = (filter_pt) malloc(sizeof(*filter));
-                *pos += 1;
-                filter->operand = LESS;
-                filter->attribute = attr;
-                filter->value = filter_parseValue(filterString, pos);
-                return filter;
-			}
-			break;
-		}
-		case '=': {
-			filter_pt filter = NULL;
-			array_list_pt subs;
-			if (filterString[*pos + 1] == '*') {
-				int oldPos = *pos;
-				*pos += 2;
-				filter_skipWhiteSpace(filterString, pos);
-				if (filterString[*pos] == ')') {
-					filter_pt filter = (filter_pt) malloc(sizeof(*filter));
-					filter->operand = PRESENT;
-					filter->attribute = attr;
-					filter->value = NULL;
-					return filter;
-				}
-				*pos = oldPos;
-			}
-			filter = (filter_pt) malloc(sizeof(*filter));			
-			(*pos)++;
-			subs = filter_parseSubstring(filterString, pos);
-			if(subs!=NULL){
-				if (arrayList_size(subs) == 1) {
-					char * string = (char *) arrayList_get(subs, 0);
-					if (string != NULL) {
-						filter->operand = EQUAL;
-						filter->attribute = attr;
-						filter->value = string;
-
-						arrayList_clear(subs);
-						arrayList_destroy(subs);
-
-						return filter;
-					}
-				}
-			}
-			filter->operand = SUBSTRING;
-			filter->attribute = attr;
-			filter->value = subs;
-			return filter;
-		}
-	}
-	fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Invalid operator.");
-	free(attr);
-	return NULL;
-}
-
-static char * filter_parseAttr(char * filterString, int * pos) {
-	char c;
-	int begin = *pos;
-	int end = *pos;
-	int length = 0;
-
-	filter_skipWhiteSpace(filterString, pos);
-	c = filterString[*pos];
-
-	while (c != '~' && c != '<' && c != '>' && c != '=' && c != '(' && c != ')') {
-		(*pos)++;
-
-		if (!isspace(c)) {
-			end = *pos;
-		}
-
-		c = filterString[*pos];
-	}
-
-	length = end - begin;
-
-	if (length == 0) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Missing attr.");
-		return NULL;
-	} else {
-		char * attr = (char *) malloc(length+1);
-		strncpy(attr, filterString+begin, length);
-		attr[length] = '\0';
-		return attr;
-	}
-}
-
-static char * filter_parseValue(char * filterString, int * pos) {
-	char *value = calloc(strlen(filterString) + 1, sizeof(*value));
-	int keepRunning = 1;
-
-	while (keepRunning) {
-		char c = filterString[*pos];
-
-		switch (c) {
-			case ')': {
-				keepRunning = 0;
-				break;
-			}
-			case '(': {
-				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Invalid value.");
-				free(value);
-				return NULL;
-			}
-			case '\0':{
-				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Unclosed bracket.");
-				free(value);
-				return NULL;
-			}
-			case '\\': {
-				(*pos)++;
-				c = filterString[*pos];
-			}
-			/* no break */
-			default: {
-				char ch[2];
-				ch[0] = c;
-				ch[1] = '\0';
-				strcat(value, ch);
-				(*pos)++;
-				break;
-			}
-		}
-	}
-
-	if (strlen(value) == 0) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Missing value.");
-		free(value);
-		return NULL;
-	}
-	return value;
-}
-
-static array_list_pt filter_parseSubstring(char * filterString, int * pos) {
-	char *sub = calloc(strlen(filterString) + 1, sizeof(*sub));
-	array_list_pt operands = NULL;
-	int keepRunning = 1;
-
-	arrayList_create(&operands);
-	while (keepRunning) {
-		char c = filterString[*pos];
-		
-
-		switch (c) {
-			case ')': {
-				if (strlen(sub) > 0) {
-					arrayList_add(operands, strdup(sub));
-				}
-				keepRunning = 0;
-				break;
-			}
-			case '\0':{
-				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Unclosed bracket.");
-				keepRunning = false;
-				break;
-			}
-			case '(': {
-				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Invalid value.");
-				keepRunning = false;
-				break;
-			}
-			case '*': {
-				if (strlen(sub) > 0) {
-					arrayList_add(operands, strdup(sub));
-				}
-				sub[0] = '\0';
-				arrayList_add(operands, NULL);
-				(*pos)++;
-				break;
-			}
-			case '\\': {
-				(*pos)++;
-				c = filterString[*pos];
-			}
-			/* no break */
-			default: {
-				char ch[2];
-				ch[0] = c;
-				ch[1] = '\0';
-				strcat(sub, ch);
-				(*pos)++;
-				break;
-			}
-		}
-	}
-	free(sub);
-
-	if (arrayList_size(operands) == 0) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Missing value.");
-		arrayList_destroy(operands);
-		return NULL;
-	}
-
-	return operands;
-}
-
-celix_status_t filter_match(filter_pt filter, properties_pt properties, bool *result) {
-	switch (filter->operand) {
-		case AND: {
-			array_list_pt filters = (array_list_pt) filter->value;
-			unsigned int i;
-			for (i = 0; i < arrayList_size(filters); i++) {
-				filter_pt sfilter = (filter_pt) arrayList_get(filters, i);
-				bool mresult;
-				filter_match(sfilter, properties, &mresult);
-				if (!mresult) {
-					*result = 0;
-					return CELIX_SUCCESS;
-				}
-			}
-			*result = 1;
-			return CELIX_SUCCESS;
-		}
-		case OR: {
-			array_list_pt filters = (array_list_pt) filter->value;
-			unsigned int i;
-			for (i = 0; i < arrayList_size(filters); i++) {
-				filter_pt sfilter = (filter_pt) arrayList_get(filters, i);
-				bool mresult;
-				filter_match(sfilter, properties, &mresult);
-				if (mresult) {
-					*result = 1;
-					return CELIX_SUCCESS;
-				}
-			}
-			*result = 0;
-			return CELIX_SUCCESS;
-		}
-		case NOT: {
-			filter_pt sfilter = (filter_pt) filter->value;
-			bool mresult;
-			filter_match(sfilter, properties, &mresult);
-			*result = !mresult;
-			return CELIX_SUCCESS;
-		}
-		case SUBSTRING :
-		case EQUAL :
-		case GREATER :
-        case GREATEREQUAL :
-		case LESS :
-        case LESSEQUAL :
-		case APPROX : {
-			char * value = (properties == NULL) ? NULL: (char*)properties_get(properties, filter->attribute);
-
-			return filter_compare(filter->operand, value, filter->value, result);
-		}
-		case PRESENT: {
-			char * value = (properties == NULL) ? NULL: (char*)properties_get(properties, filter->attribute);
-			*result = value != NULL;
-			return CELIX_SUCCESS;
-		}
-	}
-	*result = 0;
-	return CELIX_SUCCESS;
-}
-
-static celix_status_t filter_compare(OPERAND operand, char * string, void * value2, bool *result) {
-	if (string == NULL) {
-		*result = 0;
-		return CELIX_SUCCESS;
-	}
-	return filter_compareString(operand, string, value2, result);
-
-}
-
-static celix_status_t filter_compareString(OPERAND operand, char * string, void * value2, bool *result) {
-	switch (operand) {
-		case SUBSTRING: {
-			array_list_pt subs = (array_list_pt) value2;
-			int pos = 0;
-			unsigned int i;
-			int size = arrayList_size(subs);
-			for (i = 0; i < size; i++) {
-				char * substr = (char *) arrayList_get(subs, i);
-
-				if (i + 1 < size) {
-					if (substr == NULL) {
-						unsigned int index;
-						char * substr2 = (char *) arrayList_get(subs, i + 1);
-						if (substr2 == NULL) {
-							continue;
-						}
-						index = strcspn(string+pos, substr2);
-						if (index == strlen(string+pos)) {
-							*result = false;
-							return CELIX_SUCCESS;
-						}
-
-						pos = index + strlen(substr2);
-						if (i + 2 < size) {
-							i++;
-						}
-					} else {
-						unsigned int len = strlen(substr);
-						char * region = (char *)malloc(len+1);
-						strncpy(region, string+pos, len);
-						region[len]	= '\0';
-						if (strcmp(region, substr) == 0) {
-							pos += len;
-						} else {
-							free(region);
-							*result = false;
-							return CELIX_SUCCESS;
-						}
-						free(region);
-					}
-				} else {
-					unsigned int len;
-					int begin;
-
-					if (substr == NULL) {
-						*result = true;
-						return CELIX_SUCCESS;
-					}
-					len = strlen(substr);
-					begin = strlen(string)-len;
-					*result = (strcmp(string+begin, substr) == 0);
-					return CELIX_SUCCESS;
-				}
-			}
-			*result = true;
-			return CELIX_SUCCESS;
-		}
-		case APPROX: //TODO: Implement strcmp with ignorecase and ignorespaces
-		case EQUAL: {
-			*result = (strcmp(string, (char *) value2) == 0);
-			return CELIX_SUCCESS;
-		}
-		case GREATER: {
-			*result = (strcmp(string, (char *) value2) > 0);
-			return CELIX_SUCCESS;
-		}
-        case GREATEREQUAL: {
-            *result = (strcmp(string, (char *) value2) >= 0);
-            return CELIX_SUCCESS;
-        }
-		case LESS: {
-			*result = (strcmp(string, (char *) value2) < 0);
-			return CELIX_SUCCESS;
-		}
-        case LESSEQUAL: {
-            *result = (strcmp(string, (char *) value2) <= 0);
-            return CELIX_SUCCESS;
-        }
-		case AND:
-		case NOT:
-		case OR:
-		case PRESENT: {
-		}
-		/* no break */
-	}
-	*result = false;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t filter_getString(filter_pt filter, const char **filterStr) {
-	if (filter != NULL) {
-		*filterStr = filter->filterStr;
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t filter_match_filter(filter_pt src, filter_pt dest, bool *result) {
-	char *srcStr = NULL;
-	char *destStr = NULL;
-	*result = false;
-
-	if (src) srcStr = src->filterStr;
-	if (dest) destStr = dest->filterStr;
-
-	if ((srcStr != NULL) && (destStr != NULL)) {
-		// TODO: should be done smarted, e.g. src="&(a=1)(b=2)" and dest="&(b=2)(a=1)" should result in true
-		*result = (strcmp(srcStr, destStr) == 0);
-	}
-
-	return CELIX_SUCCESS;
-}


[25/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/service_registration_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/service_registration_private.h b/framework/private/include/service_registration_private.h
deleted file mode 100644
index ca0cb67..0000000
--- a/framework/private/include/service_registration_private.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- *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.
- */
-/*
- * service_registration_private.h
- *
- *  \date       Feb 11, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef SERVICE_REGISTRATION_PRIVATE_H_
-#define SERVICE_REGISTRATION_PRIVATE_H_
-
-#include "registry_callback_private.h"
-#include "service_registration.h"
-
-struct serviceRegistration {
-    registry_callback_t callback;
-
-	char * className;
-	bundle_pt bundle;
-	properties_pt properties;
-	const void * svcObj;
-	unsigned long serviceId;
-
-	bool isUnregistering;
-
-	bool isServiceFactory;
-	const void *serviceFactory;
-
-	struct service *services;
-	int nrOfServices;
-
-	size_t refCount; //protected by mutex
-
-	celix_thread_rwlock_t lock;
-};
-
-service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt dictionary);
-service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt dictionary);
-
-void serviceRegistration_retain(service_registration_pt registration);
-void serviceRegistration_release(service_registration_pt registration);
-
-bool serviceRegistration_isValid(service_registration_pt registration);
-void serviceRegistration_invalidate(service_registration_pt registration);
-
-celix_status_t serviceRegistration_getService(service_registration_pt registration, bundle_pt bundle, const void **service);
-celix_status_t serviceRegistration_ungetService(service_registration_pt registration, bundle_pt bundle, const void **service);
-
-celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle);
-celix_status_t serviceRegistration_getServiceName(service_registration_pt registration, const char **serviceName);
-
-#endif /* SERVICE_REGISTRATION_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/service_registry_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/service_registry_private.h b/framework/private/include/service_registry_private.h
deleted file mode 100644
index d68fe11..0000000
--- a/framework/private/include/service_registry_private.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- *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.
- */
-/*
- * service_registry_private.h
- *
- *  \date       Feb 7, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef SERVICE_REGISTRY_PRIVATE_H_
-#define SERVICE_REGISTRY_PRIVATE_H_
-
-#include "registry_callback_private.h"
-#include "service_registry.h"
-
-struct serviceRegistry {
-	framework_pt framework;
-	registry_callback_t callback;
-
-	hash_map_pt serviceRegistrations; //key = bundle (reg owner), value = list ( registration )
-	hash_map_pt serviceReferences; //key = bundle, value = map (key = serviceId, value = reference)
-
-	bool checkDeletedReferences; //If enabled. check if provided service references are still valid
-	hash_map_pt deletedServiceReferences; //key = ref pointer, value = bool
-
-	serviceChanged_function_pt serviceChanged;
-	unsigned long currentServiceId;
-
-	array_list_pt listenerHooks;
-
-	celix_thread_rwlock_t lock;
-};
-
-typedef enum reference_status_enum {
-	REF_ACTIVE,
-	REF_DELETED,
-	REF_UNKNOWN
-} reference_status_t;
-
-struct usageCount {
-	unsigned int count;
-	service_reference_pt reference;
-	void * service;
-	service_registration_pt registration;
-};
-
-typedef struct usageCount * usage_count_pt;
-
-#endif /* SERVICE_REGISTRY_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/service_tracker_customizer_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/service_tracker_customizer_private.h b/framework/private/include/service_tracker_customizer_private.h
deleted file mode 100644
index 61fb52f..0000000
--- a/framework/private/include/service_tracker_customizer_private.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *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.
- */
-/*
- * service_tracker_customizer_private.h
- *
- *  \date       Feb 7, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef SERVICE_TRACKER_CUSTOMIZER_PRIVATE_H_
-#define SERVICE_TRACKER_CUSTOMIZER_PRIVATE_H_
-
-#include "service_reference.h"
-
-#include "service_tracker_customizer.h"
-
-
-struct serviceTrackerCustomizer {
-	void * handle;
-	celix_status_t (*addingService)(void * handle, service_reference_pt reference, void **service);
-	celix_status_t (*addedService)(void * handle, service_reference_pt reference, void * service);
-	celix_status_t (*modifiedService)(void * handle, service_reference_pt reference, void * service);
-
-	/*TODO rename to removingService. because it is invoke during remove not after!*/
-	celix_status_t (*removedService)(void * handle, service_reference_pt reference, void * service);
-
-	/*TODO add removed function ? invoked after the remove ?? */
-};
-
-
-#endif /* SERVICE_TRACKER_CUSTOMIZER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/service_tracker_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/service_tracker_private.h b/framework/private/include/service_tracker_private.h
deleted file mode 100644
index 1d80ba1..0000000
--- a/framework/private/include/service_tracker_private.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- *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.
- */
-/*
- * service_tracker_private.h
- *
- *  \date       Feb 6, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef SERVICE_TRACKER_PRIVATE_H_
-#define SERVICE_TRACKER_PRIVATE_H_
-
-#include "service_tracker.h"
-
-struct serviceTracker {
-	bundle_context_pt context;
-	char * filter;
-
-	service_tracker_pt tracker;
-	service_tracker_customizer_pt customizer;
-	service_listener_pt listener;
-
-	celix_thread_rwlock_t lock; //projects trackedServices
-	array_list_pt trackedServices;
-};
-
-struct tracked {
-	service_reference_pt reference;
-	void * service;
-};
-
-typedef struct tracked * tracked_pt;
-
-#endif /* SERVICE_TRACKER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/unzip.h
----------------------------------------------------------------------
diff --git a/framework/private/include/unzip.h b/framework/private/include/unzip.h
deleted file mode 100644
index 3183968..0000000
--- a/framework/private/include/unzip.h
+++ /dev/null
@@ -1,437 +0,0 @@
-/* unzip.h -- IO for uncompress .zip files using zlib
-   Version 1.1, February 14h, 2010
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications of Unzip for Zip64
-         Copyright (C) 2007-2008 Even Rouault
-
-         Modifications for Zip64 support on both zip and unzip
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-         ---------------------------------------------------------------------------------
-
-        Condition of use and distribution are the same than zlib :
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-
-  ---------------------------------------------------------------------------------
-
-        Changes
-
-        See header of unzip64.c
-
-*/
-
-#ifndef _unz64_H
-#define _unz64_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _ZLIB_H
-#include "zlib.h"
-#endif
-
-#ifndef  _ZLIBIOAPI_H
-#include "ioapi.h"
-#endif
-
-#ifdef HAVE_BZIP2
-#include "bzlib.h"
-#endif
-
-#define Z_BZIP2ED 12
-
-#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
-/* like the STRICT of WIN32, we define a pointer that cannot be converted
-    from (void*) without cast */
-typedef struct TagunzFile__ { int unused; } unzFile__;
-typedef unzFile__ *unzFile;
-#else
-typedef voidp unzFile;
-#endif
-
-
-#define UNZ_OK                          (0)
-#define UNZ_END_OF_LIST_OF_FILE         (-100)
-#define UNZ_ERRNO                       (Z_ERRNO)
-#define UNZ_EOF                         (0)
-#define UNZ_PARAMERROR                  (-102)
-#define UNZ_BADZIPFILE                  (-103)
-#define UNZ_INTERNALERROR               (-104)
-#define UNZ_CRCERROR                    (-105)
-
-/* tm_unz contain date/time info */
-typedef struct tm_unz_s
-{
-    uInt tm_sec;            /* seconds after the minute - [0,59] */
-    uInt tm_min;            /* minutes after the hour - [0,59] */
-    uInt tm_hour;           /* hours since midnight - [0,23] */
-    uInt tm_mday;           /* day of the month - [1,31] */
-    uInt tm_mon;            /* months since January - [0,11] */
-    uInt tm_year;           /* years - [1980..2044] */
-} tm_unz;
-
-/* unz_global_info structure contain global data about the ZIPfile
-   These data comes from the end of central dir */
-typedef struct unz_global_info64_s
-{
-    ZPOS64_T number_entry;         /* total number of entries in
-                                     the central dir on this disk */
-    uLong size_comment;         /* size of the global comment of the zipfile */
-} unz_global_info64;
-
-typedef struct unz_global_info_s
-{
-    uLong number_entry;         /* total number of entries in
-                                     the central dir on this disk */
-    uLong size_comment;         /* size of the global comment of the zipfile */
-} unz_global_info;
-
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_info64_s
-{
-    uLong version;              /* version made by                 2 bytes */
-    uLong version_needed;       /* version needed to extract       2 bytes */
-    uLong flag;                 /* general purpose bit flag        2 bytes */
-    uLong compression_method;   /* compression method              2 bytes */
-    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
-    uLong crc;                  /* crc-32                          4 bytes */
-    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */
-    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */
-    uLong size_filename;        /* filename length                 2 bytes */
-    uLong size_file_extra;      /* extra field length              2 bytes */
-    uLong size_file_comment;    /* file comment length             2 bytes */
-
-    uLong disk_num_start;       /* disk number start               2 bytes */
-    uLong internal_fa;          /* internal file attributes        2 bytes */
-    uLong external_fa;          /* external file attributes        4 bytes */
-
-    tm_unz tmu_date;
-} unz_file_info64;
-
-typedef struct unz_file_info_s
-{
-    uLong version;              /* version made by                 2 bytes */
-    uLong version_needed;       /* version needed to extract       2 bytes */
-    uLong flag;                 /* general purpose bit flag        2 bytes */
-    uLong compression_method;   /* compression method              2 bytes */
-    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
-    uLong crc;                  /* crc-32                          4 bytes */
-    uLong compressed_size;      /* compressed size                 4 bytes */
-    uLong uncompressed_size;    /* uncompressed size               4 bytes */
-    uLong size_filename;        /* filename length                 2 bytes */
-    uLong size_file_extra;      /* extra field length              2 bytes */
-    uLong size_file_comment;    /* file comment length             2 bytes */
-
-    uLong disk_num_start;       /* disk number start               2 bytes */
-    uLong internal_fa;          /* internal file attributes        2 bytes */
-    uLong external_fa;          /* external file attributes        4 bytes */
-
-    tm_unz tmu_date;
-} unz_file_info;
-
-extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
-                                                 const char* fileName2,
-                                                 int iCaseSensitivity));
-/*
-   Compare two filename (fileName1,fileName2).
-   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
-   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
-                                or strcasecmp)
-   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
-    (like 1 on Unix, 2 on Windows)
-*/
-
-
-extern unzFile ZEXPORT unzOpen OF((const char *path));
-extern unzFile ZEXPORT unzOpen64 OF((const void *path));
-/*
-  Open a Zip file. path contain the full pathname (by example,
-     on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
-     "zlib/zlib113.zip".
-     If the zipfile cannot be opened (file don't exist or in not valid), the
-       return value is NULL.
-     Else, the return value is a unzFile Handle, usable with other function
-       of this unzip package.
-     the "64" function take a const void* pointer, because the path is just the
-       value passed to the open64_file_func callback.
-     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
-       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
-       does not describe the reality
-*/
-
-
-extern unzFile ZEXPORT unzOpen2 OF((const char *path,
-                                    zlib_filefunc_def* pzlib_filefunc_def));
-/*
-   Open a Zip file, like unzOpen, but provide a set of file low level API
-      for read/write the zip file (see ioapi.h)
-*/
-
-extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
-                                    zlib_filefunc64_def* pzlib_filefunc_def));
-/*
-   Open a Zip file, like unz64Open, but provide a set of file low level API
-      for read/write the zip file (see ioapi.h)
-*/
-
-extern int ZEXPORT unzClose OF((unzFile file));
-/*
-  Close a ZipFile opened with unzipOpen.
-  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
-    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
-  return UNZ_OK if there is no problem. */
-
-extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
-                                        unz_global_info *pglobal_info));
-
-extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
-                                        unz_global_info64 *pglobal_info));
-/*
-  Write info about the ZipFile in the *pglobal_info structure.
-  No preparation of the structure is needed
-  return UNZ_OK if there is no problem. */
-
-
-extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
-                                           char *szComment,
-                                           uLong uSizeBuf));
-/*
-  Get the global comment string of the ZipFile, in the szComment buffer.
-  uSizeBuf is the size of the szComment buffer.
-  return the number of byte copied or an error code <0
-*/
-
-
-/***************************************************************************/
-/* Unzip package allow you browse the directory of the zipfile */
-
-extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
-/*
-  Set the current file of the zipfile to the first file.
-  return UNZ_OK if there is no problem
-*/
-
-extern int ZEXPORT unzGoToNextFile OF((unzFile file));
-/*
-  Set the current file of the zipfile to the next file.
-  return UNZ_OK if there is no problem
-  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-
-extern int ZEXPORT unzLocateFile OF((unzFile file,
-                     const char *szFileName,
-                     int iCaseSensitivity));
-/*
-  Try locate the file szFileName in the zipfile.
-  For the iCaseSensitivity signification, see unzStringFileNameCompare
-
-  return value :
-  UNZ_OK if the file is found. It becomes the current file.
-  UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-
-
-/* ****************************************** */
-/* Ryan supplied functions */
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_pos_s
-{
-    uLong pos_in_zip_directory;   /* offset in zip file directory */
-    uLong num_of_file;            /* # of file */
-} unz_file_pos;
-
-extern int ZEXPORT unzGetFilePos(
-    unzFile file,
-    unz_file_pos* file_pos);
-
-extern int ZEXPORT unzGoToFilePos(
-    unzFile file,
-    unz_file_pos* file_pos);
-
-typedef struct unz64_file_pos_s
-{
-    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */
-    ZPOS64_T num_of_file;            /* # of file */
-} unz64_file_pos;
-
-extern int ZEXPORT unzGetFilePos64(
-    unzFile file,
-    unz64_file_pos* file_pos);
-
-extern int ZEXPORT unzGoToFilePos64(
-    unzFile file,
-    const unz64_file_pos* file_pos);
-
-/* ****************************************** */
-
-extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
-                         unz_file_info64 *pfile_info,
-                         char *szFileName,
-                         uLong fileNameBufferSize,
-                         void *extraField,
-                         uLong extraFieldBufferSize,
-                         char *szComment,
-                         uLong commentBufferSize));
-
-extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
-                         unz_file_info *pfile_info,
-                         char *szFileName,
-                         uLong fileNameBufferSize,
-                         void *extraField,
-                         uLong extraFieldBufferSize,
-                         char *szComment,
-                         uLong commentBufferSize));
-/*
-  Get Info about the current file
-  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
-        the current file
-  if szFileName!=NULL, the filemane string will be copied in szFileName
-            (fileNameBufferSize is the size of the buffer)
-  if extraField!=NULL, the extra field information will be copied in extraField
-            (extraFieldBufferSize is the size of the buffer).
-            This is the Central-header version of the extra field
-  if szComment!=NULL, the comment string of the file will be copied in szComment
-            (commentBufferSize is the size of the buffer)
-*/
-
-
-/** Addition for GDAL : START */
-
-extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
-
-/** Addition for GDAL : END */
-
-
-/***************************************************************************/
-/* for reading the content of the current zipfile, you can open it, read data
-   from it, and close it (you can close it before reading all the file)
-   */
-
-extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
-/*
-  Open for reading data the current file in the zipfile.
-  If there is no error, the return value is UNZ_OK.
-*/
-
-extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
-                                                  const char* password));
-/*
-  Open for reading data the current file in the zipfile.
-  password is a crypting password
-  If there is no error, the return value is UNZ_OK.
-*/
-
-extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
-                                           int* method,
-                                           int* level,
-                                           int raw));
-/*
-  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
-    if raw==1
-  *method will receive method of compression, *level will receive level of
-     compression
-  note : you can set level parameter as NULL (if you did not want known level,
-         but you CANNOT set method parameter as NULL
-*/
-
-extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
-                                           int* method,
-                                           int* level,
-                                           int raw,
-                                           const char* password));
-/*
-  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
-    if raw==1
-  *method will receive method of compression, *level will receive level of
-     compression
-  note : you can set level parameter as NULL (if you did not want known level,
-         but you CANNOT set method parameter as NULL
-*/
-
-
-extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
-/*
-  Close the file in zip opened with unzOpenCurrentFile
-  Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-
-extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
-                      voidp buf,
-                      unsigned len));
-/*
-  Read bytes from the current file (opened by unzOpenCurrentFile)
-  buf contain buffer where data must be copied
-  len the size of buf.
-
-  return the number of byte copied if somes bytes are copied
-  return 0 if the end of file was reached
-  return <0 with error code if there is an error
-    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-
-extern z_off_t ZEXPORT unztell OF((unzFile file));
-
-extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
-/*
-  Give the current position in uncompressed data
-*/
-
-extern int ZEXPORT unzeof OF((unzFile file));
-/*
-  return 1 if the end of file was reached, 0 elsewhere
-*/
-
-extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
-                                             voidp buf,
-                                             unsigned len));
-/*
-  Read extra field from the current file (opened by unzOpenCurrentFile)
-  This is the local-header version of the extra field (sometimes, there is
-    more info in the local-header version than in the central-header)
-
-  if buf==NULL, it return the size of the local extra field
-
-  if buf!=NULL, len is the size of the buffer, the extra header is copied in
-    buf.
-  the return value is the number of bytes copied in buf, or (if <0)
-    the error code
-*/
-
-/***************************************************************************/
-
-/* Get the current file offset */
-extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
-extern uLong ZEXPORT unzGetOffset (unzFile file);
-
-/* Set the current file offset */
-extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
-extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _unz64_H */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/attribute.c
----------------------------------------------------------------------
diff --git a/framework/private/src/attribute.c b/framework/private/src/attribute.c
deleted file mode 100644
index 318d8f5..0000000
--- a/framework/private/src/attribute.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- *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.
- */
-/*
- * attribute.c
- *
- *  \date       Jul 27, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "attribute_private.h"
-#include "celix_log.h"
-
-celix_status_t attribute_create(char * key, char * value, attribute_pt *attribute) {
-	celix_status_t status = CELIX_SUCCESS;
-	char *error = NULL;
-
-	if (key == NULL || value == NULL || *attribute != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	    error = "Missing required arguments and/or values";
-	} else {
-		attribute_pt attr = malloc(sizeof(*attr));
-		if (!attr) {
-			status = CELIX_ENOMEM;
-		} else {
-			attr->key = key;
-			attr->value = value;
-
-			*attribute = attr;
-		}
-	}
-
-	framework_logIfError(logger, status, error, "Could not create attribute: [key=%s;value=%s]", key, value);
-
-	return status;
-}
-
-celix_status_t attribute_destroy(attribute_pt attribute) {
-    free(attribute->key);
-    free(attribute->value);
-    free(attribute);
-    return CELIX_SUCCESS;
-}
-
-celix_status_t attribute_getKey(attribute_pt attribute, char **key) {
-	*key = attribute->key;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t attribute_getValue(attribute_pt attribute, char **value) {
-	*value = attribute->value;
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/bundle.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle.c b/framework/private/src/bundle.c
deleted file mode 100644
index a0e6b3d..0000000
--- a/framework/private/src/bundle.c
+++ /dev/null
@@ -1,695 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle.c
- *
- *  \date       Mar 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "framework_private.h"
-#include "bundle_private.h"
-#include "resolver.h"
-#include "utils.h"
-
-celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module);
-celix_status_t bundle_closeRevisions(bundle_pt bundle);
-
-celix_status_t bundle_create(bundle_pt * bundle) {
-    celix_status_t status;
-    bundle_archive_pt archive = NULL;
-
-	*bundle = (bundle_pt) malloc(sizeof(**bundle));
-	if (*bundle == NULL) {
-		return CELIX_ENOMEM;
-	}
-	status = bundleArchive_createSystemBundleArchive(&archive);
-	if (status == CELIX_SUCCESS) {
-        module_pt module;
-
-        (*bundle)->archive = archive;
-        (*bundle)->activator = NULL;
-        (*bundle)->context = NULL;
-        (*bundle)->framework = NULL;
-        (*bundle)->state = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
-        (*bundle)->modules = NULL;
-        arrayList_create(&(*bundle)->modules);
-        (*bundle)->handle = NULL;
-        (*bundle)->manifest = NULL;
-
-        module = module_createFrameworkModule((*bundle));
-        bundle_addModule(*bundle, module);
-
-        status = celixThreadMutex_create(&(*bundle)->lock, NULL);
-        if (status != CELIX_SUCCESS) {
-        	status = CELIX_ILLEGAL_STATE;
-        } else {
-			(*bundle)->lockCount = 0;
-			(*bundle)->lockThread = celix_thread_default;
-        }
-	}
-	framework_logIfError(logger, status, NULL, "Failed to create bundle");
-
-	return status;
-}
-
-celix_status_t bundle_createFromArchive(bundle_pt * bundle, framework_pt framework, bundle_archive_pt archive) {
-    module_pt module;
-	
-	celix_status_t status;
-
-	*bundle = (bundle_pt) malloc(sizeof(**bundle));
-	if (*bundle == NULL) {
-		return CELIX_ENOMEM;
-	}
-	(*bundle)->archive = archive;
-	(*bundle)->activator = NULL;
-	(*bundle)->context = NULL;
-	(*bundle)->handle = NULL;
-	(*bundle)->manifest = NULL;
-	(*bundle)->framework = framework;
-	(*bundle)->state = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
-	(*bundle)->modules = NULL;
-	arrayList_create(&(*bundle)->modules);
-	
-	status = bundle_createModule(*bundle, &module);
-	if (status == CELIX_SUCCESS) {
-		bundle_addModule(*bundle, module);
-        status = celixThreadMutex_create(&(*bundle)->lock, NULL);
-        if (status != CELIX_SUCCESS) {
-			status = CELIX_ILLEGAL_STATE;
-		} else {
-			(*bundle)->lockCount = 0;
-			(*bundle)->lockThread = celix_thread_default;
-		}
-	} else {
-	    status = CELIX_FILE_IO_EXCEPTION;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to create bundle");
-
-	return status;
-}
-
-celix_status_t bundle_destroy(bundle_pt bundle) {
-	array_list_iterator_pt iter = arrayListIterator_create(bundle->modules);
-	while (arrayListIterator_hasNext(iter)) {
-		module_pt module = arrayListIterator_next(iter);
-		module_destroy(module);
-	}
-	arrayListIterator_destroy(iter);
-	arrayList_destroy(bundle->modules);
-	celixThreadMutex_destroy(&bundle->lock);
-
-	free(bundle);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundle_getArchive(bundle_pt bundle, bundle_archive_pt *archive) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (bundle != NULL && *archive == NULL) {
-		*archive = bundle->archive;
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get bundle archive");
-
-	return status;
-}
-
-celix_status_t bundle_getCurrentModule(bundle_pt bundle, module_pt *module) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (bundle == NULL || arrayList_size(bundle->modules)==0 ) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*module = arrayList_get(bundle->modules, arrayList_size(bundle->modules) - 1);
-	}
-
-	return status;
-}
-
-array_list_pt bundle_getModules(bundle_pt bundle) {
-    return bundle->modules;
-}
-
-void * bundle_getHandle(bundle_pt bundle) {
-	return bundle->handle;
-}
-
-void bundle_setHandle(bundle_pt bundle, void * handle) {
-	bundle->handle = handle;
-}
-
-activator_pt bundle_getActivator(bundle_pt bundle) {
-	return bundle->activator;
-}
-
-celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator) {
-	bundle->activator = activator;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context) {
-	*context = bundle->context;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundle_setContext(bundle_pt bundle, bundle_context_pt context) {
-	bundle->context = context;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundle_getEntry(bundle_pt bundle, const char* name, char** entry) {
-	return framework_getBundleEntry(bundle->framework, bundle, name, entry);
-}
-
-celix_status_t bundle_getState(bundle_pt bundle, bundle_state_e *state) {
-	if(bundle==NULL){
-		*state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
-		return CELIX_BUNDLE_EXCEPTION;
-	}
-	*state = bundle->state;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundle_setState(bundle_pt bundle, bundle_state_e state) {
-	bundle->state = state;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_archive_pt archive = NULL;
-	bundle_revision_pt revision = NULL;
-	manifest_pt headerMap = NULL;
-
-	status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
-	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
-	status = CELIX_DO_IF(status, bundleRevision_getManifest(revision, &headerMap));
-	if (status == CELIX_SUCCESS) {
-		long bundleId = 0;
-        status = bundleArchive_getId(bundle->archive, &bundleId);
-        if (status == CELIX_SUCCESS) {
-			int revision = 0;
-			char moduleId[512];
-
-			snprintf(moduleId, sizeof(moduleId), "%ld.%d", bundleId, revision);
-			*module = module_create(headerMap, moduleId, bundle);
-
-			if (*module != NULL) {
-				version_pt bundleVersion = module_getVersion(*module);
-				const char * symName = NULL;
-				status = module_getSymbolicName(*module, &symName);
-				if (status == CELIX_SUCCESS) {
-					array_list_pt bundles = framework_getBundles(bundle->framework);
-					unsigned int i;
-					for (i = 0; i < arrayList_size(bundles); i++) {
-						bundle_pt check = (bundle_pt) arrayList_get(bundles, i);
-
-						long id;
-						if (bundleArchive_getId(check->archive, &id) == CELIX_SUCCESS) {
-							if (id != bundleId) {
-								module_pt mod = NULL;
-								const char * sym = NULL;
-								version_pt version;
-								int cmp;
-								status = bundle_getCurrentModule(check, &mod);
-								status = module_getSymbolicName(mod, &sym);
-
-								version = module_getVersion(mod);
-								version_compareTo(bundleVersion, version, &cmp);
-								if ((symName != NULL) && (sym != NULL) && !strcmp(symName, sym) &&
-										!cmp) {
-									char *versionString = NULL;
-									version_toString(version, &versionString);
-									printf("Bundle symbolic name and version are not unique: %s:%s\n", sym, versionString);
-									free(versionString);
-									status = CELIX_BUNDLE_EXCEPTION;
-									break;
-								}
-							}
-						}
-					}
-					arrayList_destroy(bundles);
-				}
-			}
-        }
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to create module");
-
-	return status;
-}
-
-celix_status_t bundle_start(bundle_pt bundle) {
-	return bundle_startWithOptions(bundle, 0);
-}
-
-celix_status_t bundle_startWithOptions(bundle_pt bundle, int options) {
-	celix_status_t status = CELIX_SUCCESS;
-    if (bundle != NULL) {
-    	bool systemBundle = false;
-    	status = bundle_isSystemBundle(bundle, &systemBundle);
-    	if (status == CELIX_SUCCESS) {
-    		if (systemBundle) {
-    			framework_start(bundle->framework);
-    		} else {
-    			status = fw_startBundle(bundle->framework, bundle, options);
-    		}
-    	}
-    }
-
-	framework_logIfError(logger, status, NULL, "Failed to start bundle");
-
-    return status;
-}
-
-celix_status_t bundle_update(bundle_pt bundle, const char *inputFile) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (bundle != NULL) {
-		bool systemBundle = false;
-		status = bundle_isSystemBundle(bundle, &systemBundle);
-		if (status == CELIX_SUCCESS) {
-			if (systemBundle) {
-				// #TODO: Support framework update
-				status = CELIX_BUNDLE_EXCEPTION;
-			} else {
-				status = framework_updateBundle(bundle->framework, bundle, inputFile);
-			}
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to update bundle");
-
-	return status;
-}
-
-celix_status_t bundle_stop(bundle_pt bundle) {
-	return bundle_stopWithOptions(bundle, 0);
-}
-
-celix_status_t bundle_stopWithOptions(bundle_pt bundle, int options) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (bundle != NULL) {
-		bool systemBundle = false;
-		status = bundle_isSystemBundle(bundle, &systemBundle);
-		if (status == CELIX_SUCCESS) {
-			if (systemBundle) {
-				framework_stop(bundle->framework);
-			} else {
-				status = fw_stopBundle(bundle->framework, bundle, options);
-			}
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to stop bundle");
-
-	return status;
-}
-
-celix_status_t bundle_uninstall(bundle_pt bundle) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (bundle != NULL) {
-		bool systemBundle = false;
-		status = bundle_isSystemBundle(bundle, &systemBundle);
-		if (status == CELIX_SUCCESS) {
-			if (systemBundle) {
-				status = CELIX_BUNDLE_EXCEPTION;
-			} else {
-				status = fw_uninstallBundle(bundle->framework, bundle);
-			}
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to uninstall bundle");
-
-	return status;
-}
-
-celix_status_t bundle_setPersistentStateInactive(bundle_pt bundle) {
-	celix_status_t status;
-	bool systemBundle;
-
-	status = bundle_isSystemBundle(bundle, &systemBundle);
-	if (status == CELIX_SUCCESS) {
-		if (!systemBundle) {
-			status = bundleArchive_setPersistentState(bundle->archive, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to set persistent state to inactive");
-
-	return status;
-}
-
-celix_status_t bundle_setPersistentStateUninstalled(bundle_pt bundle) {
-	celix_status_t status;
-	bool systemBundle;
-
-	status = bundle_isSystemBundle(bundle, &systemBundle);
-	if (status == CELIX_SUCCESS) {
-		if (!systemBundle) {
-			status = bundleArchive_setPersistentState(bundle->archive, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED);
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to set persistent state to uninstalled");
-
-    return status;
-}
-
-celix_status_t bundle_revise(bundle_pt bundle, const char * location, const char *inputFile) {
-	celix_status_t status;
-
-	bundle_archive_pt archive = NULL;
-	status = bundle_getArchive(bundle, &archive);
-	if (status == CELIX_SUCCESS) {
-		status = bundleArchive_revise(archive, location, inputFile);
-		if (status == CELIX_SUCCESS) {
-			module_pt module;
-			status = bundle_createModule(bundle, &module);
-			if (status == CELIX_SUCCESS) {
-				status = bundle_addModule(bundle, module);
-			} else {
-				bool rolledback;
-				status = bundleArchive_rollbackRevise(archive, &rolledback);
-				if (status == CELIX_SUCCESS) {
-					status = CELIX_BUNDLE_EXCEPTION;
-				}
-			}
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to revise bundle");
-
-	return status;
-}
-
-//bool bundle_rollbackRevise(bundle_pt bundle) {
-//	module_pt module = arrayList_remove(bundle->modules, arrayList_set(bundle->modules) - 1);
-//	return resolver_removeModule(module);
-//}
-
-celix_status_t bundle_addModule(bundle_pt bundle, module_pt module) {
-	arrayList_add(bundle->modules, module);
-	resolver_addModule(module);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundle_isSystemBundle(bundle_pt bundle, bool *systemBundle) {
-	celix_status_t status;
-	long bundleId;
-	bundle_archive_pt archive = NULL;
-
-	status = bundle_getArchive(bundle, &archive);
-	if (status == CELIX_SUCCESS) {
-		status = bundleArchive_getId(archive, &bundleId);
-		if (status == CELIX_SUCCESS) {
-			*systemBundle = (bundleId == 0);
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to check if bundle is the systembundle");
-
-	return status;
-}
-
-celix_status_t bundle_isLockable(bundle_pt bundle, bool *lockable) {
-	celix_status_t status;
-
-	status = celixThreadMutex_lock(&bundle->lock);
-	if (status != CELIX_SUCCESS) {
-		status = CELIX_BUNDLE_EXCEPTION;
-	} else {
-		bool equals;
-		status = thread_equalsSelf(bundle->lockThread, &equals);
-		if (status == CELIX_SUCCESS) {
-			*lockable = (bundle->lockCount == 0) || (equals);
-		}
-
-		status = celixThreadMutex_unlock(&bundle->lock);
-		if (status != CELIX_SUCCESS) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to check if bundle is lockable");
-
-	return status;
-}
-
-celix_status_t bundle_getLockingThread(bundle_pt bundle, celix_thread_t *thread) {
-	celix_status_t status;
-
-	status = celixThreadMutex_lock(&bundle->lock);
-	if (status != CELIX_SUCCESS) {
-		status = CELIX_BUNDLE_EXCEPTION;
-	} else {
-		*thread = bundle->lockThread;
-
-		status = celixThreadMutex_unlock(&bundle->lock);
-		if (status != CELIX_SUCCESS) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get locking thread");
-
-	return status;
-}
-
-celix_status_t bundle_lock(bundle_pt bundle, bool *locked) {
-	celix_status_t status;
-	bool equals;
-
-	celixThreadMutex_lock(&bundle->lock);
-
-	status = thread_equalsSelf(bundle->lockThread, &equals);
-	if (status == CELIX_SUCCESS) {
-		if ((bundle->lockCount > 0) && !equals) {
-			*locked = false;
-		} else {
-			bundle->lockCount++;
-			bundle->lockThread = celixThread_self();
-			*locked = true;
-		}
-	}
-
-	celixThreadMutex_unlock(&bundle->lock);
-
-	framework_logIfError(logger, status, NULL, "Failed to lock bundle");
-
-	return status;
-}
-
-celix_status_t bundle_unlock(bundle_pt bundle, bool *unlocked) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bool equals;
-
-	celixThreadMutex_lock(&bundle->lock);
-
-	if (bundle->lockCount == 0) {
-		*unlocked = false;
-	} else {
-		status = thread_equalsSelf(bundle->lockThread, &equals);
-		if (status == CELIX_SUCCESS) {
-			if ((bundle->lockCount > 0) && !equals) {
-				*unlocked = false;
-			}
-			else{
-			   bundle->lockCount--;
-			   if (bundle->lockCount == 0) {
-			   	bundle->lockThread = celix_thread_default;
-			   }
-			   *unlocked = true;
-		   }
-	   }
-	}
-
-	celixThreadMutex_unlock(&bundle->lock);
-
-	framework_logIfError(logger, status, NULL, "Failed to unlock bundle");
-
-	return status;
-}
-
-celix_status_t bundle_close(bundle_pt bundle) {
-	bundle_archive_pt archive = NULL;
-	
-	celix_status_t status;
-
-    bundle_closeModules(bundle);
-    bundle_closeRevisions(bundle);
-    status = bundle_getArchive(bundle, &archive);
-    if (status == CELIX_SUCCESS) {
-		bundleArchive_close(archive);
-    }
-
-	framework_logIfError(logger, status, NULL, "Failed to close bundle");
-
-    return status;
-}
-
-celix_status_t bundle_closeAndDelete(bundle_pt bundle) {
-	celix_status_t status;
-
-	bundle_archive_pt archive = NULL;
-
-    bundle_closeModules(bundle);
-    bundle_closeRevisions(bundle);
-    status = bundle_getArchive(bundle, &archive);
-    if (status == CELIX_SUCCESS) {
-    	bundleArchive_closeAndDelete(archive);
-    }
-
-	framework_logIfError(logger, status, NULL, "Failed to close and delete bundle");
-
-    return status;
-}
-
-celix_status_t bundle_closeRevisions(bundle_pt bundle) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    // TODO implement this
-    return status;
-}
-
-celix_status_t bundle_closeModules(bundle_pt bundle) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    unsigned int i = 0;
-    for (i = 0; i < arrayList_size(bundle->modules); i++) {
-        module_pt module = (module_pt) arrayList_get(bundle->modules, i);
-        resolver_removeModule(module);
-        module_setWires(module, NULL);
-    }
-
-    return status;
-}
-
-celix_status_t bundle_refresh(bundle_pt bundle) {
-	celix_status_t status;
-	module_pt module;
-
-	status = bundle_closeModules(bundle);
-	if (status == CELIX_SUCCESS) {
-		arrayList_clear(bundle->modules);
-		status = bundle_createModule(bundle, &module);
-		if (status == CELIX_SUCCESS) {
-			status = bundle_addModule(bundle, module);
-			if (status == CELIX_SUCCESS) {
-				bundle->state = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
-			}
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to refresh bundle");
-
-    return status;
-}
-
-celix_status_t bundle_getBundleId(bundle_pt bundle, long *id) {
-	celix_status_t status;
-	bundle_archive_pt archive = NULL;
-	status = bundle_getArchive(bundle, &archive);
-	if (status == CELIX_SUCCESS) {
-		status = bundleArchive_getId(archive, id);
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get bundle id");
-
-	return status;
-}
-
-celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *list) {
-	celix_status_t status;
-
-	status = fw_getBundleRegisteredServices(bundle->framework, bundle, list);
-
-	framework_logIfError(bundle->framework->logger, status, NULL, "Failed to get registered services");
-
-	return status;
-}
-
-celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list) {
-	celix_status_t status;
-
-	status = fw_getBundleServicesInUse(bundle->framework, bundle, list);
-
-	framework_logIfError(logger, status, NULL, "Failed to get in use services");
-
-	return status;
-}
-
-celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (bundle != NULL && framework != NULL) {
-		bundle->framework = framework;
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to set framework");
-
-	return status;
-}
-
-celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (bundle != NULL && *framework == NULL) {
-		*framework = bundle->framework;
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get framework");
-
-	return status;
-}
-
-celix_status_t bundle_getBundleLocation(bundle_pt bundle, const char **location){
-
-	celix_status_t status;
-
-	bundle_archive_pt archive = NULL;
-
-	status = bundle_getArchive(bundle, &archive);
-	if (status != CELIX_SUCCESS){
-		printf("[ ERROR ]: Bundle - getBundleLocation (BundleArchive) \n");
-		return status;
-	}
-
-	status =  bundleArchive_getLocation(archive, location);
-	if (status != CELIX_SUCCESS){
-		printf("[ ERROR ]:  Bundle - getBundleLocation (BundleArchiveLocation) \n");
-		return status;
-	}
-
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/bundle_archive.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_archive.c b/framework/private/src/bundle_archive.c
deleted file mode 100644
index cde727e..0000000
--- a/framework/private/src/bundle_archive.c
+++ /dev/null
@@ -1,792 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_archive.c
- *
- *  \date       Aug 8, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <unistd.h>
-
-#include "bundle_archive.h"
-#include "linked_list_iterator.h"
-
-struct bundleArchive {
-	long id;
-	char * location;
-	DIR *archiveRootDir;
-	char * archiveRoot;
-	linked_list_pt revisions;
-	long refreshCount;
-	time_t lastModified;
-
-	bundle_state_e persistentState;
-};
-
-static celix_status_t bundleArchive_getRevisionLocation(bundle_archive_pt archive, long revNr, char **revision_location);
-static celix_status_t bundleArchive_setRevisionLocation(bundle_archive_pt archive, const char * location, long revNr);
-
-static celix_status_t bundleArchive_initialize(bundle_archive_pt archive);
-
-static celix_status_t bundleArchive_deleteTree(bundle_archive_pt archive, const char * directory);
-
-static celix_status_t bundleArchive_createRevisionFromLocation(bundle_archive_pt archive, const char *location, const char *inputFile, long revNr, bundle_revision_pt *bundle_revision);
-static celix_status_t bundleArchive_reviseInternal(bundle_archive_pt archive, bool isReload, long revNr, const char * location, const char *inputFile);
-
-static celix_status_t bundleArchive_readLastModified(bundle_archive_pt archive, time_t *time);
-static celix_status_t bundleArchive_writeLastModified(bundle_archive_pt archive);
-
-celix_status_t bundleArchive_createSystemBundleArchive(bundle_archive_pt *bundle_archive) {
-	celix_status_t status = CELIX_SUCCESS;
-	char *error = NULL;
-	bundle_archive_pt archive = NULL;
-
-	if (*bundle_archive != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-		error = "Missing required arguments and/or incorrect values";
-	} else {
-		archive = (bundle_archive_pt) calloc(1,sizeof(*archive));
-		if (archive == NULL) {
-			status = CELIX_ENOMEM;
-		} else {
-			status = linkedList_create(&archive->revisions);
-			if (status == CELIX_SUCCESS) {
-				archive->id = 0l;
-				archive->location = strdup("System Bundle");
-				archive->archiveRoot = NULL;
-				archive->archiveRootDir = NULL;
-				archive->refreshCount = -1;
-				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
-				time(&archive->lastModified);
-
-				*bundle_archive = archive;
-			}
-		}
-	}
-
-	if(status != CELIX_SUCCESS && archive != NULL){
-		bundleArchive_destroy(archive);
-	}
-
-	framework_logIfError(logger, status, error, "Could not create archive");
-
-	return status;
-}
-
-celix_status_t bundleArchive_create(const char *archiveRoot, long id, const char * location, const char *inputFile, bundle_archive_pt *bundle_archive) {
-	celix_status_t status = CELIX_SUCCESS;
-	char *error = NULL;
-	bundle_archive_pt archive = NULL;
-
-	if (*bundle_archive != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-		error = "bundle_archive_pt must be NULL";
-	} else {
-		archive = (bundle_archive_pt) calloc(1,sizeof(*archive));
-		if (archive == NULL) {
-			status = CELIX_ENOMEM;
-		} else {
-			status = linkedList_create(&archive->revisions);
-			if (status == CELIX_SUCCESS) {
-				archive->id = id;
-				archive->location = strdup(location);
-				archive->archiveRootDir = NULL;
-				archive->archiveRoot = strdup(archiveRoot);
-				archive->refreshCount = -1;
-				time(&archive->lastModified);
-
-				status = bundleArchive_initialize(archive);
-				if (status == CELIX_SUCCESS) {
-					status = bundleArchive_revise(archive, location, inputFile);
-
-					if (status == CELIX_SUCCESS) {
-						*bundle_archive = archive;
-					}
-					else{
-						bundleArchive_closeAndDelete(archive);
-					}
-				}
-			}
-		}
-	}
-
-	if(status != CELIX_SUCCESS && archive != NULL){
-		bundleArchive_destroy(archive);
-	}
-
-	framework_logIfError(logger, status, error, "Could not create archive");
-
-	return status;
-}
-
-celix_status_t bundleArchive_destroy(bundle_archive_pt archive) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if(archive != NULL){
-		if (archive->revisions != NULL) {
-			linked_list_iterator_pt iter = linkedListIterator_create(archive->revisions, 0);
-			while(linkedListIterator_hasNext(iter)) {
-				bundle_revision_pt rev = linkedListIterator_next(iter);
-				bundleRevision_destroy(rev);
-			}
-			linkedListIterator_destroy(iter);
-			linkedList_destroy(archive->revisions);
-		}
-		if (archive->archiveRoot != NULL) {
-			free(archive->archiveRoot);
-		}
-		if (archive->location != NULL) {
-			free(archive->location);
-		}
-
-		free(archive);
-		archive = NULL;
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not create archive");
-
-	return status;
-}
-
-celix_status_t bundleArchive_recreate(const char * archiveRoot, bundle_archive_pt *bundle_archive) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bundle_archive_pt archive = NULL;
-
-	archive = (bundle_archive_pt) calloc(1,sizeof(*archive));
-	if (archive == NULL) {
-		status = CELIX_ENOMEM;
-	} else {
-		status = linkedList_create(&archive->revisions);
-		if (status == CELIX_SUCCESS) {
-			archive->archiveRoot = strdup(archiveRoot);
-			archive->archiveRootDir = NULL;
-			archive->id = -1;
-			archive->persistentState = -1;
-			archive->location = NULL;
-			archive->refreshCount = -1;
-			archive->lastModified = (time_t) NULL;
-
-			archive->archiveRootDir = opendir(archiveRoot);
-			if (archive->archiveRootDir == NULL) {
-				status = CELIX_FRAMEWORK_EXCEPTION;
-			} else {
-
-				long idx = 0;
-				long highestId = -1;
-				char *location = NULL;
-
-				struct dirent *dent = NULL;
-				struct stat st;
-
-                errno = 0;
-                dent = readdir(archive->archiveRootDir);
-				while (errno == 0 && dent != NULL) {
-					char subdir[512];
-					snprintf(subdir, 512, "%s/%s", archiveRoot, dent->d_name);
-					int rv = stat(subdir, &st);
-					if (rv == 0 && S_ISDIR(st.st_mode) && (strncmp(dent->d_name, "version", 7) == 0)) {
-						sscanf(dent->d_name, "version%*d.%ld", &idx);
-						if (idx > highestId) {
-							highestId = idx;
-						}
-					}
-                    errno = 0;
-                    dent = readdir(archive->archiveRootDir);
-				}
-
-				status = CELIX_DO_IF(status, bundleArchive_getRevisionLocation(archive, 0, &location));
-				status = CELIX_DO_IF(status, bundleArchive_reviseInternal(archive, true, highestId, location, NULL));
-				if (location) {
-					free(location);
-				}
-				if (status == CELIX_SUCCESS) {
-					*bundle_archive = archive;
-				}
-				closedir(archive->archiveRootDir);
-			}
-		}
-	}
-
-	if(status != CELIX_SUCCESS && archive != NULL){
-		bundleArchive_destroy(archive);
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not create archive");
-
-	return status;
-}
-
-celix_status_t bundleArchive_getId(bundle_archive_pt archive, long *id) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (archive->id < 0) {
-		FILE *bundleIdFile;
-		char id[256];
-		char bundleId[512];
-		snprintf(bundleId, sizeof(bundleId), "%s/bundle.id", archive->archiveRoot);
-
-		bundleIdFile = fopen(bundleId, "r");
-		if(bundleIdFile!=NULL){
-			fgets(id, sizeof(id), bundleIdFile);
-			fclose(bundleIdFile);
-			sscanf(id, "%ld", &archive->id);
-		}
-		else{
-			status = CELIX_FILE_IO_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*id = archive->id;
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not get archive id");
-
-	return status;
-}
-
-celix_status_t bundleArchive_getLocation(bundle_archive_pt archive, const char **location) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (archive->location == NULL) {
-		FILE *bundleLocationFile;
-		char bundleLocation[512];
-		char loc[256];
-
-		snprintf(bundleLocation, sizeof(bundleLocation), "%s/bundle.location", archive->archiveRoot);
-
-		bundleLocationFile = fopen(bundleLocation, "r");
-		if(bundleLocationFile!=NULL){
-			fgets(loc, sizeof(loc), bundleLocationFile);
-			fclose(bundleLocationFile);
-			archive->location = strdup(loc);
-		}
-		else{
-			status = CELIX_FILE_IO_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*location = archive->location;
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not get archive location");
-
-	return status;
-}
-
-celix_status_t bundleArchive_getArchiveRoot(bundle_archive_pt archive, const char **archiveRoot) {
-	*archiveRoot = archive->archiveRoot;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleArchive_getCurrentRevisionNumber(bundle_archive_pt archive, long *revisionNumber) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_revision_pt revision;
-	*revisionNumber = -1;
-
-	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
-	status = CELIX_DO_IF(status, bundleRevision_getNumber(revision, revisionNumber));
-
-	framework_logIfError(logger, status, NULL, "Could not get current revision number");
-
-	return status;
-}
-
-celix_status_t bundleArchive_getCurrentRevision(bundle_archive_pt archive, bundle_revision_pt *revision) {
-	*revision = linkedList_isEmpty(archive->revisions) ? NULL : linkedList_getLast(archive->revisions);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleArchive_getRevision(bundle_archive_pt archive, long revNr, bundle_revision_pt *revision) {
-	*revision = linkedList_get(archive->revisions, revNr);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleArchive_getPersistentState(bundle_archive_pt archive, bundle_state_e *state) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (archive->persistentState != OSGI_FRAMEWORK_BUNDLE_UNKNOWN) {
-		*state = archive->persistentState;
-	} else {
-		FILE *persistentStateLocationFile;
-		char persistentStateLocation[512];
-		char stateString[256];
-		snprintf(persistentStateLocation, sizeof(persistentStateLocation), "%s/bundle.state", archive->archiveRoot);
-
-		persistentStateLocationFile = fopen(persistentStateLocation, "r");
-		if (persistentStateLocationFile == NULL) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		} else {
-			if (fgets(stateString, sizeof(stateString), persistentStateLocationFile) == NULL) {
-				status = CELIX_FILE_IO_EXCEPTION;
-			}
-			fclose(persistentStateLocationFile);
-		}
-
-		if (status == CELIX_SUCCESS) {
-			if (strncmp(stateString, "active", 256) == 0) {
-				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_ACTIVE;
-			} else if (strncmp(stateString, "starting", 256) == 0) {
-				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_STARTING;
-			} else if (strncmp(stateString, "uninstalled", 256) == 0) {
-				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_UNINSTALLED;
-			} else {
-				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
-			}
-
-			*state = archive->persistentState;
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not get persistent state");
-
-	return status;
-}
-
-celix_status_t bundleArchive_setPersistentState(bundle_archive_pt archive, bundle_state_e state) {
-	celix_status_t status = CELIX_SUCCESS;
-	char persistentStateLocation[512];
-	FILE *persistentStateLocationFile;
-
-	snprintf(persistentStateLocation, sizeof(persistentStateLocation), "%s/bundle.state", archive->archiveRoot);
-
-	persistentStateLocationFile = fopen(persistentStateLocation, "w");
-	if (persistentStateLocationFile == NULL) {
-		status = CELIX_FILE_IO_EXCEPTION;
-	} else {
-		char * s;
-		switch (state) {
-		case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
-			s = "active";
-			break;
-		case OSGI_FRAMEWORK_BUNDLE_STARTING:
-			s = "starting";
-			break;
-		case OSGI_FRAMEWORK_BUNDLE_UNINSTALLED:
-			s = "uninstalled";
-			break;
-		default:
-			s = "installed";
-			break;
-		}
-		fprintf(persistentStateLocationFile, "%s", s);
-		if (fclose(persistentStateLocationFile) ==  0) {
-			archive->persistentState = state;
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not set persistent state");
-
-	return status;
-}
-
-celix_status_t bundleArchive_getRefreshCount(bundle_archive_pt archive, long *refreshCount) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (archive->refreshCount == -1) {
-		FILE *refreshCounterFile;
-		char refreshCounter[512];
-		snprintf(refreshCounter, sizeof(refreshCounter), "%s/refresh.counter", archive->archiveRoot);
-
-		refreshCounterFile = fopen(refreshCounter, "r");
-		if (refreshCounterFile == NULL) {
-			archive->refreshCount = 0;
-		} else {
-			char counterStr[256];
-			if (fgets(counterStr, sizeof(counterStr), refreshCounterFile) == NULL) {
-				status = CELIX_FILE_IO_EXCEPTION;
-			}
-			fclose(refreshCounterFile);
-			if (status == CELIX_SUCCESS) {
-				sscanf(counterStr, "%ld", &archive->refreshCount);
-			}
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*refreshCount = archive->refreshCount;
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not get refresh count");
-
-	return status;
-}
-
-celix_status_t bundleArchive_setRefreshCount(bundle_archive_pt archive) {
-	FILE *refreshCounterFile;
-	celix_status_t status = CELIX_SUCCESS;
-	char refreshCounter[512];
-
-	snprintf(refreshCounter, sizeof(refreshCounter), "%s/refresh.counter", archive->archiveRoot);
-
-	refreshCounterFile = fopen(refreshCounter, "w");
-	if (refreshCounterFile == NULL) {
-		status = CELIX_FILE_IO_EXCEPTION;
-	} else {
-		fprintf(refreshCounterFile, "%ld", archive->refreshCount);
-		if (fclose(refreshCounterFile) ==  0) {
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not set refresh count");
-
-	return status;
-}
-
-celix_status_t bundleArchive_getLastModified(bundle_archive_pt archive, time_t *lastModified) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (archive->lastModified == (time_t) NULL) {
-		status = CELIX_DO_IF(status, bundleArchive_readLastModified(archive, &archive->lastModified));
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*lastModified = archive->lastModified;
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not get last modified");
-
-	return status;
-}
-
-celix_status_t bundleArchive_setLastModified(bundle_archive_pt archive, time_t lastModifiedTime) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	archive->lastModified = lastModifiedTime;
-	status = CELIX_DO_IF(status, bundleArchive_writeLastModified(archive));
-
-	framework_logIfError(logger, status, NULL, "Could not set last modified");
-
-	return status;
-}
-
-static celix_status_t bundleArchive_readLastModified(bundle_archive_pt archive, time_t *time) {
-	FILE *lastModifiedFile;
-	char lastModified[512];
-
-	celix_status_t status = CELIX_SUCCESS;
-
-	snprintf(lastModified, sizeof(lastModified), "%s/bundle.lastmodified", archive->archiveRoot);
-
-	lastModifiedFile = fopen(lastModified, "r");
-	if (lastModifiedFile == NULL) {
-		status = CELIX_FILE_IO_EXCEPTION;
-	} else {
-		char timeStr[20];
-		int year, month, day, hours, minutes, seconds;
-		struct tm tm_time;
-		memset(&tm_time,0,sizeof(struct tm));
-
-		if (fgets(timeStr, sizeof(timeStr), lastModifiedFile) == NULL) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		}
-		fclose(lastModifiedFile);
-		if (status == CELIX_SUCCESS) {
-			sscanf(timeStr, "%d %d %d %d:%d:%d", &year, &month, &day, &hours, &minutes, &seconds);
-			tm_time.tm_year = year - 1900;
-			tm_time.tm_mon = month - 1;
-			tm_time.tm_mday = day;
-			tm_time.tm_hour = hours;
-			tm_time.tm_min = minutes;
-			tm_time.tm_sec = seconds;
-
-			*time = mktime(&tm_time);
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not read last modified");
-
-	return status;
-}
-
-static celix_status_t bundleArchive_writeLastModified(bundle_archive_pt archive) {
-	celix_status_t status = CELIX_SUCCESS;
-	FILE *lastModifiedFile;
-	char lastModified[512];
-
-	snprintf(lastModified, sizeof(lastModified), "%s/bundle.lastmodified", archive->archiveRoot);
-	lastModifiedFile = fopen(lastModified, "w");
-	if (lastModifiedFile == NULL) {
-		status = CELIX_FILE_IO_EXCEPTION;
-	} else {
-		char timeStr[20];
-		strftime(timeStr, 20, "%Y %m %d %H:%M:%S", localtime(&archive->lastModified));
-		fprintf(lastModifiedFile, "%s", timeStr);
-		fclose(lastModifiedFile);
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not write last modified");
-
-	return status;
-}
-
-celix_status_t bundleArchive_revise(bundle_archive_pt archive, const char * location, const char *inputFile) {
-	celix_status_t status = CELIX_SUCCESS;
-	long revNr = 0l;
-	if (!linkedList_isEmpty(archive->revisions)) {
-		long revisionNr;
-		status = bundleRevision_getNumber(linkedList_getLast(archive->revisions), &revisionNr);
-		revNr = revisionNr + 1;
-	}
-	if (status == CELIX_SUCCESS) {
-		status = bundleArchive_reviseInternal(archive, false, revNr, location, inputFile);
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not revise bundle archive");
-
-	return status;
-}
-
-static celix_status_t bundleArchive_reviseInternal(bundle_archive_pt archive, bool isReload, long revNr, const char * location, const char *inputFile) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_revision_pt revision = NULL;
-
-	if (inputFile != NULL) {
-		location = "inputstream:";
-	}
-
-	status = bundleArchive_createRevisionFromLocation(archive, location, inputFile, revNr, &revision);
-
-	if (status == CELIX_SUCCESS) {
-		if (!isReload) {
-			status = bundleArchive_setRevisionLocation(archive, location, revNr);
-		}
-
-		linkedList_addElement(archive->revisions, revision);
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not revise bundle archive");
-
-	return status;
-}
-
-celix_status_t bundleArchive_rollbackRevise(bundle_archive_pt archive, bool *rolledback) {
-	*rolledback = true;
-	return CELIX_SUCCESS;
-}
-
-static celix_status_t bundleArchive_createRevisionFromLocation(bundle_archive_pt archive, const char *location, const char *inputFile, long revNr, bundle_revision_pt *bundle_revision) {
-	celix_status_t status = CELIX_SUCCESS;
-	char root[256];
-	long refreshCount;
-
-	status = bundleArchive_getRefreshCount(archive, &refreshCount);
-	if (status == CELIX_SUCCESS) {
-		bundle_revision_pt revision = NULL;
-
-		sprintf(root, "%s/version%ld.%ld", archive->archiveRoot, refreshCount, revNr);
-		status = bundleRevision_create(root, location, revNr, inputFile, &revision);
-
-		if (status == CELIX_SUCCESS) {
-			*bundle_revision = revision;
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Could not create revision [location=%s,inputFile=%s]", location, inputFile);
-
-	return status;
-}
-
-static celix_status_t bundleArchive_getRevisionLocation(bundle_archive_pt archive, long revNr, char **revision_location) {
-	celix_status_t status = CELIX_SUCCESS;
-	char revisionLocation[256];
-	long refreshCount;
-
-	status = bundleArchive_getRefreshCount(archive, &refreshCount);
-	if (status == CELIX_SUCCESS) {
-		FILE *revisionLocationFile;
-
-		snprintf(revisionLocation, sizeof(revisionLocation), "%s/version%ld.%ld/revision.location", archive->archiveRoot, refreshCount, revNr);
-
-		revisionLocationFile = fopen(revisionLocation, "r");
-		if (revisionLocationFile != NULL) {
-			char location[256];
-			fgets(location , sizeof(location) , revisionLocationFile);
-			fclose(revisionLocationFile);
-
-			*revision_location = strdup(location);
-			status = CELIX_SUCCESS;
-		} else {
-			// revision file not found
-			printf("Failed to open revision file at: %s\n", revisionLocation);
-			status = CELIX_FILE_IO_EXCEPTION;
-		}
-	}
-
-
-	framework_logIfError(logger, status, NULL, "Failed to get revision location");
-
-	return status;
-}
-
-static celix_status_t bundleArchive_setRevisionLocation(bundle_archive_pt archive, const char * location, long revNr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	char revisionLocation[256];
-	long refreshCount;
-
-	status = bundleArchive_getRefreshCount(archive, &refreshCount);
-	if (status == CELIX_SUCCESS) {
-		FILE * revisionLocationFile;
-
-		snprintf(revisionLocation, sizeof(revisionLocation), "%s/version%ld.%ld/revision.location", archive->archiveRoot, refreshCount, revNr);
-
-		revisionLocationFile = fopen(revisionLocation, "w");
-		if (revisionLocationFile == NULL) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		} else {
-			fprintf(revisionLocationFile, "%s", location);
-			fclose(revisionLocationFile);
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to set revision location");
-
-	return status;
-}
-
-celix_status_t bundleArchive_close(bundle_archive_pt archive) {
-	// close revision
-	// not yet needed/possible
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleArchive_closeAndDelete(bundle_archive_pt archive) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = bundleArchive_close(archive);
-	if (status == CELIX_SUCCESS) {
-		status = bundleArchive_deleteTree(archive, archive->archiveRoot);
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to close and delete archive");
-
-	return status;
-}
-
-static celix_status_t bundleArchive_initialize(bundle_archive_pt archive) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (archive->archiveRootDir == NULL) {
-		int err = mkdir(archive->archiveRoot, S_IRWXU) ;
-		if (err != 0) {
-			char *errmsg = strerror(errno);
-			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error mkdir: %s\n", errmsg);
-			status = CELIX_FILE_IO_EXCEPTION;
-		} else {
-			archive->archiveRootDir = opendir(archive->archiveRoot);
-			if (archive->archiveRootDir == NULL) {
-				status = CELIX_FILE_IO_EXCEPTION;
-			} else {
-				FILE *bundleIdFile;
-				char bundleId[512];
-
-				snprintf(bundleId, sizeof(bundleId), "%s/bundle.id", archive->archiveRoot);
-				bundleIdFile = fopen(bundleId, "w");
-
-				if (bundleIdFile == NULL) {
-					status = CELIX_FILE_IO_EXCEPTION;
-				} else {
-					FILE *bundleLocationFile;
-					char bundleLocation[512];
-
-					fprintf(bundleIdFile, "%ld", archive->id);
-					// Ignore close status, let it fail if needed again
-					fclose(bundleIdFile);
-
-					snprintf(bundleLocation, sizeof(bundleLocation), "%s/bundle.location", archive->archiveRoot);
-					bundleLocationFile = fopen(bundleLocation, "w");
-
-					if (bundleLocationFile == NULL) {
-						status = CELIX_FILE_IO_EXCEPTION;
-					} else {
-						fprintf(bundleLocationFile, "%s", archive->location);
-						// Ignore close status, let it fail if needed again
-						fclose(bundleLocationFile);
-
-						status = bundleArchive_writeLastModified(archive);
-					}
-				}
-				closedir(archive->archiveRootDir);
-			}
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to initialize archive");
-
-	return status;
-}
-
-static celix_status_t bundleArchive_deleteTree(bundle_archive_pt archive, const char * directory) {
-	DIR *dir;
-	celix_status_t status = CELIX_SUCCESS;
-	dir = opendir(directory);
-	if (dir == NULL) {
-		status = CELIX_FILE_IO_EXCEPTION;
-	} else {
-
-		struct dirent* dent = NULL;
-
-        errno = 0;
-        dent = readdir(dir);
-		while (errno == 0 && dent != NULL) {
-			if ((strcmp((dent->d_name), ".") != 0) && (strcmp((dent->d_name), "..") != 0)) {
-				char subdir[512];
-				snprintf(subdir, 512, "%s/%s", directory, dent->d_name);
-
-				struct stat st;
-				if (stat(subdir, &st) == 0) {
-					if (S_ISDIR (st.st_mode)) {
-						status = bundleArchive_deleteTree(archive, subdir);
-					} else {
-						if (remove(subdir) != 0) {
-							status = CELIX_FILE_IO_EXCEPTION;
-							break;
-						}
-					}
-				}
-			}
-            errno = 0;
-            dent = readdir(dir);
-		}
-
-        if (errno != 0) {
-            status = CELIX_FILE_IO_EXCEPTION;
-        } else if (closedir(dir) != 0) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		} else if (status == CELIX_SUCCESS) {
-			if (rmdir(directory) != 0) {
-				status = CELIX_FILE_IO_EXCEPTION;
-			}
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to delete tree");
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/bundle_cache.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_cache.c b/framework/private/src/bundle_cache.c
deleted file mode 100644
index 39875b5..0000000
--- a/framework/private/src/bundle_cache.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_cache.c
- *
- *  \date       Aug 6, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <unistd.h>
-
-#include "bundle_cache_private.h"
-#include "bundle_archive.h"
-#include "constants.h"
-#include "celix_log.h"
-
-static celix_status_t bundleCache_deleteTree(bundle_cache_pt cache, char * directory);
-
-celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache) {
-	celix_status_t status;
-	bundle_cache_pt cache;
-
-	if (configurationMap == NULL || *bundle_cache != NULL) {
-		return CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	cache = (bundle_cache_pt) calloc(1, sizeof(*cache));
-	if (cache == NULL) {
-		status = CELIX_ENOMEM;
-	} else {
-		char* cacheDir = (char*)properties_get(configurationMap, (char *) OSGI_FRAMEWORK_FRAMEWORK_STORAGE);
-		cache->configurationMap = configurationMap;
-		if (cacheDir == NULL) {
-			cacheDir = ".cache";
-		}
-		cache->cacheDir = cacheDir;
-
-		*bundle_cache = cache;
-		status = CELIX_SUCCESS;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to create bundle cache");
-
-	return status;
-}
-
-celix_status_t bundleCache_destroy(bundle_cache_pt *cache) {
-
-	free(*cache);
-	*cache = NULL;
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleCache_delete(bundle_cache_pt cache) {
-	return bundleCache_deleteTree(cache, cache->cacheDir);
-}
-
-celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *archives) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	DIR *dir;
-	struct stat st;
-
-	dir = opendir(cache->cacheDir);
-
-	if (dir == NULL && errno == ENOENT) {
-		if(mkdir(cache->cacheDir, S_IRWXU) == 0 ){
-			dir = opendir(cache->cacheDir);
-		}
-	}
-
-	if (dir != NULL) {
-		array_list_pt list = NULL;
-		arrayList_create(&list);
-
-		struct dirent* dent = NULL;
-
-		errno = 0;
-		dent = readdir(dir);
-		while (errno == 0 && dent != NULL) {
-			char archiveRoot[512];
-
-			snprintf(archiveRoot, sizeof(archiveRoot), "%s/%s", cache->cacheDir, dent->d_name);
-
-			if (stat (archiveRoot, &st) == 0) {
-				if (S_ISDIR (st.st_mode)
-						&& (strcmp((dent->d_name), ".") != 0)
-						&& (strcmp((dent->d_name), "..") != 0)
-						&& (strncmp(dent->d_name, "bundle", 6) == 0)
-						&& (strcmp(dent->d_name, "bundle0") != 0)) {
-
-					bundle_archive_pt archive = NULL;
-					status = bundleArchive_recreate(archiveRoot, &archive);
-					if (status == CELIX_SUCCESS) {
-						arrayList_add(list, archive);
-					}
-				}
-			}
-
-			errno = 0;
-			dent = readdir(dir);
-		}
-
-		if (errno != 0) {
-			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error reading dir");
-			status = CELIX_FILE_IO_EXCEPTION;
-		} else {
-			status = CELIX_SUCCESS;
-		}
-
-		closedir(dir);
-
-		if (status == CELIX_SUCCESS) {
-			*archives = list;
-		}
-		else{
-			int idx = 0;
-			for(;idx<arrayList_size(list);idx++){
-				bundleArchive_destroy((bundle_archive_pt)arrayList_get(list,idx));
-			}
-			arrayList_destroy(list);
-			*archives = NULL;
-		}
-
-	} else {
-		status = CELIX_FILE_IO_EXCEPTION;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get bundle archives");
-
-	return status;
-}
-
-celix_status_t bundleCache_createArchive(bundle_cache_pt cache, long id, const char * location, const char *inputFile, bundle_archive_pt *bundle_archive) {
-	celix_status_t status = CELIX_SUCCESS;
-	char archiveRoot[512];
-
-	if (cache && location) {
-		snprintf(archiveRoot, sizeof(archiveRoot), "%s/bundle%ld",  cache->cacheDir, id);
-		status = bundleArchive_create(archiveRoot, id, location, inputFile, bundle_archive);
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to create archive");
-
-	return status;
-}
-
-static celix_status_t bundleCache_deleteTree(bundle_cache_pt cache, char * directory) {
-	DIR *dir;
-	celix_status_t status = CELIX_SUCCESS;
-	struct stat st;
-
-	errno = 0;
-	dir = opendir(directory);
-	if (dir == NULL) {
-		status = CELIX_FILE_IO_EXCEPTION;
-	} else {
-		struct dirent* dent = NULL;
-		dent = readdir(dir);
-		while (errno == 0 && dent != NULL) {
-			if ((strcmp((dent->d_name), ".") != 0) && (strcmp((dent->d_name), "..") != 0)) {
-				char subdir[512];
-				snprintf(subdir, sizeof(subdir), "%s/%s", directory, dent->d_name);
-
-				if (stat(subdir, &st) == 0) {
-					if (S_ISDIR (st.st_mode)) {
-						status = bundleCache_deleteTree(cache, subdir);
-					} else {
-						if (remove(subdir) != 0) {
-							status = CELIX_FILE_IO_EXCEPTION;
-							break;
-						}
-					}
-				}
-			}
-			errno = 0;
-			dent = readdir(dir);
-		}
-
-		if (errno != 0) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		}
-		else if (closedir(dir) != 0) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		}
-		if (status == CELIX_SUCCESS) {
-			if (rmdir(directory) != 0) {
-				status = CELIX_FILE_IO_EXCEPTION;
-			}
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to delete tree at dir '%s'", directory);
-
-	return status;
-}


[06/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/README.md
----------------------------------------------------------------------
diff --git a/shell/README.md b/shell/README.md
index b830edc..76f1cc7 100644
--- a/shell/README.md
+++ b/shell/README.md
@@ -19,10 +19,15 @@ While the shell can be extended with additional commands by other bundles, it al
 
 Further information about a command can be retrieved by using `help` combined with the command.
 
+## CMake options
+    BUILD_SHELL=ON
+
 ## Shell Config Options
 
-- SHELL_USE_ANSI_COLORS - Wether shell command are allowed to use
+- SHELL_USE_ANSI_COLORS - Whether shell command are allowed to use
 ANSI colors when printing info. default is true.
 
-## CMake options
-    BUILD_SHELL=ON
+## Using info
+
+If the Celix Shell is installed The `FindCelix.cmake` will set:
+ - The `Celix::dependency_manager_cxx_static` library target

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/include/command.h
----------------------------------------------------------------------
diff --git a/shell/include/command.h b/shell/include/command.h
new file mode 100644
index 0000000..0e86dcc
--- /dev/null
+++ b/shell/include/command.h
@@ -0,0 +1,57 @@
+/**
+ *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.
+ */
+/*
+ * command.h
+ *
+ *  \date       Aug 13, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef COMMAND_H_
+#define COMMAND_H_
+
+#include "celix_errno.h"
+#include <stdio.h>
+
+#define OSGI_SHELL_COMMAND_NAME "command.name"
+#define OSGI_SHELL_COMMAND_USAGE "command.usage"
+#define OSGI_SHELL_COMMAND_DESCRIPTION "command.description"
+
+static const char * const OSGI_SHELL_COMMAND_SERVICE_NAME = "commandService";
+
+typedef struct commandService command_service_t;
+typedef command_service_t * command_service_pt;
+
+/**
+ * The command service can be used to register additional shell commands.
+ * The service should be register with the following properties:
+ *  - command.name: mandatory, name of the command e.g. 'lb'
+ *  - command.usage: optional, string describing how tu use the commmand e.g. 'lb [-l | -s | -u]'
+ *  - command.descrription: optional, string describing the command e.g. 'list bundles.'
+ */
+struct commandService {
+	void *handle;
+	celix_status_t (*executeCommand)(void *handle, char * commandLine, FILE *outStream, FILE *errorStream);
+};
+
+
+
+
+#endif /* COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/include/shell.h
----------------------------------------------------------------------
diff --git a/shell/include/shell.h b/shell/include/shell.h
new file mode 100644
index 0000000..c8e7d60
--- /dev/null
+++ b/shell/include/shell.h
@@ -0,0 +1,51 @@
+/**
+ *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.
+ */
+/*
+ * shell.h
+ *
+ *  \date       Aug 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef SHELL_H_
+#define SHELL_H_
+
+#include "array_list.h"
+#include "service_reference.h"
+
+static const char * const OSGI_SHELL_SERVICE_NAME = "shellService";
+
+typedef struct shell shell_t;
+typedef shell_t* shell_pt;
+
+struct shellService {
+	shell_pt shell;
+
+	celix_status_t (*getCommands)(shell_pt shell_ptr, array_list_pt *commands_ptr);
+	celix_status_t (*getCommandUsage)(shell_pt shell_ptr, char *command_name_str, char **usage_str);
+	celix_status_t (*getCommandDescription)(shell_pt shell_ptr, char *command_name_str, char **command_description_str);
+	celix_status_t (*getCommandReference)(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
+	celix_status_t (*executeCommand)(shell_pt shell_ptr, char * command_line_str, FILE *out, FILE *err);
+};
+
+typedef struct shellService shell_service_t;
+typedef shell_service_t* shell_service_pt;
+
+#endif /* SHELL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/include/shell_constants.h
----------------------------------------------------------------------
diff --git a/shell/include/shell_constants.h b/shell/include/shell_constants.h
new file mode 100644
index 0000000..1e7f875
--- /dev/null
+++ b/shell/include/shell_constants.h
@@ -0,0 +1,27 @@
+/**
+ *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.
+ */
+
+
+#ifndef SHELL_CONSTANTS_H_
+#define SHELL_CONSTANTS_H_
+
+#define SHELL_USE_ANSI_COLORS "SHELL_USE_ANSI_COLORS"
+#define SHELL_USE_ANSI_COLORS_DEFAULT_VALUE "true"
+
+#endif /* SHELL_CONSTANTS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/include/shell_private.h
----------------------------------------------------------------------
diff --git a/shell/private/include/shell_private.h b/shell/private/include/shell_private.h
deleted file mode 100644
index 7270fa2..0000000
--- a/shell/private/include/shell_private.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *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.
- */
-/*
- * shell_private.h
- *
- *  \date       Aug 13, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef SHELL_PRIVATE_H_
-#define SHELL_PRIVATE_H_
-
-#include "bundle_context.h"
-#include "shell.h"
-#include "hash_map.h"
-#include "command.h"
-#include "log_helper.h"
-
-struct shell {
-	bundle_context_pt bundle_context_ptr;
-	hash_map_pt command_reference_map_ptr;
-	hash_map_pt command_name_map_ptr;
-	log_helper_pt logHelper;
-};
-
-celix_status_t shell_create(bundle_context_pt context_ptr, shell_service_pt *shell_service_ptr);
-celix_status_t shell_destroy(shell_service_pt *shell_service_ptr);
-celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc);
-celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc);
-
-celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
-celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, FILE *out, FILE *err);
-
-#endif /* SHELL_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/include/std_commands.h
----------------------------------------------------------------------
diff --git a/shell/private/include/std_commands.h b/shell/private/include/std_commands.h
deleted file mode 100644
index ef7f37e..0000000
--- a/shell/private/include/std_commands.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *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.
- */
-/*
- * std_commands.h
- *
- *  \date       March 27, 2014
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef __STD_COMMANDS_H_
-#define __STD_COMMANDS_H_
-
-#include "celix_errno.h"
-
-#define OSGI_SHELL_COMMAND_SEPARATOR " "
-
-celix_status_t psCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr);
-celix_status_t startCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr);
-celix_status_t stopCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t installCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t uninstallCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t updateCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t logCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t inspectCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t helpCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/activator.c
----------------------------------------------------------------------
diff --git a/shell/private/src/activator.c b/shell/private/src/activator.c
deleted file mode 100644
index ac298d8..0000000
--- a/shell/private/src/activator.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Aug 13, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "shell_private.h"
-#include "bundle_activator.h"
-#include "std_commands.h"
-#include "service_tracker.h"
-#include "constants.h"
-
-#define NUMBER_OF_COMMANDS 10
-
-struct command {
-    celix_status_t (*exec)(void *handle, char *commandLine, FILE *out, FILE *err);
-    char *name;
-    char *description;
-    char *usage;
-    command_service_pt service;
-    service_registration_pt reg;
-    properties_pt props;
-};
-
-struct bundle_instance {
-	shell_service_pt shellService;
-	service_registration_pt registration;
-    service_tracker_pt tracker;
-
-    struct command std_commands[NUMBER_OF_COMMANDS];
-};
-
-typedef struct bundle_instance *bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context_ptr, void **_pptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    bundle_instance_pt instance_ptr = NULL;
-
-    if (!_pptr || !context_ptr) {
-        status = CELIX_ENOMEM;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        instance_ptr = (bundle_instance_pt) calloc(1, sizeof(struct bundle_instance));
-        if (!instance_ptr) {
-            status = CELIX_ENOMEM;
-        }
-    }
-
-    if (status == CELIX_SUCCESS) {
-        status = shell_create(context_ptr, &instance_ptr->shellService);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        instance_ptr->std_commands[0] =
-                (struct command) {
-                        .exec = psCommand_execute,
-                        .name = "lb",
-                        .description = "list bundles.",
-                        .usage = "lb [-l | -s | -u]"
-                };
-        instance_ptr->std_commands[1] =
-                (struct command) {
-                        .exec = startCommand_execute,
-                        .name = "start",
-                        .description = "start bundle(s).",
-                        .usage = "start <id> [<id> ...]"
-                };
-        instance_ptr->std_commands[2] =
-                (struct command) {
-                        .exec = stopCommand_execute,
-                        .name = "stop",
-                        .description = "stop bundle(s).",
-                        .usage = "stop <id> [<id> ...]"
-                };
-        instance_ptr->std_commands[3] =
-                (struct command) {
-                        .exec = installCommand_execute,
-                        .name = "install",
-                        .description = "install bundle(s).",
-                        .usage = "install <file> [<file> ...]"
-                };
-        instance_ptr->std_commands[4] =
-                (struct command) {
-                        .exec = uninstallCommand_execute,
-                        .name = "uninstall",
-                        .description = "uninstall bundle(s).",
-                        .usage = "uninstall <file> [<file> ...]"
-                };
-        instance_ptr->std_commands[5] =
-                (struct command) {
-                        .exec = updateCommand_execute,
-                        .name = "update",
-                        .description = "update bundle(s).",
-                        .usage = "update <id> [<URL>]"
-                };
-        instance_ptr->std_commands[6] =
-                (struct command) {
-                        .exec = helpCommand_execute,
-                        .name = "help",
-                        .description = "display available commands and description.",
-                        .usage = "help <command>]"
-                };
-        instance_ptr->std_commands[7] =
-                (struct command) {
-                        .exec = logCommand_execute,
-                        .name = "log",
-                        .description = "print log.",
-                        .usage = "log"
-                };
-        instance_ptr->std_commands[8] =
-                (struct command) {
-                        .exec = inspectCommand_execute,
-                        .name = "inspect",
-                        .description = "inspect services and components.",
-                        .usage = "inspect (service) (capability|requirement) [<id> ...]"
-                };
-        instance_ptr->std_commands[9] =
-                (struct command) { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; /*marker for last element*/
-
-        unsigned int i = 0;
-        while (instance_ptr->std_commands[i].exec != NULL) {
-            instance_ptr->std_commands[i].props = properties_create();
-            if (!instance_ptr->std_commands[i].props) {
-                status = CELIX_BUNDLE_EXCEPTION;
-                break;
-            }
-
-            properties_set(instance_ptr->std_commands[i].props, OSGI_SHELL_COMMAND_NAME, instance_ptr->std_commands[i].name);
-            properties_set(instance_ptr->std_commands[i].props, OSGI_SHELL_COMMAND_USAGE, instance_ptr->std_commands[i].usage);
-            properties_set(instance_ptr->std_commands[i].props, OSGI_SHELL_COMMAND_DESCRIPTION, instance_ptr->std_commands[i].description);
-            properties_set(instance_ptr->std_commands[i].props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-
-            instance_ptr->std_commands[i].service = calloc(1, sizeof(*instance_ptr->std_commands[i].service));
-            if (!instance_ptr->std_commands[i].service) {
-                status = CELIX_ENOMEM;
-                break;
-            }
-
-            instance_ptr->std_commands[i].service->handle = context_ptr;
-            instance_ptr->std_commands[i].service->executeCommand = instance_ptr->std_commands[i].exec;
-
-            i += 1;
-        }
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *_pptr = instance_ptr;
-    }
-
-
-    if (status != CELIX_SUCCESS) {
-        bundleActivator_destroy(instance_ptr, context_ptr);
-    }
-
-	return status;
-}
-
-celix_status_t bundleActivator_start(void *_ptr, bundle_context_pt context_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bundle_instance_pt instance_ptr  = (bundle_instance_pt) _ptr;
-
-    if (!instance_ptr || !context_ptr) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        properties_pt props = properties_create();
-        properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-        status = bundleContext_registerService(context_ptr, (char *) OSGI_SHELL_SERVICE_NAME, instance_ptr->shellService, props, &instance_ptr->registration);
-    }
-
-	if (status == CELIX_SUCCESS) {
-        service_tracker_customizer_pt cust = NULL;
-        serviceTrackerCustomizer_create(instance_ptr->shellService->shell, NULL, (void *)shell_addCommand, NULL, (void *)shell_removeCommand, &cust);
-        serviceTracker_create(context_ptr, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, cust, &instance_ptr->tracker);
-        serviceTracker_open(instance_ptr->tracker);
-    }
-
-
-    if (status == CELIX_SUCCESS) {
-        for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
-            status = bundleContext_registerService(context_ptr, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME,
-                                                   instance_ptr->std_commands[i].service,
-                                                   instance_ptr->std_commands[i].props,
-                                                   &instance_ptr->std_commands[i].reg);
-            if (status != CELIX_SUCCESS) {
-                break;
-            }
-
-        }
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void *_ptr, bundle_context_pt context_ptr) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
-
-    if (instance_ptr) {
-        for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
-            if (instance_ptr->std_commands[i].reg != NULL) {
-                status = serviceRegistration_unregister(instance_ptr->std_commands[i].reg);
-                instance_ptr->std_commands[i].reg = NULL;
-                instance_ptr->std_commands[i].props = NULL;
-            }
-        }
-
-        if (instance_ptr->tracker != NULL) {
-            serviceTracker_close(instance_ptr->tracker);
-        }
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    return status;
-}
-
-celix_status_t bundleActivator_destroy(void *_ptr, bundle_context_pt __attribute__((__unused__)) context_ptr) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
-
-    if (instance_ptr) {
-        serviceRegistration_unregister(instance_ptr->registration);
-
-        for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
-            free(instance_ptr->std_commands[i].service);
-        }
-
-        shell_destroy(&instance_ptr->shellService);
-
-        if (instance_ptr->tracker != NULL) {
-            serviceTracker_destroy(instance_ptr->tracker);
-        }
-
-        free(instance_ptr);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/help_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/help_command.c b/shell/private/src/help_command.c
deleted file mode 100644
index 48615ae..0000000
--- a/shell/private/src/help_command.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- *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.
- */
-/*
- * help_command.c
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-#include "shell.h"
-#include "std_commands.h"
-
-celix_status_t helpCommand_execute(void *_ptr, char *line_str, FILE *out_ptr, FILE *err_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bundle_context_pt context_ptr = _ptr;
-	service_reference_pt shell_service_reference_ptr = NULL;
-	shell_service_pt shell_ptr = NULL;
-
-	if (!context_ptr || !line_str || !out_ptr || !err_ptr) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getServiceReference(context_ptr, (char *) OSGI_SHELL_SERVICE_NAME, &shell_service_reference_ptr);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getService(context_ptr, shell_service_reference_ptr, (void **) &shell_ptr);
-	}
-
-	if (status == CELIX_SUCCESS) {
-        uint32_t out_len = 256;
-        char *sub = NULL;
-        char *save_ptr = NULL;
-        char out_str[out_len];
-
-        memset(out_str, 0, sizeof(out_str));
-
-        strtok_r(line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-        sub = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-
-        if (sub == NULL) {
-            unsigned int i;
-            array_list_pt commands = NULL;
-
-            status = shell_ptr->getCommands(shell_ptr->shell, &commands);
-            for (i = 0; i < arrayList_size(commands); i++) {
-                char *name = arrayList_get(commands, i);
-                fprintf(out_ptr, "%s\n", name);
-            }
-            fprintf(out_ptr, "\nUse 'help <command-name>' for more information.\n");
-            arrayList_destroy(commands);
-        } else {
-            celix_status_t sub_status_desc;
-            celix_status_t sub_status_usage;
-            int i;
-            array_list_pt commands = NULL;
-            shell_ptr->getCommands(shell_ptr->shell, &commands);
-            for (i = 0; i < arrayList_size(commands); i++) {
-                char *name = arrayList_get(commands, i);
-                if (strcmp(sub, name) == 0) {
-                    char *usage_str = NULL;
-                    char *desc_str = NULL;
-
-                    sub_status_desc = shell_ptr->getCommandDescription(shell_ptr->shell, name, &desc_str);
-                    sub_status_usage = shell_ptr->getCommandUsage(shell_ptr->shell, name, &usage_str);
-
-                    if (sub_status_usage == CELIX_SUCCESS && sub_status_desc == CELIX_SUCCESS) {
-                        fprintf(out_ptr, "Command     : %s\n", name);
-                        fprintf(out_ptr, "Usage       : %s\n", usage_str == NULL ? "" : usage_str);
-                        fprintf(out_ptr, "Description : %s\n", desc_str == NULL ? "" : desc_str);
-                    } else {
-                        fprintf(err_ptr, "Error retreiving help info for command '%s'\n", sub);
-                    }
-
-                    if (sub_status_desc != CELIX_SUCCESS && status == CELIX_SUCCESS) {
-                        status = sub_status_desc;
-                    }
-                    if (sub_status_usage != CELIX_SUCCESS && status == CELIX_SUCCESS) {
-                        status = sub_status_usage;
-                    }
-                }
-            }
-            arrayList_destroy(commands);
-        }
-    }
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/inspect_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/inspect_command.c b/shell/private/src/inspect_command.c
deleted file mode 100644
index cb93e9c..0000000
--- a/shell/private/src/inspect_command.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- *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.
- */
-/*
- * inspect_command.c
- *
- *  \date       Oct 13, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-
-#include "std_commands.h"
-
-#define SERVICE_TYPE "service"
-#define CAPABILITY "capability"
-#define REQUIREMENT "requirement"
-
-celix_status_t inspectCommand_printExportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream);
-celix_status_t inspectCommand_printImportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream);
-
-celix_status_t inspectCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bundle_context_pt context = handle;
-
-	char *token;
-	strtok_r(commandline, " ", &token);
-	char *type = strtok_r(NULL, " ", &token);
-	if (type != NULL) {
-		char *direction = strtok_r(NULL, " ", &token);
-		if (direction != NULL) {
-			array_list_pt ids = NULL;
-			char *id = strtok_r(NULL, " ", &token);
-
-			arrayList_create(&ids);
-			while (id != NULL) {
-				arrayList_add(ids, id);
-				id = strtok_r(NULL, " ", &token);
-			}
-
-			if (strcmp(type, SERVICE_TYPE) == 0) {
-				if (strcmp(direction, CAPABILITY) == 0) {
-					status = inspectCommand_printExportedServices(context, ids, outStream, errStream);
-					if (status != CELIX_SUCCESS) {
-						fprintf(errStream, "INSPECT: Error\n");
-					}
-				} else if (strcmp(direction, REQUIREMENT) == 0) {
-                    status = inspectCommand_printImportedServices(context, ids, outStream, errStream);
-                    if (status != CELIX_SUCCESS) {
-						fprintf(errStream, "INSPECT: Error\n");
-                    }
-				} else {
-					fprintf(errStream, "INSPECT: Invalid argument\n");
-				}
-			} else {
-				fprintf(errStream, "INSPECT: Invalid argument\n");
-			}
-			arrayList_destroy(ids);
-		} else {
-			fprintf(errStream, "INSPECT: Too few arguments\n");
-		}
-	} else {
-		fprintf(errStream, "INSPECT: Too few arguments\n");
-	}
-	return status;
-}
-
-celix_status_t inspectCommand_printExportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream) {
-	celix_status_t status = CELIX_SUCCESS;
-	array_list_pt bundles = NULL;
-
-	if (arrayList_isEmpty(ids)) {
-		status = bundleContext_getBundles(context, &bundles);
-	} else {
-		unsigned int i;
-
-		arrayList_create(&bundles);
-		for (i = 0; i < arrayList_size(ids); i++) {
-			char *idStr = (char *) arrayList_get(ids, i);
-			long id = atol(idStr);
-			bundle_pt b = NULL;
-			celix_status_t st = bundleContext_getBundleById(context, id, &b);
-			if (st == CELIX_SUCCESS) {
-				arrayList_add(bundles, b);
-			} else {
-				fprintf(outStream, "INSPECT: Invalid bundle ID: %ld\n", id);
-			}
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		unsigned int i = 0;
-		for (i = 0; i < arrayList_size(bundles); i++) {
-			bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
-
-			if (i > 0) {
-				fprintf(outStream, "\n");
-			}
-
-			if (bundle != NULL) {
-				array_list_pt refs = NULL;
-
-				if (bundle_getRegisteredServices(bundle, &refs) == CELIX_SUCCESS) {
-					module_pt module = NULL;
-					const char * name = NULL;
-					status = bundle_getCurrentModule(bundle, &module);
-					if (status == CELIX_SUCCESS) {
-						status = module_getSymbolicName(module, &name);
-						if (status == CELIX_SUCCESS) {
-							fprintf(outStream, "%s provides services:\n", name);
-							fprintf(outStream, "==============\n");
-
-							if (refs == NULL || arrayList_size(refs) == 0) {
-								fprintf(outStream, "Nothing\n");
-							} else {
-								unsigned int j = 0;
-								for (j = 0; j < arrayList_size(refs); j++) {
-									service_reference_pt ref = (service_reference_pt) arrayList_get(refs, j);
-									unsigned int size = 0;
-									char **keys;
-
-									serviceReference_getPropertyKeys(ref, &keys, &size);
-									for (int k = 0; k < size; k++) {
-									    char *key = keys[k];
-									    const char *value = NULL;
-									    serviceReference_getProperty(ref, key, &value);
-
-										fprintf(outStream, "%s = %s\n", key, value);
-									}
-
-									free(keys);
-
-//									objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
-//									sprintf(line, "ObjectClass = %s\n", objectClass);
-									if ((j + 1) < arrayList_size(refs)) {
-										fprintf(outStream, "----\n");
-									}
-								}
-							}
-						}
-					}
-				}
-
-				if(refs!=NULL){
-					arrayList_destroy(refs);
-				}
-			}
-		}
-	}
-
-	if (bundles != NULL) {
-	    arrayList_destroy(bundles);
-	}
-
-	return status;
-}
-
-celix_status_t inspectCommand_printImportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream) {
-    celix_status_t status = CELIX_SUCCESS;
-    array_list_pt bundles = NULL;
-
-    if (arrayList_isEmpty(ids)) {
-        status = bundleContext_getBundles(context, &bundles);
-    } else {
-        unsigned int i;
-
-        arrayList_create(&bundles);
-        for (i = 0; i < arrayList_size(ids); i++) {
-            char *idStr = (char *) arrayList_get(ids, i);
-            long id = atol(idStr);
-            bundle_pt b = NULL;
-            celix_status_t st = bundleContext_getBundleById(context, id, &b);
-            if (st == CELIX_SUCCESS) {
-                arrayList_add(bundles, b);
-            } else {
-				fprintf(outStream, "INSPECT: Invalid bundle ID: %ld\n", id);
-            }
-        }
-    }
-
-    if (status == CELIX_SUCCESS) {
-        unsigned int i = 0;
-        for (i = 0; i < arrayList_size(bundles); i++) {
-            bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
-
-            if (i > 0) {
-				fprintf(outStream, "\n");
-            }
-
-            if (bundle != NULL) {
-                array_list_pt refs = NULL;
-
-                if (bundle_getServicesInUse(bundle, &refs) == CELIX_SUCCESS) {
-                    module_pt module = NULL;
-                    const char * name = NULL;
-                    status = bundle_getCurrentModule(bundle, &module);
-                    if (status == CELIX_SUCCESS) {
-                        status = module_getSymbolicName(module, &name);
-                        if (status == CELIX_SUCCESS) {
-							fprintf(outStream, "%s requires services:\n", name);
-							fprintf(outStream, "==============\n");
-
-                            if (refs == NULL || arrayList_size(refs) == 0) {
-								fprintf(outStream, "Nothing\n");
-                            } else {
-                                unsigned int j = 0;
-                                for (j = 0; j < arrayList_size(refs); j++) {
-                                    service_reference_pt ref = (service_reference_pt) arrayList_get(refs, j);
-                                    bundle_pt usedBundle = NULL;
-                                    module_pt usedModule = NULL;
-                                    const char *usedSymbolicName = NULL;
-                                    long usedBundleId;
-
-                                    serviceReference_getBundle(ref, &usedBundle);
-                                    bundle_getBundleId(usedBundle, &usedBundleId);
-                                    bundle_getCurrentModule(usedBundle, &usedModule);
-                                    module_getSymbolicName(usedModule, &usedSymbolicName);
-
-									fprintf(outStream, "%s [%ld]\n", usedSymbolicName, usedBundleId);
-
-                                    unsigned int size = 0;
-                                    char **keys;
-
-                                    serviceReference_getPropertyKeys(ref, &keys, &size);
-                                    for (int k = 0; k < size; k++) {
-                                        char *key = keys[k];
-                                        const char *value = NULL;
-                                        serviceReference_getProperty(ref, key, &value);
-
-										fprintf(outStream, "%s = %s\n", key, value);
-                                    }
-                                    free(keys);
-
-//                                  objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
-//                                  sprintf(line, "ObjectClass = %s\n", objectClass);
-                                    if ((j + 1) < arrayList_size(refs)) {
-										fprintf(outStream, "----\n");
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-
-                if(refs!=NULL){
-                	arrayList_destroy(refs);
-                }
-            }
-        }
-    }
-
-    arrayList_destroy(bundles);
-
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/install_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/install_command.c b/shell/private/src/install_command.c
deleted file mode 100644
index 067ba2b..0000000
--- a/shell/private/src/install_command.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *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.
- */
-/*
- * install_command.c
- *
- *  \date       Apr 4, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-
-void installCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
-	bundle_context_pt context = handle;
-
-	char delims[] = " ";
-	char * sub = NULL;
-	char *save_ptr = NULL;
-	char info[256];
-
-	// ignore the command
-	sub = strtok_r(line, delims, &save_ptr);
-	sub = strtok_r(NULL, delims, &save_ptr);
-	
-	if (sub == NULL) {
-		fprintf(errStream, "Incorrect number of arguments.\n");
-	} else {
-		info[0] = '\0';
-		while (sub != NULL) {
-			bundle_pt bundle = NULL;
-			bundleContext_installBundle(context, sub, &bundle);
-			if (bundle != NULL) {
-				long id;
-				bundle_archive_pt archive = NULL;
-				char bundleId[sizeof(id) + 1];
-
-				if (strlen(info) > 0) {
-					strcat(info, ", ");
-				}
-				bundle_getArchive(bundle, &archive);
-				bundleArchive_getId(archive, &id);
-				sprintf(bundleId, "%ld", id);
-				strcat(info, bundleId);
-			}
-			sub = strtok_r(NULL, delims, &save_ptr);
-		}
-		if (strchr(info, ',') != NULL) {
-			fprintf(outStream, "Bundle IDs: ");
-			fprintf(outStream, "%s", info);
-			fprintf(outStream, "\n");
-		} else if (strlen(info) > 0) {
-			fprintf(outStream, "Bundle ID: ");
-			fprintf(outStream, "%s", info);
-			fprintf(outStream, "\n");
-		}
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/lb_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/lb_command.c b/shell/private/src/lb_command.c
deleted file mode 100644
index d0504f6..0000000
--- a/shell/private/src/lb_command.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/**
- *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.
- */
-/*
- * std_shell_commands.c
- *
- *  \date       March 27, 2014
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-#include "std_commands.h"
-#include "shell_constants.h"
-
-static const char * const HEAD_COLOR = "\033[4m"; //underline
-static const char * const EVEN_COLOR = "\033[1m"; //bold
-static const char * const ODD_COLOR = "\033[3m";  //italic
-static const char * const END_COLOR = "\033[0m";
-
-static char * psCommand_stateString(bundle_state_e state); 
-
-celix_status_t psCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_context_t* ctx = _ptr;
-
-    const char* config = NULL;
-    bundleContext_getPropertyWithDefault(ctx, SHELL_USE_ANSI_COLORS, SHELL_USE_ANSI_COLORS_DEFAULT_VALUE, &config);
-    bool useColors = config != NULL && strncmp("true", config, 5) == 0;
-
-    bundle_context_pt context_ptr = _ptr;
-    array_list_pt bundles_ptr     = NULL;
-
-    bool show_location        = false;
-    bool show_symbolic_name   = false;
-    bool show_update_location = false;
-    char *message_str         = "Name";
-
-    if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        status = bundleContext_getBundles(context_ptr, &bundles_ptr);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        char *sub_str = NULL;
-        char *save_ptr = NULL;
-
-        strtok_r(command_line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-        sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-        while (sub_str != NULL) {
-            if (strcmp(sub_str, "-l") == 0) {
-                show_location = true;
-                message_str = "Location";
-            } else if (strcmp(sub_str, "-s") == 0) {
-                show_symbolic_name = true;
-                message_str = "Symbolic name";
-            } else if (strcmp(sub_str, "-u") == 0) {
-                show_update_location = true;
-                message_str = "Update location";
-            }
-            sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-        }
-
-	const char* startColor = "";
-	const char* endColor = "";
-	if (useColors) {
-		startColor = HEAD_COLOR;
-		endColor = END_COLOR;
-	} 
-        fprintf(out_ptr, "%s  %-5s %-12s %s%s\n", startColor, "ID", "State", message_str, endColor);
-
-        unsigned int size = arrayList_size(bundles_ptr);
-
-        bundle_pt bundles_array_ptr[size];
-
-        for (unsigned int i = 0; i < size; i++) {
-            bundles_array_ptr[i] = arrayList_get(bundles_ptr, i);
-        }
-
-        for (unsigned int i = 0; i < size - 1; i++) {
-            for (unsigned int j = i + 1; j < size; j++) {
-                bundle_pt first_ptr = bundles_array_ptr[i];
-                bundle_pt second_ptr = bundles_array_ptr[j];
-
-                bundle_archive_pt first_archive_ptr = NULL;
-                bundle_archive_pt second_archive_ptr = NULL;
-
-                long first_id;
-                long second_id;
-
-                bundle_getArchive(first_ptr, &first_archive_ptr);
-                bundle_getArchive(second_ptr, &second_archive_ptr);
-
-                bundleArchive_getId(first_archive_ptr, &first_id);
-                bundleArchive_getId(second_archive_ptr, &second_id);
-
-                if (first_id > second_id) {
-                    bundle_pt temp_ptr = bundles_array_ptr[i];
-                    bundles_array_ptr[i] = bundles_array_ptr[j];
-                    bundles_array_ptr[j] = temp_ptr;
-                }
-            }
-        }
-
-        for (unsigned int i = 0; i < size; i++) {
-            celix_status_t sub_status;
-
-            bundle_pt bundle_ptr = bundles_array_ptr[i];
-
-            bundle_archive_pt archive_ptr = NULL;
-            long id = 0;
-            bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
-            const char *state_str = NULL;
-            module_pt module_ptr = NULL;
-            const char *name_str = NULL;
-
-            sub_status = bundle_getArchive(bundle_ptr, &archive_ptr);
-            if (sub_status == CELIX_SUCCESS) {
-                sub_status = bundleArchive_getId(archive_ptr, &id);
-            }
-
-            if (sub_status == CELIX_SUCCESS) {
-                sub_status = bundle_getState(bundle_ptr, &state);
-            }
-
-            if (sub_status == CELIX_SUCCESS) {
-                state_str = psCommand_stateString(state);
-
-                sub_status = bundle_getCurrentModule(bundle_ptr, &module_ptr);
-            }
-
-            if (sub_status == CELIX_SUCCESS) {
-                sub_status = module_getSymbolicName(module_ptr, &name_str);
-            }
-
-            if (sub_status == CELIX_SUCCESS) {
-                if (show_location) {
-                    sub_status = bundleArchive_getLocation(archive_ptr, &name_str);
-                } else if (show_symbolic_name) {
-                    // do nothing
-                } else if (show_update_location) {
-                    sub_status = bundleArchive_getLocation(archive_ptr, &name_str);
-                }
-            }
-
-            if (sub_status == CELIX_SUCCESS) {
-		startColor = "";
-		endColor = "";
-                if (useColors) {
-                    startColor = i % 2 == 0 ? EVEN_COLOR : ODD_COLOR;
-                    endColor = END_COLOR;
-                } 
-		fprintf(out_ptr, "%s  %-5ld %-12s %s%s\n", startColor, id, state_str, name_str, endColor);
-
-            }
-
-            if (sub_status != CELIX_SUCCESS) {
-                status = sub_status;
-                break;
-            }
-        }
-
-        arrayList_destroy(bundles_ptr);
-    }
-
-    return status;
-}
-
-static char * psCommand_stateString(bundle_state_e state) {
-    switch (state) {
-        case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
-            return "Active      ";
-        case OSGI_FRAMEWORK_BUNDLE_INSTALLED:
-            return "Installed   ";
-        case OSGI_FRAMEWORK_BUNDLE_RESOLVED:
-            return "Resolved    ";
-        case OSGI_FRAMEWORK_BUNDLE_STARTING:
-            return "Starting    ";
-        case OSGI_FRAMEWORK_BUNDLE_STOPPING:
-            return "Stopping    ";
-        default:
-            return "Unknown     ";
-    }
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/log_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/log_command.c b/shell/private/src/log_command.c
deleted file mode 100644
index 8b0244a..0000000
--- a/shell/private/src/log_command.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- *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.
- */
-/*
- * log_command.c
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "bundle_context.h"
-#include "log_reader_service.h"
-#include "linked_list_iterator.h"
-
-celix_status_t logCommand_levelAsString(bundle_context_pt context, log_level_t level, char **string);
-
-void logCommand_execute(bundle_context_pt context, char *line, FILE *outStream, FILE *errStream) {
-    celix_status_t status;
-    service_reference_pt readerService = NULL;
-
-    status = bundleContext_getServiceReference(context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, &readerService);
-    if (status != CELIX_SUCCESS || readerService != NULL) {
-        linked_list_pt list = NULL;
-        linked_list_iterator_pt iter = NULL;
-        log_reader_service_pt reader = NULL;
-
-
-		bundleContext_getService(context, readerService, (void **) &reader);
-		reader->getLog(reader->reader, &list);
-		iter = linkedListIterator_create(list, 0);
-		while (linkedListIterator_hasNext(iter)) {
-			log_entry_pt entry = linkedListIterator_next(iter);
-			char time[20];
-			char *level = NULL;
-			char errorString[256];
-
-            strftime(time, 20, "%Y-%m-%d %H:%M:%S", localtime(&entry->time));
-            logCommand_levelAsString(context, entry->level, &level);
-
-			if (entry->errorCode > 0) {
-				celix_strerror(entry->errorCode, errorString, 256);
-				fprintf(outStream, "%s - Bundle: %s - %s - %d %s\n", time, entry->bundleSymbolicName, entry->message, entry->errorCode, errorString);
-			} else {
-				fprintf(outStream, "%s - Bundle: %s - %s\n", time, entry->bundleSymbolicName, entry->message);
-			}
-		}
-		linkedListIterator_destroy(iter);
-		linkedList_destroy(list);
-		bool result = true;
-		bundleContext_ungetService(context, readerService, &result);
-        bundleContext_ungetServiceReference(context, readerService);
-    } else {
-		fprintf(outStream, "No log reader available\n");
-    }
-}
-
-celix_status_t logCommand_levelAsString(bundle_context_pt context, log_level_t level, char **string) {
-	switch (level) {
-	case OSGI_LOGSERVICE_ERROR:
-		*string = "ERROR";
-		break;
-	case OSGI_LOGSERVICE_WARNING:
-		*string = "WARNING";
-		break;
-	case OSGI_LOGSERVICE_INFO:
-		*string = "INFO";
-		break;
-	case OSGI_LOGSERVICE_DEBUG:
-	default:
-		*string = "DEBUG";
-		break;
-	}
-
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/shell.c
----------------------------------------------------------------------
diff --git a/shell/private/src/shell.c b/shell/private/src/shell.c
deleted file mode 100644
index ac8603e..0000000
--- a/shell/private/src/shell.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/**
- *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.
- */
-/*
- * shell.c
- *
- *  \date       Aug 13, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <log_helper.h>
-
-#include "celix_errno.h"
-
-#include "shell_private.h"
-
-
-#include "utils.h"
-
-celix_status_t shell_getCommands(shell_pt shell_ptr, array_list_pt *commands_ptr);
-celix_status_t shell_getCommandUsage(shell_pt shell_ptr, char *command_name_str, char **usage_pstr);
-celix_status_t shell_getCommandDescription(shell_pt shell_ptr, char *command_name_str, char **command_description_pstr);
-
-celix_status_t shell_create(bundle_context_pt context_ptr, shell_service_pt *shell_service_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!context_ptr || !shell_service_ptr) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*shell_service_ptr =  calloc(1, sizeof(**shell_service_ptr));
-		if (!*shell_service_ptr) {
-			status = CELIX_ENOMEM;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		(*shell_service_ptr)->shell = calloc(1, sizeof(*(*shell_service_ptr)->shell));
-		if (!(*shell_service_ptr)->shell) {
-			status = CELIX_ENOMEM;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		(*shell_service_ptr)->shell->bundle_context_ptr = context_ptr;
-		(*shell_service_ptr)->shell->command_name_map_ptr = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-		(*shell_service_ptr)->shell->command_reference_map_ptr = hashMap_create(NULL, NULL, NULL, NULL);
-
-		(*shell_service_ptr)->getCommands = shell_getCommands;
-		(*shell_service_ptr)->getCommandDescription = shell_getCommandDescription;
-		(*shell_service_ptr)->getCommandUsage = shell_getCommandUsage;
-		(*shell_service_ptr)->getCommandReference = shell_getCommandReference;
-		(*shell_service_ptr)->executeCommand = shell_executeCommand;
-
-        status = logHelper_create(context_ptr, &(*shell_service_ptr)->shell->logHelper);
-	}
-
-	if (status != CELIX_SUCCESS) {
-		shell_destroy(shell_service_ptr);
-	}
-
-	return status;
-}
-
-celix_status_t shell_destroy(shell_service_pt *shell_service_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!shell_service_ptr || !*shell_service_ptr) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		if ((*shell_service_ptr)->shell) {
-			if ((*shell_service_ptr)->shell->command_name_map_ptr) {
-				hashMap_destroy((*shell_service_ptr)->shell->command_name_map_ptr, false, false);
-			}
-			if ((*shell_service_ptr)->shell->command_reference_map_ptr) {
-				hashMap_destroy((*shell_service_ptr)->shell->command_reference_map_ptr, false, false);
-			}
-			if ((*shell_service_ptr)->shell->logHelper) {
-				logHelper_destroy(&((*shell_service_ptr)->shell->logHelper));
-			}
-			free((*shell_service_ptr)->shell);
-			(*shell_service_ptr)->shell = NULL;
-		}
-		free(*shell_service_ptr);
-		*shell_service_ptr = NULL;
-	}
-
-	return status;
-}
-
-celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc) {
-    celix_status_t status = CELIX_SUCCESS;
-    command_service_pt command_ptr = NULL;
-    const char *name_str = NULL;
-
-    if (!shell_ptr || !reference_ptr) {
-        return CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        command_ptr = svc;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
-        if (!name_str) {
-            logHelper_log(shell_ptr->logHelper, OSGI_LOGSERVICE_ERROR, "Command service must contain a 'command.name' property!");
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
-
-    if (status == CELIX_SUCCESS) {
-        hashMap_put(shell_ptr->command_name_map_ptr, (char *)name_str, command_ptr);
-        hashMap_put(shell_ptr->command_reference_map_ptr, reference_ptr, command_ptr);
-    }
-
-    if (status != CELIX_SUCCESS) {
-        shell_removeCommand(shell_ptr, reference_ptr, svc);
-        char err[32];
-        celix_strerror(status, err, 32);
-        logHelper_log(shell_ptr->logHelper, OSGI_LOGSERVICE_ERROR, "Could not add command, got error %s\n", err);
-    }
-
-    return status;
-}
-
-celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    command_service_pt command_ptr = NULL;
-    const char *name_str = NULL;
-
-    if (!shell_ptr || !reference_ptr) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        command_ptr = hashMap_remove(shell_ptr->command_reference_map_ptr, reference_ptr);
-        if (!command_ptr) {
-            status = CELIX_ILLEGAL_ARGUMENT;
-        }
-    }
-
-    if (status == CELIX_SUCCESS) {
-        status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
-        if (!name_str) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
-
-    if (status == CELIX_SUCCESS) {
-        hashMap_remove(shell_ptr->command_name_map_ptr, (char *)name_str);
-    }
-
-    return status;
-}
-
-celix_status_t shell_getCommands(shell_pt shell_ptr, array_list_pt *commands_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	hash_map_iterator_pt iter = NULL;
-
-	if (!shell_ptr || !commands_ptr) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		iter = hashMapIterator_create(shell_ptr->command_name_map_ptr);
-		if (!iter) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		arrayList_create(commands_ptr);
-		while (hashMapIterator_hasNext(iter)) {
-			char *name_str = hashMapIterator_nextKey(iter);
-			arrayList_add(*commands_ptr, name_str);
-		}
-		hashMapIterator_destroy(iter);
-	}
-
-	return status;
-}
-
-
-celix_status_t shell_getCommandUsage(shell_pt shell_ptr, char *command_name_str, char **usage_pstr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_reference_pt reference = NULL;
-
-	if (!shell_ptr || !command_name_str || !usage_pstr) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = shell_getCommandReference(shell_ptr, command_name_str, &reference);
-		if (!reference) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = serviceReference_getProperty(reference, "command.usage", (const char**)usage_pstr);
-	}
-
-	return status;
-}
-
-celix_status_t shell_getCommandDescription(shell_pt shell_ptr, char *command_name_str, char **command_description_pstr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_reference_pt reference = NULL;
-
-	if (!shell_ptr || !command_name_str || !command_description_pstr) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = shell_getCommandReference(shell_ptr, command_name_str, &reference);
-		if (!reference) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		serviceReference_getProperty(reference, "command.description", (const char**)command_description_pstr);
-	}
-
-	return status;
-}
-
-celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!shell_ptr || !command_name_str || !command_reference_ptr) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*command_reference_ptr = NULL;
-		hash_map_iterator_pt iter = hashMapIterator_create(shell_ptr->command_reference_map_ptr);
-		while (hashMapIterator_hasNext(iter)) {
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-			service_reference_pt reference = hashMapEntry_getKey(entry);
-			const char *name_str = NULL;
-			serviceReference_getProperty(reference, "command.name", &name_str);
-			if (strcmp(name_str, command_name_str) == 0) {
-				*command_reference_ptr = (service_reference_pt) hashMapEntry_getKey(entry);
-				break;
-			}
-		}
-		hashMapIterator_destroy(iter);
-	}
-
-	return status;
-}
-
-celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, FILE *out, FILE *err) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	command_service_pt command_ptr = NULL;
-
-	if (!shell_ptr || !command_line_str || !out || !err) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		size_t pos = strcspn(command_line_str, " ");
-
-		char *command_name_str = (pos != strlen(command_line_str)) ? strndup(command_line_str, pos) : strdup(command_line_str);
-		command_ptr = hashMap_get(shell_ptr->command_name_map_ptr, command_name_str);
-		free(command_name_str);
-		if (!command_ptr) {
-			fprintf(err, "No such command\n");
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = command_ptr->executeCommand(command_ptr->handle, command_line_str, out, err);
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/start_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/start_command.c b/shell/private/src/start_command.c
deleted file mode 100644
index f43699a..0000000
--- a/shell/private/src/start_command.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- *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.
- */
-/*
- * start_command.c
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "std_commands.h"
-#include "bundle_context.h"
-
-celix_status_t startCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    bundle_context_pt context_ptr = _ptr;
-
-    if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        char *sub_str = NULL;
-        char *save_ptr = NULL;
-
-        strtok_r(command_line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-        sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-
-        if (sub_str == NULL) {
-            fprintf(out_ptr, "Incorrect number of arguments.\n");
-        } else {
-            while (sub_str != NULL) {
-                celix_status_t sub_status = CELIX_SUCCESS;
-
-                bundle_pt bundle_ptr = NULL;
-
-                char *end_str = NULL;
-                long id = strtol(sub_str, &end_str, 10);
-                if (*end_str) {
-                    sub_status = CELIX_ILLEGAL_ARGUMENT;
-                    fprintf(err_ptr, "Bundle id '%s' is invalid, problem at %s\n", sub_str, end_str);
-                }
-
-                if (sub_status == CELIX_SUCCESS) {
-                    sub_status = bundleContext_getBundleById(context_ptr, id, &bundle_ptr);
-                }
-
-                if (sub_status == CELIX_SUCCESS) {
-                    bundle_startWithOptions(bundle_ptr, 0);
-                }
-
-                if (sub_status != CELIX_SUCCESS) {
-                    status = sub_status;
-                    break;
-                }
-
-                sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-            }
-        }
-
-    }
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/stop_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/stop_command.c b/shell/private/src/stop_command.c
deleted file mode 100644
index 0093c99..0000000
--- a/shell/private/src/stop_command.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *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.
- */
-/*
- * stop_command.c
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "bundle_context.h"
-#include "std_commands.h"
-
-celix_status_t stopCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    bundle_context_pt context_ptr = _ptr;
-
-    if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        char *sub_str = NULL;
-        char *save_ptr = NULL;
-
-        strtok_r(command_line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-        sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-
-        if (sub_str == NULL) {
-            fprintf(out_ptr, "Incorrect number of arguments.\n");
-        } else {
-            while (sub_str != NULL) {
-                celix_status_t sub_status = CELIX_SUCCESS;
-
-                bundle_pt bundle_ptr = NULL;
-
-                char *end_str = NULL;
-                long id = strtol(sub_str, &end_str, 10);
-                if (*end_str) {
-                    sub_status = CELIX_ILLEGAL_ARGUMENT;
-                    fprintf(err_ptr, "Bundle id '%s' is invalid, problem at %s\n", sub_str, end_str);
-                }
-
-                if (sub_status == CELIX_SUCCESS) {
-                    sub_status = bundleContext_getBundleById(context_ptr, id, &bundle_ptr);
-                }
-
-                if (sub_status == CELIX_SUCCESS) {
-                    bundle_stopWithOptions(bundle_ptr, 0);
-                }
-
-                if (sub_status != CELIX_SUCCESS) {
-                    status = sub_status;
-                    break;
-                }
-
-                sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-            }
-        }
-    }
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/uninstall_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/uninstall_command.c b/shell/private/src/uninstall_command.c
deleted file mode 100644
index fb30831..0000000
--- a/shell/private/src/uninstall_command.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- *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.
- */
-/*
- * uninstall_command.c
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-
-celix_status_t uninstallCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
-	bundle_context_pt context = handle;
-	char delims[] = " ";
-	char * sub = NULL;
-	char *save_ptr = NULL;
-	celix_status_t status = CELIX_SUCCESS;
-
-	sub = strtok_r(line, delims, &save_ptr);
-	sub = strtok_r(NULL, delims, &save_ptr);
-
-	if (sub == NULL) {
-		fprintf(errStream, "Incorrect number of arguments.\n");
-	} else {
-		while (sub != NULL) {
-			long id = atol(sub);
-			bundle_pt bundle = NULL;
-			status = bundleContext_getBundleById(context, id, &bundle);
-			if (status==CELIX_SUCCESS && bundle!=NULL) {
-				bundle_uninstall(bundle);
-			} else {
-				fprintf(errStream, "Bundle id is invalid.");
-			}
-			sub = strtok_r(NULL, delims, &save_ptr);
-		}
-	}
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/update_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/update_command.c b/shell/private/src/update_command.c
deleted file mode 100644
index 64999ac..0000000
--- a/shell/private/src/update_command.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- *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.
- */
-/*
- * update_command.c
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- *
- */
-#include <stdlib.h>
-#include <string.h>
-#include <curl/curl.h>
-#include <sys/stat.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-
-celix_status_t updateCommand_download(bundle_context_pt context, char * url, char **inputFile);
-size_t updateCommand_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream);
-
-void updateCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
-	bundle_context_pt context = handle;
-    bundle_pt bundle = NULL;
-	char delims[] = " ";
-	char * sub = NULL;
-	char *save_ptr = NULL;
-
-	sub = strtok_r(line, delims, &save_ptr);
-	sub = strtok_r(NULL, delims, &save_ptr);
-
-	if (sub == NULL) {
-		fprintf(errStream, "Incorrect number of arguments.\n");
-	} else {
-		long id = atol(sub);
-		celix_status_t ret = bundleContext_getBundleById(context, id, &bundle);
-		if (ret==CELIX_SUCCESS && bundle!=NULL) {
-			char inputFile[256];
-			sub = strtok_r(NULL, delims, &save_ptr);
-			inputFile[0] = '\0';
-			if (sub != NULL) {
-				char *test = inputFile;
-				printf("URL: %s\n", sub);
-
-				if (updateCommand_download(context, sub, &test) == CELIX_SUCCESS) {
-					printf("Update bundle with stream\n");
-					bundle_update(bundle, inputFile);
-				} else {
-					fprintf(errStream, "Unable to download from %s\n", sub);
-				}
-			} else {
-				bundle_update(bundle, NULL);
-			}
-		} else {
-			fprintf(errStream, "Bundle id is invalid.\n");
-		}
-	}
-}
-
-celix_status_t updateCommand_download(bundle_context_pt context, char * url, char **inputFile) {
-	CURL *curl = NULL;
-	CURLcode res = CURLE_FILE_COULDNT_READ_FILE;
-	curl = curl_easy_init();
-	if (curl) {
-		FILE *fp = NULL;
-		snprintf(*inputFile, 13,"updateXXXXXX");
-		umask(0011);
-		int fd = mkstemp(*inputFile);
-		if (fd) {
-		    fp = fopen(*inputFile, "wb+");
-		    if(fp!=NULL){
-		    	printf("Temp file: %s\n", *inputFile);
-		    	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-		    	curl_easy_setopt(curl, CURLOPT_URL, url);
-		    	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, updateCommand_writeData);
-		    	curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
-		    	//curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
-		    	//curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, updateCommand_downloadProgress);
-		    	res = curl_easy_perform(curl);
-		    	fclose(fp);
-		    }
-		    /* always cleanup */
-		    curl_easy_cleanup(curl);
-		    if(fp==NULL){
-		    	return CELIX_FILE_IO_EXCEPTION;
-		    }
-		}
-	}
-	if (res != CURLE_OK) {
-		printf("Error: %d\n", res);
-		*inputFile[0] = '\0';
-		return CELIX_ILLEGAL_STATE;
-	} else {
-		return CELIX_SUCCESS;
-	}
-}
-
-size_t updateCommand_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream) {
-    size_t written = fwrite(ptr, size, nmemb, stream);
-    return written;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/public/include/command.h
----------------------------------------------------------------------
diff --git a/shell/public/include/command.h b/shell/public/include/command.h
deleted file mode 100644
index 0e86dcc..0000000
--- a/shell/public/include/command.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *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.
- */
-/*
- * command.h
- *
- *  \date       Aug 13, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef COMMAND_H_
-#define COMMAND_H_
-
-#include "celix_errno.h"
-#include <stdio.h>
-
-#define OSGI_SHELL_COMMAND_NAME "command.name"
-#define OSGI_SHELL_COMMAND_USAGE "command.usage"
-#define OSGI_SHELL_COMMAND_DESCRIPTION "command.description"
-
-static const char * const OSGI_SHELL_COMMAND_SERVICE_NAME = "commandService";
-
-typedef struct commandService command_service_t;
-typedef command_service_t * command_service_pt;
-
-/**
- * The command service can be used to register additional shell commands.
- * The service should be register with the following properties:
- *  - command.name: mandatory, name of the command e.g. 'lb'
- *  - command.usage: optional, string describing how tu use the commmand e.g. 'lb [-l | -s | -u]'
- *  - command.descrription: optional, string describing the command e.g. 'list bundles.'
- */
-struct commandService {
-	void *handle;
-	celix_status_t (*executeCommand)(void *handle, char * commandLine, FILE *outStream, FILE *errorStream);
-};
-
-
-
-
-#endif /* COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/public/include/shell.h
----------------------------------------------------------------------
diff --git a/shell/public/include/shell.h b/shell/public/include/shell.h
deleted file mode 100644
index c8e7d60..0000000
--- a/shell/public/include/shell.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *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.
- */
-/*
- * shell.h
- *
- *  \date       Aug 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef SHELL_H_
-#define SHELL_H_
-
-#include "array_list.h"
-#include "service_reference.h"
-
-static const char * const OSGI_SHELL_SERVICE_NAME = "shellService";
-
-typedef struct shell shell_t;
-typedef shell_t* shell_pt;
-
-struct shellService {
-	shell_pt shell;
-
-	celix_status_t (*getCommands)(shell_pt shell_ptr, array_list_pt *commands_ptr);
-	celix_status_t (*getCommandUsage)(shell_pt shell_ptr, char *command_name_str, char **usage_str);
-	celix_status_t (*getCommandDescription)(shell_pt shell_ptr, char *command_name_str, char **command_description_str);
-	celix_status_t (*getCommandReference)(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
-	celix_status_t (*executeCommand)(shell_pt shell_ptr, char * command_line_str, FILE *out, FILE *err);
-};
-
-typedef struct shellService shell_service_t;
-typedef shell_service_t* shell_service_pt;
-
-#endif /* SHELL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/public/include/shell_constants.h
----------------------------------------------------------------------
diff --git a/shell/public/include/shell_constants.h b/shell/public/include/shell_constants.h
deleted file mode 100644
index 1e7f875..0000000
--- a/shell/public/include/shell_constants.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- *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.
- */
-
-
-#ifndef SHELL_CONSTANTS_H_
-#define SHELL_CONSTANTS_H_
-
-#define SHELL_USE_ANSI_COLORS "SHELL_USE_ANSI_COLORS"
-#define SHELL_USE_ANSI_COLORS_DEFAULT_VALUE "true"
-
-#endif /* SHELL_CONSTANTS_H_ */


[32/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/dyn_function_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_function_tests.cpp b/dfi/private/test/dyn_function_tests.cpp
deleted file mode 100644
index 58ad662..0000000
--- a/dfi/private/test/dyn_function_tests.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
- *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.
- */
-#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*, 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");
-        va_end(ap);
-    }
-
-    #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);
-    }
-
-    static void test_access_functions(void) {
-        dyn_function_type *dynFunc = NULL;
-        int rc;
-        rc = dynFunction_parseWithStr("add(D{DD a b}*D)V", NULL, &dynFunc);
-
-        CHECK_EQUAL(0, rc);
-
-        int nrOfArgs = dynFunction_nrOfArguments(dynFunc);
-        CHECK_EQUAL(3, nrOfArgs);
-
-        dyn_type *arg1 = dynFunction_argumentTypeForIndex(dynFunc, 1);
-        CHECK(arg1 != NULL);
-        CHECK_EQUAL('{', (char) dynType_descriptorType(arg1));
-
-        dyn_type *nonExist = dynFunction_argumentTypeForIndex(dynFunc, 10);
-        CHECK(nonExist == NULL);
-
-        dyn_type *returnType = dynFunction_returnType(dynFunc);
-        CHECK_EQUAL('V', (char) dynType_descriptorType(returnType));
-
-        dynFunction_destroy(dynFunc);
-    }
-
-    //example with gen pointer and output
-    #define EXAMPLE3_DESCRIPTOR "example(PD*D)N"
-
-    static int testExample3(void *ptr, double a, double *out) {
-        double *b = (double *)ptr;
-        CHECK_EQUAL(2.0, *b)
-        CHECK_EQUAL(a, 2.0);
-        *out = *b * a;
-        return 0;
-    }
-
-    static void test_example3(void) {
-        dyn_function_type *dynFunc = NULL;
-        void (*fp)(void) = (void(*)(void)) testExample3;
-        int rc;
-
-        rc = dynFunction_parseWithStr(EXAMPLE3_DESCRIPTOR, NULL, &dynFunc);
-        CHECK_EQUAL(0, rc);
-        double result = -1.0;
-        double *input = &result;
-        double a = 2.0;
-        void *ptr = &a;
-        void *args[3];
-        args[0] = &ptr;
-        args[1] = &a;
-        args[2] = &input;
-        int rVal = 0;
-        rc = dynFunction_call(dynFunc, fp, &rVal, args);
-        CHECK_EQUAL(0, rc);
-        CHECK_EQUAL(4.0, result);
-
-
-        double *inMemResult = (double *)calloc(1, sizeof(double));
-        a = 2.0;
-        ptr = &a;
-        args[0] = &ptr;
-        args[1] = &a;
-        args[2] = &inMemResult;
-        rVal = 0;
-        rc = dynFunction_call(dynFunc, fp, &rVal, args);
-        CHECK_EQUAL(0, rc);
-        CHECK_EQUAL(4.0, result);
-        free(inMemResult);
-
-        dynFunction_destroy(dynFunc);
-    }
-
-    struct tst_seq {
-        uint32_t cap;
-        uint32_t len;
-        double *buf;
-    };
-
-    #define EXAMPLE4_DESCRIPTOR "example([D)V"
-
-    static void example4Func(struct tst_seq seq) {
-        CHECK_EQUAL(4, seq.cap);
-        CHECK_EQUAL(2, seq.len);
-        CHECK_EQUAL(1.1, seq.buf[0]);
-        CHECK_EQUAL(2.2, seq.buf[1]);
-    }
-
-    static void test_example4(void) {
-        dyn_function_type *dynFunc = NULL;
-        void (*fp)(void) = (void(*)(void)) example4Func;
-        int rc;
-
-        rc = dynFunction_parseWithStr(EXAMPLE4_DESCRIPTOR, NULL, &dynFunc);
-        CHECK_EQUAL(0, rc);
-
-        double buf[4];
-        buf[0] = 1.1;
-        buf[1] = 2.2;
-        struct tst_seq seq;
-        seq.cap = 4;
-        seq.len = 2;
-        seq.buf = buf;
-
-        void *args[1];
-        args[0] = &seq;
-        rc = dynFunction_call(dynFunc, fp, NULL, args);
-        CHECK_EQUAL(0, rc);
-
-        dynFunction_destroy(dynFunc);
-    }
-
-    #define INVALID_FUNC_DESCRIPTOR "example$[D)V"//$ is an invalid symbol, missing (
-
-    static void test_invalidDynFunc(void) {
-        dyn_function_type *dynFunc = NULL;
-        int rc = dynFunction_parseWithStr(INVALID_FUNC_DESCRIPTOR, NULL, &dynFunc);
-        CHECK_EQUAL(2, rc); //Mem error
-    }
-
-    #define INVALID_FUNC_TYPE_DESCRIPTOR "example(H)A"//H and A are invalid types
-
-    static void test_invalidDynFuncType(void) {
-        dyn_function_type *dynFunc = NULL;
-        int rc = dynFunction_parseWithStr(INVALID_FUNC_TYPE_DESCRIPTOR, NULL, &dynFunc);
-        CHECK_EQUAL(3, rc); //Parse Error
-    }
-}
-
-TEST_GROUP(DynFunctionTests) {
-    void setup() {
-        int lvl = 1;
-        dynFunction_logSetup(stdLog, NULL, lvl);
-        dynType_logSetup(stdLog, NULL, lvl);
-        dynCommon_logSetup(stdLog, NULL, lvl);
-    }
-};
-
-TEST(DynFunctionTests, DynFuncTest1) {
-    test_example1();
-}
-
-TEST(DynFunctionTests, DynFuncTest2) {
-    test_example2();
-}
-
-TEST(DynFunctionTests, DynFuncAccTest) {
-    test_access_functions();
-}
-
-TEST(DynFunctionTests, DynFuncTest3) {
-    test_example3();
-}
-
-TEST(DynFunctionTests, DynFuncTest4) {
-    test_example4();
-}
-
-TEST(DynFunctionTests, InvalidDynFuncTest) {
-    test_invalidDynFunc();
-    test_invalidDynFuncType();
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/dyn_interface_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_interface_tests.cpp b/dfi/private/test/dyn_interface_tests.cpp
deleted file mode 100644
index df9752f..0000000
--- a/dfi/private/test/dyn_interface_tests.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/**
- *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.
- */
-#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*, 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");
-        va_end(ap);
-    }
-
-    static void checkInterfaceVersion(dyn_interface_type* dynIntf, const char* v) {
-        int status;
-
-        char *version = NULL;
-        status = dynInterface_getVersionString(dynIntf, &version);
-        CHECK_EQUAL(0, status);
-        STRCMP_EQUAL(v, version);
-        version_pt msgVersion = NULL, localMsgVersion = NULL;
-        int cmpVersion = -1;
-        version_createVersionFromString(version, &localMsgVersion);
-        status = dynInterface_getVersion(dynIntf, &msgVersion);
-        CHECK_EQUAL(0, status);
-        version_compareTo(msgVersion, localMsgVersion, &cmpVersion);
-        CHECK_EQUAL(cmpVersion, 0);
-        version_destroy(localMsgVersion);
-    }
-
-    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);
-
-	checkInterfaceVersion(dynIntf,"1.0.0");
-
-        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);
-
-        struct methods_head *list = NULL;
-        status = dynInterface_methods(dynIntf, &list);
-        CHECK(status == 0);
-        CHECK(list != NULL);
-
-        int count = dynInterface_nrOfMethods(dynIntf);
-        CHECK_EQUAL(4, count);
-
-        dynInterface_destroy(dynIntf);
-    }
-
-    static void test2(void) {
-        int status = 0;
-        dyn_interface_type *dynIntf = NULL;
-        FILE *desc = fopen("descriptors/example3.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        CHECK_EQUAL(0, status);
-        fclose(desc);
-
-        dynInterface_destroy(dynIntf);
-    }
-
-    static void testInvalid(void) {
-        int status = 0;
-
-        /* Invalid field */
-        dyn_interface_type *dynIntf = NULL;
-        FILE *desc = fopen("descriptors/invalids/invalid.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        //dynInterface_destroy(dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of a space at the end of the name
-        fclose(desc); desc=NULL;
-
-
-        /* Header without Version */
-        desc = fopen("descriptors/invalids/noVersion.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        //dynInterface_destroy(dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of missing version field in header section
-        fclose(desc); desc=NULL;
-
-        /* Invalid section */
-        desc = fopen("descriptors/invalids/invalidSection.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        //dynInterface_destroy(dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of unknown section type
-        fclose(desc); desc=NULL;
-
-        /* Invalid return type */
-        desc = fopen("descriptors/invalids/invalidMethodReturnType.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        //dynInterface_destroy(dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of invalid return type (D instead of N)
-        fclose(desc); desc=NULL;
-
-        /* Invalid  method section */
-        desc = fopen("descriptors/invalids/invalidMethod.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        //dynInterface_destroy(dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of space at the end of the method
-        fclose(desc); desc=NULL;
-
-        /* Invalid type */
-        desc = fopen("descriptors/invalids/invalidType.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        //dynInterface_destroy(dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of space at the end of the type
-        fclose(desc); desc=NULL;
-
-        /* Invalid metatype in method description */
-        desc = fopen("descriptors/invalids/invalidMetaType.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        dynInterface_destroy(dynIntf);
-        CHECK_EQUAL(0, status); //Invalid meta type doesn't generate errors, just warnings
-        fclose(desc); desc=NULL; dynIntf=NULL;
-
-        /* Invalid version section */
-        desc = fopen("descriptors/invalids/invalidVersion.descriptor", "r");
-        assert(desc != NULL);
-        status = dynInterface_parse(desc, &dynIntf);
-        //dynInterface_destroy(dynIntf);
-        CHECK_EQUAL(1, status); //Invalid meta type doesn't generate errors, just warnings
-        fclose(desc); desc=NULL;
-
-    }
-}
-
-
-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();
-}
-
-TEST(DynInterfaceTests, test2) {
-    test2();
-}
-
-TEST(DynInterfaceTests, testInvalid) {
-    testInvalid();
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/dyn_message_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_message_tests.cpp b/dfi/private/test/dyn_message_tests.cpp
deleted file mode 100644
index e310537..0000000
--- a/dfi/private/test/dyn_message_tests.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/**
- *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.
- */
-#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_message.h"
-
-#if defined(BSD) || defined(__APPLE__) 
-#include "open_memstream.h"
-#include "fmemopen.h"
-#endif
-
-static void stdLog(void*, 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");
-	va_end(ap);
-}
-
-static void checkMessageVersion(dyn_message_type* dynMsg, const char* v){
-	int status = 0;
-
-	char *version = NULL;
-	status = dynMessage_getVersionString(dynMsg, &version);
-	CHECK_EQUAL(0, status);
-	STRCMP_EQUAL(v, version);
-	version_pt msgVersion = NULL, localMsgVersion = NULL;
-	int cmpVersion = -1;
-	version_createVersionFromString(version,&localMsgVersion);
-	status = dynMessage_getVersion(dynMsg,&msgVersion);
-	CHECK_EQUAL(0, status);
-	version_compareTo(msgVersion,localMsgVersion,&cmpVersion);
-	CHECK_EQUAL(cmpVersion,0);
-	version_destroy(localMsgVersion);
-
-}
-
-
-static void msg_test1(void) {
-	int status = 0;
-	dyn_message_type *dynMsg = NULL;
-	FILE *desc = fopen("descriptors/msg_example1.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK_EQUAL(0, status);
-	fclose(desc);
-
-	char *name = NULL;
-	status = dynMessage_getName(dynMsg, &name);
-	CHECK_EQUAL(0, status);
-	STRCMP_EQUAL("poi", name);
-
-	checkMessageVersion(dynMsg,"1.0.0");
-
-	char *annVal = NULL;
-	status = dynMessage_getAnnotationEntry(dynMsg, "classname", &annVal);
-	CHECK_EQUAL(0, status);
-	STRCMP_EQUAL("org.example.PointOfInterest", annVal);
-
-	char *nonExist = NULL;
-	status = dynMessage_getHeaderEntry(dynMsg, "nonExisting", &nonExist);
-	CHECK(status != 0);
-	CHECK(nonExist == NULL);
-
-	dyn_type *msgType = NULL;
-	status = dynMessage_getMessageType(dynMsg, &msgType);
-	CHECK_EQUAL(0, status);
-	CHECK(msgType != NULL);
-
-	dynMessage_destroy(dynMsg);
-}
-
-
-static void msg_test2(void) {
-	int status = 0;
-	dyn_message_type *dynMsg = NULL;
-	FILE *desc = fopen("descriptors/msg_example2.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK_EQUAL(0, status);
-	fclose(desc);
-
-	char *name = NULL;
-	status = dynMessage_getName(dynMsg, &name);
-	CHECK_EQUAL(0, status);
-	STRCMP_EQUAL("track", name);
-
-	checkMessageVersion(dynMsg,"0.0.1");
-
-	char *annVal = NULL;
-	status = dynMessage_getAnnotationEntry(dynMsg, "classname", &annVal);
-	CHECK_EQUAL(0, status);
-	STRCMP_EQUAL("org.example.Track", annVal);
-
-	char *nonExist = NULL;
-	status = dynMessage_getHeaderEntry(dynMsg, "nonExisting", &nonExist);
-	CHECK(status != 0);
-	CHECK(nonExist == NULL);
-
-	dyn_type *msgType = NULL;
-	status = dynMessage_getMessageType(dynMsg, &msgType);
-	CHECK_EQUAL(0, status);
-	CHECK(msgType != NULL);
-
-	dynMessage_destroy(dynMsg);
-}
-
-static void msg_test3(void) {
-	int status = 0;
-	dyn_message_type *dynMsg = NULL;
-	FILE *desc = fopen("descriptors/msg_example3.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK_EQUAL(0, status);
-	fclose(desc);
-
-	char *name = NULL;
-	status = dynMessage_getName(dynMsg, &name);
-	CHECK_EQUAL(0, status);
-	STRCMP_EQUAL("logEntry", name);
-
-	checkMessageVersion(dynMsg,"1.0.0");
-
-	char *annVal = NULL;
-	status = dynMessage_getAnnotationEntry(dynMsg, "classname", &annVal);
-	CHECK_EQUAL(0, status);
-	STRCMP_EQUAL("org.example.LogEntry", annVal);
-
-	char *nonExist = NULL;
-	status = dynMessage_getHeaderEntry(dynMsg, "nonExisting", &nonExist);
-	CHECK(status != 0);
-	CHECK(nonExist == NULL);
-
-	dyn_type *msgType = NULL;
-	status = dynMessage_getMessageType(dynMsg, &msgType);
-	CHECK_EQUAL(0, status);
-	CHECK(msgType != NULL);
-
-	dynMessage_destroy(dynMsg);
-}
-
-static void msg_test4(void) {
-	int status = 0;
-	dyn_message_type *dynMsg = NULL;
-	FILE *desc = fopen("descriptors/msg_example4.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK(status != 0);
-	fclose(desc);
-}
-
-static void msg_invalid(void) {
-	int status = 0;
-	dyn_message_type *dynMsg = NULL;
-	FILE *desc = fopen("descriptors/invalids/invalidMsgHdr.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK_EQUAL(1, status);
-	fclose(desc);
-
-	desc = fopen("descriptors/invalids/invalidMsgMissingVersion.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK_EQUAL(1, status);
-	fclose(desc);
-
-	desc = fopen("descriptors/invalids/invalidMsgInvalidSection.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK_EQUAL(1, status);
-	fclose(desc);
-
-	desc = fopen("descriptors/invalids/invalidMsgInvalidName.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK_EQUAL(1, status);
-	fclose(desc);
-
-	desc = fopen("descriptors/invalids/invalidMsgInvalidType.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK_EQUAL(1, status);
-	fclose(desc);
-
-	desc = fopen("descriptors/invalids/invalidMsgInvalidVersion.descriptor", "r");
-	assert(desc != NULL);
-	status = dynMessage_parse(desc, &dynMsg);
-	CHECK_EQUAL(1, status);
-	fclose(desc);
-
-}
-
-}
-
-
-TEST_GROUP(DynMessageTests) {
-	void setup() {
-		int level = 1;
-		dynCommon_logSetup(stdLog, NULL, level);
-		dynType_logSetup(stdLog, NULL, level);
-		dynMessage_logSetup(stdLog, NULL, level);
-	}
-};
-
-
-TEST(DynMessageTests, msg_test1) {
-	msg_test1();
-}
-
-TEST(DynMessageTests, msg_test2) {
-	msg_test2();
-}
-
-TEST(DynMessageTests, msg_test3) {
-	msg_test3();
-}
-
-TEST(DynMessageTests, msg_test4) {
-	msg_test4();
-}
-
-TEST(DynMessageTests, msg_invalid) {
-	msg_invalid();
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/dyn_type_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_type_tests.cpp b/dfi/private/test/dyn_type_tests.cpp
deleted file mode 100644
index 52f9537..0000000
--- a/dfi/private/test/dyn_type_tests.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/**
- *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.
- */
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
-
-extern "C" {
-    #include <stdarg.h>
-    
-    #include "dyn_common.h"
-    #include "dyn_type.h"
-
-	static void stdLog(void*, 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");
-	    va_end(ap);
-	}
-
-    static void runTest(const char *descriptorStr, const char *exName) {
-        dyn_type *type;
-        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);
-
-        //MEM check, to try to ensure no mem leaks/corruptions occur.
-        int i;
-        int j;
-        int nrOfBurst = 10;
-        int burst = 50;
-        void *pointers[burst];
-        for (j = 0; j < nrOfBurst; j += 1) {
-            for (i = 0; i < burst ; i +=1 ) {
-                pointers[i] = NULL;
-                dynType_alloc(type, &pointers[i]);
-            }
-            for (i = 0; i < burst ; i +=1 ) {
-                dynType_free(type, pointers[i]);
-            }
-        }
-
-        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, 1);
-	}
-};
-
-#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 EX15 "Tsample={jDD time val1 val2};Tresult={jDlsample; time result sample};Lresult;"
-#define EX16 "Tpoi={BDD id lat lon};Lpoi;"
-
-#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)
-CREATE_EXAMPLES_TEST(EX15)
-CREATE_EXAMPLES_TEST(EX16)
-
-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);
-}
-
-TEST(DynTypeTests, MetaInfoTest) {
-    dyn_type *type = NULL;
-    int rc = 0;
-    rc = dynType_parseWithStr("#a=t;{DD#longname=longvalue;D a b c}", NULL, NULL, &type);
-    //rc = dynType_parseWithStr("{DDD a b c}", NULL, NULL, &type);
-
-    CHECK_EQUAL(0, rc);
-
-    const char *val = NULL;
-    val = dynType_getMetaInfo(type, "a");
-    CHECK(val != NULL);
-    CHECK(strcmp("t", val) == 0);
-
-    val = dynType_getMetaInfo(type, "longname");
-    CHECK(val == NULL);
-
-    val = dynType_getMetaInfo(type, "nonexisting");
-    CHECK(val == NULL);
-
-    dynType_destroy(type);
-}
-
-TEST(DynTypeTests, SequenceWithPointerTest) {
-    struct val {
-        double a;
-        double b;
-    };
-
-    struct item {
-        int64_t a;
-        const char *text;
-        struct val val;
-        double c;
-        double d;
-        long e;
-    };
-
-    struct item_sequence {
-        uint32_t cap;
-        uint32_t len;
-        struct item **buf;
-    };
-
-    dyn_type *type = NULL;
-    int rc = 0;
-    rc = dynType_parseWithStr("Tval={DD a b};Titem={Jtlval;DDJ a text val c d e};**[Litem;", NULL, NULL, &type);
-    CHECK_EQUAL(0, rc);
-
-    struct item_sequence *seq = NULL;
-    rc = dynType_alloc(type, (void **)&seq);
-    CHECK_EQUAL(0, rc);
-    CHECK(seq != NULL);
-
-    dynType_free(type, seq);
-
-    /*
-
-
-    struct item_sequence *items = (struct item_sequence *) calloc(1,sizeof(struct item_sequence));
-    items->buf = (struct item **) calloc(2, sizeof(struct item *));
-    items->cap = 2;
-    items->len = 2;
-    items->buf[0] = (struct item *)calloc(1, sizeof(struct item));
-    items->buf[0]->text = strdup("boe");
-    items->buf[1] = (struct item *)calloc(1, sizeof(struct item));
-    items->buf[1]->text = strdup("boe2");
-
-    dynType_free(type, items);
-     */
-
-    dynType_destroy(type);
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/json_rpc_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/json_rpc_tests.cpp b/dfi/private/test/json_rpc_tests.cpp
deleted file mode 100644
index bff582e..0000000
--- a/dfi/private/test/json_rpc_tests.cpp
+++ /dev/null
@@ -1,433 +0,0 @@
-/**
- *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.
- */
-#include <CppUTest/TestHarness.h>
-#include <float.h>
-#include <assert.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"
-#include "json_rpc.h"
-
-static void stdLog(void*, 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");
-    va_end(ap);
-}
-
-
-    void prepareTest(void) {
-        dyn_function_type *dynFunc = NULL;
-        int rc = dynFunction_parseWithStr("add(#am=handle;PDD#am=pre;*D)N", NULL, &dynFunc);
-        CHECK_EQUAL(0, rc);
-
-        char *result = NULL;
-
-        void *handle = NULL;
-        double arg1 = 1.0;
-        double arg2 = 2.0;
-
-        void *args[4];
-        args[0] = &handle;
-        args[1] = &arg1;
-        args[2] = &arg2;
-
-        rc = jsonRpc_prepareInvokeRequest(dynFunc, "add", args, &result);
-        CHECK_EQUAL(0, rc);
-
-        //printf("result is %s\n", result);
-
-        STRCMP_CONTAINS("\"add\"", result);
-        STRCMP_CONTAINS("1.0", result);
-        STRCMP_CONTAINS("2.0", result);
-
-        free(result);
-        dynFunction_destroy(dynFunc);
-    }
-
-    void handleTestPre(void) {
-        dyn_function_type *dynFunc = NULL;
-        int rc = dynFunction_parseWithStr("add(#am=handle;PDD#am=pre;*D)N", NULL, &dynFunc);
-        CHECK_EQUAL(0, rc);
-
-        const char *reply = "{\"r\":2.2}";
-        double result = -1.0;
-        double *out = &result;
-        void *args[4];
-        args[3] = &out;
-        rc = jsonRpc_handleReply(dynFunc, reply, args);
-        CHECK_EQUAL(0, rc);
-        //CHECK_EQUAL(2.2, result);
-
-        dynFunction_destroy(dynFunc);
-    }
-
-    int add(void*, double a, double b, double *result) {
-        *result = a + b;
-        return 0;
-    }
-
-    int getName_example4(void*, char** result) {
-        *result = strdup("allocatedInFunction");
-        return 0;
-    }
-
-    struct tst_seq {
-        uint32_t cap;
-        uint32_t len;
-        double *buf;
-    };
-
-
-    //StatsResult={DDD[D average min max input}
-    struct tst_StatsResult {
-        double average;
-        double min;
-        double max;
-        struct tst_seq input;
-    };
-
-
-    int stats(void*, struct tst_seq input, struct tst_StatsResult **out) {
-        assert(out != NULL);
-        assert(*out == NULL);
-        double total = 0.0;
-        unsigned int count = 0;
-        double max = DBL_MIN;
-        double min = DBL_MAX;
-
-        unsigned int i;
-        for (i = 0; i<input.len; i += 1) {
-            total += input.buf[i];
-            count += 1;
-            if (input.buf[i] > max) {
-                max = input.buf[i];
-            }
-            if (input.buf[i] < min) {
-                min = input.buf[i];
-            }
-        }
-
-        struct tst_StatsResult *result = (struct tst_StatsResult *) calloc(1, sizeof(*result));
-        if(count>0){
-		result->average = total / count;
-        }
-        result->min = min;
-        result->max = max;
-        double *buf = (double *)calloc(input.len, sizeof(double));
-        memcpy(buf, input.buf, input.len * sizeof(double));
-        result->input.len = input.len;
-        result->input.cap = input.len;
-        result->input.buf = buf;
-
-        *out = result;
-        return 0;
-    }
-
-    struct item {
-        double a;
-        double b;
-    };
-
-    struct item_seq {
-        uint32_t  cap;
-        uint32_t  len;
-        struct item **buf;
-    };
-
-    struct tst_serv {
-        void *handle;
-        int (*add)(void *, double, double, double *);
-        int (*sub)(void *, double, double, double *);
-        int (*sqrt)(void *, double, double *);
-        int (*stats)(void *, struct tst_seq, struct tst_StatsResult **);
-    };
-
-    struct tst_serv_example4 {
-        void *handle;
-        int (*getName_example4)(void *, char** name);
-    };
-
-    void callTestPreAllocated(void) {
-        dyn_interface_type *intf = NULL;
-        FILE *desc = fopen("descriptors/example1.descriptor", "r");
-        CHECK(desc != NULL);
-        int rc = dynInterface_parse(desc, &intf);
-        CHECK_EQUAL(0, rc);
-        fclose(desc);
-
-        char *result = NULL;
-
-        struct tst_serv serv;
-        serv.handle = NULL;
-        serv.add = add;
-
-
-        rc = jsonRpc_call(intf, &serv, "{\"m\":\"add(DD)D\", \"a\": [1.0,2.0]}", &result);
-        CHECK_EQUAL(0, rc);
-        STRCMP_CONTAINS("3.0", result);
-
-        free(result);
-        dynInterface_destroy(intf);
-    }
-
-    void callTestOutput(void) {
-        dyn_interface_type *intf = NULL;
-        FILE *desc = fopen("descriptors/example1.descriptor", "r");
-        CHECK(desc != NULL);
-        int rc = dynInterface_parse(desc, &intf);
-        CHECK_EQUAL(0, rc);
-        fclose(desc);
-
-        char *result = NULL;
-
-        struct tst_serv serv;
-        serv.handle = NULL;
-        serv.stats = stats;
-
-        rc = jsonRpc_call(intf, &serv, "{\"m\":\"stats([D)LStatsResult;\", \"a\": [[1.0,2.0]]}", &result);
-        CHECK_EQUAL(0, rc);
-        STRCMP_CONTAINS("1.5", result); //avg
-
-        free(result);
-        dynInterface_destroy(intf);
-    }
-
-    void handleTestOut(void) {
-        dyn_interface_type *intf = NULL;
-        FILE *desc = fopen("descriptors/example1.descriptor", "r");
-        CHECK(desc != NULL);
-        int rc = dynInterface_parse(desc, &intf);
-        CHECK_EQUAL(0, rc);
-        fclose(desc);
-
-        struct methods_head *head;
-        dynInterface_methods(intf, &head);
-        dyn_function_type *func = NULL;
-        struct method_entry *entry = NULL;
-        TAILQ_FOREACH(entry, head, entries) {
-            if (strcmp(entry->name, "stats") == 0) {
-                func = entry->dynFunc;
-                break;
-            }
-        }
-        CHECK(func != NULL);
-
-        const char *reply = "{\"r\":{\"input\":[1.0,2.0],\"max\":2.0,\"average\":1.5,\"min\":1.0}}";
-
-        void *args[3];
-        args[0] = NULL;
-        args[1] = NULL;
-        args[2] = NULL;
-
-        struct tst_StatsResult *result = NULL;
-        void *out = &result;
-        args[2] = &out;
-
-        rc = jsonRpc_handleReply(func, reply, args);
-        CHECK_EQUAL(0, rc);
-        CHECK_EQUAL(1.5, result->average);
-
-        free(result->input.buf);
-        free(result);
-        dynInterface_destroy(intf);
-    }
-
-    static void handleTestOutputSequence(void) {
-        dyn_interface_type *intf = NULL;
-        FILE *desc = fopen("descriptors/example2.descriptor", "r");
-        CHECK(desc != NULL);
-        int rc = dynInterface_parse(desc, &intf);
-        CHECK_EQUAL(0, rc);
-        fclose(desc);
-
-        struct methods_head *head;
-        dynInterface_methods(intf, &head);
-        dyn_function_type *func = NULL;
-        struct method_entry *entry = NULL;
-        TAILQ_FOREACH(entry, head, entries) {
-            if (strcmp(entry->name, "example1") == 0) {
-                func = entry->dynFunc;
-                break;
-            }
-        }
-        CHECK(func != NULL);
-
-        //dyn_type *arg = dynFunction_argumentTypeForIndex(func, 1);
-        //dynType_print(arg, stdout);
-
-        const char *reply = "{\"r\":[{\"a\":1.0,\"b\":1.5},{\"a\":2.0,\"b\":2.5}]}";
-
-        void *args[2];
-        args[0] = NULL;
-        args[1] = NULL;
-
-        struct item_seq *result = NULL;
-        void *out = &result;
-        args[1] = &out;
-
-        rc = jsonRpc_handleReply(func, reply, args);
-        CHECK_EQUAL(0, rc);
-        CHECK_EQUAL(2, result->len);
-        CHECK_EQUAL(1.0, result->buf[0]->a);
-        CHECK_EQUAL(1.5, result->buf[0]->b);
-        CHECK_EQUAL(2.0, result->buf[1]->a);
-        CHECK_EQUAL(2.5, result->buf[1]->b);
-
-
-        unsigned int i;
-        for (i = 0; i < result->len; i +=1 ) {
-            free(result->buf[i]);
-        }
-        free(result->buf);
-        free(result);
-        dynInterface_destroy(intf);
-    }
-
-
-
-
-    void callTestOutChar(void) {
-        dyn_interface_type *intf = NULL;
-        FILE *desc = fopen("descriptors/example4.descriptor", "r");
-        CHECK(desc != NULL);
-        int rc = dynInterface_parse(desc, &intf);
-        CHECK_EQUAL(0, rc);
-        fclose(desc);
-
-        char *result = NULL;
-
-        struct tst_serv_example4 serv;
-        serv.handle = NULL;
-        serv.getName_example4 = getName_example4;
-
-        rc = jsonRpc_call(intf, &serv, "{\"m\":\"getName(V)t\", \"a\": []}", &result);
-        CHECK_EQUAL(0, rc);
-
-        STRCMP_CONTAINS("allocatedInFunction", result);
-
-        free(result);
-        dynInterface_destroy(intf);
-    }
-
-
-    void handleTestOutChar(void) {
-        dyn_interface_type *intf = NULL;
-        FILE *desc = fopen("descriptors/example4.descriptor", "r");
-        CHECK(desc != NULL);
-        int rc = dynInterface_parse(desc, &intf);
-        CHECK_EQUAL(0, rc);
-        fclose(desc);
-
-        struct methods_head *head;
-        dynInterface_methods(intf, &head);
-        dyn_function_type *func = NULL;
-        struct method_entry *entry = NULL;
-        TAILQ_FOREACH(entry, head, entries) {
-            if (strcmp(entry->name, "getName") == 0) {
-                func = entry->dynFunc;
-                break;
-            }
-        }
-
-        CHECK(func != NULL);
-
-        const char *reply = "{\"r\": \"this is a test string\" }";
-        char *result = NULL;
-        void *out = &result;
-
-        void *args[2];
-        args[0] = NULL;
-        args[1] = &out;
-
-        if(func!=NULL){ // Check needed just to satisfy Coverity
-		rc = jsonRpc_handleReply(func, reply, args);
-        }
-
-        STRCMP_EQUAL("this is a test string", result);
-
-        free(result);
-        dynInterface_destroy(intf);
-    }
-
-
-}
-
-TEST_GROUP(JsonRpcTests) {
-    void setup() {
-        int lvl = 1;
-        dynCommon_logSetup(stdLog, NULL, lvl);
-        dynType_logSetup(stdLog, NULL,lvl);
-        dynFunction_logSetup(stdLog, NULL,lvl);
-        dynInterface_logSetup(stdLog, NULL,lvl);
-        jsonSerializer_logSetup(stdLog, NULL, lvl);
-        jsonRpc_logSetup(stdLog, NULL, lvl);
-
-    }
-};
-
-
-TEST(JsonRpcTests, prepareTest) {
-    prepareTest();
-}
-
-TEST(JsonRpcTests, handleTestPre) {
-    handleTestPre();
-}
-
-TEST(JsonRpcTests, handleTestOut) {
-    handleTestOut();
-}
-
-TEST(JsonRpcTests, callPre) {
-    callTestPreAllocated();
-}
-
-TEST(JsonRpcTests, callOut) {
-    callTestOutput();
-}
-
-TEST(JsonRpcTests, handleOutSeq) {
-    handleTestOutputSequence();
-}
-
-
-
-TEST(JsonRpcTests, callTestOutChar) {
-    callTestOutChar();
-}
-
-TEST(JsonRpcTests, handleOutChar) {
-    handleTestOutChar();
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/json_serializer_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/json_serializer_tests.cpp b/dfi/private/test/json_serializer_tests.cpp
deleted file mode 100644
index a52e4cc..0000000
--- a/dfi/private/test/json_serializer_tests.cpp
+++ /dev/null
@@ -1,558 +0,0 @@
-/**
- *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.
- */
-#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*, 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");
-	va_end(ap);
-}
-
-/*********** 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);
-	LONGS_EQUAL(22, ex->b);
-	LONGS_EQUAL(32, ex->c);
-	LONGS_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);
-	LONGS_EQUAL(232, ex->long1);
-	LONGS_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 5 ************************/
-/** 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 const char *example6_descriptor = "Tsample={DD v1 v2};[lsample;";
-
-static const char *example6_input = "[{\"v1\":0.1,\"v2\":0.2},{\"v1\":1.1,\"v2\":1.2},{\"v1\":2.1,\"v2\":2.2}]";
-
-struct ex6_sample {
-	double v1;
-	double v2;
-};
-
-struct ex6_sequence {
-	uint32_t cap;
-	uint32_t len;
-	struct ex6_sample *buf;
-};
-
-static void check_example6(struct ex6_sequence seq) {
-	CHECK_EQUAL(3, seq.cap);
-	CHECK_EQUAL(3, seq.len);
-	CHECK_EQUAL(0.1, seq.buf[0].v1);
-	CHECK_EQUAL(0.2, seq.buf[0].v2);
-	CHECK_EQUAL(1.1, seq.buf[1].v1);
-	CHECK_EQUAL(1.2, seq.buf[1].v2);
-	CHECK_EQUAL(2.1, seq.buf[2].v1);
-	CHECK_EQUAL(2.2, seq.buf[2].v2);
-}
-
-
-/*********** example 7 ************************/
-const char *example7_descriptor = "{t a}";
-
-const char *example7_input = "{ \
-    \"a\" : \"apache celix\" \
-}";
-
-struct example7 {
-	char* a;   //0
-};
-
-static void check_example7(void *data) {
-	struct example7 *ex = (struct example7 *)data;
-	STRCMP_EQUAL("apache celix", ex->a);
-}
-
-
-/*********** example 8 ************************/
-
-const char *example8_descriptor = "{ZbijNP a b c d e f}";
-
-const char *example8_input = "{ \
-    \"a\" : true, \
-    \"b\" : 4, \
-    \"c\" : 8, \
-    \"d\" : 16, \
-    \"e\" : 32 \
-}";
-
-struct example8 {
-	bool a;
-	unsigned char b;
-	uint32_t c;
-	uint64_t d;
-	int e;
-	void* f;
-};
-
-static void check_example8(void *data) {
-	struct example8 *ex = (struct example8 *)data;
-	CHECK_EQUAL(true,ex->a);
-	CHECK_EQUAL(4,ex->b);
-	CHECK_EQUAL(8,ex->c);
-	//error on mac CHECK_EQUAL(16,ex->d);
-    CHECK(16 == ex->d)
-	CHECK_EQUAL(32,ex->e);
-}
-
-
-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);
-
-	type = NULL;
-	struct ex6_sequence *seq;
-	rc = dynType_parseWithStr(example6_descriptor, NULL, NULL, &type);
-	CHECK_EQUAL(0, rc);
-	rc = jsonSerializer_deserialize(type, example6_input, (void **)&seq);
-	CHECK_EQUAL(0, rc);
-	check_example6((*seq));
-	dynType_free(type, seq);
-	dynType_destroy(type);
-
-
-	type = NULL;
-	inst = NULL;
-	rc = dynType_parseWithStr(example7_descriptor, NULL, NULL, &type);
-	CHECK_EQUAL(0, rc);
-	rc = jsonSerializer_deserialize(type, example7_input, &inst);
-	CHECK_EQUAL(0, rc);
-	check_example7(inst);
-	dynType_free(type, inst);
-	dynType_destroy(type);
-
-	type = NULL;
-	inst = NULL;
-	rc = dynType_parseWithStr(example8_descriptor, NULL, NULL, &type);
-	CHECK_EQUAL(0, rc);
-	rc = jsonSerializer_deserialize(type, example8_input, &inst);
-	CHECK_EQUAL(0, rc);
-	check_example8(inst);
-	dynType_free(type, inst);
-	dynType_destroy(type);
-}
-
-const char *write_example1_descriptor = "{BSIJsijFDNZb a b c d e f g h i j k l}";
-
-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;
-	bool k;
-	unsigned char l;
-};
-
-void writeTest1(void) {
-	struct write_example1 ex1;
-	ex1.a=1;
-	ex1.b=2;
-	ex1.c=3;
-	ex1.d=4;
-	ex1.e=5;
-	ex1.f=6;
-	ex1.g=7;
-	ex1.h=8.8f;
-	ex1.i=9.9;
-	ex1.j=10;
-	ex1.k=true;
-	ex1.l=12;
-
-	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);
-	STRCMP_CONTAINS("\"k\":true", result);
-	STRCMP_CONTAINS("\"l\":12", 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;
-	sub1.a = 1;
-	sub1.b = 2;
-
-	struct write_example2 ex;
-	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;
-	p1.name = "John";
-	p1.age = 33;
-
-	struct write_example3_person p2;
-	p2.name = "Peter";
-	p2.age = 44;
-
-	struct write_example3_person p3;
-	p3.name = "Carol";
-	p3.age = 55;
-
-	struct write_example3_person p4;
-	p4.name = "Elton";
-	p4.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/a1c30887/dfi/private/test/run_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/run_tests.cpp b/dfi/private/test/run_tests.cpp
deleted file mode 100644
index 786f4bf..0000000
--- a/dfi/private/test/run_tests.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- *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.
- */
-#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/a1c30887/dfi/private/test/schemas/complex.avdl
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/complex.avdl b/dfi/private/test/schemas/complex.avdl
deleted file mode 100644
index eff1fd8..0000000
--- a/dfi/private/test/schemas/complex.avdl
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- *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.
- */
-
-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/a1c30887/dfi/private/test/schemas/complex.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/complex.avpr b/dfi/private/test/schemas/complex.avpr
deleted file mode 100644
index ca39b56..0000000
--- a/dfi/private/test/schemas/complex.avpr
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- *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.
- */
-
-{
-  "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/a1c30887/dfi/private/test/schemas/invalid1.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/invalid1.avpr b/dfi/private/test/schemas/invalid1.avpr
deleted file mode 100644
index bbf77ee..0000000
--- a/dfi/private/test/schemas/invalid1.avpr
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- *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.
- */
-{
-  "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/a1c30887/dfi/private/test/schemas/invalid2.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/invalid2.avpr b/dfi/private/test/schemas/invalid2.avpr
deleted file mode 100644
index 9eb9209..0000000
--- a/dfi/private/test/schemas/invalid2.avpr
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *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.
- */
- {
-  "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/a1c30887/dfi/private/test/schemas/simple.avdl
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/simple.avdl b/dfi/private/test/schemas/simple.avdl
deleted file mode 100644
index a03e352..0000000
--- a/dfi/private/test/schemas/simple.avdl
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- *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.
- */
- @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/a1c30887/dfi/private/test/schemas/simple.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/simple.avpr b/dfi/private/test/schemas/simple.avpr
deleted file mode 100644
index 4910346..0000000
--- a/dfi/private/test/schemas/simple.avpr
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *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.
- */
- {
-  "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/a1c30887/dfi/private/test/schemas/simple_min.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/simple_min.avpr b/dfi/private/test/schemas/simple_min.avpr
deleted file mode 100644
index f5c6673..0000000
--- a/dfi/private/test/schemas/simple_min.avpr
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- *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.
- */
- {"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/a1c30887/dfi/public/include/dfi_log_util.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dfi_log_util.h b/dfi/public/include/dfi_log_util.h
deleted file mode 100644
index 2bcd8fa..0000000
--- a/dfi/public/include/dfi_log_util.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- *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.
- */
-#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

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/public/include/dyn_common.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_common.h b/dfi/public/include/dyn_common.h
deleted file mode 100644
index 6ec236f..0000000
--- a/dfi/public/include/dyn_common.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- *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.
- */
-#ifndef _DYN_COMMON_H_
-#define _DYN_COMMON_H_
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/queue.h>
-
-#include "dfi_log_util.h"
-
-//logging
-DFI_SETUP_LOG_HEADER(dynCommon);
-
-TAILQ_HEAD(namvals_head, namval_entry);
-
-struct namval_entry {
-    char *name;
-    char *value;
-    TAILQ_ENTRY(namval_entry) entries;
-};
-
-int dynCommon_parseName(FILE *stream, char **result);
-int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result);
-int dynCommon_parseNameValue(FILE *stream, char **name, char **value);
-int dynCommon_eatChar(FILE *stream, int c);
-
-void dynCommon_clearNamValHead(struct namvals_head *head);
-
-#endif 

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/public/include/dyn_function.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_function.h b/dfi/public/include/dyn_function.h
deleted file mode 100644
index 7f5cd57..0000000
--- a/dfi/public/include/dyn_function.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- *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.
- */
-#ifndef __DYN_FUNCTION_H_
-#define __DYN_FUNCTION_H_
-
-#include "dyn_type.h"
-#include "dfi_log_util.h"
-
-/**
- * Uses the following schema
- * (Name)([Type]*)Type
- *
- * Dyn fynction argument meta (am) as meta info, with the following possible values
- * am=handle #void pointer for the handle
- * am=pre #output pointer with memory preallocated
- * am=out #output pointer
- */
-
-typedef struct _dyn_function_type dyn_function_type;
-
-DFI_SETUP_LOG_HEADER(dynFunction);
-
-enum dyn_function_argument_meta {
-    DYN_FUNCTION_ARGUMENT_META__STD = 0,
-    DYN_FUNCTION_ARGUMENT_META__HANDLE = 1,
-    DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT = 2,
-    DYN_FUNCTION_ARGUMENT_META__OUTPUT = 3
-};
-
-int dynFunction_parse(FILE *descriptorStream, struct types_head *refTypes, dyn_function_type **dynFunc);
-int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **dynFunc);
-
-int dynFunction_nrOfArguments(dyn_function_type *dynFunc);
-dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr);
-enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr);
-dyn_type * dynFunction_returnType(dyn_function_type *dynFunction);
-
-void dynFunction_destroy(dyn_function_type *dynFunc);
-int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues);
-
-int dynFunction_createClosure(dyn_function_type *func, void (*bind)(void *, void **, void*), void *userData, void(**fn)(void));
-int dynFunction_getFnPointer(dyn_function_type *func, void (**fn)(void));
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/public/include/dyn_interface.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_interface.h b/dfi/public/include/dyn_interface.h
deleted file mode 100644
index 54bf41c..0000000
--- a/dfi/public/include/dyn_interface.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- *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.
- */
-#ifndef __DYN_INTERFACE_H_
-#define __DYN_INTERFACE_H_
-
-#include "dyn_common.h"
-#include "dyn_type.h"
-#include "dyn_function.h"
-#include "dfi_log_util.h"
-
-#include "version.h"
-
-DFI_SETUP_LOG_HEADER(dynInterface);
-
-/* Description string
- *
- * Descriptor (interface) = HeaderSection AnnotationSection TypesSection MethodsSection
- *
- * HeaderSection=
- * ':header\n' [NameValue]*
- * ':annotations\n' [NameValue]*
- * ':types\n' [TypeIdValue]*
- * ':methods\n' [MethodIdValue]
- *
- */
-typedef struct _dyn_interface_type dyn_interface_type;
-
-TAILQ_HEAD(methods_head, method_entry);
-struct method_entry {
-    int index;
-    char *id;
-    char *name;
-    dyn_function_type *dynFunc;
-
-    TAILQ_ENTRY(method_entry) entries; 
-};
-
-int dynInterface_parse(FILE *descriptor, dyn_interface_type **out);
-void dynInterface_destroy(dyn_interface_type *intf);
-
-int dynInterface_getName(dyn_interface_type *intf, char **name);
-int dynInterface_getVersion(dyn_interface_type *intf, version_pt* version);
-int dynInterface_getVersionString(dyn_interface_type *intf, char **version);
-int dynInterface_getHeaderEntry(dyn_interface_type *intf, const char *name, char **value);
-int dynInterface_getAnnotationEntry(dyn_interface_type *intf, const char *name, char **value);
-int dynInterface_methods(dyn_interface_type *intf, struct methods_head **list);
-int dynInterface_nrOfMethods(dyn_interface_type *intf);
-
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/public/include/dyn_message.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_message.h b/dfi/public/include/dyn_message.h
deleted file mode 100644
index d1c8dd7..0000000
--- a/dfi/public/include/dyn_message.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- *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.
- */
-#ifndef __DYN_MESSAGE_H_
-#define __DYN_MESSAGE_H_
-
-#include "dyn_common.h"
-#include "dyn_type.h"
-#include "dfi_log_util.h"
-
-#include "version.h"
-
-DFI_SETUP_LOG_HEADER(dynMessage);
-
-/* Description string
- *
- * Descriptor (message) = HeaderSection AnnotationSection TypesSection MessageSection
- *
- * HeaderSection=
- * ':header\n' [NameValue]*
- * ':annotations\n' [NameValue]*
- * ':types\n' [TypeIdValue]*
- * ':message\n' [MessageIdValue]
- *
- */
-typedef struct _dyn_message_type dyn_message_type;
-
-
-int dynMessage_parse(FILE *descriptor, dyn_message_type **out);
-void dynMessage_destroy(dyn_message_type *msg);
-
-int dynMessage_getName(dyn_message_type *msg, char **name);
-int dynMessage_getVersion(dyn_message_type *msg, version_pt* version);
-int dynMessage_getVersionString(dyn_message_type *msg, char **version);
-int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value);
-int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value);
-int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type);
-
-
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/public/include/dyn_type.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_type.h b/dfi/public/include/dyn_type.h
deleted file mode 100644
index 554966a..0000000
--- a/dfi/public/include/dyn_type.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- *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.
- */
-
-#ifndef _DYN_TYPE_H_
-#define _DYN_TYPE_H_
-
-#include <stdio.h>
-#include <sys/queue.h>
-#include <stdbool.h>
-
-#include <stdint.h>
-
-#include "dfi_log_util.h"
-
-#if defined(BSD) || defined(__APPLE__) || defined(__ANDROID__)
-#include "memstream/open_memstream.h"
-#include "memstream/fmemopen.h"
-#endif
-
-/* Description string
- *
- * Type = [TypeDef]* (MetaInfo)* (SimpleType | ComplexType | SequenceType | TypedPointer | PointerReference ) [TypeDef]*
- * Name = alpha[(alpha|numeric)*]
- * SPACE = ' ' 
- *
- * SimplesTypes (based on java bytecode method signatures)
- * //Java based:
- * B char
- * C (not supported)
- * D double
- * F float
- * I int32_t 
- * J int64_t 
- * S int16_t 
- * V void
- * Z boolean
- * //Extended
- * b unsigned char
- * i uint32_t
- * j uint62_t
- * s uint64_t
- * P untyped pointer (void *)
- * t char* string
- * N native int
- *
- * ComplexTypes (Struct)
- * {[Type]+ [(Name)(SPACE)]+}
- *
- * ReferenceByValue
- * l(name);
- *
- * PointerReference -> note shortcut for *l(name);
- * L(Name);
- *
- * TypeDef 
- * T(Name)=Type;
- *
- * SequenceType
- * [(Type)
- *
- * TypedPointer
- * *(Type)
- *
- * MetaInfo TODO
- * #Name=Value;
- *
- *
- *
- * examples
- * "{DDII a b c d}" -> struct { double a; double b; int c; int d; }; 
- * "{DD{FF c1 c2} a b c}" -> struct { double a; double b; struct c { float c1; float c2; }; }; 
- *
- *
- */
-
-#define DYN_TYPE_INVALID 0
-#define DYN_TYPE_SIMPLE 1
-#define DYN_TYPE_COMPLEX 2
-#define DYN_TYPE_SEQUENCE 3
-#define DYN_TYPE_TYPED_POINTER 4
-#define DYN_TYPE_TEXT 5
-#define DYN_TYPE_REF 6
-
-typedef struct _dyn_type dyn_type;
-
-TAILQ_HEAD(types_head, type_entry);
-struct type_entry {
-    dyn_type *type;
-    TAILQ_ENTRY(type_entry) entries;
-};
-
-TAILQ_HEAD(complex_type_entries_head, complex_type_entry);
-struct complex_type_entry {
-    dyn_type *type;
-    char *name;
-    TAILQ_ENTRY(complex_type_entry) entries;
-};
-
-//logging
-DFI_SETUP_LOG_HEADER(dynType);
-
-//generic
-int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *refTypes, dyn_type **type);
-int dynType_parseWithStr(const char *descriptor, const char *name, struct types_head *refTypes, dyn_type **type);
-void dynType_destroy(dyn_type *type);
-
-int dynType_alloc(dyn_type *type, void **bufLoc);
-void dynType_free(dyn_type *type, void *loc);
-
-void dynType_print(dyn_type *type, FILE *stream);
-size_t dynType_size(dyn_type *type);
-int dynType_type(dyn_type *type);
-int dynType_descriptorType(dyn_type *type);
-const char * dynType_getMetaInfo(dyn_type *type, const char *name);
-
-//complexType
-int dynType_complex_indexForName(dyn_type *type, const char *name);
-int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **subType);
-int dynType_complex_setValueAt(dyn_type *type, int index, void *inst, void *in);
-int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **valLoc);
-int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries);
-
-//sequence
-int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap);
-int dynType_sequence_locForIndex(dyn_type *type, void *seqLoc, int index, void **valLoc);
-int dynType_sequence_increaseLengthAndReturnLastLoc(dyn_type *type, void *seqLoc, void **valLoc);
-dyn_type * dynType_sequence_itemType(dyn_type *type);
-uint32_t dynType_sequence_length(void *seqLoc);
-
-//typed pointer
-int dynType_typedPointer_getTypedType(dyn_type *type, dyn_type **typedType);
-
-//text
-int dynType_text_allocAndInit(dyn_type *type, void *textLoc, const char *value);
-
-//simple
-void dynType_simple_setValue(dyn_type *type, void *inst, void *in);
-
-#endif


[14/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/resolver.c
----------------------------------------------------------------------
diff --git a/framework/src/resolver.c b/framework/src/resolver.c
new file mode 100644
index 0000000..256eff5
--- /dev/null
+++ b/framework/src/resolver.c
@@ -0,0 +1,495 @@
+/**
+ *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.
+ */
+/*
+ * resolver.c
+ *
+ *  \date       Jul 13, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "resolver.h"
+#include "linked_list_iterator.h"
+#include "bundle.h"
+#include "celix_log.h"
+
+struct capabilityList {
+    char * serviceName;
+    linked_list_pt capabilities;
+};
+
+typedef struct capabilityList * capability_list_pt;
+
+struct candidateSet {
+    module_pt module;
+    requirement_pt requirement;
+    linked_list_pt candidates;
+};
+
+typedef struct candidateSet * candidate_set_pt;
+
+// List containing module_ts
+linked_list_pt m_modules = NULL;
+// List containing capability_t_LISTs
+linked_list_pt m_unresolvedServices = NULL;
+// List containing capability_t_LISTs
+linked_list_pt m_resolvedServices = NULL;
+
+int resolver_populateCandidatesMap(hash_map_pt candidatesMap, module_pt targetModule);
+capability_list_pt resolver_getCapabilityList(linked_list_pt list, const char* name);
+void resolver_removeInvalidCandidate(module_pt module, hash_map_pt candidates, linked_list_pt invalid);
+linked_list_pt resolver_populateWireMap(hash_map_pt candidates, module_pt importer, linked_list_pt wireMap);
+
+linked_list_pt resolver_resolve(module_pt root) {
+    hash_map_pt candidatesMap = NULL;
+    linked_list_pt wireMap = NULL;
+    linked_list_pt resolved = NULL;
+    hash_map_iterator_pt iter = NULL;
+
+    if (module_isResolved(root)) {
+        return NULL;
+    }
+
+    candidatesMap = hashMap_create(NULL, NULL, NULL, NULL);
+
+    if (resolver_populateCandidatesMap(candidatesMap, root) != 0) {
+        hash_map_iterator_pt iter = hashMapIterator_create(candidatesMap);
+        while (hashMapIterator_hasNext(iter)) {
+            hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+            linked_list_pt value = hashMapEntry_getValue(entry);
+            hashMapIterator_remove(iter);
+            if (value != NULL) {
+                linked_list_iterator_pt candSetIter = linkedListIterator_create(value, 0);
+                while (linkedListIterator_hasNext(candSetIter)) {
+                    candidate_set_pt set = linkedListIterator_next(candSetIter);
+                    linkedList_destroy(set->candidates);
+                    free(set);
+                    linkedListIterator_remove(candSetIter);
+                }
+                linkedListIterator_destroy(candSetIter);
+                linkedList_destroy(value);
+            }
+        }
+        hashMapIterator_destroy(iter);
+        hashMap_destroy(candidatesMap, false, false);
+        return NULL;
+    }
+
+    linkedList_create(&wireMap);
+    resolved = resolver_populateWireMap(candidatesMap, root, wireMap);
+    iter = hashMapIterator_create(candidatesMap);
+    while (hashMapIterator_hasNext(iter)) {
+        hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+        linked_list_pt value = hashMapEntry_getValue(entry);
+        hashMapIterator_remove(iter);
+        if (value != NULL) {
+            linked_list_iterator_pt candSetIter = linkedListIterator_create(value, 0);
+            while (linkedListIterator_hasNext(candSetIter)) {
+                candidate_set_pt set = linkedListIterator_next(candSetIter);
+                linkedList_destroy(set->candidates);
+                free(set);
+                linkedListIterator_remove(candSetIter);
+            }
+            linkedListIterator_destroy(candSetIter);
+            linkedList_destroy(value);
+        }
+    }
+    hashMapIterator_destroy(iter);
+    hashMap_destroy(candidatesMap, false, false);
+    return resolved;
+}
+
+int resolver_populateCandidatesMap(hash_map_pt candidatesMap, module_pt targetModule) {
+    linked_list_pt candSetList;
+    linked_list_pt candidates;
+    linked_list_pt invalid;
+
+    if (hashMap_containsKey(candidatesMap, targetModule)) {
+        return 0;
+    }
+
+    hashMap_put(candidatesMap, targetModule, NULL);
+
+    if (linkedList_create(&candSetList) == CELIX_SUCCESS) {
+        int i;
+        for (i = 0; i < linkedList_size(module_getRequirements(targetModule)); i++) {
+            capability_list_pt capList;
+            requirement_pt req;
+            const char *targetName = NULL;
+            req = (requirement_pt) linkedList_get(module_getRequirements(targetModule), i);
+            requirement_getTargetName(req, &targetName);
+            capList = resolver_getCapabilityList(m_resolvedServices, targetName);
+
+            if (linkedList_create(&candidates) == CELIX_SUCCESS) {
+                int c;
+                for (c = 0; (capList != NULL) && (c < linkedList_size(capList->capabilities)); c++) {
+                    capability_pt cap = (capability_pt) linkedList_get(capList->capabilities, c);
+                    bool satisfied = false;
+                    requirement_isSatisfied(req, cap, &satisfied);
+                    if (satisfied) {
+                        linkedList_addElement(candidates, cap);
+                    }
+                }
+                capList = resolver_getCapabilityList(m_unresolvedServices, targetName);
+                for (c = 0; (capList != NULL) && (c < linkedList_size(capList->capabilities)); c++) {
+                    capability_pt cap = (capability_pt) linkedList_get(capList->capabilities, c);
+                    bool satisfied = false;
+                    requirement_isSatisfied(req, cap, &satisfied);
+                    if (satisfied) {
+                        linkedList_addElement(candidates, cap);
+                    }
+                }
+
+                if (linkedList_size(candidates) > 0) {
+                    linked_list_iterator_pt iterator = NULL;
+                    for (iterator = linkedListIterator_create(candidates, 0); linkedListIterator_hasNext(iterator);) {
+                        capability_pt candidate = (capability_pt) linkedListIterator_next(iterator);
+                        module_pt module = NULL;
+                        capability_getModule(candidate, &module);
+                        if (!module_isResolved(module)) {
+                            if (resolver_populateCandidatesMap(candidatesMap, module) != 0) {
+                                linkedListIterator_remove(iterator);
+                            }
+                        }
+                    }
+                    linkedListIterator_destroy(iterator);
+                }
+
+                if (linkedList_size(candidates) == 0) {
+                    if (linkedList_create(&invalid) == CELIX_SUCCESS) {
+                        const char *name = NULL;
+                        resolver_removeInvalidCandidate(targetModule, candidatesMap, invalid);
+
+                        module_getSymbolicName(targetModule, &name);
+
+                        linkedList_destroy(invalid);
+                        fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Unable to resolve: %s, %s\n", name, targetName);
+                    }
+                    linkedList_destroy(candidates);
+                    linkedList_destroy(candSetList);
+                    return -1;
+                } else if (linkedList_size(candidates) > 0) {
+                    candidate_set_pt cs = (candidate_set_pt) malloc(sizeof(*cs));
+                    cs->candidates = candidates;
+                    cs->module = targetModule;
+                    cs->requirement = req;
+                    linkedList_addElement(candSetList, cs);
+                }
+
+            }
+        }
+        hashMap_put(candidatesMap, targetModule, candSetList);
+    }
+    return 0;
+}
+
+void resolver_removeInvalidCandidate(module_pt invalidModule, hash_map_pt candidates, linked_list_pt invalid) {
+    hash_map_iterator_pt iterator;
+    hashMap_remove(candidates, invalidModule);
+
+    for (iterator = hashMapIterator_create(candidates); hashMapIterator_hasNext(iterator);) {
+        hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
+        linked_list_pt candSetList = (linked_list_pt) hashMapEntry_getValue(entry);
+        if (candSetList != NULL) {
+            linked_list_iterator_pt itCandSetList;
+            for (itCandSetList = linkedListIterator_create(candSetList, 0); linkedListIterator_hasNext(itCandSetList);) {
+                candidate_set_pt set = (candidate_set_pt) linkedListIterator_next(itCandSetList);
+                linked_list_iterator_pt candIter;
+                for (candIter = linkedListIterator_create(set->candidates, 0); linkedListIterator_hasNext(candIter);) {
+                    capability_pt candCap = (capability_pt) linkedListIterator_next(candIter);
+                    module_pt module = NULL;
+                    capability_getModule(candCap, &module);
+                    if (module == invalidModule) {
+                        linkedListIterator_remove(candIter);
+                        if (linkedList_size(set->candidates) == 0) {
+                            linkedListIterator_remove(itCandSetList);
+                            if (module != invalidModule && linkedList_contains(invalid, module)) {
+                                linkedList_addElement(invalid, module);
+                            }
+                        }
+                        break;
+                    }
+                }
+                linkedListIterator_destroy(candIter);
+            }
+            linkedListIterator_destroy(itCandSetList);
+        }
+    }
+    hashMapIterator_destroy(iterator);
+
+    if (linkedList_size(invalid) > 0) {
+        while (!linkedList_isEmpty(invalid)) {
+            module_pt m = (module_pt) linkedList_removeIndex(invalid, 0);
+            resolver_removeInvalidCandidate(m, candidates, invalid);
+        }
+    }
+}
+
+void resolver_addModule(module_pt module) {
+
+    if (m_modules == NULL) {
+        linkedList_create(&m_modules);
+        linkedList_create(&m_unresolvedServices);
+        linkedList_create(&m_resolvedServices);
+    }
+
+    if (m_modules != NULL && m_unresolvedServices != NULL) {
+        int i;
+
+        linkedList_addElement(m_modules, module);
+
+        for (i = 0; i < linkedList_size(module_getCapabilities(module)); i++) {
+            const char *serviceName = NULL;
+            capability_list_pt list = NULL;
+            capability_pt cap;
+
+            cap = (capability_pt) linkedList_get(module_getCapabilities(module), i);
+            capability_getServiceName(cap, &serviceName);
+            list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
+            if (list == NULL) {
+                list = (capability_list_pt) malloc(sizeof(*list));
+                if (list != NULL) {
+                    list->serviceName = strdup(serviceName);
+                    if (linkedList_create(&list->capabilities) == CELIX_SUCCESS) {
+                        linkedList_addElement(m_unresolvedServices, list);
+                    }
+                    else{
+                    	free(list->serviceName);
+                    	free(list);
+			list=NULL;
+                    }
+                }
+            }
+            if(list != NULL){
+		linkedList_addElement(list->capabilities, cap);
+            }
+        }
+    }
+}
+
+void resolver_removeModule(module_pt module) {
+    linked_list_pt caps = NULL;
+    linkedList_removeElement(m_modules, module);
+    caps = module_getCapabilities(module);
+    if (caps != NULL) {
+        int i = 0;
+        for (i = 0; i < linkedList_size(caps); i++) {
+            capability_pt cap = (capability_pt) linkedList_get(caps, i);
+            const char *serviceName = NULL;
+            capability_list_pt list;
+            capability_getServiceName(cap, &serviceName);
+            list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
+            if (list != NULL) {
+                linkedList_removeElement(list->capabilities, cap);
+
+                if (linkedList_isEmpty(list->capabilities)) {
+                    linkedList_removeElement(m_unresolvedServices, list);
+                    linkedList_destroy(list->capabilities);
+                    free(list->serviceName);
+                    free(list);
+                }
+            }
+            list = resolver_getCapabilityList(m_resolvedServices, serviceName);
+            if (list != NULL) {
+                linkedList_removeElement(list->capabilities, cap);
+
+                if (linkedList_isEmpty(list->capabilities)) {
+                    linkedList_removeElement(m_resolvedServices, list);
+                    linkedList_destroy(list->capabilities);
+                    free(list->serviceName);
+                    free(list);
+                }
+            }
+        }
+    }
+    if (linkedList_isEmpty(m_modules)) {
+        linkedList_destroy(m_modules);
+        m_modules = NULL;
+
+        if (!linkedList_isEmpty(m_unresolvedServices)) {
+            // #TODO: Something is wrong, not all modules have been removed from the resolver
+            fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Unexpected entries in unresolved module list");
+        }
+        linkedList_destroy(m_unresolvedServices);
+        m_unresolvedServices = NULL;
+        if (!linkedList_isEmpty(m_resolvedServices)) {
+            // #TODO: Something is wrong, not all modules have been removed from the resolver
+            fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Unexpected entries in resolved module list");
+        }
+        linkedList_destroy(m_resolvedServices);
+        m_resolvedServices = NULL;
+    }
+}
+
+void resolver_moduleResolved(module_pt module) {
+
+    if (module_isResolved(module)) {
+        linked_list_pt capsCopy = NULL;
+
+        if (linkedList_create(&capsCopy) == CELIX_SUCCESS) {
+            linked_list_pt wires = NULL;
+            int capIdx;
+
+            for (capIdx = 0; (module_getCapabilities(module) != NULL) && (capIdx < linkedList_size(module_getCapabilities(module))); capIdx++) {
+                capability_pt cap = (capability_pt) linkedList_get(module_getCapabilities(module), capIdx);
+                const char *serviceName = NULL;
+                capability_list_pt list;
+                capability_getServiceName(cap, &serviceName);
+                list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
+                if(list != NULL){
+			linkedList_removeElement(list->capabilities, cap);
+                }
+
+                linkedList_addElement(capsCopy, cap);
+            }
+
+            wires = module_getWires(module);
+            for (capIdx = 0; (capsCopy != NULL) && (capIdx < linkedList_size(capsCopy)); capIdx++) {
+                capability_pt cap = linkedList_get(capsCopy, capIdx);
+
+                int wireIdx = 0;
+                for (wireIdx = 0; (wires != NULL) && (wireIdx < linkedList_size(wires)); wireIdx++) {
+                    wire_pt wire = (wire_pt) linkedList_get(wires, wireIdx);
+                    requirement_pt req = NULL;
+                    bool satisfied = false;
+                    wire_getRequirement(wire, &req);
+                    requirement_isSatisfied(req, cap, &satisfied);
+                    if (satisfied) {
+                        linkedList_set(capsCopy, capIdx, NULL);
+                        break;
+                    }
+                }
+            }
+
+            for (capIdx = 0; (capsCopy != NULL) && (capIdx < linkedList_size(capsCopy)); capIdx++) {
+                capability_pt cap = linkedList_get(capsCopy, capIdx);
+
+                if (cap != NULL) {
+                    const char *serviceName = NULL;
+                    capability_list_pt list = NULL;
+                    capability_getServiceName(cap, &serviceName);
+
+                    list = resolver_getCapabilityList(m_resolvedServices, serviceName);
+                    if (list == NULL) {
+                        list = (capability_list_pt) malloc(sizeof(*list));
+                        if (list != NULL) {
+                            list->serviceName = strdup(serviceName);
+                            if (linkedList_create(&list->capabilities) == CELIX_SUCCESS) {
+                                linkedList_addElement(m_resolvedServices, list);
+                            }
+                            else{
+                            	free(list->serviceName);
+                            	free(list);
+				list=NULL;
+                            }
+                        }
+                    }
+                    if(list != NULL){
+			linkedList_addElement(list->capabilities, cap);
+                    }
+                }
+            }
+
+            linkedList_destroy(capsCopy);
+        }
+    }
+}
+
+capability_list_pt resolver_getCapabilityList(linked_list_pt list, const char * name) {
+    capability_list_pt capabilityList = NULL;
+    linked_list_iterator_pt iterator = linkedListIterator_create(list, 0);
+    while (linkedListIterator_hasNext(iterator)) {
+        capability_list_pt services = (capability_list_pt) linkedListIterator_next(iterator);
+        if (strcmp(services->serviceName, name) == 0) {
+            capabilityList = services;
+            break;
+        }
+    }
+    linkedListIterator_destroy(iterator);
+    return capabilityList;
+}
+
+linked_list_pt resolver_populateWireMap(hash_map_pt candidates, module_pt importer, linked_list_pt wireMap) {
+    linked_list_pt serviceWires;
+
+    if (candidates && importer && wireMap) {
+        linked_list_pt candSetList = NULL;
+        bool resolved = false;
+
+        if (module_isResolved(importer)) {
+            // already resolved
+            resolved = true;
+        }
+        if (!resolved) {
+            bool self = false;
+            linked_list_iterator_pt wit = linkedListIterator_create(wireMap, 0);
+            while (linkedListIterator_hasNext(wit)) {
+                importer_wires_pt iw = linkedListIterator_next(wit);
+                if (iw->importer == importer) {
+                    // Do not resolve yourself
+                    self = true;
+                    break;
+                }
+            }
+            linkedListIterator_destroy(wit);
+
+            if (!self) {
+                candSetList = (linked_list_pt) hashMap_get(candidates, importer);
+
+                if (linkedList_create(&serviceWires) == CELIX_SUCCESS) {
+//                    if (linkedList_create(&emptyWires) == CELIX_SUCCESS) {
+                    int candSetIdx = 0;
+
+                    // hashMap_put(wireMap, importer, emptyWires);
+
+                    const char *mname = NULL;
+                    module_getSymbolicName(importer, &mname);
+
+                    importer_wires_pt importerWires = malloc(sizeof(*importerWires));
+                    importerWires->importer = importer;
+                    importerWires->wires = NULL;
+                    linkedList_addElement(wireMap, importerWires);
+
+                    for (candSetIdx = 0; candSetIdx < linkedList_size(candSetList); candSetIdx++) {
+                        candidate_set_pt cs = (candidate_set_pt) linkedList_get(candSetList, candSetIdx);
+
+                        module_pt module = NULL;
+                        capability_getModule(((capability_pt) linkedList_get(cs->candidates, 0)), &module);
+                        if (importer != module) {
+                            wire_pt wire = NULL;
+                            wire_create(importer, cs->requirement, module, ((capability_pt) linkedList_get(cs->candidates, 0)), &wire);
+                            linkedList_addElement(serviceWires, wire);
+                        }
+
+                        wireMap = resolver_populateWireMap(candidates, module, wireMap);
+                    }
+
+                    importerWires->wires = serviceWires;
+                    // hashMap_put(wireMap, importer, serviceWires);
+//                    }
+                }
+            }
+        }
+    }
+
+    return wireMap;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/resolver.h
----------------------------------------------------------------------
diff --git a/framework/src/resolver.h b/framework/src/resolver.h
new file mode 100644
index 0000000..87440e9
--- /dev/null
+++ b/framework/src/resolver.h
@@ -0,0 +1,45 @@
+/**
+ *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.
+ */
+/*
+ * resolver.h
+ *
+ *  \date       Jul 13, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef RESOLVER_H_
+#define RESOLVER_H_
+
+#include "module.h"
+#include "wire.h"
+#include "hash_map.h"
+
+struct importer_wires {
+    module_pt importer;
+    linked_list_pt wires;
+};
+typedef struct importer_wires *importer_wires_pt;
+
+linked_list_pt resolver_resolve(module_pt root);
+void resolver_moduleResolved(module_pt module);
+void resolver_addModule(module_pt module);
+void resolver_removeModule(module_pt module);
+
+#endif /* RESOLVER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_reference.c
----------------------------------------------------------------------
diff --git a/framework/src/service_reference.c b/framework/src/service_reference.c
new file mode 100644
index 0000000..545426d
--- /dev/null
+++ b/framework/src/service_reference.c
@@ -0,0 +1,378 @@
+/**
+ *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.
+ */
+/*
+ * service_reference.c
+ *
+ *  \date       Jul 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <constants.h>
+#include <stdint.h>
+#include <utils.h>
+#include <assert.h>
+
+#include "service_reference.h"
+
+#include "service_reference_private.h"
+#include "service_registration_private.h"
+
+static void serviceReference_destroy(service_reference_pt);
+static void serviceReference_logWarningUsageCountBelowZero(service_reference_pt ref);
+
+celix_status_t serviceReference_create(registry_callback_t callback, bundle_pt referenceOwner, service_registration_pt registration,  service_reference_pt *out) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	service_reference_pt ref = calloc(1, sizeof(*ref));
+	if (!ref) {
+		status = CELIX_ENOMEM;
+	} else {
+        ref->callback = callback;
+		ref->referenceOwner = referenceOwner;
+		ref->registration = registration;
+        ref->service = NULL;
+        serviceRegistration_getBundle(registration, &ref->registrationBundle);
+		celixThreadRwlock_create(&ref->lock, NULL);
+		ref->refCount = 1;
+        ref->usageCount = 0;
+
+        serviceRegistration_retain(ref->registration);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*out = ref;
+	}
+
+    framework_logIfError(logger, status, NULL, "Cannot create service reference");
+
+	return status;
+}
+
+celix_status_t serviceReference_retain(service_reference_pt ref) {
+    celixThreadRwlock_writeLock(&ref->lock);
+    ref->refCount += 1;
+    celixThreadRwlock_unlock(&ref->lock);
+    return CELIX_SUCCESS;
+}
+
+celix_status_t serviceReference_release(service_reference_pt ref, bool *out) {
+    bool destroyed = false;
+    celixThreadRwlock_writeLock(&ref->lock);
+    assert(ref->refCount > 0);
+    ref->refCount -= 1;
+    if (ref->refCount == 0) {
+        if (ref->registration != NULL) {
+            serviceRegistration_release(ref->registration);
+        }
+        celixThreadRwlock_unlock(&ref->lock);
+        serviceReference_destroy(ref);
+        destroyed = true;
+    } else {
+        celixThreadRwlock_unlock(&ref->lock);
+    }
+
+    if (out) {
+        *out = destroyed;
+    }
+    return CELIX_SUCCESS;
+}
+
+celix_status_t serviceReference_increaseUsage(service_reference_pt ref, size_t *out) {
+    //fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Destroying service reference %p\n", ref);
+    size_t local = 0;
+    celixThreadRwlock_writeLock(&ref->lock);
+    ref->usageCount += 1;
+    local = ref->usageCount;
+    celixThreadRwlock_unlock(&ref->lock);
+    if (out) {
+        *out = local;
+    }
+    return CELIX_SUCCESS;
+}
+
+celix_status_t serviceReference_decreaseUsage(service_reference_pt ref, size_t *out) {
+    celix_status_t status = CELIX_SUCCESS;
+    size_t localCount = 0;
+    celixThreadRwlock_writeLock(&ref->lock);
+    if (ref->usageCount == 0) {
+        serviceReference_logWarningUsageCountBelowZero(ref);
+        status = CELIX_BUNDLE_EXCEPTION;
+    } else {
+        ref->usageCount -= 1;
+    }
+    localCount = ref->usageCount;
+    celixThreadRwlock_unlock(&ref->lock);
+
+    if (out) {
+        *out = localCount;
+    }
+    return status;
+}
+
+static void serviceReference_logWarningUsageCountBelowZero(service_reference_pt ref __attribute__((unused))) {
+    fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot decrease service usage count below 0\n");
+}
+
+
+celix_status_t serviceReference_getUsageCount(service_reference_pt ref, size_t *count) {
+    celix_status_t status = CELIX_SUCCESS;
+    celixThreadRwlock_readLock(&ref->lock);
+    *count = ref->usageCount;
+    celixThreadRwlock_unlock(&ref->lock);
+    return status;
+}
+
+celix_status_t serviceReference_getReferenceCount(service_reference_pt ref, size_t *count) {
+    celix_status_t status = CELIX_SUCCESS;
+    celixThreadRwlock_readLock(&ref->lock);
+    *count = ref->refCount;
+    celixThreadRwlock_unlock(&ref->lock);
+    return status;
+}
+
+celix_status_t serviceReference_getService(service_reference_pt ref, void **service) {
+    celix_status_t status = CELIX_SUCCESS;
+    celixThreadRwlock_readLock(&ref->lock);
+    /*NOTE the service argument should be 'const void**'
+      To ensure backwards compatability a cast is made instead.
+    */
+    *service = (const void**) ref->service;
+    celixThreadRwlock_unlock(&ref->lock);
+    return status;
+}
+
+celix_status_t serviceReference_setService(service_reference_pt ref, const void *service) {
+    celix_status_t status = CELIX_SUCCESS;
+    celixThreadRwlock_writeLock(&ref->lock);
+    ref->service = service;
+    celixThreadRwlock_unlock(&ref->lock);
+    return status;
+}
+
+static void serviceReference_destroy(service_reference_pt ref) {
+	assert(ref->refCount == 0);
+    celixThreadRwlock_destroy(&ref->lock);
+	ref->registration = NULL;
+	free(ref);
+}
+
+celix_status_t serviceReference_getBundle(service_reference_pt ref, bundle_pt *bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+    celixThreadRwlock_readLock(&ref->lock);
+    if (ref->registration != NULL) {
+        *bundle = ref->registrationBundle;
+    }
+    celixThreadRwlock_unlock(&ref->lock);
+    return status;
+}
+
+celix_status_t serviceReference_getOwner(service_reference_pt ref, bundle_pt *owner) { 
+    celix_status_t status = CELIX_SUCCESS;
+    celixThreadRwlock_readLock(&ref->lock);
+    *owner = ref->referenceOwner;
+    celixThreadRwlock_unlock(&ref->lock);
+    return status;
+}
+
+celix_status_t serviceReference_getServiceRegistration(service_reference_pt ref, service_registration_pt *out) {
+    if (ref != NULL) {
+        celixThreadRwlock_readLock(&ref->lock);
+        *out = ref->registration;
+        celixThreadRwlock_unlock(&ref->lock);
+        return CELIX_SUCCESS;
+    } else {
+        return CELIX_ILLEGAL_ARGUMENT;
+    }
+}
+
+celix_status_t serviceReference_getProperty(service_reference_pt ref, const char* key, const char** value) {
+    celix_status_t status = CELIX_SUCCESS;
+    properties_pt props = NULL;
+    celixThreadRwlock_readLock(&ref->lock);
+    if (ref->registration != NULL) {
+        status = serviceRegistration_getProperties(ref->registration, &props);
+        if (status == CELIX_SUCCESS) {
+            *value = (char*) properties_get(props, key);
+        }
+    } else {
+        *value = NULL;
+    }
+    celixThreadRwlock_unlock(&ref->lock);
+    return status;
+}
+
+FRAMEWORK_EXPORT celix_status_t serviceReference_getPropertyKeys(service_reference_pt ref, char **keys[], unsigned int *size) {
+    celix_status_t status = CELIX_SUCCESS;
+    properties_pt props = NULL;
+
+    celixThreadRwlock_readLock(&ref->lock);
+    serviceRegistration_getProperties(ref->registration, &props);
+    hash_map_iterator_pt it;
+    int i = 0;
+    int vsize = hashMap_size(props);
+    *size = (unsigned int)vsize;
+    *keys = malloc(vsize * sizeof(**keys));
+    it = hashMapIterator_create(props);
+    while (hashMapIterator_hasNext(it)) {
+        (*keys)[i] = hashMapIterator_nextKey(it);
+        i++;
+    }
+    hashMapIterator_destroy(it);
+    celixThreadRwlock_unlock(&ref->lock);
+    return status;
+}
+
+celix_status_t serviceReference_invalidate(service_reference_pt ref) {
+    assert(ref != NULL);
+    celix_status_t status = CELIX_SUCCESS;
+    service_registration_pt reg = NULL;
+    celixThreadRwlock_writeLock(&ref->lock);
+    reg = ref->registration;
+    ref->registration = NULL;
+    celixThreadRwlock_unlock(&ref->lock);
+
+    if (reg != NULL) {
+        serviceRegistration_release(reg);
+    }
+	return status;
+}
+
+celix_status_t serviceReference_isValid(service_reference_pt ref, bool *result) {
+    celixThreadRwlock_readLock(&ref->lock);
+    (*result) = ref->registration != NULL;
+    celixThreadRwlock_unlock(&ref->lock);
+    return CELIX_SUCCESS;
+}
+
+bool serviceReference_isAssignableTo(service_reference_pt reference __attribute__((unused)), bundle_pt requester __attribute__((unused)), const char* serviceName __attribute__((unused))) {
+	bool allow = true;
+
+	/*NOTE for now always true. It would be nice to be able to do somechecks if the services are really assignable.
+	 */
+
+	return allow;
+}
+
+celix_status_t serviceReference_equals(service_reference_pt reference, service_reference_pt compareTo, bool *equal) {
+    celix_status_t status = CELIX_SUCCESS;
+    if (reference != NULL && compareTo != NULL) {
+        service_registration_pt reg1;
+        service_registration_pt reg2;
+        serviceReference_getServiceRegistration(reference, &reg1);
+        serviceReference_getServiceRegistration(compareTo, &reg2);
+        *equal = (reg1 == reg2);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+        *equal = false;
+    }
+	return status;
+}
+
+int serviceReference_equals2(const void* reference1, const void* reference2) {
+	bool equal;
+	serviceReference_equals((service_reference_pt)reference1, (service_reference_pt)reference2, &equal);
+	return equal;
+}
+
+celix_status_t serviceReference_compareTo(service_reference_pt reference, service_reference_pt compareTo, int *compare) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	long id, other_id;
+	const char* id_str;
+    const char* other_id_str;
+	serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &id_str);
+	serviceReference_getProperty(compareTo, (char *) OSGI_FRAMEWORK_SERVICE_ID, &other_id_str);
+
+	id = atol(id_str);
+	other_id = atol(other_id_str);
+
+
+	long rank, other_rank;
+	const char *rank_str;
+    const char* other_rank_str;
+	serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank_str);
+	serviceReference_getProperty(compareTo, OSGI_FRAMEWORK_SERVICE_RANKING, &other_rank_str);
+
+	rank = rank_str == NULL ? 0 : atol(rank_str);
+	other_rank = other_rank_str == NULL ? 0 : atol(other_rank_str);
+
+    *compare = utils_compareServiceIdsAndRanking(id, rank, other_id, other_rank);
+
+	return status;
+}
+
+unsigned int serviceReference_hashCode(const void *referenceP) {
+    service_reference_pt ref = (service_reference_pt)referenceP;
+    bundle_pt bundle = NULL;
+    service_registration_pt reg = NULL;
+
+    if (ref != NULL) {
+        celixThreadRwlock_readLock(&ref->lock);
+        bundle = ref->registrationBundle;
+        reg = ref->registration;
+        celixThreadRwlock_unlock(&ref->lock);
+    }
+
+
+	int prime = 31;
+	int result = 1;
+	result = prime * result;
+
+	if (bundle != NULL && reg != NULL) {
+		intptr_t bundleA = (intptr_t) bundle;
+		intptr_t registrationA = (intptr_t) reg;
+
+		result += bundleA + registrationA;
+	}
+	return result;
+}
+
+
+celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, array_list_pt *out) {
+    celix_status_t status = CELIX_SUCCESS;
+    service_registration_pt reg = NULL;
+    registry_callback_t callback;
+
+    callback.getUsingBundles = NULL;
+
+
+    celixThreadRwlock_readLock(&ref->lock);
+    reg = ref->registration;
+    if (reg != NULL) {
+        serviceRegistration_retain(reg);
+        callback.handle = ref->callback.handle;
+        callback.getUsingBundles = ref->callback.getUsingBundles;
+    }
+    celixThreadRwlock_unlock(&ref->lock);
+
+    if (reg != NULL) {
+        if (callback.getUsingBundles != NULL) {
+            status = callback.getUsingBundles(callback.handle, reg, out);
+        } else {
+            fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "getUsingBundles callback not set");
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+        serviceRegistration_release(reg);
+    }
+
+    return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_reference_private.h
----------------------------------------------------------------------
diff --git a/framework/src/service_reference_private.h b/framework/src/service_reference_private.h
new file mode 100644
index 0000000..d7fcac1
--- /dev/null
+++ b/framework/src/service_reference_private.h
@@ -0,0 +1,69 @@
+/**
+ *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.
+ */
+/*
+ * service_reference_private.h
+ *
+ *  \date       Feb 6, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef SERVICE_REFERENCE_PRIVATE_H_
+#define SERVICE_REFERENCE_PRIVATE_H_
+
+#include "registry_callback_private.h"
+#include "service_reference.h"
+
+
+struct serviceReference {
+    registry_callback_t callback;
+	bundle_pt referenceOwner;
+	struct serviceRegistration * registration;
+    bundle_pt registrationBundle;
+    const void* service;
+
+	size_t refCount;
+    size_t usageCount;
+
+    celix_thread_rwlock_t lock;
+};
+
+celix_status_t serviceReference_create(registry_callback_t callback, bundle_pt referenceOwner, service_registration_pt registration, service_reference_pt *reference);
+
+celix_status_t serviceReference_retain(service_reference_pt ref);
+celix_status_t serviceReference_release(service_reference_pt ref, bool *destroyed);
+
+celix_status_t serviceReference_increaseUsage(service_reference_pt ref, size_t *updatedCount);
+celix_status_t serviceReference_decreaseUsage(service_reference_pt ref, size_t *updatedCount);
+
+celix_status_t serviceReference_invalidate(service_reference_pt reference);
+celix_status_t serviceReference_isValid(service_reference_pt reference, bool *result);
+
+celix_status_t serviceReference_getUsageCount(service_reference_pt reference, size_t *count);
+celix_status_t serviceReference_getReferenceCount(service_reference_pt reference, size_t *count);
+
+celix_status_t serviceReference_setService(service_reference_pt ref, const void *service);
+celix_status_t serviceReference_getService(service_reference_pt reference, void **service);
+
+celix_status_t serviceReference_getOwner(service_reference_pt reference, bundle_pt *owner);
+
+
+
+#endif /* SERVICE_REFERENCE_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_registration.c
----------------------------------------------------------------------
diff --git a/framework/src/service_registration.c b/framework/src/service_registration.c
new file mode 100644
index 0000000..5d23dbf
--- /dev/null
+++ b/framework/src/service_registration.c
@@ -0,0 +1,291 @@
+/**
+ *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.
+ */
+/*
+ * service_registration.c
+ *
+ *  \date       Aug 6, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include "service_registration_private.h"
+#include "constants.h"
+
+static celix_status_t serviceRegistration_initializeProperties(service_registration_pt registration, properties_pt properties);
+static celix_status_t serviceRegistration_createInternal(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId,
+        const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *registration);
+static celix_status_t serviceRegistration_destroy(service_registration_pt registration);
+
+service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt dictionary) {
+    service_registration_pt registration = NULL;
+	serviceRegistration_createInternal(callback, bundle, serviceName, serviceId, serviceObject, dictionary, false, &registration);
+	return registration;
+}
+
+service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt dictionary) {
+    service_registration_pt registration = NULL;
+    serviceRegistration_createInternal(callback, bundle, serviceName, serviceId, serviceObject, dictionary, true, &registration);
+    return registration;
+}
+
+static celix_status_t serviceRegistration_createInternal(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId,
+        const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *out) {
+    celix_status_t status = CELIX_SUCCESS;
+
+	service_registration_pt  reg = calloc(1, sizeof(*reg));
+    if (reg) {
+        reg->callback = callback;
+        reg->services = NULL;
+        reg->nrOfServices = 0;
+		reg->isServiceFactory = isFactory;
+		reg->className = strndup(serviceName, 1024*10);
+		reg->bundle = bundle;
+		reg->refCount = 1;
+
+		reg->serviceId = serviceId;
+	reg->svcObj = serviceObject;
+		if (isFactory) {
+			reg->serviceFactory = (service_factory_pt) reg->svcObj;
+		} else {
+			reg->serviceFactory = NULL;
+		}
+
+		reg->isUnregistering = false;
+		celixThreadRwlock_create(&reg->lock, NULL);
+
+		celixThreadRwlock_writeLock(&reg->lock);
+		serviceRegistration_initializeProperties(reg, dictionary);
+		celixThreadRwlock_unlock(&reg->lock);
+
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*out = reg;
+	}
+
+	return status;
+}
+
+void serviceRegistration_retain(service_registration_pt registration) {
+	celixThreadRwlock_writeLock(&registration->lock);
+	registration->refCount += 1;
+    celixThreadRwlock_unlock(&registration->lock);
+}
+
+void serviceRegistration_release(service_registration_pt registration) {
+    celixThreadRwlock_writeLock(&registration->lock);
+    assert(registration->refCount > 0);
+	registration->refCount -= 1;
+	if (registration->refCount == 0) {
+		serviceRegistration_destroy(registration);
+	} else {
+        celixThreadRwlock_unlock(&registration->lock);
+	}
+}
+
+static celix_status_t serviceRegistration_destroy(service_registration_pt registration) {
+	//fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Destroying service registration %p\n", registration);
+    free(registration->className);
+	registration->className = NULL;
+
+    registration->callback.unregister = NULL;
+
+	properties_destroy(registration->properties);
+	celixThreadRwlock_unlock(&registration->lock);
+    celixThreadRwlock_destroy(&registration->lock);
+	free(registration);
+
+	return CELIX_SUCCESS;
+}
+
+static celix_status_t serviceRegistration_initializeProperties(service_registration_pt registration, properties_pt dictionary) {
+    char sId[32];
+
+	if (dictionary == NULL) {
+		dictionary = properties_create();
+	}
+
+
+	snprintf(sId, 32, "%lu", registration->serviceId);
+	properties_set(dictionary, (char *) OSGI_FRAMEWORK_SERVICE_ID, sId);
+
+	if (properties_get(dictionary, (char *) OSGI_FRAMEWORK_OBJECTCLASS) == NULL) {
+		properties_set(dictionary, (char *) OSGI_FRAMEWORK_OBJECTCLASS, registration->className);
+	}
+
+	registration->properties = dictionary;
+
+	return CELIX_SUCCESS;
+}
+
+void serviceRegistration_invalidate(service_registration_pt registration) {
+    celixThreadRwlock_writeLock(&registration->lock);
+    registration->svcObj = NULL;
+    celixThreadRwlock_unlock(&registration->lock);
+}
+
+bool serviceRegistration_isValid(service_registration_pt registration) {
+    bool isValid;
+    if (registration != NULL) {
+        celixThreadRwlock_readLock(&registration->lock);
+        isValid = registration->svcObj != NULL;
+        celixThreadRwlock_unlock(&registration->lock);
+    } else {
+        isValid = false;
+    }
+    return isValid;
+}
+
+celix_status_t serviceRegistration_unregister(service_registration_pt registration) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    bool notValidOrUnregistering;
+    celixThreadRwlock_readLock(&registration->lock);
+    notValidOrUnregistering = !serviceRegistration_isValid(registration) || registration->isUnregistering;
+    celixThreadRwlock_unlock(&registration->lock);
+
+    registry_callback_t callback;
+    callback.unregister = NULL;
+    bundle_pt bundle = NULL;
+
+	if (notValidOrUnregistering) {
+		status = CELIX_ILLEGAL_STATE;
+	} else {
+        celixThreadRwlock_writeLock(&registration->lock);
+        registration->isUnregistering = true;
+        bundle = registration->bundle;
+        callback = registration->callback;
+        celixThreadRwlock_unlock(&registration->lock);
+    }
+
+	if (status == CELIX_SUCCESS && callback.unregister != NULL) {
+        callback.unregister(callback.handle, bundle, registration);
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot unregister service registration");
+
+	return status;
+}
+
+celix_status_t serviceRegistration_getService(service_registration_pt registration, bundle_pt bundle, const void** service) {
+	int status = CELIX_SUCCESS;
+    celixThreadRwlock_readLock(&registration->lock);
+    if (registration->isServiceFactory) {
+        service_factory_pt factory = (void*) registration->serviceFactory;
+        /*NOTE the service argument of the service_factory should be const void**.
+          To ensure backwards compatability a cast is made instead.
+        */
+        status = factory->getService(factory->handle, bundle, registration, (void**) service);
+    } else {
+        (*service) = registration->svcObj;
+    }
+    celixThreadRwlock_unlock(&registration->lock);
+    return status;
+}
+
+celix_status_t serviceRegistration_ungetService(service_registration_pt registration, bundle_pt bundle, const void** service) {
+    celixThreadRwlock_readLock(&registration->lock);
+    if (registration->isServiceFactory) {
+        service_factory_pt factory = (void*) registration->serviceFactory;
+        /*NOTE the service argument of the service_factory should be const void**.
+          To ensure backwards compatability a cast is made instead.
+        */
+        factory->ungetService(factory->handle, bundle, registration, (void**) service);
+    }
+    celixThreadRwlock_unlock(&registration->lock);
+    return CELIX_SUCCESS;
+}
+
+celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    if (registration != NULL) {
+        celixThreadRwlock_readLock(&registration->lock);
+        *properties = registration->properties;
+        celixThreadRwlock_unlock(&registration->lock);
+     } else {
+          status = CELIX_ILLEGAL_ARGUMENT;
+     }
+
+    framework_logIfError(logger, status, NULL, "Cannot get registration properties");
+
+    return status;
+}
+
+celix_status_t serviceRegistration_setProperties(service_registration_pt registration, properties_pt properties) {
+    celix_status_t status;
+
+    properties_pt oldProperties = NULL;
+    registry_callback_t callback;
+
+    celixThreadRwlock_writeLock(&registration->lock);
+    oldProperties = registration->properties;
+    status = serviceRegistration_initializeProperties(registration, properties);
+    callback = registration->callback;
+    celixThreadRwlock_unlock(&registration->lock);
+
+    if (status == CELIX_SUCCESS && callback.modified != NULL) {
+        callback.modified(callback.handle, registration, oldProperties);
+    }
+
+	return status;
+}
+
+
+celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+    if (registration == NULL) {
+        return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (registration != NULL && *bundle == NULL) {
+        celixThreadRwlock_readLock(&registration->lock);
+        *bundle = registration->bundle;
+        celixThreadRwlock_unlock(&registration->lock);
+	} else {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+    framework_logIfError(logger, status, NULL, "Cannot get bundle");
+
+	return status;
+}
+
+celix_status_t serviceRegistration_getServiceName(service_registration_pt registration, const char **serviceName) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    if (registration != NULL && *serviceName == NULL) {
+        celixThreadRwlock_readLock(&registration->lock);
+        *serviceName = registration->className;
+        celixThreadRwlock_unlock(&registration->lock);
+	} else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+
+    framework_logIfError(logger, status, NULL, "Cannot get service name");
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_registration_private.h
----------------------------------------------------------------------
diff --git a/framework/src/service_registration_private.h b/framework/src/service_registration_private.h
new file mode 100644
index 0000000..ca0cb67
--- /dev/null
+++ b/framework/src/service_registration_private.h
@@ -0,0 +1,71 @@
+/**
+ *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.
+ */
+/*
+ * service_registration_private.h
+ *
+ *  \date       Feb 11, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef SERVICE_REGISTRATION_PRIVATE_H_
+#define SERVICE_REGISTRATION_PRIVATE_H_
+
+#include "registry_callback_private.h"
+#include "service_registration.h"
+
+struct serviceRegistration {
+    registry_callback_t callback;
+
+	char * className;
+	bundle_pt bundle;
+	properties_pt properties;
+	const void * svcObj;
+	unsigned long serviceId;
+
+	bool isUnregistering;
+
+	bool isServiceFactory;
+	const void *serviceFactory;
+
+	struct service *services;
+	int nrOfServices;
+
+	size_t refCount; //protected by mutex
+
+	celix_thread_rwlock_t lock;
+};
+
+service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt dictionary);
+service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt dictionary);
+
+void serviceRegistration_retain(service_registration_pt registration);
+void serviceRegistration_release(service_registration_pt registration);
+
+bool serviceRegistration_isValid(service_registration_pt registration);
+void serviceRegistration_invalidate(service_registration_pt registration);
+
+celix_status_t serviceRegistration_getService(service_registration_pt registration, bundle_pt bundle, const void **service);
+celix_status_t serviceRegistration_ungetService(service_registration_pt registration, bundle_pt bundle, const void **service);
+
+celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle);
+celix_status_t serviceRegistration_getServiceName(service_registration_pt registration, const char **serviceName);
+
+#endif /* SERVICE_REGISTRATION_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_registry.c
----------------------------------------------------------------------
diff --git a/framework/src/service_registry.c b/framework/src/service_registry.c
new file mode 100644
index 0000000..d27cc32
--- /dev/null
+++ b/framework/src/service_registry.c
@@ -0,0 +1,800 @@
+/**
+ *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.
+ */
+/*
+ * service_registry.c
+ *
+ *  \date       Aug 6, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include "service_registry_private.h"
+#include "service_registration_private.h"
+#include "listener_hook_service.h"
+#include "constants.h"
+#include "service_reference_private.h"
+#include "framework_private.h"
+
+#ifdef DEBUG
+#define CHECK_DELETED_REFERENCES true
+#else
+#define CHECK_DELETED_REFERENCES false
+#endif
+
+static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *registration);
+static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, const char* serviceName, const void *serviceObject, service_registration_pt registration);
+static celix_status_t serviceRegistry_removeHook(service_registry_pt registry, service_registration_pt registration);
+static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registry_pt registry, bundle_pt bundle, service_reference_pt ref, size_t usageCount, size_t refCount);
+static void serviceRegistry_logWarningServiceRegistration(service_registry_pt registry, service_registration_pt reg);
+static celix_status_t serviceRegistry_checkReference(service_registry_pt registry, service_reference_pt ref,
+                                                     reference_status_t *refStatus);
+static void serviceRegistry_logIllegalReference(service_registry_pt registry, service_reference_pt reference,
+                                                   reference_status_t refStatus);
+static celix_status_t serviceRegistry_setReferenceStatus(service_registry_pt registry, service_reference_pt reference,
+                                                  bool deleted);
+static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt registry, service_registration_pt reg, array_list_pt *bundles);
+static celix_status_t serviceRegistry_getServiceReference_internal(service_registry_pt registry, bundle_pt owner, service_registration_pt registration, service_reference_pt *out);
+
+celix_status_t serviceRegistry_create(framework_pt framework, serviceChanged_function_pt serviceChanged, service_registry_pt *out) {
+	celix_status_t status;
+
+	service_registry_pt reg = calloc(1, sizeof(*reg));
+	if (reg == NULL) {
+		status = CELIX_ENOMEM;
+	} else {
+
+        reg->callback.handle = reg;
+        reg->callback.getUsingBundles = (void *)serviceRegistry_getUsingBundles;
+        reg->callback.unregister = (void *) serviceRegistry_unregisterService;
+        reg->callback.modified = (void *) serviceRegistry_servicePropertiesModified;
+
+        reg->serviceChanged = serviceChanged;
+		reg->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
+		reg->framework = framework;
+		reg->currentServiceId = 1UL;
+		reg->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
+
+        reg->checkDeletedReferences = CHECK_DELETED_REFERENCES;
+        reg->deletedServiceReferences = hashMap_create(NULL, NULL, NULL, NULL);
+
+		arrayList_create(&reg->listenerHooks);
+
+		status = celixThreadRwlock_create(&reg->lock, NULL);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*out = reg;
+	} else {
+		framework_logIfError(logger, status, NULL, "Cannot create service registry");
+	}
+
+	return status;
+}
+
+celix_status_t serviceRegistry_destroy(service_registry_pt registry) {
+    celixThreadRwlock_writeLock(&registry->lock);
+
+    //destroy service registration map
+    int size = hashMap_size(registry->serviceRegistrations);
+    assert(size == 0);
+    hashMap_destroy(registry->serviceRegistrations, false, false);
+
+    //destroy service references (double) map);
+    //FIXME. The framework bundle does not (yet) call clearReferences, as result the size could be > 0 for test code.
+    //size = hashMap_size(registry->serviceReferences);
+    //assert(size == 0);
+    hashMap_destroy(registry->serviceReferences, false, false);
+
+    //destroy listener hooks
+    size = arrayList_size(registry->listenerHooks);
+    if (size == 0)
+    	arrayList_destroy(registry->listenerHooks);
+
+    hashMap_destroy(registry->deletedServiceReferences, false, false);
+
+    free(registry);
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt registry, bundle_pt bundle, array_list_pt *services) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	celixThreadRwlock_writeLock(&registry->lock);
+
+	array_list_pt regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle);
+	if (regs != NULL) {
+		unsigned int i;
+		arrayList_create(services);
+		
+		for (i = 0; i < arrayList_size(regs); i++) {
+			service_registration_pt reg = arrayList_get(regs, i);
+			if (serviceRegistration_isValid(reg)) {
+				service_reference_pt reference = NULL;
+				status = serviceRegistry_getServiceReference_internal(registry, bundle, reg, &reference);
+				if (status == CELIX_SUCCESS) {
+					arrayList_add(*services, reference);
+				}
+			}
+		}
+	}
+
+	celixThreadRwlock_unlock(&registry->lock);
+
+	framework_logIfError(logger, status, NULL, "Cannot get registered services");
+
+	return status;
+}
+
+celix_status_t serviceRegistry_registerService(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void* serviceObject, properties_pt dictionary, service_registration_pt *registration) {
+    return serviceRegistry_registerServiceInternal(registry, bundle, serviceName, serviceObject, dictionary, false, registration);
+}
+
+celix_status_t serviceRegistry_registerServiceFactory(service_registry_pt registry, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt dictionary, service_registration_pt *registration) {
+    return serviceRegistry_registerServiceInternal(registry, bundle, serviceName, (const void *) factory, dictionary, true, registration);
+}
+
+static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void* serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *registration) {
+	array_list_pt regs;
+
+	if (isFactory) {
+	    *registration = serviceRegistration_createServiceFactory(registry->callback, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
+	} else {
+	    *registration = serviceRegistration_create(registry->callback, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
+	}
+
+    //long id;
+    //bundle_getBundleId(bundle, &id);
+    //fprintf(stderr, "REG: Registering service '%s' for bundle id %li with reg pointer %p\n", serviceName, id, *registration);
+
+
+    serviceRegistry_addHooks(registry, serviceName, serviceObject, *registration);
+
+	celixThreadRwlock_writeLock(&registry->lock);
+	regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle);
+	if (regs == NULL) {
+		regs = NULL;
+		arrayList_create(&regs);
+        hashMap_put(registry->serviceRegistrations, bundle, regs);
+    }
+	arrayList_add(regs, *registration);
+	celixThreadRwlock_unlock(&registry->lock);
+
+	if (registry->serviceChanged != NULL) {
+		registry->serviceChanged(registry->framework, OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED, *registration, NULL);
+	}
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceRegistry_unregisterService(service_registry_pt registry, bundle_pt bundle, service_registration_pt registration) {
+	// array_list_t clients;
+	array_list_pt regs;
+
+    //fprintf(stderr, "REG: Unregistering service registration with pointer %p\n", registration);
+
+	serviceRegistry_removeHook(registry, registration);
+
+	celixThreadRwlock_writeLock(&registry->lock);
+	regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle);
+	if (regs != NULL) {
+		arrayList_removeElement(regs, registration);
+        int size = arrayList_size(regs);
+        if (size == 0) {
+            arrayList_destroy(regs);
+            hashMap_remove(registry->serviceRegistrations, bundle);
+        }
+	}
+	celixThreadRwlock_unlock(&registry->lock);
+
+	if (registry->serviceChanged != NULL) {
+		registry->serviceChanged(registry->framework, OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING, registration, NULL);
+	}
+
+
+	celixThreadRwlock_readLock(&registry->lock);
+    //invalidate service references
+    hash_map_iterator_pt iter = hashMapIterator_create(registry->serviceReferences);
+    while (hashMapIterator_hasNext(iter)) {
+        hash_map_pt refsMap = hashMapIterator_nextValue(iter);
+        service_reference_pt ref = refsMap != NULL ?
+                                   hashMap_get(refsMap, (void*)registration->serviceId) : NULL;
+        if (ref != NULL) {
+            serviceReference_invalidate(ref);
+        }
+    }
+    hashMapIterator_destroy(iter);
+	celixThreadRwlock_unlock(&registry->lock);
+
+	serviceRegistration_invalidate(registration);
+    serviceRegistration_release(registration);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceRegistry_clearServiceRegistrations(service_registry_pt registry, bundle_pt bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+    array_list_pt registrations = NULL;
+    bool registrationsLeft;
+
+    celixThreadRwlock_writeLock(&registry->lock);
+    registrations = hashMap_get(registry->serviceRegistrations, bundle);
+    registrationsLeft = (registrations != NULL);
+    if (registrationsLeft) {
+        registrationsLeft = (arrayList_size(registrations) > 0);
+    }
+    celixThreadRwlock_unlock(&registry->lock);
+
+    while (registrationsLeft) {
+        service_registration_pt reg = arrayList_get(registrations, 0);
+
+        serviceRegistry_logWarningServiceRegistration(registry, reg);
+
+        if (serviceRegistration_isValid(reg)) {
+            serviceRegistration_unregister(reg);
+        }
+        else {
+            arrayList_remove(registrations, 0);
+        }
+
+        // not removed by last unregister call?
+        celixThreadRwlock_writeLock(&registry->lock);
+        registrations = hashMap_get(registry->serviceRegistrations, bundle);
+        registrationsLeft = (registrations != NULL);
+        if (registrationsLeft) {
+            registrationsLeft = (arrayList_size(registrations) > 0);
+        }
+        celixThreadRwlock_unlock(&registry->lock);
+    }
+
+    return status;
+}
+
+static void serviceRegistry_logWarningServiceRegistration(service_registry_pt registry __attribute__((unused)), service_registration_pt reg) {
+    const char *servName = NULL;
+    serviceRegistration_getServiceName(reg, &servName);
+    fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Dangling service registration for service %s. Look for missing serviceRegistration_unregister calls.", servName);
+}
+
+celix_status_t serviceRegistry_getServiceReference(service_registry_pt registry, bundle_pt owner,
+                                                   service_registration_pt registration, service_reference_pt *out) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if(celixThreadRwlock_writeLock(&registry->lock) == CELIX_SUCCESS) {
+	    status = serviceRegistry_getServiceReference_internal(registry, owner, registration, out);
+	    celixThreadRwlock_unlock(&registry->lock);
+	}
+
+	return status;
+}
+
+static celix_status_t serviceRegistry_getServiceReference_internal(service_registry_pt registry, bundle_pt owner,
+                                                   service_registration_pt registration, service_reference_pt *out) {
+	//only call after locked registry RWlock
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_pt bundle = NULL;
+    service_reference_pt ref = NULL;
+    hash_map_pt references = NULL;
+
+    references = hashMap_get(registry->serviceReferences, owner);
+    if (references == NULL) {
+        references = hashMap_create(NULL, NULL, NULL, NULL);
+        hashMap_put(registry->serviceReferences, owner, references);
+	}
+
+    ref = hashMap_get(references, (void*)registration->serviceId);
+
+    if (ref == NULL) {
+        status = serviceRegistration_getBundle(registration, &bundle);
+        if (status == CELIX_SUCCESS) {
+            status = serviceReference_create(registry->callback, owner, registration, &ref);
+        }
+        if (status == CELIX_SUCCESS) {
+            hashMap_put(references, (void*)registration->serviceId, ref);
+            hashMap_put(registry->deletedServiceReferences, ref, (void *)false);
+        }
+    } else {
+        serviceReference_retain(ref);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        *out = ref;
+    }
+
+	framework_logIfError(logger, status, NULL, "Cannot create service reference");
+
+
+	return status;
+}
+
+celix_status_t serviceRegistry_getServiceReferences(service_registry_pt registry, bundle_pt owner, const char *serviceName, filter_pt filter, array_list_pt *out) {
+	celix_status_t status;
+	hash_map_iterator_pt iterator;
+    array_list_pt references = NULL;
+	array_list_pt matchingRegistrations = NULL;
+    bool matchResult;
+
+    status = arrayList_create(&references);
+    status = CELIX_DO_IF(status, arrayList_create(&matchingRegistrations));
+
+    celixThreadRwlock_readLock(&registry->lock);
+	iterator = hashMapIterator_create(registry->serviceRegistrations);
+	while (status == CELIX_SUCCESS && hashMapIterator_hasNext(iterator)) {
+		array_list_pt regs = (array_list_pt) hashMapIterator_nextValue(iterator);
+		unsigned int regIdx;
+		for (regIdx = 0; (regs != NULL) && regIdx < arrayList_size(regs); regIdx++) {
+			service_registration_pt registration = (service_registration_pt) arrayList_get(regs, regIdx);
+			properties_pt props = NULL;
+
+			status = serviceRegistration_getProperties(registration, &props);
+			if (status == CELIX_SUCCESS) {
+				bool matched = false;
+				matchResult = false;
+				if (filter != NULL) {
+					filter_match(filter, props, &matchResult);
+				}
+				if ((serviceName == NULL) && ((filter == NULL) || matchResult)) {
+					matched = true;
+				} else if (serviceName != NULL) {
+					const char *className = NULL;
+					matchResult = false;
+					serviceRegistration_getServiceName(registration, &className);
+					if (filter != NULL) {
+						filter_match(filter, props, &matchResult);
+					}
+					if ((strcmp(className, serviceName) == 0) && ((filter == NULL) || matchResult)) {
+						matched = true;
+					}
+				}
+				if (matched) {
+					if (serviceRegistration_isValid(registration)) {
+                        serviceRegistration_retain(registration);
+                        arrayList_add(matchingRegistrations, registration);
+					}
+				}
+			}
+		}
+	}
+    celixThreadRwlock_unlock(&registry->lock);
+	hashMapIterator_destroy(iterator);
+
+    if (status == CELIX_SUCCESS) {
+        unsigned int i;
+        unsigned int size = arrayList_size(matchingRegistrations);
+
+        for (i = 0; i < size; i += 1) {
+            service_registration_pt reg = arrayList_get(matchingRegistrations, i);
+            service_reference_pt reference = NULL;
+            celix_status_t subStatus = serviceRegistry_getServiceReference(registry, owner, reg, &reference);
+            if (subStatus == CELIX_SUCCESS) {
+                arrayList_add(references, reference);
+            } else {
+                status = CELIX_BUNDLE_EXCEPTION;
+            }
+            serviceRegistration_release(reg);
+        }
+    }
+
+    if(matchingRegistrations != NULL){
+    	arrayList_destroy(matchingRegistrations);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        *out = references;
+    } else {
+        //TODO ungetServiceRefs
+        arrayList_destroy(references);
+        framework_logIfError(logger, status, NULL, "Cannot get service references");
+    }
+
+	return status;
+}
+
+celix_status_t serviceRegistry_retainServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference) {
+    celix_status_t status = CELIX_SUCCESS;
+    reference_status_t refStatus;
+    bundle_pt refBundle = NULL;
+    
+    celixThreadRwlock_writeLock(&registry->lock);
+    serviceRegistry_checkReference(registry, reference, &refStatus);
+    if (refStatus == REF_ACTIVE) {
+        serviceReference_getOwner(reference, &refBundle);
+        if (refBundle == bundle) {
+            serviceReference_retain(reference);
+        } else {
+            status = CELIX_ILLEGAL_ARGUMENT;
+            fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "cannot retain a service reference from an other bundle (in ref %p) (provided %p).", refBundle, bundle);
+        }
+    } else {
+        serviceRegistry_logIllegalReference(registry, reference, refStatus);
+    }
+    celixThreadRwlock_unlock(&registry->lock);
+
+    return status;
+}
+
+
+celix_status_t serviceRegistry_ungetServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference) {
+    celix_status_t status = CELIX_SUCCESS;
+    bool destroyed = false;
+    size_t count = 0;
+    reference_status_t refStatus;
+
+    celixThreadRwlock_writeLock(&registry->lock);
+    serviceRegistry_checkReference(registry, reference, &refStatus);
+    if (refStatus == REF_ACTIVE) {
+        serviceReference_getUsageCount(reference, &count);
+        serviceReference_release(reference, &destroyed);
+        if (destroyed) {
+
+            if (count > 0) {
+                serviceRegistry_logWarningServiceReferenceUsageCount(registry, bundle, reference, count, 0);
+            }
+
+            hash_map_pt refsMap = hashMap_get(registry->serviceReferences, bundle);
+
+            unsigned long refId = 0UL;
+            service_reference_pt ref = NULL;
+            hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
+            while (hashMapIterator_hasNext(iter)) {
+                hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+                refId = (unsigned long)hashMapEntry_getKey(entry); //note could be invalid e.g. freed
+                ref = hashMapEntry_getValue(entry);
+
+                if (ref == reference) {
+                    break;
+                } else {
+                    ref = NULL;
+                    refId = 0UL;
+                }
+            }
+            hashMapIterator_destroy(iter);
+
+            if (ref != NULL) {
+                hashMap_remove(refsMap, (void*)refId);
+                int size = hashMap_size(refsMap);
+                if (size == 0) {
+                    hashMap_destroy(refsMap, false, false);
+                    hashMap_remove(registry->serviceReferences, bundle);
+                }
+                serviceRegistry_setReferenceStatus(registry, reference, true);
+            } else {
+                fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Cannot find reference %p in serviceReferences map",
+                       reference);
+            }
+        }
+    } else {
+        serviceRegistry_logIllegalReference(registry, reference, refStatus);
+    }
+    celixThreadRwlock_unlock(&registry->lock);
+
+    return status;
+}
+
+static celix_status_t serviceRegistry_setReferenceStatus(service_registry_pt registry, service_reference_pt reference,
+                                                  bool deleted) {
+    //precondition write locked on registry->lock
+    if (registry->checkDeletedReferences) {
+        hashMap_put(registry->deletedServiceReferences, reference, (void *) deleted);
+    }
+    return CELIX_SUCCESS;
+}
+
+static void serviceRegistry_logIllegalReference(service_registry_pt registry __attribute__((unused)), service_reference_pt reference,
+                                                   reference_status_t refStatus) {
+    fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR,
+           "Error handling service reference %p, status is %i",reference, refStatus);
+}
+
+static celix_status_t serviceRegistry_checkReference(service_registry_pt registry, service_reference_pt ref,
+                                              reference_status_t *out) {
+    //precondition read or write locked on registry->lock
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (registry->checkDeletedReferences) {
+        reference_status_t refStatus = REF_UNKNOWN;
+
+        if (hashMap_containsKey(registry->deletedServiceReferences, ref)) {
+            bool deleted = (bool) hashMap_get(registry->deletedServiceReferences, ref);
+            refStatus = deleted ? REF_DELETED : REF_ACTIVE;
+        }
+
+        *out = refStatus;
+    } else {
+        *out = REF_ACTIVE;
+    }
+
+    return status;
+}
+
+static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registry_pt registry __attribute__((unused)), bundle_pt bundle, service_reference_pt ref, size_t usageCount, size_t refCount) {
+    if (usageCount > 0) {
+        fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Service Reference destroyed with usage count is %zu, expected 0. Look for missing bundleContext_ungetService calls.", usageCount);
+    }
+    if (refCount > 0) {
+        fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Dangling service reference. Reference count is %zu, expected 1.  Look for missing bundleContext_ungetServiceReference calls.", refCount);
+    }
+
+    if(usageCount > 0 || refCount > 0) {
+        module_pt module_ptr = NULL;
+        bundle_getCurrentModule(bundle, &module_ptr);
+        const char* bundle_name = NULL;
+        module_getSymbolicName(module_ptr, &bundle_name);
+
+        const char* service_name = "unknown";
+        const char* bundle_provider_name = "unknown";
+        if (refCount > 0 && ref != NULL) {
+            serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &service_name);
+            service_registration_pt reg = NULL;
+            bundle_pt bundle = NULL;
+            module_pt mod = NULL;
+            serviceReference_getServiceRegistration(ref, &reg);
+            serviceRegistration_getBundle(reg, &bundle);
+            bundle_getCurrentModule(bundle, &mod);
+            module_getSymbolicName(mod, &bundle_provider_name);
+        }
+
+        fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Previous Dangling service reference warnings caused by bundle '%s', for service '%s', provided by bundle '%s'", bundle_name, service_name, bundle_provider_name);
+    }
+}
+
+
+celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry, bundle_pt bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    celixThreadRwlock_writeLock(&registry->lock);
+
+    hash_map_pt refsMap = hashMap_remove(registry->serviceReferences, bundle);
+    if (refsMap != NULL) {
+        hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
+        while (hashMapIterator_hasNext(iter)) {
+            service_reference_pt ref = hashMapIterator_nextValue(iter);
+            size_t refCount;
+            size_t usageCount;
+
+            serviceReference_getUsageCount(ref, &usageCount);
+            serviceReference_getReferenceCount(ref, &refCount);
+            serviceRegistry_logWarningServiceReferenceUsageCount(registry, bundle, ref, usageCount, refCount);
+
+            while (usageCount > 0) {
+                serviceReference_decreaseUsage(ref, &usageCount);
+            }
+
+            bool destroyed = false;
+            while (!destroyed) {
+                serviceReference_release(ref, &destroyed);
+            }
+            serviceRegistry_setReferenceStatus(registry, ref, true);
+
+        }
+        hashMapIterator_destroy(iter);
+        hashMap_destroy(refsMap, false, false);
+    }
+
+    celixThreadRwlock_unlock(&registry->lock);
+
+    return status;
+}
+
+
+celix_status_t serviceRegistry_getServicesInUse(service_registry_pt registry, bundle_pt bundle, array_list_pt *out) {
+
+    array_list_pt result = NULL;
+    arrayList_create(&result);
+
+    //LOCK
+    celixThreadRwlock_readLock(&registry->lock);
+
+    hash_map_pt refsMap = hashMap_get(registry->serviceReferences, bundle);
+
+    if(refsMap) {
+        hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
+        while (hashMapIterator_hasNext(iter)) {
+            service_reference_pt ref = hashMapIterator_nextValue(iter);
+            arrayList_add(result, ref);
+        }
+        hashMapIterator_destroy(iter);
+    }
+
+    //UNLOCK
+    celixThreadRwlock_unlock(&registry->lock);
+
+    *out = result;
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceRegistry_getService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference, const void **out) {
+	celix_status_t status = CELIX_SUCCESS;
+	service_registration_pt registration = NULL;
+    size_t count = 0;
+    const void *service = NULL;
+    reference_status_t refStatus;
+
+
+
+    celixThreadRwlock_readLock(&registry->lock);
+    serviceRegistry_checkReference(registry, reference, &refStatus);
+    if (refStatus == REF_ACTIVE) {
+        serviceReference_getServiceRegistration(reference, &registration);
+
+        if (serviceRegistration_isValid(registration)) {
+            serviceReference_increaseUsage(reference, &count);
+            if (count == 1) {
+                serviceRegistration_getService(registration, bundle, &service);
+                serviceReference_setService(reference, service);
+            }
+
+            /* NOTE the out argument of sr_getService should be 'const void**'
+               To ensure backwards compatability a cast is made instead.
+            */
+            serviceReference_getService(reference, (void **)out);
+        } else {
+            *out = NULL; //invalid service registration
+        }
+    } else {
+        serviceRegistry_logIllegalReference(registry, reference, refStatus);
+        status = CELIX_BUNDLE_EXCEPTION;
+    }
+    celixThreadRwlock_unlock(&registry->lock);
+
+	return status;
+}
+
+celix_status_t serviceRegistry_ungetService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference, bool *result) {
+	celix_status_t status = CELIX_SUCCESS;
+    service_registration_pt reg = NULL;
+    const void *service = NULL;
+    size_t count = 0;
+    celix_status_t subStatus = CELIX_SUCCESS;
+    reference_status_t refStatus;
+
+    celixThreadRwlock_readLock(&registry->lock);
+    serviceRegistry_checkReference(registry, reference, &refStatus);
+    celixThreadRwlock_unlock(&registry->lock);
+
+    if (refStatus == REF_ACTIVE) {
+        subStatus = serviceReference_decreaseUsage(reference, &count);
+        if (count == 0) {
+            /*NOTE the argument service of sr_getService should be 'const void**'
+              TO ensure backwards compatability a cast is made instead.
+              */
+            serviceReference_getService(reference, (void**)&service);
+            serviceReference_getServiceRegistration(reference, &reg);
+            if (reg != NULL) {
+                serviceRegistration_ungetService(reg, bundle, &service);
+            }
+        }
+    } else {
+        serviceRegistry_logIllegalReference(registry, reference, refStatus);
+        status = CELIX_BUNDLE_EXCEPTION;
+    }
+
+    if (result) {
+        *result = (subStatus == CELIX_SUCCESS);
+    }
+
+
+	return status;
+}
+
+static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, const char* serviceName, const void* serviceObject __attribute__((unused)), service_registration_pt registration) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (strcmp(OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, serviceName) == 0) {
+        celixThreadRwlock_writeLock(&registry->lock);
+		arrayList_add(registry->listenerHooks, registration);
+        celixThreadRwlock_unlock(&registry->lock);
+	}
+
+	return status;
+}
+
+static celix_status_t serviceRegistry_removeHook(service_registry_pt registry, service_registration_pt registration) {
+	celix_status_t status = CELIX_SUCCESS;
+	const char* serviceName = NULL;
+
+	properties_pt props = NULL;
+	serviceRegistration_getProperties(registration, &props);
+	serviceName = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
+	if (strcmp(OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, serviceName) == 0) {
+        celixThreadRwlock_writeLock(&registry->lock);
+		arrayList_removeElement(registry->listenerHooks, registration);
+        celixThreadRwlock_unlock(&registry->lock);
+	}
+
+	return status;
+}
+
+celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, bundle_pt owner, array_list_pt *out) {
+	celix_status_t status;
+    array_list_pt result;
+
+    status = arrayList_create(&result);
+    if (status == CELIX_SUCCESS) {
+        unsigned int i;
+        unsigned size = arrayList_size(registry->listenerHooks);
+
+        for (i = 0; i < size; i += 1) {
+            celixThreadRwlock_readLock(&registry->lock);
+            service_registration_pt registration = arrayList_get(registry->listenerHooks, i);
+            serviceRegistration_retain(registration);
+            celixThreadRwlock_unlock(&registry->lock);
+
+            service_reference_pt reference = NULL;
+            serviceRegistry_getServiceReference(registry, owner, registration, &reference);
+            arrayList_add(result, reference);
+            serviceRegistration_release(registration);
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        *out = result;
+    } else {
+        if (result != NULL) {
+            arrayList_destroy(result);
+        }
+        framework_logIfError(logger, status, NULL, "Cannot get listener hooks");
+    }
+
+	return status;
+}
+
+celix_status_t serviceRegistry_servicePropertiesModified(service_registry_pt registry, service_registration_pt registration, properties_pt oldprops) {
+	if (registry->serviceChanged != NULL) {
+		registry->serviceChanged(registry->framework, OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED, registration, oldprops);
+	}
+	return CELIX_SUCCESS;
+}
+
+static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt registry, service_registration_pt registration, array_list_pt *out) {
+    celix_status_t status;
+    array_list_pt bundles = NULL;
+    hash_map_iterator_pt iter;
+
+    status = arrayList_create(&bundles);
+    if (status == CELIX_SUCCESS) {
+        celixThreadRwlock_readLock(&registry->lock);
+        iter = hashMapIterator_create(registry->serviceReferences);
+        while (hashMapIterator_hasNext(iter)) {
+            hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+            bundle_pt registrationUser = hashMapEntry_getKey(entry);
+            hash_map_pt regMap = hashMapEntry_getValue(entry);
+            if (hashMap_containsKey(regMap, (void*)registration->serviceId)) {
+                arrayList_add(bundles, registrationUser);
+            }
+        }
+        hashMapIterator_destroy(iter);
+        celixThreadRwlock_unlock(&registry->lock);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        *out = bundles;
+    } else {
+        if (bundles != NULL) {
+            arrayList_destroy(bundles);
+        }
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/service_registry_private.h
----------------------------------------------------------------------
diff --git a/framework/src/service_registry_private.h b/framework/src/service_registry_private.h
new file mode 100644
index 0000000..d68fe11
--- /dev/null
+++ b/framework/src/service_registry_private.h
@@ -0,0 +1,67 @@
+/**
+ *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.
+ */
+/*
+ * service_registry_private.h
+ *
+ *  \date       Feb 7, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef SERVICE_REGISTRY_PRIVATE_H_
+#define SERVICE_REGISTRY_PRIVATE_H_
+
+#include "registry_callback_private.h"
+#include "service_registry.h"
+
+struct serviceRegistry {
+	framework_pt framework;
+	registry_callback_t callback;
+
+	hash_map_pt serviceRegistrations; //key = bundle (reg owner), value = list ( registration )
+	hash_map_pt serviceReferences; //key = bundle, value = map (key = serviceId, value = reference)
+
+	bool checkDeletedReferences; //If enabled. check if provided service references are still valid
+	hash_map_pt deletedServiceReferences; //key = ref pointer, value = bool
+
+	serviceChanged_function_pt serviceChanged;
+	unsigned long currentServiceId;
+
+	array_list_pt listenerHooks;
+
+	celix_thread_rwlock_t lock;
+};
+
+typedef enum reference_status_enum {
+	REF_ACTIVE,
+	REF_DELETED,
+	REF_UNKNOWN
+} reference_status_t;
+
+struct usageCount {
+	unsigned int count;
+	service_reference_pt reference;
+	void * service;
+	service_registration_pt registration;
+};
+
+typedef struct usageCount * usage_count_pt;
+
+#endif /* SERVICE_REGISTRY_PRIVATE_H_ */


[34/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dfi/CMakeLists.txt b/dfi/CMakeLists.txt
index 3fd196b..ad3a41f 100644
--- a/dfi/CMakeLists.txt
+++ b/dfi/CMakeLists.txt
@@ -18,72 +18,56 @@
 find_package(FFI REQUIRED)
 find_package(Jansson REQUIRED)
 
-include_directories(
-        ${FFI_INCLUDE_DIRS}
-        ${JANSSON_INCLUDE_DIRS}
-	    private/include
-	    public/include
-	    ${PROJECT_SOURCE_DIR}/utils/public/include
+add_library(dfi SHARED
+    src/dyn_common.c
+    src/dyn_type.c
+    src/dyn_function.c
+    src/dyn_interface.c
+    src/dyn_message.c
+    src/json_serializer.c
+    src/json_rpc.c
 )
+set_target_properties(dfi PROPERTIES OUTPUT_NAME "celix_dfi")
 
-set(MEMSTREAM_SOURCES )
-set(MEMSTREAM_INCLUDES )
-if (APPLE OR ANDROID)
-	set(MEMSTREAM_SOURCES ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/open_memstream.c  ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/fmemopen.c)
-	set(MEMSTREAM_INCLUDES ${PROJECT_SOURCE_DIR}/utils/public/include/memstream/open_memstream.h ${PROJECT_SOURCE_DIR}/utils/public/include/memstream/fmemopen.h)
-    include_directories(${PROJECT_SOURCE_DIR}/utils/public/include/memstream)
-endif()
+target_include_directories(dfi PUBLIC
+	include
+	${JANSSON_INCLUDE_DIRS}
+)
+target_include_directories(dfi PRIVATE
+	src
+	${FFI_INCLUDE_DIRS}
+)
 
-add_library(celix_dfi SHARED
-    private/src/dyn_common.c
-    private/src/dyn_type.c
-    private/src/dyn_function.c
-    private/src/dyn_interface.c
-    private/src/dyn_message.c
-    private/src/json_serializer.c
-    private/src/json_rpc.c
-    ${MEMSTREAM_SOURCES}
+target_link_libraries(dfi PUBLIC ${JANSSON_LIBRARY})
+target_link_libraries(dfi PRIVATE Celix::utils ${FFI_LIBRARIES})
 
-    public/include/dyn_common.h
-    public/include/dyn_type.h
-    public/include/dyn_function.h
-    public/include/dyn_interface.h
-    public/include/dyn_message.h
-    public/include/json_serializer.h
-    public/include/json_rpc.h
-    ${MEMSTREAM_INCLUDES}
-)
-set_target_properties(celix_dfi PROPERTIES "SOVERSION" 1)
-target_link_libraries(celix_dfi celix_utils ${FFI_LIBRARIES} ${JANSSON_LIBRARY})
+set_target_properties(dfi PROPERTIES "SOVERSION" 1)
 
-install(TARGETS celix_dfi DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework)
-FILE(GLOB files "public/include/*.h" ${MEMSTREAM_INCLUDES})
-INSTALL(FILES ${files} DESTINATION include/celix/dfi COMPONENT framework)
+install(TARGETS dfi DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework)
 
 
+#Alias setup to match external usage
+add_library(Celix::dfi ALIAS dfi)
+
 if (ENABLE_TESTING)
     find_package(CppUTest REQUIRED)
-        
     include_directories(${CPPUTEST_INCLUDE_DIR})
 
-	SET(CMAKE_SKIP_BUILD_RPATH  FALSE) #TODO needed?
-	SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) #TODO needed?
-    SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/dfi" "${PROJECT_BINARY_DIR}/utils")
-
 	add_executable(test_dfi
-		private/test/dyn_type_tests.cpp
-		private/test/dyn_function_tests.cpp
-		private/test/dyn_closure_tests.cpp
-		private/test/dyn_interface_tests.cpp
-		private/test/dyn_message_tests.cpp
-		private/test/json_serializer_tests.cpp
-		private/test/json_rpc_tests.cpp
-		private/test/run_tests.cpp
+		test/dyn_type_tests.cpp
+		test/dyn_function_tests.cpp
+		test/dyn_closure_tests.cpp
+		test/dyn_interface_tests.cpp
+		test/dyn_message_tests.cpp
+		test/json_serializer_tests.cpp
+		test/json_rpc_tests.cpp
+		test/run_tests.cpp
 	)
-	target_link_libraries(test_dfi celix_dfi ${FFI_LIBRARIES} ${CPPUTEST_LIBRARY})
+	target_link_libraries(test_dfi PRIVATE Celix::dfi Celix::utils ${FFI_LIBRARIES} ${CPPUTEST_LIBRARY})
+	target_include_directories(test_dfi PRIVATE ${FFI_INCLUDE_DIRS})
 
-    file(COPY ${CMAKE_CURRENT_LIST_DIR}/private/test/schemas DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-    file(COPY ${CMAKE_CURRENT_LIST_DIR}/private/test/descriptors DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+    file(COPY ${CMAKE_CURRENT_LIST_DIR}/test/schemas DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+    file(COPY ${CMAKE_CURRENT_LIST_DIR}/test/descriptors DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 
 	add_test(NAME run_test_dfi COMMAND test_dfi)
 	SETUP_TARGET_FOR_COVERAGE(test_dfi_cov test_dfi ${CMAKE_BINARY_DIR}/coverage/test_dfi/test_dfi)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/include/dfi_log_util.h
----------------------------------------------------------------------
diff --git a/dfi/include/dfi_log_util.h b/dfi/include/dfi_log_util.h
new file mode 100644
index 0000000..2bcd8fa
--- /dev/null
+++ b/dfi/include/dfi_log_util.h
@@ -0,0 +1,63 @@
+/**
+ *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.
+ */
+#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

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/include/dyn_common.h
----------------------------------------------------------------------
diff --git a/dfi/include/dyn_common.h b/dfi/include/dyn_common.h
new file mode 100644
index 0000000..6ec236f
--- /dev/null
+++ b/dfi/include/dyn_common.h
@@ -0,0 +1,47 @@
+/**
+ *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.
+ */
+#ifndef _DYN_COMMON_H_
+#define _DYN_COMMON_H_
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/queue.h>
+
+#include "dfi_log_util.h"
+
+//logging
+DFI_SETUP_LOG_HEADER(dynCommon);
+
+TAILQ_HEAD(namvals_head, namval_entry);
+
+struct namval_entry {
+    char *name;
+    char *value;
+    TAILQ_ENTRY(namval_entry) entries;
+};
+
+int dynCommon_parseName(FILE *stream, char **result);
+int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result);
+int dynCommon_parseNameValue(FILE *stream, char **name, char **value);
+int dynCommon_eatChar(FILE *stream, int c);
+
+void dynCommon_clearNamValHead(struct namvals_head *head);
+
+#endif 

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/include/dyn_function.h
----------------------------------------------------------------------
diff --git a/dfi/include/dyn_function.h b/dfi/include/dyn_function.h
new file mode 100644
index 0000000..7f5cd57
--- /dev/null
+++ b/dfi/include/dyn_function.h
@@ -0,0 +1,60 @@
+/**
+ *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.
+ */
+#ifndef __DYN_FUNCTION_H_
+#define __DYN_FUNCTION_H_
+
+#include "dyn_type.h"
+#include "dfi_log_util.h"
+
+/**
+ * Uses the following schema
+ * (Name)([Type]*)Type
+ *
+ * Dyn fynction argument meta (am) as meta info, with the following possible values
+ * am=handle #void pointer for the handle
+ * am=pre #output pointer with memory preallocated
+ * am=out #output pointer
+ */
+
+typedef struct _dyn_function_type dyn_function_type;
+
+DFI_SETUP_LOG_HEADER(dynFunction);
+
+enum dyn_function_argument_meta {
+    DYN_FUNCTION_ARGUMENT_META__STD = 0,
+    DYN_FUNCTION_ARGUMENT_META__HANDLE = 1,
+    DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT = 2,
+    DYN_FUNCTION_ARGUMENT_META__OUTPUT = 3
+};
+
+int dynFunction_parse(FILE *descriptorStream, struct types_head *refTypes, dyn_function_type **dynFunc);
+int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **dynFunc);
+
+int dynFunction_nrOfArguments(dyn_function_type *dynFunc);
+dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr);
+enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr);
+dyn_type * dynFunction_returnType(dyn_function_type *dynFunction);
+
+void dynFunction_destroy(dyn_function_type *dynFunc);
+int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues);
+
+int dynFunction_createClosure(dyn_function_type *func, void (*bind)(void *, void **, void*), void *userData, void(**fn)(void));
+int dynFunction_getFnPointer(dyn_function_type *func, void (**fn)(void));
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/include/dyn_interface.h
----------------------------------------------------------------------
diff --git a/dfi/include/dyn_interface.h b/dfi/include/dyn_interface.h
new file mode 100644
index 0000000..54bf41c
--- /dev/null
+++ b/dfi/include/dyn_interface.h
@@ -0,0 +1,66 @@
+/**
+ *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.
+ */
+#ifndef __DYN_INTERFACE_H_
+#define __DYN_INTERFACE_H_
+
+#include "dyn_common.h"
+#include "dyn_type.h"
+#include "dyn_function.h"
+#include "dfi_log_util.h"
+
+#include "version.h"
+
+DFI_SETUP_LOG_HEADER(dynInterface);
+
+/* Description string
+ *
+ * Descriptor (interface) = HeaderSection AnnotationSection TypesSection MethodsSection
+ *
+ * HeaderSection=
+ * ':header\n' [NameValue]*
+ * ':annotations\n' [NameValue]*
+ * ':types\n' [TypeIdValue]*
+ * ':methods\n' [MethodIdValue]
+ *
+ */
+typedef struct _dyn_interface_type dyn_interface_type;
+
+TAILQ_HEAD(methods_head, method_entry);
+struct method_entry {
+    int index;
+    char *id;
+    char *name;
+    dyn_function_type *dynFunc;
+
+    TAILQ_ENTRY(method_entry) entries; 
+};
+
+int dynInterface_parse(FILE *descriptor, dyn_interface_type **out);
+void dynInterface_destroy(dyn_interface_type *intf);
+
+int dynInterface_getName(dyn_interface_type *intf, char **name);
+int dynInterface_getVersion(dyn_interface_type *intf, version_pt* version);
+int dynInterface_getVersionString(dyn_interface_type *intf, char **version);
+int dynInterface_getHeaderEntry(dyn_interface_type *intf, const char *name, char **value);
+int dynInterface_getAnnotationEntry(dyn_interface_type *intf, const char *name, char **value);
+int dynInterface_methods(dyn_interface_type *intf, struct methods_head **list);
+int dynInterface_nrOfMethods(dyn_interface_type *intf);
+
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/include/dyn_message.h
----------------------------------------------------------------------
diff --git a/dfi/include/dyn_message.h b/dfi/include/dyn_message.h
new file mode 100644
index 0000000..d1c8dd7
--- /dev/null
+++ b/dfi/include/dyn_message.h
@@ -0,0 +1,56 @@
+/**
+ *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.
+ */
+#ifndef __DYN_MESSAGE_H_
+#define __DYN_MESSAGE_H_
+
+#include "dyn_common.h"
+#include "dyn_type.h"
+#include "dfi_log_util.h"
+
+#include "version.h"
+
+DFI_SETUP_LOG_HEADER(dynMessage);
+
+/* Description string
+ *
+ * Descriptor (message) = HeaderSection AnnotationSection TypesSection MessageSection
+ *
+ * HeaderSection=
+ * ':header\n' [NameValue]*
+ * ':annotations\n' [NameValue]*
+ * ':types\n' [TypeIdValue]*
+ * ':message\n' [MessageIdValue]
+ *
+ */
+typedef struct _dyn_message_type dyn_message_type;
+
+
+int dynMessage_parse(FILE *descriptor, dyn_message_type **out);
+void dynMessage_destroy(dyn_message_type *msg);
+
+int dynMessage_getName(dyn_message_type *msg, char **name);
+int dynMessage_getVersion(dyn_message_type *msg, version_pt* version);
+int dynMessage_getVersionString(dyn_message_type *msg, char **version);
+int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value);
+int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value);
+int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type);
+
+
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/include/dyn_type.h
----------------------------------------------------------------------
diff --git a/dfi/include/dyn_type.h b/dfi/include/dyn_type.h
new file mode 100644
index 0000000..554966a
--- /dev/null
+++ b/dfi/include/dyn_type.h
@@ -0,0 +1,155 @@
+/**
+ *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.
+ */
+
+#ifndef _DYN_TYPE_H_
+#define _DYN_TYPE_H_
+
+#include <stdio.h>
+#include <sys/queue.h>
+#include <stdbool.h>
+
+#include <stdint.h>
+
+#include "dfi_log_util.h"
+
+#if defined(BSD) || defined(__APPLE__) || defined(__ANDROID__)
+#include "memstream/open_memstream.h"
+#include "memstream/fmemopen.h"
+#endif
+
+/* Description string
+ *
+ * Type = [TypeDef]* (MetaInfo)* (SimpleType | ComplexType | SequenceType | TypedPointer | PointerReference ) [TypeDef]*
+ * Name = alpha[(alpha|numeric)*]
+ * SPACE = ' ' 
+ *
+ * SimplesTypes (based on java bytecode method signatures)
+ * //Java based:
+ * B char
+ * C (not supported)
+ * D double
+ * F float
+ * I int32_t 
+ * J int64_t 
+ * S int16_t 
+ * V void
+ * Z boolean
+ * //Extended
+ * b unsigned char
+ * i uint32_t
+ * j uint62_t
+ * s uint64_t
+ * P untyped pointer (void *)
+ * t char* string
+ * N native int
+ *
+ * ComplexTypes (Struct)
+ * {[Type]+ [(Name)(SPACE)]+}
+ *
+ * ReferenceByValue
+ * l(name);
+ *
+ * PointerReference -> note shortcut for *l(name);
+ * L(Name);
+ *
+ * TypeDef 
+ * T(Name)=Type;
+ *
+ * SequenceType
+ * [(Type)
+ *
+ * TypedPointer
+ * *(Type)
+ *
+ * MetaInfo TODO
+ * #Name=Value;
+ *
+ *
+ *
+ * examples
+ * "{DDII a b c d}" -> struct { double a; double b; int c; int d; }; 
+ * "{DD{FF c1 c2} a b c}" -> struct { double a; double b; struct c { float c1; float c2; }; }; 
+ *
+ *
+ */
+
+#define DYN_TYPE_INVALID 0
+#define DYN_TYPE_SIMPLE 1
+#define DYN_TYPE_COMPLEX 2
+#define DYN_TYPE_SEQUENCE 3
+#define DYN_TYPE_TYPED_POINTER 4
+#define DYN_TYPE_TEXT 5
+#define DYN_TYPE_REF 6
+
+typedef struct _dyn_type dyn_type;
+
+TAILQ_HEAD(types_head, type_entry);
+struct type_entry {
+    dyn_type *type;
+    TAILQ_ENTRY(type_entry) entries;
+};
+
+TAILQ_HEAD(complex_type_entries_head, complex_type_entry);
+struct complex_type_entry {
+    dyn_type *type;
+    char *name;
+    TAILQ_ENTRY(complex_type_entry) entries;
+};
+
+//logging
+DFI_SETUP_LOG_HEADER(dynType);
+
+//generic
+int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *refTypes, dyn_type **type);
+int dynType_parseWithStr(const char *descriptor, const char *name, struct types_head *refTypes, dyn_type **type);
+void dynType_destroy(dyn_type *type);
+
+int dynType_alloc(dyn_type *type, void **bufLoc);
+void dynType_free(dyn_type *type, void *loc);
+
+void dynType_print(dyn_type *type, FILE *stream);
+size_t dynType_size(dyn_type *type);
+int dynType_type(dyn_type *type);
+int dynType_descriptorType(dyn_type *type);
+const char * dynType_getMetaInfo(dyn_type *type, const char *name);
+
+//complexType
+int dynType_complex_indexForName(dyn_type *type, const char *name);
+int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **subType);
+int dynType_complex_setValueAt(dyn_type *type, int index, void *inst, void *in);
+int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **valLoc);
+int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries);
+
+//sequence
+int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap);
+int dynType_sequence_locForIndex(dyn_type *type, void *seqLoc, int index, void **valLoc);
+int dynType_sequence_increaseLengthAndReturnLastLoc(dyn_type *type, void *seqLoc, void **valLoc);
+dyn_type * dynType_sequence_itemType(dyn_type *type);
+uint32_t dynType_sequence_length(void *seqLoc);
+
+//typed pointer
+int dynType_typedPointer_getTypedType(dyn_type *type, dyn_type **typedType);
+
+//text
+int dynType_text_allocAndInit(dyn_type *type, void *textLoc, const char *value);
+
+//simple
+void dynType_simple_setValue(dyn_type *type, void *inst, void *in);
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/include/json_rpc.h
----------------------------------------------------------------------
diff --git a/dfi/include/json_rpc.h b/dfi/include/json_rpc.h
new file mode 100644
index 0000000..1cc1464
--- /dev/null
+++ b/dfi/include/json_rpc.h
@@ -0,0 +1,37 @@
+/**
+ *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.
+ */
+#ifndef __JSON_RPC_H_
+#define __JSON_RPC_H_
+
+#include <jansson.h>
+#include "dfi_log_util.h"
+#include "dyn_type.h"
+#include "dyn_function.h"
+#include "dyn_interface.h"
+
+//logging
+DFI_SETUP_LOG_HEADER(jsonRpc);
+
+int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, char **out);
+
+
+int jsonRpc_prepareInvokeRequest(dyn_function_type *func, const char *id, void *args[], char **out);
+int jsonRpc_handleReply(dyn_function_type *func, const char *reply, void *args[]);
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/include/json_serializer.h
----------------------------------------------------------------------
diff --git a/dfi/include/json_serializer.h b/dfi/include/json_serializer.h
new file mode 100644
index 0000000..2f91f2b
--- /dev/null
+++ b/dfi/include/json_serializer.h
@@ -0,0 +1,37 @@
+/**
+ *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.
+ */
+#ifndef __JSON_SERIALIZER_H_
+#define __JSON_SERIALIZER_H_
+
+#include <jansson.h>
+#include "dfi_log_util.h"
+#include "dyn_type.h"
+#include "dyn_function.h"
+#include "dyn_interface.h"
+
+//logging
+DFI_SETUP_LOG_HEADER(jsonSerializer);
+
+int jsonSerializer_deserialize(dyn_type *type, const char *input, void **result);
+int jsonSerializer_deserializeJson(dyn_type *type, json_t *input, void **result);
+
+int jsonSerializer_serialize(dyn_type *type, const void* input, char **output);
+int jsonSerializer_serializeJson(dyn_type *type, const void* input, json_t **out);
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/dyn_common.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_common.c b/dfi/private/src/dyn_common.c
deleted file mode 100644
index ea8f425..0000000
--- a/dfi/private/src/dyn_common.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- *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.
- */
-#include "dyn_common.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdbool.h>
-
-#if defined(BSD) || defined(__APPLE__)  || defined(ANDROID)
-#include "open_memstream.h"
-#include "fmemopen.h"
-#endif
-
-static const int OK = 0;
-static const int ERROR = 1;
-
-DFI_SETUP_LOG(dynCommon)
-
-static bool dynCommon_charIn(int c, const char *acceptedChars);
-
-int dynCommon_parseName(FILE *stream, char **result) {
-    return dynCommon_parseNameAlsoAccept(stream, NULL, result);
-}
-
-int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result) {
-    int status = OK;
-
-    char *buf = NULL;
-    size_t size = 0;
-    int strLen = 0;
-    FILE *name = open_memstream(&buf, &size);
-
-    if (name != NULL) { 
-        int c = getc(stream);
-        while (isalnum(c) || c == '_' || dynCommon_charIn(c, acceptedChars)) {
-            fputc(c, name); 
-            c = getc(stream);
-            strLen += 1;
-        }
-        fflush(name);
-        fclose(name);
-        ungetc(c, stream);
-    } else {
-        status = ERROR;
-        LOG_ERROR("Error creating mem stream for name. %s", strerror(errno));
-    }
-
-    if (status == OK) {
-        if (strLen == 0) {
-            status = ERROR;
-            LOG_ERROR("Parsed empty name");
-        }
-    }
-
-    if (status == OK) {
-       LOG_DEBUG("Parsed name '%s'", buf);
-       *result = buf;
-    } else if (buf != NULL) {
-        free(buf);
-    }
-
-    return status;
-}
-
-int dynCommon_parseNameValue(FILE *stream, char **outName, char **outValue) {
-    int status;
-    char *name = NULL;
-    char *value = NULL;
-
-    status = dynCommon_parseName(stream, &name);
-    if (status == OK) {
-        status = dynCommon_eatChar(stream, '=');
-    }
-    if (status == OK) {
-        const char *valueAcceptedChars = ".<>{}[]?;:~!@#$%^&*()_+-=,./\\'\"";
-
-        status = dynCommon_parseNameAlsoAccept(stream, valueAcceptedChars, &value); //NOTE use different more lenient function e.g. only stop at '\n' ?
-    }
-
-    if (status == OK) {
-        *outName = name;
-        *outValue = value;
-    } else {
-        if (name != NULL) {
-            free(name);
-        }
-        if (value != NULL) {
-            free(value);
-        }
-    }
-    return status;
-}
-
-int dynCommon_eatChar(FILE *stream, int expected) {
-    int status = OK;
-    long loc = ftell(stream);
-    int c = fgetc(stream);
-    if (c != expected) {
-        status = ERROR;
-        LOG_ERROR("Error parsing, expected token '%c' got '%c' at position %li", expected, c, loc);
-    }
-    return status;
-}
-
-static bool dynCommon_charIn(int c, const char *acceptedChars) {
-    bool status = false;
-    if (acceptedChars != NULL) {
-        int i;
-        for (i = 0; acceptedChars[i] != '\0'; i += 1) {
-            if (c == acceptedChars[i]) {
-                status = true;
-                break;
-            }
-        }
-    }
-
-    return status;
-}
-
-void dynCommon_clearNamValHead(struct namvals_head *head) {
-    struct namval_entry *entry = TAILQ_FIRST(head);
-    while (entry != NULL) {
-        struct namval_entry *tmp = entry;
-
-        if (entry->name != NULL) {
-            free(entry->name);
-        }
-        if (entry->value != NULL) {
-            free(entry->value);
-        }
-        entry = TAILQ_NEXT(entry, entries);
-        free(tmp);
-    }
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/dyn_function.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_function.c b/dfi/private/src/dyn_function.c
deleted file mode 100644
index 615ad16..0000000
--- a/dfi/private/src/dyn_function.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/**
- *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.
- */
-#include "dyn_function.h"
-
-#include <strings.h>
-#include <stdlib.h>
-#include <ffi.h>
-
-#include "dyn_common.h"
-
-struct _dyn_function_type {
-    char *name;
-    struct types_head *refTypes; //NOTE not owned
-    TAILQ_HEAD(,_dyn_function_argument_type) arguments;
-    ffi_type **ffiArguments;
-    dyn_type *funcReturn;
-    ffi_cif cif;
-
-    //closure part
-    ffi_closure *ffiClosure;
-    void (*fn)(void);
-    void *userData;
-    void (*bind)(void *userData, void *args[], void *ret);
-};
-
-typedef struct _dyn_function_argument_type dyn_function_argument_type;
-struct _dyn_function_argument_type {
-    int index;
-    char *name;
-    enum dyn_function_argument_meta argumentMeta;
-    dyn_type *type;
-    TAILQ_ENTRY(_dyn_function_argument_type) entries;
-};
-
-static const int OK = 0;
-static const int MEM_ERROR = 1;
-static const int PARSE_ERROR = 2;
-static const int ERROR = 2;
-
-DFI_SETUP_LOG(dynFunction)
-
-static int dynFunction_initCif(dyn_function_type *dynFunc);
-static int dynFunction_parseDescriptor(dyn_function_type *dynFunc, FILE *descriptor);
-static void dynFunction_ffiBind(ffi_cif *cif, void *ret, void *args[], void *userData);
-
-extern ffi_type * dynType_ffiType(dyn_type *type);
-
-int dynFunction_parse(FILE *descriptor, struct types_head *refTypes, dyn_function_type **out) {
-    int status = OK;
-    dyn_function_type *dynFunc = NULL;
-    LOG_DEBUG("Creating dyn function", descriptor);
-    
-    dynFunc = calloc(1, sizeof(*dynFunc));
-
-    if (dynFunc != NULL) {
-        TAILQ_INIT(&dynFunc->arguments);
-        dynFunc->refTypes = refTypes;
-        status = dynFunction_parseDescriptor(dynFunc, descriptor);
-        if (status == 0) {
-            int rc = dynFunction_initCif(dynFunc);
-            if (rc != 0) {
-                LOG_ERROR("Error initializing cif");
-                status = ERROR;
-            }
-        }
-    } else {
-        LOG_ERROR("Error allocationg memory for dyn functipn\n");
-        status = MEM_ERROR;
-    }
-
-    if (status == OK) {
-        dyn_function_argument_type *arg = NULL;
-        TAILQ_FOREACH(arg, &dynFunc->arguments, entries) {
-            const char *meta = dynType_getMetaInfo(arg->type, "am");
-            if (meta == NULL) {
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__STD;
-            } else if (strcmp(meta, "handle") == 0) {
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__HANDLE;
-            } else if (strcmp(meta, "pre") == 0) {
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT;
-            } else if (strcmp(meta, "out") == 0) {
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__OUTPUT;
-            } else {
-                LOG_WARNING("unknown argument meta '%s' encountered", meta);
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__STD;
-            }
-        }
-    }
-    
-    if (status == OK) {
-        *out = dynFunc;
-    }    else {
-        if (dynFunc != NULL) {
-            dynFunction_destroy(dynFunc);
-        }
-
-    }
-    
-    return status;
-}
-
-int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **out)  {
-    int status = OK;
-    FILE *stream = fmemopen((char *)descriptor, strlen(descriptor), "r");
-    if (stream != NULL) {
-        status = dynFunction_parse(stream, refTypes, out);
-        fclose(stream);
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error creating mem stream for descriptor string. %s", strerror(errno)); 
-    }
-    return status;
-}
-
-static int dynFunction_parseDescriptor(dyn_function_type *dynFunc, FILE *descriptor) {
-    int status = OK;
-    char *name = NULL;
-
-    status = dynCommon_parseName(descriptor, &name);
-
-    if (status == OK) {
-        dynFunc->name = name;
-    }
-
-    if (status == OK) {
-        int c = fgetc(descriptor);
-        if ( c != '(') {
-            status = PARSE_ERROR;
-            LOG_ERROR("Expected '(' token got '%c'", c);
-        }
-    }
-
-    int nextChar = fgetc(descriptor);
-    int index = 0;
-    dyn_type *type = NULL;
-    char argName[32];
-    while (nextChar != ')' && status == 0)  {
-        ungetc(nextChar, descriptor);
-        type = NULL;
-
-        dyn_function_argument_type *arg = NULL;
-
-        status = dynType_parse(descriptor, NULL, dynFunc->refTypes, &type);
-        if (status == OK) {
-            arg = calloc(1, sizeof(*arg));
-            if (arg != NULL) {
-                arg->index = index;
-                arg->type = type;
-                snprintf(argName, 32, "arg%04i", index);
-                arg->name = strdup(argName);
-
-                index += 1;
-            } else {
-                LOG_ERROR("Error allocating memory");
-                status = MEM_ERROR;
-            }
-        }
-
-        if (status == OK) {
-            TAILQ_INSERT_TAIL(&dynFunc->arguments, arg, entries);
-        }
-
-        nextChar = fgetc(descriptor);
-    }
-
-    if (status == 0) {
-        status = dynType_parse(descriptor, NULL, dynFunc->refTypes, &dynFunc->funcReturn); 
-    }
-    
-    return status;
-}
-
-enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr) {
-    enum dyn_function_argument_meta result = 0;
-    dyn_function_argument_type *arg = NULL;
-    int index = 0;
-    TAILQ_FOREACH(arg, &dynFunc->arguments, entries) {
-        if (index == argumentNr) {
-            result = arg->argumentMeta;
-            break;
-        }
-        index += 1;
-    }
-    return result;
-}
-
-
-static int dynFunction_initCif(dyn_function_type *dynFunc) {
-    int status = 0;
-
-    int count = 0;
-    dyn_function_argument_type *entry = NULL;
-    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
-        count +=1;
-    }
-
-    dynFunc->ffiArguments = calloc(count, sizeof(ffi_type*));
-
-    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
-        dynFunc->ffiArguments[entry->index] = dynType_ffiType(entry->type);
-    }
-    
-    ffi_type **args = dynFunc->ffiArguments;
-    ffi_type *returnType = dynType_ffiType(dynFunc->funcReturn);
-
-    int ffiResult = ffi_prep_cif(&dynFunc->cif, FFI_DEFAULT_ABI, count, returnType, args);
-    if (ffiResult != FFI_OK) {
-        status = 1;
-    }
-
-    return status;
-}
-
-void dynFunction_destroy(dyn_function_type *dynFunc) {
-    if (dynFunc != NULL) {
-        if (dynFunc->funcReturn != NULL) {
-            dynType_destroy(dynFunc->funcReturn);
-        }
-        if (dynFunc->ffiClosure != NULL) {
-            ffi_closure_free(dynFunc->ffiClosure);
-        }
-        if (dynFunc->name != NULL) {
-            free(dynFunc->name);
-        }
-        if (dynFunc->ffiArguments != NULL) {
-            free(dynFunc->ffiArguments);
-        }
-        
-        dyn_function_argument_type *entry = NULL;
-        dyn_function_argument_type *tmp = NULL;
-        entry = TAILQ_FIRST(&dynFunc->arguments); 
-        while (entry != NULL) {
-            if (entry->name != NULL) {
-                free(entry->name);
-            }
-            dynType_destroy(entry->type);
-            tmp = entry;
-            entry = TAILQ_NEXT(entry, entries);
-            free(tmp);
-        }
-
-        free(dynFunc);
-    }
-}
-
-int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues) {
-    ffi_call(&dynFunc->cif, fn, returnValue, argValues);
-    return 0;
-}
-
-static void dynFunction_ffiBind(ffi_cif *cif, void *ret, void *args[], void *userData) {
-    dyn_function_type *dynFunc = userData;
-    dynFunc->bind(dynFunc->userData, args, ret);
-}
-
-int dynFunction_createClosure(dyn_function_type *dynFunc, void (*bind)(void *, void **, void*), void *userData, void(**out)(void)) {
-    int status = 0;
-    void (*fn)(void);
-    dynFunc->ffiClosure = ffi_closure_alloc(sizeof(ffi_closure), (void **)&fn);
-    if (dynFunc->ffiClosure != NULL) {
-        int rc = ffi_prep_closure_loc(dynFunc->ffiClosure, &dynFunc->cif, dynFunction_ffiBind, dynFunc, fn);
-        if (rc != FFI_OK) {
-            status = 1;
-        }
-    } else {
-        status = 2;
-    }
-
-    if (status == 0) {
-        dynFunc->userData = userData;
-        dynFunc->bind = bind;
-        dynFunc->fn = fn;
-        *out =fn;
-    }
-
-    return status;
-}
-
-int dynFunction_getFnPointer(dyn_function_type *dynFunc, void (**fn)(void)) {
-    int status = 0;
-    if (dynFunc != NULL && dynFunc->fn != NULL) {
-        (*fn) = dynFunc->fn;
-    } else {
-        status = 1;
-    }
-    return status;
-}
-
-int dynFunction_nrOfArguments(dyn_function_type *dynFunc) {
-    int count = 0;
-    dyn_function_argument_type *entry = NULL;
-    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
-        count += 1;
-    }
-    return count;
-}
-
-dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr) {
-    dyn_type *result = NULL;
-    int index = 0;
-    dyn_function_argument_type *entry = NULL;
-    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
-        if (index == argumentNr) {
-            result = entry->type;
-            break;
-        }
-        index +=1;
-    }
-    return result;
-}
-
-dyn_type * dynFunction_returnType(dyn_function_type *dynFunction) {
-    return dynFunction->funcReturn;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/dyn_interface.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_interface.c b/dfi/private/src/dyn_interface.c
deleted file mode 100644
index 63aafac..0000000
--- a/dfi/private/src/dyn_interface.c
+++ /dev/null
@@ -1,444 +0,0 @@
-/**
- *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.
- */
-#include "dyn_interface.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "dyn_common.h"
-#include "dyn_type.h"
-#include "dyn_interface.h"
-
-DFI_SETUP_LOG(dynInterface);
-
-struct _dyn_interface_type {
-    struct namvals_head header;
-    struct namvals_head annotations;
-    struct types_head types;
-    struct methods_head methods;
-    version_pt version;
-};
-
-static const int OK = 0;
-static const int ERROR = 1;
-
-static int dynInterface_parseSection(dyn_interface_type *intf, FILE *stream);
-static int dynInterface_parseAnnotations(dyn_interface_type *intf, FILE *stream);
-static int dynInterface_parseTypes(dyn_interface_type *intf, FILE *stream);
-static int dynInterface_parseMethods(dyn_interface_type *intf, FILE *stream);
-static int dynInterface_parseHeader(dyn_interface_type *intf, FILE *stream);
-static int dynInterface_parseNameValueSection(dyn_interface_type *intf, FILE *stream, struct namvals_head *head);
-static int dynInterface_checkInterface(dyn_interface_type *intf);
-static int dynInterface_getEntryForHead(struct namvals_head *head, const char *name, char **value);
-
-int dynInterface_parse(FILE *descriptor, dyn_interface_type **out) {
-    int status = OK;
-
-    dyn_interface_type *intf = calloc(1, sizeof(*intf));
-    if (intf != NULL) {
-        TAILQ_INIT(&intf->header);
-        TAILQ_INIT(&intf->annotations);
-        TAILQ_INIT(&intf->types);
-        TAILQ_INIT(&intf->methods);
-
-        char peek = (char)fgetc(descriptor);
-        while (peek == ':') {
-            ungetc(peek, descriptor);
-            status = dynInterface_parseSection(intf, descriptor);
-            if (status == OK) {
-                peek = (char)fgetc(descriptor);
-            } else {
-                break;
-            }
-        }
-
-        if (status == OK) {
-            status = dynCommon_eatChar(descriptor, EOF);
-        }
-
-        if (status == OK) {
-            status = dynInterface_checkInterface(intf);
-        }
-
-        if(status==OK){ /* We are sure that version field is present in the header */
-        	char* version=NULL;
-            dynInterface_getVersionString(intf,&version);
-            if(version!=NULL){
-            	status = (version_createVersionFromString(version,&(intf->version)) == CELIX_SUCCESS)?OK:ERROR;
-            }
-            if(status==ERROR){
-            	LOG_ERROR("Invalid version (%s) in parsed descriptor\n",version);
-            }
-        }
-    } else {
-        status = ERROR;
-        LOG_ERROR("Error allocating memory for dynamic interface\n");
-    }
-
-    if (status == OK) {
-        *out = intf;
-    } else if (intf != NULL) {
-        dynInterface_destroy(intf);
-    }
-    return status;
-}
-
-static int dynInterface_checkInterface(dyn_interface_type *intf) {
-    int status = OK;
-
-    //check header section
-    if (status == OK) {
-        bool foundType = false;
-        bool foundVersion = false;
-        bool foundName = false;
-        struct namval_entry *entry = NULL;
-        TAILQ_FOREACH(entry, &intf->header, entries) {
-            if (strcmp(entry->name, "type") == 0) {
-                foundType = true;
-            } else if (strcmp(entry->name, "version") == 0) {
-                foundVersion = true;
-            } else if (strcmp(entry->name, "name") == 0) {
-                foundName = true;
-            }
-        }
-
-        if (!foundType || !foundVersion || !foundName) {
-            status = ERROR;
-            LOG_ERROR("Parse Error. There must be a header section with a type, version and name entry");
-        }
-
-        struct method_entry *mEntry = NULL;
-        TAILQ_FOREACH(mEntry, &intf->methods, entries) {
-            dyn_type *type = dynFunction_returnType(mEntry->dynFunc);
-            int descriptor = dynType_descriptorType(type);
-            if (descriptor != 'N') {
-                status = ERROR;
-                LOG_ERROR("Parse Error. Only method with a return type 'N' (native int) are supported. Got return type '%c'\n", descriptor);
-                break;
-            }
-        }
-    }
-
-    return status;
-}
-
-static int dynInterface_parseSection(dyn_interface_type *intf, FILE *stream) {
-    int status = OK;
-    char *sectionName = NULL;
-
-    status = dynCommon_eatChar(stream, ':');
-
-    if (status == OK) {
-        status = dynCommon_parseName(stream, &sectionName);
-    }
-
-    if (status == OK) {
-        status = dynCommon_eatChar(stream, '\n');
-    }
-
-    if (status == OK) {
-        if (strcmp("header", sectionName) == 0) {
-            status = dynInterface_parseHeader(intf, stream);
-        } else if (strcmp("annotations", sectionName) == 0) {
-            status = dynInterface_parseAnnotations(intf, stream);
-        } else if (strcmp("types", sectionName) == 0) {
-            status = dynInterface_parseTypes(intf, stream);
-        } else if (strcmp("methods", sectionName) == 0) {
-            status = dynInterface_parseMethods(intf, stream);
-        } else {
-            status = ERROR;
-            LOG_ERROR("unsupported section '%s'", sectionName);
-        }
-    }
-
-    if (sectionName != NULL) {
-        free(sectionName);
-    }
-
-    return status;
-}
-
-static int dynInterface_parseHeader(dyn_interface_type *intf, FILE *stream) {
-    return dynInterface_parseNameValueSection(intf, stream, &intf->header);
-}
-
-static int dynInterface_parseAnnotations(dyn_interface_type *intf, FILE *stream) {
-    return dynInterface_parseNameValueSection(intf, stream, &intf->annotations);
-}
-
-static int dynInterface_parseNameValueSection(dyn_interface_type *intf, FILE *stream, struct namvals_head *head) {
-    int status = OK;
-
-    int peek = fgetc(stream);
-    while (peek != ':' && peek != EOF) {
-        ungetc(peek, stream);
-
-        char *name;
-        char *value;
-        status = dynCommon_parseNameValue(stream, &name, &value);
-
-        if (status == OK) {
-            status = dynCommon_eatChar(stream, '\n');
-        }
-
-        struct namval_entry *entry = NULL;
-        if (status == OK) {
-            entry = calloc(1, sizeof(*entry));
-            if (entry != NULL) {
-                entry->name = name;
-                entry->value = value;
-                TAILQ_INSERT_TAIL(head, entry, entries);
-            } else {
-                status = ERROR;
-                LOG_ERROR("Error allocating memory for namval entry");
-            }
-        }
-
-        if (status != OK) {
-            if (name != NULL) {
-                free(name);
-            }
-            if (value != NULL) {
-                free(value);
-            }
-            break;
-        }
-        peek = fgetc(stream);
-    }
-    ungetc(peek, stream);
-
-    return status;
-}
-
-static int dynInterface_parseTypes(dyn_interface_type *intf, FILE *stream) {
-    int status = OK;
-
-    //expected input (Name)=<Type>\n
-    int peek = fgetc(stream);
-    while (peek != ':' && peek != EOF) {
-        ungetc(peek, stream);
-
-        char *name;
-        status = dynCommon_parseName(stream, &name);
-
-        if (status == OK) {
-            status = dynCommon_eatChar(stream, '=');
-        }
-
-        dyn_type *type = NULL;
-        if (status == OK) {
-            dynType_parse(stream, name, &intf->types, &type);
-        }
-        if (name != NULL) {
-            free(name);
-        }
-
-        if (status == OK) {
-            status = dynCommon_eatChar(stream, '\n');
-        }
-
-        struct type_entry *entry = NULL;
-        if (status == OK) {
-            entry = calloc(1, sizeof(*entry));
-            if (entry != NULL) {
-                entry->type = type;
-                TAILQ_INSERT_TAIL(&intf->types, entry, entries);
-            } else {
-                status = ERROR;
-                LOG_ERROR("Error allocating memory for type entry");
-            }
-        }
-
-        if (status != OK) {
-            if (type != NULL) {
-                dynType_destroy(type);
-            }
-            break;
-        }
-        peek = fgetc(stream);
-    }
-    ungetc(peek, stream);
-
-    return status;
-}
-
-static int dynInterface_parseMethods(dyn_interface_type *intf, FILE *stream) {
-    int status = OK;
-
-    //expected input (Name)=<Method>\n
-    int peek = fgetc(stream);
-    int index = 0;
-    while (peek != ':' && peek != EOF) {
-        ungetc(peek, stream);
-
-        char *id;
-        status = dynCommon_parseNameAlsoAccept(stream, ".();[{}/", &id);
-
-        if (status == OK) {
-            status = dynCommon_eatChar(stream, '=');
-        }
-
-
-        dyn_function_type *func = NULL;
-        if (status == OK) {
-            status = dynFunction_parse(stream, &intf->types, &func);
-        }
-
-        if (status == OK) {
-            status = dynCommon_eatChar(stream, '\n');
-        }
-
-        struct method_entry *entry = NULL;
-        if (status == OK) {
-            entry = calloc(1, sizeof(*entry));
-            if (entry != NULL) {
-                entry->index = index++;
-                entry->id = id;
-                entry->dynFunc = func;
-                entry->name = strndup(id, 1024);
-                if (entry->name != NULL) {
-                    int i;
-                    for (i = 0; i < 1024; i += 1) {
-                        if (entry->name[i] == '\0') {
-                            break;
-                        } else if (entry->name[i] == '(') {
-                            entry->name[i] = '\0';
-                            break;
-                        }
-                    }
-                }
-                TAILQ_INSERT_TAIL(&intf->methods, entry, entries);
-            } else {
-                status = ERROR;
-                LOG_ERROR("Error allocating memory for method entry");
-            }
-        }
-
-        if (status != OK) {
-            if (id != NULL) {
-                free(id);
-            }
-            if (func != NULL) {
-                dynFunction_destroy(func);
-                //TODO free strIdentier, name
-            }
-            break;
-        }
-        peek = fgetc(stream);
-    }
-    ungetc(peek, stream);
-
-    return status;
-}
-
-void dynInterface_destroy(dyn_interface_type *intf) {
-    if (intf != NULL) {
-        dynCommon_clearNamValHead(&intf->header);
-        dynCommon_clearNamValHead(&intf->annotations);
-
-        struct method_entry *mInfo = TAILQ_FIRST(&intf->methods);
-        while (mInfo != NULL) {
-            struct method_entry *mTmp = mInfo;
-            mInfo = TAILQ_NEXT(mInfo, entries);
-            
-            if (mTmp->id != NULL) {
-                free(mTmp->id);
-            }
-            if (mTmp->name != NULL) {
-                free(mTmp->name);
-            }
-            if (mTmp->dynFunc != NULL) {
-                dynFunction_destroy(mTmp->dynFunc);
-            }
-            free(mTmp);
-        }
-
-        struct type_entry *tInfo = TAILQ_FIRST(&intf->types);
-        while (tInfo != NULL) {
-            struct type_entry *tmp = tInfo;
-            tInfo = TAILQ_NEXT(tInfo, entries);
-            dynType_destroy(tmp->type);
-            free(tmp);
-        }
-
-        if(intf->version!=NULL){
-        	version_destroy(intf->version);
-        }
-
-        free(intf);
-    } 
-}
-
-int dynInterface_getName(dyn_interface_type *intf, char **out) {
-    return dynInterface_getEntryForHead(&intf->header, "name", out);
-}
-
-int dynInterface_getVersion(dyn_interface_type* intf , version_pt* version){
-	*version = intf->version;
-	if(*version==NULL){
-		return ERROR;
-	}
-	return OK;
-}
-
-int dynInterface_getVersionString(dyn_interface_type *intf, char **version) {
-    return dynInterface_getEntryForHead(&intf->header, "version", version);
-}
-
-int dynInterface_getHeaderEntry(dyn_interface_type *intf, const char *name, char **value) {
-    return dynInterface_getEntryForHead(&intf->header, name, value);
-}
-
-int dynInterface_getAnnotationEntry(dyn_interface_type *intf, const char *name, char **value) {
-    return dynInterface_getEntryForHead(&intf->annotations, name, value);
-}
-
-static int dynInterface_getEntryForHead(struct namvals_head *head, const char *name, char **out) {
-    int status = OK;
-    char *value = NULL;
-    struct namval_entry *entry = NULL;
-    TAILQ_FOREACH(entry, head, entries) {
-        if (strcmp(name, entry->name) == 0) {
-            value = entry->value;
-            break;
-        }
-    }
-    if (value != NULL) {
-        *out = value;
-    } else {
-        status = ERROR;
-        LOG_WARNING("Cannot find '%s' in list", name);
-    }
-    return status;
-}
-
-int dynInterface_methods(dyn_interface_type *intf, struct methods_head **list) {
-    int status = OK;
-    *list = &intf->methods;
-    return status;
-}
-
-int dynInterface_nrOfMethods(dyn_interface_type *intf) {
-    int count = 0;
-    struct method_entry *entry = NULL;
-    TAILQ_FOREACH(entry, &intf->methods, entries) {
-        count +=1;
-    }
-    return count;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/dyn_message.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_message.c b/dfi/private/src/dyn_message.c
deleted file mode 100644
index 652be83..0000000
--- a/dfi/private/src/dyn_message.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/**
- *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.
- */
-#include "dyn_message.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "dyn_common.h"
-#include "dyn_type.h"
-
-DFI_SETUP_LOG(dynMessage);
-
-struct _dyn_message_type {
-    struct namvals_head header;
-    struct namvals_head annotations;
-    struct types_head types;
-    dyn_type *msgType;
-    version_pt msgVersion;
-};
-
-static const int OK = 0;
-static const int ERROR = 1;
-
-static int dynMessage_parseSection(dyn_message_type *msg, FILE *stream);
-static int dynMessage_parseAnnotations(dyn_message_type *msg, FILE *stream);
-static int dynMessage_parseTypes(dyn_message_type *msg, FILE *stream);
-static int dynMessage_parseMessage(dyn_message_type *msg, FILE *stream);
-static int dynMessage_parseHeader(dyn_message_type *msg, FILE *stream);
-static int dynMessage_parseNameValueSection(dyn_message_type *msg, FILE *stream, struct namvals_head *head);
-static int dynMessage_checkMessage(dyn_message_type *msg);
-static int dynMessage_getEntryForHead(struct namvals_head *head, const char *name, char **value);
-
-int dynMessage_parse(FILE *descriptor, dyn_message_type **out) {
-    int status = OK;
-
-    dyn_message_type *msg = calloc(1, sizeof(*msg));
-    if (msg != NULL) {
-        TAILQ_INIT(&msg->header);
-        TAILQ_INIT(&msg->annotations);
-        TAILQ_INIT(&msg->types);
-
-        char peek = (char)fgetc(descriptor);
-        while (peek == ':') {
-            ungetc(peek, descriptor);
-            status = dynMessage_parseSection(msg, descriptor);
-            if (status == OK) {
-                peek = (char)fgetc(descriptor);
-            } else {
-                break;
-            }
-        }
-
-        if (status == OK) {
-            status = dynCommon_eatChar(descriptor, EOF);
-        }
-
-        if (status == OK) {
-            status = dynMessage_checkMessage(msg);
-        }
-
-        if(status==OK){ /* We are sure that version field is present in the header */
-        	char* version=NULL;
-        	dynMessage_getVersionString(msg,&version);
-        	if(version!=NULL){
-        		status = (version_createVersionFromString(version,&(msg->msgVersion)) == CELIX_SUCCESS)?OK:ERROR;
-        	}
-        	if(status==ERROR){
-        		LOG_ERROR("Invalid version (%s) in parsed descriptor\n",version);
-        	}
-        }
-
-    } else {
-        status = ERROR;
-        LOG_ERROR("Error allocating memory for dynamic message\n");
-    }
-
-    if (status == OK) {
-        *out = msg;
-    } else if (msg != NULL) {
-        LOG_ERROR("Error parsing msg\n");
-        dynMessage_destroy(msg);
-    }
-    return status;
-}
-
-static int dynMessage_checkMessage(dyn_message_type *msg) {
-    int status = OK;
-
-    //check header section
-    if (status == OK) {
-        bool foundType = false;
-        bool foundVersion = false;
-        bool foundName = false;
-        struct namval_entry *entry = NULL;
-        TAILQ_FOREACH(entry, &msg->header, entries) {
-            if (strcmp(entry->name, "type") == 0) {
-                foundType = true;
-            } else if (strcmp(entry->name, "version") == 0) {
-                foundVersion = true;
-            } else if (strcmp(entry->name, "name") == 0) {
-                foundName = true;
-            }
-        }
-
-        if (!foundType || !foundVersion || !foundName) {
-            status = ERROR;
-            LOG_ERROR("Parse Error. There must be a header section with a type, version and name entry");
-        }
-    }
-
-    return status;
-}
-
-static int dynMessage_parseSection(dyn_message_type *msg, FILE *stream) {
-    int status;
-    char *sectionName = NULL;
-
-    status = dynCommon_eatChar(stream, ':');
-
-    if (status == OK) {
-        status = dynCommon_parseName(stream, &sectionName);
-    }
-
-    if (status == OK) {
-        status = dynCommon_eatChar(stream, '\n');
-    }
-
-    if (status == OK) {
-        if (strcmp("header", sectionName) == 0) {
-            status = dynMessage_parseHeader(msg, stream);
-        } else if (strcmp("annotations", sectionName) == 0) {
-            status = dynMessage_parseAnnotations(msg, stream);
-        } else if (strcmp("types", sectionName) == 0) {
-            status = dynMessage_parseTypes(msg, stream);
-        } else if (strcmp("message", sectionName) == 0) {
-            status = dynMessage_parseMessage(msg, stream);
-        } else {
-            status = ERROR;
-            LOG_ERROR("unsupported section '%s'", sectionName);
-        }
-    }
-
-    if (sectionName != NULL) {
-        free(sectionName);
-    }
-
-    return status;
-}
-
-static int dynMessage_parseHeader(dyn_message_type *msg, FILE *stream) {
-    return dynMessage_parseNameValueSection(msg, stream, &msg->header);
-}
-
-static int dynMessage_parseAnnotations(dyn_message_type *msg, FILE *stream) {
-    return dynMessage_parseNameValueSection(msg, stream, &msg->annotations);
-}
-
-static int dynMessage_parseNameValueSection(dyn_message_type *msg, FILE *stream, struct namvals_head *head) {
-    int status = OK;
-
-    int peek = fgetc(stream);
-    while (peek != ':' && peek != EOF) {
-        ungetc(peek, stream);
-
-        char *name;
-        char *value;
-        status = dynCommon_parseNameValue(stream, &name, &value);
-
-        if (status == OK) {
-            status = dynCommon_eatChar(stream, '\n');
-        }
-
-        struct namval_entry *entry = NULL;
-        if (status == OK) {
-            entry = calloc(1, sizeof(*entry));
-            if (entry != NULL) {
-                entry->name = name;
-                entry->value = value;
-                TAILQ_INSERT_TAIL(head, entry, entries);
-            } else {
-                status = ERROR;
-                LOG_ERROR("Error allocating memory for namval entry");
-            }
-        }
-
-        if (status != OK) {
-            if (name != NULL) {
-                free(name);
-            }
-            if (value != NULL) {
-                free(value);
-            }
-            break;
-        }
-        peek = fgetc(stream);
-    }
-    ungetc(peek, stream);
-
-    return status;
-}
-
-static int dynMessage_parseTypes(dyn_message_type *msg, FILE *stream) {
-    int status = OK;
-
-    //expected input (Name)=<Type>\n
-    int peek = fgetc(stream);
-    while (peek != ':' && peek != EOF) {
-        ungetc(peek, stream);
-
-        char *name = NULL;
-        status = dynCommon_parseName(stream, &name);
-
-        if (status == OK) {
-            status = dynCommon_eatChar(stream, '=');
-        }
-
-        dyn_type *type = NULL;
-        if (status == OK) {
-            status = dynType_parse(stream, name, &msg->types, &type);
-        }
-
-        if (status == OK) {
-            status = dynCommon_eatChar(stream, '\n');
-        }
-
-        struct type_entry *entry = NULL;
-        if (status == OK) {
-            entry = calloc(1, sizeof(*entry));
-            if (entry != NULL) {
-                LOG_DEBUG("Adding type '%s' with pointer %p to types", name, type);
-                entry->type = type;
-                TAILQ_INSERT_TAIL(&msg->types, entry, entries);
-            } else {
-                status = ERROR;
-                LOG_ERROR("Error allocating memory for type entry");
-            }
-        }
-
-        if (name != NULL) {
-            free(name);
-        }
-
-        if (status != OK) {
-            if (type != NULL) {
-                dynType_destroy(type);
-            }
-            break;
-        }
-        peek = fgetc(stream);
-    }
-    ungetc(peek, stream);
-
-    return status;
-}
-
-static int dynMessage_parseMessage(dyn_message_type *msg, FILE *stream) {
-    int status;
-
-    //expected input <dynType>\n
-    char *name = NULL;
-    status = dynMessage_getName(msg, &name);
-
-    if (status == OK) {
-    	status = dynType_parse(stream, name, &(msg->types), &(msg->msgType));
-    }
-
-    return status;
-}
-
-void dynMessage_destroy(dyn_message_type *msg) {
-    if (msg != NULL) {
-        dynCommon_clearNamValHead(&msg->header);
-        dynCommon_clearNamValHead(&msg->annotations);
-
-        struct type_entry *tInfo = TAILQ_FIRST(&msg->types);
-        while (tInfo != NULL) {
-            struct type_entry *tmp = tInfo;
-            tInfo = TAILQ_NEXT(tInfo, entries);
-            dynType_destroy(tmp->type);
-            free(tmp);
-        }
-
-        if (msg->msgType != NULL) {
-        	dynType_destroy(msg->msgType);
-        }
-
-        if(msg->msgVersion != NULL){
-        	version_destroy(msg->msgVersion);
-        }
-
-        free(msg);
-    } 
-}
-
-int dynMessage_getName(dyn_message_type *msg, char **out) {
-    return dynMessage_getEntryForHead(&msg->header, "name", out);
-}
-
-int dynMessage_getVersion(dyn_message_type *msg, version_pt* version){
-	*version = msg->msgVersion;
-	if(*version==NULL){
-		return ERROR;
-	}
-	return OK;
-}
-
-int dynMessage_getVersionString(dyn_message_type *msg, char **version) {
-    return dynMessage_getEntryForHead(&msg->header, "version", version);
-}
-
-int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value) {
-    return dynMessage_getEntryForHead(&msg->header, name, value);
-}
-
-int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value) {
-    return dynMessage_getEntryForHead(&msg->annotations, name, value);
-}
-
-static int dynMessage_getEntryForHead(struct namvals_head *head, const char *name, char **out) {
-    int status = OK;
-    char *value = NULL;
-    struct namval_entry *entry = NULL;
-    TAILQ_FOREACH(entry, head, entries) {
-        if (strcmp(name, entry->name) == 0) {
-            value = entry->value;
-            break;
-        }
-    }
-    if (value != NULL) {
-        *out = value;
-    } else {
-        status = ERROR;
-        LOG_WARNING("Cannot find '%s' in list", name);
-    }
-    return status;
-}
-
-int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type) {
-	int status = OK;
-	*type = msg->msgType;
-	return status;
-}


[39/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/deployment_admin.c
----------------------------------------------------------------------
diff --git a/deployment_admin/src/deployment_admin.c b/deployment_admin/src/deployment_admin.c
new file mode 100644
index 0000000..17e78db
--- /dev/null
+++ b/deployment_admin/src/deployment_admin.c
@@ -0,0 +1,809 @@
+/**
+ *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.
+ */
+/*
+ * deployment_admin.c
+ *
+ *  \date       Nov 7, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdint.h>
+
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <curl/curl.h>
+#include <curl/easy.h>
+
+#include <uuid/uuid.h>
+
+#include "celixbool.h"
+#include "deployment_admin.h"
+#include "celix_errno.h"
+#include "bundle_context.h"
+#include "constants.h"
+#include "deployment_package.h"
+#include "bundle.h"
+#include "utils.h"
+
+#include "log.h"
+#include "log_store.h"
+#include "log_sync.h"
+
+#include "resource_processor.h"
+#include "miniunz.h"
+
+#define IDENTIFICATION_ID "deployment_admin_identification"
+#define DEFAULT_IDENTIFICATION_ID "celix"
+
+#define ADMIN_URL "deployment_admin_url"
+#define DEFAULT_ADMIN_URL "localhost:8080"
+
+#define DEPLOYMENT_CACHE_DIR "deployment_cache_dir"
+#define DEPLOYMENT_TAGS "deployment_tags"
+// "http://localhost:8080/deployment/"
+
+#define VERSIONS "/versions"
+
+static void* deploymentAdmin_poll(void *deploymentAdmin);
+celix_status_t deploymentAdmin_download(deployment_admin_pt admin, char * url, char **inputFile);
+size_t deploymentAdmin_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream);
+static celix_status_t deploymentAdmin_deleteTree(char * directory);
+celix_status_t deploymentAdmin_readVersions(deployment_admin_pt admin, array_list_pt versions);
+
+celix_status_t deploymentAdmin_stopDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt target);
+celix_status_t deploymentAdmin_updateDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source);
+celix_status_t deploymentAdmin_startDeploymentPackageCustomizerBundles(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target);
+celix_status_t deploymentAdmin_processDeploymentPackageResources(deployment_admin_pt admin, deployment_package_pt source);
+celix_status_t deploymentAdmin_dropDeploymentPackageResources(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target);
+celix_status_t deploymentAdmin_dropDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target);
+celix_status_t deploymentAdmin_startDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source);
+
+static celix_status_t deploymentAdmin_performRequest(deployment_admin_pt admin, char* entry);
+static celix_status_t deploymentAdmin_auditEventTargetPropertiesSet(deployment_admin_pt admin);
+static celix_status_t deploymentAdmin_auditEventFrameworkStarted(deployment_admin_pt admin);
+
+celix_status_t deploymentAdmin_create(bundle_context_pt context, deployment_admin_pt *admin) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*admin = calloc(1, sizeof(**admin));
+	if (!*admin) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*admin)->running = true;
+		(*admin)->context = context;
+		(*admin)->current = NULL;
+		(*admin)->packages = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+		(*admin)->targetIdentification = NULL;
+		(*admin)->pollUrl = NULL;
+		(*admin)->auditlogUrl = NULL;
+
+        bundleContext_getProperty(context, IDENTIFICATION_ID, (const char**) &(*admin)->targetIdentification);
+        if ((*admin)->targetIdentification == NULL) {
+        	(*admin)->targetIdentification = DEFAULT_IDENTIFICATION_ID;
+        	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Identification ID not set, using default '%s'. Set id by using '%s'",
+        		DEFAULT_IDENTIFICATION_ID, IDENTIFICATION_ID);
+        }
+
+        struct timeval tv;
+		gettimeofday(&tv,NULL);
+		(*admin)->auditlogId =  tv.tv_sec*(uint64_t)1000000+tv.tv_usec;
+        (*admin)->aditlogSeqNr = 0;
+
+		if ((*admin)->targetIdentification == NULL ) {
+		    fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Target name must be set using \"deployment_admin_identification\"");
+		} else {
+			const char *url = NULL;
+			bundleContext_getProperty(context, ADMIN_URL, &url);
+			if (url == NULL) {
+				url = DEFAULT_ADMIN_URL;
+			    fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Server URL is not set, using default '%s'. Set id by using '%s'",
+        			DEFAULT_ADMIN_URL, ADMIN_URL);
+			}
+		
+			int pollUrlLength = strlen(url) + strlen((*admin)->targetIdentification) + strlen(VERSIONS) + 13;
+			int auditlogUrlLength = strlen(url) + 10;
+
+			char pollUrl[pollUrlLength];
+			char auditlogUrl[auditlogUrlLength];
+
+			snprintf(pollUrl, pollUrlLength, "%s/deployment/%s%s", url, (*admin)->targetIdentification, VERSIONS);
+			snprintf(auditlogUrl, auditlogUrlLength, "%s/auditlog", url);
+
+			(*admin)->pollUrl = strdup(pollUrl);
+			(*admin)->auditlogUrl = strdup(auditlogUrl);
+
+//				log_store_pt store = NULL;
+//				log_pt log = NULL;
+//				log_sync_pt sync = NULL;
+//				logStore_create(subpool, &store);
+//				log_create(subpool, store, &log);
+//				logSync_create(subpool, (*admin)->targetIdentification, store, &sync);
+//
+//				log_log(log, 20000, NULL);
+
+
+			celixThread_create(&(*admin)->poller, NULL, deploymentAdmin_poll, *admin);
+		}
+	}
+
+	return status;
+}
+
+
+
+celix_status_t deploymentAdmin_destroy(deployment_admin_pt admin) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    admin->running = false;
+
+    celixThread_join(admin->poller, NULL);
+
+	hash_map_iterator_pt iter = hashMapIterator_create(admin->packages);
+
+	while (hashMapIterator_hasNext(iter)) {
+		deployment_package_pt target = (deployment_package_pt) hashMapIterator_nextValue(iter);
+		deploymentPackage_destroy(target);
+	}
+
+	hashMapIterator_destroy(iter);
+
+	hashMap_destroy(admin->packages, false, false);
+
+	if (admin->current != NULL) {
+		free(admin->current);
+	}
+
+	free(admin->pollUrl);
+	free(admin->auditlogUrl);
+
+	free(admin);
+
+	return status;
+}
+
+
+static celix_status_t deploymentAdmin_performRequest(deployment_admin_pt admin, char* entry) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    CURL *curl;
+    CURLcode res;
+    curl = curl_easy_init();
+
+    if (!curl) {
+        status = CELIX_BUNDLE_EXCEPTION;
+
+        fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error initializing curl.");
+    }
+
+    char url[strlen(admin->auditlogUrl)+6];
+    sprintf(url, "%s/send", admin->auditlogUrl);
+
+    if (status == CELIX_SUCCESS) {
+            curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+            curl_easy_setopt(curl, CURLOPT_URL, url);
+            curl_easy_setopt(curl, CURLOPT_POSTFIELDS, entry);
+            res = curl_easy_perform(curl);
+
+            if (res != CURLE_OK ) {
+                status = CELIX_BUNDLE_EXCEPTION;
+                fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error sending auditlog, got curl error code %d", res);
+            }
+    }
+
+    return status;
+}
+
+static celix_status_t deploymentAdmin_auditEventTargetPropertiesSet(deployment_admin_pt admin) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    const char *tags = NULL;
+
+    bundleContext_getProperty(admin->context, DEPLOYMENT_TAGS, &tags);
+
+    if (tags != NULL) {
+        char entry[512];
+        int entrySize = 0;
+
+        entrySize = snprintf(entry, 512, "%s,%llu,%u,0,%i,%s\n", admin->targetIdentification, admin->auditlogId, admin->aditlogSeqNr++, DEPLOYMENT_ADMIN_AUDIT_EVENT__TARGETPROPERTIES_SET, tags);
+
+        if (entrySize >= 512) {
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+        else {
+            status = deploymentAdmin_performRequest(admin, entry);
+        }
+    }
+
+    return status;
+}
+
+static celix_status_t deploymentAdmin_auditEventFrameworkStarted(deployment_admin_pt admin) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    char entry[512];
+    int entrySize = 0;
+
+    entrySize = snprintf(entry, 512, "%s,%llu,%u,0,%i\n", admin->targetIdentification, admin->auditlogId, admin->aditlogSeqNr++, DEPLOYMENT_ADMIN_AUDIT_EVENT__FRAMEWORK_STARTED);
+
+    if (entrySize >= 512) {
+        status = CELIX_BUNDLE_EXCEPTION;
+    }
+    else {
+        status = deploymentAdmin_performRequest(admin, entry);
+    }
+
+    return status;
+}
+
+
+static void *deploymentAdmin_poll(void *deploymentAdmin) {
+	deployment_admin_pt admin = deploymentAdmin;
+
+	/*first poll send framework started audit event, note this will register the target in Apache ACE*/
+    deploymentAdmin_auditEventFrameworkStarted(admin);
+    deploymentAdmin_auditEventTargetPropertiesSet(admin);
+
+	while (admin->running) {
+        int i;
+
+		//poll ace
+		array_list_pt versions = NULL;
+	    arrayList_create(&versions);
+
+		deploymentAdmin_readVersions(admin, versions);
+
+		char *last = arrayList_get(versions, arrayList_size(versions) - 1);
+
+		if (last != NULL) {
+			if (admin->current == NULL || strcmp(last, admin->current) != 0) {
+				int length = strlen(admin->pollUrl) + strlen(last) + 2;
+				char request[length];
+
+				// TODO
+                //      We do not yet support fix packages
+                //		Check string lenght!
+                // snprintf(request, length, "%s/%s?current=%s", admin->pollUrl, last, admin->current);
+                snprintf(request, length, "%s/%s", admin->pollUrl, last);
+
+				char *inputFilename = NULL;
+				celix_status_t status = deploymentAdmin_download(admin ,request, &inputFilename);
+				if (status == CELIX_SUCCESS) {
+					bundle_pt bundle = NULL;
+					bundleContext_getBundle(admin->context, &bundle);
+					char *entry = NULL;
+					bundle_getEntry(bundle, "/", &entry);
+
+					// Handle file
+					char tmpDir[256];
+					char uuid[37];
+					uuid_t uid;
+					uuid_generate(uid);
+					uuid_unparse(uid, uuid);
+                    snprintf(tmpDir, 256, "%s%s", entry, uuid);
+                    if( mkdir(tmpDir, S_IRWXU) == -1){
+                        fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Failed creating directory %s",tmpDir);
+                    }
+
+					// TODO: update to use bundle cache DataFile instead of module entries.
+					unzip_extractDeploymentPackage(inputFilename, tmpDir);
+					int length = strlen(tmpDir) + 22;
+					char manifest[length];
+					snprintf(manifest, length, "%s/META-INF/MANIFEST.MF", tmpDir);
+					manifest_pt mf = NULL;
+					manifest_createFromFile(manifest, &mf);
+					deployment_package_pt source = NULL;
+					deploymentPackage_create(admin->context, mf, &source);
+					const char *name = NULL;
+					deploymentPackage_getName(source, &name);
+
+					int repoDirLength = strlen(entry) + 5;
+					char repoDir[repoDirLength];
+					snprintf(repoDir, repoDirLength, "%srepo", entry);
+					if( mkdir(repoDir, S_IRWXU) == -1){
+						fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Failed creating directory %s",repoDir);
+					}
+
+					int repoCacheLength = strlen(entry) + strlen(name) + 6;
+					char repoCache[repoCacheLength];
+					snprintf(repoCache, repoCacheLength, "%srepo/%s", entry, name);
+					deploymentAdmin_deleteTree(repoCache);
+					int stat = rename(tmpDir, repoCache);
+					if (stat != 0) {
+						fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "No success");
+					}
+
+					deployment_package_pt target = hashMap_get(admin->packages, name);
+					if (target == NULL) {
+//						target = empty package
+					}
+
+					deploymentAdmin_stopDeploymentPackageBundles(admin, target);
+					deploymentAdmin_updateDeploymentPackageBundles(admin, source);
+					deploymentAdmin_startDeploymentPackageCustomizerBundles(admin, source, target);
+					deploymentAdmin_processDeploymentPackageResources(admin, source);
+					deploymentAdmin_dropDeploymentPackageResources(admin, source, target);
+					deploymentAdmin_dropDeploymentPackageBundles(admin, source, target);
+					deploymentAdmin_startDeploymentPackageBundles(admin, source);
+
+					deploymentAdmin_deleteTree(repoCache);
+					deploymentAdmin_deleteTree(tmpDir);
+					if( remove(inputFilename) == -1){
+						fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Remove of %s failed",inputFilename);
+					}
+					admin->current = strdup(last);
+					hashMap_put(admin->packages, (char*)name, source);
+
+                    free(entry);
+				}
+				if (inputFilename != NULL) {
+					free(inputFilename);
+				}
+			}
+		}
+
+		sleep(5);
+
+		for (i = arrayList_size(versions); i > 0; --i) {
+		    free(arrayList_remove(versions, 0));
+		}
+
+		arrayList_destroy(versions);
+	}
+
+	return NULL;
+}
+
+struct MemoryStruct {
+	char *memory;
+	size_t size;
+};
+
+size_t deploymentAdmin_parseVersions(void *contents, size_t size, size_t nmemb, void *userp) {
+	size_t realsize = size * nmemb;
+	struct MemoryStruct *mem = (struct MemoryStruct *)userp;
+
+	mem->memory = realloc(mem->memory, mem->size + realsize + 1);
+	if (mem->memory == NULL) {
+		/* out of memory! */
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "not enough memory (realloc returned NULL)");
+		exit(EXIT_FAILURE);
+	}
+
+	memcpy(&(mem->memory[mem->size]), contents, realsize);
+	mem->size += realsize;
+	mem->memory[mem->size] = 0;
+
+	return realsize;
+}
+
+celix_status_t deploymentAdmin_readVersions(deployment_admin_pt admin, array_list_pt versions) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	CURL *curl;
+	CURLcode res;
+	curl = curl_easy_init();
+	struct MemoryStruct chunk;
+	chunk.memory = calloc(1, sizeof(char));
+	chunk.size = 0;
+	if (curl) {
+	    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+		curl_easy_setopt(curl, CURLOPT_URL, admin->pollUrl);
+		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, deploymentAdmin_parseVersions);
+		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunk);
+		curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
+		res = curl_easy_perform(curl);
+		if (res != CURLE_OK) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+		/* always cleanup */
+		curl_easy_cleanup(curl);
+
+		char *last;
+		char *token = strtok_r(chunk.memory, "\n", &last);
+		while (token != NULL) {
+			arrayList_add(versions, strdup(token));
+			token = strtok_r(NULL, "\n", &last);
+		}
+	}
+
+    if (chunk.memory) {
+        free(chunk.memory);
+    }
+
+	return status;
+}
+
+
+celix_status_t deploymentAdmin_download(deployment_admin_pt admin, char * url, char **inputFile) {
+	celix_status_t status = CELIX_SUCCESS;
+	CURL *curl = NULL;
+	CURLcode res = 0;
+	curl = curl_easy_init();
+	if (curl) {
+		const char *dir = NULL;
+		bundleContext_getProperty(admin->context, DEPLOYMENT_CACHE_DIR, &dir);
+		if (dir != NULL) {
+			*inputFile = calloc(1024, sizeof (char));
+			snprintf(*inputFile, 1024, "%s/%s", dir, "updateXXXXXX");
+		}
+		else {
+			*inputFile = strdup("updateXXXXXX");
+		}
+		umask(0011);
+        int fd = mkstemp(*inputFile);
+        if (fd != -1) {
+            FILE *fp = fopen(*inputFile, "wb+");
+            if(fp!=NULL){
+            	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+            	curl_easy_setopt(curl, CURLOPT_URL, url);
+            	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, deploymentAdmin_writeData);
+            	curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
+            	curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
+            	//curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
+            	//curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, updateCommand_downloadProgress);
+            	res = curl_easy_perform(curl);
+
+            	/* always cleanup */
+            	curl_easy_cleanup(curl);
+            	fclose(fp);
+            }
+            else{
+            	status = CELIX_FILE_IO_EXCEPTION;
+            }
+        }
+        else{
+        	status = CELIX_FILE_IO_EXCEPTION;
+        }
+	}
+	else{
+		res = CURLE_FAILED_INIT;
+	}
+
+	if (res != CURLE_OK) {
+		*inputFile[0] = '\0';
+		status = CELIX_ILLEGAL_STATE;
+	}
+
+	return status;
+}
+
+size_t deploymentAdmin_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream) {
+    size_t written = fwrite(ptr, size, nmemb, stream);
+    return written;
+}
+
+
+static celix_status_t deploymentAdmin_deleteTree(char * directory) {
+	DIR *dir;
+	celix_status_t status = CELIX_SUCCESS;
+	dir = opendir(directory);
+	if (dir == NULL) {
+	    status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+
+		struct dirent* dent = NULL;
+
+		errno = 0;
+		dent = readdir(dir);
+		while (errno == 0 && dent != NULL) {
+			if ((strcmp((dent->d_name), ".") != 0) && (strcmp((dent->d_name), "..") != 0)) {
+				char subdir[512];
+				snprintf(subdir, sizeof(subdir), "%s/%s", directory, dent->d_name);
+
+				if (dent->d_type == DT_DIR) {
+					status = deploymentAdmin_deleteTree(subdir);
+				} else {
+					if (remove(subdir) != 0) {
+						status = CELIX_FILE_IO_EXCEPTION;
+						break;
+					}
+				}
+			}
+
+			errno = 0;
+			dent = readdir(dir);
+		}
+
+		if (errno != 0) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else if (closedir(dir) != 0) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else if (rmdir(directory) != 0) {
+				status = CELIX_FILE_IO_EXCEPTION;
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to delete tree");
+
+	return status;
+}
+
+celix_status_t deploymentAdmin_stopDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt target) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (target != NULL) {
+		array_list_pt infos = NULL;
+		deploymentPackage_getBundleInfos(target, &infos);
+		int i;
+		for (i = 0; i < arrayList_size(infos); i++) {
+			bundle_pt bundle = NULL;
+			bundle_info_pt info = arrayList_get(infos, i);
+			deploymentPackage_getBundle(target, info->symbolicName, &bundle);
+			if (bundle != NULL) {
+				bundle_stop(bundle);
+			} else {
+				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "DEPLOYMENT_ADMIN: Bundle %s not found", info->symbolicName);
+			}
+		}
+		arrayList_destroy(infos);
+	}
+
+	return status;
+}
+
+celix_status_t deploymentAdmin_updateDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	array_list_pt infos = NULL;
+	deploymentPackage_getBundleInfos(source, &infos);
+	int i;
+	for (i = 0; i < arrayList_size(infos); i++) {
+		bundle_pt bundle = NULL;
+		bundle_info_pt info = arrayList_get(infos, i);
+
+		bundleContext_getBundle(admin->context, &bundle);
+		char *entry = NULL;
+		bundle_getEntry(bundle, "/", &entry);
+		const char *name = NULL;
+		deploymentPackage_getName(source, &name);
+
+		int bundlePathLength = strlen(entry) + strlen(name) + strlen(info->path) + 7;
+		int bsnLength = strlen(info->symbolicName) + 9;
+
+		char bundlePath[bundlePathLength];
+		snprintf(bundlePath, bundlePathLength, "%srepo/%s/%s", entry, name, info->path);
+
+		char bsn[bsnLength];
+		snprintf(bsn, bsnLength, "osgi-dp:%s", info->symbolicName);
+
+		bundle_pt updateBundle = NULL;
+		deploymentPackage_getBundle(source, info->symbolicName, &updateBundle);
+		if (updateBundle != NULL) {
+			//printf("Update bundle from: %s\n", bundlePath);
+			bundle_update(updateBundle, bundlePath);
+		} else {
+			//printf("Install bundle from: %s\n", bundlePath);
+			bundleContext_installBundle2(admin->context, bsn, bundlePath, &updateBundle);
+		}
+
+        free(entry);
+	}
+	arrayList_destroy(infos);
+	return status;
+}
+
+celix_status_t deploymentAdmin_startDeploymentPackageCustomizerBundles(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	array_list_pt bundles = NULL;
+	array_list_pt sourceInfos = NULL;
+
+	arrayList_create(&bundles);
+
+	deploymentPackage_getBundleInfos(source, &sourceInfos);
+	int i;
+	for (i = 0; i < arrayList_size(sourceInfos); i++) {
+		bundle_info_pt sourceInfo = arrayList_get(sourceInfos, i);
+		if (sourceInfo->customizer) {
+			bundle_pt bundle = NULL;
+			deploymentPackage_getBundle(source, sourceInfo->symbolicName, &bundle);
+			if (bundle != NULL) {
+				arrayList_add(bundles, bundle);
+			}
+		}
+	}
+	arrayList_destroy(sourceInfos);
+
+	if (target != NULL) {
+		array_list_pt targetInfos = NULL;
+		deploymentPackage_getBundleInfos(target, &targetInfos);
+		for (i = 0; i < arrayList_size(targetInfos); i++) {
+			bundle_info_pt targetInfo = arrayList_get(targetInfos, i);
+			if (targetInfo->customizer) {
+				bundle_pt bundle = NULL;
+				deploymentPackage_getBundle(target, targetInfo->symbolicName, &bundle);
+				if (bundle != NULL) {
+					arrayList_add(bundles, bundle);
+				}
+			}
+		}
+		arrayList_destroy(targetInfos);
+	}
+
+	for (i = 0; i < arrayList_size(bundles); i++) {
+		bundle_pt bundle = arrayList_get(bundles, i);
+		bundle_start(bundle);
+	}
+
+    arrayList_destroy(bundles);
+
+	return status;
+}
+
+celix_status_t deploymentAdmin_processDeploymentPackageResources(deployment_admin_pt admin, deployment_package_pt source) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	array_list_pt infos = NULL;
+	deploymentPackage_getResourceInfos(source, &infos);
+	int i;
+	for (i = 0; i < arrayList_size(infos); i++) {
+		resource_info_pt info = arrayList_get(infos, i);
+		array_list_pt services = NULL;
+		int length = strlen(OSGI_FRAMEWORK_SERVICE_PID) + strlen(info->resourceProcessor) + 4;
+		char filter[length];
+
+		snprintf(filter, length, "(%s=%s)", OSGI_FRAMEWORK_SERVICE_PID, info->resourceProcessor);
+
+		status = bundleContext_getServiceReferences(admin->context, DEPLOYMENTADMIN_RESOURCE_PROCESSOR_SERVICE, filter, &services);
+		if (status == CELIX_SUCCESS) {
+			if (services != NULL && arrayList_size(services) > 0) {
+				service_reference_pt ref = arrayList_get(services, 0);
+				// In Felix a check is done to assure the processor belongs to the deployment package
+				// Is this according to spec?
+				void *processorP = NULL;
+				status = bundleContext_getService(admin->context, ref, &processorP);
+				if (status == CELIX_SUCCESS) {
+					bundle_pt bundle = NULL;
+					char *entry = NULL;
+					const char *name = NULL;
+					const char *packageName = NULL;
+					resource_processor_service_pt processor = processorP;
+
+					bundleContext_getBundle(admin->context, &bundle);
+					bundle_getEntry(bundle, "/", &entry);
+					deploymentPackage_getName(source, &name);
+
+					int length = strlen(entry) + strlen(name) + strlen(info->path) + 7;
+					char resourcePath[length];
+					snprintf(resourcePath, length, "%srepo/%s/%s", entry, name, info->path);
+					deploymentPackage_getName(source, &packageName);
+
+					processor->begin(processor->processor, (char*)packageName);
+					processor->process(processor->processor, info->path, resourcePath);
+
+                    free(entry);
+				}
+			}
+		}
+
+		if(services != NULL) {
+			arrayList_destroy(services);
+		}
+	}
+
+    arrayList_destroy(infos);
+
+
+	return status;
+}
+
+celix_status_t deploymentAdmin_dropDeploymentPackageResources(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (target != NULL) {
+        array_list_pt infos = NULL;
+        deploymentPackage_getResourceInfos(target, &infos);
+        int i;
+        for (i = 0; i < arrayList_size(infos); i++) {
+            resource_info_pt info = arrayList_get(infos, i);
+            resource_info_pt sourceInfo = NULL;
+            deploymentPackage_getResourceInfoByPath(source, info->path, &sourceInfo);
+            if (sourceInfo == NULL) {
+                array_list_pt services = NULL;
+                int length = strlen(OSGI_FRAMEWORK_SERVICE_PID) + strlen(info->resourceProcessor) + 4;
+                char filter[length];
+
+                snprintf(filter, length, "(%s=%s)", OSGI_FRAMEWORK_SERVICE_PID, info->resourceProcessor);
+                status = bundleContext_getServiceReferences(admin->context, DEPLOYMENTADMIN_RESOURCE_PROCESSOR_SERVICE, filter, &services);
+                if (status == CELIX_SUCCESS) {
+                    if (services != NULL && arrayList_size(services) > 0) {
+                        service_reference_pt ref = arrayList_get(services, 0);
+                        // In Felix a check is done to assure the processor belongs to the deployment package
+                        // Is this according to spec?
+                        void *processorP = NULL;
+                        status = bundleContext_getService(admin->context, ref, &processorP);
+                        if (status == CELIX_SUCCESS) {
+                            const char *packageName = NULL;
+                            resource_processor_service_pt processor = processorP;
+
+                            deploymentPackage_getName(source, &packageName);
+                            processor->begin(processor->processor, (char*)packageName);
+                            processor->dropped(processor->processor, info->path);
+                        }
+                    }
+                }
+
+                if (services != NULL) {
+                    arrayList_destroy(services);
+                }
+
+            }
+        }
+
+        arrayList_destroy(infos);
+    }
+
+    return status;
+}
+
+celix_status_t deploymentAdmin_dropDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (target != NULL) {
+		array_list_pt targetInfos = NULL;
+		deploymentPackage_getBundleInfos(target, &targetInfos);
+		int i;
+		for (i = 0; i < arrayList_size(targetInfos); i++) {
+			bundle_info_pt targetInfo = arrayList_get(targetInfos, i);
+			if (!targetInfo->customizer) {
+				bundle_info_pt info = NULL;
+				deploymentPackage_getBundleInfoByName(source, targetInfo->symbolicName, &info);
+				if (info == NULL) {
+					bundle_pt bundle = NULL;
+					deploymentPackage_getBundle(target, targetInfo->symbolicName, &bundle);
+					bundle_uninstall(bundle);
+				}
+			}
+		}
+		arrayList_destroy(targetInfos);
+	}
+
+	return status;
+}
+
+celix_status_t deploymentAdmin_startDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	array_list_pt infos = NULL;
+	deploymentPackage_getBundleInfos(source, &infos);
+	int i;
+	for (i = 0; i < arrayList_size(infos); i++) {
+		bundle_pt bundle = NULL;
+		bundle_info_pt info = arrayList_get(infos, i);
+		if (!info->customizer) {
+			deploymentPackage_getBundle(source, info->symbolicName, &bundle);
+			if (bundle != NULL) {
+				bundle_start(bundle);
+			} else {
+				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "DEPLOYMENT_ADMIN: Could not start bundle %s", info->symbolicName);
+			}
+		}
+	}
+	arrayList_destroy(infos);
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/deployment_admin.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/deployment_admin.h b/deployment_admin/src/deployment_admin.h
new file mode 100644
index 0000000..a7e3a39
--- /dev/null
+++ b/deployment_admin/src/deployment_admin.h
@@ -0,0 +1,57 @@
+/**
+ *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.
+ */
+/*
+ * deployment_admin.h
+ *
+ *  \date       Nov 7, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef DEPLOYMENT_ADMIN_H_
+#define DEPLOYMENT_ADMIN_H_
+
+#include "bundle_context.h"
+
+typedef struct deployment_admin *deployment_admin_pt;
+
+struct deployment_admin {
+	celix_thread_t poller;
+	bundle_context_pt context;
+
+	bool running;
+	char *current;
+	hash_map_pt packages;
+	char *targetIdentification;
+	char *pollUrl;
+	char *auditlogUrl;
+	unsigned long long auditlogId;
+	unsigned int aditlogSeqNr;
+};
+
+typedef enum {
+	DEPLOYMENT_ADMIN_AUDIT_EVENT__FRAMEWORK_STARTED = 1005,
+	DEPLOYMENT_ADMIN_AUDIT_EVENT__TARGETPROPERTIES_SET = 4001
+
+} DEPLOYMENT_ADMIN_AUDIT_EVENT;
+
+celix_status_t deploymentAdmin_create(bundle_context_pt context, deployment_admin_pt *admin);
+celix_status_t deploymentAdmin_destroy(deployment_admin_pt admin);
+
+#endif /* DEPLOYMENT_ADMIN_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/deployment_admin_activator.c
----------------------------------------------------------------------
diff --git a/deployment_admin/src/deployment_admin_activator.c b/deployment_admin/src/deployment_admin_activator.c
new file mode 100644
index 0000000..93fd6b5
--- /dev/null
+++ b/deployment_admin/src/deployment_admin_activator.c
@@ -0,0 +1,78 @@
+/**
+ *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.
+ */
+/*
+ * deployment_admin_activator.c
+ *
+ *  \date       Nov 7, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "bundle_activator.h"
+#include "deployment_admin.h"
+
+struct bundle_activator {
+	deployment_admin_pt admin;
+};
+
+typedef struct bundle_activator* bundle_activator_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bundle_activator_pt activator = NULL;
+
+	activator = calloc(1, sizeof(*activator));
+	if (!activator) {
+		status = CELIX_ENOMEM;
+	} else {
+		status = deploymentAdmin_create(context, &activator->admin);
+
+		*userData = activator;
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	celix_status_t status;
+
+	bundle_activator_pt activator = (bundle_activator_pt) userData;
+
+	status = deploymentAdmin_destroy(activator->admin);
+
+	free(activator);
+
+	return status;
+}
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/deployment_package.c
----------------------------------------------------------------------
diff --git a/deployment_admin/src/deployment_package.c b/deployment_admin/src/deployment_package.c
new file mode 100644
index 0000000..1520db8
--- /dev/null
+++ b/deployment_admin/src/deployment_package.c
@@ -0,0 +1,219 @@
+/**
+ *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.
+ */
+/*
+ * deployment_package.c
+ *
+ *  \date       Nov 8, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "celix_errno.h"
+
+#include "deployment_package.h"
+#include "constants.h"
+#include "utils.h"
+#include "bundle_context.h"
+#include "module.h"
+#include "bundle.h"
+
+static const char * const RESOURCE_PROCESSOR = "Resource-Processor";
+static const char * const DEPLOYMENTPACKAGE_CUSTOMIZER = "DeploymentPackage-Customizer";
+
+celix_status_t deploymentPackage_processEntries(deployment_package_pt package);
+static celix_status_t deploymentPackage_isBundleResource(properties_pt attributes, bool *isBundleResource);
+static celix_status_t deploymentPackage_parseBooleanHeader(const char *value, bool *boolValue);
+
+celix_status_t deploymentPackage_create(bundle_context_pt context, manifest_pt manifest, deployment_package_pt *package) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*package = calloc(1, sizeof(**package));
+	if (!(*package)) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*package)->context = context;
+		(*package)->manifest = manifest;
+		(*package)->bundleInfos = NULL;
+		(*package)->resourceInfos = NULL;
+		(*package)->nameToBundleInfo = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+		(*package)->pathToEntry = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+		status = arrayList_create(&(*package)->bundleInfos);
+		if (status == CELIX_SUCCESS) {
+			status = arrayList_create(&(*package)->resourceInfos);
+			if (status == CELIX_SUCCESS) {
+				status = deploymentPackage_processEntries(*package);
+				if (status == CELIX_SUCCESS) {
+					int i;
+					for (i = 0; i < arrayList_size((*package)->bundleInfos); i++) {
+						bundle_info_pt info = arrayList_get((*package)->bundleInfos, i);
+						hashMap_put((*package)->nameToBundleInfo, info->symbolicName, info);
+					}
+					for (i = 0; i < arrayList_size((*package)->resourceInfos); i++) {
+						resource_info_pt info = arrayList_get((*package)->resourceInfos, i);
+						hashMap_put((*package)->pathToEntry, info->path, info);
+					}
+				}
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t deploymentPackage_destroy(deployment_package_pt package) {
+	celix_status_t status = CELIX_SUCCESS;
+	int i;
+
+
+    manifest_destroy(package->manifest);
+
+	hashMap_destroy(package->nameToBundleInfo, false, false);
+	hashMap_destroy(package->pathToEntry, false, false);
+
+
+    for(i = arrayList_size(package->bundleInfos); i  > 0; --i) {
+        free(arrayList_remove(package->bundleInfos, 0));
+    }
+
+	arrayList_destroy(package->bundleInfos);
+
+    for (i = arrayList_size(package->resourceInfos); i > 0; --i) {
+        free(arrayList_remove(package->resourceInfos, 0));
+    }
+
+
+	arrayList_destroy(package->resourceInfos);
+
+	free(package);
+
+	return status;
+}
+
+celix_status_t deploymentPackage_getName(deployment_package_pt package, const char **name) {
+	*name = manifest_getValue(package->manifest, "DeploymentPackage-SymbolicName");
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deploymentPackage_getBundleInfos(deployment_package_pt package, array_list_pt *infos) {
+	*infos = arrayList_clone(package->bundleInfos);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deploymentPackage_getBundleInfoByName(deployment_package_pt package, const char *name, bundle_info_pt *info) {
+	*info = hashMap_get(package->nameToBundleInfo, name);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deploymentPackage_getBundle(deployment_package_pt package, const char *name, bundle_pt *bundle) {
+	if (hashMap_containsKey(package->nameToBundleInfo, name)) {
+		array_list_pt bundles = NULL;
+		bundleContext_getBundles(package->context, &bundles);
+		int i;
+		for (i = 0; i < arrayList_size(bundles); i++) {
+			bundle_pt ibundle = arrayList_get(bundles, i);
+			module_pt module = NULL;
+			bundle_getCurrentModule(ibundle, &module);
+			const char *bsn = NULL;
+			module_getSymbolicName(module, &bsn);
+			if (strcmp(bsn, name) == 0) {
+				*bundle = ibundle;
+				break;
+			}
+		}
+
+		arrayList_destroy(bundles);
+	}
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deploymentPackage_getResourceInfos(deployment_package_pt package, array_list_pt *infos) {
+	*infos = arrayList_clone(package->resourceInfos);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deploymentPackage_getResourceInfoByPath(deployment_package_pt package, const char *path, resource_info_pt *info) {
+	*info = hashMap_get(package->pathToEntry, path);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deploymentPackage_getVersion(deployment_package_pt package, version_pt *version) {
+	const char *versionStr = manifest_getValue(package->manifest, "DeploymentPackage-Version");
+	return version_createVersionFromString(versionStr, version);
+}
+
+celix_status_t deploymentPackage_processEntries(deployment_package_pt package) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	hash_map_pt entries = NULL;
+	manifest_getEntries(package->manifest, &entries);
+	hash_map_iterator_pt iter = hashMapIterator_create(entries);
+	while (hashMapIterator_hasNext(iter)) {
+		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+		char *name = hashMapEntry_getKey(entry);
+		properties_pt values = hashMapEntry_getValue(entry);
+
+		bool isBundleResource;
+		deploymentPackage_isBundleResource(values, &isBundleResource);
+		if (isBundleResource) {
+			bundle_info_pt info = calloc(1, sizeof(*info));
+			info->path = name;
+			info->attributes = values;
+			info->symbolicName = (char*)properties_get(values, OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME);
+			const char *version = properties_get(values, OSGI_FRAMEWORK_BUNDLE_VERSION);
+			info->version = NULL;
+			status = version_createVersionFromString((char*)version, &info->version);
+			const char *customizer = properties_get(values, DEPLOYMENTPACKAGE_CUSTOMIZER);
+			deploymentPackage_parseBooleanHeader((char*)customizer, &info->customizer);
+
+			arrayList_add(package->bundleInfos, info);
+		} else {
+			resource_info_pt info = calloc(1, sizeof(*info));
+			info->path = name;
+			info->attributes = values;
+			info->resourceProcessor = (char*)properties_get(values,RESOURCE_PROCESSOR);
+
+			arrayList_add(package->resourceInfos, info);
+		}
+	}
+	hashMapIterator_destroy(iter);
+
+	return status;
+}
+
+static celix_status_t deploymentPackage_isBundleResource(properties_pt attributes, bool *isBundleResource) {
+	*isBundleResource = properties_get(attributes, (char *) OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME) != NULL;
+	return CELIX_SUCCESS;
+}
+
+static celix_status_t deploymentPackage_parseBooleanHeader(const char *value, bool *boolValue) {
+	*boolValue = false;
+	if (value != NULL) {
+		if (strcmp(value, "true") == 0) {
+			*boolValue = true;
+		} else {
+			*boolValue = false;
+		}
+	}
+	return CELIX_SUCCESS;
+}
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/deployment_package.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/deployment_package.h b/deployment_admin/src/deployment_package.h
new file mode 100644
index 0000000..06c1767
--- /dev/null
+++ b/deployment_admin/src/deployment_package.h
@@ -0,0 +1,76 @@
+/**
+ *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.
+ */
+/*
+ * deployment_package.h
+ *
+ *  \date       Nov 8, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef DEPLOYMENT_PACKAGE_H_
+#define DEPLOYMENT_PACKAGE_H_
+
+#include "version.h"
+#include "bundle_context.h"
+
+#include "array_list.h"
+
+struct bundle_info {
+	char *path;
+	version_pt version;
+	char *symbolicName;
+	bool customizer;
+
+	properties_pt attributes;
+};
+
+typedef struct bundle_info *bundle_info_pt;
+
+struct resource_info {
+	char *path;
+	properties_pt attributes;
+
+	char *resourceProcessor;
+};
+
+typedef struct resource_info *resource_info_pt;
+
+struct deployment_package {
+	bundle_context_pt context;
+	manifest_pt manifest;
+	array_list_pt bundleInfos;
+	array_list_pt resourceInfos;
+	hash_map_pt nameToBundleInfo;
+	hash_map_pt pathToEntry;
+};
+
+typedef struct deployment_package *deployment_package_pt;
+
+celix_status_t deploymentPackage_create(bundle_context_pt context, manifest_pt manifest, deployment_package_pt *package);
+celix_status_t deploymentPackage_destroy(deployment_package_pt package);
+celix_status_t deploymentPackage_getName(deployment_package_pt package, const char** name);
+celix_status_t deploymentPackage_getBundleInfos(deployment_package_pt package, array_list_pt *infos);
+celix_status_t deploymentPackage_getBundleInfoByName(deployment_package_pt package, const char* name, bundle_info_pt *info);
+celix_status_t deploymentPackage_getResourceInfos(deployment_package_pt package, array_list_pt *infos);
+celix_status_t deploymentPackage_getResourceInfoByPath(deployment_package_pt package, const char* path, resource_info_pt *info);
+celix_status_t deploymentPackage_getBundle(deployment_package_pt package, const char* name, bundle_pt *bundle);
+celix_status_t deploymentPackage_getVersion(deployment_package_pt package, version_pt *version);
+
+#endif /* DEPLOYMENT_PACKAGE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/ioapi.c
----------------------------------------------------------------------
diff --git a/deployment_admin/src/ioapi.c b/deployment_admin/src/ioapi.c
new file mode 100644
index 0000000..49958f6
--- /dev/null
+++ b/deployment_admin/src/ioapi.c
@@ -0,0 +1,235 @@
+/* ioapi.h -- IO base function header for compress/uncompress .zip
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications for Zip64 support
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+*/
+
+#if (defined(_WIN32))
+        #define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include "ioapi.h"
+
+voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
+{
+    if (pfilefunc->zfile_func64.zopen64_file != NULL)
+        return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
+    else
+    {
+        return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
+    }
+}
+
+long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
+{
+    if (pfilefunc->zfile_func64.zseek64_file != NULL)
+        return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
+    else
+    {
+        uLong offsetTruncated = (uLong)offset;
+        if (offsetTruncated != offset)
+            return -1;
+        else
+            return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
+    }
+}
+
+ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
+{
+    if (pfilefunc->zfile_func64.zseek64_file != NULL)
+        return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
+    else
+    {
+        uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
+        if ((tell_uLong) == ((uLong)-1))
+            return (ZPOS64_T)-1;
+        else
+            return tell_uLong;
+    }
+}
+
+void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
+{
+    p_filefunc64_32->zfile_func64.zopen64_file = NULL;
+    p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
+    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
+    p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
+    p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
+    p_filefunc64_32->zfile_func64.ztell64_file = NULL;
+    p_filefunc64_32->zfile_func64.zseek64_file = NULL;
+    p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
+    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
+    p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
+    p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
+    p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
+}
+
+
+
+static voidpf  ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
+static uLong   ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+static uLong   ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
+static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
+static long    ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
+static int     ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
+static int     ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
+
+static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
+{
+    FILE* file = NULL;
+    const char* mode_fopen = NULL;
+    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
+        mode_fopen = "rb";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
+        mode_fopen = "r+b";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+        mode_fopen = "wb";
+
+    if ((filename!=NULL) && (mode_fopen != NULL))
+        file = fopen(filename, mode_fopen);
+    return file;
+}
+
+static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
+{
+    FILE* file = NULL;
+    const char* mode_fopen = NULL;
+    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
+        mode_fopen = "rb";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
+        mode_fopen = "r+b";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+        mode_fopen = "wb";
+
+    if ((filename!=NULL) && (mode_fopen != NULL))
+        file = fopen64((const char*)filename, mode_fopen);
+    return file;
+}
+
+
+static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
+{
+    uLong ret;
+    ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
+    return ret;
+}
+
+static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
+{
+    uLong ret;
+    ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
+    return ret;
+}
+
+static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
+{
+    long ret;
+    ret = ftell((FILE *)stream);
+    return ret;
+}
+
+
+static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
+{
+    ZPOS64_T ret;
+    ret = ftello64((FILE *)stream);
+    return ret;
+}
+
+static long ZCALLBACK fseek_file_func (voidpf  opaque, voidpf stream, uLong offset, int origin)
+{
+    int fseek_origin=0;
+    long ret;
+    switch (origin)
+    {
+    case ZLIB_FILEFUNC_SEEK_CUR :
+        fseek_origin = SEEK_CUR;
+        break;
+    case ZLIB_FILEFUNC_SEEK_END :
+        fseek_origin = SEEK_END;
+        break;
+    case ZLIB_FILEFUNC_SEEK_SET :
+        fseek_origin = SEEK_SET;
+        break;
+    default: return -1;
+    }
+    ret = 0;
+    if (fseek((FILE *)stream, offset, fseek_origin) != 0)
+        ret = -1;
+    return ret;
+}
+
+static long ZCALLBACK fseek64_file_func (voidpf  opaque, voidpf stream, ZPOS64_T offset, int origin)
+{
+    int fseek_origin=0;
+    long ret;
+    switch (origin)
+    {
+    case ZLIB_FILEFUNC_SEEK_CUR :
+        fseek_origin = SEEK_CUR;
+        break;
+    case ZLIB_FILEFUNC_SEEK_END :
+        fseek_origin = SEEK_END;
+        break;
+    case ZLIB_FILEFUNC_SEEK_SET :
+        fseek_origin = SEEK_SET;
+        break;
+    default: return -1;
+    }
+    ret = 0;
+
+    if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)
+                        ret = -1;
+
+    return ret;
+}
+
+
+static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
+{
+    int ret;
+    ret = fclose((FILE *)stream);
+    return ret;
+}
+
+static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
+{
+    int ret;
+    ret = ferror((FILE *)stream);
+    return ret;
+}
+
+void fill_fopen_filefunc (pzlib_filefunc_def)
+  zlib_filefunc_def* pzlib_filefunc_def;
+{
+    pzlib_filefunc_def->zopen_file = fopen_file_func;
+    pzlib_filefunc_def->zread_file = fread_file_func;
+    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
+    pzlib_filefunc_def->ztell_file = ftell_file_func;
+    pzlib_filefunc_def->zseek_file = fseek_file_func;
+    pzlib_filefunc_def->zclose_file = fclose_file_func;
+    pzlib_filefunc_def->zerror_file = ferror_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}
+
+void fill_fopen64_filefunc (zlib_filefunc64_def*  pzlib_filefunc_def)
+{
+    pzlib_filefunc_def->zopen64_file = fopen64_file_func;
+    pzlib_filefunc_def->zread_file = fread_file_func;
+    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
+    pzlib_filefunc_def->ztell64_file = ftell64_file_func;
+    pzlib_filefunc_def->zseek64_file = fseek64_file_func;
+    pzlib_filefunc_def->zclose_file = fclose_file_func;
+    pzlib_filefunc_def->zerror_file = ferror_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/ioapi.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/ioapi.h b/deployment_admin/src/ioapi.h
new file mode 100644
index 0000000..8309c4c
--- /dev/null
+++ b/deployment_admin/src/ioapi.h
@@ -0,0 +1,200 @@
+/* ioapi.h -- IO base function header for compress/uncompress .zip
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications for Zip64 support
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+         Changes
+
+    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
+    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
+               More if/def section may be needed to support other platforms
+    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
+                          (but you should use iowin32.c for windows instead)
+
+*/
+
+#ifndef _ZLIBIOAPI64_H
+#define _ZLIBIOAPI64_H
+
+#if (!defined(_WIN32)) && (!defined(WIN32))
+
+  // Linux needs this to support file operation on files larger then 4+GB
+  // But might need better if/def to select just the platforms that needs them.
+
+        #ifndef __USE_FILE_OFFSET64
+                #define __USE_FILE_OFFSET64
+        #endif
+        #ifndef __USE_LARGEFILE64
+                #define __USE_LARGEFILE64
+        #endif
+        #ifndef _LARGEFILE64_SOURCE
+                #define _LARGEFILE64_SOURCE
+        #endif
+        #ifndef _FILE_OFFSET_BIT
+                #define _FILE_OFFSET_BIT 64
+        #endif
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "zlib.h"
+
+#if defined(USE_FILE32API)
+#define fopen64 fopen
+#define ftello64 ftell
+#define fseeko64 fseek
+#else
+#ifdef _MSC_VER
+ #define fopen64 fopen
+ #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
+  #define ftello64 _ftelli64
+  #define fseeko64 _fseeki64
+ #else // old MSC
+  #define ftello64 ftell
+  #define fseeko64 fseek
+ #endif
+#endif
+#endif
+
+/*
+#ifndef ZPOS64_T
+  #ifdef _WIN32
+                #define ZPOS64_T fpos_t
+  #else
+    #include <stdint.h>
+    #define ZPOS64_T uint64_t
+  #endif
+#endif
+*/
+
+#ifdef HAVE_MINIZIP64_CONF_H
+#include "mz64conf.h"
+#endif
+
+/* a type choosen by DEFINE */
+#ifdef HAVE_64BIT_INT_CUSTOM
+typedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;
+#else
+#ifdef HAS_STDINT_H
+#include "stdint.h"
+typedef uint64_t ZPOS64_T;
+#else
+
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+typedef unsigned __int64 ZPOS64_T;
+#else
+typedef unsigned long long int ZPOS64_T;
+#endif
+#endif
+#endif
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define ZLIB_FILEFUNC_SEEK_CUR (1)
+#define ZLIB_FILEFUNC_SEEK_END (2)
+#define ZLIB_FILEFUNC_SEEK_SET (0)
+
+#define ZLIB_FILEFUNC_MODE_READ      (1)
+#define ZLIB_FILEFUNC_MODE_WRITE     (2)
+#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
+
+#define ZLIB_FILEFUNC_MODE_EXISTING (4)
+#define ZLIB_FILEFUNC_MODE_CREATE   (8)
+
+
+#ifndef ZCALLBACK
+ #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
+   #define ZCALLBACK CALLBACK
+ #else
+   #define ZCALLBACK
+ #endif
+#endif
+
+
+
+
+typedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));
+typedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+typedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
+typedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));
+typedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
+
+typedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));
+typedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));
+
+
+/* here is the "old" 32 bits structure structure */
+typedef struct zlib_filefunc_def_s
+{
+    open_file_func      zopen_file;
+    read_file_func      zread_file;
+    write_file_func     zwrite_file;
+    tell_file_func      ztell_file;
+    seek_file_func      zseek_file;
+    close_file_func     zclose_file;
+    testerror_file_func zerror_file;
+    voidpf              opaque;
+} zlib_filefunc_def;
+
+typedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));
+typedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
+typedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));
+
+typedef struct zlib_filefunc64_def_s
+{
+    open64_file_func    zopen64_file;
+    read_file_func      zread_file;
+    write_file_func     zwrite_file;
+    tell64_file_func    ztell64_file;
+    seek64_file_func    zseek64_file;
+    close_file_func     zclose_file;
+    testerror_file_func zerror_file;
+    voidpf              opaque;
+} zlib_filefunc64_def;
+
+void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
+void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
+
+/* now internal definition, only for zip.c and unzip.h */
+typedef struct zlib_filefunc64_32_def_s
+{
+    zlib_filefunc64_def zfile_func64;
+    open_file_func      zopen32_file;
+    tell_file_func      ztell32_file;
+    seek_file_func      zseek32_file;
+} zlib_filefunc64_32_def;
+
+
+#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))
+#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))
+//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
+//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
+#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))
+#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))
+
+voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
+long    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
+ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
+
+void    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
+
+#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))
+#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))
+#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/log.c
----------------------------------------------------------------------
diff --git a/deployment_admin/src/log.c b/deployment_admin/src/log.c
new file mode 100644
index 0000000..98e757d
--- /dev/null
+++ b/deployment_admin/src/log.c
@@ -0,0 +1,73 @@
+/**
+ *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.
+ */
+/*
+ * log.c
+ *
+ *  \date       Apr 19, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "celix_errno.h"
+
+#include "log.h"
+#include "log_store.h"
+
+struct log {
+	log_store_pt logStore;
+};
+
+celix_status_t log_create(log_store_pt store, log_pt *log) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*log = calloc(1, sizeof(**log));
+	if (!*log) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*log)->logStore = store;
+	}
+
+	return status;
+}
+
+celix_status_t log_destroy(log_pt *log) {
+	free(*log);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t log_log(log_pt log, unsigned int type, properties_pt properties) {
+	celix_status_t status;
+
+	log_event_pt event = NULL;
+
+	status = logStore_put(log->logStore, type, properties, &event);
+
+	return status;
+}
+
+celix_status_t log_bundleChanged(void * listener, bundle_event_pt event) {
+	return CELIX_SUCCESS;
+}
+
+celix_status_t log_frameworkEvent(void * listener, framework_event_pt event) {
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/log.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/log.h b/deployment_admin/src/log.h
new file mode 100644
index 0000000..fa77911
--- /dev/null
+++ b/deployment_admin/src/log.h
@@ -0,0 +1,44 @@
+/**
+ *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.
+ */
+/*
+ * log.h
+ *
+ *  \date       Apr 18, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_H_
+#define LOG_H_
+
+#include "log_event.h"
+#include "log_store.h"
+
+#include "bundle_event.h"
+#include "framework_event.h"
+
+typedef struct log *log_pt;
+
+celix_status_t log_create(log_store_pt store, log_pt *log);
+celix_status_t log_log(log_pt log, unsigned int type, properties_pt properties);
+
+celix_status_t log_bundleChanged(void * listener, bundle_event_pt event);
+celix_status_t log_frameworkEvent(void * listener, framework_event_pt event);
+
+#endif /* LOG_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/log_event.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/log_event.h b/deployment_admin/src/log_event.h
new file mode 100644
index 0000000..c1a76a9
--- /dev/null
+++ b/deployment_admin/src/log_event.h
@@ -0,0 +1,43 @@
+/**
+ *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.
+ */
+/*
+ * log_event.h
+ *
+ *  \date       Apr 19, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_EVENT_H_
+#define LOG_EVENT_H_
+
+#include "properties.h"
+
+struct log_event {
+	char *targetId;
+	unsigned long logId;
+	unsigned long id;
+	unsigned long time;
+	unsigned int type;
+	properties_pt properties;
+};
+
+typedef struct log_event *log_event_pt;
+
+#endif /* LOG_EVENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/log_store.c
----------------------------------------------------------------------
diff --git a/deployment_admin/src/log_store.c b/deployment_admin/src/log_store.c
new file mode 100644
index 0000000..c2bfabc
--- /dev/null
+++ b/deployment_admin/src/log_store.c
@@ -0,0 +1,94 @@
+/**
+ *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.
+ */
+/*
+ * log_store.c
+ *
+ *  \date       Apr 18, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include <time.h>
+
+#include "celix_errno.h"
+#include "array_list.h"
+
+#include "log_store.h"
+#include "log.h"
+
+struct log_store {
+	unsigned long storeId;
+
+	array_list_pt logEvents;
+};
+
+static celix_status_t logStore_getNextID(log_store_pt store, unsigned long *id);
+
+celix_status_t logStore_create(log_store_pt *store) {
+	celix_status_t status = CELIX_SUCCESS;
+	*store = calloc(1, sizeof(**store));
+	if (!*store) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*store)->storeId = 1;
+		arrayList_create(&(*store)->logEvents);
+	}
+
+	return status;
+}
+
+celix_status_t logStore_put(log_store_pt store, unsigned int type, properties_pt properties, log_event_pt *event) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*event = calloc(1, sizeof(**event));
+	(*event)->targetId = NULL;
+	(*event)->logId = store->storeId;
+	(*event)->id = 0;
+	(*event)->time = time(NULL);
+	(*event)->type = type;
+	(*event)->properties = properties;
+
+	logStore_getNextID(store, &(*event)->id);
+
+	arrayList_add(store->logEvents, *event);
+
+	return status;
+}
+
+celix_status_t logStore_getLogId(log_store_pt store, unsigned long *id) {
+	*id = store->storeId;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t logStore_getEvents(log_store_pt store, array_list_pt *events) {
+	*events = store->logEvents;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t logStore_getHighestId(log_store_pt store, long *id) {
+	*id = ((long) arrayList_size(store->logEvents)) - 1;
+	return CELIX_SUCCESS;
+}
+
+static celix_status_t logStore_getNextID(log_store_pt store, unsigned long *id) {
+	*id = arrayList_size(store->logEvents);
+	return CELIX_SUCCESS;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/log_store.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/log_store.h b/deployment_admin/src/log_store.h
new file mode 100644
index 0000000..84299b3
--- /dev/null
+++ b/deployment_admin/src/log_store.h
@@ -0,0 +1,45 @@
+/**
+ *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.
+ */
+/*
+ * log_store.h
+ *
+ *  \date       Apr 18, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_STORE_H_
+#define LOG_STORE_H_
+
+#include "log_event.h"
+
+#include "properties.h"
+#include "array_list.h"
+
+typedef struct log_store *log_store_pt;
+
+celix_status_t logStore_create(log_store_pt *store);
+celix_status_t logStore_put(log_store_pt store, unsigned int type, properties_pt properties, log_event_pt *event);
+
+celix_status_t logStore_getLogId(log_store_pt store, unsigned long *id);
+celix_status_t logStore_getEvents(log_store_pt store, array_list_pt *events);
+
+celix_status_t logStore_getHighestId(log_store_pt store, long *id);
+
+#endif /* LOG_STORE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/log_sync.c
----------------------------------------------------------------------
diff --git a/deployment_admin/src/log_sync.c b/deployment_admin/src/log_sync.c
new file mode 100644
index 0000000..242beea
--- /dev/null
+++ b/deployment_admin/src/log_sync.c
@@ -0,0 +1,209 @@
+/**
+ *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.
+ */
+/*
+ * log_sync.c
+ *
+ *  \date       Apr 19, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <curl/curl.h>
+#include <curl/easy.h>
+
+#include "celix_errno.h"
+#include "celix_log.h"
+#include "celixbool.h"
+
+#include "celix_threads.h"
+
+#include "log_sync.h"
+#include "log_event.h"
+
+struct log_sync {
+	log_store_pt logStore;
+
+	char *targetId;
+	bool running;
+
+	celix_thread_t syncTask;
+};
+
+struct log_descriptor {
+	char *targetId;
+	unsigned long logId;
+	unsigned long low;
+	unsigned long high;
+};
+
+typedef struct log_descriptor *log_descriptor_pt;
+
+celix_status_t logSync_queryLog(log_sync_pt logSync, char *targetId, long logId, char **queryReply);
+static size_t logSync_readQeury(void *contents, size_t size, size_t nmemb, void *userp);
+static void *logSync_synchronize(void *logSyncP);
+
+celix_status_t logSync_create(char *targetId, log_store_pt store, log_sync_pt *logSync) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*logSync = calloc(1, sizeof(**logSync));
+	if (!*logSync) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*logSync)->logStore = store;
+		(*logSync)->targetId = targetId;
+		(*logSync)->syncTask = celix_thread_default;
+		(*logSync)->running = true;
+
+		celixThread_create(&(*logSync)->syncTask, NULL, logSync_synchronize, *logSync);
+	}
+
+	return status;
+}
+
+celix_status_t logSync_parseLogDescriptor(log_sync_pt logSync, char *descriptorString, log_descriptor_pt *descriptor) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Descriptor: %s", descriptorString);
+	char *last = NULL;
+	char *targetId = strtok_r(descriptorString, ",", &last);
+	char *logIdStr = strtok_r(NULL, ",", &last);
+	long logId = 0;
+	if (logIdStr != NULL) {
+		logId = atol(logIdStr);
+	}
+	char *range = strtok_r(NULL, ",", &last);
+	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Range: %s", range);
+
+	long low = 0;
+	long high = 0;
+	if (range != NULL) {
+		char *rangeToken = NULL;
+		low = atol(strtok_r(range, "-", &rangeToken));
+		high = atol(strtok_r(NULL, "-", &rangeToken));
+	}
+
+	*descriptor = calloc(1, sizeof(**descriptor));
+	if (!*descriptor) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*descriptor)->targetId = targetId;
+		(*descriptor)->logId = logId;
+		(*descriptor)->low = low;
+		(*descriptor)->high = high;
+	}
+
+	return status;
+}
+
+static void *logSync_synchronize(void *logSyncP) {
+	log_sync_pt logSync = logSyncP;
+
+	while (logSync->running) {
+
+		//query current log
+		// http://localhost:8080/auditlog/query?tid=targetid&logid=logid
+		char *logDescriptorString = NULL;
+		unsigned long id = 0;
+		logStore_getLogId(logSync->logStore, &id);
+		logSync_queryLog(logSync, logSync->targetId, id, &logDescriptorString);
+		log_descriptor_pt descriptor = NULL;
+		logSync_parseLogDescriptor(logSync, logDescriptorString, &descriptor);
+
+		long highest = 0;
+		logStore_getHighestId(logSync->logStore, &highest);
+
+		if (highest >= 0) {
+			int i;
+			for (i = descriptor->high + 1; i <= highest; i++) {
+				array_list_pt events = NULL;
+				logStore_getEvents(logSync->logStore, &events);
+			}
+		}
+
+		if(descriptor!=NULL){
+			free(descriptor);
+		}
+
+		sleep(10);
+	}
+
+
+	celixThread_exit(NULL);
+	return NULL;
+}
+
+struct MemoryStruct {
+	char *memory;
+	size_t size;
+};
+
+celix_status_t logSync_queryLog(log_sync_pt logSync, char *targetId, long logId, char **queryReply) {
+	// http://localhost:8080/auditlog/query?tid=targetid&logid=logid
+	celix_status_t status = CELIX_SUCCESS;
+	int length = strlen(targetId) + 60;
+	char query[length];
+	snprintf(query, length, "http://localhost:8080/auditlog/query?tid=%s&logid=1", targetId);
+
+	CURL *curl;
+	CURLcode res;
+	curl = curl_easy_init();
+	struct MemoryStruct chunk;
+	chunk.memory = calloc(1, sizeof(char));
+	chunk.size = 0;
+	if (curl) {
+		curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+		curl_easy_setopt(curl, CURLOPT_URL, query);
+		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, logSync_readQeury);
+		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunk);
+		curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
+		res = curl_easy_perform(curl);
+		if (res != CURLE_OK) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: %d", res);
+		/* always cleanup */
+		curl_easy_cleanup(curl);
+
+		*queryReply = strdup(chunk.memory);
+	}
+
+	return status;
+}
+
+static size_t logSync_readQeury(void *contents, size_t size, size_t nmemb, void *userp) {
+	size_t realsize = size * nmemb;
+	struct MemoryStruct *mem = (struct MemoryStruct *)userp;
+
+	mem->memory = realloc(mem->memory, mem->size + realsize + 1);
+	if (mem->memory == NULL) {
+		/* out of memory! */
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "not enough memory (realloc returned NULL)");
+		exit(EXIT_FAILURE);
+	}
+
+	memcpy(&(mem->memory[mem->size]), contents, realsize);
+	mem->size += realsize;
+	mem->memory[mem->size] = 0;
+
+	return realsize;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/log_sync.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/log_sync.h b/deployment_admin/src/log_sync.h
new file mode 100644
index 0000000..7cd10d9
--- /dev/null
+++ b/deployment_admin/src/log_sync.h
@@ -0,0 +1,36 @@
+/**
+ *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.
+ */
+/*
+ * log_sync.h
+ *
+ *  \date       Apr 19, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_SYNC_H_
+#define LOG_SYNC_H_
+
+#include "log_store.h"
+
+typedef struct log_sync *log_sync_pt;
+
+celix_status_t logSync_create(char *targetId, log_store_pt store, log_sync_pt *logSync);
+
+#endif /* LOG_SYNC_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/miniunz.c
----------------------------------------------------------------------
diff --git a/deployment_admin/src/miniunz.c b/deployment_admin/src/miniunz.c
new file mode 100644
index 0000000..e543c3b
--- /dev/null
+++ b/deployment_admin/src/miniunz.c
@@ -0,0 +1,402 @@
+/** License
+ * ----------------------------------------------------------
+ *    Condition of use and distribution are the same than zlib :
+ *
+ *   This software is provided 'as-is', without any express or implied
+ *   warranty.  In no event will the authors be held liable for any damages
+ *   arising from the use of this software.
+ *
+ *   Permission is granted to anyone to use this software for any purpose,
+ *   including commercial applications, and to alter it and redistribute it
+ *   freely, subject to the following restrictions:
+ *
+ *   1. The origin of this software must not be misrepresented; you must not
+ *      claim that you wrote the original software. If you use this software
+ *      in a product, an acknowledgment in the product documentation would be
+ *      appreciated but is not required.
+ *   2. Altered source versions must be plainly marked as such, and must not be
+ *      misrepresented as being the original software.
+ *   3. This notice may not be removed or altered from any source distribution.
+ *
+ * ----------------------------------------------------------
+ */
+/*
+   miniunz.c
+   Version 1.1, February 14h, 2010
+   sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications of Unzip for Zip64
+         Copyright (C) 2007-2008 Even Rouault
+
+         Modifications for Zip64 support on both zip and unzip
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+    Changes made to the original source specific for Apache Celix:
+    * Updated several parts to use output directory fitting Celix.
+    * Removed several parts not needed (main function etc).
+    * Added some checks for OSX/Apple
+*/
+
+#ifndef _WIN32
+        #ifndef __USE_FILE_OFFSET64
+                #define __USE_FILE_OFFSET64
+        #endif
+        #ifndef __USE_LARGEFILE64
+                #define __USE_LARGEFILE64
+        #endif
+        #ifndef _LARGEFILE64_SOURCE
+                #define _LARGEFILE64_SOURCE
+        #endif
+        #ifndef _FILE_OFFSET_BIT
+                #define _FILE_OFFSET_BIT 64
+        #endif
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include <unistd.h>
+#include <utime.h>
+#include <sys/stat.h>
+
+#include "unzip.h"
+#include "archive.h"
+
+#define CASESENSITIVITY (0)
+#define WRITEBUFFERSIZE (8192)
+#define MAXFILENAME (256)
+
+#ifdef _WIN32
+#define USEWIN32IOAPI
+#include "iowin32.h"
+#endif
+/*
+  mini unzip, demo of unzip package
+
+  usage :
+  Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir]
+
+  list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT
+    if it exists
+*/
+
+
+/* change_file_date : change the date/time of a file
+    filename : the filename of the file where date/time must be modified
+    dosdate : the new date at the MSDos format (4 bytes)
+    tmu_date : the SAME new date at the tm_unz format */
+void change_file_date(filename,dosdate,tmu_date)
+    const char *filename;
+    uLong dosdate;
+    tm_unz tmu_date;
+{
+#ifdef _WIN32
+  HANDLE hFile;
+  FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
+
+  hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
+                      0,NULL,OPEN_EXISTING,0,NULL);
+  GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
+  DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
+  LocalFileTimeToFileTime(&ftLocal,&ftm);
+  SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
+  CloseHandle(hFile);
+#else
+#if defined(unix) || defined(__APPLE__)
+  struct utimbuf ut;
+  struct tm newdate;
+  newdate.tm_sec = tmu_date.tm_sec;
+  newdate.tm_min=tmu_date.tm_min;
+  newdate.tm_hour=tmu_date.tm_hour;
+  newdate.tm_mday=tmu_date.tm_mday;
+  newdate.tm_mon=tmu_date.tm_mon;
+  if (tmu_date.tm_year > 1900)
+      newdate.tm_year=tmu_date.tm_year - 1900;
+  else
+      newdate.tm_year=tmu_date.tm_year ;
+  newdate.tm_isdst=-1;
+
+  ut.actime=ut.modtime=mktime(&newdate);
+  utime(filename,&ut);
+#endif
+#endif
+}
+
+
+/* mymkdir and change_file_date are not 100 % portable
+   As I don't know well Unix, I wait feedback for the unix portion */
+
+int mymkdir(dirname)
+    const char* dirname;
+{
+    int ret=0;
+#ifdef _WIN32
+    ret = _mkdir(dirname);
+#else
+#if defined unix || defined __APPLE__
+    ret = mkdir(dirname,0775);
+#endif
+#endif
+    return ret;
+}
+
+int makedir (newdir)
+    char *newdir;
+{
+  char *buffer ;
+  char *p;
+  int  len = (int)strlen(newdir);
+
+  if (len <= 0)
+    return 0;
+
+  buffer = (char*)malloc(len+1);
+        if (buffer==NULL)
+        {
+                printf("Error allocating memory\n");
+                return UNZ_INTERNALERROR;
+        }
+  strcpy(buffer,newdir);
+
+  if (buffer[len-1] == '/') {
+    buffer[len-1] = '\0';
+  }
+  if (mymkdir(buffer) == 0)
+    {
+      free(buffer);
+      return 1;
+    }
+
+  p = buffer+1;
+  while (1)
+    {
+      char hold;
+
+      while(*p && *p != '\\' && *p != '/')
+        p++;
+      hold = *p;
+      *p = 0;
+      if ((mymkdir(buffer) == -1) && (errno == ENOENT))
+        {
+          printf("couldn't create directory %s\n",buffer);
+          free(buffer);
+          return 0;
+        }
+      if (hold == 0)
+        break;
+      *p++ = hold;
+    }
+  free(buffer);
+  return 1;
+}
+
+int do_extract_currentfile(unzFile uf, char * revisionRoot) {
+    char filename_inzip[256];
+    char* filename_withoutpath;
+    char* p;
+    int err=UNZ_OK;
+    FILE *fout=NULL;
+    void* buf;
+    uInt size_buf;
+
+    unz_file_info64 file_info;
+    err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
+
+    if (err!=UNZ_OK)
+    {
+        printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
+        return err;
+    }
+
+    size_buf = WRITEBUFFERSIZE;
+    buf = (void*)malloc(size_buf);
+    if (buf==NULL)
+    {
+        printf("Error allocating memory\n");
+        return UNZ_INTERNALERROR;
+    }
+
+    p = filename_withoutpath = filename_inzip;
+    while ((*p) != '\0')
+    {
+        if (((*p)=='/') || ((*p)=='\\'))
+            filename_withoutpath = p+1;
+        p++;
+    }
+
+    if ((*filename_withoutpath)=='\0') {
+		char dir[strlen(revisionRoot) + strlen(filename_inzip) + 2];
+		strcpy(dir, revisionRoot);
+		strcat(dir, "/");
+		strcat(dir, filename_inzip);
+		mymkdir(dir);
+    }
+    else
+    {
+        const char* write_filename;
+        int skip=0;
+        write_filename = filename_inzip;
+
+        int length = strlen(write_filename) + strlen(revisionRoot) + 2;
+        char fWFN[length];
+        strcpy(fWFN, revisionRoot);
+        strcat(fWFN, "/");
+        strcat(fWFN, write_filename);
+
+        err = unzOpenCurrentFile(uf);
+        if (err!=UNZ_OK)
+        {
+            printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err);
+        }
+
+        if ((skip==0) && (err==UNZ_OK))
+        {
+            fout=fopen64(fWFN,"wb");
+
+            /* some zipfile don't contain directory alone before file */
+            if ((fout==NULL) && (filename_withoutpath!=(char*)filename_inzip))
+            {
+                char c=*(filename_withoutpath-1);
+                *(filename_withoutpath-1)='\0';
+                int length = strlen(write_filename) + strlen(revisionRoot) + 2;
+                char dir[length];
+				strcpy(dir, revisionRoot);
+				strcat(dir, "/");
+				strcat(dir, write_filename);
+                makedir(dir);
+                *(filename_withoutpath-1)=c;
+
+                fout=fopen64(fWFN,"wb");
+            }
+
+            if (fout==NULL)
+            {
+                printf("error opening %s\n",write_filename);
+            }
+        }
+
+        if (fout!=NULL)
+        {
+            do
+            {
+                err = unzReadCurrentFile(uf,buf,size_buf);
+                if (err<0)
+                {
+                    printf("error %d with zipfile in unzReadCurrentFile\n",err);
+                    break;
+                }
+                if (err>0)
+                    if (fwrite(buf,err,1,fout)!=1)
+                    {
+                        printf("error in writing extracted file\n");
+                        err=UNZ_ERRNO;
+                        break;
+                    }
+            }
+            while (err>0);
+            if (fout)
+                    fclose(fout);
+
+            if (err==0)
+                change_file_date(fWFN,file_info.dosDate,
+                                 file_info.tmu_date);
+        }
+
+        if (err==UNZ_OK)
+        {
+            err = unzCloseCurrentFile (uf);
+            if (err!=UNZ_OK)
+            {
+                printf("error %d with zipfile in unzCloseCurrentFile\n",err);
+            }
+        }
+        else
+            unzCloseCurrentFile(uf); /* don't lose the error */
+    }
+
+    free(buf);
+    return err;
+}
+
+
+int do_extract(unzFile uf, char * revisionRoot) {
+    uLong i;
+    unz_global_info64 gi;
+    int err;
+
+    err = unzGetGlobalInfo64(uf,&gi);
+    if (err!=UNZ_OK)
+        printf("error %d with zipfile in unzGetGlobalInfo \n",err);
+
+    for (i=0;i<gi.number_entry;i++)
+    {
+        if (do_extract_currentfile(uf, revisionRoot) != UNZ_OK)
+            break;
+
+        if ((i+1)<gi.number_entry)
+        {
+            err = unzGoToNextFile(uf);
+            if (err!=UNZ_OK)
+            {
+                printf("error %d with zipfile in unzGoToNextFile\n",err);
+                break;
+            }
+        }
+    }
+
+    return 0;
+}
+
+celix_status_t unzip_extractDeploymentPackage(char * packageName, char * destination) {
+    celix_status_t status = CELIX_SUCCESS;
+    char filename_try[MAXFILENAME+16] = "";
+    unzFile uf=NULL;
+
+    if (packageName!=NULL)
+    {
+
+#        ifdef USEWIN32IOAPI
+        zlib_filefunc64_def ffunc;
+#        endif
+
+        strncpy(filename_try, packageName,MAXFILENAME-1);
+        /* strncpy doesnt append the trailing NULL, of the string is too long. */
+        filename_try[ MAXFILENAME ] = '\0';
+
+#        ifdef USEWIN32IOAPI
+        fill_win32_filefunc64A(&ffunc);
+        uf = unzOpen2_64(bundleName,&ffunc);
+#        else
+        uf = unzOpen64(packageName);
+#        endif
+        if (uf==NULL)
+        {
+            strcat(filename_try,".zip");
+#            ifdef USEWIN32IOAPI
+            uf = unzOpen2_64(filename_try,&ffunc);
+#            else
+            uf = unzOpen64(filename_try);
+#            endif
+        }
+    }
+
+    if (uf==NULL)
+    {
+        printf("Cannot open %s or %s.zip\n",packageName,packageName);
+        status = CELIX_FILE_IO_EXCEPTION;
+    } else {
+        if (do_extract(uf, destination) != 0) {
+            status = CELIX_FILE_IO_EXCEPTION;
+        }
+
+        unzClose(uf);
+    }
+
+    return status;
+}


[17/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/capability.c
----------------------------------------------------------------------
diff --git a/framework/src/capability.c b/framework/src/capability.c
new file mode 100644
index 0000000..9e4dc3a
--- /dev/null
+++ b/framework/src/capability.c
@@ -0,0 +1,100 @@
+/**
+ *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.
+ */
+/*
+ * capability.c
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "capability_private.h"
+#include "attribute.h"
+#include "celix_log.h"
+
+celix_status_t capability_create(module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability) {
+	celix_status_t status;
+	*capability = (capability_pt) malloc(sizeof(**capability));
+	if (!*capability) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*capability)->module = module;
+		(*capability)->attributes = attributes;
+		(*capability)->directives = directives;
+		(*capability)->version = NULL;
+
+		attribute_pt versionAttribute = NULL;
+		attribute_pt serviceAttribute = (attribute_pt) hashMap_get(attributes, "service");
+		status = attribute_getValue(serviceAttribute, &(*capability)->serviceName);
+		if (status == CELIX_SUCCESS) {
+			versionAttribute = (attribute_pt) hashMap_get(attributes, "version");
+			if (versionAttribute != NULL) {
+				char *versionStr = NULL;
+				attribute_getValue(versionAttribute, &versionStr);
+				status = version_createVersionFromString(versionStr, &(*capability)->version);
+			} else {
+				status = version_createEmptyVersion(&(*capability)->version);
+			}
+		}
+
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to create capability");
+
+	return status;
+}
+
+celix_status_t capability_destroy(capability_pt capability) {
+	hash_map_iterator_pt attrIter = hashMapIterator_create(capability->attributes);
+	while (hashMapIterator_hasNext(attrIter)) {
+		attribute_pt attr = hashMapIterator_nextValue(attrIter);
+		hashMapIterator_remove(attrIter);
+		attribute_destroy(attr);
+	}
+	hashMapIterator_destroy(attrIter);
+	hashMap_destroy(capability->attributes, false, false);
+	hashMap_destroy(capability->directives, false, false);
+
+	capability->attributes = NULL;
+	capability->directives = NULL;
+	capability->module = NULL;
+
+	version_destroy(capability->version);
+	capability->version = NULL;
+
+	free(capability);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t capability_getServiceName(capability_pt capability, const char **serviceName) {
+	*serviceName = capability->serviceName;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t capability_getVersion(capability_pt capability, version_pt *version) {
+	*version = capability->version;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t capability_getModule(capability_pt capability, module_pt *module) {
+	*module = capability->module;
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/capability_private.h
----------------------------------------------------------------------
diff --git a/framework/src/capability_private.h b/framework/src/capability_private.h
new file mode 100644
index 0000000..5e302a5
--- /dev/null
+++ b/framework/src/capability_private.h
@@ -0,0 +1,41 @@
+/**
+ *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.
+ */
+/*
+ * capability_private.h
+ *
+ *  \date       Feb 11, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef CAPABILITY_PRIVATE_H_
+#define CAPABILITY_PRIVATE_H_
+
+#include "capability.h"
+
+struct capability {
+	char * serviceName;
+	module_pt module;
+	version_pt version;
+	hash_map_pt attributes;
+	hash_map_pt directives;
+};
+
+#endif /* CAPABILITY_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/celix_errorcodes.c
----------------------------------------------------------------------
diff --git a/framework/src/celix_errorcodes.c b/framework/src/celix_errorcodes.c
new file mode 100644
index 0000000..80323e7
--- /dev/null
+++ b/framework/src/celix_errorcodes.c
@@ -0,0 +1,64 @@
+/**
+ *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_errorcodes.c
+ *
+ *  \date       Aug 30, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <string.h>
+
+#include "celix_errno.h"
+
+static char* celix_error_string(celix_status_t statcode) {
+	switch (statcode) {
+        case CELIX_BUNDLE_EXCEPTION:
+            return "Bundle exception";
+        case CELIX_INVALID_BUNDLE_CONTEXT:
+            return "Invalid bundle context";
+        case CELIX_ILLEGAL_ARGUMENT:
+            return "Illegal argument";
+        case CELIX_INVALID_SYNTAX:
+            return "Invalid syntax";
+        case CELIX_FRAMEWORK_SHUTDOWN:
+            return "Framework shutdown";
+        case CELIX_ILLEGAL_STATE:
+            return "Illegal state";
+        case CELIX_FRAMEWORK_EXCEPTION:
+            return "Framework exception";
+        case CELIX_FILE_IO_EXCEPTION:
+            return "File I/O exception";
+        case CELIX_SERVICE_EXCEPTION:
+            return "Service exception";
+        default:
+            return "Unknown code";
+	}
+}
+
+char* celix_strerror(celix_status_t errorcode, char *buffer, size_t bufferSize) {
+    if (errorcode < CELIX_START_ERROR) {
+        return strerror(errorcode);
+    } else {
+    	char * str = celix_error_string(errorcode);
+    	strncpy(buffer, str, bufferSize);
+        return buffer;
+    }
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/celix_launcher.c
----------------------------------------------------------------------
diff --git a/framework/src/celix_launcher.c b/framework/src/celix_launcher.c
new file mode 100644
index 0000000..ba83f25
--- /dev/null
+++ b/framework/src/celix_launcher.c
@@ -0,0 +1,242 @@
+/**
+ *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_launcher.c
+ *
+ *  \date       Mar 23, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include "celix_launcher.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <libgen.h>
+#include <signal.h>
+
+#ifndef CELIX_NO_CURLINIT
+#include <curl/curl.h>
+#endif
+
+#include <string.h>
+#include <curl/curl.h>
+#include <signal.h>
+#include <libgen.h>
+#include "celix_launcher.h"
+#include "framework.h"
+#include "linked_list_iterator.h"
+
+static void show_usage(char* prog_name);
+static void shutdown_framework(int signal);
+static void ignore(int signal);
+
+#define DEFAULT_CONFIG_FILE "config.properties"
+
+static framework_pt framework = NULL;
+
+int celixLauncher_launchWithArgs(int argc, char *argv[]) {
+	// Perform some minimal command-line option parsing...
+	char *opt = NULL;
+	if (argc > 1) {
+		opt = argv[1];
+	}
+
+	char *config_file = NULL;
+
+	if (opt) {
+		// Check whether the user wants some help...
+		if (strcmp("-h", opt) == 0 || strcmp("-help", opt) == 0) {
+			show_usage(argv[0]);
+			return 0;
+		} else {
+			config_file = opt;
+		}
+	} else {
+		config_file = DEFAULT_CONFIG_FILE;
+	}
+
+	struct sigaction sigact;
+	memset(&sigact, 0, sizeof(sigact));
+	sigact.sa_handler = shutdown_framework;
+	sigaction(SIGINT,  &sigact, NULL);
+	sigaction(SIGTERM, &sigact, NULL);
+
+	memset(&sigact, 0, sizeof(sigact));
+	sigact.sa_handler = ignore;
+	sigaction(SIGUSR1,  &sigact, NULL);
+	sigaction(SIGUSR2,  &sigact, NULL);
+
+	int rc = celixLauncher_launch(config_file, &framework);
+	if (rc == 0) {
+		celixLauncher_waitForShutdown(framework);
+		celixLauncher_destroy(framework);
+	}
+	return rc;
+}
+
+static void show_usage(char* prog_name) {
+	printf("Usage:\n  %s [path/to/config.properties]\n\n", basename(prog_name));
+}
+
+static void shutdown_framework(int signal) {
+	if (framework != NULL) {
+		celixLauncher_stop(framework); //NOTE main thread will destroy
+	}
+}
+
+static void ignore(int signal) {
+	//ignoring for signal SIGUSR1, SIGUSR2. Can be used on threads
+}
+
+int celixLauncher_launch(const char *configFile, framework_pt *framework) {
+	int status = 0;
+	FILE *config = fopen(configFile, "r");
+	if (config != NULL) {
+		status = celixLauncher_launchWithStream(config, framework);
+	} else {
+		fprintf(stderr, "Error: invalid or non-existing configuration file: '%s'.", configFile);
+		perror("");
+		status = 1;
+	}
+	return status;
+}
+
+int celixLauncher_launchWithStream(FILE *stream, framework_pt *framework) {
+	int status = 0;
+
+	properties_pt config = properties_loadWithStream(stream);
+	fclose(stream);
+	// Make sure we've read it and that nothing went wrong with the file access...
+	if (config == NULL) {
+		fprintf(stderr, "Error: invalid configuration file");
+		perror(NULL);
+		status = 1;
+	}
+	else {
+		status = celixLauncher_launchWithProperties(config, framework);
+	}
+
+	return status;
+}
+
+
+int celixLauncher_launchWithProperties(properties_pt config, framework_pt *framework) {
+	celix_status_t status;
+#ifndef CELIX_NO_CURLINIT
+	// Before doing anything else, let's setup Curl
+	curl_global_init(CURL_GLOBAL_NOTHING);
+#endif
+
+	const char* autoStartProp = properties_get(config, "cosgi.auto.start.1");
+	char* autoStart = NULL;
+	if (autoStartProp != NULL) {
+		autoStart = strndup(autoStartProp, 1024*10);
+	}
+
+	status = framework_create(framework, config);
+	bundle_pt fwBundle = NULL;
+	if (status == CELIX_SUCCESS) {
+		status = fw_init(*framework);
+		if (status == CELIX_SUCCESS) {
+			// Start the system bundle
+			status = framework_getFrameworkBundle(*framework, &fwBundle);
+
+			if(status == CELIX_SUCCESS){
+				bundle_start(fwBundle);
+
+				char delims[] = " ";
+				char *result = NULL;
+				char *save_ptr = NULL;
+				linked_list_pt bundles;
+				array_list_pt installed = NULL;
+				bundle_context_pt context = NULL;
+				linked_list_iterator_pt iter = NULL;
+				unsigned int i;
+
+				linkedList_create(&bundles);
+				result = strtok_r(autoStart, delims, &save_ptr);
+				while (result != NULL) {
+					char *location = strdup(result);
+					linkedList_addElement(bundles, location);
+					result = strtok_r(NULL, delims, &save_ptr);
+				}
+				// First install all bundles
+				// Afterwards start them
+				arrayList_create(&installed);
+				bundle_getContext(fwBundle, &context);
+				iter = linkedListIterator_create(bundles, 0);
+				while (linkedListIterator_hasNext(iter)) {
+					bundle_pt current = NULL;
+					char *location = (char *) linkedListIterator_next(iter);
+					if (bundleContext_installBundle(context, location, &current) == CELIX_SUCCESS) {
+						// Only add bundle if it is installed correctly
+						arrayList_add(installed, current);
+					} else {
+						printf("Could not install bundle from %s\n", location);
+					}
+					linkedListIterator_remove(iter);
+					free(location);
+				}
+				linkedListIterator_destroy(iter);
+				linkedList_destroy(bundles);
+
+				for (i = 0; i < arrayList_size(installed); i++) {
+					bundle_pt installedBundle = (bundle_pt) arrayList_get(installed, i);
+					bundle_startWithOptions(installedBundle, 0);
+				}
+
+				arrayList_destroy(installed);
+			}
+		}
+	}
+
+	if (status != CELIX_SUCCESS) {
+		printf("Problem creating framework\n");
+	}
+
+	printf("Launcher: Framework Started\n");
+
+	free(autoStart);
+	
+	return status;
+}
+
+void celixLauncher_waitForShutdown(framework_pt framework) {
+	framework_waitForStop(framework);
+}
+
+void celixLauncher_destroy(framework_pt framework) {
+	framework_destroy(framework);
+
+#ifndef CELIX_NO_CURLINIT
+	// Cleanup Curl
+	curl_global_cleanup();
+#endif
+
+	printf("Launcher: Exit\n");
+}
+
+void celixLauncher_stop(framework_pt framework) {
+	bundle_pt fwBundle = NULL;
+	if( framework_getFrameworkBundle(framework, &fwBundle) == CELIX_SUCCESS){
+		bundle_stop(fwBundle);
+	}
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/celix_log.c
----------------------------------------------------------------------
diff --git a/framework/src/celix_log.c b/framework/src/celix_log.c
new file mode 100644
index 0000000..c4d51e2
--- /dev/null
+++ b/framework/src/celix_log.c
@@ -0,0 +1,83 @@
+/**
+ *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_log.c
+ *
+ *  \date       6 Oct 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+#include <stdarg.h>
+
+#include "celix_errno.h"
+#include "celix_log.h"
+
+void framework_log(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line, const char *fmsg, ...) {
+    char msg[512];
+    va_list listPointer;
+    va_start(listPointer, fmsg);
+    vsprintf(msg, fmsg, listPointer);
+
+    //FIXME logger and/or logger->logFucntion can be null. But this solution is not thread safe!
+    if (logger != NULL && logger->logFunction != NULL) {
+        logger->logFunction(level, func, file, line, msg);
+    }
+
+    va_end(listPointer);
+}
+
+void framework_logCode(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line, celix_status_t code, const char *fmsg, ...) {
+    char message[256];
+    celix_strerror(code, message, 256);
+    char msg[512];
+    va_list listPointer;
+    va_start(listPointer, fmsg);
+    vsprintf(msg, fmsg, listPointer);
+
+    framework_log(logger, level, func, file, line, "%s [%d]: %s", message, code, msg);
+
+    va_end(listPointer);
+}
+
+celix_status_t frameworkLogger_log(framework_log_level_t level, const char *func, const char *file, int line, const char *msg) {
+    char *levelStr = NULL;
+    switch (level) {
+        case OSGI_FRAMEWORK_LOG_ERROR:
+            levelStr = "ERROR";
+            break;
+        case OSGI_FRAMEWORK_LOG_WARNING:
+            levelStr = "WARNING";
+            break;
+        case OSGI_FRAMEWORK_LOG_INFO:
+            levelStr = "INFO";
+            break;
+        case OSGI_FRAMEWORK_LOG_DEBUG:
+        default:
+            levelStr = "DEBUG";
+            break;
+    }
+
+    if (level == OSGI_FRAMEWORK_LOG_ERROR) {
+        printf("%s: %s\n\tat %s(%s:%d)\n", levelStr, msg, func, file, line);
+    } else {
+        printf("%s: %s\n", levelStr, msg);
+    }
+
+    return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/filter.c
----------------------------------------------------------------------
diff --git a/framework/src/filter.c b/framework/src/filter.c
new file mode 100644
index 0000000..f06d6e8
--- /dev/null
+++ b/framework/src/filter.c
@@ -0,0 +1,687 @@
+/**
+ *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.
+ */
+/*
+ * filter.c
+ *
+ *  \date       Apr 28, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "celix_log.h"
+#include "filter_private.h"
+
+static void filter_skipWhiteSpace(char* filterString, int* pos);
+static filter_pt filter_parseFilter(char* filterString, int* pos);
+static filter_pt filter_parseFilterComp(char* filterString, int* pos);
+static filter_pt filter_parseAnd(char* filterString, int* pos);
+static filter_pt filter_parseOr(char* filterString, int* pos);
+static filter_pt filter_parseNot(char* filterString, int* pos);
+static filter_pt filter_parseItem(char* filterString, int* pos);
+static char * filter_parseAttr(char* filterString, int* pos);
+static char * filter_parseValue(char* filterString, int* pos);
+static array_list_pt filter_parseSubstring(char* filterString, int* pos);
+
+static celix_status_t filter_compare(OPERAND operand, char * string, void * value2, bool *result);
+static celix_status_t filter_compareString(OPERAND operand, char * string, void * value2, bool *result);
+
+static void filter_skipWhiteSpace(char * filterString, int * pos) {
+	int length;
+	for (length = strlen(filterString); (*pos < length) && isspace(filterString[*pos]);) {
+		(*pos)++;
+	}
+}
+
+filter_pt filter_create(const char* filterString) {
+	filter_pt filter = NULL;
+	char* filterStr = (char*) filterString;
+	int pos = 0;
+	filter = filter_parseFilter(filterStr, &pos);
+	if (pos != strlen(filterStr)) {
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error: Extraneous trailing characters.");
+		filter_destroy(filter);
+		return NULL;
+	}
+	if(filter != NULL){
+		filter->filterStr = filterStr;
+	} 
+
+	return filter;
+}
+
+void filter_destroy(filter_pt filter) {
+	if (filter != NULL) {
+		if(filter->value!=NULL){
+			if (filter->operand == SUBSTRING) {
+				int size = arrayList_size(filter->value);
+				for (; size > 0; --size) {
+					char* operand = (char*) arrayList_remove(filter->value, 0);
+					free(operand);
+				}
+				arrayList_destroy(filter->value);
+				filter->value = NULL;
+			} else if ( (filter->operand == OR) || (filter->operand == AND) ) {
+				int size = arrayList_size(filter->value);
+				unsigned int i = 0;
+				for (i = 0; i < size; i++) {
+					filter_pt f = arrayList_get(filter->value, i);
+					filter_destroy(f);
+				}
+				arrayList_destroy(filter->value);
+				filter->value = NULL;
+			} else  if (filter->operand == NOT) {
+				filter_destroy(filter->value);
+				filter->value = NULL;
+			} else {
+				free(filter->value);
+				filter->value = NULL;
+			}
+		}
+		free(filter->attribute);
+		filter->attribute = NULL;
+		free(filter);
+		filter = NULL;
+	}
+}
+
+static filter_pt filter_parseFilter(char * filterString, int * pos) {
+	filter_pt filter;
+	filter_skipWhiteSpace(filterString, pos);
+	if (filterString[*pos] != '(') {
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing '(' in filter string '%s'.", filterString);
+		return NULL;
+	}
+	(*pos)++;
+
+	filter = filter_parseFilterComp(filterString, pos);
+
+	filter_skipWhiteSpace(filterString, pos);
+
+	if (filterString[*pos] != ')') {
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing ')' in filter string '%s'.", filterString);
+		if(filter!=NULL){
+			filter_destroy(filter);
+		}
+		return NULL;
+	}
+	(*pos)++;
+	filter_skipWhiteSpace(filterString, pos);
+
+	if(filter != NULL){
+		if(filter->value == NULL && filter->operand!=PRESENT){
+			filter_destroy(filter);
+			return NULL;
+		}
+	}
+
+	return filter;
+}
+
+static filter_pt filter_parseFilterComp(char * filterString, int * pos) {
+	char c;
+	filter_skipWhiteSpace(filterString, pos);
+
+	c = filterString[*pos];
+
+	switch (c) {
+		case '&': {
+			(*pos)++;
+			return filter_parseAnd(filterString, pos);
+		}
+		case '|': {
+			(*pos)++;
+			return filter_parseOr(filterString, pos);
+		}
+		case '!': {
+			(*pos)++;
+			return filter_parseNot(filterString, pos);
+		}
+	}
+	return filter_parseItem(filterString, pos);
+}
+
+static filter_pt filter_parseAnd(char * filterString, int * pos) {
+
+	array_list_pt operands = NULL;
+	filter_skipWhiteSpace(filterString, pos);
+	bool failure = false;
+
+	if (filterString[*pos] != '(') {
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing '('.");
+		return NULL;
+	}
+
+	arrayList_create(&operands);
+	while(filterString[*pos] == '(') {
+		filter_pt child = filter_parseFilter(filterString, pos);
+		if(child == NULL){
+			failure = true;
+			break;
+		}
+		arrayList_add(operands, child);
+	}
+
+	if(failure == true){
+		array_list_iterator_pt listIt = arrayListIterator_create(operands);
+		while(arrayListIterator_hasNext(listIt)){
+			filter_pt f = arrayListIterator_next(listIt);
+			filter_destroy(f);
+		}
+		arrayListIterator_destroy(listIt);
+		arrayList_destroy(operands);
+		operands = NULL;
+	}
+
+	filter_pt filter = (filter_pt) malloc(sizeof(*filter));
+	filter->operand = AND;
+	filter->attribute = NULL;
+	filter->value = operands;
+
+	return filter;
+}
+
+static filter_pt filter_parseOr(char * filterString, int * pos) {
+
+	array_list_pt operands = NULL;
+
+	filter_skipWhiteSpace(filterString, pos);
+	bool failure = false;
+
+	if (filterString[*pos] != '(') {
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing '('.");
+		return NULL;
+	}
+
+	arrayList_create(&operands);
+	while(filterString[*pos] == '(') {
+		filter_pt child = filter_parseFilter(filterString, pos);
+		if(child == NULL){
+			failure = true;
+			break;
+		}
+		arrayList_add(operands, child);
+	}
+
+	if(failure == true){
+		array_list_iterator_pt listIt = arrayListIterator_create(operands);
+		while(arrayListIterator_hasNext(listIt)){
+			filter_pt f = arrayListIterator_next(listIt);
+			filter_destroy(f);
+		}
+		arrayListIterator_destroy(listIt);
+		arrayList_destroy(operands);
+		operands = NULL;
+	}
+
+	filter_pt filter = (filter_pt) malloc(sizeof(*filter));
+	filter->operand = OR;
+	filter->attribute = NULL;
+	filter->value = operands;
+
+	return filter;
+}
+
+static filter_pt filter_parseNot(char * filterString, int * pos) {
+	filter_pt child = NULL;
+	filter_skipWhiteSpace(filterString, pos);
+
+	if (filterString[*pos] != '(') {
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: Missing '('.");
+		return NULL;
+	}
+
+	child = filter_parseFilter(filterString, pos);
+
+
+	filter_pt filter = (filter_pt) malloc(sizeof(*filter));
+	filter->operand = NOT;
+	filter->attribute = NULL;
+	filter->value = child;
+
+	return filter;
+}
+
+static filter_pt filter_parseItem(char * filterString, int * pos) {
+	char * attr = filter_parseAttr(filterString, pos);
+	if(attr == NULL){
+		return NULL;
+	}
+
+	filter_skipWhiteSpace(filterString, pos);
+	switch(filterString[*pos]) {
+		case '~': {
+			if (filterString[*pos + 1] == '=') {
+				filter_pt filter = (filter_pt) malloc(sizeof(*filter));
+				*pos += 2;
+				filter->operand = APPROX;
+				filter->attribute = attr;
+				filter->value = filter_parseValue(filterString, pos);
+				return filter;
+			}
+			break;
+		}
+		case '>': {
+			if (filterString[*pos + 1] == '=') {
+				filter_pt filter = (filter_pt) malloc(sizeof(*filter));
+				*pos += 2;
+				filter->operand = GREATEREQUAL;
+				filter->attribute = attr;
+				filter->value = filter_parseValue(filterString, pos);
+				return filter;
+			}
+			else {
+                filter_pt filter = (filter_pt) malloc(sizeof(*filter));
+                *pos += 1;
+                filter->operand = GREATER;
+                filter->attribute = attr;
+                filter->value = filter_parseValue(filterString, pos);
+                return filter;
+			}
+			break;
+		}
+		case '<': {
+			if (filterString[*pos + 1] == '=') {
+				filter_pt filter = (filter_pt) malloc(sizeof(*filter));
+				*pos += 2;
+				filter->operand = LESSEQUAL;
+				filter->attribute = attr;
+				filter->value = filter_parseValue(filterString, pos);
+				return filter;
+			}
+			else {
+                filter_pt filter = (filter_pt) malloc(sizeof(*filter));
+                *pos += 1;
+                filter->operand = LESS;
+                filter->attribute = attr;
+                filter->value = filter_parseValue(filterString, pos);
+                return filter;
+			}
+			break;
+		}
+		case '=': {
+			filter_pt filter = NULL;
+			array_list_pt subs;
+			if (filterString[*pos + 1] == '*') {
+				int oldPos = *pos;
+				*pos += 2;
+				filter_skipWhiteSpace(filterString, pos);
+				if (filterString[*pos] == ')') {
+					filter_pt filter = (filter_pt) malloc(sizeof(*filter));
+					filter->operand = PRESENT;
+					filter->attribute = attr;
+					filter->value = NULL;
+					return filter;
+				}
+				*pos = oldPos;
+			}
+			filter = (filter_pt) malloc(sizeof(*filter));			
+			(*pos)++;
+			subs = filter_parseSubstring(filterString, pos);
+			if(subs!=NULL){
+				if (arrayList_size(subs) == 1) {
+					char * string = (char *) arrayList_get(subs, 0);
+					if (string != NULL) {
+						filter->operand = EQUAL;
+						filter->attribute = attr;
+						filter->value = string;
+
+						arrayList_clear(subs);
+						arrayList_destroy(subs);
+
+						return filter;
+					}
+				}
+			}
+			filter->operand = SUBSTRING;
+			filter->attribute = attr;
+			filter->value = subs;
+			return filter;
+		}
+	}
+	fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Invalid operator.");
+	free(attr);
+	return NULL;
+}
+
+static char * filter_parseAttr(char * filterString, int * pos) {
+	char c;
+	int begin = *pos;
+	int end = *pos;
+	int length = 0;
+
+	filter_skipWhiteSpace(filterString, pos);
+	c = filterString[*pos];
+
+	while (c != '~' && c != '<' && c != '>' && c != '=' && c != '(' && c != ')') {
+		(*pos)++;
+
+		if (!isspace(c)) {
+			end = *pos;
+		}
+
+		c = filterString[*pos];
+	}
+
+	length = end - begin;
+
+	if (length == 0) {
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Missing attr.");
+		return NULL;
+	} else {
+		char * attr = (char *) malloc(length+1);
+		strncpy(attr, filterString+begin, length);
+		attr[length] = '\0';
+		return attr;
+	}
+}
+
+static char * filter_parseValue(char * filterString, int * pos) {
+	char *value = calloc(strlen(filterString) + 1, sizeof(*value));
+	int keepRunning = 1;
+
+	while (keepRunning) {
+		char c = filterString[*pos];
+
+		switch (c) {
+			case ')': {
+				keepRunning = 0;
+				break;
+			}
+			case '(': {
+				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Invalid value.");
+				free(value);
+				return NULL;
+			}
+			case '\0':{
+				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Unclosed bracket.");
+				free(value);
+				return NULL;
+			}
+			case '\\': {
+				(*pos)++;
+				c = filterString[*pos];
+			}
+			/* no break */
+			default: {
+				char ch[2];
+				ch[0] = c;
+				ch[1] = '\0';
+				strcat(value, ch);
+				(*pos)++;
+				break;
+			}
+		}
+	}
+
+	if (strlen(value) == 0) {
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Missing value.");
+		free(value);
+		return NULL;
+	}
+	return value;
+}
+
+static array_list_pt filter_parseSubstring(char * filterString, int * pos) {
+	char *sub = calloc(strlen(filterString) + 1, sizeof(*sub));
+	array_list_pt operands = NULL;
+	int keepRunning = 1;
+
+	arrayList_create(&operands);
+	while (keepRunning) {
+		char c = filterString[*pos];
+		
+
+		switch (c) {
+			case ')': {
+				if (strlen(sub) > 0) {
+					arrayList_add(operands, strdup(sub));
+				}
+				keepRunning = 0;
+				break;
+			}
+			case '\0':{
+				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Unclosed bracket.");
+				keepRunning = false;
+				break;
+			}
+			case '(': {
+				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Invalid value.");
+				keepRunning = false;
+				break;
+			}
+			case '*': {
+				if (strlen(sub) > 0) {
+					arrayList_add(operands, strdup(sub));
+				}
+				sub[0] = '\0';
+				arrayList_add(operands, NULL);
+				(*pos)++;
+				break;
+			}
+			case '\\': {
+				(*pos)++;
+				c = filterString[*pos];
+			}
+			/* no break */
+			default: {
+				char ch[2];
+				ch[0] = c;
+				ch[1] = '\0';
+				strcat(sub, ch);
+				(*pos)++;
+				break;
+			}
+		}
+	}
+	free(sub);
+
+	if (arrayList_size(operands) == 0) {
+		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Missing value.");
+		arrayList_destroy(operands);
+		return NULL;
+	}
+
+	return operands;
+}
+
+celix_status_t filter_match(filter_pt filter, properties_pt properties, bool *result) {
+	switch (filter->operand) {
+		case AND: {
+			array_list_pt filters = (array_list_pt) filter->value;
+			unsigned int i;
+			for (i = 0; i < arrayList_size(filters); i++) {
+				filter_pt sfilter = (filter_pt) arrayList_get(filters, i);
+				bool mresult;
+				filter_match(sfilter, properties, &mresult);
+				if (!mresult) {
+					*result = 0;
+					return CELIX_SUCCESS;
+				}
+			}
+			*result = 1;
+			return CELIX_SUCCESS;
+		}
+		case OR: {
+			array_list_pt filters = (array_list_pt) filter->value;
+			unsigned int i;
+			for (i = 0; i < arrayList_size(filters); i++) {
+				filter_pt sfilter = (filter_pt) arrayList_get(filters, i);
+				bool mresult;
+				filter_match(sfilter, properties, &mresult);
+				if (mresult) {
+					*result = 1;
+					return CELIX_SUCCESS;
+				}
+			}
+			*result = 0;
+			return CELIX_SUCCESS;
+		}
+		case NOT: {
+			filter_pt sfilter = (filter_pt) filter->value;
+			bool mresult;
+			filter_match(sfilter, properties, &mresult);
+			*result = !mresult;
+			return CELIX_SUCCESS;
+		}
+		case SUBSTRING :
+		case EQUAL :
+		case GREATER :
+        case GREATEREQUAL :
+		case LESS :
+        case LESSEQUAL :
+		case APPROX : {
+			char * value = (properties == NULL) ? NULL: (char*)properties_get(properties, filter->attribute);
+
+			return filter_compare(filter->operand, value, filter->value, result);
+		}
+		case PRESENT: {
+			char * value = (properties == NULL) ? NULL: (char*)properties_get(properties, filter->attribute);
+			*result = value != NULL;
+			return CELIX_SUCCESS;
+		}
+	}
+	*result = 0;
+	return CELIX_SUCCESS;
+}
+
+static celix_status_t filter_compare(OPERAND operand, char * string, void * value2, bool *result) {
+	if (string == NULL) {
+		*result = 0;
+		return CELIX_SUCCESS;
+	}
+	return filter_compareString(operand, string, value2, result);
+
+}
+
+static celix_status_t filter_compareString(OPERAND operand, char * string, void * value2, bool *result) {
+	switch (operand) {
+		case SUBSTRING: {
+			array_list_pt subs = (array_list_pt) value2;
+			int pos = 0;
+			unsigned int i;
+			int size = arrayList_size(subs);
+			for (i = 0; i < size; i++) {
+				char * substr = (char *) arrayList_get(subs, i);
+
+				if (i + 1 < size) {
+					if (substr == NULL) {
+						unsigned int index;
+						char * substr2 = (char *) arrayList_get(subs, i + 1);
+						if (substr2 == NULL) {
+							continue;
+						}
+						index = strcspn(string+pos, substr2);
+						if (index == strlen(string+pos)) {
+							*result = false;
+							return CELIX_SUCCESS;
+						}
+
+						pos = index + strlen(substr2);
+						if (i + 2 < size) {
+							i++;
+						}
+					} else {
+						unsigned int len = strlen(substr);
+						char * region = (char *)malloc(len+1);
+						strncpy(region, string+pos, len);
+						region[len]	= '\0';
+						if (strcmp(region, substr) == 0) {
+							pos += len;
+						} else {
+							free(region);
+							*result = false;
+							return CELIX_SUCCESS;
+						}
+						free(region);
+					}
+				} else {
+					unsigned int len;
+					int begin;
+
+					if (substr == NULL) {
+						*result = true;
+						return CELIX_SUCCESS;
+					}
+					len = strlen(substr);
+					begin = strlen(string)-len;
+					*result = (strcmp(string+begin, substr) == 0);
+					return CELIX_SUCCESS;
+				}
+			}
+			*result = true;
+			return CELIX_SUCCESS;
+		}
+		case APPROX: //TODO: Implement strcmp with ignorecase and ignorespaces
+		case EQUAL: {
+			*result = (strcmp(string, (char *) value2) == 0);
+			return CELIX_SUCCESS;
+		}
+		case GREATER: {
+			*result = (strcmp(string, (char *) value2) > 0);
+			return CELIX_SUCCESS;
+		}
+        case GREATEREQUAL: {
+            *result = (strcmp(string, (char *) value2) >= 0);
+            return CELIX_SUCCESS;
+        }
+		case LESS: {
+			*result = (strcmp(string, (char *) value2) < 0);
+			return CELIX_SUCCESS;
+		}
+        case LESSEQUAL: {
+            *result = (strcmp(string, (char *) value2) <= 0);
+            return CELIX_SUCCESS;
+        }
+		case AND:
+		case NOT:
+		case OR:
+		case PRESENT: {
+		}
+		/* no break */
+	}
+	*result = false;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t filter_getString(filter_pt filter, const char **filterStr) {
+	if (filter != NULL) {
+		*filterStr = filter->filterStr;
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t filter_match_filter(filter_pt src, filter_pt dest, bool *result) {
+	char *srcStr = NULL;
+	char *destStr = NULL;
+	*result = false;
+
+	if (src) srcStr = src->filterStr;
+	if (dest) destStr = dest->filterStr;
+
+	if ((srcStr != NULL) && (destStr != NULL)) {
+		// TODO: should be done smarted, e.g. src="&(a=1)(b=2)" and dest="&(b=2)(a=1)" should result in true
+		*result = (strcmp(srcStr, destStr) == 0);
+	}
+
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/filter_private.h
----------------------------------------------------------------------
diff --git a/framework/src/filter_private.h b/framework/src/filter_private.h
new file mode 100644
index 0000000..d19de2d
--- /dev/null
+++ b/framework/src/filter_private.h
@@ -0,0 +1,57 @@
+/**
+ *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.
+ */
+/*
+ * filter_private.h
+ *
+ *  \date       Feb 13, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef FILTER_PRIVATE_H_
+#define FILTER_PRIVATE_H_
+
+#include "filter.h"
+#include "array_list.h"
+
+typedef enum operand
+{
+	EQUAL,
+	APPROX,
+	GREATER,
+    GREATEREQUAL,
+	LESS,
+	LESSEQUAL,
+	PRESENT,
+	SUBSTRING,
+	AND,
+	OR,
+	NOT,
+} OPERAND;
+
+struct filter {
+	OPERAND operand;
+	char * attribute;
+	void * value;
+	char *filterStr;
+};
+
+
+#endif /* FILTER_PRIVATE_H_ */


[28/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/CMakeLists.txt b/examples/dm_example_cxx/CMakeLists.txt
index 9572142..1a47113 100644
--- a/examples/dm_example_cxx/CMakeLists.txt
+++ b/examples/dm_example_cxx/CMakeLists.txt
@@ -19,7 +19,6 @@ if (BUILD_DEPENDENCY_MANAGER_CXX)
             ${PROJECT_SOURCE_DIR}/dependency_manager/public/include
             ${PROJECT_SOURCE_DIR}/dependency_manager_cxx/include
             ${PROJECT_SOURCE_DIR}/utils/public/include
-            ${PROJECT_SOURCE_DIR}/shell/public/include
             ${PROJECT_SOURCE_DIR}/log_service/public/include
             api
     )
@@ -33,10 +32,10 @@ if (BUILD_DEPENDENCY_MANAGER_CXX)
 
     add_deploy("dm_example_cxx"
         COPY 
-	CXX
+	    CXX
         BUNDLES
-            shell
-            shell_tui
+            Celix::shell
+            Celix::shell_tui
             dm_shell
             log_service
             log_writer
@@ -56,7 +55,7 @@ if (BUILD_DEPENDENCY_MANAGER_CXX)
             BUNDLES_DIR /usr/share/bundles
             WORKDIR /workspace
             BUNDLES
-                shell
+                celix_shell
                 shell_tui
                 dm_shell
                 log_service

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example_cxx/phase1/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase1/CMakeLists.txt b/examples/dm_example_cxx/phase1/CMakeLists.txt
index 3c0544a..728278b 100644
--- a/examples/dm_example_cxx/phase1/CMakeLists.txt
+++ b/examples/dm_example_cxx/phase1/CMakeLists.txt
@@ -31,12 +31,12 @@ add_bundle(phase1_cxx
 target_compile_options(phase1_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
 
 IF(APPLE)
-    target_link_libraries(phase1_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static)
+    target_link_libraries(phase1_cxx PRIVATE  -Wl,-all_load dependency_manager_cxx_static Celix::shell_api)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(phase1_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase1_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive Celix::shell_api)
     else()
-        target_link_libraries(phase1_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase1_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive Celix::shell_api)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example_cxx/phase2a/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase2a/CMakeLists.txt b/examples/dm_example_cxx/phase2a/CMakeLists.txt
index 8528078..4e2e673 100644
--- a/examples/dm_example_cxx/phase2a/CMakeLists.txt
+++ b/examples/dm_example_cxx/phase2a/CMakeLists.txt
@@ -14,12 +14,6 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-
-include_directories(
-        ../phase2/include
-        ../api
-)
-
 add_bundle(phase2a_cxx
     SYMBOLIC_NAME phase2a_cxx
     VERSION 0.0.1
@@ -28,15 +22,20 @@ add_bundle(phase2a_cxx
         src/Phase2aCmp.cc
 )
 
-target_compile_options(phase2a_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
+target_include_directories(phase2a_cxx PRIVATE
+        ../phase2/include
+        ../api
+)
+
+target_link_libraries(phase2a_cxx PRIVATE Celix::log_service_api)
 
 IF(APPLE)
-    target_link_libraries(phase2a_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static)
+    target_link_libraries(phase2a_cxx PRIVATE -Wl,-all_load Celix::dependency_manager_cxx_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(phase2a_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase2a_cxx PRIVATE -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(phase2a_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase2a_cxx PRIVATE  -Wl,--no-undefined -Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example_cxx/phase2b/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase2b/CMakeLists.txt b/examples/dm_example_cxx/phase2b/CMakeLists.txt
index 29ff664..cfbda7c 100644
--- a/examples/dm_example_cxx/phase2b/CMakeLists.txt
+++ b/examples/dm_example_cxx/phase2b/CMakeLists.txt
@@ -15,12 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-include_directories(
-        ../phase2/include
-        include
-        ../api
-)
-
 add_bundle(phase2b_cxx
     SYMBOLIC_NAME phase2b_cxx
     VERSION 0.0.1
@@ -28,16 +22,18 @@ add_bundle(phase2b_cxx
         src/Phase2bActivator.cc
         src/Phase2bCmp.cc
 )
+target_link_libraries(phase2b_cxx PRIVATE Celix::log_service_api)
+target_include_directories(phase2b_cxx PRIVATE ../api ../phase2/include)
+
 
-target_compile_options(phase2b_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
 
 IF(APPLE)
-    target_link_libraries(phase2b_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static)
+    target_link_libraries(phase2b_cxx PRIVATE  -Wl,-all_load  Celix::dependency_manager_cxx_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(phase2b_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase2b_cxx PRIVATE  -Wl,--whole-archive  Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(phase2b_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase2b_cxx PRIVATE  -Wl,--no-undefined -Wl,--whole-archive  Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example_cxx/phase3/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase3/CMakeLists.txt b/examples/dm_example_cxx/phase3/CMakeLists.txt
index 99c3a5b..a0f6973 100644
--- a/examples/dm_example_cxx/phase3/CMakeLists.txt
+++ b/examples/dm_example_cxx/phase3/CMakeLists.txt
@@ -32,12 +32,12 @@ add_bundle(phase3_cxx
 target_compile_options(phase3_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
 
 IF(APPLE)
-    target_link_libraries(phase3_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static)
+    target_link_libraries(phase3_cxx PRIVATE -Wl,-all_load dependency_manager_cxx_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(phase3_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase3_cxx PRIVATE  -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(phase3_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase3_cxx PRIVATE  -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example_cxx/phase3_locking/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase3_locking/CMakeLists.txt b/examples/dm_example_cxx/phase3_locking/CMakeLists.txt
index 07c9b54..956f6e1 100644
--- a/examples/dm_example_cxx/phase3_locking/CMakeLists.txt
+++ b/examples/dm_example_cxx/phase3_locking/CMakeLists.txt
@@ -31,12 +31,12 @@ add_bundle(phase3_locking_cxx
 target_compile_options(phase3_locking_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
 
 IF(APPLE)
-    target_link_libraries(phase3_locking_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static)
+    target_link_libraries(phase3_locking_cxx PRIVATE -Wl,-all_load dependency_manager_cxx_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(phase3_locking_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase3_locking_cxx PRIVATE -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(phase3_locking_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase3_locking_cxx PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/embedding/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/embedding/CMakeLists.txt b/examples/embedding/CMakeLists.txt
index c7475e7..e39433a 100644
--- a/examples/embedding/CMakeLists.txt
+++ b/examples/embedding/CMakeLists.txt
@@ -18,4 +18,4 @@
 
 add_executable(embedding private/src/main)
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-target_link_libraries(embedding celix_framework)
\ No newline at end of file
+target_link_libraries(embedding Celix::framework )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/hello_world/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt
index 0ed7ed6..7cb590f 100644
--- a/examples/hello_world/CMakeLists.txt
+++ b/examples/hello_world/CMakeLists.txt
@@ -51,13 +51,13 @@ bundle_private_libs(hello
 
 add_deploy(helloworld_byref
     GROUP hello
-    BUNDLES hello_export hello shell shell_tui
+    BUNDLES hello_export hello ${CELIX_SHELL_BUNDLE} ${CELIX_SHELL_TUI_BUNDLE}
 )
 
 add_deploy(helloworld_withcopy
     GROUP hello
     COPY #Ensures that bundles are copied in the deploy location
-    BUNDLES hello_export hello shell shell_tui
+    BUNDLES hello_export hello ${SHELL_BUNDLE} ${SHELL_TUI_BUNDLE}
 )
 
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/hello_world_test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/hello_world_test/CMakeLists.txt b/examples/hello_world_test/CMakeLists.txt
index 39198ed..08053e5 100644
--- a/examples/hello_world_test/CMakeLists.txt
+++ b/examples/hello_world_test/CMakeLists.txt
@@ -19,15 +19,18 @@
 ## NOTE Examples of using add_bundle and add_deploy and assorted commands ##
 #############################################################################
 
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories(public/include)
-
 add_bundle(hellotest1
     VERSION "1.2"
     SOURCES
         private/src/activator
 )
 
+target_include_directories(hellotest1 PRIVATE
+        ${PROJECT_SOURCE_DIR}/utils/public/include
+        public/include
+)
+
+
 bundle_headers(hellotest1
     "X-WebContent: web"
     "X-MediaType: application/json"
@@ -72,6 +75,7 @@ add_library(hello2act SHARED
     private/src/activator
 )
 set_library_version(hello2act "3.2.4") #sets VERSION prop to 3.2.4 and SOVERSION to 3
+target_link_libraries(hello2act PRIVATE Celix::framework )
 add_bundle(hellotest2
     VERSION "1.0.0" #can be the same as activator lib, but does not have to be
     ACTIVATOR hello2act

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/log_service_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/log_service_example/CMakeLists.txt b/examples/log_service_example/CMakeLists.txt
index 6b7e681..0363da3 100644
--- a/examples/log_service_example/CMakeLists.txt
+++ b/examples/log_service_example/CMakeLists.txt
@@ -17,20 +17,15 @@
 
 #Importing and exporting libraries not (yet) work under OSX.
 
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("public/include")
-include_directories("${CMAKE_SOURCE_DIR}/log_service/public/include")
-
 add_bundle(log_service_example
     VERSION "1.0"
     SOURCES
-        private/src/activator.c
-        ${CMAKE_SOURCE_DIR}/log_service/public/src/log_helper.c
+        src/activator.c
 )
+target_include_directories(log_service_example PRIVATE src)
+target_link_libraries(log_service_example PRIVATE Celix::log_service_api Celix::log_helper)
 
 add_deploy(log_example
     GROUP log_service
-    BUNDLES log_service_example log_service shell shell_tui
-)
-
-target_link_libraries(log_service_example celix_framework celix_utils)
\ No newline at end of file
+    BUNDLES log_service_example Celix::log_service Celix::shell Celix::shell_tui
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/log_service_example/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/log_service_example/private/src/activator.c b/examples/log_service_example/private/src/activator.c
deleted file mode 100644
index 75eaf59..0000000
--- a/examples/log_service_example/private/src/activator.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Sep 11, 2017
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include "bundle_activator.h"
-#include "log_helper.h"
-
-struct userData {
-	pthread_t logger_thread;
-	bool running;
-	log_helper_pt log_helper;
-};
-
-static void *loggerThread(void *userData);
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-    *userData = calloc(1, sizeof(struct userData));
-    if (*userData != NULL) {
-        struct userData * data = (struct userData *) *userData;
-        status = logHelper_create(context, &data->log_helper);
-	} else {
-		status = CELIX_START_ERROR;
-	}
-	return status;
-}
-
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	struct userData * data = (struct userData *) userData;
-	printf("Started log example\n");
-    logHelper_start(data->log_helper);
-	data->running = true;
-    pthread_create(&data->logger_thread, NULL, loggerThread, data);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	struct userData * data = (struct userData *) userData;
-	printf("Stopping logger example\n");
-	data->running = false;
-	pthread_join(data->logger_thread, NULL);
-    logHelper_stop(data->log_helper);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-    struct userData * data = (struct userData *) userData;
-    logHelper_destroy(&data->log_helper);
-    free(userData);
-	return CELIX_SUCCESS;
-}
-
-static void *loggerThread(void *userData) {
-    struct userData * data = (struct userData *) userData;
-    while (data->running) {
-        logHelper_log(data->log_helper, OSGI_LOGSERVICE_INFO, "My log message");
-        sleep(1);
-    }
-    return NULL;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/log_service_example/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/log_service_example/src/activator.c b/examples/log_service_example/src/activator.c
new file mode 100644
index 0000000..75eaf59
--- /dev/null
+++ b/examples/log_service_example/src/activator.c
@@ -0,0 +1,85 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Sep 11, 2017
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "bundle_activator.h"
+#include "log_helper.h"
+
+struct userData {
+	pthread_t logger_thread;
+	bool running;
+	log_helper_pt log_helper;
+};
+
+static void *loggerThread(void *userData);
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+    *userData = calloc(1, sizeof(struct userData));
+    if (*userData != NULL) {
+        struct userData * data = (struct userData *) *userData;
+        status = logHelper_create(context, &data->log_helper);
+	} else {
+		status = CELIX_START_ERROR;
+	}
+	return status;
+}
+
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	struct userData * data = (struct userData *) userData;
+	printf("Started log example\n");
+    logHelper_start(data->log_helper);
+	data->running = true;
+    pthread_create(&data->logger_thread, NULL, loggerThread, data);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	struct userData * data = (struct userData *) userData;
+	printf("Stopping logger example\n");
+	data->running = false;
+	pthread_join(data->logger_thread, NULL);
+    logHelper_stop(data->log_helper);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+    struct userData * data = (struct userData *) userData;
+    logHelper_destroy(&data->log_helper);
+    free(userData);
+	return CELIX_SUCCESS;
+}
+
+static void *loggerThread(void *userData) {
+    struct userData * data = (struct userData *) userData;
+    while (data->running) {
+        logHelper_log(data->log_helper, OSGI_LOGSERVICE_INFO, "My log message");
+        sleep(1);
+    }
+    return NULL;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/mongoose/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/mongoose/CMakeLists.txt b/examples/mongoose/CMakeLists.txt
index f4250ef..118d923 100644
--- a/examples/mongoose/CMakeLists.txt
+++ b/examples/mongoose/CMakeLists.txt
@@ -37,6 +37,6 @@ add_bundle(mongoose
 
 bundle_files(mongoose ${CMAKE_CURRENT_LIST_DIR}/root)
 
-target_link_libraries(mongoose celix_framework mongooselib ${LIBS})
+target_link_libraries(mongoose PRIVATE mongooselib ${LIBS})
 
-add_deploy("mongoose_deploy" BUNDLES shell shell_tui log_service mongoose)
+add_deploy("mongoose_deploy" BUNDLES Celix::shell Celix::shell_tui log_service mongoose)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/service_hook_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/service_hook_example/CMakeLists.txt b/examples/service_hook_example/CMakeLists.txt
index 8835a85..99e9b2a 100644
--- a/examples/service_hook_example/CMakeLists.txt
+++ b/examples/service_hook_example/CMakeLists.txt
@@ -15,23 +15,16 @@
 # specific language governing permissions and limitations
 # under the License.
 
-if(NOT APPLE)
-#Importing and exporting libraries not (yet) work under OSX.
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("public/include")
-
 add_bundle(hook_example
-           BUNDLE_SYMBOLICNAME "Hook_Example"
-           VERSION "1.0.0"
-           SOURCES
-                private/src/activator
+    BUNDLE_SYMBOLICNAME "Hook_Example"
+    VERSION "1.0.0"
+    SOURCES
+        src/activator
 )
 
-add_deploy("hook_service_example"
-            BUNDLES
-                shell
-                shell_tui
-                hook_example
-)
-endif()
+add_deploy(hook_service_example
+    BUNDLES
+        Celix::shell
+        Celix::shell_tui
+        hook_example
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/service_hook_example/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/service_hook_example/private/src/activator.c b/examples/service_hook_example/private/src/activator.c
deleted file mode 100644
index f2d2a15..0000000
--- a/examples/service_hook_example/private/src/activator.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#include "bundle_activator.h"
-#include "service_tracker_customizer.h"
-#include "service_tracker.h"
-#include "bundle_context.h"
-#include "listener_hook_service.h"
-#include "service_registry.h"
-
-struct userData {
-    service_registration_pt hookReg;
-    service_tracker_pt trackerBefore;
-    service_tracker_pt trackerAfter;
-    listener_hook_service_pt hookService; 
-};
-
-
-celix_status_t tracker_added(void*hook, array_list_pt listeners) {
-    for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
-        listener_hook_info_pt info = arrayList_get(listeners, i);
-        printf("Added tracker for service %s\n", info->filter);
-    }
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t tracker_removed(void*hook, array_list_pt listeners) {
-    for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
-        listener_hook_info_pt info = arrayList_get(listeners, i);
-        printf("Removed tracker for service %s\n", info->filter);
-    }
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-    *userData = malloc(sizeof(struct userData));
-    if (*userData != NULL) {
-       
-	} else {
-		status = CELIX_START_ERROR;
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * handle, bundle_context_pt context) {
-	printf("Starting hook example bundle\n");
-    struct userData *userData = (struct userData*)handle;   
-    
-    userData->trackerBefore = 0;
-    serviceTracker_create(context, "MY_SERVICE_BEFORE_REGISTERING_HOOK", NULL, &userData->trackerBefore);
-    serviceTracker_open(userData->trackerBefore);
-    
-    listener_hook_service_pt hookService = calloc(1, sizeof(*hookService));
-    hookService->handle = userData;
-    hookService->added = tracker_added;
-    hookService->removed = tracker_removed;
-
-    userData->hookService = hookService;
-    userData->hookReg = NULL;
-
-    printf("Registering hook service\n");
-    bundleContext_registerService(context, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, &userData->hookReg);
-
-    printf("Unregistering hook service\n");
-    serviceRegistration_unregister(userData->hookReg);
-
-    printf("Re-Registering hook service\n");
-    userData->hookReg = NULL;
-    bundleContext_registerService(context, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, &userData->hookReg);
-
-    userData->trackerAfter = 0;
-    serviceTracker_create(context, "MY_SERVICE_AFTER_REGISTERING_HOOK", NULL, &userData->trackerAfter);
-    serviceTracker_open(userData->trackerAfter);
-  
-    sleep(1);
-    printf("Closing tracker\n");
-    serviceTracker_close(userData->trackerAfter);
-    printf("Reopening tracker\n");
-    serviceTracker_open(userData->trackerAfter);
-    
-    sleep(1);
-    printf("Closing tracker\n");
-    serviceTracker_close(userData->trackerAfter);
-    printf("Reopening tracker\n");
-    serviceTracker_open(userData->trackerAfter);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_stop(void * handle, bundle_context_pt context) {
-	printf("Stopping hook example bundle\n");
-    struct userData *userData = (struct userData*)handle;   
-
-    serviceTracker_close(userData->trackerAfter);
-    serviceTracker_close(userData->trackerBefore);
-    serviceTracker_destroy(userData->trackerAfter);
-    serviceTracker_destroy(userData->trackerBefore);
-
-    serviceRegistration_unregister(userData->hookReg);
-    free(userData->hookService);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * handle, bundle_context_pt context) {
-    free(handle);
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/service_hook_example/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/service_hook_example/src/activator.c b/examples/service_hook_example/src/activator.c
new file mode 100644
index 0000000..f2d2a15
--- /dev/null
+++ b/examples/service_hook_example/src/activator.c
@@ -0,0 +1,137 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Aug 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "bundle_activator.h"
+#include "service_tracker_customizer.h"
+#include "service_tracker.h"
+#include "bundle_context.h"
+#include "listener_hook_service.h"
+#include "service_registry.h"
+
+struct userData {
+    service_registration_pt hookReg;
+    service_tracker_pt trackerBefore;
+    service_tracker_pt trackerAfter;
+    listener_hook_service_pt hookService; 
+};
+
+
+celix_status_t tracker_added(void*hook, array_list_pt listeners) {
+    for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
+        listener_hook_info_pt info = arrayList_get(listeners, i);
+        printf("Added tracker for service %s\n", info->filter);
+    }
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t tracker_removed(void*hook, array_list_pt listeners) {
+    for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
+        listener_hook_info_pt info = arrayList_get(listeners, i);
+        printf("Removed tracker for service %s\n", info->filter);
+    }
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+    *userData = malloc(sizeof(struct userData));
+    if (*userData != NULL) {
+       
+	} else {
+		status = CELIX_START_ERROR;
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * handle, bundle_context_pt context) {
+	printf("Starting hook example bundle\n");
+    struct userData *userData = (struct userData*)handle;   
+    
+    userData->trackerBefore = 0;
+    serviceTracker_create(context, "MY_SERVICE_BEFORE_REGISTERING_HOOK", NULL, &userData->trackerBefore);
+    serviceTracker_open(userData->trackerBefore);
+    
+    listener_hook_service_pt hookService = calloc(1, sizeof(*hookService));
+    hookService->handle = userData;
+    hookService->added = tracker_added;
+    hookService->removed = tracker_removed;
+
+    userData->hookService = hookService;
+    userData->hookReg = NULL;
+
+    printf("Registering hook service\n");
+    bundleContext_registerService(context, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, &userData->hookReg);
+
+    printf("Unregistering hook service\n");
+    serviceRegistration_unregister(userData->hookReg);
+
+    printf("Re-Registering hook service\n");
+    userData->hookReg = NULL;
+    bundleContext_registerService(context, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, &userData->hookReg);
+
+    userData->trackerAfter = 0;
+    serviceTracker_create(context, "MY_SERVICE_AFTER_REGISTERING_HOOK", NULL, &userData->trackerAfter);
+    serviceTracker_open(userData->trackerAfter);
+  
+    sleep(1);
+    printf("Closing tracker\n");
+    serviceTracker_close(userData->trackerAfter);
+    printf("Reopening tracker\n");
+    serviceTracker_open(userData->trackerAfter);
+    
+    sleep(1);
+    printf("Closing tracker\n");
+    serviceTracker_close(userData->trackerAfter);
+    printf("Reopening tracker\n");
+    serviceTracker_open(userData->trackerAfter);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_stop(void * handle, bundle_context_pt context) {
+	printf("Stopping hook example bundle\n");
+    struct userData *userData = (struct userData*)handle;   
+
+    serviceTracker_close(userData->trackerAfter);
+    serviceTracker_close(userData->trackerBefore);
+    serviceTracker_destroy(userData->trackerAfter);
+    serviceTracker_destroy(userData->trackerBefore);
+
+    serviceRegistration_unregister(userData->hookReg);
+    free(userData->hookService);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * handle, bundle_context_pt context) {
+    free(handle);
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/services_example_c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/services_example_c/CMakeLists.txt b/examples/services_example_c/CMakeLists.txt
index f6a5066..540399d 100644
--- a/examples/services_example_c/CMakeLists.txt
+++ b/examples/services_example_c/CMakeLists.txt
@@ -30,8 +30,8 @@ if (BUILD_DEPENDENCY_MANAGER)
         GROUP services_example
         COPY
         BUNDLES
-            shell
-            shell_tui
+            Celix::shell
+            Celix::shell_tui
             dm_shell
             bar
             foo1

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/services_example_c/bar/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/services_example_c/bar/CMakeLists.txt b/examples/services_example_c/bar/CMakeLists.txt
index 7ebb45c..2332931 100644
--- a/examples/services_example_c/bar/CMakeLists.txt
+++ b/examples/services_example_c/bar/CMakeLists.txt
@@ -28,12 +28,12 @@ add_bundle(bar
 )
 
 IF(APPLE)
-    target_link_libraries(bar celix_framework -Wl,-all_load dependency_manager_static)
+    target_link_libraries(bar PRIVATE Celix::framework  -Wl,-all_load dependency_manager_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(bar -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(bar -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive Celix::framework )
     else()
-        target_link_libraries(bar -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(bar -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive Celix::framework )
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/services_example_c/foo1/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/services_example_c/foo1/CMakeLists.txt b/examples/services_example_c/foo1/CMakeLists.txt
index 0d1b93c..d95546c 100644
--- a/examples/services_example_c/foo1/CMakeLists.txt
+++ b/examples/services_example_c/foo1/CMakeLists.txt
@@ -28,12 +28,12 @@ add_bundle(foo1
 )
 
 IF(APPLE)
-    target_link_libraries(foo1 celix_framework -Wl,-all_load dependency_manager_static)
+    target_link_libraries(foo1 PRIVATE -Wl,-all_load dependency_manager_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(foo1 -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(foo1 PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(foo1 -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(foo1 PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/services_example_c/foo2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/services_example_c/foo2/CMakeLists.txt b/examples/services_example_c/foo2/CMakeLists.txt
index 1096c6c..b28e96c 100644
--- a/examples/services_example_c/foo2/CMakeLists.txt
+++ b/examples/services_example_c/foo2/CMakeLists.txt
@@ -28,12 +28,12 @@ add_bundle(foo2
 )
 
 IF(APPLE)
-    target_link_libraries(foo2 celix_framework -Wl,-all_load dependency_manager_static)
+    target_link_libraries(foo2 PRIVATE -Wl,-all_load dependency_manager_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(foo2 -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(foo2 PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(foo2 -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(foo2 PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/services_example_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/services_example_cxx/CMakeLists.txt b/examples/services_example_cxx/CMakeLists.txt
index 6f45ef7..0d4e732 100644
--- a/examples/services_example_cxx/CMakeLists.txt
+++ b/examples/services_example_cxx/CMakeLists.txt
@@ -30,8 +30,8 @@ if (BUILD_DEPENDENCY_MANAGER_CXX)
         GROUP services_example
         COPY
         BUNDLES
-            shell
-            shell_tui
+            Celix::shell
+            Celix::shell_tui
             dm_shell
             bar_cxx
             foo_cxx

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/services_example_cxx/bar/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/services_example_cxx/bar/CMakeLists.txt b/examples/services_example_cxx/bar/CMakeLists.txt
index b3cdb07..ae91605 100644
--- a/examples/services_example_cxx/bar/CMakeLists.txt
+++ b/examples/services_example_cxx/bar/CMakeLists.txt
@@ -30,12 +30,12 @@ add_bundle(bar_cxx
 target_compile_options(bar_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
 
 IF(APPLE)
-    target_link_libraries(bar_cxx celix_framework -Wl,-all_load  dependency_manager_cxx_static)
+    target_link_libraries(bar_cxx PRIVATE -Wl,-all_load  dependency_manager_cxx_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(bar_cxx -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(bar_cxx PRIVATE -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(bar_cxx -Wl,--no-undefined -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(bar_cxx PRIVATE -Wl,--no-undefined -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
     endif()
 endif()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/services_example_cxx/baz/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/services_example_cxx/baz/CMakeLists.txt b/examples/services_example_cxx/baz/CMakeLists.txt
index 205c716..7e7acb1 100644
--- a/examples/services_example_cxx/baz/CMakeLists.txt
+++ b/examples/services_example_cxx/baz/CMakeLists.txt
@@ -30,12 +30,12 @@ add_bundle(baz_cxx
 target_compile_options(baz_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
 
 IF(APPLE)
-    target_link_libraries(baz_cxx celix_framework -Wl,-all_load  dependency_manager_cxx_static)
+    target_link_libraries(baz_cxx PRIVATE  -Wl,-all_load  dependency_manager_cxx_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(baz_cxx -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(baz_cxx PRIVATE -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(baz_cxx -Wl,--no-undefined -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(baz_cxx PRIVATE -Wl,--no-undefined -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/services_example_cxx/foo/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/services_example_cxx/foo/CMakeLists.txt b/examples/services_example_cxx/foo/CMakeLists.txt
index e01af00..384c276 100644
--- a/examples/services_example_cxx/foo/CMakeLists.txt
+++ b/examples/services_example_cxx/foo/CMakeLists.txt
@@ -30,12 +30,12 @@ add_bundle(foo_cxx
 target_compile_options(foo_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
 
 IF(APPLE)
-    target_link_libraries(foo_cxx celix_framework -Wl,-all_load  dependency_manager_cxx_static)
+    target_link_libraries(foo_cxx PRIVATE -Wl,-all_load  dependency_manager_cxx_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(foo_cxx -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(foo_cxx PRIVATE -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(foo_cxx -Wl,--no-undefined -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(foo_cxx PRIVATE -Wl,--no-undefined -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/whiteboard/CMakeLists.txt b/examples/whiteboard/CMakeLists.txt
deleted file mode 100644
index b904241..0000000
--- a/examples/whiteboard/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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.
-
-add_subdirectory(publisherA)
-add_subdirectory(publisherB)
-add_subdirectory(tracker)
-add_subdirectory(tracker_depman)
-
-add_deploy("whiteboard" GROUP whiteboard BUNDLES tracker publisherA publisherB shell shell_tui log_service log_writer)
-add_deploy("whiteboard_dependency_manager" GROUP whiteboard BUNDLES tracker_depman publisherA publisherB shell shell_tui log_service log_writer dm_shell)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/publisherA/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/whiteboard/publisherA/CMakeLists.txt b/examples/whiteboard/publisherA/CMakeLists.txt
deleted file mode 100644
index a219360..0000000
--- a/examples/whiteboard/publisherA/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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.
-
-
-add_bundle(publisherA VERSION 1.0.0 SOURCES private/src/activator private/src/publisher)
-include_directories("../publisherService/public/include")
-include_directories("../publisherService/private/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-target_link_libraries(publisherA celix_framework)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/publisherA/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/whiteboard/publisherA/private/src/activator.c b/examples/whiteboard/publisherA/private/src/activator.c
deleted file mode 100644
index 663b0b9..0000000
--- a/examples/whiteboard/publisherA/private/src/activator.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <constants.h>
-
-#include "bundle_activator.h"
-#include "publisher_private.h"
-
-struct activatorData {
-    publisher_service_pt ps;
-    publisher_pt pub;
-
-    service_registration_pt reg;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	*userData = calloc(1, sizeof(struct activatorData));
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-	properties_pt props = NULL;
-
-	struct activatorData * data = (struct activatorData *) userData;
-	data->ps = calloc(1, sizeof(*(data->ps)));
-	data->pub = calloc(1, sizeof(*(data->pub)));
-	data->ps->invoke = publisher_invoke;
-	data->ps->publisher = data->pub;
-	data->reg = NULL;
-
-	props = properties_create();
-	properties_set(props, "id", "A");
-	properties_set(props,(char*)OSGI_FRAMEWORK_SERVICE_RANKING , "10");
-
-	status = bundleContext_registerService(context, PUBLISHER_NAME, data->ps, props, &data->reg);
-	if (status != CELIX_SUCCESS) {
-		char error[256];
-		printf("Error: %s\n", celix_strerror(status, error, 256));
-	}
-
-    return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    struct activatorData * data = (struct activatorData *) userData;
-    serviceRegistration_unregister(data->reg);
-
-    free(data->ps);
-    free(data->pub);
-
-    return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	free(userData);
-    return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/publisherA/private/src/publisher.c
----------------------------------------------------------------------
diff --git a/examples/whiteboard/publisherA/private/src/publisher.c b/examples/whiteboard/publisherA/private/src/publisher.c
deleted file mode 100644
index 997befd..0000000
--- a/examples/whiteboard/publisherA/private/src/publisher.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- *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.
- */
-/*
- * publisher.c
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-
-#include "publisher_private.h"
-
-void publisher_invoke(publisher_pt publisher, char * text) {
-	printf("Publisher A received: %s\n", text);
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/publisherB/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/whiteboard/publisherB/CMakeLists.txt b/examples/whiteboard/publisherB/CMakeLists.txt
deleted file mode 100644
index 74f0bb5..0000000
--- a/examples/whiteboard/publisherB/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# 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.
-
-add_bundle(publisherB VERSION 1.0.0 SOURCES private/src/activator private/src/publisher)
-include_directories("../publisherService/public/include")
-include_directories("../publisherService/private/include")
-target_link_libraries(publisherB celix_framework)
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/publisherB/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/whiteboard/publisherB/private/src/activator.c b/examples/whiteboard/publisherB/private/src/activator.c
deleted file mode 100644
index f5f1a2e..0000000
--- a/examples/whiteboard/publisherB/private/src/activator.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <constants.h>
-
-#include "bundle_activator.h"
-#include "publisher_private.h"
-
-struct activatorData {
-	publisher_service_pt ps;
-	publisher_pt pub;
-
-	service_registration_pt reg;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	*userData = calloc(1, sizeof(struct activatorData));
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-	properties_pt props = properties_create();
-
-	struct activatorData * data = (struct activatorData *) userData;
-	data->ps = calloc(1, sizeof(*(data->ps)));
-	data->pub = calloc(1, sizeof(*(data->pub)));
-	data->ps->invoke = publisher_invoke;
-	data->ps->publisher = data->pub;
-	data->reg = NULL;
-
-	properties_set(props, "id", "B");
-	properties_set(props,(char*)OSGI_FRAMEWORK_SERVICE_RANKING , "20");
-
-	bundleContext_registerService(context, PUBLISHER_NAME, data->ps, props, &data->reg);
-    return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    struct activatorData * data = (struct activatorData *) userData;
-	serviceRegistration_unregister(data->reg);
-
-	free(data->pub);
-	free(data->ps);
-
-    return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	free(userData);
-    return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/publisherB/private/src/publisher.c
----------------------------------------------------------------------
diff --git a/examples/whiteboard/publisherB/private/src/publisher.c b/examples/whiteboard/publisherB/private/src/publisher.c
deleted file mode 100644
index 87bb300..0000000
--- a/examples/whiteboard/publisherB/private/src/publisher.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- *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.
- */
-/*
- * publisher.c
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-
-#include "publisher_private.h"
-
-void publisher_invoke(publisher_pt publisher, char * text) {
-	printf("Publisher B received: %s\n", text);
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/publisherService/private/include/publisher_private.h
----------------------------------------------------------------------
diff --git a/examples/whiteboard/publisherService/private/include/publisher_private.h b/examples/whiteboard/publisherService/private/include/publisher_private.h
deleted file mode 100644
index 19c524d..0000000
--- a/examples/whiteboard/publisherService/private/include/publisher_private.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- *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.
- */
-/*
- * publisher_private.h
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef PUBLISHER_PRIVATE_H_
-#define PUBLISHER_PRIVATE_H_
-
-#include "publisher.h"
-
-struct publisher {
-	void *data;
-};
-
-void publisher_invoke(publisher_pt publisher, char * text);
-
-#endif /* PUBLISHER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/publisherService/public/include/publisher.h
----------------------------------------------------------------------
diff --git a/examples/whiteboard/publisherService/public/include/publisher.h b/examples/whiteboard/publisherService/public/include/publisher.h
deleted file mode 100644
index 9b18429..0000000
--- a/examples/whiteboard/publisherService/public/include/publisher.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *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.
- */
-/*
- * publisher.h
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef PUBLISHER_H_
-#define PUBLISHER_H_
-
-#define PUBLISHER_NAME "Publisher"
-
-typedef struct publisher * publisher_pt;
-
-struct publisherService {
-	publisher_pt publisher;
-	void (*invoke)(publisher_pt pub, char * text);
-};
-
-typedef struct publisherService * publisher_service_pt;
-
-
-#endif /* PUBLISHER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/tracker/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/whiteboard/tracker/CMakeLists.txt b/examples/whiteboard/tracker/CMakeLists.txt
deleted file mode 100644
index c44b206..0000000
--- a/examples/whiteboard/tracker/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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.
-
-add_bundle(tracker VERSION 1.0.0 SOURCES private/src/activator)
-include_directories("../publisherService/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-target_link_libraries(tracker celix_framework)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/tracker/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/whiteboard/tracker/private/src/activator.c b/examples/whiteboard/tracker/private/src/activator.c
deleted file mode 100644
index db5f3fc..0000000
--- a/examples/whiteboard/tracker/private/src/activator.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "celixbool.h"
-
-#include "bundle_activator.h"
-#include "publisher.h"
-#include "service_tracker.h"
-
-struct data {
-	bundle_context_pt context;
-	service_tracker_pt tracker;
-	array_list_pt publishers;
-	pthread_t sender;
-	bool running;
-};
-
-static void *trk_send(void *handle) {
-	struct data * data = (struct data *) handle;
-	while (data->running) {
-		int i;
-		for (i = 0; i < arrayList_size(data->publishers); i++) {
-			publisher_service_pt pub = arrayList_get(data->publishers, i);
-			pub->invoke(pub->publisher, "test");
-		}
-		usleep(1000000);
-	}
-	pthread_exit(NULL);
-	return NULL;
-}
-
-celix_status_t addingServ(void * handle, service_reference_pt ref, void **service) {
-    struct data * data = (struct data *) handle;
-
-    printf("Adding\n");
-	bundleContext_getService(data->context, ref, service);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t addedServ(void * handle, service_reference_pt ref, void * service) {
-	struct data * data = (struct data *) handle;
-	arrayList_add(data->publishers, service);
-	printf("Added %p\n", service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t modifiedServ(void * handle, service_reference_pt ref, void * service) {
-	printf("Modified\n");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t removedServ(void * handle, service_reference_pt ref, void * service) {
-	struct data * data = (struct data *) handle;
-	arrayList_removeElement(data->publishers, service);
-	printf("Removed %p\n", service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-    *userData = calloc(1, sizeof(struct data));
-    ((struct data *) (*userData))->publishers = NULL;
-    arrayList_create(&((struct data *) (*userData))->publishers);
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-    struct data * data = (struct data *) userData;
-    service_tracker_customizer_pt cust = NULL;
-    service_tracker_pt tracker = NULL;
-    data->context = context;
-    serviceTrackerCustomizer_create(data, addingServ, addedServ, modifiedServ, removedServ, &cust);
-    serviceTracker_create(context, (char *) PUBLISHER_NAME, cust, &tracker);
-    data->tracker = tracker;
-    serviceTracker_open(tracker);
-    data->running = true;
-    pthread_create(&data->sender, NULL, trk_send, data);
-    return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-    struct data * data = (struct data *) userData;
-
-	printf("Stop\n");
-    serviceTracker_close(data->tracker);
-    data->running = false;
-    pthread_join(data->sender, NULL);
-
-    return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-    struct data * data = (struct data *) userData;
-
-    arrayList_destroy(data->publishers);
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/tracker_depman/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/whiteboard/tracker_depman/CMakeLists.txt b/examples/whiteboard/tracker_depman/CMakeLists.txt
deleted file mode 100644
index 3bd5942..0000000
--- a/examples/whiteboard/tracker_depman/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# 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.
-
-add_bundle(tracker_depman VERSION 1.0.0 SOURCES
-    private/src/dependency_activator
-    private/src/tracker
-    
-    private/include/tracker.h
-)
-include_directories("private/include")
-include_directories("${PROJECT_SOURCE_DIR}/dependency_manager/public/include")
-#include_directories("${PROJECT_SOURCE_DIR}/dependency_manager/private/include")
-include_directories("../publisherService/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-
-# Use some magic to include all symbols of the static library
-IF(APPLE)
-target_link_libraries(tracker_depman celix_framework -Wl,-all_load dependency_manager_static)
-else()
-target_link_libraries(tracker_depman -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
-ENDIF()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/tracker_depman/private/include/tracker.h
----------------------------------------------------------------------
diff --git a/examples/whiteboard/tracker_depman/private/include/tracker.h b/examples/whiteboard/tracker_depman/private/include/tracker.h
deleted file mode 100644
index 55438d2..0000000
--- a/examples/whiteboard/tracker_depman/private/include/tracker.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- *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.
- */
-/*
- * tracker.h
- *
- *  \date       Mar 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef TRACKER_H_
-#define TRACKER_H_
-
-#include "dm_component.h"
-#include "log_service.h"
-
-struct data {
-	dm_component_pt service;
-	dm_service_dependency_pt dep;
-	dm_service_dependency_pt dep2;
-	bundle_context_pt context;
-	array_list_pt publishers;
-	pthread_t sender;
-	bool running;
-	log_service_pt logger;
-
-	celix_thread_mutex_t logger_lock;
-	celix_thread_mutex_t publisher_lock;
-};
-
-celix_status_t tracker_setServ(void * handle, service_reference_pt ref, const void * service);
-celix_status_t tracker_addedServ(void * handle, service_reference_pt ref, const void * service);
-celix_status_t tracker_modifiedServ(void * handle, service_reference_pt ref, const void * service);
-celix_status_t tracker_removedServ(void * handle, service_reference_pt ref, const void * service);
-
-celix_status_t tracker_setLog(void * handle, service_reference_pt ref, const void * service);
-celix_status_t tracker_addLog(void * handle, service_reference_pt ref, const void * service);
-celix_status_t tracker_modifiedLog(void * handle, service_reference_pt ref, const void * service);
-celix_status_t tracker_removeLog(void * handle, service_reference_pt ref, const void * service);
-
-celix_status_t service_init(void * userData);
-celix_status_t service_start(void * userData);
-celix_status_t service_stop(void * userData);
-celix_status_t service_deinit(void * userData);
-
-
-#endif /* TRACKER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/tracker_depman/private/src/dependency_activator.c
----------------------------------------------------------------------
diff --git a/examples/whiteboard/tracker_depman/private/src/dependency_activator.c b/examples/whiteboard/tracker_depman/private/src/dependency_activator.c
deleted file mode 100644
index 9ac295d..0000000
--- a/examples/whiteboard/tracker_depman/private/src/dependency_activator.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- *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.
- */
-/*
- * dependency_activator.c
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include "celixbool.h"
-
-#include "dm_activator.h"
-#include "publisher.h"
-#include "tracker.h"
-
-celix_status_t dm_create(bundle_context_pt context, void **userData) {
-	printf("Create\n");
-	struct data * data = malloc(sizeof(*data));
-	data->publishers = NULL;
-	arrayList_create(&data->publishers);
-	data->context = NULL;
-	data->running = false;
-	data->sender = 0;
-	data->service = NULL;
-	data->logger = NULL;
-	*userData = data;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
-	printf("Init\n");
-	struct data * data = (struct data *) userData;
-	dm_component_pt service = NULL;
-	dm_service_dependency_pt dep1 = NULL;
-	dm_service_dependency_pt dep2 = NULL;
-
-	data->context = context;
-
-	component_create(context, "ExampleCmp", &service);
-	component_setImplementation(service, data);
-	component_setCallbacks(service, service_init, service_start, service_stop, service_deinit);
-
-	serviceDependency_create(&dep1);
-	serviceDependency_setRequired(dep1, true);
-	serviceDependency_setService(dep1, PUBLISHER_NAME, NULL, "(|(id=A)(id=B))");
-	serviceDependency_setCallbacksWithServiceReference(dep1, NULL /*tracker_setServ*/, tracker_addedServ, tracker_modifiedServ, tracker_removedServ, NULL);
-	component_addServiceDependency(service, dep1);
-
-	serviceDependency_create(&dep2);
-    serviceDependency_setRequired(dep2, false);
-    serviceDependency_setService(dep2, (char *) OSGI_LOGSERVICE_NAME, NULL,  NULL);
-    serviceDependency_setCallbacksWithServiceReference(dep2, NULL  /*tracker_setLog*/, tracker_addLog, tracker_modifiedLog, tracker_removeLog, NULL);
-	serviceDependency_setAutoConfigure(dep2, &data->logger_lock, (const void **) &data->logger);
-    component_addServiceDependency(service, dep2);
-
-	data->service = service;
-	data->dep = dep1;
-	data->dep2 = dep2;
-
-	dependencyManager_add(manager, service);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
-	struct data * data = (struct data *) userData;
-
-	arrayList_destroy(data->publishers);
-	data->publishers = NULL;
-	free(data);
-	data = NULL;
-	return CELIX_SUCCESS;
-}
-
-//int count;
-//
-//void lock(int state) {
-//	pthread_mutex_t lock;
-//	if (state == 1) {
-//		if (count > 0) {
-//			count++;
-//		} else {
-//			pthread_mutex_lock(&lock);
-//		}
-//	} else {
-//		pthread_mutex_lock(&lock);
-//	}
-//}
-//
-//void unlcok(int state) {
-//	if (state == 1) {
-//		if (count-- == 0) {
-//			pthread_mutex_unlock(&lock);
-//		}
-//	} else {
-//		pthread_mutex_unlock(&lock);
-//	}
-//}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/whiteboard/tracker_depman/private/src/tracker.c
----------------------------------------------------------------------
diff --git a/examples/whiteboard/tracker_depman/private/src/tracker.c b/examples/whiteboard/tracker_depman/private/src/tracker.c
deleted file mode 100644
index d38abb9..0000000
--- a/examples/whiteboard/tracker_depman/private/src/tracker.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- *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.
- */
-/*
- * tracker.c
- *
- *  \date       Mar 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "celixbool.h"
-
-#include "publisher.h"
-#include "tracker.h"
-
-static void *dp_send(void *handle) {
-	struct data * data = (struct data *) handle;
-	while (data->running) {
-		printf("Running\n");
-		int i;
-		// lock
-		for (i = 0; i < arrayList_size(data->publishers); i++) {
-			publisher_service_pt pub = (publisher_service_pt) arrayList_get(data->publishers, i);
-			pub->invoke(pub->publisher, "Tracker message");
-			celixThreadMutex_lock(&data->logger_lock);
-			printf("%p\n", data->logger);
-			if (data->logger != NULL) {
-				data->logger->log(data->logger->logger, OSGI_LOGSERVICE_INFO, "Sending message to publisher");
-			}
-			celixThreadMutex_unlock(&data->logger_lock);
-		}
-		// lock
-		usleep(1000000);
-	}
-	pthread_exit(NULL);
-	return NULL;
-}
-
-celix_status_t service_init(void * userData) {
-	fprintf(stderr, "Service init");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t service_start(void * userData) {
-	struct data * data = (struct data *) userData;
-	fprintf(stderr, "Service started\n");
-	data->running = true;
-	pthread_create(&data->sender, NULL, dp_send, data);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t service_stop(void * userData) {
-	struct data * data = (struct data *) userData;
-	fprintf(stderr, "Service stopped\n");
-	data->running = false;
-	pthread_join(data->sender, NULL);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t service_deinit(void * userData) {
-	fprintf(stderr, "Service deinit\n");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t tracker_setServ(void * handle, service_reference_pt ref, const void * service) {
-	printf("Service Set %p\n", service);
-	return CELIX_SUCCESS;
-}
-
-
-celix_status_t tracker_addedServ(void * handle, service_reference_pt ref, const void * service) {
-	struct data * data = (struct data *) handle;
-	arrayList_add(data->publishers, (void*)service);
-	printf("Service Added %p\n", service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t tracker_modifiedServ(void * handle, service_reference_pt ref, const void * service) {
-    printf("Service Changed\n");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t tracker_removedServ(void * handle, service_reference_pt ref, const void * service) {
-	struct data * data = (struct data *) handle;
-	arrayList_removeElement(data->publishers, (void*) service);
-	printf("Service Removed\n");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t tracker_setLog(void *handle, service_reference_pt ref, const void *service) {
-	struct data * data = (struct data *) handle;
-
-	printf("SET log %p\n", service);
-	if(service) {
-		data->logger = (log_service_pt)service;
-		((log_service_pt) service)->log(((log_service_pt) service)->logger, OSGI_LOGSERVICE_DEBUG, "SET log");
-	}
-	fprintf(stderr, "SET end %p\n", service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t tracker_addLog(void *handle, service_reference_pt ref, const void *service) {
-    struct data * data = (struct data *) handle;
-    printf("Add log %p\n", service);
-    data->logger = (log_service_pt)service;
-    ((log_service_pt) service)->log(((log_service_pt) service)->logger, OSGI_LOGSERVICE_DEBUG, "test");
-    return CELIX_SUCCESS;
-}
-
-celix_status_t tracker_modifiedLog(void *handle, service_reference_pt ref, const void *service) {
-    struct data * data = (struct data *) handle;
-    printf("Modify log\n");
-    data->logger = (void*)service;
-    ((log_service_pt) service)->log(((log_service_pt) service)->logger, OSGI_LOGSERVICE_DEBUG, "test");
-    return CELIX_SUCCESS;
-}
-
-celix_status_t tracker_removeLog(void *handle, service_reference_pt ref, const void *service) {
-    struct data * data = (struct data *) handle;
-    data->logger = NULL;
-    printf("Remove log\n");
-    return CELIX_SUCCESS;
-}


[40/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/src/unzip.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/unzip.c b/deployment_admin/private/src/unzip.c
deleted file mode 100644
index d8a6716..0000000
--- a/deployment_admin/private/src/unzip.c
+++ /dev/null
@@ -1,2128 +0,0 @@
-/* unzip.c -- IO for uncompress .zip files using zlib
-   Version 1.1, February 14h, 2010
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications of Unzip for Zip64
-         Copyright (C) 2007-2008 Even Rouault
-
-         Modifications for Zip64 support on both zip and unzip
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-
-  ------------------------------------------------------------------------------------
-  Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
-  compatibility with older software. The following is from the original crypt.c.
-  Code woven in by Terry Thorsen 1/2003.
-
-  Copyright (c) 1990-2000 Info-ZIP.  All rights reserved.
-
-  See the accompanying file LICENSE, version 2000-Apr-09 or later
-  (the contents of which are also included in zip.h) for terms of use.
-  If, for some reason, all these files are missing, the Info-ZIP license
-  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
-
-        crypt.c (full version) by Info-ZIP.      Last revised:  [see crypt.h]
-
-  The encryption/decryption parts of this source code (as opposed to the
-  non-echoing password parts) were originally written in Europe.  The
-  whole source package can be freely distributed, including from the USA.
-  (Prior to January 2000, re-export from the US was a violation of US law.)
-
-        This encryption code is a direct transcription of the algorithm from
-  Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
-  file (appnote.txt) is distributed with the PKZIP program (even in the
-  version without encryption capabilities).
-
-        ------------------------------------------------------------------------------------
-
-        Changes in unzip.c
-
-        2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos
-  2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz*
-  2007-2008 - Even Rouault - Remove old C style function prototypes
-  2007-2008 - Even Rouault - Add unzip support for ZIP64
-
-        Copyright (C) 2007-2008 Even Rouault
-
-
-        Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
-  Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G
-                                should only read the compressed/uncompressed size from the Zip64 format if
-                                the size from normal header was 0xFFFFFFFF
-  Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant
-        Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required)
-                                Patch created by Daniel Borca
-
-  Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
-
-  Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson
-
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef NOUNCRYPT
-        #define NOUNCRYPT
-#endif
-
-#include "zlib.h"
-#include "unzip.h"
-
-#ifdef STDC
-#  include <stddef.h>
-#  include <string.h>
-#  include <stdlib.h>
-#endif
-#ifdef NO_ERRNO_H
-    extern int errno;
-#else
-#   include <errno.h>
-#endif
-
-
-#ifndef local
-#  define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-
-#ifndef CASESENSITIVITYDEFAULT_NO
-#  if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
-#    define CASESENSITIVITYDEFAULT_NO
-#  endif
-#endif
-
-
-#ifndef UNZ_BUFSIZE
-#define UNZ_BUFSIZE (16384)
-#endif
-
-#ifndef UNZ_MAXFILENAMEINZIP
-#define UNZ_MAXFILENAMEINZIP (256)
-#endif
-
-#ifndef ALLOC
-# define ALLOC(size) (malloc(size))
-#endif
-#ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
-#endif
-
-#define SIZECENTRALDIRITEM (0x2e)
-#define SIZEZIPLOCALHEADER (0x1e)
-
-
-const char unz_copyright[] =
-   " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
-
-/* unz_file_info_interntal contain internal info about a file in zipfile*/
-typedef struct unz_file_info64_internal_s
-{
-    ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
-} unz_file_info64_internal;
-
-
-/* file_in_zip_read_info_s contain internal information about a file in zipfile,
-    when reading and decompress it */
-typedef struct
-{
-    char  *read_buffer;         /* internal buffer for compressed data */
-    z_stream stream;            /* zLib stream structure for inflate */
-
-#ifdef HAVE_BZIP2
-    bz_stream bstream;          /* bzLib stream structure for bziped */
-#endif
-
-    ZPOS64_T pos_in_zipfile;       /* position in byte on the zipfile, for fseek*/
-    uLong stream_initialised;   /* flag set if stream structure is initialised*/
-
-    ZPOS64_T offset_local_extrafield;/* offset of the local extra field */
-    uInt  size_local_extrafield;/* size of the local extra field */
-    ZPOS64_T pos_local_extrafield;   /* position in the local extra field in read*/
-    ZPOS64_T total_out_64;
-
-    uLong crc32;                /* crc32 of all data uncompressed */
-    uLong crc32_wait;           /* crc32 we must obtain after decompress all */
-    ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
-    ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/
-    zlib_filefunc64_32_def z_filefunc;
-    voidpf filestream;        /* io structore of the zipfile */
-    uLong compression_method;   /* compression method (0==store) */
-    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
-    int   raw;
-} file_in_zip64_read_info_s;
-
-
-/* unz64_s contain internal information about the zipfile
-*/
-typedef struct
-{
-    zlib_filefunc64_32_def z_filefunc;
-    int is64bitOpenFunction;
-    voidpf filestream;        /* io structore of the zipfile */
-    unz_global_info64 gi;       /* public global information */
-    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
-    ZPOS64_T num_file;             /* number of the current file in the zipfile*/
-    ZPOS64_T pos_in_central_dir;   /* pos of the current file in the central dir*/
-    ZPOS64_T current_file_ok;      /* flag about the usability of the current file*/
-    ZPOS64_T central_pos;          /* position of the beginning of the central dir*/
-
-    ZPOS64_T size_central_dir;     /* size of the central directory  */
-    ZPOS64_T offset_central_dir;   /* offset of start of central directory with
-                                   respect to the starting disk number */
-
-    unz_file_info64 cur_file_info; /* public info about the current file in zip*/
-    unz_file_info64_internal cur_file_info_internal; /* private info about it*/
-    file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current
-                                        file if we are decompressing it */
-    int encrypted;
-
-    int isZip64;
-
-#    ifndef NOUNCRYPT
-    unsigned long keys[3];     /* keys defining the pseudo-random sequence */
-    const unsigned long* pcrc_32_tab;
-#    endif
-} unz64_s;
-
-
-#ifndef NOUNCRYPT
-#include "crypt.h"
-#endif
-
-/* ===========================================================================
-     Read a byte from a gz_stream; update next_in and avail_in. Return EOF
-   for end of file.
-   IN assertion: the stream s has been sucessfully opened for reading.
-*/
-
-
-local int unz64local_getByte OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream,
-    int *pi));
-
-local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
-{
-    unsigned char c;
-    int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
-    if (err==1)
-    {
-        *pi = (int)c;
-        return UNZ_OK;
-    }
-    else
-    {
-        if (ZERROR64(*pzlib_filefunc_def,filestream))
-            return UNZ_ERRNO;
-        else
-            return UNZ_EOF;
-    }
-}
-
-
-/* ===========================================================================
-   Reads a long in LSB order from the given gz_stream. Sets
-*/
-local int unz64local_getShort OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream,
-    uLong *pX));
-
-local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
-                             voidpf filestream,
-                             uLong *pX)
-{
-    uLong x ;
-    int i = 0;
-    int err;
-
-    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x = (uLong)i;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((uLong)i)<<8;
-
-    if (err==UNZ_OK)
-        *pX = x;
-    else
-        *pX = 0;
-    return err;
-}
-
-local int unz64local_getLong OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream,
-    uLong *pX));
-
-local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
-                            voidpf filestream,
-                            uLong *pX)
-{
-    uLong x ;
-    int i = 0;
-    int err;
-
-    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x = (uLong)i;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((uLong)i)<<8;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((uLong)i)<<16;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x += ((uLong)i)<<24;
-
-    if (err==UNZ_OK)
-        *pX = x;
-    else
-        *pX = 0;
-    return err;
-}
-
-local int unz64local_getLong64 OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream,
-    ZPOS64_T *pX));
-
-
-local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
-                            voidpf filestream,
-                            ZPOS64_T *pX)
-{
-    ZPOS64_T x ;
-    int i = 0;
-    int err;
-
-    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x = (ZPOS64_T)i;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<8;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<16;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<24;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<32;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<40;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<48;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<56;
-
-    if (err==UNZ_OK)
-        *pX = x;
-    else
-        *pX = 0;
-    return err;
-}
-
-/* My own strcmpi / strcasecmp */
-local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)
-{
-    for (;;)
-    {
-        char c1=*(fileName1++);
-        char c2=*(fileName2++);
-        if ((c1>='a') && (c1<='z'))
-            c1 -= 0x20;
-        if ((c2>='a') && (c2<='z'))
-            c2 -= 0x20;
-        if (c1=='\0')
-            return ((c2=='\0') ? 0 : -1);
-        if (c2=='\0')
-            return 1;
-        if (c1<c2)
-            return -1;
-        if (c1>c2)
-            return 1;
-    }
-}
-
-
-#ifdef  CASESENSITIVITYDEFAULT_NO
-#define CASESENSITIVITYDEFAULTVALUE 2
-#else
-#define CASESENSITIVITYDEFAULTVALUE 1
-#endif
-
-#ifndef STRCMPCASENOSENTIVEFUNCTION
-#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
-#endif
-
-/*
-   Compare two filename (fileName1,fileName2).
-   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
-   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
-                                                                or strcasecmp)
-   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
-        (like 1 on Unix, 2 on Windows)
-
-*/
-extern int ZEXPORT unzStringFileNameCompare (const char*  fileName1,
-                                                 const char*  fileName2,
-                                                 int iCaseSensitivity)
-
-{
-    if (iCaseSensitivity==0)
-        iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
-
-    if (iCaseSensitivity==1)
-        return strcmp(fileName1,fileName2);
-
-    return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
-}
-
-#ifndef BUFREADCOMMENT
-#define BUFREADCOMMENT (0x400)
-#endif
-
-/*
-  Locate the Central directory of a zipfile (at the end, just before
-    the global comment)
-*/
-local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
-local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
-{
-    unsigned char* buf;
-    ZPOS64_T uSizeFile;
-    ZPOS64_T uBackRead;
-    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
-    ZPOS64_T uPosFound=0;
-
-    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
-        return 0;
-
-
-    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
-
-    if (uMaxBack>uSizeFile)
-        uMaxBack = uSizeFile;
-
-    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
-    if (buf==NULL)
-        return 0;
-
-    uBackRead = 4;
-    while (uBackRead<uMaxBack)
-    {
-        uLong uReadSize;
-        ZPOS64_T uReadPos ;
-        int i;
-        if (uBackRead+BUFREADCOMMENT>uMaxBack)
-            uBackRead = uMaxBack;
-        else
-            uBackRead+=BUFREADCOMMENT;
-        uReadPos = uSizeFile-uBackRead ;
-
-        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
-                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
-        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-            break;
-
-        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
-            break;
-
-        for (i=(int)uReadSize-3; (i--)>0;)
-            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
-                ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
-            {
-                uPosFound = uReadPos+i;
-                break;
-            }
-
-        if (uPosFound!=0)
-            break;
-    }
-    TRYFREE(buf);
-    return uPosFound;
-}
-
-
-/*
-  Locate the Central directory 64 of a zipfile (at the end, just before
-    the global comment)
-*/
-local ZPOS64_T unz64local_SearchCentralDir64 OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream));
-
-local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
-                                      voidpf filestream)
-{
-    unsigned char* buf;
-    ZPOS64_T uSizeFile;
-    ZPOS64_T uBackRead;
-    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
-    ZPOS64_T uPosFound=0;
-    uLong uL;
-                ZPOS64_T relativeOffset;
-
-    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
-        return 0;
-
-
-    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
-
-    if (uMaxBack>uSizeFile)
-        uMaxBack = uSizeFile;
-
-    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
-    if (buf==NULL)
-        return 0;
-
-    uBackRead = 4;
-    while (uBackRead<uMaxBack)
-    {
-        uLong uReadSize;
-        ZPOS64_T uReadPos;
-        int i;
-        if (uBackRead+BUFREADCOMMENT>uMaxBack)
-            uBackRead = uMaxBack;
-        else
-            uBackRead+=BUFREADCOMMENT;
-        uReadPos = uSizeFile-uBackRead ;
-
-        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
-                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
-        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-            break;
-
-        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
-            break;
-
-        for (i=(int)uReadSize-3; (i--)>0;)
-            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
-                ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
-            {
-                uPosFound = uReadPos+i;
-                break;
-            }
-
-        if (uPosFound!=0)
-            break;
-    }
-    TRYFREE(buf);
-    if (uPosFound == 0)
-        return 0;
-
-    /* Zip64 end of central directory locator */
-    if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return 0;
-
-    /* the signature, already checked */
-    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-        return 0;
-
-    /* number of the disk with the start of the zip64 end of  central directory */
-    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-        return 0;
-    if (uL != 0)
-        return 0;
-
-    /* relative offset of the zip64 end of central directory record */
-    if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
-        return 0;
-
-    /* total number of disks */
-    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-        return 0;
-    if (uL != 1)
-        return 0;
-
-    /* Goto end of central directory record */
-    if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return 0;
-
-     /* the signature */
-    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-        return 0;
-
-    if (uL != 0x06064b50)
-        return 0;
-
-    return relativeOffset;
-}
-
-/*
-  Open a Zip file. path contain the full pathname (by example,
-     on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
-     "zlib/zlib114.zip".
-     If the zipfile cannot be opened (file doesn't exist or in not valid), the
-       return value is NULL.
-     Else, the return value is a unzFile Handle, usable with other function
-       of this unzip package.
-*/
-local unzFile unzOpenInternal (const void *path,
-                               zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
-                               int is64bitOpenFunction)
-{
-    unz64_s us;
-    unz64_s *s;
-    ZPOS64_T central_pos;
-    uLong   uL;
-
-    uLong number_disk;          /* number of the current dist, used for
-                                   spaning ZIP, unsupported, always 0*/
-    uLong number_disk_with_CD;  /* number the the disk with central dir, used
-                                   for spaning ZIP, unsupported, always 0*/
-    ZPOS64_T number_entry_CD;      /* total number of entries in
-                                   the central dir
-                                   (same than number_entry on nospan) */
-
-    int err=UNZ_OK;
-
-    if (unz_copyright[0]!=' ')
-        return NULL;
-
-    memset(&us,0,sizeof(unz64_s));
-    us.z_filefunc.zseek32_file = NULL;
-    us.z_filefunc.ztell32_file = NULL;
-    if (pzlib_filefunc64_32_def==NULL)
-        fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
-    else
-        us.z_filefunc = *pzlib_filefunc64_32_def;
-    us.is64bitOpenFunction = is64bitOpenFunction;
-
-
-
-    us.filestream = ZOPEN64(us.z_filefunc,
-                                                 path,
-                                                 ZLIB_FILEFUNC_MODE_READ |
-                                                 ZLIB_FILEFUNC_MODE_EXISTING);
-    if (us.filestream==NULL)
-        return NULL;
-
-    central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
-    if (central_pos)
-    {
-        uLong uS;
-        ZPOS64_T uL64;
-
-        us.isZip64 = 1;
-
-        if (ZSEEK64(us.z_filefunc, us.filestream,
-                                      central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        err=UNZ_ERRNO;
-
-        /* the signature, already checked */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* size of zip64 end of central directory record */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* version made by */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* version needed to extract */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* number of this disk */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* number of the disk with the start of the central directory */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* total number of entries in the central directory on this disk */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* total number of entries in the central directory */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        if ((number_entry_CD!=us.gi.number_entry) ||
-            (number_disk_with_CD!=0) ||
-            (number_disk!=0))
-            err=UNZ_BADZIPFILE;
-
-        /* size of the central directory */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* offset of start of central directory with respect to the
-          starting disk number */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        us.gi.size_comment = 0;
-    }
-    else
-    {
-        central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);
-        if (central_pos==0)
-            err=UNZ_ERRNO;
-
-        us.isZip64 = 0;
-
-        if (ZSEEK64(us.z_filefunc, us.filestream,
-                                        central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-            err=UNZ_ERRNO;
-
-        /* the signature, already checked */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* number of this disk */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* number of the disk with the start of the central directory */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* total number of entries in the central dir on this disk */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-        us.gi.number_entry = uL;
-
-        /* total number of entries in the central dir */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-        number_entry_CD = uL;
-
-        if ((number_entry_CD!=us.gi.number_entry) ||
-            (number_disk_with_CD!=0) ||
-            (number_disk!=0))
-            err=UNZ_BADZIPFILE;
-
-        /* size of the central directory */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-        us.size_central_dir = uL;
-
-        /* offset of start of central directory with respect to the
-            starting disk number */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-        us.offset_central_dir = uL;
-
-        /* zipfile comment length */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
-            err=UNZ_ERRNO;
-    }
-
-    if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
-        (err==UNZ_OK))
-        err=UNZ_BADZIPFILE;
-
-    if (err!=UNZ_OK)
-    {
-        ZCLOSE64(us.z_filefunc, us.filestream);
-        return NULL;
-    }
-
-    us.byte_before_the_zipfile = central_pos -
-                            (us.offset_central_dir+us.size_central_dir);
-    us.central_pos = central_pos;
-    us.pfile_in_zip_read = NULL;
-    us.encrypted = 0;
-    us.num_file = 0;
-
-
-    s=(unz64_s*)ALLOC(sizeof(unz64_s));
-    if( s != NULL)
-    {
-        *s=us;
-        unzGoToFirstFile((unzFile)s);
-    }
-    return (unzFile)s;
-}
-
-
-extern unzFile ZEXPORT unzOpen2 (const char *path,
-                                        zlib_filefunc_def* pzlib_filefunc32_def)
-{
-    if (pzlib_filefunc32_def != NULL)
-    {
-        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
-        fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);
-        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0);
-    }
-    else
-        return unzOpenInternal(path, NULL, 0);
-}
-
-extern unzFile ZEXPORT unzOpen2_64 (const void *path,
-                                     zlib_filefunc64_def* pzlib_filefunc_def)
-{
-    if (pzlib_filefunc_def != NULL)
-    {
-        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
-        zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
-        zlib_filefunc64_32_def_fill.ztell32_file = NULL;
-        zlib_filefunc64_32_def_fill.zseek32_file = NULL;
-        zlib_filefunc64_32_def_fill.zopen32_file = NULL;
-        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
-    }
-    else
-        return unzOpenInternal(path, NULL, 1);
-}
-
-extern unzFile ZEXPORT unzOpen (const char *path)
-{
-    return unzOpenInternal(path, NULL, 0);
-}
-
-extern unzFile ZEXPORT unzOpen64 (const void *path)
-{
-    return unzOpenInternal(path, NULL, 1);
-}
-
-/*
-  Close a ZipFile opened with unzipOpen.
-  If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
-    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
-  return UNZ_OK if there is no problem. */
-extern int ZEXPORT unzClose (unzFile file)
-{
-    unz64_s* s;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-
-    if (s->pfile_in_zip_read!=NULL)
-        unzCloseCurrentFile(file);
-
-    ZCLOSE64(s->z_filefunc, s->filestream);
-    TRYFREE(s);
-    return UNZ_OK;
-}
-
-
-/*
-  Write info about the ZipFile in the *pglobal_info structure.
-  No preparation of the structure is needed
-  return UNZ_OK if there is no problem. */
-extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)
-{
-    unz64_s* s;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    *pglobal_info=s->gi;
-    return UNZ_OK;
-}
-
-extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)
-{
-    unz64_s* s;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    /* to do : check if number_entry is not truncated */
-    pglobal_info32->number_entry = (uLong)s->gi.number_entry;
-    pglobal_info32->size_comment = s->gi.size_comment;
-    return UNZ_OK;
-}
-/*
-   Translate date/time from Dos format to tm_unz (readable more easilty)
-*/
-local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
-{
-    ZPOS64_T uDate;
-    uDate = (ZPOS64_T)(ulDosDate>>16);
-    ptm->tm_mday = (uInt)(uDate&0x1f) ;
-    ptm->tm_mon =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;
-    ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
-
-    ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
-    ptm->tm_min =  (uInt) ((ulDosDate&0x7E0)/0x20) ;
-    ptm->tm_sec =  (uInt) (2*(ulDosDate&0x1f)) ;
-}
-
-/*
-  Get Info about the current file in the zipfile, with internal only info
-*/
-local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
-                                                  unz_file_info64 *pfile_info,
-                                                  unz_file_info64_internal
-                                                  *pfile_info_internal,
-                                                  char *szFileName,
-                                                  uLong fileNameBufferSize,
-                                                  void *extraField,
-                                                  uLong extraFieldBufferSize,
-                                                  char *szComment,
-                                                  uLong commentBufferSize));
-
-local int unz64local_GetCurrentFileInfoInternal (unzFile file,
-                                                  unz_file_info64 *pfile_info,
-                                                  unz_file_info64_internal
-                                                  *pfile_info_internal,
-                                                  char *szFileName,
-                                                  uLong fileNameBufferSize,
-                                                  void *extraField,
-                                                  uLong extraFieldBufferSize,
-                                                  char *szComment,
-                                                  uLong commentBufferSize)
-{
-    unz64_s* s;
-    unz_file_info64 file_info;
-    unz_file_info64_internal file_info_internal;
-    int err=UNZ_OK;
-    uLong uMagic;
-    long lSeek=0;
-    uLong uL;
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (ZSEEK64(s->z_filefunc, s->filestream,
-              s->pos_in_central_dir+s->byte_before_the_zipfile,
-              ZLIB_FILEFUNC_SEEK_SET)!=0)
-        err=UNZ_ERRNO;
-
-
-    /* we check the magic */
-    if (err==UNZ_OK)
-    {
-        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
-            err=UNZ_ERRNO;
-        else if (uMagic!=0x02014b50)
-            err=UNZ_BADZIPFILE;
-    }
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-        err=UNZ_ERRNO;
-    file_info.compressed_size = uL;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-        err=UNZ_ERRNO;
-    file_info.uncompressed_size = uL;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-                // relative offset of local header
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-        err=UNZ_ERRNO;
-    file_info_internal.offset_curfile = uL;
-
-    lSeek+=file_info.size_filename;
-    if ((err==UNZ_OK) && (szFileName!=NULL))
-    {
-        uLong uSizeRead ;
-        if (file_info.size_filename<fileNameBufferSize)
-        {
-            *(szFileName+file_info.size_filename)='\0';
-            uSizeRead = file_info.size_filename;
-        }
-        else
-            uSizeRead = fileNameBufferSize;
-
-        if ((file_info.size_filename>0) && (fileNameBufferSize>0))
-            if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
-                err=UNZ_ERRNO;
-        lSeek -= uSizeRead;
-    }
-
-    // Read extrafield
-    if ((err==UNZ_OK) && (extraField!=NULL))
-    {
-        ZPOS64_T uSizeRead ;
-        if (file_info.size_file_extra<extraFieldBufferSize)
-            uSizeRead = file_info.size_file_extra;
-        else
-            uSizeRead = extraFieldBufferSize;
-
-        if (lSeek!=0)
-        {
-            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-                lSeek=0;
-            else
-                err=UNZ_ERRNO;
-        }
-
-        if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
-            if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)
-                err=UNZ_ERRNO;
-
-        lSeek += file_info.size_file_extra - (uLong)uSizeRead;
-    }
-    else
-        lSeek += file_info.size_file_extra;
-
-
-    if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
-    {
-                                uLong acc = 0;
-
-        // since lSeek now points to after the extra field we need to move back
-        lSeek -= file_info.size_file_extra;
-
-        if (lSeek!=0)
-        {
-            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-                lSeek=0;
-            else
-                err=UNZ_ERRNO;
-        }
-
-        while(acc < file_info.size_file_extra)
-        {
-            uLong headerId;
-                                                uLong dataSize;
-
-            if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)
-                err=UNZ_ERRNO;
-
-            if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)
-                err=UNZ_ERRNO;
-
-            /* ZIP64 extra fields */
-            if (headerId == 0x0001)
-            {
-                                                        uLong uL;
-
-                                                                if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)
-                                                                {
-                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
-                                                                                        err=UNZ_ERRNO;
-                                                                }
-
-                                                                if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)
-                                                                {
-                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
-                                                                                  err=UNZ_ERRNO;
-                                                                }
-
-                                                                if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)
-                                                                {
-                                                                        /* Relative Header offset */
-                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
-                                                                                err=UNZ_ERRNO;
-                                                                }
-
-                                                                if(file_info.disk_num_start == (unsigned long)-1)
-                                                                {
-                                                                        /* Disk Start Number */
-                                                                        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-                                                                                err=UNZ_ERRNO;
-                                                                }
-
-            }
-            else
-            {
-                if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
-                    err=UNZ_ERRNO;
-            }
-
-            acc += 2 + 2 + dataSize;
-        }
-    }
-
-    if ((err==UNZ_OK) && (szComment!=NULL))
-    {
-        uLong uSizeRead ;
-        if (file_info.size_file_comment<commentBufferSize)
-        {
-            *(szComment+file_info.size_file_comment)='\0';
-            uSizeRead = file_info.size_file_comment;
-        }
-        else
-            uSizeRead = commentBufferSize;
-
-        if (lSeek!=0)
-        {
-            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-                lSeek=0;
-            else
-                err=UNZ_ERRNO;
-        }
-
-        if ((file_info.size_file_comment>0) && (commentBufferSize>0))
-            if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
-                err=UNZ_ERRNO;
-        lSeek+=file_info.size_file_comment - uSizeRead;
-    }
-    else
-        lSeek+=file_info.size_file_comment;
-
-
-    if ((err==UNZ_OK) && (pfile_info!=NULL))
-        *pfile_info=file_info;
-
-    if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
-        *pfile_info_internal=file_info_internal;
-
-    return err;
-}
-
-
-
-/*
-  Write info about the ZipFile in the *pglobal_info structure.
-  No preparation of the structure is needed
-  return UNZ_OK if there is no problem.
-*/
-extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
-                                          unz_file_info64 * pfile_info,
-                                          char * szFileName, uLong fileNameBufferSize,
-                                          void *extraField, uLong extraFieldBufferSize,
-                                          char* szComment,  uLong commentBufferSize)
-{
-    return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
-                                                szFileName,fileNameBufferSize,
-                                                extraField,extraFieldBufferSize,
-                                                szComment,commentBufferSize);
-}
-
-extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
-                                          unz_file_info * pfile_info,
-                                          char * szFileName, uLong fileNameBufferSize,
-                                          void *extraField, uLong extraFieldBufferSize,
-                                          char* szComment,  uLong commentBufferSize)
-{
-    int err;
-    unz_file_info64 file_info64;
-    err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
-                                                szFileName,fileNameBufferSize,
-                                                extraField,extraFieldBufferSize,
-                                                szComment,commentBufferSize);
-    if (err==UNZ_OK)
-    {
-        pfile_info->version = file_info64.version;
-        pfile_info->version_needed = file_info64.version_needed;
-        pfile_info->flag = file_info64.flag;
-        pfile_info->compression_method = file_info64.compression_method;
-        pfile_info->dosDate = file_info64.dosDate;
-        pfile_info->crc = file_info64.crc;
-
-        pfile_info->size_filename = file_info64.size_filename;
-        pfile_info->size_file_extra = file_info64.size_file_extra;
-        pfile_info->size_file_comment = file_info64.size_file_comment;
-
-        pfile_info->disk_num_start = file_info64.disk_num_start;
-        pfile_info->internal_fa = file_info64.internal_fa;
-        pfile_info->external_fa = file_info64.external_fa;
-
-        pfile_info->tmu_date = file_info64.tmu_date,
-
-
-        pfile_info->compressed_size = (uLong)file_info64.compressed_size;
-        pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
-
-    }
-    return err;
-}
-/*
-  Set the current file of the zipfile to the first file.
-  return UNZ_OK if there is no problem
-*/
-extern int ZEXPORT unzGoToFirstFile (unzFile file)
-{
-    int err=UNZ_OK;
-    unz64_s* s;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    s->pos_in_central_dir=s->offset_central_dir;
-    s->num_file=0;
-    err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-                                             &s->cur_file_info_internal,
-                                             NULL,0,NULL,0,NULL,0);
-    s->current_file_ok = (err == UNZ_OK);
-    return err;
-}
-
-/*
-  Set the current file of the zipfile to the next file.
-  return UNZ_OK if there is no problem
-  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-extern int ZEXPORT unzGoToNextFile (unzFile  file)
-{
-    unz64_s* s;
-    int err;
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-        return UNZ_END_OF_LIST_OF_FILE;
-    if (s->gi.number_entry != 0xffff)    /* 2^16 files overflow hack */
-      if (s->num_file+1==s->gi.number_entry)
-        return UNZ_END_OF_LIST_OF_FILE;
-
-    s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
-            s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
-    s->num_file++;
-    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-                                               &s->cur_file_info_internal,
-                                               NULL,0,NULL,0,NULL,0);
-    s->current_file_ok = (err == UNZ_OK);
-    return err;
-}
-
-
-/*
-  Try locate the file szFileName in the zipfile.
-  For the iCaseSensitivity signification, see unzipStringFileNameCompare
-
-  return value :
-  UNZ_OK if the file is found. It becomes the current file.
-  UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
-{
-    unz64_s* s;
-    int err;
-
-    /* We remember the 'current' position in the file so that we can jump
-     * back there if we fail.
-     */
-    unz_file_info64 cur_file_infoSaved;
-    unz_file_info64_internal cur_file_info_internalSaved;
-    ZPOS64_T num_fileSaved;
-    ZPOS64_T pos_in_central_dirSaved;
-
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-
-    if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
-        return UNZ_PARAMERROR;
-
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-        return UNZ_END_OF_LIST_OF_FILE;
-
-    /* Save the current state */
-    num_fileSaved = s->num_file;
-    pos_in_central_dirSaved = s->pos_in_central_dir;
-    cur_file_infoSaved = s->cur_file_info;
-    cur_file_info_internalSaved = s->cur_file_info_internal;
-
-    err = unzGoToFirstFile(file);
-
-    while (err == UNZ_OK)
-    {
-        char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
-        err = unzGetCurrentFileInfo64(file,NULL,
-                                    szCurrentFileName,sizeof(szCurrentFileName)-1,
-                                    NULL,0,NULL,0);
-        if (err == UNZ_OK)
-        {
-            if (unzStringFileNameCompare(szCurrentFileName,
-                                            szFileName,iCaseSensitivity)==0)
-                return UNZ_OK;
-            err = unzGoToNextFile(file);
-        }
-    }
-
-    /* We failed, so restore the state of the 'current file' to where we
-     * were.
-     */
-    s->num_file = num_fileSaved ;
-    s->pos_in_central_dir = pos_in_central_dirSaved ;
-    s->cur_file_info = cur_file_infoSaved;
-    s->cur_file_info_internal = cur_file_info_internalSaved;
-    return err;
-}
-
-
-/*
-///////////////////////////////////////////
-// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
-// I need random access
-//
-// Further optimization could be realized by adding an ability
-// to cache the directory in memory. The goal being a single
-// comprehensive file read to put the file I need in a memory.
-*/
-
-/*
-typedef struct unz_file_pos_s
-{
-    ZPOS64_T pos_in_zip_directory;   // offset in file
-    ZPOS64_T num_of_file;            // # of file
-} unz_file_pos;
-*/
-
-extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos*  file_pos)
-{
-    unz64_s* s;
-
-    if (file==NULL || file_pos==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-        return UNZ_END_OF_LIST_OF_FILE;
-
-    file_pos->pos_in_zip_directory  = s->pos_in_central_dir;
-    file_pos->num_of_file           = s->num_file;
-
-    return UNZ_OK;
-}
-
-extern int ZEXPORT unzGetFilePos(
-    unzFile file,
-    unz_file_pos* file_pos)
-{
-    unz64_file_pos file_pos64;
-    int err = unzGetFilePos64(file,&file_pos64);
-    if (err==UNZ_OK)
-    {
-        file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
-        file_pos->num_of_file = (uLong)file_pos64.num_of_file;
-    }
-    return err;
-}
-
-extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)
-{
-    unz64_s* s;
-    int err;
-
-    if (file==NULL || file_pos==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-
-    /* jump to the right spot */
-    s->pos_in_central_dir = file_pos->pos_in_zip_directory;
-    s->num_file           = file_pos->num_of_file;
-
-    /* set the current file */
-    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-                                               &s->cur_file_info_internal,
-                                               NULL,0,NULL,0,NULL,0);
-    /* return results */
-    s->current_file_ok = (err == UNZ_OK);
-    return err;
-}
-
-extern int ZEXPORT unzGoToFilePos(
-    unzFile file,
-    unz_file_pos* file_pos)
-{
-    unz64_file_pos file_pos64;
-    if (file_pos == NULL)
-        return UNZ_PARAMERROR;
-
-    file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
-    file_pos64.num_of_file = file_pos->num_of_file;
-    return unzGoToFilePos64(file,&file_pos64);
-}
-
-/*
-// Unzip Helper Functions - should be here?
-///////////////////////////////////////////
-*/
-
-/*
-  Read the local header of the current zipfile
-  Check the coherency of the local header and info in the end of central
-        directory about this file
-  store in *piSizeVar the size of extra info in local header
-        (filename and size of extra field data)
-*/
-local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,
-                                                    ZPOS64_T * poffset_local_extrafield,
-                                                    uInt  * psize_local_extrafield)
-{
-    uLong uMagic,uData,uFlags;
-    uLong size_filename;
-    uLong size_extra_field;
-    int err=UNZ_OK;
-
-    *piSizeVar = 0;
-    *poffset_local_extrafield = 0;
-    *psize_local_extrafield = 0;
-
-    if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
-                                s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return UNZ_ERRNO;
-
-
-    if (err==UNZ_OK)
-    {
-        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
-            err=UNZ_ERRNO;
-        else if (uMagic!=0x04034b50)
-            err=UNZ_BADZIPFILE;
-    }
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
-        err=UNZ_ERRNO;
-/*
-    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
-        err=UNZ_BADZIPFILE;
-*/
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
-        err=UNZ_ERRNO;
-    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
-        err=UNZ_BADZIPFILE;
-
-    if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
-/* #ifdef HAVE_BZIP2 */
-                         (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-/* #endif */
-                         (s->cur_file_info.compression_method!=Z_DEFLATED))
-        err=UNZ_BADZIPFILE;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
-        err=UNZ_ERRNO;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
-        err=UNZ_ERRNO;
-    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))
-        err=UNZ_BADZIPFILE;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
-        err=UNZ_ERRNO;
-    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))
-        err=UNZ_BADZIPFILE;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
-        err=UNZ_ERRNO;
-    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))
-        err=UNZ_BADZIPFILE;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
-        err=UNZ_ERRNO;
-    else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
-        err=UNZ_BADZIPFILE;
-
-    *piSizeVar += (uInt)size_filename;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
-        err=UNZ_ERRNO;
-    *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
-                                    SIZEZIPLOCALHEADER + size_filename;
-    *psize_local_extrafield = (uInt)size_extra_field;
-
-    *piSizeVar += (uInt)size_extra_field;
-
-    return err;
-}
-
-/*
-  Open for reading data the current file in the zipfile.
-  If there is no error and the file is opened, the return value is UNZ_OK.
-*/
-extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
-                                            int* level, int raw, const char* password)
-{
-    int err=UNZ_OK;
-    uInt iSizeVar;
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    ZPOS64_T offset_local_extrafield;  /* offset of the local extra field */
-    uInt  size_local_extrafield;    /* size of the local extra field */
-#    ifndef NOUNCRYPT
-    char source[12];
-#    else
-    if (password != NULL)
-        return UNZ_PARAMERROR;
-#    endif
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-        return UNZ_PARAMERROR;
-
-    if (s->pfile_in_zip_read != NULL)
-        unzCloseCurrentFile(file);
-
-    if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
-        return UNZ_BADZIPFILE;
-
-    pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s));
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_INTERNALERROR;
-
-    pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
-    pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
-    pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
-    pfile_in_zip_read_info->pos_local_extrafield=0;
-    pfile_in_zip_read_info->raw=raw;
-
-    if (pfile_in_zip_read_info->read_buffer==NULL)
-    {
-        TRYFREE(pfile_in_zip_read_info);
-        return UNZ_INTERNALERROR;
-    }
-
-    pfile_in_zip_read_info->stream_initialised=0;
-
-    if (method!=NULL)
-        *method = (int)s->cur_file_info.compression_method;
-
-    if (level!=NULL)
-    {
-        *level = 6;
-        switch (s->cur_file_info.flag & 0x06)
-        {
-          case 6 : *level = 1; break;
-          case 4 : *level = 2; break;
-          case 2 : *level = 9; break;
-        }
-    }
-
-    if ((s->cur_file_info.compression_method!=0) &&
-/* #ifdef HAVE_BZIP2 */
-        (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-/* #endif */
-        (s->cur_file_info.compression_method!=Z_DEFLATED))
-
-        err=UNZ_BADZIPFILE;
-
-    pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
-    pfile_in_zip_read_info->crc32=0;
-    pfile_in_zip_read_info->total_out_64=0;
-    pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;
-    pfile_in_zip_read_info->filestream=s->filestream;
-    pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
-    pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
-
-    pfile_in_zip_read_info->stream.total_out = 0;
-
-    if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))
-    {
-#ifdef HAVE_BZIP2
-      pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
-      pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
-      pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
-      pfile_in_zip_read_info->bstream.state = (voidpf)0;
-
-      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
-      pfile_in_zip_read_info->stream.zfree = (free_func)0;
-      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
-      pfile_in_zip_read_info->stream.next_in = (voidpf)0;
-      pfile_in_zip_read_info->stream.avail_in = 0;
-
-      err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
-      if (err == Z_OK)
-        pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
-      else
-      {
-        TRYFREE(pfile_in_zip_read_info);
-        return err;
-      }
-#else
-      pfile_in_zip_read_info->raw=1;
-#endif
-    }
-    else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
-    {
-      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
-      pfile_in_zip_read_info->stream.zfree = (free_func)0;
-      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
-      pfile_in_zip_read_info->stream.next_in = 0;
-      pfile_in_zip_read_info->stream.avail_in = 0;
-
-      err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
-      if (err == Z_OK)
-        pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
-      else
-      {
-        TRYFREE(pfile_in_zip_read_info);
-        return err;
-      }
-        /* windowBits is passed < 0 to tell that there is no zlib header.
-         * Note that in this case inflate *requires* an extra "dummy" byte
-         * after the compressed stream in order to complete decompression and
-         * return Z_STREAM_END.
-         * In unzip, i don't wait absolutely Z_STREAM_END because I known the
-         * size of both compressed and uncompressed data
-         */
-    }
-    pfile_in_zip_read_info->rest_read_compressed =
-            s->cur_file_info.compressed_size ;
-    pfile_in_zip_read_info->rest_read_uncompressed =
-            s->cur_file_info.uncompressed_size ;
-
-
-    pfile_in_zip_read_info->pos_in_zipfile =
-            s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
-              iSizeVar;
-
-    pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-
-    s->pfile_in_zip_read = pfile_in_zip_read_info;
-                s->encrypted = 0;
-
-#    ifndef NOUNCRYPT
-    if (password != NULL)
-    {
-        int i;
-        s->pcrc_32_tab = get_crc_table();
-        init_keys(password,s->keys,s->pcrc_32_tab);
-        if (ZSEEK64(s->z_filefunc, s->filestream,
-                  s->pfile_in_zip_read->pos_in_zipfile +
-                     s->pfile_in_zip_read->byte_before_the_zipfile,
-                  SEEK_SET)!=0)
-            return UNZ_INTERNALERROR;
-        if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12)
-            return UNZ_INTERNALERROR;
-
-        for (i = 0; i<12; i++)
-            zdecode(s->keys,s->pcrc_32_tab,source[i]);
-
-        s->pfile_in_zip_read->pos_in_zipfile+=12;
-        s->encrypted=1;
-    }
-#    endif
-
-
-    return UNZ_OK;
-}
-
-extern int ZEXPORT unzOpenCurrentFile (unzFile file)
-{
-    return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
-}
-
-extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char*  password)
-{
-    return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
-}
-
-extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw)
-{
-    return unzOpenCurrentFile3(file, method, level, raw, NULL);
-}
-
-/** Addition for GDAL : START */
-
-extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
-{
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    s=(unz64_s*)file;
-    if (file==NULL)
-        return 0; //UNZ_PARAMERROR;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-    if (pfile_in_zip_read_info==NULL)
-        return 0; //UNZ_PARAMERROR;
-    return pfile_in_zip_read_info->pos_in_zipfile +
-                         pfile_in_zip_read_info->byte_before_the_zipfile;
-}
-
-/** Addition for GDAL : END */
-
-/*
-  Read bytes from the current file.
-  buf contain buffer where data must be copied
-  len the size of buf.
-
-  return the number of byte copied if somes bytes are copied
-  return 0 if the end of file was reached
-  return <0 with error code if there is an error
-    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-extern int ZEXPORT unzReadCurrentFile  (unzFile file, voidp buf, unsigned len)
-{
-    int err=UNZ_OK;
-    uInt iRead = 0;
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-
-    if (pfile_in_zip_read_info->read_buffer == NULL)
-        return UNZ_END_OF_LIST_OF_FILE;
-    if (len==0)
-        return 0;
-
-    pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
-
-    pfile_in_zip_read_info->stream.avail_out = (uInt)len;
-
-    if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
-        (!(pfile_in_zip_read_info->raw)))
-        pfile_in_zip_read_info->stream.avail_out =
-            (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
-
-    if ((len>pfile_in_zip_read_info->rest_read_compressed+
-           pfile_in_zip_read_info->stream.avail_in) &&
-         (pfile_in_zip_read_info->raw))
-        pfile_in_zip_read_info->stream.avail_out =
-            (uInt)pfile_in_zip_read_info->rest_read_compressed+
-            pfile_in_zip_read_info->stream.avail_in;
-
-    while (pfile_in_zip_read_info->stream.avail_out>0)
-    {
-        if ((pfile_in_zip_read_info->stream.avail_in==0) &&
-            (pfile_in_zip_read_info->rest_read_compressed>0))
-        {
-            uInt uReadThis = UNZ_BUFSIZE;
-            if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
-                uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
-            if (uReadThis == 0)
-                return UNZ_EOF;
-            if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
-                      pfile_in_zip_read_info->filestream,
-                      pfile_in_zip_read_info->pos_in_zipfile +
-                         pfile_in_zip_read_info->byte_before_the_zipfile,
-                         ZLIB_FILEFUNC_SEEK_SET)!=0)
-                return UNZ_ERRNO;
-            if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
-                      pfile_in_zip_read_info->filestream,
-                      pfile_in_zip_read_info->read_buffer,
-                      uReadThis)!=uReadThis)
-                return UNZ_ERRNO;
-
-
-#            ifndef NOUNCRYPT
-            if(s->encrypted)
-            {
-                uInt i;
-                for(i=0;i<uReadThis;i++)
-                  pfile_in_zip_read_info->read_buffer[i] =
-                      zdecode(s->keys,s->pcrc_32_tab,
-                              pfile_in_zip_read_info->read_buffer[i]);
-            }
-#            endif
-
-
-            pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
-
-            pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
-
-            pfile_in_zip_read_info->stream.next_in =
-                (Bytef*)pfile_in_zip_read_info->read_buffer;
-            pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
-        }
-
-        if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
-        {
-            uInt uDoCopy,i ;
-
-            if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
-                (pfile_in_zip_read_info->rest_read_compressed == 0))
-                return (iRead==0) ? UNZ_EOF : iRead;
-
-            if (pfile_in_zip_read_info->stream.avail_out <
-                            pfile_in_zip_read_info->stream.avail_in)
-                uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
-            else
-                uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
-
-            for (i=0;i<uDoCopy;i++)
-                *(pfile_in_zip_read_info->stream.next_out+i) =
-                        *(pfile_in_zip_read_info->stream.next_in+i);
-
-            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;
-
-            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
-                                pfile_in_zip_read_info->stream.next_out,
-                                uDoCopy);
-            pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
-            pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
-            pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
-            pfile_in_zip_read_info->stream.next_out += uDoCopy;
-            pfile_in_zip_read_info->stream.next_in += uDoCopy;
-            pfile_in_zip_read_info->stream.total_out += uDoCopy;
-            iRead += uDoCopy;
-        }
-        else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
-        {
-#ifdef HAVE_BZIP2
-            uLong uTotalOutBefore,uTotalOutAfter;
-            const Bytef *bufBefore;
-            uLong uOutThis;
-
-            pfile_in_zip_read_info->bstream.next_in        = (char*)pfile_in_zip_read_info->stream.next_in;
-            pfile_in_zip_read_info->bstream.avail_in       = pfile_in_zip_read_info->stream.avail_in;
-            pfile_in_zip_read_info->bstream.total_in_lo32  = pfile_in_zip_read_info->stream.total_in;
-            pfile_in_zip_read_info->bstream.total_in_hi32  = 0;
-            pfile_in_zip_read_info->bstream.next_out       = (char*)pfile_in_zip_read_info->stream.next_out;
-            pfile_in_zip_read_info->bstream.avail_out      = pfile_in_zip_read_info->stream.avail_out;
-            pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
-            pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
-
-            uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
-            bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;
-
-            err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
-
-            uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
-            uOutThis = uTotalOutAfter-uTotalOutBefore;
-
-            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
-
-            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));
-            pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
-            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
-            pfile_in_zip_read_info->stream.next_in   = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
-            pfile_in_zip_read_info->stream.avail_in  = pfile_in_zip_read_info->bstream.avail_in;
-            pfile_in_zip_read_info->stream.total_in  = pfile_in_zip_read_info->bstream.total_in_lo32;
-            pfile_in_zip_read_info->stream.next_out  = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
-            pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
-            pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
-
-            if (err==BZ_STREAM_END)
-              return (iRead==0) ? UNZ_EOF : iRead;
-            if (err!=BZ_OK)
-              break;
-#endif
-        } // end Z_BZIP2ED
-        else
-        {
-            ZPOS64_T uTotalOutBefore,uTotalOutAfter;
-            const Bytef *bufBefore;
-            ZPOS64_T uOutThis;
-            int flush=Z_SYNC_FLUSH;
-
-            uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
-            bufBefore = pfile_in_zip_read_info->stream.next_out;
-
-            /*
-            if ((pfile_in_zip_read_info->rest_read_uncompressed ==
-                     pfile_in_zip_read_info->stream.avail_out) &&
-                (pfile_in_zip_read_info->rest_read_compressed == 0))
-                flush = Z_FINISH;
-            */
-            err=inflate(&pfile_in_zip_read_info->stream,flush);
-
-            if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
-              err = Z_DATA_ERROR;
-
-            uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
-            uOutThis = uTotalOutAfter-uTotalOutBefore;
-
-            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
-
-            pfile_in_zip_read_info->crc32 =
-                crc32(pfile_in_zip_read_info->crc32,bufBefore,
-                        (uInt)(uOutThis));
-
-            pfile_in_zip_read_info->rest_read_uncompressed -=
-                uOutThis;
-
-            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
-            if (err==Z_STREAM_END)
-                return (iRead==0) ? UNZ_EOF : iRead;
-            if (err!=Z_OK)
-                break;
-        }
-    }
-
-    if (err==Z_OK)
-        return iRead;
-    return err;
-}
-
-
-/*
-  Give the current position in uncompressed data
-*/
-extern z_off_t ZEXPORT unztell (unzFile file)
-{
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-    return (z_off_t)pfile_in_zip_read_info->stream.total_out;
-}
-
-extern ZPOS64_T ZEXPORT unztell64 (unzFile file)
-{
-
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return (ZPOS64_T)-1;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return (ZPOS64_T)-1;
-
-    return pfile_in_zip_read_info->total_out_64;
-}
-
-
-/*
-  return 1 if the end of file was reached, 0 elsewhere
-*/
-extern int ZEXPORT unzeof (unzFile file)
-{
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-    if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
-        return 1;
-    else
-        return 0;
-}
-
-
-
-/*
-Read extra field from the current file (opened by unzOpenCurrentFile)
-This is the local-header version of the extra field (sometimes, there is
-more info in the local-header version than in the central-header)
-
-  if buf==NULL, it return the size of the local extra field that can be read
-
-  if buf!=NULL, len is the size of the buffer, the extra header is copied in
-    buf.
-  the return value is the number of bytes copied in buf, or (if <0)
-    the error code
-*/
-extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
-{
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    uInt read_now;
-    ZPOS64_T size_to_read;
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-    size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
-                pfile_in_zip_read_info->pos_local_extrafield);
-
-    if (buf==NULL)
-        return (int)size_to_read;
-
-    if (len>size_to_read)
-        read_now = (uInt)size_to_read;
-    else
-        read_now = (uInt)len ;
-
-    if (read_now==0)
-        return 0;
-
-    if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
-              pfile_in_zip_read_info->filestream,
-              pfile_in_zip_read_info->offset_local_extrafield +
-              pfile_in_zip_read_info->pos_local_extrafield,
-              ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return UNZ_ERRNO;
-
-    if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
-              pfile_in_zip_read_info->filestream,
-              buf,read_now)!=read_now)
-        return UNZ_ERRNO;
-
-    return (int)read_now;
-}
-
-/*
-  Close the file in zip opened with unzipOpenCurrentFile
-  Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-extern int ZEXPORT unzCloseCurrentFile (unzFile file)
-{
-    int err=UNZ_OK;
-
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-
-    if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
-        (!pfile_in_zip_read_info->raw))
-    {
-        if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
-            err=UNZ_CRCERROR;
-    }
-
-
-    TRYFREE(pfile_in_zip_read_info->read_buffer);
-    pfile_in_zip_read_info->read_buffer = NULL;
-    if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
-        inflateEnd(&pfile_in_zip_read_info->stream);
-#ifdef HAVE_BZIP2
-    else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
-        BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
-#endif
-
-
-    pfile_in_zip_read_info->stream_initialised = 0;
-    TRYFREE(pfile_in_zip_read_info);
-
-    s->pfile_in_zip_read=NULL;
-
-    return err;
-}
-
-
-/*
-  Get the global comment string of the ZipFile, in the szComment buffer.
-  uSizeBuf is the size of the szComment buffer.
-  return the number of byte copied or an error code <0
-*/
-extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)
-{
-    unz64_s* s;
-    uLong uReadThis ;
-    if (file==NULL)
-        return (int)UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-
-    uReadThis = uSizeBuf;
-    if (uReadThis>s->gi.size_comment)
-        uReadThis = s->gi.size_comment;
-
-    if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return UNZ_ERRNO;
-
-    if (uReadThis>0)
-    {
-      *szComment='\0';
-      if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
-        return UNZ_ERRNO;
-    }
-
-    if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
-        *(szComment+s->gi.size_comment)='\0';
-    return (int)uReadThis;
-}
-
-/* Additions by RX '2004 */
-extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
-{
-    unz64_s* s;
-
-    if (file==NULL)
-          return 0; //UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-      return 0;
-    if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
-      if (s->num_file==s->gi.number_entry)
-         return 0;
-    return s->pos_in_central_dir;
-}
-
-extern uLong ZEXPORT unzGetOffset (unzFile file)
-{
-    ZPOS64_T offset64;
-
-    if (file==NULL)
-          return 0; //UNZ_PARAMERROR;
-    offset64 = unzGetOffset64(file);
-    return (uLong)offset64;
-}
-
-extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
-{
-    unz64_s* s;
-    int err;
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-
-    s->pos_in_central_dir = pos;
-    s->num_file = s->gi.number_entry;      /* hack */
-    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-                                              &s->cur_file_info_internal,
-                                              NULL,0,NULL,0,NULL,0);
-    s->current_file_ok = (err == UNZ_OK);
-    return err;
-}
-
-extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
-{
-    return unzSetOffset64(file,pos);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/public/include/resource_processor.h
----------------------------------------------------------------------
diff --git a/deployment_admin/public/include/resource_processor.h b/deployment_admin/public/include/resource_processor.h
deleted file mode 100644
index f91e13b..0000000
--- a/deployment_admin/public/include/resource_processor.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- *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.
- */
-/*
- * resource_processor.h
- *
- *  \date       Feb 13, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef RESOURCE_PROCESSOR_H_
-#define RESOURCE_PROCESSOR_H_
-
-#include "celix_errno.h"
-
-#define DEPLOYMENTADMIN_RESOURCE_PROCESSOR_SERVICE "resource_processor"
-
-typedef struct resource_processor *resource_processor_pt;
-
-typedef struct resource_processor_service *resource_processor_service_pt;
-
-struct resource_processor_service {
-	resource_processor_pt processor;
-	celix_status_t (*begin)(resource_processor_pt processor, char *packageName);
-
-	celix_status_t (*process)(resource_processor_pt processor, char *name, char *path);
-
-	celix_status_t (*dropped)(resource_processor_pt processor, char *name);
-	celix_status_t (*dropAllResources)(resource_processor_pt processor);
-
-	//celix_status_t (*prepare)(resource_processor_pt processor);
-	//celix_status_t (*commit)(resource_processor_pt processor);
-	//celix_status_t (*rollback)(resource_processor_pt processor);
-
-	//celix_status_t (*cancel)(resource_processor_pt processor);
-};
-
-#endif /* RESOURCE_PROCESSOR_H_ */


[21/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/service_reference.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_reference.c b/framework/private/src/service_reference.c
deleted file mode 100644
index 545426d..0000000
--- a/framework/private/src/service_reference.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/**
- *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.
- */
-/*
- * service_reference.c
- *
- *  \date       Jul 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <constants.h>
-#include <stdint.h>
-#include <utils.h>
-#include <assert.h>
-
-#include "service_reference.h"
-
-#include "service_reference_private.h"
-#include "service_registration_private.h"
-
-static void serviceReference_destroy(service_reference_pt);
-static void serviceReference_logWarningUsageCountBelowZero(service_reference_pt ref);
-
-celix_status_t serviceReference_create(registry_callback_t callback, bundle_pt referenceOwner, service_registration_pt registration,  service_reference_pt *out) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_reference_pt ref = calloc(1, sizeof(*ref));
-	if (!ref) {
-		status = CELIX_ENOMEM;
-	} else {
-        ref->callback = callback;
-		ref->referenceOwner = referenceOwner;
-		ref->registration = registration;
-        ref->service = NULL;
-        serviceRegistration_getBundle(registration, &ref->registrationBundle);
-		celixThreadRwlock_create(&ref->lock, NULL);
-		ref->refCount = 1;
-        ref->usageCount = 0;
-
-        serviceRegistration_retain(ref->registration);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*out = ref;
-	}
-
-    framework_logIfError(logger, status, NULL, "Cannot create service reference");
-
-	return status;
-}
-
-celix_status_t serviceReference_retain(service_reference_pt ref) {
-    celixThreadRwlock_writeLock(&ref->lock);
-    ref->refCount += 1;
-    celixThreadRwlock_unlock(&ref->lock);
-    return CELIX_SUCCESS;
-}
-
-celix_status_t serviceReference_release(service_reference_pt ref, bool *out) {
-    bool destroyed = false;
-    celixThreadRwlock_writeLock(&ref->lock);
-    assert(ref->refCount > 0);
-    ref->refCount -= 1;
-    if (ref->refCount == 0) {
-        if (ref->registration != NULL) {
-            serviceRegistration_release(ref->registration);
-        }
-        celixThreadRwlock_unlock(&ref->lock);
-        serviceReference_destroy(ref);
-        destroyed = true;
-    } else {
-        celixThreadRwlock_unlock(&ref->lock);
-    }
-
-    if (out) {
-        *out = destroyed;
-    }
-    return CELIX_SUCCESS;
-}
-
-celix_status_t serviceReference_increaseUsage(service_reference_pt ref, size_t *out) {
-    //fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Destroying service reference %p\n", ref);
-    size_t local = 0;
-    celixThreadRwlock_writeLock(&ref->lock);
-    ref->usageCount += 1;
-    local = ref->usageCount;
-    celixThreadRwlock_unlock(&ref->lock);
-    if (out) {
-        *out = local;
-    }
-    return CELIX_SUCCESS;
-}
-
-celix_status_t serviceReference_decreaseUsage(service_reference_pt ref, size_t *out) {
-    celix_status_t status = CELIX_SUCCESS;
-    size_t localCount = 0;
-    celixThreadRwlock_writeLock(&ref->lock);
-    if (ref->usageCount == 0) {
-        serviceReference_logWarningUsageCountBelowZero(ref);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else {
-        ref->usageCount -= 1;
-    }
-    localCount = ref->usageCount;
-    celixThreadRwlock_unlock(&ref->lock);
-
-    if (out) {
-        *out = localCount;
-    }
-    return status;
-}
-
-static void serviceReference_logWarningUsageCountBelowZero(service_reference_pt ref __attribute__((unused))) {
-    fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot decrease service usage count below 0\n");
-}
-
-
-celix_status_t serviceReference_getUsageCount(service_reference_pt ref, size_t *count) {
-    celix_status_t status = CELIX_SUCCESS;
-    celixThreadRwlock_readLock(&ref->lock);
-    *count = ref->usageCount;
-    celixThreadRwlock_unlock(&ref->lock);
-    return status;
-}
-
-celix_status_t serviceReference_getReferenceCount(service_reference_pt ref, size_t *count) {
-    celix_status_t status = CELIX_SUCCESS;
-    celixThreadRwlock_readLock(&ref->lock);
-    *count = ref->refCount;
-    celixThreadRwlock_unlock(&ref->lock);
-    return status;
-}
-
-celix_status_t serviceReference_getService(service_reference_pt ref, void **service) {
-    celix_status_t status = CELIX_SUCCESS;
-    celixThreadRwlock_readLock(&ref->lock);
-    /*NOTE the service argument should be 'const void**'
-      To ensure backwards compatability a cast is made instead.
-    */
-    *service = (const void**) ref->service;
-    celixThreadRwlock_unlock(&ref->lock);
-    return status;
-}
-
-celix_status_t serviceReference_setService(service_reference_pt ref, const void *service) {
-    celix_status_t status = CELIX_SUCCESS;
-    celixThreadRwlock_writeLock(&ref->lock);
-    ref->service = service;
-    celixThreadRwlock_unlock(&ref->lock);
-    return status;
-}
-
-static void serviceReference_destroy(service_reference_pt ref) {
-	assert(ref->refCount == 0);
-    celixThreadRwlock_destroy(&ref->lock);
-	ref->registration = NULL;
-	free(ref);
-}
-
-celix_status_t serviceReference_getBundle(service_reference_pt ref, bundle_pt *bundle) {
-    celix_status_t status = CELIX_SUCCESS;
-    celixThreadRwlock_readLock(&ref->lock);
-    if (ref->registration != NULL) {
-        *bundle = ref->registrationBundle;
-    }
-    celixThreadRwlock_unlock(&ref->lock);
-    return status;
-}
-
-celix_status_t serviceReference_getOwner(service_reference_pt ref, bundle_pt *owner) { 
-    celix_status_t status = CELIX_SUCCESS;
-    celixThreadRwlock_readLock(&ref->lock);
-    *owner = ref->referenceOwner;
-    celixThreadRwlock_unlock(&ref->lock);
-    return status;
-}
-
-celix_status_t serviceReference_getServiceRegistration(service_reference_pt ref, service_registration_pt *out) {
-    if (ref != NULL) {
-        celixThreadRwlock_readLock(&ref->lock);
-        *out = ref->registration;
-        celixThreadRwlock_unlock(&ref->lock);
-        return CELIX_SUCCESS;
-    } else {
-        return CELIX_ILLEGAL_ARGUMENT;
-    }
-}
-
-celix_status_t serviceReference_getProperty(service_reference_pt ref, const char* key, const char** value) {
-    celix_status_t status = CELIX_SUCCESS;
-    properties_pt props = NULL;
-    celixThreadRwlock_readLock(&ref->lock);
-    if (ref->registration != NULL) {
-        status = serviceRegistration_getProperties(ref->registration, &props);
-        if (status == CELIX_SUCCESS) {
-            *value = (char*) properties_get(props, key);
-        }
-    } else {
-        *value = NULL;
-    }
-    celixThreadRwlock_unlock(&ref->lock);
-    return status;
-}
-
-FRAMEWORK_EXPORT celix_status_t serviceReference_getPropertyKeys(service_reference_pt ref, char **keys[], unsigned int *size) {
-    celix_status_t status = CELIX_SUCCESS;
-    properties_pt props = NULL;
-
-    celixThreadRwlock_readLock(&ref->lock);
-    serviceRegistration_getProperties(ref->registration, &props);
-    hash_map_iterator_pt it;
-    int i = 0;
-    int vsize = hashMap_size(props);
-    *size = (unsigned int)vsize;
-    *keys = malloc(vsize * sizeof(**keys));
-    it = hashMapIterator_create(props);
-    while (hashMapIterator_hasNext(it)) {
-        (*keys)[i] = hashMapIterator_nextKey(it);
-        i++;
-    }
-    hashMapIterator_destroy(it);
-    celixThreadRwlock_unlock(&ref->lock);
-    return status;
-}
-
-celix_status_t serviceReference_invalidate(service_reference_pt ref) {
-    assert(ref != NULL);
-    celix_status_t status = CELIX_SUCCESS;
-    service_registration_pt reg = NULL;
-    celixThreadRwlock_writeLock(&ref->lock);
-    reg = ref->registration;
-    ref->registration = NULL;
-    celixThreadRwlock_unlock(&ref->lock);
-
-    if (reg != NULL) {
-        serviceRegistration_release(reg);
-    }
-	return status;
-}
-
-celix_status_t serviceReference_isValid(service_reference_pt ref, bool *result) {
-    celixThreadRwlock_readLock(&ref->lock);
-    (*result) = ref->registration != NULL;
-    celixThreadRwlock_unlock(&ref->lock);
-    return CELIX_SUCCESS;
-}
-
-bool serviceReference_isAssignableTo(service_reference_pt reference __attribute__((unused)), bundle_pt requester __attribute__((unused)), const char* serviceName __attribute__((unused))) {
-	bool allow = true;
-
-	/*NOTE for now always true. It would be nice to be able to do somechecks if the services are really assignable.
-	 */
-
-	return allow;
-}
-
-celix_status_t serviceReference_equals(service_reference_pt reference, service_reference_pt compareTo, bool *equal) {
-    celix_status_t status = CELIX_SUCCESS;
-    if (reference != NULL && compareTo != NULL) {
-        service_registration_pt reg1;
-        service_registration_pt reg2;
-        serviceReference_getServiceRegistration(reference, &reg1);
-        serviceReference_getServiceRegistration(compareTo, &reg2);
-        *equal = (reg1 == reg2);
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-        *equal = false;
-    }
-	return status;
-}
-
-int serviceReference_equals2(const void* reference1, const void* reference2) {
-	bool equal;
-	serviceReference_equals((service_reference_pt)reference1, (service_reference_pt)reference2, &equal);
-	return equal;
-}
-
-celix_status_t serviceReference_compareTo(service_reference_pt reference, service_reference_pt compareTo, int *compare) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	long id, other_id;
-	const char* id_str;
-    const char* other_id_str;
-	serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &id_str);
-	serviceReference_getProperty(compareTo, (char *) OSGI_FRAMEWORK_SERVICE_ID, &other_id_str);
-
-	id = atol(id_str);
-	other_id = atol(other_id_str);
-
-
-	long rank, other_rank;
-	const char *rank_str;
-    const char* other_rank_str;
-	serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank_str);
-	serviceReference_getProperty(compareTo, OSGI_FRAMEWORK_SERVICE_RANKING, &other_rank_str);
-
-	rank = rank_str == NULL ? 0 : atol(rank_str);
-	other_rank = other_rank_str == NULL ? 0 : atol(other_rank_str);
-
-    *compare = utils_compareServiceIdsAndRanking(id, rank, other_id, other_rank);
-
-	return status;
-}
-
-unsigned int serviceReference_hashCode(const void *referenceP) {
-    service_reference_pt ref = (service_reference_pt)referenceP;
-    bundle_pt bundle = NULL;
-    service_registration_pt reg = NULL;
-
-    if (ref != NULL) {
-        celixThreadRwlock_readLock(&ref->lock);
-        bundle = ref->registrationBundle;
-        reg = ref->registration;
-        celixThreadRwlock_unlock(&ref->lock);
-    }
-
-
-	int prime = 31;
-	int result = 1;
-	result = prime * result;
-
-	if (bundle != NULL && reg != NULL) {
-		intptr_t bundleA = (intptr_t) bundle;
-		intptr_t registrationA = (intptr_t) reg;
-
-		result += bundleA + registrationA;
-	}
-	return result;
-}
-
-
-celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, array_list_pt *out) {
-    celix_status_t status = CELIX_SUCCESS;
-    service_registration_pt reg = NULL;
-    registry_callback_t callback;
-
-    callback.getUsingBundles = NULL;
-
-
-    celixThreadRwlock_readLock(&ref->lock);
-    reg = ref->registration;
-    if (reg != NULL) {
-        serviceRegistration_retain(reg);
-        callback.handle = ref->callback.handle;
-        callback.getUsingBundles = ref->callback.getUsingBundles;
-    }
-    celixThreadRwlock_unlock(&ref->lock);
-
-    if (reg != NULL) {
-        if (callback.getUsingBundles != NULL) {
-            status = callback.getUsingBundles(callback.handle, reg, out);
-        } else {
-            fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "getUsingBundles callback not set");
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-        serviceRegistration_release(reg);
-    }
-
-    return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/service_registration.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registration.c b/framework/private/src/service_registration.c
deleted file mode 100644
index 5d23dbf..0000000
--- a/framework/private/src/service_registration.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/**
- *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.
- */
-/*
- * service_registration.c
- *
- *  \date       Aug 6, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include "service_registration_private.h"
-#include "constants.h"
-
-static celix_status_t serviceRegistration_initializeProperties(service_registration_pt registration, properties_pt properties);
-static celix_status_t serviceRegistration_createInternal(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId,
-        const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *registration);
-static celix_status_t serviceRegistration_destroy(service_registration_pt registration);
-
-service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt dictionary) {
-    service_registration_pt registration = NULL;
-	serviceRegistration_createInternal(callback, bundle, serviceName, serviceId, serviceObject, dictionary, false, &registration);
-	return registration;
-}
-
-service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt dictionary) {
-    service_registration_pt registration = NULL;
-    serviceRegistration_createInternal(callback, bundle, serviceName, serviceId, serviceObject, dictionary, true, &registration);
-    return registration;
-}
-
-static celix_status_t serviceRegistration_createInternal(registry_callback_t callback, bundle_pt bundle, const char* serviceName, unsigned long serviceId,
-        const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *out) {
-    celix_status_t status = CELIX_SUCCESS;
-
-	service_registration_pt  reg = calloc(1, sizeof(*reg));
-    if (reg) {
-        reg->callback = callback;
-        reg->services = NULL;
-        reg->nrOfServices = 0;
-		reg->isServiceFactory = isFactory;
-		reg->className = strndup(serviceName, 1024*10);
-		reg->bundle = bundle;
-		reg->refCount = 1;
-
-		reg->serviceId = serviceId;
-	reg->svcObj = serviceObject;
-		if (isFactory) {
-			reg->serviceFactory = (service_factory_pt) reg->svcObj;
-		} else {
-			reg->serviceFactory = NULL;
-		}
-
-		reg->isUnregistering = false;
-		celixThreadRwlock_create(&reg->lock, NULL);
-
-		celixThreadRwlock_writeLock(&reg->lock);
-		serviceRegistration_initializeProperties(reg, dictionary);
-		celixThreadRwlock_unlock(&reg->lock);
-
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*out = reg;
-	}
-
-	return status;
-}
-
-void serviceRegistration_retain(service_registration_pt registration) {
-	celixThreadRwlock_writeLock(&registration->lock);
-	registration->refCount += 1;
-    celixThreadRwlock_unlock(&registration->lock);
-}
-
-void serviceRegistration_release(service_registration_pt registration) {
-    celixThreadRwlock_writeLock(&registration->lock);
-    assert(registration->refCount > 0);
-	registration->refCount -= 1;
-	if (registration->refCount == 0) {
-		serviceRegistration_destroy(registration);
-	} else {
-        celixThreadRwlock_unlock(&registration->lock);
-	}
-}
-
-static celix_status_t serviceRegistration_destroy(service_registration_pt registration) {
-	//fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Destroying service registration %p\n", registration);
-    free(registration->className);
-	registration->className = NULL;
-
-    registration->callback.unregister = NULL;
-
-	properties_destroy(registration->properties);
-	celixThreadRwlock_unlock(&registration->lock);
-    celixThreadRwlock_destroy(&registration->lock);
-	free(registration);
-
-	return CELIX_SUCCESS;
-}
-
-static celix_status_t serviceRegistration_initializeProperties(service_registration_pt registration, properties_pt dictionary) {
-    char sId[32];
-
-	if (dictionary == NULL) {
-		dictionary = properties_create();
-	}
-
-
-	snprintf(sId, 32, "%lu", registration->serviceId);
-	properties_set(dictionary, (char *) OSGI_FRAMEWORK_SERVICE_ID, sId);
-
-	if (properties_get(dictionary, (char *) OSGI_FRAMEWORK_OBJECTCLASS) == NULL) {
-		properties_set(dictionary, (char *) OSGI_FRAMEWORK_OBJECTCLASS, registration->className);
-	}
-
-	registration->properties = dictionary;
-
-	return CELIX_SUCCESS;
-}
-
-void serviceRegistration_invalidate(service_registration_pt registration) {
-    celixThreadRwlock_writeLock(&registration->lock);
-    registration->svcObj = NULL;
-    celixThreadRwlock_unlock(&registration->lock);
-}
-
-bool serviceRegistration_isValid(service_registration_pt registration) {
-    bool isValid;
-    if (registration != NULL) {
-        celixThreadRwlock_readLock(&registration->lock);
-        isValid = registration->svcObj != NULL;
-        celixThreadRwlock_unlock(&registration->lock);
-    } else {
-        isValid = false;
-    }
-    return isValid;
-}
-
-celix_status_t serviceRegistration_unregister(service_registration_pt registration) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    bool notValidOrUnregistering;
-    celixThreadRwlock_readLock(&registration->lock);
-    notValidOrUnregistering = !serviceRegistration_isValid(registration) || registration->isUnregistering;
-    celixThreadRwlock_unlock(&registration->lock);
-
-    registry_callback_t callback;
-    callback.unregister = NULL;
-    bundle_pt bundle = NULL;
-
-	if (notValidOrUnregistering) {
-		status = CELIX_ILLEGAL_STATE;
-	} else {
-        celixThreadRwlock_writeLock(&registration->lock);
-        registration->isUnregistering = true;
-        bundle = registration->bundle;
-        callback = registration->callback;
-        celixThreadRwlock_unlock(&registration->lock);
-    }
-
-	if (status == CELIX_SUCCESS && callback.unregister != NULL) {
-        callback.unregister(callback.handle, bundle, registration);
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot unregister service registration");
-
-	return status;
-}
-
-celix_status_t serviceRegistration_getService(service_registration_pt registration, bundle_pt bundle, const void** service) {
-	int status = CELIX_SUCCESS;
-    celixThreadRwlock_readLock(&registration->lock);
-    if (registration->isServiceFactory) {
-        service_factory_pt factory = (void*) registration->serviceFactory;
-        /*NOTE the service argument of the service_factory should be const void**.
-          To ensure backwards compatability a cast is made instead.
-        */
-        status = factory->getService(factory->handle, bundle, registration, (void**) service);
-    } else {
-        (*service) = registration->svcObj;
-    }
-    celixThreadRwlock_unlock(&registration->lock);
-    return status;
-}
-
-celix_status_t serviceRegistration_ungetService(service_registration_pt registration, bundle_pt bundle, const void** service) {
-    celixThreadRwlock_readLock(&registration->lock);
-    if (registration->isServiceFactory) {
-        service_factory_pt factory = (void*) registration->serviceFactory;
-        /*NOTE the service argument of the service_factory should be const void**.
-          To ensure backwards compatability a cast is made instead.
-        */
-        factory->ungetService(factory->handle, bundle, registration, (void**) service);
-    }
-    celixThreadRwlock_unlock(&registration->lock);
-    return CELIX_SUCCESS;
-}
-
-celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    if (registration != NULL) {
-        celixThreadRwlock_readLock(&registration->lock);
-        *properties = registration->properties;
-        celixThreadRwlock_unlock(&registration->lock);
-     } else {
-          status = CELIX_ILLEGAL_ARGUMENT;
-     }
-
-    framework_logIfError(logger, status, NULL, "Cannot get registration properties");
-
-    return status;
-}
-
-celix_status_t serviceRegistration_setProperties(service_registration_pt registration, properties_pt properties) {
-    celix_status_t status;
-
-    properties_pt oldProperties = NULL;
-    registry_callback_t callback;
-
-    celixThreadRwlock_writeLock(&registration->lock);
-    oldProperties = registration->properties;
-    status = serviceRegistration_initializeProperties(registration, properties);
-    callback = registration->callback;
-    celixThreadRwlock_unlock(&registration->lock);
-
-    if (status == CELIX_SUCCESS && callback.modified != NULL) {
-        callback.modified(callback.handle, registration, oldProperties);
-    }
-
-	return status;
-}
-
-
-celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle) {
-    celix_status_t status = CELIX_SUCCESS;
-    if (registration == NULL) {
-        return CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    if (registration != NULL && *bundle == NULL) {
-        celixThreadRwlock_readLock(&registration->lock);
-        *bundle = registration->bundle;
-        celixThreadRwlock_unlock(&registration->lock);
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-    framework_logIfError(logger, status, NULL, "Cannot get bundle");
-
-	return status;
-}
-
-celix_status_t serviceRegistration_getServiceName(service_registration_pt registration, const char **serviceName) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    if (registration != NULL && *serviceName == NULL) {
-        celixThreadRwlock_readLock(&registration->lock);
-        *serviceName = registration->className;
-        celixThreadRwlock_unlock(&registration->lock);
-	} else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-
-    framework_logIfError(logger, status, NULL, "Cannot get service name");
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/service_registry.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registry.c b/framework/private/src/service_registry.c
deleted file mode 100644
index d27cc32..0000000
--- a/framework/private/src/service_registry.c
+++ /dev/null
@@ -1,800 +0,0 @@
-/**
- *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.
- */
-/*
- * service_registry.c
- *
- *  \date       Aug 6, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include "service_registry_private.h"
-#include "service_registration_private.h"
-#include "listener_hook_service.h"
-#include "constants.h"
-#include "service_reference_private.h"
-#include "framework_private.h"
-
-#ifdef DEBUG
-#define CHECK_DELETED_REFERENCES true
-#else
-#define CHECK_DELETED_REFERENCES false
-#endif
-
-static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *registration);
-static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, const char* serviceName, const void *serviceObject, service_registration_pt registration);
-static celix_status_t serviceRegistry_removeHook(service_registry_pt registry, service_registration_pt registration);
-static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registry_pt registry, bundle_pt bundle, service_reference_pt ref, size_t usageCount, size_t refCount);
-static void serviceRegistry_logWarningServiceRegistration(service_registry_pt registry, service_registration_pt reg);
-static celix_status_t serviceRegistry_checkReference(service_registry_pt registry, service_reference_pt ref,
-                                                     reference_status_t *refStatus);
-static void serviceRegistry_logIllegalReference(service_registry_pt registry, service_reference_pt reference,
-                                                   reference_status_t refStatus);
-static celix_status_t serviceRegistry_setReferenceStatus(service_registry_pt registry, service_reference_pt reference,
-                                                  bool deleted);
-static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt registry, service_registration_pt reg, array_list_pt *bundles);
-static celix_status_t serviceRegistry_getServiceReference_internal(service_registry_pt registry, bundle_pt owner, service_registration_pt registration, service_reference_pt *out);
-
-celix_status_t serviceRegistry_create(framework_pt framework, serviceChanged_function_pt serviceChanged, service_registry_pt *out) {
-	celix_status_t status;
-
-	service_registry_pt reg = calloc(1, sizeof(*reg));
-	if (reg == NULL) {
-		status = CELIX_ENOMEM;
-	} else {
-
-        reg->callback.handle = reg;
-        reg->callback.getUsingBundles = (void *)serviceRegistry_getUsingBundles;
-        reg->callback.unregister = (void *) serviceRegistry_unregisterService;
-        reg->callback.modified = (void *) serviceRegistry_servicePropertiesModified;
-
-        reg->serviceChanged = serviceChanged;
-		reg->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
-		reg->framework = framework;
-		reg->currentServiceId = 1UL;
-		reg->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
-
-        reg->checkDeletedReferences = CHECK_DELETED_REFERENCES;
-        reg->deletedServiceReferences = hashMap_create(NULL, NULL, NULL, NULL);
-
-		arrayList_create(&reg->listenerHooks);
-
-		status = celixThreadRwlock_create(&reg->lock, NULL);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*out = reg;
-	} else {
-		framework_logIfError(logger, status, NULL, "Cannot create service registry");
-	}
-
-	return status;
-}
-
-celix_status_t serviceRegistry_destroy(service_registry_pt registry) {
-    celixThreadRwlock_writeLock(&registry->lock);
-
-    //destroy service registration map
-    int size = hashMap_size(registry->serviceRegistrations);
-    assert(size == 0);
-    hashMap_destroy(registry->serviceRegistrations, false, false);
-
-    //destroy service references (double) map);
-    //FIXME. The framework bundle does not (yet) call clearReferences, as result the size could be > 0 for test code.
-    //size = hashMap_size(registry->serviceReferences);
-    //assert(size == 0);
-    hashMap_destroy(registry->serviceReferences, false, false);
-
-    //destroy listener hooks
-    size = arrayList_size(registry->listenerHooks);
-    if (size == 0)
-    	arrayList_destroy(registry->listenerHooks);
-
-    hashMap_destroy(registry->deletedServiceReferences, false, false);
-
-    free(registry);
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt registry, bundle_pt bundle, array_list_pt *services) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	celixThreadRwlock_writeLock(&registry->lock);
-
-	array_list_pt regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle);
-	if (regs != NULL) {
-		unsigned int i;
-		arrayList_create(services);
-		
-		for (i = 0; i < arrayList_size(regs); i++) {
-			service_registration_pt reg = arrayList_get(regs, i);
-			if (serviceRegistration_isValid(reg)) {
-				service_reference_pt reference = NULL;
-				status = serviceRegistry_getServiceReference_internal(registry, bundle, reg, &reference);
-				if (status == CELIX_SUCCESS) {
-					arrayList_add(*services, reference);
-				}
-			}
-		}
-	}
-
-	celixThreadRwlock_unlock(&registry->lock);
-
-	framework_logIfError(logger, status, NULL, "Cannot get registered services");
-
-	return status;
-}
-
-celix_status_t serviceRegistry_registerService(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void* serviceObject, properties_pt dictionary, service_registration_pt *registration) {
-    return serviceRegistry_registerServiceInternal(registry, bundle, serviceName, serviceObject, dictionary, false, registration);
-}
-
-celix_status_t serviceRegistry_registerServiceFactory(service_registry_pt registry, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt dictionary, service_registration_pt *registration) {
-    return serviceRegistry_registerServiceInternal(registry, bundle, serviceName, (const void *) factory, dictionary, true, registration);
-}
-
-static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void* serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *registration) {
-	array_list_pt regs;
-
-	if (isFactory) {
-	    *registration = serviceRegistration_createServiceFactory(registry->callback, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
-	} else {
-	    *registration = serviceRegistration_create(registry->callback, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
-	}
-
-    //long id;
-    //bundle_getBundleId(bundle, &id);
-    //fprintf(stderr, "REG: Registering service '%s' for bundle id %li with reg pointer %p\n", serviceName, id, *registration);
-
-
-    serviceRegistry_addHooks(registry, serviceName, serviceObject, *registration);
-
-	celixThreadRwlock_writeLock(&registry->lock);
-	regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle);
-	if (regs == NULL) {
-		regs = NULL;
-		arrayList_create(&regs);
-        hashMap_put(registry->serviceRegistrations, bundle, regs);
-    }
-	arrayList_add(regs, *registration);
-	celixThreadRwlock_unlock(&registry->lock);
-
-	if (registry->serviceChanged != NULL) {
-		registry->serviceChanged(registry->framework, OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED, *registration, NULL);
-	}
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceRegistry_unregisterService(service_registry_pt registry, bundle_pt bundle, service_registration_pt registration) {
-	// array_list_t clients;
-	array_list_pt regs;
-
-    //fprintf(stderr, "REG: Unregistering service registration with pointer %p\n", registration);
-
-	serviceRegistry_removeHook(registry, registration);
-
-	celixThreadRwlock_writeLock(&registry->lock);
-	regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle);
-	if (regs != NULL) {
-		arrayList_removeElement(regs, registration);
-        int size = arrayList_size(regs);
-        if (size == 0) {
-            arrayList_destroy(regs);
-            hashMap_remove(registry->serviceRegistrations, bundle);
-        }
-	}
-	celixThreadRwlock_unlock(&registry->lock);
-
-	if (registry->serviceChanged != NULL) {
-		registry->serviceChanged(registry->framework, OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING, registration, NULL);
-	}
-
-
-	celixThreadRwlock_readLock(&registry->lock);
-    //invalidate service references
-    hash_map_iterator_pt iter = hashMapIterator_create(registry->serviceReferences);
-    while (hashMapIterator_hasNext(iter)) {
-        hash_map_pt refsMap = hashMapIterator_nextValue(iter);
-        service_reference_pt ref = refsMap != NULL ?
-                                   hashMap_get(refsMap, (void*)registration->serviceId) : NULL;
-        if (ref != NULL) {
-            serviceReference_invalidate(ref);
-        }
-    }
-    hashMapIterator_destroy(iter);
-	celixThreadRwlock_unlock(&registry->lock);
-
-	serviceRegistration_invalidate(registration);
-    serviceRegistration_release(registration);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceRegistry_clearServiceRegistrations(service_registry_pt registry, bundle_pt bundle) {
-    celix_status_t status = CELIX_SUCCESS;
-    array_list_pt registrations = NULL;
-    bool registrationsLeft;
-
-    celixThreadRwlock_writeLock(&registry->lock);
-    registrations = hashMap_get(registry->serviceRegistrations, bundle);
-    registrationsLeft = (registrations != NULL);
-    if (registrationsLeft) {
-        registrationsLeft = (arrayList_size(registrations) > 0);
-    }
-    celixThreadRwlock_unlock(&registry->lock);
-
-    while (registrationsLeft) {
-        service_registration_pt reg = arrayList_get(registrations, 0);
-
-        serviceRegistry_logWarningServiceRegistration(registry, reg);
-
-        if (serviceRegistration_isValid(reg)) {
-            serviceRegistration_unregister(reg);
-        }
-        else {
-            arrayList_remove(registrations, 0);
-        }
-
-        // not removed by last unregister call?
-        celixThreadRwlock_writeLock(&registry->lock);
-        registrations = hashMap_get(registry->serviceRegistrations, bundle);
-        registrationsLeft = (registrations != NULL);
-        if (registrationsLeft) {
-            registrationsLeft = (arrayList_size(registrations) > 0);
-        }
-        celixThreadRwlock_unlock(&registry->lock);
-    }
-
-    return status;
-}
-
-static void serviceRegistry_logWarningServiceRegistration(service_registry_pt registry __attribute__((unused)), service_registration_pt reg) {
-    const char *servName = NULL;
-    serviceRegistration_getServiceName(reg, &servName);
-    fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Dangling service registration for service %s. Look for missing serviceRegistration_unregister calls.", servName);
-}
-
-celix_status_t serviceRegistry_getServiceReference(service_registry_pt registry, bundle_pt owner,
-                                                   service_registration_pt registration, service_reference_pt *out) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if(celixThreadRwlock_writeLock(&registry->lock) == CELIX_SUCCESS) {
-	    status = serviceRegistry_getServiceReference_internal(registry, owner, registration, out);
-	    celixThreadRwlock_unlock(&registry->lock);
-	}
-
-	return status;
-}
-
-static celix_status_t serviceRegistry_getServiceReference_internal(service_registry_pt registry, bundle_pt owner,
-                                                   service_registration_pt registration, service_reference_pt *out) {
-	//only call after locked registry RWlock
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_pt bundle = NULL;
-    service_reference_pt ref = NULL;
-    hash_map_pt references = NULL;
-
-    references = hashMap_get(registry->serviceReferences, owner);
-    if (references == NULL) {
-        references = hashMap_create(NULL, NULL, NULL, NULL);
-        hashMap_put(registry->serviceReferences, owner, references);
-	}
-
-    ref = hashMap_get(references, (void*)registration->serviceId);
-
-    if (ref == NULL) {
-        status = serviceRegistration_getBundle(registration, &bundle);
-        if (status == CELIX_SUCCESS) {
-            status = serviceReference_create(registry->callback, owner, registration, &ref);
-        }
-        if (status == CELIX_SUCCESS) {
-            hashMap_put(references, (void*)registration->serviceId, ref);
-            hashMap_put(registry->deletedServiceReferences, ref, (void *)false);
-        }
-    } else {
-        serviceReference_retain(ref);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *out = ref;
-    }
-
-	framework_logIfError(logger, status, NULL, "Cannot create service reference");
-
-
-	return status;
-}
-
-celix_status_t serviceRegistry_getServiceReferences(service_registry_pt registry, bundle_pt owner, const char *serviceName, filter_pt filter, array_list_pt *out) {
-	celix_status_t status;
-	hash_map_iterator_pt iterator;
-    array_list_pt references = NULL;
-	array_list_pt matchingRegistrations = NULL;
-    bool matchResult;
-
-    status = arrayList_create(&references);
-    status = CELIX_DO_IF(status, arrayList_create(&matchingRegistrations));
-
-    celixThreadRwlock_readLock(&registry->lock);
-	iterator = hashMapIterator_create(registry->serviceRegistrations);
-	while (status == CELIX_SUCCESS && hashMapIterator_hasNext(iterator)) {
-		array_list_pt regs = (array_list_pt) hashMapIterator_nextValue(iterator);
-		unsigned int regIdx;
-		for (regIdx = 0; (regs != NULL) && regIdx < arrayList_size(regs); regIdx++) {
-			service_registration_pt registration = (service_registration_pt) arrayList_get(regs, regIdx);
-			properties_pt props = NULL;
-
-			status = serviceRegistration_getProperties(registration, &props);
-			if (status == CELIX_SUCCESS) {
-				bool matched = false;
-				matchResult = false;
-				if (filter != NULL) {
-					filter_match(filter, props, &matchResult);
-				}
-				if ((serviceName == NULL) && ((filter == NULL) || matchResult)) {
-					matched = true;
-				} else if (serviceName != NULL) {
-					const char *className = NULL;
-					matchResult = false;
-					serviceRegistration_getServiceName(registration, &className);
-					if (filter != NULL) {
-						filter_match(filter, props, &matchResult);
-					}
-					if ((strcmp(className, serviceName) == 0) && ((filter == NULL) || matchResult)) {
-						matched = true;
-					}
-				}
-				if (matched) {
-					if (serviceRegistration_isValid(registration)) {
-                        serviceRegistration_retain(registration);
-                        arrayList_add(matchingRegistrations, registration);
-					}
-				}
-			}
-		}
-	}
-    celixThreadRwlock_unlock(&registry->lock);
-	hashMapIterator_destroy(iterator);
-
-    if (status == CELIX_SUCCESS) {
-        unsigned int i;
-        unsigned int size = arrayList_size(matchingRegistrations);
-
-        for (i = 0; i < size; i += 1) {
-            service_registration_pt reg = arrayList_get(matchingRegistrations, i);
-            service_reference_pt reference = NULL;
-            celix_status_t subStatus = serviceRegistry_getServiceReference(registry, owner, reg, &reference);
-            if (subStatus == CELIX_SUCCESS) {
-                arrayList_add(references, reference);
-            } else {
-                status = CELIX_BUNDLE_EXCEPTION;
-            }
-            serviceRegistration_release(reg);
-        }
-    }
-
-    if(matchingRegistrations != NULL){
-    	arrayList_destroy(matchingRegistrations);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *out = references;
-    } else {
-        //TODO ungetServiceRefs
-        arrayList_destroy(references);
-        framework_logIfError(logger, status, NULL, "Cannot get service references");
-    }
-
-	return status;
-}
-
-celix_status_t serviceRegistry_retainServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference) {
-    celix_status_t status = CELIX_SUCCESS;
-    reference_status_t refStatus;
-    bundle_pt refBundle = NULL;
-    
-    celixThreadRwlock_writeLock(&registry->lock);
-    serviceRegistry_checkReference(registry, reference, &refStatus);
-    if (refStatus == REF_ACTIVE) {
-        serviceReference_getOwner(reference, &refBundle);
-        if (refBundle == bundle) {
-            serviceReference_retain(reference);
-        } else {
-            status = CELIX_ILLEGAL_ARGUMENT;
-            fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "cannot retain a service reference from an other bundle (in ref %p) (provided %p).", refBundle, bundle);
-        }
-    } else {
-        serviceRegistry_logIllegalReference(registry, reference, refStatus);
-    }
-    celixThreadRwlock_unlock(&registry->lock);
-
-    return status;
-}
-
-
-celix_status_t serviceRegistry_ungetServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference) {
-    celix_status_t status = CELIX_SUCCESS;
-    bool destroyed = false;
-    size_t count = 0;
-    reference_status_t refStatus;
-
-    celixThreadRwlock_writeLock(&registry->lock);
-    serviceRegistry_checkReference(registry, reference, &refStatus);
-    if (refStatus == REF_ACTIVE) {
-        serviceReference_getUsageCount(reference, &count);
-        serviceReference_release(reference, &destroyed);
-        if (destroyed) {
-
-            if (count > 0) {
-                serviceRegistry_logWarningServiceReferenceUsageCount(registry, bundle, reference, count, 0);
-            }
-
-            hash_map_pt refsMap = hashMap_get(registry->serviceReferences, bundle);
-
-            unsigned long refId = 0UL;
-            service_reference_pt ref = NULL;
-            hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
-            while (hashMapIterator_hasNext(iter)) {
-                hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-                refId = (unsigned long)hashMapEntry_getKey(entry); //note could be invalid e.g. freed
-                ref = hashMapEntry_getValue(entry);
-
-                if (ref == reference) {
-                    break;
-                } else {
-                    ref = NULL;
-                    refId = 0UL;
-                }
-            }
-            hashMapIterator_destroy(iter);
-
-            if (ref != NULL) {
-                hashMap_remove(refsMap, (void*)refId);
-                int size = hashMap_size(refsMap);
-                if (size == 0) {
-                    hashMap_destroy(refsMap, false, false);
-                    hashMap_remove(registry->serviceReferences, bundle);
-                }
-                serviceRegistry_setReferenceStatus(registry, reference, true);
-            } else {
-                fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Cannot find reference %p in serviceReferences map",
-                       reference);
-            }
-        }
-    } else {
-        serviceRegistry_logIllegalReference(registry, reference, refStatus);
-    }
-    celixThreadRwlock_unlock(&registry->lock);
-
-    return status;
-}
-
-static celix_status_t serviceRegistry_setReferenceStatus(service_registry_pt registry, service_reference_pt reference,
-                                                  bool deleted) {
-    //precondition write locked on registry->lock
-    if (registry->checkDeletedReferences) {
-        hashMap_put(registry->deletedServiceReferences, reference, (void *) deleted);
-    }
-    return CELIX_SUCCESS;
-}
-
-static void serviceRegistry_logIllegalReference(service_registry_pt registry __attribute__((unused)), service_reference_pt reference,
-                                                   reference_status_t refStatus) {
-    fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR,
-           "Error handling service reference %p, status is %i",reference, refStatus);
-}
-
-static celix_status_t serviceRegistry_checkReference(service_registry_pt registry, service_reference_pt ref,
-                                              reference_status_t *out) {
-    //precondition read or write locked on registry->lock
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (registry->checkDeletedReferences) {
-        reference_status_t refStatus = REF_UNKNOWN;
-
-        if (hashMap_containsKey(registry->deletedServiceReferences, ref)) {
-            bool deleted = (bool) hashMap_get(registry->deletedServiceReferences, ref);
-            refStatus = deleted ? REF_DELETED : REF_ACTIVE;
-        }
-
-        *out = refStatus;
-    } else {
-        *out = REF_ACTIVE;
-    }
-
-    return status;
-}
-
-static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registry_pt registry __attribute__((unused)), bundle_pt bundle, service_reference_pt ref, size_t usageCount, size_t refCount) {
-    if (usageCount > 0) {
-        fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Service Reference destroyed with usage count is %zu, expected 0. Look for missing bundleContext_ungetService calls.", usageCount);
-    }
-    if (refCount > 0) {
-        fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Dangling service reference. Reference count is %zu, expected 1.  Look for missing bundleContext_ungetServiceReference calls.", refCount);
-    }
-
-    if(usageCount > 0 || refCount > 0) {
-        module_pt module_ptr = NULL;
-        bundle_getCurrentModule(bundle, &module_ptr);
-        const char* bundle_name = NULL;
-        module_getSymbolicName(module_ptr, &bundle_name);
-
-        const char* service_name = "unknown";
-        const char* bundle_provider_name = "unknown";
-        if (refCount > 0 && ref != NULL) {
-            serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &service_name);
-            service_registration_pt reg = NULL;
-            bundle_pt bundle = NULL;
-            module_pt mod = NULL;
-            serviceReference_getServiceRegistration(ref, &reg);
-            serviceRegistration_getBundle(reg, &bundle);
-            bundle_getCurrentModule(bundle, &mod);
-            module_getSymbolicName(mod, &bundle_provider_name);
-        }
-
-        fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Previous Dangling service reference warnings caused by bundle '%s', for service '%s', provided by bundle '%s'", bundle_name, service_name, bundle_provider_name);
-    }
-}
-
-
-celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry, bundle_pt bundle) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    celixThreadRwlock_writeLock(&registry->lock);
-
-    hash_map_pt refsMap = hashMap_remove(registry->serviceReferences, bundle);
-    if (refsMap != NULL) {
-        hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
-        while (hashMapIterator_hasNext(iter)) {
-            service_reference_pt ref = hashMapIterator_nextValue(iter);
-            size_t refCount;
-            size_t usageCount;
-
-            serviceReference_getUsageCount(ref, &usageCount);
-            serviceReference_getReferenceCount(ref, &refCount);
-            serviceRegistry_logWarningServiceReferenceUsageCount(registry, bundle, ref, usageCount, refCount);
-
-            while (usageCount > 0) {
-                serviceReference_decreaseUsage(ref, &usageCount);
-            }
-
-            bool destroyed = false;
-            while (!destroyed) {
-                serviceReference_release(ref, &destroyed);
-            }
-            serviceRegistry_setReferenceStatus(registry, ref, true);
-
-        }
-        hashMapIterator_destroy(iter);
-        hashMap_destroy(refsMap, false, false);
-    }
-
-    celixThreadRwlock_unlock(&registry->lock);
-
-    return status;
-}
-
-
-celix_status_t serviceRegistry_getServicesInUse(service_registry_pt registry, bundle_pt bundle, array_list_pt *out) {
-
-    array_list_pt result = NULL;
-    arrayList_create(&result);
-
-    //LOCK
-    celixThreadRwlock_readLock(&registry->lock);
-
-    hash_map_pt refsMap = hashMap_get(registry->serviceReferences, bundle);
-
-    if(refsMap) {
-        hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
-        while (hashMapIterator_hasNext(iter)) {
-            service_reference_pt ref = hashMapIterator_nextValue(iter);
-            arrayList_add(result, ref);
-        }
-        hashMapIterator_destroy(iter);
-    }
-
-    //UNLOCK
-    celixThreadRwlock_unlock(&registry->lock);
-
-    *out = result;
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceRegistry_getService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference, const void **out) {
-	celix_status_t status = CELIX_SUCCESS;
-	service_registration_pt registration = NULL;
-    size_t count = 0;
-    const void *service = NULL;
-    reference_status_t refStatus;
-
-
-
-    celixThreadRwlock_readLock(&registry->lock);
-    serviceRegistry_checkReference(registry, reference, &refStatus);
-    if (refStatus == REF_ACTIVE) {
-        serviceReference_getServiceRegistration(reference, &registration);
-
-        if (serviceRegistration_isValid(registration)) {
-            serviceReference_increaseUsage(reference, &count);
-            if (count == 1) {
-                serviceRegistration_getService(registration, bundle, &service);
-                serviceReference_setService(reference, service);
-            }
-
-            /* NOTE the out argument of sr_getService should be 'const void**'
-               To ensure backwards compatability a cast is made instead.
-            */
-            serviceReference_getService(reference, (void **)out);
-        } else {
-            *out = NULL; //invalid service registration
-        }
-    } else {
-        serviceRegistry_logIllegalReference(registry, reference, refStatus);
-        status = CELIX_BUNDLE_EXCEPTION;
-    }
-    celixThreadRwlock_unlock(&registry->lock);
-
-	return status;
-}
-
-celix_status_t serviceRegistry_ungetService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference, bool *result) {
-	celix_status_t status = CELIX_SUCCESS;
-    service_registration_pt reg = NULL;
-    const void *service = NULL;
-    size_t count = 0;
-    celix_status_t subStatus = CELIX_SUCCESS;
-    reference_status_t refStatus;
-
-    celixThreadRwlock_readLock(&registry->lock);
-    serviceRegistry_checkReference(registry, reference, &refStatus);
-    celixThreadRwlock_unlock(&registry->lock);
-
-    if (refStatus == REF_ACTIVE) {
-        subStatus = serviceReference_decreaseUsage(reference, &count);
-        if (count == 0) {
-            /*NOTE the argument service of sr_getService should be 'const void**'
-              TO ensure backwards compatability a cast is made instead.
-              */
-            serviceReference_getService(reference, (void**)&service);
-            serviceReference_getServiceRegistration(reference, &reg);
-            if (reg != NULL) {
-                serviceRegistration_ungetService(reg, bundle, &service);
-            }
-        }
-    } else {
-        serviceRegistry_logIllegalReference(registry, reference, refStatus);
-        status = CELIX_BUNDLE_EXCEPTION;
-    }
-
-    if (result) {
-        *result = (subStatus == CELIX_SUCCESS);
-    }
-
-
-	return status;
-}
-
-static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, const char* serviceName, const void* serviceObject __attribute__((unused)), service_registration_pt registration) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (strcmp(OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, serviceName) == 0) {
-        celixThreadRwlock_writeLock(&registry->lock);
-		arrayList_add(registry->listenerHooks, registration);
-        celixThreadRwlock_unlock(&registry->lock);
-	}
-
-	return status;
-}
-
-static celix_status_t serviceRegistry_removeHook(service_registry_pt registry, service_registration_pt registration) {
-	celix_status_t status = CELIX_SUCCESS;
-	const char* serviceName = NULL;
-
-	properties_pt props = NULL;
-	serviceRegistration_getProperties(registration, &props);
-	serviceName = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
-	if (strcmp(OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, serviceName) == 0) {
-        celixThreadRwlock_writeLock(&registry->lock);
-		arrayList_removeElement(registry->listenerHooks, registration);
-        celixThreadRwlock_unlock(&registry->lock);
-	}
-
-	return status;
-}
-
-celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, bundle_pt owner, array_list_pt *out) {
-	celix_status_t status;
-    array_list_pt result;
-
-    status = arrayList_create(&result);
-    if (status == CELIX_SUCCESS) {
-        unsigned int i;
-        unsigned size = arrayList_size(registry->listenerHooks);
-
-        for (i = 0; i < size; i += 1) {
-            celixThreadRwlock_readLock(&registry->lock);
-            service_registration_pt registration = arrayList_get(registry->listenerHooks, i);
-            serviceRegistration_retain(registration);
-            celixThreadRwlock_unlock(&registry->lock);
-
-            service_reference_pt reference = NULL;
-            serviceRegistry_getServiceReference(registry, owner, registration, &reference);
-            arrayList_add(result, reference);
-            serviceRegistration_release(registration);
-        }
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *out = result;
-    } else {
-        if (result != NULL) {
-            arrayList_destroy(result);
-        }
-        framework_logIfError(logger, status, NULL, "Cannot get listener hooks");
-    }
-
-	return status;
-}
-
-celix_status_t serviceRegistry_servicePropertiesModified(service_registry_pt registry, service_registration_pt registration, properties_pt oldprops) {
-	if (registry->serviceChanged != NULL) {
-		registry->serviceChanged(registry->framework, OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED, registration, oldprops);
-	}
-	return CELIX_SUCCESS;
-}
-
-static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt registry, service_registration_pt registration, array_list_pt *out) {
-    celix_status_t status;
-    array_list_pt bundles = NULL;
-    hash_map_iterator_pt iter;
-
-    status = arrayList_create(&bundles);
-    if (status == CELIX_SUCCESS) {
-        celixThreadRwlock_readLock(&registry->lock);
-        iter = hashMapIterator_create(registry->serviceReferences);
-        while (hashMapIterator_hasNext(iter)) {
-            hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-            bundle_pt registrationUser = hashMapEntry_getKey(entry);
-            hash_map_pt regMap = hashMapEntry_getValue(entry);
-            if (hashMap_containsKey(regMap, (void*)registration->serviceId)) {
-                arrayList_add(bundles, registrationUser);
-            }
-        }
-        hashMapIterator_destroy(iter);
-        celixThreadRwlock_unlock(&registry->lock);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *out = bundles;
-    } else {
-        if (bundles != NULL) {
-            arrayList_destroy(bundles);
-        }
-    }
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/service_tracker.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_tracker.c b/framework/private/src/service_tracker.c
deleted file mode 100644
index 2631058..0000000
--- a/framework/private/src/service_tracker.c
+++ /dev/null
@@ -1,449 +0,0 @@
-/**
- *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.
- */
-/*
- * service_tracker.c
- *
- *  \date       Apr 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <service_reference_private.h>
-#include <framework_private.h>
-#include <assert.h>
-
-#include "service_tracker_private.h"
-#include "bundle_context.h"
-#include "constants.h"
-#include "service_reference.h"
-#include "celix_log.h"
-
-static celix_status_t serviceTracker_invokeAddingService(service_tracker_pt tracker, service_reference_pt reference,
-                                                         void **service);
-static celix_status_t serviceTracker_track(service_tracker_pt tracker, service_reference_pt reference, service_event_pt event);
-static celix_status_t serviceTracker_untrack(service_tracker_pt tracker, service_reference_pt reference, service_event_pt event);
-static celix_status_t serviceTracker_invokeAddService(service_tracker_pt tracker, service_reference_pt ref, void *service);
-static celix_status_t serviceTracker_invokeModifiedService(service_tracker_pt tracker, service_reference_pt ref, void *service);
-
-static celix_status_t serviceTracker_invokeRemovingService(service_tracker_pt tracker, service_reference_pt ref,
-                                                           void *service);
-
-celix_status_t serviceTracker_create(bundle_context_pt context, const char * service, service_tracker_customizer_pt customizer, service_tracker_pt *tracker) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (service == NULL || *tracker != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		if (status == CELIX_SUCCESS) {
-			char filter[512];
-			snprintf(filter, sizeof(filter), "(%s=%s)", OSGI_FRAMEWORK_OBJECTCLASS, service);
-            serviceTracker_createWithFilter(context, filter, customizer, tracker);
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot create service tracker");
-
-	return status;
-}
-
-celix_status_t serviceTracker_createWithFilter(bundle_context_pt context, const char * filter, service_tracker_customizer_pt customizer, service_tracker_pt *tracker) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*tracker = (service_tracker_pt) malloc(sizeof(**tracker));
-	if (!*tracker) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*tracker)->context = context;
-		(*tracker)->filter = strdup(filter);
-
-		(*tracker)->tracker = *tracker;
-        celixThreadRwlock_create(&(*tracker)->lock, NULL);
-		(*tracker)->trackedServices = NULL;
-		arrayList_create(&(*tracker)->trackedServices);
-		(*tracker)->customizer = customizer;
-		(*tracker)->listener = NULL;
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot create service tracker [filter=%s]", filter);
-
-	return status;
-}
-
-celix_status_t serviceTracker_destroy(service_tracker_pt tracker) {
-	if (tracker->listener != NULL) {
-		bundleContext_removeServiceListener(tracker->context, tracker->listener);
-	}
-	if (tracker->customizer != NULL) {
-	    serviceTrackerCustomizer_destroy(tracker->customizer);
-	}
-
-    celixThreadRwlock_writeLock(&tracker->lock);
-	arrayList_destroy(tracker->trackedServices);
-    celixThreadRwlock_unlock(&tracker->lock);
-
-
-	if (tracker->listener != NULL) {
-		free (tracker->listener);
-	}
-
-    celixThreadRwlock_destroy(&tracker->lock);
-
-	free(tracker->filter);
-	free(tracker);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceTracker_open(service_tracker_pt tracker) {
-	service_listener_pt listener;
-	array_list_pt initial = NULL;
-	celix_status_t status = CELIX_SUCCESS;
-	listener = (service_listener_pt) malloc(sizeof(*listener));
-	
-	status = bundleContext_getServiceReferences(tracker->context, NULL, tracker->filter, &initial); //REF COUNT to 1
-	if (status == CELIX_SUCCESS && listener != NULL) {
-		service_reference_pt initial_reference;
-		unsigned int i;
-
-		listener->handle = tracker;
-		listener->serviceChanged = (void *) serviceTracker_serviceChanged;
-		status = bundleContext_addServiceListener(tracker->context, listener, tracker->filter);
-		if (status == CELIX_SUCCESS) {
-			tracker->listener = listener;
-
-			for (i = 0; i < arrayList_size(initial); i++) {
-				initial_reference = (service_reference_pt) arrayList_get(initial, i);
-				serviceTracker_track(tracker, initial_reference, NULL); //REF COUNT to 2
-                bundleContext_ungetServiceReference(tracker->context, initial_reference); //REF COUNT to 1
-			}
-
-			arrayList_destroy(initial);
-
-			initial = NULL;
-		}
-	}
-
-	if(status != CELIX_SUCCESS && listener != NULL){
-		free(listener);
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot open tracker");
-
-	return status;
-}
-
-celix_status_t serviceTracker_close(service_tracker_pt tracker) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (status == CELIX_SUCCESS) {
-		array_list_pt refs = serviceTracker_getServiceReferences(tracker);
-		if (refs != NULL) {
-			unsigned int i;
-			for (i = 0; i < arrayList_size(refs); i++) {
-				service_reference_pt ref = (service_reference_pt) arrayList_get(refs, i);
-				status = serviceTracker_untrack(tracker, ref, NULL);
-			}
-		}
-		arrayList_destroy(refs);
-	}
-    if (status == CELIX_SUCCESS) {
-        status = bundleContext_removeServiceListener(tracker->context, tracker->listener);
-        if(status == CELIX_SUCCESS) {
-            free(tracker->listener);
-            tracker->listener = NULL;
-        }
-    }
-	framework_logIfError(logger, status, NULL, "Cannot close tracker");
-
-	return status;
-}
-
-service_reference_pt serviceTracker_getServiceReference(service_tracker_pt tracker) {
-	tracked_pt tracked;
-    service_reference_pt result = NULL;
-	unsigned int i;
-
-    celixThreadRwlock_readLock(&tracker->lock);
-	for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
-		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
-		result = tracked->reference;
-        break;
-	}
-    celixThreadRwlock_unlock(&tracker->lock);
-
-	return result;
-}
-
-array_list_pt serviceTracker_getServiceReferences(service_tracker_pt tracker) {
-	tracked_pt tracked;
-	unsigned int i;
-	array_list_pt references = NULL;
-	arrayList_create(&references);
-
-    celixThreadRwlock_readLock(&tracker->lock);
-	for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
-		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
-		arrayList_add(references, tracked->reference);
-	}
-    celixThreadRwlock_unlock(&tracker->lock);
-
-	return references;
-}
-
-void *serviceTracker_getService(service_tracker_pt tracker) {
-	tracked_pt tracked;
-    void *service = NULL;
-	unsigned int i;
-
-    celixThreadRwlock_readLock(&tracker->lock);
-    for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
-		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
-		service = tracked->service;
-        break;
-	}
-    celixThreadRwlock_unlock(&tracker->lock);
-
-    return service;
-}
-
-array_list_pt serviceTracker_getServices(service_tracker_pt tracker) {
-	tracked_pt tracked;
-	unsigned int i;
-	array_list_pt references = NULL;
-	arrayList_create(&references);
-
-    celixThreadRwlock_readLock(&tracker->lock);
-    for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
-		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
-		arrayList_add(references, tracked->service);
-	}
-    celixThreadRwlock_unlock(&tracker->lock);
-
-    return references;
-}
-
-void *serviceTracker_getServiceByReference(service_tracker_pt tracker, service_reference_pt reference) {
-	tracked_pt tracked;
-    void *service = NULL;
-	unsigned int i;
-
-    celixThreadRwlock_readLock(&tracker->lock);
-	for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
-		bool equals = false;
-		tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
-		serviceReference_equals(reference, tracked->reference, &equals);
-		if (equals) {
-			service = tracked->service;
-            break;
-		}
-	}
-    celixThreadRwlock_unlock(&tracker->lock);
-
-	return service;
-}
-
-void serviceTracker_serviceChanged(service_listener_pt listener, service_event_pt event) {
-	service_tracker_pt tracker = listener->handle;
-	switch (event->type) {
-		case OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED:
-			serviceTracker_track(tracker, event->reference, event);
-			break;
-		case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED:
-			serviceTracker_track(tracker, event->reference, event);
-			break;
-		case OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING:
-			serviceTracker_untrack(tracker, event->reference, event);
-			break;
-		case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH:
-            //TODO
-			break;
-	}
-}
-
-static celix_status_t serviceTracker_track(service_tracker_pt tracker, service_reference_pt reference, service_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    tracked_pt tracked = NULL;
-    bool found = false;
-    unsigned int i;
-    
-    bundleContext_retainServiceReference(tracker->context, reference);
-
-    celixThreadRwlock_readLock(&tracker->lock);
-    for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
-        bool equals = false;
-        tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
-        status = serviceReference_equals(reference, tracked->reference, &equals);
-        if (status != CELIX_SUCCESS) {
-            break;
-        }
-        if (equals) {
-            found = true;
-            break;
-        }
-    }
-    celixThreadRwlock_unlock(&tracker->lock);
-
-    if (status == CELIX_SUCCESS && !found /*new*/) {
-        void * service = NULL;
-        status = serviceTracker_invokeAddingService(tracker, reference, &service);
-        if (status == CELIX_SUCCESS) {
-            if (service != NULL) {
-                tracked = (tracked_pt) calloc(1, sizeof (*tracked));
-                assert(reference != NULL);
-                tracked->reference = reference;
-                tracked->service = service;
-
-                celixThreadRwlock_writeLock(&tracker->lock);
-                arrayList_add(tracker->trackedServices, tracked);
-                celixThreadRwlock_unlock(&tracker->lock);
-
-                serviceTracker_invokeAddService(tracker, reference, service);
-            }
-        }
-
-    } else {
-        status = serviceTracker_invokeModifiedService(tracker, reference, tracked->service);
-    }
-
-    framework_logIfError(logger, status, NULL, "Cannot track reference");
-
-    return status;
-}
-
-static celix_status_t serviceTracker_invokeModifiedService(service_tracker_pt tracker, service_reference_pt ref, void *service) {
-    celix_status_t status = CELIX_SUCCESS;
-    if (tracker->customizer != NULL) {
-        void *handle = NULL;
-        modified_callback_pt function = NULL;
-
-        serviceTrackerCustomizer_getHandle(tracker->customizer, &handle);
-        serviceTrackerCustomizer_getModifiedFunction(tracker->customizer, &function);
-
-        if (function != NULL) {
-            function(handle, ref, service);
-        }
-    }
-    return status;
-}
-
-static celix_status_t serviceTracker_invokeAddService(service_tracker_pt tracker, service_reference_pt ref, void *service) {
-    celix_status_t status = CELIX_SUCCESS;
-    if (tracker->customizer != NULL) {
-        void *handle = NULL;
-        added_callback_pt function = NULL;
-
-        serviceTrackerCustomizer_getHandle(tracker->customizer, &handle);
-        serviceTrackerCustomizer_getAddedFunction(tracker->customizer, &function);
-        if (function != NULL) {
-            function(handle, ref, service);
-        }
-    }
-    return status;
-}
-
-static celix_status_t serviceTracker_invokeAddingService(service_tracker_pt tracker, service_reference_pt reference,
-                                                          void **service) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    if (tracker->customizer != NULL) {
-    	void *handle = NULL;
-		adding_callback_pt function = NULL;
-
-		status =  serviceTrackerCustomizer_getHandle(tracker->customizer, &handle);
-
-        if (status == CELIX_SUCCESS) {
-            status = serviceTrackerCustomizer_getAddingFunction(tracker->customizer, &function);
-        }
-
-		if (status == CELIX_SUCCESS) {
-            if (function != NULL) {
-                status = function(handle, reference, service);
-            } else {
-                status = bundleContext_getService(tracker->context, reference, service);
-            }
-		}
-	} else {
-        status = bundleContext_getService(tracker->context, reference, service);
-    }
-
-    framework_logIfError(logger, status, NULL, "Cannot handle addingService");
-
-    return status;
-}
-
-static celix_status_t serviceTracker_untrack(service_tracker_pt tracker, service_reference_pt reference, service_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
-    tracked_pt tracked = NULL;
-    unsigned int i;
-    bool found = false;
-
-    celixThreadRwlock_writeLock(&tracker->lock);
-    for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
-        bool equals;
-        tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
-        serviceReference_equals(reference, tracked->reference, &equals);
-        if (equals) {
-            found = true;
-            arrayList_remove(tracker->trackedServices, i);
-            break;
-        }
-    }
-    celixThreadRwlock_unlock(&tracker->lock);
-
-    if (found && tracked != NULL) {
-        serviceTracker_invokeRemovingService(tracker, tracked->reference, tracked->service);
-        bundleContext_ungetServiceReference(tracker->context, reference);
-        free(tracked);
-    }
-   
-    framework_logIfError(logger, status, NULL, "Cannot untrack reference");
-
-    return status;
-}
-
-static celix_status_t serviceTracker_invokeRemovingService(service_tracker_pt tracker, service_reference_pt ref,  void *service) {
-    celix_status_t status = CELIX_SUCCESS;
-    bool ungetSuccess = true;
-    if (tracker->customizer != NULL) {
-        void *handle = NULL;
-        removed_callback_pt function = NULL;
-
-        serviceTrackerCustomizer_getHandle(tracker->customizer, &handle);
-        serviceTrackerCustomizer_getRemovedFunction(tracker->customizer, &function);
-
-        if (function != NULL) {
-            status = function(handle, ref, service);
-        }
-        if (status == CELIX_SUCCESS) {
-            status = bundleContext_ungetService(tracker->context, ref, &ungetSuccess);
-        }
-    } else {
-        status = bundleContext_ungetService(tracker->context, ref, &ungetSuccess);
-    }
-
-    if (!ungetSuccess) {
-        framework_log(logger, OSGI_FRAMEWORK_LOG_ERROR, __FUNCTION__, __FILE__, __LINE__, "Error ungetting service");
-        status = CELIX_BUNDLE_EXCEPTION;
-    }
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/service_tracker_customizer.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_tracker_customizer.c b/framework/private/src/service_tracker_customizer.c
deleted file mode 100644
index b62a23a..0000000
--- a/framework/private/src/service_tracker_customizer.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- *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.
- */
-/*
- * service_tracker_customizer.c
- *
- *  \date       Nov 15, 2012
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-
-#include "service_tracker_customizer_private.h"
-#include "celix_log.h"
-
-celix_status_t serviceTrackerCustomizer_create(void *handle,
-		adding_callback_pt addingFunction, added_callback_pt addedFunction,
-		modified_callback_pt modifiedFunction, removed_callback_pt removedFunction, service_tracker_customizer_pt *customizer) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (handle == NULL || *customizer != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*customizer = malloc(sizeof(**customizer));
-		if (!*customizer) {
-			status = CELIX_ENOMEM;
-		} else {
-			(*customizer)->handle = handle;
-			(*customizer)->addingService = addingFunction;
-			(*customizer)->addedService = addedFunction;
-			(*customizer)->modifiedService = modifiedFunction;
-			(*customizer)->removedService = removedFunction;
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot create customizer");
-
-	return status;
-}
-
-celix_status_t serviceTrackerCustomizer_destroy(service_tracker_customizer_pt customizer) {
-	customizer->handle = NULL;
-	customizer->addingService = NULL;
-	customizer->addedService = NULL;
-	customizer->modifiedService = NULL;
-	customizer->removedService = NULL;
-
-	free(customizer);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceTrackerCustomizer_getHandle(service_tracker_customizer_pt customizer, void **handle) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*handle = customizer->handle;
-
-	return status;
-}
-
-celix_status_t serviceTrackerCustomizer_getAddingFunction(service_tracker_customizer_pt customizer, adding_callback_pt *function) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*function = customizer->addingService;
-
-	return status;
-}
-
-celix_status_t serviceTrackerCustomizer_getAddedFunction(service_tracker_customizer_pt customizer, added_callback_pt *function) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*function = customizer->addedService;
-
-	return status;
-}
-
-celix_status_t serviceTrackerCustomizer_getModifiedFunction(service_tracker_customizer_pt customizer, modified_callback_pt *function) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*function = customizer->modifiedService;
-
-	return status;
-}
-
-celix_status_t serviceTrackerCustomizer_getRemovedFunction(service_tracker_customizer_pt customizer, removed_callback_pt *function) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*function = customizer->removedService;
-
-	return status;
-}


[04/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/celix_threads.h
----------------------------------------------------------------------
diff --git a/utils/include/celix_threads.h b/utils/include/celix_threads.h
new file mode 100644
index 0000000..6af57bb
--- /dev/null
+++ b/utils/include/celix_threads.h
@@ -0,0 +1,135 @@
+/**
+ *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_threads.h
+ *
+ *  \date       4 Jun 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef CELIX_THREADS_H_
+#define CELIX_THREADS_H_
+
+#include <pthread.h>
+#include <stdbool.h>
+
+#include "celix_errno.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct celix_thread {
+	bool threadInitialized;
+	pthread_t thread;
+};
+
+typedef pthread_once_t celix_thread_once_t;
+#define CELIX_THREAD_ONCE_INIT PTHREAD_ONCE_INIT
+
+typedef struct celix_thread celix_thread_t;
+typedef pthread_attr_t celix_thread_attr_t;
+
+typedef void *(*celix_thread_start_t)(void *);
+
+static const celix_thread_t celix_thread_default = {0, 0};
+
+celix_status_t
+celixThread_create(celix_thread_t *new_thread, celix_thread_attr_t *attr, celix_thread_start_t func, void *data);
+
+void celixThread_exit(void *exitStatus);
+
+celix_status_t celixThread_detach(celix_thread_t thread);
+
+celix_status_t celixThread_join(celix_thread_t thread, void **status);
+
+celix_status_t celixThread_kill(celix_thread_t thread, int sig);
+
+celix_thread_t celixThread_self(void);
+
+int celixThread_equals(celix_thread_t thread1, celix_thread_t thread2);
+
+bool celixThread_initalized(celix_thread_t thread);
+
+
+typedef pthread_mutex_t celix_thread_mutex_t;
+typedef pthread_mutexattr_t celix_thread_mutexattr_t;
+
+//MUTEX TYPES
+enum {
+	CELIX_THREAD_MUTEX_NORMAL,
+	CELIX_THREAD_MUTEX_RECURSIVE,
+	CELIX_THREAD_MUTEX_ERRORCHECK,
+	CELIX_THREAD_MUTEX_DEFAULT
+};
+
+
+celix_status_t celixThreadMutex_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t *attr);
+
+celix_status_t celixThreadMutex_destroy(celix_thread_mutex_t *mutex);
+
+celix_status_t celixThreadMutex_lock(celix_thread_mutex_t *mutex);
+
+celix_status_t celixThreadMutex_unlock(celix_thread_mutex_t *mutex);
+
+celix_status_t celixThreadMutexAttr_create(celix_thread_mutexattr_t *attr);
+
+celix_status_t celixThreadMutexAttr_destroy(celix_thread_mutexattr_t *attr);
+
+celix_status_t celixThreadMutexAttr_settype(celix_thread_mutexattr_t *attr, int type);
+
+typedef pthread_rwlock_t celix_thread_rwlock_t;
+typedef pthread_rwlockattr_t celix_thread_rwlockattr_t;
+
+celix_status_t celixThreadRwlock_create(celix_thread_rwlock_t *lock, celix_thread_rwlockattr_t *attr);
+
+celix_status_t celixThreadRwlock_destroy(celix_thread_rwlock_t *lock);
+
+celix_status_t celixThreadRwlock_readLock(celix_thread_rwlock_t *lock);
+
+celix_status_t celixThreadRwlock_writeLock(celix_thread_rwlock_t *lock);
+
+celix_status_t celixThreadRwlock_unlock(celix_thread_rwlock_t *lock);
+
+celix_status_t celixThreadRwlockAttr_create(celix_thread_rwlockattr_t *attr);
+
+celix_status_t celixThreadRwlockAttr_destroy(celix_thread_rwlockattr_t *attr);
+//NOTE: No support yet for setting specific rw lock attributes
+
+
+typedef pthread_cond_t celix_thread_cond_t;
+typedef pthread_condattr_t celix_thread_condattr_t;
+
+celix_status_t celixThreadCondition_init(celix_thread_cond_t *condition, celix_thread_condattr_t *attr);
+
+celix_status_t celixThreadCondition_destroy(celix_thread_cond_t *condition);
+
+celix_status_t celixThreadCondition_wait(celix_thread_cond_t *cond, celix_thread_mutex_t *mutex);
+
+celix_status_t celixThreadCondition_broadcast(celix_thread_cond_t *cond);
+
+celix_status_t celixThreadCondition_signal(celix_thread_cond_t *cond);
+
+celix_status_t celixThread_once(celix_thread_once_t *once_control, void (*init_routine)(void));
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* CELIX_THREADS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/celixbool.h
----------------------------------------------------------------------
diff --git a/utils/include/celixbool.h b/utils/include/celixbool.h
new file mode 100644
index 0000000..526392b
--- /dev/null
+++ b/utils/include/celixbool.h
@@ -0,0 +1,61 @@
+/*
+ *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.
+ */
+/*
+ * celixbool.h
+ *
+ *  \date       Jun 16, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef CELIXBOOL_H_
+#define CELIXBOOL_H_
+
+
+#if defined(__STDC__)
+# define C89
+# if defined(__STDC_VERSION__)
+#  define C90
+#  if (__STDC_VERSION__ >= 199409L)
+#   define C94
+#  endif
+#  if (__STDC_VERSION__ >= 199901L)
+#   define C99
+#  endif
+# endif
+#endif
+
+
+#if __STDC_VERSION__ < 199901L && __GNUC__ < 3
+// #ifndef C99
+
+typedef int _Bool;
+
+#define bool _Bool
+#define false 0 
+#define true 1
+
+
+#else
+
+#include <stdbool.h>
+
+#endif
+
+#endif /* CELIXBOOL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/exports.h
----------------------------------------------------------------------
diff --git a/utils/include/exports.h b/utils/include/exports.h
new file mode 100644
index 0000000..b128c88
--- /dev/null
+++ b/utils/include/exports.h
@@ -0,0 +1,49 @@
+/**
+ *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.
+ */
+/*
+ * exports.h
+ *
+ *  \date       Jun 16, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef EXPORTS_H_
+#define EXPORTS_H_
+
+/* Cmake will define utils_EXPORTS on Windows when it
+configures to build a shared library. If you are going to use
+another build system on windows or create the visual studio
+projects by hand you need to define utils_EXPORTS when
+building a DLL on windows.
+
+We are using the Visual Studio Compiler and building Shared libraries
+*/
+
+#if defined (_WIN32)
+  #if defined(celix_utils_EXPORTS)
+    #define  UTILS_EXPORT __declspec(dllexport)
+  #else
+    #define  UTILS_EXPORT __declspec(dllimport)
+  #endif /* celix_utils_EXPORTS */
+#else /* defined (_WIN32) */
+  #define UTILS_EXPORT __attribute__((visibility("default")))
+#endif
+
+#endif /* EXPORTS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/hash_map.h
----------------------------------------------------------------------
diff --git a/utils/include/hash_map.h b/utils/include/hash_map.h
new file mode 100644
index 0000000..28d386b
--- /dev/null
+++ b/utils/include/hash_map.h
@@ -0,0 +1,161 @@
+/**
+ *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.
+ */
+/*
+ * hash_map.h
+ *
+ *  \date       Jul 21, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef HASH_MAP_H_
+#define HASH_MAP_H_
+
+#include "celixbool.h"
+#include "exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct hashMapEntry* hash_map_entry_pt;
+typedef struct hasMapEntry hash_map_entry_t;
+
+typedef struct hashMap* hash_map_pt;
+typedef struct hashMap hash_map_t;
+
+struct hashMapIterator {
+	hash_map_pt map;
+	hash_map_entry_pt next;
+	hash_map_entry_pt current;
+	int expectedModCount;
+	int index;
+};
+
+typedef struct hashMapIterator hash_map_iterator_t;
+typedef hash_map_iterator_t *hash_map_iterator_pt;
+
+typedef struct hashMapKeySet *hash_map_key_set_pt;
+typedef struct hashMapValues *hash_map_values_pt;
+typedef struct hashMapEntrySet *hash_map_entry_set_pt;
+
+UTILS_EXPORT hash_map_pt hashMap_create(unsigned int (*keyHash)(const void *), unsigned int (*valueHash)(const void *),
+										int (*keyEquals)(const void *, const void *),
+										int (*valueEquals)(const void *, const void *));
+
+UTILS_EXPORT void hashMap_destroy(hash_map_pt map, bool freeKeys, bool freeValues);
+
+UTILS_EXPORT int hashMap_size(hash_map_pt map);
+
+UTILS_EXPORT bool hashMap_isEmpty(hash_map_pt map);
+
+UTILS_EXPORT void *hashMap_get(hash_map_pt map, const void *key);
+
+UTILS_EXPORT bool hashMap_containsKey(hash_map_pt map, const void *key);
+
+UTILS_EXPORT hash_map_entry_pt hashMap_getEntry(hash_map_pt map, const void *key);
+
+UTILS_EXPORT void *hashMap_put(hash_map_pt map, void *key, void *value);
+
+UTILS_EXPORT void *hashMap_remove(hash_map_pt map, const void *key);
+
+UTILS_EXPORT void hashMap_clear(hash_map_pt map, bool freeKey, bool freeValue);
+
+UTILS_EXPORT bool hashMap_containsValue(hash_map_pt map, const void *value);
+
+UTILS_EXPORT hash_map_iterator_pt hashMapIterator_create(hash_map_pt map);
+
+UTILS_EXPORT void hashMapIterator_destroy(hash_map_iterator_pt iterator);
+
+UTILS_EXPORT hash_map_iterator_pt hashMapIterator_alloc(void);
+
+UTILS_EXPORT void hashMapIterator_dealloc(hash_map_iterator_pt iterator);
+
+UTILS_EXPORT void hashMapIterator_init(hash_map_pt map, hash_map_iterator_pt iterator);
+
+UTILS_EXPORT void hashMapIterator_deinit(hash_map_iterator_pt iterator);
+
+UTILS_EXPORT hash_map_iterator_t hashMapIterator_construct(hash_map_pt map);
+
+
+UTILS_EXPORT bool hashMapIterator_hasNext(hash_map_iterator_pt iterator);
+
+UTILS_EXPORT void hashMapIterator_remove(hash_map_iterator_pt iterator);
+
+UTILS_EXPORT void *hashMapIterator_nextValue(hash_map_iterator_pt iterator);
+
+UTILS_EXPORT void *hashMapIterator_nextKey(hash_map_iterator_pt iterator);
+
+UTILS_EXPORT hash_map_entry_pt hashMapIterator_nextEntry(hash_map_iterator_pt iterator);
+
+UTILS_EXPORT hash_map_key_set_pt hashMapKeySet_create(hash_map_pt map);
+
+UTILS_EXPORT void hashMapKeySet_destroy(hash_map_key_set_pt keySet);
+
+UTILS_EXPORT int hashMapKeySet_size(hash_map_key_set_pt keySet);
+
+UTILS_EXPORT bool hashMapKeySet_contains(hash_map_key_set_pt keySet, const void *key);
+
+UTILS_EXPORT bool hashMapKeySet_remove(hash_map_key_set_pt keySet, const void *key);
+
+UTILS_EXPORT void hashMapKeySet_clear(hash_map_key_set_pt keySet);
+
+UTILS_EXPORT bool hashMapKeySet_isEmpty(hash_map_key_set_pt keySet);
+
+UTILS_EXPORT hash_map_values_pt hashMapValues_create(hash_map_pt map);
+
+UTILS_EXPORT void hashMapValues_destroy(hash_map_values_pt values);
+
+UTILS_EXPORT hash_map_iterator_pt hashMapValues_iterator(hash_map_values_pt values);
+
+UTILS_EXPORT int hashMapValues_size(hash_map_values_pt values);
+
+UTILS_EXPORT bool hashMapValues_contains(hash_map_values_pt values, const void *o);
+
+UTILS_EXPORT void hashMapValues_toArray(hash_map_values_pt values, void **array[], unsigned int *size);
+
+UTILS_EXPORT bool hashMapValues_remove(hash_map_values_pt values, const void *o);
+
+UTILS_EXPORT void hashMapValues_clear(hash_map_values_pt values);
+
+UTILS_EXPORT bool hashMapValues_isEmpty(hash_map_values_pt values);
+
+UTILS_EXPORT hash_map_entry_set_pt hashMapEntrySet_create(hash_map_pt map);
+
+UTILS_EXPORT void hashMapEntrySet_destroy(hash_map_entry_set_pt entrySet);
+
+UTILS_EXPORT int hashMapEntrySet_size(hash_map_entry_set_pt entrySet);
+
+UTILS_EXPORT bool hashMapEntrySet_contains(hash_map_entry_set_pt entrySet, hash_map_entry_pt entry);
+
+UTILS_EXPORT bool hashMapEntrySet_remove(hash_map_entry_set_pt entrySet, hash_map_entry_pt entry);
+
+UTILS_EXPORT void hashMapEntrySet_clear(hash_map_entry_set_pt entrySet);
+
+UTILS_EXPORT bool hashMapEntrySet_isEmpty(hash_map_entry_set_pt entrySet);
+
+UTILS_EXPORT void *hashMapEntry_getKey(hash_map_entry_pt entry);
+
+UTILS_EXPORT void *hashMapEntry_getValue(hash_map_entry_pt entry);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HASH_MAP_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/linked_list.h
----------------------------------------------------------------------
diff --git a/utils/include/linked_list.h b/utils/include/linked_list.h
new file mode 100644
index 0000000..cbf650c
--- /dev/null
+++ b/utils/include/linked_list.h
@@ -0,0 +1,91 @@
+/**
+ *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.
+ */
+/*
+ * linked_list.h
+ *
+ *  \date       Jul 16, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LINKED_LIST_H_
+#define LINKED_LIST_H_
+
+
+#include "celixbool.h"
+#include "celix_errno.h"
+#include "exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef struct linked_list_entry *linked_list_entry_pt;
+typedef struct linked_list *linked_list_pt;
+
+UTILS_EXPORT celix_status_t linkedList_create(linked_list_pt *list);
+
+UTILS_EXPORT celix_status_t linkedList_destroy(linked_list_pt list);
+
+UTILS_EXPORT celix_status_t linkedList_clone(linked_list_pt list, linked_list_pt *clone);
+
+UTILS_EXPORT void *linkedList_getFirst(linked_list_pt list);
+
+UTILS_EXPORT void *linkedList_getLast(linked_list_pt list);
+
+UTILS_EXPORT void *linkedList_removeFirst(linked_list_pt list);
+
+UTILS_EXPORT void *linkedList_removeLast(linked_list_pt list);
+
+UTILS_EXPORT void linkedList_addFirst(linked_list_pt list, void *element);
+
+UTILS_EXPORT void linkedList_addLast(linked_list_pt list, void *element);
+
+UTILS_EXPORT bool linkedList_contains(linked_list_pt list, void *element);
+
+UTILS_EXPORT int linkedList_size(linked_list_pt list);
+
+UTILS_EXPORT bool linkedList_isEmpty(linked_list_pt list);
+
+UTILS_EXPORT bool linkedList_addElement(linked_list_pt list, void *element);
+
+UTILS_EXPORT bool linkedList_removeElement(linked_list_pt list, void *element);
+
+UTILS_EXPORT void linkedList_clear(linked_list_pt list);
+
+UTILS_EXPORT void *linkedList_get(linked_list_pt list, int index);
+
+UTILS_EXPORT void *linkedList_set(linked_list_pt list, int index, void *element);
+
+UTILS_EXPORT void linkedList_addIndex(linked_list_pt list, int index, void *element);
+
+UTILS_EXPORT void *linkedList_removeIndex(linked_list_pt list, int index);
+
+UTILS_EXPORT linked_list_entry_pt linkedList_entry(linked_list_pt list, int index);
+
+UTILS_EXPORT int linkedList_indexOf(linked_list_pt list, void *element);
+
+UTILS_EXPORT linked_list_entry_pt linkedList_addBefore(linked_list_pt list, void *element, linked_list_entry_pt entry);
+
+UTILS_EXPORT void *linkedList_removeEntry(linked_list_pt list, linked_list_entry_pt entry);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LINKED_LIST_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/linked_list_iterator.h
----------------------------------------------------------------------
diff --git a/utils/include/linked_list_iterator.h b/utils/include/linked_list_iterator.h
new file mode 100644
index 0000000..f765d5d
--- /dev/null
+++ b/utils/include/linked_list_iterator.h
@@ -0,0 +1,66 @@
+/**
+ *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.
+ */
+/*
+ * linked_list_iterator.h
+ *
+ *  \date       Jul 16, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LINKED_LIST_ITERATOR_H_
+#define LINKED_LIST_ITERATOR_H_
+
+#include "celixbool.h"
+
+#include "linked_list.h"
+#include "exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef struct linkedListIterator *linked_list_iterator_pt;
+
+UTILS_EXPORT linked_list_iterator_pt linkedListIterator_create(linked_list_pt list, unsigned int index);
+
+UTILS_EXPORT void linkedListIterator_destroy(linked_list_iterator_pt iterator);
+
+UTILS_EXPORT bool linkedListIterator_hasNext(linked_list_iterator_pt iterator);
+
+UTILS_EXPORT void *linkedListIterator_next(linked_list_iterator_pt iterator);
+
+UTILS_EXPORT bool linkedListIterator_hasPrevious(linked_list_iterator_pt iterator);
+
+UTILS_EXPORT void *linkedListIterator_previous(linked_list_iterator_pt iterator);
+
+UTILS_EXPORT int linkedListIterator_nextIndex(linked_list_iterator_pt iterator);
+
+UTILS_EXPORT int linkedListIterator_previousIndex(linked_list_iterator_pt iterator);
+
+UTILS_EXPORT void linkedListIterator_remove(linked_list_iterator_pt iterator);
+
+UTILS_EXPORT void linkedListIterator_set(linked_list_iterator_pt iterator, void *element);
+
+UTILS_EXPORT void linkedListIterator_add(linked_list_iterator_pt iterator, void *element);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LINKED_LIST_ITERATOR_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/memstream/README.md
----------------------------------------------------------------------
diff --git a/utils/include/memstream/README.md b/utils/include/memstream/README.md
new file mode 100644
index 0000000..476810e
--- /dev/null
+++ b/utils/include/memstream/README.md
@@ -0,0 +1,49 @@
+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/a1c30887/utils/include/memstream/fmemopen.h
----------------------------------------------------------------------
diff --git a/utils/include/memstream/fmemopen.h b/utils/include/memstream/fmemopen.h
new file mode 100644
index 0000000..3d06b20
--- /dev/null
+++ b/utils/include/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/a1c30887/utils/include/memstream/open_memstream.h
----------------------------------------------------------------------
diff --git a/utils/include/memstream/open_memstream.h b/utils/include/memstream/open_memstream.h
new file mode 100644
index 0000000..e87bb0a
--- /dev/null
+++ b/utils/include/memstream/open_memstream.h
@@ -0,0 +1,15 @@
+#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/a1c30887/utils/include/properties.h
----------------------------------------------------------------------
diff --git a/utils/include/properties.h b/utils/include/properties.h
new file mode 100644
index 0000000..cf93ca0
--- /dev/null
+++ b/utils/include/properties.h
@@ -0,0 +1,66 @@
+/**
+ *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.
+ */
+/*
+ * properties.h
+ *
+ *  \date       Apr 27, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef PROPERTIES_H_
+#define PROPERTIES_H_
+
+#include <stdio.h>
+
+#include "hash_map.h"
+#include "exports.h"
+#include "celix_errno.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef hash_map_pt properties_pt;
+typedef hash_map_t properties_t;
+
+UTILS_EXPORT properties_pt properties_create(void);
+
+UTILS_EXPORT void properties_destroy(properties_pt properties);
+
+UTILS_EXPORT properties_pt properties_load(const char *filename);
+
+UTILS_EXPORT properties_pt properties_loadWithStream(FILE *stream);
+
+UTILS_EXPORT void properties_store(properties_pt properties, const char *file, const char *header);
+
+UTILS_EXPORT const char *properties_get(properties_pt properties, const char *key);
+
+UTILS_EXPORT const char *properties_getWithDefault(properties_pt properties, const char *key, const char *defaultValue);
+
+UTILS_EXPORT void properties_set(properties_pt properties, const char *key, const char *value);
+
+UTILS_EXPORT celix_status_t properties_copy(properties_pt properties, properties_pt *copy);
+
+#define PROPERTIES_FOR_EACH(props, key) \
+    for(hash_map_iterator_t iter = hashMapIterator_construct(props); \
+        hashMapIterator_hasNext(&iter), (key) = (const char*)hashMapIterator_nextKey(&iter);)
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PROPERTIES_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/thpool.h
----------------------------------------------------------------------
diff --git a/utils/include/thpool.h b/utils/include/thpool.h
new file mode 100644
index 0000000..0180aa6
--- /dev/null
+++ b/utils/include/thpool.h
@@ -0,0 +1,168 @@
+/********************************** 
+ * @author      Johan Hanssen Seferidis
+ * License:     MIT
+ * 
+ **********************************/
+
+#ifndef _THPOOL_
+#define _THPOOL_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* =================================== API ======================================= */
+
+
+typedef struct thpool_ *threadpool;
+
+
+/**
+ * @brief  Initialize threadpool
+ * 
+ * Initializes a threadpool. This function will not return untill all
+ * threads have initialized successfully.
+ * 
+ * @example
+ * 
+ *    ..
+ *    threadpool thpool;                     //First we declare a threadpool
+ *    thpool = thpool_init(4);               //then we initialize it to 4 threads
+ *    ..
+ * 
+ * @param  num_threads   number of threads to be created in the threadpool
+ * @return threadpool    created threadpool on success,
+ *                       NULL on error
+ */
+threadpool thpool_init(int num_threads);
+
+
+/**
+ * @brief Add work to the job queue
+ * 
+ * Takes an action and its argument and adds it to the threadpool's job queue.
+ * If you want to add to work a function with more than one arguments then
+ * a way to implement this is by passing a pointer to a structure.
+ * 
+ * NOTICE: You have to cast both the function and argument to not get warnings.
+ * 
+ * @example
+ * 
+ *    void print_num(int num){
+ *       printf("%d\n", num);
+ *    }
+ * 
+ *    int main() {
+ *       ..
+ *       int a = 10;
+ *       thpool_add_work(thpool, (void*)print_num, (void*)a);
+ *       ..
+ *    }
+ * 
+ * @param  threadpool    threadpool to which the work will be added
+ * @param  function_p    pointer to function to add as work
+ * @param  arg_p         pointer to an argument
+ * @return nothing
+ */
+int thpool_add_work(threadpool, void *(*function_p)(void *), void *arg_p);
+
+
+/**
+ * @brief Wait for all queued jobs to finish
+ * 
+ * Will wait for all jobs - both queued and currently running to finish.
+ * Once the queue is empty and all work has completed, the calling thread
+ * (probably the main program) will continue.
+ * 
+ * Smart polling is used in wait. The polling is initially 0 - meaning that
+ * there is virtually no polling at all. If after 1 seconds the threads
+ * haven't finished, the polling interval starts growing exponentially 
+ * untill it reaches max_secs seconds. Then it jumps down to a maximum polling
+ * interval assuming that heavy processing is being used in the threadpool.
+ *
+ * @example
+ * 
+ *    ..
+ *    threadpool thpool = thpool_init(4);
+ *    ..
+ *    // Add a bunch of work
+ *    ..
+ *    thpool_wait(thpool);
+ *    puts("All added work has finished");
+ *    ..
+ * 
+ * @param threadpool     the threadpool to wait for
+ * @return nothing
+ */
+void thpool_wait(threadpool);
+
+
+/**
+ * @brief Pauses all threads immediately
+ * 
+ * The threads will be paused no matter if they are idle or working.
+ * The threads return to their previous states once thpool_resume
+ * is called.
+ * 
+ * While the thread is being paused, new work can be added.
+ * 
+ * @example
+ * 
+ *    threadpool thpool = thpool_init(4);
+ *    thpool_pause(thpool);
+ *    ..
+ *    // Add a bunch of work
+ *    ..
+ *    thpool_resume(thpool); // Let the threads start their magic
+ * 
+ * @param threadpool    the threadpool where the threads should be paused
+ * @return nothing
+ */
+void thpool_pause(threadpool);
+
+
+/**
+ * @brief Unpauses all threads if they are paused
+ * 
+ * @example
+ *    ..
+ *    thpool_pause(thpool);
+ *    sleep(10);              // Delay execution 10 seconds
+ *    thpool_resume(thpool);
+ *    ..
+ * 
+ * @param threadpool     the threadpool where the threads should be unpaused
+ * @return nothing
+ */
+void thpool_resume(threadpool);
+
+
+/**
+ * @brief Destroy the threadpool
+ * 
+ * This will wait for the currently active threads to finish and then 'kill'
+ * the whole threadpool to free up memory.
+ * 
+ * @example
+ * int main() {
+ *    threadpool thpool1 = thpool_init(2);
+ *    threadpool thpool2 = thpool_init(2);
+ *    ..
+ *    thpool_destroy(thpool1);
+ *    ..
+ *    return 0;
+ * }
+ * 
+ * @param threadpool     the threadpool to destroy
+ * @return nothing
+ */
+void thpool_destroy(threadpool);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/utils.h
----------------------------------------------------------------------
diff --git a/utils/include/utils.h b/utils/include/utils.h
new file mode 100644
index 0000000..2fc7d44
--- /dev/null
+++ b/utils/include/utils.h
@@ -0,0 +1,61 @@
+/**
+ *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.
+ */
+/*
+ * utils.h
+ *
+ *  \date       Jul 27, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef UTILS_H_
+#define UTILS_H_
+
+#include <ctype.h>
+
+#include "celix_errno.h"
+#include "celixbool.h"
+#include "exports.h"
+#include "celix_threads.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+UTILS_EXPORT unsigned int utils_stringHash(const void *string);
+
+UTILS_EXPORT int utils_stringEquals(const void *string, const void *toCompare);
+
+UTILS_EXPORT char *string_ndup(const char *s, size_t n);
+
+UTILS_EXPORT char *utils_stringTrim(char *string);
+
+UTILS_EXPORT bool utils_isStringEmptyOrNull(const char *const str);
+
+UTILS_EXPORT int
+utils_compareServiceIdsAndRanking(unsigned long servId, long servRank, unsigned long otherServId, long otherServRank);
+
+UTILS_EXPORT celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals);
+
+UTILS_EXPORT celix_status_t utils_isNumeric(const char *number, bool *ret);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* UTILS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/version.h
----------------------------------------------------------------------
diff --git a/utils/include/version.h b/utils/include/version.h
new file mode 100644
index 0000000..88e146a
--- /dev/null
+++ b/utils/include/version.h
@@ -0,0 +1,186 @@
+/**
+ *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.
+ */
+/*
+ * version.h
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef VERSION_H_
+#define VERSION_H_
+
+#include "celix_errno.h"
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * The definition of the version_pt abstract data type.
+ */
+typedef struct version *version_pt;
+
+/**
+ * Creates a new version_pt using the supplied arguments.
+ *
+ * @param major Major component of the version identifier.
+ * @param minor Minor component of the version identifier.
+ * @param micro Micro component of the version identifier.
+ * @param qualifier Qualifier component of the version identifier. If
+ *        <code>null</code> is specified, then the qualifier will be set to
+ *        the empty string.
+ * @param version The created version_pt
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
+ * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative
+ * 		  or the qualifier string is invalid.
+ */
+celix_status_t version_createVersion(int major, int minor, int micro, char *qualifier, version_pt *version);
+
+celix_status_t version_destroy(version_pt version);
+
+/**
+ * Creates a clone of <code>version</code>.
+ *
+ * @param version The version to clone
+ * @param clone The cloned version
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
+ * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative
+ * 		  or the qualifier string is invalid.
+ */
+celix_status_t version_clone(version_pt version, version_pt *clone);
+
+/**
+ * Creates a version identifier from the specified string.
+ *
+ * <p>
+ * Here is the grammar for version strings.
+ *
+ * <pre>
+ * version ::= major('.'minor('.'micro('.'qualifier)?)?)?
+ * major ::= digit+
+ * minor ::= digit+
+ * micro ::= digit+
+ * qualifier ::= (alpha|digit|'_'|'-')+
+ * digit ::= [0..9]
+ * alpha ::= [a..zA..Z]
+ * </pre>
+ *
+ * There must be no whitespace in version.
+ *
+ * @param versionStr String representation of the version identifier.
+ * @param version The created version_pt
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
+ * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
+ * 		  	the qualifier string is invalid or <code>versionStr</code> is improperly formatted.
+ */
+celix_status_t version_createVersionFromString(const char *versionStr, version_pt *version);
+
+/**
+ * The empty version "0.0.0".
+ *
+ * @param version The created version_pt
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
+ * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
+ * 		  	the qualifier string is invalid or <code>versionStr</code> is improperly formatted.
+ */
+celix_status_t version_createEmptyVersion(version_pt *version);
+
+celix_status_t version_getMajor(version_pt version, int *major);
+
+celix_status_t version_getMinor(version_pt version, int *minor);
+
+celix_status_t version_getMicro(version_pt version, int *micro);
+
+celix_status_t version_getQualifier(version_pt version, const char **qualifier);
+
+/**
+ * Compares this <code>Version</code> object to another object.
+ *
+ * <p>
+ * A version is considered to be <b>less than </b> another version if its
+ * major component is less than the other version's major component, or the
+ * major components are equal and its minor component is less than the other
+ * version's minor component, or the major and minor components are equal
+ * and its micro component is less than the other version's micro component,
+ * or the major, minor and micro components are equal and it's qualifier
+ * component is less than the other version's qualifier component (using
+ * <code>String.compareTo</code>).
+ *
+ * <p>
+ * A version is considered to be <b>equal to</b> another version if the
+ * major, minor and micro components are equal and the qualifier component
+ * is equal (using <code>String.compareTo</code>).
+ *
+ * @param version The <code>version_pt</code> to be compared with <code>compare</code>.
+ * @param compare The <code>version_pt</code> to be compared with <code>version</code>.
+ * @param result A negative integer, zero, or a positive integer if <code>version</code> is
+ *         less than, equal to, or greater than the <code>compare</code>.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t version_compareTo(version_pt version, version_pt compare, int *result);
+
+/**
+ * Returns the string representation of <code>version</code> identifier.
+ *
+ * <p>
+ * The format of the version string will be <code>major.minor.micro</code>
+ * if qualifier is the empty string or
+ * <code>major.minor.micro.qualifier</code> otherwise.
+ *
+ * @return The string representation of this version identifier.
+ * @param version The <code>version_pt</code> to get the string representation from.
+ * @param string Pointer to the string (char *) in which the result will be placed.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t version_toString(version_pt version, char **string);
+
+/**
+ * Check if two versions are semantically compatible.
+ *
+ * <p>
+ * The user version is compatible with the provider version if the provider version is in the range
+ * [user_version, next_macro_from_user_version)
+ *
+ * @return Boolean indicating if the versions are compatible
+ * @param version The user <code>version_pt</code> .
+ * @param version The reference provider <code>version_pt</code> .
+ * @param Boolean indicating if the versions are compatible
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t version_isCompatible(version_pt user, version_pt provider, bool *isCompatible);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VERSION_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/version_range.h
----------------------------------------------------------------------
diff --git a/utils/include/version_range.h b/utils/include/version_range.h
new file mode 100644
index 0000000..b661cd3
--- /dev/null
+++ b/utils/include/version_range.h
@@ -0,0 +1,160 @@
+/**
+ *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.
+ */
+/*
+ * version_range.h
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef VERSION_RANGE_H_
+#define VERSION_RANGE_H_
+
+/**
+ * @defgroup VersionRange Version Range functions
+ * @ingroup framework
+ * @{
+ */
+
+#include "celixbool.h"
+#include "celix_errno.h"
+#include "version.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * Type definition for the version_range_pt abstract data type.
+ */
+typedef struct versionRange *version_range_pt;
+
+/**
+ * Creates a new <code>version_range_pt</code>.
+ *
+ * @param low Lower bound version
+ * @param isLowInclusive True if lower bound should be included in the range
+ * @param high Upper bound version
+ * @param isHighInclusive True if upper bound should be included in the range
+ * @param versionRange The created range
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>versionRange</code> failed.
+ */
+celix_status_t
+versionRange_createVersionRange(version_pt low, bool isLowInclusive, version_pt high, bool isHighInclusive,
+                                version_range_pt *versionRange);
+
+/**
+ * Creates an infinite version range using ::version_createEmptyVersion for the low version,
+ * 	NULL for the high version and high and low inclusive set to true.
+ *
+ * @param range The created range
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>range</code> failed.
+ */
+celix_status_t versionRange_createInfiniteVersionRange(version_range_pt *range);
+
+celix_status_t versionRange_destroy(version_range_pt range);
+
+/**
+ * Determine if the specified version is part of the version range or not.
+ *
+ * @param versionRange The range to check <code>version</code> against.
+ * @param version The version to check.
+ * @param inRange True if the specified version is included in this version range, false otherwise.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t versionRange_isInRange(version_range_pt versionRange, version_pt version, bool *inRange);
+
+/**
+ * Determines whether the lower bound is included in the given range
+ *
+ * @param versionRange The range to check
+ * @param isLowInclusive is set to true in case, the lower bound the lower bound is included, otherwise false
+ * @return Status code indication failure or success:
+ *      - CELIX_SUCCESS when no errors are encountered.
+ *      - CELIX_ILLEGAL_ARGUMENT in case the versionRange is NULL
+ */
+celix_status_t versionRange_isLowInclusive(version_range_pt versionRange, bool *isLowInclusive);
+
+/**
+ * Determines whether the higher bound is included in the given range
+ *
+ * @param versionRange The range to check
+ * @param isHighInclusive is set to true in case, the lower bound the higher bound is included, otherwise false
+ * @return Status code indication failure or success:
+ *      - CELIX_SUCCESS when no errors are encountered.
+ *      - CELIX_ILLEGAL_ARGUMENT in case the versionRange is NULL
+ */
+celix_status_t versionRange_isHighInclusive(version_range_pt versionRange, bool *isHighInclusive);
+
+/**
+ * Retrieves whether the lower bound version from the given range
+ *
+ * @param versionRange The range
+ * @param highVersion is set to the lower bound version
+ * @return Status code indication failure or success:
+ *      - CELIX_SUCCESS when no errors are encountered.
+ *      - CELIX_ILLEGAL_ARGUMENT in case the versionRange is NULL
+ */
+celix_status_t versionRange_getLowVersion(version_range_pt versionRange, version_pt *lowVersion);
+
+/**
+ * Retrieves whether the upper bound version from the given range
+ *
+ * @param versionRange The range
+ * @param highVersion is set to the upper bound version
+ * @return Status code indication failure or success:
+ *      - CELIX_SUCCESS when no errors are encountered.
+ *      - CELIX_ILLEGAL_ARGUMENT in case the versionRange is NULL
+ */
+celix_status_t versionRange_getHighVersion(version_range_pt versionRange, version_pt *highVersion);
+
+/**
+ * Parses a version range from the specified string.
+ *
+ * <p>
+ * Here is the grammar for version range strings.
+ *
+ * <pre>
+ * version-range ::= interval | atleast
+ * interval ::= ( '[' | '(' ) floor ',' ceiling ( ']' | ')' )
+ * atleast ::= version
+ * floor ::= version
+ * ceiling ::= version
+ * </pre>
+ *
+ * @param rangeStr String representation of the version range.
+ * @param range The created version_range_pt.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>versionRange</code> failed.
+ * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
+ * 		  	the qualifier string is invalid or <code>versionStr</code> is impropertly formatted.
+ */
+celix_status_t versionRange_parse(const char *rangeStr, version_range_pt *range);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VERSION_RANGE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/include/array_list_private.h
----------------------------------------------------------------------
diff --git a/utils/private/include/array_list_private.h b/utils/private/include/array_list_private.h
deleted file mode 100644
index bea2712..0000000
--- a/utils/private/include/array_list_private.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- *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.
- */
-/*
- * array_list_private.h
- *
- *  \date       Aug 4, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef array_list_t_PRIVATE_H_
-#define array_list_t_PRIVATE_H_
-
-#include "array_list.h"
-
-struct arrayList {
-	void ** elementData;
-	unsigned int size;
-	unsigned int capacity;
-
-	unsigned int modCount;
-
-	array_list_element_equals_pt equals;
-};
-
-struct arrayListIterator {
-	array_list_pt list;
-	unsigned int cursor;
-	int lastReturned;
-	unsigned int expectedModificationCount;
-};
-
-void * arrayList_remove(array_list_pt list, unsigned int index);
-
-
-#endif /* array_list_t_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/include/hash_map_private.h
----------------------------------------------------------------------
diff --git a/utils/private/include/hash_map_private.h b/utils/private/include/hash_map_private.h
deleted file mode 100644
index cddf7a1..0000000
--- a/utils/private/include/hash_map_private.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- *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.
- */
-/*
- * hash_map_private.h
- *
- *  \date       Jul 21, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef HASH_MAP_PRIVATE_H_
-#define HASH_MAP_PRIVATE_H_
-
-#include "exports.h"
-#include "hash_map.h"
-
-UTILS_EXPORT unsigned int hashMap_hashCode(const void* toHash);
-UTILS_EXPORT int hashMap_equals(const void* toCompare, const void* compare);
-
-void hashMap_resize(hash_map_pt map, int newCapacity);
-hash_map_entry_pt hashMap_removeEntryForKey(hash_map_pt map, const void* key);
-UTILS_EXPORT hash_map_entry_pt hashMap_removeMapping(hash_map_pt map, hash_map_entry_pt entry);
-void hashMap_addEntry(hash_map_pt map, int hash, void* key, void* value, int bucketIndex);
-
-struct hashMapEntry {
-	void* key;
-	void* value;
-	hash_map_entry_pt next;
-	unsigned int hash;
-};
-
-struct hashMap {
-	hash_map_entry_pt * table;
-	unsigned int size;
-	unsigned int treshold;
-	unsigned int modificationCount;
-	unsigned int tablelength;
-
-	unsigned int (*hashKey)(const void* key);
-	unsigned int (*hashValue)(const void* value);
-	int (*equalsKey)(const void* key1, const void* key2);
-	int (*equalsValue)(const void* value1, const void* value2);
-};
-
-struct hashMapKeySet {
-	hash_map_pt map;
-};
-
-struct hashMapValues {
-	hash_map_pt map;
-};
-
-struct hashMapEntrySet {
-	hash_map_pt map;
-};
-
-
-#endif /* HASH_MAP_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/include/linked_list_private.h
----------------------------------------------------------------------
diff --git a/utils/private/include/linked_list_private.h b/utils/private/include/linked_list_private.h
deleted file mode 100644
index dcb0a46..0000000
--- a/utils/private/include/linked_list_private.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *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.
- */
-/*
- * linked_list_private.h
- *
- *  \date       Jul 16, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LINKED_LIST_PRIVATE_H_
-#define LINKED_LIST_PRIVATE_H_
-
-#include "linked_list.h"
-
-struct linked_list_entry {
-	void * element;
-	struct linked_list_entry * next;
-	struct linked_list_entry * previous;
-};
-
-struct linked_list {
-	linked_list_entry_pt header;
-	size_t size;
-	int modificationCount;
-};
-
-#endif /* LINKED_LIST_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/include/version_private.h
----------------------------------------------------------------------
diff --git a/utils/private/include/version_private.h b/utils/private/include/version_private.h
deleted file mode 100644
index 15e5c89..0000000
--- a/utils/private/include/version_private.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *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.
- */
-/*
- * version_private.h
- *
- *  \date       Dec 18, 2012
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef VERSION_PRIVATE_H_
-#define VERSION_PRIVATE_H_
-
-#include "version.h"
-
-struct version {
-	int major;
-	int minor;
-	int micro;
-	char *qualifier;
-};
-
-
-#endif /* VERSION_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/include/version_range_private.h
----------------------------------------------------------------------
diff --git a/utils/private/include/version_range_private.h b/utils/private/include/version_range_private.h
deleted file mode 100644
index dfccd59..0000000
--- a/utils/private/include/version_range_private.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *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.
- */
-/*
- * version_range_private.h
- *
- *  \date       Dec 18, 2012
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef VERSION_RANGE_PRIVATE_H_
-#define VERSION_RANGE_PRIVATE_H_
-
-#include "version_range.h"
-
-struct versionRange {
-	version_pt low;
-	bool isLowInclusive;
-	version_pt high;
-	bool isHighInclusive;
-
-};
-
-#endif /* VERSION_RANGE_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/array_list.c
----------------------------------------------------------------------
diff --git a/utils/private/src/array_list.c b/utils/private/src/array_list.c
deleted file mode 100644
index e7a2e30..0000000
--- a/utils/private/src/array_list.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/**
- *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.
- */
-/*
- * array_list.c
- *
- *  \date       Aug 4, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "array_list.h"
-#include "array_list_private.h"
-
-static celix_status_t arrayList_elementEquals(const void *a, const void *b, bool *equals);
-
-celix_status_t arrayList_create(array_list_pt *list) {
-	return arrayList_createWithEquals(arrayList_elementEquals, list);
-}
-
- celix_status_t arrayList_createWithEquals(array_list_element_equals_pt equals, array_list_pt *list) {
-	*list = (array_list_pt) malloc(sizeof(**list));
-
-	(*list)->equals = equals;
-	(*list)->size = 0;
-	(*list)->capacity = 10;
-	(*list)->modCount = 0;
-	(*list)->elementData = (void **) malloc(sizeof(void*) * (*list)->capacity);
-
-	return CELIX_SUCCESS;
-}
-
-void arrayList_destroy(array_list_pt list) {
-	list->size = 0;
-	free(list->elementData);
-	list->elementData = NULL;
-	free(list);
-}
-
-static celix_status_t arrayList_elementEquals(const void *a, const void *b, bool *equals) {
-	*equals = (a == b);
-	return CELIX_SUCCESS;
-}
-
-void arrayList_trimToSize(array_list_pt list) {
-	unsigned int oldCapacity;
-	list->modCount++;
-	oldCapacity = list->capacity;
-	if (list->size < oldCapacity) {
-		void ** newList = (void **) realloc(list->elementData, sizeof(void *) * list->size);
-		list->capacity = list->size;
-		list->elementData = newList;
-	}
-}
-
-void arrayList_ensureCapacity(array_list_pt list, int capacity) {
-	void ** newList;
-	unsigned int oldCapacity;
-	list->modCount++;
-	oldCapacity = list->capacity;
-	if (capacity > oldCapacity) {
-		unsigned int newCapacity = (oldCapacity * 3) / 2 + 1;
-		if (newCapacity < capacity) {
-			newCapacity = capacity;
-		}
-		newList = (void **) realloc(list->elementData, sizeof(void *) * newCapacity);
-		list->capacity = newCapacity;
-		list->elementData = newList;
-	}
-}
-
-unsigned int arrayList_size(array_list_pt list) {
-	return list->size;
-}
-
-bool arrayList_isEmpty(array_list_pt list) {
-	return list->size == 0;
-}
-
-bool arrayList_contains(array_list_pt list, void * element) {
-	int index = arrayList_indexOf(list, element);
-	return index >= 0;
-}
-
-int arrayList_indexOf(array_list_pt list, void * element) {
-	if (element == NULL) {
-		unsigned int i = 0;
-		for (i = 0; i < list->size; i++) {
-			if (list->elementData[i] == NULL) {
-				return i;
-			}
-		}
-	} else {
-		unsigned int i = 0;
-		for (i = 0; i < list->size; i++) {
-			bool equals = false;
-			list->equals(element, list->elementData[i], &equals);
-			if (equals) {
-				return i;
-			}
-		}
-	}
-	return -1;
-}
-
-int arrayList_lastIndexOf(array_list_pt list, void * element) {
-	if (element == NULL) {
-		int i = 0;
-		for (i = list->size - 1; i >= 0; i--) {
-			if (list->elementData[i] == NULL) {
-				return i;
-			}
-		}
-	} else {
-		int i = 0;
-		for (i = list->size - 1; i >= 0; i--) {
-			bool equals = false;
-			list->equals(element, list->elementData[i], &equals);
-			if (equals) {
-				return i;
-			}
-		}
-	}
-	return -1;
-}
-
-void * arrayList_get(array_list_pt list, unsigned int index) {
-	if (index >= list->size) {
-		return NULL;
-	}
-
-	return list->elementData[index];
-}
-
-void * arrayList_set(array_list_pt list, unsigned int index, void * element) {
-	void * oldElement;
-	if (index >= list->size) {
-		return NULL;
-	}
-
-	oldElement = list->elementData[index];
-	list->elementData[index] = element;
-	return oldElement;
-}
-
-bool arrayList_add(array_list_pt list, void * element) {
-	arrayList_ensureCapacity(list, list->size + 1);
-	list->elementData[list->size++] = element;
-	return true;
-}
-
-int arrayList_addIndex(array_list_pt list, unsigned int index, void * element) {
-	unsigned int numMoved;
-	if (index > list->size) {
-		return -1;
-	}
-	arrayList_ensureCapacity(list, list->size+1);
-	numMoved = list->size - index;
-	memmove(list->elementData+(index+1), list->elementData+index, sizeof(void *) * numMoved);
-
-	list->elementData[index] = element;
-	list->size++;
-	return 0;
-}
-
-void * arrayList_remove(array_list_pt list, unsigned int index) {
-	void * oldElement;
-	unsigned int numMoved;
-	if (index >= list->size) {
-		return NULL;
-	}
-
-	list->modCount++;
-	oldElement = list->elementData[index];
-	numMoved = list->size - index - 1;
-	memmove(list->elementData+index, list->elementData+index+1, sizeof(void *) * numMoved);
-	list->elementData[--list->size] = NULL;
-
-	return oldElement;
-}
-
-void arrayList_fastRemove(array_list_pt list, unsigned int index) {
-	unsigned int numMoved;
-	list->modCount++;
-
-	numMoved = list->size - index - 1;
-	memmove(list->elementData+index, list->elementData+index+1, sizeof(void *) * numMoved);
-	list->elementData[--list->size] = NULL;
-}
-
-bool arrayList_removeElement(array_list_pt list, void * element) {
-	if (element == NULL) {
-		unsigned int i = 0;
-		for (i = 0; i < list->size; i++) {
-			if (list->elementData[i] == NULL) {
-				arrayList_fastRemove(list, i);
-				return true;
-			}
-		}
-	} else {
-		unsigned int i = 0;
-		for (i = 0; i < list->size; i++) {
-			bool equals = false;
-			list->equals(element, list->elementData[i], &equals);
-			if (equals) {
-				arrayList_fastRemove(list, i);
-				return true;
-			}
-		}
-	}
-	return false;
-}
-
-void arrayList_clear(array_list_pt list) {
-	unsigned int i;
-	list->modCount++;
-
-	for (i = 0; i < list->size; i++) {
-		// free(list->elementData[i]);
-		list->elementData[i] = NULL;
-	}
-	list->size = 0;
-}
-
-bool arrayList_addAll(array_list_pt list, array_list_pt toAdd) {
-    unsigned int i;
-    unsigned int size = arrayList_size(toAdd);
-    arrayList_ensureCapacity(list, list->size + size);
-//    memcpy(list->elementData+list->size, *toAdd->elementData, size);
-//    list->size += size;
-    for (i = 0; i < arrayList_size(toAdd); i++) {
-        arrayList_add(list, arrayList_get(toAdd, i));
-    }
-    return size != 0;
-}
-
-array_list_pt arrayList_clone(array_list_pt list) {
-	unsigned int i;
-	array_list_pt new = NULL;
-	arrayList_create(&new);
-//	arrayList_ensureCapacity(new, list->size);
-//	memcpy(new->elementData, list->elementData, list->size);
-//	new->size = list->size;
-	
-	for (i = 0; i < arrayList_size(list); i++) {
-		arrayList_add(new, arrayList_get(list, i));
-	}
-	new->modCount = 0;
-	return new;
-}
-
-array_list_iterator_pt arrayListIterator_create(array_list_pt list) {
-	array_list_iterator_pt iterator = (array_list_iterator_pt) malloc(sizeof(*iterator));
-
-	iterator->lastReturned = -1;
-	iterator->cursor = 0;
-	iterator->list = list;
-	iterator->expectedModificationCount = list->modCount;
-
-	return iterator;
-}
-
-void arrayListIterator_destroy(array_list_iterator_pt iterator) {
-	iterator->lastReturned = -1;
-	iterator->cursor = 0;
-	iterator->expectedModificationCount = 0;
-	iterator->list = NULL;
-	free(iterator);
-}
-
-bool arrayListIterator_hasNext(array_list_iterator_pt iterator) {
-	return iterator->cursor != iterator->list->size;
-}
-
-void * arrayListIterator_next(array_list_iterator_pt iterator) {
-	void * next;
-	if (iterator->expectedModificationCount != iterator->list->modCount) {
-		return NULL;
-	}
-	next = arrayList_get(iterator->list, iterator->cursor);
-	iterator->lastReturned = iterator->cursor++;
-	return next;
-}
-
-bool arrayListIterator_hasPrevious(array_list_iterator_pt iterator) {
-	return iterator->cursor != 0;
-}
-
-void * arrayListIterator_previous(array_list_iterator_pt iterator) {
-	int i;
-	void * previous;
-	if (iterator->expectedModificationCount != iterator->list->modCount) {
-		return NULL;
-	}
-	i = iterator->cursor - 1;
-	previous = arrayList_get(iterator->list, i);
-	iterator->lastReturned = iterator->cursor = i;
-	return previous;
-}
-
-void arrayListIterator_remove(array_list_iterator_pt iterator) {
-	if (iterator->lastReturned == -1) {
-		return;
-	}
-	if (iterator->expectedModificationCount != iterator->list->modCount) {
-		return;
-	}
-	if (arrayList_remove(iterator->list, iterator->lastReturned) != NULL) {
-		if (iterator->lastReturned < iterator->cursor) {
-			iterator->cursor--;
-		}
-		iterator->lastReturned = -1;
-		iterator->expectedModificationCount = iterator->list->modCount;
-	}
-}
-
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/celix_threads.c
----------------------------------------------------------------------
diff --git a/utils/private/src/celix_threads.c b/utils/private/src/celix_threads.c
deleted file mode 100644
index 64bdf5b..0000000
--- a/utils/private/src/celix_threads.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
- *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_threads.c
- *
- *  \date       4 Jun 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include "signal.h"
-#include "celix_threads.h"
-
-
-celix_status_t celixThread_create(celix_thread_t *new_thread, celix_thread_attr_t *attr, celix_thread_start_t func, void *data) {
-    celix_status_t status = CELIX_SUCCESS;
-
-	if (pthread_create(&(*new_thread).thread, attr, func, data) != 0) {
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-	else {
-		(*new_thread).threadInitialized = true;
-	}
-
-	return status;
-}
-
-// Returns void, since pthread_exit does exit the thread and never returns.
-void celixThread_exit(void *exitStatus) {
-    pthread_exit(exitStatus);
-}
-
-celix_status_t celixThread_detach(celix_thread_t thread) {
-    return pthread_detach(thread.thread);
-}
-
-celix_status_t celixThread_join(celix_thread_t thread, void **retVal) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (pthread_join(thread.thread, retVal) != 0) {
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-
-    // #TODO make thread a pointer? Now this statement has no effect
-	// thread.threadInitialized = false;
-
-    return status;
-}
-
-celix_status_t celixThread_kill(celix_thread_t thread, int sig) {
-    return pthread_kill(thread.thread, sig);
-}
-
-celix_thread_t celixThread_self() {
-	celix_thread_t thread;
-
-	thread.thread = pthread_self();
-	thread.threadInitialized = true;
-
-	return thread;
-}
-
-int celixThread_equals(celix_thread_t thread1, celix_thread_t thread2) {
-    return pthread_equal(thread1.thread, thread2.thread);
-}
-
-bool celixThread_initalized(celix_thread_t thread) {
-    return thread.threadInitialized;
-}
-
-
-celix_status_t celixThreadMutex_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t *attr) {
-    return pthread_mutex_init(mutex, attr);
-}
-
-celix_status_t celixThreadMutex_destroy(celix_thread_mutex_t *mutex) {
-    return pthread_mutex_destroy(mutex);
-}
-
-celix_status_t celixThreadMutex_lock(celix_thread_mutex_t *mutex) {
-    return pthread_mutex_lock(mutex);
-}
-
-celix_status_t celixThreadMutex_unlock(celix_thread_mutex_t *mutex) {
-    return pthread_mutex_unlock(mutex);
-}
-
-celix_status_t celixThreadMutexAttr_create(celix_thread_mutexattr_t *attr) {
-	return pthread_mutexattr_init(attr);
-}
-
-celix_status_t celixThreadMutexAttr_destroy(celix_thread_mutexattr_t *attr) {
-	return pthread_mutexattr_destroy(attr);
-}
-
-celix_status_t celixThreadMutexAttr_settype(celix_thread_mutexattr_t *attr, int type) {
-	celix_status_t status;
-	switch(type) {
-		case CELIX_THREAD_MUTEX_NORMAL :
-			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_NORMAL);
-			break;
-		case CELIX_THREAD_MUTEX_RECURSIVE :
-			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE);
-			break;
-		case CELIX_THREAD_MUTEX_ERRORCHECK :
-			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_ERRORCHECK);
-			break;
-		case CELIX_THREAD_MUTEX_DEFAULT :
-			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_DEFAULT);
-			break;
-		default:
-			status = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_DEFAULT);
-			break;
-    }
-	return status;
-}
-
-celix_status_t celixThreadCondition_init(celix_thread_cond_t *condition, celix_thread_condattr_t *attr) {
-    return pthread_cond_init(condition, attr);
-}
-
-celix_status_t celixThreadCondition_destroy(celix_thread_cond_t *condition) {
-    return pthread_cond_destroy(condition);
-}
-
-celix_status_t celixThreadCondition_wait(celix_thread_cond_t *cond, celix_thread_mutex_t *mutex) {
-    return pthread_cond_wait(cond, mutex);
-}
-
-celix_status_t celixThreadCondition_broadcast(celix_thread_cond_t *cond) {
-    return pthread_cond_broadcast(cond);
-}
-
-celix_status_t celixThreadCondition_signal(celix_thread_cond_t *cond) {
-    return pthread_cond_signal(cond);
-}
-
-celix_status_t celixThreadRwlock_create(celix_thread_rwlock_t *lock, celix_thread_rwlockattr_t *attr) {
-	return pthread_rwlock_init(lock, attr);
-}
-
-celix_status_t celixThreadRwlock_destroy(celix_thread_rwlock_t *lock) {
-	return pthread_rwlock_destroy(lock);
-}
-
-celix_status_t celixThreadRwlock_readLock(celix_thread_rwlock_t *lock) {
-	return pthread_rwlock_rdlock(lock);
-}
-
-celix_status_t celixThreadRwlock_writeLock(celix_thread_rwlock_t *lock) {
-	return pthread_rwlock_wrlock(lock);
-}
-
-celix_status_t celixThreadRwlock_unlock(celix_thread_rwlock_t *lock) {
-	return pthread_rwlock_unlock(lock);
-}
-
-celix_status_t celixThreadRwlockAttr_create(celix_thread_rwlockattr_t *attr) {
-	return pthread_rwlockattr_init(attr);
-}
-
-celix_status_t celixThreadRwlockAttr_destroy(celix_thread_rwlockattr_t *attr) {
-	return pthread_rwlockattr_destroy(attr);
-}
-
-celix_status_t celixThread_once(celix_thread_once_t *once_control, void (*init_routine)(void)) {
-	return pthread_once(once_control, init_routine);
-}
\ No newline at end of file


[31/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/public/include/json_rpc.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/json_rpc.h b/dfi/public/include/json_rpc.h
deleted file mode 100644
index 1cc1464..0000000
--- a/dfi/public/include/json_rpc.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *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.
- */
-#ifndef __JSON_RPC_H_
-#define __JSON_RPC_H_
-
-#include <jansson.h>
-#include "dfi_log_util.h"
-#include "dyn_type.h"
-#include "dyn_function.h"
-#include "dyn_interface.h"
-
-//logging
-DFI_SETUP_LOG_HEADER(jsonRpc);
-
-int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, char **out);
-
-
-int jsonRpc_prepareInvokeRequest(dyn_function_type *func, const char *id, void *args[], char **out);
-int jsonRpc_handleReply(dyn_function_type *func, const char *reply, void *args[]);
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/public/include/json_serializer.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/json_serializer.h b/dfi/public/include/json_serializer.h
deleted file mode 100644
index 2f91f2b..0000000
--- a/dfi/public/include/json_serializer.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *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.
- */
-#ifndef __JSON_SERIALIZER_H_
-#define __JSON_SERIALIZER_H_
-
-#include <jansson.h>
-#include "dfi_log_util.h"
-#include "dyn_type.h"
-#include "dyn_function.h"
-#include "dyn_interface.h"
-
-//logging
-DFI_SETUP_LOG_HEADER(jsonSerializer);
-
-int jsonSerializer_deserialize(dyn_type *type, const char *input, void **result);
-int jsonSerializer_deserializeJson(dyn_type *type, json_t *input, void **result);
-
-int jsonSerializer_serialize(dyn_type *type, const void* input, char **output);
-int jsonSerializer_serializeJson(dyn_type *type, const void* input, json_t **out);
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/src/dyn_common.c
----------------------------------------------------------------------
diff --git a/dfi/src/dyn_common.c b/dfi/src/dyn_common.c
new file mode 100644
index 0000000..ea8f425
--- /dev/null
+++ b/dfi/src/dyn_common.c
@@ -0,0 +1,151 @@
+/**
+ *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.
+ */
+#include "dyn_common.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdbool.h>
+
+#if defined(BSD) || defined(__APPLE__)  || defined(ANDROID)
+#include "open_memstream.h"
+#include "fmemopen.h"
+#endif
+
+static const int OK = 0;
+static const int ERROR = 1;
+
+DFI_SETUP_LOG(dynCommon)
+
+static bool dynCommon_charIn(int c, const char *acceptedChars);
+
+int dynCommon_parseName(FILE *stream, char **result) {
+    return dynCommon_parseNameAlsoAccept(stream, NULL, result);
+}
+
+int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result) {
+    int status = OK;
+
+    char *buf = NULL;
+    size_t size = 0;
+    int strLen = 0;
+    FILE *name = open_memstream(&buf, &size);
+
+    if (name != NULL) { 
+        int c = getc(stream);
+        while (isalnum(c) || c == '_' || dynCommon_charIn(c, acceptedChars)) {
+            fputc(c, name); 
+            c = getc(stream);
+            strLen += 1;
+        }
+        fflush(name);
+        fclose(name);
+        ungetc(c, stream);
+    } else {
+        status = ERROR;
+        LOG_ERROR("Error creating mem stream for name. %s", strerror(errno));
+    }
+
+    if (status == OK) {
+        if (strLen == 0) {
+            status = ERROR;
+            LOG_ERROR("Parsed empty name");
+        }
+    }
+
+    if (status == OK) {
+       LOG_DEBUG("Parsed name '%s'", buf);
+       *result = buf;
+    } else if (buf != NULL) {
+        free(buf);
+    }
+
+    return status;
+}
+
+int dynCommon_parseNameValue(FILE *stream, char **outName, char **outValue) {
+    int status;
+    char *name = NULL;
+    char *value = NULL;
+
+    status = dynCommon_parseName(stream, &name);
+    if (status == OK) {
+        status = dynCommon_eatChar(stream, '=');
+    }
+    if (status == OK) {
+        const char *valueAcceptedChars = ".<>{}[]?;:~!@#$%^&*()_+-=,./\\'\"";
+
+        status = dynCommon_parseNameAlsoAccept(stream, valueAcceptedChars, &value); //NOTE use different more lenient function e.g. only stop at '\n' ?
+    }
+
+    if (status == OK) {
+        *outName = name;
+        *outValue = value;
+    } else {
+        if (name != NULL) {
+            free(name);
+        }
+        if (value != NULL) {
+            free(value);
+        }
+    }
+    return status;
+}
+
+int dynCommon_eatChar(FILE *stream, int expected) {
+    int status = OK;
+    long loc = ftell(stream);
+    int c = fgetc(stream);
+    if (c != expected) {
+        status = ERROR;
+        LOG_ERROR("Error parsing, expected token '%c' got '%c' at position %li", expected, c, loc);
+    }
+    return status;
+}
+
+static bool dynCommon_charIn(int c, const char *acceptedChars) {
+    bool status = false;
+    if (acceptedChars != NULL) {
+        int i;
+        for (i = 0; acceptedChars[i] != '\0'; i += 1) {
+            if (c == acceptedChars[i]) {
+                status = true;
+                break;
+            }
+        }
+    }
+
+    return status;
+}
+
+void dynCommon_clearNamValHead(struct namvals_head *head) {
+    struct namval_entry *entry = TAILQ_FIRST(head);
+    while (entry != NULL) {
+        struct namval_entry *tmp = entry;
+
+        if (entry->name != NULL) {
+            free(entry->name);
+        }
+        if (entry->value != NULL) {
+            free(entry->value);
+        }
+        entry = TAILQ_NEXT(entry, entries);
+        free(tmp);
+    }
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/src/dyn_function.c
----------------------------------------------------------------------
diff --git a/dfi/src/dyn_function.c b/dfi/src/dyn_function.c
new file mode 100644
index 0000000..615ad16
--- /dev/null
+++ b/dfi/src/dyn_function.c
@@ -0,0 +1,331 @@
+/**
+ *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.
+ */
+#include "dyn_function.h"
+
+#include <strings.h>
+#include <stdlib.h>
+#include <ffi.h>
+
+#include "dyn_common.h"
+
+struct _dyn_function_type {
+    char *name;
+    struct types_head *refTypes; //NOTE not owned
+    TAILQ_HEAD(,_dyn_function_argument_type) arguments;
+    ffi_type **ffiArguments;
+    dyn_type *funcReturn;
+    ffi_cif cif;
+
+    //closure part
+    ffi_closure *ffiClosure;
+    void (*fn)(void);
+    void *userData;
+    void (*bind)(void *userData, void *args[], void *ret);
+};
+
+typedef struct _dyn_function_argument_type dyn_function_argument_type;
+struct _dyn_function_argument_type {
+    int index;
+    char *name;
+    enum dyn_function_argument_meta argumentMeta;
+    dyn_type *type;
+    TAILQ_ENTRY(_dyn_function_argument_type) entries;
+};
+
+static const int OK = 0;
+static const int MEM_ERROR = 1;
+static const int PARSE_ERROR = 2;
+static const int ERROR = 2;
+
+DFI_SETUP_LOG(dynFunction)
+
+static int dynFunction_initCif(dyn_function_type *dynFunc);
+static int dynFunction_parseDescriptor(dyn_function_type *dynFunc, FILE *descriptor);
+static void dynFunction_ffiBind(ffi_cif *cif, void *ret, void *args[], void *userData);
+
+extern ffi_type * dynType_ffiType(dyn_type *type);
+
+int dynFunction_parse(FILE *descriptor, struct types_head *refTypes, dyn_function_type **out) {
+    int status = OK;
+    dyn_function_type *dynFunc = NULL;
+    LOG_DEBUG("Creating dyn function", descriptor);
+    
+    dynFunc = calloc(1, sizeof(*dynFunc));
+
+    if (dynFunc != NULL) {
+        TAILQ_INIT(&dynFunc->arguments);
+        dynFunc->refTypes = refTypes;
+        status = dynFunction_parseDescriptor(dynFunc, descriptor);
+        if (status == 0) {
+            int rc = dynFunction_initCif(dynFunc);
+            if (rc != 0) {
+                LOG_ERROR("Error initializing cif");
+                status = ERROR;
+            }
+        }
+    } else {
+        LOG_ERROR("Error allocationg memory for dyn functipn\n");
+        status = MEM_ERROR;
+    }
+
+    if (status == OK) {
+        dyn_function_argument_type *arg = NULL;
+        TAILQ_FOREACH(arg, &dynFunc->arguments, entries) {
+            const char *meta = dynType_getMetaInfo(arg->type, "am");
+            if (meta == NULL) {
+                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__STD;
+            } else if (strcmp(meta, "handle") == 0) {
+                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__HANDLE;
+            } else if (strcmp(meta, "pre") == 0) {
+                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT;
+            } else if (strcmp(meta, "out") == 0) {
+                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__OUTPUT;
+            } else {
+                LOG_WARNING("unknown argument meta '%s' encountered", meta);
+                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__STD;
+            }
+        }
+    }
+    
+    if (status == OK) {
+        *out = dynFunc;
+    }    else {
+        if (dynFunc != NULL) {
+            dynFunction_destroy(dynFunc);
+        }
+
+    }
+    
+    return status;
+}
+
+int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **out)  {
+    int status = OK;
+    FILE *stream = fmemopen((char *)descriptor, strlen(descriptor), "r");
+    if (stream != NULL) {
+        status = dynFunction_parse(stream, refTypes, out);
+        fclose(stream);
+    } else {
+        status = MEM_ERROR;
+        LOG_ERROR("Error creating mem stream for descriptor string. %s", strerror(errno)); 
+    }
+    return status;
+}
+
+static int dynFunction_parseDescriptor(dyn_function_type *dynFunc, FILE *descriptor) {
+    int status = OK;
+    char *name = NULL;
+
+    status = dynCommon_parseName(descriptor, &name);
+
+    if (status == OK) {
+        dynFunc->name = name;
+    }
+
+    if (status == OK) {
+        int c = fgetc(descriptor);
+        if ( c != '(') {
+            status = PARSE_ERROR;
+            LOG_ERROR("Expected '(' token got '%c'", c);
+        }
+    }
+
+    int nextChar = fgetc(descriptor);
+    int index = 0;
+    dyn_type *type = NULL;
+    char argName[32];
+    while (nextChar != ')' && status == 0)  {
+        ungetc(nextChar, descriptor);
+        type = NULL;
+
+        dyn_function_argument_type *arg = NULL;
+
+        status = dynType_parse(descriptor, NULL, dynFunc->refTypes, &type);
+        if (status == OK) {
+            arg = calloc(1, sizeof(*arg));
+            if (arg != NULL) {
+                arg->index = index;
+                arg->type = type;
+                snprintf(argName, 32, "arg%04i", index);
+                arg->name = strdup(argName);
+
+                index += 1;
+            } else {
+                LOG_ERROR("Error allocating memory");
+                status = MEM_ERROR;
+            }
+        }
+
+        if (status == OK) {
+            TAILQ_INSERT_TAIL(&dynFunc->arguments, arg, entries);
+        }
+
+        nextChar = fgetc(descriptor);
+    }
+
+    if (status == 0) {
+        status = dynType_parse(descriptor, NULL, dynFunc->refTypes, &dynFunc->funcReturn); 
+    }
+    
+    return status;
+}
+
+enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr) {
+    enum dyn_function_argument_meta result = 0;
+    dyn_function_argument_type *arg = NULL;
+    int index = 0;
+    TAILQ_FOREACH(arg, &dynFunc->arguments, entries) {
+        if (index == argumentNr) {
+            result = arg->argumentMeta;
+            break;
+        }
+        index += 1;
+    }
+    return result;
+}
+
+
+static int dynFunction_initCif(dyn_function_type *dynFunc) {
+    int status = 0;
+
+    int count = 0;
+    dyn_function_argument_type *entry = NULL;
+    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
+        count +=1;
+    }
+
+    dynFunc->ffiArguments = calloc(count, sizeof(ffi_type*));
+
+    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
+        dynFunc->ffiArguments[entry->index] = dynType_ffiType(entry->type);
+    }
+    
+    ffi_type **args = dynFunc->ffiArguments;
+    ffi_type *returnType = dynType_ffiType(dynFunc->funcReturn);
+
+    int ffiResult = ffi_prep_cif(&dynFunc->cif, FFI_DEFAULT_ABI, count, returnType, args);
+    if (ffiResult != FFI_OK) {
+        status = 1;
+    }
+
+    return status;
+}
+
+void dynFunction_destroy(dyn_function_type *dynFunc) {
+    if (dynFunc != NULL) {
+        if (dynFunc->funcReturn != NULL) {
+            dynType_destroy(dynFunc->funcReturn);
+        }
+        if (dynFunc->ffiClosure != NULL) {
+            ffi_closure_free(dynFunc->ffiClosure);
+        }
+        if (dynFunc->name != NULL) {
+            free(dynFunc->name);
+        }
+        if (dynFunc->ffiArguments != NULL) {
+            free(dynFunc->ffiArguments);
+        }
+        
+        dyn_function_argument_type *entry = NULL;
+        dyn_function_argument_type *tmp = NULL;
+        entry = TAILQ_FIRST(&dynFunc->arguments); 
+        while (entry != NULL) {
+            if (entry->name != NULL) {
+                free(entry->name);
+            }
+            dynType_destroy(entry->type);
+            tmp = entry;
+            entry = TAILQ_NEXT(entry, entries);
+            free(tmp);
+        }
+
+        free(dynFunc);
+    }
+}
+
+int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues) {
+    ffi_call(&dynFunc->cif, fn, returnValue, argValues);
+    return 0;
+}
+
+static void dynFunction_ffiBind(ffi_cif *cif, void *ret, void *args[], void *userData) {
+    dyn_function_type *dynFunc = userData;
+    dynFunc->bind(dynFunc->userData, args, ret);
+}
+
+int dynFunction_createClosure(dyn_function_type *dynFunc, void (*bind)(void *, void **, void*), void *userData, void(**out)(void)) {
+    int status = 0;
+    void (*fn)(void);
+    dynFunc->ffiClosure = ffi_closure_alloc(sizeof(ffi_closure), (void **)&fn);
+    if (dynFunc->ffiClosure != NULL) {
+        int rc = ffi_prep_closure_loc(dynFunc->ffiClosure, &dynFunc->cif, dynFunction_ffiBind, dynFunc, fn);
+        if (rc != FFI_OK) {
+            status = 1;
+        }
+    } else {
+        status = 2;
+    }
+
+    if (status == 0) {
+        dynFunc->userData = userData;
+        dynFunc->bind = bind;
+        dynFunc->fn = fn;
+        *out =fn;
+    }
+
+    return status;
+}
+
+int dynFunction_getFnPointer(dyn_function_type *dynFunc, void (**fn)(void)) {
+    int status = 0;
+    if (dynFunc != NULL && dynFunc->fn != NULL) {
+        (*fn) = dynFunc->fn;
+    } else {
+        status = 1;
+    }
+    return status;
+}
+
+int dynFunction_nrOfArguments(dyn_function_type *dynFunc) {
+    int count = 0;
+    dyn_function_argument_type *entry = NULL;
+    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
+        count += 1;
+    }
+    return count;
+}
+
+dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr) {
+    dyn_type *result = NULL;
+    int index = 0;
+    dyn_function_argument_type *entry = NULL;
+    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
+        if (index == argumentNr) {
+            result = entry->type;
+            break;
+        }
+        index +=1;
+    }
+    return result;
+}
+
+dyn_type * dynFunction_returnType(dyn_function_type *dynFunction) {
+    return dynFunction->funcReturn;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/src/dyn_interface.c
----------------------------------------------------------------------
diff --git a/dfi/src/dyn_interface.c b/dfi/src/dyn_interface.c
new file mode 100644
index 0000000..63aafac
--- /dev/null
+++ b/dfi/src/dyn_interface.c
@@ -0,0 +1,444 @@
+/**
+ *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.
+ */
+#include "dyn_interface.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "dyn_common.h"
+#include "dyn_type.h"
+#include "dyn_interface.h"
+
+DFI_SETUP_LOG(dynInterface);
+
+struct _dyn_interface_type {
+    struct namvals_head header;
+    struct namvals_head annotations;
+    struct types_head types;
+    struct methods_head methods;
+    version_pt version;
+};
+
+static const int OK = 0;
+static const int ERROR = 1;
+
+static int dynInterface_parseSection(dyn_interface_type *intf, FILE *stream);
+static int dynInterface_parseAnnotations(dyn_interface_type *intf, FILE *stream);
+static int dynInterface_parseTypes(dyn_interface_type *intf, FILE *stream);
+static int dynInterface_parseMethods(dyn_interface_type *intf, FILE *stream);
+static int dynInterface_parseHeader(dyn_interface_type *intf, FILE *stream);
+static int dynInterface_parseNameValueSection(dyn_interface_type *intf, FILE *stream, struct namvals_head *head);
+static int dynInterface_checkInterface(dyn_interface_type *intf);
+static int dynInterface_getEntryForHead(struct namvals_head *head, const char *name, char **value);
+
+int dynInterface_parse(FILE *descriptor, dyn_interface_type **out) {
+    int status = OK;
+
+    dyn_interface_type *intf = calloc(1, sizeof(*intf));
+    if (intf != NULL) {
+        TAILQ_INIT(&intf->header);
+        TAILQ_INIT(&intf->annotations);
+        TAILQ_INIT(&intf->types);
+        TAILQ_INIT(&intf->methods);
+
+        char peek = (char)fgetc(descriptor);
+        while (peek == ':') {
+            ungetc(peek, descriptor);
+            status = dynInterface_parseSection(intf, descriptor);
+            if (status == OK) {
+                peek = (char)fgetc(descriptor);
+            } else {
+                break;
+            }
+        }
+
+        if (status == OK) {
+            status = dynCommon_eatChar(descriptor, EOF);
+        }
+
+        if (status == OK) {
+            status = dynInterface_checkInterface(intf);
+        }
+
+        if(status==OK){ /* We are sure that version field is present in the header */
+        	char* version=NULL;
+            dynInterface_getVersionString(intf,&version);
+            if(version!=NULL){
+            	status = (version_createVersionFromString(version,&(intf->version)) == CELIX_SUCCESS)?OK:ERROR;
+            }
+            if(status==ERROR){
+            	LOG_ERROR("Invalid version (%s) in parsed descriptor\n",version);
+            }
+        }
+    } else {
+        status = ERROR;
+        LOG_ERROR("Error allocating memory for dynamic interface\n");
+    }
+
+    if (status == OK) {
+        *out = intf;
+    } else if (intf != NULL) {
+        dynInterface_destroy(intf);
+    }
+    return status;
+}
+
+static int dynInterface_checkInterface(dyn_interface_type *intf) {
+    int status = OK;
+
+    //check header section
+    if (status == OK) {
+        bool foundType = false;
+        bool foundVersion = false;
+        bool foundName = false;
+        struct namval_entry *entry = NULL;
+        TAILQ_FOREACH(entry, &intf->header, entries) {
+            if (strcmp(entry->name, "type") == 0) {
+                foundType = true;
+            } else if (strcmp(entry->name, "version") == 0) {
+                foundVersion = true;
+            } else if (strcmp(entry->name, "name") == 0) {
+                foundName = true;
+            }
+        }
+
+        if (!foundType || !foundVersion || !foundName) {
+            status = ERROR;
+            LOG_ERROR("Parse Error. There must be a header section with a type, version and name entry");
+        }
+
+        struct method_entry *mEntry = NULL;
+        TAILQ_FOREACH(mEntry, &intf->methods, entries) {
+            dyn_type *type = dynFunction_returnType(mEntry->dynFunc);
+            int descriptor = dynType_descriptorType(type);
+            if (descriptor != 'N') {
+                status = ERROR;
+                LOG_ERROR("Parse Error. Only method with a return type 'N' (native int) are supported. Got return type '%c'\n", descriptor);
+                break;
+            }
+        }
+    }
+
+    return status;
+}
+
+static int dynInterface_parseSection(dyn_interface_type *intf, FILE *stream) {
+    int status = OK;
+    char *sectionName = NULL;
+
+    status = dynCommon_eatChar(stream, ':');
+
+    if (status == OK) {
+        status = dynCommon_parseName(stream, &sectionName);
+    }
+
+    if (status == OK) {
+        status = dynCommon_eatChar(stream, '\n');
+    }
+
+    if (status == OK) {
+        if (strcmp("header", sectionName) == 0) {
+            status = dynInterface_parseHeader(intf, stream);
+        } else if (strcmp("annotations", sectionName) == 0) {
+            status = dynInterface_parseAnnotations(intf, stream);
+        } else if (strcmp("types", sectionName) == 0) {
+            status = dynInterface_parseTypes(intf, stream);
+        } else if (strcmp("methods", sectionName) == 0) {
+            status = dynInterface_parseMethods(intf, stream);
+        } else {
+            status = ERROR;
+            LOG_ERROR("unsupported section '%s'", sectionName);
+        }
+    }
+
+    if (sectionName != NULL) {
+        free(sectionName);
+    }
+
+    return status;
+}
+
+static int dynInterface_parseHeader(dyn_interface_type *intf, FILE *stream) {
+    return dynInterface_parseNameValueSection(intf, stream, &intf->header);
+}
+
+static int dynInterface_parseAnnotations(dyn_interface_type *intf, FILE *stream) {
+    return dynInterface_parseNameValueSection(intf, stream, &intf->annotations);
+}
+
+static int dynInterface_parseNameValueSection(dyn_interface_type *intf, FILE *stream, struct namvals_head *head) {
+    int status = OK;
+
+    int peek = fgetc(stream);
+    while (peek != ':' && peek != EOF) {
+        ungetc(peek, stream);
+
+        char *name;
+        char *value;
+        status = dynCommon_parseNameValue(stream, &name, &value);
+
+        if (status == OK) {
+            status = dynCommon_eatChar(stream, '\n');
+        }
+
+        struct namval_entry *entry = NULL;
+        if (status == OK) {
+            entry = calloc(1, sizeof(*entry));
+            if (entry != NULL) {
+                entry->name = name;
+                entry->value = value;
+                TAILQ_INSERT_TAIL(head, entry, entries);
+            } else {
+                status = ERROR;
+                LOG_ERROR("Error allocating memory for namval entry");
+            }
+        }
+
+        if (status != OK) {
+            if (name != NULL) {
+                free(name);
+            }
+            if (value != NULL) {
+                free(value);
+            }
+            break;
+        }
+        peek = fgetc(stream);
+    }
+    ungetc(peek, stream);
+
+    return status;
+}
+
+static int dynInterface_parseTypes(dyn_interface_type *intf, FILE *stream) {
+    int status = OK;
+
+    //expected input (Name)=<Type>\n
+    int peek = fgetc(stream);
+    while (peek != ':' && peek != EOF) {
+        ungetc(peek, stream);
+
+        char *name;
+        status = dynCommon_parseName(stream, &name);
+
+        if (status == OK) {
+            status = dynCommon_eatChar(stream, '=');
+        }
+
+        dyn_type *type = NULL;
+        if (status == OK) {
+            dynType_parse(stream, name, &intf->types, &type);
+        }
+        if (name != NULL) {
+            free(name);
+        }
+
+        if (status == OK) {
+            status = dynCommon_eatChar(stream, '\n');
+        }
+
+        struct type_entry *entry = NULL;
+        if (status == OK) {
+            entry = calloc(1, sizeof(*entry));
+            if (entry != NULL) {
+                entry->type = type;
+                TAILQ_INSERT_TAIL(&intf->types, entry, entries);
+            } else {
+                status = ERROR;
+                LOG_ERROR("Error allocating memory for type entry");
+            }
+        }
+
+        if (status != OK) {
+            if (type != NULL) {
+                dynType_destroy(type);
+            }
+            break;
+        }
+        peek = fgetc(stream);
+    }
+    ungetc(peek, stream);
+
+    return status;
+}
+
+static int dynInterface_parseMethods(dyn_interface_type *intf, FILE *stream) {
+    int status = OK;
+
+    //expected input (Name)=<Method>\n
+    int peek = fgetc(stream);
+    int index = 0;
+    while (peek != ':' && peek != EOF) {
+        ungetc(peek, stream);
+
+        char *id;
+        status = dynCommon_parseNameAlsoAccept(stream, ".();[{}/", &id);
+
+        if (status == OK) {
+            status = dynCommon_eatChar(stream, '=');
+        }
+
+
+        dyn_function_type *func = NULL;
+        if (status == OK) {
+            status = dynFunction_parse(stream, &intf->types, &func);
+        }
+
+        if (status == OK) {
+            status = dynCommon_eatChar(stream, '\n');
+        }
+
+        struct method_entry *entry = NULL;
+        if (status == OK) {
+            entry = calloc(1, sizeof(*entry));
+            if (entry != NULL) {
+                entry->index = index++;
+                entry->id = id;
+                entry->dynFunc = func;
+                entry->name = strndup(id, 1024);
+                if (entry->name != NULL) {
+                    int i;
+                    for (i = 0; i < 1024; i += 1) {
+                        if (entry->name[i] == '\0') {
+                            break;
+                        } else if (entry->name[i] == '(') {
+                            entry->name[i] = '\0';
+                            break;
+                        }
+                    }
+                }
+                TAILQ_INSERT_TAIL(&intf->methods, entry, entries);
+            } else {
+                status = ERROR;
+                LOG_ERROR("Error allocating memory for method entry");
+            }
+        }
+
+        if (status != OK) {
+            if (id != NULL) {
+                free(id);
+            }
+            if (func != NULL) {
+                dynFunction_destroy(func);
+                //TODO free strIdentier, name
+            }
+            break;
+        }
+        peek = fgetc(stream);
+    }
+    ungetc(peek, stream);
+
+    return status;
+}
+
+void dynInterface_destroy(dyn_interface_type *intf) {
+    if (intf != NULL) {
+        dynCommon_clearNamValHead(&intf->header);
+        dynCommon_clearNamValHead(&intf->annotations);
+
+        struct method_entry *mInfo = TAILQ_FIRST(&intf->methods);
+        while (mInfo != NULL) {
+            struct method_entry *mTmp = mInfo;
+            mInfo = TAILQ_NEXT(mInfo, entries);
+            
+            if (mTmp->id != NULL) {
+                free(mTmp->id);
+            }
+            if (mTmp->name != NULL) {
+                free(mTmp->name);
+            }
+            if (mTmp->dynFunc != NULL) {
+                dynFunction_destroy(mTmp->dynFunc);
+            }
+            free(mTmp);
+        }
+
+        struct type_entry *tInfo = TAILQ_FIRST(&intf->types);
+        while (tInfo != NULL) {
+            struct type_entry *tmp = tInfo;
+            tInfo = TAILQ_NEXT(tInfo, entries);
+            dynType_destroy(tmp->type);
+            free(tmp);
+        }
+
+        if(intf->version!=NULL){
+        	version_destroy(intf->version);
+        }
+
+        free(intf);
+    } 
+}
+
+int dynInterface_getName(dyn_interface_type *intf, char **out) {
+    return dynInterface_getEntryForHead(&intf->header, "name", out);
+}
+
+int dynInterface_getVersion(dyn_interface_type* intf , version_pt* version){
+	*version = intf->version;
+	if(*version==NULL){
+		return ERROR;
+	}
+	return OK;
+}
+
+int dynInterface_getVersionString(dyn_interface_type *intf, char **version) {
+    return dynInterface_getEntryForHead(&intf->header, "version", version);
+}
+
+int dynInterface_getHeaderEntry(dyn_interface_type *intf, const char *name, char **value) {
+    return dynInterface_getEntryForHead(&intf->header, name, value);
+}
+
+int dynInterface_getAnnotationEntry(dyn_interface_type *intf, const char *name, char **value) {
+    return dynInterface_getEntryForHead(&intf->annotations, name, value);
+}
+
+static int dynInterface_getEntryForHead(struct namvals_head *head, const char *name, char **out) {
+    int status = OK;
+    char *value = NULL;
+    struct namval_entry *entry = NULL;
+    TAILQ_FOREACH(entry, head, entries) {
+        if (strcmp(name, entry->name) == 0) {
+            value = entry->value;
+            break;
+        }
+    }
+    if (value != NULL) {
+        *out = value;
+    } else {
+        status = ERROR;
+        LOG_WARNING("Cannot find '%s' in list", name);
+    }
+    return status;
+}
+
+int dynInterface_methods(dyn_interface_type *intf, struct methods_head **list) {
+    int status = OK;
+    *list = &intf->methods;
+    return status;
+}
+
+int dynInterface_nrOfMethods(dyn_interface_type *intf) {
+    int count = 0;
+    struct method_entry *entry = NULL;
+    TAILQ_FOREACH(entry, &intf->methods, entries) {
+        count +=1;
+    }
+    return count;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/src/dyn_message.c
----------------------------------------------------------------------
diff --git a/dfi/src/dyn_message.c b/dfi/src/dyn_message.c
new file mode 100644
index 0000000..652be83
--- /dev/null
+++ b/dfi/src/dyn_message.c
@@ -0,0 +1,358 @@
+/**
+ *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.
+ */
+#include "dyn_message.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "dyn_common.h"
+#include "dyn_type.h"
+
+DFI_SETUP_LOG(dynMessage);
+
+struct _dyn_message_type {
+    struct namvals_head header;
+    struct namvals_head annotations;
+    struct types_head types;
+    dyn_type *msgType;
+    version_pt msgVersion;
+};
+
+static const int OK = 0;
+static const int ERROR = 1;
+
+static int dynMessage_parseSection(dyn_message_type *msg, FILE *stream);
+static int dynMessage_parseAnnotations(dyn_message_type *msg, FILE *stream);
+static int dynMessage_parseTypes(dyn_message_type *msg, FILE *stream);
+static int dynMessage_parseMessage(dyn_message_type *msg, FILE *stream);
+static int dynMessage_parseHeader(dyn_message_type *msg, FILE *stream);
+static int dynMessage_parseNameValueSection(dyn_message_type *msg, FILE *stream, struct namvals_head *head);
+static int dynMessage_checkMessage(dyn_message_type *msg);
+static int dynMessage_getEntryForHead(struct namvals_head *head, const char *name, char **value);
+
+int dynMessage_parse(FILE *descriptor, dyn_message_type **out) {
+    int status = OK;
+
+    dyn_message_type *msg = calloc(1, sizeof(*msg));
+    if (msg != NULL) {
+        TAILQ_INIT(&msg->header);
+        TAILQ_INIT(&msg->annotations);
+        TAILQ_INIT(&msg->types);
+
+        char peek = (char)fgetc(descriptor);
+        while (peek == ':') {
+            ungetc(peek, descriptor);
+            status = dynMessage_parseSection(msg, descriptor);
+            if (status == OK) {
+                peek = (char)fgetc(descriptor);
+            } else {
+                break;
+            }
+        }
+
+        if (status == OK) {
+            status = dynCommon_eatChar(descriptor, EOF);
+        }
+
+        if (status == OK) {
+            status = dynMessage_checkMessage(msg);
+        }
+
+        if(status==OK){ /* We are sure that version field is present in the header */
+        	char* version=NULL;
+        	dynMessage_getVersionString(msg,&version);
+        	if(version!=NULL){
+        		status = (version_createVersionFromString(version,&(msg->msgVersion)) == CELIX_SUCCESS)?OK:ERROR;
+        	}
+        	if(status==ERROR){
+        		LOG_ERROR("Invalid version (%s) in parsed descriptor\n",version);
+        	}
+        }
+
+    } else {
+        status = ERROR;
+        LOG_ERROR("Error allocating memory for dynamic message\n");
+    }
+
+    if (status == OK) {
+        *out = msg;
+    } else if (msg != NULL) {
+        LOG_ERROR("Error parsing msg\n");
+        dynMessage_destroy(msg);
+    }
+    return status;
+}
+
+static int dynMessage_checkMessage(dyn_message_type *msg) {
+    int status = OK;
+
+    //check header section
+    if (status == OK) {
+        bool foundType = false;
+        bool foundVersion = false;
+        bool foundName = false;
+        struct namval_entry *entry = NULL;
+        TAILQ_FOREACH(entry, &msg->header, entries) {
+            if (strcmp(entry->name, "type") == 0) {
+                foundType = true;
+            } else if (strcmp(entry->name, "version") == 0) {
+                foundVersion = true;
+            } else if (strcmp(entry->name, "name") == 0) {
+                foundName = true;
+            }
+        }
+
+        if (!foundType || !foundVersion || !foundName) {
+            status = ERROR;
+            LOG_ERROR("Parse Error. There must be a header section with a type, version and name entry");
+        }
+    }
+
+    return status;
+}
+
+static int dynMessage_parseSection(dyn_message_type *msg, FILE *stream) {
+    int status;
+    char *sectionName = NULL;
+
+    status = dynCommon_eatChar(stream, ':');
+
+    if (status == OK) {
+        status = dynCommon_parseName(stream, &sectionName);
+    }
+
+    if (status == OK) {
+        status = dynCommon_eatChar(stream, '\n');
+    }
+
+    if (status == OK) {
+        if (strcmp("header", sectionName) == 0) {
+            status = dynMessage_parseHeader(msg, stream);
+        } else if (strcmp("annotations", sectionName) == 0) {
+            status = dynMessage_parseAnnotations(msg, stream);
+        } else if (strcmp("types", sectionName) == 0) {
+            status = dynMessage_parseTypes(msg, stream);
+        } else if (strcmp("message", sectionName) == 0) {
+            status = dynMessage_parseMessage(msg, stream);
+        } else {
+            status = ERROR;
+            LOG_ERROR("unsupported section '%s'", sectionName);
+        }
+    }
+
+    if (sectionName != NULL) {
+        free(sectionName);
+    }
+
+    return status;
+}
+
+static int dynMessage_parseHeader(dyn_message_type *msg, FILE *stream) {
+    return dynMessage_parseNameValueSection(msg, stream, &msg->header);
+}
+
+static int dynMessage_parseAnnotations(dyn_message_type *msg, FILE *stream) {
+    return dynMessage_parseNameValueSection(msg, stream, &msg->annotations);
+}
+
+static int dynMessage_parseNameValueSection(dyn_message_type *msg, FILE *stream, struct namvals_head *head) {
+    int status = OK;
+
+    int peek = fgetc(stream);
+    while (peek != ':' && peek != EOF) {
+        ungetc(peek, stream);
+
+        char *name;
+        char *value;
+        status = dynCommon_parseNameValue(stream, &name, &value);
+
+        if (status == OK) {
+            status = dynCommon_eatChar(stream, '\n');
+        }
+
+        struct namval_entry *entry = NULL;
+        if (status == OK) {
+            entry = calloc(1, sizeof(*entry));
+            if (entry != NULL) {
+                entry->name = name;
+                entry->value = value;
+                TAILQ_INSERT_TAIL(head, entry, entries);
+            } else {
+                status = ERROR;
+                LOG_ERROR("Error allocating memory for namval entry");
+            }
+        }
+
+        if (status != OK) {
+            if (name != NULL) {
+                free(name);
+            }
+            if (value != NULL) {
+                free(value);
+            }
+            break;
+        }
+        peek = fgetc(stream);
+    }
+    ungetc(peek, stream);
+
+    return status;
+}
+
+static int dynMessage_parseTypes(dyn_message_type *msg, FILE *stream) {
+    int status = OK;
+
+    //expected input (Name)=<Type>\n
+    int peek = fgetc(stream);
+    while (peek != ':' && peek != EOF) {
+        ungetc(peek, stream);
+
+        char *name = NULL;
+        status = dynCommon_parseName(stream, &name);
+
+        if (status == OK) {
+            status = dynCommon_eatChar(stream, '=');
+        }
+
+        dyn_type *type = NULL;
+        if (status == OK) {
+            status = dynType_parse(stream, name, &msg->types, &type);
+        }
+
+        if (status == OK) {
+            status = dynCommon_eatChar(stream, '\n');
+        }
+
+        struct type_entry *entry = NULL;
+        if (status == OK) {
+            entry = calloc(1, sizeof(*entry));
+            if (entry != NULL) {
+                LOG_DEBUG("Adding type '%s' with pointer %p to types", name, type);
+                entry->type = type;
+                TAILQ_INSERT_TAIL(&msg->types, entry, entries);
+            } else {
+                status = ERROR;
+                LOG_ERROR("Error allocating memory for type entry");
+            }
+        }
+
+        if (name != NULL) {
+            free(name);
+        }
+
+        if (status != OK) {
+            if (type != NULL) {
+                dynType_destroy(type);
+            }
+            break;
+        }
+        peek = fgetc(stream);
+    }
+    ungetc(peek, stream);
+
+    return status;
+}
+
+static int dynMessage_parseMessage(dyn_message_type *msg, FILE *stream) {
+    int status;
+
+    //expected input <dynType>\n
+    char *name = NULL;
+    status = dynMessage_getName(msg, &name);
+
+    if (status == OK) {
+    	status = dynType_parse(stream, name, &(msg->types), &(msg->msgType));
+    }
+
+    return status;
+}
+
+void dynMessage_destroy(dyn_message_type *msg) {
+    if (msg != NULL) {
+        dynCommon_clearNamValHead(&msg->header);
+        dynCommon_clearNamValHead(&msg->annotations);
+
+        struct type_entry *tInfo = TAILQ_FIRST(&msg->types);
+        while (tInfo != NULL) {
+            struct type_entry *tmp = tInfo;
+            tInfo = TAILQ_NEXT(tInfo, entries);
+            dynType_destroy(tmp->type);
+            free(tmp);
+        }
+
+        if (msg->msgType != NULL) {
+        	dynType_destroy(msg->msgType);
+        }
+
+        if(msg->msgVersion != NULL){
+        	version_destroy(msg->msgVersion);
+        }
+
+        free(msg);
+    } 
+}
+
+int dynMessage_getName(dyn_message_type *msg, char **out) {
+    return dynMessage_getEntryForHead(&msg->header, "name", out);
+}
+
+int dynMessage_getVersion(dyn_message_type *msg, version_pt* version){
+	*version = msg->msgVersion;
+	if(*version==NULL){
+		return ERROR;
+	}
+	return OK;
+}
+
+int dynMessage_getVersionString(dyn_message_type *msg, char **version) {
+    return dynMessage_getEntryForHead(&msg->header, "version", version);
+}
+
+int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value) {
+    return dynMessage_getEntryForHead(&msg->header, name, value);
+}
+
+int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value) {
+    return dynMessage_getEntryForHead(&msg->annotations, name, value);
+}
+
+static int dynMessage_getEntryForHead(struct namvals_head *head, const char *name, char **out) {
+    int status = OK;
+    char *value = NULL;
+    struct namval_entry *entry = NULL;
+    TAILQ_FOREACH(entry, head, entries) {
+        if (strcmp(name, entry->name) == 0) {
+            value = entry->value;
+            break;
+        }
+    }
+    if (value != NULL) {
+        *out = value;
+    } else {
+        status = ERROR;
+        LOG_WARNING("Cannot find '%s' in list", name);
+    }
+    return status;
+}
+
+int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type) {
+	int status = OK;
+	*type = msg->msgType;
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/src/dyn_type.c
----------------------------------------------------------------------
diff --git a/dfi/src/dyn_type.c b/dfi/src/dyn_type.c
new file mode 100644
index 0000000..4fc79ff
--- /dev/null
+++ b/dfi/src/dyn_type.c
@@ -0,0 +1,1160 @@
+/**
+ *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.
+ */
+#include "dyn_type.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+#include <ffi.h>
+
+#include "dyn_common.h"
+
+DFI_SETUP_LOG(dynType)
+
+static int dynType_parseWithStream(FILE *stream, const char *name, dyn_type *parent, struct types_head *refTypes, dyn_type **result);
+static void dynType_clear(dyn_type *type);
+static void dynType_clearComplex(dyn_type *type);
+static void dynType_clearSequence(dyn_type *type);
+static void dynType_clearTypedPointer(dyn_type *type);
+ffi_type * dynType_ffiType(dyn_type *type);
+
+static struct type_entry *dynType_allocTypeEntry(void);
+
+static ffi_type * dynType_ffiTypeFor(int c);
+static dyn_type * dynType_findType(dyn_type *type, char *name);
+static int dynType_parseAny(FILE *stream, dyn_type *type);
+static int dynType_parseComplex(FILE *stream, dyn_type *type);
+static int dynType_parseNestedType(FILE *stream, dyn_type *type);
+static int dynType_parseReference(FILE *stream, dyn_type *type);
+static int dynType_parseRefByValue(FILE *stream, dyn_type *type);
+static int dynType_parseSequence(FILE *stream, dyn_type *type);
+static int dynType_parseSimple(int c, dyn_type *type);
+static int dynType_parseTypedPointer(FILE *stream, dyn_type *type);
+static void dynType_prepCif(ffi_type *type);
+static unsigned short dynType_getOffset(dyn_type *type, int index);
+
+static void dynType_printAny(char *name, dyn_type *type, int depth, FILE *stream);
+static void dynType_printComplex(char *name, dyn_type *type, int depth, FILE *stream);
+static void dynType_printSequence(char *name, dyn_type *type, int depth, FILE *stream);
+static void dynType_printSimple(char *name, dyn_type *type, int depth, FILE *stream);
+static void dynType_printTypedPointer(char *name, dyn_type *type, int depth, FILE *stream);
+static void dynType_printDepth(int depth, FILE *stream);
+
+static void dynType_printTypes(dyn_type *type, FILE *stream);
+static void dynType_printComplexType(dyn_type *type, FILE *stream);
+static void dynType_printSimpleType(dyn_type *type, FILE *stream);
+
+static int dynType_parseText(FILE *stream, dyn_type *type);
+void dynType_freeComplexType(dyn_type *type, void *loc);
+void dynType_deepFree(dyn_type *type, void *loc, bool alsoDeleteSelf);
+void dynType_freeSequenceType(dyn_type *type, void *seqLoc);
+
+static int dynType_parseMetaInfo(FILE *stream, dyn_type *type);
+
+struct generic_sequence {
+    uint32_t cap;
+    uint32_t len;
+    void *buf;
+};
+
+TAILQ_HEAD(meta_properties_head, meta_entry);
+struct meta_entry {
+    char *name;
+    char *value;
+    TAILQ_ENTRY(meta_entry) entries;
+};
+
+
+struct _dyn_type {
+    char *name;
+    char descriptor;
+    int type;
+    ffi_type *ffiType;
+    dyn_type *parent;
+    struct types_head *referenceTypes; //NOTE: not owned
+    struct types_head nestedTypesHead;
+    struct meta_properties_head metaProperties;
+    union {
+        struct {
+            struct complex_type_entries_head entriesHead;
+            ffi_type structType; //dyn_type.ffiType points to this
+            dyn_type **types; //based on entriesHead for fast access
+        } complex;
+        struct {
+            ffi_type seqType; //dyn_type.ffiType points to this
+            dyn_type *itemType;
+        } sequence;
+        struct {
+            dyn_type *typedType;
+        } typedPointer;
+        struct {
+            dyn_type *ref;
+        } ref;
+    };
+};
+
+static const int OK = 0;
+static const int ERROR = 1;
+static const int MEM_ERROR = 2;
+static const int PARSE_ERROR = 3;
+
+int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *refTypes, dyn_type **type) {
+    return dynType_parseWithStream(descriptorStream, name, NULL, refTypes, type);
+}
+
+int dynType_parseWithStr(const char *descriptor, const char *name, struct types_head *refTypes, dyn_type **type) {
+    int status = OK;
+    FILE *stream = fmemopen((char *)descriptor, strlen(descriptor), "r");
+    if (stream != NULL) {
+        status = dynType_parseWithStream(stream, name, NULL, refTypes, type);
+        if (status == OK) {
+            int c = fgetc(stream);
+            if (c != '\0' && c != EOF) {
+                status = PARSE_ERROR;
+                LOG_ERROR("Expected EOF got %c", c);
+            }
+        } 
+        fclose(stream);
+    } else {
+        status = ERROR;
+        LOG_ERROR("Error creating mem stream for descriptor string. %s", strerror(errno)); 
+    }
+    return status;
+}
+
+static int dynType_parseWithStream(FILE *stream, const char *name, dyn_type *parent, struct types_head *refTypes, dyn_type **result) {
+    int status = OK;
+    dyn_type *type = calloc(1, sizeof(*type));
+    if (type != NULL) {
+        type->parent = parent;
+        type->type = DYN_TYPE_INVALID;
+        type->referenceTypes = refTypes;
+        TAILQ_INIT(&type->nestedTypesHead);
+        TAILQ_INIT(&type->metaProperties);
+        if (name != NULL) {
+            type->name = strdup(name);
+            if (type->name == NULL) {
+                status = MEM_ERROR;
+                LOG_ERROR("Error strdup'ing name '%s'\n", name);			
+            } 
+        }
+        if (status == OK) {
+            status = dynType_parseAny(stream, type);        
+        }
+        if (status == OK) {
+            *result = type;
+        } else {
+            dynType_destroy(type);
+        }
+    } else {
+        status = MEM_ERROR;
+        LOG_ERROR("Error allocating memory for type");
+    }
+    return status;
+}
+
+static int dynType_parseAny(FILE *stream, dyn_type *type) {
+    int status = OK;
+
+    int c = fgetc(stream);
+    switch(c) {
+        case 'T' :
+            status = dynType_parseNestedType(stream, type);
+            if (status == OK) {
+                status = dynType_parseAny(stream, type);
+            } 
+            break;
+        case 'L' :
+            status = dynType_parseReference(stream, type);
+            break;
+        case 'l' :
+            status = dynType_parseRefByValue(stream, type);
+            break;
+        case '{' :
+            status = dynType_parseComplex(stream, type);
+            break;
+        case '[' :
+            status = dynType_parseSequence(stream, type);
+            break;
+        case '*' :
+            status = dynType_parseTypedPointer(stream, type);
+            break;
+        case 't' :
+            status = dynType_parseText(stream, type);
+            break;
+        case '#' :
+            status = dynType_parseMetaInfo(stream, type);
+            if (status == OK) {
+                status = dynType_parseAny(stream, type);
+            }
+            break;
+        default :
+            status = dynType_parseSimple(c, type);
+            break;
+    }
+
+    return status;
+}
+
+static int dynType_parseMetaInfo(FILE *stream, dyn_type *type) {
+    int status = OK;
+    char *name = NULL;
+    char *value = NULL;
+
+    struct meta_entry *entry = calloc(1, sizeof(*entry));
+    if (entry == NULL) {
+        status = ERROR;
+    }
+
+    if (status == OK) {
+        status = dynCommon_parseName(stream, &name);
+    }
+
+    if (status == OK) {
+        status = dynCommon_eatChar(stream, '=');
+    }
+
+    if (status == OK) {
+        status = dynCommon_parseName(stream, &value);
+    }
+
+    if (status == OK) {
+        status = dynCommon_eatChar(stream, ';');
+    }
+
+    if (status == OK) {
+        entry->name = name;
+        entry->value = value;
+        TAILQ_INSERT_TAIL(&type->metaProperties, entry, entries);
+        LOG_DEBUG("Added meta properties '%s':'%s'", name, value)
+    } else {
+        free(name);
+        free(value);
+        free(entry);
+    }
+
+    return status;
+}
+
+static int dynType_parseText(FILE *stream, dyn_type *type) {
+    int status = OK;
+    type->type = DYN_TYPE_TEXT;
+    type->descriptor = 't';
+    type->ffiType = &ffi_type_pointer;
+    return status;
+}
+
+static int dynType_parseComplex(FILE *stream, dyn_type *type) {
+    int status = OK;
+    type->type = DYN_TYPE_COMPLEX;
+    type->descriptor = '{';
+    type->ffiType = &type->complex.structType;
+    TAILQ_INIT(&type->complex.entriesHead);
+
+    int c = fgetc(stream);
+    struct complex_type_entry *entry = NULL;
+    while (c != ' ' && c != '}') {
+        ungetc(c,stream);
+        entry = calloc(1, sizeof(*entry));
+        if (entry != NULL) {
+            entry->type = calloc(1, sizeof(*entry->type));
+        }
+        if (entry != NULL && entry->type != NULL) {
+            entry->type->parent = type;
+            entry->type->type = DYN_TYPE_INVALID;
+            TAILQ_INIT(&entry->type->nestedTypesHead);
+            TAILQ_INIT(&entry->type->metaProperties);
+            TAILQ_INSERT_TAIL(&type->complex.entriesHead, entry, entries);
+            status = dynType_parseAny(stream, entry->type);
+        } else {
+            free(entry);
+            status = MEM_ERROR;
+            LOG_ERROR("Error allocating memory for type");
+        }
+
+        if (status != OK) {
+            break;
+        }
+
+        c = fgetc(stream);
+    }
+
+
+    if (status == OK) {
+        entry = TAILQ_FIRST(&type->complex.entriesHead);
+        char *name = NULL;
+        while (c == ' ' && entry != NULL) {
+            status = dynCommon_parseName(stream, &name);
+            if (status == OK) {
+                entry->name = name;
+                entry = TAILQ_NEXT(entry, entries);
+            } else {
+                break;
+            }
+            c = getc(stream); 
+        }
+    }
+
+    int count = 0;
+    if (status == OK) {
+        TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
+            count +=1;
+        }
+    }
+
+    if (status == OK) {
+        type->complex.structType.type =  FFI_TYPE_STRUCT;
+        type->complex.structType.elements = calloc(count + 1, sizeof(ffi_type*));
+        if (type->complex.structType.elements != NULL) {
+            type->complex.structType.elements[count] = NULL;
+            int index = 0;
+            TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
+                type->complex.structType.elements[index++] = dynType_ffiType(entry->type);
+            }
+        } else {
+            status = MEM_ERROR;
+            LOG_ERROR("Error allocating memory for elements")
+        }
+    }
+
+    if (status == OK) {
+        type->complex.types = calloc(count, sizeof(dyn_type *));
+        if (type->complex.types != NULL) {
+            int index = 0;
+            TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
+                type->complex.types[index++] = entry->type;
+            }
+        } else {
+            status = MEM_ERROR;
+            LOG_ERROR("Error allocating memory for type")
+        }
+    }
+
+    if (status == OK) {
+        dynType_prepCif(type->ffiType);
+    }
+
+
+    return status;
+}
+
+static int dynType_parseNestedType(FILE *stream, dyn_type *type) {
+    int status = OK;
+    char *name = NULL;
+    struct type_entry *entry = NULL;
+
+    entry = dynType_allocTypeEntry();
+    if (entry != NULL) {
+        entry->type->parent = type;
+        entry->type->type = DYN_TYPE_INVALID;
+        TAILQ_INIT(&entry->type->nestedTypesHead);
+        TAILQ_INIT(&entry->type->metaProperties);
+        TAILQ_INSERT_TAIL(&type->nestedTypesHead, entry, entries);
+        status = dynCommon_parseName(stream, &name);
+        entry->type->name = name;
+    } else {
+        status = MEM_ERROR;
+        LOG_ERROR("Error allocating entry");
+    }     
+
+    if (status == OK) {
+        int c = fgetc(stream);
+        if (c != '=') {
+            status = PARSE_ERROR;
+            LOG_ERROR("Error parsing nested type expected '=' got '%c'", c);
+        }
+    }
+
+    if (status == OK) {
+        status = dynType_parseAny(stream, entry->type);
+        int c = fgetc(stream);
+        if (c != ';') {
+            status = PARSE_ERROR;
+            LOG_ERROR("Expected ';' got '%c'\n", c);
+        }
+    }
+
+    return status;
+}
+
+static int dynType_parseReference(FILE *stream, dyn_type *type) {
+    int status = OK;
+    type->type = DYN_TYPE_TYPED_POINTER;
+    type->descriptor = '*';
+
+    type->ffiType = &ffi_type_pointer;
+    type->typedPointer.typedType =  NULL;
+
+    dyn_type *subType = calloc(1, sizeof(*subType));
+
+    if (subType != NULL) {
+        type->typedPointer.typedType = subType;
+        subType->parent = type;
+        subType->type = DYN_TYPE_INVALID;
+        TAILQ_INIT(&subType->nestedTypesHead);
+        TAILQ_INIT(&subType->metaProperties);
+        status = dynType_parseRefByValue(stream, subType);
+    } else {
+        status = MEM_ERROR;
+        LOG_ERROR("Error allocating memory for subtype\n");
+    }
+
+    return status;
+}
+
+static int dynType_parseRefByValue(FILE *stream, dyn_type *type) {
+    int status = OK;
+    type->type = DYN_TYPE_REF;
+    type->descriptor = 'l';
+
+    char *name = NULL;
+    status = dynCommon_parseName(stream, &name);
+    if (status == OK) {
+        dyn_type *ref = dynType_findType(type, name);
+        if (ref != NULL) {
+            type->ref.ref = ref;
+        } else {
+            status = PARSE_ERROR;
+            LOG_ERROR("Error cannot find type '%s'", name);
+        }
+        free(name);
+    } 
+
+    if (status ==OK) {
+        int c = fgetc(stream);
+        if (c != ';') {
+            status = PARSE_ERROR;
+            LOG_ERROR("Error expected ';' got '%c'", c);
+        } 
+    }
+
+    return status;
+}
+
+static struct type_entry *dynType_allocTypeEntry(void) {
+    struct type_entry *entry = calloc(1, sizeof(*entry));
+    if (entry != NULL) {
+        entry->type = calloc(1, sizeof(*entry->type));
+        if (entry->type == NULL) {
+            free(entry);
+            entry = NULL;
+        }
+    }
+    return entry;
+}
+
+static ffi_type *seq_types[] = {&ffi_type_uint32, &ffi_type_uint32, &ffi_type_pointer, NULL};
+
+static int dynType_parseSequence(FILE *stream, dyn_type *type) {
+    int status = OK;
+    type->type = DYN_TYPE_SEQUENCE;
+    type->descriptor = '[';
+
+    type->sequence.seqType.elements = seq_types;
+    type->sequence.seqType.type = FFI_TYPE_STRUCT;
+    type->sequence.seqType.size = 0;
+    type->sequence.seqType.alignment = 0;
+
+    status = dynType_parseWithStream(stream, NULL, type, NULL, &type->sequence.itemType);
+
+    if (status == OK) {
+        type->ffiType = &type->sequence.seqType;
+        dynType_prepCif(&type->sequence.seqType);
+    }
+
+    return status;
+}
+
+static int dynType_parseSimple(int c, dyn_type *type) {
+    int status = OK;
+    ffi_type *ffiType = dynType_ffiTypeFor(c);
+    if (ffiType != NULL) {
+        type->type = DYN_TYPE_SIMPLE;
+        type->descriptor = c;
+        type->ffiType = ffiType;
+    } else {
+        status = PARSE_ERROR;
+        LOG_ERROR("Error unsupported type '%c'", c);
+    }
+
+    return status;
+}
+
+static int dynType_parseTypedPointer(FILE *stream, dyn_type *type) {
+    int status = OK;
+    type->type = DYN_TYPE_TYPED_POINTER;
+    type->descriptor = '*';
+    type->ffiType = &ffi_type_pointer;
+
+    status = dynType_parseWithStream(stream, NULL, type, NULL, &type->typedPointer.typedType);
+
+    return status;
+}
+
+static void dynType_prepCif(ffi_type *type) {
+    ffi_cif cif;
+    ffi_type *args[1];
+    args[0] = type;
+    ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint, args);
+}
+
+void dynType_destroy(dyn_type *type) {
+    if (type != NULL) {          
+        dynType_clear(type);
+        free(type);
+    }
+}
+
+static void dynType_clear(dyn_type *type) {
+    struct type_entry *entry = TAILQ_FIRST(&type->nestedTypesHead);
+    struct type_entry *tmp = NULL;
+    while (entry != NULL) {
+        tmp = entry;
+        entry = TAILQ_NEXT(entry, entries);
+        if (tmp->type != NULL) {
+            dynType_destroy(tmp->type);
+            tmp->type = NULL;
+        }
+        free(tmp);
+    }
+
+    struct meta_entry *mEntry = TAILQ_FIRST(&type->metaProperties);;
+    struct meta_entry *next = NULL;
+    while (mEntry != NULL) {
+        next = TAILQ_NEXT(mEntry, entries);
+        if (mEntry != NULL) {
+            free(mEntry->name);
+            free(mEntry->value);
+            free(mEntry);
+        }
+        mEntry = next;
+    }
+
+    switch (type->type) {
+        case DYN_TYPE_COMPLEX :
+            dynType_clearComplex(type);
+            break;
+        case DYN_TYPE_SEQUENCE :
+            dynType_clearSequence(type);
+            break;
+        case DYN_TYPE_TYPED_POINTER :
+            dynType_clearTypedPointer(type);
+            break;
+    } 
+
+    if (type->name != NULL) {
+        free(type->name);
+    }
+}
+
+static void dynType_clearComplex(dyn_type *type) {
+    assert(type->type == DYN_TYPE_COMPLEX);
+    struct complex_type_entry *entry = TAILQ_FIRST(&type->complex.entriesHead);
+    struct complex_type_entry *tmp = NULL;
+    while (entry != NULL) {
+        dynType_destroy(entry->type);
+        if (entry->name != NULL) {
+            free(entry->name);
+        }
+        tmp = entry;
+        entry = TAILQ_NEXT(entry, entries);
+        free(tmp);
+    }
+    if (type->complex.types != NULL) {
+        free(type->complex.types);
+    }
+    if (type->complex.structType.elements != NULL) {
+        free(type->complex.structType.elements);
+    }
+}
+
+static void dynType_clearSequence(dyn_type *type) {
+    assert(type->type == DYN_TYPE_SEQUENCE);
+    if (type->sequence.itemType != NULL) {
+        dynType_destroy(type->sequence.itemType);
+    }
+}
+
+static void dynType_clearTypedPointer(dyn_type *type) {
+    assert(type->type == DYN_TYPE_TYPED_POINTER);
+    if (type->typedPointer.typedType != NULL) {
+        dynType_destroy(type->typedPointer.typedType);
+    }
+}
+
+int dynType_alloc(dyn_type *type, void **bufLoc) {
+    assert(type->type != DYN_TYPE_REF);
+    assert(type->ffiType->size != 0);
+    int status = OK;
+
+    void *inst = calloc(1, type->ffiType->size);
+    if (inst != NULL) {
+        if (type->type == DYN_TYPE_TYPED_POINTER) {
+            void *ptr = NULL;
+            dyn_type *sub = NULL;
+            status = dynType_typedPointer_getTypedType(type, &sub);
+            if (status == OK) {
+                status = dynType_alloc(sub, &ptr);
+                if (status == OK) {
+                    *(void **)inst = ptr;
+                }
+            }
+        }
+        *bufLoc = inst;
+    } else {
+        status = MEM_ERROR;
+        LOG_ERROR("Error allocating memory for type '%c'", type->descriptor);
+    }
+
+    return status;
+}
+
+
+int dynType_complex_indexForName(dyn_type *type, const char *name) {
+    assert(type->type == DYN_TYPE_COMPLEX);
+    int i = 0;
+    int index = -1;
+    struct complex_type_entry *entry = NULL;
+    TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
+        if (strcmp(name, entry->name) == 0) {
+            index = i;
+        }
+        i +=1;
+    }
+    return index;
+}
+
+int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **result) {
+    assert(type->type == DYN_TYPE_COMPLEX);
+    assert(index >= 0);
+    dyn_type *sub = type->complex.types[index];
+    if (sub->type == DYN_TYPE_REF) {
+        sub = sub->ref.ref;
+    }
+    *result = sub;
+    return 0;
+}
+
+int dynType_complex_setValueAt(dyn_type *type, int index, void *start, void *in) {
+    assert(type->type == DYN_TYPE_COMPLEX);
+    char *loc = ((char *)start) + dynType_getOffset(type, index);
+    size_t size = type->complex.structType.elements[index]->size;
+    memcpy(loc, in, size);
+    return 0;
+}
+
+int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **result) {
+    assert(type->type == DYN_TYPE_COMPLEX);
+    char *l = (char *)inst;
+    void *loc = (void *)(l + dynType_getOffset(type, index));
+    *result = loc;
+    return OK;
+}
+
+int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries) {
+    assert(type->type == DYN_TYPE_COMPLEX);
+    int status = OK;
+    *entries = &type->complex.entriesHead;
+    return status;
+}
+
+//sequence
+int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap) {
+    assert(type->type == DYN_TYPE_SEQUENCE);
+    int status = OK;
+    struct generic_sequence *seq = inst;
+    if (seq != NULL) {
+        size_t size = dynType_size(type->sequence.itemType);
+        seq->buf = calloc(cap, size);
+        if (seq->buf != NULL) {
+            seq->cap = cap;
+            seq->len = 0;;
+        } else {
+            seq->cap = 0;
+            status = MEM_ERROR;
+            LOG_ERROR("Error allocating memory for buf")
+        }
+    } else {
+            status = MEM_ERROR;
+            LOG_ERROR("Error allocating memory for seq")
+    }
+    return status;
+}
+
+void dynType_free(dyn_type *type, void *loc) {
+    dynType_deepFree(type, loc, true);
+}
+
+void dynType_deepFree(dyn_type *type, void *loc, bool alsoDeleteSelf) {
+    if (loc != NULL) {
+        dyn_type *subType = NULL;
+        char *text = NULL;
+        switch (type->type) {
+            case DYN_TYPE_COMPLEX :
+                dynType_freeComplexType(type, loc);
+                break;
+            case DYN_TYPE_SEQUENCE :
+                dynType_freeSequenceType(type, loc);
+                break;
+            case DYN_TYPE_TYPED_POINTER:
+                dynType_typedPointer_getTypedType(type, &subType);
+                dynType_deepFree(subType, *(void **)loc, true);
+                break;
+            case DYN_TYPE_TEXT :
+                text = *(char **)loc;
+                free(text);
+                break;
+        }
+
+        if (alsoDeleteSelf) {
+            free(loc);
+        }
+    }
+}
+
+void dynType_freeSequenceType(dyn_type *type, void *seqLoc) {
+    struct generic_sequence *seq = seqLoc;
+    dyn_type *itemType = dynType_sequence_itemType(type);
+    void *itemLoc = NULL;
+    int i;
+    for (i = 0; i < seq->len; i += 1) {
+        dynType_sequence_locForIndex(type, seqLoc, i, &itemLoc);
+        dynType_deepFree(itemType, itemLoc, false);
+    }
+    free(seq->buf);
+}
+
+void dynType_freeComplexType(dyn_type *type, void *loc) {
+    struct complex_type_entry *entry = NULL;
+    int index = 0;
+    void *entryLoc = NULL;
+    TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
+        dynType_complex_valLocAt(type, index++, loc, &entryLoc);
+        dynType_deepFree(entry->type, entryLoc, false);
+    }
+}
+
+
+uint32_t dynType_sequence_length(void *seqLoc) {
+    struct generic_sequence *seq = seqLoc;
+    return seq->len;
+}
+
+int dynType_sequence_locForIndex(dyn_type *type, void *seqLoc, int index, void **out) {
+    assert(type->type == DYN_TYPE_SEQUENCE);
+    int status = OK;
+
+    struct generic_sequence *seq = seqLoc;
+    char *valLoc = seq->buf;
+
+    size_t itemSize = dynType_size(type->sequence.itemType);
+
+    if (index >= seq->cap) {
+        status = ERROR;
+        LOG_ERROR("Requested index (%i) is greater than capacity (%u) of sequence", index, seq->cap);
+    }
+
+    if (index >= seq->len) {
+        LOG_WARNING("Requesting index (%i) outsize defined length (%u) but within capacity", index, seq->len);
+    }
+
+    if (status == OK) { }
+    int i;
+    for (i = 0; i < seq->cap; i += 1) {
+        if (index == i) {
+            break;
+        } else {
+            valLoc += itemSize;
+        }
+    }
+
+    (*out) = valLoc;
+
+    return status;
+}
+
+int dynType_sequence_increaseLengthAndReturnLastLoc(dyn_type *type, void *seqLoc, void **valLoc) {
+    assert(type->type == DYN_TYPE_SEQUENCE);
+    int status = OK;
+    struct generic_sequence *seq = seqLoc;
+
+    int lastIndex = seq->len;
+    if (seq->len < seq->cap) {
+        seq->len += 1;
+    } else {
+        status = ERROR;
+        LOG_ERROR("Cannot increase sequence length beyond capacity (%u)", seq->cap);
+    }
+
+    if (status == OK) {
+        status = dynType_sequence_locForIndex(type, seqLoc, lastIndex, valLoc);
+    }
+
+    return status;
+}
+
+dyn_type * dynType_sequence_itemType(dyn_type *type) {
+    assert(type->type == DYN_TYPE_SEQUENCE);
+    dyn_type *itemType = type->sequence.itemType;
+    if (itemType->type == DYN_TYPE_REF) {
+        itemType = itemType->ref.ref;
+    }
+    return itemType;
+}
+
+void dynType_simple_setValue(dyn_type *type, void *inst, void *in) {
+    size_t size = dynType_size(type);
+    memcpy(inst, in, size);
+}
+
+
+int dynType_descriptorType(dyn_type *type) {
+    return type->descriptor;
+}
+
+const char * dynType_getMetaInfo(dyn_type *type, const char *name) {
+    const char *result = NULL;
+    struct meta_entry *entry = NULL;
+    TAILQ_FOREACH(entry, &type->metaProperties, entries) {
+        LOG_DEBUG("Checking '%s'", entry->name);
+        if (strcmp(entry->name, name) == 0) {
+            result = entry->value;
+            break;
+        }
+    }
+    return result;
+}
+
+ffi_type *dynType_ffiType(dyn_type *type) {
+    if (type->type == DYN_TYPE_REF) {
+        if (type->ref.ref == NULL) {
+            LOG_ERROR("Error. Ref for %s is not (yet) initialized", type->name);
+            return NULL;
+        }
+        return type->ref.ref->ffiType;
+    }
+    return type->ffiType;
+}
+
+static ffi_type * dynType_ffiTypeFor(int c) {
+    ffi_type *type = NULL;
+    switch (c) {
+        case 'Z' :
+            type = &ffi_type_uint8;
+            break;
+        case 'F' :
+            type = &ffi_type_float;
+            break;
+        case 'D' :
+            type = &ffi_type_double;
+            break;
+        case 'B' :
+            type = &ffi_type_sint8;
+            break;
+        case 'b' :
+            type = &ffi_type_uint8;
+            break;
+        case 'S' :
+            type = &ffi_type_sint16;
+            break;
+        case 's' :
+            type = &ffi_type_uint16;
+            break;
+        case 'I' :
+            type = &ffi_type_sint32;
+            break;
+        case 'i' :
+            type = &ffi_type_uint32;
+            break;
+        case 'J' :
+            type = &ffi_type_sint64;
+            break;
+        case 'j' :
+            type = &ffi_type_sint64;
+            break;
+        case 'N' :
+            type = &ffi_type_sint;
+            break;
+        case 'P' :
+            type = &ffi_type_pointer;
+            break;
+        case 'V' :
+            type = &ffi_type_void;
+            break;
+    }
+    return type;
+}
+
+static dyn_type * dynType_findType(dyn_type *type, char *name) {
+    dyn_type *result = NULL;
+
+    struct type_entry *entry = NULL;
+    if (type->referenceTypes != NULL) {
+        TAILQ_FOREACH(entry, type->referenceTypes, entries) {
+            LOG_DEBUG("checking ref type '%s' with name '%s'", entry->type->name, name);
+            if (strcmp(name, entry->type->name) == 0) {
+                result = entry->type;
+                break;
+            }
+        }
+    }
+
+    if (result == NULL) {
+        struct type_entry *nEntry = NULL;
+        TAILQ_FOREACH(nEntry, &type->nestedTypesHead, entries) {
+            LOG_DEBUG("checking nested type '%s' with name '%s'", nEntry->type->name, name);
+            if (strcmp(name, nEntry->type->name) == 0) {
+                result = nEntry->type;
+                break;
+            }
+        }
+    }
+
+    if (result == NULL && type->parent != NULL) {
+        result = dynType_findType(type->parent, name);
+    }
+
+    return result;
+}
+
+static unsigned short dynType_getOffset(dyn_type *type, int index) {
+    assert(type->type == DYN_TYPE_COMPLEX);
+    unsigned short offset = 0;
+
+    ffi_type *ffiType = &type->complex.structType;
+    int i;
+    for (i = 0;  i <= index && ffiType->elements[i] != NULL; i += 1) {
+        size_t size = ffiType->elements[i]->size;
+        unsigned short alignment = ffiType->elements[i]->alignment;
+        int alignment_diff = offset % alignment;
+        if (alignment_diff > 0) {
+            offset += (alignment - alignment_diff);
+        }
+        if (i < index) {
+            offset += size;
+        }
+    }
+
+    return offset;
+}
+
+size_t dynType_size(dyn_type *type) {
+    dyn_type *rType = type;
+    if (type->type == DYN_TYPE_REF) {
+        rType = type->ref.ref;
+    }
+    return rType->ffiType->size;
+}
+
+int dynType_type(dyn_type *type) {
+    return type->type;
+}
+
+
+int dynType_typedPointer_getTypedType(dyn_type *type, dyn_type **out) {
+    assert(type->type == DYN_TYPE_TYPED_POINTER);
+    int status = 0;
+
+    dyn_type *typedType = type->typedPointer.typedType;
+    if (typedType->type == DYN_TYPE_REF) {
+        typedType = typedType->ref.ref;
+    }
+
+    *out = typedType;
+    return status;
+}
+
+
+int dynType_text_allocAndInit(dyn_type *type, void *textLoc, const char *value) {
+    assert(type->type == DYN_TYPE_TEXT);
+    int status = 0;
+    const char *str = strdup(value);
+    char const **loc = textLoc;
+    if (str != NULL) {
+        *loc = str;
+    } else {
+        status = ERROR;
+        LOG_ERROR("Cannot allocate memory for string");
+    }
+    return status;
+}
+
+
+
+
+
+void dynType_print(dyn_type *type, FILE *stream) {
+    if (type != NULL) {
+        dynType_printTypes(type, stream);
+
+        fprintf(stream, "main type:\n");
+        dynType_printAny("root", type, 0, stream);
+    } else {
+        fprintf(stream, "invalid type\n");
+    }
+}
+
+static void dynType_printDepth(int depth, FILE *stream) {
+    int i;
+    for (i = 0; i < depth; i +=1 ) {
+        fprintf(stream, "\t");
+    }
+}
+
+static void dynType_printAny(char *name, dyn_type *type, int depth, FILE *stream) {
+    dyn_type *toPrint = type;
+    if (toPrint->type == DYN_TYPE_REF) {
+        toPrint = toPrint->ref.ref;
+    }
+    switch(toPrint->type) {
+        case DYN_TYPE_COMPLEX :
+            dynType_printComplex(name, toPrint, depth, stream);
+            break;
+        case DYN_TYPE_SIMPLE :
+            dynType_printSimple(name, toPrint, depth, stream);
+            break;
+        case DYN_TYPE_SEQUENCE :
+            dynType_printSequence(name, toPrint, depth, stream);
+            break;
+        case DYN_TYPE_TYPED_POINTER :
+            dynType_printTypedPointer(name, toPrint, depth, stream);
+            break;
+        default :
+            fprintf(stream, "TODO Unsupported type %i\n", toPrint->type);
+            break;
+    }
+}
+
+static void dynType_printComplex(char *name, dyn_type *type, int depth, FILE *stream) {
+    if (type->name == NULL) {
+        dynType_printDepth(depth, stream);
+        fprintf(stream, "%s: complex type (anon), size is %zu, alignment is %i, descriptor is '%c'. fields:\n", name,  type->ffiType->size, type->ffiType->alignment, type->descriptor);
+
+        struct complex_type_entry *entry = NULL;
+        TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
+            dynType_printAny(entry->name, entry->type, depth + 1, stream);
+        }
+
+        dynType_printDepth(depth, stream);
+        fprintf(stream, "}\n");
+    } else {
+        dynType_printDepth(depth, stream);
+        fprintf(stream, "%s: complex type ('%s'), size is %zu, alignment is %i, descriptor is '%c'.\n", name, type->name, type->ffiType->size, type->ffiType->alignment, type->descriptor);
+    }
+}
+
+static void dynType_printSequence(char *name, dyn_type *type, int depth, FILE *stream) {
+    dynType_printDepth(depth, stream);
+    fprintf(stream, "sequence, size is %zu, alignment is %i, descriptor is '%c'. fields:\n", type->ffiType->size, type->ffiType->alignment, type->descriptor);
+
+    dynType_printDepth(depth + 1, stream);
+    fprintf(stream, "cap: simple type, size is %zu, alignment is %i.\n", type->sequence.seqType.elements[0]->size, type->sequence.seqType.elements[0]->alignment);
+
+    dynType_printDepth(depth + 1, stream);
+    fprintf(stream, "len: simple type, size is %zu, alignment is %i.\n", type->sequence.seqType.elements[1]->size, type->sequence.seqType.elements[1]->alignment);
+
+    dynType_printDepth(depth + 1, stream);
+    fprintf(stream, "buf: array, size is %zu, alignment is %i. points to ->\n", type->sequence.seqType.elements[2]->size, type->sequence.seqType.elements[2]->alignment);
+    dynType_printAny("element", type->sequence.itemType, depth + 1, stream);
+}
+
+static void dynType_printSimple(char *name, dyn_type *type, int depth, FILE *stream) {
+    dynType_printDepth(depth, stream);
+    fprintf(stream, "%s: simple type, size is %zu, alignment is %i, descriptor is '%c'.\n", name, type->ffiType->size, type->ffiType->alignment, type->descriptor);
+}
+
+static void dynType_printTypedPointer(char *name, dyn_type *type, int depth, FILE *stream) {
+    dynType_printDepth(depth, stream);
+    fprintf(stream, "%s: typed pointer, size is %zu, alignment is %i, points to ->\n", name, type->ffiType->size, type->ffiType->alignment);
+    char *subName = NULL;
+    char buf[128];
+    memset(buf,0,128);
+    if (name != NULL) {
+        snprintf(buf, 128, "*%s", name);
+        subName = buf;
+    }
+    dynType_printAny(subName, type->typedPointer.typedType, depth + 1, stream);
+}
+
+static void dynType_printTypes(dyn_type *type, FILE *stream) {
+
+    dyn_type *parent = type->parent;
+    struct type_entry *pentry = NULL;
+    while (parent != NULL) {
+        TAILQ_FOREACH(pentry, &parent->nestedTypesHead, entries) {
+            if (pentry->type == type) {
+                return;
+            }
+        }
+        parent = parent->parent;
+    }
+
+    struct type_entry *entry = NULL;
+    TAILQ_FOREACH(entry, &type->nestedTypesHead, entries) {
+        dyn_type *toPrint = entry->type;
+        if (toPrint->type == DYN_TYPE_REF) {
+            toPrint = toPrint->ref.ref;
+        }
+
+        switch(toPrint->type) {
+            case DYN_TYPE_COMPLEX :
+                dynType_printComplexType(toPrint, stream);
+                break;
+            case DYN_TYPE_SIMPLE :
+                dynType_printSimpleType(toPrint, stream);
+                break;
+            default :
+                printf("TODO Print Type\n");
+                break;
+        }
+    }
+
+
+    struct complex_type_entry *centry = NULL;
+    switch(type->type) {
+        case DYN_TYPE_COMPLEX :
+            TAILQ_FOREACH(centry, &type->complex.entriesHead, entries) {
+                dynType_printTypes(centry->type, stream);
+            }
+            break;
+        case DYN_TYPE_SEQUENCE :
+            dynType_printTypes(type->sequence.itemType, stream);
+            break;
+        case DYN_TYPE_TYPED_POINTER :
+            dynType_printTypes(type->typedPointer.typedType, stream);
+            break;
+    }
+}
+
+static void dynType_printComplexType(dyn_type *type, FILE *stream) {
+    fprintf(stream, "type '%s': complex type, size is %zu, alignment is %i, descriptor is '%c'. fields:\n", type->name,  type->ffiType->size, type->ffiType->alignment, type->descriptor);
+
+    struct complex_type_entry *entry = NULL;
+    TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
+        dynType_printAny(entry->name, entry->type, 2, stream);
+    }
+
+    fprintf(stream, "}\n");
+}
+
+static void dynType_printSimpleType(dyn_type *type, FILE *stream) {
+    fprintf(stream, "\ttype '%s': simple type, size is %zu, alignment is %i, descriptor is '%c'\n", type->name, type->ffiType->size, type->ffiType->alignment, type->descriptor);
+}
+


[03/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/hash_map.c
----------------------------------------------------------------------
diff --git a/utils/private/src/hash_map.c b/utils/private/src/hash_map.c
deleted file mode 100644
index bc514a7..0000000
--- a/utils/private/src/hash_map.c
+++ /dev/null
@@ -1,607 +0,0 @@
-/**
- *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.
- */
-/*
- * hash_map.c
- *
- *  \date       Jul 21, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include "celixbool.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <stdint.h>
-#include <string.h>
-
-#include "hash_map.h"
-#include "hash_map_private.h"
-
-static unsigned int DEFAULT_INITIAL_CAPACITY = 16;
-static float DEFAULT_LOAD_FACTOR = 0.75f;
-static unsigned int MAXIMUM_CAPACITY = 1 << 30;
-
-unsigned int hashMap_hashCode(const void * toHash) {
-	intptr_t address = (intptr_t) toHash;
-	return address;
-}
-
-int hashMap_equals(const void * toCompare, const void * compare) {
-	return toCompare == compare;
-}
-
-int hashMap_entryEquals(hash_map_pt map, hash_map_entry_pt entry, hash_map_entry_pt compare) {
-	if (entry->key == compare->key || map->equalsKey(entry->key, compare->key)) {
-		if (entry->value == compare->value || map->equalsValue(entry->value, compare->value)) {
-			return true;
-		}
-	}
-	return false;
-}
-
-static unsigned int hashMap_hash(unsigned int h) {
-	h += ~(h << 9);
-	h ^=  ((h >> 14) | (h << 18)); /* >>> */
-	h +=  (h << 4);
-	h ^=  ((h >> 10) | (h << 22)); /* >>> */
-	return h;
-}
-
-static unsigned int hashMap_indexFor(unsigned int h, unsigned int length) {
-	return h & (length - 1);
-}
-
-hash_map_pt hashMap_create(unsigned int (*keyHash)(const void *), unsigned int (*valueHash)(const void *),
-		int (*keyEquals)(const void *, const void *), int (*valueEquals)(const void *, const void *)) {
-	hash_map_pt map = (hash_map_pt) malloc(sizeof(*map));
-	map->treshold = (unsigned int) (DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR);
-	map->table = (hash_map_entry_pt *) calloc(DEFAULT_INITIAL_CAPACITY, sizeof(hash_map_entry_pt));
-	map->size = 0;
-	map->modificationCount = 0;
-	map->tablelength = DEFAULT_INITIAL_CAPACITY;
-	map->hashKey = hashMap_hashCode;
-	map->hashValue = hashMap_hashCode;
-	map->equalsKey = hashMap_equals;
-	map->equalsValue = hashMap_equals;
-
-	if (keyHash != NULL) {
-		map->hashKey = keyHash;
-	}
-	if (valueHash != NULL) {
-		map->hashValue = valueHash;
-	}
-	if (keyEquals != NULL) {
-		map->equalsKey = keyEquals;
-	}
-	if (valueEquals != NULL) {
-		map->equalsValue = valueEquals;
-	}
-
-	return map;
-}
-
-void hashMap_destroy(hash_map_pt map, bool freeKeys, bool freeValues) {
-	hashMap_clear(map, freeKeys, freeValues);
-	free(map->table);
-	free(map);
-}
-
-int hashMap_size(hash_map_pt map) {
-	return map->size;
-}
-
-bool hashMap_isEmpty(hash_map_pt map) {
-	return hashMap_size(map) == 0;
-}
-
-void * hashMap_get(hash_map_pt map, const void* key) {
-	unsigned int hash;
-	if (key == NULL) {
-		hash_map_entry_pt entry;
-		for (entry = map->table[0]; entry != NULL; entry = entry->next) {
-			if (entry->key == NULL) {
-				return entry->value;
-			}
-		}
-		return NULL;
-	}
-
-	hash = hashMap_hash(map->hashKey(key));
-	hash_map_entry_pt entry = NULL;
-	for (entry = map->table[hashMap_indexFor(hash, map->tablelength)]; entry != NULL; entry = entry->next) {
-		if (entry->hash == hash && (entry->key == key || map->equalsKey(key, entry->key))) {
-			return entry->value;
-		}
-	}
-	return NULL;
-}
-
-bool hashMap_containsKey(hash_map_pt map, const void* key) {
-	return hashMap_getEntry(map, key) != NULL;
-}
-
-hash_map_entry_pt hashMap_getEntry(hash_map_pt map, const void* key) {
-	unsigned int hash = (key == NULL) ? 0 : hashMap_hash(map->hashKey(key));
-	hash_map_entry_pt entry;
-	int index = hashMap_indexFor(hash, map->tablelength);
-	for (entry = map->table[index]; entry != NULL; entry = entry->next) {
-		if (entry->hash == hash && (entry->key == key || map->equalsKey(key, entry->key))) {
-			return entry;
-		}
-	}
-	return NULL;
-}
-
-void * hashMap_put(hash_map_pt map, void * key, void * value) {
-	unsigned int hash;
-	int i;
-	if (key == NULL) {
-		hash_map_entry_pt entry;
-		for (entry = map->table[0]; entry != NULL; entry = entry->next) {
-			if (entry->key == NULL) {
-				void * oldValue = entry->value;
-				entry->value = value;
-				return oldValue;
-			}
-		}
-		map->modificationCount++;
-		hashMap_addEntry(map, 0, NULL, value, 0);
-		return NULL;
-	}
-	hash = hashMap_hash(map->hashKey(key));
-	i = hashMap_indexFor(hash, map->tablelength);
-
-	hash_map_entry_pt entry;
-	for (entry = map->table[i]; entry != NULL; entry = entry->next) {
-		if (entry->hash == hash && (entry->key == key || map->equalsKey(key, entry->key))) {
-			void * oldValue = entry->value;
-			entry->value = value;
-			return oldValue;
-		}
-	}
-	map->modificationCount++;
-	hashMap_addEntry(map, hash, key, value, i);
-	return NULL;
-}
-
-void hashMap_resize(hash_map_pt map, int newCapacity) {
-	hash_map_entry_pt * newTable;
-	unsigned int j;
-	if (map->tablelength == MAXIMUM_CAPACITY) {
-		return;
-	}
-
-	newTable = (hash_map_entry_pt *) calloc(newCapacity, sizeof(hash_map_entry_pt));
-
-	for (j = 0; j < map->tablelength; j++) {
-		hash_map_entry_pt entry = map->table[j];
-		if (entry != NULL) {
-			map->table[j] = NULL;
-			do {
-				hash_map_entry_pt next = entry->next;
-				int i = hashMap_indexFor(entry->hash, newCapacity);
-				entry->next = newTable[i];
-				newTable[i] = entry;
-				entry = next;
-			} while (entry != NULL);
-		}
-	}
-	free(map->table);
-	map->table = newTable;
-	map->tablelength = newCapacity;
-	map->treshold = (unsigned int) ceil(newCapacity * DEFAULT_LOAD_FACTOR);
-}
-
-void * hashMap_remove(hash_map_pt map, const void* key) {
-	hash_map_entry_pt entry = hashMap_removeEntryForKey(map, key);
-	void * value = (entry == NULL ? NULL : entry->value);
-	if (entry != NULL) {
-		entry->key = NULL;
-		entry->value = NULL;
-		free(entry);
-	}
-	return value;
-}
-
-hash_map_entry_pt hashMap_removeEntryForKey(hash_map_pt map, const void* key) {
-	unsigned int hash = (key == NULL) ? 0 : hashMap_hash(map->hashKey(key));
-	int i = hashMap_indexFor(hash, map->tablelength);
-	hash_map_entry_pt prev = map->table[i];
-	hash_map_entry_pt entry = prev;
-
-	while (entry != NULL) {
-		hash_map_entry_pt next = entry->next;
-		if (entry->hash == hash && (entry->key == key || (key != NULL && map->equalsKey(key, entry->key)))) {
-			map->modificationCount++;
-			map->size--;
-			if (prev == entry) {
-				map->table[i] = next;
-			} else {
-				prev->next = next;
-			}
-			return entry;
-		}
-		prev = entry;
-		entry = next;
-	}
-
-	return entry;
-}
-
-hash_map_entry_pt hashMap_removeMapping(hash_map_pt map, hash_map_entry_pt entry) {
-	unsigned int hash;
-	hash_map_entry_pt prev;
-	hash_map_entry_pt e;
-	int i;
-	if (entry == NULL) {
-		return NULL;
-	}
-	hash = (entry->key == NULL) ? 0 : hashMap_hash(map->hashKey(entry->key));
-	i = hashMap_indexFor(hash, map->tablelength);
-	prev = map->table[i];
-	e = prev;
-
-	while (e != NULL) {
-		hash_map_entry_pt next = e->next;
-		if (e->hash == hash && hashMap_entryEquals(map, e, entry)) {
-			map->modificationCount++;
-			map->size--;
-			if (prev == e) {
-				map->table[i] = next;
-			} else {
-				prev->next = next;
-			}
-			return e;
-		}
-		prev = e;
-		e = next;
-	}
-
-	return e;
-}
-
-void hashMap_clear(hash_map_pt map, bool freeKey, bool freeValue) {
-	unsigned int i;
-	hash_map_entry_pt * table;
-	map->modificationCount++;
-	table = map->table;
-
-	for (i = 0; i < map->tablelength; i++) {
-		hash_map_entry_pt entry = table[i];
-		while (entry != NULL) {
-			hash_map_entry_pt f = entry;
-			entry = entry->next;
-			if (freeKey && f->key != NULL)
-				free(f->key);
-			if (freeValue && f->value != NULL)
-				free(f->value);
-			free(f);
-		}
-		table[i] = NULL;
-	}
-	map->size = 0;
-}
-
-bool hashMap_containsValue(hash_map_pt map, const void* value) {
-	unsigned int i;
-	if (value == NULL) {
-		for (i = 0; i < map->tablelength; i++) {
-			hash_map_entry_pt entry;
-			for (entry = map->table[i]; entry != NULL; entry = entry->next) {
-				if (entry->value == NULL) {
-					return true;
-				}
-			}
-		}
-		return false;
-	}
-	for (i = 0; i < map->tablelength; i++) {
-		hash_map_entry_pt entry;
-		for (entry = map->table[i]; entry != NULL; entry = entry->next) {
-			if (entry->value == value || map->equalsValue(entry->value, value)) {
-				return true;
-			}
-		}
-	}
-	return false;
-}
-
-void hashMap_addEntry(hash_map_pt map, int hash, void* key, void* value, int bucketIndex) {
-	hash_map_entry_pt entry = map->table[bucketIndex];
-	hash_map_entry_pt new = (hash_map_entry_pt) malloc(sizeof(*new));
-	new->hash = hash;
-	new->key = key;
-	new->value = value;
-	new->next = entry;
-	map->table[bucketIndex] = new;
-	if (map->size++ >= map->treshold) {
-		hashMap_resize(map, 2 * map->tablelength);
-	}
-}
-
-hash_map_iterator_pt hashMapIterator_alloc(void) {
-    return calloc(1, sizeof(hash_map_iterator_t));
-}
-
-void hashMapIterator_dealloc(hash_map_iterator_pt iterator) {
-    free(iterator);
-}
-
-hash_map_iterator_pt hashMapIterator_create(hash_map_pt map) {
-	hash_map_iterator_pt iterator = hashMapIterator_alloc();
-    hashMapIterator_init(map, iterator);
-    return iterator;
-}
-
-UTILS_EXPORT hash_map_iterator_t hashMapIterator_construct(hash_map_pt map) {
-    hash_map_iterator_t iter;
-    memset(&iter, 0, sizeof(iter));
-    hashMapIterator_init(map, &iter);
-    return iter;
-}
-
-void hashMapIterator_init(hash_map_pt map, hash_map_iterator_pt iterator) {
-	iterator->map = map;
-	iterator->expectedModCount = map->modificationCount;
-	iterator->index = 0;
-	iterator->next = NULL;
-	iterator->current = NULL;
-	if (map->size > 0) {
-		while (iterator->index < map->tablelength && (iterator->next = map->table[iterator->index++]) == NULL) {
-		}
-	}
-}
-
-void hashMapIterator_deinit(hash_map_iterator_pt iterator) {
-    iterator->current = NULL;
-    iterator->expectedModCount = 0;
-    iterator->index = 0;
-    iterator->map = NULL;
-    iterator->next = NULL;
-}
-
-void hashMapIterator_destroy(hash_map_iterator_pt iterator) {
-	hashMapIterator_deinit(iterator);
-    hashMapIterator_dealloc(iterator);
-}
-
-bool hashMapIterator_hasNext(hash_map_iterator_pt iterator) {
-	return iterator->next != NULL;
-}
-
-void hashMapIterator_remove(hash_map_iterator_pt iterator) {
-	void * key;
-	hash_map_entry_pt entry;
-	if (iterator->current == NULL) {
-		return;
-	}
-	if (iterator->expectedModCount != iterator->map->modificationCount) {
-		return;
-	}
-	key = iterator->current->key;
-	iterator->current = NULL;
-	entry = hashMap_removeEntryForKey(iterator->map, key);
-	free(entry);
-	iterator->expectedModCount = iterator->map->modificationCount;
-}
-
-void * hashMapIterator_nextValue(hash_map_iterator_pt iterator) {
-	hash_map_entry_pt entry;
-	if (iterator->expectedModCount != iterator->map->modificationCount) {
-		return NULL;
-	}
-	entry = iterator->next;
-	if (entry == NULL) {
-		return NULL;
-	}
-	if ((iterator->next = entry->next) == NULL) {
-		while (iterator->index < iterator->map->tablelength && (iterator->next = iterator->map->table[iterator->index++]) == NULL) {
-		}
-	}
-	iterator->current = entry;
-	return entry->value;
-}
-
-void * hashMapIterator_nextKey(hash_map_iterator_pt iterator) {
-	hash_map_entry_pt entry;
-	if (iterator->expectedModCount != iterator->map->modificationCount) {
-		return NULL;
-	}
-	entry = iterator->next;
-	if (entry == NULL) {
-		return NULL;
-	}
-	if ((iterator->next = entry->next) == NULL) {
-		while (iterator->index < iterator->map->tablelength && (iterator->next = iterator->map->table[iterator->index++]) == NULL) {
-		}
-	}
-	iterator->current = entry;
-	return entry->key;
-}
-
-hash_map_entry_pt hashMapIterator_nextEntry(hash_map_iterator_pt iterator) {
-	hash_map_entry_pt entry;
-	if (iterator->expectedModCount != iterator->map->modificationCount) {
-		return NULL;
-	}
-	entry = iterator->next;
-	if (entry == NULL) {
-		return NULL;
-	}
-	if ((iterator->next = entry->next) == NULL) {
-		while (iterator->index < iterator->map->tablelength && (iterator->next = iterator->map->table[iterator->index++]) == NULL) {
-		}
-	}
-	iterator->current = entry;
-	return entry;
-}
-
-hash_map_key_set_pt hashMapKeySet_create(hash_map_pt map) {
-	hash_map_key_set_pt keySet = (hash_map_key_set_pt) malloc(sizeof(*keySet));
-	keySet->map = map;
-
-	return keySet;
-}
-
-void hashMapKeySet_destroy(hash_map_key_set_pt keySet){
-	keySet->map = NULL;
-	free(keySet);
-}
-
-int hashMapKeySet_size(hash_map_key_set_pt keySet) {
-	return keySet->map->size;
-}
-
-bool hashMapKeySet_contains(hash_map_key_set_pt keySet, const void* key) {
-	return hashMap_containsKey(keySet->map, key);
-}
-
-bool hashMapKeySet_remove(hash_map_key_set_pt keySet, const void* key) {
-	hash_map_entry_pt entry = hashMap_removeEntryForKey(keySet->map, key);
-	bool removed = entry != NULL;
-	free(entry);
-	return removed;
-}
-
-void hashMapKeySet_clear(hash_map_key_set_pt keySet) {
-	hashMap_clear(keySet->map, false, false);
-}
-
-bool hashMapKeySet_isEmpty(hash_map_key_set_pt keySet) {
-	return hashMapKeySet_size(keySet) == 0;
-}
-
-hash_map_values_pt hashMapValues_create(hash_map_pt map) {
-	hash_map_values_pt values = (hash_map_values_pt) malloc(sizeof(*values));
-	values->map = map;
-
-	return values;
-}
-
-void hashMapValues_destroy(hash_map_values_pt values) {
-	values->map = NULL;
-	free(values);
-}
-
-hash_map_iterator_pt hashMapValues_iterator(hash_map_values_pt values) {
-	return hashMapIterator_create(values->map);
-}
-
-int hashMapValues_size(hash_map_values_pt values) {
-	return values->map->size;
-}
-
-bool hashMapValues_contains(hash_map_values_pt values, const void* value) {
-	return hashMap_containsValue(values->map, value);
-}
-
-void hashMapValues_toArray(hash_map_values_pt values, void* *array[], unsigned int *size) {
-	hash_map_iterator_pt it;
-	int i = 0;
-	int vsize = hashMapValues_size(values);
-	*size = vsize;
-	*array = malloc(vsize * sizeof(**array));
-	it = hashMapValues_iterator(values);
-	while(hashMapIterator_hasNext(it) && i<vsize){
-		(*array)[i++] = hashMapIterator_nextValue(it);
-	}
-	hashMapIterator_destroy(it);
-}
-
-bool hashMapValues_remove(hash_map_values_pt values, const void* value) {
-	hash_map_iterator_pt iterator = hashMapValues_iterator(values);
-	if (value == NULL) {
-		while (hashMapIterator_hasNext(iterator)) {
-			if (hashMapIterator_nextValue(iterator) == NULL) {
-				hashMapIterator_remove(iterator);
-				hashMapIterator_destroy(iterator);
-				return true;
-			}
-		}
-	} else {
-		while (hashMapIterator_hasNext(iterator)) {
-			if (values->map->equalsValue(value, hashMapIterator_nextValue(iterator))) {
-				hashMapIterator_remove(iterator);
-				hashMapIterator_destroy(iterator);
-				return true;
-			}
-		}
-	}
-	hashMapIterator_destroy(iterator);
-	return false;
-}
-
-void hashMapValues_clear(hash_map_values_pt values) {
-	hashMap_clear(values->map, false, false);
-}
-
-bool hashMapValues_isEmpty(hash_map_values_pt values) {
-	return hashMapValues_size(values) == 0;
-}
-
-hash_map_entry_set_pt hashMapEntrySet_create(hash_map_pt map) {
-	hash_map_entry_set_pt entrySet = (hash_map_entry_set_pt) malloc(sizeof(*entrySet));
-	entrySet->map = map;
-
-	return entrySet;
-}
-
-void hashMapEntrySet_destroy(hash_map_entry_set_pt entrySet){
-	entrySet->map = NULL;
-	free(entrySet);
-}
-
-int hashMapEntrySet_size(hash_map_entry_set_pt entrySet) {
-	return entrySet->map->size;
-}
-
-bool hashMapEntrySet_contains(hash_map_entry_set_pt entrySet, hash_map_entry_pt entry) {
-	return hashMap_containsValue(entrySet->map, entry);
-}
-
-bool hashMapEntrySet_remove(hash_map_entry_set_pt entrySet, hash_map_entry_pt entry) {
-	hash_map_entry_pt temp = hashMap_removeMapping(entrySet->map, entry);
-	if (temp != NULL) {
-		free(temp);
-		return true;
-	} else {
-		return false;
-	}
-}
-
-void hashMapEntrySet_clear(hash_map_entry_set_pt entrySet) {
-	hashMap_clear(entrySet->map, false, false);
-}
-
-bool hashMapEntrySet_isEmpty(hash_map_entry_set_pt entrySet) {
-	return hashMapEntrySet_size(entrySet) == 0;
-}
-
-void * hashMapEntry_getKey(hash_map_entry_pt entry) {
-	return entry->key;
-}
-
-void * hashMapEntry_getValue(hash_map_entry_pt entry) {
-	return entry->value;
-}
-
-
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/linked_list.c
----------------------------------------------------------------------
diff --git a/utils/private/src/linked_list.c b/utils/private/src/linked_list.c
deleted file mode 100644
index 235c3e7..0000000
--- a/utils/private/src/linked_list.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/**
- *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.
- */
-/*
- * linked_list.c
- *
- *  \date       Jul 16, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include "celixbool.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "linked_list.h"
-#include "linked_list_private.h"
-
-celix_status_t linkedList_create(linked_list_pt *list) {
-	linked_list_pt linked_list = malloc(sizeof(*linked_list));
-	if (linked_list) {
-        linked_list->header = (linked_list_entry_pt) malloc(sizeof(*(linked_list->header)));
-        if (linked_list->header) {
-            linked_list->header->element = NULL;
-            linked_list->header->next = linked_list->header;
-            linked_list->header->previous = linked_list->header;
-            linked_list->size = 0;
-            linked_list->modificationCount = 0;
-
-            *list = linked_list;
-
-            return CELIX_SUCCESS;
-        }
-	}
-
-	return CELIX_ENOMEM;
-}
-
-UTILS_EXPORT celix_status_t linkedList_destroy(linked_list_pt list) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	linked_list_entry_pt current = NULL;
-	linked_list_entry_pt next = NULL;
-
-	current = list->header->next;
-
-	while (current != list->header) {
-		next = current->next;
-		free(current);
-		current = next;
-	}
-
-	free(list->header);
-	free(list);
-
-	return status;
-}
-
-celix_status_t linkedList_clone(linked_list_pt list, linked_list_pt *clone) {
-	celix_status_t status;
-
-	status = linkedList_create(clone);
-	if (status == CELIX_SUCCESS) {
-		struct linked_list_entry *e;
-        for (e = list->header->next; e != list->header; e = e->next) {
-            linkedList_addElement(*clone, e->element);
-        }
-	}
-
-	return status;
-}
-
-void * linkedList_getFirst(linked_list_pt list) {
-	if (list->size == 0) {
-		return NULL;
-	}
-	return list->header->next->element;
-}
-
-void * linkedList_getLast(linked_list_pt list) {
-	if (list->size == 0) {
-		return NULL;
-	}
-	return list->header->previous->element;
-}
-
-void * linkedList_removeFirst(linked_list_pt list) {
-	return linkedList_removeEntry(list, list->header->next);
-}
-
-void * linkedList_removeLast(linked_list_pt list) {
-	return linkedList_removeEntry(list, list->header->previous);
-}
-
-void linkedList_addFirst(linked_list_pt list, void * element) {
-	linkedList_addBefore(list, element, list->header->next);
-}
-
-void linkedList_addLast(linked_list_pt list, void * element) {
-	linkedList_addBefore(list, element, list->header);
-}
-
-bool linkedList_contains(linked_list_pt list, void * element) {
-	return linkedList_indexOf(list, element) != -1;
-}
-
-int linkedList_size(linked_list_pt list) {
-	return list->size;
-}
-
-bool linkedList_isEmpty(linked_list_pt list) {
-	return linkedList_size(list) == 0;
-}
-
-bool linkedList_addElement(linked_list_pt list, void * element) {
-	linkedList_addBefore(list, element, list->header);
-	return true;
-}
-
-bool linkedList_removeElement(linked_list_pt list, void * element) {
-	if (element == NULL) {
-		linked_list_entry_pt entry;
-		for (entry = list->header->next; entry != list->header; entry = entry->next) {
-			if (entry->element == NULL) {
-				linkedList_removeEntry(list, entry);
-				return true;
-			}
-		}
-	} else {
-		linked_list_entry_pt entry;
-		for (entry = list->header->next; entry != list->header; entry = entry->next) {
-			if (element == entry->element) {
-				linkedList_removeEntry(list, entry);
-				return true;
-			}
-		}
-	}
-	return false;
-}
-
-void linkedList_clear(linked_list_pt list) {
-	linked_list_entry_pt entry = list->header->next;
-	while (entry != list->header) {
-		linked_list_entry_pt next = entry->next;
-		entry->next = entry->previous = NULL;
-		// free(entry->element);
-		entry->element = NULL;
-		free(entry);
-		entry = next;
-	}
-	list->header->next = list->header->previous = list->header;
-	list->size = 0;
-	list->modificationCount++;
-}
-
-void * linkedList_get(linked_list_pt list, int index) {
-	return linkedList_entry(list, index)->element;
-}
-void * linkedList_set(linked_list_pt list, int index, void * element) {
-	linked_list_entry_pt entry = linkedList_entry(list, index);
-	void * old = entry->element;
-	entry->element = element;
-	return old;
-}
-
-void linkedList_addIndex(linked_list_pt list, int index, void * element) {
-	linkedList_addBefore(list, element, (index == list->size ? list->header : linkedList_entry(list, index)));
-}
-
-void * linkedList_removeIndex(linked_list_pt list, int index) {
-	return linkedList_removeEntry(list, linkedList_entry(list, index));
-}
-
-linked_list_entry_pt linkedList_entry(linked_list_pt list, int index) {
-	linked_list_entry_pt entry;
-	int i;
-	if (index < 0 || index >= list->size) {
-		return NULL;
-	}
-
-	entry = list->header;
-	if (index < (list->size >> 1)) {
-		for (i = 0; i <= index; i++) {
-			entry = entry->next;
-		}
-	} else {
-		for (i = list->size; i > index; i--) {
-			entry = entry->previous;
-		}
-	}
-	return entry;
-}
-
-int linkedList_indexOf(linked_list_pt list, void * element) {
-	int index = 0;
-	if (element == NULL) {
-		linked_list_entry_pt entry;
-		for (entry = list->header->next; entry != list->header; entry = entry->next) {
-			if (entry->element == NULL) {
-				return index;
-			}
-			index++;
-		}
-	} else {
-		linked_list_entry_pt entry;
-		for (entry = list->header->next; entry != list->header; entry = entry->next) {
-			if (element == entry->element) {
-				return index;
-			}
-			index++;
-		}
-	}
-	return -1;
-}
-
-linked_list_entry_pt linkedList_addBefore(linked_list_pt list, void * element, linked_list_entry_pt entry) {
-    linked_list_entry_pt new = NULL;
-
-    new = malloc(sizeof(*new));
-    if (new != NULL) {
-
-        new->element = element;
-        new->next = entry;
-        new->previous = entry->previous;
-
-        new->previous->next = new;
-        new->next->previous = new;
-
-        list->size++;
-        list->modificationCount++;
-    }
-
-	return new;
-}
-
-void * linkedList_removeEntry(linked_list_pt list, linked_list_entry_pt entry) {
-    void * result;
-	if (entry == list->header) {
-		return NULL;
-	}
-
-	result = entry->element;
-
-	entry->previous->next = entry->next;
-	entry->next->previous = entry->previous;
-
-	entry->next = entry->previous = NULL;
-	free(entry);
-
-	list->size--;
-	list->modificationCount++;
-
-	return result;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/linked_list_iterator.c
----------------------------------------------------------------------
diff --git a/utils/private/src/linked_list_iterator.c b/utils/private/src/linked_list_iterator.c
deleted file mode 100644
index dc0e5c4..0000000
--- a/utils/private/src/linked_list_iterator.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- *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.
- */
-/*
- * linked_list_iterator.c
- *
- *  \date       Jul 16, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "linked_list_iterator.h"
-#include "linked_list_private.h"
-
-struct linkedListIterator {
-	linked_list_entry_pt lastReturned;
-	linked_list_entry_pt next;
-	int nextIndex;
-	linked_list_pt list;
-	int expectedModificationCount;
-};
-
-linked_list_iterator_pt linkedListIterator_create(linked_list_pt list, unsigned int index) {
-	linked_list_iterator_pt iterator;
-	if (index > list->size) {
-		return NULL;
-	}
-	iterator = (linked_list_iterator_pt) malloc(sizeof(*iterator));
-	iterator->lastReturned = list->header;
-	iterator->list = list;
-	iterator->expectedModificationCount = list->modificationCount;
-	if (index < (list->size >> 1)) {
-		iterator->next = iterator->list->header->next;
-		for (iterator->nextIndex = 0; iterator->nextIndex < index; iterator->nextIndex++) {
-			iterator->next = iterator->next->next;
-		}
-	} else {
-		iterator->next = list->header;
-		for (iterator->nextIndex = list->size; iterator->nextIndex > index; iterator->nextIndex--) {
-			iterator->next = iterator->next->previous;
-		}
-	}
-	return iterator;
-}
-
-void linkedListIterator_destroy(linked_list_iterator_pt iterator) {
-	iterator->expectedModificationCount = 0;
-	iterator->lastReturned = NULL;
-	iterator->list = NULL;
-	iterator->next = NULL;
-	iterator->nextIndex = 0;
-	free(iterator);
-}
-
-bool linkedListIterator_hasNext(linked_list_iterator_pt iterator) {
-	return iterator->nextIndex != iterator->list->size;
-}
-
-void * linkedListIterator_next(linked_list_iterator_pt iterator) {
-	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
-		return NULL;
-	}
-	if (iterator->nextIndex == iterator->list->size) {
-		return NULL;
-	}
-	iterator->lastReturned = iterator->next;
-	iterator->next = iterator->next->next;
-	iterator->nextIndex++;
-	return iterator->lastReturned->element;
-}
-
-bool linkedListIterator_hasPrevious(linked_list_iterator_pt iterator) {
-	return iterator->nextIndex != 0;
-}
-
-void * linkedListIterator_previous(linked_list_iterator_pt iterator) {
-	if (iterator->nextIndex == 0) {
-		return NULL;
-	}
-
-	iterator->lastReturned = iterator->next = iterator->next->previous;
-	iterator->nextIndex--;
-
-	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
-		return NULL;
-	}
-
-	return iterator->lastReturned->element;
-}
-
-int linkedListIterator_nextIndex(linked_list_iterator_pt iterator) {
-	return iterator->nextIndex;
-}
-
-int linkedListIterator_previousIndex(linked_list_iterator_pt iterator) {
-	return iterator->nextIndex-1;
-}
-
-void linkedListIterator_remove(linked_list_iterator_pt iterator) {
-	linked_list_entry_pt lastNext;
-	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
-		return;
-	}
-	lastNext = iterator->lastReturned->next;
-	if (linkedList_removeEntry(iterator->list, iterator->lastReturned) == NULL) {
-		return;
-	}
-	if (iterator->next == iterator->lastReturned) {
-		iterator->next = lastNext;
-	} else {
-		iterator->nextIndex--;
-	}
-	iterator->lastReturned = iterator->list->header;
-	iterator->expectedModificationCount++;
-}
-
-void linkedListIterator_set(linked_list_iterator_pt iterator, void * element) {
-	if (iterator->lastReturned == iterator->list->header) {
-		return;
-	}
-	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
-		return;
-	}
-	iterator->lastReturned->element = element;
-}
-
-void linkedListIterator_add(linked_list_iterator_pt iterator, void * element) {
-	if (iterator->list->modificationCount != iterator->expectedModificationCount) {
-		return;
-	}
-	iterator->lastReturned = iterator->list->header;
-	linkedList_addBefore(iterator->list, element, iterator->next);
-	iterator->nextIndex++;
-	iterator->expectedModificationCount++;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/memstream/fmemopen.c
----------------------------------------------------------------------
diff --git a/utils/private/src/memstream/fmemopen.c b/utils/private/src/memstream/fmemopen.c
deleted file mode 100644
index cb1b0c0..0000000
--- a/utils/private/src/memstream/fmemopen.c
+++ /dev/null
@@ -1,76 +0,0 @@
-
-/*
- * fmem.c : fmemopen() on top of BSD's funopen()
- * 20081017 AF
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-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 > 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);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/memstream/open_memstream.c
----------------------------------------------------------------------
diff --git a/utils/private/src/memstream/open_memstream.c b/utils/private/src/memstream/open_memstream.c
deleted file mode 100644
index 6bc4f01..0000000
--- a/utils/private/src/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/a1c30887/utils/private/src/properties.c
----------------------------------------------------------------------
diff --git a/utils/private/src/properties.c b/utils/private/src/properties.c
deleted file mode 100644
index 0bd6dc3..0000000
--- a/utils/private/src/properties.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/**
- *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.
- */
-/*
- * properties.c
- *
- *  \date       Apr 27, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include "celixbool.h"
-#include "properties.h"
-#include "utils.h"
-
-#define MALLOC_BLOCK_SIZE		5
-
-static void parseLine(const char* line, properties_pt props);
-
-properties_pt properties_create(void) {
-	return hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
-}
-
-void properties_destroy(properties_pt properties) {
-	hash_map_iterator_pt iter = hashMapIterator_create(properties);
-	while (hashMapIterator_hasNext(iter)) {
-		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-		free(hashMapEntry_getKey(entry));
-		free(hashMapEntry_getValue(entry));
-	}
-	hashMapIterator_destroy(iter);
-	hashMap_destroy(properties, false, false);
-}
-
-properties_pt properties_load(const char* filename) {
-	FILE *file = fopen(filename, "r");
-	if(file==NULL){
-		return NULL;
-	}
-	properties_pt props = properties_loadWithStream(file);
-	fclose(file);
-	return props;
-}
-
-properties_pt properties_loadWithStream(FILE *file) {
-	properties_pt props = NULL;
-
-
-	if (file != NULL ) {
-		char *saveptr;
-		char *filebuffer = NULL;
-		char *line = NULL;
-		size_t file_size = 0;
-
-		props = properties_create();
-		fseek(file, 0, SEEK_END);
-		file_size = ftell(file);
-		fseek(file, 0, SEEK_SET);
-
-		if(file_size > 0){
-			filebuffer = calloc(file_size + 1, sizeof(char));
-			if(filebuffer) {
-				size_t rs = fread(filebuffer, sizeof(char), file_size, file);
-				if(rs != file_size){
-					fprintf(stderr,"fread read only %lu bytes out of %lu\n",rs,file_size);
-				}
-				filebuffer[file_size]='\0';
-				line = strtok_r(filebuffer, "\n", &saveptr);
-				while ( line != NULL ) {
-					parseLine(line, props);
-					line = strtok_r(NULL, "\n", &saveptr);
-				}
-				free(filebuffer);
-			}
-		}
-	}
-
-	return props;
-}
-
-
-/**
- * Header is ignored for now, cannot handle comments yet
- */
-void properties_store(properties_pt properties, const char* filename, const char* header) {
-	FILE *file = fopen ( filename, "w+" );
-	char *str;
-
-	if (file != NULL) {
-		if (hashMap_size(properties) > 0) {
-			hash_map_iterator_pt iterator = hashMapIterator_create(properties);
-			while (hashMapIterator_hasNext(iterator)) {
-				hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
-				str = hashMapEntry_getKey(entry);
-				for (int i = 0; i < strlen(str); i += 1) {
-					if (str[i] == '#' || str[i] == '!' || str[i] == '=' || str[i] == ':') {
-						fputc('\\', file);
-					}
-					fputc(str[i], file);
-				}
-
-				fputc('=', file);
-
-				str = hashMapEntry_getValue(entry);
-				for (int i = 0; i < strlen(str); i += 1) {
-					if (str[i] == '#' || str[i] == '!' || str[i] == '=' || str[i] == ':') {
-						fputc('\\', file);
-					}
-					fputc(str[i], file);
-				}
-
-				fputc('\n', file);
-
-			}
-			hashMapIterator_destroy(iterator);
-		}
-		fclose(file);
-	} else {
-		perror("File is null");
-	}
-}
-
-celix_status_t properties_copy(properties_pt properties, properties_pt *out) {
-	celix_status_t status = CELIX_SUCCESS;
-	properties_pt copy = properties_create();
-
-	if (copy != NULL) {
-		hash_map_iterator_pt iter = hashMapIterator_create(properties);
-		while (hashMapIterator_hasNext(iter)) {
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-			char *key = hashMapEntry_getKey(entry);
-			char *value = hashMapEntry_getValue(entry);
-			properties_set(copy, key, value);
-		}
-		hashMapIterator_destroy(iter);
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*out = copy;
-	}
-
-	return status;
-}
-
-const char* properties_get(properties_pt properties, const char* key) {
-	return hashMap_get(properties, (void*)key);
-}
-
-const char* properties_getWithDefault(properties_pt properties, const char* key, const char* defaultValue) {
-	const char* value = properties_get(properties, key);
-	return value == NULL ? defaultValue : value;
-}
-
-void properties_set(properties_pt properties, const char* key, const char* value) {
-	hash_map_entry_pt entry = hashMap_getEntry(properties, key);
-	char* oldValue = NULL;
-	if (entry != NULL) {
-		char* oldKey = hashMapEntry_getKey(entry);
-		oldValue = hashMapEntry_getValue(entry);
-		hashMap_put(properties, oldKey, strndup(value, 1024*10));
-	} else {
-		hashMap_put(properties, strndup(key, 1024*10), strndup(value, 1024*10));
-	}
-	free(oldValue);
-}
-
-static void updateBuffers(char **key, char ** value, char **output, int outputPos, int *key_len, int *value_len) {
-	if (*output == *key) {
-		if (outputPos == (*key_len) - 1) {
-			(*key_len) += MALLOC_BLOCK_SIZE;
-			*key = realloc(*key, *key_len);
-			*output = *key;
-		}
-	}
-	else {
-		if (outputPos == (*value_len) - 1) {
-			(*value_len) += MALLOC_BLOCK_SIZE;
-			*value = realloc(*value, *value_len);
-			*output = *value;
-		}
-	}
-}
-
-static void parseLine(const char* line, properties_pt props) {
-	int linePos = 0;
-	bool precedingCharIsBackslash = false;
-	bool isComment = false;
-	int outputPos = 0;
-	char *output = NULL;
-	int key_len = MALLOC_BLOCK_SIZE;
-	int value_len = MALLOC_BLOCK_SIZE;
-	linePos = 0;
-	precedingCharIsBackslash = false;
-	isComment = false;
-	output = NULL;
-	outputPos = 0;
-
-	//Ignore empty lines
-	if (line[0] == '\n' && line[1] == '\0') {
-		return;
-	}
-
-	char *key = calloc(1, key_len);
-	char *value = calloc(1, value_len);
-	key[0] = '\0';
-	value[0] = '\0';
-
-	while (line[linePos] != '\0') {
-		if (line[linePos] == ' ' || line[linePos] == '\t') {
-			if (output == NULL) {
-				//ignore
-				linePos += 1;
-				continue;
-			}
-		}
-		else {
-			if (output == NULL) {
-				output = key;
-			}
-		}
-		if (line[linePos] == '=' || line[linePos] == ':' || line[linePos] == '#' || line[linePos] == '!') {
-			if (precedingCharIsBackslash) {
-				//escaped special character
-				output[outputPos++] = line[linePos];
-				updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
-				precedingCharIsBackslash = false;
-			}
-			else {
-				if (line[linePos] == '#' || line[linePos] == '!') {
-					if (outputPos == 0) {
-						isComment = true;
-						break;
-					}
-					else {
-						output[outputPos++] = line[linePos];
-						updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
-					}
-				}
-				else { // = or :
-					if (output == value) { //already have a seperator
-						output[outputPos++] = line[linePos];
-						updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
-					}
-					else {
-						output[outputPos++] = '\0';
-						updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
-						output = value;
-						outputPos = 0;
-					}
-				}
-			}
-		}
-		else if (line[linePos] == '\\') {
-			if (precedingCharIsBackslash) { //double backslash -> backslash
-				output[outputPos++] = '\\';
-				updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
-			}
-			precedingCharIsBackslash = true;
-		}
-		else { //normal character
-			precedingCharIsBackslash = false;
-			output[outputPos++] = line[linePos];
-			updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
-		}
-		linePos += 1;
-	}
-	if (output != NULL) {
-		output[outputPos] = '\0';
-	}
-
-	if (!isComment) {
-		//printf("putting 'key'/'value' '%s'/'%s' in properties\n", utils_stringTrim(key), utils_stringTrim(value));
-		properties_set(props, utils_stringTrim(key), utils_stringTrim(value));
-	}
-	if(key) {
-		free(key);
-	}
-	if(value) {
-		free(value);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/thpool.c
----------------------------------------------------------------------
diff --git a/utils/private/src/thpool.c b/utils/private/src/thpool.c
deleted file mode 100644
index 5121fca..0000000
--- a/utils/private/src/thpool.c
+++ /dev/null
@@ -1,535 +0,0 @@
-/* ********************************
- * Author:       Johan Hanssen Seferidis
- * License:	     MIT
- * Description:  Library providing a threading pool where you can add
- *               work. For usage, check the thpool.h file or README.md
- *
- *//** @file thpool.h *//*
- * 
- ********************************/
-
-
-#include <unistd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <errno.h>
-#include <time.h> 
-#include "thpool.h"
-
-#ifdef THPOOL_DEBUG
-#define THPOOL_DEBUG 1
-#else
-#define THPOOL_DEBUG 0
-#endif
-
-static volatile int threads_keepalive;
-static volatile int threads_on_hold;
-
-
-
-/* ========================== STRUCTURES ============================ */
-
-
-/* Binary semaphore */
-typedef struct bsem {
-	pthread_mutex_t mutex;
-	pthread_cond_t   cond;
-	int v;
-} bsem;
-
-
-/* Job */
-typedef struct job{
-	struct job*  prev;                   /* pointer to previous job   */
-	void*  (*function)(void* arg);       /* function pointer          */
-	void*  arg;                          /* function's argument       */
-} job;
-
-
-/* Job queue */
-typedef struct jobqueue{
-	pthread_mutex_t rwmutex;             /* used for queue r/w access */
-	job  *front;                         /* pointer to front of queue */
-	job  *rear;                          /* pointer to rear  of queue */
-	bsem *has_jobs;                      /* flag as binary semaphore  */
-	int   len;                           /* number of jobs in queue   */
-} jobqueue;
-
-
-/* Thread */
-typedef struct thread{
-	int       id;                        /* friendly id               */
-	pthread_t pthread;                   /* pointer to actual thread  */
-	struct thpool_* thpool_p;            /* access to thpool          */
-} thread;
-
-
-/* Threadpool */
-typedef struct thpool_{
-	thread**   threads;                  /* pointer to threads        */
-	volatile int num_threads_alive;      /* threads currently alive   */
-	volatile int num_threads_working;    /* threads currently working */
-	pthread_mutex_t  thcount_lock;       /* used for thread count etc */
-	pthread_cond_t  threads_all_idle;    /* signal to thpool_wait     */
-	jobqueue*  jobqueue_p;               /* pointer to the job queue  */    
-} thpool_;
-
-
-
-
-
-/* ========================== PROTOTYPES ============================ */
-
-
-static void  thread_init(thpool_* thpool_p, struct thread** thread_p, int id);
-static void* thread_do(struct thread* thread_p);
-static void  thread_hold();
-static void  thread_destroy(struct thread* thread_p);
-
-static int   jobqueue_init(thpool_* thpool_p);
-static void  jobqueue_clear(thpool_* thpool_p);
-static void  jobqueue_push(thpool_* thpool_p, struct job* newjob_p);
-static struct job* jobqueue_pull(thpool_* thpool_p);
-static void  jobqueue_destroy(thpool_* thpool_p);
-
-static void  bsem_init(struct bsem *bsem_p, int value);
-static void  bsem_reset(struct bsem *bsem_p);
-static void  bsem_post(struct bsem *bsem_p);
-static void  bsem_post_all(struct bsem *bsem_p);
-static void  bsem_wait(struct bsem *bsem_p);
-
-
-
-
-
-/* ========================== THREADPOOL ============================ */
-
-
-/* Initialise thread pool */
-struct thpool_* thpool_init(int num_threads){
-
-	threads_on_hold   = 0;
-	threads_keepalive = 1;
-
-	if ( num_threads < 0){
-		num_threads = 0;
-	}
-
-	/* Make new thread pool */
-	thpool_* thpool_p;
-	thpool_p = (struct thpool_*)malloc(sizeof(struct thpool_));
-	if (thpool_p == NULL){
-		fprintf(stderr, "thpool_init(): Could not allocate memory for thread pool\n");
-		return NULL;
-	}
-	thpool_p->num_threads_alive   = 0;
-	thpool_p->num_threads_working = 0;
-
-	/* Initialise the job queue */
-	if (jobqueue_init(thpool_p) == -1){
-		fprintf(stderr, "thpool_init(): Could not allocate memory for job queue\n");
-		free(thpool_p);
-		return NULL;
-	}
-
-	/* Make threads in pool */
-	thpool_p->threads = (struct thread**)malloc(num_threads * sizeof(struct thread*));
-	if (thpool_p->threads == NULL){
-		fprintf(stderr, "thpool_init(): Could not allocate memory for threads\n");
-		jobqueue_destroy(thpool_p);
-		free(thpool_p->jobqueue_p);
-		free(thpool_p);
-		return NULL;
-	}
-
-	pthread_mutex_init(&(thpool_p->thcount_lock), NULL);
-	pthread_cond_init(&thpool_p->threads_all_idle, NULL);
-	
-	/* Thread init */
-	int n;
-	for (n=0; n<num_threads; n++){
-		thread_init(thpool_p, &thpool_p->threads[n], n);
-		if (THPOOL_DEBUG)
-			printf("THPOOL_DEBUG: Created thread %d in pool \n", n);
-	}
-	
-	/* Wait for threads to initialize */
-	while (thpool_p->num_threads_alive != num_threads) {}
-
-	return thpool_p;
-}
-
-
-/* Add work to the thread pool */
-int thpool_add_work(thpool_* thpool_p, void *(*function_p)(void*), void* arg_p){
-	job* newjob;
-
-	newjob=(struct job*)malloc(sizeof(struct job));
-	if (newjob==NULL){
-		fprintf(stderr, "thpool_add_work(): Could not allocate memory for new job\n");
-		return -1;
-	}
-
-	/* add function and argument */
-	newjob->function=function_p;
-	newjob->arg=arg_p;
-
-	/* add job to queue */
-	pthread_mutex_lock(&thpool_p->jobqueue_p->rwmutex);
-	jobqueue_push(thpool_p, newjob);
-	pthread_mutex_unlock(&thpool_p->jobqueue_p->rwmutex);
-
-	return 0;
-}
-
-
-/* Wait until all jobs have finished */
-void thpool_wait(thpool_* thpool_p){
-	pthread_mutex_lock(&thpool_p->thcount_lock);
-	while (thpool_p->jobqueue_p->len || thpool_p->num_threads_working) {
-		pthread_cond_wait(&thpool_p->threads_all_idle, &thpool_p->thcount_lock);
-	}
-	pthread_mutex_unlock(&thpool_p->thcount_lock);
-}
-
-
-/* Destroy the threadpool */
-void thpool_destroy(thpool_* thpool_p){
-	
-	volatile int threads_total = thpool_p->num_threads_alive;
-
-	/* End each thread 's infinite loop */
-	threads_keepalive = 0;
-	
-	/* Give one second to kill idle threads */
-	double TIMEOUT = 1.0;
-	time_t start, end;
-	double tpassed = 0.0;
-	time (&start);
-	while (tpassed < TIMEOUT && thpool_p->num_threads_alive){
-		bsem_post_all(thpool_p->jobqueue_p->has_jobs);
-		time (&end);
-		tpassed = difftime(end,start);
-	}
-	
-	/* Poll remaining threads */
-	while (thpool_p->num_threads_alive){
-		bsem_post_all(thpool_p->jobqueue_p->has_jobs);
-		sleep(1);
-	}
-
-	/* Job queue cleanup */
-	jobqueue_destroy(thpool_p);
-	free(thpool_p->jobqueue_p);
-	
-	/* Deallocs */
-	int n;
-	for (n=0; n < threads_total; n++){
-		thread_destroy(thpool_p->threads[n]);
-	}
-	free(thpool_p->threads);
-	free(thpool_p);
-}
-
-
-/* Pause all threads in threadpool */
-void thpool_pause(thpool_* thpool_p) {
-	int n;
-	for (n=0; n < thpool_p->num_threads_alive; n++){
-		pthread_kill(thpool_p->threads[n]->pthread, SIGUSR1);
-	}
-}
-
-
-/* Resume all threads in threadpool */
-void thpool_resume(thpool_* thpool_p) {
-	threads_on_hold = 0;
-}
-
-
-
-
-
-/* ============================ THREAD ============================== */
-
-
-/* Initialize a thread in the thread pool
- * 
- * @param thread        address to the pointer of the thread to be created
- * @param id            id to be given to the thread
- * 
- */
-static void thread_init (thpool_* thpool_p, struct thread** thread_p, int id){
-	
-	*thread_p = (struct thread*)malloc(sizeof(struct thread));
-	if (*thread_p == NULL){
-		fprintf(stderr, "thpool_init(): Could not allocate memory for thread\n");
-		exit(1);
-	}
-
-	(*thread_p)->thpool_p = thpool_p;
-	(*thread_p)->id       = id;
-
-	pthread_create(&(*thread_p)->pthread, NULL, (void *)thread_do, (*thread_p));
-	pthread_detach((*thread_p)->pthread);
-	
-}
-
-
-/* Sets the calling thread on hold */
-static void thread_hold () {
-	threads_on_hold = 1;
-	while (threads_on_hold){
-		sleep(1);
-	}
-}
-
-
-/* What each thread is doing
-* 
-* In principle this is an endless loop. The only time this loop gets interuppted is once
-* thpool_destroy() is invoked or the program exits.
-* 
-* @param  thread        thread that will run this function
-* @return nothing
-*/
-static void* thread_do(struct thread* thread_p){
-
-	/* Set thread name for profiling and debuging */
-	char thread_name[128] = {0};
-	sprintf(thread_name, "thread-pool-%d", thread_p->id);
-
-#if defined(__linux__)
-	pthread_setname_np(thread_p->pthread, thread_name);
-#elif defined(__APPLE__) && defined(__MACH__)
-	pthread_setname_np(thread_name);
-#else
-	fprintf(stderr, "thread_do(): pthread_setname_np is not supported on this system");
-#endif
-
-	/* Assure all threads have been created before starting serving */
-	thpool_* thpool_p = thread_p->thpool_p;
-	
-	/* Register signal handler */
-	struct sigaction act;
-	sigemptyset(&act.sa_mask);
-	act.sa_flags = 0;
-	act.sa_handler = thread_hold;
-	if (sigaction(SIGUSR1, &act, NULL) == -1) {
-		fprintf(stderr, "thread_do(): cannot handle SIGUSR1");
-	}
-	
-	/* Mark thread as alive (initialized) */
-	pthread_mutex_lock(&thpool_p->thcount_lock);
-	thpool_p->num_threads_alive += 1;
-	pthread_mutex_unlock(&thpool_p->thcount_lock);
-
-	while(threads_keepalive){
-
-		bsem_wait(thpool_p->jobqueue_p->has_jobs);
-
-		if (threads_keepalive){
-			
-			pthread_mutex_lock(&thpool_p->thcount_lock);
-			thpool_p->num_threads_working++;
-			pthread_mutex_unlock(&thpool_p->thcount_lock);
-			
-			/* Read job from queue and execute it */
-			void*(*func_buff)(void* arg);
-			void*  arg_buff;
-			job* job_p;
-			pthread_mutex_lock(&thpool_p->jobqueue_p->rwmutex);
-			job_p = jobqueue_pull(thpool_p);
-			pthread_mutex_unlock(&thpool_p->jobqueue_p->rwmutex);
-			if (job_p) {
-				func_buff = job_p->function;
-				arg_buff  = job_p->arg;
-				func_buff(arg_buff);
-				free(job_p);
-			}
-			
-			pthread_mutex_lock(&thpool_p->thcount_lock);
-			thpool_p->num_threads_working--;
-			if (!thpool_p->num_threads_working) {
-				pthread_cond_signal(&thpool_p->threads_all_idle);
-			}
-			pthread_mutex_unlock(&thpool_p->thcount_lock);
-
-		}
-	}
-	pthread_mutex_lock(&thpool_p->thcount_lock);
-	thpool_p->num_threads_alive --;
-	pthread_mutex_unlock(&thpool_p->thcount_lock);
-
-	return NULL;
-}
-
-
-/* Frees a thread  */
-static void thread_destroy (thread* thread_p){
-	free(thread_p);
-}
-
-
-
-
-
-/* ============================ JOB QUEUE =========================== */
-
-
-/* Initialize queue */
-static int jobqueue_init(thpool_* thpool_p){
-	
-	thpool_p->jobqueue_p = (struct jobqueue*)malloc(sizeof(struct jobqueue));
-	if (thpool_p->jobqueue_p == NULL){
-		return -1;
-	}
-	thpool_p->jobqueue_p->len = 0;
-	thpool_p->jobqueue_p->front = NULL;
-	thpool_p->jobqueue_p->rear  = NULL;
-
-	thpool_p->jobqueue_p->has_jobs = (struct bsem*)malloc(sizeof(struct bsem));
-	if (thpool_p->jobqueue_p->has_jobs == NULL){
-		return -1;
-	}
-
-	pthread_mutex_init(&(thpool_p->jobqueue_p->rwmutex), NULL);
-	bsem_init(thpool_p->jobqueue_p->has_jobs, 0);
-
-	return 0;
-}
-
-
-/* Clear the queue */
-static void jobqueue_clear(thpool_* thpool_p){
-
-	while(thpool_p->jobqueue_p->len){
-		free(jobqueue_pull(thpool_p));
-	}
-
-	thpool_p->jobqueue_p->front = NULL;
-	thpool_p->jobqueue_p->rear  = NULL;
-	bsem_reset(thpool_p->jobqueue_p->has_jobs);
-	thpool_p->jobqueue_p->len = 0;
-
-}
-
-
-/* Add (allocated) job to queue
- *
- * Notice: Caller MUST hold a mutex
- */
-static void jobqueue_push(thpool_* thpool_p, struct job* newjob){
-
-	newjob->prev = NULL;
-
-	switch(thpool_p->jobqueue_p->len){
-
-		case 0:  /* if no jobs in queue */
-					thpool_p->jobqueue_p->front = newjob;
-					thpool_p->jobqueue_p->rear  = newjob;
-					break;
-
-		default: /* if jobs in queue */
-					thpool_p->jobqueue_p->rear->prev = newjob;
-					thpool_p->jobqueue_p->rear = newjob;
-					
-	}
-	thpool_p->jobqueue_p->len++;
-	
-	bsem_post(thpool_p->jobqueue_p->has_jobs);
-}
-
-
-/* Get first job from queue(removes it from queue)
- * 
- * Notice: Caller MUST hold a mutex
- */
-static struct job* jobqueue_pull(thpool_* thpool_p){
-
-	job* job_p;
-	job_p = thpool_p->jobqueue_p->front;
-
-	switch(thpool_p->jobqueue_p->len){
-		
-		case 0:  /* if no jobs in queue */
-		  			break;
-		
-		case 1:  /* if one job in queue */
-					thpool_p->jobqueue_p->front = NULL;
-					thpool_p->jobqueue_p->rear  = NULL;
-					thpool_p->jobqueue_p->len = 0;
-					break;
-		
-		default: /* if >1 jobs in queue */
-					thpool_p->jobqueue_p->front = job_p->prev;
-					thpool_p->jobqueue_p->len--;
-					/* more than one job in queue -> post it */
-					bsem_post(thpool_p->jobqueue_p->has_jobs);
-					
-	}
-	
-	return job_p;
-}
-
-
-/* Free all queue resources back to the system */
-static void jobqueue_destroy(thpool_* thpool_p){
-	jobqueue_clear(thpool_p);
-	free(thpool_p->jobqueue_p->has_jobs);
-}
-
-
-
-
-
-/* ======================== SYNCHRONISATION ========================= */
-
-
-/* Init semaphore to 1 or 0 */
-static void bsem_init(bsem *bsem_p, int value) {
-	if (value < 0 || value > 1) {
-		fprintf(stderr, "bsem_init(): Binary semaphore can take only values 1 or 0");
-		exit(1);
-	}
-	pthread_mutex_init(&(bsem_p->mutex), NULL);
-	pthread_cond_init(&(bsem_p->cond), NULL);
-	bsem_p->v = value;
-}
-
-
-/* Reset semaphore to 0 */
-static void bsem_reset(bsem *bsem_p) {
-	bsem_init(bsem_p, 0);
-}
-
-
-/* Post to at least one thread */
-static void bsem_post(bsem *bsem_p) {
-	pthread_mutex_lock(&bsem_p->mutex);
-	bsem_p->v = 1;
-	pthread_cond_signal(&bsem_p->cond);
-	pthread_mutex_unlock(&bsem_p->mutex);
-}
-
-
-/* Post to all threads */
-static void bsem_post_all(bsem *bsem_p) {
-	pthread_mutex_lock(&bsem_p->mutex);
-	bsem_p->v = 1;
-	pthread_cond_broadcast(&bsem_p->cond);
-	pthread_mutex_unlock(&bsem_p->mutex);
-}
-
-
-/* Wait on semaphore until semaphore has value 0 */
-static void bsem_wait(bsem* bsem_p) {
-	pthread_mutex_lock(&bsem_p->mutex);
-	while (bsem_p->v != 1) {
-		pthread_cond_wait(&bsem_p->cond, &bsem_p->mutex);
-	}
-	bsem_p->v = 0;
-	pthread_mutex_unlock(&bsem_p->mutex);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/utils.c
----------------------------------------------------------------------
diff --git a/utils/private/src/utils.c b/utils/private/src/utils.c
deleted file mode 100644
index fc4d538..0000000
--- a/utils/private/src/utils.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- *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.
- */
-/*
- * utils.c
- *
- *  \date       Jul 27, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "utils.h"
-
-unsigned int utils_stringHash(const void* strPtr) {
-    const char* string = strPtr;
-    unsigned int hc = 5381;
-    char ch;
-    while((ch = *string++) != '\0'){
-        hc = (hc << 5) + hc + ch;
-    }
-
-    return hc;
-}
-
-int utils_stringEquals(const void* string, const void* toCompare) {
-	return strcmp((const char*)string, (const char*)toCompare) == 0;
-}
-
-char * string_ndup(const char *s, size_t n) {
-	size_t len = strlen(s);
-	char *ret;
-
-	if (len <= n) {
-		return strdup(s);
-	}
-
-	ret = malloc(n + 1);
-	strncpy(ret, s, n);
-	ret[n] = '\0';
-	return ret;
-}
-
-char * utils_stringTrim(char * string) {
-	char* copy = string;
-
-	char *end;
-	// Trim leading space
-	while (isspace(*copy)) {
-		copy++;
-	}
-
-	// Trim trailing space
-	end = copy + strlen(copy) - 1;
-	while(end > copy && isspace(*end)) {
-		*(end) = '\0';
-		end--;
-	}
-
-	if (copy != string) { 
-		//beginning whitespaces -> move char in copy to to begin string
-		//This to ensure free still works on the same pointer.
-		char* nstring = string;
-		while(*copy != '\0') {
-			*(nstring++) = *(copy++);
-		}
-		(*nstring) = '\0';
-	}
-
-	return string;
-}
-
-bool utils_isStringEmptyOrNull(const char * const str) {
-	bool empty = true;
-	if (str != NULL) {
-		int i;
-		for (i = 0; i < strnlen(str, 1024 * 1024); i += 1) {
-			if (!isspace(str[i])) {
-				empty = false;
-				break;
-			}
-		}
-	}
-
-	return empty;
-}
-
-celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	celix_thread_t self = celixThread_self();
-	if (status == CELIX_SUCCESS) {
-		*equals = celixThread_equals(self, thread);
-	}
-
-	return status;
-}
-
-celix_status_t utils_isNumeric(const char *number, bool *ret) {
-	celix_status_t status = CELIX_SUCCESS;
-	*ret = true;
-	while(*number) {
-		if(!isdigit(*number) && *number != '.') {
-			*ret = false;
-			break;
-		}
-		number++;
-	}
-	return status;
-}
-
-
-int utils_compareServiceIdsAndRanking(unsigned long servId, long servRank, unsigned long otherServId, long otherServRank) {
-	int result;
-
-	if (servId == otherServId) {
-		result = 0;
-	} else if (servRank != otherServRank) {
-		result = servRank < otherServRank ? -1 : 1;
-	} else { //equal service rank, compare service ids
-		result = servId < otherServId ? 1 : -1;
-	}
-
-	return result;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/version.c
----------------------------------------------------------------------
diff --git a/utils/private/src/version.c b/utils/private/src/version.c
deleted file mode 100644
index cb2703d..0000000
--- a/utils/private/src/version.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- *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.
- */
-/*
- * version.c
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "celix_errno.h"
-#include "version_private.h"
-
-celix_status_t version_createVersion(int major, int minor, int micro, char * qualifier, version_pt *version) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (*version != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*version = (version_pt) malloc(sizeof(**version));
-		if (!*version) {
-			status = CELIX_ENOMEM;
-		} else {
-			unsigned int i;
-
-			(*version)->major = major;
-			(*version)->minor = minor;
-			(*version)->micro = micro;
-			if (qualifier == NULL) {
-				qualifier = "";
-			}
-			(*version)->qualifier = strdup(qualifier);
-
-			if (major < 0) {
-				status = CELIX_ILLEGAL_ARGUMENT;
-			}
-			if (minor < 0) {
-				status = CELIX_ILLEGAL_ARGUMENT;
-			}
-			if (micro < 0) {
-				status = CELIX_ILLEGAL_ARGUMENT;
-			}
-
-			for (i = 0; i < strlen(qualifier); i++) {
-				char ch = qualifier[i];
-				if (('A' <= ch) && (ch <= 'Z')) {
-					continue;
-				}
-				if (('a' <= ch) && (ch <= 'z')) {
-					continue;
-				}
-				if (('0' <= ch) && (ch <= '9')) {
-					continue;
-				}
-				if ((ch == '_') || (ch == '-')) {
-					continue;
-				}
-				status = CELIX_ILLEGAL_ARGUMENT;
-				break;
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t version_clone(version_pt version, version_pt *clone) {
-	return version_createVersion(version->major, version->minor, version->micro, version->qualifier, clone);
-}
-
-celix_status_t version_destroy(version_pt version) {
-	version->major = 0;
-	version->minor = 0;
-	version->micro = 0;
-	free(version->qualifier);
-	version->qualifier = NULL;
-	free(version);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t version_createVersionFromString(const char * versionStr, version_pt *version) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	int major = 0;
-	int minor = 0;
-	int micro = 0;
-	char * qualifier = NULL;
-
-	char delims[] = ".";
-	char *token = NULL;
-	char *last = NULL;
-
-	int i = 0;
-
-	char* versionWrkStr = strdup(versionStr);
-
-	token = strtok_r(versionWrkStr, delims, &last);
-	if (token != NULL) {
-		for (i = 0; i < strlen(token); i++) {
-			char ch = token[i];
-			if (('0' <= ch) && (ch <= '9')) {
-				continue;
-			}
-			status = CELIX_ILLEGAL_ARGUMENT;
-			break;
-		}
-		major = atoi(token);
-		token = strtok_r(NULL, delims, &last);
-		if (token != NULL) {
-			for (i = 0; i < strlen(token); i++) {
-				char ch = token[i];
-				if (('0' <= ch) && (ch <= '9')) {
-					continue;
-				}
-				status = CELIX_ILLEGAL_ARGUMENT;
-				break;
-			}
-			minor = atoi(token);
-			token = strtok_r(NULL, delims, &last);
-			if (token != NULL) {
-				for (i = 0; i < strlen(token); i++) {
-					char ch = token[i];
-					if (('0' <= ch) && (ch <= '9')) {
-						continue;
-					}
-					status = CELIX_ILLEGAL_ARGUMENT;
-					break;
-				}
-				micro = atoi(token);
-				token = strtok_r(NULL, delims, &last);
-				if (token != NULL) {
-					qualifier = strdup(token);
-					token = strtok_r(NULL, delims, &last);
-					if (token != NULL) {
-						*version = NULL;
-						status = CELIX_ILLEGAL_ARGUMENT;
-					}
-				}
-			}
-		}
-	}
-
-	free(versionWrkStr);
-
-	if (status == CELIX_SUCCESS) {
-		status = version_createVersion(major, minor, micro, qualifier, version);
-	}
-
-	if (qualifier != NULL) {
-	    free(qualifier);
-	}
-
-	return status;
-}
-
-celix_status_t version_createEmptyVersion(version_pt *version) {
-	return version_createVersion(0, 0, 0, "", version);
-}
-
-celix_status_t version_getMajor(version_pt version, int *major) {
-	celix_status_t status = CELIX_SUCCESS;
-	*major = version->major;
-	return status;
-}
-
-celix_status_t version_getMinor(version_pt version, int *minor) {
-	celix_status_t status = CELIX_SUCCESS;
-	*minor = version->minor;
-	return status;
-}
-
-celix_status_t version_getMicro(version_pt version, int *micro) {
-	celix_status_t status = CELIX_SUCCESS;
-	*micro = version->micro;
-	return status;
-}
-
-celix_status_t version_getQualifier(version_pt version, const char **qualifier) {
-	celix_status_t status = CELIX_SUCCESS;
-	*qualifier = version->qualifier;
-	return status;
-}
-
-celix_status_t version_compareTo(version_pt version, version_pt compare, int *result) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (compare == version) {
-		*result = 0;
-	} else {
-		int res = version->major - compare->major;
-		if (res != 0) {
-			*result = res;
-		} else {
-			res = version->minor - compare->minor;
-			if (res != 0) {
-				*result = res;
-			} else {
-				res = version->micro - compare->micro;
-				if (res != 0) {
-					*result = res;
-				} else {
-					*result = strcmp(version->qualifier, compare->qualifier);
-				}
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t version_toString(version_pt version, char **string) {
-    celix_status_t status = CELIX_SUCCESS;
-	if (strlen(version->qualifier) > 0) {
-	    char str[512];
-	    int written = snprintf(str, 512, "%d.%d.%d.%s", version->major, version->minor, version->micro, version->qualifier);
-	    if (written >= 512 || written < 0) {
-	        status = CELIX_BUNDLE_EXCEPTION;
-	    }
-	    *string = strdup(str);
-	} else {
-	    char str[512];
-        int written = snprintf(str, 512, "%d.%d.%d", version->major, version->minor, version->micro);
-        if (written >= 512 || written < 0) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-        *string = strdup(str);
-	}
-	return status;
-}
-
-celix_status_t version_isCompatible(version_pt user, version_pt provider, bool* isCompatible) {
-    celix_status_t status = CELIX_SUCCESS;
-    bool result = false;
-
-    if (user == NULL || provider == NULL) {
-        return CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    if (user->major == provider->major) {
-        result = (provider->minor >= user->minor);
-    }
-
-    *isCompatible = result;
-
-    return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/private/src/version_range.c
----------------------------------------------------------------------
diff --git a/utils/private/src/version_range.c b/utils/private/src/version_range.c
deleted file mode 100644
index ed681fd..0000000
--- a/utils/private/src/version_range.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/**
- *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.
- */
-/*
- * version_range.c
- *
- *  \date       Jul 12, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "version_range_private.h"
-
-celix_status_t versionRange_createVersionRange(version_pt low, bool isLowInclusive,
-			version_pt high, bool isHighInclusive, version_range_pt *range) {
-	celix_status_t status = CELIX_SUCCESS;
-	*range = (version_range_pt) malloc(sizeof(**range));
-	if (!*range) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*range)->low = low;
-		(*range)->isLowInclusive = isLowInclusive;
-		(*range)->high = high;
-		(*range)->isHighInclusive = isHighInclusive;
-	}
-
-	return status;
-}
-
-celix_status_t versionRange_destroy(version_range_pt range) {
-    if (range->high != NULL) {
-        version_destroy(range->high);
-    }
-    if (range->low != NULL) {
-        version_destroy(range->low);
-    }
-
-	range->high = NULL;
-	range->isHighInclusive = false;
-	range->low = NULL;
-	range->isLowInclusive = false;
-
-	free(range);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t versionRange_createInfiniteVersionRange(version_range_pt *range) {
-	celix_status_t status;
-
-	version_pt version = NULL;
-	status = version_createEmptyVersion(&version);
-	if (status == CELIX_SUCCESS) {
-		status = versionRange_createVersionRange(version, true, NULL, true, range);
-	}
-
-	return status;
-}
-
-celix_status_t versionRange_isInRange(version_range_pt versionRange, version_pt version, bool *inRange) {
-	celix_status_t status;
-	if (versionRange->high == NULL) {
-		int cmp;
-		status = version_compareTo(version, versionRange->low, &cmp);
-		if (status == CELIX_SUCCESS) {
-			*inRange = (cmp >= 0);
-		}
-	} else if (versionRange->isLowInclusive && versionRange->isHighInclusive) {
-		int low, high;
-		status = version_compareTo(version, versionRange->low, &low);
-		if (status == CELIX_SUCCESS) {
-			status = version_compareTo(version, versionRange->high, &high);
-			if (status == CELIX_SUCCESS) {
-				*inRange = (low >= 0) && (high <= 0);
-			}
-		}
-	} else if (versionRange->isHighInclusive) {
-		int low, high;
-		status = version_compareTo(version, versionRange->low, &low);
-		if (status == CELIX_SUCCESS) {
-			status = version_compareTo(version, versionRange->high, &high);
-			if (status == CELIX_SUCCESS) {
-				*inRange = (low > 0) && (high <= 0);
-			}
-		}
-	} else if (versionRange->isLowInclusive) {
-		int low, high;
-		status = version_compareTo(version, versionRange->low, &low);
-		if (status == CELIX_SUCCESS) {
-			status = version_compareTo(version, versionRange->high, &high);
-			if (status == CELIX_SUCCESS) {
-				*inRange = (low >= 0) && (high < 0);
-			}
-		}
-	} else {
-		int low, high;
-		status = version_compareTo(version, versionRange->low, &low);
-		if (status == CELIX_SUCCESS) {
-			status = version_compareTo(version, versionRange->high, &high);
-			if (status == CELIX_SUCCESS) {
-				*inRange = (low > 0) && (high < 0);
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t versionRange_getLowVersion(version_range_pt versionRange, version_pt *lowVersion) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (versionRange == NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-    else {
-        *lowVersion = versionRange->low;
-    }
-
-    return status;
-}
-
-celix_status_t versionRange_isLowInclusive(version_range_pt versionRange, bool *isLowInclusive) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (versionRange == NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-    else {
-        *isLowInclusive = versionRange->isLowInclusive;
-    }
-
-    return status;
-}
-
-celix_status_t versionRange_getHighVersion(version_range_pt versionRange, version_pt *highVersion) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (versionRange == NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-    else {
-        *highVersion = versionRange->high;
-    }
-
-    return status;
-}
-
-celix_status_t versionRange_isHighInclusive(version_range_pt versionRange, bool *isHighInclusive) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (versionRange == NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-    else {
-        *isHighInclusive = versionRange->isHighInclusive;
-    }
-
-    return status;
-}
-
-
-celix_status_t versionRange_parse(const char * rangeStr, version_range_pt *range) {
-	celix_status_t status;
-	if (strchr(rangeStr, ',') != NULL) {
-			int vlowL = strcspn(rangeStr+1, ",");
-			char * vlow = (char *) malloc(sizeof(char) * (vlowL + 1));
-			if (!vlow) {
-				status = CELIX_ENOMEM;
-			} else {
-				int vhighL;
-				char * vhigh;
-				vlow = strncpy(vlow, rangeStr+1, vlowL);
-				vlow[vlowL] = '\0';
-				vhighL = strlen(rangeStr+1) - vlowL - 2;
-				vhigh = (char *) malloc(sizeof(char) * (vhighL+1));
-				if (!vhigh) {
-					status = CELIX_ENOMEM;
-				} else {					
-					version_pt versionLow = NULL;
-					int rangeL = strlen(rangeStr);
-					char start = rangeStr[0];
-					char end = rangeStr[rangeL-1];
-
-					vhigh = strncpy(vhigh, rangeStr+vlowL+2, vhighL);
-					vhigh[vhighL] = '\0';
-					status = version_createVersionFromString(vlow, &versionLow);
-					if (status == CELIX_SUCCESS) {
-						version_pt versionHigh = NULL;
-						status = version_createVersionFromString(vhigh, &versionHigh);
-						if (status == CELIX_SUCCESS) {
-							status = versionRange_createVersionRange(
-									versionLow,
-									start == '[',
-									versionHigh,
-									end ==']',
-									range
-								);
-						}
-					}
-					free(vhigh);
-				}
-				free(vlow);
-
-		}
-	} else {
-		version_pt version = NULL;
-		status = version_createVersionFromString(rangeStr, &version);
-		if (status == CELIX_SUCCESS) {
-			status = versionRange_createVersionRange(version, true, NULL, false, range);
-		}
-	}
-
-	return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/array_list.h
----------------------------------------------------------------------
diff --git a/utils/public/include/array_list.h b/utils/public/include/array_list.h
deleted file mode 100644
index 4f83a45..0000000
--- a/utils/public/include/array_list.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- *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.
- */
-/*
- * array_list.h
- *
- *  \date       Aug 4, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef ARRAY_LIST_H_
-#define ARRAY_LIST_H_
-
-#include "celixbool.h"
-#include "exports.h"
-#include "celix_errno.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct arrayList *array_list_pt;
-
-typedef struct arrayListIterator *array_list_iterator_pt;
-
-typedef celix_status_t (*array_list_element_equals_pt)(const void *, const void *, bool *equals);
-
-UTILS_EXPORT celix_status_t arrayList_create(array_list_pt *list);
-
-UTILS_EXPORT celix_status_t arrayList_createWithEquals(array_list_element_equals_pt equals, array_list_pt *list);
-
-UTILS_EXPORT void arrayList_destroy(array_list_pt list);
-
-UTILS_EXPORT void arrayList_trimToSize(array_list_pt list);
-
-UTILS_EXPORT void arrayList_ensureCapacity(array_list_pt list, int capacity);
-
-UTILS_EXPORT unsigned int arrayList_size(array_list_pt list);
-
-UTILS_EXPORT bool arrayList_isEmpty(array_list_pt list);
-
-UTILS_EXPORT bool arrayList_contains(array_list_pt list, void *element);
-
-UTILS_EXPORT int arrayList_indexOf(array_list_pt list, void *element);
-
-UTILS_EXPORT int arrayList_lastIndexOf(array_list_pt list, void *element);
-
-UTILS_EXPORT void *arrayList_get(array_list_pt list, unsigned int index);
-
-UTILS_EXPORT void *arrayList_set(array_list_pt list, unsigned int index, void *element);
-
-UTILS_EXPORT bool arrayList_add(array_list_pt list, void *element);
-
-UTILS_EXPORT int arrayList_addIndex(array_list_pt list, unsigned int index, void *element);
-
-UTILS_EXPORT bool arrayList_addAll(array_list_pt list, array_list_pt toAdd);
-
-UTILS_EXPORT void *arrayList_remove(array_list_pt list, unsigned int index);
-
-UTILS_EXPORT bool arrayList_removeElement(array_list_pt list, void *element);
-
-UTILS_EXPORT void arrayList_clear(array_list_pt list);
-
-UTILS_EXPORT array_list_pt arrayList_clone(array_list_pt list);
-
-UTILS_EXPORT array_list_iterator_pt arrayListIterator_create(array_list_pt list);
-
-UTILS_EXPORT void arrayListIterator_destroy(array_list_iterator_pt iterator);
-
-UTILS_EXPORT bool arrayListIterator_hasNext(array_list_iterator_pt iterator);
-
-UTILS_EXPORT void *arrayListIterator_next(array_list_iterator_pt iterator);
-
-UTILS_EXPORT bool arrayListIterator_hasPrevious(array_list_iterator_pt iterator);
-
-UTILS_EXPORT void *arrayListIterator_previous(array_list_iterator_pt iterator);
-
-UTILS_EXPORT void arrayListIterator_remove(array_list_iterator_pt iterator);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* ARRAY_LIST_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/celix_errno.h
----------------------------------------------------------------------
diff --git a/utils/public/include/celix_errno.h b/utils/public/include/celix_errno.h
deleted file mode 100644
index b51540b..0000000
--- a/utils/public/include/celix_errno.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- *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_errno.h
- *
- *  \date       Feb 15, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-/*!
-  \file
-  \brief Error codes
-  \defgroup framework Celix Framework
- */
-#ifndef CELIX_ERRNO_H_
-#define CELIX_ERRNO_H_
-
-#include <stddef.h>
-#include <errno.h>
-
-#include "exports.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*!
- * Helper macro which check the current status and executes the provided expression if the
- * status is still CELIX_SUCCESS (0)
- */
-#define CELIX_DO_IF(status, expr) ((status) == CELIX_SUCCESS) ? (expr) : (status)
-
-/*!
- * \defgroup celix_errno Error Codes
- * \ingroup framework
- * \{
- */
-
-struct celix_status {
-    int code;
-    char *error;
-};
-
-/*!
- * Status type returned by all functions in Celix
- */
-typedef int celix_status_t;
-
-/*!
- * Return a readable string for the given error code.
- *
- */
-UTILS_EXPORT char *celix_strerror(celix_status_t errorcode, char *buffer, size_t bufferSize);
-
-/*!
- * Error code indicating successful execution of the function.
- */
-#define CELIX_SUCCESS 0
-
-/*!
- * Starting point for Celix errors.
- */
-#define CELIX_START_ERROR 70000
-
-/*!
- * The range for Celix errors.
- */
-#define CELIX_ERRSPACE_SIZE 1000
-
-/*!
- * The start error number user application can use.
- */
-#define CELIX_START_USERERR (CELIX_START_ERROR + CELIX_ERRSPACE_SIZE)
-
-/*!
- * Exception indicating a problem with a bundle
- */
-#define CELIX_BUNDLE_EXCEPTION (CELIX_START_ERROR + 1)
-/*!
- * Invalid bundle context is used
- */
-#define CELIX_INVALID_BUNDLE_CONTEXT (CELIX_START_ERROR + 2)
-/*!
- * Argument is not correct
- */
-#define CELIX_ILLEGAL_ARGUMENT (CELIX_START_ERROR + 3)
-#define CELIX_INVALID_SYNTAX (CELIX_START_ERROR + 4)
-#define CELIX_FRAMEWORK_SHUTDOWN (CELIX_START_ERROR + 5)
-#define CELIX_ILLEGAL_STATE (CELIX_START_ERROR + 6)
-#define CELIX_FRAMEWORK_EXCEPTION (CELIX_START_ERROR + 7)
-#define CELIX_FILE_IO_EXCEPTION (CELIX_START_ERROR + 8)
-#define CELIX_SERVICE_EXCEPTION (CELIX_START_ERROR + 9)
-
-#define CELIX_ENOMEM ENOMEM
-
-/**
- * \}
- */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CELIX_ERRNO_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/celix_threads.h
----------------------------------------------------------------------
diff --git a/utils/public/include/celix_threads.h b/utils/public/include/celix_threads.h
deleted file mode 100644
index 6af57bb..0000000
--- a/utils/public/include/celix_threads.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- *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_threads.h
- *
- *  \date       4 Jun 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef CELIX_THREADS_H_
-#define CELIX_THREADS_H_
-
-#include <pthread.h>
-#include <stdbool.h>
-
-#include "celix_errno.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct celix_thread {
-	bool threadInitialized;
-	pthread_t thread;
-};
-
-typedef pthread_once_t celix_thread_once_t;
-#define CELIX_THREAD_ONCE_INIT PTHREAD_ONCE_INIT
-
-typedef struct celix_thread celix_thread_t;
-typedef pthread_attr_t celix_thread_attr_t;
-
-typedef void *(*celix_thread_start_t)(void *);
-
-static const celix_thread_t celix_thread_default = {0, 0};
-
-celix_status_t
-celixThread_create(celix_thread_t *new_thread, celix_thread_attr_t *attr, celix_thread_start_t func, void *data);
-
-void celixThread_exit(void *exitStatus);
-
-celix_status_t celixThread_detach(celix_thread_t thread);
-
-celix_status_t celixThread_join(celix_thread_t thread, void **status);
-
-celix_status_t celixThread_kill(celix_thread_t thread, int sig);
-
-celix_thread_t celixThread_self(void);
-
-int celixThread_equals(celix_thread_t thread1, celix_thread_t thread2);
-
-bool celixThread_initalized(celix_thread_t thread);
-
-
-typedef pthread_mutex_t celix_thread_mutex_t;
-typedef pthread_mutexattr_t celix_thread_mutexattr_t;
-
-//MUTEX TYPES
-enum {
-	CELIX_THREAD_MUTEX_NORMAL,
-	CELIX_THREAD_MUTEX_RECURSIVE,
-	CELIX_THREAD_MUTEX_ERRORCHECK,
-	CELIX_THREAD_MUTEX_DEFAULT
-};
-
-
-celix_status_t celixThreadMutex_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t *attr);
-
-celix_status_t celixThreadMutex_destroy(celix_thread_mutex_t *mutex);
-
-celix_status_t celixThreadMutex_lock(celix_thread_mutex_t *mutex);
-
-celix_status_t celixThreadMutex_unlock(celix_thread_mutex_t *mutex);
-
-celix_status_t celixThreadMutexAttr_create(celix_thread_mutexattr_t *attr);
-
-celix_status_t celixThreadMutexAttr_destroy(celix_thread_mutexattr_t *attr);
-
-celix_status_t celixThreadMutexAttr_settype(celix_thread_mutexattr_t *attr, int type);
-
-typedef pthread_rwlock_t celix_thread_rwlock_t;
-typedef pthread_rwlockattr_t celix_thread_rwlockattr_t;
-
-celix_status_t celixThreadRwlock_create(celix_thread_rwlock_t *lock, celix_thread_rwlockattr_t *attr);
-
-celix_status_t celixThreadRwlock_destroy(celix_thread_rwlock_t *lock);
-
-celix_status_t celixThreadRwlock_readLock(celix_thread_rwlock_t *lock);
-
-celix_status_t celixThreadRwlock_writeLock(celix_thread_rwlock_t *lock);
-
-celix_status_t celixThreadRwlock_unlock(celix_thread_rwlock_t *lock);
-
-celix_status_t celixThreadRwlockAttr_create(celix_thread_rwlockattr_t *attr);
-
-celix_status_t celixThreadRwlockAttr_destroy(celix_thread_rwlockattr_t *attr);
-//NOTE: No support yet for setting specific rw lock attributes
-
-
-typedef pthread_cond_t celix_thread_cond_t;
-typedef pthread_condattr_t celix_thread_condattr_t;
-
-celix_status_t celixThreadCondition_init(celix_thread_cond_t *condition, celix_thread_condattr_t *attr);
-
-celix_status_t celixThreadCondition_destroy(celix_thread_cond_t *condition);
-
-celix_status_t celixThreadCondition_wait(celix_thread_cond_t *cond, celix_thread_mutex_t *mutex);
-
-celix_status_t celixThreadCondition_broadcast(celix_thread_cond_t *cond);
-
-celix_status_t celixThreadCondition_signal(celix_thread_cond_t *cond);
-
-celix_status_t celixThread_once(celix_thread_once_t *once_control, void (*init_routine)(void));
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* CELIX_THREADS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/public/include/celixbool.h
----------------------------------------------------------------------
diff --git a/utils/public/include/celixbool.h b/utils/public/include/celixbool.h
deleted file mode 100644
index 526392b..0000000
--- a/utils/public/include/celixbool.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *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.
- */
-/*
- * celixbool.h
- *
- *  \date       Jun 16, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef CELIXBOOL_H_
-#define CELIXBOOL_H_
-
-
-#if defined(__STDC__)
-# define C89
-# if defined(__STDC_VERSION__)
-#  define C90
-#  if (__STDC_VERSION__ >= 199409L)
-#   define C94
-#  endif
-#  if (__STDC_VERSION__ >= 199901L)
-#   define C99
-#  endif
-# endif
-#endif
-
-
-#if __STDC_VERSION__ < 199901L && __GNUC__ < 3
-// #ifndef C99
-
-typedef int _Bool;
-
-#define bool _Bool
-#define false 0 
-#define true 1
-
-
-#else
-
-#include <stdbool.h>
-
-#endif
-
-#endif /* CELIXBOOL_H_ */


[20/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/unzip.c
----------------------------------------------------------------------
diff --git a/framework/private/src/unzip.c b/framework/private/src/unzip.c
deleted file mode 100644
index d8a6716..0000000
--- a/framework/private/src/unzip.c
+++ /dev/null
@@ -1,2128 +0,0 @@
-/* unzip.c -- IO for uncompress .zip files using zlib
-   Version 1.1, February 14h, 2010
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications of Unzip for Zip64
-         Copyright (C) 2007-2008 Even Rouault
-
-         Modifications for Zip64 support on both zip and unzip
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-
-  ------------------------------------------------------------------------------------
-  Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
-  compatibility with older software. The following is from the original crypt.c.
-  Code woven in by Terry Thorsen 1/2003.
-
-  Copyright (c) 1990-2000 Info-ZIP.  All rights reserved.
-
-  See the accompanying file LICENSE, version 2000-Apr-09 or later
-  (the contents of which are also included in zip.h) for terms of use.
-  If, for some reason, all these files are missing, the Info-ZIP license
-  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
-
-        crypt.c (full version) by Info-ZIP.      Last revised:  [see crypt.h]
-
-  The encryption/decryption parts of this source code (as opposed to the
-  non-echoing password parts) were originally written in Europe.  The
-  whole source package can be freely distributed, including from the USA.
-  (Prior to January 2000, re-export from the US was a violation of US law.)
-
-        This encryption code is a direct transcription of the algorithm from
-  Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
-  file (appnote.txt) is distributed with the PKZIP program (even in the
-  version without encryption capabilities).
-
-        ------------------------------------------------------------------------------------
-
-        Changes in unzip.c
-
-        2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos
-  2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz*
-  2007-2008 - Even Rouault - Remove old C style function prototypes
-  2007-2008 - Even Rouault - Add unzip support for ZIP64
-
-        Copyright (C) 2007-2008 Even Rouault
-
-
-        Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
-  Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G
-                                should only read the compressed/uncompressed size from the Zip64 format if
-                                the size from normal header was 0xFFFFFFFF
-  Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant
-        Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required)
-                                Patch created by Daniel Borca
-
-  Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
-
-  Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson
-
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef NOUNCRYPT
-        #define NOUNCRYPT
-#endif
-
-#include "zlib.h"
-#include "unzip.h"
-
-#ifdef STDC
-#  include <stddef.h>
-#  include <string.h>
-#  include <stdlib.h>
-#endif
-#ifdef NO_ERRNO_H
-    extern int errno;
-#else
-#   include <errno.h>
-#endif
-
-
-#ifndef local
-#  define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-
-#ifndef CASESENSITIVITYDEFAULT_NO
-#  if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
-#    define CASESENSITIVITYDEFAULT_NO
-#  endif
-#endif
-
-
-#ifndef UNZ_BUFSIZE
-#define UNZ_BUFSIZE (16384)
-#endif
-
-#ifndef UNZ_MAXFILENAMEINZIP
-#define UNZ_MAXFILENAMEINZIP (256)
-#endif
-
-#ifndef ALLOC
-# define ALLOC(size) (malloc(size))
-#endif
-#ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
-#endif
-
-#define SIZECENTRALDIRITEM (0x2e)
-#define SIZEZIPLOCALHEADER (0x1e)
-
-
-const char unz_copyright[] =
-   " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
-
-/* unz_file_info_interntal contain internal info about a file in zipfile*/
-typedef struct unz_file_info64_internal_s
-{
-    ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
-} unz_file_info64_internal;
-
-
-/* file_in_zip_read_info_s contain internal information about a file in zipfile,
-    when reading and decompress it */
-typedef struct
-{
-    char  *read_buffer;         /* internal buffer for compressed data */
-    z_stream stream;            /* zLib stream structure for inflate */
-
-#ifdef HAVE_BZIP2
-    bz_stream bstream;          /* bzLib stream structure for bziped */
-#endif
-
-    ZPOS64_T pos_in_zipfile;       /* position in byte on the zipfile, for fseek*/
-    uLong stream_initialised;   /* flag set if stream structure is initialised*/
-
-    ZPOS64_T offset_local_extrafield;/* offset of the local extra field */
-    uInt  size_local_extrafield;/* size of the local extra field */
-    ZPOS64_T pos_local_extrafield;   /* position in the local extra field in read*/
-    ZPOS64_T total_out_64;
-
-    uLong crc32;                /* crc32 of all data uncompressed */
-    uLong crc32_wait;           /* crc32 we must obtain after decompress all */
-    ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
-    ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/
-    zlib_filefunc64_32_def z_filefunc;
-    voidpf filestream;        /* io structore of the zipfile */
-    uLong compression_method;   /* compression method (0==store) */
-    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
-    int   raw;
-} file_in_zip64_read_info_s;
-
-
-/* unz64_s contain internal information about the zipfile
-*/
-typedef struct
-{
-    zlib_filefunc64_32_def z_filefunc;
-    int is64bitOpenFunction;
-    voidpf filestream;        /* io structore of the zipfile */
-    unz_global_info64 gi;       /* public global information */
-    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
-    ZPOS64_T num_file;             /* number of the current file in the zipfile*/
-    ZPOS64_T pos_in_central_dir;   /* pos of the current file in the central dir*/
-    ZPOS64_T current_file_ok;      /* flag about the usability of the current file*/
-    ZPOS64_T central_pos;          /* position of the beginning of the central dir*/
-
-    ZPOS64_T size_central_dir;     /* size of the central directory  */
-    ZPOS64_T offset_central_dir;   /* offset of start of central directory with
-                                   respect to the starting disk number */
-
-    unz_file_info64 cur_file_info; /* public info about the current file in zip*/
-    unz_file_info64_internal cur_file_info_internal; /* private info about it*/
-    file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current
-                                        file if we are decompressing it */
-    int encrypted;
-
-    int isZip64;
-
-#    ifndef NOUNCRYPT
-    unsigned long keys[3];     /* keys defining the pseudo-random sequence */
-    const unsigned long* pcrc_32_tab;
-#    endif
-} unz64_s;
-
-
-#ifndef NOUNCRYPT
-#include "crypt.h"
-#endif
-
-/* ===========================================================================
-     Read a byte from a gz_stream; update next_in and avail_in. Return EOF
-   for end of file.
-   IN assertion: the stream s has been sucessfully opened for reading.
-*/
-
-
-local int unz64local_getByte OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream,
-    int *pi));
-
-local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
-{
-    unsigned char c;
-    int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
-    if (err==1)
-    {
-        *pi = (int)c;
-        return UNZ_OK;
-    }
-    else
-    {
-        if (ZERROR64(*pzlib_filefunc_def,filestream))
-            return UNZ_ERRNO;
-        else
-            return UNZ_EOF;
-    }
-}
-
-
-/* ===========================================================================
-   Reads a long in LSB order from the given gz_stream. Sets
-*/
-local int unz64local_getShort OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream,
-    uLong *pX));
-
-local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
-                             voidpf filestream,
-                             uLong *pX)
-{
-    uLong x ;
-    int i = 0;
-    int err;
-
-    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x = (uLong)i;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((uLong)i)<<8;
-
-    if (err==UNZ_OK)
-        *pX = x;
-    else
-        *pX = 0;
-    return err;
-}
-
-local int unz64local_getLong OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream,
-    uLong *pX));
-
-local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
-                            voidpf filestream,
-                            uLong *pX)
-{
-    uLong x ;
-    int i = 0;
-    int err;
-
-    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x = (uLong)i;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((uLong)i)<<8;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((uLong)i)<<16;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x += ((uLong)i)<<24;
-
-    if (err==UNZ_OK)
-        *pX = x;
-    else
-        *pX = 0;
-    return err;
-}
-
-local int unz64local_getLong64 OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream,
-    ZPOS64_T *pX));
-
-
-local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
-                            voidpf filestream,
-                            ZPOS64_T *pX)
-{
-    ZPOS64_T x ;
-    int i = 0;
-    int err;
-
-    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x = (ZPOS64_T)i;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<8;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<16;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<24;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<32;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<40;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<48;
-
-    if (err==UNZ_OK)
-        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-    x |= ((ZPOS64_T)i)<<56;
-
-    if (err==UNZ_OK)
-        *pX = x;
-    else
-        *pX = 0;
-    return err;
-}
-
-/* My own strcmpi / strcasecmp */
-local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)
-{
-    for (;;)
-    {
-        char c1=*(fileName1++);
-        char c2=*(fileName2++);
-        if ((c1>='a') && (c1<='z'))
-            c1 -= 0x20;
-        if ((c2>='a') && (c2<='z'))
-            c2 -= 0x20;
-        if (c1=='\0')
-            return ((c2=='\0') ? 0 : -1);
-        if (c2=='\0')
-            return 1;
-        if (c1<c2)
-            return -1;
-        if (c1>c2)
-            return 1;
-    }
-}
-
-
-#ifdef  CASESENSITIVITYDEFAULT_NO
-#define CASESENSITIVITYDEFAULTVALUE 2
-#else
-#define CASESENSITIVITYDEFAULTVALUE 1
-#endif
-
-#ifndef STRCMPCASENOSENTIVEFUNCTION
-#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
-#endif
-
-/*
-   Compare two filename (fileName1,fileName2).
-   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
-   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
-                                                                or strcasecmp)
-   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
-        (like 1 on Unix, 2 on Windows)
-
-*/
-extern int ZEXPORT unzStringFileNameCompare (const char*  fileName1,
-                                                 const char*  fileName2,
-                                                 int iCaseSensitivity)
-
-{
-    if (iCaseSensitivity==0)
-        iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
-
-    if (iCaseSensitivity==1)
-        return strcmp(fileName1,fileName2);
-
-    return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
-}
-
-#ifndef BUFREADCOMMENT
-#define BUFREADCOMMENT (0x400)
-#endif
-
-/*
-  Locate the Central directory of a zipfile (at the end, just before
-    the global comment)
-*/
-local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
-local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
-{
-    unsigned char* buf;
-    ZPOS64_T uSizeFile;
-    ZPOS64_T uBackRead;
-    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
-    ZPOS64_T uPosFound=0;
-
-    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
-        return 0;
-
-
-    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
-
-    if (uMaxBack>uSizeFile)
-        uMaxBack = uSizeFile;
-
-    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
-    if (buf==NULL)
-        return 0;
-
-    uBackRead = 4;
-    while (uBackRead<uMaxBack)
-    {
-        uLong uReadSize;
-        ZPOS64_T uReadPos ;
-        int i;
-        if (uBackRead+BUFREADCOMMENT>uMaxBack)
-            uBackRead = uMaxBack;
-        else
-            uBackRead+=BUFREADCOMMENT;
-        uReadPos = uSizeFile-uBackRead ;
-
-        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
-                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
-        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-            break;
-
-        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
-            break;
-
-        for (i=(int)uReadSize-3; (i--)>0;)
-            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
-                ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
-            {
-                uPosFound = uReadPos+i;
-                break;
-            }
-
-        if (uPosFound!=0)
-            break;
-    }
-    TRYFREE(buf);
-    return uPosFound;
-}
-
-
-/*
-  Locate the Central directory 64 of a zipfile (at the end, just before
-    the global comment)
-*/
-local ZPOS64_T unz64local_SearchCentralDir64 OF((
-    const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream));
-
-local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
-                                      voidpf filestream)
-{
-    unsigned char* buf;
-    ZPOS64_T uSizeFile;
-    ZPOS64_T uBackRead;
-    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
-    ZPOS64_T uPosFound=0;
-    uLong uL;
-                ZPOS64_T relativeOffset;
-
-    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
-        return 0;
-
-
-    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
-
-    if (uMaxBack>uSizeFile)
-        uMaxBack = uSizeFile;
-
-    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
-    if (buf==NULL)
-        return 0;
-
-    uBackRead = 4;
-    while (uBackRead<uMaxBack)
-    {
-        uLong uReadSize;
-        ZPOS64_T uReadPos;
-        int i;
-        if (uBackRead+BUFREADCOMMENT>uMaxBack)
-            uBackRead = uMaxBack;
-        else
-            uBackRead+=BUFREADCOMMENT;
-        uReadPos = uSizeFile-uBackRead ;
-
-        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
-                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
-        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-            break;
-
-        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
-            break;
-
-        for (i=(int)uReadSize-3; (i--)>0;)
-            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
-                ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
-            {
-                uPosFound = uReadPos+i;
-                break;
-            }
-
-        if (uPosFound!=0)
-            break;
-    }
-    TRYFREE(buf);
-    if (uPosFound == 0)
-        return 0;
-
-    /* Zip64 end of central directory locator */
-    if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return 0;
-
-    /* the signature, already checked */
-    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-        return 0;
-
-    /* number of the disk with the start of the zip64 end of  central directory */
-    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-        return 0;
-    if (uL != 0)
-        return 0;
-
-    /* relative offset of the zip64 end of central directory record */
-    if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
-        return 0;
-
-    /* total number of disks */
-    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-        return 0;
-    if (uL != 1)
-        return 0;
-
-    /* Goto end of central directory record */
-    if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return 0;
-
-     /* the signature */
-    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-        return 0;
-
-    if (uL != 0x06064b50)
-        return 0;
-
-    return relativeOffset;
-}
-
-/*
-  Open a Zip file. path contain the full pathname (by example,
-     on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
-     "zlib/zlib114.zip".
-     If the zipfile cannot be opened (file doesn't exist or in not valid), the
-       return value is NULL.
-     Else, the return value is a unzFile Handle, usable with other function
-       of this unzip package.
-*/
-local unzFile unzOpenInternal (const void *path,
-                               zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
-                               int is64bitOpenFunction)
-{
-    unz64_s us;
-    unz64_s *s;
-    ZPOS64_T central_pos;
-    uLong   uL;
-
-    uLong number_disk;          /* number of the current dist, used for
-                                   spaning ZIP, unsupported, always 0*/
-    uLong number_disk_with_CD;  /* number the the disk with central dir, used
-                                   for spaning ZIP, unsupported, always 0*/
-    ZPOS64_T number_entry_CD;      /* total number of entries in
-                                   the central dir
-                                   (same than number_entry on nospan) */
-
-    int err=UNZ_OK;
-
-    if (unz_copyright[0]!=' ')
-        return NULL;
-
-    memset(&us,0,sizeof(unz64_s));
-    us.z_filefunc.zseek32_file = NULL;
-    us.z_filefunc.ztell32_file = NULL;
-    if (pzlib_filefunc64_32_def==NULL)
-        fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
-    else
-        us.z_filefunc = *pzlib_filefunc64_32_def;
-    us.is64bitOpenFunction = is64bitOpenFunction;
-
-
-
-    us.filestream = ZOPEN64(us.z_filefunc,
-                                                 path,
-                                                 ZLIB_FILEFUNC_MODE_READ |
-                                                 ZLIB_FILEFUNC_MODE_EXISTING);
-    if (us.filestream==NULL)
-        return NULL;
-
-    central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
-    if (central_pos)
-    {
-        uLong uS;
-        ZPOS64_T uL64;
-
-        us.isZip64 = 1;
-
-        if (ZSEEK64(us.z_filefunc, us.filestream,
-                                      central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        err=UNZ_ERRNO;
-
-        /* the signature, already checked */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* size of zip64 end of central directory record */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* version made by */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* version needed to extract */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* number of this disk */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* number of the disk with the start of the central directory */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* total number of entries in the central directory on this disk */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* total number of entries in the central directory */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        if ((number_entry_CD!=us.gi.number_entry) ||
-            (number_disk_with_CD!=0) ||
-            (number_disk!=0))
-            err=UNZ_BADZIPFILE;
-
-        /* size of the central directory */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* offset of start of central directory with respect to the
-          starting disk number */
-        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        us.gi.size_comment = 0;
-    }
-    else
-    {
-        central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);
-        if (central_pos==0)
-            err=UNZ_ERRNO;
-
-        us.isZip64 = 0;
-
-        if (ZSEEK64(us.z_filefunc, us.filestream,
-                                        central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-            err=UNZ_ERRNO;
-
-        /* the signature, already checked */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* number of this disk */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* number of the disk with the start of the central directory */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
-            err=UNZ_ERRNO;
-
-        /* total number of entries in the central dir on this disk */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-        us.gi.number_entry = uL;
-
-        /* total number of entries in the central dir */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-        number_entry_CD = uL;
-
-        if ((number_entry_CD!=us.gi.number_entry) ||
-            (number_disk_with_CD!=0) ||
-            (number_disk!=0))
-            err=UNZ_BADZIPFILE;
-
-        /* size of the central directory */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-        us.size_central_dir = uL;
-
-        /* offset of start of central directory with respect to the
-            starting disk number */
-        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-            err=UNZ_ERRNO;
-        us.offset_central_dir = uL;
-
-        /* zipfile comment length */
-        if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
-            err=UNZ_ERRNO;
-    }
-
-    if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
-        (err==UNZ_OK))
-        err=UNZ_BADZIPFILE;
-
-    if (err!=UNZ_OK)
-    {
-        ZCLOSE64(us.z_filefunc, us.filestream);
-        return NULL;
-    }
-
-    us.byte_before_the_zipfile = central_pos -
-                            (us.offset_central_dir+us.size_central_dir);
-    us.central_pos = central_pos;
-    us.pfile_in_zip_read = NULL;
-    us.encrypted = 0;
-    us.num_file = 0;
-
-
-    s=(unz64_s*)ALLOC(sizeof(unz64_s));
-    if( s != NULL)
-    {
-        *s=us;
-        unzGoToFirstFile((unzFile)s);
-    }
-    return (unzFile)s;
-}
-
-
-extern unzFile ZEXPORT unzOpen2 (const char *path,
-                                        zlib_filefunc_def* pzlib_filefunc32_def)
-{
-    if (pzlib_filefunc32_def != NULL)
-    {
-        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
-        fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);
-        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0);
-    }
-    else
-        return unzOpenInternal(path, NULL, 0);
-}
-
-extern unzFile ZEXPORT unzOpen2_64 (const void *path,
-                                     zlib_filefunc64_def* pzlib_filefunc_def)
-{
-    if (pzlib_filefunc_def != NULL)
-    {
-        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
-        zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
-        zlib_filefunc64_32_def_fill.ztell32_file = NULL;
-        zlib_filefunc64_32_def_fill.zseek32_file = NULL;
-        zlib_filefunc64_32_def_fill.zopen32_file = NULL;
-        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
-    }
-    else
-        return unzOpenInternal(path, NULL, 1);
-}
-
-extern unzFile ZEXPORT unzOpen (const char *path)
-{
-    return unzOpenInternal(path, NULL, 0);
-}
-
-extern unzFile ZEXPORT unzOpen64 (const void *path)
-{
-    return unzOpenInternal(path, NULL, 1);
-}
-
-/*
-  Close a ZipFile opened with unzipOpen.
-  If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
-    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
-  return UNZ_OK if there is no problem. */
-extern int ZEXPORT unzClose (unzFile file)
-{
-    unz64_s* s;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-
-    if (s->pfile_in_zip_read!=NULL)
-        unzCloseCurrentFile(file);
-
-    ZCLOSE64(s->z_filefunc, s->filestream);
-    TRYFREE(s);
-    return UNZ_OK;
-}
-
-
-/*
-  Write info about the ZipFile in the *pglobal_info structure.
-  No preparation of the structure is needed
-  return UNZ_OK if there is no problem. */
-extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)
-{
-    unz64_s* s;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    *pglobal_info=s->gi;
-    return UNZ_OK;
-}
-
-extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)
-{
-    unz64_s* s;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    /* to do : check if number_entry is not truncated */
-    pglobal_info32->number_entry = (uLong)s->gi.number_entry;
-    pglobal_info32->size_comment = s->gi.size_comment;
-    return UNZ_OK;
-}
-/*
-   Translate date/time from Dos format to tm_unz (readable more easilty)
-*/
-local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
-{
-    ZPOS64_T uDate;
-    uDate = (ZPOS64_T)(ulDosDate>>16);
-    ptm->tm_mday = (uInt)(uDate&0x1f) ;
-    ptm->tm_mon =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;
-    ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
-
-    ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
-    ptm->tm_min =  (uInt) ((ulDosDate&0x7E0)/0x20) ;
-    ptm->tm_sec =  (uInt) (2*(ulDosDate&0x1f)) ;
-}
-
-/*
-  Get Info about the current file in the zipfile, with internal only info
-*/
-local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
-                                                  unz_file_info64 *pfile_info,
-                                                  unz_file_info64_internal
-                                                  *pfile_info_internal,
-                                                  char *szFileName,
-                                                  uLong fileNameBufferSize,
-                                                  void *extraField,
-                                                  uLong extraFieldBufferSize,
-                                                  char *szComment,
-                                                  uLong commentBufferSize));
-
-local int unz64local_GetCurrentFileInfoInternal (unzFile file,
-                                                  unz_file_info64 *pfile_info,
-                                                  unz_file_info64_internal
-                                                  *pfile_info_internal,
-                                                  char *szFileName,
-                                                  uLong fileNameBufferSize,
-                                                  void *extraField,
-                                                  uLong extraFieldBufferSize,
-                                                  char *szComment,
-                                                  uLong commentBufferSize)
-{
-    unz64_s* s;
-    unz_file_info64 file_info;
-    unz_file_info64_internal file_info_internal;
-    int err=UNZ_OK;
-    uLong uMagic;
-    long lSeek=0;
-    uLong uL;
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (ZSEEK64(s->z_filefunc, s->filestream,
-              s->pos_in_central_dir+s->byte_before_the_zipfile,
-              ZLIB_FILEFUNC_SEEK_SET)!=0)
-        err=UNZ_ERRNO;
-
-
-    /* we check the magic */
-    if (err==UNZ_OK)
-    {
-        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
-            err=UNZ_ERRNO;
-        else if (uMagic!=0x02014b50)
-            err=UNZ_BADZIPFILE;
-    }
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-        err=UNZ_ERRNO;
-    file_info.compressed_size = uL;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-        err=UNZ_ERRNO;
-    file_info.uncompressed_size = uL;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-                // relative offset of local header
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-        err=UNZ_ERRNO;
-    file_info_internal.offset_curfile = uL;
-
-    lSeek+=file_info.size_filename;
-    if ((err==UNZ_OK) && (szFileName!=NULL))
-    {
-        uLong uSizeRead ;
-        if (file_info.size_filename<fileNameBufferSize)
-        {
-            *(szFileName+file_info.size_filename)='\0';
-            uSizeRead = file_info.size_filename;
-        }
-        else
-            uSizeRead = fileNameBufferSize;
-
-        if ((file_info.size_filename>0) && (fileNameBufferSize>0))
-            if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
-                err=UNZ_ERRNO;
-        lSeek -= uSizeRead;
-    }
-
-    // Read extrafield
-    if ((err==UNZ_OK) && (extraField!=NULL))
-    {
-        ZPOS64_T uSizeRead ;
-        if (file_info.size_file_extra<extraFieldBufferSize)
-            uSizeRead = file_info.size_file_extra;
-        else
-            uSizeRead = extraFieldBufferSize;
-
-        if (lSeek!=0)
-        {
-            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-                lSeek=0;
-            else
-                err=UNZ_ERRNO;
-        }
-
-        if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
-            if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)
-                err=UNZ_ERRNO;
-
-        lSeek += file_info.size_file_extra - (uLong)uSizeRead;
-    }
-    else
-        lSeek += file_info.size_file_extra;
-
-
-    if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
-    {
-                                uLong acc = 0;
-
-        // since lSeek now points to after the extra field we need to move back
-        lSeek -= file_info.size_file_extra;
-
-        if (lSeek!=0)
-        {
-            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-                lSeek=0;
-            else
-                err=UNZ_ERRNO;
-        }
-
-        while(acc < file_info.size_file_extra)
-        {
-            uLong headerId;
-                                                uLong dataSize;
-
-            if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)
-                err=UNZ_ERRNO;
-
-            if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)
-                err=UNZ_ERRNO;
-
-            /* ZIP64 extra fields */
-            if (headerId == 0x0001)
-            {
-                                                        uLong uL;
-
-                                                                if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)
-                                                                {
-                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
-                                                                                        err=UNZ_ERRNO;
-                                                                }
-
-                                                                if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)
-                                                                {
-                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
-                                                                                  err=UNZ_ERRNO;
-                                                                }
-
-                                                                if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)
-                                                                {
-                                                                        /* Relative Header offset */
-                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
-                                                                                err=UNZ_ERRNO;
-                                                                }
-
-                                                                if(file_info.disk_num_start == (unsigned long)-1)
-                                                                {
-                                                                        /* Disk Start Number */
-                                                                        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-                                                                                err=UNZ_ERRNO;
-                                                                }
-
-            }
-            else
-            {
-                if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
-                    err=UNZ_ERRNO;
-            }
-
-            acc += 2 + 2 + dataSize;
-        }
-    }
-
-    if ((err==UNZ_OK) && (szComment!=NULL))
-    {
-        uLong uSizeRead ;
-        if (file_info.size_file_comment<commentBufferSize)
-        {
-            *(szComment+file_info.size_file_comment)='\0';
-            uSizeRead = file_info.size_file_comment;
-        }
-        else
-            uSizeRead = commentBufferSize;
-
-        if (lSeek!=0)
-        {
-            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-                lSeek=0;
-            else
-                err=UNZ_ERRNO;
-        }
-
-        if ((file_info.size_file_comment>0) && (commentBufferSize>0))
-            if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
-                err=UNZ_ERRNO;
-        lSeek+=file_info.size_file_comment - uSizeRead;
-    }
-    else
-        lSeek+=file_info.size_file_comment;
-
-
-    if ((err==UNZ_OK) && (pfile_info!=NULL))
-        *pfile_info=file_info;
-
-    if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
-        *pfile_info_internal=file_info_internal;
-
-    return err;
-}
-
-
-
-/*
-  Write info about the ZipFile in the *pglobal_info structure.
-  No preparation of the structure is needed
-  return UNZ_OK if there is no problem.
-*/
-extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
-                                          unz_file_info64 * pfile_info,
-                                          char * szFileName, uLong fileNameBufferSize,
-                                          void *extraField, uLong extraFieldBufferSize,
-                                          char* szComment,  uLong commentBufferSize)
-{
-    return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
-                                                szFileName,fileNameBufferSize,
-                                                extraField,extraFieldBufferSize,
-                                                szComment,commentBufferSize);
-}
-
-extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
-                                          unz_file_info * pfile_info,
-                                          char * szFileName, uLong fileNameBufferSize,
-                                          void *extraField, uLong extraFieldBufferSize,
-                                          char* szComment,  uLong commentBufferSize)
-{
-    int err;
-    unz_file_info64 file_info64;
-    err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
-                                                szFileName,fileNameBufferSize,
-                                                extraField,extraFieldBufferSize,
-                                                szComment,commentBufferSize);
-    if (err==UNZ_OK)
-    {
-        pfile_info->version = file_info64.version;
-        pfile_info->version_needed = file_info64.version_needed;
-        pfile_info->flag = file_info64.flag;
-        pfile_info->compression_method = file_info64.compression_method;
-        pfile_info->dosDate = file_info64.dosDate;
-        pfile_info->crc = file_info64.crc;
-
-        pfile_info->size_filename = file_info64.size_filename;
-        pfile_info->size_file_extra = file_info64.size_file_extra;
-        pfile_info->size_file_comment = file_info64.size_file_comment;
-
-        pfile_info->disk_num_start = file_info64.disk_num_start;
-        pfile_info->internal_fa = file_info64.internal_fa;
-        pfile_info->external_fa = file_info64.external_fa;
-
-        pfile_info->tmu_date = file_info64.tmu_date,
-
-
-        pfile_info->compressed_size = (uLong)file_info64.compressed_size;
-        pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
-
-    }
-    return err;
-}
-/*
-  Set the current file of the zipfile to the first file.
-  return UNZ_OK if there is no problem
-*/
-extern int ZEXPORT unzGoToFirstFile (unzFile file)
-{
-    int err=UNZ_OK;
-    unz64_s* s;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    s->pos_in_central_dir=s->offset_central_dir;
-    s->num_file=0;
-    err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-                                             &s->cur_file_info_internal,
-                                             NULL,0,NULL,0,NULL,0);
-    s->current_file_ok = (err == UNZ_OK);
-    return err;
-}
-
-/*
-  Set the current file of the zipfile to the next file.
-  return UNZ_OK if there is no problem
-  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-extern int ZEXPORT unzGoToNextFile (unzFile  file)
-{
-    unz64_s* s;
-    int err;
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-        return UNZ_END_OF_LIST_OF_FILE;
-    if (s->gi.number_entry != 0xffff)    /* 2^16 files overflow hack */
-      if (s->num_file+1==s->gi.number_entry)
-        return UNZ_END_OF_LIST_OF_FILE;
-
-    s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
-            s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
-    s->num_file++;
-    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-                                               &s->cur_file_info_internal,
-                                               NULL,0,NULL,0,NULL,0);
-    s->current_file_ok = (err == UNZ_OK);
-    return err;
-}
-
-
-/*
-  Try locate the file szFileName in the zipfile.
-  For the iCaseSensitivity signification, see unzipStringFileNameCompare
-
-  return value :
-  UNZ_OK if the file is found. It becomes the current file.
-  UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
-{
-    unz64_s* s;
-    int err;
-
-    /* We remember the 'current' position in the file so that we can jump
-     * back there if we fail.
-     */
-    unz_file_info64 cur_file_infoSaved;
-    unz_file_info64_internal cur_file_info_internalSaved;
-    ZPOS64_T num_fileSaved;
-    ZPOS64_T pos_in_central_dirSaved;
-
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-
-    if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
-        return UNZ_PARAMERROR;
-
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-        return UNZ_END_OF_LIST_OF_FILE;
-
-    /* Save the current state */
-    num_fileSaved = s->num_file;
-    pos_in_central_dirSaved = s->pos_in_central_dir;
-    cur_file_infoSaved = s->cur_file_info;
-    cur_file_info_internalSaved = s->cur_file_info_internal;
-
-    err = unzGoToFirstFile(file);
-
-    while (err == UNZ_OK)
-    {
-        char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
-        err = unzGetCurrentFileInfo64(file,NULL,
-                                    szCurrentFileName,sizeof(szCurrentFileName)-1,
-                                    NULL,0,NULL,0);
-        if (err == UNZ_OK)
-        {
-            if (unzStringFileNameCompare(szCurrentFileName,
-                                            szFileName,iCaseSensitivity)==0)
-                return UNZ_OK;
-            err = unzGoToNextFile(file);
-        }
-    }
-
-    /* We failed, so restore the state of the 'current file' to where we
-     * were.
-     */
-    s->num_file = num_fileSaved ;
-    s->pos_in_central_dir = pos_in_central_dirSaved ;
-    s->cur_file_info = cur_file_infoSaved;
-    s->cur_file_info_internal = cur_file_info_internalSaved;
-    return err;
-}
-
-
-/*
-///////////////////////////////////////////
-// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
-// I need random access
-//
-// Further optimization could be realized by adding an ability
-// to cache the directory in memory. The goal being a single
-// comprehensive file read to put the file I need in a memory.
-*/
-
-/*
-typedef struct unz_file_pos_s
-{
-    ZPOS64_T pos_in_zip_directory;   // offset in file
-    ZPOS64_T num_of_file;            // # of file
-} unz_file_pos;
-*/
-
-extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos*  file_pos)
-{
-    unz64_s* s;
-
-    if (file==NULL || file_pos==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-        return UNZ_END_OF_LIST_OF_FILE;
-
-    file_pos->pos_in_zip_directory  = s->pos_in_central_dir;
-    file_pos->num_of_file           = s->num_file;
-
-    return UNZ_OK;
-}
-
-extern int ZEXPORT unzGetFilePos(
-    unzFile file,
-    unz_file_pos* file_pos)
-{
-    unz64_file_pos file_pos64;
-    int err = unzGetFilePos64(file,&file_pos64);
-    if (err==UNZ_OK)
-    {
-        file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
-        file_pos->num_of_file = (uLong)file_pos64.num_of_file;
-    }
-    return err;
-}
-
-extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)
-{
-    unz64_s* s;
-    int err;
-
-    if (file==NULL || file_pos==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-
-    /* jump to the right spot */
-    s->pos_in_central_dir = file_pos->pos_in_zip_directory;
-    s->num_file           = file_pos->num_of_file;
-
-    /* set the current file */
-    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-                                               &s->cur_file_info_internal,
-                                               NULL,0,NULL,0,NULL,0);
-    /* return results */
-    s->current_file_ok = (err == UNZ_OK);
-    return err;
-}
-
-extern int ZEXPORT unzGoToFilePos(
-    unzFile file,
-    unz_file_pos* file_pos)
-{
-    unz64_file_pos file_pos64;
-    if (file_pos == NULL)
-        return UNZ_PARAMERROR;
-
-    file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
-    file_pos64.num_of_file = file_pos->num_of_file;
-    return unzGoToFilePos64(file,&file_pos64);
-}
-
-/*
-// Unzip Helper Functions - should be here?
-///////////////////////////////////////////
-*/
-
-/*
-  Read the local header of the current zipfile
-  Check the coherency of the local header and info in the end of central
-        directory about this file
-  store in *piSizeVar the size of extra info in local header
-        (filename and size of extra field data)
-*/
-local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,
-                                                    ZPOS64_T * poffset_local_extrafield,
-                                                    uInt  * psize_local_extrafield)
-{
-    uLong uMagic,uData,uFlags;
-    uLong size_filename;
-    uLong size_extra_field;
-    int err=UNZ_OK;
-
-    *piSizeVar = 0;
-    *poffset_local_extrafield = 0;
-    *psize_local_extrafield = 0;
-
-    if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
-                                s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return UNZ_ERRNO;
-
-
-    if (err==UNZ_OK)
-    {
-        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
-            err=UNZ_ERRNO;
-        else if (uMagic!=0x04034b50)
-            err=UNZ_BADZIPFILE;
-    }
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
-        err=UNZ_ERRNO;
-/*
-    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
-        err=UNZ_BADZIPFILE;
-*/
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
-        err=UNZ_ERRNO;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
-        err=UNZ_ERRNO;
-    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
-        err=UNZ_BADZIPFILE;
-
-    if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
-/* #ifdef HAVE_BZIP2 */
-                         (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-/* #endif */
-                         (s->cur_file_info.compression_method!=Z_DEFLATED))
-        err=UNZ_BADZIPFILE;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
-        err=UNZ_ERRNO;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
-        err=UNZ_ERRNO;
-    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))
-        err=UNZ_BADZIPFILE;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
-        err=UNZ_ERRNO;
-    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))
-        err=UNZ_BADZIPFILE;
-
-    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
-        err=UNZ_ERRNO;
-    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))
-        err=UNZ_BADZIPFILE;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
-        err=UNZ_ERRNO;
-    else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
-        err=UNZ_BADZIPFILE;
-
-    *piSizeVar += (uInt)size_filename;
-
-    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
-        err=UNZ_ERRNO;
-    *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
-                                    SIZEZIPLOCALHEADER + size_filename;
-    *psize_local_extrafield = (uInt)size_extra_field;
-
-    *piSizeVar += (uInt)size_extra_field;
-
-    return err;
-}
-
-/*
-  Open for reading data the current file in the zipfile.
-  If there is no error and the file is opened, the return value is UNZ_OK.
-*/
-extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
-                                            int* level, int raw, const char* password)
-{
-    int err=UNZ_OK;
-    uInt iSizeVar;
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    ZPOS64_T offset_local_extrafield;  /* offset of the local extra field */
-    uInt  size_local_extrafield;    /* size of the local extra field */
-#    ifndef NOUNCRYPT
-    char source[12];
-#    else
-    if (password != NULL)
-        return UNZ_PARAMERROR;
-#    endif
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-        return UNZ_PARAMERROR;
-
-    if (s->pfile_in_zip_read != NULL)
-        unzCloseCurrentFile(file);
-
-    if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
-        return UNZ_BADZIPFILE;
-
-    pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s));
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_INTERNALERROR;
-
-    pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
-    pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
-    pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
-    pfile_in_zip_read_info->pos_local_extrafield=0;
-    pfile_in_zip_read_info->raw=raw;
-
-    if (pfile_in_zip_read_info->read_buffer==NULL)
-    {
-        TRYFREE(pfile_in_zip_read_info);
-        return UNZ_INTERNALERROR;
-    }
-
-    pfile_in_zip_read_info->stream_initialised=0;
-
-    if (method!=NULL)
-        *method = (int)s->cur_file_info.compression_method;
-
-    if (level!=NULL)
-    {
-        *level = 6;
-        switch (s->cur_file_info.flag & 0x06)
-        {
-          case 6 : *level = 1; break;
-          case 4 : *level = 2; break;
-          case 2 : *level = 9; break;
-        }
-    }
-
-    if ((s->cur_file_info.compression_method!=0) &&
-/* #ifdef HAVE_BZIP2 */
-        (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-/* #endif */
-        (s->cur_file_info.compression_method!=Z_DEFLATED))
-
-        err=UNZ_BADZIPFILE;
-
-    pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
-    pfile_in_zip_read_info->crc32=0;
-    pfile_in_zip_read_info->total_out_64=0;
-    pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;
-    pfile_in_zip_read_info->filestream=s->filestream;
-    pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
-    pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
-
-    pfile_in_zip_read_info->stream.total_out = 0;
-
-    if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))
-    {
-#ifdef HAVE_BZIP2
-      pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
-      pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
-      pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
-      pfile_in_zip_read_info->bstream.state = (voidpf)0;
-
-      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
-      pfile_in_zip_read_info->stream.zfree = (free_func)0;
-      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
-      pfile_in_zip_read_info->stream.next_in = (voidpf)0;
-      pfile_in_zip_read_info->stream.avail_in = 0;
-
-      err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
-      if (err == Z_OK)
-        pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
-      else
-      {
-        TRYFREE(pfile_in_zip_read_info);
-        return err;
-      }
-#else
-      pfile_in_zip_read_info->raw=1;
-#endif
-    }
-    else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
-    {
-      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
-      pfile_in_zip_read_info->stream.zfree = (free_func)0;
-      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
-      pfile_in_zip_read_info->stream.next_in = 0;
-      pfile_in_zip_read_info->stream.avail_in = 0;
-
-      err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
-      if (err == Z_OK)
-        pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
-      else
-      {
-        TRYFREE(pfile_in_zip_read_info);
-        return err;
-      }
-        /* windowBits is passed < 0 to tell that there is no zlib header.
-         * Note that in this case inflate *requires* an extra "dummy" byte
-         * after the compressed stream in order to complete decompression and
-         * return Z_STREAM_END.
-         * In unzip, i don't wait absolutely Z_STREAM_END because I known the
-         * size of both compressed and uncompressed data
-         */
-    }
-    pfile_in_zip_read_info->rest_read_compressed =
-            s->cur_file_info.compressed_size ;
-    pfile_in_zip_read_info->rest_read_uncompressed =
-            s->cur_file_info.uncompressed_size ;
-
-
-    pfile_in_zip_read_info->pos_in_zipfile =
-            s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
-              iSizeVar;
-
-    pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-
-    s->pfile_in_zip_read = pfile_in_zip_read_info;
-                s->encrypted = 0;
-
-#    ifndef NOUNCRYPT
-    if (password != NULL)
-    {
-        int i;
-        s->pcrc_32_tab = get_crc_table();
-        init_keys(password,s->keys,s->pcrc_32_tab);
-        if (ZSEEK64(s->z_filefunc, s->filestream,
-                  s->pfile_in_zip_read->pos_in_zipfile +
-                     s->pfile_in_zip_read->byte_before_the_zipfile,
-                  SEEK_SET)!=0)
-            return UNZ_INTERNALERROR;
-        if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12)
-            return UNZ_INTERNALERROR;
-
-        for (i = 0; i<12; i++)
-            zdecode(s->keys,s->pcrc_32_tab,source[i]);
-
-        s->pfile_in_zip_read->pos_in_zipfile+=12;
-        s->encrypted=1;
-    }
-#    endif
-
-
-    return UNZ_OK;
-}
-
-extern int ZEXPORT unzOpenCurrentFile (unzFile file)
-{
-    return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
-}
-
-extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char*  password)
-{
-    return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
-}
-
-extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw)
-{
-    return unzOpenCurrentFile3(file, method, level, raw, NULL);
-}
-
-/** Addition for GDAL : START */
-
-extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
-{
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    s=(unz64_s*)file;
-    if (file==NULL)
-        return 0; //UNZ_PARAMERROR;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-    if (pfile_in_zip_read_info==NULL)
-        return 0; //UNZ_PARAMERROR;
-    return pfile_in_zip_read_info->pos_in_zipfile +
-                         pfile_in_zip_read_info->byte_before_the_zipfile;
-}
-
-/** Addition for GDAL : END */
-
-/*
-  Read bytes from the current file.
-  buf contain buffer where data must be copied
-  len the size of buf.
-
-  return the number of byte copied if somes bytes are copied
-  return 0 if the end of file was reached
-  return <0 with error code if there is an error
-    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-extern int ZEXPORT unzReadCurrentFile  (unzFile file, voidp buf, unsigned len)
-{
-    int err=UNZ_OK;
-    uInt iRead = 0;
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-
-    if (pfile_in_zip_read_info->read_buffer == NULL)
-        return UNZ_END_OF_LIST_OF_FILE;
-    if (len==0)
-        return 0;
-
-    pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
-
-    pfile_in_zip_read_info->stream.avail_out = (uInt)len;
-
-    if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
-        (!(pfile_in_zip_read_info->raw)))
-        pfile_in_zip_read_info->stream.avail_out =
-            (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
-
-    if ((len>pfile_in_zip_read_info->rest_read_compressed+
-           pfile_in_zip_read_info->stream.avail_in) &&
-         (pfile_in_zip_read_info->raw))
-        pfile_in_zip_read_info->stream.avail_out =
-            (uInt)pfile_in_zip_read_info->rest_read_compressed+
-            pfile_in_zip_read_info->stream.avail_in;
-
-    while (pfile_in_zip_read_info->stream.avail_out>0)
-    {
-        if ((pfile_in_zip_read_info->stream.avail_in==0) &&
-            (pfile_in_zip_read_info->rest_read_compressed>0))
-        {
-            uInt uReadThis = UNZ_BUFSIZE;
-            if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
-                uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
-            if (uReadThis == 0)
-                return UNZ_EOF;
-            if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
-                      pfile_in_zip_read_info->filestream,
-                      pfile_in_zip_read_info->pos_in_zipfile +
-                         pfile_in_zip_read_info->byte_before_the_zipfile,
-                         ZLIB_FILEFUNC_SEEK_SET)!=0)
-                return UNZ_ERRNO;
-            if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
-                      pfile_in_zip_read_info->filestream,
-                      pfile_in_zip_read_info->read_buffer,
-                      uReadThis)!=uReadThis)
-                return UNZ_ERRNO;
-
-
-#            ifndef NOUNCRYPT
-            if(s->encrypted)
-            {
-                uInt i;
-                for(i=0;i<uReadThis;i++)
-                  pfile_in_zip_read_info->read_buffer[i] =
-                      zdecode(s->keys,s->pcrc_32_tab,
-                              pfile_in_zip_read_info->read_buffer[i]);
-            }
-#            endif
-
-
-            pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
-
-            pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
-
-            pfile_in_zip_read_info->stream.next_in =
-                (Bytef*)pfile_in_zip_read_info->read_buffer;
-            pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
-        }
-
-        if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
-        {
-            uInt uDoCopy,i ;
-
-            if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
-                (pfile_in_zip_read_info->rest_read_compressed == 0))
-                return (iRead==0) ? UNZ_EOF : iRead;
-
-            if (pfile_in_zip_read_info->stream.avail_out <
-                            pfile_in_zip_read_info->stream.avail_in)
-                uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
-            else
-                uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
-
-            for (i=0;i<uDoCopy;i++)
-                *(pfile_in_zip_read_info->stream.next_out+i) =
-                        *(pfile_in_zip_read_info->stream.next_in+i);
-
-            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;
-
-            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
-                                pfile_in_zip_read_info->stream.next_out,
-                                uDoCopy);
-            pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
-            pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
-            pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
-            pfile_in_zip_read_info->stream.next_out += uDoCopy;
-            pfile_in_zip_read_info->stream.next_in += uDoCopy;
-            pfile_in_zip_read_info->stream.total_out += uDoCopy;
-            iRead += uDoCopy;
-        }
-        else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
-        {
-#ifdef HAVE_BZIP2
-            uLong uTotalOutBefore,uTotalOutAfter;
-            const Bytef *bufBefore;
-            uLong uOutThis;
-
-            pfile_in_zip_read_info->bstream.next_in        = (char*)pfile_in_zip_read_info->stream.next_in;
-            pfile_in_zip_read_info->bstream.avail_in       = pfile_in_zip_read_info->stream.avail_in;
-            pfile_in_zip_read_info->bstream.total_in_lo32  = pfile_in_zip_read_info->stream.total_in;
-            pfile_in_zip_read_info->bstream.total_in_hi32  = 0;
-            pfile_in_zip_read_info->bstream.next_out       = (char*)pfile_in_zip_read_info->stream.next_out;
-            pfile_in_zip_read_info->bstream.avail_out      = pfile_in_zip_read_info->stream.avail_out;
-            pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
-            pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
-
-            uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
-            bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;
-
-            err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
-
-            uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
-            uOutThis = uTotalOutAfter-uTotalOutBefore;
-
-            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
-
-            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));
-            pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
-            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
-            pfile_in_zip_read_info->stream.next_in   = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
-            pfile_in_zip_read_info->stream.avail_in  = pfile_in_zip_read_info->bstream.avail_in;
-            pfile_in_zip_read_info->stream.total_in  = pfile_in_zip_read_info->bstream.total_in_lo32;
-            pfile_in_zip_read_info->stream.next_out  = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
-            pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
-            pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
-
-            if (err==BZ_STREAM_END)
-              return (iRead==0) ? UNZ_EOF : iRead;
-            if (err!=BZ_OK)
-              break;
-#endif
-        } // end Z_BZIP2ED
-        else
-        {
-            ZPOS64_T uTotalOutBefore,uTotalOutAfter;
-            const Bytef *bufBefore;
-            ZPOS64_T uOutThis;
-            int flush=Z_SYNC_FLUSH;
-
-            uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
-            bufBefore = pfile_in_zip_read_info->stream.next_out;
-
-            /*
-            if ((pfile_in_zip_read_info->rest_read_uncompressed ==
-                     pfile_in_zip_read_info->stream.avail_out) &&
-                (pfile_in_zip_read_info->rest_read_compressed == 0))
-                flush = Z_FINISH;
-            */
-            err=inflate(&pfile_in_zip_read_info->stream,flush);
-
-            if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
-              err = Z_DATA_ERROR;
-
-            uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
-            uOutThis = uTotalOutAfter-uTotalOutBefore;
-
-            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
-
-            pfile_in_zip_read_info->crc32 =
-                crc32(pfile_in_zip_read_info->crc32,bufBefore,
-                        (uInt)(uOutThis));
-
-            pfile_in_zip_read_info->rest_read_uncompressed -=
-                uOutThis;
-
-            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
-            if (err==Z_STREAM_END)
-                return (iRead==0) ? UNZ_EOF : iRead;
-            if (err!=Z_OK)
-                break;
-        }
-    }
-
-    if (err==Z_OK)
-        return iRead;
-    return err;
-}
-
-
-/*
-  Give the current position in uncompressed data
-*/
-extern z_off_t ZEXPORT unztell (unzFile file)
-{
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-    return (z_off_t)pfile_in_zip_read_info->stream.total_out;
-}
-
-extern ZPOS64_T ZEXPORT unztell64 (unzFile file)
-{
-
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return (ZPOS64_T)-1;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return (ZPOS64_T)-1;
-
-    return pfile_in_zip_read_info->total_out_64;
-}
-
-
-/*
-  return 1 if the end of file was reached, 0 elsewhere
-*/
-extern int ZEXPORT unzeof (unzFile file)
-{
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-    if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
-        return 1;
-    else
-        return 0;
-}
-
-
-
-/*
-Read extra field from the current file (opened by unzOpenCurrentFile)
-This is the local-header version of the extra field (sometimes, there is
-more info in the local-header version than in the central-header)
-
-  if buf==NULL, it return the size of the local extra field that can be read
-
-  if buf!=NULL, len is the size of the buffer, the extra header is copied in
-    buf.
-  the return value is the number of bytes copied in buf, or (if <0)
-    the error code
-*/
-extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
-{
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    uInt read_now;
-    ZPOS64_T size_to_read;
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-    size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
-                pfile_in_zip_read_info->pos_local_extrafield);
-
-    if (buf==NULL)
-        return (int)size_to_read;
-
-    if (len>size_to_read)
-        read_now = (uInt)size_to_read;
-    else
-        read_now = (uInt)len ;
-
-    if (read_now==0)
-        return 0;
-
-    if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
-              pfile_in_zip_read_info->filestream,
-              pfile_in_zip_read_info->offset_local_extrafield +
-              pfile_in_zip_read_info->pos_local_extrafield,
-              ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return UNZ_ERRNO;
-
-    if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
-              pfile_in_zip_read_info->filestream,
-              buf,read_now)!=read_now)
-        return UNZ_ERRNO;
-
-    return (int)read_now;
-}
-
-/*
-  Close the file in zip opened with unzipOpenCurrentFile
-  Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-extern int ZEXPORT unzCloseCurrentFile (unzFile file)
-{
-    int err=UNZ_OK;
-
-    unz64_s* s;
-    file_in_zip64_read_info_s* pfile_in_zip_read_info;
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-    if (pfile_in_zip_read_info==NULL)
-        return UNZ_PARAMERROR;
-
-
-    if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
-        (!pfile_in_zip_read_info->raw))
-    {
-        if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
-            err=UNZ_CRCERROR;
-    }
-
-
-    TRYFREE(pfile_in_zip_read_info->read_buffer);
-    pfile_in_zip_read_info->read_buffer = NULL;
-    if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
-        inflateEnd(&pfile_in_zip_read_info->stream);
-#ifdef HAVE_BZIP2
-    else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
-        BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
-#endif
-
-
-    pfile_in_zip_read_info->stream_initialised = 0;
-    TRYFREE(pfile_in_zip_read_info);
-
-    s->pfile_in_zip_read=NULL;
-
-    return err;
-}
-
-
-/*
-  Get the global comment string of the ZipFile, in the szComment buffer.
-  uSizeBuf is the size of the szComment buffer.
-  return the number of byte copied or an error code <0
-*/
-extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)
-{
-    unz64_s* s;
-    uLong uReadThis ;
-    if (file==NULL)
-        return (int)UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-
-    uReadThis = uSizeBuf;
-    if (uReadThis>s->gi.size_comment)
-        uReadThis = s->gi.size_comment;
-
-    if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
-        return UNZ_ERRNO;
-
-    if (uReadThis>0)
-    {
-      *szComment='\0';
-      if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
-        return UNZ_ERRNO;
-    }
-
-    if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
-        *(szComment+s->gi.size_comment)='\0';
-    return (int)uReadThis;
-}
-
-/* Additions by RX '2004 */
-extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
-{
-    unz64_s* s;
-
-    if (file==NULL)
-          return 0; //UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-    if (!s->current_file_ok)
-      return 0;
-    if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
-      if (s->num_file==s->gi.number_entry)
-         return 0;
-    return s->pos_in_central_dir;
-}
-
-extern uLong ZEXPORT unzGetOffset (unzFile file)
-{
-    ZPOS64_T offset64;
-
-    if (file==NULL)
-          return 0; //UNZ_PARAMERROR;
-    offset64 = unzGetOffset64(file);
-    return (uLong)offset64;
-}
-
-extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
-{
-    unz64_s* s;
-    int err;
-
-    if (file==NULL)
-        return UNZ_PARAMERROR;
-    s=(unz64_s*)file;
-
-    s->pos_in_central_dir = pos;
-    s->num_file = s->gi.number_entry;      /* hack */
-    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-                                              &s->cur_file_info_internal,
-                                              NULL,0,NULL,0,NULL,0);
-    s->current_file_ok = (err == UNZ_OK);
-    return err;
-}
-
-extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
-{
-    return unzSetOffset64(file,pos);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/src/wire.c
----------------------------------------------------------------------
diff --git a/framework/private/src/wire.c b/framework/private/src/wire.c
deleted file mode 100644
index 508c865..0000000
--- a/framework/private/src/wire.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- *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.
- */
-/*
- * wire.c
- *
- *  \date       Jul 19, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "wire.h"
-
-struct wire {
-	module_pt importer;
-	requirement_pt requirement;
-	module_pt exporter;
-	capability_pt capability;
-};
-
-celix_status_t wire_create(module_pt importer, requirement_pt requirement,
-		module_pt exporter, capability_pt capability, wire_pt *wire) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (*wire != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		(*wire) = (wire_pt) malloc(sizeof(**wire));
-		if (!*wire) {
-			status = CELIX_ENOMEM;
-		} else {
-			(*wire)->importer = importer;
-			(*wire)->requirement = requirement;
-			(*wire)->exporter = exporter;
-			(*wire)->capability = capability;
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Cannot create wire");
-
-	return status;
-}
-
-celix_status_t wire_destroy(wire_pt wire) {
-	wire->importer = NULL;
-	wire->requirement = NULL;
-	wire->exporter = NULL;
-	wire->capability = NULL;
-	free(wire);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t wire_getCapability(wire_pt wire, capability_pt *capability) {
-	*capability = wire->capability;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t wire_getRequirement(wire_pt wire, requirement_pt *requirement) {
-	*requirement = wire->requirement;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t wire_getImporter(wire_pt wire, module_pt *importer) {
-	*importer = wire->importer;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t wire_getExporter(wire_pt wire, module_pt *exporter) {
-	*exporter = wire->exporter;
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/archive.h
----------------------------------------------------------------------
diff --git a/framework/public/include/archive.h b/framework/public/include/archive.h
deleted file mode 100644
index f51b960..0000000
--- a/framework/public/include/archive.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *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.
- */
-/**
- *
- * @defgroup Archive Archive
- * @ingroup framework
- * @{
- *
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \date      	May 31, 2010
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef ARCHIVE_H_
-#define ARCHIVE_H_
-
-#include "celix_errno.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Extracts the bundle pointed to by bundleName to the given root.
- *
- * @param bundleName location of the bundle to extract.
- * @param revisionRoot directory to where the bundle must be extracted.
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_FILE_IO_EXCEPTION If the zip file cannot be extracted.
- */
-celix_status_t extractBundle(const char *bundleName, const char *revisionRoot);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ARCHIVE_H_ */
-
-/**
- * @}
- */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/public/include/bundle.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle.h b/framework/public/include/bundle.h
deleted file mode 100644
index 3d93bbd..0000000
--- a/framework/public/include/bundle.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle.h
- *
- *  \date       Mar 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef BUNDLE_H_
-#define BUNDLE_H_
-
-typedef struct bundle * bundle_pt;
-
-#include "celix_errno.h"
-#include "bundle_state.h"
-#include "bundle_archive.h"
-#include "framework.h"
-#include "wire.h"
-#include "module.h"
-#include "service_reference.h"
-#include "bundle_context.h"
-#include "celix_log.h"
-#include "celix_threads.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-FRAMEWORK_EXPORT celix_status_t bundle_create(bundle_pt *bundle);
-
-FRAMEWORK_EXPORT celix_status_t
-bundle_createFromArchive(bundle_pt *bundle, framework_pt framework, bundle_archive_pt archive);
-
-FRAMEWORK_EXPORT celix_status_t bundle_destroy(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_isSystemBundle(bundle_pt bundle, bool *systemBundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getArchive(bundle_pt bundle, bundle_archive_pt *archive);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getCurrentModule(bundle_pt bundle, module_pt *module);
-
-FRAMEWORK_EXPORT array_list_pt bundle_getModules(bundle_pt bundle);
-
-FRAMEWORK_EXPORT void *bundle_getHandle(bundle_pt bundle);
-
-FRAMEWORK_EXPORT void bundle_setHandle(bundle_pt bundle, void *handle);
-
-FRAMEWORK_EXPORT activator_pt bundle_getActivator(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context);
-
-FRAMEWORK_EXPORT celix_status_t bundle_setContext(bundle_pt bundle, bundle_context_pt context);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getEntry(bundle_pt bundle, const char *name, char **entry);
-
-FRAMEWORK_EXPORT celix_status_t bundle_start(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_startWithOptions(bundle_pt bundle, int options);
-
-FRAMEWORK_EXPORT celix_status_t bundle_update(bundle_pt bundle, const char *inputFile);
-
-FRAMEWORK_EXPORT celix_status_t bundle_stop(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_stopWithOptions(bundle_pt bundle, int options);
-
-FRAMEWORK_EXPORT celix_status_t bundle_uninstall(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_setState(bundle_pt bundle, bundle_state_e state);
-
-FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateInactive(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateUninstalled(bundle_pt bundle);
-
-FRAMEWORK_EXPORT void uninstallBundle(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_revise(bundle_pt bundle, const char *location, const char *inputFile);
-
-FRAMEWORK_EXPORT celix_status_t bundle_addModule(bundle_pt bundle, module_pt module);
-
-FRAMEWORK_EXPORT celix_status_t bundle_closeModules(bundle_pt bundle);
-
-// Service Reference Functions
-FRAMEWORK_EXPORT array_list_pt getUsingBundles(service_reference_pt reference);
-
-FRAMEWORK_EXPORT int compareTo(service_reference_pt a, service_reference_pt b);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getState(bundle_pt bundle, bundle_state_e *state);
-
-FRAMEWORK_EXPORT celix_status_t bundle_isLockable(bundle_pt bundle, bool *lockable);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getLockingThread(bundle_pt bundle, celix_thread_t *thread);
-
-FRAMEWORK_EXPORT celix_status_t bundle_lock(bundle_pt bundle, bool *locked);
-
-FRAMEWORK_EXPORT celix_status_t bundle_unlock(bundle_pt bundle, bool *unlocked);
-
-FRAMEWORK_EXPORT celix_status_t bundle_closeAndDelete(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_close(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_refresh(bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getBundleId(bundle_pt bundle, long *id);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *list);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list);
-
-FRAMEWORK_EXPORT celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework);
-
-FRAMEWORK_EXPORT celix_status_t bundle_getBundleLocation(bundle_pt bundle, const char **location);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BUNDLE_H_ */


[36/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/public/include/device.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/public/include/device.h b/device_access/device_access/public/include/device.h
deleted file mode 100644
index 28032ba..0000000
--- a/device_access/device_access/public/include/device.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- *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.
- */
-/*
- * device.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DEVICE_H_
-#define DEVICE_H_
-
-#include "celix_errno.h"
-
-#define OSGI_DEVICEACCESS_DEVICE_CATEGORY	"DEVICE_CATEGORY"
-#define OSGI_DEVICEACCESS_DEVICE_SERIAL	"DEVICE_SERIAL"
-
-#define OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME "device"
-
-static const int OSGI_DEVICEACCESS_DEVICE_MATCH_NONE	= 0;
-
-typedef struct device * device_pt;
-
-struct device_service {
-	device_pt device;
-	celix_status_t (*noDriverFound)(device_pt device);
-};
-
-typedef struct device_service * device_service_pt;
-
-#endif /* DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/public/include/driver.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/public/include/driver.h b/device_access/device_access/public/include/driver.h
deleted file mode 100644
index 7e70e06..0000000
--- a/device_access/device_access/public/include/driver.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *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.
- */
-/*
- * driver.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_H_
-#define DRIVER_H_
-
-#include "celix_errno.h"
-#include "service_reference.h"
-
-#define OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME "driver"
-
-#define OSGI_DEVICEACCESS_DRIVER_ID "DRIVER_ID"
-
-struct driver_service {
-	void *driver;
-	celix_status_t (*attach)(void *driver, service_reference_pt reference, char **result);
-	celix_status_t (*match)(void *driver, service_reference_pt reference, int *value);
-};
-
-typedef struct driver_service *driver_service_pt;
-
-
-#endif /* DRIVER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/public/include/driver_locator.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/public/include/driver_locator.h b/device_access/device_access/public/include/driver_locator.h
deleted file mode 100644
index 405e33a..0000000
--- a/device_access/device_access/public/include/driver_locator.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_locator.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_LOCATOR_H_
-#define DRIVER_LOCATOR_H_
-
-#include "celix_errno.h"
-#include "properties.h"
-#include "array_list.h"
-
-#define OSGI_DEVICEACCESS_DRIVER_LOCATOR_SERVICE_NAME "driver_locator"
-
-typedef struct driver_locator *driver_locator_pt;
-
-struct driver_locator_service {
-	driver_locator_pt locator;
-	celix_status_t(*findDrivers)(driver_locator_pt loc, properties_pt props, array_list_pt *drivers);
-	celix_status_t(*loadDriver)(driver_locator_pt loc, char *id, char **driver);
-};
-
-typedef struct driver_locator_service *driver_locator_service_pt;
-
-
-#endif /* DRIVER_LOCATOR_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/public/include/driver_selector.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/public/include/driver_selector.h b/device_access/device_access/public/include/driver_selector.h
deleted file mode 100644
index a088d05..0000000
--- a/device_access/device_access/public/include/driver_selector.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_selector.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_SELECTOR_H_
-#define DRIVER_SELECTOR_H_
-
-#define OSGI_DEVICEACCESS_DRIVER_SELECTOR_SERVICE_NAME "driver_selector"
-
-typedef struct driver_selector *driver_selector_pt;
-
-struct driver_selector_service {
-	driver_selector_pt selector;
-	celix_status_t (*driverSelector_select)(driver_selector_pt selector, service_reference_pt reference, array_list_pt matches, int *select);
-};
-
-typedef struct driver_selector_service *driver_selector_service_pt;
-
-
-#endif /* DRIVER_SELECTOR_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/public/include/match.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/public/include/match.h b/device_access/device_access/public/include/match.h
deleted file mode 100644
index dd8906d..0000000
--- a/device_access/device_access/public/include/match.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- *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.
- */
-/*
- * match.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef MATCH_H_
-#define MATCH_H_
-
-#include <service_reference.h>
-
-struct match {
-	service_reference_pt reference;
-	int matchValue;
-};
-
-typedef struct match *match_pt;
-
-#endif /* MATCH_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/src/activator.c b/device_access/device_access/src/activator.c
new file mode 100755
index 0000000..007e725
--- /dev/null
+++ b/device_access/device_access/src/activator.c
@@ -0,0 +1,194 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include <bundle_activator.h>
+#include <bundle_context.h>
+#include <celixbool.h>
+#include <service_tracker.h>
+
+#include "driver_locator.h"
+#include "device_manager.h"
+#include "log_service.h"
+#include "log_helper.h"
+
+struct device_manager_bundle_instance {
+	log_helper_pt loghelper;
+	bundle_context_pt context;
+	device_manager_pt deviceManager;
+	service_tracker_pt driverLocatorTracker;
+	service_tracker_pt driverTracker;
+	service_tracker_pt deviceTracker;
+};
+
+typedef struct device_manager_bundle_instance *device_manager_bundle_instance_pt;
+
+static celix_status_t deviceManagerBundle_createDriverLocatorTracker(device_manager_bundle_instance_pt bundleData);
+static celix_status_t deviceManagerBundle_createDriverTracker(device_manager_bundle_instance_pt bundleData);
+static celix_status_t deviceManagerBundle_createDeviceTracker(device_manager_bundle_instance_pt bundleData);
+
+celix_status_t addingService_dummy_func(void * handle, service_reference_pt reference, void **service) {
+	celix_status_t status = CELIX_SUCCESS;
+	device_manager_pt dm = handle;
+	bundle_context_pt context = NULL;
+	status = deviceManager_getBundleContext(dm, &context);
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getService(context, reference, service);
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	device_manager_bundle_instance_pt bi = calloc(1, sizeof(struct device_manager_bundle_instance));
+	if (bi == NULL) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*userData) = bi;
+		bi->context = context;
+
+		logHelper_create(context, &bi->loghelper);
+		logHelper_start(bi->loghelper);
+
+		status = deviceManager_create(context, bi->loghelper, &bi->deviceManager);
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	device_manager_bundle_instance_pt bundleData = userData;
+
+	status = deviceManagerBundle_createDriverLocatorTracker(bundleData);
+	if (status == CELIX_SUCCESS) {
+		status = deviceManagerBundle_createDriverTracker(bundleData);
+		if (status == CELIX_SUCCESS) {
+				status = deviceManagerBundle_createDeviceTracker(bundleData);
+				if (status == CELIX_SUCCESS) {
+					status = serviceTracker_open(bundleData->driverLocatorTracker);
+					if (status == CELIX_SUCCESS) {
+						status = serviceTracker_open(bundleData->driverTracker);
+						if (status == CELIX_SUCCESS) {
+							status = serviceTracker_open(bundleData->deviceTracker);
+						}
+					}
+				}
+		}
+	}
+
+	if (status != CELIX_SUCCESS) {
+		logHelper_log(bundleData->loghelper, OSGI_LOGSERVICE_ERROR, "DEVICE_MANAGER: Error while starting bundle got error num %d", status);
+	}
+
+	logHelper_log(bundleData->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Started");
+
+	return status;
+}
+
+static celix_status_t deviceManagerBundle_createDriverLocatorTracker(device_manager_bundle_instance_pt bundleData) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	service_tracker_customizer_pt customizer = NULL;
+
+	status = serviceTrackerCustomizer_create(bundleData->deviceManager, addingService_dummy_func,
+			deviceManager_locatorAdded, deviceManager_locatorModified, deviceManager_locatorRemoved, &customizer);
+
+	if (status == CELIX_SUCCESS) {
+		service_tracker_pt tracker = NULL;
+		status = serviceTracker_create(bundleData->context, "driver_locator", customizer, &tracker);
+		if (status == CELIX_SUCCESS) {
+			bundleData->driverLocatorTracker=tracker;
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+static celix_status_t deviceManagerBundle_createDriverTracker(device_manager_bundle_instance_pt bundleData) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	service_tracker_customizer_pt customizer = NULL;
+
+	status = serviceTrackerCustomizer_create(bundleData->deviceManager, addingService_dummy_func,
+			deviceManager_driverAdded, deviceManager_driverModified, deviceManager_driverRemoved, &customizer);
+
+	if (status == CELIX_SUCCESS) {
+		service_tracker_pt tracker = NULL;
+		status = serviceTracker_createWithFilter(bundleData->context, "(objectClass=driver)", customizer, &tracker);
+		if (status == CELIX_SUCCESS) {
+			bundleData->driverTracker=tracker;
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+static celix_status_t deviceManagerBundle_createDeviceTracker(device_manager_bundle_instance_pt bundleData) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	service_tracker_customizer_pt customizer = NULL;
+
+	status = serviceTrackerCustomizer_create(bundleData->deviceManager, addingService_dummy_func,
+			deviceManager_deviceAdded, deviceManager_deviceModified, deviceManager_deviceRemoved, &customizer);
+
+	if (status == CELIX_SUCCESS) {
+		service_tracker_pt tracker = NULL;
+		status = serviceTracker_createWithFilter(bundleData->context, "(|(objectClass=device)(DEVICE_CATEGORY=*))", customizer, &tracker);
+		if (status == CELIX_SUCCESS) {
+			bundleData->deviceTracker=tracker;
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	device_manager_bundle_instance_pt bundleData = userData;
+//	status = serviceTracker_close(bundleData->driverLocatorTracker);
+	if (status == CELIX_SUCCESS) {
+		status = serviceTracker_close(bundleData->driverTracker);
+		if (status == CELIX_SUCCESS) {
+			status = serviceTracker_close(bundleData->deviceTracker);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	device_manager_bundle_instance_pt bundleData = userData;
+	status = deviceManager_destroy(bundleData->deviceManager);
+
+	logHelper_stop(bundleData->loghelper);
+	logHelper_destroy(&bundleData->loghelper);
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/src/device_manager.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/src/device_manager.c b/device_access/device_access/src/device_manager.c
new file mode 100644
index 0000000..6e7cfd9
--- /dev/null
+++ b/device_access/device_access/src/device_manager.c
@@ -0,0 +1,570 @@
+/**
+ *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.
+ */
+/*
+ * device_manager.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <constants.h>
+#include <string.h>
+
+#include "device_manager.h"
+#include "driver_locator.h"
+#include "driver_matcher.h"
+#include "driver_attributes.h"
+#include "driver_loader.h"
+#include "driver.h"
+#include "device.h"
+#include "log_service.h"
+
+
+#include <bundle.h>
+#include <module.h>
+#include <array_list.h>
+#include <service_registry.h>
+#include <service_reference.h>
+
+struct device_manager {
+	bundle_context_pt context;
+	hash_map_pt devices;
+	hash_map_pt drivers;
+	array_list_pt locators;
+	driver_selector_service_pt selector;
+	log_helper_pt loghelper;
+};
+
+static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, service_reference_pt ref, void *service);
+static celix_status_t deviceManager_getIdleDevices(device_manager_pt manager, array_list_pt *idleDevices);
+static celix_status_t deviceManager_isDriverBundle(device_manager_pt manager, bundle_pt bundle, bool *isDriver);
+
+celix_status_t deviceManager_create(bundle_context_pt context, log_helper_pt logHelper, device_manager_pt *manager) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*manager = calloc(1, sizeof(**manager));
+	if (!*manager) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*manager)->context = context;
+		(*manager)->devices = NULL;
+		(*manager)->drivers = NULL;
+		(*manager)->locators = NULL;
+		(*manager)->selector = NULL;
+
+		(*manager)->devices = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
+		(*manager)->drivers = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
+
+		(*manager)->loghelper = logHelper;
+
+		status = arrayList_create(&(*manager)->locators);
+
+		logHelper_log((*manager)->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Initialized");
+	}
+
+
+	return status;
+}
+
+celix_status_t deviceManager_destroy(device_manager_pt manager) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Stop");
+
+	hashMap_destroy(manager->devices, false, false);
+	hashMap_destroy(manager->drivers, false, false);
+	arrayList_destroy(manager->locators);
+
+	return status;
+}
+
+celix_status_t deviceManager_selectorAdded(void * handle, service_reference_pt ref, void * service) {
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add selector");
+
+	manager->selector = (driver_selector_service_pt) service;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deviceManager_selectorModified(void * handle, service_reference_pt ref, void * service) {
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify selector");
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deviceManager_selectorRemoved(void * handle, service_reference_pt ref, void * service) {
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove selector");
+	manager->selector = NULL;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deviceManager_locatorAdded(void * handle, service_reference_pt ref, void * service) {
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add locator");
+	arrayList_add(manager->locators, service);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deviceManager_locatorModified(void * handle, service_reference_pt ref, void * service) {
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify locator");
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deviceManager_locatorRemoved(void * handle, service_reference_pt ref, void * service) {
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove locator");
+	arrayList_removeElement(manager->locators, service);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deviceManager_deviceAdded(void * handle, service_reference_pt ref, void * service) {
+	celix_status_t status = CELIX_SUCCESS;
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add device");
+	status = deviceManager_attachAlgorithm(manager, ref, service);
+
+	return status;
+}
+
+static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, service_reference_pt ref, void *service) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	driver_loader_pt loader = NULL;
+	status = driverLoader_create(manager->context, &loader);
+	if (status == CELIX_SUCCESS) {
+		array_list_pt included = NULL;
+		array_list_pt excluded = NULL;
+
+		array_list_pt driverIds = NULL;
+
+		hashMap_put(manager->devices, ref, service);
+
+		status = arrayList_create(&included);
+		if (status == CELIX_SUCCESS) {
+			status = arrayList_create(&excluded);
+			if (status == CELIX_SUCCESS) {
+				properties_pt properties = properties_create();
+
+				unsigned int size = 0;
+				char **keys;
+
+				serviceReference_getPropertyKeys(ref, &keys, &size);
+				for (int i = 0; i < size; i++) {
+					char* key = keys[i];
+					const char* value = NULL;
+					serviceReference_getProperty(ref, key, &value);
+					properties_set(properties, key, value);
+				}
+
+				status = driverLoader_findDrivers(loader, manager->locators, properties, &driverIds);
+				if (status == CELIX_SUCCESS) {
+					hash_map_iterator_pt iter = hashMapIterator_create(manager->drivers);
+					while (hashMapIterator_hasNext(iter)) {
+						driver_attributes_pt driverAttributes = hashMapIterator_nextValue(iter);
+						arrayList_add(included, driverAttributes);
+
+						// Each driver that already is installed can be removed from the list
+						char *id = NULL;
+						celix_status_t substatus = driverAttributes_getDriverId(driverAttributes, &id);
+						if (substatus == CELIX_SUCCESS) {
+							// arrayList_removeElement(driverIds, id);
+							array_list_iterator_pt idsIter = arrayListIterator_create(driverIds);
+							while (arrayListIterator_hasNext(idsIter)) {
+								char *value = arrayListIterator_next(idsIter);
+								if (strcmp(value, id) == 0) {
+									arrayListIterator_remove(idsIter);
+								}
+							}
+							arrayListIterator_destroy(idsIter);
+						}
+						if(id != NULL){
+							free(id);
+						}
+					}
+					hashMapIterator_destroy(iter);
+
+					status = deviceManager_matchAttachDriver(manager, loader, driverIds, included, excluded, service, ref);
+
+				}
+				arrayList_destroy(driverIds);
+				properties_destroy(properties);
+				arrayList_destroy(excluded);
+			}
+			arrayList_destroy(included);
+		}
+
+	}
+
+	driverLoader_destroy(&loader);
+	return status;
+}
+
+celix_status_t deviceManager_matchAttachDriver(device_manager_pt manager, driver_loader_pt loader,
+		array_list_pt driverIds, array_list_pt included, array_list_pt excluded, void *service, service_reference_pt reference) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	array_list_pt references = NULL;
+
+	int i;
+	for (i = 0; i < arrayList_size(excluded); i++) {
+		void *exclude = arrayList_get(excluded, i);
+		arrayList_removeElement(included, exclude);
+	}
+
+	for (i = 0; i < arrayList_size(driverIds); i++) {
+		char *id = arrayList_get(driverIds, i);
+		logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Driver found: %s", id);
+	}
+
+	status = driverLoader_loadDrivers(loader, manager->locators, driverIds, &references);
+	if (status == CELIX_SUCCESS) {
+		for (i = 0; i < arrayList_size(references); i++) {
+			service_reference_pt reference = arrayList_get(references, i);
+			driver_attributes_pt attributes = hashMap_get(manager->drivers, reference);
+			if (attributes != NULL) {
+				arrayList_add(included, attributes);
+			}
+		}
+
+		driver_matcher_pt matcher = NULL;
+		status = driverMatcher_create(manager->context, &matcher);
+		if (status == CELIX_SUCCESS) {
+			for (i = 0; i < arrayList_size(included); i++) {
+				driver_attributes_pt attributes = arrayList_get(included, i);
+
+				int match = 0;
+				celix_status_t substatus = driverAttributes_match(attributes, reference, &match);
+				if (substatus == CELIX_SUCCESS) {
+					logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Found match: %d", match);
+					if (match <= OSGI_DEVICEACCESS_DEVICE_MATCH_NONE) {
+						continue;
+					}
+					driverMatcher_add(matcher, match, attributes);
+				} else {
+					// Ignore
+				}
+			}
+
+			match_pt match = NULL;
+			status = driverMatcher_getBestMatch(matcher, reference, &match);
+			if (status == CELIX_SUCCESS) {
+				if (match == NULL) {
+					status = deviceManager_noDriverFound(manager, service, reference);
+				} else {
+                    driver_attributes_pt finalAttributes = hashMap_get(manager->drivers, match->reference);
+                    if (finalAttributes == NULL) {
+                        status = deviceManager_noDriverFound(manager, service, reference);
+                    } else {
+                        char *newDriverId = NULL;
+                        status = driverAttributes_attach(finalAttributes, reference, &newDriverId);
+                        if (status == CELIX_SUCCESS) {
+                            if (newDriverId != NULL) {
+                                array_list_pt ids = NULL;
+                                arrayList_create(&ids);
+                                arrayList_add(ids, newDriverId);
+                                arrayList_add(excluded, finalAttributes);
+                                status = deviceManager_matchAttachDriver(manager, loader,
+                                        ids, included, excluded, service, reference);
+                            } else {
+                                // Attached, unload unused drivers
+                                status = driverLoader_unloadDrivers(loader, finalAttributes);
+                            }
+                        }
+					}
+				}
+			}
+		}
+
+		driverMatcher_destroy(&matcher);
+
+	}
+
+	if (references != NULL) {
+		arrayList_destroy(references);
+	}
+
+	return status;
+}
+
+celix_status_t deviceManager_noDriverFound(device_manager_pt manager, void *service, service_reference_pt reference) {
+	celix_status_t status = CELIX_SUCCESS;
+    const char* objectClass = NULL;
+    serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &objectClass);
+    if (strcmp(objectClass, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME) == 0) {
+        device_service_pt device = service;
+        status = device->noDriverFound(device->device);
+    }
+	return status;
+}
+
+celix_status_t deviceManager_deviceModified(void * handle, service_reference_pt ref, void * service) {
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify device");
+	// #TODO the device properties could be changed
+	//hashMap_put(manager->devices, ref, service);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deviceManager_deviceRemoved(void * handle, service_reference_pt ref, void * service) {
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove device");
+	hashMap_remove(manager->devices, ref);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deviceManager_driverAdded(void * handle, service_reference_pt ref, void * service) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add driver");
+	driver_attributes_pt attributes = NULL;
+
+	status = driverAttributes_create(ref, service, &attributes);
+	if (status == CELIX_SUCCESS) {
+		hashMap_put(manager->drivers, ref, attributes);
+	}
+	else{
+		driverAttributes_destroy(attributes);
+	}
+	return status;
+}
+
+celix_status_t deviceManager_driverModified(void * handle, service_reference_pt ref, void * service) {
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify driver");
+	// #TODO the driver properties could be changed?
+	return CELIX_SUCCESS;
+}
+
+celix_status_t deviceManager_driverRemoved(void * handle, service_reference_pt ref, void * service) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove driver");
+
+	hashMap_remove(manager->drivers, ref);
+
+	array_list_pt idleDevices = NULL;
+	status = deviceManager_getIdleDevices(manager, &idleDevices);
+	if (status == CELIX_SUCCESS) {
+		int i;
+		for (i = 0; i < arrayList_size(idleDevices); i++) {
+			celix_status_t forStatus = CELIX_SUCCESS;
+			service_reference_pt ref = arrayList_get(idleDevices, i);
+			const char *bsn = NULL;
+			bundle_pt bundle = NULL;
+			forStatus = serviceReference_getBundle(ref, &bundle);
+			if (forStatus == CELIX_SUCCESS) {
+				module_pt module = NULL;
+				forStatus = bundle_getCurrentModule(bundle, &module);
+				if (forStatus == CELIX_SUCCESS) {
+					forStatus = module_getSymbolicName(module, &bsn);
+					if (forStatus == CELIX_SUCCESS) {
+						logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: IDLE: %s", bsn);
+						// #TODO attachDriver (idle device)
+						// #TODO this can result in a loop?
+						//		Locate and install a driver
+						//		Let the match fail, the device is idle
+						//		The driver is removed, idle check is performed
+						//		Attach is tried again
+						//		.. loop ..
+						void *device = hashMap_get(manager->devices, ref);
+						forStatus = deviceManager_attachAlgorithm(manager, ref, device);
+					}
+				}
+			}
+
+			if (forStatus != CELIX_SUCCESS) {
+				break; //Got error, stop loop and return status
+			}
+		}
+
+
+		hash_map_iterator_pt iter = hashMapIterator_create(manager->drivers);
+		while (hashMapIterator_hasNext(iter)) {
+			hashMapIterator_nextValue(iter);
+//			driver_attributes_pt da = hashMapIterator_nextValue(iter);
+//			driverAttributes_tryUninstall(da);
+		}
+		hashMapIterator_destroy(iter);
+	}
+
+	if (idleDevices != NULL) {
+		arrayList_destroy(idleDevices);
+	}
+
+	return status;
+}
+
+
+celix_status_t deviceManager_getIdleDevices(device_manager_pt manager, array_list_pt *idleDevices) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	status = arrayList_create(idleDevices);
+	if (status == CELIX_SUCCESS) {
+		hash_map_iterator_pt iter = hashMapIterator_create(manager->devices);
+		while (hashMapIterator_hasNext(iter)) {
+			celix_status_t substatus = CELIX_SUCCESS;
+			service_reference_pt ref = hashMapIterator_nextKey(iter);
+			const char *bsn = NULL;
+			module_pt module = NULL;
+			bundle_pt bundle = NULL;
+			substatus = serviceReference_getBundle(ref, &bundle);
+			if (substatus == CELIX_SUCCESS) {
+				substatus = bundle_getCurrentModule(bundle, &module);
+				if (substatus == CELIX_SUCCESS) {
+					substatus = module_getSymbolicName(module, &bsn);
+					if (substatus == CELIX_SUCCESS) {
+						logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Check idle device: %s", bsn);
+						array_list_pt bundles = NULL;
+						substatus = serviceReference_getUsingBundles(ref, &bundles);
+						if (substatus == CELIX_SUCCESS) {
+							bool inUse = false;
+							int i;
+							for (i = 0; i < arrayList_size(bundles); i++) {
+								bundle_pt bundle = arrayList_get(bundles, i);
+								bool isDriver;
+								celix_status_t sstatus = deviceManager_isDriverBundle(manager, bundle, &isDriver);
+								if (sstatus == CELIX_SUCCESS) {
+									if (isDriver) {
+										const char *bsn = NULL;
+										module_pt module = NULL;
+										bundle_getCurrentModule(bundle, &module);
+										module_getSymbolicName(module, &bsn);
+
+										logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Not idle, used by driver: %s", bsn);
+
+										inUse = true;
+										break;
+									}
+								}
+							}
+
+							if (!inUse) {
+								arrayList_add(*idleDevices, ref);
+							}
+						}
+
+						if(bundles!=NULL){
+							arrayList_destroy(bundles);
+						}
+					}
+				}
+			}
+		}
+		hashMapIterator_destroy(iter);
+	}
+
+	return status;
+}
+
+//TODO examply for discussion only, remove after discussion
+#define DO_IF_SUCCESS(status, call_func) ((status) == CELIX_SUCCESS) ? (call_func) : (status)
+celix_status_t deviceManager_getIdleDevices_exmaple(device_manager_pt manager, array_list_pt *idleDevices) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	status = arrayList_create(idleDevices);
+	if (status == CELIX_SUCCESS) {
+		hash_map_iterator_pt iter = hashMapIterator_create(manager->devices);
+		while (hashMapIterator_hasNext(iter)) {
+			celix_status_t substatus = CELIX_SUCCESS;
+			service_reference_pt ref = hashMapIterator_nextKey(iter);
+			const char *bsn = NULL;
+			module_pt module = NULL;
+			bundle_pt bundle = NULL;
+			array_list_pt bundles = NULL;
+			substatus = serviceReference_getBundle(ref, &bundle);
+			substatus = DO_IF_SUCCESS(substatus, bundle_getCurrentModule(bundle, &module));
+			substatus = DO_IF_SUCCESS(substatus, module_getSymbolicName(module, &bsn));
+			substatus = DO_IF_SUCCESS(substatus, serviceReference_getUsingBundles(ref, &bundles));
+
+			if (substatus == CELIX_SUCCESS) {
+				logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Check idle device: %s", bsn);
+				bool inUse = false;
+				int i;
+				for (i = 0; i < arrayList_size(bundles); i++) {
+					bundle_pt bundle = arrayList_get(bundles, i);
+					bool isDriver;
+					celix_status_t sstatus = deviceManager_isDriverBundle(manager, bundle, &isDriver);
+					if (sstatus == CELIX_SUCCESS) {
+						if (isDriver) {
+							const char *bsn = NULL;
+							module_pt module = NULL;
+							bundle_getCurrentModule(bundle, &module);
+							module_getSymbolicName(module, &bsn);
+
+							logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Not idle, used by driver: %s", bsn);
+
+							inUse = true;
+							break;
+						}
+					}
+				}
+
+				if (!inUse) {
+					arrayList_add(*idleDevices, ref);
+				}
+			}
+		}
+		hashMapIterator_destroy(iter);
+	}
+	return status;
+}
+
+celix_status_t deviceManager_isDriverBundle(device_manager_pt manager, bundle_pt bundle, bool *isDriver) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*isDriver) = false;
+
+	array_list_pt refs = NULL;
+		status = bundle_getRegisteredServices(bundle, &refs);
+		if (status == CELIX_SUCCESS) {
+			if (refs != NULL) {
+				int i;
+				for (i = 0; i < arrayList_size(refs); i++) {
+					service_reference_pt ref = arrayList_get(refs, i);
+                    const char* object = NULL;
+                    serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &object);
+                    if (strcmp(object, "driver") == 0) {
+                        *isDriver = true;
+                        break;
+                    }
+				}
+				arrayList_destroy(refs);
+			}
+		}
+
+	return status;
+}
+
+
+celix_status_t deviceManager_getBundleContext(device_manager_pt manager, bundle_context_pt *context) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (manager->context != NULL) {
+		(*context) = manager->context;
+	} else {
+		status = CELIX_INVALID_BUNDLE_CONTEXT;
+	}
+	return status;
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/src/device_manager.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/src/device_manager.h b/device_access/device_access/src/device_manager.h
new file mode 100644
index 0000000..00a4f2c
--- /dev/null
+++ b/device_access/device_access/src/device_manager.h
@@ -0,0 +1,56 @@
+/**
+ *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.
+ */
+/*
+ * device_manager.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DEVICE_MANAGER_H_
+#define DEVICE_MANAGER_H_
+
+#include "log_helper.h"
+
+#include "driver_loader.h"
+
+typedef struct device_manager *device_manager_pt;
+
+celix_status_t deviceManager_create(bundle_context_pt context, log_helper_pt logHelper, device_manager_pt *manager);
+celix_status_t deviceManager_destroy(device_manager_pt manager);
+
+celix_status_t deviceManager_matchAttachDriver(device_manager_pt manager, driver_loader_pt loader,
+			array_list_pt driverIds, array_list_pt included, array_list_pt excluded, void *service, service_reference_pt reference);
+celix_status_t deviceManager_noDriverFound(device_manager_pt manager, void *service, service_reference_pt reference);
+
+celix_status_t deviceManager_locatorAdded(void * handle, service_reference_pt ref, void * service);
+celix_status_t deviceManager_locatorModified(void * handle, service_reference_pt ref, void * service);
+celix_status_t deviceManager_locatorRemoved(void * handle, service_reference_pt ref, void * service);
+celix_status_t deviceManager_deviceAdded(void * handle, service_reference_pt ref, void * service);
+celix_status_t deviceManager_deviceModified(void * handle, service_reference_pt ref, void * service);
+celix_status_t deviceManager_deviceRemoved(void * handle, service_reference_pt ref, void * service);
+celix_status_t deviceManager_driverAdded(void * handle, service_reference_pt ref, void * service);
+celix_status_t deviceManager_driverModified(void * handle, service_reference_pt ref, void * service);
+celix_status_t deviceManager_driverRemoved(void * handle, service_reference_pt ref, void * service);
+
+celix_status_t deviceManager_getBundleContext(device_manager_pt manager, bundle_context_pt *context);
+
+// celix_status_t deviceManager_match(device_manager_pt manager, ...);
+
+#endif /* DEVICE_MANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/src/driver_attributes.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/src/driver_attributes.c b/device_access/device_access/src/driver_attributes.c
new file mode 100644
index 0000000..5ac7fda
--- /dev/null
+++ b/device_access/device_access/src/driver_attributes.c
@@ -0,0 +1,169 @@
+/**
+ *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.
+ */
+/*
+ * driver_attributes.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "driver_attributes.h"
+#include "bundle.h"
+#include "celixbool.h"
+#include "driver_loader.h"
+#include "device.h"
+#include "constants.h"
+
+struct driver_attributes {
+	bundle_pt bundle;
+	service_reference_pt reference;
+	driver_service_pt driver;
+	bool dynamic;
+};
+
+celix_status_t driverAttributes_create(service_reference_pt reference, driver_service_pt driver, driver_attributes_pt *attributes) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*attributes = calloc(1, sizeof(**attributes));
+	if (!*attributes) {
+		status = CELIX_ENOMEM;
+	} else {
+		bundle_pt bundle = NULL;
+		bundle_archive_pt bundleArchive = NULL;
+		status = serviceReference_getBundle(reference, &bundle);
+
+		if (status == CELIX_SUCCESS) {
+			status = bundle_getArchive(bundle, &bundleArchive);
+
+			if (status == CELIX_SUCCESS) {
+				(*attributes)->reference = reference;
+				(*attributes)->driver = driver;
+				(*attributes)->bundle = bundle;
+
+				const char *location;
+				status = bundleArchive_getLocation(bundleArchive, &location);
+				if (status == CELIX_SUCCESS) {
+					(*attributes)->dynamic = strncmp(location, DRIVER_LOCATION_PREFIX, 4) == 0 ? true : false;
+				}
+
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t driverAttributes_destroy(driver_attributes_pt attributes){
+	if(attributes != NULL){
+		free(attributes);
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t driverAttributes_getReference(driver_attributes_pt driverAttributes, service_reference_pt *reference) {
+	*reference = driverAttributes->reference;
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t driverAttributes_getDriverId(driver_attributes_pt driverAttributes, char **driverId) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    const char* id_prop = NULL;
+    status = serviceReference_getProperty(driverAttributes->reference, "DRIVER_ID", &id_prop);
+    if (status == CELIX_SUCCESS) {
+        if (!id_prop) {
+            status = CELIX_ENOMEM;
+        } else {
+            *driverId = strdup(id_prop);
+
+            if (*driverId == NULL) {
+                status = CELIX_ENOMEM;
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t driverAttributes_match(driver_attributes_pt driverAttributes, service_reference_pt reference, int *match) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	status = driverAttributes->driver->match(driverAttributes->driver->driver, reference, match);
+
+	return status;
+}
+
+celix_status_t driverAttributes_isInUse(driver_attributes_pt driverAttributes, bool *inUse) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	array_list_pt references = NULL;
+	status = bundle_getServicesInUse(driverAttributes->bundle, &references);
+	if (status == CELIX_SUCCESS) {
+		if (references == NULL || arrayList_size(references) == 0) {
+			*inUse = false;
+		} else {
+			int i;
+			for (i = 0; i < arrayList_size(references); i++) {
+				service_reference_pt ref = arrayList_get(references, i);
+				const char *object = NULL;
+				status = serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &object);
+
+				if (status == CELIX_SUCCESS) {
+					const char* category = NULL;
+					status = serviceReference_getProperty(ref, "DEVICE_CATEGORY", &category);
+
+					if (status == CELIX_SUCCESS) {
+						if ((object != NULL && strcmp(object, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME) == 0) || (category != NULL)) {
+							*inUse = true;
+						}
+					}
+				}
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t driverAttributes_attach(driver_attributes_pt driverAttributes, service_reference_pt reference, char **attach) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	status = driverAttributes->driver->attach(driverAttributes->driver->driver, reference, attach);
+
+	return status;
+}
+
+celix_status_t driverAttributes_tryUninstall(driver_attributes_pt driverAttributes) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bool inUse = false;
+
+	status = driverAttributes_isInUse(driverAttributes, &inUse);
+	if (status == CELIX_SUCCESS) {
+		if (!inUse && driverAttributes->dynamic) {
+			status = bundle_uninstall(driverAttributes->bundle);
+		}
+	}
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/src/driver_attributes.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/src/driver_attributes.h b/device_access/device_access/src/driver_attributes.h
new file mode 100644
index 0000000..bdb12a2
--- /dev/null
+++ b/device_access/device_access/src/driver_attributes.h
@@ -0,0 +1,46 @@
+/**
+ *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.
+ */
+/*
+ * driver_attributes.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_ATTRIBUTES_H_
+#define DRIVER_ATTRIBUTES_H_
+
+#include "driver.h"
+
+typedef struct driver_attributes *driver_attributes_pt;
+
+celix_status_t driverAttributes_create(service_reference_pt reference, driver_service_pt driver, driver_attributes_pt *attributes);
+celix_status_t driverAttributes_destroy(driver_attributes_pt attributes);
+
+celix_status_t driverAttributes_getReference(driver_attributes_pt driverAttributes, service_reference_pt *reference);
+celix_status_t driverAttributes_getDriverId(driver_attributes_pt driverAttributes, char **driverId);
+
+celix_status_t driverAttributes_match(driver_attributes_pt driverAttributes, service_reference_pt reference, int *match);
+celix_status_t driverAttributes_attach(driver_attributes_pt driverAttributes, service_reference_pt reference, char **attach);
+
+celix_status_t driverAttributes_isInUse(driver_attributes_pt driverAttributes, bool *inUse);
+
+celix_status_t driverAttributes_tryUninstall(driver_attributes_pt driverAttributes);
+
+#endif /* DRIVER_ATTRIBUTES_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/src/driver_loader.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/src/driver_loader.c b/device_access/device_access/src/driver_loader.c
new file mode 100644
index 0000000..c4caa65
--- /dev/null
+++ b/device_access/device_access/src/driver_loader.c
@@ -0,0 +1,185 @@
+/**
+ *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.
+ */
+/*
+ * driver_loader.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "driver_loader.h"
+#include "bundle_context.h"
+#include "bundle.h"
+
+struct driver_loader {
+	bundle_context_pt context;
+	array_list_pt loadedDrivers;
+};
+
+celix_status_t driverLoader_create(bundle_context_pt context, driver_loader_pt *loader) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*loader = calloc(1, sizeof(**loader));
+	if (!*loader) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*loader)->context = context;
+		(*loader)->loadedDrivers = NULL;
+		status = arrayList_create(&(*loader)->loadedDrivers);
+	}
+
+	return status;
+}
+
+celix_status_t driverLoader_destroy(driver_loader_pt *loader) {
+	if((*loader) != NULL){
+		arrayList_destroy((*loader)->loadedDrivers);
+		free((*loader));
+		(*loader)=NULL;
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t driverLoader_findDrivers(driver_loader_pt loader, array_list_pt locators, properties_pt properties, array_list_pt *driversIds) {
+	celix_status_t status = CELIX_SUCCESS;
+	arrayList_create(driversIds);
+
+	int i;
+	for (i = 0; i < arrayList_size(locators); i++) {
+		array_list_pt drivers;
+		driver_locator_service_pt locator = arrayList_get(locators, i);
+
+		status = driverLoader_findDriversForLocator(loader, locator, properties, &drivers);
+		if (status == CELIX_SUCCESS) {
+			arrayList_addAll(*driversIds, drivers);
+		}
+		arrayList_destroy(drivers);
+	}
+
+	return status;
+}
+
+celix_status_t driverLoader_findDriversForLocator(driver_loader_pt loader, driver_locator_service_pt locator, properties_pt properties, array_list_pt *driversIds) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	status = locator->findDrivers(locator->locator, properties, driversIds);
+
+	return status;
+}
+
+celix_status_t driverLoader_loadDrivers(driver_loader_pt loader, array_list_pt locators, array_list_pt driverIds, array_list_pt *references) {
+	celix_status_t status = CELIX_SUCCESS;
+	status = arrayList_create(references);
+	if (status == CELIX_SUCCESS) {
+		int i;
+		for (i = 0; i < arrayList_size(driverIds); i++) {
+			array_list_pt refs = NULL;
+			char *id = arrayList_get(driverIds, i);
+
+			status = driverLoader_loadDriver(loader, locators, id, &refs);
+			if (status == CELIX_SUCCESS) {
+				arrayList_addAll(*references, refs);
+			}
+			if (refs != NULL) {
+				arrayList_destroy(refs);
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t driverLoader_loadDriver(driver_loader_pt loader, array_list_pt locators, char *driverId, array_list_pt *references) {
+	celix_status_t status = CELIX_SUCCESS;
+	status = arrayList_create(references);
+	if (status == CELIX_SUCCESS) {
+		int i;
+		for (i = 0; i < arrayList_size(locators); i++) {
+			array_list_pt refs = NULL;
+			driver_locator_service_pt locator = arrayList_get(locators, i);
+
+			status = driverLoader_loadDriverForLocator(loader, locator, driverId, &refs);
+			if (status == CELIX_SUCCESS) {
+				arrayList_addAll(*references, refs);
+			}
+
+			if (refs != NULL) {
+				arrayList_destroy(refs);
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t driverLoader_loadDriverForLocator(driver_loader_pt loader, driver_locator_service_pt locator, char *driverId, array_list_pt *references) {
+	celix_status_t status = CELIX_SUCCESS;
+	//The list is created in the bundle_getRegisteredServices chain
+	//arrayList_create(references);
+
+	char *filename = NULL;
+	status = locator->loadDriver(locator->locator, driverId, &filename);
+	if (status == CELIX_SUCCESS) {
+		bundle_pt bundle = NULL;
+		int length = strlen(DRIVER_LOCATION_PREFIX) + strlen(driverId);
+		char location[length+2];
+		snprintf(location, length+2, "%s%s", DRIVER_LOCATION_PREFIX, driverId);
+		status = bundleContext_installBundle2(loader->context, location, filename, &bundle);
+		if (status == CELIX_SUCCESS) {
+			status = bundle_start(bundle);
+			if (status == CELIX_SUCCESS) {
+				status = bundle_getRegisteredServices(bundle, references);
+				if (status == CELIX_SUCCESS) {
+					arrayList_addAll(loader->loadedDrivers, *references);
+				}
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t driverLoader_unloadDrivers(driver_loader_pt loader, driver_attributes_pt finalDriver) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	service_reference_pt finalReference = NULL;
+	if (finalDriver != NULL) {
+		status = driverAttributes_getReference(finalDriver, &finalReference);
+	}
+	if (status == CELIX_SUCCESS) {
+		int i;
+		for (i = 0; i < arrayList_size(loader->loadedDrivers); i++) {
+			service_reference_pt reference = arrayList_get(loader->loadedDrivers, i);
+			bool equal = false;
+			status = serviceReference_equals(reference, finalReference, &equal);
+			if (status == CELIX_SUCCESS && !equal) {
+				bundle_pt bundle = NULL;
+				status = serviceReference_getBundle(reference, &bundle);
+				if (status == CELIX_SUCCESS) {
+					bundle_uninstall(bundle); // Ignore status
+				}
+			}
+		}
+	}
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/src/driver_loader.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/src/driver_loader.h b/device_access/device_access/src/driver_loader.h
new file mode 100644
index 0000000..fde9c88
--- /dev/null
+++ b/device_access/device_access/src/driver_loader.h
@@ -0,0 +1,48 @@
+/**
+ *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.
+ */
+/*
+ * driver_loader.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_LOADER_H_
+#define DRIVER_LOADER_H_
+
+#include "driver_locator.h"
+#include "driver_attributes.h"
+
+#define DRIVER_LOCATION_PREFIX "_DD_"
+
+typedef struct driver_loader *driver_loader_pt;
+
+celix_status_t driverLoader_create(bundle_context_pt context, driver_loader_pt *loader);
+celix_status_t driverLoader_destroy(driver_loader_pt *loader);
+
+celix_status_t driverLoader_findDrivers(driver_loader_pt loader, array_list_pt locators, properties_pt properties, array_list_pt *driversIds);
+celix_status_t driverLoader_findDriversForLocator(driver_loader_pt loader, driver_locator_service_pt locator, properties_pt properties, array_list_pt *driversIds);
+
+celix_status_t driverLoader_loadDrivers(driver_loader_pt loader, array_list_pt locators, array_list_pt driverIds, array_list_pt *references);
+celix_status_t driverLoader_loadDriver(driver_loader_pt loader, array_list_pt locators, char *driverId, array_list_pt *references);
+celix_status_t driverLoader_loadDriverForLocator(driver_loader_pt loader, driver_locator_service_pt locator, char *driverId, array_list_pt *references);
+
+celix_status_t driverLoader_unloadDrivers(driver_loader_pt loader, driver_attributes_pt finalDriver);
+
+#endif /* DRIVER_LOADER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/src/driver_matcher.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/src/driver_matcher.c b/device_access/device_access/src/driver_matcher.c
new file mode 100644
index 0000000..c7597d3
--- /dev/null
+++ b/device_access/device_access/src/driver_matcher.c
@@ -0,0 +1,274 @@
+/**
+ *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.
+ */
+/*
+ * driver_matcher.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "hash_map.h"
+#include "constants.h"
+
+#include "driver_matcher.h"
+#include "log_helper.h"
+#include "log_service.h"
+
+
+struct driver_matcher {
+	hash_map_pt attributes;
+	array_list_pt matches;
+	log_helper_pt loghelper;
+
+	bundle_context_pt context;
+};
+
+typedef struct match_key {
+	int matchValue;
+}*match_key_t;
+
+static celix_status_t driverMatcher_get(driver_matcher_pt matcher, int key, array_list_pt *attributesV);
+static celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, match_pt *match);
+
+unsigned int driverMatcher_matchKeyHash(const void* match_key) {
+	match_key_t key = (match_key_t) match_key;
+
+	return key->matchValue;
+}
+
+int driverMatcher_matchKeyEquals(const void* key, const void* toCompare) {
+	return ((match_key_t) key)->matchValue == ((match_key_t) toCompare)->matchValue;
+}
+
+celix_status_t driverMatcher_create(bundle_context_pt context, driver_matcher_pt *matcher) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*matcher = calloc(1, sizeof(**matcher));
+	if (!*matcher) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*matcher)->matches = NULL;
+		(*matcher)->context = context;
+		(*matcher)->attributes = hashMap_create(driverMatcher_matchKeyHash, NULL, driverMatcher_matchKeyEquals, NULL);
+
+		arrayList_create(&(*matcher)->matches);
+
+		if(logHelper_create(context, &(*matcher)->loghelper) == CELIX_SUCCESS) {
+			logHelper_start((*matcher)->loghelper);
+		}
+
+	}
+
+	return status;
+}
+
+celix_status_t driverMatcher_destroy(driver_matcher_pt *matcher) {
+
+	if((*matcher) != NULL){
+
+		int i = 0;
+
+		for(;i<arrayList_size((*matcher)->matches);i++){
+			free(arrayList_get((*matcher)->matches,i));
+		}
+		arrayList_destroy((*matcher)->matches);
+
+		hash_map_iterator_pt iter = hashMapIterator_create((*matcher)->attributes);
+		while (hashMapIterator_hasNext(iter)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+			match_key_t match = (match_key_t)hashMapEntry_getKey(entry);
+			array_list_pt list = (array_list_pt)hashMapEntry_getValue(entry);
+			free(match);
+			if (list != NULL) {
+				arrayList_destroy(list);
+			}
+		}
+		hashMapIterator_destroy(iter);
+		hashMap_destroy((*matcher)->attributes, false, false);
+
+		logHelper_stop((*matcher)->loghelper);
+		logHelper_destroy(&(*matcher)->loghelper);
+
+		free(*matcher);
+	}
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t driverMatcher_add(driver_matcher_pt matcher, int matchValue, driver_attributes_pt attributes) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	array_list_pt da = NULL;
+	status = driverMatcher_get(matcher, matchValue, &da);
+	if (status == CELIX_SUCCESS) {
+		arrayList_add(da, attributes);
+
+		match_pt match = NULL;
+		match = calloc(1, sizeof(*match));
+		if (!match) {
+			status = CELIX_ENOMEM;
+		} else {
+			match->matchValue = matchValue;
+			match->reference = NULL;
+			driverAttributes_getReference(attributes, &match->reference);
+			arrayList_add(matcher->matches, match);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t driverMatcher_get(driver_matcher_pt matcher, int key, array_list_pt *attributes) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	match_key_t matchKeyS = calloc(1, sizeof(*matchKeyS));
+	matchKeyS->matchValue = key;
+
+	*attributes = hashMap_get(matcher->attributes, matchKeyS);
+	if (*attributes == NULL) {
+		arrayList_create(attributes);
+		match_key_t matchKey = calloc(1, sizeof(*matchKey));
+		matchKey->matchValue = key;
+		hashMap_put(matcher->attributes, matchKey, *attributes);
+	}
+
+	free(matchKeyS);
+
+	return status;
+}
+
+celix_status_t driverMatcher_getBestMatch(driver_matcher_pt matcher, service_reference_pt reference, match_pt *match) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (*match != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		service_reference_pt selectorRef = NULL;
+		status = bundleContext_getServiceReference(matcher->context, OSGI_DEVICEACCESS_DRIVER_SELECTOR_SERVICE_NAME, &selectorRef);
+		if (status == CELIX_SUCCESS) {
+			int index = -1;
+			if (selectorRef != NULL) {
+				driver_selector_service_pt selector = NULL;
+				status = bundleContext_getService(matcher->context, selectorRef, (void **) &selector);
+				if (status == CELIX_SUCCESS) {
+					if (selector != NULL) {
+						int size = -1;
+						status = selector->driverSelector_select(selector->selector, reference, matcher->matches, &index);
+						if (status == CELIX_SUCCESS) {
+							size = arrayList_size(matcher->matches);
+							if (index != -1 && index >= 0 && index < size) {
+								*match = arrayList_get(matcher->matches, index);
+							}
+						}
+					}
+				}
+			}
+			if (status == CELIX_SUCCESS && *match == NULL) {
+				status = driverMatcher_getBestMatchInternal(matcher, match);
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, match_pt *match) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!hashMap_isEmpty(matcher->attributes)) {
+		match_key_t matchKey = NULL;
+		hash_map_iterator_pt iter = hashMapIterator_create(matcher->attributes);
+		while (hashMapIterator_hasNext(iter)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+			match_key_t key = hashMapEntry_getKey(entry);
+			if (matchKey == NULL || matchKey->matchValue < key->matchValue) {
+				matchKey = key;
+			}
+		}
+		hashMapIterator_destroy(iter);
+
+		array_list_pt das = hashMap_get(matcher->attributes, matchKey);
+		service_reference_pt best = NULL;
+		int i;
+		for (i = 0; i < arrayList_size(das); i++) {
+			driver_attributes_pt attributes = arrayList_get(das, i);
+			service_reference_pt reference = NULL;
+
+			celix_status_t substatus = driverAttributes_getReference(attributes, &reference);
+			if (substatus == CELIX_SUCCESS) {
+				if (best != NULL) {
+					const char* rank1Str;
+					const char* rank2Str;
+					int rank1, rank2;
+
+					rank1Str = "0";
+					rank2Str = "0";
+
+					logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare ranking");
+
+					serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank1Str);
+					serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank2Str);
+
+					rank1 = atoi(rank1Str);
+					rank2 = atoi(rank2Str);
+
+					if (rank1 != rank2) {
+						if (rank1 > rank2) {
+							best = reference;
+						}
+					} else {
+						const char* id1Str;
+						const char* id2Str;
+						long id1, id2;
+
+						id1Str = NULL;
+						id2Str = NULL;
+
+						logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare id's");
+
+						serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &id1Str);
+						serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &id2Str);
+
+						id1 = atol(id1Str);
+						id2 = atol(id2Str);
+
+						if (id1 < id2) {
+							best = reference;
+						}
+					}
+				} else {
+					best = reference;
+				}
+			}
+
+		}
+
+		*match = calloc(1, sizeof(**match));
+		if (!*match) {
+			status = CELIX_ENOMEM;
+		} else {
+			(*match)->matchValue = matchKey->matchValue;
+			(*match)->reference = best;
+		}
+	}
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/src/driver_matcher.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/src/driver_matcher.h b/device_access/device_access/src/driver_matcher.h
new file mode 100644
index 0000000..d6cdb22
--- /dev/null
+++ b/device_access/device_access/src/driver_matcher.h
@@ -0,0 +1,42 @@
+/**
+ *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.
+ */
+/*
+ * driver_matcher.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_MATCHER_H_
+#define DRIVER_MATCHER_H_
+
+#include "match.h"
+#include "driver_selector.h"
+#include "driver_attributes.h"
+
+typedef struct driver_matcher *driver_matcher_pt;
+
+celix_status_t driverMatcher_create(bundle_context_pt context, driver_matcher_pt *matcher);
+celix_status_t driverMatcher_destroy(driver_matcher_pt *matcher);
+
+celix_status_t driverMatcher_add(driver_matcher_pt matcher, int match, driver_attributes_pt attributes);
+
+celix_status_t driverMatcher_getBestMatch(driver_matcher_pt matcher, service_reference_pt reference, match_pt *match);
+
+#endif /* DRIVER_MATCHER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/driver_locator/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/device_access/driver_locator/CMakeLists.txt b/device_access/driver_locator/CMakeLists.txt
index 9138f4a..2e0dde2 100644
--- a/device_access/driver_locator/CMakeLists.txt
+++ b/device_access/driver_locator/CMakeLists.txt
@@ -20,15 +20,13 @@ add_bundle(driver_locator
 	VERSION "0.0.2"
 	NAME "Apache Celix Device Access Driver Locator"
 	SOURCES
-		private/src/activator
-		private/src/driver_locator
+		src/activator
+		src/driver_locator
 )
 
 install_bundle(driver_locator)
+target_include_directories(driver_locator PRIVATE src)
+target_link_libraries(driver_locator PRIVATE Celix::device_access_api)
 
-include_directories(${PROJECT_SOURCE_DIR}/device_access/device_access/public/include)
-include_directories(private/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-
-target_link_libraries(driver_locator celix_utils celix_framework)
+#Setup target aliases to match external usage
+add_library(Celix::driver_locator ALIAS driver_locator)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/driver_locator/private/include/driver_locator_private.h
----------------------------------------------------------------------
diff --git a/device_access/driver_locator/private/include/driver_locator_private.h b/device_access/driver_locator/private/include/driver_locator_private.h
deleted file mode 100644
index bf6dcbf..0000000
--- a/device_access/driver_locator/private/include/driver_locator_private.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_locator_private.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_LOCATOR_PRIVATE_H_
-#define DRIVER_LOCATOR_PRIVATE_H_
-
-#include "driver_locator.h"
-
-struct driver_locator {
-    char *path;
-    array_list_pt drivers;
-};
-
-celix_status_t driverLocator_findDrivers(driver_locator_pt locator, properties_pt props, array_list_pt *drivers);
-celix_status_t driverLocator_loadDriver(driver_locator_pt locator, char *id, char **driver);
-
-#endif /* DRIVER_LOCATOR_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/driver_locator/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/driver_locator/private/src/activator.c b/device_access/driver_locator/private/src/activator.c
deleted file mode 100644
index abc60c5..0000000
--- a/device_access/driver_locator/private/src/activator.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- *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.
- */
-/*
- * activator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "driver_locator_private.h"
-
-static const char *DEFAULT_LOCATOR_PATH = "drivers";
-
-struct bundle_instance {
-	driver_locator_service_pt service;
-	driver_locator_pt locator;
-	service_registration_pt locatorRegistration;
-};
-
-typedef struct bundle_instance *bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*userData) = calloc(1, sizeof(struct bundle_instance));
-	if ( (*userData) == NULL ){
-		status = CELIX_ENOMEM;
-	}
-    return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_instance_pt bi = (bundle_instance_pt)userData;
-
-    bi->service = calloc(1, sizeof(*(bi->service)));
-    bi->locator = calloc(1, sizeof(*(bi->locator)));
-    if(bi->service != NULL && bi->locator != NULL){
-	bi->service->findDrivers = driverLocator_findDrivers;
-	bi->service->loadDriver = driverLocator_loadDriver;
-
-	bi->service->locator = bi->locator;
-	bi->locator->drivers = NULL;
-	arrayList_create(&bi->locator->drivers);
-	bundleContext_getProperty(context, "DRIVER_LOCATOR_PATH", (const char**)&bi->locator->path);
-	if (bi->locator->path == NULL ) {
-		bi->locator->path = (char *)DEFAULT_LOCATOR_PATH;
-	}
-	status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_LOCATOR_SERVICE_NAME, bi->service, NULL, &bi->locatorRegistration);
-    }
-    else{
-	if(bi->service!=NULL) free(bi->service);
-	if(bi->locator!=NULL) free(bi->locator);
-	status = CELIX_ENOMEM;
-    }
-
-    return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_instance_pt bi = (bundle_instance_pt)userData;
-    serviceRegistration_unregister(bi->locatorRegistration);
-    arrayList_destroy(bi->locator->drivers);
-    return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-    return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/driver_locator/private/src/driver_locator.c
----------------------------------------------------------------------
diff --git a/device_access/driver_locator/private/src/driver_locator.c b/device_access/driver_locator/private/src/driver_locator.c
deleted file mode 100644
index 9c360bf..0000000
--- a/device_access/driver_locator/private/src/driver_locator.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- *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.
- */
-/*
- * driver_locator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <dirent.h>
-
-#include "driver_locator_private.h"
-#include "device.h"
-
-celix_status_t driverLocator_findDrivers(driver_locator_pt locator, properties_pt props, array_list_pt *drivers) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	const char* category = properties_get(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY);
-
-	status = arrayList_create(drivers);
-	if (status == CELIX_SUCCESS) {
-		DIR *dir;
-		dir = opendir(locator->path);
-		if (!dir) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		} else {
-			struct dirent *dp;
-			while ((dp = readdir(dir)) != NULL) {
-				char str1[256], str2[256], str3[256];
-				if (sscanf(dp->d_name, "%[^_]_%[^.].%s", str1, str2, str3) == 3 &&
-					strcmp(str1, category) == 0 &&
-					strcmp(str3, "zip") == 0) {
-					int length = strlen(str1) + strlen(str2) + 2;
-					char driver[length];
-					snprintf(driver, length, "%s_%s", str1, str2);
-                    arrayList_add(*drivers, strdup(driver));
-				}
-			}
-			closedir(dir);
-		}
-	}
-	return status;
-}
-
-celix_status_t driverLocator_loadDriver(driver_locator_pt locator, char *id, char **stream) {
-	celix_status_t status = CELIX_SUCCESS;
-	*stream = NULL;
-
-	DIR *dir;
-	dir = opendir(locator->path);
-	if (!dir) {
-		status = CELIX_FILE_IO_EXCEPTION;
-	} else {
-		struct dirent *dp;
-		while ((dp = readdir(dir)) != NULL) {
-			char str1[256], str2[256];
-			if (sscanf(dp->d_name, "%[^.].%s", str1, str2) == 2 &&
-				strcmp(str1, id) == 0 &&
-				strcmp(str2, "zip") == 0) {
-				int length = strlen(locator->path) + strlen(dp->d_name) + 2;
-				char stream_str[length];
-				snprintf(stream_str, length, "%s/%s", locator->path, dp->d_name);
-				*stream = strdup(stream_str);
-				break;
-			}
-		}
-		closedir(dir);
-	}
-
-	return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/driver_locator/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/driver_locator/src/activator.c b/device_access/driver_locator/src/activator.c
new file mode 100644
index 0000000..abc60c5
--- /dev/null
+++ b/device_access/driver_locator/src/activator.c
@@ -0,0 +1,89 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "driver_locator_private.h"
+
+static const char *DEFAULT_LOCATOR_PATH = "drivers";
+
+struct bundle_instance {
+	driver_locator_service_pt service;
+	driver_locator_pt locator;
+	service_registration_pt locatorRegistration;
+};
+
+typedef struct bundle_instance *bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*userData) = calloc(1, sizeof(struct bundle_instance));
+	if ( (*userData) == NULL ){
+		status = CELIX_ENOMEM;
+	}
+    return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+    celix_status_t status = CELIX_SUCCESS;
+    bundle_instance_pt bi = (bundle_instance_pt)userData;
+
+    bi->service = calloc(1, sizeof(*(bi->service)));
+    bi->locator = calloc(1, sizeof(*(bi->locator)));
+    if(bi->service != NULL && bi->locator != NULL){
+	bi->service->findDrivers = driverLocator_findDrivers;
+	bi->service->loadDriver = driverLocator_loadDriver;
+
+	bi->service->locator = bi->locator;
+	bi->locator->drivers = NULL;
+	arrayList_create(&bi->locator->drivers);
+	bundleContext_getProperty(context, "DRIVER_LOCATOR_PATH", (const char**)&bi->locator->path);
+	if (bi->locator->path == NULL ) {
+		bi->locator->path = (char *)DEFAULT_LOCATOR_PATH;
+	}
+	status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_LOCATOR_SERVICE_NAME, bi->service, NULL, &bi->locatorRegistration);
+    }
+    else{
+	if(bi->service!=NULL) free(bi->service);
+	if(bi->locator!=NULL) free(bi->locator);
+	status = CELIX_ENOMEM;
+    }
+
+    return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+    celix_status_t status = CELIX_SUCCESS;
+    bundle_instance_pt bi = (bundle_instance_pt)userData;
+    serviceRegistration_unregister(bi->locatorRegistration);
+    arrayList_destroy(bi->locator->drivers);
+    return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+    return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/driver_locator/src/driver_locator.c
----------------------------------------------------------------------
diff --git a/device_access/driver_locator/src/driver_locator.c b/device_access/driver_locator/src/driver_locator.c
new file mode 100644
index 0000000..9c360bf
--- /dev/null
+++ b/device_access/driver_locator/src/driver_locator.c
@@ -0,0 +1,91 @@
+/**
+ *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.
+ */
+/*
+ * driver_locator.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+
+#include "driver_locator_private.h"
+#include "device.h"
+
+celix_status_t driverLocator_findDrivers(driver_locator_pt locator, properties_pt props, array_list_pt *drivers) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	const char* category = properties_get(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY);
+
+	status = arrayList_create(drivers);
+	if (status == CELIX_SUCCESS) {
+		DIR *dir;
+		dir = opendir(locator->path);
+		if (!dir) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else {
+			struct dirent *dp;
+			while ((dp = readdir(dir)) != NULL) {
+				char str1[256], str2[256], str3[256];
+				if (sscanf(dp->d_name, "%[^_]_%[^.].%s", str1, str2, str3) == 3 &&
+					strcmp(str1, category) == 0 &&
+					strcmp(str3, "zip") == 0) {
+					int length = strlen(str1) + strlen(str2) + 2;
+					char driver[length];
+					snprintf(driver, length, "%s_%s", str1, str2);
+                    arrayList_add(*drivers, strdup(driver));
+				}
+			}
+			closedir(dir);
+		}
+	}
+	return status;
+}
+
+celix_status_t driverLocator_loadDriver(driver_locator_pt locator, char *id, char **stream) {
+	celix_status_t status = CELIX_SUCCESS;
+	*stream = NULL;
+
+	DIR *dir;
+	dir = opendir(locator->path);
+	if (!dir) {
+		status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+		struct dirent *dp;
+		while ((dp = readdir(dir)) != NULL) {
+			char str1[256], str2[256];
+			if (sscanf(dp->d_name, "%[^.].%s", str1, str2) == 2 &&
+				strcmp(str1, id) == 0 &&
+				strcmp(str2, "zip") == 0) {
+				int length = strlen(locator->path) + strlen(dp->d_name) + 2;
+				char stream_str[length];
+				snprintf(stream_str, length, "%s/%s", locator->path, dp->d_name);
+				*stream = strdup(stream_str);
+				break;
+			}
+		}
+		closedir(dir);
+	}
+
+	return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/driver_locator/src/driver_locator_private.h
----------------------------------------------------------------------
diff --git a/device_access/driver_locator/src/driver_locator_private.h b/device_access/driver_locator/src/driver_locator_private.h
new file mode 100644
index 0000000..bf6dcbf
--- /dev/null
+++ b/device_access/driver_locator/src/driver_locator_private.h
@@ -0,0 +1,39 @@
+/**
+ *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.
+ */
+/*
+ * driver_locator_private.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_LOCATOR_PRIVATE_H_
+#define DRIVER_LOCATOR_PRIVATE_H_
+
+#include "driver_locator.h"
+
+struct driver_locator {
+    char *path;
+    array_list_pt drivers;
+};
+
+celix_status_t driverLocator_findDrivers(driver_locator_pt locator, properties_pt props, array_list_pt *drivers);
+celix_status_t driverLocator_loadDriver(driver_locator_pt locator, char *id, char **driver);
+
+#endif /* DRIVER_LOCATOR_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/device_access/example/CMakeLists.txt b/device_access/example/CMakeLists.txt
index 1a5cd77..e21e5e0 100644
--- a/device_access/example/CMakeLists.txt
+++ b/device_access/example/CMakeLists.txt
@@ -22,7 +22,7 @@ if(DEVICE_ACCESS_EXAMPLE)
 	add_subdirectory(refining_driver)
 
     add_deploy(device_access_example
-        BUNDLES device_manager driver_locator shell shell_tui log_service base_driver
+        BUNDLES Celix::device_manager Celix::driver_locator Celix::shell Celix::shell_tui log_service base_driver
     )
 
     deploy_bundles_dir(device_access_example

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/CMakeLists.txt b/device_access/example/base_driver/CMakeLists.txt
index c354d3b..49096a6 100644
--- a/device_access/example/base_driver/CMakeLists.txt
+++ b/device_access/example/base_driver/CMakeLists.txt
@@ -20,14 +20,9 @@ add_bundle(base_driver
  	VERSION "0.0.1"
  	NAME "Apache Celix Device Access Base Driver Example"
 	SOURCES
-		private/src/activator
-		private/src/base_driver
+		src/activator
+		src/base_driver
 )
-
-include_directories(${PROJECT_SOURCE_DIR}/device_access/device_access/public/include)
-include_directories(private/include)
-include_directories(public/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-
-target_link_libraries(base_driver celix_utils celix_framework)
+target_include_directories(base_driver PRIVATE src)
+target_include_directories(base_driver PUBLIC include)
+target_link_libraries(base_driver PRIVATE Celix::device_access_api)


[10/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/include/log_listener.h
----------------------------------------------------------------------
diff --git a/log_service/public/include/log_listener.h b/log_service/public/include/log_listener.h
deleted file mode 100644
index b726994..0000000
--- a/log_service/public/include/log_listener.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *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.
- */
-/*
- * log_listener.h
- *
- *  \date       Jul 4, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_LISTENER_H_
-#define LOG_LISTENER_H_
-
-#include "log_entry.h"
-#include "celix_errno.h"
-
-struct log_listener {
-    void *handle;
-    celix_status_t (*logged)(struct log_listener *listener, log_entry_pt entry);
-};
-
-typedef struct log_listener log_listener_t;
-typedef log_listener_t* log_listener_pt;
-
-celix_status_t logListener_logged(log_listener_pt listener, log_entry_pt entry);
-
-#endif /* LOG_LISTENER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/include/log_reader_service.h
----------------------------------------------------------------------
diff --git a/log_service/public/include/log_reader_service.h b/log_service/public/include/log_reader_service.h
deleted file mode 100644
index 6815123..0000000
--- a/log_service/public/include/log_reader_service.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- *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.
- */
-/*
- * log_reader_service.h
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_READER_SERVICE_H_
-#define LOG_READER_SERVICE_H_
-
-
-#include "celix_errno.h"
-#include "linked_list.h"
-#include "log_listener.h"
-
-static const char * const OSGI_LOGSERVICE_READER_SERVICE_NAME = "log_reader_service";
-
-typedef struct log_reader_data log_reader_data_t;
-typedef log_reader_data_t* log_reader_data_pt;
-
-struct log_reader_service {
-    log_reader_data_pt reader;
-    celix_status_t (*getLog)(log_reader_data_pt reader, linked_list_pt *list);
-    celix_status_t (*addLogListener)(log_reader_data_pt reader, log_listener_pt listener);
-    celix_status_t (*removeLogListener)(log_reader_data_pt reader, log_listener_pt listener);
-    celix_status_t (*removeAllLogListener)(log_reader_data_pt reader);
-};
-
-typedef struct log_reader_service * log_reader_service_pt;
-
-#endif /* LOG_READER_SERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/include/log_service.h
----------------------------------------------------------------------
diff --git a/log_service/public/include/log_service.h b/log_service/public/include/log_service.h
deleted file mode 100644
index 2691e35..0000000
--- a/log_service/public/include/log_service.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- *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.
- */
-/*
- * log_service.h
- *
- *  \date       Jun 22, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_SERVICE_H_
-#define LOG_SERVICE_H_
-
-#include "celix_errno.h"
-#include "service_reference.h"
-
-static const char * const OSGI_LOGSERVICE_NAME = "log_service";
-
-typedef struct log_service_data *log_service_data_pt;
-
-enum log_level
-{
-    OSGI_LOGSERVICE_ERROR = 0x00000001,
-    OSGI_LOGSERVICE_WARNING = 0x00000002,
-    OSGI_LOGSERVICE_INFO = 0x00000003,
-    OSGI_LOGSERVICE_DEBUG = 0x00000004,
-};
-
-typedef enum log_level log_level_t;
-
-struct log_service {
-    log_service_data_pt logger;
-    celix_status_t (*log)(log_service_data_pt logger, log_level_t level, char * message);
-    celix_status_t (*logSr)(log_service_data_pt logger, service_reference_pt reference, log_level_t level, char * message);
-};
-
-typedef struct log_service log_service_t;
-typedef log_service_t* log_service_pt;
-
-
-
-#endif /* LOG_SERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/src/log_helper.c
----------------------------------------------------------------------
diff --git a/log_service/public/src/log_helper.c b/log_service/public/src/log_helper.c
deleted file mode 100644
index c0cd309..0000000
--- a/log_service/public/src/log_helper.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
- *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.
- */
-/*
- * log_helper.c
- *
- *  \date       Nov 10, 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "bundle_context.h"
-#include "service_tracker.h"
-#include "celix_threads.h"
-#include "array_list.h"
-
-#include "celix_errno.h"
-#include "log_service.h"
-
-#include "log_helper.h"
-
-#define LOGHELPER_ENABLE_STDOUT_FALLBACK_PROPERTY_NAME 	"LOGHELPER_ENABLE_STDOUT_FALLBACK"
-
-
-struct log_helper {
-	bundle_context_pt bundleContext;
-    service_tracker_pt logServiceTracker;
-	celix_thread_mutex_t logListLock;
-	array_list_pt logServices;
-	bool stdOutFallback;
-};
-
-celix_status_t logHelper_logServiceAdded(void *handle, service_reference_pt reference, void *service);
-celix_status_t logHelper_logServiceRemoved(void *handle, service_reference_pt reference, void *service);
-
-
-celix_status_t logHelper_create(bundle_context_pt context, log_helper_pt* loghelper)
-{
-	celix_status_t status = CELIX_SUCCESS;
-
-	(*loghelper) = calloc(1, sizeof(**loghelper));
-
-	if (!(*loghelper))
-	{
-		status = CELIX_ENOMEM;
-	}
-	else
-	{
-		const char* stdOutFallbackStr = NULL;
-		(*loghelper)->bundleContext = context;
-		(*loghelper)->logServiceTracker = NULL;
-		(*loghelper)->stdOutFallback = false;
-
-		bundleContext_getProperty(context, LOGHELPER_ENABLE_STDOUT_FALLBACK_PROPERTY_NAME, &stdOutFallbackStr);
-
-		if (stdOutFallbackStr != NULL) {
-			(*loghelper)->stdOutFallback = true;
-		}
-
-		pthread_mutex_init(&(*loghelper)->logListLock, NULL);
-        arrayList_create(&(*loghelper)->logServices);
-	}
-
-	return status;
-}
-
-celix_status_t logHelper_start(log_helper_pt loghelper)
-{
-	celix_status_t status;
-	service_tracker_customizer_pt logTrackerCustomizer = NULL;
-
-	status = serviceTrackerCustomizer_create(loghelper, NULL, logHelper_logServiceAdded, NULL, logHelper_logServiceRemoved, &logTrackerCustomizer);
-
-	if (status == CELIX_SUCCESS) {
-        loghelper->logServiceTracker = NULL;
-		status = serviceTracker_create(loghelper->bundleContext, (char*) OSGI_LOGSERVICE_NAME, logTrackerCustomizer, &loghelper->logServiceTracker);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = serviceTracker_open(loghelper->logServiceTracker);
-	}
-
-	return status;
-}
-
-
-
-celix_status_t logHelper_logServiceAdded(void *handle, service_reference_pt reference, void *service)
-{
-	log_helper_pt loghelper = handle;
-
-	pthread_mutex_lock(&loghelper->logListLock);
-	arrayList_add(loghelper->logServices, service);
-	pthread_mutex_unlock(&loghelper->logListLock);
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t logHelper_logServiceRemoved(void *handle, service_reference_pt reference, void *service)
-{
-	log_helper_pt loghelper = handle;
-
-	pthread_mutex_lock(&loghelper->logListLock);
-	arrayList_removeElement(loghelper->logServices, service);
-	pthread_mutex_unlock(&loghelper->logListLock);
-
-	return CELIX_SUCCESS;
-}
-
-
-celix_status_t logHelper_stop(log_helper_pt loghelper) {
-	celix_status_t status;
-
-    status = serviceTracker_close(loghelper->logServiceTracker);
-
-    return status;
-}
-
-celix_status_t logHelper_destroy(log_helper_pt* loghelper) {
-        celix_status_t status = CELIX_SUCCESS;
-
-        if((*loghelper)->logServiceTracker){
-      		serviceTracker_destroy((*loghelper)->logServiceTracker);
-        }
-
-        pthread_mutex_lock(&(*loghelper)->logListLock);
-        arrayList_destroy((*loghelper)->logServices);
-    	pthread_mutex_unlock(&(*loghelper)->logListLock);
-
-        pthread_mutex_destroy(&(*loghelper)->logListLock);
-
-        free(*loghelper);
-        *loghelper = NULL;
-        return status;
-}
-
-
-
-
-celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* message, ... )
-{
-    celix_status_t status = CELIX_SUCCESS;
-	va_list listPointer;
-    char msg[1024];
-    msg[0] = '\0';
-    bool logged = false;
-
-    if(loghelper == NULL){
-	return CELIX_ILLEGAL_ARGUMENT;
-    }
-
-	va_start(listPointer, message);
-	vsnprintf(msg, 1024, message, listPointer);
-
-	pthread_mutex_lock(&loghelper->logListLock);
-
-	int i = 0;
-	for (; i < arrayList_size(loghelper->logServices); i++) {
-		log_service_pt logService = arrayList_get(loghelper->logServices, i);
-		if (logService != NULL) {
-			(logService->log)(logService->logger, level, msg);
-			logged = true;
-		}
-	}
-
-	pthread_mutex_unlock(&loghelper->logListLock);
-
-    if (!logged && loghelper->stdOutFallback) {
-        char *levelStr = NULL;
-
-        switch (level) {
-            case OSGI_LOGSERVICE_ERROR:
-                levelStr = "ERROR";
-                break;
-            case OSGI_LOGSERVICE_WARNING:
-                levelStr = "WARNING";
-                break;
-            case OSGI_LOGSERVICE_INFO:
-                levelStr = "INFO";
-                break;
-            case OSGI_LOGSERVICE_DEBUG:
-            default:
-                levelStr = "DEBUG";
-                break;
-        }
-
-        printf("%s: %s\n", levelStr, msg);
-    }
-
-    va_end(listPointer);
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log.c
----------------------------------------------------------------------
diff --git a/log_service/src/log.c b/log_service/src/log.c
new file mode 100644
index 0000000..5b29318
--- /dev/null
+++ b/log_service/src/log.c
@@ -0,0 +1,375 @@
+/**
+ *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.
+ */
+/*
+ * log.c
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "log.h"
+#include "linked_list_iterator.h"
+#include "array_list.h"
+
+struct log {
+	linked_list_pt entries;
+	celix_thread_mutex_t lock;
+
+	array_list_pt listeners;
+	array_list_pt listenerEntries;
+
+	celix_thread_t listenerThread;
+	bool running;
+
+	celix_thread_cond_t entriesToDeliver;
+	celix_thread_mutex_t deliverLock;
+	celix_thread_mutex_t listenerLock;
+
+	int max_size;
+	bool store_debug;
+};
+
+static celix_status_t log_startListenerThread(log_pt logger);
+static celix_status_t log_stopListenerThread(log_pt logger);
+
+
+static void *log_listenerThread(void *data);
+
+celix_status_t log_create(int max_size, bool store_debug, log_pt *logger) {
+	celix_status_t status = CELIX_ENOMEM;
+
+	*logger = calloc(1, sizeof(**logger));
+
+	if (*logger != NULL) {
+		linkedList_create(&(*logger)->entries);
+
+		status = celixThreadMutex_create(&(*logger)->lock, NULL);
+
+		(*logger)->listeners = NULL;
+		(*logger)->listenerEntries = NULL;
+		(*logger)->listenerThread = celix_thread_default;
+		(*logger)->running = false;
+
+		(*logger)->max_size = max_size;
+		(*logger)->store_debug = store_debug;
+
+		arrayList_create(&(*logger)->listeners);
+		arrayList_create(&(*logger)->listenerEntries);
+
+		if (celixThreadCondition_init(&(*logger)->entriesToDeliver, NULL) != CELIX_SUCCESS) {
+			status = CELIX_INVALID_SYNTAX;
+		}
+		else if (celixThreadMutex_create(&(*logger)->deliverLock, NULL) != CELIX_SUCCESS) {
+			status = CELIX_INVALID_SYNTAX;
+		}
+		else if (celixThreadMutex_create(&(*logger)->listenerLock, NULL) != CELIX_SUCCESS) {
+			status = CELIX_INVALID_SYNTAX;
+		}
+		else {
+			status = CELIX_SUCCESS;
+		}
+	}
+
+	return status;
+}
+
+celix_status_t log_destroy(log_pt logger) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	celixThreadMutex_destroy(&logger->listenerLock);
+	celixThreadMutex_destroy(&logger->deliverLock);
+	celixThreadCondition_destroy(&logger->entriesToDeliver);
+
+	arrayList_destroy(logger->listeners);
+	linked_list_iterator_pt iter = linkedListIterator_create(logger->entries, 0);
+	while (linkedListIterator_hasNext(iter)) {
+        	log_entry_pt entry = linkedListIterator_next(iter);
+        	if (arrayList_contains(logger->listenerEntries, entry)) {
+            		arrayList_removeElement(logger->listenerEntries, entry);
+        	}
+        	logEntry_destroy(&entry);
+    	}
+    	linkedListIterator_destroy(iter);
+
+    	array_list_iterator_pt entryIter = arrayListIterator_create(logger->listenerEntries);
+
+    	while (arrayListIterator_hasNext(entryIter)) {
+        	log_entry_pt entry = arrayListIterator_next(entryIter);
+        	logEntry_destroy(&entry);
+    	}
+    	arrayListIterator_destroy(entryIter);
+
+    	arrayList_destroy(logger->listenerEntries);
+	linkedList_destroy(logger->entries);
+
+	celixThreadMutex_destroy(&logger->lock);
+
+	free(logger);
+
+	return status;
+}
+
+celix_status_t log_addEntry(log_pt log, log_entry_pt entry) {
+	celixThreadMutex_lock(&log->lock);
+
+	if (log->max_size != 0) {
+		if (log->store_debug || entry->level != OSGI_LOGSERVICE_DEBUG) {
+			linkedList_addElement(log->entries, entry);
+		}
+	}
+
+	celixThreadMutex_lock(&log->deliverLock);
+	arrayList_add(log->listenerEntries, entry);
+	celixThreadMutex_unlock(&log->deliverLock);
+
+	celixThreadCondition_signal(&log->entriesToDeliver);
+
+	if (log->max_size != 0) {
+		if (log->max_size != -1) {
+			if (linkedList_size(log->entries) > log->max_size) {
+				log_entry_pt rentry = linkedList_removeFirst(log->entries);
+				if (rentry) {
+					celixThreadMutex_lock(&log->deliverLock);
+					arrayList_removeElement(log->listenerEntries, rentry);
+					logEntry_destroy(&rentry);
+					celixThreadMutex_unlock(&log->deliverLock);
+				}
+			}
+		}
+	}
+
+	celixThreadMutex_unlock(&log->lock);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t log_getEntries(log_pt log, linked_list_pt *list) {
+	linked_list_pt entries = NULL;
+	if (linkedList_create(&entries) == CELIX_SUCCESS) {
+		linked_list_iterator_pt iter = NULL;
+
+		celixThreadMutex_lock(&log->lock);
+
+		iter = linkedListIterator_create(log->entries, 0);
+		while (linkedListIterator_hasNext(iter)) {
+			linkedList_addElement(entries, linkedListIterator_next(iter));
+		}
+		linkedListIterator_destroy(iter);
+
+		*list = entries;
+
+		celixThreadMutex_unlock(&log->lock);
+
+		return CELIX_SUCCESS;
+	} else {
+		return CELIX_ENOMEM;
+	}
+}
+
+celix_status_t log_bundleChanged(void *listener, bundle_event_pt event) {
+	celix_status_t status = CELIX_SUCCESS;
+	log_pt logger = ((bundle_listener_pt) listener)->handle;
+	log_entry_pt entry = NULL;
+
+	int messagesLength = 10;
+	char *messages[] = {
+		"BUNDLE_EVENT_INSTALLED",
+		"BUNDLE_EVENT_STARTED",
+		"BUNDLE_EVENT_STOPPED",
+		"BUNDLE_EVENT_UPDATED",
+		"BUNDLE_EVENT_UNINSTALLED",
+		"BUNDLE_EVENT_RESOLVED",
+		"BUNDLE_EVENT_UNRESOLVED",
+		"BUNDLE_EVENT_STARTING",
+		"BUNDLE_EVENT_STOPPING",
+		"BUNDLE_EVENT_LAZY_ACTIVATION"
+	};
+
+	char *message = NULL;
+	int i = 0;
+	for (i = 0; i < messagesLength; i++) {
+		if (event->type >> i == 1) {
+			message = messages[i];
+		}
+	}
+
+	if (message != NULL) {
+		status = logEntry_create(event->bundleId, event->bundleSymbolicName, NULL, OSGI_LOGSERVICE_INFO, message, 0, &entry);
+		if (status == CELIX_SUCCESS) {
+			status = log_addEntry(logger, entry);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t log_frameworkEvent(void *listener, framework_event_pt event) {
+	celix_status_t status;
+	log_pt logger = ((framework_listener_pt) listener)->handle;
+	log_entry_pt entry = NULL;
+
+	status = logEntry_create(event->bundleId, event->bundleSymbolicName, NULL, (event->type == OSGI_FRAMEWORK_EVENT_ERROR) ? OSGI_LOGSERVICE_ERROR : OSGI_LOGSERVICE_INFO, event->error, event->errorCode, &entry);
+	if (status == CELIX_SUCCESS) {
+		status = log_addEntry(logger, entry);
+	}
+
+	return status;
+}
+
+celix_status_t log_addLogListener(log_pt logger, log_listener_pt listener) {
+	celix_status_t status;
+
+	status = celixThreadMutex_lock(&logger->listenerLock);
+
+	if (status == CELIX_SUCCESS) {
+		arrayList_add(logger->listeners, listener);
+		log_startListenerThread(logger);
+
+		status = celixThreadMutex_unlock(&logger->listenerLock);
+	}
+
+	return status;
+}
+
+celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    status += celixThreadMutex_lock(&logger->deliverLock);
+    status += celixThreadMutex_lock(&logger->listenerLock);
+
+	if (status == CELIX_SUCCESS) {
+	    bool last = false;
+
+		arrayList_removeElement(logger->listeners, listener);
+		if (arrayList_size(logger->listeners) == 0) {
+			status = log_stopListenerThread(logger);
+			last = true;
+		}
+
+        status += celixThreadMutex_unlock(&logger->listenerLock);
+        status += celixThreadMutex_unlock(&logger->deliverLock);
+
+		if (last) {
+		    status += celixThread_join(logger->listenerThread, NULL);
+		}
+	}
+
+	if (status != CELIX_SUCCESS) {
+		status = CELIX_SERVICE_EXCEPTION;
+	}
+
+	return status;
+}
+
+celix_status_t log_removeAllLogListener(log_pt logger) {
+	celix_status_t status;
+
+	status = celixThreadMutex_lock(&logger->listenerLock);
+
+    if (status == CELIX_SUCCESS) {
+    	arrayList_clear(logger->listeners);
+
+    	status = celixThreadMutex_unlock(&logger->listenerLock);
+    }
+
+	return status;
+}
+
+static celix_status_t log_startListenerThread(log_pt logger) {
+	celix_status_t status;
+
+	logger->running = true;
+    logger->running = true;
+    status = celixThread_create(&logger->listenerThread, NULL, log_listenerThread, logger);
+
+	return status;
+}
+
+static celix_status_t log_stopListenerThread(log_pt logger) {
+	celix_status_t status;
+
+	logger->running = false;
+
+	status = celixThreadCondition_signal(&logger->entriesToDeliver);
+
+	return status;
+}
+
+static void * log_listenerThread(void *data) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	log_pt logger = data;
+
+	while (logger->running) {
+
+		status = celixThreadMutex_lock(&logger->deliverLock);
+
+		if ( status != CELIX_SUCCESS) {
+			logger->running = false;
+		}
+		else {
+			if (!arrayList_isEmpty(logger->listenerEntries)) {
+				log_entry_pt entry = (log_entry_pt) arrayList_remove(logger->listenerEntries, 0);
+
+				if (entry) {
+					status = celixThreadMutex_lock(&logger->listenerLock);
+					if (status != CELIX_SUCCESS) {
+						logger->running = false;
+						break;
+					} else {
+						array_list_iterator_pt it = arrayListIterator_create(logger->listeners);
+						while (arrayListIterator_hasNext(it)) {
+							log_listener_pt listener = arrayListIterator_next(it);
+							listener->logged(listener, entry);
+						}
+						arrayListIterator_destroy(it);
+
+						// destroy not-stored entries
+						if (!(logger->store_debug || entry->level != OSGI_LOGSERVICE_DEBUG)) {
+							logEntry_destroy(&entry);
+						}
+
+						status = celixThreadMutex_unlock(&logger->listenerLock);
+						if (status != CELIX_SUCCESS) {
+							logger->running = false;
+							break;
+						}
+					}
+				}
+			}
+
+			if (arrayList_isEmpty(logger->listenerEntries) && logger->running) {
+				celixThreadCondition_wait(&logger->entriesToDeliver, &logger->deliverLock);
+			}
+
+			status = celixThreadMutex_unlock(&logger->deliverLock);
+
+			if (status != CELIX_SUCCESS) {
+				logger->running = false;
+				break;
+			}
+		}
+
+	}
+
+    celixThread_exit(NULL);
+    return NULL;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log.h
----------------------------------------------------------------------
diff --git a/log_service/src/log.h b/log_service/src/log.h
new file mode 100644
index 0000000..e0d7b87
--- /dev/null
+++ b/log_service/src/log.h
@@ -0,0 +1,48 @@
+/**
+ *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.
+ */
+/*
+ * log.h
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_H_
+#define LOG_H_
+
+#include "linked_list.h"
+#include "log_entry.h"
+#include "log_listener.h"
+
+typedef struct log * log_pt;
+
+celix_status_t log_create(int max_size, bool store_debug, log_pt *logger);
+celix_status_t log_destroy(log_pt logger);
+celix_status_t log_addEntry(log_pt log, log_entry_pt entry);
+celix_status_t log_getEntries(log_pt log, linked_list_pt *list);
+
+celix_status_t log_bundleChanged(void *listener, bundle_event_pt event);
+celix_status_t log_frameworkEvent(void *listener, framework_event_pt event);
+
+celix_status_t log_addLogListener(log_pt logger, log_listener_pt listener);
+celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener);
+celix_status_t log_removeAllLogListener(log_pt logger);
+
+#endif /* LOG_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_entry.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_entry.c b/log_service/src/log_entry.c
new file mode 100644
index 0000000..3a8603a
--- /dev/null
+++ b/log_service/src/log_entry.c
@@ -0,0 +1,94 @@
+/**
+ *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.
+ */
+/*
+ * log_entry.c
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "celix_errno.h"
+#include "log_service.h"
+#include "log_entry.h"
+
+celix_status_t logEntry_create(long bundleId, const char* bundleSymbolicName , service_reference_pt reference,
+        log_level_t level, char *message, int errorCode,
+        log_entry_pt *entry) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *entry = malloc(sizeof(**entry));
+    if (*entry == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        (*entry)->level = level;
+        (*entry)->message = strdup(message);
+        (*entry)->errorCode = errorCode;
+        (*entry)->time = time(NULL);
+
+        (*entry)->bundleSymbolicName = strdup(bundleSymbolicName);
+        (*entry)->bundleId = bundleId;
+    }
+
+    return status;
+}
+
+celix_status_t logEntry_destroy(log_entry_pt *entry) {
+    if (*entry) {
+    	free((*entry)->bundleSymbolicName);
+        free((*entry)->message);
+        free(*entry);
+        *entry = NULL;
+    }
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getBundleSymbolicName(log_entry_pt entry, const char** bundleSymbolicName) {
+    *bundleSymbolicName = entry->bundleSymbolicName;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getBundleId(log_entry_pt entry, long *bundleId) {
+    *bundleId = entry->bundleId;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getErrorCode(log_entry_pt entry, int *errorCode) {
+    *errorCode = entry->errorCode;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getLevel(log_entry_pt entry, log_level_t *level) {
+    *level = entry->level;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getMessage(log_entry_pt entry, const char **message) {
+    *message = entry->message;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getTime(log_entry_pt entry, time_t *time) {
+    *time = entry->time;
+    return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_factory.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_factory.c b/log_service/src/log_factory.c
new file mode 100644
index 0000000..1c0a17a
--- /dev/null
+++ b/log_service/src/log_factory.c
@@ -0,0 +1,100 @@
+/**
+ *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.
+ */
+/*
+ * log_factory.c
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+
+
+#include "service_factory.h"
+#include "log_factory.h"
+#include "log_service_impl.h"
+
+struct log_service_factory {
+    log_pt log;
+};
+
+celix_status_t logFactory_create(log_pt log, service_factory_pt *factory) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *factory = calloc(1, sizeof(**factory));
+    if (*factory == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        log_service_factory_pt factoryData = calloc(1, sizeof(*factoryData));
+        if (factoryData == NULL) {
+            status = CELIX_ENOMEM;
+        } else {
+            factoryData->log = log;
+
+            (*factory)->handle = factoryData;
+            (*factory)->getService = logFactory_getService;
+            (*factory)->ungetService = logFactory_ungetService;
+        }
+    }
+
+    return status;
+}
+
+celix_status_t logFactory_destroy(service_factory_pt *factory) {
+    celix_status_t status = CELIX_SUCCESS;
+
+
+    free((*factory)->handle);
+    free(*factory);
+
+    factory = NULL;
+
+    return status;
+}
+
+
+celix_status_t logFactory_getService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service) {
+    log_service_factory_pt log_factory = factory;
+    log_service_pt log_service = NULL;
+    log_service_data_pt log_service_data = NULL;
+
+    logService_create(log_factory->log, bundle, &log_service_data);
+
+    log_service = calloc(1, sizeof(*log_service));
+    log_service->logger = log_service_data;
+    log_service->log = logService_log;
+  //  log_service->logSr = logService_logSr;
+
+    (*service) = log_service;
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service) {
+	log_service_pt log_service = *service;
+
+	logService_destroy(&log_service->logger);
+
+	free(*service);
+	*service = NULL;
+
+    return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_factory.h
----------------------------------------------------------------------
diff --git a/log_service/src/log_factory.h b/log_service/src/log_factory.h
new file mode 100644
index 0000000..8ebe5f8
--- /dev/null
+++ b/log_service/src/log_factory.h
@@ -0,0 +1,40 @@
+/**
+ *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.
+ */
+/*
+ * log_factory.h
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_FACTORY_H_
+#define LOG_FACTORY_H_
+
+#include "log.h"
+
+typedef struct log_service_factory * log_service_factory_pt;
+
+celix_status_t logFactory_create(log_pt log, service_factory_pt *factory);
+celix_status_t logFactory_destroy(service_factory_pt *factory);
+celix_status_t logFactory_getService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service);
+celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service);
+
+
+#endif /* LOG_FACTORY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_helper.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_helper.c b/log_service/src/log_helper.c
new file mode 100644
index 0000000..c0cd309
--- /dev/null
+++ b/log_service/src/log_helper.c
@@ -0,0 +1,211 @@
+/**
+ *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.
+ */
+/*
+ * log_helper.c
+ *
+ *  \date       Nov 10, 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "bundle_context.h"
+#include "service_tracker.h"
+#include "celix_threads.h"
+#include "array_list.h"
+
+#include "celix_errno.h"
+#include "log_service.h"
+
+#include "log_helper.h"
+
+#define LOGHELPER_ENABLE_STDOUT_FALLBACK_PROPERTY_NAME 	"LOGHELPER_ENABLE_STDOUT_FALLBACK"
+
+
+struct log_helper {
+	bundle_context_pt bundleContext;
+    service_tracker_pt logServiceTracker;
+	celix_thread_mutex_t logListLock;
+	array_list_pt logServices;
+	bool stdOutFallback;
+};
+
+celix_status_t logHelper_logServiceAdded(void *handle, service_reference_pt reference, void *service);
+celix_status_t logHelper_logServiceRemoved(void *handle, service_reference_pt reference, void *service);
+
+
+celix_status_t logHelper_create(bundle_context_pt context, log_helper_pt* loghelper)
+{
+	celix_status_t status = CELIX_SUCCESS;
+
+	(*loghelper) = calloc(1, sizeof(**loghelper));
+
+	if (!(*loghelper))
+	{
+		status = CELIX_ENOMEM;
+	}
+	else
+	{
+		const char* stdOutFallbackStr = NULL;
+		(*loghelper)->bundleContext = context;
+		(*loghelper)->logServiceTracker = NULL;
+		(*loghelper)->stdOutFallback = false;
+
+		bundleContext_getProperty(context, LOGHELPER_ENABLE_STDOUT_FALLBACK_PROPERTY_NAME, &stdOutFallbackStr);
+
+		if (stdOutFallbackStr != NULL) {
+			(*loghelper)->stdOutFallback = true;
+		}
+
+		pthread_mutex_init(&(*loghelper)->logListLock, NULL);
+        arrayList_create(&(*loghelper)->logServices);
+	}
+
+	return status;
+}
+
+celix_status_t logHelper_start(log_helper_pt loghelper)
+{
+	celix_status_t status;
+	service_tracker_customizer_pt logTrackerCustomizer = NULL;
+
+	status = serviceTrackerCustomizer_create(loghelper, NULL, logHelper_logServiceAdded, NULL, logHelper_logServiceRemoved, &logTrackerCustomizer);
+
+	if (status == CELIX_SUCCESS) {
+        loghelper->logServiceTracker = NULL;
+		status = serviceTracker_create(loghelper->bundleContext, (char*) OSGI_LOGSERVICE_NAME, logTrackerCustomizer, &loghelper->logServiceTracker);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = serviceTracker_open(loghelper->logServiceTracker);
+	}
+
+	return status;
+}
+
+
+
+celix_status_t logHelper_logServiceAdded(void *handle, service_reference_pt reference, void *service)
+{
+	log_helper_pt loghelper = handle;
+
+	pthread_mutex_lock(&loghelper->logListLock);
+	arrayList_add(loghelper->logServices, service);
+	pthread_mutex_unlock(&loghelper->logListLock);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t logHelper_logServiceRemoved(void *handle, service_reference_pt reference, void *service)
+{
+	log_helper_pt loghelper = handle;
+
+	pthread_mutex_lock(&loghelper->logListLock);
+	arrayList_removeElement(loghelper->logServices, service);
+	pthread_mutex_unlock(&loghelper->logListLock);
+
+	return CELIX_SUCCESS;
+}
+
+
+celix_status_t logHelper_stop(log_helper_pt loghelper) {
+	celix_status_t status;
+
+    status = serviceTracker_close(loghelper->logServiceTracker);
+
+    return status;
+}
+
+celix_status_t logHelper_destroy(log_helper_pt* loghelper) {
+        celix_status_t status = CELIX_SUCCESS;
+
+        if((*loghelper)->logServiceTracker){
+      		serviceTracker_destroy((*loghelper)->logServiceTracker);
+        }
+
+        pthread_mutex_lock(&(*loghelper)->logListLock);
+        arrayList_destroy((*loghelper)->logServices);
+    	pthread_mutex_unlock(&(*loghelper)->logListLock);
+
+        pthread_mutex_destroy(&(*loghelper)->logListLock);
+
+        free(*loghelper);
+        *loghelper = NULL;
+        return status;
+}
+
+
+
+
+celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* message, ... )
+{
+    celix_status_t status = CELIX_SUCCESS;
+	va_list listPointer;
+    char msg[1024];
+    msg[0] = '\0';
+    bool logged = false;
+
+    if(loghelper == NULL){
+	return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+	va_start(listPointer, message);
+	vsnprintf(msg, 1024, message, listPointer);
+
+	pthread_mutex_lock(&loghelper->logListLock);
+
+	int i = 0;
+	for (; i < arrayList_size(loghelper->logServices); i++) {
+		log_service_pt logService = arrayList_get(loghelper->logServices, i);
+		if (logService != NULL) {
+			(logService->log)(logService->logger, level, msg);
+			logged = true;
+		}
+	}
+
+	pthread_mutex_unlock(&loghelper->logListLock);
+
+    if (!logged && loghelper->stdOutFallback) {
+        char *levelStr = NULL;
+
+        switch (level) {
+            case OSGI_LOGSERVICE_ERROR:
+                levelStr = "ERROR";
+                break;
+            case OSGI_LOGSERVICE_WARNING:
+                levelStr = "WARNING";
+                break;
+            case OSGI_LOGSERVICE_INFO:
+                levelStr = "INFO";
+                break;
+            case OSGI_LOGSERVICE_DEBUG:
+            default:
+                levelStr = "DEBUG";
+                break;
+        }
+
+        printf("%s: %s\n", levelStr, msg);
+    }
+
+    va_end(listPointer);
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_reader_service_impl.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_reader_service_impl.c b/log_service/src/log_reader_service_impl.c
new file mode 100644
index 0000000..2a46ea7
--- /dev/null
+++ b/log_service/src/log_reader_service_impl.c
@@ -0,0 +1,82 @@
+/**
+ *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.
+ */
+ /*
+ * log_reader_service_impl.c
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <stddef.h>
+
+#include "log_reader_service_impl.h"
+#include "celixbool.h"
+
+struct log_reader_data {
+    log_pt log;
+};
+
+celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *reader = (log_reader_data_pt) calloc(1, sizeof(**reader));
+
+    if (*reader == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        (*reader)->log = log;
+    }
+
+    return status;
+}
+
+celix_status_t logReaderService_destroy(log_reader_data_pt *reader) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(*reader);
+    reader = NULL;
+
+    return status;
+}
+
+
+
+celix_status_t logReaderService_getLog(log_reader_data_pt reader, linked_list_pt *list) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    status = log_getEntries(reader->log, list);
+
+    return status;
+}
+
+celix_status_t logReaderService_addLogListener(log_reader_data_pt reader, log_listener_pt listener) {
+    return log_addLogListener(reader->log, listener);
+}
+
+celix_status_t logReaderService_removeLogListener(log_reader_data_pt reader, log_listener_pt listener) {
+    return log_removeLogListener(reader->log, listener);
+}
+
+celix_status_t logReaderService_removeAllLogListener(log_reader_data_pt reader) {
+    return log_removeAllLogListener(reader->log);
+}
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_reader_service_impl.h
----------------------------------------------------------------------
diff --git a/log_service/src/log_reader_service_impl.h b/log_service/src/log_reader_service_impl.h
new file mode 100644
index 0000000..71829f2
--- /dev/null
+++ b/log_service/src/log_reader_service_impl.h
@@ -0,0 +1,43 @@
+/**
+ *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.
+ */
+/*
+ * log_reader_service_impl.h
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_READER_SERVICE_IMPL_H_
+#define LOG_READER_SERVICE_IMPL_H_
+
+#include "log_reader_service.h"
+#include "log.h"
+
+celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader);
+celix_status_t logReaderService_destroy(log_reader_data_pt *reader);
+
+celix_status_t logReaderService_getLog(log_reader_data_pt reader, linked_list_pt *list);
+
+celix_status_t logReaderService_addLogListener(log_reader_data_pt reader, log_listener_pt listener);
+celix_status_t logReaderService_removeLogListener(log_reader_data_pt reader, log_listener_pt listener);
+celix_status_t logReaderService_removeAllLogListener(log_reader_data_pt reader);
+
+
+#endif /* LOG_READER_SERVICE_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_service_activator.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_service_activator.c b/log_service/src/log_service_activator.c
new file mode 100644
index 0000000..8c72fb1
--- /dev/null
+++ b/log_service/src/log_service_activator.c
@@ -0,0 +1,198 @@
+/**
+ *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.
+ */
+/*
+ * log_service_activator.c
+ *
+ *  \date       Jun 25, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <constants.h>
+
+#include "bundle_activator.h"
+#include "log_service_impl.h"
+#include "service_factory.h"
+#include "log_factory.h"
+#include "log.h"
+#include "log_reader_service_impl.h"
+#include "service_registration.h"
+
+#define DEFAULT_MAX_SIZE 100
+#define DEFAULT_STORE_DEBUG false
+
+#define MAX_SIZE_PROPERTY "CELIX_LOG_MAX_SIZE"
+#define STORE_DEBUG_PROPERTY "CELIX_LOG_STORE_DEBUG"
+
+struct logActivator {
+    bundle_context_pt bundleContext;
+    service_registration_pt logServiceFactoryReg;
+    service_registration_pt logReaderServiceReg;
+
+    bundle_listener_pt bundleListener;
+    framework_listener_pt frameworkListener;
+
+    log_pt logger;
+    service_factory_pt factory;
+    log_reader_data_pt reader;
+    log_reader_service_pt reader_service;
+};
+
+static celix_status_t bundleActivator_getMaxSize(struct logActivator *activator, int *max_size);
+static celix_status_t bundleActivator_getStoreDebug(struct logActivator *activator, bool *store_debug);
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+    celix_status_t status = CELIX_SUCCESS;
+	struct logActivator * activator = NULL;
+
+    activator = (struct logActivator *) calloc(1, sizeof(struct logActivator));
+
+    if (activator == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+		activator->bundleContext = context;
+		activator->logServiceFactoryReg = NULL;
+		activator->logReaderServiceReg = NULL;
+
+		activator->logger = NULL;
+		activator->factory = NULL;
+		activator->reader = NULL;
+		activator->reader_service = NULL;
+
+        *userData = activator;
+    }
+
+    return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+    struct logActivator * activator = (struct logActivator *) userData;
+    celix_status_t status = CELIX_SUCCESS;
+
+    int max_size = 0;
+    bool store_debug = false;
+
+    bundleActivator_getMaxSize(activator, &max_size);
+    bundleActivator_getStoreDebug(activator, &store_debug);
+
+    log_create(max_size, store_debug, &activator->logger);
+
+    // Add logger as Bundle- and FrameworkEvent listener
+    activator->bundleListener = calloc(1, sizeof(*activator->bundleListener));
+    activator->bundleListener->handle = activator->logger;
+    activator->bundleListener->bundleChanged = log_bundleChanged;
+    bundleContext_addBundleListener(context, activator->bundleListener);
+
+    activator->frameworkListener = calloc(1, sizeof(*activator->frameworkListener));
+    activator->frameworkListener->handle = activator->logger;
+    activator->frameworkListener->frameworkEvent = log_frameworkEvent;
+    bundleContext_addFrameworkListener(context, activator->frameworkListener);
+
+    logFactory_create(activator->logger, &activator->factory);
+
+	properties_pt props = properties_create();
+	properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+
+
+	bundleContext_registerServiceFactory(context, (char *) OSGI_LOGSERVICE_NAME, activator->factory, props, &activator->logServiceFactoryReg);
+
+    logReaderService_create(activator->logger, &activator->reader);
+
+    activator->reader_service = calloc(1, sizeof(*activator->reader_service));
+    activator->reader_service->reader = activator->reader;
+    activator->reader_service->getLog = logReaderService_getLog;
+    activator->reader_service->addLogListener = logReaderService_addLogListener;
+    activator->reader_service->removeLogListener = logReaderService_removeLogListener;
+    activator->reader_service->removeAllLogListener = logReaderService_removeAllLogListener;
+
+	props = properties_create();
+	properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+
+    bundleContext_registerService(context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, activator->reader_service, props, &activator->logReaderServiceReg);
+
+    return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	struct logActivator * activator = (struct logActivator *) userData;
+
+	serviceRegistration_unregister(activator->logReaderServiceReg);
+	activator->logReaderServiceReg = NULL;
+	serviceRegistration_unregister(activator->logServiceFactoryReg);
+	activator->logServiceFactoryReg = NULL;
+
+    logReaderService_destroy(&activator->reader);
+	free(activator->reader_service);
+
+	logFactory_destroy(&activator->factory);
+
+	bundleContext_removeBundleListener(context, activator->bundleListener);
+	bundleContext_removeFrameworkListener(context, activator->frameworkListener);
+
+	free(activator->bundleListener);
+	free(activator->frameworkListener);
+
+	log_destroy(activator->logger);
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	struct logActivator * activator = (struct logActivator *) userData;
+
+	free(activator);
+
+    return CELIX_SUCCESS;
+}
+
+static celix_status_t bundleActivator_getMaxSize(struct logActivator *activator, int *max_size) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	const char *max_size_str = NULL;
+
+	*max_size = DEFAULT_MAX_SIZE;
+
+	bundleContext_getProperty(activator->bundleContext, MAX_SIZE_PROPERTY, &max_size_str);
+	if (max_size_str) {
+		*max_size = atoi(max_size_str);
+	}
+
+	return status;
+}
+
+static celix_status_t bundleActivator_getStoreDebug(struct logActivator *activator, bool *store_debug) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	const char *store_debug_str = NULL;
+
+	*store_debug = DEFAULT_STORE_DEBUG;
+
+	bundleContext_getProperty(activator->bundleContext, STORE_DEBUG_PROPERTY, &store_debug_str);
+	if (store_debug_str) {
+		if (strcasecmp(store_debug_str, "true") == 0) {
+			*store_debug = true;
+		} else if (strcasecmp(store_debug_str, "false") == 0) {
+			*store_debug = false;
+		}
+	}
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_service_impl.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_service_impl.c b/log_service/src/log_service_impl.c
new file mode 100644
index 0000000..a77e9ad
--- /dev/null
+++ b/log_service/src/log_service_impl.c
@@ -0,0 +1,96 @@
+/**
+ *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.
+ */
+/*
+ * log_service_impl.c
+ *
+ *  \date       Jun 22, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "log_service_impl.h"
+#include "module.h"
+#include "bundle.h"
+
+struct log_service_data {
+    log_pt log;
+    bundle_pt bundle;
+};
+
+celix_status_t logService_create(log_pt log, bundle_pt bundle, log_service_data_pt *logger) {
+    celix_status_t status = CELIX_SUCCESS;
+    *logger = calloc(1, sizeof(struct log_service_data));
+    if (*logger == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        (*logger)->bundle = bundle;
+        (*logger)->log = log;
+    }
+
+    return status;
+}
+
+celix_status_t logService_destroy(log_service_data_pt *logger) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(*logger);
+    logger = NULL;
+
+    return status;
+}
+
+celix_status_t logService_log(log_service_data_pt logger, log_level_t level, char * message) {
+    return logService_logSr(logger, NULL, level, message);
+}
+
+celix_status_t logService_logSr(log_service_data_pt logger, service_reference_pt reference, log_level_t level, char * message) {
+    celix_status_t status;
+    log_entry_pt entry = NULL;
+    bundle_pt bundle = logger->bundle;
+    bundle_archive_pt archive = NULL;
+    module_pt module = NULL;
+    const char *symbolicName = NULL;
+    long bundleId = -1;
+
+    if (reference != NULL) {
+    	serviceReference_getBundle(reference, &bundle);
+    }
+
+    status = bundle_getArchive(bundle, &archive);
+
+    if (status == CELIX_SUCCESS) {
+        status = bundleArchive_getId(archive, &bundleId);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = bundle_getCurrentModule(bundle, &module);
+
+        if (status == CELIX_SUCCESS) {
+            status = module_getSymbolicName(module, &symbolicName);
+        }
+    }
+
+    if(status == CELIX_SUCCESS && symbolicName != NULL && message != NULL){
+	status = logEntry_create(bundleId, symbolicName, reference, level, message, 0, &entry);
+	log_addEntry(logger->log, entry);
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_service_impl.h
----------------------------------------------------------------------
diff --git a/log_service/src/log_service_impl.h b/log_service/src/log_service_impl.h
new file mode 100644
index 0000000..04c986e
--- /dev/null
+++ b/log_service/src/log_service_impl.h
@@ -0,0 +1,39 @@
+/**
+ *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.
+ */
+/*
+ * log_service_impl.h
+ *
+ *  \date       Jun 22, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_SERVICE_IMPL_H_
+#define LOG_SERVICE_IMPL_H_
+
+#include "log_service.h"
+#include "log.h"
+
+celix_status_t logService_create(log_pt log, bundle_pt bundle, log_service_data_pt *logger);
+celix_status_t logService_destroy(log_service_data_pt *logger);
+celix_status_t logService_log(log_service_data_pt logger, log_level_t level, char * message);
+celix_status_t logService_logSr(log_service_data_pt logger, service_reference_pt reference, log_level_t level, char * message);
+
+
+#endif /* LOG_SERVICE_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/log_writer/CMakeLists.txt b/log_writer/CMakeLists.txt
index 4692d7a..a742af2 100644
--- a/log_writer/CMakeLists.txt
+++ b/log_writer/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 celix_subproject(LOG_WRITER "Option to enable building the Log Writer bundles" ON DEPS FRAMEWORK LOG_SERVICE)
 if (LOG_WRITER)
+    add_subdirectory(log_writer)
     add_subdirectory(log_writer_stdout)
   	add_subdirectory(log_writer_syslog) 
 endif (LOG_WRITER)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/CMakeLists.txt b/log_writer/log_writer/CMakeLists.txt
new file mode 100644
index 0000000..09aa9cf
--- /dev/null
+++ b/log_writer/log_writer/CMakeLists.txt
@@ -0,0 +1,24 @@
+# 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.
+
+add_library(log_writer_common STATIC
+		src/log_writer.c
+		src/log_writer_activator.c
+)
+target_include_directories(log_writer_common PRIVATE src)
+target_include_directories(log_writer_common PUBLIC include)
+target_link_libraries(log_writer_common PUBLIC Celix::log_service_api Celix::framework)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/include/log_writer.h
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/include/log_writer.h b/log_writer/log_writer/include/log_writer.h
new file mode 100644
index 0000000..b4b70d0
--- /dev/null
+++ b/log_writer/log_writer/include/log_writer.h
@@ -0,0 +1,53 @@
+/**
+ *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.
+ */
+/*
+ * log_writer.h
+ *
+ *  \date       Jul 4, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LOG_WRITER_H_
+#define LOG_WRITER_H_
+
+#include "log_reader_service.h"
+#include "service_tracker.h"
+
+struct log_writer {
+    log_reader_service_pt logReader;
+    log_listener_pt logListener;
+
+    bundle_context_pt context;
+    service_tracker_pt tracker;
+};
+
+typedef struct log_writer *log_writer_pt;
+
+celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt *writer);
+celix_status_t logWriter_destroy(log_writer_pt *writer);
+celix_status_t logWriter_start(log_writer_pt writer);
+celix_status_t logWriter_stop(log_writer_pt writer);
+
+celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, void **service);
+celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, void * service);
+celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, void * service);
+celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, void * service);
+
+#endif /* LOG_WRITER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/private/include/log_writer.h
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/private/include/log_writer.h b/log_writer/log_writer/private/include/log_writer.h
deleted file mode 100644
index fdf65c8..0000000
--- a/log_writer/log_writer/private/include/log_writer.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- *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.
- */
-/*
- * log_writer.h
- *
- *  \date       Jul 4, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_WRITER_H_
-#define LOG_WRITER_H_
-
-#include "log_reader_service.h"
-
-#include "service_tracker.h"
-
-struct log_writer {
-    log_reader_service_pt logReader;
-    log_listener_pt logListener;
-
-    bundle_context_pt context;
-    service_tracker_pt tracker;
-};
-
-typedef struct log_writer *log_writer_pt;
-
-celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt *writer);
-celix_status_t logWriter_destroy(log_writer_pt *writer);
-celix_status_t logWriter_start(log_writer_pt writer);
-celix_status_t logWriter_stop(log_writer_pt writer);
-
-celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, void **service);
-celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, void * service);
-celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, void * service);
-celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, void * service);
-
-#endif /* LOG_WRITER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/private/src/log_writer.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/private/src/log_writer.c b/log_writer/log_writer/private/src/log_writer.c
deleted file mode 100644
index 685c1a5..0000000
--- a/log_writer/log_writer/private/src/log_writer.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- *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.
- */
-/*
- * log_writer.c
- *
- *  \date       Mar 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "celix_errno.h"
-#include "celixbool.h"
-
-#include "log_writer.h"
-#include "log_listener.h"
-#include "module.h"
-#include "bundle.h"
-
-celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt *writer) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*writer = calloc(1, sizeof(**writer));
-	(*writer)->logListener = calloc(1, sizeof(*(*writer)->logListener));
-	(*writer)->logListener->handle = *writer;
-	(*writer)->logListener->logged = logListener_logged;
-	(*writer)->logReader = NULL;
-	(*writer)->context = context;
-	(*writer)->tracker = NULL;
-
-	return status;
-}
-
-
-celix_status_t logWriter_destroy(log_writer_pt *writer) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	free((*writer)->logListener);
-	free(*writer);
-
-	writer = NULL;
-
-	return status;
-}
-celix_status_t logWriter_start(log_writer_pt writer) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_tracker_customizer_pt cust = NULL;
-	service_tracker_pt tracker = NULL;
-
-	status = serviceTrackerCustomizer_create(writer, logWriter_addingServ, logWriter_addedServ, logWriter_modifiedServ, logWriter_removedServ, &cust);
-	if (status == CELIX_SUCCESS) {
-		status = serviceTracker_create(writer->context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, cust, &tracker);
-		if (status == CELIX_SUCCESS) {
-			writer->tracker = tracker;
-			status = serviceTracker_open(tracker);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t logWriter_stop(log_writer_pt writer) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (serviceTracker_close(writer->tracker) != CELIX_SUCCESS) {
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-	if (serviceTracker_destroy(writer->tracker) != CELIX_SUCCESS) {
-		status = CELIX_BUNDLE_EXCEPTION;
-	}
-
-	return status;
-}
-
-celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, void **service) {
-	log_writer_pt writer = (log_writer_pt) handle;
-	bundleContext_getService(writer->context, ref, service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, void * service) {
-	log_writer_pt writer = (log_writer_pt) handle;
-
-	// Add this writer to each log reader service found
-	if (service != NULL) {
-		((log_reader_service_pt) service)->addLogListener(((log_reader_service_pt) service)->reader, writer->logListener);
-	}
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, void * service) {
-	return CELIX_SUCCESS;
-}
-
-celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, void * service) {
-	log_writer_pt writer = (log_writer_pt) handle;
-
-	if (service != NULL) {
-		((log_reader_service_pt) service)->removeLogListener(((log_reader_service_pt) service)->reader, writer->logListener);
-	}
-
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/private/src/log_writer_activator.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/private/src/log_writer_activator.c b/log_writer/log_writer/private/src/log_writer_activator.c
deleted file mode 100644
index 248cad6..0000000
--- a/log_writer/log_writer/private/src/log_writer_activator.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *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.
- */
-/*
- * log_writer_activator.c
- *
- *  \date       Oct 1, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include "log_writer.h"
-
-#include "bundle_activator.h"
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	log_writer_pt writer = NULL;
-
-	logWriter_create(context, &writer);
-
-	*userData = writer;
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	log_writer_pt writer = (log_writer_pt) userData;
-
-	return logWriter_start(writer);
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	log_writer_pt writer = (log_writer_pt) userData;
-
-	return logWriter_stop(writer);
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	log_writer_pt writer = (log_writer_pt) userData;
-
-	return logWriter_destroy(&writer);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/src/log_writer.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/src/log_writer.c b/log_writer/log_writer/src/log_writer.c
new file mode 100644
index 0000000..685c1a5
--- /dev/null
+++ b/log_writer/log_writer/src/log_writer.c
@@ -0,0 +1,122 @@
+/**
+ *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.
+ */
+/*
+ * log_writer.c
+ *
+ *  \date       Mar 7, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "celix_errno.h"
+#include "celixbool.h"
+
+#include "log_writer.h"
+#include "log_listener.h"
+#include "module.h"
+#include "bundle.h"
+
+celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt *writer) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*writer = calloc(1, sizeof(**writer));
+	(*writer)->logListener = calloc(1, sizeof(*(*writer)->logListener));
+	(*writer)->logListener->handle = *writer;
+	(*writer)->logListener->logged = logListener_logged;
+	(*writer)->logReader = NULL;
+	(*writer)->context = context;
+	(*writer)->tracker = NULL;
+
+	return status;
+}
+
+
+celix_status_t logWriter_destroy(log_writer_pt *writer) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	free((*writer)->logListener);
+	free(*writer);
+
+	writer = NULL;
+
+	return status;
+}
+celix_status_t logWriter_start(log_writer_pt writer) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	service_tracker_customizer_pt cust = NULL;
+	service_tracker_pt tracker = NULL;
+
+	status = serviceTrackerCustomizer_create(writer, logWriter_addingServ, logWriter_addedServ, logWriter_modifiedServ, logWriter_removedServ, &cust);
+	if (status == CELIX_SUCCESS) {
+		status = serviceTracker_create(writer->context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, cust, &tracker);
+		if (status == CELIX_SUCCESS) {
+			writer->tracker = tracker;
+			status = serviceTracker_open(tracker);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t logWriter_stop(log_writer_pt writer) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (serviceTracker_close(writer->tracker) != CELIX_SUCCESS) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	}
+	if (serviceTracker_destroy(writer->tracker) != CELIX_SUCCESS) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	}
+
+	return status;
+}
+
+celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, void **service) {
+	log_writer_pt writer = (log_writer_pt) handle;
+	bundleContext_getService(writer->context, ref, service);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, void * service) {
+	log_writer_pt writer = (log_writer_pt) handle;
+
+	// Add this writer to each log reader service found
+	if (service != NULL) {
+		((log_reader_service_pt) service)->addLogListener(((log_reader_service_pt) service)->reader, writer->logListener);
+	}
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, void * service) {
+	return CELIX_SUCCESS;
+}
+
+celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, void * service) {
+	log_writer_pt writer = (log_writer_pt) handle;
+
+	if (service != NULL) {
+		((log_reader_service_pt) service)->removeLogListener(((log_reader_service_pt) service)->reader, writer->logListener);
+	}
+
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/src/log_writer_activator.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/src/log_writer_activator.c b/log_writer/log_writer/src/log_writer_activator.c
new file mode 100644
index 0000000..248cad6
--- /dev/null
+++ b/log_writer/log_writer/src/log_writer_activator.c
@@ -0,0 +1,57 @@
+/**
+ *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.
+ */
+/*
+ * log_writer_activator.c
+ *
+ *  \date       Oct 1, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include "log_writer.h"
+
+#include "bundle_activator.h"
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	log_writer_pt writer = NULL;
+
+	logWriter_create(context, &writer);
+
+	*userData = writer;
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	log_writer_pt writer = (log_writer_pt) userData;
+
+	return logWriter_start(writer);
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	log_writer_pt writer = (log_writer_pt) userData;
+
+	return logWriter_stop(writer);
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	log_writer_pt writer = (log_writer_pt) userData;
+
+	return logWriter_destroy(&writer);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer_stdout/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/log_writer/log_writer_stdout/CMakeLists.txt b/log_writer/log_writer_stdout/CMakeLists.txt
index 7874e96..11734cc 100644
--- a/log_writer/log_writer_stdout/CMakeLists.txt
+++ b/log_writer/log_writer_stdout/CMakeLists.txt
@@ -20,17 +20,13 @@ add_bundle(log_writer
 	VERSION "1.1.0"
 	NAME "Apache Celix Log Writer"
 	SOURCES
-		${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer_activator
-		${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer
-		${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include/log_writer.h
+		#${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer_activator
+		#${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer
+		#${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include/log_writer.h
 
-		private/src/log_writer_stdout
+		src/log_writer_stdout
 )
 
 install_bundle(log_writer)
-    
-target_link_libraries(log_writer celix_framework)
-    
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include")
+
+target_link_libraries(log_writer PRIVATE Celix::log_service_api log_writer_common)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer_stdout/private/src/log_writer_stdout.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer_stdout/private/src/log_writer_stdout.c b/log_writer/log_writer_stdout/private/src/log_writer_stdout.c
deleted file mode 100644
index d57e5d5..0000000
--- a/log_writer/log_writer_stdout/private/src/log_writer_stdout.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *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.
- */
-/*
- * log_writer_stdout.c
- *
- *  \date       Mar 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "celix_errno.h"
-#include "celixbool.h"
-
-#include "log_writer.h"
-#include "log_listener.h"
-
-#include "module.h"
-#include "bundle.h"
-
-celix_status_t logListener_logged(log_listener_pt listener, log_entry_pt entry) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    if (!entry) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-		printf("LogWriter: %s from %s\n", entry->message, entry->bundleSymbolicName);
-    }
-
-    return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer_stdout/src/log_writer_stdout.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer_stdout/src/log_writer_stdout.c b/log_writer/log_writer_stdout/src/log_writer_stdout.c
new file mode 100644
index 0000000..d57e5d5
--- /dev/null
+++ b/log_writer/log_writer_stdout/src/log_writer_stdout.c
@@ -0,0 +1,49 @@
+/**
+ *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.
+ */
+/*
+ * log_writer_stdout.c
+ *
+ *  \date       Mar 7, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "celix_errno.h"
+#include "celixbool.h"
+
+#include "log_writer.h"
+#include "log_listener.h"
+
+#include "module.h"
+#include "bundle.h"
+
+celix_status_t logListener_logged(log_listener_pt listener, log_entry_pt entry) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    if (!entry) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    } else {
+		printf("LogWriter: %s from %s\n", entry->message, entry->bundleSymbolicName);
+    }
+
+    return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer_syslog/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/log_writer/log_writer_syslog/CMakeLists.txt b/log_writer/log_writer_syslog/CMakeLists.txt
index 12130cf..caad713 100644
--- a/log_writer/log_writer_syslog/CMakeLists.txt
+++ b/log_writer/log_writer_syslog/CMakeLists.txt
@@ -23,18 +23,14 @@ if (LOG_WRITER_SYSLOG)
         SYMBOLIC_NAME "apache_celix_log_writer_syslog"
         NAME "Apache Celix Log Writer Syslog"
         SOURCES
-        ${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer_activator
-        ${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer
-        ${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include/log_writer.h
 
-        private/src/log_writer_syslog
+            #${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer_activator
+            #${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer
+            #${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include/log_writer.h
+            private/src/log_writer_syslog
     )
 
     install_bundle(log_writer_syslog)
-        
-    target_link_libraries(log_writer_syslog celix_framework)
-        
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include")
+
+    target_link_libraries(log_writer_syslog PRIVATE log_writer_common)
 endif (LOG_WRITER_SYSLOG)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/pubsub/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/pubsub/CMakeLists.txt b/pubsub/CMakeLists.txt
index 2c2c50f..a866ba4 100644
--- a/pubsub/CMakeLists.txt
+++ b/pubsub/CMakeLists.txt
@@ -23,9 +23,6 @@ if (PUBSUB)
 		message(WARNING "Celix will now contain a dependency with a LGPL License (ZeroMQ). For more information about this, consult the pubsub/README.md file.")
 		option(BUILD_ZMQ_SECURITY "Build with security for ZeroMQ." OFF)
     endif (BUILD_PUBSUB_PSA_ZMQ)
-
-	include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-	include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
 	
 	add_subdirectory(pubsub_topology_manager)
 	add_subdirectory(pubsub_discovery)
@@ -45,6 +42,10 @@ if (PUBSUB)
 		add_subdirectory(test)
 	endif()
 
+	#api target
+	add_libary(pubsub_api INTERFACE)
+	target_include_directories(pubsub_api INTERFACE api)
+
 	#install api
 	install(FILES api/pubsub/publisher.h api/pubsub/subscriber.h DESTINATION include/celix/pubsub COMPONENT framework)
    
@@ -67,5 +68,7 @@ if (PUBSUB)
       DESTINATION share/celix/pubsub 
       COMPONENT framework
    )
-	
+
+	#Setup target aliases to match external usage
+	add_library(Celix::pubsub_api ALIAS pubsub_api)
 endif(PUBSUB)


[15/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/framework_private.h
----------------------------------------------------------------------
diff --git a/framework/src/framework_private.h b/framework/src/framework_private.h
new file mode 100644
index 0000000..124a4b6
--- /dev/null
+++ b/framework/src/framework_private.h
@@ -0,0 +1,145 @@
+/**
+ *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.
+ */
+/*
+ * framework_private.h
+ *
+ *  \date       May 22, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef FRAMEWORK_PRIVATE_H_
+#define FRAMEWORK_PRIVATE_H_
+
+#include "framework.h"
+
+#include "manifest.h"
+#include "wire.h"
+#include "hash_map.h"
+#include "array_list.h"
+#include "celix_errno.h"
+#include "service_factory.h"
+#include "bundle_archive.h"
+#include "service_listener.h"
+#include "bundle_listener.h"
+#include "framework_listener.h"
+#include "service_registration.h"
+#include "bundle_context.h"
+#include "bundle_cache.h"
+#include "celix_log.h"
+
+#include "celix_threads.h"
+
+struct framework {
+#ifdef WITH_APR
+    apr_pool_t *pool;
+#endif
+    struct bundle * bundle;
+    hash_map_pt installedBundleMap;
+    hash_map_pt installRequestMap;
+    array_list_pt serviceListeners;
+    array_list_pt frameworkListeners;
+
+    array_list_pt bundleListeners;
+    celix_thread_mutex_t bundleListenerLock;
+
+    long nextBundleId;
+    struct serviceRegistry * registry;
+    bundle_cache_pt cache;
+
+    celix_thread_cond_t shutdownGate;
+    celix_thread_cond_t condition;
+
+    celix_thread_mutex_t installedBundleMapLock;
+    celix_thread_mutex_t installRequestLock;
+    celix_thread_mutex_t mutex;
+    celix_thread_mutex_t bundleLock;
+
+    celix_thread_t globalLockThread;
+    array_list_pt globalLockWaitersList;
+    int globalLockCount;
+
+    bool interrupted;
+    bool shutdown;
+
+    properties_pt configurationMap;
+
+    array_list_pt requests;
+    celix_thread_cond_t dispatcher;
+    celix_thread_mutex_t dispatcherLock;
+    celix_thread_t dispatcherThread;
+    celix_thread_t shutdownThread;
+
+    framework_logger_pt logger;
+};
+
+celix_status_t framework_start(framework_pt framework);
+void framework_stop(framework_pt framework);
+
+FRAMEWORK_EXPORT celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** value);
+
+FRAMEWORK_EXPORT celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, const char * location, const char *inputFile);
+FRAMEWORK_EXPORT celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle);
+
+FRAMEWORK_EXPORT celix_status_t framework_getBundleEntry(framework_pt framework, bundle_pt bundle, const char* name, char** entry);
+
+FRAMEWORK_EXPORT celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int options);
+FRAMEWORK_EXPORT celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle, const char* inputFile);
+FRAMEWORK_EXPORT celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle, bool record);
+
+FRAMEWORK_EXPORT celix_status_t fw_registerService(framework_pt framework, service_registration_pt * registration, bundle_pt bundle, const char* serviceName, const void* svcObj, properties_pt properties);
+FRAMEWORK_EXPORT celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt * registration, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt properties);
+FRAMEWORK_EXPORT void fw_unregisterService(service_registration_pt registration);
+
+FRAMEWORK_EXPORT celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *references, bundle_pt bundle, const char* serviceName, const char* filter);
+FRAMEWORK_EXPORT celix_status_t framework_ungetServiceReference(framework_pt framework, bundle_pt bundle, service_reference_pt reference);
+FRAMEWORK_EXPORT celix_status_t fw_getService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, const void** service);
+FRAMEWORK_EXPORT celix_status_t framework_ungetService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, bool *result);
+FRAMEWORK_EXPORT celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, array_list_pt *services);
+FRAMEWORK_EXPORT celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, array_list_pt *services);
+
+FRAMEWORK_EXPORT void fw_addServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener, const char* filter);
+FRAMEWORK_EXPORT void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener);
+
+FRAMEWORK_EXPORT celix_status_t fw_addBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener);
+FRAMEWORK_EXPORT celix_status_t fw_removeBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener);
+
+FRAMEWORK_EXPORT celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener);
+FRAMEWORK_EXPORT celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener);
+
+FRAMEWORK_EXPORT void fw_serviceChanged(framework_pt framework, service_event_type_e eventType, service_registration_pt registration, properties_pt oldprops);
+
+FRAMEWORK_EXPORT celix_status_t fw_isServiceAssignable(framework_pt fw, bundle_pt requester, service_reference_pt reference, bool* assignable);
+
+//bundle_archive_t fw_createArchive(long id, char * location);
+//void revise(bundle_archive_t archive, char * location);
+FRAMEWORK_EXPORT celix_status_t getManifest(bundle_archive_pt archive, manifest_pt *manifest);
+
+FRAMEWORK_EXPORT bundle_pt findBundle(bundle_context_pt context);
+FRAMEWORK_EXPORT service_registration_pt findRegistration(service_reference_pt reference);
+
+FRAMEWORK_EXPORT service_reference_pt listToArray(array_list_pt list);
+FRAMEWORK_EXPORT celix_status_t framework_markResolvedModules(framework_pt framework, linked_list_pt wires);
+
+FRAMEWORK_EXPORT array_list_pt framework_getBundles(framework_pt framework);
+FRAMEWORK_EXPORT bundle_pt framework_getBundle(framework_pt framework, const char* location);
+FRAMEWORK_EXPORT bundle_pt framework_getBundleById(framework_pt framework, long id);
+
+#endif /* FRAMEWORK_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/ioapi.c
----------------------------------------------------------------------
diff --git a/framework/src/ioapi.c b/framework/src/ioapi.c
new file mode 100644
index 0000000..49958f6
--- /dev/null
+++ b/framework/src/ioapi.c
@@ -0,0 +1,235 @@
+/* ioapi.h -- IO base function header for compress/uncompress .zip
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications for Zip64 support
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+*/
+
+#if (defined(_WIN32))
+        #define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include "ioapi.h"
+
+voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
+{
+    if (pfilefunc->zfile_func64.zopen64_file != NULL)
+        return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
+    else
+    {
+        return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
+    }
+}
+
+long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
+{
+    if (pfilefunc->zfile_func64.zseek64_file != NULL)
+        return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
+    else
+    {
+        uLong offsetTruncated = (uLong)offset;
+        if (offsetTruncated != offset)
+            return -1;
+        else
+            return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
+    }
+}
+
+ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
+{
+    if (pfilefunc->zfile_func64.zseek64_file != NULL)
+        return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
+    else
+    {
+        uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
+        if ((tell_uLong) == ((uLong)-1))
+            return (ZPOS64_T)-1;
+        else
+            return tell_uLong;
+    }
+}
+
+void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
+{
+    p_filefunc64_32->zfile_func64.zopen64_file = NULL;
+    p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
+    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
+    p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
+    p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
+    p_filefunc64_32->zfile_func64.ztell64_file = NULL;
+    p_filefunc64_32->zfile_func64.zseek64_file = NULL;
+    p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
+    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
+    p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
+    p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
+    p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
+}
+
+
+
+static voidpf  ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
+static uLong   ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+static uLong   ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
+static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
+static long    ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
+static int     ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
+static int     ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
+
+static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
+{
+    FILE* file = NULL;
+    const char* mode_fopen = NULL;
+    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
+        mode_fopen = "rb";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
+        mode_fopen = "r+b";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+        mode_fopen = "wb";
+
+    if ((filename!=NULL) && (mode_fopen != NULL))
+        file = fopen(filename, mode_fopen);
+    return file;
+}
+
+static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
+{
+    FILE* file = NULL;
+    const char* mode_fopen = NULL;
+    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
+        mode_fopen = "rb";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
+        mode_fopen = "r+b";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+        mode_fopen = "wb";
+
+    if ((filename!=NULL) && (mode_fopen != NULL))
+        file = fopen64((const char*)filename, mode_fopen);
+    return file;
+}
+
+
+static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
+{
+    uLong ret;
+    ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
+    return ret;
+}
+
+static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
+{
+    uLong ret;
+    ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
+    return ret;
+}
+
+static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
+{
+    long ret;
+    ret = ftell((FILE *)stream);
+    return ret;
+}
+
+
+static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
+{
+    ZPOS64_T ret;
+    ret = ftello64((FILE *)stream);
+    return ret;
+}
+
+static long ZCALLBACK fseek_file_func (voidpf  opaque, voidpf stream, uLong offset, int origin)
+{
+    int fseek_origin=0;
+    long ret;
+    switch (origin)
+    {
+    case ZLIB_FILEFUNC_SEEK_CUR :
+        fseek_origin = SEEK_CUR;
+        break;
+    case ZLIB_FILEFUNC_SEEK_END :
+        fseek_origin = SEEK_END;
+        break;
+    case ZLIB_FILEFUNC_SEEK_SET :
+        fseek_origin = SEEK_SET;
+        break;
+    default: return -1;
+    }
+    ret = 0;
+    if (fseek((FILE *)stream, offset, fseek_origin) != 0)
+        ret = -1;
+    return ret;
+}
+
+static long ZCALLBACK fseek64_file_func (voidpf  opaque, voidpf stream, ZPOS64_T offset, int origin)
+{
+    int fseek_origin=0;
+    long ret;
+    switch (origin)
+    {
+    case ZLIB_FILEFUNC_SEEK_CUR :
+        fseek_origin = SEEK_CUR;
+        break;
+    case ZLIB_FILEFUNC_SEEK_END :
+        fseek_origin = SEEK_END;
+        break;
+    case ZLIB_FILEFUNC_SEEK_SET :
+        fseek_origin = SEEK_SET;
+        break;
+    default: return -1;
+    }
+    ret = 0;
+
+    if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)
+                        ret = -1;
+
+    return ret;
+}
+
+
+static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
+{
+    int ret;
+    ret = fclose((FILE *)stream);
+    return ret;
+}
+
+static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
+{
+    int ret;
+    ret = ferror((FILE *)stream);
+    return ret;
+}
+
+void fill_fopen_filefunc (pzlib_filefunc_def)
+  zlib_filefunc_def* pzlib_filefunc_def;
+{
+    pzlib_filefunc_def->zopen_file = fopen_file_func;
+    pzlib_filefunc_def->zread_file = fread_file_func;
+    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
+    pzlib_filefunc_def->ztell_file = ftell_file_func;
+    pzlib_filefunc_def->zseek_file = fseek_file_func;
+    pzlib_filefunc_def->zclose_file = fclose_file_func;
+    pzlib_filefunc_def->zerror_file = ferror_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}
+
+void fill_fopen64_filefunc (zlib_filefunc64_def*  pzlib_filefunc_def)
+{
+    pzlib_filefunc_def->zopen64_file = fopen64_file_func;
+    pzlib_filefunc_def->zread_file = fread_file_func;
+    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
+    pzlib_filefunc_def->ztell64_file = ftell64_file_func;
+    pzlib_filefunc_def->zseek64_file = fseek64_file_func;
+    pzlib_filefunc_def->zclose_file = fclose_file_func;
+    pzlib_filefunc_def->zerror_file = ferror_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/ioapi.h
----------------------------------------------------------------------
diff --git a/framework/src/ioapi.h b/framework/src/ioapi.h
new file mode 100644
index 0000000..8309c4c
--- /dev/null
+++ b/framework/src/ioapi.h
@@ -0,0 +1,200 @@
+/* ioapi.h -- IO base function header for compress/uncompress .zip
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications for Zip64 support
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+         Changes
+
+    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
+    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
+               More if/def section may be needed to support other platforms
+    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
+                          (but you should use iowin32.c for windows instead)
+
+*/
+
+#ifndef _ZLIBIOAPI64_H
+#define _ZLIBIOAPI64_H
+
+#if (!defined(_WIN32)) && (!defined(WIN32))
+
+  // Linux needs this to support file operation on files larger then 4+GB
+  // But might need better if/def to select just the platforms that needs them.
+
+        #ifndef __USE_FILE_OFFSET64
+                #define __USE_FILE_OFFSET64
+        #endif
+        #ifndef __USE_LARGEFILE64
+                #define __USE_LARGEFILE64
+        #endif
+        #ifndef _LARGEFILE64_SOURCE
+                #define _LARGEFILE64_SOURCE
+        #endif
+        #ifndef _FILE_OFFSET_BIT
+                #define _FILE_OFFSET_BIT 64
+        #endif
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "zlib.h"
+
+#if defined(USE_FILE32API)
+#define fopen64 fopen
+#define ftello64 ftell
+#define fseeko64 fseek
+#else
+#ifdef _MSC_VER
+ #define fopen64 fopen
+ #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
+  #define ftello64 _ftelli64
+  #define fseeko64 _fseeki64
+ #else // old MSC
+  #define ftello64 ftell
+  #define fseeko64 fseek
+ #endif
+#endif
+#endif
+
+/*
+#ifndef ZPOS64_T
+  #ifdef _WIN32
+                #define ZPOS64_T fpos_t
+  #else
+    #include <stdint.h>
+    #define ZPOS64_T uint64_t
+  #endif
+#endif
+*/
+
+#ifdef HAVE_MINIZIP64_CONF_H
+#include "mz64conf.h"
+#endif
+
+/* a type choosen by DEFINE */
+#ifdef HAVE_64BIT_INT_CUSTOM
+typedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;
+#else
+#ifdef HAS_STDINT_H
+#include "stdint.h"
+typedef uint64_t ZPOS64_T;
+#else
+
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+typedef unsigned __int64 ZPOS64_T;
+#else
+typedef unsigned long long int ZPOS64_T;
+#endif
+#endif
+#endif
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define ZLIB_FILEFUNC_SEEK_CUR (1)
+#define ZLIB_FILEFUNC_SEEK_END (2)
+#define ZLIB_FILEFUNC_SEEK_SET (0)
+
+#define ZLIB_FILEFUNC_MODE_READ      (1)
+#define ZLIB_FILEFUNC_MODE_WRITE     (2)
+#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
+
+#define ZLIB_FILEFUNC_MODE_EXISTING (4)
+#define ZLIB_FILEFUNC_MODE_CREATE   (8)
+
+
+#ifndef ZCALLBACK
+ #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
+   #define ZCALLBACK CALLBACK
+ #else
+   #define ZCALLBACK
+ #endif
+#endif
+
+
+
+
+typedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));
+typedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+typedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
+typedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));
+typedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
+
+typedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));
+typedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));
+
+
+/* here is the "old" 32 bits structure structure */
+typedef struct zlib_filefunc_def_s
+{
+    open_file_func      zopen_file;
+    read_file_func      zread_file;
+    write_file_func     zwrite_file;
+    tell_file_func      ztell_file;
+    seek_file_func      zseek_file;
+    close_file_func     zclose_file;
+    testerror_file_func zerror_file;
+    voidpf              opaque;
+} zlib_filefunc_def;
+
+typedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));
+typedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
+typedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));
+
+typedef struct zlib_filefunc64_def_s
+{
+    open64_file_func    zopen64_file;
+    read_file_func      zread_file;
+    write_file_func     zwrite_file;
+    tell64_file_func    ztell64_file;
+    seek64_file_func    zseek64_file;
+    close_file_func     zclose_file;
+    testerror_file_func zerror_file;
+    voidpf              opaque;
+} zlib_filefunc64_def;
+
+void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
+void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
+
+/* now internal definition, only for zip.c and unzip.h */
+typedef struct zlib_filefunc64_32_def_s
+{
+    zlib_filefunc64_def zfile_func64;
+    open_file_func      zopen32_file;
+    tell_file_func      ztell32_file;
+    seek_file_func      zseek32_file;
+} zlib_filefunc64_32_def;
+
+
+#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))
+#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))
+//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
+//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
+#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))
+#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))
+
+voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
+long    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
+ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
+
+void    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
+
+#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))
+#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))
+#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/iowin32.c
----------------------------------------------------------------------
diff --git a/framework/src/iowin32.c b/framework/src/iowin32.c
new file mode 100644
index 0000000..6a2a883
--- /dev/null
+++ b/framework/src/iowin32.c
@@ -0,0 +1,389 @@
+/* iowin32.c -- IO base function header for compress/uncompress .zip
+     Version 1.1, February 14h, 2010
+     part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications for Zip64 support
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+     For more info read MiniZip_info.txt
+
+*/
+
+#include <stdlib.h>
+
+#include "zlib.h"
+#include "ioapi.h"
+#include "iowin32.h"
+
+#ifndef INVALID_HANDLE_VALUE
+#define INVALID_HANDLE_VALUE (0xFFFFFFFF)
+#endif
+
+#ifndef INVALID_SET_FILE_POINTER
+#define INVALID_SET_FILE_POINTER ((DWORD)-1)
+#endif
+
+voidpf  ZCALLBACK win32_open_file_func  OF((voidpf opaque, const char* filename, int mode));
+uLong   ZCALLBACK win32_read_file_func  OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+uLong   ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
+ZPOS64_T ZCALLBACK win32_tell64_file_func  OF((voidpf opaque, voidpf stream));
+long    ZCALLBACK win32_seek64_file_func  OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
+int     ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
+int     ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
+
+typedef struct
+{
+    HANDLE hf;
+    int error;
+} WIN32FILE_IOWIN;
+
+
+static void win32_translate_open_mode(int mode,
+                                      DWORD* lpdwDesiredAccess,
+                                      DWORD* lpdwCreationDisposition,
+                                      DWORD* lpdwShareMode,
+                                      DWORD* lpdwFlagsAndAttributes)
+{
+    *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
+
+    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
+    {
+        *lpdwDesiredAccess = GENERIC_READ;
+        *lpdwCreationDisposition = OPEN_EXISTING;
+        *lpdwShareMode = FILE_SHARE_READ;
+    }
+    else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
+    {
+        *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
+        *lpdwCreationDisposition = OPEN_EXISTING;
+    }
+    else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+    {
+        *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
+        *lpdwCreationDisposition = CREATE_ALWAYS;
+    }
+}
+
+static voidpf win32_build_iowin(HANDLE hFile)
+{
+    voidpf ret=NULL;
+
+    if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
+    {
+        WIN32FILE_IOWIN w32fiow;
+        w32fiow.hf = hFile;
+        w32fiow.error = 0;
+        ret = malloc(sizeof(WIN32FILE_IOWIN));
+
+        if (ret==NULL)
+            CloseHandle(hFile);
+        else
+            *((WIN32FILE_IOWIN*)ret) = w32fiow;
+    }
+    return ret;
+}
+
+voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode)
+{
+    const char* mode_fopen = NULL;
+    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
+    HANDLE hFile = NULL;
+
+    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
+
+    if ((filename!=NULL) && (dwDesiredAccess != 0))
+        hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
+
+    return win32_build_iowin(hFile);
+}
+
+
+voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode)
+{
+    const char* mode_fopen = NULL;
+    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
+    HANDLE hFile = NULL;
+
+    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
+
+    if ((filename!=NULL) && (dwDesiredAccess != 0))
+        hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
+
+    return win32_build_iowin(hFile);
+}
+
+
+voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
+{
+    const char* mode_fopen = NULL;
+    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
+    HANDLE hFile = NULL;
+
+    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
+
+    if ((filename!=NULL) && (dwDesiredAccess != 0))
+        hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
+
+    return win32_build_iowin(hFile);
+}
+
+
+voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
+{
+    const char* mode_fopen = NULL;
+    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
+    HANDLE hFile = NULL;
+
+    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
+
+    if ((filename!=NULL) && (dwDesiredAccess != 0))
+        hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
+
+    return win32_build_iowin(hFile);
+}
+
+
+uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
+{
+    uLong ret=0;
+    HANDLE hFile = NULL;
+    if (stream!=NULL)
+        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
+
+    if (hFile != NULL)
+    {
+        if (!ReadFile(hFile, buf, size, &ret, NULL))
+        {
+            DWORD dwErr = GetLastError();
+            if (dwErr == ERROR_HANDLE_EOF)
+                dwErr = 0;
+            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
+        }
+    }
+
+    return ret;
+}
+
+
+uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
+{
+    uLong ret=0;
+    HANDLE hFile = NULL;
+    if (stream!=NULL)
+        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
+
+    if (hFile != NULL)
+    {
+        if (!WriteFile(hFile, buf, size, &ret, NULL))
+        {
+            DWORD dwErr = GetLastError();
+            if (dwErr == ERROR_HANDLE_EOF)
+                dwErr = 0;
+            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
+        }
+    }
+
+    return ret;
+}
+
+long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
+{
+    long ret=-1;
+    HANDLE hFile = NULL;
+    if (stream!=NULL)
+        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
+    if (hFile != NULL)
+    {
+        DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
+        if (dwSet == INVALID_SET_FILE_POINTER)
+        {
+            DWORD dwErr = GetLastError();
+            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
+            ret = -1;
+        }
+        else
+            ret=(long)dwSet;
+    }
+    return ret;
+}
+
+ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
+{
+    ZPOS64_T ret= (ZPOS64_T)-1;
+    HANDLE hFile = NULL;
+    if (stream!=NULL)
+        hFile = ((WIN32FILE_IOWIN*)stream)->hf;
+
+    if (hFile)
+    {
+        LARGE_INTEGER li;
+        li.QuadPart = 0;
+        li.u.LowPart = SetFilePointer(hFile, li.u.LowPart, &li.u.HighPart, FILE_CURRENT);
+        if ( (li.LowPart == 0xFFFFFFFF) && (GetLastError() != NO_ERROR))
+        {
+            DWORD dwErr = GetLastError();
+            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
+            ret = (ZPOS64_T)-1;
+        }
+        else
+            ret=li.QuadPart;
+    }
+    return ret;
+}
+
+
+long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
+{
+    DWORD dwMoveMethod=0xFFFFFFFF;
+    HANDLE hFile = NULL;
+
+    long ret=-1;
+    if (stream!=NULL)
+        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
+    switch (origin)
+    {
+    case ZLIB_FILEFUNC_SEEK_CUR :
+        dwMoveMethod = FILE_CURRENT;
+        break;
+    case ZLIB_FILEFUNC_SEEK_END :
+        dwMoveMethod = FILE_END;
+        break;
+    case ZLIB_FILEFUNC_SEEK_SET :
+        dwMoveMethod = FILE_BEGIN;
+        break;
+    default: return -1;
+    }
+
+    if (hFile != NULL)
+    {
+        DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod);
+        if (dwSet == INVALID_SET_FILE_POINTER)
+        {
+            DWORD dwErr = GetLastError();
+            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
+            ret = -1;
+        }
+        else
+            ret=0;
+    }
+    return ret;
+}
+
+long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
+{
+    DWORD dwMoveMethod=0xFFFFFFFF;
+    HANDLE hFile = NULL;
+    long ret=-1;
+
+    if (stream!=NULL)
+        hFile = ((WIN32FILE_IOWIN*)stream)->hf;
+
+    switch (origin)
+    {
+        case ZLIB_FILEFUNC_SEEK_CUR :
+            dwMoveMethod = FILE_CURRENT;
+            break;
+        case ZLIB_FILEFUNC_SEEK_END :
+            dwMoveMethod = FILE_END;
+            break;
+        case ZLIB_FILEFUNC_SEEK_SET :
+            dwMoveMethod = FILE_BEGIN;
+            break;
+        default: return -1;
+    }
+
+    if (hFile)
+    {
+        LARGE_INTEGER* li = (LARGE_INTEGER*)&offset;
+        DWORD dwSet = SetFilePointer(hFile, li->u.LowPart, &li->u.HighPart, dwMoveMethod);
+        if (dwSet == INVALID_SET_FILE_POINTER)
+        {
+            DWORD dwErr = GetLastError();
+            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
+            ret = -1;
+        }
+        else
+            ret=0;
+    }
+    return ret;
+}
+
+int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
+{
+    int ret=-1;
+
+    if (stream!=NULL)
+    {
+        HANDLE hFile;
+        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
+        if (hFile != NULL)
+        {
+            CloseHandle(hFile);
+            ret=0;
+        }
+        free(stream);
+    }
+    return ret;
+}
+
+int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
+{
+    int ret=-1;
+    if (stream!=NULL)
+    {
+        ret = ((WIN32FILE_IOWIN*)stream) -> error;
+    }
+    return ret;
+}
+
+void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
+{
+    pzlib_filefunc_def->zopen_file = win32_open_file_func;
+    pzlib_filefunc_def->zread_file = win32_read_file_func;
+    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
+    pzlib_filefunc_def->ztell_file = win32_tell_file_func;
+    pzlib_filefunc_def->zseek_file = win32_seek_file_func;
+    pzlib_filefunc_def->zclose_file = win32_close_file_func;
+    pzlib_filefunc_def->zerror_file = win32_error_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}
+
+void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
+{
+    pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
+    pzlib_filefunc_def->zread_file = win32_read_file_func;
+    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
+    pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
+    pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
+    pzlib_filefunc_def->zclose_file = win32_close_file_func;
+    pzlib_filefunc_def->zerror_file = win32_error_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}
+
+
+void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
+{
+    pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
+    pzlib_filefunc_def->zread_file = win32_read_file_func;
+    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
+    pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
+    pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
+    pzlib_filefunc_def->zclose_file = win32_close_file_func;
+    pzlib_filefunc_def->zerror_file = win32_error_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}
+
+
+void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
+{
+    pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
+    pzlib_filefunc_def->zread_file = win32_read_file_func;
+    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
+    pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
+    pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
+    pzlib_filefunc_def->zclose_file = win32_close_file_func;
+    pzlib_filefunc_def->zerror_file = win32_error_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/iowin32.h
----------------------------------------------------------------------
diff --git a/framework/src/iowin32.h b/framework/src/iowin32.h
new file mode 100644
index 0000000..0ca0969
--- /dev/null
+++ b/framework/src/iowin32.h
@@ -0,0 +1,28 @@
+/* iowin32.h -- IO base function header for compress/uncompress .zip
+     Version 1.1, February 14h, 2010
+     part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications for Zip64 support
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+*/
+
+#include <windows.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
+void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
+void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
+void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
+
+#ifdef __cplusplus
+}
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/listener_hook_info_impl.h
----------------------------------------------------------------------
diff --git a/framework/src/listener_hook_info_impl.h b/framework/src/listener_hook_info_impl.h
new file mode 100644
index 0000000..4b45710
--- /dev/null
+++ b/framework/src/listener_hook_info_impl.h
@@ -0,0 +1,34 @@
+/**
+ *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.
+ */
+/*
+ * listener_hook_info_impl.h
+ *
+ *  \date       Oct 28, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LISTENER_HOOK_INFO_IMPL_H_
+#define LISTENER_HOOK_INFO_IMPL_H_
+
+#include "celix_errno.h"
+
+celix_status_t listenerHookInfo_create();
+
+#endif /* LISTENER_HOOK_INFO_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/manifest.c
----------------------------------------------------------------------
diff --git a/framework/src/manifest.c b/framework/src/manifest.c
new file mode 100644
index 0000000..29b155a
--- /dev/null
+++ b/framework/src/manifest.c
@@ -0,0 +1,271 @@
+/**
+ *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.
+ */
+/*
+ * manifest.c
+ *
+ *  \date       Jul 5, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "celixbool.h"
+
+#include "manifest.h"
+#include "utils.h"
+#include "celix_log.h"
+
+int fpeek(FILE *stream);
+celix_status_t manifest_readAttributes(manifest_pt manifest, properties_pt properties, FILE *file);
+
+celix_status_t manifest_create(manifest_pt *manifest) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*manifest = malloc(sizeof(**manifest));
+	if (!*manifest) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*manifest)->mainAttributes = properties_create();
+		(*manifest)->attributes = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot create manifest");
+
+	return status;
+}
+
+celix_status_t manifest_destroy(manifest_pt manifest) {
+	if (manifest != NULL) {
+	    properties_destroy(manifest->mainAttributes);
+		hashMap_destroy(manifest->attributes, true, false);
+		manifest->mainAttributes = NULL;
+		manifest->attributes = NULL;
+		free(manifest);
+		manifest = NULL;
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t manifest_createFromFile(const char *filename, manifest_pt *manifest) {
+	celix_status_t status;
+
+	status = manifest_create(manifest);
+
+	if (status == CELIX_SUCCESS) {
+		manifest_read(*manifest, filename);
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot create manifest from file");
+
+	return status;
+}
+
+void manifest_clear(manifest_pt manifest) {
+
+}
+
+properties_pt manifest_getMainAttributes(manifest_pt manifest) {
+	return manifest->mainAttributes;
+}
+
+celix_status_t manifest_getEntries(manifest_pt manifest, hash_map_pt *map) {
+	*map = manifest->attributes;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t manifest_read(manifest_pt manifest, const char *filename) {
+    celix_status_t status = CELIX_SUCCESS;
+
+	FILE *file = fopen ( filename, "r" );
+	if (file != NULL) {
+		char lbuf[512];
+		char name[512];
+		bool skipEmptyLines = true;
+		char lastline[512];
+		memset(lbuf,0,512);
+		memset(name,0,512);
+		memset(lastline,0,512);
+
+		manifest_readAttributes(manifest, manifest->mainAttributes, file);
+		
+		while (status==CELIX_SUCCESS && fgets(lbuf, sizeof(lbuf), file) != NULL) {
+			properties_pt attributes;
+			int len = strlen(lbuf);
+
+			if (lbuf[--len] != '\n') {
+				status = CELIX_FILE_IO_EXCEPTION;
+				framework_logIfError(logger, status, NULL, "Manifest '%s' line too long", filename);
+				break;
+			}
+			if (len > 0 && lbuf[len - 1] == '\r') {
+				--len;
+			}
+			if (len == 0 && skipEmptyLines) {
+				continue;
+			}
+			skipEmptyLines = false;
+
+			if (strlen(name) == 0) {
+				
+				if ((tolower(lbuf[0]) == 'n') && (tolower(lbuf[1]) == 'a') &&
+					(tolower(lbuf[2]) == 'm') && (tolower(lbuf[3]) == 'e') &&
+					(lbuf[4] == ':') && (lbuf[5] == ' ')) {
+					name[0] = '\0';
+					strncpy(name, lbuf+6, len - 6);
+					name[len - 6] = '\0';
+				} else {
+					status = CELIX_FILE_IO_EXCEPTION;
+					framework_logIfError(logger, status, NULL, "Manifest '%s' invalid format", filename);
+					break;
+				}
+
+				if (fpeek(file) == ' ') {
+					int newlen = len - 6;
+					lastline[0] = '\0';
+					strncpy(lastline, lbuf+6, len - 6);
+					lastline[newlen] = '\0';
+					continue;
+				}
+			} else {
+				int newlen = strlen(lastline) + len;
+				char buf[512];
+				buf[0] = '\0';
+				strcpy(buf, lastline);
+				strncat(buf, lbuf+1, len - 1);
+				buf[newlen] = '\0';
+
+				if (fpeek(file) == ' ') {
+//					lastline = realloc(lastline, strlen(buf) + 1);
+					lastline[0] = '\0';
+					strcpy(lastline, buf);
+					continue;
+				}
+				name[0] = '\0';
+				strcpy(name, buf);
+				name[strlen(buf)] = '\0';
+			}
+
+			attributes = hashMap_get(manifest->attributes, name);
+			if (attributes == NULL) {
+				attributes = properties_create();
+				hashMap_put(manifest->attributes, strdup(name), attributes);
+			}
+			manifest_readAttributes(manifest, attributes, file);
+
+			name[0] = '\0';
+			skipEmptyLines = true;
+		}
+		fclose(file);
+	} else {
+		status = CELIX_FILE_IO_EXCEPTION;
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot read manifest");
+
+	return status;
+}
+
+void manifest_write(manifest_pt manifest, const char * filename) {
+
+}
+
+const char* manifest_getValue(manifest_pt manifest, const char* name) {
+	const char* val = properties_get(manifest->mainAttributes, name);
+	bool isEmpty = utils_isStringEmptyOrNull(val);
+	return isEmpty ? NULL : val;
+}
+
+int fpeek(FILE *stream) {
+	int c;
+	c = fgetc(stream);
+	ungetc(c, stream);
+	return c;
+}
+
+celix_status_t manifest_readAttributes(manifest_pt manifest, properties_pt properties, FILE *file) {
+	char name[512]; memset(name,0,512);
+	char value[512]; memset(value,0,512);
+	char lastLine[512]; memset(lastLine,0,512);
+	char lbuf[512]; memset(lbuf,0,512);
+
+
+	while (fgets(lbuf, sizeof(lbuf), file ) != NULL ) {
+		int len = strlen(lbuf);
+
+		if (lbuf[--len] != '\n') {
+			printf("MANIFEST: Line too long\n");
+			return CELIX_FILE_IO_EXCEPTION;
+		}
+		if (len > 0 && lbuf[len - 1] == '\r') {
+			--len;
+		}
+		if (len == 0) {
+			break;
+		}
+		
+		if (lbuf[0] == ' ') {
+			char buf[512];
+			buf[0] = '\0';
+
+			// Line continued
+			strcat(buf, lastLine);
+			strncat(buf, lbuf+1, len - 1);
+
+			if (fpeek(file) == ' ') {
+//				lastLine = realloc(lastLine, strlen(buf) + 1);
+				lastLine[0] = '\0';
+				strcpy(lastLine, buf);
+				continue;
+			}
+			value[0] = '\0';
+			strcpy(value, buf);
+		} else {
+	        int i = 0;
+			while (lbuf[i++] != ':') {
+				if (i >= len) {
+					printf("MANIFEST: Invalid header\n");
+					return CELIX_FILE_IO_EXCEPTION;
+				}
+			}
+			if (lbuf[i++] != ' ') {
+				printf("MANIFEST: Invalid header\n");
+				return CELIX_FILE_IO_EXCEPTION;
+			}
+			name[0] = '\0';
+			strncpy(name, lbuf, i - 2);
+			name[i - 2] = '\0';
+			if (fpeek(file) == ' ') {
+				int newlen = len - i;
+				lastLine[0] = '\0';
+				strncpy(lastLine, lbuf+i, len -i);
+				lastLine[newlen] = '\0';
+				continue;
+			}
+			value[0] = '\0';
+			strncpy(value, lbuf+i, len - i);
+			value[len - i] = '\0';
+		}
+
+		properties_set(properties, name, value);
+	}
+
+	return CELIX_SUCCESS;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/manifest_parser.c
----------------------------------------------------------------------
diff --git a/framework/src/manifest_parser.c b/framework/src/manifest_parser.c
new file mode 100644
index 0000000..07b40a8
--- /dev/null
+++ b/framework/src/manifest_parser.c
@@ -0,0 +1,490 @@
+/**
+ *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.
+ */
+/*
+ * manifest_parser.c
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "utils.h"
+#include "constants.h"
+#include "manifest_parser.h"
+#include "capability.h"
+#include "requirement.h"
+#include "attribute.h"
+#include "hash_map.h"
+#include "celix_errno.h"
+#include "linked_list_iterator.h"
+#include "celix_log.h"
+
+//FIXME the manifest parser has no destroy function and as result contains memory leaks.
+
+struct manifestParser {
+	module_pt owner;
+	manifest_pt manifest;
+
+	version_pt bundleVersion;
+	char * bundleSymbolicName;
+	linked_list_pt capabilities;
+	linked_list_pt requirements;
+};
+
+static linked_list_pt manifestParser_parseImportHeader(const char* header);
+static linked_list_pt manifestParser_parseExportHeader(module_pt module, const char* header);
+static linked_list_pt manifestParser_parseDelimitedString(const char* value, const char* delim);
+static linked_list_pt manifestParser_parseStandardHeaderClause(const char* clauseString);
+static linked_list_pt manifestParser_parseStandardHeader(const char* header);
+
+celix_status_t manifestParser_create(module_pt owner, manifest_pt manifest, manifest_parser_pt *manifest_parser) {
+	celix_status_t status;
+	manifest_parser_pt parser;
+
+	status = CELIX_SUCCESS;
+	parser = (manifest_parser_pt) malloc(sizeof(*parser));
+	if (parser) {
+		const char * bundleVersion = NULL;
+		const char * bundleSymbolicName = NULL;
+		parser->manifest = manifest;
+		parser->owner = owner;
+
+		bundleVersion = manifest_getValue(manifest, OSGI_FRAMEWORK_BUNDLE_VERSION);
+		if (bundleVersion != NULL) {
+			parser->bundleVersion = NULL;
+			version_createVersionFromString(bundleVersion, &parser->bundleVersion);
+		} else {
+			parser->bundleVersion = NULL;
+			version_createEmptyVersion(&parser->bundleVersion);
+		}
+		bundleSymbolicName = manifest_getValue(manifest, OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME);
+		if (bundleSymbolicName != NULL) {
+			parser->bundleSymbolicName = (char*)bundleSymbolicName;
+		}
+
+		parser->capabilities = manifestParser_parseExportHeader(owner, manifest_getValue(manifest, OSGI_FRAMEWORK_EXPORT_LIBRARY));
+		parser->requirements = manifestParser_parseImportHeader(manifest_getValue(manifest, OSGI_FRAMEWORK_IMPORT_LIBRARY));
+
+		*manifest_parser = parser;
+
+		status = CELIX_SUCCESS;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot create manifest parser");
+
+	return status;
+}
+
+celix_status_t manifestParser_destroy(manifest_parser_pt mp) {
+	linkedList_destroy(mp->capabilities);
+	mp->capabilities = NULL;
+	linkedList_destroy(mp->requirements);
+	mp->requirements = NULL;
+	mp->bundleSymbolicName = NULL;
+	version_destroy(mp->bundleVersion);
+	mp->bundleVersion = NULL;
+	mp->manifest = NULL;
+	mp->owner = NULL;
+
+	free(mp);
+
+	return CELIX_SUCCESS;
+}
+
+static linked_list_pt manifestParser_parseDelimitedString(const char * value, const char * delim) {
+	linked_list_pt list;
+
+	if (linkedList_create(&list) == CELIX_SUCCESS) {
+		if (value != NULL) {
+			int CHAR = 1;
+			int DELIMITER = 2;
+			int STARTQUOTE = 4;
+			int ENDQUOTE = 8;
+
+			char buffer[512];
+			int expecting = (CHAR | DELIMITER | STARTQUOTE);
+			unsigned int i;
+
+			buffer[0] = '\0';
+
+			for (i = 0; i < strlen(value); i++) {
+				char c = value[i];
+
+				bool isDelimiter = (strchr(delim, c) != NULL);
+				bool isQuote = (c == '"');
+
+				if (isDelimiter && ((expecting & DELIMITER) > 0)) {
+					linkedList_addElement(list, strdup(buffer));
+					buffer[0] = '\0';
+					expecting = (CHAR | DELIMITER | STARTQUOTE);
+				} else if (isQuote && ((expecting & STARTQUOTE) > 0)) {
+					char tmp[2];
+					tmp[0] = c;
+					tmp[1] = '\0';
+					strcat(buffer, tmp);
+					expecting = CHAR | ENDQUOTE;
+				} else if (isQuote && ((expecting & ENDQUOTE) > 0)) {
+					char tmp[2];
+					tmp[0] = c;
+					tmp[1] = '\0';
+					strcat(buffer, tmp);
+					expecting = (CHAR | STARTQUOTE | DELIMITER);
+				} else if ((expecting & CHAR) > 0) {
+					char tmp[2];
+					tmp[0] = c;
+					tmp[1] = '\0';
+					strcat(buffer, tmp);
+				} else {
+					linkedList_destroy(list);
+					return NULL;
+				}
+			}
+
+			if (strlen(buffer) > 0) {
+				linkedList_addElement(list, strdup(utils_stringTrim(buffer)));
+			}
+		}
+	}
+
+	return list;
+}
+
+static linked_list_pt manifestParser_parseStandardHeaderClause(const char * clauseString) {
+	linked_list_pt paths = NULL;
+	linked_list_pt clause = NULL;
+	linked_list_pt pieces = NULL;
+
+	if(linkedList_create(&paths) != CELIX_SUCCESS){
+		return NULL;
+	}
+
+	pieces = manifestParser_parseDelimitedString(clauseString, ";");
+
+	if (pieces != NULL) {
+		int pathCount = 0;
+		int pieceIdx;
+		hash_map_pt dirsMap = NULL;
+		hash_map_pt attrsMap = NULL;
+		char * sep;
+
+		for (pieceIdx = 0; pieceIdx < linkedList_size(pieces); pieceIdx++) {
+			char * piece = linkedList_get(pieces, pieceIdx);
+			if (strchr(piece, '=') != NULL) {
+				break;
+			} else {
+				linkedList_addElement(paths, strdup(piece));
+				pathCount++;
+			}
+		}
+
+		if (pathCount != 0) {
+
+			dirsMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+			attrsMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+
+			bool failure = false;
+			char *key = NULL;
+			char *value = NULL;
+
+			for (pieceIdx = pathCount; pieceIdx < linkedList_size(pieces) && !failure ; pieceIdx++) {
+				char * sepPtr;
+				char * DIRECTIVE_SEP = ":=";
+				char * ATTRIBUTE_SEP = "=";
+				char * piece = linkedList_get(pieces, pieceIdx);
+				if ((sepPtr = strstr(piece, DIRECTIVE_SEP)) != NULL) {
+					sep = DIRECTIVE_SEP;
+				} else if ((sepPtr = strstr(piece, ATTRIBUTE_SEP)) != NULL) {
+					sep = ATTRIBUTE_SEP;
+				} else {
+					failure=true;
+					break;
+				}
+
+				if (strcmp(sep, DIRECTIVE_SEP) == 0) {
+					// Not implemented
+				}
+				else {
+
+					key = string_ndup(piece, sepPtr - piece);
+					value = strdup(sepPtr+strlen(sep));
+
+					if (value[0] == '"' && value[strlen(value) -1] == '"') {
+						char * oldV = strdup(value);
+						int len = strlen(oldV) - 2;
+						value = (char *) realloc(value, (sizeof(char) * len+1));
+						value[0] = '\0';
+						value = strncpy(value, oldV+1, strlen(oldV) - 2);
+						value[len] = '\0';
+						//check if correct
+						free(oldV);
+					}
+
+					attribute_pt attr = NULL;
+					if (hashMap_containsKey(attrsMap, key)) {
+						failure=true;
+						break;
+					}
+
+					if (attribute_create(key, value, &attr) == CELIX_SUCCESS) {
+						hashMap_put(attrsMap, key, attr);
+					}
+				}
+			}
+
+			if(linkedList_create(&clause) != CELIX_SUCCESS){
+				failure=true;
+			}
+
+			if(failure){
+				hashMap_destroy(dirsMap,false,false);
+
+				hash_map_iterator_pt attrIter = hashMapIterator_create(attrsMap);
+				while(hashMapIterator_hasNext(attrIter)){
+					hash_map_entry_pt entry = hashMapIterator_nextEntry(attrIter);
+					char *mkey = (char*)hashMapEntry_getKey(entry);
+					attribute_pt mattr = (attribute_pt)hashMapEntry_getValue(entry);
+					free(mkey);
+					attribute_destroy(mattr);
+				}
+				hashMapIterator_destroy(attrIter);
+				hashMap_destroy(attrsMap,false,false);
+
+				if(key!=NULL){
+					free(key);
+				}
+				if(value!=NULL){
+					free(value);
+				}
+
+				linked_list_iterator_pt piter = linkedListIterator_create(paths,0);
+				while(linkedListIterator_hasNext(piter)){
+					free(linkedListIterator_next(piter));
+				}
+				linkedListIterator_destroy(piter);
+				linkedList_destroy(paths);
+
+				if(clause!=NULL){
+					linkedList_destroy(clause);
+					clause = NULL;
+				}
+			}
+			else{
+				linkedList_addElement(clause, paths);
+				linkedList_addElement(clause, dirsMap);
+				linkedList_addElement(clause, attrsMap);
+			}
+
+		}
+		else{
+			linkedList_destroy(paths);
+		}
+
+		for(int listIdx = 0; listIdx < linkedList_size(pieces); listIdx++){
+			void * element = linkedList_get(pieces, listIdx);
+			free(element);
+		}
+		linkedList_destroy(pieces);
+	}
+	else{
+		linkedList_destroy(paths);
+	}
+
+	return clause;
+}
+
+static linked_list_pt manifestParser_parseStandardHeader(const char * header) {
+	linked_list_pt clauseStrings = NULL;
+	linked_list_pt completeList = NULL;
+
+	if(header != NULL && strlen(header)==0){
+		return NULL;
+	}
+
+	if (linkedList_create(&completeList) == CELIX_SUCCESS) {
+		if(header!=NULL){
+			char *hdr = strdup(header);
+			clauseStrings = manifestParser_parseDelimitedString(hdr, ",");
+			free(hdr);
+			if (clauseStrings != NULL) {
+				int i;
+				for (i = 0; i < linkedList_size(clauseStrings); i++) {
+					char *clauseString = (char *) linkedList_get(clauseStrings, i);
+					linkedList_addElement(completeList, manifestParser_parseStandardHeaderClause(clauseString));
+					free(clauseString);
+				}
+				linkedList_destroy(clauseStrings);
+			}
+		}
+
+	}
+
+	return completeList;
+}
+
+static linked_list_pt manifestParser_parseImportHeader(const char * header) {
+	linked_list_pt clauses = NULL;
+	linked_list_pt requirements = NULL;
+	bool failure = false;
+
+	int clauseIdx;
+	linked_list_iterator_pt iter;
+	clauses = manifestParser_parseStandardHeader(header);
+	linkedList_create(&requirements);
+
+	for (clauseIdx = 0; clauseIdx < linkedList_size(clauses) && !failure ; clauseIdx++) {
+		linked_list_pt clause = linkedList_get(clauses, clauseIdx);
+
+		linked_list_pt paths = linkedList_get(clause, 0);
+		hash_map_pt directives = linkedList_get(clause, 1);
+		hash_map_pt attributes = linkedList_get(clause, 2);
+
+		int pathIdx;
+		for (pathIdx = 0; pathIdx < linkedList_size(paths) && !failure ; pathIdx++) {
+			attribute_pt name = NULL;
+			requirement_pt req = NULL;
+			char * path = (char *) linkedList_get(paths, pathIdx);
+			if (strlen(path) == 0) {
+				failure = true;
+				break;
+			}
+
+			if (attribute_create(strdup("service"), path, &name) == CELIX_SUCCESS) {
+				char *key = NULL;
+				attribute_getKey(name, &key);
+				hashMap_put(attributes, key, name);
+			}
+
+			requirement_create(directives, attributes, &req);
+			linkedList_addElement(requirements, req);
+		}
+	}
+
+	if(!failure){
+		iter = linkedListIterator_create(clauses, 0);
+		while(linkedListIterator_hasNext(iter)) {
+			linked_list_pt clause = linkedListIterator_next(iter);
+
+			linked_list_pt paths = linkedList_get(clause, 0);
+			linkedList_destroy(paths);
+
+			linkedListIterator_remove(iter);
+			linkedList_destroy(clause);
+		}
+		linkedListIterator_destroy(iter);
+	}
+
+	linkedList_destroy(clauses);
+
+	if(failure){
+		linkedList_destroy(requirements);
+		requirements = NULL;
+	}
+
+	return requirements;
+}
+
+static linked_list_pt manifestParser_parseExportHeader(module_pt module, const char * header) {
+	linked_list_pt clauses = NULL;
+	linked_list_pt capabilities = NULL;
+	int clauseIdx;
+	linked_list_iterator_pt iter;
+	bool failure = false;
+
+	clauses = manifestParser_parseStandardHeader(header);
+	linkedList_create(&capabilities);
+
+	for (clauseIdx = 0; clauseIdx < linkedList_size(clauses) && !failure ; clauseIdx++) {
+		linked_list_pt clause = linkedList_get(clauses, clauseIdx);
+
+		linked_list_pt paths = linkedList_get(clause, 0);
+		hash_map_pt directives = linkedList_get(clause, 1);
+		hash_map_pt attributes = linkedList_get(clause, 2);
+
+		int pathIdx;
+		for (pathIdx = 0; pathIdx < linkedList_size(paths) && !failure ; pathIdx++) {
+			char * path = (char *) linkedList_get(paths, pathIdx);
+			attribute_pt name = NULL;
+			capability_pt cap = NULL;
+			if (strlen(path) == 0) {
+				failure=true;
+				break;
+			}
+
+			if (attribute_create(strdup("service"), path, &name) == CELIX_SUCCESS) {
+				char *key = NULL;
+				attribute_getKey(name, &key);
+				hashMap_put(attributes, key, name);
+			}
+
+			capability_create(module, directives, attributes, &cap);
+			linkedList_addElement(capabilities, cap);
+		}
+	}
+
+	if(!failure){
+		iter = linkedListIterator_create(clauses, 0);
+		while(linkedListIterator_hasNext(iter)) {
+			linked_list_pt clause = linkedListIterator_next(iter);
+
+			linked_list_pt paths = linkedList_get(clause, 0);
+			linkedList_destroy(paths);
+
+			linkedListIterator_remove(iter);
+			linkedList_destroy(clause);
+		}
+		linkedListIterator_destroy(iter);
+	}
+
+	linkedList_destroy(clauses);
+	if(failure){
+		linkedList_destroy(capabilities);
+		capabilities = NULL;
+	}
+
+	return capabilities;
+}
+
+celix_status_t manifestParser_getAndDuplicateSymbolicName(manifest_parser_pt parser, char **symbolicName) {
+	*symbolicName = strndup(parser->bundleSymbolicName, 1024*10);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, version_pt *version) {
+	return version_clone(parser->bundleVersion, version);
+}
+
+celix_status_t manifestParser_getCapabilities(manifest_parser_pt parser, linked_list_pt *capabilities) {
+	celix_status_t status;
+
+	status = linkedList_clone(parser->capabilities, capabilities);
+
+	return status;
+}
+
+celix_status_t manifestParser_getRequirements(manifest_parser_pt parser, linked_list_pt *requirements) {
+	celix_status_t status;
+
+	status = linkedList_clone(parser->requirements, requirements);
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/manifest_parser.h
----------------------------------------------------------------------
diff --git a/framework/src/manifest_parser.h b/framework/src/manifest_parser.h
new file mode 100644
index 0000000..d6b062b
--- /dev/null
+++ b/framework/src/manifest_parser.h
@@ -0,0 +1,45 @@
+/**
+ *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.
+ */
+/*
+ * manifest_parser.h
+ *
+ *  \date       Jul 13, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef MANIFEST_PARSER_H_
+#define MANIFEST_PARSER_H_
+
+#include "module.h"
+#include "version.h"
+#include "manifest.h"
+#include "linked_list.h"
+
+typedef struct manifestParser * manifest_parser_pt;
+
+celix_status_t manifestParser_create(module_pt owner, manifest_pt manifest, manifest_parser_pt *manifest_parser);
+celix_status_t manifestParser_destroy(manifest_parser_pt mp);
+
+celix_status_t manifestParser_getAndDuplicateSymbolicName(manifest_parser_pt parser, char **symbolicName);
+celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, version_pt *version);
+celix_status_t manifestParser_getCapabilities(manifest_parser_pt parser, linked_list_pt *capabilities);
+celix_status_t manifestParser_getRequirements(manifest_parser_pt parser, linked_list_pt *requirements);
+
+#endif /* MANIFEST_PARSER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/miniunz.c
----------------------------------------------------------------------
diff --git a/framework/src/miniunz.c b/framework/src/miniunz.c
new file mode 100644
index 0000000..c3a9bd1
--- /dev/null
+++ b/framework/src/miniunz.c
@@ -0,0 +1,382 @@
+/*
+   miniunz.c
+   Version 1.1, February 14h, 2010
+   sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications of Unzip for Zip64
+         Copyright (C) 2007-2008 Even Rouault
+
+         Modifications for Zip64 support on both zip and unzip
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+*/
+
+#ifndef _WIN32
+        #ifndef __USE_FILE_OFFSET64
+                #define __USE_FILE_OFFSET64
+        #endif
+        #ifndef __USE_LARGEFILE64
+                #define __USE_LARGEFILE64
+        #endif
+        #ifndef _LARGEFILE64_SOURCE
+                #define _LARGEFILE64_SOURCE
+        #endif
+        #ifndef _FILE_OFFSET_BIT
+                #define _FILE_OFFSET_BIT 64
+        #endif
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#ifdef _WIN32
+#include <sys/utime.h>
+#else
+#include <utime.h>
+#endif
+#include <sys/stat.h>
+
+#include "unzip.h"
+#include "archive.h"
+
+#define CASESENSITIVITY (0)
+#define WRITEBUFFERSIZE (8192)
+#define MAXFILENAME (256)
+
+#ifdef _WIN32
+#define USEWIN32IOAPI
+#include "iowin32.h"
+#include <direct.h>
+#endif
+/*
+  mini unzip, demo of unzip package
+
+  usage :
+  Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir]
+
+  list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT
+    if it exists
+*/
+
+
+/* change_file_date : change the date/time of a file
+    filename : the filename of the file where date/time must be modified
+    dosdate : the new date at the MSDos format (4 bytes)
+    tmu_date : the SAME new date at the tm_unz format */
+void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date)
+{
+#ifdef _WIN32
+  HANDLE hFile;
+  FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
+
+  hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
+                      0,NULL,OPEN_EXISTING,0,NULL);
+  GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
+  DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
+  LocalFileTimeToFileTime(&ftLocal,&ftm);
+  SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
+  CloseHandle(hFile);
+#else
+#if defined(unix) || defined(__APPLE__)
+  struct utimbuf ut;
+  struct tm newdate;
+  newdate.tm_sec = tmu_date.tm_sec;
+  newdate.tm_min=tmu_date.tm_min;
+  newdate.tm_hour=tmu_date.tm_hour;
+  newdate.tm_mday=tmu_date.tm_mday;
+  newdate.tm_mon=tmu_date.tm_mon;
+  if (tmu_date.tm_year > 1900)
+      newdate.tm_year=tmu_date.tm_year - 1900;
+  else
+      newdate.tm_year=tmu_date.tm_year ;
+  newdate.tm_isdst=-1;
+
+  ut.actime=ut.modtime=mktime(&newdate);
+  utime(filename,&ut);
+#endif
+#endif
+}
+
+
+/* mymkdir and change_file_date are not 100 % portable
+   As I don't know well Unix, I wait feedback for the unix portion */
+
+int mymkdir(const char *dirname)
+{
+    int ret=0;
+#ifdef _WIN32
+    ret = _mkdir(dirname);
+#else
+#if defined unix || defined __APPLE__
+    ret = mkdir(dirname,0775);
+#endif
+#endif
+    return ret;
+}
+
+int makedir (char *newdir)
+{
+  char *buffer ;
+  char *p;
+  int  len = (int)strlen(newdir);
+
+  if (len <= 0)
+    return 0;
+
+  buffer = (char*)malloc(len+1);
+        if (buffer==NULL)
+        {
+                printf("Error allocating memory\n");
+                return UNZ_INTERNALERROR;
+        }
+  strcpy(buffer,newdir);
+
+  if (buffer[len-1] == '/') {
+    buffer[len-1] = '\0';
+  }
+  if (mymkdir(buffer) == 0)
+    {
+      free(buffer);
+      return 1;
+    }
+
+  p = buffer+1;
+  while (1)
+    {
+      char hold;
+
+      while(*p && *p != '\\' && *p != '/')
+        p++;
+      hold = *p;
+      *p = 0;
+      if ((mymkdir(buffer) == -1) && (errno == ENOENT))
+        {
+          printf("couldn't create directory %s\n",buffer);
+          free(buffer);
+          return 0;
+        }
+      if (hold == 0)
+        break;
+      *p++ = hold;
+    }
+  free(buffer);
+  return 1;
+}
+
+int do_extract_currentfile(unzFile uf, char * revisionRoot) {
+    char filename_inzip[256];
+    char* filename_withoutpath;
+    char* p;
+    int err=UNZ_OK;
+    FILE *fout=NULL;
+    void* buf;
+    uInt size_buf;
+
+    unz_file_info64 file_info;
+    err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
+
+    if (err!=UNZ_OK)
+    {
+        printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
+        return err;
+    }
+
+    size_buf = WRITEBUFFERSIZE;
+    buf = (void*)malloc(size_buf);
+    if (buf==NULL)
+    {
+        printf("Error allocating memory\n");
+        return UNZ_INTERNALERROR;
+    }
+
+    p = filename_withoutpath = filename_inzip;
+    while ((*p) != '\0')
+    {
+        if (((*p)=='/') || ((*p)=='\\'))
+            filename_withoutpath = p+1;
+        p++;
+    }
+
+    if ((*filename_withoutpath)=='\0') {
+		char * dir;
+		dir = (char *)malloc(strlen(revisionRoot) + strlen(filename_inzip) + 2);
+		strcpy(dir, revisionRoot);
+		strcat(dir, "/");
+		strcat(dir, filename_inzip);
+		mymkdir(dir);
+		free(dir);
+    }
+    else
+    {
+        const char* write_filename;
+        int skip=0;
+		int length;
+		char * fWFN;
+        write_filename = filename_inzip;
+
+        length = strlen(write_filename) + strlen(revisionRoot) + 2;
+        fWFN = (char *)malloc(length);
+        strcpy(fWFN, revisionRoot);
+        strcat(fWFN, "/");
+        strcat(fWFN, write_filename);
+
+        err = unzOpenCurrentFile(uf);
+        if (err!=UNZ_OK)
+        {
+            printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err);
+        }
+
+        if ((skip==0) && (err==UNZ_OK))
+        {
+            fout=fopen64(fWFN,"wb");
+
+            /* some zipfile don't contain directory alone before file */
+            if ((fout==NULL) && (filename_withoutpath!=(char*)filename_inzip))
+            {
+				char * dir;
+				int length;
+                char c=*(filename_withoutpath-1);
+                *(filename_withoutpath-1)='\0';
+                length = strlen(write_filename) + strlen(revisionRoot) + 2;
+                dir = (char *)malloc(length);
+				strcpy(dir, revisionRoot);
+				strcat(dir, "/");
+				strcat(dir, write_filename);
+                makedir(dir);
+                *(filename_withoutpath-1)=c;
+				free(dir);
+                fout=fopen64(fWFN,"wb");
+            }
+
+            if (fout==NULL)
+            {
+                printf("error opening %s\n",write_filename);
+            }
+        }
+
+        if (fout!=NULL)
+        {
+            do
+            {
+                err = unzReadCurrentFile(uf,buf,size_buf);
+                if (err<0)
+                {
+                    printf("error %d with zipfile in unzReadCurrentFile\n",err);
+                    break;
+                }
+                if (err>0)
+                    if (fwrite(buf,err,1,fout)!=1)
+                    {
+                        printf("error in writing extracted file\n");
+                        err=UNZ_ERRNO;
+                        break;
+                    }
+            }
+            while (err>0);
+            if (fout)
+                    fclose(fout);
+
+            if (err==0)
+                change_file_date(fWFN,file_info.dosDate,
+                                 file_info.tmu_date);
+        }
+
+        if (err==UNZ_OK)
+        {
+            err = unzCloseCurrentFile (uf);
+            if (err!=UNZ_OK)
+            {
+                printf("error %d with zipfile in unzCloseCurrentFile\n",err);
+            }
+        }
+        else
+            unzCloseCurrentFile(uf); /* don't lose the error */
+
+		free(fWFN);
+    }
+
+    free(buf);
+    return err;
+}
+
+
+int do_extract(unzFile uf, char * revisionRoot) {
+    uLong i;
+    unz_global_info64 gi;
+    int err;
+
+    err = unzGetGlobalInfo64(uf,&gi);
+    if (err!=UNZ_OK)
+        printf("error %d with zipfile in unzGetGlobalInfo \n",err);
+
+    for (i=0;i<gi.number_entry;i++)
+    {
+        if (do_extract_currentfile(uf, revisionRoot) != UNZ_OK)
+            break;
+
+        if ((i+1)<gi.number_entry)
+        {
+            err = unzGoToNextFile(uf);
+            if (err!=UNZ_OK)
+            {
+                printf("error %d with zipfile in unzGoToNextFile\n",err);
+                break;
+            }
+        }
+    }
+
+    return 0;
+}
+
+celix_status_t extractBundle(const char* bundleName, const char* revisionRoot) {
+    celix_status_t status = CELIX_SUCCESS;
+    char filename_try[MAXFILENAME+16] = "";
+    unzFile uf=NULL;
+
+    if (bundleName!=NULL)
+    {
+
+#        ifdef USEWIN32IOAPI
+        zlib_filefunc64_def ffunc;
+#        endif
+
+        strncpy(filename_try, bundleName,MAXFILENAME-1);
+        /* strncpy doesnt append the trailing NULL, of the string is too long. */
+        filename_try[ MAXFILENAME ] = '\0';
+
+#        ifdef USEWIN32IOAPI
+        fill_win32_filefunc64A(&ffunc);
+        uf = unzOpen2_64(bundleName,&ffunc);
+#        else
+        uf = unzOpen64(bundleName);
+#        endif
+        if (uf==NULL)
+        {
+            strcat(filename_try,".zip");
+#            ifdef USEWIN32IOAPI
+            uf = unzOpen2_64(filename_try,&ffunc);
+#            else
+            uf = unzOpen64(filename_try);
+#            endif
+        }
+    }
+
+    if (uf==NULL)
+    {
+        printf("Cannot open %s or %s.zip\n",bundleName,bundleName);
+        status = CELIX_FILE_IO_EXCEPTION;
+    } else {
+        if (do_extract(uf, (char*)revisionRoot) != 0) {
+            status = CELIX_FILE_IO_EXCEPTION;
+        }
+
+        unzClose(uf);
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/module.c
----------------------------------------------------------------------
diff --git a/framework/src/module.c b/framework/src/module.c
new file mode 100644
index 0000000..e81a1ee
--- /dev/null
+++ b/framework/src/module.c
@@ -0,0 +1,281 @@
+/**
+ *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.
+ */
+/*
+ * module.c
+ *
+ *  \date       Jul 19, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "module.h"
+#include "manifest_parser.h"
+#include "linked_list_iterator.h"
+
+struct module {
+	linked_list_pt capabilities;
+	linked_list_pt requirements;
+	linked_list_pt wires;
+
+	array_list_pt dependentImporters;
+
+	version_pt version;
+	char * symbolicName;
+	bool resolved;
+
+	manifest_pt headerMap;
+	char * id;
+
+	struct bundle * bundle;
+};
+
+module_pt module_create(manifest_pt headerMap, const char * moduleId, bundle_pt bundle) {
+    module_pt module = NULL;
+    manifest_parser_pt mp;
+
+    if (headerMap != NULL) {
+        module = (module_pt) malloc(sizeof(*module));
+        module->headerMap = headerMap;
+        module->id = strdup(moduleId);
+        module->bundle = bundle;
+        module->resolved = false;
+
+        module->dependentImporters = NULL;
+        arrayList_create(&module->dependentImporters);
+
+        if (manifestParser_create(module, headerMap, &mp) == CELIX_SUCCESS) {
+            module->symbolicName = NULL;
+            manifestParser_getAndDuplicateSymbolicName(mp, &module->symbolicName);
+
+            module->version = NULL;
+            manifestParser_getBundleVersion(mp, &module->version);
+
+            module->capabilities = NULL;
+            manifestParser_getCapabilities(mp, &module->capabilities);
+
+            module->requirements = NULL;
+            manifestParser_getRequirements(mp, &module->requirements);
+
+            module->wires = NULL;
+
+            manifestParser_destroy(mp);
+        }
+    }
+
+    return module;
+}
+
+module_pt module_createFrameworkModule(bundle_pt bundle) {
+    module_pt module;
+
+	module = (module_pt) malloc(sizeof(*module));
+	if (module) {
+        module->id = strdup("0");
+        module->symbolicName = strdup("framework");
+        module->version = NULL;
+        version_createVersion(1, 0, 0, "", &module->version);
+
+        linkedList_create(&module->capabilities);
+        linkedList_create(&module->requirements);
+        module->dependentImporters = NULL;
+        arrayList_create(&module->dependentImporters);
+        module->wires = NULL;
+        module->headerMap = NULL;
+        module->resolved = false;
+        module->bundle = bundle;
+	}
+	return module;
+}
+
+void module_destroy(module_pt module) {
+	arrayList_destroy(module->dependentImporters);
+
+	version_destroy(module->version);
+
+	if (module->wires != NULL) {
+        linked_list_iterator_pt iter = linkedListIterator_create(module->wires, 0);
+        while (linkedListIterator_hasNext(iter)) {
+            wire_pt next = linkedListIterator_next(iter);
+            linkedListIterator_remove(iter);
+            wire_destroy(next);
+        }
+        linkedListIterator_destroy(iter);
+        linkedList_destroy(module->wires);
+	}
+
+	if (module->requirements != NULL) {
+	    linked_list_iterator_pt iter = linkedListIterator_create(module->requirements, 0);
+        while (linkedListIterator_hasNext(iter)) {
+            requirement_pt next = linkedListIterator_next(iter);
+            linkedListIterator_remove(iter);
+            requirement_destroy(next);
+        }
+        linkedListIterator_destroy(iter);
+        linkedList_destroy(module->requirements);
+	}
+
+	if (module->capabilities != NULL) {
+	    linked_list_iterator_pt iter = linkedListIterator_create(module->capabilities, 0);
+        while (linkedListIterator_hasNext(iter)) {
+            capability_pt next = linkedListIterator_next(iter);
+            linkedListIterator_remove(iter);
+            capability_destroy(next);
+        }
+        linkedListIterator_destroy(iter);
+        linkedList_destroy(module->capabilities);
+    }
+
+	module->headerMap = NULL;
+
+	free(module->id);
+	free(module->symbolicName);
+	free(module);
+}
+
+wire_pt module_getWire(module_pt module, const char * serviceName) {
+	wire_pt wire = NULL;
+	if (module->wires != NULL) {
+		linked_list_iterator_pt iterator = linkedListIterator_create(module->wires, 0);
+		while (linkedListIterator_hasNext(iterator)) {
+			const char* name;
+			wire_pt next = linkedListIterator_next(iterator);
+			capability_pt cap = NULL;
+			wire_getCapability(next, &cap);
+			capability_getServiceName(cap, &name);
+			if (strcasecmp(name, serviceName) == 0) {
+				wire = next;
+			}
+		}
+		linkedListIterator_destroy(iterator);
+	}
+	return wire;
+}
+
+version_pt module_getVersion(module_pt module) {
+	return module->version;
+}
+
+celix_status_t module_getSymbolicName(module_pt module, const char **symbolicName) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (module == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*symbolicName = module->symbolicName;
+	}
+
+	return status;
+}
+
+char * module_getId(module_pt module) {
+	return module->id;
+}
+
+linked_list_pt module_getWires(module_pt module) {
+	return module->wires;
+}
+
+void module_setWires(module_pt module, linked_list_pt wires) {
+    int i = 0;
+    for (i = 0; (module->wires != NULL) && (i < linkedList_size(module->wires)); i++) {
+        wire_pt wire = (wire_pt) linkedList_get(module->wires, i);
+        module_pt exporter = NULL;
+        wire_getExporter(wire, &exporter);
+        module_removeDependentImporter(exporter, module);
+    }
+
+    if (module->wires != NULL) {
+		linked_list_iterator_pt iter = linkedListIterator_create(module->wires, 0);
+		while (linkedListIterator_hasNext(iter)) {
+			wire_pt next = linkedListIterator_next(iter);
+			linkedListIterator_remove(iter);
+			wire_destroy(next);
+		}
+		linkedListIterator_destroy(iter);
+		linkedList_destroy(module->wires);
+	}
+
+	module->wires = wires;
+
+	for (i = 0; (module->wires != NULL) && (i < linkedList_size(module->wires)); i++) {
+        wire_pt wire = (wire_pt) linkedList_get(module->wires, i);
+        module_pt exporter = NULL;
+        wire_getExporter(wire, &exporter);
+        module_addDependentImporter(exporter, module);
+    }
+}
+
+bool module_isResolved(module_pt module) {
+	return module->resolved;
+}
+
+void module_setResolved(module_pt module) {
+	module->resolved = true;
+}
+
+bundle_pt module_getBundle(module_pt module) {
+	return module->bundle;
+}
+
+linked_list_pt module_getRequirements(module_pt module) {
+	return module->requirements;
+}
+
+linked_list_pt module_getCapabilities(module_pt module) {
+	return module->capabilities;
+}
+
+array_list_pt module_getDependentImporters(module_pt module) {
+    return module->dependentImporters;
+}
+
+void module_addDependentImporter(module_pt module, module_pt importer) {
+    if (!arrayList_contains(module->dependentImporters, importer)) {
+        arrayList_add(module->dependentImporters, importer);
+    }
+}
+
+void module_removeDependentImporter(module_pt module, module_pt importer) {
+    arrayList_removeElement(module->dependentImporters, importer);
+}
+
+//----------------------------------------------------
+//TODO add implementation (functions not implemented but already exported)
+array_list_pt module_getDependentRequirers(module_pt module) {
+	return NULL;
+}
+
+void module_addDependentRequirer(module_pt module, module_pt requirer) {
+}
+
+void module_removeDependentRequirer(module_pt module, module_pt requirer) {
+}
+//----------------------------------------------------
+
+array_list_pt module_getDependents(module_pt module) {
+    array_list_pt dependents = NULL;
+    arrayList_create(&dependents);
+
+    arrayList_addAll(dependents, module->dependentImporters);
+
+    return dependents;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/registry_callback_private.h
----------------------------------------------------------------------
diff --git a/framework/src/registry_callback_private.h b/framework/src/registry_callback_private.h
new file mode 100644
index 0000000..146a1d1
--- /dev/null
+++ b/framework/src/registry_callback_private.h
@@ -0,0 +1,42 @@
+/**
+ *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.
+ */
+/*
+ * service_reference_private.h
+ *
+ *  \date       Nov 16, 2015
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef REGISTRY_CALLBACK_H_
+#define REGISTRY_CALLBACK_H_
+
+#include "celix_errno.h"
+#include "service_reference.h"
+#include "service_registration.h"
+
+typedef struct registry_callback_struct {
+	void *handle;
+    celix_status_t (*getUsingBundles)(void *handle, service_registration_pt reg, array_list_pt *bundles);
+	celix_status_t (*unregister)(void *handle, bundle_pt bundle, service_registration_pt reg);
+	celix_status_t (*modified)(void *handle, service_registration_pt registration, properties_pt oldProperties);
+} registry_callback_t;
+
+#endif /* REGISTRY_CALLBACK_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/requirement.c
----------------------------------------------------------------------
diff --git a/framework/src/requirement.c b/framework/src/requirement.c
new file mode 100644
index 0000000..7ce585c
--- /dev/null
+++ b/framework/src/requirement.c
@@ -0,0 +1,114 @@
+/**
+ *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.
+ */
+/*
+ * requirement.c
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "requirement_private.h"
+#include "version_range.h"
+#include "attribute.h"
+#include "celix_log.h"
+
+celix_status_t requirement_create(hash_map_pt directives, hash_map_pt attributes, requirement_pt *requirement) {
+	celix_status_t status;
+
+	*requirement = (requirement_pt) malloc(sizeof(**requirement));
+	if (!*requirement) {
+		status = CELIX_ENOMEM;
+	} else {
+		attribute_pt serviceAttribute = NULL;
+		attribute_pt versionAttribute = NULL;
+
+		(*requirement)->attributes = attributes;
+		(*requirement)->directives = directives;
+		(*requirement)->versionRange = NULL;
+
+		serviceAttribute = (attribute_pt) hashMap_get(attributes, "service");
+		status = attribute_getValue(serviceAttribute, &(*requirement)->targetName);
+		if (status == CELIX_SUCCESS) {
+			versionAttribute = (attribute_pt) hashMap_get(attributes, "version");
+			if (versionAttribute != NULL) {
+				char *versionStr = NULL;
+				attribute_getValue(versionAttribute, &versionStr);
+				status = versionRange_parse(versionStr, &(*requirement)->versionRange);
+			} else {
+				status = versionRange_createInfiniteVersionRange(&(*requirement)->versionRange);
+			}
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot create requirement");
+
+	return status;
+}
+
+celix_status_t requirement_destroy(requirement_pt requirement) {
+	hash_map_iterator_pt attrIter = hashMapIterator_create(requirement->attributes);
+	while (hashMapIterator_hasNext(attrIter)) {
+		attribute_pt attr = hashMapIterator_nextValue(attrIter);
+		hashMapIterator_remove(attrIter);
+		attribute_destroy(attr);
+	}
+	hashMapIterator_destroy(attrIter);
+	hashMap_destroy(requirement->attributes, false, false);
+	hashMap_destroy(requirement->directives, false, false);
+
+	requirement->attributes = NULL;
+	requirement->directives = NULL;
+
+	versionRange_destroy(requirement->versionRange);
+	requirement->versionRange = NULL;
+
+	free(requirement);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t requirement_getVersionRange(requirement_pt requirement, version_range_pt *range) {
+	*range = requirement->versionRange;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t requirement_getTargetName(requirement_pt requirement, const char **targetName) {
+	*targetName = requirement->targetName;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t requirement_isSatisfied(requirement_pt requirement, capability_pt capability, bool *inRange) {
+	celix_status_t status;
+	version_pt version = NULL;
+	version_range_pt range = NULL;
+
+	status = capability_getVersion(capability, &version);
+	if (status == CELIX_SUCCESS) {
+		status = requirement_getVersionRange(requirement, &range);
+		if (status == CELIX_SUCCESS) {
+			status = versionRange_isInRange(range, version, inRange);
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Cannot check if requirement is satisfied");
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/requirement_private.h
----------------------------------------------------------------------
diff --git a/framework/src/requirement_private.h b/framework/src/requirement_private.h
new file mode 100644
index 0000000..7510110
--- /dev/null
+++ b/framework/src/requirement_private.h
@@ -0,0 +1,40 @@
+/**
+ *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.
+ */
+/*
+ * requirement_private.h
+ *
+ *  \date       Feb 11, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef REQUIREMENT_PRIVATE_H_
+#define REQUIREMENT_PRIVATE_H_
+
+#include "requirement.h"
+
+struct requirement {
+	char * targetName;
+	version_range_pt versionRange;
+	hash_map_pt attributes;
+	hash_map_pt directives;
+};
+
+#endif /* REQUIREMENT_PRIVATE_H_ */


[18/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/attribute.c
----------------------------------------------------------------------
diff --git a/framework/src/attribute.c b/framework/src/attribute.c
new file mode 100644
index 0000000..318d8f5
--- /dev/null
+++ b/framework/src/attribute.c
@@ -0,0 +1,71 @@
+/**
+ *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.
+ */
+/*
+ * attribute.c
+ *
+ *  \date       Jul 27, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "attribute_private.h"
+#include "celix_log.h"
+
+celix_status_t attribute_create(char * key, char * value, attribute_pt *attribute) {
+	celix_status_t status = CELIX_SUCCESS;
+	char *error = NULL;
+
+	if (key == NULL || value == NULL || *attribute != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	    error = "Missing required arguments and/or values";
+	} else {
+		attribute_pt attr = malloc(sizeof(*attr));
+		if (!attr) {
+			status = CELIX_ENOMEM;
+		} else {
+			attr->key = key;
+			attr->value = value;
+
+			*attribute = attr;
+		}
+	}
+
+	framework_logIfError(logger, status, error, "Could not create attribute: [key=%s;value=%s]", key, value);
+
+	return status;
+}
+
+celix_status_t attribute_destroy(attribute_pt attribute) {
+    free(attribute->key);
+    free(attribute->value);
+    free(attribute);
+    return CELIX_SUCCESS;
+}
+
+celix_status_t attribute_getKey(attribute_pt attribute, char **key) {
+	*key = attribute->key;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t attribute_getValue(attribute_pt attribute, char **value) {
+	*value = attribute->value;
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/attribute.h
----------------------------------------------------------------------
diff --git a/framework/src/attribute.h b/framework/src/attribute.h
new file mode 100644
index 0000000..6f41f0c
--- /dev/null
+++ b/framework/src/attribute.h
@@ -0,0 +1,39 @@
+/**
+ *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.
+ */
+/*
+ * attribute.h
+ *
+ *  \date       Jul 27, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef ATTRIBUTE_H_
+#define ATTRIBUTE_H_
+
+#include "celix_errno.h"
+
+typedef struct attribute *attribute_pt;
+
+celix_status_t attribute_create(char * key, char * value, attribute_pt *attribute);
+celix_status_t attribute_destroy(attribute_pt attribute);
+
+celix_status_t attribute_getKey(attribute_pt attribute, char **key);
+celix_status_t attribute_getValue(attribute_pt attribute, char **value);
+
+#endif /* ATTRIBUTE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/attribute_private.h
----------------------------------------------------------------------
diff --git a/framework/src/attribute_private.h b/framework/src/attribute_private.h
new file mode 100644
index 0000000..339833f
--- /dev/null
+++ b/framework/src/attribute_private.h
@@ -0,0 +1,39 @@
+/**
+ *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.
+ */
+/*
+ * attribute_private.h
+ *
+ *  \date       Feb 11, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef ATTRIBUTE_PRIVATE_H_
+#define ATTRIBUTE_PRIVATE_H_
+
+#include "attribute.h"
+
+struct attribute {
+	char * key;
+	char * value;
+};
+
+
+#endif /* ATTRIBUTE_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle.c
----------------------------------------------------------------------
diff --git a/framework/src/bundle.c b/framework/src/bundle.c
new file mode 100644
index 0000000..a0e6b3d
--- /dev/null
+++ b/framework/src/bundle.c
@@ -0,0 +1,695 @@
+/**
+ *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.
+ */
+/*
+ * bundle.c
+ *
+ *  \date       Mar 23, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "framework_private.h"
+#include "bundle_private.h"
+#include "resolver.h"
+#include "utils.h"
+
+celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module);
+celix_status_t bundle_closeRevisions(bundle_pt bundle);
+
+celix_status_t bundle_create(bundle_pt * bundle) {
+    celix_status_t status;
+    bundle_archive_pt archive = NULL;
+
+	*bundle = (bundle_pt) malloc(sizeof(**bundle));
+	if (*bundle == NULL) {
+		return CELIX_ENOMEM;
+	}
+	status = bundleArchive_createSystemBundleArchive(&archive);
+	if (status == CELIX_SUCCESS) {
+        module_pt module;
+
+        (*bundle)->archive = archive;
+        (*bundle)->activator = NULL;
+        (*bundle)->context = NULL;
+        (*bundle)->framework = NULL;
+        (*bundle)->state = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
+        (*bundle)->modules = NULL;
+        arrayList_create(&(*bundle)->modules);
+        (*bundle)->handle = NULL;
+        (*bundle)->manifest = NULL;
+
+        module = module_createFrameworkModule((*bundle));
+        bundle_addModule(*bundle, module);
+
+        status = celixThreadMutex_create(&(*bundle)->lock, NULL);
+        if (status != CELIX_SUCCESS) {
+        	status = CELIX_ILLEGAL_STATE;
+        } else {
+			(*bundle)->lockCount = 0;
+			(*bundle)->lockThread = celix_thread_default;
+        }
+	}
+	framework_logIfError(logger, status, NULL, "Failed to create bundle");
+
+	return status;
+}
+
+celix_status_t bundle_createFromArchive(bundle_pt * bundle, framework_pt framework, bundle_archive_pt archive) {
+    module_pt module;
+	
+	celix_status_t status;
+
+	*bundle = (bundle_pt) malloc(sizeof(**bundle));
+	if (*bundle == NULL) {
+		return CELIX_ENOMEM;
+	}
+	(*bundle)->archive = archive;
+	(*bundle)->activator = NULL;
+	(*bundle)->context = NULL;
+	(*bundle)->handle = NULL;
+	(*bundle)->manifest = NULL;
+	(*bundle)->framework = framework;
+	(*bundle)->state = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
+	(*bundle)->modules = NULL;
+	arrayList_create(&(*bundle)->modules);
+	
+	status = bundle_createModule(*bundle, &module);
+	if (status == CELIX_SUCCESS) {
+		bundle_addModule(*bundle, module);
+        status = celixThreadMutex_create(&(*bundle)->lock, NULL);
+        if (status != CELIX_SUCCESS) {
+			status = CELIX_ILLEGAL_STATE;
+		} else {
+			(*bundle)->lockCount = 0;
+			(*bundle)->lockThread = celix_thread_default;
+		}
+	} else {
+	    status = CELIX_FILE_IO_EXCEPTION;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to create bundle");
+
+	return status;
+}
+
+celix_status_t bundle_destroy(bundle_pt bundle) {
+	array_list_iterator_pt iter = arrayListIterator_create(bundle->modules);
+	while (arrayListIterator_hasNext(iter)) {
+		module_pt module = arrayListIterator_next(iter);
+		module_destroy(module);
+	}
+	arrayListIterator_destroy(iter);
+	arrayList_destroy(bundle->modules);
+	celixThreadMutex_destroy(&bundle->lock);
+
+	free(bundle);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundle_getArchive(bundle_pt bundle, bundle_archive_pt *archive) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (bundle != NULL && *archive == NULL) {
+		*archive = bundle->archive;
+	} else {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get bundle archive");
+
+	return status;
+}
+
+celix_status_t bundle_getCurrentModule(bundle_pt bundle, module_pt *module) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (bundle == NULL || arrayList_size(bundle->modules)==0 ) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*module = arrayList_get(bundle->modules, arrayList_size(bundle->modules) - 1);
+	}
+
+	return status;
+}
+
+array_list_pt bundle_getModules(bundle_pt bundle) {
+    return bundle->modules;
+}
+
+void * bundle_getHandle(bundle_pt bundle) {
+	return bundle->handle;
+}
+
+void bundle_setHandle(bundle_pt bundle, void * handle) {
+	bundle->handle = handle;
+}
+
+activator_pt bundle_getActivator(bundle_pt bundle) {
+	return bundle->activator;
+}
+
+celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator) {
+	bundle->activator = activator;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context) {
+	*context = bundle->context;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundle_setContext(bundle_pt bundle, bundle_context_pt context) {
+	bundle->context = context;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundle_getEntry(bundle_pt bundle, const char* name, char** entry) {
+	return framework_getBundleEntry(bundle->framework, bundle, name, entry);
+}
+
+celix_status_t bundle_getState(bundle_pt bundle, bundle_state_e *state) {
+	if(bundle==NULL){
+		*state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
+		return CELIX_BUNDLE_EXCEPTION;
+	}
+	*state = bundle->state;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundle_setState(bundle_pt bundle, bundle_state_e state) {
+	bundle->state = state;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_archive_pt archive = NULL;
+	bundle_revision_pt revision = NULL;
+	manifest_pt headerMap = NULL;
+
+	status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
+	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+	status = CELIX_DO_IF(status, bundleRevision_getManifest(revision, &headerMap));
+	if (status == CELIX_SUCCESS) {
+		long bundleId = 0;
+        status = bundleArchive_getId(bundle->archive, &bundleId);
+        if (status == CELIX_SUCCESS) {
+			int revision = 0;
+			char moduleId[512];
+
+			snprintf(moduleId, sizeof(moduleId), "%ld.%d", bundleId, revision);
+			*module = module_create(headerMap, moduleId, bundle);
+
+			if (*module != NULL) {
+				version_pt bundleVersion = module_getVersion(*module);
+				const char * symName = NULL;
+				status = module_getSymbolicName(*module, &symName);
+				if (status == CELIX_SUCCESS) {
+					array_list_pt bundles = framework_getBundles(bundle->framework);
+					unsigned int i;
+					for (i = 0; i < arrayList_size(bundles); i++) {
+						bundle_pt check = (bundle_pt) arrayList_get(bundles, i);
+
+						long id;
+						if (bundleArchive_getId(check->archive, &id) == CELIX_SUCCESS) {
+							if (id != bundleId) {
+								module_pt mod = NULL;
+								const char * sym = NULL;
+								version_pt version;
+								int cmp;
+								status = bundle_getCurrentModule(check, &mod);
+								status = module_getSymbolicName(mod, &sym);
+
+								version = module_getVersion(mod);
+								version_compareTo(bundleVersion, version, &cmp);
+								if ((symName != NULL) && (sym != NULL) && !strcmp(symName, sym) &&
+										!cmp) {
+									char *versionString = NULL;
+									version_toString(version, &versionString);
+									printf("Bundle symbolic name and version are not unique: %s:%s\n", sym, versionString);
+									free(versionString);
+									status = CELIX_BUNDLE_EXCEPTION;
+									break;
+								}
+							}
+						}
+					}
+					arrayList_destroy(bundles);
+				}
+			}
+        }
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to create module");
+
+	return status;
+}
+
+celix_status_t bundle_start(bundle_pt bundle) {
+	return bundle_startWithOptions(bundle, 0);
+}
+
+celix_status_t bundle_startWithOptions(bundle_pt bundle, int options) {
+	celix_status_t status = CELIX_SUCCESS;
+    if (bundle != NULL) {
+    	bool systemBundle = false;
+    	status = bundle_isSystemBundle(bundle, &systemBundle);
+    	if (status == CELIX_SUCCESS) {
+    		if (systemBundle) {
+    			framework_start(bundle->framework);
+    		} else {
+    			status = fw_startBundle(bundle->framework, bundle, options);
+    		}
+    	}
+    }
+
+	framework_logIfError(logger, status, NULL, "Failed to start bundle");
+
+    return status;
+}
+
+celix_status_t bundle_update(bundle_pt bundle, const char *inputFile) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (bundle != NULL) {
+		bool systemBundle = false;
+		status = bundle_isSystemBundle(bundle, &systemBundle);
+		if (status == CELIX_SUCCESS) {
+			if (systemBundle) {
+				// #TODO: Support framework update
+				status = CELIX_BUNDLE_EXCEPTION;
+			} else {
+				status = framework_updateBundle(bundle->framework, bundle, inputFile);
+			}
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to update bundle");
+
+	return status;
+}
+
+celix_status_t bundle_stop(bundle_pt bundle) {
+	return bundle_stopWithOptions(bundle, 0);
+}
+
+celix_status_t bundle_stopWithOptions(bundle_pt bundle, int options) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (bundle != NULL) {
+		bool systemBundle = false;
+		status = bundle_isSystemBundle(bundle, &systemBundle);
+		if (status == CELIX_SUCCESS) {
+			if (systemBundle) {
+				framework_stop(bundle->framework);
+			} else {
+				status = fw_stopBundle(bundle->framework, bundle, options);
+			}
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to stop bundle");
+
+	return status;
+}
+
+celix_status_t bundle_uninstall(bundle_pt bundle) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (bundle != NULL) {
+		bool systemBundle = false;
+		status = bundle_isSystemBundle(bundle, &systemBundle);
+		if (status == CELIX_SUCCESS) {
+			if (systemBundle) {
+				status = CELIX_BUNDLE_EXCEPTION;
+			} else {
+				status = fw_uninstallBundle(bundle->framework, bundle);
+			}
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to uninstall bundle");
+
+	return status;
+}
+
+celix_status_t bundle_setPersistentStateInactive(bundle_pt bundle) {
+	celix_status_t status;
+	bool systemBundle;
+
+	status = bundle_isSystemBundle(bundle, &systemBundle);
+	if (status == CELIX_SUCCESS) {
+		if (!systemBundle) {
+			status = bundleArchive_setPersistentState(bundle->archive, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to set persistent state to inactive");
+
+	return status;
+}
+
+celix_status_t bundle_setPersistentStateUninstalled(bundle_pt bundle) {
+	celix_status_t status;
+	bool systemBundle;
+
+	status = bundle_isSystemBundle(bundle, &systemBundle);
+	if (status == CELIX_SUCCESS) {
+		if (!systemBundle) {
+			status = bundleArchive_setPersistentState(bundle->archive, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED);
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to set persistent state to uninstalled");
+
+    return status;
+}
+
+celix_status_t bundle_revise(bundle_pt bundle, const char * location, const char *inputFile) {
+	celix_status_t status;
+
+	bundle_archive_pt archive = NULL;
+	status = bundle_getArchive(bundle, &archive);
+	if (status == CELIX_SUCCESS) {
+		status = bundleArchive_revise(archive, location, inputFile);
+		if (status == CELIX_SUCCESS) {
+			module_pt module;
+			status = bundle_createModule(bundle, &module);
+			if (status == CELIX_SUCCESS) {
+				status = bundle_addModule(bundle, module);
+			} else {
+				bool rolledback;
+				status = bundleArchive_rollbackRevise(archive, &rolledback);
+				if (status == CELIX_SUCCESS) {
+					status = CELIX_BUNDLE_EXCEPTION;
+				}
+			}
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to revise bundle");
+
+	return status;
+}
+
+//bool bundle_rollbackRevise(bundle_pt bundle) {
+//	module_pt module = arrayList_remove(bundle->modules, arrayList_set(bundle->modules) - 1);
+//	return resolver_removeModule(module);
+//}
+
+celix_status_t bundle_addModule(bundle_pt bundle, module_pt module) {
+	arrayList_add(bundle->modules, module);
+	resolver_addModule(module);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundle_isSystemBundle(bundle_pt bundle, bool *systemBundle) {
+	celix_status_t status;
+	long bundleId;
+	bundle_archive_pt archive = NULL;
+
+	status = bundle_getArchive(bundle, &archive);
+	if (status == CELIX_SUCCESS) {
+		status = bundleArchive_getId(archive, &bundleId);
+		if (status == CELIX_SUCCESS) {
+			*systemBundle = (bundleId == 0);
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to check if bundle is the systembundle");
+
+	return status;
+}
+
+celix_status_t bundle_isLockable(bundle_pt bundle, bool *lockable) {
+	celix_status_t status;
+
+	status = celixThreadMutex_lock(&bundle->lock);
+	if (status != CELIX_SUCCESS) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	} else {
+		bool equals;
+		status = thread_equalsSelf(bundle->lockThread, &equals);
+		if (status == CELIX_SUCCESS) {
+			*lockable = (bundle->lockCount == 0) || (equals);
+		}
+
+		status = celixThreadMutex_unlock(&bundle->lock);
+		if (status != CELIX_SUCCESS) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to check if bundle is lockable");
+
+	return status;
+}
+
+celix_status_t bundle_getLockingThread(bundle_pt bundle, celix_thread_t *thread) {
+	celix_status_t status;
+
+	status = celixThreadMutex_lock(&bundle->lock);
+	if (status != CELIX_SUCCESS) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	} else {
+		*thread = bundle->lockThread;
+
+		status = celixThreadMutex_unlock(&bundle->lock);
+		if (status != CELIX_SUCCESS) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get locking thread");
+
+	return status;
+}
+
+celix_status_t bundle_lock(bundle_pt bundle, bool *locked) {
+	celix_status_t status;
+	bool equals;
+
+	celixThreadMutex_lock(&bundle->lock);
+
+	status = thread_equalsSelf(bundle->lockThread, &equals);
+	if (status == CELIX_SUCCESS) {
+		if ((bundle->lockCount > 0) && !equals) {
+			*locked = false;
+		} else {
+			bundle->lockCount++;
+			bundle->lockThread = celixThread_self();
+			*locked = true;
+		}
+	}
+
+	celixThreadMutex_unlock(&bundle->lock);
+
+	framework_logIfError(logger, status, NULL, "Failed to lock bundle");
+
+	return status;
+}
+
+celix_status_t bundle_unlock(bundle_pt bundle, bool *unlocked) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bool equals;
+
+	celixThreadMutex_lock(&bundle->lock);
+
+	if (bundle->lockCount == 0) {
+		*unlocked = false;
+	} else {
+		status = thread_equalsSelf(bundle->lockThread, &equals);
+		if (status == CELIX_SUCCESS) {
+			if ((bundle->lockCount > 0) && !equals) {
+				*unlocked = false;
+			}
+			else{
+			   bundle->lockCount--;
+			   if (bundle->lockCount == 0) {
+			   	bundle->lockThread = celix_thread_default;
+			   }
+			   *unlocked = true;
+		   }
+	   }
+	}
+
+	celixThreadMutex_unlock(&bundle->lock);
+
+	framework_logIfError(logger, status, NULL, "Failed to unlock bundle");
+
+	return status;
+}
+
+celix_status_t bundle_close(bundle_pt bundle) {
+	bundle_archive_pt archive = NULL;
+	
+	celix_status_t status;
+
+    bundle_closeModules(bundle);
+    bundle_closeRevisions(bundle);
+    status = bundle_getArchive(bundle, &archive);
+    if (status == CELIX_SUCCESS) {
+		bundleArchive_close(archive);
+    }
+
+	framework_logIfError(logger, status, NULL, "Failed to close bundle");
+
+    return status;
+}
+
+celix_status_t bundle_closeAndDelete(bundle_pt bundle) {
+	celix_status_t status;
+
+	bundle_archive_pt archive = NULL;
+
+    bundle_closeModules(bundle);
+    bundle_closeRevisions(bundle);
+    status = bundle_getArchive(bundle, &archive);
+    if (status == CELIX_SUCCESS) {
+    	bundleArchive_closeAndDelete(archive);
+    }
+
+	framework_logIfError(logger, status, NULL, "Failed to close and delete bundle");
+
+    return status;
+}
+
+celix_status_t bundle_closeRevisions(bundle_pt bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    // TODO implement this
+    return status;
+}
+
+celix_status_t bundle_closeModules(bundle_pt bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    unsigned int i = 0;
+    for (i = 0; i < arrayList_size(bundle->modules); i++) {
+        module_pt module = (module_pt) arrayList_get(bundle->modules, i);
+        resolver_removeModule(module);
+        module_setWires(module, NULL);
+    }
+
+    return status;
+}
+
+celix_status_t bundle_refresh(bundle_pt bundle) {
+	celix_status_t status;
+	module_pt module;
+
+	status = bundle_closeModules(bundle);
+	if (status == CELIX_SUCCESS) {
+		arrayList_clear(bundle->modules);
+		status = bundle_createModule(bundle, &module);
+		if (status == CELIX_SUCCESS) {
+			status = bundle_addModule(bundle, module);
+			if (status == CELIX_SUCCESS) {
+				bundle->state = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
+			}
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to refresh bundle");
+
+    return status;
+}
+
+celix_status_t bundle_getBundleId(bundle_pt bundle, long *id) {
+	celix_status_t status;
+	bundle_archive_pt archive = NULL;
+	status = bundle_getArchive(bundle, &archive);
+	if (status == CELIX_SUCCESS) {
+		status = bundleArchive_getId(archive, id);
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get bundle id");
+
+	return status;
+}
+
+celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *list) {
+	celix_status_t status;
+
+	status = fw_getBundleRegisteredServices(bundle->framework, bundle, list);
+
+	framework_logIfError(bundle->framework->logger, status, NULL, "Failed to get registered services");
+
+	return status;
+}
+
+celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list) {
+	celix_status_t status;
+
+	status = fw_getBundleServicesInUse(bundle->framework, bundle, list);
+
+	framework_logIfError(logger, status, NULL, "Failed to get in use services");
+
+	return status;
+}
+
+celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (bundle != NULL && framework != NULL) {
+		bundle->framework = framework;
+	} else {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to set framework");
+
+	return status;
+}
+
+celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (bundle != NULL && *framework == NULL) {
+		*framework = bundle->framework;
+	} else {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get framework");
+
+	return status;
+}
+
+celix_status_t bundle_getBundleLocation(bundle_pt bundle, const char **location){
+
+	celix_status_t status;
+
+	bundle_archive_pt archive = NULL;
+
+	status = bundle_getArchive(bundle, &archive);
+	if (status != CELIX_SUCCESS){
+		printf("[ ERROR ]: Bundle - getBundleLocation (BundleArchive) \n");
+		return status;
+	}
+
+	status =  bundleArchive_getLocation(archive, location);
+	if (status != CELIX_SUCCESS){
+		printf("[ ERROR ]:  Bundle - getBundleLocation (BundleArchiveLocation) \n");
+		return status;
+	}
+
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle_archive.c
----------------------------------------------------------------------
diff --git a/framework/src/bundle_archive.c b/framework/src/bundle_archive.c
new file mode 100644
index 0000000..cde727e
--- /dev/null
+++ b/framework/src/bundle_archive.c
@@ -0,0 +1,792 @@
+/**
+ *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.
+ */
+/*
+ * bundle_archive.c
+ *
+ *  \date       Aug 8, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+
+#include "bundle_archive.h"
+#include "linked_list_iterator.h"
+
+struct bundleArchive {
+	long id;
+	char * location;
+	DIR *archiveRootDir;
+	char * archiveRoot;
+	linked_list_pt revisions;
+	long refreshCount;
+	time_t lastModified;
+
+	bundle_state_e persistentState;
+};
+
+static celix_status_t bundleArchive_getRevisionLocation(bundle_archive_pt archive, long revNr, char **revision_location);
+static celix_status_t bundleArchive_setRevisionLocation(bundle_archive_pt archive, const char * location, long revNr);
+
+static celix_status_t bundleArchive_initialize(bundle_archive_pt archive);
+
+static celix_status_t bundleArchive_deleteTree(bundle_archive_pt archive, const char * directory);
+
+static celix_status_t bundleArchive_createRevisionFromLocation(bundle_archive_pt archive, const char *location, const char *inputFile, long revNr, bundle_revision_pt *bundle_revision);
+static celix_status_t bundleArchive_reviseInternal(bundle_archive_pt archive, bool isReload, long revNr, const char * location, const char *inputFile);
+
+static celix_status_t bundleArchive_readLastModified(bundle_archive_pt archive, time_t *time);
+static celix_status_t bundleArchive_writeLastModified(bundle_archive_pt archive);
+
+celix_status_t bundleArchive_createSystemBundleArchive(bundle_archive_pt *bundle_archive) {
+	celix_status_t status = CELIX_SUCCESS;
+	char *error = NULL;
+	bundle_archive_pt archive = NULL;
+
+	if (*bundle_archive != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+		error = "Missing required arguments and/or incorrect values";
+	} else {
+		archive = (bundle_archive_pt) calloc(1,sizeof(*archive));
+		if (archive == NULL) {
+			status = CELIX_ENOMEM;
+		} else {
+			status = linkedList_create(&archive->revisions);
+			if (status == CELIX_SUCCESS) {
+				archive->id = 0l;
+				archive->location = strdup("System Bundle");
+				archive->archiveRoot = NULL;
+				archive->archiveRootDir = NULL;
+				archive->refreshCount = -1;
+				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
+				time(&archive->lastModified);
+
+				*bundle_archive = archive;
+			}
+		}
+	}
+
+	if(status != CELIX_SUCCESS && archive != NULL){
+		bundleArchive_destroy(archive);
+	}
+
+	framework_logIfError(logger, status, error, "Could not create archive");
+
+	return status;
+}
+
+celix_status_t bundleArchive_create(const char *archiveRoot, long id, const char * location, const char *inputFile, bundle_archive_pt *bundle_archive) {
+	celix_status_t status = CELIX_SUCCESS;
+	char *error = NULL;
+	bundle_archive_pt archive = NULL;
+
+	if (*bundle_archive != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+		error = "bundle_archive_pt must be NULL";
+	} else {
+		archive = (bundle_archive_pt) calloc(1,sizeof(*archive));
+		if (archive == NULL) {
+			status = CELIX_ENOMEM;
+		} else {
+			status = linkedList_create(&archive->revisions);
+			if (status == CELIX_SUCCESS) {
+				archive->id = id;
+				archive->location = strdup(location);
+				archive->archiveRootDir = NULL;
+				archive->archiveRoot = strdup(archiveRoot);
+				archive->refreshCount = -1;
+				time(&archive->lastModified);
+
+				status = bundleArchive_initialize(archive);
+				if (status == CELIX_SUCCESS) {
+					status = bundleArchive_revise(archive, location, inputFile);
+
+					if (status == CELIX_SUCCESS) {
+						*bundle_archive = archive;
+					}
+					else{
+						bundleArchive_closeAndDelete(archive);
+					}
+				}
+			}
+		}
+	}
+
+	if(status != CELIX_SUCCESS && archive != NULL){
+		bundleArchive_destroy(archive);
+	}
+
+	framework_logIfError(logger, status, error, "Could not create archive");
+
+	return status;
+}
+
+celix_status_t bundleArchive_destroy(bundle_archive_pt archive) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if(archive != NULL){
+		if (archive->revisions != NULL) {
+			linked_list_iterator_pt iter = linkedListIterator_create(archive->revisions, 0);
+			while(linkedListIterator_hasNext(iter)) {
+				bundle_revision_pt rev = linkedListIterator_next(iter);
+				bundleRevision_destroy(rev);
+			}
+			linkedListIterator_destroy(iter);
+			linkedList_destroy(archive->revisions);
+		}
+		if (archive->archiveRoot != NULL) {
+			free(archive->archiveRoot);
+		}
+		if (archive->location != NULL) {
+			free(archive->location);
+		}
+
+		free(archive);
+		archive = NULL;
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not create archive");
+
+	return status;
+}
+
+celix_status_t bundleArchive_recreate(const char * archiveRoot, bundle_archive_pt *bundle_archive) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bundle_archive_pt archive = NULL;
+
+	archive = (bundle_archive_pt) calloc(1,sizeof(*archive));
+	if (archive == NULL) {
+		status = CELIX_ENOMEM;
+	} else {
+		status = linkedList_create(&archive->revisions);
+		if (status == CELIX_SUCCESS) {
+			archive->archiveRoot = strdup(archiveRoot);
+			archive->archiveRootDir = NULL;
+			archive->id = -1;
+			archive->persistentState = -1;
+			archive->location = NULL;
+			archive->refreshCount = -1;
+			archive->lastModified = (time_t) NULL;
+
+			archive->archiveRootDir = opendir(archiveRoot);
+			if (archive->archiveRootDir == NULL) {
+				status = CELIX_FRAMEWORK_EXCEPTION;
+			} else {
+
+				long idx = 0;
+				long highestId = -1;
+				char *location = NULL;
+
+				struct dirent *dent = NULL;
+				struct stat st;
+
+                errno = 0;
+                dent = readdir(archive->archiveRootDir);
+				while (errno == 0 && dent != NULL) {
+					char subdir[512];
+					snprintf(subdir, 512, "%s/%s", archiveRoot, dent->d_name);
+					int rv = stat(subdir, &st);
+					if (rv == 0 && S_ISDIR(st.st_mode) && (strncmp(dent->d_name, "version", 7) == 0)) {
+						sscanf(dent->d_name, "version%*d.%ld", &idx);
+						if (idx > highestId) {
+							highestId = idx;
+						}
+					}
+                    errno = 0;
+                    dent = readdir(archive->archiveRootDir);
+				}
+
+				status = CELIX_DO_IF(status, bundleArchive_getRevisionLocation(archive, 0, &location));
+				status = CELIX_DO_IF(status, bundleArchive_reviseInternal(archive, true, highestId, location, NULL));
+				if (location) {
+					free(location);
+				}
+				if (status == CELIX_SUCCESS) {
+					*bundle_archive = archive;
+				}
+				closedir(archive->archiveRootDir);
+			}
+		}
+	}
+
+	if(status != CELIX_SUCCESS && archive != NULL){
+		bundleArchive_destroy(archive);
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not create archive");
+
+	return status;
+}
+
+celix_status_t bundleArchive_getId(bundle_archive_pt archive, long *id) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (archive->id < 0) {
+		FILE *bundleIdFile;
+		char id[256];
+		char bundleId[512];
+		snprintf(bundleId, sizeof(bundleId), "%s/bundle.id", archive->archiveRoot);
+
+		bundleIdFile = fopen(bundleId, "r");
+		if(bundleIdFile!=NULL){
+			fgets(id, sizeof(id), bundleIdFile);
+			fclose(bundleIdFile);
+			sscanf(id, "%ld", &archive->id);
+		}
+		else{
+			status = CELIX_FILE_IO_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*id = archive->id;
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not get archive id");
+
+	return status;
+}
+
+celix_status_t bundleArchive_getLocation(bundle_archive_pt archive, const char **location) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (archive->location == NULL) {
+		FILE *bundleLocationFile;
+		char bundleLocation[512];
+		char loc[256];
+
+		snprintf(bundleLocation, sizeof(bundleLocation), "%s/bundle.location", archive->archiveRoot);
+
+		bundleLocationFile = fopen(bundleLocation, "r");
+		if(bundleLocationFile!=NULL){
+			fgets(loc, sizeof(loc), bundleLocationFile);
+			fclose(bundleLocationFile);
+			archive->location = strdup(loc);
+		}
+		else{
+			status = CELIX_FILE_IO_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*location = archive->location;
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not get archive location");
+
+	return status;
+}
+
+celix_status_t bundleArchive_getArchiveRoot(bundle_archive_pt archive, const char **archiveRoot) {
+	*archiveRoot = archive->archiveRoot;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleArchive_getCurrentRevisionNumber(bundle_archive_pt archive, long *revisionNumber) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_revision_pt revision;
+	*revisionNumber = -1;
+
+	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+	status = CELIX_DO_IF(status, bundleRevision_getNumber(revision, revisionNumber));
+
+	framework_logIfError(logger, status, NULL, "Could not get current revision number");
+
+	return status;
+}
+
+celix_status_t bundleArchive_getCurrentRevision(bundle_archive_pt archive, bundle_revision_pt *revision) {
+	*revision = linkedList_isEmpty(archive->revisions) ? NULL : linkedList_getLast(archive->revisions);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleArchive_getRevision(bundle_archive_pt archive, long revNr, bundle_revision_pt *revision) {
+	*revision = linkedList_get(archive->revisions, revNr);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleArchive_getPersistentState(bundle_archive_pt archive, bundle_state_e *state) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (archive->persistentState != OSGI_FRAMEWORK_BUNDLE_UNKNOWN) {
+		*state = archive->persistentState;
+	} else {
+		FILE *persistentStateLocationFile;
+		char persistentStateLocation[512];
+		char stateString[256];
+		snprintf(persistentStateLocation, sizeof(persistentStateLocation), "%s/bundle.state", archive->archiveRoot);
+
+		persistentStateLocationFile = fopen(persistentStateLocation, "r");
+		if (persistentStateLocationFile == NULL) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else {
+			if (fgets(stateString, sizeof(stateString), persistentStateLocationFile) == NULL) {
+				status = CELIX_FILE_IO_EXCEPTION;
+			}
+			fclose(persistentStateLocationFile);
+		}
+
+		if (status == CELIX_SUCCESS) {
+			if (strncmp(stateString, "active", 256) == 0) {
+				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_ACTIVE;
+			} else if (strncmp(stateString, "starting", 256) == 0) {
+				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_STARTING;
+			} else if (strncmp(stateString, "uninstalled", 256) == 0) {
+				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_UNINSTALLED;
+			} else {
+				archive->persistentState = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
+			}
+
+			*state = archive->persistentState;
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not get persistent state");
+
+	return status;
+}
+
+celix_status_t bundleArchive_setPersistentState(bundle_archive_pt archive, bundle_state_e state) {
+	celix_status_t status = CELIX_SUCCESS;
+	char persistentStateLocation[512];
+	FILE *persistentStateLocationFile;
+
+	snprintf(persistentStateLocation, sizeof(persistentStateLocation), "%s/bundle.state", archive->archiveRoot);
+
+	persistentStateLocationFile = fopen(persistentStateLocation, "w");
+	if (persistentStateLocationFile == NULL) {
+		status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+		char * s;
+		switch (state) {
+		case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
+			s = "active";
+			break;
+		case OSGI_FRAMEWORK_BUNDLE_STARTING:
+			s = "starting";
+			break;
+		case OSGI_FRAMEWORK_BUNDLE_UNINSTALLED:
+			s = "uninstalled";
+			break;
+		default:
+			s = "installed";
+			break;
+		}
+		fprintf(persistentStateLocationFile, "%s", s);
+		if (fclose(persistentStateLocationFile) ==  0) {
+			archive->persistentState = state;
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not set persistent state");
+
+	return status;
+}
+
+celix_status_t bundleArchive_getRefreshCount(bundle_archive_pt archive, long *refreshCount) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (archive->refreshCount == -1) {
+		FILE *refreshCounterFile;
+		char refreshCounter[512];
+		snprintf(refreshCounter, sizeof(refreshCounter), "%s/refresh.counter", archive->archiveRoot);
+
+		refreshCounterFile = fopen(refreshCounter, "r");
+		if (refreshCounterFile == NULL) {
+			archive->refreshCount = 0;
+		} else {
+			char counterStr[256];
+			if (fgets(counterStr, sizeof(counterStr), refreshCounterFile) == NULL) {
+				status = CELIX_FILE_IO_EXCEPTION;
+			}
+			fclose(refreshCounterFile);
+			if (status == CELIX_SUCCESS) {
+				sscanf(counterStr, "%ld", &archive->refreshCount);
+			}
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*refreshCount = archive->refreshCount;
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not get refresh count");
+
+	return status;
+}
+
+celix_status_t bundleArchive_setRefreshCount(bundle_archive_pt archive) {
+	FILE *refreshCounterFile;
+	celix_status_t status = CELIX_SUCCESS;
+	char refreshCounter[512];
+
+	snprintf(refreshCounter, sizeof(refreshCounter), "%s/refresh.counter", archive->archiveRoot);
+
+	refreshCounterFile = fopen(refreshCounter, "w");
+	if (refreshCounterFile == NULL) {
+		status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+		fprintf(refreshCounterFile, "%ld", archive->refreshCount);
+		if (fclose(refreshCounterFile) ==  0) {
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not set refresh count");
+
+	return status;
+}
+
+celix_status_t bundleArchive_getLastModified(bundle_archive_pt archive, time_t *lastModified) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (archive->lastModified == (time_t) NULL) {
+		status = CELIX_DO_IF(status, bundleArchive_readLastModified(archive, &archive->lastModified));
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*lastModified = archive->lastModified;
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not get last modified");
+
+	return status;
+}
+
+celix_status_t bundleArchive_setLastModified(bundle_archive_pt archive, time_t lastModifiedTime) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	archive->lastModified = lastModifiedTime;
+	status = CELIX_DO_IF(status, bundleArchive_writeLastModified(archive));
+
+	framework_logIfError(logger, status, NULL, "Could not set last modified");
+
+	return status;
+}
+
+static celix_status_t bundleArchive_readLastModified(bundle_archive_pt archive, time_t *time) {
+	FILE *lastModifiedFile;
+	char lastModified[512];
+
+	celix_status_t status = CELIX_SUCCESS;
+
+	snprintf(lastModified, sizeof(lastModified), "%s/bundle.lastmodified", archive->archiveRoot);
+
+	lastModifiedFile = fopen(lastModified, "r");
+	if (lastModifiedFile == NULL) {
+		status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+		char timeStr[20];
+		int year, month, day, hours, minutes, seconds;
+		struct tm tm_time;
+		memset(&tm_time,0,sizeof(struct tm));
+
+		if (fgets(timeStr, sizeof(timeStr), lastModifiedFile) == NULL) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		}
+		fclose(lastModifiedFile);
+		if (status == CELIX_SUCCESS) {
+			sscanf(timeStr, "%d %d %d %d:%d:%d", &year, &month, &day, &hours, &minutes, &seconds);
+			tm_time.tm_year = year - 1900;
+			tm_time.tm_mon = month - 1;
+			tm_time.tm_mday = day;
+			tm_time.tm_hour = hours;
+			tm_time.tm_min = minutes;
+			tm_time.tm_sec = seconds;
+
+			*time = mktime(&tm_time);
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not read last modified");
+
+	return status;
+}
+
+static celix_status_t bundleArchive_writeLastModified(bundle_archive_pt archive) {
+	celix_status_t status = CELIX_SUCCESS;
+	FILE *lastModifiedFile;
+	char lastModified[512];
+
+	snprintf(lastModified, sizeof(lastModified), "%s/bundle.lastmodified", archive->archiveRoot);
+	lastModifiedFile = fopen(lastModified, "w");
+	if (lastModifiedFile == NULL) {
+		status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+		char timeStr[20];
+		strftime(timeStr, 20, "%Y %m %d %H:%M:%S", localtime(&archive->lastModified));
+		fprintf(lastModifiedFile, "%s", timeStr);
+		fclose(lastModifiedFile);
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not write last modified");
+
+	return status;
+}
+
+celix_status_t bundleArchive_revise(bundle_archive_pt archive, const char * location, const char *inputFile) {
+	celix_status_t status = CELIX_SUCCESS;
+	long revNr = 0l;
+	if (!linkedList_isEmpty(archive->revisions)) {
+		long revisionNr;
+		status = bundleRevision_getNumber(linkedList_getLast(archive->revisions), &revisionNr);
+		revNr = revisionNr + 1;
+	}
+	if (status == CELIX_SUCCESS) {
+		status = bundleArchive_reviseInternal(archive, false, revNr, location, inputFile);
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not revise bundle archive");
+
+	return status;
+}
+
+static celix_status_t bundleArchive_reviseInternal(bundle_archive_pt archive, bool isReload, long revNr, const char * location, const char *inputFile) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_revision_pt revision = NULL;
+
+	if (inputFile != NULL) {
+		location = "inputstream:";
+	}
+
+	status = bundleArchive_createRevisionFromLocation(archive, location, inputFile, revNr, &revision);
+
+	if (status == CELIX_SUCCESS) {
+		if (!isReload) {
+			status = bundleArchive_setRevisionLocation(archive, location, revNr);
+		}
+
+		linkedList_addElement(archive->revisions, revision);
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not revise bundle archive");
+
+	return status;
+}
+
+celix_status_t bundleArchive_rollbackRevise(bundle_archive_pt archive, bool *rolledback) {
+	*rolledback = true;
+	return CELIX_SUCCESS;
+}
+
+static celix_status_t bundleArchive_createRevisionFromLocation(bundle_archive_pt archive, const char *location, const char *inputFile, long revNr, bundle_revision_pt *bundle_revision) {
+	celix_status_t status = CELIX_SUCCESS;
+	char root[256];
+	long refreshCount;
+
+	status = bundleArchive_getRefreshCount(archive, &refreshCount);
+	if (status == CELIX_SUCCESS) {
+		bundle_revision_pt revision = NULL;
+
+		sprintf(root, "%s/version%ld.%ld", archive->archiveRoot, refreshCount, revNr);
+		status = bundleRevision_create(root, location, revNr, inputFile, &revision);
+
+		if (status == CELIX_SUCCESS) {
+			*bundle_revision = revision;
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Could not create revision [location=%s,inputFile=%s]", location, inputFile);
+
+	return status;
+}
+
+static celix_status_t bundleArchive_getRevisionLocation(bundle_archive_pt archive, long revNr, char **revision_location) {
+	celix_status_t status = CELIX_SUCCESS;
+	char revisionLocation[256];
+	long refreshCount;
+
+	status = bundleArchive_getRefreshCount(archive, &refreshCount);
+	if (status == CELIX_SUCCESS) {
+		FILE *revisionLocationFile;
+
+		snprintf(revisionLocation, sizeof(revisionLocation), "%s/version%ld.%ld/revision.location", archive->archiveRoot, refreshCount, revNr);
+
+		revisionLocationFile = fopen(revisionLocation, "r");
+		if (revisionLocationFile != NULL) {
+			char location[256];
+			fgets(location , sizeof(location) , revisionLocationFile);
+			fclose(revisionLocationFile);
+
+			*revision_location = strdup(location);
+			status = CELIX_SUCCESS;
+		} else {
+			// revision file not found
+			printf("Failed to open revision file at: %s\n", revisionLocation);
+			status = CELIX_FILE_IO_EXCEPTION;
+		}
+	}
+
+
+	framework_logIfError(logger, status, NULL, "Failed to get revision location");
+
+	return status;
+}
+
+static celix_status_t bundleArchive_setRevisionLocation(bundle_archive_pt archive, const char * location, long revNr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	char revisionLocation[256];
+	long refreshCount;
+
+	status = bundleArchive_getRefreshCount(archive, &refreshCount);
+	if (status == CELIX_SUCCESS) {
+		FILE * revisionLocationFile;
+
+		snprintf(revisionLocation, sizeof(revisionLocation), "%s/version%ld.%ld/revision.location", archive->archiveRoot, refreshCount, revNr);
+
+		revisionLocationFile = fopen(revisionLocation, "w");
+		if (revisionLocationFile == NULL) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else {
+			fprintf(revisionLocationFile, "%s", location);
+			fclose(revisionLocationFile);
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to set revision location");
+
+	return status;
+}
+
+celix_status_t bundleArchive_close(bundle_archive_pt archive) {
+	// close revision
+	// not yet needed/possible
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleArchive_closeAndDelete(bundle_archive_pt archive) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	status = bundleArchive_close(archive);
+	if (status == CELIX_SUCCESS) {
+		status = bundleArchive_deleteTree(archive, archive->archiveRoot);
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to close and delete archive");
+
+	return status;
+}
+
+static celix_status_t bundleArchive_initialize(bundle_archive_pt archive) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (archive->archiveRootDir == NULL) {
+		int err = mkdir(archive->archiveRoot, S_IRWXU) ;
+		if (err != 0) {
+			char *errmsg = strerror(errno);
+			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error mkdir: %s\n", errmsg);
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else {
+			archive->archiveRootDir = opendir(archive->archiveRoot);
+			if (archive->archiveRootDir == NULL) {
+				status = CELIX_FILE_IO_EXCEPTION;
+			} else {
+				FILE *bundleIdFile;
+				char bundleId[512];
+
+				snprintf(bundleId, sizeof(bundleId), "%s/bundle.id", archive->archiveRoot);
+				bundleIdFile = fopen(bundleId, "w");
+
+				if (bundleIdFile == NULL) {
+					status = CELIX_FILE_IO_EXCEPTION;
+				} else {
+					FILE *bundleLocationFile;
+					char bundleLocation[512];
+
+					fprintf(bundleIdFile, "%ld", archive->id);
+					// Ignore close status, let it fail if needed again
+					fclose(bundleIdFile);
+
+					snprintf(bundleLocation, sizeof(bundleLocation), "%s/bundle.location", archive->archiveRoot);
+					bundleLocationFile = fopen(bundleLocation, "w");
+
+					if (bundleLocationFile == NULL) {
+						status = CELIX_FILE_IO_EXCEPTION;
+					} else {
+						fprintf(bundleLocationFile, "%s", archive->location);
+						// Ignore close status, let it fail if needed again
+						fclose(bundleLocationFile);
+
+						status = bundleArchive_writeLastModified(archive);
+					}
+				}
+				closedir(archive->archiveRootDir);
+			}
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to initialize archive");
+
+	return status;
+}
+
+static celix_status_t bundleArchive_deleteTree(bundle_archive_pt archive, const char * directory) {
+	DIR *dir;
+	celix_status_t status = CELIX_SUCCESS;
+	dir = opendir(directory);
+	if (dir == NULL) {
+		status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+
+		struct dirent* dent = NULL;
+
+        errno = 0;
+        dent = readdir(dir);
+		while (errno == 0 && dent != NULL) {
+			if ((strcmp((dent->d_name), ".") != 0) && (strcmp((dent->d_name), "..") != 0)) {
+				char subdir[512];
+				snprintf(subdir, 512, "%s/%s", directory, dent->d_name);
+
+				struct stat st;
+				if (stat(subdir, &st) == 0) {
+					if (S_ISDIR (st.st_mode)) {
+						status = bundleArchive_deleteTree(archive, subdir);
+					} else {
+						if (remove(subdir) != 0) {
+							status = CELIX_FILE_IO_EXCEPTION;
+							break;
+						}
+					}
+				}
+			}
+            errno = 0;
+            dent = readdir(dir);
+		}
+
+        if (errno != 0) {
+            status = CELIX_FILE_IO_EXCEPTION;
+        } else if (closedir(dir) != 0) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else if (status == CELIX_SUCCESS) {
+			if (rmdir(directory) != 0) {
+				status = CELIX_FILE_IO_EXCEPTION;
+			}
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to delete tree");
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle_cache.c
----------------------------------------------------------------------
diff --git a/framework/src/bundle_cache.c b/framework/src/bundle_cache.c
new file mode 100644
index 0000000..39875b5
--- /dev/null
+++ b/framework/src/bundle_cache.c
@@ -0,0 +1,218 @@
+/**
+ *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.
+ */
+/*
+ * bundle_cache.c
+ *
+ *  \date       Aug 6, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+
+#include "bundle_cache_private.h"
+#include "bundle_archive.h"
+#include "constants.h"
+#include "celix_log.h"
+
+static celix_status_t bundleCache_deleteTree(bundle_cache_pt cache, char * directory);
+
+celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache) {
+	celix_status_t status;
+	bundle_cache_pt cache;
+
+	if (configurationMap == NULL || *bundle_cache != NULL) {
+		return CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	cache = (bundle_cache_pt) calloc(1, sizeof(*cache));
+	if (cache == NULL) {
+		status = CELIX_ENOMEM;
+	} else {
+		char* cacheDir = (char*)properties_get(configurationMap, (char *) OSGI_FRAMEWORK_FRAMEWORK_STORAGE);
+		cache->configurationMap = configurationMap;
+		if (cacheDir == NULL) {
+			cacheDir = ".cache";
+		}
+		cache->cacheDir = cacheDir;
+
+		*bundle_cache = cache;
+		status = CELIX_SUCCESS;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to create bundle cache");
+
+	return status;
+}
+
+celix_status_t bundleCache_destroy(bundle_cache_pt *cache) {
+
+	free(*cache);
+	*cache = NULL;
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleCache_delete(bundle_cache_pt cache) {
+	return bundleCache_deleteTree(cache, cache->cacheDir);
+}
+
+celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *archives) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	DIR *dir;
+	struct stat st;
+
+	dir = opendir(cache->cacheDir);
+
+	if (dir == NULL && errno == ENOENT) {
+		if(mkdir(cache->cacheDir, S_IRWXU) == 0 ){
+			dir = opendir(cache->cacheDir);
+		}
+	}
+
+	if (dir != NULL) {
+		array_list_pt list = NULL;
+		arrayList_create(&list);
+
+		struct dirent* dent = NULL;
+
+		errno = 0;
+		dent = readdir(dir);
+		while (errno == 0 && dent != NULL) {
+			char archiveRoot[512];
+
+			snprintf(archiveRoot, sizeof(archiveRoot), "%s/%s", cache->cacheDir, dent->d_name);
+
+			if (stat (archiveRoot, &st) == 0) {
+				if (S_ISDIR (st.st_mode)
+						&& (strcmp((dent->d_name), ".") != 0)
+						&& (strcmp((dent->d_name), "..") != 0)
+						&& (strncmp(dent->d_name, "bundle", 6) == 0)
+						&& (strcmp(dent->d_name, "bundle0") != 0)) {
+
+					bundle_archive_pt archive = NULL;
+					status = bundleArchive_recreate(archiveRoot, &archive);
+					if (status == CELIX_SUCCESS) {
+						arrayList_add(list, archive);
+					}
+				}
+			}
+
+			errno = 0;
+			dent = readdir(dir);
+		}
+
+		if (errno != 0) {
+			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error reading dir");
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else {
+			status = CELIX_SUCCESS;
+		}
+
+		closedir(dir);
+
+		if (status == CELIX_SUCCESS) {
+			*archives = list;
+		}
+		else{
+			int idx = 0;
+			for(;idx<arrayList_size(list);idx++){
+				bundleArchive_destroy((bundle_archive_pt)arrayList_get(list,idx));
+			}
+			arrayList_destroy(list);
+			*archives = NULL;
+		}
+
+	} else {
+		status = CELIX_FILE_IO_EXCEPTION;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get bundle archives");
+
+	return status;
+}
+
+celix_status_t bundleCache_createArchive(bundle_cache_pt cache, long id, const char * location, const char *inputFile, bundle_archive_pt *bundle_archive) {
+	celix_status_t status = CELIX_SUCCESS;
+	char archiveRoot[512];
+
+	if (cache && location) {
+		snprintf(archiveRoot, sizeof(archiveRoot), "%s/bundle%ld",  cache->cacheDir, id);
+		status = bundleArchive_create(archiveRoot, id, location, inputFile, bundle_archive);
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to create archive");
+
+	return status;
+}
+
+static celix_status_t bundleCache_deleteTree(bundle_cache_pt cache, char * directory) {
+	DIR *dir;
+	celix_status_t status = CELIX_SUCCESS;
+	struct stat st;
+
+	errno = 0;
+	dir = opendir(directory);
+	if (dir == NULL) {
+		status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+		struct dirent* dent = NULL;
+		dent = readdir(dir);
+		while (errno == 0 && dent != NULL) {
+			if ((strcmp((dent->d_name), ".") != 0) && (strcmp((dent->d_name), "..") != 0)) {
+				char subdir[512];
+				snprintf(subdir, sizeof(subdir), "%s/%s", directory, dent->d_name);
+
+				if (stat(subdir, &st) == 0) {
+					if (S_ISDIR (st.st_mode)) {
+						status = bundleCache_deleteTree(cache, subdir);
+					} else {
+						if (remove(subdir) != 0) {
+							status = CELIX_FILE_IO_EXCEPTION;
+							break;
+						}
+					}
+				}
+			}
+			errno = 0;
+			dent = readdir(dir);
+		}
+
+		if (errno != 0) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		}
+		else if (closedir(dir) != 0) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		}
+		if (status == CELIX_SUCCESS) {
+			if (rmdir(directory) != 0) {
+				status = CELIX_FILE_IO_EXCEPTION;
+			}
+		}
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to delete tree at dir '%s'", directory);
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle_cache.h
----------------------------------------------------------------------
diff --git a/framework/src/bundle_cache.h b/framework/src/bundle_cache.h
new file mode 100644
index 0000000..350f33b
--- /dev/null
+++ b/framework/src/bundle_cache.h
@@ -0,0 +1,115 @@
+/**
+ *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.
+ */
+/*
+ * bundle_cache.h
+ *
+ *  \date       Aug 8, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef BUNDLE_CACHE_H_
+#define BUNDLE_CACHE_H_
+
+/**
+ * @defgroup BundleCache BundleCache
+ * @ingroup framework
+ * @{
+ */
+
+#include "properties.h"
+#include "array_list.h"
+#include "bundle_archive.h"
+#include "celix_log.h"
+
+/**
+ * Type definition for the bundle_cache_pt abstract data type.
+ */
+typedef struct bundleCache *bundle_cache_pt;
+
+/**
+ * Creates the bundle cache using the supplied configuration map.
+ *
+ * @param configurationMap Set with properties to use for this cache
+ * @param mp The memory pool to use for allocation the cache
+ * @param bundle_cache Output parameter for the created cache
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ILLEGAL_ARGUMENT If <code>bundle_cache</code> not is null.
+ * 		- CELIX_ENOMEM If allocating memory for <code>bundle_cache</code> failed.
+ */
+celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache);
+
+/**
+ * Frees the bundle_cache memory allocated in bundleCache_create
+ *
+ * @param bundle_cache Output parameter for the created cache
+ * @return Status code indication failure or success:
+ *      - CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t bundleCache_destroy(bundle_cache_pt *cache);
+
+/**
+ * Recreates and retrieves the list of archives for the given bundle cache.
+ * Archives are recreated on the bundle cache memory pool, the list for the results is created on the suplied pool, and is owned by the caller.
+ *
+ * @param cache The cache to recreate archives out
+ * @param pool The pool on which the list of archives is created
+ * @param archives List with recreated archives
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ILLEGAL_ARGUMENT If <code>archives</code> not is null.
+ * 		- CELIX_ENOMEM If allocating memory for <code>archives</code> failed.
+ * 		- CELIX_FILE_IO_EXCEPTION If the cache cannot be opened or read.
+ */
+celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *archives);
+
+/**
+ * Creates a new archive for the given bundle (using the id and location). The archive is created on the supplied bundlePool.
+ *
+ * @param cache The cache to create an archive in
+ * @param bundlePool The pool to use for the archive creation
+ * @param id The id of the bundle
+ * @param location The location identifier of the bundle
+ * @param inputFile Input identifier to read the bundle data from
+ * @param archive The archive to create
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ILLEGAL_ARGUMENT If <code>bundle_archive</code> not is null.
+ * 		- CELIX_ENOMEM If allocating memory for <code>bundle_archive</code> failed.
+ */
+celix_status_t bundleCache_createArchive(bundle_cache_pt cache, long id, const char* location, const char* inputFile, bundle_archive_pt *archive);
+
+/**
+ * Deletes the entire bundle cache.
+ *
+ * @param cache the cache to delete
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ILLEGAL_ARGUMENT If the cache is invalid
+ * 		- CELIX_FILE_IO_EXCEPTION If the cache cannot be opened or read.
+ */
+celix_status_t bundleCache_delete(bundle_cache_pt cache);
+
+/**
+ * @}
+ */
+
+#endif /* BUNDLE_CACHE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle_cache_private.h
----------------------------------------------------------------------
diff --git a/framework/src/bundle_cache_private.h b/framework/src/bundle_cache_private.h
new file mode 100644
index 0000000..69e26ee
--- /dev/null
+++ b/framework/src/bundle_cache_private.h
@@ -0,0 +1,39 @@
+/**
+ *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.
+ */
+/*
+ * bundle_cache_private.h
+ *
+ *  \date       Feb 12, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef BUNDLE_CACHE_PRIVATE_H_
+#define BUNDLE_CACHE_PRIVATE_H_
+
+#include "bundle_cache.h"
+
+struct bundleCache {
+	properties_pt configurationMap;
+	char * cacheDir;
+};
+
+
+#endif /* BUNDLE_CACHE_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/framework/src/bundle_context.c b/framework/src/bundle_context.c
new file mode 100644
index 0000000..face85d
--- /dev/null
+++ b/framework/src/bundle_context.c
@@ -0,0 +1,384 @@
+/**
+ *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.
+ */
+/*
+ * bundle_context.c
+ *
+ *  \date       Mar 26, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "bundle_context_private.h"
+#include "framework_private.h"
+#include "bundle.h"
+#include "celix_log.h"
+
+celix_status_t bundleContext_create(framework_pt framework, framework_logger_pt logger, bundle_pt bundle, bundle_context_pt *bundle_context) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = NULL;
+
+	if (*bundle_context != NULL && framework == NULL && bundle == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+        context = malloc(sizeof(*context));
+        if (!context) {
+            status = CELIX_ENOMEM;
+        } else {
+            context->framework = framework;
+            context->bundle = bundle;
+
+            *bundle_context = context;
+        }
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to create context");
+
+	return status;
+}
+
+celix_status_t bundleContext_destroy(bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (context != NULL) {
+	    free(context);
+		context = NULL;
+	} else {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to destroy context");
+
+	return status;
+}
+
+celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *bundle) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (context == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*bundle = context->bundle;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get bundle");
+
+	return status;
+}
+
+celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_pt *framework) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (context == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*framework = context->framework;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get framework");
+
+	return status;
+}
+
+celix_status_t bundleContext_installBundle(bundle_context_pt context, const char * location, bundle_pt *bundle) {
+	return bundleContext_installBundle2(context, location, NULL, bundle);
+}
+
+celix_status_t bundleContext_installBundle2(bundle_context_pt context, const char * location, const char *inputFile, bundle_pt *bundle) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_pt b = NULL;
+
+	if (context != NULL && *bundle == NULL) {
+		if (fw_installBundle(context->framework, &b, location, inputFile) != CELIX_SUCCESS) {
+            status = CELIX_FRAMEWORK_EXCEPTION;
+		} else {
+			*bundle = b;
+		}
+	} else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to install bundle");
+
+	return status;
+}
+
+celix_status_t bundleContext_registerService(bundle_context_pt context, const char * serviceName, const void * svcObj,
+        properties_pt properties, service_registration_pt *service_registration) {
+	service_registration_pt registration = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (context != NULL) {
+	    fw_registerService(context->framework, &registration, context->bundle, serviceName, svcObj, properties);
+	    *service_registration = registration;
+	} else {
+	    status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to register service. serviceName '%s'", serviceName);
+
+	return status;
+}
+
+celix_status_t bundleContext_registerServiceFactory(bundle_context_pt context, const char * serviceName, service_factory_pt factory,
+        properties_pt properties, service_registration_pt *service_registration) {
+    service_registration_pt registration = NULL;
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && *service_registration == NULL) {
+        fw_registerServiceFactory(context->framework, &registration, context->bundle, serviceName, factory, properties);
+        *service_registration = registration;
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to register service factory");
+
+    return status;
+}
+
+celix_status_t bundleContext_getServiceReferences(bundle_context_pt context, const char * serviceName, const char * filter, array_list_pt *service_references) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && *service_references == NULL) {
+        fw_getServiceReferences(context->framework, service_references, context->bundle, serviceName, filter);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to get service references");
+
+	return status;
+}
+
+celix_status_t bundleContext_getServiceReference(bundle_context_pt context, const char * serviceName, service_reference_pt *service_reference) {
+    service_reference_pt reference = NULL;
+    array_list_pt services = NULL;
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (serviceName != NULL) {
+        if (bundleContext_getServiceReferences(context, serviceName, NULL, &services) == CELIX_SUCCESS) {
+            reference = (arrayList_size(services) > 0) ? arrayList_get(services, 0) : NULL;
+            arrayList_destroy(services);
+            *service_reference = reference;
+        } else {
+            status = CELIX_ILLEGAL_ARGUMENT;
+        }
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to get service reference");
+
+	return status;
+}
+
+FRAMEWORK_EXPORT celix_status_t bundleContext_retainServiceReference(bundle_context_pt context, service_reference_pt ref) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && ref != NULL) {
+        serviceRegistry_retainServiceReference(context->framework->registry, context->bundle, ref);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to get service references");
+
+    return status;
+}
+
+celix_status_t bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && reference != NULL) {
+        status = framework_ungetServiceReference(context->framework, context->bundle, reference);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to unget service_reference");
+
+    return status;
+}
+
+celix_status_t bundleContext_getService(bundle_context_pt context, service_reference_pt reference, void** service_instance) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && reference != NULL && *service_instance == NULL) {
+        /*NOTE argument service_instance should be considerd a 'const void**'. 
+        To ensure backwards compatiblity a cast is made instead.
+        */
+	    status = fw_getService(context->framework, context->bundle, reference, (const void**) service_instance);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to get service");
+
+    return status;
+}
+
+celix_status_t bundleContext_ungetService(bundle_context_pt context, service_reference_pt reference, bool *result) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && reference != NULL) {
+        status = framework_ungetService(context->framework, context->bundle, reference, result);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to unget service");
+
+    return status;
+}
+
+celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (context == NULL || *bundles != NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*bundles = framework_getBundles(context->framework);
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get bundles");
+
+	return status;
+}
+
+celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, bundle_pt *bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context == NULL || *bundle != NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    } else {
+        *bundle = framework_getBundleById(context->framework, id);
+        if (*bundle == NULL) {
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to get bundle [id=%ld]", id);
+
+	return status;
+}
+
+celix_status_t bundleContext_addServiceListener(bundle_context_pt context, service_listener_pt listener, const char* filter) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && listener != NULL) {
+        fw_addServiceListener(context->framework, context->bundle, listener, filter);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to add service listener");
+
+    return status;
+}
+
+celix_status_t bundleContext_removeServiceListener(bundle_context_pt context, service_listener_pt listener) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && listener != NULL) {
+        fw_removeServiceListener(context->framework, context->bundle, listener);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to remove service listener");
+
+    return status;
+}
+
+celix_status_t bundleContext_addBundleListener(bundle_context_pt context, bundle_listener_pt listener) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && listener != NULL) {
+        fw_addBundleListener(context->framework, context->bundle, listener);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to add bundle listener");
+
+    return status;
+}
+
+celix_status_t bundleContext_removeBundleListener(bundle_context_pt context, bundle_listener_pt listener) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && listener != NULL) {
+        fw_removeBundleListener(context->framework, context->bundle, listener);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to remove bundle listener");
+
+    return status;
+}
+
+celix_status_t bundleContext_addFrameworkListener(bundle_context_pt context, framework_listener_pt listener) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && listener != NULL) {
+        fw_addFrameworkListener(context->framework, context->bundle, listener);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to add framework listener");
+
+    return status;
+}
+
+celix_status_t bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && listener != NULL) {
+        fw_removeFrameworkListener(context->framework, context->bundle, listener);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to remove framework listener");
+
+    return status;
+}
+
+celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *name, const char** value) {
+	return bundleContext_getPropertyWithDefault(context, name, NULL, value);
+}
+
+celix_status_t bundleContext_getPropertyWithDefault(bundle_context_pt context, const char* name, const char* defaultValue, const char** value) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context == NULL || name == NULL || *value != NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    } else {
+        fw_getProperty(context->framework, name, defaultValue, value);
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to get property [name=%s]", name);
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle_context_private.h
----------------------------------------------------------------------
diff --git a/framework/src/bundle_context_private.h b/framework/src/bundle_context_private.h
new file mode 100644
index 0000000..3810cd0
--- /dev/null
+++ b/framework/src/bundle_context_private.h
@@ -0,0 +1,43 @@
+/**
+ *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.
+ */
+/*
+ * bundle_context_private.h
+ *
+ *  \date       Feb 12, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef BUNDLE_CONTEXT_PRIVATE_H_
+#define BUNDLE_CONTEXT_PRIVATE_H_
+
+#include "bundle_context.h"
+#include "celix_log.h"
+
+struct bundleContext {
+#ifdef WITH_APR
+    apr_pool_t *pool;
+#endif
+	struct framework * framework;
+	struct bundle * bundle;
+};
+
+
+#endif /* BUNDLE_CONTEXT_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle_private.h
----------------------------------------------------------------------
diff --git a/framework/src/bundle_private.h b/framework/src/bundle_private.h
new file mode 100644
index 0000000..8085609
--- /dev/null
+++ b/framework/src/bundle_private.h
@@ -0,0 +1,48 @@
+/**
+ *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.
+ */
+/*
+ * bundle_private.h
+ *
+ *  \date       Feb 18, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef BUNDLE_PRIVATE_H_
+#define BUNDLE_PRIVATE_H_
+
+#include "bundle.h"
+
+struct bundle {
+	bundle_context_pt context;
+	activator_pt activator;
+	bundle_state_e state;
+	void * handle;
+	bundle_archive_pt archive;
+	array_list_pt modules;
+	manifest_pt manifest;
+
+	celix_thread_mutex_t lock;
+	int lockCount;
+	celix_thread_t lockThread;
+
+	struct framework * framework;
+};
+
+#endif /* BUNDLE_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle_revision.c
----------------------------------------------------------------------
diff --git a/framework/src/bundle_revision.c b/framework/src/bundle_revision.c
new file mode 100644
index 0000000..cfa10aa
--- /dev/null
+++ b/framework/src/bundle_revision.c
@@ -0,0 +1,153 @@
+/**
+ *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.
+ */
+/*
+ * bundle_revision.c
+ *
+ *  \date       Apr 12, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <archive.h>
+#include <string.h>
+
+#include "bundle_revision_private.h"
+
+celix_status_t bundleRevision_create(const char *root, const char *location, long revisionNr, const char *inputFile, bundle_revision_pt *bundle_revision) {
+    celix_status_t status = CELIX_SUCCESS;
+	bundle_revision_pt revision = NULL;
+
+	revision = (bundle_revision_pt) malloc(sizeof(*revision));
+    if (!revision) {
+    	status = CELIX_ENOMEM;
+    } else {
+    	// TODO: This overwrites an existing revision, is this supposed to happen?
+        int state = mkdir(root, S_IRWXU);
+        if ((state != 0) && (errno != EEXIST)) {
+            free(revision);
+            status = CELIX_FILE_IO_EXCEPTION;
+        } else {
+            if (inputFile != NULL) {
+                status = extractBundle(inputFile, root);
+            } else if (strcmp(location, "inputstream:") != 0) {
+            	// TODO how to handle this correctly?
+            	// If location != inputstream, extract it, else ignore it and assume this is a cache entry.
+                status = extractBundle(location, root);
+            }
+
+            status = CELIX_DO_IF(status, arrayList_create(&(revision->libraryHandles)));
+            if (status == CELIX_SUCCESS) {
+                revision->revisionNr = revisionNr;
+                revision->root = strdup(root);
+                revision->location = strdup(location);
+
+                *bundle_revision = revision;
+
+                char manifest[512];
+                snprintf(manifest, sizeof(manifest), "%s/META-INF/MANIFEST.MF", revision->root);
+				status = manifest_createFromFile(manifest, &revision->manifest);
+            }
+            else {
+            	free(revision);
+            }
+
+        }
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to create revision");
+
+	return status;
+}
+
+celix_status_t bundleRevision_destroy(bundle_revision_pt revision) {
+    arrayList_destroy(revision->libraryHandles);
+    manifest_destroy(revision->manifest);
+    free(revision->root);
+    free(revision->location);
+    free(revision);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleRevision_getNumber(bundle_revision_pt revision, long *revisionNr) {
+	celix_status_t status = CELIX_SUCCESS;
+    if (revision == NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    } else {
+    	*revisionNr = revision->revisionNr;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to get revision number");
+
+	return status;
+}
+
+celix_status_t bundleRevision_getLocation(bundle_revision_pt revision, const char **location) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (revision == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*location = revision->location;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get revision location");
+
+	return status;
+}
+
+celix_status_t bundleRevision_getRoot(bundle_revision_pt revision, const char **root) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (revision == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*root = revision->root;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get revision root");
+
+	return status;
+}
+
+celix_status_t bundleRevision_getManifest(bundle_revision_pt revision, manifest_pt *manifest) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (revision == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*manifest = revision->manifest;
+	}
+
+	framework_logIfError(logger, status, NULL, "Failed to get manifest");
+
+	return status;
+}
+
+celix_status_t bundleRevision_getHandles(bundle_revision_pt revision, array_list_pt *handles) {
+    celix_status_t status = CELIX_SUCCESS;
+    if (revision == NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    } else {
+        *handles = revision->libraryHandles;
+    }
+
+    framework_logIfError(logger, status, NULL, "Failed to get handles");
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/bundle_revision_private.h
----------------------------------------------------------------------
diff --git a/framework/src/bundle_revision_private.h b/framework/src/bundle_revision_private.h
new file mode 100644
index 0000000..cb1dcd8
--- /dev/null
+++ b/framework/src/bundle_revision_private.h
@@ -0,0 +1,42 @@
+/**
+ *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.
+ */
+/*
+ * bundle_revision_private.h
+ *
+ *  \date       Feb 12, 2013
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef BUNDLE_REVISION_PRIVATE_H_
+#define BUNDLE_REVISION_PRIVATE_H_
+
+#include "bundle_revision.h"
+
+struct bundleRevision {
+	long revisionNr;
+	char *root;
+	char *location;
+	manifest_pt manifest;
+
+	array_list_pt libraryHandles;
+};
+
+#endif /* BUNDLE_REVISION_PRIVATE_H_ */


[05/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/activator.c
----------------------------------------------------------------------
diff --git a/shell/src/activator.c b/shell/src/activator.c
new file mode 100644
index 0000000..ac298d8
--- /dev/null
+++ b/shell/src/activator.c
@@ -0,0 +1,269 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Aug 13, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "shell_private.h"
+#include "bundle_activator.h"
+#include "std_commands.h"
+#include "service_tracker.h"
+#include "constants.h"
+
+#define NUMBER_OF_COMMANDS 10
+
+struct command {
+    celix_status_t (*exec)(void *handle, char *commandLine, FILE *out, FILE *err);
+    char *name;
+    char *description;
+    char *usage;
+    command_service_pt service;
+    service_registration_pt reg;
+    properties_pt props;
+};
+
+struct bundle_instance {
+	shell_service_pt shellService;
+	service_registration_pt registration;
+    service_tracker_pt tracker;
+
+    struct command std_commands[NUMBER_OF_COMMANDS];
+};
+
+typedef struct bundle_instance *bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context_ptr, void **_pptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+    bundle_instance_pt instance_ptr = NULL;
+
+    if (!_pptr || !context_ptr) {
+        status = CELIX_ENOMEM;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        instance_ptr = (bundle_instance_pt) calloc(1, sizeof(struct bundle_instance));
+        if (!instance_ptr) {
+            status = CELIX_ENOMEM;
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = shell_create(context_ptr, &instance_ptr->shellService);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        instance_ptr->std_commands[0] =
+                (struct command) {
+                        .exec = psCommand_execute,
+                        .name = "lb",
+                        .description = "list bundles.",
+                        .usage = "lb [-l | -s | -u]"
+                };
+        instance_ptr->std_commands[1] =
+                (struct command) {
+                        .exec = startCommand_execute,
+                        .name = "start",
+                        .description = "start bundle(s).",
+                        .usage = "start <id> [<id> ...]"
+                };
+        instance_ptr->std_commands[2] =
+                (struct command) {
+                        .exec = stopCommand_execute,
+                        .name = "stop",
+                        .description = "stop bundle(s).",
+                        .usage = "stop <id> [<id> ...]"
+                };
+        instance_ptr->std_commands[3] =
+                (struct command) {
+                        .exec = installCommand_execute,
+                        .name = "install",
+                        .description = "install bundle(s).",
+                        .usage = "install <file> [<file> ...]"
+                };
+        instance_ptr->std_commands[4] =
+                (struct command) {
+                        .exec = uninstallCommand_execute,
+                        .name = "uninstall",
+                        .description = "uninstall bundle(s).",
+                        .usage = "uninstall <file> [<file> ...]"
+                };
+        instance_ptr->std_commands[5] =
+                (struct command) {
+                        .exec = updateCommand_execute,
+                        .name = "update",
+                        .description = "update bundle(s).",
+                        .usage = "update <id> [<URL>]"
+                };
+        instance_ptr->std_commands[6] =
+                (struct command) {
+                        .exec = helpCommand_execute,
+                        .name = "help",
+                        .description = "display available commands and description.",
+                        .usage = "help <command>]"
+                };
+        instance_ptr->std_commands[7] =
+                (struct command) {
+                        .exec = logCommand_execute,
+                        .name = "log",
+                        .description = "print log.",
+                        .usage = "log"
+                };
+        instance_ptr->std_commands[8] =
+                (struct command) {
+                        .exec = inspectCommand_execute,
+                        .name = "inspect",
+                        .description = "inspect services and components.",
+                        .usage = "inspect (service) (capability|requirement) [<id> ...]"
+                };
+        instance_ptr->std_commands[9] =
+                (struct command) { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; /*marker for last element*/
+
+        unsigned int i = 0;
+        while (instance_ptr->std_commands[i].exec != NULL) {
+            instance_ptr->std_commands[i].props = properties_create();
+            if (!instance_ptr->std_commands[i].props) {
+                status = CELIX_BUNDLE_EXCEPTION;
+                break;
+            }
+
+            properties_set(instance_ptr->std_commands[i].props, OSGI_SHELL_COMMAND_NAME, instance_ptr->std_commands[i].name);
+            properties_set(instance_ptr->std_commands[i].props, OSGI_SHELL_COMMAND_USAGE, instance_ptr->std_commands[i].usage);
+            properties_set(instance_ptr->std_commands[i].props, OSGI_SHELL_COMMAND_DESCRIPTION, instance_ptr->std_commands[i].description);
+            properties_set(instance_ptr->std_commands[i].props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+
+            instance_ptr->std_commands[i].service = calloc(1, sizeof(*instance_ptr->std_commands[i].service));
+            if (!instance_ptr->std_commands[i].service) {
+                status = CELIX_ENOMEM;
+                break;
+            }
+
+            instance_ptr->std_commands[i].service->handle = context_ptr;
+            instance_ptr->std_commands[i].service->executeCommand = instance_ptr->std_commands[i].exec;
+
+            i += 1;
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        *_pptr = instance_ptr;
+    }
+
+
+    if (status != CELIX_SUCCESS) {
+        bundleActivator_destroy(instance_ptr, context_ptr);
+    }
+
+	return status;
+}
+
+celix_status_t bundleActivator_start(void *_ptr, bundle_context_pt context_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bundle_instance_pt instance_ptr  = (bundle_instance_pt) _ptr;
+
+    if (!instance_ptr || !context_ptr) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        properties_pt props = properties_create();
+        properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+        status = bundleContext_registerService(context_ptr, (char *) OSGI_SHELL_SERVICE_NAME, instance_ptr->shellService, props, &instance_ptr->registration);
+    }
+
+	if (status == CELIX_SUCCESS) {
+        service_tracker_customizer_pt cust = NULL;
+        serviceTrackerCustomizer_create(instance_ptr->shellService->shell, NULL, (void *)shell_addCommand, NULL, (void *)shell_removeCommand, &cust);
+        serviceTracker_create(context_ptr, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, cust, &instance_ptr->tracker);
+        serviceTracker_open(instance_ptr->tracker);
+    }
+
+
+    if (status == CELIX_SUCCESS) {
+        for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
+            status = bundleContext_registerService(context_ptr, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME,
+                                                   instance_ptr->std_commands[i].service,
+                                                   instance_ptr->std_commands[i].props,
+                                                   &instance_ptr->std_commands[i].reg);
+            if (status != CELIX_SUCCESS) {
+                break;
+            }
+
+        }
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void *_ptr, bundle_context_pt context_ptr) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
+
+    if (instance_ptr) {
+        for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
+            if (instance_ptr->std_commands[i].reg != NULL) {
+                status = serviceRegistration_unregister(instance_ptr->std_commands[i].reg);
+                instance_ptr->std_commands[i].reg = NULL;
+                instance_ptr->std_commands[i].props = NULL;
+            }
+        }
+
+        if (instance_ptr->tracker != NULL) {
+            serviceTracker_close(instance_ptr->tracker);
+        }
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    return status;
+}
+
+celix_status_t bundleActivator_destroy(void *_ptr, bundle_context_pt __attribute__((__unused__)) context_ptr) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
+
+    if (instance_ptr) {
+        serviceRegistration_unregister(instance_ptr->registration);
+
+        for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
+            free(instance_ptr->std_commands[i].service);
+        }
+
+        shell_destroy(&instance_ptr->shellService);
+
+        if (instance_ptr->tracker != NULL) {
+            serviceTracker_destroy(instance_ptr->tracker);
+        }
+
+        free(instance_ptr);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/help_command.c
----------------------------------------------------------------------
diff --git a/shell/src/help_command.c b/shell/src/help_command.c
new file mode 100644
index 0000000..48615ae
--- /dev/null
+++ b/shell/src/help_command.c
@@ -0,0 +1,112 @@
+/**
+ *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.
+ */
+/*
+ * help_command.c
+ *
+ *  \date       Aug 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "array_list.h"
+#include "bundle_context.h"
+#include "shell.h"
+#include "std_commands.h"
+
+celix_status_t helpCommand_execute(void *_ptr, char *line_str, FILE *out_ptr, FILE *err_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bundle_context_pt context_ptr = _ptr;
+	service_reference_pt shell_service_reference_ptr = NULL;
+	shell_service_pt shell_ptr = NULL;
+
+	if (!context_ptr || !line_str || !out_ptr || !err_ptr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getServiceReference(context_ptr, (char *) OSGI_SHELL_SERVICE_NAME, &shell_service_reference_ptr);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getService(context_ptr, shell_service_reference_ptr, (void **) &shell_ptr);
+	}
+
+	if (status == CELIX_SUCCESS) {
+        uint32_t out_len = 256;
+        char *sub = NULL;
+        char *save_ptr = NULL;
+        char out_str[out_len];
+
+        memset(out_str, 0, sizeof(out_str));
+
+        strtok_r(line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+        sub = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+
+        if (sub == NULL) {
+            unsigned int i;
+            array_list_pt commands = NULL;
+
+            status = shell_ptr->getCommands(shell_ptr->shell, &commands);
+            for (i = 0; i < arrayList_size(commands); i++) {
+                char *name = arrayList_get(commands, i);
+                fprintf(out_ptr, "%s\n", name);
+            }
+            fprintf(out_ptr, "\nUse 'help <command-name>' for more information.\n");
+            arrayList_destroy(commands);
+        } else {
+            celix_status_t sub_status_desc;
+            celix_status_t sub_status_usage;
+            int i;
+            array_list_pt commands = NULL;
+            shell_ptr->getCommands(shell_ptr->shell, &commands);
+            for (i = 0; i < arrayList_size(commands); i++) {
+                char *name = arrayList_get(commands, i);
+                if (strcmp(sub, name) == 0) {
+                    char *usage_str = NULL;
+                    char *desc_str = NULL;
+
+                    sub_status_desc = shell_ptr->getCommandDescription(shell_ptr->shell, name, &desc_str);
+                    sub_status_usage = shell_ptr->getCommandUsage(shell_ptr->shell, name, &usage_str);
+
+                    if (sub_status_usage == CELIX_SUCCESS && sub_status_desc == CELIX_SUCCESS) {
+                        fprintf(out_ptr, "Command     : %s\n", name);
+                        fprintf(out_ptr, "Usage       : %s\n", usage_str == NULL ? "" : usage_str);
+                        fprintf(out_ptr, "Description : %s\n", desc_str == NULL ? "" : desc_str);
+                    } else {
+                        fprintf(err_ptr, "Error retreiving help info for command '%s'\n", sub);
+                    }
+
+                    if (sub_status_desc != CELIX_SUCCESS && status == CELIX_SUCCESS) {
+                        status = sub_status_desc;
+                    }
+                    if (sub_status_usage != CELIX_SUCCESS && status == CELIX_SUCCESS) {
+                        status = sub_status_usage;
+                    }
+                }
+            }
+            arrayList_destroy(commands);
+        }
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/inspect_command.c
----------------------------------------------------------------------
diff --git a/shell/src/inspect_command.c b/shell/src/inspect_command.c
new file mode 100644
index 0000000..cb93e9c
--- /dev/null
+++ b/shell/src/inspect_command.c
@@ -0,0 +1,277 @@
+/**
+ *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.
+ */
+/*
+ * inspect_command.c
+ *
+ *  \date       Oct 13, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "array_list.h"
+#include "bundle_context.h"
+
+#include "std_commands.h"
+
+#define SERVICE_TYPE "service"
+#define CAPABILITY "capability"
+#define REQUIREMENT "requirement"
+
+celix_status_t inspectCommand_printExportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream);
+celix_status_t inspectCommand_printImportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream);
+
+celix_status_t inspectCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	bundle_context_pt context = handle;
+
+	char *token;
+	strtok_r(commandline, " ", &token);
+	char *type = strtok_r(NULL, " ", &token);
+	if (type != NULL) {
+		char *direction = strtok_r(NULL, " ", &token);
+		if (direction != NULL) {
+			array_list_pt ids = NULL;
+			char *id = strtok_r(NULL, " ", &token);
+
+			arrayList_create(&ids);
+			while (id != NULL) {
+				arrayList_add(ids, id);
+				id = strtok_r(NULL, " ", &token);
+			}
+
+			if (strcmp(type, SERVICE_TYPE) == 0) {
+				if (strcmp(direction, CAPABILITY) == 0) {
+					status = inspectCommand_printExportedServices(context, ids, outStream, errStream);
+					if (status != CELIX_SUCCESS) {
+						fprintf(errStream, "INSPECT: Error\n");
+					}
+				} else if (strcmp(direction, REQUIREMENT) == 0) {
+                    status = inspectCommand_printImportedServices(context, ids, outStream, errStream);
+                    if (status != CELIX_SUCCESS) {
+						fprintf(errStream, "INSPECT: Error\n");
+                    }
+				} else {
+					fprintf(errStream, "INSPECT: Invalid argument\n");
+				}
+			} else {
+				fprintf(errStream, "INSPECT: Invalid argument\n");
+			}
+			arrayList_destroy(ids);
+		} else {
+			fprintf(errStream, "INSPECT: Too few arguments\n");
+		}
+	} else {
+		fprintf(errStream, "INSPECT: Too few arguments\n");
+	}
+	return status;
+}
+
+celix_status_t inspectCommand_printExportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream) {
+	celix_status_t status = CELIX_SUCCESS;
+	array_list_pt bundles = NULL;
+
+	if (arrayList_isEmpty(ids)) {
+		status = bundleContext_getBundles(context, &bundles);
+	} else {
+		unsigned int i;
+
+		arrayList_create(&bundles);
+		for (i = 0; i < arrayList_size(ids); i++) {
+			char *idStr = (char *) arrayList_get(ids, i);
+			long id = atol(idStr);
+			bundle_pt b = NULL;
+			celix_status_t st = bundleContext_getBundleById(context, id, &b);
+			if (st == CELIX_SUCCESS) {
+				arrayList_add(bundles, b);
+			} else {
+				fprintf(outStream, "INSPECT: Invalid bundle ID: %ld\n", id);
+			}
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		unsigned int i = 0;
+		for (i = 0; i < arrayList_size(bundles); i++) {
+			bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
+
+			if (i > 0) {
+				fprintf(outStream, "\n");
+			}
+
+			if (bundle != NULL) {
+				array_list_pt refs = NULL;
+
+				if (bundle_getRegisteredServices(bundle, &refs) == CELIX_SUCCESS) {
+					module_pt module = NULL;
+					const char * name = NULL;
+					status = bundle_getCurrentModule(bundle, &module);
+					if (status == CELIX_SUCCESS) {
+						status = module_getSymbolicName(module, &name);
+						if (status == CELIX_SUCCESS) {
+							fprintf(outStream, "%s provides services:\n", name);
+							fprintf(outStream, "==============\n");
+
+							if (refs == NULL || arrayList_size(refs) == 0) {
+								fprintf(outStream, "Nothing\n");
+							} else {
+								unsigned int j = 0;
+								for (j = 0; j < arrayList_size(refs); j++) {
+									service_reference_pt ref = (service_reference_pt) arrayList_get(refs, j);
+									unsigned int size = 0;
+									char **keys;
+
+									serviceReference_getPropertyKeys(ref, &keys, &size);
+									for (int k = 0; k < size; k++) {
+									    char *key = keys[k];
+									    const char *value = NULL;
+									    serviceReference_getProperty(ref, key, &value);
+
+										fprintf(outStream, "%s = %s\n", key, value);
+									}
+
+									free(keys);
+
+//									objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
+//									sprintf(line, "ObjectClass = %s\n", objectClass);
+									if ((j + 1) < arrayList_size(refs)) {
+										fprintf(outStream, "----\n");
+									}
+								}
+							}
+						}
+					}
+				}
+
+				if(refs!=NULL){
+					arrayList_destroy(refs);
+				}
+			}
+		}
+	}
+
+	if (bundles != NULL) {
+	    arrayList_destroy(bundles);
+	}
+
+	return status;
+}
+
+celix_status_t inspectCommand_printImportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream) {
+    celix_status_t status = CELIX_SUCCESS;
+    array_list_pt bundles = NULL;
+
+    if (arrayList_isEmpty(ids)) {
+        status = bundleContext_getBundles(context, &bundles);
+    } else {
+        unsigned int i;
+
+        arrayList_create(&bundles);
+        for (i = 0; i < arrayList_size(ids); i++) {
+            char *idStr = (char *) arrayList_get(ids, i);
+            long id = atol(idStr);
+            bundle_pt b = NULL;
+            celix_status_t st = bundleContext_getBundleById(context, id, &b);
+            if (st == CELIX_SUCCESS) {
+                arrayList_add(bundles, b);
+            } else {
+				fprintf(outStream, "INSPECT: Invalid bundle ID: %ld\n", id);
+            }
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        unsigned int i = 0;
+        for (i = 0; i < arrayList_size(bundles); i++) {
+            bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
+
+            if (i > 0) {
+				fprintf(outStream, "\n");
+            }
+
+            if (bundle != NULL) {
+                array_list_pt refs = NULL;
+
+                if (bundle_getServicesInUse(bundle, &refs) == CELIX_SUCCESS) {
+                    module_pt module = NULL;
+                    const char * name = NULL;
+                    status = bundle_getCurrentModule(bundle, &module);
+                    if (status == CELIX_SUCCESS) {
+                        status = module_getSymbolicName(module, &name);
+                        if (status == CELIX_SUCCESS) {
+							fprintf(outStream, "%s requires services:\n", name);
+							fprintf(outStream, "==============\n");
+
+                            if (refs == NULL || arrayList_size(refs) == 0) {
+								fprintf(outStream, "Nothing\n");
+                            } else {
+                                unsigned int j = 0;
+                                for (j = 0; j < arrayList_size(refs); j++) {
+                                    service_reference_pt ref = (service_reference_pt) arrayList_get(refs, j);
+                                    bundle_pt usedBundle = NULL;
+                                    module_pt usedModule = NULL;
+                                    const char *usedSymbolicName = NULL;
+                                    long usedBundleId;
+
+                                    serviceReference_getBundle(ref, &usedBundle);
+                                    bundle_getBundleId(usedBundle, &usedBundleId);
+                                    bundle_getCurrentModule(usedBundle, &usedModule);
+                                    module_getSymbolicName(usedModule, &usedSymbolicName);
+
+									fprintf(outStream, "%s [%ld]\n", usedSymbolicName, usedBundleId);
+
+                                    unsigned int size = 0;
+                                    char **keys;
+
+                                    serviceReference_getPropertyKeys(ref, &keys, &size);
+                                    for (int k = 0; k < size; k++) {
+                                        char *key = keys[k];
+                                        const char *value = NULL;
+                                        serviceReference_getProperty(ref, key, &value);
+
+										fprintf(outStream, "%s = %s\n", key, value);
+                                    }
+                                    free(keys);
+
+//                                  objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
+//                                  sprintf(line, "ObjectClass = %s\n", objectClass);
+                                    if ((j + 1) < arrayList_size(refs)) {
+										fprintf(outStream, "----\n");
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+
+                if(refs!=NULL){
+                	arrayList_destroy(refs);
+                }
+            }
+        }
+    }
+
+    arrayList_destroy(bundles);
+
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/install_command.c
----------------------------------------------------------------------
diff --git a/shell/src/install_command.c b/shell/src/install_command.c
new file mode 100644
index 0000000..067ba2b
--- /dev/null
+++ b/shell/src/install_command.c
@@ -0,0 +1,76 @@
+/**
+ *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.
+ */
+/*
+ * install_command.c
+ *
+ *  \date       Apr 4, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "array_list.h"
+#include "bundle_context.h"
+
+void installCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
+	bundle_context_pt context = handle;
+
+	char delims[] = " ";
+	char * sub = NULL;
+	char *save_ptr = NULL;
+	char info[256];
+
+	// ignore the command
+	sub = strtok_r(line, delims, &save_ptr);
+	sub = strtok_r(NULL, delims, &save_ptr);
+	
+	if (sub == NULL) {
+		fprintf(errStream, "Incorrect number of arguments.\n");
+	} else {
+		info[0] = '\0';
+		while (sub != NULL) {
+			bundle_pt bundle = NULL;
+			bundleContext_installBundle(context, sub, &bundle);
+			if (bundle != NULL) {
+				long id;
+				bundle_archive_pt archive = NULL;
+				char bundleId[sizeof(id) + 1];
+
+				if (strlen(info) > 0) {
+					strcat(info, ", ");
+				}
+				bundle_getArchive(bundle, &archive);
+				bundleArchive_getId(archive, &id);
+				sprintf(bundleId, "%ld", id);
+				strcat(info, bundleId);
+			}
+			sub = strtok_r(NULL, delims, &save_ptr);
+		}
+		if (strchr(info, ',') != NULL) {
+			fprintf(outStream, "Bundle IDs: ");
+			fprintf(outStream, "%s", info);
+			fprintf(outStream, "\n");
+		} else if (strlen(info) > 0) {
+			fprintf(outStream, "Bundle ID: ");
+			fprintf(outStream, "%s", info);
+			fprintf(outStream, "\n");
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/lb_command.c
----------------------------------------------------------------------
diff --git a/shell/src/lb_command.c b/shell/src/lb_command.c
new file mode 100644
index 0000000..d0504f6
--- /dev/null
+++ b/shell/src/lb_command.c
@@ -0,0 +1,205 @@
+/**
+ *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.
+ */
+/*
+ * std_shell_commands.c
+ *
+ *  \date       March 27, 2014
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "array_list.h"
+#include "bundle_context.h"
+#include "std_commands.h"
+#include "shell_constants.h"
+
+static const char * const HEAD_COLOR = "\033[4m"; //underline
+static const char * const EVEN_COLOR = "\033[1m"; //bold
+static const char * const ODD_COLOR = "\033[3m";  //italic
+static const char * const END_COLOR = "\033[0m";
+
+static char * psCommand_stateString(bundle_state_e state); 
+
+celix_status_t psCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
+    celix_status_t status = CELIX_SUCCESS;
+    bundle_context_t* ctx = _ptr;
+
+    const char* config = NULL;
+    bundleContext_getPropertyWithDefault(ctx, SHELL_USE_ANSI_COLORS, SHELL_USE_ANSI_COLORS_DEFAULT_VALUE, &config);
+    bool useColors = config != NULL && strncmp("true", config, 5) == 0;
+
+    bundle_context_pt context_ptr = _ptr;
+    array_list_pt bundles_ptr     = NULL;
+
+    bool show_location        = false;
+    bool show_symbolic_name   = false;
+    bool show_update_location = false;
+    char *message_str         = "Name";
+
+    if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = bundleContext_getBundles(context_ptr, &bundles_ptr);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        char *sub_str = NULL;
+        char *save_ptr = NULL;
+
+        strtok_r(command_line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+        sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+        while (sub_str != NULL) {
+            if (strcmp(sub_str, "-l") == 0) {
+                show_location = true;
+                message_str = "Location";
+            } else if (strcmp(sub_str, "-s") == 0) {
+                show_symbolic_name = true;
+                message_str = "Symbolic name";
+            } else if (strcmp(sub_str, "-u") == 0) {
+                show_update_location = true;
+                message_str = "Update location";
+            }
+            sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+        }
+
+	const char* startColor = "";
+	const char* endColor = "";
+	if (useColors) {
+		startColor = HEAD_COLOR;
+		endColor = END_COLOR;
+	} 
+        fprintf(out_ptr, "%s  %-5s %-12s %s%s\n", startColor, "ID", "State", message_str, endColor);
+
+        unsigned int size = arrayList_size(bundles_ptr);
+
+        bundle_pt bundles_array_ptr[size];
+
+        for (unsigned int i = 0; i < size; i++) {
+            bundles_array_ptr[i] = arrayList_get(bundles_ptr, i);
+        }
+
+        for (unsigned int i = 0; i < size - 1; i++) {
+            for (unsigned int j = i + 1; j < size; j++) {
+                bundle_pt first_ptr = bundles_array_ptr[i];
+                bundle_pt second_ptr = bundles_array_ptr[j];
+
+                bundle_archive_pt first_archive_ptr = NULL;
+                bundle_archive_pt second_archive_ptr = NULL;
+
+                long first_id;
+                long second_id;
+
+                bundle_getArchive(first_ptr, &first_archive_ptr);
+                bundle_getArchive(second_ptr, &second_archive_ptr);
+
+                bundleArchive_getId(first_archive_ptr, &first_id);
+                bundleArchive_getId(second_archive_ptr, &second_id);
+
+                if (first_id > second_id) {
+                    bundle_pt temp_ptr = bundles_array_ptr[i];
+                    bundles_array_ptr[i] = bundles_array_ptr[j];
+                    bundles_array_ptr[j] = temp_ptr;
+                }
+            }
+        }
+
+        for (unsigned int i = 0; i < size; i++) {
+            celix_status_t sub_status;
+
+            bundle_pt bundle_ptr = bundles_array_ptr[i];
+
+            bundle_archive_pt archive_ptr = NULL;
+            long id = 0;
+            bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
+            const char *state_str = NULL;
+            module_pt module_ptr = NULL;
+            const char *name_str = NULL;
+
+            sub_status = bundle_getArchive(bundle_ptr, &archive_ptr);
+            if (sub_status == CELIX_SUCCESS) {
+                sub_status = bundleArchive_getId(archive_ptr, &id);
+            }
+
+            if (sub_status == CELIX_SUCCESS) {
+                sub_status = bundle_getState(bundle_ptr, &state);
+            }
+
+            if (sub_status == CELIX_SUCCESS) {
+                state_str = psCommand_stateString(state);
+
+                sub_status = bundle_getCurrentModule(bundle_ptr, &module_ptr);
+            }
+
+            if (sub_status == CELIX_SUCCESS) {
+                sub_status = module_getSymbolicName(module_ptr, &name_str);
+            }
+
+            if (sub_status == CELIX_SUCCESS) {
+                if (show_location) {
+                    sub_status = bundleArchive_getLocation(archive_ptr, &name_str);
+                } else if (show_symbolic_name) {
+                    // do nothing
+                } else if (show_update_location) {
+                    sub_status = bundleArchive_getLocation(archive_ptr, &name_str);
+                }
+            }
+
+            if (sub_status == CELIX_SUCCESS) {
+		startColor = "";
+		endColor = "";
+                if (useColors) {
+                    startColor = i % 2 == 0 ? EVEN_COLOR : ODD_COLOR;
+                    endColor = END_COLOR;
+                } 
+		fprintf(out_ptr, "%s  %-5ld %-12s %s%s\n", startColor, id, state_str, name_str, endColor);
+
+            }
+
+            if (sub_status != CELIX_SUCCESS) {
+                status = sub_status;
+                break;
+            }
+        }
+
+        arrayList_destroy(bundles_ptr);
+    }
+
+    return status;
+}
+
+static char * psCommand_stateString(bundle_state_e state) {
+    switch (state) {
+        case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
+            return "Active      ";
+        case OSGI_FRAMEWORK_BUNDLE_INSTALLED:
+            return "Installed   ";
+        case OSGI_FRAMEWORK_BUNDLE_RESOLVED:
+            return "Resolved    ";
+        case OSGI_FRAMEWORK_BUNDLE_STARTING:
+            return "Starting    ";
+        case OSGI_FRAMEWORK_BUNDLE_STOPPING:
+            return "Stopping    ";
+        default:
+            return "Unknown     ";
+    }
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/log_command.c
----------------------------------------------------------------------
diff --git a/shell/src/log_command.c b/shell/src/log_command.c
new file mode 100644
index 0000000..8b0244a
--- /dev/null
+++ b/shell/src/log_command.c
@@ -0,0 +1,94 @@
+/**
+ *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.
+ */
+/*
+ * log_command.c
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "bundle_context.h"
+#include "log_reader_service.h"
+#include "linked_list_iterator.h"
+
+celix_status_t logCommand_levelAsString(bundle_context_pt context, log_level_t level, char **string);
+
+void logCommand_execute(bundle_context_pt context, char *line, FILE *outStream, FILE *errStream) {
+    celix_status_t status;
+    service_reference_pt readerService = NULL;
+
+    status = bundleContext_getServiceReference(context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, &readerService);
+    if (status != CELIX_SUCCESS || readerService != NULL) {
+        linked_list_pt list = NULL;
+        linked_list_iterator_pt iter = NULL;
+        log_reader_service_pt reader = NULL;
+
+
+		bundleContext_getService(context, readerService, (void **) &reader);
+		reader->getLog(reader->reader, &list);
+		iter = linkedListIterator_create(list, 0);
+		while (linkedListIterator_hasNext(iter)) {
+			log_entry_pt entry = linkedListIterator_next(iter);
+			char time[20];
+			char *level = NULL;
+			char errorString[256];
+
+            strftime(time, 20, "%Y-%m-%d %H:%M:%S", localtime(&entry->time));
+            logCommand_levelAsString(context, entry->level, &level);
+
+			if (entry->errorCode > 0) {
+				celix_strerror(entry->errorCode, errorString, 256);
+				fprintf(outStream, "%s - Bundle: %s - %s - %d %s\n", time, entry->bundleSymbolicName, entry->message, entry->errorCode, errorString);
+			} else {
+				fprintf(outStream, "%s - Bundle: %s - %s\n", time, entry->bundleSymbolicName, entry->message);
+			}
+		}
+		linkedListIterator_destroy(iter);
+		linkedList_destroy(list);
+		bool result = true;
+		bundleContext_ungetService(context, readerService, &result);
+        bundleContext_ungetServiceReference(context, readerService);
+    } else {
+		fprintf(outStream, "No log reader available\n");
+    }
+}
+
+celix_status_t logCommand_levelAsString(bundle_context_pt context, log_level_t level, char **string) {
+	switch (level) {
+	case OSGI_LOGSERVICE_ERROR:
+		*string = "ERROR";
+		break;
+	case OSGI_LOGSERVICE_WARNING:
+		*string = "WARNING";
+		break;
+	case OSGI_LOGSERVICE_INFO:
+		*string = "INFO";
+		break;
+	case OSGI_LOGSERVICE_DEBUG:
+	default:
+		*string = "DEBUG";
+		break;
+	}
+
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/shell.c
----------------------------------------------------------------------
diff --git a/shell/src/shell.c b/shell/src/shell.c
new file mode 100644
index 0000000..ac8603e
--- /dev/null
+++ b/shell/src/shell.c
@@ -0,0 +1,305 @@
+/**
+ *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.
+ */
+/*
+ * shell.c
+ *
+ *  \date       Aug 13, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <log_helper.h>
+
+#include "celix_errno.h"
+
+#include "shell_private.h"
+
+
+#include "utils.h"
+
+celix_status_t shell_getCommands(shell_pt shell_ptr, array_list_pt *commands_ptr);
+celix_status_t shell_getCommandUsage(shell_pt shell_ptr, char *command_name_str, char **usage_pstr);
+celix_status_t shell_getCommandDescription(shell_pt shell_ptr, char *command_name_str, char **command_description_pstr);
+
+celix_status_t shell_create(bundle_context_pt context_ptr, shell_service_pt *shell_service_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!context_ptr || !shell_service_ptr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*shell_service_ptr =  calloc(1, sizeof(**shell_service_ptr));
+		if (!*shell_service_ptr) {
+			status = CELIX_ENOMEM;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		(*shell_service_ptr)->shell = calloc(1, sizeof(*(*shell_service_ptr)->shell));
+		if (!(*shell_service_ptr)->shell) {
+			status = CELIX_ENOMEM;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		(*shell_service_ptr)->shell->bundle_context_ptr = context_ptr;
+		(*shell_service_ptr)->shell->command_name_map_ptr = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+		(*shell_service_ptr)->shell->command_reference_map_ptr = hashMap_create(NULL, NULL, NULL, NULL);
+
+		(*shell_service_ptr)->getCommands = shell_getCommands;
+		(*shell_service_ptr)->getCommandDescription = shell_getCommandDescription;
+		(*shell_service_ptr)->getCommandUsage = shell_getCommandUsage;
+		(*shell_service_ptr)->getCommandReference = shell_getCommandReference;
+		(*shell_service_ptr)->executeCommand = shell_executeCommand;
+
+        status = logHelper_create(context_ptr, &(*shell_service_ptr)->shell->logHelper);
+	}
+
+	if (status != CELIX_SUCCESS) {
+		shell_destroy(shell_service_ptr);
+	}
+
+	return status;
+}
+
+celix_status_t shell_destroy(shell_service_pt *shell_service_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!shell_service_ptr || !*shell_service_ptr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		if ((*shell_service_ptr)->shell) {
+			if ((*shell_service_ptr)->shell->command_name_map_ptr) {
+				hashMap_destroy((*shell_service_ptr)->shell->command_name_map_ptr, false, false);
+			}
+			if ((*shell_service_ptr)->shell->command_reference_map_ptr) {
+				hashMap_destroy((*shell_service_ptr)->shell->command_reference_map_ptr, false, false);
+			}
+			if ((*shell_service_ptr)->shell->logHelper) {
+				logHelper_destroy(&((*shell_service_ptr)->shell->logHelper));
+			}
+			free((*shell_service_ptr)->shell);
+			(*shell_service_ptr)->shell = NULL;
+		}
+		free(*shell_service_ptr);
+		*shell_service_ptr = NULL;
+	}
+
+	return status;
+}
+
+celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc) {
+    celix_status_t status = CELIX_SUCCESS;
+    command_service_pt command_ptr = NULL;
+    const char *name_str = NULL;
+
+    if (!shell_ptr || !reference_ptr) {
+        return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        command_ptr = svc;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
+        if (!name_str) {
+            logHelper_log(shell_ptr->logHelper, OSGI_LOGSERVICE_ERROR, "Command service must contain a 'command.name' property!");
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        hashMap_put(shell_ptr->command_name_map_ptr, (char *)name_str, command_ptr);
+        hashMap_put(shell_ptr->command_reference_map_ptr, reference_ptr, command_ptr);
+    }
+
+    if (status != CELIX_SUCCESS) {
+        shell_removeCommand(shell_ptr, reference_ptr, svc);
+        char err[32];
+        celix_strerror(status, err, 32);
+        logHelper_log(shell_ptr->logHelper, OSGI_LOGSERVICE_ERROR, "Could not add command, got error %s\n", err);
+    }
+
+    return status;
+}
+
+celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    command_service_pt command_ptr = NULL;
+    const char *name_str = NULL;
+
+    if (!shell_ptr || !reference_ptr) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        command_ptr = hashMap_remove(shell_ptr->command_reference_map_ptr, reference_ptr);
+        if (!command_ptr) {
+            status = CELIX_ILLEGAL_ARGUMENT;
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
+        if (!name_str) {
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        hashMap_remove(shell_ptr->command_name_map_ptr, (char *)name_str);
+    }
+
+    return status;
+}
+
+celix_status_t shell_getCommands(shell_pt shell_ptr, array_list_pt *commands_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	hash_map_iterator_pt iter = NULL;
+
+	if (!shell_ptr || !commands_ptr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		iter = hashMapIterator_create(shell_ptr->command_name_map_ptr);
+		if (!iter) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		arrayList_create(commands_ptr);
+		while (hashMapIterator_hasNext(iter)) {
+			char *name_str = hashMapIterator_nextKey(iter);
+			arrayList_add(*commands_ptr, name_str);
+		}
+		hashMapIterator_destroy(iter);
+	}
+
+	return status;
+}
+
+
+celix_status_t shell_getCommandUsage(shell_pt shell_ptr, char *command_name_str, char **usage_pstr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	service_reference_pt reference = NULL;
+
+	if (!shell_ptr || !command_name_str || !usage_pstr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = shell_getCommandReference(shell_ptr, command_name_str, &reference);
+		if (!reference) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = serviceReference_getProperty(reference, "command.usage", (const char**)usage_pstr);
+	}
+
+	return status;
+}
+
+celix_status_t shell_getCommandDescription(shell_pt shell_ptr, char *command_name_str, char **command_description_pstr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	service_reference_pt reference = NULL;
+
+	if (!shell_ptr || !command_name_str || !command_description_pstr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = shell_getCommandReference(shell_ptr, command_name_str, &reference);
+		if (!reference) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		serviceReference_getProperty(reference, "command.description", (const char**)command_description_pstr);
+	}
+
+	return status;
+}
+
+celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!shell_ptr || !command_name_str || !command_reference_ptr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*command_reference_ptr = NULL;
+		hash_map_iterator_pt iter = hashMapIterator_create(shell_ptr->command_reference_map_ptr);
+		while (hashMapIterator_hasNext(iter)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+			service_reference_pt reference = hashMapEntry_getKey(entry);
+			const char *name_str = NULL;
+			serviceReference_getProperty(reference, "command.name", &name_str);
+			if (strcmp(name_str, command_name_str) == 0) {
+				*command_reference_ptr = (service_reference_pt) hashMapEntry_getKey(entry);
+				break;
+			}
+		}
+		hashMapIterator_destroy(iter);
+	}
+
+	return status;
+}
+
+celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, FILE *out, FILE *err) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	command_service_pt command_ptr = NULL;
+
+	if (!shell_ptr || !command_line_str || !out || !err) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		size_t pos = strcspn(command_line_str, " ");
+
+		char *command_name_str = (pos != strlen(command_line_str)) ? strndup(command_line_str, pos) : strdup(command_line_str);
+		command_ptr = hashMap_get(shell_ptr->command_name_map_ptr, command_name_str);
+		free(command_name_str);
+		if (!command_ptr) {
+			fprintf(err, "No such command\n");
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = command_ptr->executeCommand(command_ptr->handle, command_line_str, out, err);
+	}
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/shell_private.h
----------------------------------------------------------------------
diff --git a/shell/src/shell_private.h b/shell/src/shell_private.h
new file mode 100644
index 0000000..7270fa2
--- /dev/null
+++ b/shell/src/shell_private.h
@@ -0,0 +1,51 @@
+/**
+ *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.
+ */
+/*
+ * shell_private.h
+ *
+ *  \date       Aug 13, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef SHELL_PRIVATE_H_
+#define SHELL_PRIVATE_H_
+
+#include "bundle_context.h"
+#include "shell.h"
+#include "hash_map.h"
+#include "command.h"
+#include "log_helper.h"
+
+struct shell {
+	bundle_context_pt bundle_context_ptr;
+	hash_map_pt command_reference_map_ptr;
+	hash_map_pt command_name_map_ptr;
+	log_helper_pt logHelper;
+};
+
+celix_status_t shell_create(bundle_context_pt context_ptr, shell_service_pt *shell_service_ptr);
+celix_status_t shell_destroy(shell_service_pt *shell_service_ptr);
+celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc);
+celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc);
+
+celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
+celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, FILE *out, FILE *err);
+
+#endif /* SHELL_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/start_command.c
----------------------------------------------------------------------
diff --git a/shell/src/start_command.c b/shell/src/start_command.c
new file mode 100644
index 0000000..f43699a
--- /dev/null
+++ b/shell/src/start_command.c
@@ -0,0 +1,84 @@
+/**
+ *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.
+ */
+/*
+ * start_command.c
+ *
+ *  \date       Aug 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "std_commands.h"
+#include "bundle_context.h"
+
+celix_status_t startCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    bundle_context_pt context_ptr = _ptr;
+
+    if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        char *sub_str = NULL;
+        char *save_ptr = NULL;
+
+        strtok_r(command_line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+        sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+
+        if (sub_str == NULL) {
+            fprintf(out_ptr, "Incorrect number of arguments.\n");
+        } else {
+            while (sub_str != NULL) {
+                celix_status_t sub_status = CELIX_SUCCESS;
+
+                bundle_pt bundle_ptr = NULL;
+
+                char *end_str = NULL;
+                long id = strtol(sub_str, &end_str, 10);
+                if (*end_str) {
+                    sub_status = CELIX_ILLEGAL_ARGUMENT;
+                    fprintf(err_ptr, "Bundle id '%s' is invalid, problem at %s\n", sub_str, end_str);
+                }
+
+                if (sub_status == CELIX_SUCCESS) {
+                    sub_status = bundleContext_getBundleById(context_ptr, id, &bundle_ptr);
+                }
+
+                if (sub_status == CELIX_SUCCESS) {
+                    bundle_startWithOptions(bundle_ptr, 0);
+                }
+
+                if (sub_status != CELIX_SUCCESS) {
+                    status = sub_status;
+                    break;
+                }
+
+                sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+            }
+        }
+
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/std_commands.h
----------------------------------------------------------------------
diff --git a/shell/src/std_commands.h b/shell/src/std_commands.h
new file mode 100644
index 0000000..ef7f37e
--- /dev/null
+++ b/shell/src/std_commands.h
@@ -0,0 +1,44 @@
+/**
+ *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.
+ */
+/*
+ * std_commands.h
+ *
+ *  \date       March 27, 2014
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef __STD_COMMANDS_H_
+#define __STD_COMMANDS_H_
+
+#include "celix_errno.h"
+
+#define OSGI_SHELL_COMMAND_SEPARATOR " "
+
+celix_status_t psCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr);
+celix_status_t startCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr);
+celix_status_t stopCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+celix_status_t installCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+celix_status_t uninstallCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+celix_status_t updateCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+celix_status_t logCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+celix_status_t inspectCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+celix_status_t helpCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/stop_command.c
----------------------------------------------------------------------
diff --git a/shell/src/stop_command.c b/shell/src/stop_command.c
new file mode 100644
index 0000000..0093c99
--- /dev/null
+++ b/shell/src/stop_command.c
@@ -0,0 +1,82 @@
+/**
+ *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.
+ */
+/*
+ * stop_command.c
+ *
+ *  \date       Aug 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "bundle_context.h"
+#include "std_commands.h"
+
+celix_status_t stopCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    bundle_context_pt context_ptr = _ptr;
+
+    if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        char *sub_str = NULL;
+        char *save_ptr = NULL;
+
+        strtok_r(command_line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+        sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+
+        if (sub_str == NULL) {
+            fprintf(out_ptr, "Incorrect number of arguments.\n");
+        } else {
+            while (sub_str != NULL) {
+                celix_status_t sub_status = CELIX_SUCCESS;
+
+                bundle_pt bundle_ptr = NULL;
+
+                char *end_str = NULL;
+                long id = strtol(sub_str, &end_str, 10);
+                if (*end_str) {
+                    sub_status = CELIX_ILLEGAL_ARGUMENT;
+                    fprintf(err_ptr, "Bundle id '%s' is invalid, problem at %s\n", sub_str, end_str);
+                }
+
+                if (sub_status == CELIX_SUCCESS) {
+                    sub_status = bundleContext_getBundleById(context_ptr, id, &bundle_ptr);
+                }
+
+                if (sub_status == CELIX_SUCCESS) {
+                    bundle_stopWithOptions(bundle_ptr, 0);
+                }
+
+                if (sub_status != CELIX_SUCCESS) {
+                    status = sub_status;
+                    break;
+                }
+
+                sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+            }
+        }
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/uninstall_command.c
----------------------------------------------------------------------
diff --git a/shell/src/uninstall_command.c b/shell/src/uninstall_command.c
new file mode 100644
index 0000000..fb30831
--- /dev/null
+++ b/shell/src/uninstall_command.c
@@ -0,0 +1,58 @@
+/**
+ *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.
+ */
+/*
+ * uninstall_command.c
+ *
+ *  \date       Aug 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "array_list.h"
+#include "bundle_context.h"
+
+celix_status_t uninstallCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
+	bundle_context_pt context = handle;
+	char delims[] = " ";
+	char * sub = NULL;
+	char *save_ptr = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+
+	sub = strtok_r(line, delims, &save_ptr);
+	sub = strtok_r(NULL, delims, &save_ptr);
+
+	if (sub == NULL) {
+		fprintf(errStream, "Incorrect number of arguments.\n");
+	} else {
+		while (sub != NULL) {
+			long id = atol(sub);
+			bundle_pt bundle = NULL;
+			status = bundleContext_getBundleById(context, id, &bundle);
+			if (status==CELIX_SUCCESS && bundle!=NULL) {
+				bundle_uninstall(bundle);
+			} else {
+				fprintf(errStream, "Bundle id is invalid.");
+			}
+			sub = strtok_r(NULL, delims, &save_ptr);
+		}
+	}
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/src/update_command.c
----------------------------------------------------------------------
diff --git a/shell/src/update_command.c b/shell/src/update_command.c
new file mode 100644
index 0000000..64999ac
--- /dev/null
+++ b/shell/src/update_command.c
@@ -0,0 +1,117 @@
+/**
+ *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.
+ */
+/*
+ * update_command.c
+ *
+ *  \date       Aug 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ *
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <curl/curl.h>
+#include <sys/stat.h>
+
+#include "array_list.h"
+#include "bundle_context.h"
+
+celix_status_t updateCommand_download(bundle_context_pt context, char * url, char **inputFile);
+size_t updateCommand_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream);
+
+void updateCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
+	bundle_context_pt context = handle;
+    bundle_pt bundle = NULL;
+	char delims[] = " ";
+	char * sub = NULL;
+	char *save_ptr = NULL;
+
+	sub = strtok_r(line, delims, &save_ptr);
+	sub = strtok_r(NULL, delims, &save_ptr);
+
+	if (sub == NULL) {
+		fprintf(errStream, "Incorrect number of arguments.\n");
+	} else {
+		long id = atol(sub);
+		celix_status_t ret = bundleContext_getBundleById(context, id, &bundle);
+		if (ret==CELIX_SUCCESS && bundle!=NULL) {
+			char inputFile[256];
+			sub = strtok_r(NULL, delims, &save_ptr);
+			inputFile[0] = '\0';
+			if (sub != NULL) {
+				char *test = inputFile;
+				printf("URL: %s\n", sub);
+
+				if (updateCommand_download(context, sub, &test) == CELIX_SUCCESS) {
+					printf("Update bundle with stream\n");
+					bundle_update(bundle, inputFile);
+				} else {
+					fprintf(errStream, "Unable to download from %s\n", sub);
+				}
+			} else {
+				bundle_update(bundle, NULL);
+			}
+		} else {
+			fprintf(errStream, "Bundle id is invalid.\n");
+		}
+	}
+}
+
+celix_status_t updateCommand_download(bundle_context_pt context, char * url, char **inputFile) {
+	CURL *curl = NULL;
+	CURLcode res = CURLE_FILE_COULDNT_READ_FILE;
+	curl = curl_easy_init();
+	if (curl) {
+		FILE *fp = NULL;
+		snprintf(*inputFile, 13,"updateXXXXXX");
+		umask(0011);
+		int fd = mkstemp(*inputFile);
+		if (fd) {
+		    fp = fopen(*inputFile, "wb+");
+		    if(fp!=NULL){
+		    	printf("Temp file: %s\n", *inputFile);
+		    	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+		    	curl_easy_setopt(curl, CURLOPT_URL, url);
+		    	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, updateCommand_writeData);
+		    	curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
+		    	//curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
+		    	//curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, updateCommand_downloadProgress);
+		    	res = curl_easy_perform(curl);
+		    	fclose(fp);
+		    }
+		    /* always cleanup */
+		    curl_easy_cleanup(curl);
+		    if(fp==NULL){
+		    	return CELIX_FILE_IO_EXCEPTION;
+		    }
+		}
+	}
+	if (res != CURLE_OK) {
+		printf("Error: %d\n", res);
+		*inputFile[0] = '\0';
+		return CELIX_ILLEGAL_STATE;
+	} else {
+		return CELIX_SUCCESS;
+	}
+}
+
+size_t updateCommand_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream) {
+    size_t written = fwrite(ptr, size, nmemb, stream);
+    return written;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell_bonjour/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell_bonjour/CMakeLists.txt b/shell_bonjour/CMakeLists.txt
index 300fef0..2276f09 100644
--- a/shell_bonjour/CMakeLists.txt
+++ b/shell_bonjour/CMakeLists.txt
@@ -26,28 +26,24 @@ if (SHELL_BONJOUR)
 	set(BUNDLE_VERSION "0.1.0")
 	set(BUNDLE_NAME "bonjour_shell")
 
-	include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-	include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
-	include_directories("${LIBXML2_INCLUDE_DIR}")
-	include_directories("private/include")
-
-	set(MEMSTREAM_SOURCES )
-	if (APPLE OR ANDROID)
-		set(MEMSTREAM_SOURCES ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/open_memstream.c  ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/fmemopen.c)
-		include_directories(${PROJECT_SOURCE_DIR}/utils/public/include/memstream)
-	endif()
 	add_bundle(bonjour_shell
-                VERSION "1.0.0"
+		VERSION "1.0.0"
 		SOURCES
 		 	private/src/activator.c
 		 	private/src/bonjour_shell.c
-			${MEMSTREAM_SOURCES}
 	)
-	
-	target_link_libraries(bonjour_shell celix_framework celix_utils ${LIBXML2_LIBRARIES} ${DNS_SD_LIB})
+	add_library(Celix::bonjour_shell ALIAS bonjour_shell)
+
+
+	target_include_directories(bonjour_shell PRIVATE
+			"${PROJECT_SOURCE_DIR}/utils/public/include"
+			"${LIBXML2_INCLUDE_DIR}"
+			private/include
+	)
+	target_link_libraries(bonjour_shell PRIVATE ${LIBXML2_LIBRARIES} ${DNS_SD_LIB} Celix::shell_api)
 
 	add_deploy("bonjour_shell_deploy" BUNDLES 
-		shell
+		Celix::shell
 		bonjour_shell
 		PROPERTIES "bonjour.shell.id=Apache Celix"
 	)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell_tui/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell_tui/CMakeLists.txt b/shell_tui/CMakeLists.txt
index 0216261..bd6b316 100644
--- a/shell_tui/CMakeLists.txt
+++ b/shell_tui/CMakeLists.txt
@@ -27,10 +27,14 @@ if (SHELL_TUI)
     		private/src/history
 	)
 	
+	target_include_directories(shell_tui PRIVATE
+			"${PROJECT_SOURCE_DIR}/utils/public/include"
+			private/include
+	)
+    target_link_libraries(shell_tui PRIVATE Celix::shell_api)
+
 	install_bundle(shell_tui)
-	
-	include_directories("private/include")
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
-    target_link_libraries(shell_tui celix_framework)
+
+	#Alias setup to match external usage
+	add_library(Celix::shell_tui ALIAS shell_tui)
 endif (SHELL_TUI)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell_tui/README.md
----------------------------------------------------------------------
diff --git a/shell_tui/README.md b/shell_tui/README.md
index a637214..8a58fcb 100644
--- a/shell_tui/README.md
+++ b/shell_tui/README.md
@@ -10,3 +10,8 @@ The Celix Shell TUI implements a textual user interface for the Celix Shell.
 - SHELL_USE_ANSI_CONTROL_SEQUENCES - Wether to use ANSI control
 sequences to support backspace, left, up, etc key commands in the
 shell tui. Default is true if a TERM environment is set else false.
+
+## Using info
+
+If the Celix Shell TUI is installed The `FindCelix.cmake` will set:
+ - The `Celix::shell_tui` bundle target if the shell_tui is installed

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index 9132f45..e0c187f 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -15,93 +15,98 @@
 # specific language governing permissions and limitations
 # under the License.
 
-celix_subproject(UTILS "Option to build the utilities library" ON)
-if (UTILS) 
-    cmake_minimum_required(VERSION 2.6)
-    
+set(MEMSTREAM_SOURCES )
+set(MEMSTREAM_INCLUDES )
+if (APPLE OR ANDROID)
+    set(MEMSTREAM_SOURCES src/memstream/open_memstream.c  src/memstream/fmemopen.c)
+    set(MEMSTREAM_INCLUDE_DIR include/memstream)
+endif()
+
+add_library(utils SHARED
+    src/array_list.c
+    src/hash_map.c
+    src/linked_list.c
+    src/linked_list_iterator.c
+    src/celix_threads.c
+    src/version.c
+    src/version_range.c
+    src/thpool.c
+    src/properties.c
+    src/utils.c
+    ${MEMSTREAM_SOURCES}
+)
+set_target_properties(utils PROPERTIES OUTPUT_NAME "celix_utils")
+
 if (ANDROID)
-    add_definitions(-DUSE_FILE32API)
+    target_compile_definitions(utils PRIVATE -DUSE_FILE32API)
 endif ()
 
-    include_directories("private/include")
-    include_directories("public/include")
-    add_library(celix_utils SHARED 
-                private/src/array_list.c
-                private/src/hash_map.c
-                private/src/linked_list.c
-                private/src/linked_list_iterator.c
-                private/src/celix_threads.c
-                private/src/version.c
-                private/src/version_range.c
-                private/src/thpool.c
-                private/src/properties.c
-                private/src/utils.c
-    )
-
-    set_target_properties(celix_utils PROPERTIES "SOVERSION" 2)
-    
-    IF(UNIX AND NOT ANDROID)
-        target_link_libraries(celix_utils m pthread)
-    ELSEIF(ANDROID)
-        target_link_libraries(celix_utils m)
-    ENDIF()
-    
-    install(TARGETS celix_utils DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework)
-    FILE(GLOB files "public/include/*.h")
-    INSTALL(FILES ${files} DESTINATION include/celix COMPONENT framework)
-    
-    celix_subproject(UTILS-TESTS "Option to build the utilities library tests" "OFF")
-
-        if (ENABLE_TESTING AND UTILS-TESTS)
-            find_package(CppUTest REQUIRED)
-
-            SET(CMAKE_SKIP_BUILD_RPATH  FALSE) 
-            SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 
-            SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/utils")
-
-
-            include_directories(${CUNIT_INCLUDE_DIRS})
-            include_directories(${CPPUTEST_INCLUDE_DIR})
-            include_directories(public/include)
-            include_directories(utils/private/include)
-            
-            add_executable(hash_map_test private/test/hash_map_test.cpp)
-            target_link_libraries(hash_map_test celix_utils ${CPPUTEST_LIBRARY} pthread)
-            
-            add_executable(array_list_test private/test/array_list_test.cpp)
-            target_link_libraries(array_list_test celix_utils ${CPPUTEST_LIBRARY} pthread)
-            
-            add_executable(celix_threads_test private/test/celix_threads_test.cpp)
-            target_link_libraries(celix_threads_test celix_utils ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} pthread)
-            add_executable(linked_list_test private/test/linked_list_test.cpp)
-            target_link_libraries(linked_list_test celix_utils ${CPPUTEST_LIBRARY} pthread)
-            
-            add_executable(thread_pool_test private/test/thread_pool_test.cpp)
-            target_link_libraries(thread_pool_test celix_utils ${CPPUTEST_LIBRARY} pthread) 
-
-            add_executable(properties_test private/test/properties_test.cpp)
-            target_link_libraries(properties_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-
-            add_executable(utils_test private/test/utils_test.cpp)
-            target_link_libraries(utils_test ${CPPUTEST_LIBRARY} celix_utils pthread)
-		
-            configure_file(private/resources-test/properties.txt ${CMAKE_BINARY_DIR}/utils/resources-test/properties.txt COPYONLY)
-
-            add_test(NAME run_array_list_test COMMAND array_list_test)
-            add_test(NAME run_hash_map_test COMMAND hash_map_test)
-            add_test(NAME run_celix_threads_test COMMAND celix_threads_test)
-            add_test(NAME run_thread_pool_test COMMAND thread_pool_test)
-            add_test(NAME run_linked_list_test COMMAND linked_list_test)
-            add_test(NAME run_properties_test COMMAND properties_test)
-            add_test(NAME run_utils_test COMMAND utils_test)
-        
-            SETUP_TARGET_FOR_COVERAGE(array_list_test array_list_test ${CMAKE_BINARY_DIR}/coverage/array_list_test/array_list_test)
-            SETUP_TARGET_FOR_COVERAGE(hash_map hash_map_test ${CMAKE_BINARY_DIR}/coverage/hash_map_test/hash_map_test)
-            SETUP_TARGET_FOR_COVERAGE(celix_threads_test celix_threads_test ${CMAKE_BINARY_DIR}/coverage/celix_threads_test/celix_threads_test)
-            SETUP_TARGET_FOR_COVERAGE(thread_pool_test thread_pool_test ${CMAKE_BINARY_DIR}/coverage/thread_pool_test/thread_pool_test)
-            SETUP_TARGET_FOR_COVERAGE(linked_list_test linked_list_test ${CMAKE_BINARY_DIR}/coverage/linked_list_test/linked_list_test)
-            SETUP_TARGET_FOR_COVERAGE(properties_test properties_test ${CMAKE_BINARY_DIR}/coverage/properties_test/properties_test)
-            SETUP_TARGET_FOR_COVERAGE(utils_test utils_test ${CMAKE_BINARY_DIR}/coverage/utils_test/utils_test)
-
-   endif(ENABLE_TESTING AND UTILS-TESTS)
-endif (UTILS)
+target_include_directories(utils PUBLIC include ${MEMSTREAM_INCLUDE_DIR})
+target_include_directories(utils PRIVATE src)
+set_target_properties(utils PROPERTIES "SOVERSION" 2)
+
+IF(UNIX AND NOT ANDROID)
+    target_link_libraries(utils PRIVATE m pthread)
+ELSEIF(ANDROID)
+    target_link_libraries(utils PRIVATE m)
+ENDIF()
+
+install(TARGETS utils DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework)
+
+#Alias setup to match external usage
+add_library(Celix::utils ALIAS utils)
+
+
+celix_subproject(UTILS-TESTS "Option to build the utilities library tests" "OFF")
+if (ENABLE_TESTING AND UTILS-TESTS)
+    find_package(CppUTest REQUIRED)
+
+    SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
+    SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+    SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/utils")
+
+
+    include_directories(${CUNIT_INCLUDE_DIRS})
+    include_directories(${CPPUTEST_INCLUDE_DIR})
+    include_directories(include)
+    include_directories(src)
+
+    add_executable(hash_map_test private/test/hash_map_test.cpp)
+    target_link_libraries(hash_map_test Celix::utils ${CPPUTEST_LIBRARY} pthread)
+
+    add_executable(array_list_test private/test/array_list_test.cpp)
+    target_link_libraries(array_list_test  Celix::utils ${CPPUTEST_LIBRARY} pthread)
+
+    add_executable(celix_threads_test private/test/celix_threads_test.cpp)
+    target_link_libraries(celix_threads_test Celix::utils ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} pthread)
+    add_executable(linked_list_test private/test/linked_list_test.cpp)
+    target_link_libraries(linked_list_test  Celix::utils ${CPPUTEST_LIBRARY} pthread)
+
+    add_executable(thread_pool_test private/test/thread_pool_test.cpp)
+    target_link_libraries(thread_pool_test  Celix::utils ${CPPUTEST_LIBRARY} pthread)
+
+    add_executable(properties_test private/test/properties_test.cpp)
+    target_link_libraries(properties_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY}  Celix::utils pthread)
+
+    add_executable(utils_test private/test/utils_test.cpp)
+    target_link_libraries(utils_test ${CPPUTEST_LIBRARY}  Celix::utils pthread)
+
+    configure_file(private/resources-test/properties.txt ${CMAKE_BINARY_DIR}/utils/resources-test/properties.txt COPYONLY)
+
+    add_test(NAME run_array_list_test COMMAND array_list_test)
+    add_test(NAME run_hash_map_test COMMAND hash_map_test)
+    add_test(NAME run_celix_threads_test COMMAND celix_threads_test)
+    add_test(NAME run_thread_pool_test COMMAND thread_pool_test)
+    add_test(NAME run_linked_list_test COMMAND linked_list_test)
+    add_test(NAME run_properties_test COMMAND properties_test)
+    add_test(NAME run_utils_test COMMAND utils_test)
+
+    SETUP_TARGET_FOR_COVERAGE(array_list_test array_list_test ${CMAKE_BINARY_DIR}/coverage/array_list_test/array_list_test)
+    SETUP_TARGET_FOR_COVERAGE(hash_map hash_map_test ${CMAKE_BINARY_DIR}/coverage/hash_map_test/hash_map_test)
+    SETUP_TARGET_FOR_COVERAGE(celix_threads_test celix_threads_test ${CMAKE_BINARY_DIR}/coverage/celix_threads_test/celix_threads_test)
+    SETUP_TARGET_FOR_COVERAGE(thread_pool_test thread_pool_test ${CMAKE_BINARY_DIR}/coverage/thread_pool_test/thread_pool_test)
+    SETUP_TARGET_FOR_COVERAGE(linked_list_test linked_list_test ${CMAKE_BINARY_DIR}/coverage/linked_list_test/linked_list_test)
+    SETUP_TARGET_FOR_COVERAGE(properties_test properties_test ${CMAKE_BINARY_DIR}/coverage/properties_test/properties_test)
+    SETUP_TARGET_FOR_COVERAGE(utils_test utils_test ${CMAKE_BINARY_DIR}/coverage/utils_test/utils_test)
+
+endif(ENABLE_TESTING AND UTILS-TESTS)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/array_list.h
----------------------------------------------------------------------
diff --git a/utils/include/array_list.h b/utils/include/array_list.h
new file mode 100644
index 0000000..4f83a45
--- /dev/null
+++ b/utils/include/array_list.h
@@ -0,0 +1,99 @@
+/**
+ *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.
+ */
+/*
+ * array_list.h
+ *
+ *  \date       Aug 4, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef ARRAY_LIST_H_
+#define ARRAY_LIST_H_
+
+#include "celixbool.h"
+#include "exports.h"
+#include "celix_errno.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct arrayList *array_list_pt;
+
+typedef struct arrayListIterator *array_list_iterator_pt;
+
+typedef celix_status_t (*array_list_element_equals_pt)(const void *, const void *, bool *equals);
+
+UTILS_EXPORT celix_status_t arrayList_create(array_list_pt *list);
+
+UTILS_EXPORT celix_status_t arrayList_createWithEquals(array_list_element_equals_pt equals, array_list_pt *list);
+
+UTILS_EXPORT void arrayList_destroy(array_list_pt list);
+
+UTILS_EXPORT void arrayList_trimToSize(array_list_pt list);
+
+UTILS_EXPORT void arrayList_ensureCapacity(array_list_pt list, int capacity);
+
+UTILS_EXPORT unsigned int arrayList_size(array_list_pt list);
+
+UTILS_EXPORT bool arrayList_isEmpty(array_list_pt list);
+
+UTILS_EXPORT bool arrayList_contains(array_list_pt list, void *element);
+
+UTILS_EXPORT int arrayList_indexOf(array_list_pt list, void *element);
+
+UTILS_EXPORT int arrayList_lastIndexOf(array_list_pt list, void *element);
+
+UTILS_EXPORT void *arrayList_get(array_list_pt list, unsigned int index);
+
+UTILS_EXPORT void *arrayList_set(array_list_pt list, unsigned int index, void *element);
+
+UTILS_EXPORT bool arrayList_add(array_list_pt list, void *element);
+
+UTILS_EXPORT int arrayList_addIndex(array_list_pt list, unsigned int index, void *element);
+
+UTILS_EXPORT bool arrayList_addAll(array_list_pt list, array_list_pt toAdd);
+
+UTILS_EXPORT void *arrayList_remove(array_list_pt list, unsigned int index);
+
+UTILS_EXPORT bool arrayList_removeElement(array_list_pt list, void *element);
+
+UTILS_EXPORT void arrayList_clear(array_list_pt list);
+
+UTILS_EXPORT array_list_pt arrayList_clone(array_list_pt list);
+
+UTILS_EXPORT array_list_iterator_pt arrayListIterator_create(array_list_pt list);
+
+UTILS_EXPORT void arrayListIterator_destroy(array_list_iterator_pt iterator);
+
+UTILS_EXPORT bool arrayListIterator_hasNext(array_list_iterator_pt iterator);
+
+UTILS_EXPORT void *arrayListIterator_next(array_list_iterator_pt iterator);
+
+UTILS_EXPORT bool arrayListIterator_hasPrevious(array_list_iterator_pt iterator);
+
+UTILS_EXPORT void *arrayListIterator_previous(array_list_iterator_pt iterator);
+
+UTILS_EXPORT void arrayListIterator_remove(array_list_iterator_pt iterator);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ARRAY_LIST_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/utils/include/celix_errno.h
----------------------------------------------------------------------
diff --git a/utils/include/celix_errno.h b/utils/include/celix_errno.h
new file mode 100644
index 0000000..b51540b
--- /dev/null
+++ b/utils/include/celix_errno.h
@@ -0,0 +1,119 @@
+/*
+ *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_errno.h
+ *
+ *  \date       Feb 15, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+/*!
+  \file
+  \brief Error codes
+  \defgroup framework Celix Framework
+ */
+#ifndef CELIX_ERRNO_H_
+#define CELIX_ERRNO_H_
+
+#include <stddef.h>
+#include <errno.h>
+
+#include "exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*!
+ * Helper macro which check the current status and executes the provided expression if the
+ * status is still CELIX_SUCCESS (0)
+ */
+#define CELIX_DO_IF(status, expr) ((status) == CELIX_SUCCESS) ? (expr) : (status)
+
+/*!
+ * \defgroup celix_errno Error Codes
+ * \ingroup framework
+ * \{
+ */
+
+struct celix_status {
+    int code;
+    char *error;
+};
+
+/*!
+ * Status type returned by all functions in Celix
+ */
+typedef int celix_status_t;
+
+/*!
+ * Return a readable string for the given error code.
+ *
+ */
+UTILS_EXPORT char *celix_strerror(celix_status_t errorcode, char *buffer, size_t bufferSize);
+
+/*!
+ * Error code indicating successful execution of the function.
+ */
+#define CELIX_SUCCESS 0
+
+/*!
+ * Starting point for Celix errors.
+ */
+#define CELIX_START_ERROR 70000
+
+/*!
+ * The range for Celix errors.
+ */
+#define CELIX_ERRSPACE_SIZE 1000
+
+/*!
+ * The start error number user application can use.
+ */
+#define CELIX_START_USERERR (CELIX_START_ERROR + CELIX_ERRSPACE_SIZE)
+
+/*!
+ * Exception indicating a problem with a bundle
+ */
+#define CELIX_BUNDLE_EXCEPTION (CELIX_START_ERROR + 1)
+/*!
+ * Invalid bundle context is used
+ */
+#define CELIX_INVALID_BUNDLE_CONTEXT (CELIX_START_ERROR + 2)
+/*!
+ * Argument is not correct
+ */
+#define CELIX_ILLEGAL_ARGUMENT (CELIX_START_ERROR + 3)
+#define CELIX_INVALID_SYNTAX (CELIX_START_ERROR + 4)
+#define CELIX_FRAMEWORK_SHUTDOWN (CELIX_START_ERROR + 5)
+#define CELIX_ILLEGAL_STATE (CELIX_START_ERROR + 6)
+#define CELIX_FRAMEWORK_EXCEPTION (CELIX_START_ERROR + 7)
+#define CELIX_FILE_IO_EXCEPTION (CELIX_START_ERROR + 8)
+#define CELIX_SERVICE_EXCEPTION (CELIX_START_ERROR + 9)
+
+#define CELIX_ENOMEM ENOMEM
+
+/**
+ * \}
+ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CELIX_ERRNO_H_ */


[29/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/json_rpc_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/test/json_rpc_tests.cpp b/dfi/test/json_rpc_tests.cpp
new file mode 100644
index 0000000..bff582e
--- /dev/null
+++ b/dfi/test/json_rpc_tests.cpp
@@ -0,0 +1,433 @@
+/**
+ *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.
+ */
+#include <CppUTest/TestHarness.h>
+#include <float.h>
+#include <assert.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"
+#include "json_rpc.h"
+
+static void stdLog(void*, 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");
+    va_end(ap);
+}
+
+
+    void prepareTest(void) {
+        dyn_function_type *dynFunc = NULL;
+        int rc = dynFunction_parseWithStr("add(#am=handle;PDD#am=pre;*D)N", NULL, &dynFunc);
+        CHECK_EQUAL(0, rc);
+
+        char *result = NULL;
+
+        void *handle = NULL;
+        double arg1 = 1.0;
+        double arg2 = 2.0;
+
+        void *args[4];
+        args[0] = &handle;
+        args[1] = &arg1;
+        args[2] = &arg2;
+
+        rc = jsonRpc_prepareInvokeRequest(dynFunc, "add", args, &result);
+        CHECK_EQUAL(0, rc);
+
+        //printf("result is %s\n", result);
+
+        STRCMP_CONTAINS("\"add\"", result);
+        STRCMP_CONTAINS("1.0", result);
+        STRCMP_CONTAINS("2.0", result);
+
+        free(result);
+        dynFunction_destroy(dynFunc);
+    }
+
+    void handleTestPre(void) {
+        dyn_function_type *dynFunc = NULL;
+        int rc = dynFunction_parseWithStr("add(#am=handle;PDD#am=pre;*D)N", NULL, &dynFunc);
+        CHECK_EQUAL(0, rc);
+
+        const char *reply = "{\"r\":2.2}";
+        double result = -1.0;
+        double *out = &result;
+        void *args[4];
+        args[3] = &out;
+        rc = jsonRpc_handleReply(dynFunc, reply, args);
+        CHECK_EQUAL(0, rc);
+        //CHECK_EQUAL(2.2, result);
+
+        dynFunction_destroy(dynFunc);
+    }
+
+    int add(void*, double a, double b, double *result) {
+        *result = a + b;
+        return 0;
+    }
+
+    int getName_example4(void*, char** result) {
+        *result = strdup("allocatedInFunction");
+        return 0;
+    }
+
+    struct tst_seq {
+        uint32_t cap;
+        uint32_t len;
+        double *buf;
+    };
+
+
+    //StatsResult={DDD[D average min max input}
+    struct tst_StatsResult {
+        double average;
+        double min;
+        double max;
+        struct tst_seq input;
+    };
+
+
+    int stats(void*, struct tst_seq input, struct tst_StatsResult **out) {
+        assert(out != NULL);
+        assert(*out == NULL);
+        double total = 0.0;
+        unsigned int count = 0;
+        double max = DBL_MIN;
+        double min = DBL_MAX;
+
+        unsigned int i;
+        for (i = 0; i<input.len; i += 1) {
+            total += input.buf[i];
+            count += 1;
+            if (input.buf[i] > max) {
+                max = input.buf[i];
+            }
+            if (input.buf[i] < min) {
+                min = input.buf[i];
+            }
+        }
+
+        struct tst_StatsResult *result = (struct tst_StatsResult *) calloc(1, sizeof(*result));
+        if(count>0){
+		result->average = total / count;
+        }
+        result->min = min;
+        result->max = max;
+        double *buf = (double *)calloc(input.len, sizeof(double));
+        memcpy(buf, input.buf, input.len * sizeof(double));
+        result->input.len = input.len;
+        result->input.cap = input.len;
+        result->input.buf = buf;
+
+        *out = result;
+        return 0;
+    }
+
+    struct item {
+        double a;
+        double b;
+    };
+
+    struct item_seq {
+        uint32_t  cap;
+        uint32_t  len;
+        struct item **buf;
+    };
+
+    struct tst_serv {
+        void *handle;
+        int (*add)(void *, double, double, double *);
+        int (*sub)(void *, double, double, double *);
+        int (*sqrt)(void *, double, double *);
+        int (*stats)(void *, struct tst_seq, struct tst_StatsResult **);
+    };
+
+    struct tst_serv_example4 {
+        void *handle;
+        int (*getName_example4)(void *, char** name);
+    };
+
+    void callTestPreAllocated(void) {
+        dyn_interface_type *intf = NULL;
+        FILE *desc = fopen("descriptors/example1.descriptor", "r");
+        CHECK(desc != NULL);
+        int rc = dynInterface_parse(desc, &intf);
+        CHECK_EQUAL(0, rc);
+        fclose(desc);
+
+        char *result = NULL;
+
+        struct tst_serv serv;
+        serv.handle = NULL;
+        serv.add = add;
+
+
+        rc = jsonRpc_call(intf, &serv, "{\"m\":\"add(DD)D\", \"a\": [1.0,2.0]}", &result);
+        CHECK_EQUAL(0, rc);
+        STRCMP_CONTAINS("3.0", result);
+
+        free(result);
+        dynInterface_destroy(intf);
+    }
+
+    void callTestOutput(void) {
+        dyn_interface_type *intf = NULL;
+        FILE *desc = fopen("descriptors/example1.descriptor", "r");
+        CHECK(desc != NULL);
+        int rc = dynInterface_parse(desc, &intf);
+        CHECK_EQUAL(0, rc);
+        fclose(desc);
+
+        char *result = NULL;
+
+        struct tst_serv serv;
+        serv.handle = NULL;
+        serv.stats = stats;
+
+        rc = jsonRpc_call(intf, &serv, "{\"m\":\"stats([D)LStatsResult;\", \"a\": [[1.0,2.0]]}", &result);
+        CHECK_EQUAL(0, rc);
+        STRCMP_CONTAINS("1.5", result); //avg
+
+        free(result);
+        dynInterface_destroy(intf);
+    }
+
+    void handleTestOut(void) {
+        dyn_interface_type *intf = NULL;
+        FILE *desc = fopen("descriptors/example1.descriptor", "r");
+        CHECK(desc != NULL);
+        int rc = dynInterface_parse(desc, &intf);
+        CHECK_EQUAL(0, rc);
+        fclose(desc);
+
+        struct methods_head *head;
+        dynInterface_methods(intf, &head);
+        dyn_function_type *func = NULL;
+        struct method_entry *entry = NULL;
+        TAILQ_FOREACH(entry, head, entries) {
+            if (strcmp(entry->name, "stats") == 0) {
+                func = entry->dynFunc;
+                break;
+            }
+        }
+        CHECK(func != NULL);
+
+        const char *reply = "{\"r\":{\"input\":[1.0,2.0],\"max\":2.0,\"average\":1.5,\"min\":1.0}}";
+
+        void *args[3];
+        args[0] = NULL;
+        args[1] = NULL;
+        args[2] = NULL;
+
+        struct tst_StatsResult *result = NULL;
+        void *out = &result;
+        args[2] = &out;
+
+        rc = jsonRpc_handleReply(func, reply, args);
+        CHECK_EQUAL(0, rc);
+        CHECK_EQUAL(1.5, result->average);
+
+        free(result->input.buf);
+        free(result);
+        dynInterface_destroy(intf);
+    }
+
+    static void handleTestOutputSequence(void) {
+        dyn_interface_type *intf = NULL;
+        FILE *desc = fopen("descriptors/example2.descriptor", "r");
+        CHECK(desc != NULL);
+        int rc = dynInterface_parse(desc, &intf);
+        CHECK_EQUAL(0, rc);
+        fclose(desc);
+
+        struct methods_head *head;
+        dynInterface_methods(intf, &head);
+        dyn_function_type *func = NULL;
+        struct method_entry *entry = NULL;
+        TAILQ_FOREACH(entry, head, entries) {
+            if (strcmp(entry->name, "example1") == 0) {
+                func = entry->dynFunc;
+                break;
+            }
+        }
+        CHECK(func != NULL);
+
+        //dyn_type *arg = dynFunction_argumentTypeForIndex(func, 1);
+        //dynType_print(arg, stdout);
+
+        const char *reply = "{\"r\":[{\"a\":1.0,\"b\":1.5},{\"a\":2.0,\"b\":2.5}]}";
+
+        void *args[2];
+        args[0] = NULL;
+        args[1] = NULL;
+
+        struct item_seq *result = NULL;
+        void *out = &result;
+        args[1] = &out;
+
+        rc = jsonRpc_handleReply(func, reply, args);
+        CHECK_EQUAL(0, rc);
+        CHECK_EQUAL(2, result->len);
+        CHECK_EQUAL(1.0, result->buf[0]->a);
+        CHECK_EQUAL(1.5, result->buf[0]->b);
+        CHECK_EQUAL(2.0, result->buf[1]->a);
+        CHECK_EQUAL(2.5, result->buf[1]->b);
+
+
+        unsigned int i;
+        for (i = 0; i < result->len; i +=1 ) {
+            free(result->buf[i]);
+        }
+        free(result->buf);
+        free(result);
+        dynInterface_destroy(intf);
+    }
+
+
+
+
+    void callTestOutChar(void) {
+        dyn_interface_type *intf = NULL;
+        FILE *desc = fopen("descriptors/example4.descriptor", "r");
+        CHECK(desc != NULL);
+        int rc = dynInterface_parse(desc, &intf);
+        CHECK_EQUAL(0, rc);
+        fclose(desc);
+
+        char *result = NULL;
+
+        struct tst_serv_example4 serv;
+        serv.handle = NULL;
+        serv.getName_example4 = getName_example4;
+
+        rc = jsonRpc_call(intf, &serv, "{\"m\":\"getName(V)t\", \"a\": []}", &result);
+        CHECK_EQUAL(0, rc);
+
+        STRCMP_CONTAINS("allocatedInFunction", result);
+
+        free(result);
+        dynInterface_destroy(intf);
+    }
+
+
+    void handleTestOutChar(void) {
+        dyn_interface_type *intf = NULL;
+        FILE *desc = fopen("descriptors/example4.descriptor", "r");
+        CHECK(desc != NULL);
+        int rc = dynInterface_parse(desc, &intf);
+        CHECK_EQUAL(0, rc);
+        fclose(desc);
+
+        struct methods_head *head;
+        dynInterface_methods(intf, &head);
+        dyn_function_type *func = NULL;
+        struct method_entry *entry = NULL;
+        TAILQ_FOREACH(entry, head, entries) {
+            if (strcmp(entry->name, "getName") == 0) {
+                func = entry->dynFunc;
+                break;
+            }
+        }
+
+        CHECK(func != NULL);
+
+        const char *reply = "{\"r\": \"this is a test string\" }";
+        char *result = NULL;
+        void *out = &result;
+
+        void *args[2];
+        args[0] = NULL;
+        args[1] = &out;
+
+        if(func!=NULL){ // Check needed just to satisfy Coverity
+		rc = jsonRpc_handleReply(func, reply, args);
+        }
+
+        STRCMP_EQUAL("this is a test string", result);
+
+        free(result);
+        dynInterface_destroy(intf);
+    }
+
+
+}
+
+TEST_GROUP(JsonRpcTests) {
+    void setup() {
+        int lvl = 1;
+        dynCommon_logSetup(stdLog, NULL, lvl);
+        dynType_logSetup(stdLog, NULL,lvl);
+        dynFunction_logSetup(stdLog, NULL,lvl);
+        dynInterface_logSetup(stdLog, NULL,lvl);
+        jsonSerializer_logSetup(stdLog, NULL, lvl);
+        jsonRpc_logSetup(stdLog, NULL, lvl);
+
+    }
+};
+
+
+TEST(JsonRpcTests, prepareTest) {
+    prepareTest();
+}
+
+TEST(JsonRpcTests, handleTestPre) {
+    handleTestPre();
+}
+
+TEST(JsonRpcTests, handleTestOut) {
+    handleTestOut();
+}
+
+TEST(JsonRpcTests, callPre) {
+    callTestPreAllocated();
+}
+
+TEST(JsonRpcTests, callOut) {
+    callTestOutput();
+}
+
+TEST(JsonRpcTests, handleOutSeq) {
+    handleTestOutputSequence();
+}
+
+
+
+TEST(JsonRpcTests, callTestOutChar) {
+    callTestOutChar();
+}
+
+TEST(JsonRpcTests, handleOutChar) {
+    handleTestOutChar();
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/json_serializer_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/test/json_serializer_tests.cpp b/dfi/test/json_serializer_tests.cpp
new file mode 100644
index 0000000..a52e4cc
--- /dev/null
+++ b/dfi/test/json_serializer_tests.cpp
@@ -0,0 +1,558 @@
+/**
+ *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.
+ */
+#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*, 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");
+	va_end(ap);
+}
+
+/*********** 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);
+	LONGS_EQUAL(22, ex->b);
+	LONGS_EQUAL(32, ex->c);
+	LONGS_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);
+	LONGS_EQUAL(232, ex->long1);
+	LONGS_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 5 ************************/
+/** 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 const char *example6_descriptor = "Tsample={DD v1 v2};[lsample;";
+
+static const char *example6_input = "[{\"v1\":0.1,\"v2\":0.2},{\"v1\":1.1,\"v2\":1.2},{\"v1\":2.1,\"v2\":2.2}]";
+
+struct ex6_sample {
+	double v1;
+	double v2;
+};
+
+struct ex6_sequence {
+	uint32_t cap;
+	uint32_t len;
+	struct ex6_sample *buf;
+};
+
+static void check_example6(struct ex6_sequence seq) {
+	CHECK_EQUAL(3, seq.cap);
+	CHECK_EQUAL(3, seq.len);
+	CHECK_EQUAL(0.1, seq.buf[0].v1);
+	CHECK_EQUAL(0.2, seq.buf[0].v2);
+	CHECK_EQUAL(1.1, seq.buf[1].v1);
+	CHECK_EQUAL(1.2, seq.buf[1].v2);
+	CHECK_EQUAL(2.1, seq.buf[2].v1);
+	CHECK_EQUAL(2.2, seq.buf[2].v2);
+}
+
+
+/*********** example 7 ************************/
+const char *example7_descriptor = "{t a}";
+
+const char *example7_input = "{ \
+    \"a\" : \"apache celix\" \
+}";
+
+struct example7 {
+	char* a;   //0
+};
+
+static void check_example7(void *data) {
+	struct example7 *ex = (struct example7 *)data;
+	STRCMP_EQUAL("apache celix", ex->a);
+}
+
+
+/*********** example 8 ************************/
+
+const char *example8_descriptor = "{ZbijNP a b c d e f}";
+
+const char *example8_input = "{ \
+    \"a\" : true, \
+    \"b\" : 4, \
+    \"c\" : 8, \
+    \"d\" : 16, \
+    \"e\" : 32 \
+}";
+
+struct example8 {
+	bool a;
+	unsigned char b;
+	uint32_t c;
+	uint64_t d;
+	int e;
+	void* f;
+};
+
+static void check_example8(void *data) {
+	struct example8 *ex = (struct example8 *)data;
+	CHECK_EQUAL(true,ex->a);
+	CHECK_EQUAL(4,ex->b);
+	CHECK_EQUAL(8,ex->c);
+	//error on mac CHECK_EQUAL(16,ex->d);
+    CHECK(16 == ex->d)
+	CHECK_EQUAL(32,ex->e);
+}
+
+
+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);
+
+	type = NULL;
+	struct ex6_sequence *seq;
+	rc = dynType_parseWithStr(example6_descriptor, NULL, NULL, &type);
+	CHECK_EQUAL(0, rc);
+	rc = jsonSerializer_deserialize(type, example6_input, (void **)&seq);
+	CHECK_EQUAL(0, rc);
+	check_example6((*seq));
+	dynType_free(type, seq);
+	dynType_destroy(type);
+
+
+	type = NULL;
+	inst = NULL;
+	rc = dynType_parseWithStr(example7_descriptor, NULL, NULL, &type);
+	CHECK_EQUAL(0, rc);
+	rc = jsonSerializer_deserialize(type, example7_input, &inst);
+	CHECK_EQUAL(0, rc);
+	check_example7(inst);
+	dynType_free(type, inst);
+	dynType_destroy(type);
+
+	type = NULL;
+	inst = NULL;
+	rc = dynType_parseWithStr(example8_descriptor, NULL, NULL, &type);
+	CHECK_EQUAL(0, rc);
+	rc = jsonSerializer_deserialize(type, example8_input, &inst);
+	CHECK_EQUAL(0, rc);
+	check_example8(inst);
+	dynType_free(type, inst);
+	dynType_destroy(type);
+}
+
+const char *write_example1_descriptor = "{BSIJsijFDNZb a b c d e f g h i j k l}";
+
+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;
+	bool k;
+	unsigned char l;
+};
+
+void writeTest1(void) {
+	struct write_example1 ex1;
+	ex1.a=1;
+	ex1.b=2;
+	ex1.c=3;
+	ex1.d=4;
+	ex1.e=5;
+	ex1.f=6;
+	ex1.g=7;
+	ex1.h=8.8f;
+	ex1.i=9.9;
+	ex1.j=10;
+	ex1.k=true;
+	ex1.l=12;
+
+	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);
+	STRCMP_CONTAINS("\"k\":true", result);
+	STRCMP_CONTAINS("\"l\":12", 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;
+	sub1.a = 1;
+	sub1.b = 2;
+
+	struct write_example2 ex;
+	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;
+	p1.name = "John";
+	p1.age = 33;
+
+	struct write_example3_person p2;
+	p2.name = "Peter";
+	p2.age = 44;
+
+	struct write_example3_person p3;
+	p3.name = "Carol";
+	p3.age = 55;
+
+	struct write_example3_person p4;
+	p4.name = "Elton";
+	p4.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/a1c30887/dfi/test/run_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/test/run_tests.cpp b/dfi/test/run_tests.cpp
new file mode 100644
index 0000000..786f4bf
--- /dev/null
+++ b/dfi/test/run_tests.cpp
@@ -0,0 +1,24 @@
+/**
+ *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.
+ */
+#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/a1c30887/dfi/test/schemas/complex.avdl
----------------------------------------------------------------------
diff --git a/dfi/test/schemas/complex.avdl b/dfi/test/schemas/complex.avdl
new file mode 100644
index 0000000..eff1fd8
--- /dev/null
+++ b/dfi/test/schemas/complex.avdl
@@ -0,0 +1,30 @@
+/**
+ *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.
+ */
+
+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/a1c30887/dfi/test/schemas/complex.avpr
----------------------------------------------------------------------
diff --git a/dfi/test/schemas/complex.avpr b/dfi/test/schemas/complex.avpr
new file mode 100644
index 0000000..ca39b56
--- /dev/null
+++ b/dfi/test/schemas/complex.avpr
@@ -0,0 +1,55 @@
+/**
+ *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.
+ */
+
+{
+  "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/a1c30887/dfi/test/schemas/invalid1.avpr
----------------------------------------------------------------------
diff --git a/dfi/test/schemas/invalid1.avpr b/dfi/test/schemas/invalid1.avpr
new file mode 100644
index 0000000..bbf77ee
--- /dev/null
+++ b/dfi/test/schemas/invalid1.avpr
@@ -0,0 +1,47 @@
+/**
+ *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.
+ */
+{
+  "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/a1c30887/dfi/test/schemas/invalid2.avpr
----------------------------------------------------------------------
diff --git a/dfi/test/schemas/invalid2.avpr b/dfi/test/schemas/invalid2.avpr
new file mode 100644
index 0000000..9eb9209
--- /dev/null
+++ b/dfi/test/schemas/invalid2.avpr
@@ -0,0 +1,49 @@
+/**
+ *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.
+ */
+ {
+  "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/a1c30887/dfi/test/schemas/simple.avdl
----------------------------------------------------------------------
diff --git a/dfi/test/schemas/simple.avdl b/dfi/test/schemas/simple.avdl
new file mode 100644
index 0000000..a03e352
--- /dev/null
+++ b/dfi/test/schemas/simple.avdl
@@ -0,0 +1,24 @@
+/**
+ *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.
+ */
+ @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/a1c30887/dfi/test/schemas/simple.avpr
----------------------------------------------------------------------
diff --git a/dfi/test/schemas/simple.avpr b/dfi/test/schemas/simple.avpr
new file mode 100644
index 0000000..4910346
--- /dev/null
+++ b/dfi/test/schemas/simple.avpr
@@ -0,0 +1,51 @@
+/**
+ *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.
+ */
+ {
+  "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/a1c30887/dfi/test/schemas/simple_min.avpr
----------------------------------------------------------------------
diff --git a/dfi/test/schemas/simple_min.avpr b/dfi/test/schemas/simple_min.avpr
new file mode 100644
index 0000000..f5c6673
--- /dev/null
+++ b/dfi/test/schemas/simple_min.avpr
@@ -0,0 +1,19 @@
+/**
+ *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.
+ */
+ {"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/a1c30887/doap/doap_Celix.rdf
----------------------------------------------------------------------
diff --git a/doap/doap_Celix.rdf b/doap/doap_Celix.rdf
index 8571a14..41da6c3 100755
--- a/doap/doap_Celix.rdf
+++ b/doap/doap_Celix.rdf
@@ -37,7 +37,7 @@
     <name>Apache Celix</name>
     <homepage rdf:resource="http://celix.apache.org" />
     <asfext:pmc rdf:resource="http://celix.apache.org" />
-    <shortdesc>OSGi framework implementation in C.</shortdesc>
+    <shortdesc>OSGi framework implementation in C and C++.</shortdesc>
      <description>
      Celix is an implementation of the OSGi specification adapted to C. 
      It will follow the API as close as possible, but since the OSGi specification is written primarily for Java, there will be differences (Java is OO, C is procedural). 

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/etcdlib/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/etcdlib/CMakeLists.txt b/etcdlib/CMakeLists.txt
index fd72d79..060eeb0 100644
--- a/etcdlib/CMakeLists.txt
+++ b/etcdlib/CMakeLists.txt
@@ -41,28 +41,34 @@ endif ()
 find_package(CURL REQUIRED)
 find_package(Jansson REQUIRED)
 
-include_directories(
-        ${CURL_INCLUDE_DIRS}
-        ${JANSSON_INCLUDE_DIRS}
-        private/include
-        public/include
-)
-
 add_library(etcdlib SHARED
-    private/src/etcd.c
+    src/etcd.c
+)
+target_include_directories(etcdlib PUBLIC api)
+target_include_directories(etcdlib PRIVATE
+    src
+    ${CURL_INCLUDE_DIRS}
+    ${JANSSON_INCLUDE_DIRS}
 )
 
 set_target_properties(etcdlib PROPERTIES "SOVERSION" 1)
 target_link_libraries(etcdlib ${CURL_LIBRARIES} ${JANSSON_LIBRARIES})
 
 add_library(etcdlib_static STATIC
-    private/src/etcd.c
+    src/etcd.c
+)
+target_include_directories(etcdlib_static PUBLIC api)
+target_include_directories(etcdlib_static PRIVATE
+    src
+    ${CURL_INCLUDE_DIRS}
+    ${JANSSON_INCLUDE_DIRS}
 )
-
 set_target_properties(etcdlib_static PROPERTIES "SOVERSION" 1)
 target_link_libraries(etcdlib_static ${CURL_LIBRARIES} ${JANSSON_LIBRARY})
 
 
 install(TARGETS etcdlib etcdlib_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${ETCDLIB_CMP})
-FILE(GLOB files "public/include/*.h")
-INSTALL(FILES ${files} DESTINATION include/etcdlib COMPONENT framework)
+
+#Setup target aliases to match external usage
+add_library(Celix::etcdlib ALIAS etcdlib)
+add_library(Celix::etcdlib_static ALIAS etcdlib_static)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/etcdlib/api/etcd.h
----------------------------------------------------------------------
diff --git a/etcdlib/api/etcd.h b/etcdlib/api/etcd.h
new file mode 100644
index 0000000..7980700
--- /dev/null
+++ b/etcdlib/api/etcd.h
@@ -0,0 +1,110 @@
+/**
+ *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.
+ */
+
+#ifndef ETCDLIB_H_
+#define ETCDLIB_H_
+
+#include <stdbool.h>
+
+/*
+ * If set etcdlib will _not_ initialize curl
+ * using curl_global_init. Note that 
+ * curl_global_init can be called multiple
+ * times, but is _not_ thread-safe.
+ */
+#define ETCDLIB_NO_CURL_INITIALIZATION (1)
+
+#define ETCDLIB_ACTION_CREATE   "create"
+#define ETCDLIB_ACTION_GET      "get"
+#define ETCDLIB_ACTION_SET      "set"
+#define ETCDLIB_ACTION_UPDATE   "update"
+#define ETCDLIB_ACTION_DELETE   "delete"
+#define ETCDLIB_ACTION_EXPIRE   "expire"
+
+typedef void (*etcd_key_value_callback) (const char *key, const char *value, void* arg);
+
+/**
+ * @desc Initialize the ETCD-LIB  with the server/port where Etcd can be reached.
+ * @param const char* server. String containing the IP-number of the server.
+ * @param int port. Port number of the server.
+ * @param int flags. bitwise flags to control etcdlib initialization. 
+ * @return 0 on success, non zero otherwise.
+ */
+int etcd_init(const char* server, int port, int flags);
+
+/**
+ * @desc Retrieve a single value from Etcd.
+ * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
+ * @param char** value. The allocated memory contains the Etcd-value. The caller is responsible for freeing this memory.
+ * @param int* modifiedIndex. If not NULL the Etcd-index of the last modified value.
+ * @return 0 on success, non zero otherwise
+ */
+int etcd_get(const char* key, char** value, int* modifiedIndex);
+
+/**
+ * @desc Retrieve the contents of a directory. For every found key/value pair the given callback function is called.
+ * @param const char* directory. The Etcd-directory which has to be searched for keys
+ * @param etcd_key_value_callback callback. Callback function which is called for every found key
+ * @param void *arg. Argument is passed to the callback function
+ * @param int* modifiedIndex. If not NULL the Etcd-index of the last modified value.
+ * @return 0 on success, non zero otherwise
+ */
+int etcd_get_directory(const char* directory, etcd_key_value_callback callback, void *arg, long long* modifiedIndex);
+
+/**
+ * @desc Setting an Etcd-key/value
+ * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
+ * @param const char* value. The Etcd-value 
+ * @param int ttl. If non-zero this is used as the TTL value
+ * @param bool prevExist. If true the value is only set when the key already exists, if false it is always set
+ * @return 0 on success, non zero otherwise
+ */
+int etcd_set(const char* key, const char* value, int ttl, bool prevExist);
+
+/**
+ * @desc Setting an Etcd-key/value and checks if there is a different previuos value
+ * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
+ * @param const char* value. The Etcd-value 
+ * @param int ttl. If non-zero this is used as the TTL value
+ * @param bool always_write. If true the value is written, if false only when the given value is equal to the value in etcd.
+ * @return 0 on success, non zero otherwise
+ */
+int etcd_set_with_check(const char* key, const char* value, int ttl, bool always_write);
+
+/**
+ * @desc Deleting an Etcd-key
+ * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
+ * @return 0 on success, non zero otherwise
+ */
+int etcd_del(const char* key);
+
+/**
+ * @desc Watching an etcd directory for changes
+ * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
+ * @param long long index. The Etcd-index which the watch has to be started on.
+ * @param char** action. If not NULL, memory is allocated and contains the action-string. The caller is responsible of freeing the memory.
+ * @param char** prevValue. If not NULL, memory is allocated and contains the previous value. The caller is responsible of freeing the memory.
+ * @param char** value. If not NULL, memory is allocated and contains the new value. The caller is responsible of freeing the memory.
+ * @param char** rkey. If not NULL, memory is allocated and contains the updated key. The caller is responsible of freeing the memory.
+ * @param long long* modifiedIndex. If not NULL, the index of the modification is written.
+ * @return 0 on success, non zero otherwise
+ */
+int etcd_watch(const char* key, long long index, char** action, char** prevValue, char** value, char** rkey, long long* modifiedIndex);
+
+#endif /*ETCDLIB_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/etcdlib/private/src/etcd.c
----------------------------------------------------------------------
diff --git a/etcdlib/private/src/etcd.c b/etcdlib/private/src/etcd.c
deleted file mode 100644
index ff9f827..0000000
--- a/etcdlib/private/src/etcd.c
+++ /dev/null
@@ -1,487 +0,0 @@
-/**
- *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.
- */
-
-#include <stdio.h>
-#include <stdbool.h>
-#include <string.h>
-#include <curl/curl.h>
-#include <jansson.h>
-
-#include "etcd.h"
-
-#define ETCD_JSON_NODE                  "node"
-#define ETCD_JSON_PREVNODE              "prevNode"
-#define ETCD_JSON_NODES                 "nodes"
-#define ETCD_JSON_ACTION                "action"
-#define ETCD_JSON_KEY                   "key"
-#define ETCD_JSON_VALUE                 "value"
-#define ETCD_JSON_DIR                   "dir"
-#define ETCD_JSON_MODIFIEDINDEX         "modifiedIndex"
-
-#define MAX_OVERHEAD_LENGTH           64
-#define DEFAULT_CURL_TIMEOUT          10
-#define DEFAULT_CURL_CONECTTIMEOUT    10
-
-typedef enum {
-	GET, PUT, DELETE
-} request_t;
-
-static const char* etcd_server;
-static int etcd_port = 0;
-
-struct MemoryStruct {
-	char *memory;
-	size_t size;
-};
-
-
-/**
- * Static function declarations
- */
-static int performRequest(char* url, request_t request, void* callback, void* reqData, void* repData);
-static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp);
-/**
- * External function definition
- */
-
-
-/**
- * etcd_init
- */
-int etcd_init(const char* server, int port, int flags) {
-	int status = 0;
-	etcd_server = server;
-	etcd_port = port;
-
-	if ((flags & ETCDLIB_NO_CURL_INITIALIZATION) == 0) {
-		//NO_CURL_INITIALIZATION flag not set
-		status = curl_global_init(CURL_GLOBAL_ALL);
-	}
-
-	return status;
-}
-
-
-/**
- * etcd_get
- */
-int etcd_get(const char* key, char** value, int* modifiedIndex) {
-	json_t* js_root = NULL;
-	json_t* js_node = NULL;
-	json_t* js_value = NULL;
-	json_t* js_modifiedIndex = NULL;
-	json_error_t error;
-	int res = -1;
-	struct MemoryStruct reply;
-
-	reply.memory = malloc(1); /* will be grown as needed by the realloc above */
-	reply.size = 0; /* no data at this point */
-
-	int retVal = -1;
-	char *url;
-	asprintf(&url, "http://%s:%d/v2/keys/%s", etcd_server, etcd_port, key);
-	res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) &reply);
-	free(url);
-
-	if (res == CURLE_OK) {
-		js_root = json_loads(reply.memory, 0, &error);
-
-		if (js_root != NULL) {
-			js_node = json_object_get(js_root, ETCD_JSON_NODE);
-		}
-		if (js_node != NULL) {
-			js_value = json_object_get(js_node, ETCD_JSON_VALUE);
-			js_modifiedIndex = json_object_get(js_node,
-					ETCD_JSON_MODIFIEDINDEX);
-
-			if (js_modifiedIndex != NULL && js_value != NULL) {
-				if (modifiedIndex) {
-					*modifiedIndex = json_integer_value(js_modifiedIndex);
-				}
-				*value = strdup(json_string_value(js_value));
-				retVal = 0;
-			}
-		}
-		if (js_root != NULL) {
-			json_decref(js_root);
-		}
-	}
-
-	if (reply.memory) {
-		free(reply.memory);
-	}
-	if(retVal != 0) {
-		*value = NULL;
-	}
-	return retVal;
-}
-
-
-static int etcd_get_recursive_values(json_t* js_root, etcd_key_value_callback callback, void *arg, json_int_t *mod_index) {
-	json_t *js_nodes;
-	if ((js_nodes = json_object_get(js_root, ETCD_JSON_NODES)) != NULL) {
-		// subarray
-		if (json_is_array(js_nodes)) {
-			int len = json_array_size(js_nodes);
-			for (int i = 0; i < len; i++) {
-				json_t *js_object = json_array_get(js_nodes, i);
-				json_t *js_mod_index = json_object_get(js_object, ETCD_JSON_MODIFIEDINDEX);
-
-				if(js_mod_index != NULL) {
-					json_int_t index = json_integer_value(js_mod_index);
-					if(*mod_index < index) {
-						*mod_index = index;
-					}
-				} else {
-					printf("[ETCDLIB] Error: No INDEX found for key!\n");
-				}
-
-				if (json_object_get(js_object, ETCD_JSON_NODES)) {
-					// node contains nodes
-					etcd_get_recursive_values(js_object, callback, arg, mod_index);
-				} else {
-					json_t* js_key = json_object_get(js_object, ETCD_JSON_KEY);
-					json_t* js_value = json_object_get(js_object, ETCD_JSON_VALUE);
-
-					if (js_key && js_value) {
-						if (!json_object_get(js_object, ETCD_JSON_DIR)) {
-							callback(json_string_value(js_key), json_string_value(js_value), arg);
-						}
-					} //else empty etcd directory, not an error.
-
-				}
-			}
-		} else {
-			fprintf(stderr, "[ETCDLIB] Error: misformatted JSON: nodes element is not an array !!\n");
-		}
-	} else {
-		fprintf(stderr, "[ETCDLIB] Error: nodes element not found!!\n");
-	}
-
-	return (*mod_index > 0 ? 0 : 1);
-}
-
-/**
- * etcd_get_directory
- */
-int etcd_get_directory(const char* directory, etcd_key_value_callback callback, void* arg, long long* modifiedIndex) {
-	json_t* js_root = NULL;
-	json_t* js_rootnode = NULL;
-
-	json_error_t error;
-	int res;
-	struct MemoryStruct reply;
-
-	reply.memory = malloc(1); /* will be grown as needed by the realloc above */
-	reply.size = 0; /* no data at this point */
-
-	int retVal = 0;
-	char *url;
-
-	asprintf(&url, "http://%s:%d/v2/keys/%s?recursive=true", etcd_server, etcd_port, directory);
-
-	res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) &reply);
-	free(url);
-
-	if (res == CURLE_OK) {
-		js_root = json_loads(reply.memory, 0, &error);
-		if (js_root != NULL) {
-			js_rootnode = json_object_get(js_root, ETCD_JSON_NODE);
-		} else {
-			retVal = -1;
-			fprintf(stderr, "[ETCDLIB] Error: %s in js_root not found", ETCD_JSON_NODE);
-		}
-		if (js_rootnode != NULL) {
-			*modifiedIndex = 0;
-			retVal = etcd_get_recursive_values(js_rootnode, callback, arg, (json_int_t*)modifiedIndex);
-		}
-		if (js_root != NULL) {
-			json_decref(js_root);
-		}
-	}
-
-	if (reply.memory) {
-		free(reply.memory);
-	}
-
-	return retVal;
-}
-
-/**
- * etcd_set
- */
-int etcd_set(const char* key, const char* value, int ttl, bool prevExist) {
-	json_error_t error;
-	json_t* js_root = NULL;
-	json_t* js_node = NULL;
-	json_t* js_value = NULL;
-	int retVal = -1;
-	char *url;
-	size_t req_len = strlen(value) + MAX_OVERHEAD_LENGTH;
-	char request[req_len];
-	char* requestPtr = request;
-	int res;
-	struct MemoryStruct reply;
-
-	/* Skip leading '/', etcd cannot handle this. */
-	while(*key == '/') {
-		key++;
-	}
-
-	reply.memory = calloc(1, 1); /* will be grown as needed by the realloc above */
-	reply.size = 0; /* no data at this point */
-
-	asprintf(&url, "http://%s:%d/v2/keys/%s", etcd_server, etcd_port, key);
-
-	requestPtr += snprintf(requestPtr, req_len, "value=%s", value);
-	if (ttl > 0) {
-		requestPtr += snprintf(requestPtr, req_len-(requestPtr-request), ";ttl=%d", ttl);
-	}
-
-	if (prevExist) {
-		requestPtr += snprintf(requestPtr, req_len-(requestPtr-request), ";prevExist=true");
-	}
-
-	res = performRequest(url, PUT, WriteMemoryCallback, request, (void*) &reply);
-
-	if(url) {
-		free(url);
-	}
-
-	if (res == CURLE_OK) {
-		js_root = json_loads(reply.memory, 0, &error);
-
-		if (js_root != NULL) {
-			js_node = json_object_get(js_root, ETCD_JSON_NODE);
-		}
-		if (js_node != NULL) {
-			js_value = json_object_get(js_node, ETCD_JSON_VALUE);
-		}
-		if (js_value != NULL && json_is_string(js_value)) {
-			if(strcmp(json_string_value(js_value), value) == 0) {
-				retVal = 0;
-			}
-		}
-		if (js_root != NULL) {
-			json_decref(js_root);
-		}
-	}
-
-	if (reply.memory) {
-		free(reply.memory);
-	}
-
-	return retVal;
-}
-
-
-/**
- * etcd_set_with_check
- */
-int etcd_set_with_check(const char* key, const char* value, int ttl, bool always_write) {
-	char *etcd_value;
-	int result = 0;
-	if (etcd_get(key, &etcd_value, NULL) == 0) {
-		if(etcd_value!=NULL){
-			if (strcmp(etcd_value, value) != 0) {
-				fprintf(stderr, "[ETCDLIB] WARNING: value already exists and is different\n");
-				fprintf(stderr, "   key       = %s\n", key);
-				fprintf(stderr, "   old value = %s\n", etcd_value);
-				fprintf(stderr, "   new value = %s\n", value);
-				result = -1;
-			}
-			free(etcd_value);
-		}
-	}
-	if(always_write || !result) {
-		result = etcd_set(key, value, ttl, false);
-	}
-	return result;
-}
-
-
-/**
- * etcd_watch
- */
-int etcd_watch(const char* key, long long index, char** action, char** prevValue, char** value, char** rkey, long long* modifiedIndex) {
-	json_error_t error;
-	json_t* js_root = NULL;
-	json_t* js_node = NULL;
-	json_t* js_prevNode = NULL;
-	json_t* js_action = NULL;
-	json_t* js_value = NULL;
-	json_t* js_rkey = NULL;
-	json_t* js_prevValue = NULL;
-	json_t* js_modIndex = NULL;
-	int retVal = -1;
-	char *url = NULL;
-	int res;
-	struct MemoryStruct reply;
-
-	reply.memory = malloc(1); /* will be grown as needed by the realloc above */
-	reply.size = 0; /* no data at this point */
-
-	if (index != 0)
-		asprintf(&url, "http://%s:%d/v2/keys/%s?wait=true&recursive=true&waitIndex=%lld", etcd_server, etcd_port, key, index);
-	else
-		asprintf(&url, "http://%s:%d/v2/keys/%s?wait=true&recursive=true", etcd_server, etcd_port, key);
-	res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) &reply);
-	if(url)
-		free(url);
-	if (res == CURLE_OK) {
-		js_root = json_loads(reply.memory, 0, &error);
-
-		if (js_root != NULL) {
-			js_action = json_object_get(js_root, ETCD_JSON_ACTION);
-			js_node = json_object_get(js_root, ETCD_JSON_NODE);
-			js_prevNode = json_object_get(js_root, ETCD_JSON_PREVNODE);
-			retVal = 0;
-		}
-		if (js_prevNode != NULL) {
-			js_prevValue = json_object_get(js_prevNode, ETCD_JSON_VALUE);
-		}
-		if (js_node != NULL) {
-			js_rkey = json_object_get(js_node, ETCD_JSON_KEY);
-			js_value = json_object_get(js_node, ETCD_JSON_VALUE);
-			js_modIndex = json_object_get(js_node, ETCD_JSON_MODIFIEDINDEX);
-		}
-		if (js_prevNode != NULL) {
-			js_prevValue = json_object_get(js_prevNode, ETCD_JSON_VALUE);
-		}
-		if ((prevValue != NULL) && (js_prevValue != NULL) && (json_is_string(js_prevValue))) {
-
-			*prevValue = strdup(json_string_value(js_prevValue));
-		}
-		if(modifiedIndex != NULL) {
-			if ((js_modIndex != NULL) && (json_is_integer(js_modIndex))) {
-				*modifiedIndex = json_integer_value(js_modIndex);
-			} else {
-				*modifiedIndex = index;
-			}
-		}
-		if ((rkey != NULL) && (js_rkey != NULL) && (json_is_string(js_rkey))) {
-			*rkey = strdup(json_string_value(js_rkey));
-
-		}
-		if ((action != NULL)  && (js_action != NULL)  && (json_is_string(js_action))) {
-			*action = strdup(json_string_value(js_action));
-		}
-		if ((value != NULL) && (js_value != NULL) && (json_is_string(js_value))) {
-			*value = strdup(json_string_value(js_value));
-		}
-		if (js_root != NULL) {
-			json_decref(js_root);
-		}
-
-	}
-
-	if (reply.memory) {
-		free(reply.memory);
-	}
-
-	return retVal;
-}
-
-/**
- * etcd_del
- */
-int etcd_del(const char* key) {
-	json_error_t error;
-	json_t* js_root = NULL;
-	json_t* js_node = NULL;
-	int retVal = -1;
-	char *url;
-	int res;
-	struct MemoryStruct reply;
-
-	reply.memory = malloc(1); /* will be grown as needed by the realloc above */
-	reply.size = 0; /* no data at this point */
-
-	asprintf(&url, "http://%s:%d/v2/keys/%s?recursive=true", etcd_server, etcd_port, key);
-	res = performRequest(url, DELETE, WriteMemoryCallback, NULL, (void*) &reply);
-	free(url);
-
-	if (res == CURLE_OK) {
-		js_root = json_loads(reply.memory, 0, &error);
-		if (js_root != NULL) {
-			js_node = json_object_get(js_root, ETCD_JSON_NODE);
-		}
-
-		if (js_node != NULL) {
-			retVal = 0;
-		}
-
-		if (js_root != NULL) {
-			json_decref(js_root);
-		}
-	}
-
-	if (reply.memory) {
-		free(reply.memory);
-	}
-
-	return retVal;
-}
-
-
-static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) {
-	size_t realsize = size * nmemb;
-	struct MemoryStruct *mem = (struct MemoryStruct *) userp;
-
-	mem->memory = realloc(mem->memory, mem->size + realsize + 1);
-	if (mem->memory == NULL) {
-		/* out of memory! */
-		fprintf(stderr, "[ETCDLIB] Error: not enough memory (realloc returned NULL)\n");
-		return 0;
-	}
-
-	memcpy(&(mem->memory[mem->size]), contents, realsize);
-	mem->size += realsize;
-	mem->memory[mem->size] = 0;
-
-	return realsize;
-}
-
-static int performRequest(char* url, request_t request, void* callback, void* reqData, void* repData) {
-	CURL *curl = NULL;
-	CURLcode res = 0;
-	curl = curl_easy_init();
-	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-	curl_easy_setopt(curl, CURLOPT_TIMEOUT, DEFAULT_CURL_TIMEOUT);
-	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, DEFAULT_CURL_CONECTTIMEOUT);
-	curl_easy_setopt(curl, CURLOPT_URL, url);
-	curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
-	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback);
-	curl_easy_setopt(curl, CURLOPT_WRITEDATA, repData);
-
-	if (request == PUT) {
-		curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
-		curl_easy_setopt(curl, CURLOPT_POST, 1L);
-		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, reqData);
-	} else if (request == DELETE) {
-		curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
-	} else if (request == GET) {
-		curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
-	}
-
-	res = curl_easy_perform(curl);
-	curl_easy_cleanup(curl);
-
-	return res;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/etcdlib/public/include/etcd.h
----------------------------------------------------------------------
diff --git a/etcdlib/public/include/etcd.h b/etcdlib/public/include/etcd.h
deleted file mode 100644
index 7980700..0000000
--- a/etcdlib/public/include/etcd.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- *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.
- */
-
-#ifndef ETCDLIB_H_
-#define ETCDLIB_H_
-
-#include <stdbool.h>
-
-/*
- * If set etcdlib will _not_ initialize curl
- * using curl_global_init. Note that 
- * curl_global_init can be called multiple
- * times, but is _not_ thread-safe.
- */
-#define ETCDLIB_NO_CURL_INITIALIZATION (1)
-
-#define ETCDLIB_ACTION_CREATE   "create"
-#define ETCDLIB_ACTION_GET      "get"
-#define ETCDLIB_ACTION_SET      "set"
-#define ETCDLIB_ACTION_UPDATE   "update"
-#define ETCDLIB_ACTION_DELETE   "delete"
-#define ETCDLIB_ACTION_EXPIRE   "expire"
-
-typedef void (*etcd_key_value_callback) (const char *key, const char *value, void* arg);
-
-/**
- * @desc Initialize the ETCD-LIB  with the server/port where Etcd can be reached.
- * @param const char* server. String containing the IP-number of the server.
- * @param int port. Port number of the server.
- * @param int flags. bitwise flags to control etcdlib initialization. 
- * @return 0 on success, non zero otherwise.
- */
-int etcd_init(const char* server, int port, int flags);
-
-/**
- * @desc Retrieve a single value from Etcd.
- * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
- * @param char** value. The allocated memory contains the Etcd-value. The caller is responsible for freeing this memory.
- * @param int* modifiedIndex. If not NULL the Etcd-index of the last modified value.
- * @return 0 on success, non zero otherwise
- */
-int etcd_get(const char* key, char** value, int* modifiedIndex);
-
-/**
- * @desc Retrieve the contents of a directory. For every found key/value pair the given callback function is called.
- * @param const char* directory. The Etcd-directory which has to be searched for keys
- * @param etcd_key_value_callback callback. Callback function which is called for every found key
- * @param void *arg. Argument is passed to the callback function
- * @param int* modifiedIndex. If not NULL the Etcd-index of the last modified value.
- * @return 0 on success, non zero otherwise
- */
-int etcd_get_directory(const char* directory, etcd_key_value_callback callback, void *arg, long long* modifiedIndex);
-
-/**
- * @desc Setting an Etcd-key/value
- * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
- * @param const char* value. The Etcd-value 
- * @param int ttl. If non-zero this is used as the TTL value
- * @param bool prevExist. If true the value is only set when the key already exists, if false it is always set
- * @return 0 on success, non zero otherwise
- */
-int etcd_set(const char* key, const char* value, int ttl, bool prevExist);
-
-/**
- * @desc Setting an Etcd-key/value and checks if there is a different previuos value
- * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
- * @param const char* value. The Etcd-value 
- * @param int ttl. If non-zero this is used as the TTL value
- * @param bool always_write. If true the value is written, if false only when the given value is equal to the value in etcd.
- * @return 0 on success, non zero otherwise
- */
-int etcd_set_with_check(const char* key, const char* value, int ttl, bool always_write);
-
-/**
- * @desc Deleting an Etcd-key
- * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
- * @return 0 on success, non zero otherwise
- */
-int etcd_del(const char* key);
-
-/**
- * @desc Watching an etcd directory for changes
- * @param const char* key. The Etcd-key (Note: a leading '/' should be avoided)
- * @param long long index. The Etcd-index which the watch has to be started on.
- * @param char** action. If not NULL, memory is allocated and contains the action-string. The caller is responsible of freeing the memory.
- * @param char** prevValue. If not NULL, memory is allocated and contains the previous value. The caller is responsible of freeing the memory.
- * @param char** value. If not NULL, memory is allocated and contains the new value. The caller is responsible of freeing the memory.
- * @param char** rkey. If not NULL, memory is allocated and contains the updated key. The caller is responsible of freeing the memory.
- * @param long long* modifiedIndex. If not NULL, the index of the modification is written.
- * @return 0 on success, non zero otherwise
- */
-int etcd_watch(const char* key, long long index, char** action, char** prevValue, char** value, char** rkey, long long* modifiedIndex);
-
-#endif /*ETCDLIB_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/etcdlib/src/etcd.c
----------------------------------------------------------------------
diff --git a/etcdlib/src/etcd.c b/etcdlib/src/etcd.c
new file mode 100644
index 0000000..ff9f827
--- /dev/null
+++ b/etcdlib/src/etcd.c
@@ -0,0 +1,487 @@
+/**
+ *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.
+ */
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+#include <curl/curl.h>
+#include <jansson.h>
+
+#include "etcd.h"
+
+#define ETCD_JSON_NODE                  "node"
+#define ETCD_JSON_PREVNODE              "prevNode"
+#define ETCD_JSON_NODES                 "nodes"
+#define ETCD_JSON_ACTION                "action"
+#define ETCD_JSON_KEY                   "key"
+#define ETCD_JSON_VALUE                 "value"
+#define ETCD_JSON_DIR                   "dir"
+#define ETCD_JSON_MODIFIEDINDEX         "modifiedIndex"
+
+#define MAX_OVERHEAD_LENGTH           64
+#define DEFAULT_CURL_TIMEOUT          10
+#define DEFAULT_CURL_CONECTTIMEOUT    10
+
+typedef enum {
+	GET, PUT, DELETE
+} request_t;
+
+static const char* etcd_server;
+static int etcd_port = 0;
+
+struct MemoryStruct {
+	char *memory;
+	size_t size;
+};
+
+
+/**
+ * Static function declarations
+ */
+static int performRequest(char* url, request_t request, void* callback, void* reqData, void* repData);
+static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp);
+/**
+ * External function definition
+ */
+
+
+/**
+ * etcd_init
+ */
+int etcd_init(const char* server, int port, int flags) {
+	int status = 0;
+	etcd_server = server;
+	etcd_port = port;
+
+	if ((flags & ETCDLIB_NO_CURL_INITIALIZATION) == 0) {
+		//NO_CURL_INITIALIZATION flag not set
+		status = curl_global_init(CURL_GLOBAL_ALL);
+	}
+
+	return status;
+}
+
+
+/**
+ * etcd_get
+ */
+int etcd_get(const char* key, char** value, int* modifiedIndex) {
+	json_t* js_root = NULL;
+	json_t* js_node = NULL;
+	json_t* js_value = NULL;
+	json_t* js_modifiedIndex = NULL;
+	json_error_t error;
+	int res = -1;
+	struct MemoryStruct reply;
+
+	reply.memory = malloc(1); /* will be grown as needed by the realloc above */
+	reply.size = 0; /* no data at this point */
+
+	int retVal = -1;
+	char *url;
+	asprintf(&url, "http://%s:%d/v2/keys/%s", etcd_server, etcd_port, key);
+	res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) &reply);
+	free(url);
+
+	if (res == CURLE_OK) {
+		js_root = json_loads(reply.memory, 0, &error);
+
+		if (js_root != NULL) {
+			js_node = json_object_get(js_root, ETCD_JSON_NODE);
+		}
+		if (js_node != NULL) {
+			js_value = json_object_get(js_node, ETCD_JSON_VALUE);
+			js_modifiedIndex = json_object_get(js_node,
+					ETCD_JSON_MODIFIEDINDEX);
+
+			if (js_modifiedIndex != NULL && js_value != NULL) {
+				if (modifiedIndex) {
+					*modifiedIndex = json_integer_value(js_modifiedIndex);
+				}
+				*value = strdup(json_string_value(js_value));
+				retVal = 0;
+			}
+		}
+		if (js_root != NULL) {
+			json_decref(js_root);
+		}
+	}
+
+	if (reply.memory) {
+		free(reply.memory);
+	}
+	if(retVal != 0) {
+		*value = NULL;
+	}
+	return retVal;
+}
+
+
+static int etcd_get_recursive_values(json_t* js_root, etcd_key_value_callback callback, void *arg, json_int_t *mod_index) {
+	json_t *js_nodes;
+	if ((js_nodes = json_object_get(js_root, ETCD_JSON_NODES)) != NULL) {
+		// subarray
+		if (json_is_array(js_nodes)) {
+			int len = json_array_size(js_nodes);
+			for (int i = 0; i < len; i++) {
+				json_t *js_object = json_array_get(js_nodes, i);
+				json_t *js_mod_index = json_object_get(js_object, ETCD_JSON_MODIFIEDINDEX);
+
+				if(js_mod_index != NULL) {
+					json_int_t index = json_integer_value(js_mod_index);
+					if(*mod_index < index) {
+						*mod_index = index;
+					}
+				} else {
+					printf("[ETCDLIB] Error: No INDEX found for key!\n");
+				}
+
+				if (json_object_get(js_object, ETCD_JSON_NODES)) {
+					// node contains nodes
+					etcd_get_recursive_values(js_object, callback, arg, mod_index);
+				} else {
+					json_t* js_key = json_object_get(js_object, ETCD_JSON_KEY);
+					json_t* js_value = json_object_get(js_object, ETCD_JSON_VALUE);
+
+					if (js_key && js_value) {
+						if (!json_object_get(js_object, ETCD_JSON_DIR)) {
+							callback(json_string_value(js_key), json_string_value(js_value), arg);
+						}
+					} //else empty etcd directory, not an error.
+
+				}
+			}
+		} else {
+			fprintf(stderr, "[ETCDLIB] Error: misformatted JSON: nodes element is not an array !!\n");
+		}
+	} else {
+		fprintf(stderr, "[ETCDLIB] Error: nodes element not found!!\n");
+	}
+
+	return (*mod_index > 0 ? 0 : 1);
+}
+
+/**
+ * etcd_get_directory
+ */
+int etcd_get_directory(const char* directory, etcd_key_value_callback callback, void* arg, long long* modifiedIndex) {
+	json_t* js_root = NULL;
+	json_t* js_rootnode = NULL;
+
+	json_error_t error;
+	int res;
+	struct MemoryStruct reply;
+
+	reply.memory = malloc(1); /* will be grown as needed by the realloc above */
+	reply.size = 0; /* no data at this point */
+
+	int retVal = 0;
+	char *url;
+
+	asprintf(&url, "http://%s:%d/v2/keys/%s?recursive=true", etcd_server, etcd_port, directory);
+
+	res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) &reply);
+	free(url);
+
+	if (res == CURLE_OK) {
+		js_root = json_loads(reply.memory, 0, &error);
+		if (js_root != NULL) {
+			js_rootnode = json_object_get(js_root, ETCD_JSON_NODE);
+		} else {
+			retVal = -1;
+			fprintf(stderr, "[ETCDLIB] Error: %s in js_root not found", ETCD_JSON_NODE);
+		}
+		if (js_rootnode != NULL) {
+			*modifiedIndex = 0;
+			retVal = etcd_get_recursive_values(js_rootnode, callback, arg, (json_int_t*)modifiedIndex);
+		}
+		if (js_root != NULL) {
+			json_decref(js_root);
+		}
+	}
+
+	if (reply.memory) {
+		free(reply.memory);
+	}
+
+	return retVal;
+}
+
+/**
+ * etcd_set
+ */
+int etcd_set(const char* key, const char* value, int ttl, bool prevExist) {
+	json_error_t error;
+	json_t* js_root = NULL;
+	json_t* js_node = NULL;
+	json_t* js_value = NULL;
+	int retVal = -1;
+	char *url;
+	size_t req_len = strlen(value) + MAX_OVERHEAD_LENGTH;
+	char request[req_len];
+	char* requestPtr = request;
+	int res;
+	struct MemoryStruct reply;
+
+	/* Skip leading '/', etcd cannot handle this. */
+	while(*key == '/') {
+		key++;
+	}
+
+	reply.memory = calloc(1, 1); /* will be grown as needed by the realloc above */
+	reply.size = 0; /* no data at this point */
+
+	asprintf(&url, "http://%s:%d/v2/keys/%s", etcd_server, etcd_port, key);
+
+	requestPtr += snprintf(requestPtr, req_len, "value=%s", value);
+	if (ttl > 0) {
+		requestPtr += snprintf(requestPtr, req_len-(requestPtr-request), ";ttl=%d", ttl);
+	}
+
+	if (prevExist) {
+		requestPtr += snprintf(requestPtr, req_len-(requestPtr-request), ";prevExist=true");
+	}
+
+	res = performRequest(url, PUT, WriteMemoryCallback, request, (void*) &reply);
+
+	if(url) {
+		free(url);
+	}
+
+	if (res == CURLE_OK) {
+		js_root = json_loads(reply.memory, 0, &error);
+
+		if (js_root != NULL) {
+			js_node = json_object_get(js_root, ETCD_JSON_NODE);
+		}
+		if (js_node != NULL) {
+			js_value = json_object_get(js_node, ETCD_JSON_VALUE);
+		}
+		if (js_value != NULL && json_is_string(js_value)) {
+			if(strcmp(json_string_value(js_value), value) == 0) {
+				retVal = 0;
+			}
+		}
+		if (js_root != NULL) {
+			json_decref(js_root);
+		}
+	}
+
+	if (reply.memory) {
+		free(reply.memory);
+	}
+
+	return retVal;
+}
+
+
+/**
+ * etcd_set_with_check
+ */
+int etcd_set_with_check(const char* key, const char* value, int ttl, bool always_write) {
+	char *etcd_value;
+	int result = 0;
+	if (etcd_get(key, &etcd_value, NULL) == 0) {
+		if(etcd_value!=NULL){
+			if (strcmp(etcd_value, value) != 0) {
+				fprintf(stderr, "[ETCDLIB] WARNING: value already exists and is different\n");
+				fprintf(stderr, "   key       = %s\n", key);
+				fprintf(stderr, "   old value = %s\n", etcd_value);
+				fprintf(stderr, "   new value = %s\n", value);
+				result = -1;
+			}
+			free(etcd_value);
+		}
+	}
+	if(always_write || !result) {
+		result = etcd_set(key, value, ttl, false);
+	}
+	return result;
+}
+
+
+/**
+ * etcd_watch
+ */
+int etcd_watch(const char* key, long long index, char** action, char** prevValue, char** value, char** rkey, long long* modifiedIndex) {
+	json_error_t error;
+	json_t* js_root = NULL;
+	json_t* js_node = NULL;
+	json_t* js_prevNode = NULL;
+	json_t* js_action = NULL;
+	json_t* js_value = NULL;
+	json_t* js_rkey = NULL;
+	json_t* js_prevValue = NULL;
+	json_t* js_modIndex = NULL;
+	int retVal = -1;
+	char *url = NULL;
+	int res;
+	struct MemoryStruct reply;
+
+	reply.memory = malloc(1); /* will be grown as needed by the realloc above */
+	reply.size = 0; /* no data at this point */
+
+	if (index != 0)
+		asprintf(&url, "http://%s:%d/v2/keys/%s?wait=true&recursive=true&waitIndex=%lld", etcd_server, etcd_port, key, index);
+	else
+		asprintf(&url, "http://%s:%d/v2/keys/%s?wait=true&recursive=true", etcd_server, etcd_port, key);
+	res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) &reply);
+	if(url)
+		free(url);
+	if (res == CURLE_OK) {
+		js_root = json_loads(reply.memory, 0, &error);
+
+		if (js_root != NULL) {
+			js_action = json_object_get(js_root, ETCD_JSON_ACTION);
+			js_node = json_object_get(js_root, ETCD_JSON_NODE);
+			js_prevNode = json_object_get(js_root, ETCD_JSON_PREVNODE);
+			retVal = 0;
+		}
+		if (js_prevNode != NULL) {
+			js_prevValue = json_object_get(js_prevNode, ETCD_JSON_VALUE);
+		}
+		if (js_node != NULL) {
+			js_rkey = json_object_get(js_node, ETCD_JSON_KEY);
+			js_value = json_object_get(js_node, ETCD_JSON_VALUE);
+			js_modIndex = json_object_get(js_node, ETCD_JSON_MODIFIEDINDEX);
+		}
+		if (js_prevNode != NULL) {
+			js_prevValue = json_object_get(js_prevNode, ETCD_JSON_VALUE);
+		}
+		if ((prevValue != NULL) && (js_prevValue != NULL) && (json_is_string(js_prevValue))) {
+
+			*prevValue = strdup(json_string_value(js_prevValue));
+		}
+		if(modifiedIndex != NULL) {
+			if ((js_modIndex != NULL) && (json_is_integer(js_modIndex))) {
+				*modifiedIndex = json_integer_value(js_modIndex);
+			} else {
+				*modifiedIndex = index;
+			}
+		}
+		if ((rkey != NULL) && (js_rkey != NULL) && (json_is_string(js_rkey))) {
+			*rkey = strdup(json_string_value(js_rkey));
+
+		}
+		if ((action != NULL)  && (js_action != NULL)  && (json_is_string(js_action))) {
+			*action = strdup(json_string_value(js_action));
+		}
+		if ((value != NULL) && (js_value != NULL) && (json_is_string(js_value))) {
+			*value = strdup(json_string_value(js_value));
+		}
+		if (js_root != NULL) {
+			json_decref(js_root);
+		}
+
+	}
+
+	if (reply.memory) {
+		free(reply.memory);
+	}
+
+	return retVal;
+}
+
+/**
+ * etcd_del
+ */
+int etcd_del(const char* key) {
+	json_error_t error;
+	json_t* js_root = NULL;
+	json_t* js_node = NULL;
+	int retVal = -1;
+	char *url;
+	int res;
+	struct MemoryStruct reply;
+
+	reply.memory = malloc(1); /* will be grown as needed by the realloc above */
+	reply.size = 0; /* no data at this point */
+
+	asprintf(&url, "http://%s:%d/v2/keys/%s?recursive=true", etcd_server, etcd_port, key);
+	res = performRequest(url, DELETE, WriteMemoryCallback, NULL, (void*) &reply);
+	free(url);
+
+	if (res == CURLE_OK) {
+		js_root = json_loads(reply.memory, 0, &error);
+		if (js_root != NULL) {
+			js_node = json_object_get(js_root, ETCD_JSON_NODE);
+		}
+
+		if (js_node != NULL) {
+			retVal = 0;
+		}
+
+		if (js_root != NULL) {
+			json_decref(js_root);
+		}
+	}
+
+	if (reply.memory) {
+		free(reply.memory);
+	}
+
+	return retVal;
+}
+
+
+static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) {
+	size_t realsize = size * nmemb;
+	struct MemoryStruct *mem = (struct MemoryStruct *) userp;
+
+	mem->memory = realloc(mem->memory, mem->size + realsize + 1);
+	if (mem->memory == NULL) {
+		/* out of memory! */
+		fprintf(stderr, "[ETCDLIB] Error: not enough memory (realloc returned NULL)\n");
+		return 0;
+	}
+
+	memcpy(&(mem->memory[mem->size]), contents, realsize);
+	mem->size += realsize;
+	mem->memory[mem->size] = 0;
+
+	return realsize;
+}
+
+static int performRequest(char* url, request_t request, void* callback, void* reqData, void* repData) {
+	CURL *curl = NULL;
+	CURLcode res = 0;
+	curl = curl_easy_init();
+	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+	curl_easy_setopt(curl, CURLOPT_TIMEOUT, DEFAULT_CURL_TIMEOUT);
+	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, DEFAULT_CURL_CONECTTIMEOUT);
+	curl_easy_setopt(curl, CURLOPT_URL, url);
+	curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback);
+	curl_easy_setopt(curl, CURLOPT_WRITEDATA, repData);
+
+	if (request == PUT) {
+		curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
+		curl_easy_setopt(curl, CURLOPT_POST, 1L);
+		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, reqData);
+	} else if (request == DELETE) {
+		curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
+	} else if (request == GET) {
+		curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
+	}
+
+	res = curl_easy_perform(curl);
+	curl_easy_cleanup(curl);
+
+	return res;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/event_admin/event_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/CMakeLists.txt b/event_admin/event_admin/CMakeLists.txt
index 4fe7ccd..4a0f687 100644
--- a/event_admin/event_admin/CMakeLists.txt
+++ b/event_admin/event_admin/CMakeLists.txt
@@ -36,4 +36,4 @@ add_bundle(event_admin
 
 install_bundle(event_admin)
 
-target_link_libraries(event_admin celix_framework celix_utils)
+target_link_libraries(event_admin Celix::framework)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/event_admin/event_handler/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/event_handler/CMakeLists.txt b/event_admin/event_handler/CMakeLists.txt
index c786a78..2843122 100644
--- a/event_admin/event_handler/CMakeLists.txt
+++ b/event_admin/event_handler/CMakeLists.txt
@@ -32,4 +32,4 @@ add_bundle(event_handler
 
 install_bundle(event_handler)
 
-target_link_libraries(event_handler celix_framework celix_utils)
+target_link_libraries(event_handler Celix::framework)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/event_admin/event_publisher/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/event_publisher/CMakeLists.txt b/event_admin/event_publisher/CMakeLists.txt
index 1999a9c..dc9e516 100644
--- a/event_admin/event_publisher/CMakeLists.txt
+++ b/event_admin/event_publisher/CMakeLists.txt
@@ -31,4 +31,4 @@ add_bundle(event_publisher
 
 install_bundle(event_publisher)
 
-target_link_libraries(event_publisher celix_framework celix_utils)
+target_link_libraries(event_publisher Celix::framework)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 164500d..93a648b 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -28,7 +28,6 @@ if (EXAMPLES)
     if (NOT ANDROID)
     	add_subdirectory(mongoose)
     endif()
-    add_subdirectory(whiteboard)
     add_subdirectory(embedding)
     add_subdirectory(service_hook_example)
     add_subdirectory(log_service_example)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/CMakeLists.txt b/examples/dm_example/CMakeLists.txt
index 8e07825..9a9e69b 100644
--- a/examples/dm_example/CMakeLists.txt
+++ b/examples/dm_example/CMakeLists.txt
@@ -30,8 +30,8 @@ if (BUILD_DEPENDENCY_MANAGER)
     add_deploy("dm_example"
         COPY 
         BUNDLES
-            shell
-            shell_tui
+            Celix::shell
+            Celix::shell_tui
             dm_shell
             phase1
             phase2a
@@ -53,8 +53,8 @@ if (BUILD_DEPENDENCY_MANAGER)
             FROM dmbase
             GROUP examples
             BUNDLES
-                shell
-                shell_tui
+                ${CELIX_SHELL_BUNDLE}
+                ${CELIX_SHELL_TUI_BUNDLE}
                 dm_shell
                 phase1
                 phase2a

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example/phase1/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase1/CMakeLists.txt b/examples/dm_example/phase1/CMakeLists.txt
index 99abe65..6299688 100644
--- a/examples/dm_example/phase1/CMakeLists.txt
+++ b/examples/dm_example/phase1/CMakeLists.txt
@@ -28,16 +28,13 @@ add_bundle(phase1
         private/src/phase1_cmp.c
 )
 
-#Not possbile yet.
-#bundle_private_libs(phase1 dependency_manager)
-
 IF(APPLE)
-    target_link_libraries(phase1 celix_framework -Wl,-all_load dependency_manager_static)
+    target_link_libraries(phase1 PRIVATE -Wl,-all_load dependency_manager_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(phase1 -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase1 PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(phase1 -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase1 PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     endif()
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example/phase2a/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase2a/CMakeLists.txt b/examples/dm_example/phase2a/CMakeLists.txt
index 31c27a6..d8f9165 100644
--- a/examples/dm_example/phase2a/CMakeLists.txt
+++ b/examples/dm_example/phase2a/CMakeLists.txt
@@ -29,12 +29,12 @@ add_bundle(phase2a
 )
 
 IF(APPLE)
-    target_link_libraries(phase2a celix_framework -Wl,-all_load dependency_manager_static)
+    target_link_libraries(phase2a PRIVATE  -Wl,-all_load dependency_manager_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(phase2a -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase2a PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(phase2a -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase2a PRIVATE  -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     endif()
 ENDIF()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example/phase2b/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase2b/CMakeLists.txt b/examples/dm_example/phase2b/CMakeLists.txt
index 1d107ec..a65b422 100644
--- a/examples/dm_example/phase2b/CMakeLists.txt
+++ b/examples/dm_example/phase2b/CMakeLists.txt
@@ -31,12 +31,12 @@ add_bundle(phase2b
 #bundle_private_libs(phase2b dependency_manager)
 
 IF(APPLE)
-    target_link_libraries(phase2b celix_framework -Wl,-all_load dependency_manager_static)
+    target_link_libraries(phase2b PRIVATE -Wl,-all_load dependency_manager_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(phase2b -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase2b PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(phase2b -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase2b PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     endif()
 ENDIF()

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/examples/dm_example/phase3/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase3/CMakeLists.txt b/examples/dm_example/phase3/CMakeLists.txt
index aea9f9e..9547e04 100644
--- a/examples/dm_example/phase3/CMakeLists.txt
+++ b/examples/dm_example/phase3/CMakeLists.txt
@@ -31,12 +31,12 @@ add_bundle(phase3
 #bundle_private_libs(phase3 dependency_manager)
 
 IF(APPLE)
-    target_link_libraries(phase3 celix_framework -Wl,-all_load dependency_manager_static)
+    target_link_libraries(phase3 PRIVATE -Wl,-all_load dependency_manager_static)
 else()
     if(ENABLE_ADDRESS_SANITIZER)
         #With asan there can be undefined symbols
-        target_link_libraries(phase3 -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase3 PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     else()
-        target_link_libraries(phase3 -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework)
+        target_link_libraries(phase3 PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
     endif()
 ENDIF()


[41/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/include/unzip.h
----------------------------------------------------------------------
diff --git a/deployment_admin/private/include/unzip.h b/deployment_admin/private/include/unzip.h
deleted file mode 100644
index 3183968..0000000
--- a/deployment_admin/private/include/unzip.h
+++ /dev/null
@@ -1,437 +0,0 @@
-/* unzip.h -- IO for uncompress .zip files using zlib
-   Version 1.1, February 14h, 2010
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications of Unzip for Zip64
-         Copyright (C) 2007-2008 Even Rouault
-
-         Modifications for Zip64 support on both zip and unzip
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-         ---------------------------------------------------------------------------------
-
-        Condition of use and distribution are the same than zlib :
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-
-  ---------------------------------------------------------------------------------
-
-        Changes
-
-        See header of unzip64.c
-
-*/
-
-#ifndef _unz64_H
-#define _unz64_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _ZLIB_H
-#include "zlib.h"
-#endif
-
-#ifndef  _ZLIBIOAPI_H
-#include "ioapi.h"
-#endif
-
-#ifdef HAVE_BZIP2
-#include "bzlib.h"
-#endif
-
-#define Z_BZIP2ED 12
-
-#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
-/* like the STRICT of WIN32, we define a pointer that cannot be converted
-    from (void*) without cast */
-typedef struct TagunzFile__ { int unused; } unzFile__;
-typedef unzFile__ *unzFile;
-#else
-typedef voidp unzFile;
-#endif
-
-
-#define UNZ_OK                          (0)
-#define UNZ_END_OF_LIST_OF_FILE         (-100)
-#define UNZ_ERRNO                       (Z_ERRNO)
-#define UNZ_EOF                         (0)
-#define UNZ_PARAMERROR                  (-102)
-#define UNZ_BADZIPFILE                  (-103)
-#define UNZ_INTERNALERROR               (-104)
-#define UNZ_CRCERROR                    (-105)
-
-/* tm_unz contain date/time info */
-typedef struct tm_unz_s
-{
-    uInt tm_sec;            /* seconds after the minute - [0,59] */
-    uInt tm_min;            /* minutes after the hour - [0,59] */
-    uInt tm_hour;           /* hours since midnight - [0,23] */
-    uInt tm_mday;           /* day of the month - [1,31] */
-    uInt tm_mon;            /* months since January - [0,11] */
-    uInt tm_year;           /* years - [1980..2044] */
-} tm_unz;
-
-/* unz_global_info structure contain global data about the ZIPfile
-   These data comes from the end of central dir */
-typedef struct unz_global_info64_s
-{
-    ZPOS64_T number_entry;         /* total number of entries in
-                                     the central dir on this disk */
-    uLong size_comment;         /* size of the global comment of the zipfile */
-} unz_global_info64;
-
-typedef struct unz_global_info_s
-{
-    uLong number_entry;         /* total number of entries in
-                                     the central dir on this disk */
-    uLong size_comment;         /* size of the global comment of the zipfile */
-} unz_global_info;
-
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_info64_s
-{
-    uLong version;              /* version made by                 2 bytes */
-    uLong version_needed;       /* version needed to extract       2 bytes */
-    uLong flag;                 /* general purpose bit flag        2 bytes */
-    uLong compression_method;   /* compression method              2 bytes */
-    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
-    uLong crc;                  /* crc-32                          4 bytes */
-    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */
-    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */
-    uLong size_filename;        /* filename length                 2 bytes */
-    uLong size_file_extra;      /* extra field length              2 bytes */
-    uLong size_file_comment;    /* file comment length             2 bytes */
-
-    uLong disk_num_start;       /* disk number start               2 bytes */
-    uLong internal_fa;          /* internal file attributes        2 bytes */
-    uLong external_fa;          /* external file attributes        4 bytes */
-
-    tm_unz tmu_date;
-} unz_file_info64;
-
-typedef struct unz_file_info_s
-{
-    uLong version;              /* version made by                 2 bytes */
-    uLong version_needed;       /* version needed to extract       2 bytes */
-    uLong flag;                 /* general purpose bit flag        2 bytes */
-    uLong compression_method;   /* compression method              2 bytes */
-    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
-    uLong crc;                  /* crc-32                          4 bytes */
-    uLong compressed_size;      /* compressed size                 4 bytes */
-    uLong uncompressed_size;    /* uncompressed size               4 bytes */
-    uLong size_filename;        /* filename length                 2 bytes */
-    uLong size_file_extra;      /* extra field length              2 bytes */
-    uLong size_file_comment;    /* file comment length             2 bytes */
-
-    uLong disk_num_start;       /* disk number start               2 bytes */
-    uLong internal_fa;          /* internal file attributes        2 bytes */
-    uLong external_fa;          /* external file attributes        4 bytes */
-
-    tm_unz tmu_date;
-} unz_file_info;
-
-extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
-                                                 const char* fileName2,
-                                                 int iCaseSensitivity));
-/*
-   Compare two filename (fileName1,fileName2).
-   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
-   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
-                                or strcasecmp)
-   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
-    (like 1 on Unix, 2 on Windows)
-*/
-
-
-extern unzFile ZEXPORT unzOpen OF((const char *path));
-extern unzFile ZEXPORT unzOpen64 OF((const void *path));
-/*
-  Open a Zip file. path contain the full pathname (by example,
-     on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
-     "zlib/zlib113.zip".
-     If the zipfile cannot be opened (file don't exist or in not valid), the
-       return value is NULL.
-     Else, the return value is a unzFile Handle, usable with other function
-       of this unzip package.
-     the "64" function take a const void* pointer, because the path is just the
-       value passed to the open64_file_func callback.
-     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
-       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
-       does not describe the reality
-*/
-
-
-extern unzFile ZEXPORT unzOpen2 OF((const char *path,
-                                    zlib_filefunc_def* pzlib_filefunc_def));
-/*
-   Open a Zip file, like unzOpen, but provide a set of file low level API
-      for read/write the zip file (see ioapi.h)
-*/
-
-extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
-                                    zlib_filefunc64_def* pzlib_filefunc_def));
-/*
-   Open a Zip file, like unz64Open, but provide a set of file low level API
-      for read/write the zip file (see ioapi.h)
-*/
-
-extern int ZEXPORT unzClose OF((unzFile file));
-/*
-  Close a ZipFile opened with unzipOpen.
-  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
-    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
-  return UNZ_OK if there is no problem. */
-
-extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
-                                        unz_global_info *pglobal_info));
-
-extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
-                                        unz_global_info64 *pglobal_info));
-/*
-  Write info about the ZipFile in the *pglobal_info structure.
-  No preparation of the structure is needed
-  return UNZ_OK if there is no problem. */
-
-
-extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
-                                           char *szComment,
-                                           uLong uSizeBuf));
-/*
-  Get the global comment string of the ZipFile, in the szComment buffer.
-  uSizeBuf is the size of the szComment buffer.
-  return the number of byte copied or an error code <0
-*/
-
-
-/***************************************************************************/
-/* Unzip package allow you browse the directory of the zipfile */
-
-extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
-/*
-  Set the current file of the zipfile to the first file.
-  return UNZ_OK if there is no problem
-*/
-
-extern int ZEXPORT unzGoToNextFile OF((unzFile file));
-/*
-  Set the current file of the zipfile to the next file.
-  return UNZ_OK if there is no problem
-  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-
-extern int ZEXPORT unzLocateFile OF((unzFile file,
-                     const char *szFileName,
-                     int iCaseSensitivity));
-/*
-  Try locate the file szFileName in the zipfile.
-  For the iCaseSensitivity signification, see unzStringFileNameCompare
-
-  return value :
-  UNZ_OK if the file is found. It becomes the current file.
-  UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-
-
-/* ****************************************** */
-/* Ryan supplied functions */
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_pos_s
-{
-    uLong pos_in_zip_directory;   /* offset in zip file directory */
-    uLong num_of_file;            /* # of file */
-} unz_file_pos;
-
-extern int ZEXPORT unzGetFilePos(
-    unzFile file,
-    unz_file_pos* file_pos);
-
-extern int ZEXPORT unzGoToFilePos(
-    unzFile file,
-    unz_file_pos* file_pos);
-
-typedef struct unz64_file_pos_s
-{
-    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */
-    ZPOS64_T num_of_file;            /* # of file */
-} unz64_file_pos;
-
-extern int ZEXPORT unzGetFilePos64(
-    unzFile file,
-    unz64_file_pos* file_pos);
-
-extern int ZEXPORT unzGoToFilePos64(
-    unzFile file,
-    const unz64_file_pos* file_pos);
-
-/* ****************************************** */
-
-extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
-                         unz_file_info64 *pfile_info,
-                         char *szFileName,
-                         uLong fileNameBufferSize,
-                         void *extraField,
-                         uLong extraFieldBufferSize,
-                         char *szComment,
-                         uLong commentBufferSize));
-
-extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
-                         unz_file_info *pfile_info,
-                         char *szFileName,
-                         uLong fileNameBufferSize,
-                         void *extraField,
-                         uLong extraFieldBufferSize,
-                         char *szComment,
-                         uLong commentBufferSize));
-/*
-  Get Info about the current file
-  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
-        the current file
-  if szFileName!=NULL, the filemane string will be copied in szFileName
-            (fileNameBufferSize is the size of the buffer)
-  if extraField!=NULL, the extra field information will be copied in extraField
-            (extraFieldBufferSize is the size of the buffer).
-            This is the Central-header version of the extra field
-  if szComment!=NULL, the comment string of the file will be copied in szComment
-            (commentBufferSize is the size of the buffer)
-*/
-
-
-/** Addition for GDAL : START */
-
-extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
-
-/** Addition for GDAL : END */
-
-
-/***************************************************************************/
-/* for reading the content of the current zipfile, you can open it, read data
-   from it, and close it (you can close it before reading all the file)
-   */
-
-extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
-/*
-  Open for reading data the current file in the zipfile.
-  If there is no error, the return value is UNZ_OK.
-*/
-
-extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
-                                                  const char* password));
-/*
-  Open for reading data the current file in the zipfile.
-  password is a crypting password
-  If there is no error, the return value is UNZ_OK.
-*/
-
-extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
-                                           int* method,
-                                           int* level,
-                                           int raw));
-/*
-  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
-    if raw==1
-  *method will receive method of compression, *level will receive level of
-     compression
-  note : you can set level parameter as NULL (if you did not want known level,
-         but you CANNOT set method parameter as NULL
-*/
-
-extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
-                                           int* method,
-                                           int* level,
-                                           int raw,
-                                           const char* password));
-/*
-  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
-    if raw==1
-  *method will receive method of compression, *level will receive level of
-     compression
-  note : you can set level parameter as NULL (if you did not want known level,
-         but you CANNOT set method parameter as NULL
-*/
-
-
-extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
-/*
-  Close the file in zip opened with unzOpenCurrentFile
-  Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-
-extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
-                      voidp buf,
-                      unsigned len));
-/*
-  Read bytes from the current file (opened by unzOpenCurrentFile)
-  buf contain buffer where data must be copied
-  len the size of buf.
-
-  return the number of byte copied if somes bytes are copied
-  return 0 if the end of file was reached
-  return <0 with error code if there is an error
-    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-
-extern z_off_t ZEXPORT unztell OF((unzFile file));
-
-extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
-/*
-  Give the current position in uncompressed data
-*/
-
-extern int ZEXPORT unzeof OF((unzFile file));
-/*
-  return 1 if the end of file was reached, 0 elsewhere
-*/
-
-extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
-                                             voidp buf,
-                                             unsigned len));
-/*
-  Read extra field from the current file (opened by unzOpenCurrentFile)
-  This is the local-header version of the extra field (sometimes, there is
-    more info in the local-header version than in the central-header)
-
-  if buf==NULL, it return the size of the local extra field
-
-  if buf!=NULL, len is the size of the buffer, the extra header is copied in
-    buf.
-  the return value is the number of bytes copied in buf, or (if <0)
-    the error code
-*/
-
-/***************************************************************************/
-
-/* Get the current file offset */
-extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
-extern uLong ZEXPORT unzGetOffset (unzFile file);
-
-/* Set the current file offset */
-extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
-extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _unz64_H */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/src/deployment_admin.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/deployment_admin.c b/deployment_admin/private/src/deployment_admin.c
deleted file mode 100644
index 17e78db..0000000
--- a/deployment_admin/private/src/deployment_admin.c
+++ /dev/null
@@ -1,809 +0,0 @@
-/**
- *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.
- */
-/*
- * deployment_admin.c
- *
- *  \date       Nov 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdint.h>
-
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <curl/curl.h>
-#include <curl/easy.h>
-
-#include <uuid/uuid.h>
-
-#include "celixbool.h"
-#include "deployment_admin.h"
-#include "celix_errno.h"
-#include "bundle_context.h"
-#include "constants.h"
-#include "deployment_package.h"
-#include "bundle.h"
-#include "utils.h"
-
-#include "log.h"
-#include "log_store.h"
-#include "log_sync.h"
-
-#include "resource_processor.h"
-#include "miniunz.h"
-
-#define IDENTIFICATION_ID "deployment_admin_identification"
-#define DEFAULT_IDENTIFICATION_ID "celix"
-
-#define ADMIN_URL "deployment_admin_url"
-#define DEFAULT_ADMIN_URL "localhost:8080"
-
-#define DEPLOYMENT_CACHE_DIR "deployment_cache_dir"
-#define DEPLOYMENT_TAGS "deployment_tags"
-// "http://localhost:8080/deployment/"
-
-#define VERSIONS "/versions"
-
-static void* deploymentAdmin_poll(void *deploymentAdmin);
-celix_status_t deploymentAdmin_download(deployment_admin_pt admin, char * url, char **inputFile);
-size_t deploymentAdmin_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream);
-static celix_status_t deploymentAdmin_deleteTree(char * directory);
-celix_status_t deploymentAdmin_readVersions(deployment_admin_pt admin, array_list_pt versions);
-
-celix_status_t deploymentAdmin_stopDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt target);
-celix_status_t deploymentAdmin_updateDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source);
-celix_status_t deploymentAdmin_startDeploymentPackageCustomizerBundles(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target);
-celix_status_t deploymentAdmin_processDeploymentPackageResources(deployment_admin_pt admin, deployment_package_pt source);
-celix_status_t deploymentAdmin_dropDeploymentPackageResources(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target);
-celix_status_t deploymentAdmin_dropDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target);
-celix_status_t deploymentAdmin_startDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source);
-
-static celix_status_t deploymentAdmin_performRequest(deployment_admin_pt admin, char* entry);
-static celix_status_t deploymentAdmin_auditEventTargetPropertiesSet(deployment_admin_pt admin);
-static celix_status_t deploymentAdmin_auditEventFrameworkStarted(deployment_admin_pt admin);
-
-celix_status_t deploymentAdmin_create(bundle_context_pt context, deployment_admin_pt *admin) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*admin = calloc(1, sizeof(**admin));
-	if (!*admin) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*admin)->running = true;
-		(*admin)->context = context;
-		(*admin)->current = NULL;
-		(*admin)->packages = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-		(*admin)->targetIdentification = NULL;
-		(*admin)->pollUrl = NULL;
-		(*admin)->auditlogUrl = NULL;
-
-        bundleContext_getProperty(context, IDENTIFICATION_ID, (const char**) &(*admin)->targetIdentification);
-        if ((*admin)->targetIdentification == NULL) {
-        	(*admin)->targetIdentification = DEFAULT_IDENTIFICATION_ID;
-        	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Identification ID not set, using default '%s'. Set id by using '%s'",
-        		DEFAULT_IDENTIFICATION_ID, IDENTIFICATION_ID);
-        }
-
-        struct timeval tv;
-		gettimeofday(&tv,NULL);
-		(*admin)->auditlogId =  tv.tv_sec*(uint64_t)1000000+tv.tv_usec;
-        (*admin)->aditlogSeqNr = 0;
-
-		if ((*admin)->targetIdentification == NULL ) {
-		    fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Target name must be set using \"deployment_admin_identification\"");
-		} else {
-			const char *url = NULL;
-			bundleContext_getProperty(context, ADMIN_URL, &url);
-			if (url == NULL) {
-				url = DEFAULT_ADMIN_URL;
-			    fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Server URL is not set, using default '%s'. Set id by using '%s'",
-        			DEFAULT_ADMIN_URL, ADMIN_URL);
-			}
-		
-			int pollUrlLength = strlen(url) + strlen((*admin)->targetIdentification) + strlen(VERSIONS) + 13;
-			int auditlogUrlLength = strlen(url) + 10;
-
-			char pollUrl[pollUrlLength];
-			char auditlogUrl[auditlogUrlLength];
-
-			snprintf(pollUrl, pollUrlLength, "%s/deployment/%s%s", url, (*admin)->targetIdentification, VERSIONS);
-			snprintf(auditlogUrl, auditlogUrlLength, "%s/auditlog", url);
-
-			(*admin)->pollUrl = strdup(pollUrl);
-			(*admin)->auditlogUrl = strdup(auditlogUrl);
-
-//				log_store_pt store = NULL;
-//				log_pt log = NULL;
-//				log_sync_pt sync = NULL;
-//				logStore_create(subpool, &store);
-//				log_create(subpool, store, &log);
-//				logSync_create(subpool, (*admin)->targetIdentification, store, &sync);
-//
-//				log_log(log, 20000, NULL);
-
-
-			celixThread_create(&(*admin)->poller, NULL, deploymentAdmin_poll, *admin);
-		}
-	}
-
-	return status;
-}
-
-
-
-celix_status_t deploymentAdmin_destroy(deployment_admin_pt admin) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    admin->running = false;
-
-    celixThread_join(admin->poller, NULL);
-
-	hash_map_iterator_pt iter = hashMapIterator_create(admin->packages);
-
-	while (hashMapIterator_hasNext(iter)) {
-		deployment_package_pt target = (deployment_package_pt) hashMapIterator_nextValue(iter);
-		deploymentPackage_destroy(target);
-	}
-
-	hashMapIterator_destroy(iter);
-
-	hashMap_destroy(admin->packages, false, false);
-
-	if (admin->current != NULL) {
-		free(admin->current);
-	}
-
-	free(admin->pollUrl);
-	free(admin->auditlogUrl);
-
-	free(admin);
-
-	return status;
-}
-
-
-static celix_status_t deploymentAdmin_performRequest(deployment_admin_pt admin, char* entry) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    CURL *curl;
-    CURLcode res;
-    curl = curl_easy_init();
-
-    if (!curl) {
-        status = CELIX_BUNDLE_EXCEPTION;
-
-        fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error initializing curl.");
-    }
-
-    char url[strlen(admin->auditlogUrl)+6];
-    sprintf(url, "%s/send", admin->auditlogUrl);
-
-    if (status == CELIX_SUCCESS) {
-            curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-            curl_easy_setopt(curl, CURLOPT_URL, url);
-            curl_easy_setopt(curl, CURLOPT_POSTFIELDS, entry);
-            res = curl_easy_perform(curl);
-
-            if (res != CURLE_OK ) {
-                status = CELIX_BUNDLE_EXCEPTION;
-                fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error sending auditlog, got curl error code %d", res);
-            }
-    }
-
-    return status;
-}
-
-static celix_status_t deploymentAdmin_auditEventTargetPropertiesSet(deployment_admin_pt admin) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    const char *tags = NULL;
-
-    bundleContext_getProperty(admin->context, DEPLOYMENT_TAGS, &tags);
-
-    if (tags != NULL) {
-        char entry[512];
-        int entrySize = 0;
-
-        entrySize = snprintf(entry, 512, "%s,%llu,%u,0,%i,%s\n", admin->targetIdentification, admin->auditlogId, admin->aditlogSeqNr++, DEPLOYMENT_ADMIN_AUDIT_EVENT__TARGETPROPERTIES_SET, tags);
-
-        if (entrySize >= 512) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-        else {
-            status = deploymentAdmin_performRequest(admin, entry);
-        }
-    }
-
-    return status;
-}
-
-static celix_status_t deploymentAdmin_auditEventFrameworkStarted(deployment_admin_pt admin) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    char entry[512];
-    int entrySize = 0;
-
-    entrySize = snprintf(entry, 512, "%s,%llu,%u,0,%i\n", admin->targetIdentification, admin->auditlogId, admin->aditlogSeqNr++, DEPLOYMENT_ADMIN_AUDIT_EVENT__FRAMEWORK_STARTED);
-
-    if (entrySize >= 512) {
-        status = CELIX_BUNDLE_EXCEPTION;
-    }
-    else {
-        status = deploymentAdmin_performRequest(admin, entry);
-    }
-
-    return status;
-}
-
-
-static void *deploymentAdmin_poll(void *deploymentAdmin) {
-	deployment_admin_pt admin = deploymentAdmin;
-
-	/*first poll send framework started audit event, note this will register the target in Apache ACE*/
-    deploymentAdmin_auditEventFrameworkStarted(admin);
-    deploymentAdmin_auditEventTargetPropertiesSet(admin);
-
-	while (admin->running) {
-        int i;
-
-		//poll ace
-		array_list_pt versions = NULL;
-	    arrayList_create(&versions);
-
-		deploymentAdmin_readVersions(admin, versions);
-
-		char *last = arrayList_get(versions, arrayList_size(versions) - 1);
-
-		if (last != NULL) {
-			if (admin->current == NULL || strcmp(last, admin->current) != 0) {
-				int length = strlen(admin->pollUrl) + strlen(last) + 2;
-				char request[length];
-
-				// TODO
-                //      We do not yet support fix packages
-                //		Check string lenght!
-                // snprintf(request, length, "%s/%s?current=%s", admin->pollUrl, last, admin->current);
-                snprintf(request, length, "%s/%s", admin->pollUrl, last);
-
-				char *inputFilename = NULL;
-				celix_status_t status = deploymentAdmin_download(admin ,request, &inputFilename);
-				if (status == CELIX_SUCCESS) {
-					bundle_pt bundle = NULL;
-					bundleContext_getBundle(admin->context, &bundle);
-					char *entry = NULL;
-					bundle_getEntry(bundle, "/", &entry);
-
-					// Handle file
-					char tmpDir[256];
-					char uuid[37];
-					uuid_t uid;
-					uuid_generate(uid);
-					uuid_unparse(uid, uuid);
-                    snprintf(tmpDir, 256, "%s%s", entry, uuid);
-                    if( mkdir(tmpDir, S_IRWXU) == -1){
-                        fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Failed creating directory %s",tmpDir);
-                    }
-
-					// TODO: update to use bundle cache DataFile instead of module entries.
-					unzip_extractDeploymentPackage(inputFilename, tmpDir);
-					int length = strlen(tmpDir) + 22;
-					char manifest[length];
-					snprintf(manifest, length, "%s/META-INF/MANIFEST.MF", tmpDir);
-					manifest_pt mf = NULL;
-					manifest_createFromFile(manifest, &mf);
-					deployment_package_pt source = NULL;
-					deploymentPackage_create(admin->context, mf, &source);
-					const char *name = NULL;
-					deploymentPackage_getName(source, &name);
-
-					int repoDirLength = strlen(entry) + 5;
-					char repoDir[repoDirLength];
-					snprintf(repoDir, repoDirLength, "%srepo", entry);
-					if( mkdir(repoDir, S_IRWXU) == -1){
-						fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Failed creating directory %s",repoDir);
-					}
-
-					int repoCacheLength = strlen(entry) + strlen(name) + 6;
-					char repoCache[repoCacheLength];
-					snprintf(repoCache, repoCacheLength, "%srepo/%s", entry, name);
-					deploymentAdmin_deleteTree(repoCache);
-					int stat = rename(tmpDir, repoCache);
-					if (stat != 0) {
-						fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "No success");
-					}
-
-					deployment_package_pt target = hashMap_get(admin->packages, name);
-					if (target == NULL) {
-//						target = empty package
-					}
-
-					deploymentAdmin_stopDeploymentPackageBundles(admin, target);
-					deploymentAdmin_updateDeploymentPackageBundles(admin, source);
-					deploymentAdmin_startDeploymentPackageCustomizerBundles(admin, source, target);
-					deploymentAdmin_processDeploymentPackageResources(admin, source);
-					deploymentAdmin_dropDeploymentPackageResources(admin, source, target);
-					deploymentAdmin_dropDeploymentPackageBundles(admin, source, target);
-					deploymentAdmin_startDeploymentPackageBundles(admin, source);
-
-					deploymentAdmin_deleteTree(repoCache);
-					deploymentAdmin_deleteTree(tmpDir);
-					if( remove(inputFilename) == -1){
-						fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Remove of %s failed",inputFilename);
-					}
-					admin->current = strdup(last);
-					hashMap_put(admin->packages, (char*)name, source);
-
-                    free(entry);
-				}
-				if (inputFilename != NULL) {
-					free(inputFilename);
-				}
-			}
-		}
-
-		sleep(5);
-
-		for (i = arrayList_size(versions); i > 0; --i) {
-		    free(arrayList_remove(versions, 0));
-		}
-
-		arrayList_destroy(versions);
-	}
-
-	return NULL;
-}
-
-struct MemoryStruct {
-	char *memory;
-	size_t size;
-};
-
-size_t deploymentAdmin_parseVersions(void *contents, size_t size, size_t nmemb, void *userp) {
-	size_t realsize = size * nmemb;
-	struct MemoryStruct *mem = (struct MemoryStruct *)userp;
-
-	mem->memory = realloc(mem->memory, mem->size + realsize + 1);
-	if (mem->memory == NULL) {
-		/* out of memory! */
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "not enough memory (realloc returned NULL)");
-		exit(EXIT_FAILURE);
-	}
-
-	memcpy(&(mem->memory[mem->size]), contents, realsize);
-	mem->size += realsize;
-	mem->memory[mem->size] = 0;
-
-	return realsize;
-}
-
-celix_status_t deploymentAdmin_readVersions(deployment_admin_pt admin, array_list_pt versions) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	CURL *curl;
-	CURLcode res;
-	curl = curl_easy_init();
-	struct MemoryStruct chunk;
-	chunk.memory = calloc(1, sizeof(char));
-	chunk.size = 0;
-	if (curl) {
-	    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-		curl_easy_setopt(curl, CURLOPT_URL, admin->pollUrl);
-		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, deploymentAdmin_parseVersions);
-		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunk);
-		curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
-		res = curl_easy_perform(curl);
-		if (res != CURLE_OK) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-		/* always cleanup */
-		curl_easy_cleanup(curl);
-
-		char *last;
-		char *token = strtok_r(chunk.memory, "\n", &last);
-		while (token != NULL) {
-			arrayList_add(versions, strdup(token));
-			token = strtok_r(NULL, "\n", &last);
-		}
-	}
-
-    if (chunk.memory) {
-        free(chunk.memory);
-    }
-
-	return status;
-}
-
-
-celix_status_t deploymentAdmin_download(deployment_admin_pt admin, char * url, char **inputFile) {
-	celix_status_t status = CELIX_SUCCESS;
-	CURL *curl = NULL;
-	CURLcode res = 0;
-	curl = curl_easy_init();
-	if (curl) {
-		const char *dir = NULL;
-		bundleContext_getProperty(admin->context, DEPLOYMENT_CACHE_DIR, &dir);
-		if (dir != NULL) {
-			*inputFile = calloc(1024, sizeof (char));
-			snprintf(*inputFile, 1024, "%s/%s", dir, "updateXXXXXX");
-		}
-		else {
-			*inputFile = strdup("updateXXXXXX");
-		}
-		umask(0011);
-        int fd = mkstemp(*inputFile);
-        if (fd != -1) {
-            FILE *fp = fopen(*inputFile, "wb+");
-            if(fp!=NULL){
-            	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-            	curl_easy_setopt(curl, CURLOPT_URL, url);
-            	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, deploymentAdmin_writeData);
-            	curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
-            	curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
-            	//curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
-            	//curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, updateCommand_downloadProgress);
-            	res = curl_easy_perform(curl);
-
-            	/* always cleanup */
-            	curl_easy_cleanup(curl);
-            	fclose(fp);
-            }
-            else{
-            	status = CELIX_FILE_IO_EXCEPTION;
-            }
-        }
-        else{
-        	status = CELIX_FILE_IO_EXCEPTION;
-        }
-	}
-	else{
-		res = CURLE_FAILED_INIT;
-	}
-
-	if (res != CURLE_OK) {
-		*inputFile[0] = '\0';
-		status = CELIX_ILLEGAL_STATE;
-	}
-
-	return status;
-}
-
-size_t deploymentAdmin_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream) {
-    size_t written = fwrite(ptr, size, nmemb, stream);
-    return written;
-}
-
-
-static celix_status_t deploymentAdmin_deleteTree(char * directory) {
-	DIR *dir;
-	celix_status_t status = CELIX_SUCCESS;
-	dir = opendir(directory);
-	if (dir == NULL) {
-	    status = CELIX_FILE_IO_EXCEPTION;
-	} else {
-
-		struct dirent* dent = NULL;
-
-		errno = 0;
-		dent = readdir(dir);
-		while (errno == 0 && dent != NULL) {
-			if ((strcmp((dent->d_name), ".") != 0) && (strcmp((dent->d_name), "..") != 0)) {
-				char subdir[512];
-				snprintf(subdir, sizeof(subdir), "%s/%s", directory, dent->d_name);
-
-				if (dent->d_type == DT_DIR) {
-					status = deploymentAdmin_deleteTree(subdir);
-				} else {
-					if (remove(subdir) != 0) {
-						status = CELIX_FILE_IO_EXCEPTION;
-						break;
-					}
-				}
-			}
-
-			errno = 0;
-			dent = readdir(dir);
-		}
-
-		if (errno != 0) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		} else if (closedir(dir) != 0) {
-			status = CELIX_FILE_IO_EXCEPTION;
-		} else if (rmdir(directory) != 0) {
-				status = CELIX_FILE_IO_EXCEPTION;
-		}
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to delete tree");
-
-	return status;
-}
-
-celix_status_t deploymentAdmin_stopDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt target) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (target != NULL) {
-		array_list_pt infos = NULL;
-		deploymentPackage_getBundleInfos(target, &infos);
-		int i;
-		for (i = 0; i < arrayList_size(infos); i++) {
-			bundle_pt bundle = NULL;
-			bundle_info_pt info = arrayList_get(infos, i);
-			deploymentPackage_getBundle(target, info->symbolicName, &bundle);
-			if (bundle != NULL) {
-				bundle_stop(bundle);
-			} else {
-				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "DEPLOYMENT_ADMIN: Bundle %s not found", info->symbolicName);
-			}
-		}
-		arrayList_destroy(infos);
-	}
-
-	return status;
-}
-
-celix_status_t deploymentAdmin_updateDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt infos = NULL;
-	deploymentPackage_getBundleInfos(source, &infos);
-	int i;
-	for (i = 0; i < arrayList_size(infos); i++) {
-		bundle_pt bundle = NULL;
-		bundle_info_pt info = arrayList_get(infos, i);
-
-		bundleContext_getBundle(admin->context, &bundle);
-		char *entry = NULL;
-		bundle_getEntry(bundle, "/", &entry);
-		const char *name = NULL;
-		deploymentPackage_getName(source, &name);
-
-		int bundlePathLength = strlen(entry) + strlen(name) + strlen(info->path) + 7;
-		int bsnLength = strlen(info->symbolicName) + 9;
-
-		char bundlePath[bundlePathLength];
-		snprintf(bundlePath, bundlePathLength, "%srepo/%s/%s", entry, name, info->path);
-
-		char bsn[bsnLength];
-		snprintf(bsn, bsnLength, "osgi-dp:%s", info->symbolicName);
-
-		bundle_pt updateBundle = NULL;
-		deploymentPackage_getBundle(source, info->symbolicName, &updateBundle);
-		if (updateBundle != NULL) {
-			//printf("Update bundle from: %s\n", bundlePath);
-			bundle_update(updateBundle, bundlePath);
-		} else {
-			//printf("Install bundle from: %s\n", bundlePath);
-			bundleContext_installBundle2(admin->context, bsn, bundlePath, &updateBundle);
-		}
-
-        free(entry);
-	}
-	arrayList_destroy(infos);
-	return status;
-}
-
-celix_status_t deploymentAdmin_startDeploymentPackageCustomizerBundles(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt bundles = NULL;
-	array_list_pt sourceInfos = NULL;
-
-	arrayList_create(&bundles);
-
-	deploymentPackage_getBundleInfos(source, &sourceInfos);
-	int i;
-	for (i = 0; i < arrayList_size(sourceInfos); i++) {
-		bundle_info_pt sourceInfo = arrayList_get(sourceInfos, i);
-		if (sourceInfo->customizer) {
-			bundle_pt bundle = NULL;
-			deploymentPackage_getBundle(source, sourceInfo->symbolicName, &bundle);
-			if (bundle != NULL) {
-				arrayList_add(bundles, bundle);
-			}
-		}
-	}
-	arrayList_destroy(sourceInfos);
-
-	if (target != NULL) {
-		array_list_pt targetInfos = NULL;
-		deploymentPackage_getBundleInfos(target, &targetInfos);
-		for (i = 0; i < arrayList_size(targetInfos); i++) {
-			bundle_info_pt targetInfo = arrayList_get(targetInfos, i);
-			if (targetInfo->customizer) {
-				bundle_pt bundle = NULL;
-				deploymentPackage_getBundle(target, targetInfo->symbolicName, &bundle);
-				if (bundle != NULL) {
-					arrayList_add(bundles, bundle);
-				}
-			}
-		}
-		arrayList_destroy(targetInfos);
-	}
-
-	for (i = 0; i < arrayList_size(bundles); i++) {
-		bundle_pt bundle = arrayList_get(bundles, i);
-		bundle_start(bundle);
-	}
-
-    arrayList_destroy(bundles);
-
-	return status;
-}
-
-celix_status_t deploymentAdmin_processDeploymentPackageResources(deployment_admin_pt admin, deployment_package_pt source) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt infos = NULL;
-	deploymentPackage_getResourceInfos(source, &infos);
-	int i;
-	for (i = 0; i < arrayList_size(infos); i++) {
-		resource_info_pt info = arrayList_get(infos, i);
-		array_list_pt services = NULL;
-		int length = strlen(OSGI_FRAMEWORK_SERVICE_PID) + strlen(info->resourceProcessor) + 4;
-		char filter[length];
-
-		snprintf(filter, length, "(%s=%s)", OSGI_FRAMEWORK_SERVICE_PID, info->resourceProcessor);
-
-		status = bundleContext_getServiceReferences(admin->context, DEPLOYMENTADMIN_RESOURCE_PROCESSOR_SERVICE, filter, &services);
-		if (status == CELIX_SUCCESS) {
-			if (services != NULL && arrayList_size(services) > 0) {
-				service_reference_pt ref = arrayList_get(services, 0);
-				// In Felix a check is done to assure the processor belongs to the deployment package
-				// Is this according to spec?
-				void *processorP = NULL;
-				status = bundleContext_getService(admin->context, ref, &processorP);
-				if (status == CELIX_SUCCESS) {
-					bundle_pt bundle = NULL;
-					char *entry = NULL;
-					const char *name = NULL;
-					const char *packageName = NULL;
-					resource_processor_service_pt processor = processorP;
-
-					bundleContext_getBundle(admin->context, &bundle);
-					bundle_getEntry(bundle, "/", &entry);
-					deploymentPackage_getName(source, &name);
-
-					int length = strlen(entry) + strlen(name) + strlen(info->path) + 7;
-					char resourcePath[length];
-					snprintf(resourcePath, length, "%srepo/%s/%s", entry, name, info->path);
-					deploymentPackage_getName(source, &packageName);
-
-					processor->begin(processor->processor, (char*)packageName);
-					processor->process(processor->processor, info->path, resourcePath);
-
-                    free(entry);
-				}
-			}
-		}
-
-		if(services != NULL) {
-			arrayList_destroy(services);
-		}
-	}
-
-    arrayList_destroy(infos);
-
-
-	return status;
-}
-
-celix_status_t deploymentAdmin_dropDeploymentPackageResources(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (target != NULL) {
-        array_list_pt infos = NULL;
-        deploymentPackage_getResourceInfos(target, &infos);
-        int i;
-        for (i = 0; i < arrayList_size(infos); i++) {
-            resource_info_pt info = arrayList_get(infos, i);
-            resource_info_pt sourceInfo = NULL;
-            deploymentPackage_getResourceInfoByPath(source, info->path, &sourceInfo);
-            if (sourceInfo == NULL) {
-                array_list_pt services = NULL;
-                int length = strlen(OSGI_FRAMEWORK_SERVICE_PID) + strlen(info->resourceProcessor) + 4;
-                char filter[length];
-
-                snprintf(filter, length, "(%s=%s)", OSGI_FRAMEWORK_SERVICE_PID, info->resourceProcessor);
-                status = bundleContext_getServiceReferences(admin->context, DEPLOYMENTADMIN_RESOURCE_PROCESSOR_SERVICE, filter, &services);
-                if (status == CELIX_SUCCESS) {
-                    if (services != NULL && arrayList_size(services) > 0) {
-                        service_reference_pt ref = arrayList_get(services, 0);
-                        // In Felix a check is done to assure the processor belongs to the deployment package
-                        // Is this according to spec?
-                        void *processorP = NULL;
-                        status = bundleContext_getService(admin->context, ref, &processorP);
-                        if (status == CELIX_SUCCESS) {
-                            const char *packageName = NULL;
-                            resource_processor_service_pt processor = processorP;
-
-                            deploymentPackage_getName(source, &packageName);
-                            processor->begin(processor->processor, (char*)packageName);
-                            processor->dropped(processor->processor, info->path);
-                        }
-                    }
-                }
-
-                if (services != NULL) {
-                    arrayList_destroy(services);
-                }
-
-            }
-        }
-
-        arrayList_destroy(infos);
-    }
-
-    return status;
-}
-
-celix_status_t deploymentAdmin_dropDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (target != NULL) {
-		array_list_pt targetInfos = NULL;
-		deploymentPackage_getBundleInfos(target, &targetInfos);
-		int i;
-		for (i = 0; i < arrayList_size(targetInfos); i++) {
-			bundle_info_pt targetInfo = arrayList_get(targetInfos, i);
-			if (!targetInfo->customizer) {
-				bundle_info_pt info = NULL;
-				deploymentPackage_getBundleInfoByName(source, targetInfo->symbolicName, &info);
-				if (info == NULL) {
-					bundle_pt bundle = NULL;
-					deploymentPackage_getBundle(target, targetInfo->symbolicName, &bundle);
-					bundle_uninstall(bundle);
-				}
-			}
-		}
-		arrayList_destroy(targetInfos);
-	}
-
-	return status;
-}
-
-celix_status_t deploymentAdmin_startDeploymentPackageBundles(deployment_admin_pt admin, deployment_package_pt source) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt infos = NULL;
-	deploymentPackage_getBundleInfos(source, &infos);
-	int i;
-	for (i = 0; i < arrayList_size(infos); i++) {
-		bundle_pt bundle = NULL;
-		bundle_info_pt info = arrayList_get(infos, i);
-		if (!info->customizer) {
-			deploymentPackage_getBundle(source, info->symbolicName, &bundle);
-			if (bundle != NULL) {
-				bundle_start(bundle);
-			} else {
-				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "DEPLOYMENT_ADMIN: Could not start bundle %s", info->symbolicName);
-			}
-		}
-	}
-	arrayList_destroy(infos);
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/src/deployment_admin_activator.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/deployment_admin_activator.c b/deployment_admin/private/src/deployment_admin_activator.c
deleted file mode 100644
index 93fd6b5..0000000
--- a/deployment_admin/private/src/deployment_admin_activator.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- *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.
- */
-/*
- * deployment_admin_activator.c
- *
- *  \date       Nov 7, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-#include "deployment_admin.h"
-
-struct bundle_activator {
-	deployment_admin_pt admin;
-};
-
-typedef struct bundle_activator* bundle_activator_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bundle_activator_pt activator = NULL;
-
-	activator = calloc(1, sizeof(*activator));
-	if (!activator) {
-		status = CELIX_ENOMEM;
-	} else {
-		status = deploymentAdmin_create(context, &activator->admin);
-
-		*userData = activator;
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status;
-
-	bundle_activator_pt activator = (bundle_activator_pt) userData;
-
-	status = deploymentAdmin_destroy(activator->admin);
-
-	free(activator);
-
-	return status;
-}
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/src/deployment_package.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/deployment_package.c b/deployment_admin/private/src/deployment_package.c
deleted file mode 100644
index 1520db8..0000000
--- a/deployment_admin/private/src/deployment_package.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/**
- *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.
- */
-/*
- * deployment_package.c
- *
- *  \date       Nov 8, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "celix_errno.h"
-
-#include "deployment_package.h"
-#include "constants.h"
-#include "utils.h"
-#include "bundle_context.h"
-#include "module.h"
-#include "bundle.h"
-
-static const char * const RESOURCE_PROCESSOR = "Resource-Processor";
-static const char * const DEPLOYMENTPACKAGE_CUSTOMIZER = "DeploymentPackage-Customizer";
-
-celix_status_t deploymentPackage_processEntries(deployment_package_pt package);
-static celix_status_t deploymentPackage_isBundleResource(properties_pt attributes, bool *isBundleResource);
-static celix_status_t deploymentPackage_parseBooleanHeader(const char *value, bool *boolValue);
-
-celix_status_t deploymentPackage_create(bundle_context_pt context, manifest_pt manifest, deployment_package_pt *package) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*package = calloc(1, sizeof(**package));
-	if (!(*package)) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*package)->context = context;
-		(*package)->manifest = manifest;
-		(*package)->bundleInfos = NULL;
-		(*package)->resourceInfos = NULL;
-		(*package)->nameToBundleInfo = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-		(*package)->pathToEntry = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-		status = arrayList_create(&(*package)->bundleInfos);
-		if (status == CELIX_SUCCESS) {
-			status = arrayList_create(&(*package)->resourceInfos);
-			if (status == CELIX_SUCCESS) {
-				status = deploymentPackage_processEntries(*package);
-				if (status == CELIX_SUCCESS) {
-					int i;
-					for (i = 0; i < arrayList_size((*package)->bundleInfos); i++) {
-						bundle_info_pt info = arrayList_get((*package)->bundleInfos, i);
-						hashMap_put((*package)->nameToBundleInfo, info->symbolicName, info);
-					}
-					for (i = 0; i < arrayList_size((*package)->resourceInfos); i++) {
-						resource_info_pt info = arrayList_get((*package)->resourceInfos, i);
-						hashMap_put((*package)->pathToEntry, info->path, info);
-					}
-				}
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t deploymentPackage_destroy(deployment_package_pt package) {
-	celix_status_t status = CELIX_SUCCESS;
-	int i;
-
-
-    manifest_destroy(package->manifest);
-
-	hashMap_destroy(package->nameToBundleInfo, false, false);
-	hashMap_destroy(package->pathToEntry, false, false);
-
-
-    for(i = arrayList_size(package->bundleInfos); i  > 0; --i) {
-        free(arrayList_remove(package->bundleInfos, 0));
-    }
-
-	arrayList_destroy(package->bundleInfos);
-
-    for (i = arrayList_size(package->resourceInfos); i > 0; --i) {
-        free(arrayList_remove(package->resourceInfos, 0));
-    }
-
-
-	arrayList_destroy(package->resourceInfos);
-
-	free(package);
-
-	return status;
-}
-
-celix_status_t deploymentPackage_getName(deployment_package_pt package, const char **name) {
-	*name = manifest_getValue(package->manifest, "DeploymentPackage-SymbolicName");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deploymentPackage_getBundleInfos(deployment_package_pt package, array_list_pt *infos) {
-	*infos = arrayList_clone(package->bundleInfos);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deploymentPackage_getBundleInfoByName(deployment_package_pt package, const char *name, bundle_info_pt *info) {
-	*info = hashMap_get(package->nameToBundleInfo, name);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deploymentPackage_getBundle(deployment_package_pt package, const char *name, bundle_pt *bundle) {
-	if (hashMap_containsKey(package->nameToBundleInfo, name)) {
-		array_list_pt bundles = NULL;
-		bundleContext_getBundles(package->context, &bundles);
-		int i;
-		for (i = 0; i < arrayList_size(bundles); i++) {
-			bundle_pt ibundle = arrayList_get(bundles, i);
-			module_pt module = NULL;
-			bundle_getCurrentModule(ibundle, &module);
-			const char *bsn = NULL;
-			module_getSymbolicName(module, &bsn);
-			if (strcmp(bsn, name) == 0) {
-				*bundle = ibundle;
-				break;
-			}
-		}
-
-		arrayList_destroy(bundles);
-	}
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deploymentPackage_getResourceInfos(deployment_package_pt package, array_list_pt *infos) {
-	*infos = arrayList_clone(package->resourceInfos);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deploymentPackage_getResourceInfoByPath(deployment_package_pt package, const char *path, resource_info_pt *info) {
-	*info = hashMap_get(package->pathToEntry, path);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deploymentPackage_getVersion(deployment_package_pt package, version_pt *version) {
-	const char *versionStr = manifest_getValue(package->manifest, "DeploymentPackage-Version");
-	return version_createVersionFromString(versionStr, version);
-}
-
-celix_status_t deploymentPackage_processEntries(deployment_package_pt package) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	hash_map_pt entries = NULL;
-	manifest_getEntries(package->manifest, &entries);
-	hash_map_iterator_pt iter = hashMapIterator_create(entries);
-	while (hashMapIterator_hasNext(iter)) {
-		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-		char *name = hashMapEntry_getKey(entry);
-		properties_pt values = hashMapEntry_getValue(entry);
-
-		bool isBundleResource;
-		deploymentPackage_isBundleResource(values, &isBundleResource);
-		if (isBundleResource) {
-			bundle_info_pt info = calloc(1, sizeof(*info));
-			info->path = name;
-			info->attributes = values;
-			info->symbolicName = (char*)properties_get(values, OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME);
-			const char *version = properties_get(values, OSGI_FRAMEWORK_BUNDLE_VERSION);
-			info->version = NULL;
-			status = version_createVersionFromString((char*)version, &info->version);
-			const char *customizer = properties_get(values, DEPLOYMENTPACKAGE_CUSTOMIZER);
-			deploymentPackage_parseBooleanHeader((char*)customizer, &info->customizer);
-
-			arrayList_add(package->bundleInfos, info);
-		} else {
-			resource_info_pt info = calloc(1, sizeof(*info));
-			info->path = name;
-			info->attributes = values;
-			info->resourceProcessor = (char*)properties_get(values,RESOURCE_PROCESSOR);
-
-			arrayList_add(package->resourceInfos, info);
-		}
-	}
-	hashMapIterator_destroy(iter);
-
-	return status;
-}
-
-static celix_status_t deploymentPackage_isBundleResource(properties_pt attributes, bool *isBundleResource) {
-	*isBundleResource = properties_get(attributes, (char *) OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME) != NULL;
-	return CELIX_SUCCESS;
-}
-
-static celix_status_t deploymentPackage_parseBooleanHeader(const char *value, bool *boolValue) {
-	*boolValue = false;
-	if (value != NULL) {
-		if (strcmp(value, "true") == 0) {
-			*boolValue = true;
-		} else {
-			*boolValue = false;
-		}
-	}
-	return CELIX_SUCCESS;
-}
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/src/ioapi.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/ioapi.c b/deployment_admin/private/src/ioapi.c
deleted file mode 100644
index 49958f6..0000000
--- a/deployment_admin/private/src/ioapi.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* ioapi.h -- IO base function header for compress/uncompress .zip
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications for Zip64 support
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-*/
-
-#if (defined(_WIN32))
-        #define _CRT_SECURE_NO_WARNINGS
-#endif
-
-#include "ioapi.h"
-
-voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
-{
-    if (pfilefunc->zfile_func64.zopen64_file != NULL)
-        return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
-    else
-    {
-        return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
-    }
-}
-
-long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
-{
-    if (pfilefunc->zfile_func64.zseek64_file != NULL)
-        return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
-    else
-    {
-        uLong offsetTruncated = (uLong)offset;
-        if (offsetTruncated != offset)
-            return -1;
-        else
-            return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
-    }
-}
-
-ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
-{
-    if (pfilefunc->zfile_func64.zseek64_file != NULL)
-        return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
-    else
-    {
-        uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
-        if ((tell_uLong) == ((uLong)-1))
-            return (ZPOS64_T)-1;
-        else
-            return tell_uLong;
-    }
-}
-
-void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
-{
-    p_filefunc64_32->zfile_func64.zopen64_file = NULL;
-    p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
-    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
-    p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
-    p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
-    p_filefunc64_32->zfile_func64.ztell64_file = NULL;
-    p_filefunc64_32->zfile_func64.zseek64_file = NULL;
-    p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
-    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
-    p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
-    p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
-    p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
-}
-
-
-
-static voidpf  ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
-static uLong   ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-static uLong   ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
-static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
-static long    ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
-static int     ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
-static int     ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
-
-static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
-{
-    FILE* file = NULL;
-    const char* mode_fopen = NULL;
-    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
-        mode_fopen = "rb";
-    else
-    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
-        mode_fopen = "r+b";
-    else
-    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
-        mode_fopen = "wb";
-
-    if ((filename!=NULL) && (mode_fopen != NULL))
-        file = fopen(filename, mode_fopen);
-    return file;
-}
-
-static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
-{
-    FILE* file = NULL;
-    const char* mode_fopen = NULL;
-    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
-        mode_fopen = "rb";
-    else
-    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
-        mode_fopen = "r+b";
-    else
-    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
-        mode_fopen = "wb";
-
-    if ((filename!=NULL) && (mode_fopen != NULL))
-        file = fopen64((const char*)filename, mode_fopen);
-    return file;
-}
-
-
-static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
-{
-    uLong ret;
-    ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
-    return ret;
-}
-
-static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
-{
-    uLong ret;
-    ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
-    return ret;
-}
-
-static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
-{
-    long ret;
-    ret = ftell((FILE *)stream);
-    return ret;
-}
-
-
-static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
-{
-    ZPOS64_T ret;
-    ret = ftello64((FILE *)stream);
-    return ret;
-}
-
-static long ZCALLBACK fseek_file_func (voidpf  opaque, voidpf stream, uLong offset, int origin)
-{
-    int fseek_origin=0;
-    long ret;
-    switch (origin)
-    {
-    case ZLIB_FILEFUNC_SEEK_CUR :
-        fseek_origin = SEEK_CUR;
-        break;
-    case ZLIB_FILEFUNC_SEEK_END :
-        fseek_origin = SEEK_END;
-        break;
-    case ZLIB_FILEFUNC_SEEK_SET :
-        fseek_origin = SEEK_SET;
-        break;
-    default: return -1;
-    }
-    ret = 0;
-    if (fseek((FILE *)stream, offset, fseek_origin) != 0)
-        ret = -1;
-    return ret;
-}
-
-static long ZCALLBACK fseek64_file_func (voidpf  opaque, voidpf stream, ZPOS64_T offset, int origin)
-{
-    int fseek_origin=0;
-    long ret;
-    switch (origin)
-    {
-    case ZLIB_FILEFUNC_SEEK_CUR :
-        fseek_origin = SEEK_CUR;
-        break;
-    case ZLIB_FILEFUNC_SEEK_END :
-        fseek_origin = SEEK_END;
-        break;
-    case ZLIB_FILEFUNC_SEEK_SET :
-        fseek_origin = SEEK_SET;
-        break;
-    default: return -1;
-    }
-    ret = 0;
-
-    if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)
-                        ret = -1;
-
-    return ret;
-}
-
-
-static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
-{
-    int ret;
-    ret = fclose((FILE *)stream);
-    return ret;
-}
-
-static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
-{
-    int ret;
-    ret = ferror((FILE *)stream);
-    return ret;
-}
-
-void fill_fopen_filefunc (pzlib_filefunc_def)
-  zlib_filefunc_def* pzlib_filefunc_def;
-{
-    pzlib_filefunc_def->zopen_file = fopen_file_func;
-    pzlib_filefunc_def->zread_file = fread_file_func;
-    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
-    pzlib_filefunc_def->ztell_file = ftell_file_func;
-    pzlib_filefunc_def->zseek_file = fseek_file_func;
-    pzlib_filefunc_def->zclose_file = fclose_file_func;
-    pzlib_filefunc_def->zerror_file = ferror_file_func;
-    pzlib_filefunc_def->opaque = NULL;
-}
-
-void fill_fopen64_filefunc (zlib_filefunc64_def*  pzlib_filefunc_def)
-{
-    pzlib_filefunc_def->zopen64_file = fopen64_file_func;
-    pzlib_filefunc_def->zread_file = fread_file_func;
-    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
-    pzlib_filefunc_def->ztell64_file = ftell64_file_func;
-    pzlib_filefunc_def->zseek64_file = fseek64_file_func;
-    pzlib_filefunc_def->zclose_file = fclose_file_func;
-    pzlib_filefunc_def->zerror_file = ferror_file_func;
-    pzlib_filefunc_def->opaque = NULL;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/src/log.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/log.c b/deployment_admin/private/src/log.c
deleted file mode 100644
index 98e757d..0000000
--- a/deployment_admin/private/src/log.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- *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.
- */
-/*
- * log.c
- *
- *  \date       Apr 19, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-
-#include "celix_errno.h"
-
-#include "log.h"
-#include "log_store.h"
-
-struct log {
-	log_store_pt logStore;
-};
-
-celix_status_t log_create(log_store_pt store, log_pt *log) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*log = calloc(1, sizeof(**log));
-	if (!*log) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*log)->logStore = store;
-	}
-
-	return status;
-}
-
-celix_status_t log_destroy(log_pt *log) {
-	free(*log);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t log_log(log_pt log, unsigned int type, properties_pt properties) {
-	celix_status_t status;
-
-	log_event_pt event = NULL;
-
-	status = logStore_put(log->logStore, type, properties, &event);
-
-	return status;
-}
-
-celix_status_t log_bundleChanged(void * listener, bundle_event_pt event) {
-	return CELIX_SUCCESS;
-}
-
-celix_status_t log_frameworkEvent(void * listener, framework_event_pt event) {
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/src/log_store.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/log_store.c b/deployment_admin/private/src/log_store.c
deleted file mode 100644
index c2bfabc..0000000
--- a/deployment_admin/private/src/log_store.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- *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.
- */
-/*
- * log_store.c
- *
- *  \date       Apr 18, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include <time.h>
-
-#include "celix_errno.h"
-#include "array_list.h"
-
-#include "log_store.h"
-#include "log.h"
-
-struct log_store {
-	unsigned long storeId;
-
-	array_list_pt logEvents;
-};
-
-static celix_status_t logStore_getNextID(log_store_pt store, unsigned long *id);
-
-celix_status_t logStore_create(log_store_pt *store) {
-	celix_status_t status = CELIX_SUCCESS;
-	*store = calloc(1, sizeof(**store));
-	if (!*store) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*store)->storeId = 1;
-		arrayList_create(&(*store)->logEvents);
-	}
-
-	return status;
-}
-
-celix_status_t logStore_put(log_store_pt store, unsigned int type, properties_pt properties, log_event_pt *event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*event = calloc(1, sizeof(**event));
-	(*event)->targetId = NULL;
-	(*event)->logId = store->storeId;
-	(*event)->id = 0;
-	(*event)->time = time(NULL);
-	(*event)->type = type;
-	(*event)->properties = properties;
-
-	logStore_getNextID(store, &(*event)->id);
-
-	arrayList_add(store->logEvents, *event);
-
-	return status;
-}
-
-celix_status_t logStore_getLogId(log_store_pt store, unsigned long *id) {
-	*id = store->storeId;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t logStore_getEvents(log_store_pt store, array_list_pt *events) {
-	*events = store->logEvents;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t logStore_getHighestId(log_store_pt store, long *id) {
-	*id = ((long) arrayList_size(store->logEvents)) - 1;
-	return CELIX_SUCCESS;
-}
-
-static celix_status_t logStore_getNextID(log_store_pt store, unsigned long *id) {
-	*id = arrayList_size(store->logEvents);
-	return CELIX_SUCCESS;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/src/log_sync.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/log_sync.c b/deployment_admin/private/src/log_sync.c
deleted file mode 100644
index 242beea..0000000
--- a/deployment_admin/private/src/log_sync.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- *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.
- */
-/*
- * log_sync.c
- *
- *  \date       Apr 19, 2012
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <curl/curl.h>
-#include <curl/easy.h>
-
-#include "celix_errno.h"
-#include "celix_log.h"
-#include "celixbool.h"
-
-#include "celix_threads.h"
-
-#include "log_sync.h"
-#include "log_event.h"
-
-struct log_sync {
-	log_store_pt logStore;
-
-	char *targetId;
-	bool running;
-
-	celix_thread_t syncTask;
-};
-
-struct log_descriptor {
-	char *targetId;
-	unsigned long logId;
-	unsigned long low;
-	unsigned long high;
-};
-
-typedef struct log_descriptor *log_descriptor_pt;
-
-celix_status_t logSync_queryLog(log_sync_pt logSync, char *targetId, long logId, char **queryReply);
-static size_t logSync_readQeury(void *contents, size_t size, size_t nmemb, void *userp);
-static void *logSync_synchronize(void *logSyncP);
-
-celix_status_t logSync_create(char *targetId, log_store_pt store, log_sync_pt *logSync) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*logSync = calloc(1, sizeof(**logSync));
-	if (!*logSync) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*logSync)->logStore = store;
-		(*logSync)->targetId = targetId;
-		(*logSync)->syncTask = celix_thread_default;
-		(*logSync)->running = true;
-
-		celixThread_create(&(*logSync)->syncTask, NULL, logSync_synchronize, *logSync);
-	}
-
-	return status;
-}
-
-celix_status_t logSync_parseLogDescriptor(log_sync_pt logSync, char *descriptorString, log_descriptor_pt *descriptor) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Descriptor: %s", descriptorString);
-	char *last = NULL;
-	char *targetId = strtok_r(descriptorString, ",", &last);
-	char *logIdStr = strtok_r(NULL, ",", &last);
-	long logId = 0;
-	if (logIdStr != NULL) {
-		logId = atol(logIdStr);
-	}
-	char *range = strtok_r(NULL, ",", &last);
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Range: %s", range);
-
-	long low = 0;
-	long high = 0;
-	if (range != NULL) {
-		char *rangeToken = NULL;
-		low = atol(strtok_r(range, "-", &rangeToken));
-		high = atol(strtok_r(NULL, "-", &rangeToken));
-	}
-
-	*descriptor = calloc(1, sizeof(**descriptor));
-	if (!*descriptor) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*descriptor)->targetId = targetId;
-		(*descriptor)->logId = logId;
-		(*descriptor)->low = low;
-		(*descriptor)->high = high;
-	}
-
-	return status;
-}
-
-static void *logSync_synchronize(void *logSyncP) {
-	log_sync_pt logSync = logSyncP;
-
-	while (logSync->running) {
-
-		//query current log
-		// http://localhost:8080/auditlog/query?tid=targetid&logid=logid
-		char *logDescriptorString = NULL;
-		unsigned long id = 0;
-		logStore_getLogId(logSync->logStore, &id);
-		logSync_queryLog(logSync, logSync->targetId, id, &logDescriptorString);
-		log_descriptor_pt descriptor = NULL;
-		logSync_parseLogDescriptor(logSync, logDescriptorString, &descriptor);
-
-		long highest = 0;
-		logStore_getHighestId(logSync->logStore, &highest);
-
-		if (highest >= 0) {
-			int i;
-			for (i = descriptor->high + 1; i <= highest; i++) {
-				array_list_pt events = NULL;
-				logStore_getEvents(logSync->logStore, &events);
-			}
-		}
-
-		if(descriptor!=NULL){
-			free(descriptor);
-		}
-
-		sleep(10);
-	}
-
-
-	celixThread_exit(NULL);
-	return NULL;
-}
-
-struct MemoryStruct {
-	char *memory;
-	size_t size;
-};
-
-celix_status_t logSync_queryLog(log_sync_pt logSync, char *targetId, long logId, char **queryReply) {
-	// http://localhost:8080/auditlog/query?tid=targetid&logid=logid
-	celix_status_t status = CELIX_SUCCESS;
-	int length = strlen(targetId) + 60;
-	char query[length];
-	snprintf(query, length, "http://localhost:8080/auditlog/query?tid=%s&logid=1", targetId);
-
-	CURL *curl;
-	CURLcode res;
-	curl = curl_easy_init();
-	struct MemoryStruct chunk;
-	chunk.memory = calloc(1, sizeof(char));
-	chunk.size = 0;
-	if (curl) {
-		curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-		curl_easy_setopt(curl, CURLOPT_URL, query);
-		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, logSync_readQeury);
-		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunk);
-		curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
-		res = curl_easy_perform(curl);
-		if (res != CURLE_OK) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error: %d", res);
-		/* always cleanup */
-		curl_easy_cleanup(curl);
-
-		*queryReply = strdup(chunk.memory);
-	}
-
-	return status;
-}
-
-static size_t logSync_readQeury(void *contents, size_t size, size_t nmemb, void *userp) {
-	size_t realsize = size * nmemb;
-	struct MemoryStruct *mem = (struct MemoryStruct *)userp;
-
-	mem->memory = realloc(mem->memory, mem->size + realsize + 1);
-	if (mem->memory == NULL) {
-		/* out of memory! */
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "not enough memory (realloc returned NULL)");
-		exit(EXIT_FAILURE);
-	}
-
-	memcpy(&(mem->memory[mem->size]), contents, realsize);
-	mem->size += realsize;
-	mem->memory[mem->size] = 0;
-
-	return realsize;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/private/src/miniunz.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/miniunz.c b/deployment_admin/private/src/miniunz.c
deleted file mode 100644
index e543c3b..0000000
--- a/deployment_admin/private/src/miniunz.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/** License
- * ----------------------------------------------------------
- *    Condition of use and distribution are the same than zlib :
- *
- *   This software is provided 'as-is', without any express or implied
- *   warranty.  In no event will the authors be held liable for any damages
- *   arising from the use of this software.
- *
- *   Permission is granted to anyone to use this software for any purpose,
- *   including commercial applications, and to alter it and redistribute it
- *   freely, subject to the following restrictions:
- *
- *   1. The origin of this software must not be misrepresented; you must not
- *      claim that you wrote the original software. If you use this software
- *      in a product, an acknowledgment in the product documentation would be
- *      appreciated but is not required.
- *   2. Altered source versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software.
- *   3. This notice may not be removed or altered from any source distribution.
- *
- * ----------------------------------------------------------
- */
-/*
-   miniunz.c
-   Version 1.1, February 14h, 2010
-   sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications of Unzip for Zip64
-         Copyright (C) 2007-2008 Even Rouault
-
-         Modifications for Zip64 support on both zip and unzip
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-    Changes made to the original source specific for Apache Celix:
-    * Updated several parts to use output directory fitting Celix.
-    * Removed several parts not needed (main function etc).
-    * Added some checks for OSX/Apple
-*/
-
-#ifndef _WIN32
-        #ifndef __USE_FILE_OFFSET64
-                #define __USE_FILE_OFFSET64
-        #endif
-        #ifndef __USE_LARGEFILE64
-                #define __USE_LARGEFILE64
-        #endif
-        #ifndef _LARGEFILE64_SOURCE
-                #define _LARGEFILE64_SOURCE
-        #endif
-        #ifndef _FILE_OFFSET_BIT
-                #define _FILE_OFFSET_BIT 64
-        #endif
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#include <unistd.h>
-#include <utime.h>
-#include <sys/stat.h>
-
-#include "unzip.h"
-#include "archive.h"
-
-#define CASESENSITIVITY (0)
-#define WRITEBUFFERSIZE (8192)
-#define MAXFILENAME (256)
-
-#ifdef _WIN32
-#define USEWIN32IOAPI
-#include "iowin32.h"
-#endif
-/*
-  mini unzip, demo of unzip package
-
-  usage :
-  Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir]
-
-  list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT
-    if it exists
-*/
-
-
-/* change_file_date : change the date/time of a file
-    filename : the filename of the file where date/time must be modified
-    dosdate : the new date at the MSDos format (4 bytes)
-    tmu_date : the SAME new date at the tm_unz format */
-void change_file_date(filename,dosdate,tmu_date)
-    const char *filename;
-    uLong dosdate;
-    tm_unz tmu_date;
-{
-#ifdef _WIN32
-  HANDLE hFile;
-  FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
-
-  hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
-                      0,NULL,OPEN_EXISTING,0,NULL);
-  GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
-  DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
-  LocalFileTimeToFileTime(&ftLocal,&ftm);
-  SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
-  CloseHandle(hFile);
-#else
-#if defined(unix) || defined(__APPLE__)
-  struct utimbuf ut;
-  struct tm newdate;
-  newdate.tm_sec = tmu_date.tm_sec;
-  newdate.tm_min=tmu_date.tm_min;
-  newdate.tm_hour=tmu_date.tm_hour;
-  newdate.tm_mday=tmu_date.tm_mday;
-  newdate.tm_mon=tmu_date.tm_mon;
-  if (tmu_date.tm_year > 1900)
-      newdate.tm_year=tmu_date.tm_year - 1900;
-  else
-      newdate.tm_year=tmu_date.tm_year ;
-  newdate.tm_isdst=-1;
-
-  ut.actime=ut.modtime=mktime(&newdate);
-  utime(filename,&ut);
-#endif
-#endif
-}
-
-
-/* mymkdir and change_file_date are not 100 % portable
-   As I don't know well Unix, I wait feedback for the unix portion */
-
-int mymkdir(dirname)
-    const char* dirname;
-{
-    int ret=0;
-#ifdef _WIN32
-    ret = _mkdir(dirname);
-#else
-#if defined unix || defined __APPLE__
-    ret = mkdir(dirname,0775);
-#endif
-#endif
-    return ret;
-}
-
-int makedir (newdir)
-    char *newdir;
-{
-  char *buffer ;
-  char *p;
-  int  len = (int)strlen(newdir);
-
-  if (len <= 0)
-    return 0;
-
-  buffer = (char*)malloc(len+1);
-        if (buffer==NULL)
-        {
-                printf("Error allocating memory\n");
-                return UNZ_INTERNALERROR;
-        }
-  strcpy(buffer,newdir);
-
-  if (buffer[len-1] == '/') {
-    buffer[len-1] = '\0';
-  }
-  if (mymkdir(buffer) == 0)
-    {
-      free(buffer);
-      return 1;
-    }
-
-  p = buffer+1;
-  while (1)
-    {
-      char hold;
-
-      while(*p && *p != '\\' && *p != '/')
-        p++;
-      hold = *p;
-      *p = 0;
-      if ((mymkdir(buffer) == -1) && (errno == ENOENT))
-        {
-          printf("couldn't create directory %s\n",buffer);
-          free(buffer);
-          return 0;
-        }
-      if (hold == 0)
-        break;
-      *p++ = hold;
-    }
-  free(buffer);
-  return 1;
-}
-
-int do_extract_currentfile(unzFile uf, char * revisionRoot) {
-    char filename_inzip[256];
-    char* filename_withoutpath;
-    char* p;
-    int err=UNZ_OK;
-    FILE *fout=NULL;
-    void* buf;
-    uInt size_buf;
-
-    unz_file_info64 file_info;
-    err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
-
-    if (err!=UNZ_OK)
-    {
-        printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
-        return err;
-    }
-
-    size_buf = WRITEBUFFERSIZE;
-    buf = (void*)malloc(size_buf);
-    if (buf==NULL)
-    {
-        printf("Error allocating memory\n");
-        return UNZ_INTERNALERROR;
-    }
-
-    p = filename_withoutpath = filename_inzip;
-    while ((*p) != '\0')
-    {
-        if (((*p)=='/') || ((*p)=='\\'))
-            filename_withoutpath = p+1;
-        p++;
-    }
-
-    if ((*filename_withoutpath)=='\0') {
-		char dir[strlen(revisionRoot) + strlen(filename_inzip) + 2];
-		strcpy(dir, revisionRoot);
-		strcat(dir, "/");
-		strcat(dir, filename_inzip);
-		mymkdir(dir);
-    }
-    else
-    {
-        const char* write_filename;
-        int skip=0;
-        write_filename = filename_inzip;
-
-        int length = strlen(write_filename) + strlen(revisionRoot) + 2;
-        char fWFN[length];
-        strcpy(fWFN, revisionRoot);
-        strcat(fWFN, "/");
-        strcat(fWFN, write_filename);
-
-        err = unzOpenCurrentFile(uf);
-        if (err!=UNZ_OK)
-        {
-            printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err);
-        }
-
-        if ((skip==0) && (err==UNZ_OK))
-        {
-            fout=fopen64(fWFN,"wb");
-
-            /* some zipfile don't contain directory alone before file */
-            if ((fout==NULL) && (filename_withoutpath!=(char*)filename_inzip))
-            {
-                char c=*(filename_withoutpath-1);
-                *(filename_withoutpath-1)='\0';
-                int length = strlen(write_filename) + strlen(revisionRoot) + 2;
-                char dir[length];
-				strcpy(dir, revisionRoot);
-				strcat(dir, "/");
-				strcat(dir, write_filename);
-                makedir(dir);
-                *(filename_withoutpath-1)=c;
-
-                fout=fopen64(fWFN,"wb");
-            }
-
-            if (fout==NULL)
-            {
-                printf("error opening %s\n",write_filename);
-            }
-        }
-
-        if (fout!=NULL)
-        {
-            do
-            {
-                err = unzReadCurrentFile(uf,buf,size_buf);
-                if (err<0)
-                {
-                    printf("error %d with zipfile in unzReadCurrentFile\n",err);
-                    break;
-                }
-                if (err>0)
-                    if (fwrite(buf,err,1,fout)!=1)
-                    {
-                        printf("error in writing extracted file\n");
-                        err=UNZ_ERRNO;
-                        break;
-                    }
-            }
-            while (err>0);
-            if (fout)
-                    fclose(fout);
-
-            if (err==0)
-                change_file_date(fWFN,file_info.dosDate,
-                                 file_info.tmu_date);
-        }
-
-        if (err==UNZ_OK)
-        {
-            err = unzCloseCurrentFile (uf);
-            if (err!=UNZ_OK)
-            {
-                printf("error %d with zipfile in unzCloseCurrentFile\n",err);
-            }
-        }
-        else
-            unzCloseCurrentFile(uf); /* don't lose the error */
-    }
-
-    free(buf);
-    return err;
-}
-
-
-int do_extract(unzFile uf, char * revisionRoot) {
-    uLong i;
-    unz_global_info64 gi;
-    int err;
-
-    err = unzGetGlobalInfo64(uf,&gi);
-    if (err!=UNZ_OK)
-        printf("error %d with zipfile in unzGetGlobalInfo \n",err);
-
-    for (i=0;i<gi.number_entry;i++)
-    {
-        if (do_extract_currentfile(uf, revisionRoot) != UNZ_OK)
-            break;
-
-        if ((i+1)<gi.number_entry)
-        {
-            err = unzGoToNextFile(uf);
-            if (err!=UNZ_OK)
-            {
-                printf("error %d with zipfile in unzGoToNextFile\n",err);
-                break;
-            }
-        }
-    }
-
-    return 0;
-}
-
-celix_status_t unzip_extractDeploymentPackage(char * packageName, char * destination) {
-    celix_status_t status = CELIX_SUCCESS;
-    char filename_try[MAXFILENAME+16] = "";
-    unzFile uf=NULL;
-
-    if (packageName!=NULL)
-    {
-
-#        ifdef USEWIN32IOAPI
-        zlib_filefunc64_def ffunc;
-#        endif
-
-        strncpy(filename_try, packageName,MAXFILENAME-1);
-        /* strncpy doesnt append the trailing NULL, of the string is too long. */
-        filename_try[ MAXFILENAME ] = '\0';
-
-#        ifdef USEWIN32IOAPI
-        fill_win32_filefunc64A(&ffunc);
-        uf = unzOpen2_64(bundleName,&ffunc);
-#        else
-        uf = unzOpen64(packageName);
-#        endif
-        if (uf==NULL)
-        {
-            strcat(filename_try,".zip");
-#            ifdef USEWIN32IOAPI
-            uf = unzOpen2_64(filename_try,&ffunc);
-#            else
-            uf = unzOpen64(filename_try);
-#            endif
-        }
-    }
-
-    if (uf==NULL)
-    {
-        printf("Cannot open %s or %s.zip\n",packageName,packageName);
-        status = CELIX_FILE_IO_EXCEPTION;
-    } else {
-        if (do_extract(uf, destination) != 0) {
-            status = CELIX_FILE_IO_EXCEPTION;
-        }
-
-        unzClose(uf);
-    }
-
-    return status;
-}


[12/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/src/unzip.c
----------------------------------------------------------------------
diff --git a/framework/src/unzip.c b/framework/src/unzip.c
new file mode 100644
index 0000000..d8a6716
--- /dev/null
+++ b/framework/src/unzip.c
@@ -0,0 +1,2128 @@
+/* unzip.c -- IO for uncompress .zip files using zlib
+   Version 1.1, February 14h, 2010
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications of Unzip for Zip64
+         Copyright (C) 2007-2008 Even Rouault
+
+         Modifications for Zip64 support on both zip and unzip
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+
+  ------------------------------------------------------------------------------------
+  Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
+  compatibility with older software. The following is from the original crypt.c.
+  Code woven in by Terry Thorsen 1/2003.
+
+  Copyright (c) 1990-2000 Info-ZIP.  All rights reserved.
+
+  See the accompanying file LICENSE, version 2000-Apr-09 or later
+  (the contents of which are also included in zip.h) for terms of use.
+  If, for some reason, all these files are missing, the Info-ZIP license
+  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
+
+        crypt.c (full version) by Info-ZIP.      Last revised:  [see crypt.h]
+
+  The encryption/decryption parts of this source code (as opposed to the
+  non-echoing password parts) were originally written in Europe.  The
+  whole source package can be freely distributed, including from the USA.
+  (Prior to January 2000, re-export from the US was a violation of US law.)
+
+        This encryption code is a direct transcription of the algorithm from
+  Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
+  file (appnote.txt) is distributed with the PKZIP program (even in the
+  version without encryption capabilities).
+
+        ------------------------------------------------------------------------------------
+
+        Changes in unzip.c
+
+        2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos
+  2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz*
+  2007-2008 - Even Rouault - Remove old C style function prototypes
+  2007-2008 - Even Rouault - Add unzip support for ZIP64
+
+        Copyright (C) 2007-2008 Even Rouault
+
+
+        Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
+  Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G
+                                should only read the compressed/uncompressed size from the Zip64 format if
+                                the size from normal header was 0xFFFFFFFF
+  Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant
+        Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required)
+                                Patch created by Daniel Borca
+
+  Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
+
+  Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson
+
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef NOUNCRYPT
+        #define NOUNCRYPT
+#endif
+
+#include "zlib.h"
+#include "unzip.h"
+
+#ifdef STDC
+#  include <stddef.h>
+#  include <string.h>
+#  include <stdlib.h>
+#endif
+#ifdef NO_ERRNO_H
+    extern int errno;
+#else
+#   include <errno.h>
+#endif
+
+
+#ifndef local
+#  define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+
+#ifndef CASESENSITIVITYDEFAULT_NO
+#  if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
+#    define CASESENSITIVITYDEFAULT_NO
+#  endif
+#endif
+
+
+#ifndef UNZ_BUFSIZE
+#define UNZ_BUFSIZE (16384)
+#endif
+
+#ifndef UNZ_MAXFILENAMEINZIP
+#define UNZ_MAXFILENAMEINZIP (256)
+#endif
+
+#ifndef ALLOC
+# define ALLOC(size) (malloc(size))
+#endif
+#ifndef TRYFREE
+# define TRYFREE(p) {if (p) free(p);}
+#endif
+
+#define SIZECENTRALDIRITEM (0x2e)
+#define SIZEZIPLOCALHEADER (0x1e)
+
+
+const char unz_copyright[] =
+   " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
+
+/* unz_file_info_interntal contain internal info about a file in zipfile*/
+typedef struct unz_file_info64_internal_s
+{
+    ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
+} unz_file_info64_internal;
+
+
+/* file_in_zip_read_info_s contain internal information about a file in zipfile,
+    when reading and decompress it */
+typedef struct
+{
+    char  *read_buffer;         /* internal buffer for compressed data */
+    z_stream stream;            /* zLib stream structure for inflate */
+
+#ifdef HAVE_BZIP2
+    bz_stream bstream;          /* bzLib stream structure for bziped */
+#endif
+
+    ZPOS64_T pos_in_zipfile;       /* position in byte on the zipfile, for fseek*/
+    uLong stream_initialised;   /* flag set if stream structure is initialised*/
+
+    ZPOS64_T offset_local_extrafield;/* offset of the local extra field */
+    uInt  size_local_extrafield;/* size of the local extra field */
+    ZPOS64_T pos_local_extrafield;   /* position in the local extra field in read*/
+    ZPOS64_T total_out_64;
+
+    uLong crc32;                /* crc32 of all data uncompressed */
+    uLong crc32_wait;           /* crc32 we must obtain after decompress all */
+    ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
+    ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/
+    zlib_filefunc64_32_def z_filefunc;
+    voidpf filestream;        /* io structore of the zipfile */
+    uLong compression_method;   /* compression method (0==store) */
+    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+    int   raw;
+} file_in_zip64_read_info_s;
+
+
+/* unz64_s contain internal information about the zipfile
+*/
+typedef struct
+{
+    zlib_filefunc64_32_def z_filefunc;
+    int is64bitOpenFunction;
+    voidpf filestream;        /* io structore of the zipfile */
+    unz_global_info64 gi;       /* public global information */
+    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+    ZPOS64_T num_file;             /* number of the current file in the zipfile*/
+    ZPOS64_T pos_in_central_dir;   /* pos of the current file in the central dir*/
+    ZPOS64_T current_file_ok;      /* flag about the usability of the current file*/
+    ZPOS64_T central_pos;          /* position of the beginning of the central dir*/
+
+    ZPOS64_T size_central_dir;     /* size of the central directory  */
+    ZPOS64_T offset_central_dir;   /* offset of start of central directory with
+                                   respect to the starting disk number */
+
+    unz_file_info64 cur_file_info; /* public info about the current file in zip*/
+    unz_file_info64_internal cur_file_info_internal; /* private info about it*/
+    file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current
+                                        file if we are decompressing it */
+    int encrypted;
+
+    int isZip64;
+
+#    ifndef NOUNCRYPT
+    unsigned long keys[3];     /* keys defining the pseudo-random sequence */
+    const unsigned long* pcrc_32_tab;
+#    endif
+} unz64_s;
+
+
+#ifndef NOUNCRYPT
+#include "crypt.h"
+#endif
+
+/* ===========================================================================
+     Read a byte from a gz_stream; update next_in and avail_in. Return EOF
+   for end of file.
+   IN assertion: the stream s has been sucessfully opened for reading.
+*/
+
+
+local int unz64local_getByte OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream,
+    int *pi));
+
+local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
+{
+    unsigned char c;
+    int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
+    if (err==1)
+    {
+        *pi = (int)c;
+        return UNZ_OK;
+    }
+    else
+    {
+        if (ZERROR64(*pzlib_filefunc_def,filestream))
+            return UNZ_ERRNO;
+        else
+            return UNZ_EOF;
+    }
+}
+
+
+/* ===========================================================================
+   Reads a long in LSB order from the given gz_stream. Sets
+*/
+local int unz64local_getShort OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream,
+    uLong *pX));
+
+local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
+                             voidpf filestream,
+                             uLong *pX)
+{
+    uLong x ;
+    int i = 0;
+    int err;
+
+    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (uLong)i;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((uLong)i)<<8;
+
+    if (err==UNZ_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+local int unz64local_getLong OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream,
+    uLong *pX));
+
+local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
+                            voidpf filestream,
+                            uLong *pX)
+{
+    uLong x ;
+    int i = 0;
+    int err;
+
+    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (uLong)i;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((uLong)i)<<8;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((uLong)i)<<16;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<24;
+
+    if (err==UNZ_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+local int unz64local_getLong64 OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream,
+    ZPOS64_T *pX));
+
+
+local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
+                            voidpf filestream,
+                            ZPOS64_T *pX)
+{
+    ZPOS64_T x ;
+    int i = 0;
+    int err;
+
+    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (ZPOS64_T)i;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<8;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<16;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<24;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<32;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<40;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<48;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<56;
+
+    if (err==UNZ_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+/* My own strcmpi / strcasecmp */
+local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)
+{
+    for (;;)
+    {
+        char c1=*(fileName1++);
+        char c2=*(fileName2++);
+        if ((c1>='a') && (c1<='z'))
+            c1 -= 0x20;
+        if ((c2>='a') && (c2<='z'))
+            c2 -= 0x20;
+        if (c1=='\0')
+            return ((c2=='\0') ? 0 : -1);
+        if (c2=='\0')
+            return 1;
+        if (c1<c2)
+            return -1;
+        if (c1>c2)
+            return 1;
+    }
+}
+
+
+#ifdef  CASESENSITIVITYDEFAULT_NO
+#define CASESENSITIVITYDEFAULTVALUE 2
+#else
+#define CASESENSITIVITYDEFAULTVALUE 1
+#endif
+
+#ifndef STRCMPCASENOSENTIVEFUNCTION
+#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
+#endif
+
+/*
+   Compare two filename (fileName1,fileName2).
+   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
+   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
+                                                                or strcasecmp)
+   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
+        (like 1 on Unix, 2 on Windows)
+
+*/
+extern int ZEXPORT unzStringFileNameCompare (const char*  fileName1,
+                                                 const char*  fileName2,
+                                                 int iCaseSensitivity)
+
+{
+    if (iCaseSensitivity==0)
+        iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
+
+    if (iCaseSensitivity==1)
+        return strcmp(fileName1,fileName2);
+
+    return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
+}
+
+#ifndef BUFREADCOMMENT
+#define BUFREADCOMMENT (0x400)
+#endif
+
+/*
+  Locate the Central directory of a zipfile (at the end, just before
+    the global comment)
+*/
+local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
+local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
+{
+    unsigned char* buf;
+    ZPOS64_T uSizeFile;
+    ZPOS64_T uBackRead;
+    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
+    ZPOS64_T uPosFound=0;
+
+    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
+        return 0;
+
+
+    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
+
+    if (uMaxBack>uSizeFile)
+        uMaxBack = uSizeFile;
+
+    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
+    if (buf==NULL)
+        return 0;
+
+    uBackRead = 4;
+    while (uBackRead<uMaxBack)
+    {
+        uLong uReadSize;
+        ZPOS64_T uReadPos ;
+        int i;
+        if (uBackRead+BUFREADCOMMENT>uMaxBack)
+            uBackRead = uMaxBack;
+        else
+            uBackRead+=BUFREADCOMMENT;
+        uReadPos = uSizeFile-uBackRead ;
+
+        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
+                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
+        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            break;
+
+        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
+            break;
+
+        for (i=(int)uReadSize-3; (i--)>0;)
+            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
+                ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
+            {
+                uPosFound = uReadPos+i;
+                break;
+            }
+
+        if (uPosFound!=0)
+            break;
+    }
+    TRYFREE(buf);
+    return uPosFound;
+}
+
+
+/*
+  Locate the Central directory 64 of a zipfile (at the end, just before
+    the global comment)
+*/
+local ZPOS64_T unz64local_SearchCentralDir64 OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream));
+
+local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
+                                      voidpf filestream)
+{
+    unsigned char* buf;
+    ZPOS64_T uSizeFile;
+    ZPOS64_T uBackRead;
+    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
+    ZPOS64_T uPosFound=0;
+    uLong uL;
+                ZPOS64_T relativeOffset;
+
+    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
+        return 0;
+
+
+    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
+
+    if (uMaxBack>uSizeFile)
+        uMaxBack = uSizeFile;
+
+    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
+    if (buf==NULL)
+        return 0;
+
+    uBackRead = 4;
+    while (uBackRead<uMaxBack)
+    {
+        uLong uReadSize;
+        ZPOS64_T uReadPos;
+        int i;
+        if (uBackRead+BUFREADCOMMENT>uMaxBack)
+            uBackRead = uMaxBack;
+        else
+            uBackRead+=BUFREADCOMMENT;
+        uReadPos = uSizeFile-uBackRead ;
+
+        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
+                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
+        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            break;
+
+        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
+            break;
+
+        for (i=(int)uReadSize-3; (i--)>0;)
+            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
+                ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
+            {
+                uPosFound = uReadPos+i;
+                break;
+            }
+
+        if (uPosFound!=0)
+            break;
+    }
+    TRYFREE(buf);
+    if (uPosFound == 0)
+        return 0;
+
+    /* Zip64 end of central directory locator */
+    if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return 0;
+
+    /* the signature, already checked */
+    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
+        return 0;
+
+    /* number of the disk with the start of the zip64 end of  central directory */
+    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
+        return 0;
+    if (uL != 0)
+        return 0;
+
+    /* relative offset of the zip64 end of central directory record */
+    if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
+        return 0;
+
+    /* total number of disks */
+    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
+        return 0;
+    if (uL != 1)
+        return 0;
+
+    /* Goto end of central directory record */
+    if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return 0;
+
+     /* the signature */
+    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
+        return 0;
+
+    if (uL != 0x06064b50)
+        return 0;
+
+    return relativeOffset;
+}
+
+/*
+  Open a Zip file. path contain the full pathname (by example,
+     on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
+     "zlib/zlib114.zip".
+     If the zipfile cannot be opened (file doesn't exist or in not valid), the
+       return value is NULL.
+     Else, the return value is a unzFile Handle, usable with other function
+       of this unzip package.
+*/
+local unzFile unzOpenInternal (const void *path,
+                               zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
+                               int is64bitOpenFunction)
+{
+    unz64_s us;
+    unz64_s *s;
+    ZPOS64_T central_pos;
+    uLong   uL;
+
+    uLong number_disk;          /* number of the current dist, used for
+                                   spaning ZIP, unsupported, always 0*/
+    uLong number_disk_with_CD;  /* number the the disk with central dir, used
+                                   for spaning ZIP, unsupported, always 0*/
+    ZPOS64_T number_entry_CD;      /* total number of entries in
+                                   the central dir
+                                   (same than number_entry on nospan) */
+
+    int err=UNZ_OK;
+
+    if (unz_copyright[0]!=' ')
+        return NULL;
+
+    memset(&us,0,sizeof(unz64_s));
+    us.z_filefunc.zseek32_file = NULL;
+    us.z_filefunc.ztell32_file = NULL;
+    if (pzlib_filefunc64_32_def==NULL)
+        fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
+    else
+        us.z_filefunc = *pzlib_filefunc64_32_def;
+    us.is64bitOpenFunction = is64bitOpenFunction;
+
+
+
+    us.filestream = ZOPEN64(us.z_filefunc,
+                                                 path,
+                                                 ZLIB_FILEFUNC_MODE_READ |
+                                                 ZLIB_FILEFUNC_MODE_EXISTING);
+    if (us.filestream==NULL)
+        return NULL;
+
+    central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
+    if (central_pos)
+    {
+        uLong uS;
+        ZPOS64_T uL64;
+
+        us.isZip64 = 1;
+
+        if (ZSEEK64(us.z_filefunc, us.filestream,
+                                      central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        err=UNZ_ERRNO;
+
+        /* the signature, already checked */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* size of zip64 end of central directory record */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* version made by */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* version needed to extract */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* number of this disk */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* number of the disk with the start of the central directory */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* total number of entries in the central directory on this disk */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* total number of entries in the central directory */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        if ((number_entry_CD!=us.gi.number_entry) ||
+            (number_disk_with_CD!=0) ||
+            (number_disk!=0))
+            err=UNZ_BADZIPFILE;
+
+        /* size of the central directory */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* offset of start of central directory with respect to the
+          starting disk number */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        us.gi.size_comment = 0;
+    }
+    else
+    {
+        central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);
+        if (central_pos==0)
+            err=UNZ_ERRNO;
+
+        us.isZip64 = 0;
+
+        if (ZSEEK64(us.z_filefunc, us.filestream,
+                                        central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            err=UNZ_ERRNO;
+
+        /* the signature, already checked */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* number of this disk */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* number of the disk with the start of the central directory */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* total number of entries in the central dir on this disk */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+        us.gi.number_entry = uL;
+
+        /* total number of entries in the central dir */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+        number_entry_CD = uL;
+
+        if ((number_entry_CD!=us.gi.number_entry) ||
+            (number_disk_with_CD!=0) ||
+            (number_disk!=0))
+            err=UNZ_BADZIPFILE;
+
+        /* size of the central directory */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+        us.size_central_dir = uL;
+
+        /* offset of start of central directory with respect to the
+            starting disk number */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+        us.offset_central_dir = uL;
+
+        /* zipfile comment length */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
+            err=UNZ_ERRNO;
+    }
+
+    if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
+        (err==UNZ_OK))
+        err=UNZ_BADZIPFILE;
+
+    if (err!=UNZ_OK)
+    {
+        ZCLOSE64(us.z_filefunc, us.filestream);
+        return NULL;
+    }
+
+    us.byte_before_the_zipfile = central_pos -
+                            (us.offset_central_dir+us.size_central_dir);
+    us.central_pos = central_pos;
+    us.pfile_in_zip_read = NULL;
+    us.encrypted = 0;
+    us.num_file = 0;
+
+
+    s=(unz64_s*)ALLOC(sizeof(unz64_s));
+    if( s != NULL)
+    {
+        *s=us;
+        unzGoToFirstFile((unzFile)s);
+    }
+    return (unzFile)s;
+}
+
+
+extern unzFile ZEXPORT unzOpen2 (const char *path,
+                                        zlib_filefunc_def* pzlib_filefunc32_def)
+{
+    if (pzlib_filefunc32_def != NULL)
+    {
+        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
+        fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);
+        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0);
+    }
+    else
+        return unzOpenInternal(path, NULL, 0);
+}
+
+extern unzFile ZEXPORT unzOpen2_64 (const void *path,
+                                     zlib_filefunc64_def* pzlib_filefunc_def)
+{
+    if (pzlib_filefunc_def != NULL)
+    {
+        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
+        zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
+        zlib_filefunc64_32_def_fill.ztell32_file = NULL;
+        zlib_filefunc64_32_def_fill.zseek32_file = NULL;
+        zlib_filefunc64_32_def_fill.zopen32_file = NULL;
+        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
+    }
+    else
+        return unzOpenInternal(path, NULL, 1);
+}
+
+extern unzFile ZEXPORT unzOpen (const char *path)
+{
+    return unzOpenInternal(path, NULL, 0);
+}
+
+extern unzFile ZEXPORT unzOpen64 (const void *path)
+{
+    return unzOpenInternal(path, NULL, 1);
+}
+
+/*
+  Close a ZipFile opened with unzipOpen.
+  If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
+    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+  return UNZ_OK if there is no problem. */
+extern int ZEXPORT unzClose (unzFile file)
+{
+    unz64_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+
+    if (s->pfile_in_zip_read!=NULL)
+        unzCloseCurrentFile(file);
+
+    ZCLOSE64(s->z_filefunc, s->filestream);
+    TRYFREE(s);
+    return UNZ_OK;
+}
+
+
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem. */
+extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)
+{
+    unz64_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    *pglobal_info=s->gi;
+    return UNZ_OK;
+}
+
+extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)
+{
+    unz64_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    /* to do : check if number_entry is not truncated */
+    pglobal_info32->number_entry = (uLong)s->gi.number_entry;
+    pglobal_info32->size_comment = s->gi.size_comment;
+    return UNZ_OK;
+}
+/*
+   Translate date/time from Dos format to tm_unz (readable more easilty)
+*/
+local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
+{
+    ZPOS64_T uDate;
+    uDate = (ZPOS64_T)(ulDosDate>>16);
+    ptm->tm_mday = (uInt)(uDate&0x1f) ;
+    ptm->tm_mon =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;
+    ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
+
+    ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
+    ptm->tm_min =  (uInt) ((ulDosDate&0x7E0)/0x20) ;
+    ptm->tm_sec =  (uInt) (2*(ulDosDate&0x1f)) ;
+}
+
+/*
+  Get Info about the current file in the zipfile, with internal only info
+*/
+local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
+                                                  unz_file_info64 *pfile_info,
+                                                  unz_file_info64_internal
+                                                  *pfile_info_internal,
+                                                  char *szFileName,
+                                                  uLong fileNameBufferSize,
+                                                  void *extraField,
+                                                  uLong extraFieldBufferSize,
+                                                  char *szComment,
+                                                  uLong commentBufferSize));
+
+local int unz64local_GetCurrentFileInfoInternal (unzFile file,
+                                                  unz_file_info64 *pfile_info,
+                                                  unz_file_info64_internal
+                                                  *pfile_info_internal,
+                                                  char *szFileName,
+                                                  uLong fileNameBufferSize,
+                                                  void *extraField,
+                                                  uLong extraFieldBufferSize,
+                                                  char *szComment,
+                                                  uLong commentBufferSize)
+{
+    unz64_s* s;
+    unz_file_info64 file_info;
+    unz_file_info64_internal file_info_internal;
+    int err=UNZ_OK;
+    uLong uMagic;
+    long lSeek=0;
+    uLong uL;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (ZSEEK64(s->z_filefunc, s->filestream,
+              s->pos_in_central_dir+s->byte_before_the_zipfile,
+              ZLIB_FILEFUNC_SEEK_SET)!=0)
+        err=UNZ_ERRNO;
+
+
+    /* we check the magic */
+    if (err==UNZ_OK)
+    {
+        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
+            err=UNZ_ERRNO;
+        else if (uMagic!=0x02014b50)
+            err=UNZ_BADZIPFILE;
+    }
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+        err=UNZ_ERRNO;
+    file_info.compressed_size = uL;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+        err=UNZ_ERRNO;
+    file_info.uncompressed_size = uL;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+                // relative offset of local header
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+        err=UNZ_ERRNO;
+    file_info_internal.offset_curfile = uL;
+
+    lSeek+=file_info.size_filename;
+    if ((err==UNZ_OK) && (szFileName!=NULL))
+    {
+        uLong uSizeRead ;
+        if (file_info.size_filename<fileNameBufferSize)
+        {
+            *(szFileName+file_info.size_filename)='\0';
+            uSizeRead = file_info.size_filename;
+        }
+        else
+            uSizeRead = fileNameBufferSize;
+
+        if ((file_info.size_filename>0) && (fileNameBufferSize>0))
+            if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
+                err=UNZ_ERRNO;
+        lSeek -= uSizeRead;
+    }
+
+    // Read extrafield
+    if ((err==UNZ_OK) && (extraField!=NULL))
+    {
+        ZPOS64_T uSizeRead ;
+        if (file_info.size_file_extra<extraFieldBufferSize)
+            uSizeRead = file_info.size_file_extra;
+        else
+            uSizeRead = extraFieldBufferSize;
+
+        if (lSeek!=0)
+        {
+            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+                lSeek=0;
+            else
+                err=UNZ_ERRNO;
+        }
+
+        if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
+            if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)
+                err=UNZ_ERRNO;
+
+        lSeek += file_info.size_file_extra - (uLong)uSizeRead;
+    }
+    else
+        lSeek += file_info.size_file_extra;
+
+
+    if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
+    {
+                                uLong acc = 0;
+
+        // since lSeek now points to after the extra field we need to move back
+        lSeek -= file_info.size_file_extra;
+
+        if (lSeek!=0)
+        {
+            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+                lSeek=0;
+            else
+                err=UNZ_ERRNO;
+        }
+
+        while(acc < file_info.size_file_extra)
+        {
+            uLong headerId;
+                                                uLong dataSize;
+
+            if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)
+                err=UNZ_ERRNO;
+
+            if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)
+                err=UNZ_ERRNO;
+
+            /* ZIP64 extra fields */
+            if (headerId == 0x0001)
+            {
+                                                        uLong uL;
+
+                                                                if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)
+                                                                {
+                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
+                                                                                        err=UNZ_ERRNO;
+                                                                }
+
+                                                                if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)
+                                                                {
+                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
+                                                                                  err=UNZ_ERRNO;
+                                                                }
+
+                                                                if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)
+                                                                {
+                                                                        /* Relative Header offset */
+                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
+                                                                                err=UNZ_ERRNO;
+                                                                }
+
+                                                                if(file_info.disk_num_start == (unsigned long)-1)
+                                                                {
+                                                                        /* Disk Start Number */
+                                                                        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+                                                                                err=UNZ_ERRNO;
+                                                                }
+
+            }
+            else
+            {
+                if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
+                    err=UNZ_ERRNO;
+            }
+
+            acc += 2 + 2 + dataSize;
+        }
+    }
+
+    if ((err==UNZ_OK) && (szComment!=NULL))
+    {
+        uLong uSizeRead ;
+        if (file_info.size_file_comment<commentBufferSize)
+        {
+            *(szComment+file_info.size_file_comment)='\0';
+            uSizeRead = file_info.size_file_comment;
+        }
+        else
+            uSizeRead = commentBufferSize;
+
+        if (lSeek!=0)
+        {
+            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+                lSeek=0;
+            else
+                err=UNZ_ERRNO;
+        }
+
+        if ((file_info.size_file_comment>0) && (commentBufferSize>0))
+            if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
+                err=UNZ_ERRNO;
+        lSeek+=file_info.size_file_comment - uSizeRead;
+    }
+    else
+        lSeek+=file_info.size_file_comment;
+
+
+    if ((err==UNZ_OK) && (pfile_info!=NULL))
+        *pfile_info=file_info;
+
+    if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
+        *pfile_info_internal=file_info_internal;
+
+    return err;
+}
+
+
+
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem.
+*/
+extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
+                                          unz_file_info64 * pfile_info,
+                                          char * szFileName, uLong fileNameBufferSize,
+                                          void *extraField, uLong extraFieldBufferSize,
+                                          char* szComment,  uLong commentBufferSize)
+{
+    return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
+                                                szFileName,fileNameBufferSize,
+                                                extraField,extraFieldBufferSize,
+                                                szComment,commentBufferSize);
+}
+
+extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
+                                          unz_file_info * pfile_info,
+                                          char * szFileName, uLong fileNameBufferSize,
+                                          void *extraField, uLong extraFieldBufferSize,
+                                          char* szComment,  uLong commentBufferSize)
+{
+    int err;
+    unz_file_info64 file_info64;
+    err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
+                                                szFileName,fileNameBufferSize,
+                                                extraField,extraFieldBufferSize,
+                                                szComment,commentBufferSize);
+    if (err==UNZ_OK)
+    {
+        pfile_info->version = file_info64.version;
+        pfile_info->version_needed = file_info64.version_needed;
+        pfile_info->flag = file_info64.flag;
+        pfile_info->compression_method = file_info64.compression_method;
+        pfile_info->dosDate = file_info64.dosDate;
+        pfile_info->crc = file_info64.crc;
+
+        pfile_info->size_filename = file_info64.size_filename;
+        pfile_info->size_file_extra = file_info64.size_file_extra;
+        pfile_info->size_file_comment = file_info64.size_file_comment;
+
+        pfile_info->disk_num_start = file_info64.disk_num_start;
+        pfile_info->internal_fa = file_info64.internal_fa;
+        pfile_info->external_fa = file_info64.external_fa;
+
+        pfile_info->tmu_date = file_info64.tmu_date,
+
+
+        pfile_info->compressed_size = (uLong)file_info64.compressed_size;
+        pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
+
+    }
+    return err;
+}
+/*
+  Set the current file of the zipfile to the first file.
+  return UNZ_OK if there is no problem
+*/
+extern int ZEXPORT unzGoToFirstFile (unzFile file)
+{
+    int err=UNZ_OK;
+    unz64_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    s->pos_in_central_dir=s->offset_central_dir;
+    s->num_file=0;
+    err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                             &s->cur_file_info_internal,
+                                             NULL,0,NULL,0,NULL,0);
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+/*
+  Set the current file of the zipfile to the next file.
+  return UNZ_OK if there is no problem
+  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
+*/
+extern int ZEXPORT unzGoToNextFile (unzFile  file)
+{
+    unz64_s* s;
+    int err;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_END_OF_LIST_OF_FILE;
+    if (s->gi.number_entry != 0xffff)    /* 2^16 files overflow hack */
+      if (s->num_file+1==s->gi.number_entry)
+        return UNZ_END_OF_LIST_OF_FILE;
+
+    s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
+            s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
+    s->num_file++;
+    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                               &s->cur_file_info_internal,
+                                               NULL,0,NULL,0,NULL,0);
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+
+/*
+  Try locate the file szFileName in the zipfile.
+  For the iCaseSensitivity signification, see unzipStringFileNameCompare
+
+  return value :
+  UNZ_OK if the file is found. It becomes the current file.
+  UNZ_END_OF_LIST_OF_FILE if the file is not found
+*/
+extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
+{
+    unz64_s* s;
+    int err;
+
+    /* We remember the 'current' position in the file so that we can jump
+     * back there if we fail.
+     */
+    unz_file_info64 cur_file_infoSaved;
+    unz_file_info64_internal cur_file_info_internalSaved;
+    ZPOS64_T num_fileSaved;
+    ZPOS64_T pos_in_central_dirSaved;
+
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+
+    if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
+        return UNZ_PARAMERROR;
+
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_END_OF_LIST_OF_FILE;
+
+    /* Save the current state */
+    num_fileSaved = s->num_file;
+    pos_in_central_dirSaved = s->pos_in_central_dir;
+    cur_file_infoSaved = s->cur_file_info;
+    cur_file_info_internalSaved = s->cur_file_info_internal;
+
+    err = unzGoToFirstFile(file);
+
+    while (err == UNZ_OK)
+    {
+        char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
+        err = unzGetCurrentFileInfo64(file,NULL,
+                                    szCurrentFileName,sizeof(szCurrentFileName)-1,
+                                    NULL,0,NULL,0);
+        if (err == UNZ_OK)
+        {
+            if (unzStringFileNameCompare(szCurrentFileName,
+                                            szFileName,iCaseSensitivity)==0)
+                return UNZ_OK;
+            err = unzGoToNextFile(file);
+        }
+    }
+
+    /* We failed, so restore the state of the 'current file' to where we
+     * were.
+     */
+    s->num_file = num_fileSaved ;
+    s->pos_in_central_dir = pos_in_central_dirSaved ;
+    s->cur_file_info = cur_file_infoSaved;
+    s->cur_file_info_internal = cur_file_info_internalSaved;
+    return err;
+}
+
+
+/*
+///////////////////////////////////////////
+// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
+// I need random access
+//
+// Further optimization could be realized by adding an ability
+// to cache the directory in memory. The goal being a single
+// comprehensive file read to put the file I need in a memory.
+*/
+
+/*
+typedef struct unz_file_pos_s
+{
+    ZPOS64_T pos_in_zip_directory;   // offset in file
+    ZPOS64_T num_of_file;            // # of file
+} unz_file_pos;
+*/
+
+extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos*  file_pos)
+{
+    unz64_s* s;
+
+    if (file==NULL || file_pos==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_END_OF_LIST_OF_FILE;
+
+    file_pos->pos_in_zip_directory  = s->pos_in_central_dir;
+    file_pos->num_of_file           = s->num_file;
+
+    return UNZ_OK;
+}
+
+extern int ZEXPORT unzGetFilePos(
+    unzFile file,
+    unz_file_pos* file_pos)
+{
+    unz64_file_pos file_pos64;
+    int err = unzGetFilePos64(file,&file_pos64);
+    if (err==UNZ_OK)
+    {
+        file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
+        file_pos->num_of_file = (uLong)file_pos64.num_of_file;
+    }
+    return err;
+}
+
+extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)
+{
+    unz64_s* s;
+    int err;
+
+    if (file==NULL || file_pos==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+
+    /* jump to the right spot */
+    s->pos_in_central_dir = file_pos->pos_in_zip_directory;
+    s->num_file           = file_pos->num_of_file;
+
+    /* set the current file */
+    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                               &s->cur_file_info_internal,
+                                               NULL,0,NULL,0,NULL,0);
+    /* return results */
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+extern int ZEXPORT unzGoToFilePos(
+    unzFile file,
+    unz_file_pos* file_pos)
+{
+    unz64_file_pos file_pos64;
+    if (file_pos == NULL)
+        return UNZ_PARAMERROR;
+
+    file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
+    file_pos64.num_of_file = file_pos->num_of_file;
+    return unzGoToFilePos64(file,&file_pos64);
+}
+
+/*
+// Unzip Helper Functions - should be here?
+///////////////////////////////////////////
+*/
+
+/*
+  Read the local header of the current zipfile
+  Check the coherency of the local header and info in the end of central
+        directory about this file
+  store in *piSizeVar the size of extra info in local header
+        (filename and size of extra field data)
+*/
+local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,
+                                                    ZPOS64_T * poffset_local_extrafield,
+                                                    uInt  * psize_local_extrafield)
+{
+    uLong uMagic,uData,uFlags;
+    uLong size_filename;
+    uLong size_extra_field;
+    int err=UNZ_OK;
+
+    *piSizeVar = 0;
+    *poffset_local_extrafield = 0;
+    *psize_local_extrafield = 0;
+
+    if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
+                                s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return UNZ_ERRNO;
+
+
+    if (err==UNZ_OK)
+    {
+        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
+            err=UNZ_ERRNO;
+        else if (uMagic!=0x04034b50)
+            err=UNZ_BADZIPFILE;
+    }
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
+        err=UNZ_ERRNO;
+/*
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
+        err=UNZ_BADZIPFILE;
+*/
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
+        err=UNZ_BADZIPFILE;
+
+    if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
+/* #ifdef HAVE_BZIP2 */
+                         (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
+/* #endif */
+                         (s->cur_file_info.compression_method!=Z_DEFLATED))
+        err=UNZ_BADZIPFILE;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
+        err=UNZ_ERRNO;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))
+        err=UNZ_BADZIPFILE;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
+        err=UNZ_ERRNO;
+    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))
+        err=UNZ_BADZIPFILE;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
+        err=UNZ_ERRNO;
+    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))
+        err=UNZ_BADZIPFILE;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
+        err=UNZ_BADZIPFILE;
+
+    *piSizeVar += (uInt)size_filename;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
+        err=UNZ_ERRNO;
+    *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
+                                    SIZEZIPLOCALHEADER + size_filename;
+    *psize_local_extrafield = (uInt)size_extra_field;
+
+    *piSizeVar += (uInt)size_extra_field;
+
+    return err;
+}
+
+/*
+  Open for reading data the current file in the zipfile.
+  If there is no error and the file is opened, the return value is UNZ_OK.
+*/
+extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
+                                            int* level, int raw, const char* password)
+{
+    int err=UNZ_OK;
+    uInt iSizeVar;
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    ZPOS64_T offset_local_extrafield;  /* offset of the local extra field */
+    uInt  size_local_extrafield;    /* size of the local extra field */
+#    ifndef NOUNCRYPT
+    char source[12];
+#    else
+    if (password != NULL)
+        return UNZ_PARAMERROR;
+#    endif
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_PARAMERROR;
+
+    if (s->pfile_in_zip_read != NULL)
+        unzCloseCurrentFile(file);
+
+    if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
+        return UNZ_BADZIPFILE;
+
+    pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s));
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_INTERNALERROR;
+
+    pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
+    pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
+    pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
+    pfile_in_zip_read_info->pos_local_extrafield=0;
+    pfile_in_zip_read_info->raw=raw;
+
+    if (pfile_in_zip_read_info->read_buffer==NULL)
+    {
+        TRYFREE(pfile_in_zip_read_info);
+        return UNZ_INTERNALERROR;
+    }
+
+    pfile_in_zip_read_info->stream_initialised=0;
+
+    if (method!=NULL)
+        *method = (int)s->cur_file_info.compression_method;
+
+    if (level!=NULL)
+    {
+        *level = 6;
+        switch (s->cur_file_info.flag & 0x06)
+        {
+          case 6 : *level = 1; break;
+          case 4 : *level = 2; break;
+          case 2 : *level = 9; break;
+        }
+    }
+
+    if ((s->cur_file_info.compression_method!=0) &&
+/* #ifdef HAVE_BZIP2 */
+        (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
+/* #endif */
+        (s->cur_file_info.compression_method!=Z_DEFLATED))
+
+        err=UNZ_BADZIPFILE;
+
+    pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
+    pfile_in_zip_read_info->crc32=0;
+    pfile_in_zip_read_info->total_out_64=0;
+    pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;
+    pfile_in_zip_read_info->filestream=s->filestream;
+    pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
+    pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
+
+    pfile_in_zip_read_info->stream.total_out = 0;
+
+    if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))
+    {
+#ifdef HAVE_BZIP2
+      pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
+      pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
+      pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
+      pfile_in_zip_read_info->bstream.state = (voidpf)0;
+
+      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+      pfile_in_zip_read_info->stream.zfree = (free_func)0;
+      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+      pfile_in_zip_read_info->stream.next_in = (voidpf)0;
+      pfile_in_zip_read_info->stream.avail_in = 0;
+
+      err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
+      if (err == Z_OK)
+        pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
+      else
+      {
+        TRYFREE(pfile_in_zip_read_info);
+        return err;
+      }
+#else
+      pfile_in_zip_read_info->raw=1;
+#endif
+    }
+    else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
+    {
+      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+      pfile_in_zip_read_info->stream.zfree = (free_func)0;
+      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+      pfile_in_zip_read_info->stream.next_in = 0;
+      pfile_in_zip_read_info->stream.avail_in = 0;
+
+      err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
+      if (err == Z_OK)
+        pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
+      else
+      {
+        TRYFREE(pfile_in_zip_read_info);
+        return err;
+      }
+        /* windowBits is passed < 0 to tell that there is no zlib header.
+         * Note that in this case inflate *requires* an extra "dummy" byte
+         * after the compressed stream in order to complete decompression and
+         * return Z_STREAM_END.
+         * In unzip, i don't wait absolutely Z_STREAM_END because I known the
+         * size of both compressed and uncompressed data
+         */
+    }
+    pfile_in_zip_read_info->rest_read_compressed =
+            s->cur_file_info.compressed_size ;
+    pfile_in_zip_read_info->rest_read_uncompressed =
+            s->cur_file_info.uncompressed_size ;
+
+
+    pfile_in_zip_read_info->pos_in_zipfile =
+            s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
+              iSizeVar;
+
+    pfile_in_zip_read_info->stream.avail_in = (uInt)0;
+
+    s->pfile_in_zip_read = pfile_in_zip_read_info;
+                s->encrypted = 0;
+
+#    ifndef NOUNCRYPT
+    if (password != NULL)
+    {
+        int i;
+        s->pcrc_32_tab = get_crc_table();
+        init_keys(password,s->keys,s->pcrc_32_tab);
+        if (ZSEEK64(s->z_filefunc, s->filestream,
+                  s->pfile_in_zip_read->pos_in_zipfile +
+                     s->pfile_in_zip_read->byte_before_the_zipfile,
+                  SEEK_SET)!=0)
+            return UNZ_INTERNALERROR;
+        if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12)
+            return UNZ_INTERNALERROR;
+
+        for (i = 0; i<12; i++)
+            zdecode(s->keys,s->pcrc_32_tab,source[i]);
+
+        s->pfile_in_zip_read->pos_in_zipfile+=12;
+        s->encrypted=1;
+    }
+#    endif
+
+
+    return UNZ_OK;
+}
+
+extern int ZEXPORT unzOpenCurrentFile (unzFile file)
+{
+    return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
+}
+
+extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char*  password)
+{
+    return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
+}
+
+extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw)
+{
+    return unzOpenCurrentFile3(file, method, level, raw, NULL);
+}
+
+/** Addition for GDAL : START */
+
+extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
+{
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    s=(unz64_s*)file;
+    if (file==NULL)
+        return 0; //UNZ_PARAMERROR;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+    if (pfile_in_zip_read_info==NULL)
+        return 0; //UNZ_PARAMERROR;
+    return pfile_in_zip_read_info->pos_in_zipfile +
+                         pfile_in_zip_read_info->byte_before_the_zipfile;
+}
+
+/** Addition for GDAL : END */
+
+/*
+  Read bytes from the current file.
+  buf contain buffer where data must be copied
+  len the size of buf.
+
+  return the number of byte copied if somes bytes are copied
+  return 0 if the end of file was reached
+  return <0 with error code if there is an error
+    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+*/
+extern int ZEXPORT unzReadCurrentFile  (unzFile file, voidp buf, unsigned len)
+{
+    int err=UNZ_OK;
+    uInt iRead = 0;
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+
+    if (pfile_in_zip_read_info->read_buffer == NULL)
+        return UNZ_END_OF_LIST_OF_FILE;
+    if (len==0)
+        return 0;
+
+    pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
+
+    pfile_in_zip_read_info->stream.avail_out = (uInt)len;
+
+    if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
+        (!(pfile_in_zip_read_info->raw)))
+        pfile_in_zip_read_info->stream.avail_out =
+            (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
+
+    if ((len>pfile_in_zip_read_info->rest_read_compressed+
+           pfile_in_zip_read_info->stream.avail_in) &&
+         (pfile_in_zip_read_info->raw))
+        pfile_in_zip_read_info->stream.avail_out =
+            (uInt)pfile_in_zip_read_info->rest_read_compressed+
+            pfile_in_zip_read_info->stream.avail_in;
+
+    while (pfile_in_zip_read_info->stream.avail_out>0)
+    {
+        if ((pfile_in_zip_read_info->stream.avail_in==0) &&
+            (pfile_in_zip_read_info->rest_read_compressed>0))
+        {
+            uInt uReadThis = UNZ_BUFSIZE;
+            if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
+                uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
+            if (uReadThis == 0)
+                return UNZ_EOF;
+            if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
+                      pfile_in_zip_read_info->filestream,
+                      pfile_in_zip_read_info->pos_in_zipfile +
+                         pfile_in_zip_read_info->byte_before_the_zipfile,
+                         ZLIB_FILEFUNC_SEEK_SET)!=0)
+                return UNZ_ERRNO;
+            if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
+                      pfile_in_zip_read_info->filestream,
+                      pfile_in_zip_read_info->read_buffer,
+                      uReadThis)!=uReadThis)
+                return UNZ_ERRNO;
+
+
+#            ifndef NOUNCRYPT
+            if(s->encrypted)
+            {
+                uInt i;
+                for(i=0;i<uReadThis;i++)
+                  pfile_in_zip_read_info->read_buffer[i] =
+                      zdecode(s->keys,s->pcrc_32_tab,
+                              pfile_in_zip_read_info->read_buffer[i]);
+            }
+#            endif
+
+
+            pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
+
+            pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
+
+            pfile_in_zip_read_info->stream.next_in =
+                (Bytef*)pfile_in_zip_read_info->read_buffer;
+            pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
+        }
+
+        if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
+        {
+            uInt uDoCopy,i ;
+
+            if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
+                (pfile_in_zip_read_info->rest_read_compressed == 0))
+                return (iRead==0) ? UNZ_EOF : iRead;
+
+            if (pfile_in_zip_read_info->stream.avail_out <
+                            pfile_in_zip_read_info->stream.avail_in)
+                uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
+            else
+                uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
+
+            for (i=0;i<uDoCopy;i++)
+                *(pfile_in_zip_read_info->stream.next_out+i) =
+                        *(pfile_in_zip_read_info->stream.next_in+i);
+
+            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;
+
+            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
+                                pfile_in_zip_read_info->stream.next_out,
+                                uDoCopy);
+            pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
+            pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
+            pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
+            pfile_in_zip_read_info->stream.next_out += uDoCopy;
+            pfile_in_zip_read_info->stream.next_in += uDoCopy;
+            pfile_in_zip_read_info->stream.total_out += uDoCopy;
+            iRead += uDoCopy;
+        }
+        else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
+        {
+#ifdef HAVE_BZIP2
+            uLong uTotalOutBefore,uTotalOutAfter;
+            const Bytef *bufBefore;
+            uLong uOutThis;
+
+            pfile_in_zip_read_info->bstream.next_in        = (char*)pfile_in_zip_read_info->stream.next_in;
+            pfile_in_zip_read_info->bstream.avail_in       = pfile_in_zip_read_info->stream.avail_in;
+            pfile_in_zip_read_info->bstream.total_in_lo32  = pfile_in_zip_read_info->stream.total_in;
+            pfile_in_zip_read_info->bstream.total_in_hi32  = 0;
+            pfile_in_zip_read_info->bstream.next_out       = (char*)pfile_in_zip_read_info->stream.next_out;
+            pfile_in_zip_read_info->bstream.avail_out      = pfile_in_zip_read_info->stream.avail_out;
+            pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
+            pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
+
+            uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
+            bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;
+
+            err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
+
+            uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
+            uOutThis = uTotalOutAfter-uTotalOutBefore;
+
+            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
+
+            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));
+            pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
+            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
+
+            pfile_in_zip_read_info->stream.next_in   = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
+            pfile_in_zip_read_info->stream.avail_in  = pfile_in_zip_read_info->bstream.avail_in;
+            pfile_in_zip_read_info->stream.total_in  = pfile_in_zip_read_info->bstream.total_in_lo32;
+            pfile_in_zip_read_info->stream.next_out  = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
+            pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
+            pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
+
+            if (err==BZ_STREAM_END)
+              return (iRead==0) ? UNZ_EOF : iRead;
+            if (err!=BZ_OK)
+              break;
+#endif
+        } // end Z_BZIP2ED
+        else
+        {
+            ZPOS64_T uTotalOutBefore,uTotalOutAfter;
+            const Bytef *bufBefore;
+            ZPOS64_T uOutThis;
+            int flush=Z_SYNC_FLUSH;
+
+            uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
+            bufBefore = pfile_in_zip_read_info->stream.next_out;
+
+            /*
+            if ((pfile_in_zip_read_info->rest_read_uncompressed ==
+                     pfile_in_zip_read_info->stream.avail_out) &&
+                (pfile_in_zip_read_info->rest_read_compressed == 0))
+                flush = Z_FINISH;
+            */
+            err=inflate(&pfile_in_zip_read_info->stream,flush);
+
+            if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
+              err = Z_DATA_ERROR;
+
+            uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
+            uOutThis = uTotalOutAfter-uTotalOutBefore;
+
+            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
+
+            pfile_in_zip_read_info->crc32 =
+                crc32(pfile_in_zip_read_info->crc32,bufBefore,
+                        (uInt)(uOutThis));
+
+            pfile_in_zip_read_info->rest_read_uncompressed -=
+                uOutThis;
+
+            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
+
+            if (err==Z_STREAM_END)
+                return (iRead==0) ? UNZ_EOF : iRead;
+            if (err!=Z_OK)
+                break;
+        }
+    }
+
+    if (err==Z_OK)
+        return iRead;
+    return err;
+}
+
+
+/*
+  Give the current position in uncompressed data
+*/
+extern z_off_t ZEXPORT unztell (unzFile file)
+{
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    return (z_off_t)pfile_in_zip_read_info->stream.total_out;
+}
+
+extern ZPOS64_T ZEXPORT unztell64 (unzFile file)
+{
+
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return (ZPOS64_T)-1;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return (ZPOS64_T)-1;
+
+    return pfile_in_zip_read_info->total_out_64;
+}
+
+
+/*
+  return 1 if the end of file was reached, 0 elsewhere
+*/
+extern int ZEXPORT unzeof (unzFile file)
+{
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
+        return 1;
+    else
+        return 0;
+}
+
+
+
+/*
+Read extra field from the current file (opened by unzOpenCurrentFile)
+This is the local-header version of the extra field (sometimes, there is
+more info in the local-header version than in the central-header)
+
+  if buf==NULL, it return the size of the local extra field that can be read
+
+  if buf!=NULL, len is the size of the buffer, the extra header is copied in
+    buf.
+  the return value is the number of bytes copied in buf, or (if <0)
+    the error code
+*/
+extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
+{
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    uInt read_now;
+    ZPOS64_T size_to_read;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
+                pfile_in_zip_read_info->pos_local_extrafield);
+
+    if (buf==NULL)
+        return (int)size_to_read;
+
+    if (len>size_to_read)
+        read_now = (uInt)size_to_read;
+    else
+        read_now = (uInt)len ;
+
+    if (read_now==0)
+        return 0;
+
+    if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
+              pfile_in_zip_read_info->filestream,
+              pfile_in_zip_read_info->offset_local_extrafield +
+              pfile_in_zip_read_info->pos_local_extrafield,
+              ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return UNZ_ERRNO;
+
+    if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
+              pfile_in_zip_read_info->filestream,
+              buf,read_now)!=read_now)
+        return UNZ_ERRNO;
+
+    return (int)read_now;
+}
+
+/*
+  Close the file in zip opened with unzipOpenCurrentFile
+  Return UNZ_CRCERROR if all the file was read but the CRC is not good
+*/
+extern int ZEXPORT unzCloseCurrentFile (unzFile file)
+{
+    int err=UNZ_OK;
+
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+
+    if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
+        (!pfile_in_zip_read_info->raw))
+    {
+        if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
+            err=UNZ_CRCERROR;
+    }
+
+
+    TRYFREE(pfile_in_zip_read_info->read_buffer);
+    pfile_in_zip_read_info->read_buffer = NULL;
+    if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
+        inflateEnd(&pfile_in_zip_read_info->stream);
+#ifdef HAVE_BZIP2
+    else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
+        BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
+#endif
+
+
+    pfile_in_zip_read_info->stream_initialised = 0;
+    TRYFREE(pfile_in_zip_read_info);
+
+    s->pfile_in_zip_read=NULL;
+
+    return err;
+}
+
+
+/*
+  Get the global comment string of the ZipFile, in the szComment buffer.
+  uSizeBuf is the size of the szComment buffer.
+  return the number of byte copied or an error code <0
+*/
+extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)
+{
+    unz64_s* s;
+    uLong uReadThis ;
+    if (file==NULL)
+        return (int)UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+
+    uReadThis = uSizeBuf;
+    if (uReadThis>s->gi.size_comment)
+        uReadThis = s->gi.size_comment;
+
+    if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return UNZ_ERRNO;
+
+    if (uReadThis>0)
+    {
+      *szComment='\0';
+      if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
+        return UNZ_ERRNO;
+    }
+
+    if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
+        *(szComment+s->gi.size_comment)='\0';
+    return (int)uReadThis;
+}
+
+/* Additions by RX '2004 */
+extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
+{
+    unz64_s* s;
+
+    if (file==NULL)
+          return 0; //UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+      return 0;
+    if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
+      if (s->num_file==s->gi.number_entry)
+         return 0;
+    return s->pos_in_central_dir;
+}
+
+extern uLong ZEXPORT unzGetOffset (unzFile file)
+{
+    ZPOS64_T offset64;
+
+    if (file==NULL)
+          return 0; //UNZ_PARAMERROR;
+    offset64 = unzGetOffset64(file);
+    return (uLong)offset64;
+}
+
+extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
+{
+    unz64_s* s;
+    int err;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+
+    s->pos_in_central_dir = pos;
+    s->num_file = s->gi.number_entry;      /* hack */
+    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                              &s->cur_file_info_internal,
+                                              NULL,0,NULL,0,NULL,0);
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
+{
+    return unzSetOffset64(file,pos);
+}


[30/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/src/json_rpc.c
----------------------------------------------------------------------
diff --git a/dfi/src/json_rpc.c b/dfi/src/json_rpc.c
new file mode 100644
index 0000000..f2b0c56
--- /dev/null
+++ b/dfi/src/json_rpc.c
@@ -0,0 +1,341 @@
+/**
+ *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.
+ */
+#include "json_rpc.h"
+#include "json_serializer.h"
+#include "dyn_type.h"
+#include "dyn_interface.h"
+#include <jansson.h>
+#include <assert.h>
+#include <stdint.h>
+#include <string.h>
+#include <ffi.h>
+
+
+static int OK = 0;
+static int ERROR = 1;
+
+DFI_SETUP_LOG(jsonRpc);
+
+typedef void (*gen_func_type)(void);
+
+struct generic_service_layout {
+	void *handle;
+	gen_func_type methods[];
+};
+
+int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, char **out) {
+	int status = OK;
+
+	dyn_type* returnType = NULL;
+
+	LOG_DEBUG("Parsing data: %s\n", request);
+	json_error_t error;
+	json_t *js_request = json_loads(request, 0, &error);
+	json_t *arguments = NULL;
+	const char *sig;
+	if (js_request) {
+		if (json_unpack(js_request, "{s:s}", "m", &sig) != 0) {
+			LOG_ERROR("Got json error '%s'\n", error.text);
+		} else {
+			arguments = json_object_get(js_request, "a");
+		}
+	} else {
+		LOG_ERROR("Got json error '%s' for '%s'\n", error.text, request);
+		return 0;
+	}
+
+	LOG_DEBUG("Looking for method %s\n", sig);
+	struct methods_head *methods = NULL;
+	dynInterface_methods(intf, &methods);
+	struct method_entry *entry = NULL;
+	struct method_entry *method = NULL;
+	TAILQ_FOREACH(entry, methods, entries) {
+		if (strcmp(sig, entry->id) == 0) {
+			method = entry;
+			break;
+		}
+	}
+
+	if (method == NULL) {
+		status = ERROR;
+		LOG_ERROR("Cannot find method with sig '%s'", sig);
+	}
+	else if (status == OK) {
+		LOG_DEBUG("RSA: found method '%s'\n", entry->id);
+		returnType = dynFunction_returnType(method->dynFunc);
+	}
+
+	void (*fp)(void) = NULL;
+	void *handle = NULL;
+	if (status == OK) {
+		struct generic_service_layout *serv = service;
+		handle = serv->handle;
+		fp = serv->methods[method->index];
+	}
+
+	dyn_function_type *func = NULL;
+	int nrOfArgs = 0;
+	if (status == OK) {
+		nrOfArgs = dynFunction_nrOfArguments(entry->dynFunc);
+		func = entry->dynFunc;
+	}
+
+	void *args[nrOfArgs];
+
+	json_t *value = NULL;
+
+	int i;
+	int index = 0;
+
+	void *ptr = NULL;
+	void *ptrToPtr = &ptr;
+
+	for (i = 0; i < nrOfArgs; i += 1) {
+		dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
+		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
+		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
+			value = json_array_get(arguments, index++);
+			status = jsonSerializer_deserializeJson(argType, value, &(args[i]));
+		} else if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
+			dynType_alloc(argType, &args[i]);
+		} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
+			args[i] = &ptrToPtr;
+		} else if (meta == DYN_FUNCTION_ARGUMENT_META__HANDLE) {
+			args[i] = &handle;
+		}
+
+		if (status != OK) {
+			break;
+		}
+	}
+	json_decref(js_request);
+
+	if (status == OK) {
+		if (dynType_descriptorType(returnType) != 'N') {
+			//NOTE To be able to handle exception only N as returnType is supported
+			LOG_ERROR("Only interface methods with a native int are supported. Found type '%c'", (char)dynType_descriptorType(returnType));
+			status = ERROR;
+		}
+	}
+
+	ffi_sarg returnVal = 1;
+
+	if (status == OK) {
+		status = dynFunction_call(func, fp, (void *) &returnVal, args);
+	}
+
+	int funcCallStatus = (int)returnVal;
+	if (funcCallStatus != 0) {
+		LOG_WARNING("Error calling remote endpoint function, got error code %i", funcCallStatus);
+	}
+
+	json_t *jsonResult = NULL;
+	for(i = 0; i < nrOfArgs; i += 1) {
+		dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
+		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
+		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
+			dynType_free(argType, args[i]);
+		}
+	}
+
+	if (funcCallStatus == 0 && status == OK) {
+		for (i = 0; i < nrOfArgs; i += 1) {
+			dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
+			enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
+			if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
+				if (status == OK) {
+					status = jsonSerializer_serializeJson(argType, args[i], &jsonResult);
+				}
+				dynType_free(argType, args[i]);
+			} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
+				if (ptr != NULL) {
+					dyn_type *typedType = NULL;
+					if (status == OK) {
+						status = dynType_typedPointer_getTypedType(argType, &typedType);
+					}
+					if (dynType_descriptorType(typedType) == 't') {
+						status = jsonSerializer_serializeJson(typedType, (void*) &ptr, &jsonResult);
+						free(ptr);
+					} else {
+						dyn_type *typedTypedType = NULL;
+						if (status == OK) {
+							status = dynType_typedPointer_getTypedType(typedType, &typedTypedType);
+						}
+
+						if(status == OK){
+							status = jsonSerializer_serializeJson(typedTypedType, ptr, &jsonResult);
+						}
+
+						if (status == OK) {
+							dynType_free(typedTypedType, ptr);
+						}
+					}
+
+				} else {
+					LOG_DEBUG("Output ptr is null");
+				}
+			}
+
+			if (status != OK) {
+				break;
+			}
+		}
+	}
+
+	char *response = NULL;
+	if (status == OK) {
+		LOG_DEBUG("creating payload\n");
+		json_t *payload = json_object();
+		if (funcCallStatus == 0) {
+			if (jsonResult == NULL) {
+				//ignore -> no result
+			} else {
+				LOG_DEBUG("Setting result payload");
+				json_object_set_new(payload, "r", jsonResult);
+			}
+		} else {
+			LOG_DEBUG("Setting error payload");
+			json_object_set_new(payload, "e", json_integer(funcCallStatus));
+		}
+		response = json_dumps(payload, JSON_DECODE_ANY);
+		json_decref(payload);
+		LOG_DEBUG("status ptr is %p. response is '%s'\n", status, response);
+	}
+
+	if (status == OK) {
+		*out = response;
+	} else {
+		free(response);
+	}
+
+	return status;
+}
+
+int jsonRpc_prepareInvokeRequest(dyn_function_type *func, const char *id, void *args[], char **out) {
+	int status = OK;
+
+
+	LOG_DEBUG("Calling remote function '%s'\n", id);
+	json_t *invoke = json_object();
+	json_object_set_new(invoke, "m", json_string(id));
+
+	json_t *arguments = json_array();
+	json_object_set_new(invoke, "a", arguments);
+
+	int i;
+	int nrOfArgs = dynFunction_nrOfArguments(func);
+	for (i = 0; i < nrOfArgs; i +=1) {
+		dyn_type *type = dynFunction_argumentTypeForIndex(func, i);
+		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
+		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
+			json_t *val = NULL;
+
+			int rc = jsonSerializer_serializeJson(type, args[i], &val);
+			if (rc == 0) {
+				json_array_append_new(arguments, val);
+			} else {
+				status = ERROR;
+				break;
+			}
+		} else {
+			//skip handle / output types
+		}
+	}
+
+	char *invokeStr = json_dumps(invoke, JSON_DECODE_ANY);
+	json_decref(invoke);
+
+	if (status == OK) {
+		*out = invokeStr;
+	}
+
+	return status;
+}
+
+int jsonRpc_handleReply(dyn_function_type *func, const char *reply, void *args[]) {
+	int status = OK;
+
+	json_error_t error;
+	json_t *replyJson = json_loads(reply, JSON_DECODE_ANY, &error);
+	if (replyJson == NULL) {
+		status = ERROR;
+		LOG_ERROR("Error parsing json '%s', got error '%s'", reply, error.text);
+	}
+
+	json_t *result = NULL;
+	if (status == OK) {
+		result = json_object_get(replyJson, "r"); //TODO check
+		if (result == NULL) {
+			status = ERROR;
+			LOG_ERROR("Cannot find r entry in json reply '%s'", reply);
+		}
+	}
+
+	if (status == OK) {
+		int nrOfArgs = dynFunction_nrOfArguments(func);
+		int i;
+		for (i = 0; i < nrOfArgs; i += 1) {
+			dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
+			enum dyn_function_argument_meta meta = dynFunction_argumentMetaForIndex(func, i);
+			if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
+				void *tmp = NULL;
+				void **out = (void **) args[i];
+
+				size_t size = 0;
+
+				if (dynType_descriptorType(argType) == 't') {
+					status = jsonSerializer_deserializeJson(argType, result, &tmp);
+					if(tmp!=NULL){
+						size = strnlen(((char *) *(char**) tmp), 1024 * 1024);
+						memcpy(*out, *(void**) tmp, size);
+					}
+				} else {
+					dynType_typedPointer_getTypedType(argType, &argType);
+					status = jsonSerializer_deserializeJson(argType, result, &tmp);
+					if(tmp!=NULL){
+						size = dynType_size(argType);
+						memcpy(*out, tmp, size);
+					}
+				}
+
+				dynType_free(argType, tmp);
+			} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
+				dyn_type *subType = NULL;
+
+				dynType_typedPointer_getTypedType(argType, &subType);
+
+				if (dynType_descriptorType(subType) == 't') {
+					void ***out = (void ***) args[i];
+					status = jsonSerializer_deserializeJson(subType, result, *out);
+				} else {
+					dyn_type *subSubType = NULL;
+					dynType_typedPointer_getTypedType(subType, &subSubType);
+					void ***out = (void ***) args[i];
+					status = jsonSerializer_deserializeJson(subSubType, result, *out);
+				}
+			} else {
+				//skip
+			}
+		}
+	}
+
+	json_decref(replyJson);
+
+	return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/src/json_serializer.c
----------------------------------------------------------------------
diff --git a/dfi/src/json_serializer.c b/dfi/src/json_serializer.c
new file mode 100644
index 0000000..4b78aeb
--- /dev/null
+++ b/dfi/src/json_serializer.c
@@ -0,0 +1,484 @@
+/**
+ *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.
+ */
+#include "json_serializer.h"
+#include "dyn_type.h"
+#include "dyn_interface.h"
+
+#include <jansson.h>
+#include <assert.h>
+#include <stdint.h>
+#include <string.h>
+
+static int jsonSerializer_createType(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 || dynType_type(type) == DYN_TYPE_SEQUENCE);
+    int status = 0;
+
+    json_error_t error;
+    json_t *root = json_loads(input, JSON_DECODE_ANY, &error);
+
+    if (root != NULL) {
+        status = jsonSerializer_deserializeJson(type, root, result);
+        json_decref(root);
+    } else {
+        status = ERROR;
+        LOG_ERROR("Error parsing json input '%s'. Error is: %s\n", input, error.text);
+    }
+
+    if (status != OK) {
+        LOG_ERROR("Error cannot deserialize json. Input is '%s'\n", input);
+    }
+    return status;
+}
+
+int jsonSerializer_deserializeJson(dyn_type *type, json_t *input, void **out) {
+    return jsonSerializer_createType(type, input, out);
+}
+
+static int jsonSerializer_createType(dyn_type *type, json_t *val, void **result) {
+    assert(val != NULL);
+    int status = OK;
+    void *inst = NULL;
+
+    if (dynType_descriptorType(type) == 't') {
+        if (json_typeof(val) == JSON_STRING) {
+            inst = strdup(json_string_value(val));
+        } else {
+            status = ERROR;
+            LOG_ERROR("Expected json_string type got %i\n", json_typeof(val));
+        }
+    } else {
+        status = dynType_alloc(type, &inst);
+
+        if (status == OK) {
+            assert(inst != NULL);
+            status = jsonSerializer_parseAny(type, inst, val);
+        }
+    }
+
+    if (status == OK) {
+        *result = inst;
+    }
+    else{
+    	dynType_free(type, 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;
+    void *valp = NULL;
+    dyn_type *valType = NULL;
+
+    int index = dynType_complex_indexForName(type, name);
+    if (index < 0) {
+        LOG_ERROR("Cannot find index for member '%s'", name);
+        status = ERROR;
+    }
+
+    if (status == OK) {
+        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);
+
+    /*
+    printf("parseAny with descriptor '%c' :", c);
+    json_dumpf(val, stdout, 0); //TODO remove
+    printf("\n");
+     */
+
+    bool *z;            //Z
+    float *f;           //F
+    double *d;          //D
+    char *b;            //B
+    int *n;             //N
+    int16_t *s;         //S
+    int32_t *i;         //I
+    int64_t *l;         //J
+    uint8_t   *ub;      //b
+    uint16_t  *us;      //s
+    uint32_t  *ui;      //i
+    uint64_t  *ul;      //j
+
+    switch (c) {
+        case 'Z' :
+            z = loc;
+            *z = (bool) json_is_true(val);
+            break;
+        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_integer_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 'b' :
+            ub = loc;
+            *ub = (uint8_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_createType(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 for index %zu", valLoc, index);
+
+            if (status == OK) {
+                status = jsonSerializer_parseAny(itemType, valLoc, val);
+                if (status != OK) {
+                    break;
+                }
+            }
+        }
+    }
+
+    return status;
+}
+
+int jsonSerializer_serialize(dyn_type *type, const void* input, char **output) {
+    int status = OK;
+
+    json_t *root = NULL;
+    status = jsonSerializer_serializeJson(type, input, &root);
+
+    if (status == OK) {
+        *output = json_dumps(root, JSON_COMPACT);
+        json_decref(root);
+    }
+
+    return status;
+}
+
+int jsonSerializer_serializeJson(dyn_type *type, const void* input, json_t **out) {
+    return jsonSerializer_writeAny(type, (void*)input /*TODO update static function to take const void**/, out);
+}
+
+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;
+
+    bool *z;            //Z
+    float *f;           //F
+    double *d;          //D
+    char *b;            //B
+    int *n;             //N
+    int16_t *s;         //S
+    int32_t *i;         //I
+    int64_t *l;         //J
+    uint8_t   *ub;      //b
+    uint16_t  *us;      //s
+    uint32_t  *ui;      //i
+    uint64_t  *ul;      //j
+
+    switch (descriptor) {
+        case 'Z' :
+            z = input;
+            val = json_boolean((bool)*z);
+            break;
+        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 'b' :
+            ub = input;
+            val = json_integer((json_int_t)*ub);
+            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);
+            if (index < 0) {
+		LOG_ERROR("Cannot find index for member '%s'", entry->name);
+                status = ERROR;
+            }
+            if(status == OK){
+		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;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/avro_descriptor_translator_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/test/avro_descriptor_translator_tests.cpp b/dfi/test/avro_descriptor_translator_tests.cpp
new file mode 100644
index 0000000..5bab518
--- /dev/null
+++ b/dfi/test/avro_descriptor_translator_tests.cpp
@@ -0,0 +1,180 @@
+/**
+ *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.
+ */
+#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");
+        va_end(ap);
+    }
+
+
+    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/a1c30887/dfi/test/descriptors/example1.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/example1.descriptor b/dfi/test/descriptors/example1.descriptor
new file mode 100644
index 0000000..771dc5e
--- /dev/null
+++ b/dfi/test/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(#am=handle;PDD#am=pre;*D)N
+sub(DD)D=sub(#am=handle;PDD*#am=pre;D)N
+sqrt(D)D=sqrt(#am=handle;PD*#am=pre;D)N
+stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/example2.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/example2.descriptor b/dfi/test/descriptors/example2.descriptor
new file mode 100644
index 0000000..38bf442
--- /dev/null
+++ b/dfi/test/descriptors/example2.descriptor
@@ -0,0 +1,9 @@
+:header
+type=interface
+name=example
+version=1.0.0
+:annotations
+:types
+item={DD a b}
+:methods
+example1=items(#am=handle;P#am=out;**[Litem;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/example3.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/example3.descriptor b/dfi/test/descriptors/example3.descriptor
new file mode 100644
index 0000000..c89d969
--- /dev/null
+++ b/dfi/test/descriptors/example3.descriptor
@@ -0,0 +1,11 @@
+:header
+type=interface
+name=detection_provider
+version=1.0.0
+:annotations
+:types
+location={DD lat lon}
+target={Jllocation;DDJ id location speed heading lastUpdated}
+detection={Jllocation;Dltarget; id center range simulated}
+:methods
+getDetections()Ljava/util/List;=getDetections(#am=handle;P#am=out;**[Ldetection;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/example4.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/example4.descriptor b/dfi/test/descriptors/example4.descriptor
new file mode 100644
index 0000000..4c959c4
--- /dev/null
+++ b/dfi/test/descriptors/example4.descriptor
@@ -0,0 +1,8 @@
+:header
+type=interface
+name=example4
+version=1.0.0
+:annotations
+:types
+:methods
+getName(V)t=getName(#am=handle;P#am=out;*t)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalid.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalid.descriptor b/dfi/test/descriptors/invalids/invalid.descriptor
new file mode 100644
index 0000000..fead964
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalid.descriptor
@@ -0,0 +1,13 @@
+:header
+type=interface
+name=calculator X
+version=1.0.0
+:annotations
+classname=org.example.Calculator
+:types
+StatsResult={DDD[D average min max input}
+:methods
+add(DD)D=add(#am=handle;PDD#am=pre;*D)N
+sub(DD)D=sub(#am=handle;PDD*#am=pre;D)N
+sqrt(D)D=sqrt(#am=handle;PD*#am=pre;D)N
+stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidMetaType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidMetaType.descriptor b/dfi/test/descriptors/invalids/invalidMetaType.descriptor
new file mode 100644
index 0000000..2d17c47
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidMetaType.descriptor
@@ -0,0 +1,8 @@
+:header
+type=interface
+name=calculator
+version=1.0.0
+:annotations
+classname=org.example.Calculator
+:methods
+add(DD)D=add(#am=invalid;PDD#am=pre;*D)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidMethod.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidMethod.descriptor b/dfi/test/descriptors/invalids/invalidMethod.descriptor
new file mode 100644
index 0000000..eaef7b1
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidMethod.descriptor
@@ -0,0 +1,8 @@
+:header
+type=interface
+name=calculator
+version=1.0.0
+:annotations
+classname=org.example.Calculator
+:methods
+add(DD)D=add(#am=handle;PDD#am=pre;*D)N X

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidMethodReturnType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidMethodReturnType.descriptor b/dfi/test/descriptors/invalids/invalidMethodReturnType.descriptor
new file mode 100644
index 0000000..26f75f8
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidMethodReturnType.descriptor
@@ -0,0 +1,8 @@
+:header
+type=interface
+name=calculator
+version=1.0.0
+:annotations
+classname=org.example.Calculator
+:methods
+add(DD)D=add(#am=handle;PDD#am=pre;*D)D

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidMsgHdr.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidMsgHdr.descriptor b/dfi/test/descriptors/invalids/invalidMsgHdr.descriptor
new file mode 100644
index 0000000..ae9b131
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidMsgHdr.descriptor
@@ -0,0 +1,9 @@
+:header
+type=message
+name=poi
+:annotations
+classname=org.example.PointOfInterest
+:types
+location={DD lat long}
+:message
+{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidMsgInvalidName.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidMsgInvalidName.descriptor b/dfi/test/descriptors/invalids/invalidMsgInvalidName.descriptor
new file mode 100644
index 0000000..787dd4c
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidMsgInvalidName.descriptor
@@ -0,0 +1,9 @@
+:header
+type=message
+name=poi X
+:annotations
+classname=org.example.PointOfInterest
+:types
+location={DD lat long}
+:message
+{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidMsgInvalidSection.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidMsgInvalidSection.descriptor b/dfi/test/descriptors/invalids/invalidMsgInvalidSection.descriptor
new file mode 100644
index 0000000..02a593c
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidMsgInvalidSection.descriptor
@@ -0,0 +1,10 @@
+:header
+type=message
+name=poi
+version=1.0.0
+:invalid
+classname=org.example.PointOfInterest
+:types
+location={DD lat long}
+:message
+{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidMsgInvalidType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidMsgInvalidType.descriptor b/dfi/test/descriptors/invalids/invalidMsgInvalidType.descriptor
new file mode 100644
index 0000000..5008311
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidMsgInvalidType.descriptor
@@ -0,0 +1,9 @@
+:header
+type=message
+name=poi
+:annotations
+classname=org.example.PointOfInterest
+:types
+location={DD lat long} X
+:message
+{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor b/dfi/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor
new file mode 100644
index 0000000..6cffbdc
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor
@@ -0,0 +1,10 @@
+:header
+type=message
+name=poi
+version=1.0.f
+:annotations
+classname=org.example.PointOfInterest
+:types
+location={DD lat long}
+:message
+{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidMsgMissingVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidMsgMissingVersion.descriptor b/dfi/test/descriptors/invalids/invalidMsgMissingVersion.descriptor
new file mode 100644
index 0000000..1fd3595
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidMsgMissingVersion.descriptor
@@ -0,0 +1,10 @@
+:head
+type=message
+name=poi
+version=1.0.0
+:annotations
+classname=org.example.PointOfInterest
+:types
+location={DD lat long}
+:message
+{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidSection.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidSection.descriptor b/dfi/test/descriptors/invalids/invalidSection.descriptor
new file mode 100644
index 0000000..b8a11a6
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidSection.descriptor
@@ -0,0 +1,6 @@
+:header
+type=interface
+name=calculator
+version=1.0.0
+:invalidSection
+invalidKey=invalidValue
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidType.descriptor b/dfi/test/descriptors/invalids/invalidType.descriptor
new file mode 100644
index 0000000..7b7ce1c
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidType.descriptor
@@ -0,0 +1,10 @@
+:header
+type=interface
+name=calculator
+version=1.0.0
+:annotations
+classname=org.example.Calculator
+:types
+StatsResult={DDD[D average min max input} X
+:methods
+stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/invalidVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/invalidVersion.descriptor b/dfi/test/descriptors/invalids/invalidVersion.descriptor
new file mode 100644
index 0000000..bfe4d38
--- /dev/null
+++ b/dfi/test/descriptors/invalids/invalidVersion.descriptor
@@ -0,0 +1,9 @@
+:header
+type=interface
+name=example
+version=q.0.0
+:annotations
+:types
+item={DD a b}
+:methods
+example1=items(#am=handle;P#am=out;**[Litem;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/invalids/noVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/invalids/noVersion.descriptor b/dfi/test/descriptors/invalids/noVersion.descriptor
new file mode 100644
index 0000000..731a9e6
--- /dev/null
+++ b/dfi/test/descriptors/invalids/noVersion.descriptor
@@ -0,0 +1,12 @@
+:header
+type=interface
+name=calculator
+:annotations
+classname=org.example.Calculator
+:types
+StatsResult={DDD[D average min max input}
+:methods
+add(DD)D=add(#am=handle;PDD#am=pre;*D)N
+sub(DD)D=sub(#am=handle;PDD*#am=pre;D)N
+sqrt(D)D=sqrt(#am=handle;PD*#am=pre;D)N
+stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/msg_example1.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/msg_example1.descriptor b/dfi/test/descriptors/msg_example1.descriptor
new file mode 100644
index 0000000..576523a
--- /dev/null
+++ b/dfi/test/descriptors/msg_example1.descriptor
@@ -0,0 +1,10 @@
+:header
+type=message
+name=poi
+version=1.0.0
+:annotations
+classname=org.example.PointOfInterest
+:types
+location={DD lat long}
+:message
+{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/msg_example2.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/msg_example2.descriptor b/dfi/test/descriptors/msg_example2.descriptor
new file mode 100644
index 0000000..128049d
--- /dev/null
+++ b/dfi/test/descriptors/msg_example2.descriptor
@@ -0,0 +1,12 @@
+:header
+type=message
+name=track
+version=0.0.1
+:annotations
+classname=org.example.Track
+:types
+timestamp={SSSSSSI day month year hour minute second microseconds}
+latlonpos={DD lat lon}
+polarpos={DDD azimuth elevation range}
+:message
+{Iltimestamp;llatlonpos;lpolarpos;SS trackid lastupdate abspos relpos classification identity}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/msg_example3.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/msg_example3.descriptor b/dfi/test/descriptors/msg_example3.descriptor
new file mode 100644
index 0000000..7b69380
--- /dev/null
+++ b/dfi/test/descriptors/msg_example3.descriptor
@@ -0,0 +1,10 @@
+:header
+type=message
+name=logEntry
+version=1.0.0
+:annotations
+classname=org.example.LogEntry
+:types
+timestamp={SSSSSSI day month year hour minute second microseconds}
+:message
+{ltimestamp;St timestamp severity eventdescription}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/descriptors/msg_example4.descriptor
----------------------------------------------------------------------
diff --git a/dfi/test/descriptors/msg_example4.descriptor b/dfi/test/descriptors/msg_example4.descriptor
new file mode 100644
index 0000000..e99e443
--- /dev/null
+++ b/dfi/test/descriptors/msg_example4.descriptor
@@ -0,0 +1,10 @@
+:header
+type=message
+name=exmpl4
+version=1.1.0
+:annotations
+:types
+info={Jladditional_info; id info}
+additional_info={Jt; id descr}
+:message
+{Jlinfo; id info}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/dyn_closure_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/test/dyn_closure_tests.cpp b/dfi/test/dyn_closure_tests.cpp
new file mode 100644
index 0000000..9c1abe6
--- /dev/null
+++ b/dfi/test/dyn_closure_tests.cpp
@@ -0,0 +1,162 @@
+/**
+ *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.
+ */
+#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*, 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");
+    va_end(ap);
+}
+
+#define EXAMPLE1_DESCRIPTOR "example(III)I"
+static void example1_binding(void*, 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*, 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*, 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() {
+        int lvl = 1;
+        dynFunction_logSetup(stdLog, NULL, lvl);
+        dynType_logSetup(stdLog, NULL, lvl);
+        dynCommon_logSetup(stdLog, NULL, lvl);
+        g_count = 0;
+    }
+};
+
+TEST(DynClosureTests, DynCLosureTest1) {
+    //TODO split up
+    tests();
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/dyn_function_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/test/dyn_function_tests.cpp b/dfi/test/dyn_function_tests.cpp
new file mode 100644
index 0000000..58ad662
--- /dev/null
+++ b/dfi/test/dyn_function_tests.cpp
@@ -0,0 +1,274 @@
+/**
+ *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.
+ */
+#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*, 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");
+        va_end(ap);
+    }
+
+    #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);
+    }
+
+    static void test_access_functions(void) {
+        dyn_function_type *dynFunc = NULL;
+        int rc;
+        rc = dynFunction_parseWithStr("add(D{DD a b}*D)V", NULL, &dynFunc);
+
+        CHECK_EQUAL(0, rc);
+
+        int nrOfArgs = dynFunction_nrOfArguments(dynFunc);
+        CHECK_EQUAL(3, nrOfArgs);
+
+        dyn_type *arg1 = dynFunction_argumentTypeForIndex(dynFunc, 1);
+        CHECK(arg1 != NULL);
+        CHECK_EQUAL('{', (char) dynType_descriptorType(arg1));
+
+        dyn_type *nonExist = dynFunction_argumentTypeForIndex(dynFunc, 10);
+        CHECK(nonExist == NULL);
+
+        dyn_type *returnType = dynFunction_returnType(dynFunc);
+        CHECK_EQUAL('V', (char) dynType_descriptorType(returnType));
+
+        dynFunction_destroy(dynFunc);
+    }
+
+    //example with gen pointer and output
+    #define EXAMPLE3_DESCRIPTOR "example(PD*D)N"
+
+    static int testExample3(void *ptr, double a, double *out) {
+        double *b = (double *)ptr;
+        CHECK_EQUAL(2.0, *b)
+        CHECK_EQUAL(a, 2.0);
+        *out = *b * a;
+        return 0;
+    }
+
+    static void test_example3(void) {
+        dyn_function_type *dynFunc = NULL;
+        void (*fp)(void) = (void(*)(void)) testExample3;
+        int rc;
+
+        rc = dynFunction_parseWithStr(EXAMPLE3_DESCRIPTOR, NULL, &dynFunc);
+        CHECK_EQUAL(0, rc);
+        double result = -1.0;
+        double *input = &result;
+        double a = 2.0;
+        void *ptr = &a;
+        void *args[3];
+        args[0] = &ptr;
+        args[1] = &a;
+        args[2] = &input;
+        int rVal = 0;
+        rc = dynFunction_call(dynFunc, fp, &rVal, args);
+        CHECK_EQUAL(0, rc);
+        CHECK_EQUAL(4.0, result);
+
+
+        double *inMemResult = (double *)calloc(1, sizeof(double));
+        a = 2.0;
+        ptr = &a;
+        args[0] = &ptr;
+        args[1] = &a;
+        args[2] = &inMemResult;
+        rVal = 0;
+        rc = dynFunction_call(dynFunc, fp, &rVal, args);
+        CHECK_EQUAL(0, rc);
+        CHECK_EQUAL(4.0, result);
+        free(inMemResult);
+
+        dynFunction_destroy(dynFunc);
+    }
+
+    struct tst_seq {
+        uint32_t cap;
+        uint32_t len;
+        double *buf;
+    };
+
+    #define EXAMPLE4_DESCRIPTOR "example([D)V"
+
+    static void example4Func(struct tst_seq seq) {
+        CHECK_EQUAL(4, seq.cap);
+        CHECK_EQUAL(2, seq.len);
+        CHECK_EQUAL(1.1, seq.buf[0]);
+        CHECK_EQUAL(2.2, seq.buf[1]);
+    }
+
+    static void test_example4(void) {
+        dyn_function_type *dynFunc = NULL;
+        void (*fp)(void) = (void(*)(void)) example4Func;
+        int rc;
+
+        rc = dynFunction_parseWithStr(EXAMPLE4_DESCRIPTOR, NULL, &dynFunc);
+        CHECK_EQUAL(0, rc);
+
+        double buf[4];
+        buf[0] = 1.1;
+        buf[1] = 2.2;
+        struct tst_seq seq;
+        seq.cap = 4;
+        seq.len = 2;
+        seq.buf = buf;
+
+        void *args[1];
+        args[0] = &seq;
+        rc = dynFunction_call(dynFunc, fp, NULL, args);
+        CHECK_EQUAL(0, rc);
+
+        dynFunction_destroy(dynFunc);
+    }
+
+    #define INVALID_FUNC_DESCRIPTOR "example$[D)V"//$ is an invalid symbol, missing (
+
+    static void test_invalidDynFunc(void) {
+        dyn_function_type *dynFunc = NULL;
+        int rc = dynFunction_parseWithStr(INVALID_FUNC_DESCRIPTOR, NULL, &dynFunc);
+        CHECK_EQUAL(2, rc); //Mem error
+    }
+
+    #define INVALID_FUNC_TYPE_DESCRIPTOR "example(H)A"//H and A are invalid types
+
+    static void test_invalidDynFuncType(void) {
+        dyn_function_type *dynFunc = NULL;
+        int rc = dynFunction_parseWithStr(INVALID_FUNC_TYPE_DESCRIPTOR, NULL, &dynFunc);
+        CHECK_EQUAL(3, rc); //Parse Error
+    }
+}
+
+TEST_GROUP(DynFunctionTests) {
+    void setup() {
+        int lvl = 1;
+        dynFunction_logSetup(stdLog, NULL, lvl);
+        dynType_logSetup(stdLog, NULL, lvl);
+        dynCommon_logSetup(stdLog, NULL, lvl);
+    }
+};
+
+TEST(DynFunctionTests, DynFuncTest1) {
+    test_example1();
+}
+
+TEST(DynFunctionTests, DynFuncTest2) {
+    test_example2();
+}
+
+TEST(DynFunctionTests, DynFuncAccTest) {
+    test_access_functions();
+}
+
+TEST(DynFunctionTests, DynFuncTest3) {
+    test_example3();
+}
+
+TEST(DynFunctionTests, DynFuncTest4) {
+    test_example4();
+}
+
+TEST(DynFunctionTests, InvalidDynFuncTest) {
+    test_invalidDynFunc();
+    test_invalidDynFuncType();
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/dyn_interface_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/test/dyn_interface_tests.cpp b/dfi/test/dyn_interface_tests.cpp
new file mode 100644
index 0000000..df9752f
--- /dev/null
+++ b/dfi/test/dyn_interface_tests.cpp
@@ -0,0 +1,207 @@
+/**
+ *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.
+ */
+#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*, 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");
+        va_end(ap);
+    }
+
+    static void checkInterfaceVersion(dyn_interface_type* dynIntf, const char* v) {
+        int status;
+
+        char *version = NULL;
+        status = dynInterface_getVersionString(dynIntf, &version);
+        CHECK_EQUAL(0, status);
+        STRCMP_EQUAL(v, version);
+        version_pt msgVersion = NULL, localMsgVersion = NULL;
+        int cmpVersion = -1;
+        version_createVersionFromString(version, &localMsgVersion);
+        status = dynInterface_getVersion(dynIntf, &msgVersion);
+        CHECK_EQUAL(0, status);
+        version_compareTo(msgVersion, localMsgVersion, &cmpVersion);
+        CHECK_EQUAL(cmpVersion, 0);
+        version_destroy(localMsgVersion);
+    }
+
+    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);
+
+	checkInterfaceVersion(dynIntf,"1.0.0");
+
+        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);
+
+        struct methods_head *list = NULL;
+        status = dynInterface_methods(dynIntf, &list);
+        CHECK(status == 0);
+        CHECK(list != NULL);
+
+        int count = dynInterface_nrOfMethods(dynIntf);
+        CHECK_EQUAL(4, count);
+
+        dynInterface_destroy(dynIntf);
+    }
+
+    static void test2(void) {
+        int status = 0;
+        dyn_interface_type *dynIntf = NULL;
+        FILE *desc = fopen("descriptors/example3.descriptor", "r");
+        assert(desc != NULL);
+        status = dynInterface_parse(desc, &dynIntf);
+        CHECK_EQUAL(0, status);
+        fclose(desc);
+
+        dynInterface_destroy(dynIntf);
+    }
+
+    static void testInvalid(void) {
+        int status = 0;
+
+        /* Invalid field */
+        dyn_interface_type *dynIntf = NULL;
+        FILE *desc = fopen("descriptors/invalids/invalid.descriptor", "r");
+        assert(desc != NULL);
+        status = dynInterface_parse(desc, &dynIntf);
+        //dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of a space at the end of the name
+        fclose(desc); desc=NULL;
+
+
+        /* Header without Version */
+        desc = fopen("descriptors/invalids/noVersion.descriptor", "r");
+        assert(desc != NULL);
+        status = dynInterface_parse(desc, &dynIntf);
+        //dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of missing version field in header section
+        fclose(desc); desc=NULL;
+
+        /* Invalid section */
+        desc = fopen("descriptors/invalids/invalidSection.descriptor", "r");
+        assert(desc != NULL);
+        status = dynInterface_parse(desc, &dynIntf);
+        //dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of unknown section type
+        fclose(desc); desc=NULL;
+
+        /* Invalid return type */
+        desc = fopen("descriptors/invalids/invalidMethodReturnType.descriptor", "r");
+        assert(desc != NULL);
+        status = dynInterface_parse(desc, &dynIntf);
+        //dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of invalid return type (D instead of N)
+        fclose(desc); desc=NULL;
+
+        /* Invalid  method section */
+        desc = fopen("descriptors/invalids/invalidMethod.descriptor", "r");
+        assert(desc != NULL);
+        status = dynInterface_parse(desc, &dynIntf);
+        //dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of space at the end of the method
+        fclose(desc); desc=NULL;
+
+        /* Invalid type */
+        desc = fopen("descriptors/invalids/invalidType.descriptor", "r");
+        assert(desc != NULL);
+        status = dynInterface_parse(desc, &dynIntf);
+        //dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of space at the end of the type
+        fclose(desc); desc=NULL;
+
+        /* Invalid metatype in method description */
+        desc = fopen("descriptors/invalids/invalidMetaType.descriptor", "r");
+        assert(desc != NULL);
+        status = dynInterface_parse(desc, &dynIntf);
+        dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(0, status); //Invalid meta type doesn't generate errors, just warnings
+        fclose(desc); desc=NULL; dynIntf=NULL;
+
+        /* Invalid version section */
+        desc = fopen("descriptors/invalids/invalidVersion.descriptor", "r");
+        assert(desc != NULL);
+        status = dynInterface_parse(desc, &dynIntf);
+        //dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Invalid meta type doesn't generate errors, just warnings
+        fclose(desc); desc=NULL;
+
+    }
+}
+
+
+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();
+}
+
+TEST(DynInterfaceTests, test2) {
+    test2();
+}
+
+TEST(DynInterfaceTests, testInvalid) {
+    testInvalid();
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/dyn_message_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/test/dyn_message_tests.cpp b/dfi/test/dyn_message_tests.cpp
new file mode 100644
index 0000000..e310537
--- /dev/null
+++ b/dfi/test/dyn_message_tests.cpp
@@ -0,0 +1,253 @@
+/**
+ *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.
+ */
+#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_message.h"
+
+#if defined(BSD) || defined(__APPLE__) 
+#include "open_memstream.h"
+#include "fmemopen.h"
+#endif
+
+static void stdLog(void*, 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");
+	va_end(ap);
+}
+
+static void checkMessageVersion(dyn_message_type* dynMsg, const char* v){
+	int status = 0;
+
+	char *version = NULL;
+	status = dynMessage_getVersionString(dynMsg, &version);
+	CHECK_EQUAL(0, status);
+	STRCMP_EQUAL(v, version);
+	version_pt msgVersion = NULL, localMsgVersion = NULL;
+	int cmpVersion = -1;
+	version_createVersionFromString(version,&localMsgVersion);
+	status = dynMessage_getVersion(dynMsg,&msgVersion);
+	CHECK_EQUAL(0, status);
+	version_compareTo(msgVersion,localMsgVersion,&cmpVersion);
+	CHECK_EQUAL(cmpVersion,0);
+	version_destroy(localMsgVersion);
+
+}
+
+
+static void msg_test1(void) {
+	int status = 0;
+	dyn_message_type *dynMsg = NULL;
+	FILE *desc = fopen("descriptors/msg_example1.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK_EQUAL(0, status);
+	fclose(desc);
+
+	char *name = NULL;
+	status = dynMessage_getName(dynMsg, &name);
+	CHECK_EQUAL(0, status);
+	STRCMP_EQUAL("poi", name);
+
+	checkMessageVersion(dynMsg,"1.0.0");
+
+	char *annVal = NULL;
+	status = dynMessage_getAnnotationEntry(dynMsg, "classname", &annVal);
+	CHECK_EQUAL(0, status);
+	STRCMP_EQUAL("org.example.PointOfInterest", annVal);
+
+	char *nonExist = NULL;
+	status = dynMessage_getHeaderEntry(dynMsg, "nonExisting", &nonExist);
+	CHECK(status != 0);
+	CHECK(nonExist == NULL);
+
+	dyn_type *msgType = NULL;
+	status = dynMessage_getMessageType(dynMsg, &msgType);
+	CHECK_EQUAL(0, status);
+	CHECK(msgType != NULL);
+
+	dynMessage_destroy(dynMsg);
+}
+
+
+static void msg_test2(void) {
+	int status = 0;
+	dyn_message_type *dynMsg = NULL;
+	FILE *desc = fopen("descriptors/msg_example2.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK_EQUAL(0, status);
+	fclose(desc);
+
+	char *name = NULL;
+	status = dynMessage_getName(dynMsg, &name);
+	CHECK_EQUAL(0, status);
+	STRCMP_EQUAL("track", name);
+
+	checkMessageVersion(dynMsg,"0.0.1");
+
+	char *annVal = NULL;
+	status = dynMessage_getAnnotationEntry(dynMsg, "classname", &annVal);
+	CHECK_EQUAL(0, status);
+	STRCMP_EQUAL("org.example.Track", annVal);
+
+	char *nonExist = NULL;
+	status = dynMessage_getHeaderEntry(dynMsg, "nonExisting", &nonExist);
+	CHECK(status != 0);
+	CHECK(nonExist == NULL);
+
+	dyn_type *msgType = NULL;
+	status = dynMessage_getMessageType(dynMsg, &msgType);
+	CHECK_EQUAL(0, status);
+	CHECK(msgType != NULL);
+
+	dynMessage_destroy(dynMsg);
+}
+
+static void msg_test3(void) {
+	int status = 0;
+	dyn_message_type *dynMsg = NULL;
+	FILE *desc = fopen("descriptors/msg_example3.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK_EQUAL(0, status);
+	fclose(desc);
+
+	char *name = NULL;
+	status = dynMessage_getName(dynMsg, &name);
+	CHECK_EQUAL(0, status);
+	STRCMP_EQUAL("logEntry", name);
+
+	checkMessageVersion(dynMsg,"1.0.0");
+
+	char *annVal = NULL;
+	status = dynMessage_getAnnotationEntry(dynMsg, "classname", &annVal);
+	CHECK_EQUAL(0, status);
+	STRCMP_EQUAL("org.example.LogEntry", annVal);
+
+	char *nonExist = NULL;
+	status = dynMessage_getHeaderEntry(dynMsg, "nonExisting", &nonExist);
+	CHECK(status != 0);
+	CHECK(nonExist == NULL);
+
+	dyn_type *msgType = NULL;
+	status = dynMessage_getMessageType(dynMsg, &msgType);
+	CHECK_EQUAL(0, status);
+	CHECK(msgType != NULL);
+
+	dynMessage_destroy(dynMsg);
+}
+
+static void msg_test4(void) {
+	int status = 0;
+	dyn_message_type *dynMsg = NULL;
+	FILE *desc = fopen("descriptors/msg_example4.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK(status != 0);
+	fclose(desc);
+}
+
+static void msg_invalid(void) {
+	int status = 0;
+	dyn_message_type *dynMsg = NULL;
+	FILE *desc = fopen("descriptors/invalids/invalidMsgHdr.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK_EQUAL(1, status);
+	fclose(desc);
+
+	desc = fopen("descriptors/invalids/invalidMsgMissingVersion.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK_EQUAL(1, status);
+	fclose(desc);
+
+	desc = fopen("descriptors/invalids/invalidMsgInvalidSection.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK_EQUAL(1, status);
+	fclose(desc);
+
+	desc = fopen("descriptors/invalids/invalidMsgInvalidName.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK_EQUAL(1, status);
+	fclose(desc);
+
+	desc = fopen("descriptors/invalids/invalidMsgInvalidType.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK_EQUAL(1, status);
+	fclose(desc);
+
+	desc = fopen("descriptors/invalids/invalidMsgInvalidVersion.descriptor", "r");
+	assert(desc != NULL);
+	status = dynMessage_parse(desc, &dynMsg);
+	CHECK_EQUAL(1, status);
+	fclose(desc);
+
+}
+
+}
+
+
+TEST_GROUP(DynMessageTests) {
+	void setup() {
+		int level = 1;
+		dynCommon_logSetup(stdLog, NULL, level);
+		dynType_logSetup(stdLog, NULL, level);
+		dynMessage_logSetup(stdLog, NULL, level);
+	}
+};
+
+
+TEST(DynMessageTests, msg_test1) {
+	msg_test1();
+}
+
+TEST(DynMessageTests, msg_test2) {
+	msg_test2();
+}
+
+TEST(DynMessageTests, msg_test3) {
+	msg_test3();
+}
+
+TEST(DynMessageTests, msg_test4) {
+	msg_test4();
+}
+
+TEST(DynMessageTests, msg_invalid) {
+	msg_invalid();
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/test/dyn_type_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/test/dyn_type_tests.cpp b/dfi/test/dyn_type_tests.cpp
new file mode 100644
index 0000000..52f9537
--- /dev/null
+++ b/dfi/test/dyn_type_tests.cpp
@@ -0,0 +1,297 @@
+/**
+ *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.
+ */
+#include <CppUTest/TestHarness.h>
+#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
+
+extern "C" {
+    #include <stdarg.h>
+    
+    #include "dyn_common.h"
+    #include "dyn_type.h"
+
+	static void stdLog(void*, 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");
+	    va_end(ap);
+	}
+
+    static void runTest(const char *descriptorStr, const char *exName) {
+        dyn_type *type;
+        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);
+
+        //MEM check, to try to ensure no mem leaks/corruptions occur.
+        int i;
+        int j;
+        int nrOfBurst = 10;
+        int burst = 50;
+        void *pointers[burst];
+        for (j = 0; j < nrOfBurst; j += 1) {
+            for (i = 0; i < burst ; i +=1 ) {
+                pointers[i] = NULL;
+                dynType_alloc(type, &pointers[i]);
+            }
+            for (i = 0; i < burst ; i +=1 ) {
+                dynType_free(type, pointers[i]);
+            }
+        }
+
+        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, 1);
+	}
+};
+
+#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 EX15 "Tsample={jDD time val1 val2};Tresult={jDlsample; time result sample};Lresult;"
+#define EX16 "Tpoi={BDD id lat lon};Lpoi;"
+
+#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)
+CREATE_EXAMPLES_TEST(EX15)
+CREATE_EXAMPLES_TEST(EX16)
+
+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);
+}
+
+TEST(DynTypeTests, MetaInfoTest) {
+    dyn_type *type = NULL;
+    int rc = 0;
+    rc = dynType_parseWithStr("#a=t;{DD#longname=longvalue;D a b c}", NULL, NULL, &type);
+    //rc = dynType_parseWithStr("{DDD a b c}", NULL, NULL, &type);
+
+    CHECK_EQUAL(0, rc);
+
+    const char *val = NULL;
+    val = dynType_getMetaInfo(type, "a");
+    CHECK(val != NULL);
+    CHECK(strcmp("t", val) == 0);
+
+    val = dynType_getMetaInfo(type, "longname");
+    CHECK(val == NULL);
+
+    val = dynType_getMetaInfo(type, "nonexisting");
+    CHECK(val == NULL);
+
+    dynType_destroy(type);
+}
+
+TEST(DynTypeTests, SequenceWithPointerTest) {
+    struct val {
+        double a;
+        double b;
+    };
+
+    struct item {
+        int64_t a;
+        const char *text;
+        struct val val;
+        double c;
+        double d;
+        long e;
+    };
+
+    struct item_sequence {
+        uint32_t cap;
+        uint32_t len;
+        struct item **buf;
+    };
+
+    dyn_type *type = NULL;
+    int rc = 0;
+    rc = dynType_parseWithStr("Tval={DD a b};Titem={Jtlval;DDJ a text val c d e};**[Litem;", NULL, NULL, &type);
+    CHECK_EQUAL(0, rc);
+
+    struct item_sequence *seq = NULL;
+    rc = dynType_alloc(type, (void **)&seq);
+    CHECK_EQUAL(0, rc);
+    CHECK(seq != NULL);
+
+    dynType_free(type, seq);
+
+    /*
+
+
+    struct item_sequence *items = (struct item_sequence *) calloc(1,sizeof(struct item_sequence));
+    items->buf = (struct item **) calloc(2, sizeof(struct item *));
+    items->cap = 2;
+    items->len = 2;
+    items->buf[0] = (struct item *)calloc(1, sizeof(struct item));
+    items->buf[0]->text = strdup("boe");
+    items->buf[1] = (struct item *)calloc(1, sizeof(struct item));
+    items->buf[1]->text = strdup("boe2");
+
+    dynType_free(type, items);
+     */
+
+    dynType_destroy(type);
+}
+


[26/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/framework_exports.h
----------------------------------------------------------------------
diff --git a/framework/include/framework_exports.h b/framework/include/framework_exports.h
new file mode 100644
index 0000000..50d7f6e
--- /dev/null
+++ b/framework/include/framework_exports.h
@@ -0,0 +1,65 @@
+/**
+ *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.
+ */
+/*
+ * exports.h
+ */
+
+#ifndef FRAMEWORK_EXPORTS_H_
+#define FRAMEWORK_EXPORTS_H_
+
+/* Cmake will define celix_framework_EXPORTS on Windows when it
+configures to build a shared library. If you are going to use
+another build system on windows or create the visual studio
+projects by hand you need to define celix_framework_EXPORTS when
+building a DLL on windows.
+*/
+// We are using the Visual Studio Compiler and building Shared libraries
+
+#if defined _WIN32 || defined __CYGWIN__
+  #ifdef celix_framework_EXPORTS
+    #ifdef __GNUC__
+      #define FRAMEWORK_EXPORT __attribute__ ((dllexport))
+      #define ACTIVATOR_EXPORT __attribute__ ((dllexport))
+    #else
+      #define ACTIVATOR_EXPORT __declspec(dllexport)
+      #define FRAMEWORK_EXPORT __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
+    #endif
+  #else
+    #ifdef __GNUC__
+      #define ACTIVATOR_EXPORT __attribute__ ((dllexport))
+      #define FRAMEWORK_EXPORT __attribute__ ((dllimport))
+    #else
+      #define ACTIVATOR_EXPORT __declspec(dllexport)
+      #define FRAMEWORK_EXPORT __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
+    #endif
+  #endif
+  #define DLL_LOCAL
+#else
+  #if __GNUC__ >= 4
+    #define ACTIVATOR_EXPORT __attribute__ ((visibility ("default")))
+    #define FRAMEWORK_EXPORT __attribute__ ((visibility ("default")))
+    #define FRAMEWORK_LOCAL  __attribute__ ((visibility ("hidden")))
+  #else
+    #define ACTIVATOR_EXPORT
+    #define FRAMEWORK_EXPORT
+    #define FRAMEWORK_LOCAL
+  #endif
+#endif
+
+#endif /* FRAMEWORK_EXPORTS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/framework_listener.h
----------------------------------------------------------------------
diff --git a/framework/include/framework_listener.h b/framework/include/framework_listener.h
new file mode 100644
index 0000000..f390e3b
--- /dev/null
+++ b/framework/include/framework_listener.h
@@ -0,0 +1,55 @@
+/*
+ *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.
+ */
+/**
+ *
+ * @defgroup FrameworkListener Framework Listener
+ * @ingroup framework
+ * @{
+ *
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \date      	Oct 8, 2013
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef FRAMEWORK_LISTENER_H_
+#define FRAMEWORK_LISTENER_H_
+
+typedef struct framework_listener *framework_listener_pt;
+
+#include "celix_errno.h"
+#include "framework_event.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct framework_listener {
+	void *handle;
+
+	celix_status_t (*frameworkEvent)(void *listener, framework_event_pt event);
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* FRAMEWORK_LISTENER_H_ */
+
+/**
+ * @}
+ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/listener_hook_service.h
----------------------------------------------------------------------
diff --git a/framework/include/listener_hook_service.h b/framework/include/listener_hook_service.h
new file mode 100644
index 0000000..1f0c966
--- /dev/null
+++ b/framework/include/listener_hook_service.h
@@ -0,0 +1,60 @@
+/*
+ *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.
+ */
+/*
+ * listener_hook_service.h
+ *
+ *  \date       Oct 28, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef LISTENER_HOOK_SERVICE_H_
+#define LISTENER_HOOK_SERVICE_H_
+
+
+typedef struct listener_hook *listener_hook_pt;
+typedef struct listener_hook_info *listener_hook_info_pt;
+typedef struct listener_hook_service *listener_hook_service_pt;
+
+#include "bundle_context.h"
+
+#define OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME "listener_hook_service"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct listener_hook_info {
+	bundle_context_pt context;
+	char *filter;
+	bool removed;
+};
+
+struct listener_hook_service {
+	void *handle;
+
+	celix_status_t (*added)(void *hook, array_list_pt listeners);
+
+	celix_status_t (*removed)(void *hook, array_list_pt listeners);
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LISTENER_HOOK_SERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/manifest.h
----------------------------------------------------------------------
diff --git a/framework/include/manifest.h b/framework/include/manifest.h
new file mode 100644
index 0000000..eeccfbc
--- /dev/null
+++ b/framework/include/manifest.h
@@ -0,0 +1,67 @@
+/**
+ *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.
+ */
+/*
+ * manifest.h
+ *
+ *  \date       Jul 5, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef MANIFEST_H_
+#define MANIFEST_H_
+
+#include "properties.h"
+#include "celix_errno.h"
+#include "framework_exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct manifest {
+	properties_pt mainAttributes;
+	hash_map_pt attributes;
+};
+
+typedef struct manifest *manifest_pt;
+
+FRAMEWORK_EXPORT celix_status_t manifest_create(manifest_pt *manifest);
+
+FRAMEWORK_EXPORT celix_status_t manifest_createFromFile(const char *filename, manifest_pt *manifest);
+
+FRAMEWORK_EXPORT celix_status_t manifest_destroy(manifest_pt manifest);
+
+FRAMEWORK_EXPORT void manifest_clear(manifest_pt manifest);
+
+FRAMEWORK_EXPORT properties_pt manifest_getMainAttributes(manifest_pt manifest);
+
+FRAMEWORK_EXPORT celix_status_t manifest_getEntries(manifest_pt manifest, hash_map_pt *map);
+
+FRAMEWORK_EXPORT celix_status_t manifest_read(manifest_pt manifest, const char *filename);
+
+FRAMEWORK_EXPORT void manifest_write(manifest_pt manifest, const char *filename);
+
+FRAMEWORK_EXPORT const char *manifest_getValue(manifest_pt manifest, const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MANIFEST_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/module.h
----------------------------------------------------------------------
diff --git a/framework/include/module.h b/framework/include/module.h
new file mode 100644
index 0000000..bc85ef4
--- /dev/null
+++ b/framework/include/module.h
@@ -0,0 +1,94 @@
+/**
+ *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.
+ */
+/*
+ * module.h
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef MODULE_H_
+#define MODULE_H_
+
+typedef struct module *module_pt;
+
+#include "celixbool.h"
+#include "linked_list.h"
+#include "manifest.h"
+#include "version.h"
+#include "array_list.h"
+#include "bundle.h"
+#include "framework_exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+module_pt module_create(manifest_pt headerMap, const char *moduleId, bundle_pt bundle);
+
+module_pt module_createFrameworkModule(bundle_pt bundle);
+
+void module_destroy(module_pt module);
+
+FRAMEWORK_EXPORT unsigned int module_hash(void *module);
+
+FRAMEWORK_EXPORT int module_equals(void *module, void *compare);
+
+FRAMEWORK_EXPORT wire_pt module_getWire(module_pt module, const char *serviceName);
+
+FRAMEWORK_EXPORT version_pt module_getVersion(module_pt module);
+
+FRAMEWORK_EXPORT celix_status_t module_getSymbolicName(module_pt module, const char **symbolicName);
+
+FRAMEWORK_EXPORT char *module_getId(module_pt module);
+
+FRAMEWORK_EXPORT linked_list_pt module_getWires(module_pt module);
+
+FRAMEWORK_EXPORT void module_setWires(module_pt module, linked_list_pt wires);
+
+FRAMEWORK_EXPORT bool module_isResolved(module_pt module);
+
+FRAMEWORK_EXPORT void module_setResolved(module_pt module);
+
+FRAMEWORK_EXPORT bundle_pt module_getBundle(module_pt module);
+
+FRAMEWORK_EXPORT linked_list_pt module_getRequirements(module_pt module);
+
+FRAMEWORK_EXPORT linked_list_pt module_getCapabilities(module_pt module);
+
+FRAMEWORK_EXPORT array_list_pt module_getDependentImporters(module_pt module);
+
+FRAMEWORK_EXPORT void module_addDependentImporter(module_pt module, module_pt importer);
+
+FRAMEWORK_EXPORT void module_removeDependentImporter(module_pt module, module_pt importer);
+
+FRAMEWORK_EXPORT array_list_pt module_getDependentRequirers(module_pt module);
+
+FRAMEWORK_EXPORT void module_addDependentRequirer(module_pt module, module_pt requirer);
+
+FRAMEWORK_EXPORT void module_removeDependentRequirer(module_pt module, module_pt requirer);
+
+FRAMEWORK_EXPORT array_list_pt module_getDependents(module_pt module);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MODULE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/requirement.h
----------------------------------------------------------------------
diff --git a/framework/include/requirement.h b/framework/include/requirement.h
new file mode 100644
index 0000000..febc62a
--- /dev/null
+++ b/framework/include/requirement.h
@@ -0,0 +1,53 @@
+/**
+ *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.
+ */
+/*
+ * requirement.h
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef REQUIREMENT_H_
+#define REQUIREMENT_H_
+
+typedef struct requirement *requirement_pt;
+
+#include "capability.h"
+#include "hash_map.h"
+#include "version_range.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+celix_status_t requirement_create(hash_map_pt directives, hash_map_pt attributes, requirement_pt *requirement);
+
+celix_status_t requirement_destroy(requirement_pt requirement);
+
+celix_status_t requirement_getVersionRange(requirement_pt requirement, version_range_pt *range);
+
+celix_status_t requirement_getTargetName(requirement_pt requirement, const char **targetName);
+
+celix_status_t requirement_isSatisfied(requirement_pt requirement, capability_pt capability, bool *inRange);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* REQUIREMENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/service_event.h
----------------------------------------------------------------------
diff --git a/framework/include/service_event.h b/framework/include/service_event.h
new file mode 100644
index 0000000..a018b07
--- /dev/null
+++ b/framework/include/service_event.h
@@ -0,0 +1,68 @@
+/*
+ *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.
+ */
+/**
+ *
+ * @defgroup ServiceListener Service Listener
+ * @ingroup framework
+ * @{
+ *
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \date      	January 11, 2012
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef SERVICE_EVENT_H_
+#define SERVICE_EVENT_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum serviceEventType {
+	OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED = 0x00000001,
+	OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED = 0x00000002,
+	OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING = 0x00000004,
+	OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH = 0x00000008,
+};
+
+typedef enum serviceEventType service_event_type_e;
+
+typedef struct serviceEvent *service_event_pt;
+#ifdef __cplusplus
+}
+#endif
+
+#include "service_reference.h"
+
+#include "service_reference.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct serviceEvent {
+	service_reference_pt reference;
+	service_event_type_e type;
+};
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SERVICE_EVENT_H_ */
+
+/**
+ * @}
+ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/service_factory.h
----------------------------------------------------------------------
diff --git a/framework/include/service_factory.h b/framework/include/service_factory.h
new file mode 100644
index 0000000..84e383a
--- /dev/null
+++ b/framework/include/service_factory.h
@@ -0,0 +1,60 @@
+/**
+ *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.
+ */
+/*
+ * service_factory.h
+ *
+ *  \date       Jun 26, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef SERVICE_FACTORY_H_
+#define SERVICE_FACTORY_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct service_factory service_factory_t;
+typedef service_factory_t *service_factory_pt;
+#ifdef __cplusplus
+}
+#endif
+
+#include "celix_errno.h"
+#include "service_registration.h"
+#include "bundle.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct service_factory {
+    void *handle;
+
+    celix_status_t (*getService)(void *handle, bundle_pt bundle, service_registration_pt registration, void **service);
+
+    celix_status_t
+    (*ungetService)(void *handle, bundle_pt bundle, service_registration_pt registration, void **service);
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SERVICE_FACTORY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/service_listener.h
----------------------------------------------------------------------
diff --git a/framework/include/service_listener.h b/framework/include/service_listener.h
new file mode 100644
index 0000000..c887ba1
--- /dev/null
+++ b/framework/include/service_listener.h
@@ -0,0 +1,55 @@
+/*
+ *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.
+ */
+/**
+ *
+ * @defgroup ServiceListener Service Listener
+ * @ingroup framework
+ * @{
+ *
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \date      	January 11, 2012
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef SERVICE_LISTENER_H_
+#define SERVICE_LISTENER_H_
+
+typedef struct serviceListener * service_listener_pt;
+
+#include "celix_errno.h"
+#include "service_event.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct serviceListener {
+	void *handle;
+
+	celix_status_t (*serviceChanged)(void *listener, service_event_pt event);
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* SERVICE_LISTENER_H_ */
+
+/**
+ * @}
+ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/service_reference.h
----------------------------------------------------------------------
diff --git a/framework/include/service_reference.h b/framework/include/service_reference.h
new file mode 100644
index 0000000..bb263f5
--- /dev/null
+++ b/framework/include/service_reference.h
@@ -0,0 +1,72 @@
+/**
+ *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.
+ */
+/*
+ * service_reference.h
+ *
+ *  \date       Jul 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef SERVICE_REFERENCE_H_
+#define SERVICE_REFERENCE_H_
+
+typedef struct serviceReference * service_reference_pt;
+
+#include "celixbool.h"
+#include "array_list.h"
+#include "service_registration.h"
+#include "bundle.h"
+#include "framework_exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference, bundle_pt *bundle);
+
+FRAMEWORK_EXPORT bool
+serviceReference_isAssignableTo(service_reference_pt reference, bundle_pt requester, const char *serviceName);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceReference_getProperty(service_reference_pt reference, const char *key, const char **value);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceReference_getPropertyKeys(service_reference_pt reference, char **keys[], unsigned int *size);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceReference_getServiceRegistration(service_reference_pt reference, service_registration_pt *registration);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceReference_equals(service_reference_pt reference, service_reference_pt compareTo, bool *equal);
+
+FRAMEWORK_EXPORT unsigned int serviceReference_hashCode(const void *referenceP);
+
+FRAMEWORK_EXPORT int serviceReference_equals2(const void *reference1, const void *reference2);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceReference_compareTo(service_reference_pt reference, service_reference_pt compareTo, int *compare);
+
+FRAMEWORK_EXPORT celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, array_list_pt *out);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SERVICE_REFERENCE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/service_registration.h
----------------------------------------------------------------------
diff --git a/framework/include/service_registration.h b/framework/include/service_registration.h
new file mode 100644
index 0000000..9265a00
--- /dev/null
+++ b/framework/include/service_registration.h
@@ -0,0 +1,58 @@
+/**
+ *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.
+ */
+/*
+ * service_registration.h
+ *
+ *  \date       Aug 6, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef SERVICE_REGISTRATION_H_
+#define SERVICE_REGISTRATION_H_
+
+#include "celixbool.h"
+
+typedef struct serviceRegistration * service_registration_pt;
+
+#include "service_registry.h"
+#include "array_list.h"
+#include "bundle.h"
+#include "framework_exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+FRAMEWORK_EXPORT celix_status_t serviceRegistration_unregister(service_registration_pt registration);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceRegistration_setProperties(service_registration_pt registration, properties_pt properties);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceRegistration_getServiceName(service_registration_pt registration, const char **serviceName);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SERVICE_REGISTRATION_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/service_registry.h
----------------------------------------------------------------------
diff --git a/framework/include/service_registry.h b/framework/include/service_registry.h
new file mode 100644
index 0000000..9a2ec48
--- /dev/null
+++ b/framework/include/service_registry.h
@@ -0,0 +1,103 @@
+/**
+ *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.
+ */
+/*
+ * service_registry.h
+ *
+ *  \date       Aug 6, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef SERVICE_REGISTRY_H_
+#define SERVICE_REGISTRY_H_
+
+typedef struct serviceRegistry * service_registry_pt;
+
+#include "properties.h"
+#include "filter.h"
+#include "service_factory.h"
+#include "service_event.h"
+#include "array_list.h"
+#include "service_registration.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*serviceChanged_function_pt)(framework_pt, service_event_type_e, service_registration_pt, properties_pt);
+
+celix_status_t serviceRegistry_create(framework_pt framework, serviceChanged_function_pt serviceChanged,
+                                      service_registry_pt *registry);
+
+celix_status_t serviceRegistry_destroy(service_registry_pt registry);
+
+celix_status_t
+serviceRegistry_getRegisteredServices(service_registry_pt registry, bundle_pt bundle, array_list_pt *services);
+
+celix_status_t
+serviceRegistry_getServicesInUse(service_registry_pt registry, bundle_pt bundle, array_list_pt *services);
+
+celix_status_t serviceRegistry_registerService(service_registry_pt registry, bundle_pt bundle, const char *serviceName,
+                                               const void *serviceObject, properties_pt dictionary,
+                                               service_registration_pt *registration);
+
+celix_status_t
+serviceRegistry_registerServiceFactory(service_registry_pt registry, bundle_pt bundle, const char *serviceName,
+                                       service_factory_pt factory, properties_pt dictionary,
+                                       service_registration_pt *registration);
+
+celix_status_t
+serviceRegistry_unregisterService(service_registry_pt registry, bundle_pt bundle, service_registration_pt registration);
+
+celix_status_t serviceRegistry_clearServiceRegistrations(service_registry_pt registry, bundle_pt bundle);
+
+celix_status_t serviceRegistry_getServiceReference(service_registry_pt registry, bundle_pt bundle,
+                                                   service_registration_pt registration,
+                                                   service_reference_pt *reference);
+
+celix_status_t
+serviceRegistry_getServiceReferences(service_registry_pt registry, bundle_pt bundle, const char *serviceName,
+                                     filter_pt filter, array_list_pt *references);
+
+celix_status_t
+serviceRegistry_retainServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference);
+
+celix_status_t
+serviceRegistry_ungetServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference);
+
+celix_status_t
+serviceRegistry_getService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference,
+                           const void **service);
+
+celix_status_t
+serviceRegistry_ungetService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference,
+                             bool *result);
+
+celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry, bundle_pt bundle);
+
+celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, bundle_pt bundle, array_list_pt *hooks);
+
+celix_status_t
+serviceRegistry_servicePropertiesModified(service_registry_pt registry, service_registration_pt registration,
+                                          properties_pt oldprops);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SERVICE_REGISTRY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/service_tracker.h
----------------------------------------------------------------------
diff --git a/framework/include/service_tracker.h b/framework/include/service_tracker.h
new file mode 100644
index 0000000..aa19d50
--- /dev/null
+++ b/framework/include/service_tracker.h
@@ -0,0 +1,72 @@
+/**
+ *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.
+ */
+/*
+ * service_tracker.h
+ *
+ *  \date       Apr 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef SERVICE_TRACKER_H_
+#define SERVICE_TRACKER_H_
+
+#include "service_listener.h"
+#include "array_list.h"
+#include "bundle_context.h"
+#include "service_tracker_customizer.h"
+#include "framework_exports.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct serviceTracker *service_tracker_pt;
+
+FRAMEWORK_EXPORT celix_status_t
+serviceTracker_create(bundle_context_pt context, const char *service, service_tracker_customizer_pt customizer,
+                      service_tracker_pt *tracker);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceTracker_createWithFilter(bundle_context_pt context, const char *filter, service_tracker_customizer_pt customizer,
+                                service_tracker_pt *tracker);
+
+FRAMEWORK_EXPORT celix_status_t serviceTracker_open(service_tracker_pt tracker);
+
+FRAMEWORK_EXPORT celix_status_t serviceTracker_close(service_tracker_pt tracker);
+
+FRAMEWORK_EXPORT celix_status_t serviceTracker_destroy(service_tracker_pt tracker);
+
+FRAMEWORK_EXPORT service_reference_pt serviceTracker_getServiceReference(service_tracker_pt tracker);
+
+FRAMEWORK_EXPORT array_list_pt serviceTracker_getServiceReferences(service_tracker_pt tracker);
+
+FRAMEWORK_EXPORT void *serviceTracker_getService(service_tracker_pt tracker);
+
+FRAMEWORK_EXPORT array_list_pt serviceTracker_getServices(service_tracker_pt tracker);
+
+FRAMEWORK_EXPORT void *serviceTracker_getServiceByReference(service_tracker_pt tracker, service_reference_pt reference);
+
+FRAMEWORK_EXPORT void serviceTracker_serviceChanged(service_listener_pt listener, service_event_pt event);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SERVICE_TRACKER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/service_tracker_customizer.h
----------------------------------------------------------------------
diff --git a/framework/include/service_tracker_customizer.h b/framework/include/service_tracker_customizer.h
new file mode 100644
index 0000000..19672d8
--- /dev/null
+++ b/framework/include/service_tracker_customizer.h
@@ -0,0 +1,78 @@
+/**
+ *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.
+ */
+/*
+ * service_tracker_customizer.h
+ *
+ *  \date       Nov 15, 2012
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef service_tracker_customizer_t_H_
+#define service_tracker_customizer_t_H_
+
+#include <celix_errno.h>
+#include <service_reference.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef celix_status_t (*adding_callback_pt)(void *handle, service_reference_pt reference, void **service);
+
+typedef celix_status_t (*added_callback_pt)(void *handle, service_reference_pt reference, void *service);
+
+typedef celix_status_t (*modified_callback_pt)(void *handle, service_reference_pt reference, void *service);
+
+typedef celix_status_t (*removed_callback_pt)(void *handle, service_reference_pt reference, void *service);
+
+typedef struct serviceTrackerCustomizer *service_tracker_customizer_pt;
+typedef struct serviceTrackerCustomizer service_tracker_customizer_t;
+
+
+FRAMEWORK_EXPORT celix_status_t serviceTrackerCustomizer_create(void *handle,
+																adding_callback_pt addingFunction,
+																added_callback_pt addedFunction,
+																modified_callback_pt modifiedFunction,
+																removed_callback_pt removedFunction,
+																service_tracker_customizer_pt *customizer);
+
+FRAMEWORK_EXPORT celix_status_t serviceTrackerCustomizer_destroy(service_tracker_customizer_pt customizer);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceTrackerCustomizer_getHandle(service_tracker_customizer_pt customizer, void **handle);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceTrackerCustomizer_getAddingFunction(service_tracker_customizer_pt customizer, adding_callback_pt *function);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceTrackerCustomizer_getAddedFunction(service_tracker_customizer_pt customizer, added_callback_pt *function);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceTrackerCustomizer_getModifiedFunction(service_tracker_customizer_pt customizer, modified_callback_pt *function);
+
+FRAMEWORK_EXPORT celix_status_t
+serviceTrackerCustomizer_getRemovedFunction(service_tracker_customizer_pt customizer, removed_callback_pt *function);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* service_tracker_customizer_t_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/include/wire.h
----------------------------------------------------------------------
diff --git a/framework/include/wire.h b/framework/include/wire.h
new file mode 100644
index 0000000..9bb9e02
--- /dev/null
+++ b/framework/include/wire.h
@@ -0,0 +1,120 @@
+/**
+ *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.
+ */
+/*
+ * wire.h
+ *
+ *  \date       Jul 12, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef WIRE_H_
+#define WIRE_H_
+
+typedef struct wire *wire_pt;
+
+#include "requirement.h"
+#include "capability.h"
+#include "module.h"
+#include "linked_list.h"
+#include "module.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup Version Version
+ * @ingroup framework
+ * @{
+ */
+
+/**
+ * Create a wire between two modules using a requirement and capability.
+ *
+ * @param importer The importer module of the wire.
+ * @param requirement The requirement of the importer.
+ * @param exporter The exporter module of the wire.
+ * @param capability The capability of the wire.
+ * @param wire The created wire.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>wire</code> failed.
+ */
+celix_status_t wire_create(module_pt importer, requirement_pt requirement,
+						   module_pt exporter, capability_pt capability, wire_pt *wire);
+
+/**
+ * Getter for the capability of the exporting module.
+ *
+ * @param wire The wire to get the capability from.
+ * @param capability The capability
+ * @return Status code indication failure or success:
+ *      - CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_destroy(wire_pt wire);
+
+/**
+ * Getter for the capability of the exporting module.
+ *
+ * @param wire The wire to get the capability from.
+ * @param capability The capability
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_getCapability(wire_pt wire, capability_pt *capability);
+
+/**
+ * Getter for the requirement of the importing module.
+ *
+ * @param wire The wire to get the requirement from.
+ * @param requirement The requirement
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_getRequirement(wire_pt wire, requirement_pt *requirement);
+
+/**
+ * Getter for the importer of the wire.
+ *
+ * @param wire The wire to get the importer from.
+ * @param importer The importing module.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_getImporter(wire_pt wire, module_pt *importer);
+
+/**
+ * Getter for the exporter of the wire.
+ *
+ * @param wire The wire to get the exporter from.
+ * @param exporter The exporting module.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_getExporter(wire_pt wire, module_pt *exporter);
+
+/**
+ * @}
+ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WIRE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/attribute.h
----------------------------------------------------------------------
diff --git a/framework/private/include/attribute.h b/framework/private/include/attribute.h
deleted file mode 100644
index 6f41f0c..0000000
--- a/framework/private/include/attribute.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *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.
- */
-/*
- * attribute.h
- *
- *  \date       Jul 27, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef ATTRIBUTE_H_
-#define ATTRIBUTE_H_
-
-#include "celix_errno.h"
-
-typedef struct attribute *attribute_pt;
-
-celix_status_t attribute_create(char * key, char * value, attribute_pt *attribute);
-celix_status_t attribute_destroy(attribute_pt attribute);
-
-celix_status_t attribute_getKey(attribute_pt attribute, char **key);
-celix_status_t attribute_getValue(attribute_pt attribute, char **value);
-
-#endif /* ATTRIBUTE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/attribute_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/attribute_private.h b/framework/private/include/attribute_private.h
deleted file mode 100644
index 339833f..0000000
--- a/framework/private/include/attribute_private.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *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.
- */
-/*
- * attribute_private.h
- *
- *  \date       Feb 11, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef ATTRIBUTE_PRIVATE_H_
-#define ATTRIBUTE_PRIVATE_H_
-
-#include "attribute.h"
-
-struct attribute {
-	char * key;
-	char * value;
-};
-
-
-#endif /* ATTRIBUTE_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/bundle_cache.h
----------------------------------------------------------------------
diff --git a/framework/private/include/bundle_cache.h b/framework/private/include/bundle_cache.h
deleted file mode 100644
index 350f33b..0000000
--- a/framework/private/include/bundle_cache.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_cache.h
- *
- *  \date       Aug 8, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef BUNDLE_CACHE_H_
-#define BUNDLE_CACHE_H_
-
-/**
- * @defgroup BundleCache BundleCache
- * @ingroup framework
- * @{
- */
-
-#include "properties.h"
-#include "array_list.h"
-#include "bundle_archive.h"
-#include "celix_log.h"
-
-/**
- * Type definition for the bundle_cache_pt abstract data type.
- */
-typedef struct bundleCache *bundle_cache_pt;
-
-/**
- * Creates the bundle cache using the supplied configuration map.
- *
- * @param configurationMap Set with properties to use for this cache
- * @param mp The memory pool to use for allocation the cache
- * @param bundle_cache Output parameter for the created cache
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ILLEGAL_ARGUMENT If <code>bundle_cache</code> not is null.
- * 		- CELIX_ENOMEM If allocating memory for <code>bundle_cache</code> failed.
- */
-celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache);
-
-/**
- * Frees the bundle_cache memory allocated in bundleCache_create
- *
- * @param bundle_cache Output parameter for the created cache
- * @return Status code indication failure or success:
- *      - CELIX_SUCCESS when no errors are encountered.
- */
-celix_status_t bundleCache_destroy(bundle_cache_pt *cache);
-
-/**
- * Recreates and retrieves the list of archives for the given bundle cache.
- * Archives are recreated on the bundle cache memory pool, the list for the results is created on the suplied pool, and is owned by the caller.
- *
- * @param cache The cache to recreate archives out
- * @param pool The pool on which the list of archives is created
- * @param archives List with recreated archives
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ILLEGAL_ARGUMENT If <code>archives</code> not is null.
- * 		- CELIX_ENOMEM If allocating memory for <code>archives</code> failed.
- * 		- CELIX_FILE_IO_EXCEPTION If the cache cannot be opened or read.
- */
-celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *archives);
-
-/**
- * Creates a new archive for the given bundle (using the id and location). The archive is created on the supplied bundlePool.
- *
- * @param cache The cache to create an archive in
- * @param bundlePool The pool to use for the archive creation
- * @param id The id of the bundle
- * @param location The location identifier of the bundle
- * @param inputFile Input identifier to read the bundle data from
- * @param archive The archive to create
- *
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ILLEGAL_ARGUMENT If <code>bundle_archive</code> not is null.
- * 		- CELIX_ENOMEM If allocating memory for <code>bundle_archive</code> failed.
- */
-celix_status_t bundleCache_createArchive(bundle_cache_pt cache, long id, const char* location, const char* inputFile, bundle_archive_pt *archive);
-
-/**
- * Deletes the entire bundle cache.
- *
- * @param cache the cache to delete
- * @return Status code indication failure or success:
- * 		- CELIX_SUCCESS when no errors are encountered.
- * 		- CELIX_ILLEGAL_ARGUMENT If the cache is invalid
- * 		- CELIX_FILE_IO_EXCEPTION If the cache cannot be opened or read.
- */
-celix_status_t bundleCache_delete(bundle_cache_pt cache);
-
-/**
- * @}
- */
-
-#endif /* BUNDLE_CACHE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/bundle_cache_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/bundle_cache_private.h b/framework/private/include/bundle_cache_private.h
deleted file mode 100644
index 69e26ee..0000000
--- a/framework/private/include/bundle_cache_private.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_cache_private.h
- *
- *  \date       Feb 12, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef BUNDLE_CACHE_PRIVATE_H_
-#define BUNDLE_CACHE_PRIVATE_H_
-
-#include "bundle_cache.h"
-
-struct bundleCache {
-	properties_pt configurationMap;
-	char * cacheDir;
-};
-
-
-#endif /* BUNDLE_CACHE_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/bundle_context_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/bundle_context_private.h b/framework/private/include/bundle_context_private.h
deleted file mode 100644
index 3810cd0..0000000
--- a/framework/private/include/bundle_context_private.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_context_private.h
- *
- *  \date       Feb 12, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef BUNDLE_CONTEXT_PRIVATE_H_
-#define BUNDLE_CONTEXT_PRIVATE_H_
-
-#include "bundle_context.h"
-#include "celix_log.h"
-
-struct bundleContext {
-#ifdef WITH_APR
-    apr_pool_t *pool;
-#endif
-	struct framework * framework;
-	struct bundle * bundle;
-};
-
-
-#endif /* BUNDLE_CONTEXT_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/bundle_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/bundle_private.h b/framework/private/include/bundle_private.h
deleted file mode 100644
index 8085609..0000000
--- a/framework/private/include/bundle_private.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_private.h
- *
- *  \date       Feb 18, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef BUNDLE_PRIVATE_H_
-#define BUNDLE_PRIVATE_H_
-
-#include "bundle.h"
-
-struct bundle {
-	bundle_context_pt context;
-	activator_pt activator;
-	bundle_state_e state;
-	void * handle;
-	bundle_archive_pt archive;
-	array_list_pt modules;
-	manifest_pt manifest;
-
-	celix_thread_mutex_t lock;
-	int lockCount;
-	celix_thread_t lockThread;
-
-	struct framework * framework;
-};
-
-#endif /* BUNDLE_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/bundle_revision_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/bundle_revision_private.h b/framework/private/include/bundle_revision_private.h
deleted file mode 100644
index cb1dcd8..0000000
--- a/framework/private/include/bundle_revision_private.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *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.
- */
-/*
- * bundle_revision_private.h
- *
- *  \date       Feb 12, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef BUNDLE_REVISION_PRIVATE_H_
-#define BUNDLE_REVISION_PRIVATE_H_
-
-#include "bundle_revision.h"
-
-struct bundleRevision {
-	long revisionNr;
-	char *root;
-	char *location;
-	manifest_pt manifest;
-
-	array_list_pt libraryHandles;
-};
-
-#endif /* BUNDLE_REVISION_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/capability_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/capability_private.h b/framework/private/include/capability_private.h
deleted file mode 100644
index 5e302a5..0000000
--- a/framework/private/include/capability_private.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *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.
- */
-/*
- * capability_private.h
- *
- *  \date       Feb 11, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef CAPABILITY_PRIVATE_H_
-#define CAPABILITY_PRIVATE_H_
-
-#include "capability.h"
-
-struct capability {
-	char * serviceName;
-	module_pt module;
-	version_pt version;
-	hash_map_pt attributes;
-	hash_map_pt directives;
-};
-
-#endif /* CAPABILITY_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/filter_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/filter_private.h b/framework/private/include/filter_private.h
deleted file mode 100644
index d19de2d..0000000
--- a/framework/private/include/filter_private.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *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.
- */
-/*
- * filter_private.h
- *
- *  \date       Feb 13, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef FILTER_PRIVATE_H_
-#define FILTER_PRIVATE_H_
-
-#include "filter.h"
-#include "array_list.h"
-
-typedef enum operand
-{
-	EQUAL,
-	APPROX,
-	GREATER,
-    GREATEREQUAL,
-	LESS,
-	LESSEQUAL,
-	PRESENT,
-	SUBSTRING,
-	AND,
-	OR,
-	NOT,
-} OPERAND;
-
-struct filter {
-	OPERAND operand;
-	char * attribute;
-	void * value;
-	char *filterStr;
-};
-
-
-#endif /* FILTER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/framework_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/framework_private.h b/framework/private/include/framework_private.h
deleted file mode 100644
index 124a4b6..0000000
--- a/framework/private/include/framework_private.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- *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.
- */
-/*
- * framework_private.h
- *
- *  \date       May 22, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef FRAMEWORK_PRIVATE_H_
-#define FRAMEWORK_PRIVATE_H_
-
-#include "framework.h"
-
-#include "manifest.h"
-#include "wire.h"
-#include "hash_map.h"
-#include "array_list.h"
-#include "celix_errno.h"
-#include "service_factory.h"
-#include "bundle_archive.h"
-#include "service_listener.h"
-#include "bundle_listener.h"
-#include "framework_listener.h"
-#include "service_registration.h"
-#include "bundle_context.h"
-#include "bundle_cache.h"
-#include "celix_log.h"
-
-#include "celix_threads.h"
-
-struct framework {
-#ifdef WITH_APR
-    apr_pool_t *pool;
-#endif
-    struct bundle * bundle;
-    hash_map_pt installedBundleMap;
-    hash_map_pt installRequestMap;
-    array_list_pt serviceListeners;
-    array_list_pt frameworkListeners;
-
-    array_list_pt bundleListeners;
-    celix_thread_mutex_t bundleListenerLock;
-
-    long nextBundleId;
-    struct serviceRegistry * registry;
-    bundle_cache_pt cache;
-
-    celix_thread_cond_t shutdownGate;
-    celix_thread_cond_t condition;
-
-    celix_thread_mutex_t installedBundleMapLock;
-    celix_thread_mutex_t installRequestLock;
-    celix_thread_mutex_t mutex;
-    celix_thread_mutex_t bundleLock;
-
-    celix_thread_t globalLockThread;
-    array_list_pt globalLockWaitersList;
-    int globalLockCount;
-
-    bool interrupted;
-    bool shutdown;
-
-    properties_pt configurationMap;
-
-    array_list_pt requests;
-    celix_thread_cond_t dispatcher;
-    celix_thread_mutex_t dispatcherLock;
-    celix_thread_t dispatcherThread;
-    celix_thread_t shutdownThread;
-
-    framework_logger_pt logger;
-};
-
-celix_status_t framework_start(framework_pt framework);
-void framework_stop(framework_pt framework);
-
-FRAMEWORK_EXPORT celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** value);
-
-FRAMEWORK_EXPORT celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, const char * location, const char *inputFile);
-FRAMEWORK_EXPORT celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t framework_getBundleEntry(framework_pt framework, bundle_pt bundle, const char* name, char** entry);
-
-FRAMEWORK_EXPORT celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int options);
-FRAMEWORK_EXPORT celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle, const char* inputFile);
-FRAMEWORK_EXPORT celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle, bool record);
-
-FRAMEWORK_EXPORT celix_status_t fw_registerService(framework_pt framework, service_registration_pt * registration, bundle_pt bundle, const char* serviceName, const void* svcObj, properties_pt properties);
-FRAMEWORK_EXPORT celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt * registration, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt properties);
-FRAMEWORK_EXPORT void fw_unregisterService(service_registration_pt registration);
-
-FRAMEWORK_EXPORT celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *references, bundle_pt bundle, const char* serviceName, const char* filter);
-FRAMEWORK_EXPORT celix_status_t framework_ungetServiceReference(framework_pt framework, bundle_pt bundle, service_reference_pt reference);
-FRAMEWORK_EXPORT celix_status_t fw_getService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, const void** service);
-FRAMEWORK_EXPORT celix_status_t framework_ungetService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, bool *result);
-FRAMEWORK_EXPORT celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, array_list_pt *services);
-FRAMEWORK_EXPORT celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, array_list_pt *services);
-
-FRAMEWORK_EXPORT void fw_addServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener, const char* filter);
-FRAMEWORK_EXPORT void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener);
-
-FRAMEWORK_EXPORT celix_status_t fw_addBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener);
-FRAMEWORK_EXPORT celix_status_t fw_removeBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener);
-
-FRAMEWORK_EXPORT celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener);
-FRAMEWORK_EXPORT celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener);
-
-FRAMEWORK_EXPORT void fw_serviceChanged(framework_pt framework, service_event_type_e eventType, service_registration_pt registration, properties_pt oldprops);
-
-FRAMEWORK_EXPORT celix_status_t fw_isServiceAssignable(framework_pt fw, bundle_pt requester, service_reference_pt reference, bool* assignable);
-
-//bundle_archive_t fw_createArchive(long id, char * location);
-//void revise(bundle_archive_t archive, char * location);
-FRAMEWORK_EXPORT celix_status_t getManifest(bundle_archive_pt archive, manifest_pt *manifest);
-
-FRAMEWORK_EXPORT bundle_pt findBundle(bundle_context_pt context);
-FRAMEWORK_EXPORT service_registration_pt findRegistration(service_reference_pt reference);
-
-FRAMEWORK_EXPORT service_reference_pt listToArray(array_list_pt list);
-FRAMEWORK_EXPORT celix_status_t framework_markResolvedModules(framework_pt framework, linked_list_pt wires);
-
-FRAMEWORK_EXPORT array_list_pt framework_getBundles(framework_pt framework);
-FRAMEWORK_EXPORT bundle_pt framework_getBundle(framework_pt framework, const char* location);
-FRAMEWORK_EXPORT bundle_pt framework_getBundleById(framework_pt framework, long id);
-
-#endif /* FRAMEWORK_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/ioapi.h
----------------------------------------------------------------------
diff --git a/framework/private/include/ioapi.h b/framework/private/include/ioapi.h
deleted file mode 100644
index 8309c4c..0000000
--- a/framework/private/include/ioapi.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/* ioapi.h -- IO base function header for compress/uncompress .zip
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications for Zip64 support
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-         Changes
-
-    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
-    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
-               More if/def section may be needed to support other platforms
-    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
-                          (but you should use iowin32.c for windows instead)
-
-*/
-
-#ifndef _ZLIBIOAPI64_H
-#define _ZLIBIOAPI64_H
-
-#if (!defined(_WIN32)) && (!defined(WIN32))
-
-  // Linux needs this to support file operation on files larger then 4+GB
-  // But might need better if/def to select just the platforms that needs them.
-
-        #ifndef __USE_FILE_OFFSET64
-                #define __USE_FILE_OFFSET64
-        #endif
-        #ifndef __USE_LARGEFILE64
-                #define __USE_LARGEFILE64
-        #endif
-        #ifndef _LARGEFILE64_SOURCE
-                #define _LARGEFILE64_SOURCE
-        #endif
-        #ifndef _FILE_OFFSET_BIT
-                #define _FILE_OFFSET_BIT 64
-        #endif
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "zlib.h"
-
-#if defined(USE_FILE32API)
-#define fopen64 fopen
-#define ftello64 ftell
-#define fseeko64 fseek
-#else
-#ifdef _MSC_VER
- #define fopen64 fopen
- #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
-  #define ftello64 _ftelli64
-  #define fseeko64 _fseeki64
- #else // old MSC
-  #define ftello64 ftell
-  #define fseeko64 fseek
- #endif
-#endif
-#endif
-
-/*
-#ifndef ZPOS64_T
-  #ifdef _WIN32
-                #define ZPOS64_T fpos_t
-  #else
-    #include <stdint.h>
-    #define ZPOS64_T uint64_t
-  #endif
-#endif
-*/
-
-#ifdef HAVE_MINIZIP64_CONF_H
-#include "mz64conf.h"
-#endif
-
-/* a type choosen by DEFINE */
-#ifdef HAVE_64BIT_INT_CUSTOM
-typedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;
-#else
-#ifdef HAS_STDINT_H
-#include "stdint.h"
-typedef uint64_t ZPOS64_T;
-#else
-
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-typedef unsigned __int64 ZPOS64_T;
-#else
-typedef unsigned long long int ZPOS64_T;
-#endif
-#endif
-#endif
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define ZLIB_FILEFUNC_SEEK_CUR (1)
-#define ZLIB_FILEFUNC_SEEK_END (2)
-#define ZLIB_FILEFUNC_SEEK_SET (0)
-
-#define ZLIB_FILEFUNC_MODE_READ      (1)
-#define ZLIB_FILEFUNC_MODE_WRITE     (2)
-#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
-
-#define ZLIB_FILEFUNC_MODE_EXISTING (4)
-#define ZLIB_FILEFUNC_MODE_CREATE   (8)
-
-
-#ifndef ZCALLBACK
- #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
-   #define ZCALLBACK CALLBACK
- #else
-   #define ZCALLBACK
- #endif
-#endif
-
-
-
-
-typedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));
-typedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-typedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
-typedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));
-typedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
-
-typedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));
-typedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));
-
-
-/* here is the "old" 32 bits structure structure */
-typedef struct zlib_filefunc_def_s
-{
-    open_file_func      zopen_file;
-    read_file_func      zread_file;
-    write_file_func     zwrite_file;
-    tell_file_func      ztell_file;
-    seek_file_func      zseek_file;
-    close_file_func     zclose_file;
-    testerror_file_func zerror_file;
-    voidpf              opaque;
-} zlib_filefunc_def;
-
-typedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));
-typedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
-typedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));
-
-typedef struct zlib_filefunc64_def_s
-{
-    open64_file_func    zopen64_file;
-    read_file_func      zread_file;
-    write_file_func     zwrite_file;
-    tell64_file_func    ztell64_file;
-    seek64_file_func    zseek64_file;
-    close_file_func     zclose_file;
-    testerror_file_func zerror_file;
-    voidpf              opaque;
-} zlib_filefunc64_def;
-
-void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
-void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
-
-/* now internal definition, only for zip.c and unzip.h */
-typedef struct zlib_filefunc64_32_def_s
-{
-    zlib_filefunc64_def zfile_func64;
-    open_file_func      zopen32_file;
-    tell_file_func      ztell32_file;
-    seek_file_func      zseek32_file;
-} zlib_filefunc64_32_def;
-
-
-#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))
-#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))
-//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
-//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
-#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))
-#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))
-
-voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
-long    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
-ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
-
-void    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
-
-#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))
-#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))
-#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/iowin32.h
----------------------------------------------------------------------
diff --git a/framework/private/include/iowin32.h b/framework/private/include/iowin32.h
deleted file mode 100644
index 0ca0969..0000000
--- a/framework/private/include/iowin32.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* iowin32.h -- IO base function header for compress/uncompress .zip
-     Version 1.1, February 14h, 2010
-     part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications for Zip64 support
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-*/
-
-#include <windows.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
-void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
-void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
-void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
-
-#ifdef __cplusplus
-}
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/listener_hook_info_impl.h
----------------------------------------------------------------------
diff --git a/framework/private/include/listener_hook_info_impl.h b/framework/private/include/listener_hook_info_impl.h
deleted file mode 100644
index 4b45710..0000000
--- a/framework/private/include/listener_hook_info_impl.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- *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.
- */
-/*
- * listener_hook_info_impl.h
- *
- *  \date       Oct 28, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LISTENER_HOOK_INFO_IMPL_H_
-#define LISTENER_HOOK_INFO_IMPL_H_
-
-#include "celix_errno.h"
-
-celix_status_t listenerHookInfo_create();
-
-#endif /* LISTENER_HOOK_INFO_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/manifest_parser.h
----------------------------------------------------------------------
diff --git a/framework/private/include/manifest_parser.h b/framework/private/include/manifest_parser.h
deleted file mode 100644
index d6b062b..0000000
--- a/framework/private/include/manifest_parser.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *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.
- */
-/*
- * manifest_parser.h
- *
- *  \date       Jul 13, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef MANIFEST_PARSER_H_
-#define MANIFEST_PARSER_H_
-
-#include "module.h"
-#include "version.h"
-#include "manifest.h"
-#include "linked_list.h"
-
-typedef struct manifestParser * manifest_parser_pt;
-
-celix_status_t manifestParser_create(module_pt owner, manifest_pt manifest, manifest_parser_pt *manifest_parser);
-celix_status_t manifestParser_destroy(manifest_parser_pt mp);
-
-celix_status_t manifestParser_getAndDuplicateSymbolicName(manifest_parser_pt parser, char **symbolicName);
-celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, version_pt *version);
-celix_status_t manifestParser_getCapabilities(manifest_parser_pt parser, linked_list_pt *capabilities);
-celix_status_t manifestParser_getRequirements(manifest_parser_pt parser, linked_list_pt *requirements);
-
-#endif /* MANIFEST_PARSER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/registry_callback_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/registry_callback_private.h b/framework/private/include/registry_callback_private.h
deleted file mode 100644
index 146a1d1..0000000
--- a/framework/private/include/registry_callback_private.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *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.
- */
-/*
- * service_reference_private.h
- *
- *  \date       Nov 16, 2015
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef REGISTRY_CALLBACK_H_
-#define REGISTRY_CALLBACK_H_
-
-#include "celix_errno.h"
-#include "service_reference.h"
-#include "service_registration.h"
-
-typedef struct registry_callback_struct {
-	void *handle;
-    celix_status_t (*getUsingBundles)(void *handle, service_registration_pt reg, array_list_pt *bundles);
-	celix_status_t (*unregister)(void *handle, bundle_pt bundle, service_registration_pt reg);
-	celix_status_t (*modified)(void *handle, service_registration_pt registration, properties_pt oldProperties);
-} registry_callback_t;
-
-#endif /* REGISTRY_CALLBACK_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/requirement_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/requirement_private.h b/framework/private/include/requirement_private.h
deleted file mode 100644
index 7510110..0000000
--- a/framework/private/include/requirement_private.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- *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.
- */
-/*
- * requirement_private.h
- *
- *  \date       Feb 11, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef REQUIREMENT_PRIVATE_H_
-#define REQUIREMENT_PRIVATE_H_
-
-#include "requirement.h"
-
-struct requirement {
-	char * targetName;
-	version_range_pt versionRange;
-	hash_map_pt attributes;
-	hash_map_pt directives;
-};
-
-#endif /* REQUIREMENT_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/resolver.h
----------------------------------------------------------------------
diff --git a/framework/private/include/resolver.h b/framework/private/include/resolver.h
deleted file mode 100644
index 87440e9..0000000
--- a/framework/private/include/resolver.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *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.
- */
-/*
- * resolver.h
- *
- *  \date       Jul 13, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef RESOLVER_H_
-#define RESOLVER_H_
-
-#include "module.h"
-#include "wire.h"
-#include "hash_map.h"
-
-struct importer_wires {
-    module_pt importer;
-    linked_list_pt wires;
-};
-typedef struct importer_wires *importer_wires_pt;
-
-linked_list_pt resolver_resolve(module_pt root);
-void resolver_moduleResolved(module_pt module);
-void resolver_addModule(module_pt module);
-void resolver_removeModule(module_pt module);
-
-#endif /* RESOLVER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/framework/private/include/service_reference_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/service_reference_private.h b/framework/private/include/service_reference_private.h
deleted file mode 100644
index d7fcac1..0000000
--- a/framework/private/include/service_reference_private.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- *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.
- */
-/*
- * service_reference_private.h
- *
- *  \date       Feb 6, 2013
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef SERVICE_REFERENCE_PRIVATE_H_
-#define SERVICE_REFERENCE_PRIVATE_H_
-
-#include "registry_callback_private.h"
-#include "service_reference.h"
-
-
-struct serviceReference {
-    registry_callback_t callback;
-	bundle_pt referenceOwner;
-	struct serviceRegistration * registration;
-    bundle_pt registrationBundle;
-    const void* service;
-
-	size_t refCount;
-    size_t usageCount;
-
-    celix_thread_rwlock_t lock;
-};
-
-celix_status_t serviceReference_create(registry_callback_t callback, bundle_pt referenceOwner, service_registration_pt registration, service_reference_pt *reference);
-
-celix_status_t serviceReference_retain(service_reference_pt ref);
-celix_status_t serviceReference_release(service_reference_pt ref, bool *destroyed);
-
-celix_status_t serviceReference_increaseUsage(service_reference_pt ref, size_t *updatedCount);
-celix_status_t serviceReference_decreaseUsage(service_reference_pt ref, size_t *updatedCount);
-
-celix_status_t serviceReference_invalidate(service_reference_pt reference);
-celix_status_t serviceReference_isValid(service_reference_pt reference, bool *result);
-
-celix_status_t serviceReference_getUsageCount(service_reference_pt reference, size_t *count);
-celix_status_t serviceReference_getReferenceCount(service_reference_pt reference, size_t *count);
-
-celix_status_t serviceReference_setService(service_reference_pt ref, const void *service);
-celix_status_t serviceReference_getService(service_reference_pt reference, void **service);
-
-celix_status_t serviceReference_getOwner(service_reference_pt reference, bundle_pt *owner);
-
-
-
-#endif /* SERVICE_REFERENCE_PRIVATE_H_ */


[38/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/miniunz.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/miniunz.h b/deployment_admin/src/miniunz.h
new file mode 100644
index 0000000..f54b1fa
--- /dev/null
+++ b/deployment_admin/src/miniunz.h
@@ -0,0 +1,34 @@
+/**
+ *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.
+ */
+/*
+ * miniunz.h
+ *
+ *  \date       Aug 8, 2012
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef MINIUNZ_H_
+#define MINIUNZ_H_
+
+#include "celix_errno.h"
+
+celix_status_t unzip_extractDeploymentPackage(char * packageName, char * destination);
+
+#endif /* MINIUNZ_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/unzip.c
----------------------------------------------------------------------
diff --git a/deployment_admin/src/unzip.c b/deployment_admin/src/unzip.c
new file mode 100644
index 0000000..d8a6716
--- /dev/null
+++ b/deployment_admin/src/unzip.c
@@ -0,0 +1,2128 @@
+/* unzip.c -- IO for uncompress .zip files using zlib
+   Version 1.1, February 14h, 2010
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications of Unzip for Zip64
+         Copyright (C) 2007-2008 Even Rouault
+
+         Modifications for Zip64 support on both zip and unzip
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+
+  ------------------------------------------------------------------------------------
+  Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
+  compatibility with older software. The following is from the original crypt.c.
+  Code woven in by Terry Thorsen 1/2003.
+
+  Copyright (c) 1990-2000 Info-ZIP.  All rights reserved.
+
+  See the accompanying file LICENSE, version 2000-Apr-09 or later
+  (the contents of which are also included in zip.h) for terms of use.
+  If, for some reason, all these files are missing, the Info-ZIP license
+  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
+
+        crypt.c (full version) by Info-ZIP.      Last revised:  [see crypt.h]
+
+  The encryption/decryption parts of this source code (as opposed to the
+  non-echoing password parts) were originally written in Europe.  The
+  whole source package can be freely distributed, including from the USA.
+  (Prior to January 2000, re-export from the US was a violation of US law.)
+
+        This encryption code is a direct transcription of the algorithm from
+  Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
+  file (appnote.txt) is distributed with the PKZIP program (even in the
+  version without encryption capabilities).
+
+        ------------------------------------------------------------------------------------
+
+        Changes in unzip.c
+
+        2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos
+  2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz*
+  2007-2008 - Even Rouault - Remove old C style function prototypes
+  2007-2008 - Even Rouault - Add unzip support for ZIP64
+
+        Copyright (C) 2007-2008 Even Rouault
+
+
+        Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
+  Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G
+                                should only read the compressed/uncompressed size from the Zip64 format if
+                                the size from normal header was 0xFFFFFFFF
+  Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant
+        Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required)
+                                Patch created by Daniel Borca
+
+  Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
+
+  Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson
+
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef NOUNCRYPT
+        #define NOUNCRYPT
+#endif
+
+#include "zlib.h"
+#include "unzip.h"
+
+#ifdef STDC
+#  include <stddef.h>
+#  include <string.h>
+#  include <stdlib.h>
+#endif
+#ifdef NO_ERRNO_H
+    extern int errno;
+#else
+#   include <errno.h>
+#endif
+
+
+#ifndef local
+#  define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+
+#ifndef CASESENSITIVITYDEFAULT_NO
+#  if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
+#    define CASESENSITIVITYDEFAULT_NO
+#  endif
+#endif
+
+
+#ifndef UNZ_BUFSIZE
+#define UNZ_BUFSIZE (16384)
+#endif
+
+#ifndef UNZ_MAXFILENAMEINZIP
+#define UNZ_MAXFILENAMEINZIP (256)
+#endif
+
+#ifndef ALLOC
+# define ALLOC(size) (malloc(size))
+#endif
+#ifndef TRYFREE
+# define TRYFREE(p) {if (p) free(p);}
+#endif
+
+#define SIZECENTRALDIRITEM (0x2e)
+#define SIZEZIPLOCALHEADER (0x1e)
+
+
+const char unz_copyright[] =
+   " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
+
+/* unz_file_info_interntal contain internal info about a file in zipfile*/
+typedef struct unz_file_info64_internal_s
+{
+    ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
+} unz_file_info64_internal;
+
+
+/* file_in_zip_read_info_s contain internal information about a file in zipfile,
+    when reading and decompress it */
+typedef struct
+{
+    char  *read_buffer;         /* internal buffer for compressed data */
+    z_stream stream;            /* zLib stream structure for inflate */
+
+#ifdef HAVE_BZIP2
+    bz_stream bstream;          /* bzLib stream structure for bziped */
+#endif
+
+    ZPOS64_T pos_in_zipfile;       /* position in byte on the zipfile, for fseek*/
+    uLong stream_initialised;   /* flag set if stream structure is initialised*/
+
+    ZPOS64_T offset_local_extrafield;/* offset of the local extra field */
+    uInt  size_local_extrafield;/* size of the local extra field */
+    ZPOS64_T pos_local_extrafield;   /* position in the local extra field in read*/
+    ZPOS64_T total_out_64;
+
+    uLong crc32;                /* crc32 of all data uncompressed */
+    uLong crc32_wait;           /* crc32 we must obtain after decompress all */
+    ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
+    ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/
+    zlib_filefunc64_32_def z_filefunc;
+    voidpf filestream;        /* io structore of the zipfile */
+    uLong compression_method;   /* compression method (0==store) */
+    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+    int   raw;
+} file_in_zip64_read_info_s;
+
+
+/* unz64_s contain internal information about the zipfile
+*/
+typedef struct
+{
+    zlib_filefunc64_32_def z_filefunc;
+    int is64bitOpenFunction;
+    voidpf filestream;        /* io structore of the zipfile */
+    unz_global_info64 gi;       /* public global information */
+    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+    ZPOS64_T num_file;             /* number of the current file in the zipfile*/
+    ZPOS64_T pos_in_central_dir;   /* pos of the current file in the central dir*/
+    ZPOS64_T current_file_ok;      /* flag about the usability of the current file*/
+    ZPOS64_T central_pos;          /* position of the beginning of the central dir*/
+
+    ZPOS64_T size_central_dir;     /* size of the central directory  */
+    ZPOS64_T offset_central_dir;   /* offset of start of central directory with
+                                   respect to the starting disk number */
+
+    unz_file_info64 cur_file_info; /* public info about the current file in zip*/
+    unz_file_info64_internal cur_file_info_internal; /* private info about it*/
+    file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current
+                                        file if we are decompressing it */
+    int encrypted;
+
+    int isZip64;
+
+#    ifndef NOUNCRYPT
+    unsigned long keys[3];     /* keys defining the pseudo-random sequence */
+    const unsigned long* pcrc_32_tab;
+#    endif
+} unz64_s;
+
+
+#ifndef NOUNCRYPT
+#include "crypt.h"
+#endif
+
+/* ===========================================================================
+     Read a byte from a gz_stream; update next_in and avail_in. Return EOF
+   for end of file.
+   IN assertion: the stream s has been sucessfully opened for reading.
+*/
+
+
+local int unz64local_getByte OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream,
+    int *pi));
+
+local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
+{
+    unsigned char c;
+    int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
+    if (err==1)
+    {
+        *pi = (int)c;
+        return UNZ_OK;
+    }
+    else
+    {
+        if (ZERROR64(*pzlib_filefunc_def,filestream))
+            return UNZ_ERRNO;
+        else
+            return UNZ_EOF;
+    }
+}
+
+
+/* ===========================================================================
+   Reads a long in LSB order from the given gz_stream. Sets
+*/
+local int unz64local_getShort OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream,
+    uLong *pX));
+
+local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
+                             voidpf filestream,
+                             uLong *pX)
+{
+    uLong x ;
+    int i = 0;
+    int err;
+
+    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (uLong)i;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((uLong)i)<<8;
+
+    if (err==UNZ_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+local int unz64local_getLong OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream,
+    uLong *pX));
+
+local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
+                            voidpf filestream,
+                            uLong *pX)
+{
+    uLong x ;
+    int i = 0;
+    int err;
+
+    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (uLong)i;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((uLong)i)<<8;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((uLong)i)<<16;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<24;
+
+    if (err==UNZ_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+local int unz64local_getLong64 OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream,
+    ZPOS64_T *pX));
+
+
+local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
+                            voidpf filestream,
+                            ZPOS64_T *pX)
+{
+    ZPOS64_T x ;
+    int i = 0;
+    int err;
+
+    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (ZPOS64_T)i;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<8;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<16;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<24;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<32;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<40;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<48;
+
+    if (err==UNZ_OK)
+        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
+    x |= ((ZPOS64_T)i)<<56;
+
+    if (err==UNZ_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+/* My own strcmpi / strcasecmp */
+local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)
+{
+    for (;;)
+    {
+        char c1=*(fileName1++);
+        char c2=*(fileName2++);
+        if ((c1>='a') && (c1<='z'))
+            c1 -= 0x20;
+        if ((c2>='a') && (c2<='z'))
+            c2 -= 0x20;
+        if (c1=='\0')
+            return ((c2=='\0') ? 0 : -1);
+        if (c2=='\0')
+            return 1;
+        if (c1<c2)
+            return -1;
+        if (c1>c2)
+            return 1;
+    }
+}
+
+
+#ifdef  CASESENSITIVITYDEFAULT_NO
+#define CASESENSITIVITYDEFAULTVALUE 2
+#else
+#define CASESENSITIVITYDEFAULTVALUE 1
+#endif
+
+#ifndef STRCMPCASENOSENTIVEFUNCTION
+#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
+#endif
+
+/*
+   Compare two filename (fileName1,fileName2).
+   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
+   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
+                                                                or strcasecmp)
+   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
+        (like 1 on Unix, 2 on Windows)
+
+*/
+extern int ZEXPORT unzStringFileNameCompare (const char*  fileName1,
+                                                 const char*  fileName2,
+                                                 int iCaseSensitivity)
+
+{
+    if (iCaseSensitivity==0)
+        iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
+
+    if (iCaseSensitivity==1)
+        return strcmp(fileName1,fileName2);
+
+    return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
+}
+
+#ifndef BUFREADCOMMENT
+#define BUFREADCOMMENT (0x400)
+#endif
+
+/*
+  Locate the Central directory of a zipfile (at the end, just before
+    the global comment)
+*/
+local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
+local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
+{
+    unsigned char* buf;
+    ZPOS64_T uSizeFile;
+    ZPOS64_T uBackRead;
+    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
+    ZPOS64_T uPosFound=0;
+
+    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
+        return 0;
+
+
+    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
+
+    if (uMaxBack>uSizeFile)
+        uMaxBack = uSizeFile;
+
+    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
+    if (buf==NULL)
+        return 0;
+
+    uBackRead = 4;
+    while (uBackRead<uMaxBack)
+    {
+        uLong uReadSize;
+        ZPOS64_T uReadPos ;
+        int i;
+        if (uBackRead+BUFREADCOMMENT>uMaxBack)
+            uBackRead = uMaxBack;
+        else
+            uBackRead+=BUFREADCOMMENT;
+        uReadPos = uSizeFile-uBackRead ;
+
+        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
+                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
+        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            break;
+
+        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
+            break;
+
+        for (i=(int)uReadSize-3; (i--)>0;)
+            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
+                ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
+            {
+                uPosFound = uReadPos+i;
+                break;
+            }
+
+        if (uPosFound!=0)
+            break;
+    }
+    TRYFREE(buf);
+    return uPosFound;
+}
+
+
+/*
+  Locate the Central directory 64 of a zipfile (at the end, just before
+    the global comment)
+*/
+local ZPOS64_T unz64local_SearchCentralDir64 OF((
+    const zlib_filefunc64_32_def* pzlib_filefunc_def,
+    voidpf filestream));
+
+local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
+                                      voidpf filestream)
+{
+    unsigned char* buf;
+    ZPOS64_T uSizeFile;
+    ZPOS64_T uBackRead;
+    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
+    ZPOS64_T uPosFound=0;
+    uLong uL;
+                ZPOS64_T relativeOffset;
+
+    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
+        return 0;
+
+
+    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
+
+    if (uMaxBack>uSizeFile)
+        uMaxBack = uSizeFile;
+
+    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
+    if (buf==NULL)
+        return 0;
+
+    uBackRead = 4;
+    while (uBackRead<uMaxBack)
+    {
+        uLong uReadSize;
+        ZPOS64_T uReadPos;
+        int i;
+        if (uBackRead+BUFREADCOMMENT>uMaxBack)
+            uBackRead = uMaxBack;
+        else
+            uBackRead+=BUFREADCOMMENT;
+        uReadPos = uSizeFile-uBackRead ;
+
+        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
+                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
+        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            break;
+
+        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
+            break;
+
+        for (i=(int)uReadSize-3; (i--)>0;)
+            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
+                ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
+            {
+                uPosFound = uReadPos+i;
+                break;
+            }
+
+        if (uPosFound!=0)
+            break;
+    }
+    TRYFREE(buf);
+    if (uPosFound == 0)
+        return 0;
+
+    /* Zip64 end of central directory locator */
+    if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return 0;
+
+    /* the signature, already checked */
+    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
+        return 0;
+
+    /* number of the disk with the start of the zip64 end of  central directory */
+    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
+        return 0;
+    if (uL != 0)
+        return 0;
+
+    /* relative offset of the zip64 end of central directory record */
+    if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
+        return 0;
+
+    /* total number of disks */
+    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
+        return 0;
+    if (uL != 1)
+        return 0;
+
+    /* Goto end of central directory record */
+    if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return 0;
+
+     /* the signature */
+    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
+        return 0;
+
+    if (uL != 0x06064b50)
+        return 0;
+
+    return relativeOffset;
+}
+
+/*
+  Open a Zip file. path contain the full pathname (by example,
+     on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
+     "zlib/zlib114.zip".
+     If the zipfile cannot be opened (file doesn't exist or in not valid), the
+       return value is NULL.
+     Else, the return value is a unzFile Handle, usable with other function
+       of this unzip package.
+*/
+local unzFile unzOpenInternal (const void *path,
+                               zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
+                               int is64bitOpenFunction)
+{
+    unz64_s us;
+    unz64_s *s;
+    ZPOS64_T central_pos;
+    uLong   uL;
+
+    uLong number_disk;          /* number of the current dist, used for
+                                   spaning ZIP, unsupported, always 0*/
+    uLong number_disk_with_CD;  /* number the the disk with central dir, used
+                                   for spaning ZIP, unsupported, always 0*/
+    ZPOS64_T number_entry_CD;      /* total number of entries in
+                                   the central dir
+                                   (same than number_entry on nospan) */
+
+    int err=UNZ_OK;
+
+    if (unz_copyright[0]!=' ')
+        return NULL;
+
+    memset(&us,0,sizeof(unz64_s));
+    us.z_filefunc.zseek32_file = NULL;
+    us.z_filefunc.ztell32_file = NULL;
+    if (pzlib_filefunc64_32_def==NULL)
+        fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
+    else
+        us.z_filefunc = *pzlib_filefunc64_32_def;
+    us.is64bitOpenFunction = is64bitOpenFunction;
+
+
+
+    us.filestream = ZOPEN64(us.z_filefunc,
+                                                 path,
+                                                 ZLIB_FILEFUNC_MODE_READ |
+                                                 ZLIB_FILEFUNC_MODE_EXISTING);
+    if (us.filestream==NULL)
+        return NULL;
+
+    central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
+    if (central_pos)
+    {
+        uLong uS;
+        ZPOS64_T uL64;
+
+        us.isZip64 = 1;
+
+        if (ZSEEK64(us.z_filefunc, us.filestream,
+                                      central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        err=UNZ_ERRNO;
+
+        /* the signature, already checked */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* size of zip64 end of central directory record */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* version made by */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* version needed to extract */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* number of this disk */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* number of the disk with the start of the central directory */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* total number of entries in the central directory on this disk */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* total number of entries in the central directory */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        if ((number_entry_CD!=us.gi.number_entry) ||
+            (number_disk_with_CD!=0) ||
+            (number_disk!=0))
+            err=UNZ_BADZIPFILE;
+
+        /* size of the central directory */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* offset of start of central directory with respect to the
+          starting disk number */
+        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        us.gi.size_comment = 0;
+    }
+    else
+    {
+        central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);
+        if (central_pos==0)
+            err=UNZ_ERRNO;
+
+        us.isZip64 = 0;
+
+        if (ZSEEK64(us.z_filefunc, us.filestream,
+                                        central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            err=UNZ_ERRNO;
+
+        /* the signature, already checked */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* number of this disk */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* number of the disk with the start of the central directory */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
+            err=UNZ_ERRNO;
+
+        /* total number of entries in the central dir on this disk */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+        us.gi.number_entry = uL;
+
+        /* total number of entries in the central dir */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+        number_entry_CD = uL;
+
+        if ((number_entry_CD!=us.gi.number_entry) ||
+            (number_disk_with_CD!=0) ||
+            (number_disk!=0))
+            err=UNZ_BADZIPFILE;
+
+        /* size of the central directory */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+        us.size_central_dir = uL;
+
+        /* offset of start of central directory with respect to the
+            starting disk number */
+        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+            err=UNZ_ERRNO;
+        us.offset_central_dir = uL;
+
+        /* zipfile comment length */
+        if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
+            err=UNZ_ERRNO;
+    }
+
+    if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
+        (err==UNZ_OK))
+        err=UNZ_BADZIPFILE;
+
+    if (err!=UNZ_OK)
+    {
+        ZCLOSE64(us.z_filefunc, us.filestream);
+        return NULL;
+    }
+
+    us.byte_before_the_zipfile = central_pos -
+                            (us.offset_central_dir+us.size_central_dir);
+    us.central_pos = central_pos;
+    us.pfile_in_zip_read = NULL;
+    us.encrypted = 0;
+    us.num_file = 0;
+
+
+    s=(unz64_s*)ALLOC(sizeof(unz64_s));
+    if( s != NULL)
+    {
+        *s=us;
+        unzGoToFirstFile((unzFile)s);
+    }
+    return (unzFile)s;
+}
+
+
+extern unzFile ZEXPORT unzOpen2 (const char *path,
+                                        zlib_filefunc_def* pzlib_filefunc32_def)
+{
+    if (pzlib_filefunc32_def != NULL)
+    {
+        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
+        fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);
+        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0);
+    }
+    else
+        return unzOpenInternal(path, NULL, 0);
+}
+
+extern unzFile ZEXPORT unzOpen2_64 (const void *path,
+                                     zlib_filefunc64_def* pzlib_filefunc_def)
+{
+    if (pzlib_filefunc_def != NULL)
+    {
+        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
+        zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
+        zlib_filefunc64_32_def_fill.ztell32_file = NULL;
+        zlib_filefunc64_32_def_fill.zseek32_file = NULL;
+        zlib_filefunc64_32_def_fill.zopen32_file = NULL;
+        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
+    }
+    else
+        return unzOpenInternal(path, NULL, 1);
+}
+
+extern unzFile ZEXPORT unzOpen (const char *path)
+{
+    return unzOpenInternal(path, NULL, 0);
+}
+
+extern unzFile ZEXPORT unzOpen64 (const void *path)
+{
+    return unzOpenInternal(path, NULL, 1);
+}
+
+/*
+  Close a ZipFile opened with unzipOpen.
+  If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
+    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+  return UNZ_OK if there is no problem. */
+extern int ZEXPORT unzClose (unzFile file)
+{
+    unz64_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+
+    if (s->pfile_in_zip_read!=NULL)
+        unzCloseCurrentFile(file);
+
+    ZCLOSE64(s->z_filefunc, s->filestream);
+    TRYFREE(s);
+    return UNZ_OK;
+}
+
+
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem. */
+extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)
+{
+    unz64_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    *pglobal_info=s->gi;
+    return UNZ_OK;
+}
+
+extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)
+{
+    unz64_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    /* to do : check if number_entry is not truncated */
+    pglobal_info32->number_entry = (uLong)s->gi.number_entry;
+    pglobal_info32->size_comment = s->gi.size_comment;
+    return UNZ_OK;
+}
+/*
+   Translate date/time from Dos format to tm_unz (readable more easilty)
+*/
+local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
+{
+    ZPOS64_T uDate;
+    uDate = (ZPOS64_T)(ulDosDate>>16);
+    ptm->tm_mday = (uInt)(uDate&0x1f) ;
+    ptm->tm_mon =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;
+    ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
+
+    ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
+    ptm->tm_min =  (uInt) ((ulDosDate&0x7E0)/0x20) ;
+    ptm->tm_sec =  (uInt) (2*(ulDosDate&0x1f)) ;
+}
+
+/*
+  Get Info about the current file in the zipfile, with internal only info
+*/
+local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
+                                                  unz_file_info64 *pfile_info,
+                                                  unz_file_info64_internal
+                                                  *pfile_info_internal,
+                                                  char *szFileName,
+                                                  uLong fileNameBufferSize,
+                                                  void *extraField,
+                                                  uLong extraFieldBufferSize,
+                                                  char *szComment,
+                                                  uLong commentBufferSize));
+
+local int unz64local_GetCurrentFileInfoInternal (unzFile file,
+                                                  unz_file_info64 *pfile_info,
+                                                  unz_file_info64_internal
+                                                  *pfile_info_internal,
+                                                  char *szFileName,
+                                                  uLong fileNameBufferSize,
+                                                  void *extraField,
+                                                  uLong extraFieldBufferSize,
+                                                  char *szComment,
+                                                  uLong commentBufferSize)
+{
+    unz64_s* s;
+    unz_file_info64 file_info;
+    unz_file_info64_internal file_info_internal;
+    int err=UNZ_OK;
+    uLong uMagic;
+    long lSeek=0;
+    uLong uL;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (ZSEEK64(s->z_filefunc, s->filestream,
+              s->pos_in_central_dir+s->byte_before_the_zipfile,
+              ZLIB_FILEFUNC_SEEK_SET)!=0)
+        err=UNZ_ERRNO;
+
+
+    /* we check the magic */
+    if (err==UNZ_OK)
+    {
+        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
+            err=UNZ_ERRNO;
+        else if (uMagic!=0x02014b50)
+            err=UNZ_BADZIPFILE;
+    }
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+        err=UNZ_ERRNO;
+    file_info.compressed_size = uL;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+        err=UNZ_ERRNO;
+    file_info.uncompressed_size = uL;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+                // relative offset of local header
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+        err=UNZ_ERRNO;
+    file_info_internal.offset_curfile = uL;
+
+    lSeek+=file_info.size_filename;
+    if ((err==UNZ_OK) && (szFileName!=NULL))
+    {
+        uLong uSizeRead ;
+        if (file_info.size_filename<fileNameBufferSize)
+        {
+            *(szFileName+file_info.size_filename)='\0';
+            uSizeRead = file_info.size_filename;
+        }
+        else
+            uSizeRead = fileNameBufferSize;
+
+        if ((file_info.size_filename>0) && (fileNameBufferSize>0))
+            if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
+                err=UNZ_ERRNO;
+        lSeek -= uSizeRead;
+    }
+
+    // Read extrafield
+    if ((err==UNZ_OK) && (extraField!=NULL))
+    {
+        ZPOS64_T uSizeRead ;
+        if (file_info.size_file_extra<extraFieldBufferSize)
+            uSizeRead = file_info.size_file_extra;
+        else
+            uSizeRead = extraFieldBufferSize;
+
+        if (lSeek!=0)
+        {
+            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+                lSeek=0;
+            else
+                err=UNZ_ERRNO;
+        }
+
+        if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
+            if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)
+                err=UNZ_ERRNO;
+
+        lSeek += file_info.size_file_extra - (uLong)uSizeRead;
+    }
+    else
+        lSeek += file_info.size_file_extra;
+
+
+    if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
+    {
+                                uLong acc = 0;
+
+        // since lSeek now points to after the extra field we need to move back
+        lSeek -= file_info.size_file_extra;
+
+        if (lSeek!=0)
+        {
+            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+                lSeek=0;
+            else
+                err=UNZ_ERRNO;
+        }
+
+        while(acc < file_info.size_file_extra)
+        {
+            uLong headerId;
+                                                uLong dataSize;
+
+            if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)
+                err=UNZ_ERRNO;
+
+            if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)
+                err=UNZ_ERRNO;
+
+            /* ZIP64 extra fields */
+            if (headerId == 0x0001)
+            {
+                                                        uLong uL;
+
+                                                                if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)
+                                                                {
+                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
+                                                                                        err=UNZ_ERRNO;
+                                                                }
+
+                                                                if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)
+                                                                {
+                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
+                                                                                  err=UNZ_ERRNO;
+                                                                }
+
+                                                                if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)
+                                                                {
+                                                                        /* Relative Header offset */
+                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
+                                                                                err=UNZ_ERRNO;
+                                                                }
+
+                                                                if(file_info.disk_num_start == (unsigned long)-1)
+                                                                {
+                                                                        /* Disk Start Number */
+                                                                        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+                                                                                err=UNZ_ERRNO;
+                                                                }
+
+            }
+            else
+            {
+                if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
+                    err=UNZ_ERRNO;
+            }
+
+            acc += 2 + 2 + dataSize;
+        }
+    }
+
+    if ((err==UNZ_OK) && (szComment!=NULL))
+    {
+        uLong uSizeRead ;
+        if (file_info.size_file_comment<commentBufferSize)
+        {
+            *(szComment+file_info.size_file_comment)='\0';
+            uSizeRead = file_info.size_file_comment;
+        }
+        else
+            uSizeRead = commentBufferSize;
+
+        if (lSeek!=0)
+        {
+            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+                lSeek=0;
+            else
+                err=UNZ_ERRNO;
+        }
+
+        if ((file_info.size_file_comment>0) && (commentBufferSize>0))
+            if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
+                err=UNZ_ERRNO;
+        lSeek+=file_info.size_file_comment - uSizeRead;
+    }
+    else
+        lSeek+=file_info.size_file_comment;
+
+
+    if ((err==UNZ_OK) && (pfile_info!=NULL))
+        *pfile_info=file_info;
+
+    if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
+        *pfile_info_internal=file_info_internal;
+
+    return err;
+}
+
+
+
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem.
+*/
+extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
+                                          unz_file_info64 * pfile_info,
+                                          char * szFileName, uLong fileNameBufferSize,
+                                          void *extraField, uLong extraFieldBufferSize,
+                                          char* szComment,  uLong commentBufferSize)
+{
+    return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
+                                                szFileName,fileNameBufferSize,
+                                                extraField,extraFieldBufferSize,
+                                                szComment,commentBufferSize);
+}
+
+extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
+                                          unz_file_info * pfile_info,
+                                          char * szFileName, uLong fileNameBufferSize,
+                                          void *extraField, uLong extraFieldBufferSize,
+                                          char* szComment,  uLong commentBufferSize)
+{
+    int err;
+    unz_file_info64 file_info64;
+    err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
+                                                szFileName,fileNameBufferSize,
+                                                extraField,extraFieldBufferSize,
+                                                szComment,commentBufferSize);
+    if (err==UNZ_OK)
+    {
+        pfile_info->version = file_info64.version;
+        pfile_info->version_needed = file_info64.version_needed;
+        pfile_info->flag = file_info64.flag;
+        pfile_info->compression_method = file_info64.compression_method;
+        pfile_info->dosDate = file_info64.dosDate;
+        pfile_info->crc = file_info64.crc;
+
+        pfile_info->size_filename = file_info64.size_filename;
+        pfile_info->size_file_extra = file_info64.size_file_extra;
+        pfile_info->size_file_comment = file_info64.size_file_comment;
+
+        pfile_info->disk_num_start = file_info64.disk_num_start;
+        pfile_info->internal_fa = file_info64.internal_fa;
+        pfile_info->external_fa = file_info64.external_fa;
+
+        pfile_info->tmu_date = file_info64.tmu_date,
+
+
+        pfile_info->compressed_size = (uLong)file_info64.compressed_size;
+        pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
+
+    }
+    return err;
+}
+/*
+  Set the current file of the zipfile to the first file.
+  return UNZ_OK if there is no problem
+*/
+extern int ZEXPORT unzGoToFirstFile (unzFile file)
+{
+    int err=UNZ_OK;
+    unz64_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    s->pos_in_central_dir=s->offset_central_dir;
+    s->num_file=0;
+    err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                             &s->cur_file_info_internal,
+                                             NULL,0,NULL,0,NULL,0);
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+/*
+  Set the current file of the zipfile to the next file.
+  return UNZ_OK if there is no problem
+  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
+*/
+extern int ZEXPORT unzGoToNextFile (unzFile  file)
+{
+    unz64_s* s;
+    int err;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_END_OF_LIST_OF_FILE;
+    if (s->gi.number_entry != 0xffff)    /* 2^16 files overflow hack */
+      if (s->num_file+1==s->gi.number_entry)
+        return UNZ_END_OF_LIST_OF_FILE;
+
+    s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
+            s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
+    s->num_file++;
+    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                               &s->cur_file_info_internal,
+                                               NULL,0,NULL,0,NULL,0);
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+
+/*
+  Try locate the file szFileName in the zipfile.
+  For the iCaseSensitivity signification, see unzipStringFileNameCompare
+
+  return value :
+  UNZ_OK if the file is found. It becomes the current file.
+  UNZ_END_OF_LIST_OF_FILE if the file is not found
+*/
+extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
+{
+    unz64_s* s;
+    int err;
+
+    /* We remember the 'current' position in the file so that we can jump
+     * back there if we fail.
+     */
+    unz_file_info64 cur_file_infoSaved;
+    unz_file_info64_internal cur_file_info_internalSaved;
+    ZPOS64_T num_fileSaved;
+    ZPOS64_T pos_in_central_dirSaved;
+
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+
+    if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
+        return UNZ_PARAMERROR;
+
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_END_OF_LIST_OF_FILE;
+
+    /* Save the current state */
+    num_fileSaved = s->num_file;
+    pos_in_central_dirSaved = s->pos_in_central_dir;
+    cur_file_infoSaved = s->cur_file_info;
+    cur_file_info_internalSaved = s->cur_file_info_internal;
+
+    err = unzGoToFirstFile(file);
+
+    while (err == UNZ_OK)
+    {
+        char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
+        err = unzGetCurrentFileInfo64(file,NULL,
+                                    szCurrentFileName,sizeof(szCurrentFileName)-1,
+                                    NULL,0,NULL,0);
+        if (err == UNZ_OK)
+        {
+            if (unzStringFileNameCompare(szCurrentFileName,
+                                            szFileName,iCaseSensitivity)==0)
+                return UNZ_OK;
+            err = unzGoToNextFile(file);
+        }
+    }
+
+    /* We failed, so restore the state of the 'current file' to where we
+     * were.
+     */
+    s->num_file = num_fileSaved ;
+    s->pos_in_central_dir = pos_in_central_dirSaved ;
+    s->cur_file_info = cur_file_infoSaved;
+    s->cur_file_info_internal = cur_file_info_internalSaved;
+    return err;
+}
+
+
+/*
+///////////////////////////////////////////
+// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
+// I need random access
+//
+// Further optimization could be realized by adding an ability
+// to cache the directory in memory. The goal being a single
+// comprehensive file read to put the file I need in a memory.
+*/
+
+/*
+typedef struct unz_file_pos_s
+{
+    ZPOS64_T pos_in_zip_directory;   // offset in file
+    ZPOS64_T num_of_file;            // # of file
+} unz_file_pos;
+*/
+
+extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos*  file_pos)
+{
+    unz64_s* s;
+
+    if (file==NULL || file_pos==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_END_OF_LIST_OF_FILE;
+
+    file_pos->pos_in_zip_directory  = s->pos_in_central_dir;
+    file_pos->num_of_file           = s->num_file;
+
+    return UNZ_OK;
+}
+
+extern int ZEXPORT unzGetFilePos(
+    unzFile file,
+    unz_file_pos* file_pos)
+{
+    unz64_file_pos file_pos64;
+    int err = unzGetFilePos64(file,&file_pos64);
+    if (err==UNZ_OK)
+    {
+        file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
+        file_pos->num_of_file = (uLong)file_pos64.num_of_file;
+    }
+    return err;
+}
+
+extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)
+{
+    unz64_s* s;
+    int err;
+
+    if (file==NULL || file_pos==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+
+    /* jump to the right spot */
+    s->pos_in_central_dir = file_pos->pos_in_zip_directory;
+    s->num_file           = file_pos->num_of_file;
+
+    /* set the current file */
+    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                               &s->cur_file_info_internal,
+                                               NULL,0,NULL,0,NULL,0);
+    /* return results */
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+extern int ZEXPORT unzGoToFilePos(
+    unzFile file,
+    unz_file_pos* file_pos)
+{
+    unz64_file_pos file_pos64;
+    if (file_pos == NULL)
+        return UNZ_PARAMERROR;
+
+    file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
+    file_pos64.num_of_file = file_pos->num_of_file;
+    return unzGoToFilePos64(file,&file_pos64);
+}
+
+/*
+// Unzip Helper Functions - should be here?
+///////////////////////////////////////////
+*/
+
+/*
+  Read the local header of the current zipfile
+  Check the coherency of the local header and info in the end of central
+        directory about this file
+  store in *piSizeVar the size of extra info in local header
+        (filename and size of extra field data)
+*/
+local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,
+                                                    ZPOS64_T * poffset_local_extrafield,
+                                                    uInt  * psize_local_extrafield)
+{
+    uLong uMagic,uData,uFlags;
+    uLong size_filename;
+    uLong size_extra_field;
+    int err=UNZ_OK;
+
+    *piSizeVar = 0;
+    *poffset_local_extrafield = 0;
+    *psize_local_extrafield = 0;
+
+    if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
+                                s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return UNZ_ERRNO;
+
+
+    if (err==UNZ_OK)
+    {
+        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
+            err=UNZ_ERRNO;
+        else if (uMagic!=0x04034b50)
+            err=UNZ_BADZIPFILE;
+    }
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
+        err=UNZ_ERRNO;
+/*
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
+        err=UNZ_BADZIPFILE;
+*/
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
+        err=UNZ_BADZIPFILE;
+
+    if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
+/* #ifdef HAVE_BZIP2 */
+                         (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
+/* #endif */
+                         (s->cur_file_info.compression_method!=Z_DEFLATED))
+        err=UNZ_BADZIPFILE;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
+        err=UNZ_ERRNO;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))
+        err=UNZ_BADZIPFILE;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
+        err=UNZ_ERRNO;
+    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))
+        err=UNZ_BADZIPFILE;
+
+    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
+        err=UNZ_ERRNO;
+    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))
+        err=UNZ_BADZIPFILE;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
+        err=UNZ_BADZIPFILE;
+
+    *piSizeVar += (uInt)size_filename;
+
+    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
+        err=UNZ_ERRNO;
+    *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
+                                    SIZEZIPLOCALHEADER + size_filename;
+    *psize_local_extrafield = (uInt)size_extra_field;
+
+    *piSizeVar += (uInt)size_extra_field;
+
+    return err;
+}
+
+/*
+  Open for reading data the current file in the zipfile.
+  If there is no error and the file is opened, the return value is UNZ_OK.
+*/
+extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
+                                            int* level, int raw, const char* password)
+{
+    int err=UNZ_OK;
+    uInt iSizeVar;
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    ZPOS64_T offset_local_extrafield;  /* offset of the local extra field */
+    uInt  size_local_extrafield;    /* size of the local extra field */
+#    ifndef NOUNCRYPT
+    char source[12];
+#    else
+    if (password != NULL)
+        return UNZ_PARAMERROR;
+#    endif
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_PARAMERROR;
+
+    if (s->pfile_in_zip_read != NULL)
+        unzCloseCurrentFile(file);
+
+    if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
+        return UNZ_BADZIPFILE;
+
+    pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s));
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_INTERNALERROR;
+
+    pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
+    pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
+    pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
+    pfile_in_zip_read_info->pos_local_extrafield=0;
+    pfile_in_zip_read_info->raw=raw;
+
+    if (pfile_in_zip_read_info->read_buffer==NULL)
+    {
+        TRYFREE(pfile_in_zip_read_info);
+        return UNZ_INTERNALERROR;
+    }
+
+    pfile_in_zip_read_info->stream_initialised=0;
+
+    if (method!=NULL)
+        *method = (int)s->cur_file_info.compression_method;
+
+    if (level!=NULL)
+    {
+        *level = 6;
+        switch (s->cur_file_info.flag & 0x06)
+        {
+          case 6 : *level = 1; break;
+          case 4 : *level = 2; break;
+          case 2 : *level = 9; break;
+        }
+    }
+
+    if ((s->cur_file_info.compression_method!=0) &&
+/* #ifdef HAVE_BZIP2 */
+        (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
+/* #endif */
+        (s->cur_file_info.compression_method!=Z_DEFLATED))
+
+        err=UNZ_BADZIPFILE;
+
+    pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
+    pfile_in_zip_read_info->crc32=0;
+    pfile_in_zip_read_info->total_out_64=0;
+    pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;
+    pfile_in_zip_read_info->filestream=s->filestream;
+    pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
+    pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
+
+    pfile_in_zip_read_info->stream.total_out = 0;
+
+    if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))
+    {
+#ifdef HAVE_BZIP2
+      pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
+      pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
+      pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
+      pfile_in_zip_read_info->bstream.state = (voidpf)0;
+
+      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+      pfile_in_zip_read_info->stream.zfree = (free_func)0;
+      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+      pfile_in_zip_read_info->stream.next_in = (voidpf)0;
+      pfile_in_zip_read_info->stream.avail_in = 0;
+
+      err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
+      if (err == Z_OK)
+        pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
+      else
+      {
+        TRYFREE(pfile_in_zip_read_info);
+        return err;
+      }
+#else
+      pfile_in_zip_read_info->raw=1;
+#endif
+    }
+    else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
+    {
+      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+      pfile_in_zip_read_info->stream.zfree = (free_func)0;
+      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+      pfile_in_zip_read_info->stream.next_in = 0;
+      pfile_in_zip_read_info->stream.avail_in = 0;
+
+      err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
+      if (err == Z_OK)
+        pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
+      else
+      {
+        TRYFREE(pfile_in_zip_read_info);
+        return err;
+      }
+        /* windowBits is passed < 0 to tell that there is no zlib header.
+         * Note that in this case inflate *requires* an extra "dummy" byte
+         * after the compressed stream in order to complete decompression and
+         * return Z_STREAM_END.
+         * In unzip, i don't wait absolutely Z_STREAM_END because I known the
+         * size of both compressed and uncompressed data
+         */
+    }
+    pfile_in_zip_read_info->rest_read_compressed =
+            s->cur_file_info.compressed_size ;
+    pfile_in_zip_read_info->rest_read_uncompressed =
+            s->cur_file_info.uncompressed_size ;
+
+
+    pfile_in_zip_read_info->pos_in_zipfile =
+            s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
+              iSizeVar;
+
+    pfile_in_zip_read_info->stream.avail_in = (uInt)0;
+
+    s->pfile_in_zip_read = pfile_in_zip_read_info;
+                s->encrypted = 0;
+
+#    ifndef NOUNCRYPT
+    if (password != NULL)
+    {
+        int i;
+        s->pcrc_32_tab = get_crc_table();
+        init_keys(password,s->keys,s->pcrc_32_tab);
+        if (ZSEEK64(s->z_filefunc, s->filestream,
+                  s->pfile_in_zip_read->pos_in_zipfile +
+                     s->pfile_in_zip_read->byte_before_the_zipfile,
+                  SEEK_SET)!=0)
+            return UNZ_INTERNALERROR;
+        if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12)
+            return UNZ_INTERNALERROR;
+
+        for (i = 0; i<12; i++)
+            zdecode(s->keys,s->pcrc_32_tab,source[i]);
+
+        s->pfile_in_zip_read->pos_in_zipfile+=12;
+        s->encrypted=1;
+    }
+#    endif
+
+
+    return UNZ_OK;
+}
+
+extern int ZEXPORT unzOpenCurrentFile (unzFile file)
+{
+    return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
+}
+
+extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char*  password)
+{
+    return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
+}
+
+extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw)
+{
+    return unzOpenCurrentFile3(file, method, level, raw, NULL);
+}
+
+/** Addition for GDAL : START */
+
+extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
+{
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    s=(unz64_s*)file;
+    if (file==NULL)
+        return 0; //UNZ_PARAMERROR;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+    if (pfile_in_zip_read_info==NULL)
+        return 0; //UNZ_PARAMERROR;
+    return pfile_in_zip_read_info->pos_in_zipfile +
+                         pfile_in_zip_read_info->byte_before_the_zipfile;
+}
+
+/** Addition for GDAL : END */
+
+/*
+  Read bytes from the current file.
+  buf contain buffer where data must be copied
+  len the size of buf.
+
+  return the number of byte copied if somes bytes are copied
+  return 0 if the end of file was reached
+  return <0 with error code if there is an error
+    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+*/
+extern int ZEXPORT unzReadCurrentFile  (unzFile file, voidp buf, unsigned len)
+{
+    int err=UNZ_OK;
+    uInt iRead = 0;
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+
+    if (pfile_in_zip_read_info->read_buffer == NULL)
+        return UNZ_END_OF_LIST_OF_FILE;
+    if (len==0)
+        return 0;
+
+    pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
+
+    pfile_in_zip_read_info->stream.avail_out = (uInt)len;
+
+    if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
+        (!(pfile_in_zip_read_info->raw)))
+        pfile_in_zip_read_info->stream.avail_out =
+            (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
+
+    if ((len>pfile_in_zip_read_info->rest_read_compressed+
+           pfile_in_zip_read_info->stream.avail_in) &&
+         (pfile_in_zip_read_info->raw))
+        pfile_in_zip_read_info->stream.avail_out =
+            (uInt)pfile_in_zip_read_info->rest_read_compressed+
+            pfile_in_zip_read_info->stream.avail_in;
+
+    while (pfile_in_zip_read_info->stream.avail_out>0)
+    {
+        if ((pfile_in_zip_read_info->stream.avail_in==0) &&
+            (pfile_in_zip_read_info->rest_read_compressed>0))
+        {
+            uInt uReadThis = UNZ_BUFSIZE;
+            if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
+                uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
+            if (uReadThis == 0)
+                return UNZ_EOF;
+            if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
+                      pfile_in_zip_read_info->filestream,
+                      pfile_in_zip_read_info->pos_in_zipfile +
+                         pfile_in_zip_read_info->byte_before_the_zipfile,
+                         ZLIB_FILEFUNC_SEEK_SET)!=0)
+                return UNZ_ERRNO;
+            if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
+                      pfile_in_zip_read_info->filestream,
+                      pfile_in_zip_read_info->read_buffer,
+                      uReadThis)!=uReadThis)
+                return UNZ_ERRNO;
+
+
+#            ifndef NOUNCRYPT
+            if(s->encrypted)
+            {
+                uInt i;
+                for(i=0;i<uReadThis;i++)
+                  pfile_in_zip_read_info->read_buffer[i] =
+                      zdecode(s->keys,s->pcrc_32_tab,
+                              pfile_in_zip_read_info->read_buffer[i]);
+            }
+#            endif
+
+
+            pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
+
+            pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
+
+            pfile_in_zip_read_info->stream.next_in =
+                (Bytef*)pfile_in_zip_read_info->read_buffer;
+            pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
+        }
+
+        if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
+        {
+            uInt uDoCopy,i ;
+
+            if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
+                (pfile_in_zip_read_info->rest_read_compressed == 0))
+                return (iRead==0) ? UNZ_EOF : iRead;
+
+            if (pfile_in_zip_read_info->stream.avail_out <
+                            pfile_in_zip_read_info->stream.avail_in)
+                uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
+            else
+                uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
+
+            for (i=0;i<uDoCopy;i++)
+                *(pfile_in_zip_read_info->stream.next_out+i) =
+                        *(pfile_in_zip_read_info->stream.next_in+i);
+
+            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;
+
+            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
+                                pfile_in_zip_read_info->stream.next_out,
+                                uDoCopy);
+            pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
+            pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
+            pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
+            pfile_in_zip_read_info->stream.next_out += uDoCopy;
+            pfile_in_zip_read_info->stream.next_in += uDoCopy;
+            pfile_in_zip_read_info->stream.total_out += uDoCopy;
+            iRead += uDoCopy;
+        }
+        else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
+        {
+#ifdef HAVE_BZIP2
+            uLong uTotalOutBefore,uTotalOutAfter;
+            const Bytef *bufBefore;
+            uLong uOutThis;
+
+            pfile_in_zip_read_info->bstream.next_in        = (char*)pfile_in_zip_read_info->stream.next_in;
+            pfile_in_zip_read_info->bstream.avail_in       = pfile_in_zip_read_info->stream.avail_in;
+            pfile_in_zip_read_info->bstream.total_in_lo32  = pfile_in_zip_read_info->stream.total_in;
+            pfile_in_zip_read_info->bstream.total_in_hi32  = 0;
+            pfile_in_zip_read_info->bstream.next_out       = (char*)pfile_in_zip_read_info->stream.next_out;
+            pfile_in_zip_read_info->bstream.avail_out      = pfile_in_zip_read_info->stream.avail_out;
+            pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
+            pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
+
+            uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
+            bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;
+
+            err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
+
+            uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
+            uOutThis = uTotalOutAfter-uTotalOutBefore;
+
+            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
+
+            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));
+            pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
+            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
+
+            pfile_in_zip_read_info->stream.next_in   = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
+            pfile_in_zip_read_info->stream.avail_in  = pfile_in_zip_read_info->bstream.avail_in;
+            pfile_in_zip_read_info->stream.total_in  = pfile_in_zip_read_info->bstream.total_in_lo32;
+            pfile_in_zip_read_info->stream.next_out  = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
+            pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
+            pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
+
+            if (err==BZ_STREAM_END)
+              return (iRead==0) ? UNZ_EOF : iRead;
+            if (err!=BZ_OK)
+              break;
+#endif
+        } // end Z_BZIP2ED
+        else
+        {
+            ZPOS64_T uTotalOutBefore,uTotalOutAfter;
+            const Bytef *bufBefore;
+            ZPOS64_T uOutThis;
+            int flush=Z_SYNC_FLUSH;
+
+            uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
+            bufBefore = pfile_in_zip_read_info->stream.next_out;
+
+            /*
+            if ((pfile_in_zip_read_info->rest_read_uncompressed ==
+                     pfile_in_zip_read_info->stream.avail_out) &&
+                (pfile_in_zip_read_info->rest_read_compressed == 0))
+                flush = Z_FINISH;
+            */
+            err=inflate(&pfile_in_zip_read_info->stream,flush);
+
+            if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
+              err = Z_DATA_ERROR;
+
+            uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
+            uOutThis = uTotalOutAfter-uTotalOutBefore;
+
+            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
+
+            pfile_in_zip_read_info->crc32 =
+                crc32(pfile_in_zip_read_info->crc32,bufBefore,
+                        (uInt)(uOutThis));
+
+            pfile_in_zip_read_info->rest_read_uncompressed -=
+                uOutThis;
+
+            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
+
+            if (err==Z_STREAM_END)
+                return (iRead==0) ? UNZ_EOF : iRead;
+            if (err!=Z_OK)
+                break;
+        }
+    }
+
+    if (err==Z_OK)
+        return iRead;
+    return err;
+}
+
+
+/*
+  Give the current position in uncompressed data
+*/
+extern z_off_t ZEXPORT unztell (unzFile file)
+{
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    return (z_off_t)pfile_in_zip_read_info->stream.total_out;
+}
+
+extern ZPOS64_T ZEXPORT unztell64 (unzFile file)
+{
+
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return (ZPOS64_T)-1;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return (ZPOS64_T)-1;
+
+    return pfile_in_zip_read_info->total_out_64;
+}
+
+
+/*
+  return 1 if the end of file was reached, 0 elsewhere
+*/
+extern int ZEXPORT unzeof (unzFile file)
+{
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
+        return 1;
+    else
+        return 0;
+}
+
+
+
+/*
+Read extra field from the current file (opened by unzOpenCurrentFile)
+This is the local-header version of the extra field (sometimes, there is
+more info in the local-header version than in the central-header)
+
+  if buf==NULL, it return the size of the local extra field that can be read
+
+  if buf!=NULL, len is the size of the buffer, the extra header is copied in
+    buf.
+  the return value is the number of bytes copied in buf, or (if <0)
+    the error code
+*/
+extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
+{
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    uInt read_now;
+    ZPOS64_T size_to_read;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
+                pfile_in_zip_read_info->pos_local_extrafield);
+
+    if (buf==NULL)
+        return (int)size_to_read;
+
+    if (len>size_to_read)
+        read_now = (uInt)size_to_read;
+    else
+        read_now = (uInt)len ;
+
+    if (read_now==0)
+        return 0;
+
+    if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
+              pfile_in_zip_read_info->filestream,
+              pfile_in_zip_read_info->offset_local_extrafield +
+              pfile_in_zip_read_info->pos_local_extrafield,
+              ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return UNZ_ERRNO;
+
+    if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
+              pfile_in_zip_read_info->filestream,
+              buf,read_now)!=read_now)
+        return UNZ_ERRNO;
+
+    return (int)read_now;
+}
+
+/*
+  Close the file in zip opened with unzipOpenCurrentFile
+  Return UNZ_CRCERROR if all the file was read but the CRC is not good
+*/
+extern int ZEXPORT unzCloseCurrentFile (unzFile file)
+{
+    int err=UNZ_OK;
+
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+
+    if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
+        (!pfile_in_zip_read_info->raw))
+    {
+        if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
+            err=UNZ_CRCERROR;
+    }
+
+
+    TRYFREE(pfile_in_zip_read_info->read_buffer);
+    pfile_in_zip_read_info->read_buffer = NULL;
+    if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
+        inflateEnd(&pfile_in_zip_read_info->stream);
+#ifdef HAVE_BZIP2
+    else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
+        BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
+#endif
+
+
+    pfile_in_zip_read_info->stream_initialised = 0;
+    TRYFREE(pfile_in_zip_read_info);
+
+    s->pfile_in_zip_read=NULL;
+
+    return err;
+}
+
+
+/*
+  Get the global comment string of the ZipFile, in the szComment buffer.
+  uSizeBuf is the size of the szComment buffer.
+  return the number of byte copied or an error code <0
+*/
+extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)
+{
+    unz64_s* s;
+    uLong uReadThis ;
+    if (file==NULL)
+        return (int)UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+
+    uReadThis = uSizeBuf;
+    if (uReadThis>s->gi.size_comment)
+        uReadThis = s->gi.size_comment;
+
+    if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return UNZ_ERRNO;
+
+    if (uReadThis>0)
+    {
+      *szComment='\0';
+      if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
+        return UNZ_ERRNO;
+    }
+
+    if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
+        *(szComment+s->gi.size_comment)='\0';
+    return (int)uReadThis;
+}
+
+/* Additions by RX '2004 */
+extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
+{
+    unz64_s* s;
+
+    if (file==NULL)
+          return 0; //UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    if (!s->current_file_ok)
+      return 0;
+    if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
+      if (s->num_file==s->gi.number_entry)
+         return 0;
+    return s->pos_in_central_dir;
+}
+
+extern uLong ZEXPORT unzGetOffset (unzFile file)
+{
+    ZPOS64_T offset64;
+
+    if (file==NULL)
+          return 0; //UNZ_PARAMERROR;
+    offset64 = unzGetOffset64(file);
+    return (uLong)offset64;
+}
+
+extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
+{
+    unz64_s* s;
+    int err;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+
+    s->pos_in_central_dir = pos;
+    s->num_file = s->gi.number_entry;      /* hack */
+    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                              &s->cur_file_info_internal,
+                                              NULL,0,NULL,0,NULL,0);
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
+{
+    return unzSetOffset64(file,pos);
+}


[44/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_service_dependency.c b/dependency_manager/private/src/dm_service_dependency.c
deleted file mode 100644
index 65a0593..0000000
--- a/dependency_manager/private/src/dm_service_dependency.c
+++ /dev/null
@@ -1,811 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_service_dependency.c
- *
- *  \date       17 Oct 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <assert.h>
-
-#include "constants.h"
-
-#include "dm_service_dependency_impl.h"
-#include "dm_component_impl.h"
-
-#define DEFAULT_RANKING     0
-#define DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
-
-static celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt reference, void *service);
-static celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_pt reference, void *service);
-static celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt reference, void *service);
-static void* serviceDependency_getCallbackHandle(dm_service_dependency_pt dep);
-
-celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*dependency_ptr = calloc(1, sizeof(**dependency_ptr));
-	if (!*dependency_ptr) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*dependency_ptr)->component = NULL;
-		(*dependency_ptr)->available = false;
-		(*dependency_ptr)->instanceBound = false;
-		(*dependency_ptr)->required = false;
-		(*dependency_ptr)->strategy = DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY;
-
-		(*dependency_ptr)->callbackHandle = NULL;
-		(*dependency_ptr)->set = NULL;
-		(*dependency_ptr)->add = NULL;
-		(*dependency_ptr)->change = NULL;
-		(*dependency_ptr)->remove = NULL;
-		(*dependency_ptr)->swap = NULL;
-
-		(*dependency_ptr)->add_with_ref = NULL;
-		(*dependency_ptr)->change_with_ref = NULL;
-		(*dependency_ptr)->remove_with_ref = NULL;
-		(*dependency_ptr)->swap_with_ref = NULL;
-
-		(*dependency_ptr)->autoConfigure = NULL;
-
-		(*dependency_ptr)->isStarted = false;
-
-        (*dependency_ptr)->addCLanguageFilter = false;
-		(*dependency_ptr)->tracked_service = NULL;
-		(*dependency_ptr)->tracked_filter_unmodified = NULL;
-		(*dependency_ptr)->tracked_filter = NULL;
-
-		(*dependency_ptr)->tracker = NULL;
-		(*dependency_ptr)->tracker_customizer = NULL;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_destroy(dm_service_dependency_pt *dependency_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!*dependency_ptr) {
-		status = CELIX_ENOMEM;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		free((*dependency_ptr)->tracked_service);
-		free((*dependency_ptr)->tracked_filter);
-		free((*dependency_ptr)->tracked_filter_unmodified);
-		free(*dependency_ptr);
-		*dependency_ptr = NULL;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_lock(dm_service_dependency_pt dependency) {
-	celixThreadMutex_lock(&dependency->lock);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceDependency_unlock(dm_service_dependency_pt dependency) {
-	celixThreadMutex_unlock(&dependency->lock);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency, bool required) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->required = required;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_pt dependency, bool addCLangFilter) {
-    dependency->addCLanguageFilter = addCLangFilter;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t serviceDependency_setStrategy(dm_service_dependency_pt dependency, dm_service_dependency_strategy_t strategy) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		dependency->strategy = strategy;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency, dm_service_dependency_strategy_t* strategy) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*strategy = dependency->strategy;
-	}
-
-	return status;
-
-}
-
-celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, const char* serviceName, const char* serviceVersionRange, const char* filter) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (!dependency || !serviceName) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		array_list_pt filterElements = NULL;
-		arrayList_create(&filterElements);
-
-		free(dependency->tracked_service);
-		dependency->tracked_service = strdup(serviceName);
-
-		if (serviceVersionRange != NULL) {
-			version_range_pt versionRange = NULL;
-
-			if (versionRange_parse(serviceVersionRange, &versionRange) == CELIX_SUCCESS) {
-				version_pt lowVersion = NULL;
-				version_pt highVersion = NULL;
-
-				if ((versionRange_getHighVersion(versionRange, &highVersion) == CELIX_SUCCESS) && (highVersion != NULL)) {
-					bool isHighInclusive;
-					char* highOperator;
-					char* highVersionStr = NULL;
-
-					versionRange_isHighInclusive(versionRange, &isHighInclusive);
-					version_toString(highVersion, &highVersionStr);
-
-					highOperator = isHighInclusive ? "<=" : "<";
-
-					if(highVersionStr != NULL){
-						size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(highVersionStr) + strlen(highOperator) + 3;
-						char serviceVersionFilter[len];
-						snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, highOperator, highVersionStr);
-						arrayList_add(filterElements, strdup(serviceVersionFilter));
-						free(highVersionStr);
-					}
-				}
-
-				if ((versionRange_getLowVersion(versionRange, &lowVersion) == CELIX_SUCCESS) && (lowVersion != NULL)) {
-					bool isLowInclusive;
-					char* lowOperator;
-					char* lowVersionStr = NULL;
-
-					versionRange_isLowInclusive(versionRange, &isLowInclusive);
-					version_toString(lowVersion, &lowVersionStr);
-
-					lowOperator = isLowInclusive ? ">=" : ">";
-
-					if(lowVersionStr != NULL){
-						size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(lowVersionStr) + strlen(lowOperator) + 3;
-						char serviceVersionFilter[len];
-						snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, lowOperator, lowVersionStr);
-						arrayList_add(filterElements, strdup(serviceVersionFilter));
-						free(lowVersionStr);
-					}
-				}
-			}
-
-			if(versionRange!=NULL){
-				versionRange_destroy(versionRange);
-			}
-		}
-
-		if (filter != NULL) {
-			free(dependency->tracked_filter_unmodified);
-			dependency->tracked_filter_unmodified = strdup(filter);
-			arrayList_add(filterElements, strdup(filter));
-		}
-
-
-
-        bool needLangFilter = true;
-		if (filter != NULL) {
-            char needle[128];
-            snprintf(needle, sizeof(needle), "(%s=", CELIX_FRAMEWORK_SERVICE_LANGUAGE);
-            if (strstr(filter, needle) != NULL) {
-                needLangFilter = false;
-            }
-        }
-
-        if (needLangFilter && dependency->addCLanguageFilter) {
-			char langFilter[128];
-			snprintf(langFilter, sizeof(langFilter), "(%s=%s)", CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-            arrayList_add(filterElements, strdup(langFilter));
-		}
-
-		if (arrayList_size(filterElements) > 0) {
-			array_list_iterator_pt filterElementsIter = arrayListIterator_create(filterElements);
-
-			size_t len = strlen(serviceName) + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + 4;
-			free(dependency->tracked_filter);
-			dependency->tracked_filter = calloc(len, sizeof(*dependency->tracked_filter));
-			snprintf(dependency->tracked_filter, len, "(%s=%s)", OSGI_FRAMEWORK_OBJECTCLASS, serviceName);
-
-			while (arrayListIterator_hasNext(filterElementsIter) == true) {
-				char* filterElement = (char*) arrayListIterator_next(filterElementsIter);
-				size_t len = strnlen(dependency->tracked_filter, 1024*1024) + strnlen(filterElement, 1024*1024) + 4;
-				char* newFilter = calloc(len, sizeof(*newFilter));
-
-				if (dependency->tracked_filter[0] == '(' && dependency->tracked_filter[1] == '&') {
-					//already have an & (AND) can combine with additional filter -> easier to read
-					size_t orgLen = strnlen(dependency->tracked_filter, 1024*1024);
-					snprintf(newFilter, len, "%.*s%s)", (int)orgLen -1, dependency->tracked_filter, filterElement);
-				} else {
-					snprintf(newFilter, len, "(&%s%s)", dependency->tracked_filter, filterElement);
-				}
-
-				free(dependency->tracked_filter);
-				free(filterElement);
-
-				dependency->tracked_filter = newFilter;
-			}
-
-			arrayListIterator_destroy(filterElementsIter);
-		}
-		else {
-			free(dependency->tracked_filter);
-			dependency->tracked_filter = NULL;
-		}
-
-		arrayList_destroy(filterElements);
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, const char** filter) {
-	*filter = (const char*)dependency->tracked_filter;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceDependency_setCallbacks(dm_service_dependency_pt dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    //printf("Setting callbacks set %p, add %p, change %p, remove %p and swap %p\n", set, add, change, remove, swap);
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->set = set;
-		dependency->add = add;
-		dependency->change = change;
-		dependency->remove = remove;
-		dependency->swap = swap;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_pt dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove,
-		service_swap_with_ref_fpt swap) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->set_with_ref = set;
-		dependency->add_with_ref = add;
-		dependency->change_with_ref = change;
-		dependency->remove_with_ref = remove;
-		dependency->swap_with_ref = swap;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt dependency, celix_thread_mutex_t *service_lock, const void **field) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	celix_thread_mutex_t lock;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->autoConfigure = field;
-		celixThreadMutex_create(&lock, NULL);
-		*service_lock = lock;
-		dependency->lock = lock;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependency, dm_component_pt component) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->component = component;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_start(dm_service_dependency_pt dependency) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_context_pt context = NULL;
-
-	if (!dependency || !dependency->component || (!dependency->tracked_service && !dependency->tracked_filter)) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-	if (status == CELIX_SUCCESS) {
-		status = component_getBundleContext(dependency->component, &context);
-		if (!context) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-	if (status == CELIX_SUCCESS) {
-		dependency->tracker_customizer = NULL;
-		status = serviceTrackerCustomizer_create(dependency, NULL, serviceDependency_addedService, serviceDependency_modifiedService, serviceDependency_removedService, &dependency->tracker_customizer);
-	}
-	if (status == CELIX_SUCCESS) {
-		if (dependency->tracked_filter) {
-			status = serviceTracker_createWithFilter(context, dependency->tracked_filter, dependency->tracker_customizer, &dependency->tracker);
-		} else if (dependency->tracked_service) {
-			status = serviceTracker_create(context, dependency->tracked_service, dependency->tracker_customizer, &dependency->tracker);
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = serviceTracker_open(dependency->tracker);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->isStarted = true;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->isStarted = false;
-	}
-
-	if (status == CELIX_SUCCESS && dependency->tracker) {
-		status = serviceTracker_close(dependency->tracker);
-		if (status == CELIX_SUCCESS) {
-			serviceTracker_destroy(dependency->tracker);
-			dependency->tracker = NULL;
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt dependency, bool instanceBound) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->instanceBound = instanceBound;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependency, bool available) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->available = available;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-	assert(dependency->isStarted == true);
-	array_list_pt serviceReferences = NULL;
-	int i;
-	int curRanking = INT_MIN;
-	service_reference_pt curServRef = NULL;
-	void *service = NULL;
-
-	serviceReferences = serviceTracker_getServiceReferences(dependency->tracker);
-
-	/* Find the service with the higest ranking */
-	for (i = 0; i < arrayList_size(serviceReferences); i++) {
-		service_reference_pt serviceReference = arrayList_get(serviceReferences, i);
-		const char* ranking_value;
-		int ranking = 0;
-
-		status = serviceReference_getProperty(serviceReference, ((char *) OSGI_FRAMEWORK_SERVICE_RANKING), &ranking_value);
-
-		if (status == CELIX_SUCCESS) {
-			if (ranking_value == NULL) {
-				ranking = DEFAULT_RANKING;
-			} else {
-				char *end;
-				ranking = strtol(ranking_value, &end, 10);
-				if (end == ranking_value) {
-					ranking = DEFAULT_RANKING;
-				}
-			}
-
-			if (ranking > curRanking) {
-				curRanking = ranking;
-				curServRef = serviceReference;
-			}
-		} else {
-			break;
-		}
-
-	}
-
-	arrayList_destroy(serviceReferences);
-
-	if (status == CELIX_SUCCESS) {
-		if (curServRef) {
-			status = bundleContext_getService(event->context, curServRef, &service);
-		} else {
-			service = NULL;
-		}
-
-		if (dependency->set) {
-			dependency->set(serviceDependency_getCallbackHandle(dependency), service);
-		}
-		if (dependency->set_with_ref) {
-			dependency->set_with_ref(serviceDependency_getCallbackHandle(dependency), curServRef, service);
-		}
-
-		if (curServRef) {
-			bundleContext_ungetService(event->context, curServRef, NULL);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		if (dependency->add) {
-			dependency->add(serviceDependency_getCallbackHandle(dependency), event->service);
-		}
-		if (dependency->add_with_ref) {
-			dependency->add_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		if (dependency->change) {
-			dependency->change(serviceDependency_getCallbackHandle(dependency), event->service);
-		}
-		if (dependency->change_with_ref) {
-			dependency->change_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		if (dependency->remove) {
-			dependency->remove(serviceDependency_getCallbackHandle(dependency), event->service);
-		}
-		if (dependency->remove_with_ref) {
-			dependency->remove_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		if (dependency->swap) {
-			dependency->swap(serviceDependency_getCallbackHandle(dependency), event->service, newEvent->service);
-		}
-		if (dependency->swap_with_ref) {
-			dependency->swap_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service, newEvent->reference, newEvent->service);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency, bool *available) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*available = dependency->available;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency, bool *required) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*required = dependency->required;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt dependency, bool *instanceBound) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*instanceBound = dependency->instanceBound;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependency, bool *autoConfig) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*autoConfig = dependency->autoConfigure != NULL;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependency, const void*** autoConfigure) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*autoConfigure = dependency->autoConfigure;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt reference, void *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_context_pt context = NULL;
-	bundle_pt bundle = NULL;
-	dm_event_pt event = NULL;
-	dm_service_dependency_pt dependency = _ptr;
-
-	if (!dependency || !reference || !service) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = component_getBundleContext(dependency->component, &context);
-		if (!context) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getBundle(context, &bundle);
-		if (!bundle) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = event_create(DM_EVENT_ADDED, bundle, context, reference, service, &event);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		component_handleEvent(dependency->component, dependency, event);
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_pt reference, void *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_context_pt context = NULL;
-	bundle_pt bundle = NULL;
-	dm_event_pt event = NULL;
-	dm_service_dependency_pt dependency = _ptr;
-
-	if (!dependency || !reference || !service) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = component_getBundleContext(dependency->component, &context);
-		if (!context) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getBundle(context, &bundle);
-		if (!bundle) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = event_create(DM_EVENT_CHANGED, bundle, context, reference, service, &event);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		component_handleEvent(dependency->component, dependency, event);
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt reference, void *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_context_pt context = NULL;
-	bundle_pt bundle = NULL;
-	dm_event_pt event = NULL;
-	dm_service_dependency_pt dependency = _ptr;
-
-	if (!dependency || !reference || !service) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = component_getBundleContext(dependency->component, &context);
-		if (!context) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getBundle(context, &bundle);
-		if (!bundle) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = event_create(DM_EVENT_REMOVED, bundle, context, reference, service, &event);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		component_handleEvent(dependency->component, dependency, event);
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt dep, dm_service_dependency_info_pt *out) {
-	celix_status_t status = CELIX_SUCCESS;
-	dm_service_dependency_info_pt info = calloc(1, sizeof(*info));
-	if (info != NULL) {
-		celixThreadMutex_lock(&dep->lock);
-		info->available = dep->available;
-		info->filter = dep->tracked_filter != NULL ? strdup(dep->tracked_filter) : NULL;
-		if (info->filter == NULL) {
-			info->filter = dep->tracked_service != NULL ? strdup(dep->tracked_service) : NULL;
-		}
-		info->required = dep->required;
-
-		array_list_pt refs = serviceTracker_getServiceReferences(dep->tracker);
-		if (refs != NULL) {
-			info->count = arrayList_size(refs);
-		}
-		arrayList_destroy(refs);
-
-		celixThreadMutex_unlock(&dep->lock);
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*out = info;
-	}
-
-	return status;
-}
-
-void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info) {
-	if (info != NULL) {
-		free(info->filter);
-	}
-	free(info);
-}
-
-celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_pt dependency, void* handle) {
-	dependency->callbackHandle = handle;
-    return CELIX_SUCCESS;
-}
-
-static void* serviceDependency_getCallbackHandle(dm_service_dependency_pt dependency) {
-    return dependency->callbackHandle == NULL ? component_getImplementation(dependency->component) : dependency->callbackHandle;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_shell_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_shell_activator.c b/dependency_manager/private/src/dm_shell_activator.c
deleted file mode 100644
index 4d6f507..0000000
--- a/dependency_manager/private/src/dm_shell_activator.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_shell_activator.c
- *
- *  \date       16 Oct 2015
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <constants.h>
-#include "bundle_context.h"
-#include "command.h"
-
-#include "dm_shell_list_command.h"
-#include "shell_constants.h"
-
-struct bundle_instance {
-    service_registration_pt reg;
-    command_service_t  dmCommand;
-    dm_command_handle_t dmHandle;
-};
-
-typedef struct bundle_instance * bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-
-	if(userData==NULL){
-		return CELIX_ILLEGAL_ARGUMENT;
-	}
-
-    struct bundle_instance *bi = calloc(sizeof (struct bundle_instance), 1);
-
-    if (bi==NULL) {
-        return CELIX_ENOMEM;
-    }
-
-    bi->dmHandle.context = context;
-    const char* config = NULL;
-    bundleContext_getPropertyWithDefault(context, SHELL_USE_ANSI_COLORS, SHELL_USE_ANSI_COLORS_DEFAULT_VALUE, &config);
-    bi->dmHandle.useColors = config != NULL && strncmp("true", config, 5) == 0;
-
-    (*userData) = bi;
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_instance_pt bi = (bundle_instance_pt) userData;
-
-    bi->dmCommand.handle = &bi->dmHandle;
-    bi->dmCommand.executeCommand = (void *)dmListCommand_execute;
-
-    properties_pt props = properties_create();
-    properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-    properties_set(props, OSGI_SHELL_COMMAND_NAME, "dm");
-    properties_set(props, OSGI_SHELL_COMMAND_USAGE, "dm");
-    properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION,
-                   "Gives an overview of the component managemend by a dependency manager.");
-
-    status = bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, &bi->dmCommand, props, &bi->reg);
-
-    return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-    bundle_instance_pt bi = (bundle_instance_pt) userData;
-    serviceRegistration_unregister(bi->reg);
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-    bundle_instance_pt bi = (bundle_instance_pt) userData;
-    free(bi);
-    return CELIX_SUCCESS;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_shell_list_command.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_shell_list_command.c b/dependency_manager/private/src/dm_shell_list_command.c
deleted file mode 100644
index 1600710..0000000
--- a/dependency_manager/private/src/dm_shell_list_command.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_shell_list_command.c
- *
- *  \date       Oct 16, 2015
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <dm_dependency_manager.h>
-#include <dm_shell_list_command.h>
-#include "dm_info.h"
-#include "service_reference.h"
-#include "array_list.h"
-#include "bundle_context.h"
-#include "bundle.h"
-#include "shell.h"
-
-
-static const char * const OK_COLOR = "\033[92m";
-static const char * const WARNING_COLOR = "\033[93m";
-static const char * const NOK_COLOR = "\033[91m";
-static const char * const END_COLOR = "\033[m";
-
-void dmListCommand_execute(dm_command_handle_t* handle, char * line, FILE *out, FILE *err) {
-
-    array_list_pt servRefs = NULL;
-    int i;
-    bundleContext_getServiceReferences(handle->context, DM_INFO_SERVICE_NAME ,NULL, &servRefs);
-
-    if(servRefs==NULL){
-	fprintf(out, "Invalid dm_info ServiceReferences List\n");
-	return;
-    }
-
-    bool colors = handle->useColors;
-
-    for(i = 0; i < arrayList_size(servRefs); i++) {
-        dm_dependency_manager_info_pt info = NULL;
-        dm_info_service_pt infoServ = NULL;
-        service_reference_pt servRef = NULL;
-        servRef = arrayList_get(servRefs, i);
-        bundleContext_getService(handle->context,  servRef, (void**)&infoServ);
-        infoServ->getInfo(infoServ->handle, &info);
-
-        int cmpCnt;
-        for (cmpCnt = 0; cmpCnt < arrayList_size(info->components); cmpCnt++) {
-            dm_component_info_pt compInfo = arrayList_get(info->components, cmpCnt);
-            const char *startColors = "";
-            const char *endColors = "";
-            if (colors) {
-                startColors = compInfo->active ? OK_COLOR : NOK_COLOR;
-                endColors = END_COLOR;
-            }
-            fprintf(out, "Component: Name=%s\n|- ID=%s, %sActive=%s%s, State=%s\n", compInfo->name, compInfo->id, startColors, compInfo->active ?  "true " : "false", endColors, compInfo->state);
-
-            int interfCnt;
-            fprintf(out, "|- Interfaces (%d):\n", arrayList_size(compInfo->interfaces));
-            for(interfCnt = 0 ;interfCnt < arrayList_size(compInfo->interfaces); interfCnt++) {
-                dm_interface_info_pt intfInfo= arrayList_get(compInfo->interfaces, interfCnt);
-                fprintf(out, "   |- Interface: %s\n", intfInfo->name);
-
-                hash_map_iterator_t iter = hashMapIterator_construct((hash_map_pt) intfInfo->properties);
-                char* key = NULL;
-                while((key = hashMapIterator_nextKey(&iter)) != NULL) {
-                    fprintf(out, "      | %15s = %s\n", key, properties_get(intfInfo->properties, key));
-                }
-            }
-
-            int depCnt;
-            fprintf(out, "|- Dependencies (%d):\n", arrayList_size(compInfo->dependency_list));
-            for(depCnt = 0 ;depCnt < arrayList_size(compInfo->dependency_list); depCnt++) {
-                dm_service_dependency_info_pt dependency;
-                dependency = arrayList_get(compInfo->dependency_list, depCnt);
-                const char *startColors = "";
-                const char *endColors = "";
-                if (colors) {
-                    if (dependency->required) {
-                        startColors = dependency->available ? OK_COLOR : NOK_COLOR;
-                    } else {
-                        startColors = dependency->available ? OK_COLOR : WARNING_COLOR;
-                    }
-
-                    endColors = END_COLOR;
-                }
-                fprintf(out, "   |- Dependency: %sAvailable = %s%s, Required = %s, Filter = %s\n",
-                        startColors,
-                        dependency->available ? "true " : "false" ,
-                        endColors,
-                        dependency->required ? "true " : "false",
-                        dependency->filter
-                );
-            }
-            fprintf(out, "\n");
-
-		}
-
-            infoServ->destroyInfo(infoServ->handle, info);
-
-		bundleContext_ungetService(handle->context, servRef, NULL);
-		bundleContext_ungetServiceReference(handle->context, servRef);
-
-    }
-
-	if(servRefs!=NULL){
-		arrayList_destroy(servRefs);
-    }
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/public/include/dm_activator.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_activator.h b/dependency_manager/public/include/dm_activator.h
deleted file mode 100644
index bba62e6..0000000
--- a/dependency_manager/public/include/dm_activator.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.
- */
-
-/*
- * dm_activator_base.h
- *
- *  \date       26 Jul 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#ifndef DM_ACTIVATOR_BASE_H_
-#define DM_ACTIVATOR_BASE_H_
-
-
-#include "bundle_context.h"
-#include "celix_errno.h"
-#include "dm_dependency_manager.h"
-#include "bundle_activator.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Should be implemented by a bundle specific DM activator.
- * Should allocate and initialize a bundle specific activator struct.
- */
-celix_status_t dm_create(bundle_context_pt context, void ** userData);
-
-/**
- * Should be implemented by a bundle specific DM activator.
- * Will be called after the dm_create function.
- * Can be used to specify with use of the provided dependency manager the bundle specific components.
- */
-celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager);
-
-/**
- * Should be implemented by a bundle specific DM activator.
- * Should deinitialize and deallocate the undle specific activator struct.
- */
-celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_ACTIVATOR_BASE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/public/include/dm_component.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_component.h b/dependency_manager/public/include/dm_component.h
deleted file mode 100644
index 2cdad6d..0000000
--- a/dependency_manager/public/include/dm_component.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_component.h
- *
- *  \date       8 Oct 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef COMPONENT_H_
-#define COMPONENT_H_
-
-
-#include <bundle_context.h>
-#include <celix_errno.h>
-
-#include "dm_service_dependency.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct dm_component_struct *dm_component_pt;
-
-typedef enum dm_component_state_enum {
-    DM_CMP_STATE_INACTIVE = 1,
-    DM_CMP_STATE_WAITING_FOR_REQUIRED = 2,
-    DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED = 3,
-    DM_CMP_STATE_TRACKING_OPTIONAL = 4,
-} dm_component_state_t;
-
-#define DM_COMPONENT_MAX_ID_LENGTH 64
-#define DM_COMPONENT_MAX_NAME_LENGTH 128
-
-typedef int (*init_fpt)(void *userData);
-typedef int (*start_fpt)(void *userData);
-typedef int (*stop_fpt)(void *userData);
-typedef int (*deinit_fpt)(void *userData);
-
-/**
- * Creates a DM Component
- * Caller has ownership.
- */
-celix_status_t component_create(bundle_context_pt context, const char* name, dm_component_pt *component);
-
-/**
- * Destroys a DM Component
- */
-void component_destroy(dm_component_pt component);
-
-
-/**
- * Specify if a default 'service.lang=C' should be added to the properties of interfaces if no 'service.lang' has been
- * provided. Default is false. Note that this should be set before using component_addInterface.
- */
-celix_status_t component_setCLanguageProperty(dm_component_pt component, bool setCLangProp);
-
-
-/**
- * Adds a C interface to provide as service to the Celix framework.
- *
- * @param serviceName the service name.
- * @param version The version of the interface (e.g. "1.0.0"), Can be a NULL pointer.
- * @param properties To (meta) properties to provide with the service. Can be a NULL pointer.
- */
-celix_status_t component_addInterface(dm_component_pt component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties);
-
-/**
- * Sets the implementation of the component. e.g. the component handle/self/this pointer.
- */
-celix_status_t component_setImplementation(dm_component_pt component, void* implementation);
-
-/**
- * Returns an arraylist of service names. The caller owns the arraylist and strings (char *)
- */
-celix_status_t component_getInterfaces(dm_component_pt component, array_list_pt *servicesNames);
-
-/**
- * Adds a C service dependency to the component
- */
-celix_status_t component_addServiceDependency(dm_component_pt component, dm_service_dependency_pt dep);
-
-/**
- * Removes a C service dependency to the component
- */
-celix_status_t component_removeServiceDependency(dm_component_pt component, dm_service_dependency_pt dependency);
-
-/**
- * Returns the current state of the component.
- */
-dm_component_state_t component_currentState(dm_component_pt cmp);
-
-/**
- * Returns the implementation of the component. e.g. the component handle/self/this pointer.
- */
-void * component_getImplementation(dm_component_pt cmp);
-
-/**
- * Returns the DM component name. This is used when printing information about the component.
- */
-const char * component_getName(dm_component_pt cmp);
-
-/**
- * Returns bundle context for the bundle where this DM component is part of.
- */
-celix_status_t component_getBundleContext(dm_component_pt component, bundle_context_pt *out);
-
-/**
- * Set the component life cycle callbacks.
- * The first argument will be the component implementation (@see component_getImplementation)
- */
-celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit);
-
-/**
- * Set the component life cycle callbacks using a MACRO for improving the type safety.
- */
-#define component_setCallbacksSafe(dmCmp, type, init, start, stop, deinit) \
-    do {  \
-        int (*tmp_init)(type)   = (init); \
-        int (*tmp_start)(type)  = (start); \
-        int (*tmp_stop)(type)   = (stop); \
-        int (*tmp_deinit)(type) = (deinit); \
-        component_setCallbacks((dmCmp), (init_fpt)tmp_init, (start_fpt)tmp_start, (stop_fpt)tmp_stop, (deinit_fpt)tmp_deinit); \
-    } while(0)
-
-/**
- * Create a DM Component info struct. Containing information about the component.
- * Caller has ownership.
- */
-celix_status_t component_getComponentInfo(dm_component_pt component, dm_component_info_pt *info);
-
-/**
- * Destroys a DM Component info struct.
- */
-void component_destroyComponentInfo(dm_component_info_pt info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* COMPONENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/public/include/dm_dependency_manager.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_dependency_manager.h b/dependency_manager/public/include/dm_dependency_manager.h
deleted file mode 100644
index 89fe51d..0000000
--- a/dependency_manager/public/include/dm_dependency_manager.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_dependency_manager.h
- *
- *  \date       22 Feb 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef DM_DEPENDENCY_MANAGER_H_
-#define DM_DEPENDENCY_MANAGER_H_
-
-
-#include "bundle_context.h"
-#include "celix_errno.h"
-#include "array_list.h"
-#include "dm_info.h"
-#include "dm_component.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct dm_dependency_manager *dm_dependency_manager_pt;
-
-/**
- * Creates a dependency manager.
- * Caller has ownership.
- */
-celix_status_t dependencyManager_create(bundle_context_pt context, dm_dependency_manager_pt *manager);
-
-/**
- * Destroys the provided dependency manager
- */
-void dependencyManager_destroy(dm_dependency_manager_pt manager);
-
-/**
- * Adds a DM component to the dependency manager
- */
-celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component);
-
-/**
- * Removes all DM components from the dependency manager
- */
-celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager);
-
-/**
- * Create and returns a DM Info struct. Which contains information about the state of the DM components
- * Caller has ownership.
- */
-celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt *info);
-
-/**
- * Destroys a DM info struct.
- */
-void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_DEPENDENCY_MANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/public/include/dm_info.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_info.h b/dependency_manager/public/include/dm_info.h
deleted file mode 100644
index f5e6b47..0000000
--- a/dependency_manager/public/include/dm_info.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_server.h
- *
- *  \date       15 Oct 2015
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-#ifndef CELIX_DM_INFO_SERVICE_H
-#define CELIX_DM_INFO_SERVICE_H
-
-
-
-#include <stdbool.h>
-#include "array_list.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DM_INFO_SERVICE_NAME "dm_info"
-
-
-typedef struct dm_interface_info_struct {
-    char* name;
-    properties_pt properties;
-} * dm_interface_info_pt;
-
-typedef struct dm_service_dependency_info_struct {
-    char *filter;
-    bool available;
-    bool required;
-    size_t count;
-} * dm_service_dependency_info_pt;
-
-typedef struct dm_component_info_struct {
-    char id[64];
-    char name[128];
-    bool active;
-    char * state;
-    array_list_pt interfaces;   // type dm_interface_info_pt
-    array_list_pt dependency_list;  // type dm_service_dependency_info_pt
-} * dm_component_info_pt;
-
-typedef struct dm_dependency_manager_info_struct {
-    array_list_pt  components;      // type dm_component_info
-} * dm_dependency_manager_info_pt;
-
-struct dm_info_service_struct {
-    void *handle;
-
-    /*Note: dm_caller has the ownership of the result.*/
-    celix_status_t (*getInfo)(void *handle, dm_dependency_manager_info_pt *info);
-    void (*destroyInfo)(void *handle, dm_dependency_manager_info_pt info);
-};
-
-typedef struct dm_info_service_struct dm_info_service_t;
-typedef dm_info_service_t* dm_info_service_pt;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //CELIX_DM_INFO_SERVICE_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/public/include/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_service_dependency.h b/dependency_manager/public/include/dm_service_dependency.h
deleted file mode 100644
index fb34230..0000000
--- a/dependency_manager/public/include/dm_service_dependency.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- *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.
- */
-/*
- * dm_service_dependency.h
- *
- *  \date       8 Oct 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef DM_SERVICE_DEPENDENCY_H_
-#define DM_SERVICE_DEPENDENCY_H_
-
-#include "service_reference.h"
-#include "celix_errno.h"
-#include "dm_info.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-typedef struct dm_service_dependency *dm_service_dependency_pt;
-
-typedef enum dm_service_dependency_strategy_enum {
-	DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING,
-	DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
-} dm_service_dependency_strategy_t;
-
-typedef int (*service_set_fpt)(void *handle, const void* service);
-typedef int (*service_add_fpt)(void *handle, const void* service);
-typedef int (*service_change_fpt)(void *handle, const void* service);
-typedef int (*service_remove_fpt)(void *handle, const void* service);
-typedef int (*service_swap_fpt)(void *handle, const void* oldService, const void* newService);
-
-typedef celix_status_t (*service_set_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
-typedef celix_status_t (*service_add_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
-typedef celix_status_t (*service_change_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
-typedef celix_status_t (*service_remove_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
-typedef celix_status_t (*service_swap_with_ref_fpt)(void *handle, service_reference_pt oldReference, const void* oldService, service_reference_pt newReference, const void* newService);
-
-/**
- * Create a service dependency.
- * Caller has ownership.
- */
-celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr);
-
-/**
- * Destroys a service dependency.
- * Caller has ownership.
- */
-celix_status_t serviceDependency_destroy(dm_service_dependency_pt *dependency_ptr);
-
-/**
- * Specify if the service dependency is required. default is false
- */
-celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency, bool required);
-
-/**
- * Specify if the servide dependency should add a C language filter for this dependency if no "service.lang" part if found the in the provided filter.
- * Default is false
- */
-celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_pt dependency, bool addCLangFilter);
-
-
-/**
- * Specify if the service dependency update strategy.
- *
- * The DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING strategy notifies the component in case the dependencies set
- * changes (e.g. a dependency is added/removed): the component is responsible for protecting via locks
- * the dependencies list and check (always under lock) if the service he's depending on is still available.
- *
- * The DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND (default when no strategy is explicitly set) reliefs the programmer
- * from dealing with service dependencies' consistency issues: in case this strategy is adopted, the component
- * is stopped and restarted (i.e. temporarily suspended) upon service dependencies' changes.
- *
- * Default strategy is DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
- */
-celix_status_t serviceDependency_setStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t strategy);
-
-/**
- * Return the service dependency update strategy.
- */
-celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t* strategy);
-
-/**
- * Set the service name, version range and filter.
- *
- * @param serviceName The service name. Must have a value.
- * @param serviceVersionRange The service version range, can be a NULL pointer.
- * @param filter The (additional) filter to use (e.g. "(location=front)"). Can be a NULL pointer.
- */
-celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, const char* serviceName, const char* serviceVersionRange, const char* filter);
-
-/**
- * Returns the service depenendy filter.
- */
-celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, const char** filter);
-
-/**
- * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
- * are (respectively) set, added, changed, removed or swapped.
- * The first argument of the callbacks will be the component implement (@see component_getImplementation)
- * The second the argument a pointer to an instance of a service struct of the specified service dependency.
- */
-celix_status_t serviceDependency_setCallbacks(dm_service_dependency_pt dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap);
-
-/**
- * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
- * are (respectively) set, added, changed, removed or swapped.
- * The first argument of the callbacks will be the component implement (@see component_getImplementation)
- * The second argument of th callbacks will be a pointer to an instance of a service struct of the specified service dependency.
- * The third argument of th callbacks will be a pointer to a service reference of the a service instance of the specified service dependency.
- */
-celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_pt dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove, service_swap_with_ref_fpt swap);
-
-/**
- * Specifies which field member (pointer to) to update when a service dependencies is set.
- * If provided the provided service_lock will be used for locking when updating the service instance.
- */
-celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt dependency, celix_thread_mutex_t *service_lock, const void** field);
-
-#define serviceDependency_setCallbacksSafe(dep, cmpType, servType, set, add, change, remove, swap) \
-	do { \
-		int (*tmpSet)(cmpType, servType) = set; \
-		int (*tmpAdd)(cmpType, servType) = add; \
-		int (*tmpChange)(cmpType, servType) = change; \
-		int (*tmpRemove)(cmpType, servType) = remove; \
-		int (*tmpSwap)(cmpType, servType, servType) = swap; \
-		serviceDependency_setCallbacks((dep), (service_set_fpt)tmpSet, (service_add_fpt)tmpAdd, (service_change_fpt)tmpChange, (service_remove_fpt)tmpRemove, (service_swap_fpt)tmpSwap); \
-	} while(0)
-
-/**
- * Set the callback handle to be used in the callbacks. Note that this normally should not be set, because the
- * result of component_getImplementation() is used
- * This can be used in rare cases when the callbacks are actually interceptors. e.g. in the case of C++ support.
- */
-celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_pt dependency, void* handle);
-
-/**
- * Creates a service dependency info. The service dependency info struct contains information about the service dependency.
- * The caller is the owner
- */
-celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt, dm_service_dependency_info_pt *info);
-
-/**
- * Destroy a provided service dependency info struct.
- */
-void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_SERVICE_DEPENDENCY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/readme.md
----------------------------------------------------------------------
diff --git a/dependency_manager/readme.md b/dependency_manager/readme.md
index 8b9ce71..f60fdea 100644
--- a/dependency_manager/readme.md
+++ b/dependency_manager/readme.md
@@ -114,17 +114,23 @@ celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_depende
 }  
 ```
 
+### References
+
+For more information examples please see
+
+- [The Dependency Manager API](public/include): The dependency manager header files
+- [Getting Started: Using Service with C](../documents/getting_started/using_services_with_c.md): A introduction how to work with services using the dependency manager
+- [Dm example](../examples/dm_example): A DM example.
 
-### Dependency Manager Shell support
+## Dependency Manager Shell support
 
 There is support for retrieving information of the dm components with
 use of the `dm` command. This command will print all known dm component,
 their state, provided interfaces and required interfaces.
 
-### References
 
-For more information examples please see
+## Using info
 
-- [The Dependency Manager API](public/include): The dependency manager header files
-- [Getting Started: Using Service with C](../documents/getting_started/using_services_with_c.md): A introduction how to work with services using the dependency manager
-- [Dm example](../examples/dm_example): A DM example.  
+If the Celix Dependency Manager is installed The `FindCelix.cmake` will set:
+ - The `Celix::dm_shell` bundle target
+ - The `Celix::dependency_manger_static` library target

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/src/dm_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_activator.c b/dependency_manager/src/dm_activator.c
new file mode 100644
index 0000000..8de3bf1
--- /dev/null
+++ b/dependency_manager/src/dm_activator.c
@@ -0,0 +1,119 @@
+/**
+ * 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.
+ */
+
+#include "dm_activator.h"
+
+#include <stdlib.h>
+
+struct dm_dependency_activator_base {
+    dm_dependency_manager_pt manager;
+    bundle_context_pt context;
+    service_registration_pt reg;
+    dm_info_service_pt info;
+    void* userData;
+};
+
+typedef struct dm_dependency_activator_base * dependency_activator_base_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+    celix_status_t status = CELIX_ENOMEM;
+
+    dependency_activator_base_pt dependency_activator = calloc(1, sizeof(struct dm_dependency_activator_base));
+    dm_info_service_pt serv = calloc(1, sizeof(*serv));
+
+    if (dependency_activator != NULL && serv != NULL) {
+        dependency_activator->context = context;
+        dm_create(context, &dependency_activator->userData);
+        dependency_activator->info = serv;
+
+        status = dependencyManager_create(dependency_activator->context, &dependency_activator->manager);
+    } else {
+        status = CELIX_ENOMEM;
+
+    }
+
+    if (status == CELIX_SUCCESS) {
+        *userData = dependency_activator;
+    } else {
+        if (dependency_activator != NULL) {
+            dependencyManager_destroy(dependency_activator->manager);
+        }
+        free(dependency_activator);
+        free(serv);
+    }
+
+    return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+    celix_status_t status;
+    dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
+
+
+    status = dm_init(dependency_activator->userData, context, dependency_activator->manager);
+
+    if (status == CELIX_SUCCESS) {
+        //Create the service
+        dependency_activator->info->handle = dependency_activator->manager;
+        dependency_activator->info->getInfo = (void *) dependencyManager_getInfo;
+        dependency_activator->info->destroyInfo = (void *) dependencyManager_destroyInfo;
+
+        status = bundleContext_registerService(context, DM_INFO_SERVICE_NAME, dependency_activator->info, NULL,
+                                               &(dependency_activator->reg));
+    }
+
+    return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context __attribute__((unused))) {
+    celix_status_t status = CELIX_SUCCESS;
+    dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
+
+    // Remove the service
+    status = serviceRegistration_unregister(dependency_activator->reg);
+    dependencyManager_removeAllComponents(dependency_activator->manager);
+
+    return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context __attribute__((unused))) {
+    celix_status_t status = CELIX_SUCCESS;
+    dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
+
+    if(dependency_activator==NULL){
+        return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    status = dm_destroy(dependency_activator->userData, dependency_activator->context,
+                        dependency_activator->manager);
+
+    if (status == CELIX_SUCCESS) {
+        dependencyManager_destroy(dependency_activator->manager);
+    }
+
+    dependency_activator->userData = NULL;
+    dependency_activator->manager = NULL;
+
+    if (dependency_activator != NULL) {
+        free(dependency_activator->info);
+    }
+    free(dependency_activator);
+
+    return status;
+}
\ No newline at end of file