celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1413494 [2/3] - in /incubator/celix/trunk: dependency_manager/private/src/ dependency_manager/public/include/ deployment_admin/private/include/ deployment_admin/private/src/ device_access/device_access/private/include/ device_access/device...
Date Mon, 26 Nov 2012 07:48:02 GMT
Modified: incubator/celix/trunk/examples/whiteboard/tracker/private/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker/private/src/activator.c?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker/private/src/activator.c (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker/private/src/activator.c Mon Nov 26 07:47:47 2012
@@ -34,7 +34,7 @@
 #include "bundle_context.h"
 
 struct data {
-	BUNDLE_CONTEXT context;
+	bundle_context_t context;
 	service_tracker_t tracker;
 	ARRAY_LIST publishers;
 	pthread_t sender;
@@ -84,7 +84,7 @@ celix_status_t removedServ(void * handle
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundleActivator_create(BUNDLE_CONTEXT context, void **userData) {
+celix_status_t bundleActivator_create(bundle_context_t context, void **userData) {
     apr_pool_t *pool;
     celix_status_t status = bundleContext_getMemoryPool(context, &pool);
     if (status == CELIX_SUCCESS) {
@@ -97,7 +97,7 @@ celix_status_t bundleActivator_create(BU
     return CELIX_SUCCESS;
 }
 
-celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+celix_status_t bundleActivator_start(void * userData, bundle_context_t context) {
     celix_status_t status = CELIX_SUCCESS;
     apr_pool_t *pool;
     status = bundleContext_getMemoryPool(context, &pool);
@@ -128,7 +128,7 @@ celix_status_t bundleActivator_start(voi
     return status;
 }
 
-celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+celix_status_t bundleActivator_stop(void * userData, bundle_context_t context) {
     celix_status_t status = CELIX_SUCCESS;
     printf("Stop\n");
 
@@ -140,7 +140,7 @@ celix_status_t bundleActivator_stop(void
     return status;
 }
 
-celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_t context) {
     celix_status_t status = CELIX_SUCCESS;
     struct data * data = (struct data *) userData;
 

Modified: incubator/celix/trunk/examples/whiteboard/tracker_depman/private/include/tracker.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker_depman/private/include/tracker.h?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker_depman/private/include/tracker.h (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker_depman/private/include/tracker.h Mon Nov 26 07:47:47 2012
@@ -32,7 +32,7 @@
 
 struct data {
 	SERVICE service;
-	BUNDLE_CONTEXT context;
+	bundle_context_t context;
 	ARRAY_LIST publishers;
 	pthread_t sender;
 	bool running;

Modified: incubator/celix/trunk/examples/whiteboard/tracker_depman/private/src/dependency_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker_depman/private/src/dependency_activator.c?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker_depman/private/src/dependency_activator.c (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker_depman/private/src/dependency_activator.c Mon Nov 26 07:47:47 2012
@@ -36,7 +36,7 @@
 #include "log_service.h"
 #include "bundle_context.h"
 
-void * dm_create(BUNDLE_CONTEXT context) {
+void * dm_create(bundle_context_t context) {
 	struct data * data = malloc(sizeof(*data));
 	apr_pool_t *pool = NULL;
 	bundleContext_getMemoryPool(context, &pool);
@@ -50,7 +50,7 @@ void * dm_create(BUNDLE_CONTEXT context)
 	return data;
 }
 
-void dm_init(void * userData, BUNDLE_CONTEXT context, DEPENDENCY_MANAGER manager) {
+void dm_init(void * userData, bundle_context_t context, DEPENDENCY_MANAGER manager) {
 	struct data * data = (struct data *) userData;
 	data->context = context;
 
@@ -73,7 +73,7 @@ void dm_init(void * userData, BUNDLE_CON
 	dependencyManager_add(manager, service);
 }
 
-void dm_destroy(void * userData, BUNDLE_CONTEXT context, DEPENDENCY_MANAGER manager) {
+void dm_destroy(void * userData, bundle_context_t context, DEPENDENCY_MANAGER manager) {
 	struct data * data = (struct data *) userData;
 	dependencyManager_remove(manager, data->service);
 	arrayList_destroy(data->publishers);

Modified: incubator/celix/trunk/framework/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/CMakeLists.txt?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/framework/CMakeLists.txt (original)
+++ incubator/celix/trunk/framework/CMakeLists.txt Mon Nov 26 07:47:47 2012
@@ -22,13 +22,13 @@ if (FRAMEWORK) 
     find_package(CURL REQUIRED)
     find_package(ZLIB REQUIRED)
     
-    include(CPackComponent)
+    #include(CPackComponent)
     
-    cpack_add_component(framework
-    	DISPLAY_NAME Framework
-        DESCRIPTION "The Apache Celix framework library"
-        REQUIRED
-    )
+    #cpack_add_component(framework
+    #	DISPLAY_NAME Framework
+    #    DESCRIPTION "The Apache Celix framework library"
+    #    REQUIRED
+    #)
     
     add_definitions(-DUSE_FILE32API)
     aux_source_directory("private/src" SRC)

Modified: incubator/celix/trunk/framework/private/include/bundle_cache.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle_cache.h?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/bundle_cache.h (original)
+++ incubator/celix/trunk/framework/private/include/bundle_cache.h Mon Nov 26 07:47:47 2012
@@ -38,9 +38,9 @@
 #include "bundle_archive.h"
 
 /**
- * Type definition for the BUNDLE_CACHE abstract data type.
+ * Type definition for the bundle_cache_t abstract data type.
  */
-typedef struct bundleCache * BUNDLE_CACHE;
+typedef struct bundleCache *bundle_cache_t;
 
 /**
  * Creates the bundle cache using the supplied configuration map.
@@ -53,7 +53,7 @@ typedef struct bundleCache * BUNDLE_CACH
  * 		- 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 configurationMap, apr_pool_t *mp, BUNDLE_CACHE *bundle_cache);
+celix_status_t bundleCache_create(PROPERTIES configurationMap, apr_pool_t *mp, bundle_cache_t *bundle_cache);
 
 /**
  * Recreates and retrieves the list of archives for the given bundle cache.
@@ -68,7 +68,7 @@ celix_status_t bundleCache_create(PROPER
  * 		- 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 cache, apr_pool_t *pool, ARRAY_LIST *archives);
+celix_status_t bundleCache_getArchives(bundle_cache_t cache, apr_pool_t *pool, ARRAY_LIST *archives);
 
 /**
  * Creates a new archive for the given bundle (using the id and location). The archive is created on the supplied bundlePool.
@@ -85,7 +85,7 @@ celix_status_t bundleCache_getArchives(B
  * 		- 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 cache, apr_pool_t *bundlePool, long id, char * location, char *inputFile, BUNDLE_ARCHIVE *archive);
+celix_status_t bundleCache_createArchive(bundle_cache_t cache, apr_pool_t *bundlePool, long id, char * location, char *inputFile, bundle_archive_t *archive);
 
 /**
  * Deletes the entire bundle cache.
@@ -96,7 +96,7 @@ celix_status_t bundleCache_createArchive
  * 		- 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 cache);
+celix_status_t bundleCache_delete(bundle_cache_t cache);
 
 /**
  * @}

Added: incubator/celix/trunk/framework/private/include/iowin32.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/iowin32.h?rev=1413494&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/include/iowin32.h (added)
+++ incubator/celix/trunk/framework/private/include/iowin32.h Mon Nov 26 07:47:47 2012
@@ -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

Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Mon Nov 26 07:47:47 2012
@@ -40,11 +40,11 @@
 #include "utils.h"
 
 struct bundle {
-	BUNDLE_CONTEXT context;
+	bundle_context_t context;
 	ACTIVATOR activator;
 	BUNDLE_STATE state;
 	void * handle;
-	BUNDLE_ARCHIVE archive;
+	bundle_archive_t archive;
 	ARRAY_LIST modules;
 	MANIFEST manifest;
 	apr_pool_t *memoryPool;
@@ -61,7 +61,7 @@ celix_status_t bundle_closeRevisions(BUN
 
 celix_status_t bundle_create(BUNDLE * bundle, apr_pool_t *mp) {
     celix_status_t status = CELIX_SUCCESS;
-    BUNDLE_ARCHIVE archive = NULL;
+    bundle_archive_t archive = NULL;
 
 	*bundle = (BUNDLE) apr_palloc(mp, sizeof(**bundle));
 	if (*bundle == NULL) {
@@ -101,7 +101,7 @@ celix_status_t bundle_create(BUNDLE * bu
 	return status;
 }
 
-celix_status_t bundle_createFromArchive(BUNDLE * bundle, FRAMEWORK framework, BUNDLE_ARCHIVE archive, apr_pool_t *bundlePool) {
+celix_status_t bundle_createFromArchive(BUNDLE * bundle, FRAMEWORK framework, bundle_archive_t archive, apr_pool_t *bundlePool) {
     MODULE module;
 	
 	celix_status_t status = CELIX_SUCCESS;
@@ -152,7 +152,7 @@ celix_status_t bundle_destroy(BUNDLE bun
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundle_getArchive(BUNDLE bundle, BUNDLE_ARCHIVE *archive) {
+celix_status_t bundle_getArchive(BUNDLE bundle, bundle_archive_t *archive) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (bundle != NULL && *archive == NULL) {
@@ -197,12 +197,12 @@ celix_status_t bundle_setActivator(BUNDL
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundle_getContext(BUNDLE bundle, BUNDLE_CONTEXT *context) {
+celix_status_t bundle_getContext(BUNDLE bundle, bundle_context_t *context) {
 	*context = bundle->context;
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundle_setContext(BUNDLE bundle, BUNDLE_CONTEXT context) {
+celix_status_t bundle_setContext(BUNDLE bundle, bundle_context_t context) {
 	bundle->context = context;
 	return CELIX_SUCCESS;
 }
@@ -240,7 +240,9 @@ celix_status_t bundle_createModule(BUNDL
         status = bundleArchive_getId(bundle->archive, &bundleId);
         if (status == CELIX_SUCCESS) {
 			int revision = 0;
-			char * moduleId = (char *)malloc(sizeof(bundleId) + sizeof(revision) + 2);
+			apr_pool_t *pool = NULL;
+			apr_pool_create(&pool, bundle->memoryPool);
+			char * moduleId = (char *) apr_palloc(pool, sizeof(bundleId) + sizeof(revision) +2);
 			sprintf(moduleId, "%ld.%d", bundleId, revision);
 
 			*module = module_create(headerMap, apr_pstrdup(bundle->memoryPool, moduleId), bundle);
@@ -281,7 +283,7 @@ celix_status_t bundle_createModule(BUNDL
 					arrayList_destroy(bundles);
 				}
 			}
-			free(moduleId);
+			apr_pool_destroy(pool);
         }
 	}
 
@@ -359,7 +361,7 @@ celix_status_t bundle_isUsed(BUNDLE bund
 celix_status_t bundle_revise(BUNDLE bundle, char * location, char *inputFile) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	BUNDLE_ARCHIVE archive = NULL;
+	bundle_archive_t archive = NULL;
 	status = bundle_getArchive(bundle, &archive);
 	if (status == CELIX_SUCCESS) {
 		status = bundleArchive_revise(archive, location, inputFile);
@@ -394,7 +396,7 @@ celix_status_t bundle_addModule(BUNDLE b
 celix_status_t bundle_isSystemBundle(BUNDLE bundle, bool *systemBundle) {
 	celix_status_t status = CELIX_SUCCESS;
 	long bundleId;
-	BUNDLE_ARCHIVE archive = NULL;
+	bundle_archive_t archive = NULL;
 
 	status = bundle_getArchive(bundle, &archive);
 	if (status == CELIX_SUCCESS) {
@@ -500,7 +502,7 @@ celix_status_t bundle_unlock(BUNDLE bund
 }
 
 celix_status_t bundle_close(BUNDLE bundle) {
-	BUNDLE_ARCHIVE archive = NULL;
+	bundle_archive_t archive = NULL;
 	
 	celix_status_t status = CELIX_SUCCESS;
 
@@ -517,7 +519,7 @@ celix_status_t bundle_close(BUNDLE bundl
 celix_status_t bundle_closeAndDelete(BUNDLE bundle) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	BUNDLE_ARCHIVE archive = NULL;
+	bundle_archive_t archive = NULL;
 
     bundle_closeModules(bundle);
     bundle_closeRevisions(bundle);
@@ -569,7 +571,7 @@ celix_status_t bundle_refresh(BUNDLE bun
 
 celix_status_t bundle_getBundleId(BUNDLE bundle, long *id) {
 	celix_status_t status = CELIX_SUCCESS;
-	BUNDLE_ARCHIVE archive = NULL;
+	bundle_archive_t archive = NULL;
 	status = bundle_getArchive(bundle, &archive);
 	if (status == CELIX_SUCCESS) {
 		status = bundleArchive_getId(archive, id);

Modified: incubator/celix/trunk/framework/private/src/bundle_archive.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_archive.c?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_archive.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_archive.c Mon Nov 26 07:47:47 2012
@@ -52,28 +52,28 @@ struct bundleArchive {
 
 static apr_status_t bundleArchive_destroy(void *archiveP);
 
-static celix_status_t bundleArchive_getRevisionLocation(BUNDLE_ARCHIVE archive, long revNr, char **revision_location);
-static celix_status_t bundleArchive_setRevisionLocation(BUNDLE_ARCHIVE archive, char * location, long revNr);
+static celix_status_t bundleArchive_getRevisionLocation(bundle_archive_t archive, long revNr, char **revision_location);
+static celix_status_t bundleArchive_setRevisionLocation(bundle_archive_t archive, char * location, long revNr);
 
-static celix_status_t bundleArchive_initialize(BUNDLE_ARCHIVE archive);
+static celix_status_t bundleArchive_initialize(bundle_archive_t archive);
 
 static celix_status_t bundleArchive_deleteTree(char * directory, apr_pool_t *mp);
 
-static celix_status_t bundleArchive_createRevisionFromLocation(BUNDLE_ARCHIVE archive, char *location, char *inputFile, long revNr, BUNDLE_REVISION *bundle_revision);
-static celix_status_t bundleArchive_reviseInternal(BUNDLE_ARCHIVE archive, bool isReload, long revNr, char * location, char *inputFile);
+static celix_status_t bundleArchive_createRevisionFromLocation(bundle_archive_t archive, char *location, char *inputFile, long revNr, BUNDLE_REVISION *bundle_revision);
+static celix_status_t bundleArchive_reviseInternal(bundle_archive_t archive, bool isReload, long revNr, char * location, char *inputFile);
 
-static celix_status_t bundleArchive_readLastModified(BUNDLE_ARCHIVE archive, time_t *time);
-static celix_status_t bundleArchive_writeLastModified(BUNDLE_ARCHIVE archive);
+static celix_status_t bundleArchive_readLastModified(bundle_archive_t archive, time_t *time);
+static celix_status_t bundleArchive_writeLastModified(bundle_archive_t archive);
 
-celix_status_t bundleArchive_createSystemBundleArchive(apr_pool_t *mp, BUNDLE_ARCHIVE *bundle_archive) {
+celix_status_t bundleArchive_createSystemBundleArchive(apr_pool_t *mp, bundle_archive_t *bundle_archive) {
     celix_status_t status;
-	BUNDLE_ARCHIVE archive;
+	bundle_archive_t archive;
 	apr_pool_t *revisions_pool;
 
 	if (mp == NULL || *bundle_archive != NULL) {
 	    status = CELIX_ILLEGAL_ARGUMENT;
 	} else {
-        archive = (BUNDLE_ARCHIVE) apr_palloc(mp, sizeof(*archive));
+        archive = (bundle_archive_t) apr_palloc(mp, sizeof(*archive));
         if (archive == NULL) {
             status = CELIX_ENOMEM;
         } else {
@@ -103,15 +103,15 @@ celix_status_t bundleArchive_createSyste
     return status;
 }
 
-celix_status_t bundleArchive_create(char * archiveRoot, long id, char * location, char *inputFile, apr_pool_t *mp, BUNDLE_ARCHIVE *bundle_archive) {
+celix_status_t bundleArchive_create(char * archiveRoot, long id, char * location, char *inputFile, apr_pool_t *mp, bundle_archive_t *bundle_archive) {
     celix_status_t status = CELIX_SUCCESS;
     apr_pool_t *revisions_pool;
-    BUNDLE_ARCHIVE archive;
+    bundle_archive_t archive;
 
     if (*bundle_archive != NULL) {
     	status = CELIX_ILLEGAL_ARGUMENT;
     } else {
-		archive = (BUNDLE_ARCHIVE) apr_pcalloc(mp, sizeof(*archive));
+		archive = (bundle_archive_t) apr_pcalloc(mp, sizeof(*archive));
 		if (archive != NULL) {
 			apr_pool_pre_cleanup_register(mp, archive, bundleArchive_destroy);
 			if (apr_pool_create(&revisions_pool, mp) == APR_SUCCESS) {
@@ -145,7 +145,7 @@ celix_status_t bundleArchive_create(char
 }
 
 static apr_status_t bundleArchive_destroy(void *archiveP) {
-	BUNDLE_ARCHIVE archive = archiveP;
+	bundle_archive_t archive = archiveP;
 	if (archive != NULL) {
 		if (archive->archiveRootDir != NULL) {
 			apr_dir_close(archive->archiveRootDir);
@@ -156,13 +156,13 @@ static apr_status_t bundleArchive_destro
 	return APR_SUCCESS;
 }
 
-celix_status_t bundleArchive_recreate(char * archiveRoot, apr_pool_t *mp, BUNDLE_ARCHIVE *bundle_archive) {
+celix_status_t bundleArchive_recreate(char * archiveRoot, apr_pool_t *mp, bundle_archive_t *bundle_archive) {
     apr_pool_t *revisions_pool;
     celix_status_t status;
-    BUNDLE_ARCHIVE archive;
+    bundle_archive_t archive;
 
     status = CELIX_SUCCESS;
-	archive = (BUNDLE_ARCHIVE) apr_pcalloc(mp, sizeof(*archive));
+	archive = (bundle_archive_t) apr_pcalloc(mp, sizeof(*archive));
 	if (archive != NULL) {
 		apr_pool_pre_cleanup_register(mp, archive, bundleArchive_destroy);
 	    if (apr_pool_create(&revisions_pool, mp) == APR_SUCCESS) {
@@ -213,13 +213,18 @@ celix_status_t bundleArchive_recreate(ch
 	return status;
 }
 
-celix_status_t bundleArchive_getId(BUNDLE_ARCHIVE archive, long *id) {
+celix_status_t bundleArchive_getId(bundle_archive_t archive, long *id) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (archive->id < 0) {
 		apr_file_t *bundleIdFile;
 		apr_status_t rv;
-		char * bundleId = (char *)malloc(strlen(archive->archiveRoot) + 11);
+		char * bundleId = NULL;
+		apr_pool_t *subpool = NULL;
+		apr_pool_create(&subpool, archive->mp);
+
+		bundleId = (char *)apr_palloc(subpool, strlen(archive->archiveRoot) + 11);
+
 		strcpy(bundleId, archive->archiveRoot);
 		strcat(bundleId, "/bundle.id");
 		
@@ -231,7 +236,8 @@ celix_status_t bundleArchive_getId(BUNDL
 			apr_file_close(bundleIdFile);
 			sscanf(id, "%ld", &archive->id);
 		}
-		free(bundleId);
+
+		apr_pool_destroy(subpool);
 	}
 	if (status == CELIX_SUCCESS) {
 		*id = archive->id;
@@ -240,12 +246,16 @@ celix_status_t bundleArchive_getId(BUNDL
 	return status;
 }
 
-celix_status_t bundleArchive_getLocation(BUNDLE_ARCHIVE archive, char **location) {
+celix_status_t bundleArchive_getLocation(bundle_archive_t archive, char **location) {
 	celix_status_t status = CELIX_SUCCESS;
 	if (archive->location == NULL) {
 		apr_file_t *bundleLocationFile;
 		apr_status_t rv;
-		char * bundleLocation = (char *)calloc(sizeof(char), strlen(archive->archiveRoot) + 17);
+		char * bundleLocation = NULL;
+		apr_pool_t *subpool = NULL;
+		apr_pool_create(&subpool, archive->mp);
+
+		bundleLocation = (char *)apr_palloc(subpool, strlen(archive->archiveRoot) + 17);
 		strcat(bundleLocation,archive->archiveRoot);
 		strcat(bundleLocation, "/bundle.location");
 		
@@ -258,7 +268,7 @@ celix_status_t bundleArchive_getLocation
 
 			archive->location = apr_pstrdup(archive->mp, location);
 		}
-		free(bundleLocation);
+		apr_pool_destroy(subpool);
 	}
 
 	if (status == CELIX_SUCCESS) {
@@ -268,12 +278,12 @@ celix_status_t bundleArchive_getLocation
 	return status;
 }
 
-celix_status_t bundleArchive_getArchiveRoot(BUNDLE_ARCHIVE archive, char **archiveRoot) {
+celix_status_t bundleArchive_getArchiveRoot(bundle_archive_t archive, char **archiveRoot) {
 	*archiveRoot = archive->archiveRoot;
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundleArchive_getCurrentRevisionNumber(BUNDLE_ARCHIVE archive, long *revisionNumber) {
+celix_status_t bundleArchive_getCurrentRevisionNumber(bundle_archive_t archive, long *revisionNumber) {
 	celix_status_t status = CELIX_SUCCESS;
 	BUNDLE_REVISION revision;
 	*revisionNumber = -1;
@@ -286,17 +296,17 @@ celix_status_t bundleArchive_getCurrentR
 	return status;
 }
 
-celix_status_t bundleArchive_getCurrentRevision(BUNDLE_ARCHIVE archive, BUNDLE_REVISION *revision) {
+celix_status_t bundleArchive_getCurrentRevision(bundle_archive_t archive, BUNDLE_REVISION *revision) {
 	*revision = linkedList_isEmpty(archive->revisions) ? NULL : linkedList_getLast(archive->revisions);
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundleArchive_getRevision(BUNDLE_ARCHIVE archive, long revNr, BUNDLE_REVISION *revision) {
+celix_status_t bundleArchive_getRevision(bundle_archive_t archive, long revNr, BUNDLE_REVISION *revision) {
 	*revision = linkedList_get(archive->revisions, revNr);
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundleArchive_getPersistentState(BUNDLE_ARCHIVE archive, BUNDLE_STATE *state) {
+celix_status_t bundleArchive_getPersistentState(bundle_archive_t archive, BUNDLE_STATE *state) {
 	celix_status_t status = CELIX_SUCCESS;
 	apr_status_t apr_status;
 
@@ -304,8 +314,11 @@ celix_status_t bundleArchive_getPersiste
 		*state = archive->persistentState;
 	} else {
 		apr_file_t *persistentStateLocationFile;
+		char * persistentStateLocation = NULL;
+		apr_pool_t *subpool;
+		apr_pool_create(&subpool, archive->mp);
 		
-		char * persistentStateLocation = malloc(strlen(archive->archiveRoot) + 14);
+		persistentStateLocation = apr_palloc(subpool, strlen(archive->archiveRoot) + 14);
 		strcpy(persistentStateLocation, archive->archiveRoot);
 		strcat(persistentStateLocation, "/bundle.state");
 		
@@ -329,18 +342,21 @@ celix_status_t bundleArchive_getPersiste
 
 			*state = archive->persistentState;
 		}
-		free(persistentStateLocation);
+		apr_pool_destroy(subpool);
 	}
 
 	return status;
 }
 
-celix_status_t bundleArchive_setPersistentState(BUNDLE_ARCHIVE archive, BUNDLE_STATE state) {
+celix_status_t bundleArchive_setPersistentState(bundle_archive_t archive, BUNDLE_STATE state) {
 	celix_status_t status = CELIX_SUCCESS;
 	apr_status_t apr_status;
+	char * persistentStateLocation = NULL;
 	apr_file_t *persistentStateLocationFile;
+	apr_pool_t *subpool = NULL;
+	apr_pool_create(&subpool, archive->mp);
 	
-	char * persistentStateLocation = (char *)malloc(strlen(archive->archiveRoot) + 14);
+	persistentStateLocation = (char *)apr_palloc(subpool, strlen(archive->archiveRoot) + 14);
 	strcpy(persistentStateLocation, archive->archiveRoot);
 	strcat(persistentStateLocation, "/bundle.state");
 	
@@ -368,18 +384,21 @@ celix_status_t bundleArchive_setPersiste
 
 		archive->persistentState = state;
 	}
-	free(persistentStateLocation);
+	apr_pool_destroy(subpool);
 	return status;
 }
 
-celix_status_t bundleArchive_getRefreshCount(BUNDLE_ARCHIVE archive, long *refreshCount) {
+celix_status_t bundleArchive_getRefreshCount(bundle_archive_t archive, long *refreshCount) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (archive->refreshCount == -1) {
 		apr_file_t * refreshCounterFile;
 		apr_status_t rv;
+		apr_pool_t *subpool;
+		apr_pool_create(&subpool, archive->mp);
 		
-		char * refreshCounter = (char *)malloc(strlen(archive->archiveRoot) + 17);
+		char * refreshCounter = NULL;
+		refreshCounter = (char *) apr_palloc(subpool, strlen(archive->archiveRoot) + 17);
 		strcpy(refreshCounter,archive->archiveRoot);
 		strcat(refreshCounter, "/refresh.counter");
 		
@@ -391,7 +410,7 @@ celix_status_t bundleArchive_getRefreshC
 			apr_file_close(refreshCounterFile);
 			sscanf(counterStr, "%ld", &archive->refreshCount);
 		}
-		free(refreshCounter);
+		apr_pool_destroy(subpool);
 	}
 
 	if (status == CELIX_SUCCESS) {
@@ -401,16 +420,21 @@ celix_status_t bundleArchive_getRefreshC
 	return status;
 }
 
-celix_status_t bundleArchive_setRefreshCount(BUNDLE_ARCHIVE archive) {
+celix_status_t bundleArchive_setRefreshCount(bundle_archive_t archive) {
 	apr_file_t * refreshCounterFile;
 	apr_status_t apr_status;
 	celix_status_t status = CELIX_SUCCESS;
-	char * refreshCounter = (char *)malloc(strlen(archive->archiveRoot) + 17);
+	apr_pool_t *subpool;
+	char * refreshCounter = NULL;
+
+	apr_pool_create(&subpool, archive->mp);
+	refreshCounter = (char *) apr_palloc(subpool, strlen(archive->archiveRoot) + 17);
+
 	strcpy(refreshCounter, archive->archiveRoot);
 	strcat(refreshCounter, "/refresh.counter");
 	
 	apr_status = apr_file_open(&refreshCounterFile, refreshCounter, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
-	free(refreshCounter);
+	apr_pool_destroy(subpool);
 	if (apr_status != APR_SUCCESS) {
 		status = CELIX_FILE_IO_EXCEPTION;
 	} else {
@@ -421,7 +445,7 @@ celix_status_t bundleArchive_setRefreshC
 	return status;
 }
 
-celix_status_t bundleArchive_getLastModified(BUNDLE_ARCHIVE archive, time_t *lastModified) {
+celix_status_t bundleArchive_getLastModified(bundle_archive_t archive, time_t *lastModified) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (archive->lastModified == (time_t) NULL) {
@@ -435,7 +459,7 @@ celix_status_t bundleArchive_getLastModi
 	return status;
 }
 
-celix_status_t bundleArchive_setLastModified(BUNDLE_ARCHIVE archive, time_t lastModifiedTime) {
+celix_status_t bundleArchive_setLastModified(bundle_archive_t archive, time_t lastModifiedTime) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	archive->lastModified = lastModifiedTime;
@@ -444,18 +468,22 @@ celix_status_t bundleArchive_setLastModi
 	return status;
 }
 
-static celix_status_t bundleArchive_readLastModified(BUNDLE_ARCHIVE archive, time_t *time) {
+static celix_status_t bundleArchive_readLastModified(bundle_archive_t archive, time_t *time) {
 	char timeStr[20];
 	apr_file_t *lastModifiedFile;
 	apr_status_t apr_status;
+	char *lastModified = NULL;
 
 	celix_status_t status = CELIX_SUCCESS;
 
-	char * lastModified = (char *)malloc(strlen(archive->archiveRoot) + 21);
+	apr_pool_t *subpool = NULL;
+	apr_pool_create(&subpool, archive->mp);
+
+	lastModified = (char *)apr_palloc(subpool, strlen(archive->archiveRoot) + 21);
 	sprintf(lastModified, "%s/bundle.lastmodified", archive->archiveRoot);
 
 	apr_status = apr_file_open(&lastModifiedFile, lastModified, APR_FOPEN_READ, APR_OS_DEFAULT, archive->mp);
-	free(lastModified);
+	apr_pool_destroy(subpool);
 	if (apr_status != APR_SUCCESS) {
 		status = CELIX_FILE_IO_EXCEPTION;
 	} else {
@@ -479,18 +507,24 @@ static celix_status_t bundleArchive_read
 	return status;
 }
 
-static celix_status_t bundleArchive_writeLastModified(BUNDLE_ARCHIVE archive) {
+static celix_status_t bundleArchive_writeLastModified(bundle_archive_t archive) {
 	celix_status_t status = CELIX_SUCCESS;
 	apr_file_t *lastModifiedFile;
 	char timeStr[20];
-	char * lastModified = (char *)malloc(strlen(archive->archiveRoot) + 21);
+	char * lastModified = NULL;
+	apr_pool_t *subpool = NULL;
 	apr_status_t apr_status;
 
+	apr_pool_create(&subpool, archive->mp);
+
+	lastModified = (char *)apr_palloc(subpool, strlen(archive->archiveRoot) + 21);
+
+
 	sprintf(lastModified, "%s/bundle.lastmodified", archive->archiveRoot);	
 	strftime(timeStr, 20, "%Y %m %d %H:%M:%S", localtime(&archive->lastModified));
 	
 	apr_status = apr_file_open(&lastModifiedFile, lastModified, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
-	free(lastModified);
+	apr_pool_destroy(subpool);
 	if (apr_status != APR_SUCCESS) {
 		status = CELIX_FILE_IO_EXCEPTION;
 	} else {
@@ -501,7 +535,7 @@ static celix_status_t bundleArchive_writ
 	return status;
 }
 
-celix_status_t bundleArchive_revise(BUNDLE_ARCHIVE archive, char * location, char *inputFile) {
+celix_status_t bundleArchive_revise(bundle_archive_t archive, char * location, char *inputFile) {
 	celix_status_t status = CELIX_SUCCESS;
 	long revNr = 0l;
 	if (!linkedList_isEmpty(archive->revisions)) {
@@ -515,7 +549,7 @@ celix_status_t bundleArchive_revise(BUND
 	return status;
 }
 
-static celix_status_t bundleArchive_reviseInternal(BUNDLE_ARCHIVE archive, bool isReload, long revNr, char * location, char *inputFile) {
+static celix_status_t bundleArchive_reviseInternal(bundle_archive_t archive, bool isReload, long revNr, char * location, char *inputFile) {
     celix_status_t status;
     BUNDLE_REVISION revision = NULL;
 
@@ -536,12 +570,12 @@ static celix_status_t bundleArchive_revi
 	return status;
 }
 
-celix_status_t bundleArchive_rollbackRevise(BUNDLE_ARCHIVE archive, bool *rolledback) {
+celix_status_t bundleArchive_rollbackRevise(bundle_archive_t archive, bool *rolledback) {
 	*rolledback = true;
 	return CELIX_SUCCESS;
 }
 
-static celix_status_t bundleArchive_createRevisionFromLocation(BUNDLE_ARCHIVE archive, char *location, char *inputFile, long revNr, BUNDLE_REVISION *bundle_revision) {
+static celix_status_t bundleArchive_createRevisionFromLocation(bundle_archive_t archive, char *location, char *inputFile, long revNr, BUNDLE_REVISION *bundle_revision) {
     celix_status_t status = CELIX_SUCCESS;
     char root[256];
     long refreshCount;
@@ -570,7 +604,7 @@ static celix_status_t bundleArchive_crea
 	return status;
 }
 
-static celix_status_t bundleArchive_getRevisionLocation(BUNDLE_ARCHIVE archive, long revNr, char **revision_location) {
+static celix_status_t bundleArchive_getRevisionLocation(bundle_archive_t archive, long revNr, char **revision_location) {
     celix_status_t status;
 	char revisionLocation[256];
 	long refreshCount;
@@ -598,7 +632,7 @@ static celix_status_t bundleArchive_getR
 	return status;
 }
 
-static celix_status_t bundleArchive_setRevisionLocation(BUNDLE_ARCHIVE archive, char * location, long revNr) {
+static celix_status_t bundleArchive_setRevisionLocation(bundle_archive_t archive, char * location, long revNr) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	char revisionLocation[256];
@@ -621,13 +655,13 @@ static celix_status_t bundleArchive_setR
 	return status;
 }
 
-celix_status_t bundleArchive_close(BUNDLE_ARCHIVE archive) {
+celix_status_t bundleArchive_close(bundle_archive_t archive) {
 	// close revision
 	// not yet needed/possible
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundleArchive_closeAndDelete(BUNDLE_ARCHIVE archive) {
+celix_status_t bundleArchive_closeAndDelete(bundle_archive_t archive) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	status = bundleArchive_close(archive);
@@ -638,7 +672,7 @@ celix_status_t bundleArchive_closeAndDel
 	return status;
 }
 
-static celix_status_t bundleArchive_initialize(BUNDLE_ARCHIVE archive) {
+static celix_status_t bundleArchive_initialize(bundle_archive_t archive) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (archive->archiveRootDir == NULL) {
@@ -668,8 +702,10 @@ static celix_status_t bundleArchive_init
 					apr_file_printf(bundleIdFile, "%ld", archive->id);
 					// Ignore close status, let it fail if needed again
 					apr_file_close(bundleIdFile);
+					apr_pool_t *subpool = NULL;
+					apr_pool_create(&subpool, archive->mp);
 
-					bundleLocation = (char *)malloc(strlen(archive->archiveRoot) + 17);
+					bundleLocation = (char *) apr_palloc(subpool, strlen(archive->archiveRoot) + 17);
 					strcpy(bundleLocation,archive->archiveRoot);
 					strcat(bundleLocation, "/bundle.location");
 					
@@ -683,7 +719,7 @@ static celix_status_t bundleArchive_init
 
 						status = bundleArchive_writeLastModified(archive);
 					}
-					free(bundleLocation);
+					apr_pool_destroy(subpool);
 				}
 			}
 		}
@@ -704,7 +740,13 @@ static celix_status_t bundleArchive_dele
 		apr_status_t apr_status;
 		while ((apr_status = apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) == APR_SUCCESS) {
 			if ((strcmp((dp.name), ".") != 0) && (strcmp((dp.name), "..") != 0)) {
-				char * subdir = (char *)malloc(strlen(directory) + strlen(dp.name) + 2);
+				apr_pool_t *subpool;
+				char * subdir = NULL;
+
+				apr_pool_create(&subpool, mp);
+
+				subdir = (char *) apr_palloc(subpool, strlen(directory) + strlen(dp.name) + 2);
+
 				strcpy(subdir, directory);
 				strcat(subdir, "/");
 				strcat(subdir, dp.name);
@@ -718,7 +760,7 @@ static celix_status_t bundleArchive_dele
 						break;
 					}
 				}
-				free(subdir);
+				apr_pool_destroy(subpool);
 			}
 		}
 		if (apr_status != APR_SUCCESS && apr_status != APR_ENOENT) {

Modified: incubator/celix/trunk/framework/private/src/bundle_cache.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_cache.c?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_cache.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_cache.c Mon Nov 26 07:47:47 2012
@@ -46,11 +46,11 @@ struct bundleCache {
 static celix_status_t bundleCache_deleteTree(char * directory, apr_pool_t *mp);
 static apr_status_t bundleCache_destroy(void *cacheP);
 
-celix_status_t bundleCache_create(PROPERTIES configurationMap, apr_pool_t *mp, BUNDLE_CACHE *bundle_cache) {
+celix_status_t bundleCache_create(PROPERTIES configurationMap, apr_pool_t *mp, bundle_cache_t *bundle_cache) {
     celix_status_t status;
-    BUNDLE_CACHE cache;
+   bundle_cache_t cache;
 
-	cache = (BUNDLE_CACHE) apr_palloc(mp, (sizeof(*cache)));
+	cache = (bundle_cache_t) apr_palloc(mp, (sizeof(*cache)));
     if (cache == NULL) {
         status = CELIX_ENOMEM;
     } else {
@@ -76,16 +76,16 @@ celix_status_t bundleCache_create(PROPER
 }
 
 apr_status_t bundleCache_destroy(void *cacheP) {
-	BUNDLE_CACHE cache = cacheP;
+	bundle_cache_t cache = cacheP;
     properties_destroy(cache->configurationMap);
     return CELIX_SUCCESS;
 }
 
-celix_status_t bundleCache_delete(BUNDLE_CACHE cache) {
+celix_status_t bundleCache_delete(bundle_cache_t cache) {
 	return bundleCache_deleteTree(cache->cacheDir, cache->mp);
 }
 
-celix_status_t bundleCache_getArchives(BUNDLE_CACHE cache, apr_pool_t *pool, ARRAY_LIST *archives) {
+celix_status_t bundleCache_getArchives(bundle_cache_t cache, apr_pool_t *pool, ARRAY_LIST *archives) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	apr_dir_t *dir;
@@ -102,7 +102,11 @@ celix_status_t bundleCache_getArchives(B
         arrayList_create(pool, &list);
         
         while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) == APR_SUCCESS) {
-            char * archiveRoot = (char *)malloc(strlen(cache->cacheDir) + strlen(dp.name) + 2);
+        	apr_pool_t *subpool = NULL;
+        	apr_pool_create(&subpool, pool);
+
+        	char * archiveRoot = (char *)apr_palloc(subpool, strlen(cache->cacheDir) + strlen(dp.name) + 2);
+
             strcpy(archiveRoot, cache->cacheDir);
             strcat(archiveRoot, "/");
             strcat(archiveRoot, dp.name);
@@ -113,13 +117,13 @@ celix_status_t bundleCache_getArchives(B
                     && (strncmp(dp.name, "bundle", 6) == 0)
                     && (strcmp(dp.name, "bundle0") != 0)) {
 
-                BUNDLE_ARCHIVE archive = NULL;
+                bundle_archive_t archive = NULL;
                 status = bundleArchive_recreate(apr_pstrdup(cache->mp, archiveRoot), cache->mp, &archive);
                 if (status == CELIX_SUCCESS) {
                     arrayList_add(list, archive);
                 }
             }
-			free(archiveRoot);
+			apr_pool_destroy(subpool);
         }
 
         apr_dir_close(dir);
@@ -134,10 +138,10 @@ celix_status_t bundleCache_getArchives(B
 	return status;
 }
 
-celix_status_t bundleCache_createArchive(BUNDLE_CACHE cache, apr_pool_t *bundlePool, long id, char * location, char *inputFile, BUNDLE_ARCHIVE *bundle_archive) {
+celix_status_t bundleCache_createArchive(bundle_cache_t cache, apr_pool_t *bundlePool, long id, char * location, char *inputFile, bundle_archive_t *bundle_archive) {
     celix_status_t status;
 	char *archiveRoot;
-    BUNDLE_ARCHIVE archive;
+    bundle_archive_t archive;
 
 	if (cache && location && bundlePool) {
 		archiveRoot = apr_psprintf(bundlePool, "%s/bundle%ld",  cache->cacheDir, id);

Modified: incubator/celix/trunk/framework/private/src/bundle_context.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_context.c?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_context.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_context.c Mon Nov 26 07:47:47 2012
@@ -37,49 +37,45 @@ struct bundleContext {
 	apr_pool_t *pool;
 };
 
-celix_status_t bundleContext_create(FRAMEWORK framework, BUNDLE bundle, BUNDLE_CONTEXT *bundle_context) {
+celix_status_t bundleContext_create(FRAMEWORK framework, BUNDLE bundle, bundle_context_t *bundle_context) {
 	celix_status_t status = CELIX_SUCCESS;
-	BUNDLE_CONTEXT context = NULL;
+	bundle_context_t context = NULL;
 
-	if (*bundle_context == NULL) {
-	    context = malloc(sizeof(*context));
-
-		if (context != NULL) {
-			apr_pool_t *pool = NULL;
-
-            context->pool = NULL;
-			context->framework = framework;
-			context->bundle = bundle;
+	if (*bundle_context != NULL && framework == NULL && bundle == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		apr_pool_t *pool = NULL;
 
-			status = bundle_getMemoryPool(bundle, &pool);
-			if (status == CELIX_SUCCESS) {
-				if (apr_pool_create(&context->pool, pool) != APR_SUCCESS) {
+		status = bundle_getMemoryPool(bundle, &pool);
+		if (status == CELIX_SUCCESS) {
+			apr_pool_t *contextPool = NULL;
+			if (apr_pool_create(&contextPool, pool) != APR_SUCCESS) {
+				status = CELIX_ENOMEM;
+			} else {
+				context = apr_palloc(contextPool, sizeof(*context));
+				if (!context) {
 					status = CELIX_ENOMEM;
-				}
+				} else {
+					context->pool = contextPool;
+					context->framework = framework;
+					context->bundle = bundle;
 
-				*bundle_context = context;
+					*bundle_context = context;
+				}
 			}
-		} else {
-			status = CELIX_ENOMEM;
 		}
-	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
+
 	}
 
 	return status;
 }
 
-celix_status_t bundleContext_destroy(BUNDLE_CONTEXT context) {
+celix_status_t bundleContext_destroy(bundle_context_t context) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (context != NULL) {
-		if (context->pool) {
-			apr_pool_destroy(context->pool);
-		    context->pool = NULL;
-		}
-		context->bundle = NULL;
-		context->framework = NULL;
-		free(context);
+		apr_pool_t *contextPool = context->pool;
+		apr_pool_destroy(context->pool);
 		context = NULL;
 	} else {
 		status = CELIX_ILLEGAL_ARGUMENT;
@@ -88,7 +84,7 @@ celix_status_t bundleContext_destroy(BUN
 	return status;
 }
 
-celix_status_t bundleContext_getBundle(BUNDLE_CONTEXT context, BUNDLE *bundle) {
+celix_status_t bundleContext_getBundle(bundle_context_t context, BUNDLE *bundle) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (context == NULL) {
@@ -100,7 +96,7 @@ celix_status_t bundleContext_getBundle(B
 	return status;
 }
 
-celix_status_t bundleContext_getFramework(BUNDLE_CONTEXT context, FRAMEWORK *framework) {
+celix_status_t bundleContext_getFramework(bundle_context_t context, FRAMEWORK *framework) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (context == NULL) {
@@ -112,7 +108,7 @@ celix_status_t bundleContext_getFramewor
 	return status;
 }
 
-celix_status_t bundleContext_getMemoryPool(BUNDLE_CONTEXT context, apr_pool_t **memory_pool) {
+celix_status_t bundleContext_getMemoryPool(bundle_context_t context, apr_pool_t **memory_pool) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (context == NULL) {
@@ -124,11 +120,11 @@ celix_status_t bundleContext_getMemoryPo
 	return status;
 }
 
-celix_status_t bundleContext_installBundle(BUNDLE_CONTEXT context, char * location, BUNDLE *bundle) {
+celix_status_t bundleContext_installBundle(bundle_context_t context, char * location, BUNDLE *bundle) {
 	return bundleContext_installBundle2(context, location, NULL, bundle);
 }
 
-celix_status_t bundleContext_installBundle2(BUNDLE_CONTEXT context, char * location, char *inputFile, BUNDLE *bundle) {
+celix_status_t bundleContext_installBundle2(bundle_context_t context, char * location, char *inputFile, BUNDLE *bundle) {
 	celix_status_t status = CELIX_SUCCESS;
 	BUNDLE b = NULL;
 
@@ -145,7 +141,7 @@ celix_status_t bundleContext_installBund
 	return status;
 }
 
-celix_status_t bundleContext_registerService(BUNDLE_CONTEXT context, char * serviceName, void * svcObj,
+celix_status_t bundleContext_registerService(bundle_context_t context, char * serviceName, void * svcObj,
         PROPERTIES properties, SERVICE_REGISTRATION *service_registration) {
 	SERVICE_REGISTRATION registration = NULL;
 	celix_status_t status = CELIX_SUCCESS;
@@ -160,7 +156,7 @@ celix_status_t bundleContext_registerSer
 	return status;
 }
 
-celix_status_t bundleContext_registerServiceFactory(BUNDLE_CONTEXT context, char * serviceName, service_factory_t factory,
+celix_status_t bundleContext_registerServiceFactory(bundle_context_t context, char * serviceName, service_factory_t factory,
         PROPERTIES properties, SERVICE_REGISTRATION *service_registration) {
     SERVICE_REGISTRATION registration = NULL;
     celix_status_t status = CELIX_SUCCESS;
@@ -175,7 +171,7 @@ celix_status_t bundleContext_registerSer
     return status;
 }
 
-celix_status_t bundleContext_getServiceReferences(BUNDLE_CONTEXT context, const char * serviceName, char * filter, ARRAY_LIST *service_references) {
+celix_status_t bundleContext_getServiceReferences(bundle_context_t context, const char * serviceName, char * filter, ARRAY_LIST *service_references) {
     celix_status_t status = CELIX_SUCCESS;
 
     if (context != NULL && *service_references == NULL) {
@@ -187,7 +183,7 @@ celix_status_t bundleContext_getServiceR
 	return status;
 }
 
-celix_status_t bundleContext_getServiceReference(BUNDLE_CONTEXT context, char * serviceName, SERVICE_REFERENCE *service_reference) {
+celix_status_t bundleContext_getServiceReference(bundle_context_t context, char * serviceName, SERVICE_REFERENCE *service_reference) {
     SERVICE_REFERENCE reference = NULL;
     ARRAY_LIST services = NULL;
     celix_status_t status = CELIX_SUCCESS;
@@ -207,7 +203,7 @@ celix_status_t bundleContext_getServiceR
 	return status;
 }
 
-celix_status_t bundleContext_getService(BUNDLE_CONTEXT context, SERVICE_REFERENCE reference, void **service_instance) {
+celix_status_t bundleContext_getService(bundle_context_t context, SERVICE_REFERENCE reference, void **service_instance) {
     celix_status_t status = CELIX_SUCCESS;
 
     if (context != NULL && reference != NULL && *service_instance == NULL) {
@@ -219,7 +215,7 @@ celix_status_t bundleContext_getService(
     return status;
 }
 
-celix_status_t bundleContext_ungetService(BUNDLE_CONTEXT context, SERVICE_REFERENCE reference, bool *result) {
+celix_status_t bundleContext_ungetService(bundle_context_t context, SERVICE_REFERENCE reference, bool *result) {
     celix_status_t status = CELIX_SUCCESS;
 
     if (context != NULL && reference != NULL) {
@@ -231,7 +227,7 @@ celix_status_t bundleContext_ungetServic
     return status;
 }
 
-celix_status_t bundleContext_getBundles(BUNDLE_CONTEXT context, ARRAY_LIST *bundles) {
+celix_status_t bundleContext_getBundles(bundle_context_t context, ARRAY_LIST *bundles) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (context == NULL || *bundles != NULL) {
@@ -243,7 +239,7 @@ celix_status_t bundleContext_getBundles(
 	return status;
 }
 
-celix_status_t bundleContext_getBundleById(BUNDLE_CONTEXT context, long id, BUNDLE *bundle) {
+celix_status_t bundleContext_getBundleById(bundle_context_t context, long id, BUNDLE *bundle) {
     celix_status_t status = CELIX_SUCCESS;
 
     if (context == NULL || *bundle != NULL) {
@@ -255,7 +251,7 @@ celix_status_t bundleContext_getBundleBy
 	return status;
 }
 
-celix_status_t bundleContext_addServiceListener(BUNDLE_CONTEXT context, SERVICE_LISTENER listener, char * filter) {
+celix_status_t bundleContext_addServiceListener(bundle_context_t context, SERVICE_LISTENER listener, char * filter) {
     celix_status_t status = CELIX_SUCCESS;
 
     if (context != NULL && listener != NULL) {
@@ -267,7 +263,7 @@ celix_status_t bundleContext_addServiceL
     return status;
 }
 
-celix_status_t bundleContext_removeServiceListener(BUNDLE_CONTEXT context, SERVICE_LISTENER listener) {
+celix_status_t bundleContext_removeServiceListener(bundle_context_t context, SERVICE_LISTENER listener) {
     celix_status_t status = CELIX_SUCCESS;
 
     if (context != NULL && listener != NULL) {
@@ -279,7 +275,7 @@ celix_status_t bundleContext_removeServi
     return status;
 }
 
-celix_status_t bundleContext_addBundleListener(BUNDLE_CONTEXT context, bundle_listener_t listener) {
+celix_status_t bundleContext_addBundleListener(bundle_context_t context, bundle_listener_t listener) {
     celix_status_t status = CELIX_SUCCESS;
 
     if (context != NULL && listener != NULL) {
@@ -291,7 +287,7 @@ celix_status_t bundleContext_addBundleLi
     return status;
 }
 
-celix_status_t bundleContext_removeBundleListener(BUNDLE_CONTEXT context, bundle_listener_t listener) {
+celix_status_t bundleContext_removeBundleListener(bundle_context_t context, bundle_listener_t listener) {
     celix_status_t status = CELIX_SUCCESS;
 
     if (context != NULL && listener != NULL) {
@@ -303,7 +299,7 @@ celix_status_t bundleContext_removeBundl
     return status;
 }
 
-celix_status_t bundleContext_getProperty(BUNDLE_CONTEXT context, const char *name, char **value) {
+celix_status_t bundleContext_getProperty(bundle_context_t context, const char *name, char **value) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (context == NULL || name == NULL || *value != NULL) {

Modified: incubator/celix/trunk/framework/private/src/filter.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/filter.c?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/filter.c (original)
+++ incubator/celix/trunk/framework/private/src/filter.c Mon Nov 26 07:47:47 2012
@@ -53,18 +53,18 @@ struct filter {
 };
 
 void filter_skipWhiteSpace(char * filterString, int * pos);
-FILTER filter_parseFilter(char * filterString, int * pos, apr_pool_t *pool);
-FILTER filter_parseFilterComp(char * filterString, int * pos, apr_pool_t *pool);
-FILTER filter_parseAnd(char * filterString, int * pos, apr_pool_t *pool);
-FILTER filter_parseOr(char * filterString, int * pos, apr_pool_t *pool);
-FILTER filter_parseNot(char * filterString, int * pos, apr_pool_t *pool);
-FILTER filter_parseItem(char * filterString, int * pos, apr_pool_t *pool);
+filter_t filter_parseFilter(char * filterString, int * pos, apr_pool_t *pool);
+filter_t filter_parseFilterComp(char * filterString, int * pos, apr_pool_t *pool);
+filter_t filter_parseAnd(char * filterString, int * pos, apr_pool_t *pool);
+filter_t filter_parseOr(char * filterString, int * pos, apr_pool_t *pool);
+filter_t filter_parseNot(char * filterString, int * pos, apr_pool_t *pool);
+filter_t filter_parseItem(char * filterString, int * pos, apr_pool_t *pool);
 char * filter_parseAttr(char * filterString, int * pos);
 char * filter_parseValue(char * filterString, int * pos);
 ARRAY_LIST filter_parseSubstring(char * filterString, int * pos, apr_pool_t *pool);
 
-int filter_compare(OPERAND operand, char * string, void * value2);
-int filter_compareString(OPERAND operand, char * string, void * value2);
+celix_status_t filter_compare(OPERAND operand, char * string, void * value2, bool *result);
+celix_status_t filter_compareString(OPERAND operand, char * string, void * value2, bool *result);
 
 void filter_skipWhiteSpace(char * filterString, int * pos) {
 	int length;
@@ -73,8 +73,8 @@ void filter_skipWhiteSpace(char * filter
 	}
 }
 
-FILTER filter_create(char * filterString, apr_pool_t *pool) {
-	FILTER filter = NULL;
+filter_t filter_create(char * filterString, apr_pool_t *pool) {
+	filter_t filter = NULL;
 	int pos = 0;
 	filter = filter_parseFilter(filterString, &pos, pool);
 	if (pos != strlen(filterString)) {
@@ -85,7 +85,7 @@ FILTER filter_create(char * filterString
 	return filter;
 }
 
-void filter_destroy(FILTER filter) {
+void filter_destroy(filter_t filter) {
 	if (filter != NULL) {
 		if (filter->operand == SUBSTRING) {
 			arrayList_clear(filter->value);
@@ -95,7 +95,7 @@ void filter_destroy(FILTER filter) {
 			int size = arrayList_size(filter->value);
 			int i = 0;
 			for (i = 0; i < size; i++) {
-				FILTER f = arrayList_get(filter->value, i);
+				filter_t f = arrayList_get(filter->value, i);
 				filter_destroy(f);
 			}
 			arrayList_destroy(filter->value);
@@ -111,8 +111,8 @@ void filter_destroy(FILTER filter) {
 	}
 }
 
-FILTER filter_parseFilter(char * filterString, int * pos, apr_pool_t *pool) {
-	FILTER filter;
+filter_t filter_parseFilter(char * filterString, int * pos, apr_pool_t *pool) {
+	filter_t filter;
 	filter_skipWhiteSpace(filterString, pos);
 	if (filterString[*pos] != '(') {
 		printf("Error: Missing '('\n");
@@ -134,7 +134,7 @@ FILTER filter_parseFilter(char * filterS
 	return filter;
 }
 
-FILTER filter_parseFilterComp(char * filterString, int * pos, apr_pool_t *pool) {
+filter_t filter_parseFilterComp(char * filterString, int * pos, apr_pool_t *pool) {
 	char c;
 	filter_skipWhiteSpace(filterString, pos);
 
@@ -157,8 +157,8 @@ FILTER filter_parseFilterComp(char * fil
 	return filter_parseItem(filterString, pos, pool);
 }
 
-FILTER filter_parseAnd(char * filterString, int * pos, apr_pool_t *pool) {
-	FILTER filter = (FILTER) malloc(sizeof(*filter));
+filter_t filter_parseAnd(char * filterString, int * pos, apr_pool_t *pool) {
+	filter_t filter = (filter_t) malloc(sizeof(*filter));
 	ARRAY_LIST operands = NULL;
 	arrayList_create(pool, &operands);
 	filter_skipWhiteSpace(filterString, pos);
@@ -169,7 +169,7 @@ FILTER filter_parseAnd(char * filterStri
 	}
 
 	while(filterString[*pos] == '(') {
-		FILTER child = filter_parseFilter(filterString, pos, pool);
+		filter_t child = filter_parseFilter(filterString, pos, pool);
 		arrayList_add(operands, child);
 	}
 
@@ -180,8 +180,8 @@ FILTER filter_parseAnd(char * filterStri
 	return filter;
 }
 
-FILTER filter_parseOr(char * filterString, int * pos, apr_pool_t *pool) {
-	FILTER filter = (FILTER) malloc(sizeof(*filter));
+filter_t filter_parseOr(char * filterString, int * pos, apr_pool_t *pool) {
+	filter_t filter = (filter_t) malloc(sizeof(*filter));
 	ARRAY_LIST operands = NULL;
 	arrayList_create(pool, &operands);
 	filter_skipWhiteSpace(filterString, pos);
@@ -192,7 +192,7 @@ FILTER filter_parseOr(char * filterStrin
 	}
 
 	while(filterString[*pos] == '(') {
-		FILTER child = filter_parseFilter(filterString, pos, pool);
+		filter_t child = filter_parseFilter(filterString, pos, pool);
 		arrayList_add(operands, child);
 	}
 
@@ -203,9 +203,9 @@ FILTER filter_parseOr(char * filterStrin
 	return filter;
 }
 
-FILTER filter_parseNot(char * filterString, int * pos, apr_pool_t *pool) {
-	FILTER child = NULL;
-	FILTER filter = (FILTER) malloc(sizeof(*filter));
+filter_t filter_parseNot(char * filterString, int * pos, apr_pool_t *pool) {
+	filter_t child = NULL;
+	filter_t filter = (filter_t) malloc(sizeof(*filter));
 	filter_skipWhiteSpace(filterString, pos);
 
 	if (filterString[*pos] != '(') {
@@ -222,13 +222,13 @@ FILTER filter_parseNot(char * filterStri
 	return filter;
 }
 
-FILTER filter_parseItem(char * filterString, int * pos, apr_pool_t *pool) {
+filter_t filter_parseItem(char * filterString, int * pos, apr_pool_t *pool) {
 	char * attr = filter_parseAttr(filterString, pos);
 	filter_skipWhiteSpace(filterString, pos);
 	switch(filterString[*pos]) {
 		case '~': {
 			if (filterString[*pos + 1] == '=') {
-				FILTER filter = (FILTER) malloc(sizeof(*filter));
+				filter_t filter = (filter_t) malloc(sizeof(*filter));
 				*pos += 2;
 				filter->operand = APPROX;
 				filter->attribute = attr;
@@ -239,7 +239,7 @@ FILTER filter_parseItem(char * filterStr
 		}
 		case '>': {
 			if (filterString[*pos + 1] == '=') {
-				FILTER filter = (FILTER) malloc(sizeof(*filter));
+				filter_t filter = (filter_t) malloc(sizeof(*filter));
 				*pos += 2;
 				filter->operand = GREATER;
 				filter->attribute = attr;
@@ -250,7 +250,7 @@ FILTER filter_parseItem(char * filterStr
 		}
 		case '<': {
 			if (filterString[*pos + 1] == '=') {
-				FILTER filter = (FILTER) malloc(sizeof(*filter));
+				filter_t filter = (filter_t) malloc(sizeof(*filter));
 				*pos += 2;
 				filter->operand = LESS;
 				filter->attribute = attr;
@@ -260,14 +260,14 @@ FILTER filter_parseItem(char * filterStr
 			break;
 		}
 		case '=': {
-			FILTER filter = NULL;
+			filter_t filter = NULL;
 			ARRAY_LIST subs;
 			if (filterString[*pos + 1] == '*') {
 				int oldPos = *pos;
 				*pos += 2;
 				filter_skipWhiteSpace(filterString, pos);
 				if (filterString[*pos] == ')') {
-					FILTER filter = (FILTER) malloc(sizeof(*filter));
+					filter_t filter = (filter_t) malloc(sizeof(*filter));
 					filter->operand = PRESENT;
 					filter->attribute = attr;
 					filter->value = NULL;
@@ -275,7 +275,7 @@ FILTER filter_parseItem(char * filterStr
 				}
 				*pos = oldPos;
 			}
-			filter = (FILTER) malloc(sizeof(*filter));			
+			filter = (filter_t) malloc(sizeof(*filter));			
 			(*pos)++;
 			subs = filter_parseSubstring(filterString, pos, pool);
 			if (arrayList_size(subs) == 1) {
@@ -431,33 +431,44 @@ ARRAY_LIST filter_parseSubstring(char * 
 	return operands;
 }
 
-int filter_match(FILTER filter, PROPERTIES properties) {
+celix_status_t filter_match(filter_t filter, PROPERTIES properties, bool *result) {
 	switch (filter->operand) {
 		case AND: {
 			ARRAY_LIST filters = (ARRAY_LIST) filter->value;
 			unsigned int i;
 			for (i = 0; i < arrayList_size(filters); i++) {
-				FILTER sfilter = (FILTER) arrayList_get(filters, i);
-				if (!filter_match(sfilter, properties)) {
-					return 0;
+				filter_t sfilter = (filter_t) arrayList_get(filters, i);
+				bool mresult;
+				filter_match(sfilter, properties, &mresult);
+				if (!mresult) {
+					*result = 0;
+					return CELIX_SUCCESS;
 				}
 			}
-			return 1;
+			*result = 1;
+			return CELIX_SUCCESS;
 		}
 		case OR: {
 			ARRAY_LIST filters = (ARRAY_LIST) filter->value;
 			unsigned int i;
 			for (i = 0; i < arrayList_size(filters); i++) {
-				FILTER sfilter = (FILTER) arrayList_get(filters, i);
-				if (filter_match(sfilter, properties)) {
-					return 1;
+				filter_t sfilter = (filter_t) arrayList_get(filters, i);
+				bool mresult;
+				filter_match(sfilter, properties, &mresult);
+				if (mresult) {
+					*result = 1;
+					return CELIX_SUCCESS;
 				}
 			}
-			return 0;
+			*result = 0;
+			return CELIX_SUCCESS;
 		}
 		case NOT: {
-			FILTER sfilter = (FILTER) filter->value;
-			return !filter_match(sfilter, properties);
+			filter_t sfilter = (filter_t) filter->value;
+			bool mresult;
+			filter_match(sfilter, properties, &mresult);
+			*result = !mresult;
+			return CELIX_SUCCESS;
 		}
 		case SUBSTRING :
 		case EQUAL :
@@ -466,25 +477,28 @@ int filter_match(FILTER filter, PROPERTI
 		case APPROX : {
 			char * value = (properties == NULL) ? NULL: properties_get(properties, filter->attribute);
 
-			return filter_compare(filter->operand, (char *) value, filter->value);
+			return filter_compare(filter->operand, (char *) value, filter->value, result);
 		}
 		case PRESENT: {
 			char * value = (properties == NULL) ? NULL: properties_get(properties, filter->attribute);
-			return value != NULL;
+			*result = value != NULL;
+			return CELIX_SUCCESS;
 		}
 	}
-	return 0;
+	*result = 0;
+	return CELIX_SUCCESS;
 }
 
-int filter_compare(OPERAND operand, char * string, void * value2) {
+celix_status_t filter_compare(OPERAND operand, char * string, void * value2, bool *result) {
 	if (string == NULL) {
-		return 0;
+		*result = 0;
+		return CELIX_SUCCESS;
 	}
-	return filter_compareString(operand, string, value2);
+	return filter_compareString(operand, string, value2, result);
 
 }
 
-int filter_compareString(OPERAND operand, char * string, void * value2) {
+celix_status_t filter_compareString(OPERAND operand, char * string, void * value2, bool *result) {
 	switch (operand) {
 		case SUBSTRING: {
 			ARRAY_LIST subs = (ARRAY_LIST) value2;
@@ -503,7 +517,8 @@ int filter_compareString(OPERAND operand
 						}
 						index = strcspn(string+pos, substr2);
 						if (index == strlen(string+pos)) {
-							return 0;
+							*result = false;
+							return CELIX_SUCCESS;
 						}
 
 						pos = index + strlen(substr2);
@@ -519,7 +534,8 @@ int filter_compareString(OPERAND operand
 							pos += len;
 						} else {
 							free(region);
-							return 0;
+							*result = false;
+							return CELIX_SUCCESS;
 						}
 						free(region);
 					}
@@ -528,24 +544,30 @@ int filter_compareString(OPERAND operand
 					int begin;
 
 					if (substr == NULL) {
-						return 1;
+						*result = true;
+						return CELIX_SUCCESS;
 					}
 					len = strlen(substr);
 					begin = strlen(string)-len;
-					return (strcmp(string+begin, substr) == 0);
+					*result = (strcmp(string+begin, substr) == 0);
+					return CELIX_SUCCESS;
 				}
 			}
-			return 0;
+			*result = true;
+			return CELIX_SUCCESS;
 		}
 		case APPROX:
 		case EQUAL: {
-			return (strcmp(string, (char *) value2) == 0);
+			*result = (strcmp(string, (char *) value2) == 0);
+			return CELIX_SUCCESS;
 		}
 		case GREATER: {
-			return (strcmp(string, (char *) value2) >= 0);
+			*result = (strcmp(string, (char *) value2) >= 0);
+			return CELIX_SUCCESS;
 		}
 		case LESS: {
-			return (strcmp(string, (char *) value2) <= 0);
+			*result = (strcmp(string, (char *) value2) <= 0);
+			return CELIX_SUCCESS;
 		}
 		case AND:
 		case NOT:
@@ -554,10 +576,11 @@ int filter_compareString(OPERAND operand
 		}
 		/* no break */
 	}
-	return 0;
+	*result = false;
+	return CELIX_SUCCESS;
 }
 
-celix_status_t filter_getString(FILTER filter, char **filterStr) {
+celix_status_t filter_getString(filter_t filter, char **filterStr) {
 	if (filter != NULL) {
 		*filterStr = filter->filterStr;
 	}

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Mon Nov 26 07:47:47 2012
@@ -70,7 +70,7 @@ struct framework {
 
 	long nextBundleId;
 	struct serviceRegistry * registry;
-	BUNDLE_CACHE cache;
+bundle_cache_t cache;
 
 	apr_thread_cond_t *shutdownGate;
 	apr_thread_cond_t *condition;
@@ -98,9 +98,9 @@ struct framework {
 
 struct activator {
 	void * userData;
-	void (*start)(void * userData, BUNDLE_CONTEXT context);
-	void (*stop)(void * userData, BUNDLE_CONTEXT context);
-	void (*destroy)(void * userData, BUNDLE_CONTEXT context);
+	void (*start)(void * userData, bundle_context_t context);
+	void (*stop)(void * userData, bundle_context_t context);
+	void (*destroy)(void * userData, bundle_context_t context);
 };
 
 celix_status_t framework_setBundleStateAndNotify(FRAMEWORK framework, BUNDLE bundle, int state);
@@ -117,7 +117,7 @@ celix_status_t framework_releaseInstallL
 
 long framework_getNextBundleId(FRAMEWORK framework);
 
-celix_status_t fw_installBundle2(FRAMEWORK framework, BUNDLE * bundle, long id, char * location, char *inputFile, BUNDLE_ARCHIVE archive);
+celix_status_t fw_installBundle2(FRAMEWORK framework, BUNDLE * bundle, long id, char * location, char *inputFile, bundle_archive_t archive);
 
 celix_status_t fw_refreshBundles(FRAMEWORK framework, BUNDLE bundles[], int size);
 celix_status_t fw_refreshBundle(FRAMEWORK framework, BUNDLE bundle);
@@ -141,7 +141,7 @@ celix_status_t fw_refreshHelper_stop(str
 struct fw_serviceListener {
 	BUNDLE bundle;
 	SERVICE_LISTENER listener;
-	FILTER filter;
+	filter_t filter;
 };
 
 typedef struct fw_serviceListener * FW_SERVICE_LISTENER;
@@ -265,7 +265,7 @@ celix_status_t framework_destroy(FRAMEWO
 	    HASH_MAP_ENTRY entry = hashMapIterator_nextEntry(iterator);
 		BUNDLE bundle = hashMapEntry_getValue(entry);
 		char * location = hashMapEntry_getKey(entry);
-		BUNDLE_ARCHIVE archive = NULL;
+		bundle_archive_t archive = NULL;
 
 		// for each installed bundle, clean up memory
 		MODULE mod = NULL;
@@ -311,7 +311,7 @@ celix_status_t fw_init(FRAMEWORK framewo
 	MODULE module = NULL;
 	HASH_MAP wires;
 	ARRAY_LIST archives;
-	BUNDLE_ARCHIVE archive = NULL;
+	bundle_archive_t archive = NULL;
 
 	if (status != CELIX_SUCCESS) {
 		framework_releaseBundleLock(framework, framework->bundle);
@@ -371,11 +371,11 @@ celix_status_t fw_init(FRAMEWORK framewo
 #endif
         int arcIdx;
 		void * handle;
-		BUNDLE_CONTEXT context = NULL;
+		bundle_context_t context = NULL;
 		ACTIVATOR activator;
 
         for (arcIdx = 0; arcIdx < arrayList_size(archives); arcIdx++) {
-            BUNDLE_ARCHIVE archive = (BUNDLE_ARCHIVE) arrayList_get(archives, arcIdx);
+            bundle_archive_t archive = (bundle_archive_t) arrayList_get(archives, arcIdx);
             long id;
 			BUNDLE_STATE bundleState;
             bundleArchive_getId(archive, &id);
@@ -421,12 +421,12 @@ celix_status_t fw_init(FRAMEWORK framewo
         if (activator == NULL) {
             status = CELIX_ENOMEM;
         }  else {
-			BUNDLE_CONTEXT context = NULL;
+			bundle_context_t context = NULL;
 			void * userData = NULL;
-            void * (*create)(BUNDLE_CONTEXT context);
-            void (*start)(void * handle, BUNDLE_CONTEXT context);
-            void (*stop)(void * handle, BUNDLE_CONTEXT context);
-            void (*destroy)(void * handle, BUNDLE_CONTEXT context);
+            void * (*create)(bundle_context_t context);
+            void (*start)(void * handle, bundle_context_t context);
+            void (*stop)(void * handle, bundle_context_t context);
+            void (*destroy)(void * handle, bundle_context_t context);
             create = dlsym(bundle_getHandle(framework->bundle), BUNDLE_ACTIVATOR_CREATE);
             start = dlsym(bundle_getHandle(framework->bundle), BUNDLE_ACTIVATOR_START);
             stop = dlsym(bundle_getHandle(framework->bundle), BUNDLE_ACTIVATOR_STOP);
@@ -514,8 +514,8 @@ celix_status_t fw_installBundle(FRAMEWOR
 	return fw_installBundle2(framework, bundle, -1, location, inputFile, NULL);
 }
 
-celix_status_t fw_installBundle2(FRAMEWORK framework, BUNDLE * bundle, long id, char * location, char *inputFile, BUNDLE_ARCHIVE archive) {
-    BUNDLE_ARCHIVE bundle_archive = NULL;
+celix_status_t fw_installBundle2(FRAMEWORK framework, BUNDLE * bundle, long id, char * location, char *inputFile, bundle_archive_t archive) {
+    bundle_archive_t bundle_archive = NULL;
     BUNDLE_STATE state;
 	apr_pool_t *bundlePool;
   	bool locked;
@@ -579,7 +579,7 @@ celix_status_t framework_getBundleEntry(
 	celix_status_t status = CELIX_SUCCESS;
 
 	BUNDLE_REVISION revision;
-	BUNDLE_ARCHIVE archive = NULL;
+	bundle_archive_t archive = NULL;
 
 	status = bundle_getArchive(bundle, &archive);
 	if (status == CELIX_SUCCESS) {
@@ -615,7 +615,7 @@ celix_status_t fw_startBundle(FRAMEWORK 
 
 	HASH_MAP wires;
 	void * handle;
-	BUNDLE_CONTEXT context = NULL;
+	bundle_context_t context = NULL;
 	BUNDLE_STATE state;
 	MODULE module = NULL;
 	MANIFEST manifest = NULL;
@@ -636,7 +636,7 @@ celix_status_t fw_startBundle(FRAMEWORK 
 	char *archiveRoot;
 	long revisionNumber;
 	ACTIVATOR activator;
-	BUNDLE_ARCHIVE archive = NULL;
+	bundle_archive_t archive = NULL;
 	apr_pool_t *bundlePool = NULL;
 
 	if (lock != CELIX_SUCCESS) {
@@ -724,11 +724,11 @@ celix_status_t fw_startBundle(FRAMEWORK 
 			    return CELIX_ENOMEM;
 			} else {
 				void * userData = NULL;
-                BUNDLE_CONTEXT context;
-                void * (*create)(BUNDLE_CONTEXT context, void **userData);
-                void (*start)(void * userData, BUNDLE_CONTEXT context);
-                void (*stop)(void * userData, BUNDLE_CONTEXT context);
-                void (*destroy)(void * userData, BUNDLE_CONTEXT context);
+                bundle_context_t context;
+                void * (*create)(bundle_context_t context, void **userData);
+                void (*start)(void * userData, bundle_context_t context);
+                void (*stop)(void * userData, bundle_context_t context);
+                void (*destroy)(void * userData, bundle_context_t context);
                 create = dlsym(bundle_getHandle(bundle), BUNDLE_ACTIVATOR_CREATE);
                 start = dlsym(bundle_getHandle(bundle), BUNDLE_ACTIVATOR_START);
                 stop = dlsym(bundle_getHandle(bundle), BUNDLE_ACTIVATOR_STOP);
@@ -771,7 +771,7 @@ celix_status_t framework_updateBundle(FR
 	BUNDLE_STATE oldState;
 	char *location;
 	bool locked;
-	BUNDLE_ARCHIVE archive = NULL;
+	bundle_archive_t archive = NULL;
 
 	if (lock != CELIX_SUCCESS) {
 		printf("Cannot update bundle, in wrong state");
@@ -821,7 +821,7 @@ celix_status_t fw_stopBundle(FRAMEWORK f
 	} else {
 		BUNDLE_STATE state;
 		ACTIVATOR activator;
-		BUNDLE_CONTEXT context;
+		bundle_context_t context;
 		MODULE module = NULL;
 		MANIFEST manifest = NULL;
 		if (record) {
@@ -920,7 +920,7 @@ celix_status_t fw_uninstallBundle(FRAMEW
             framework_releaseGlobalLock(framework);
             status = CELIX_ILLEGAL_STATE;
         } else {
-            BUNDLE_ARCHIVE archive = NULL;
+            bundle_archive_t archive = NULL;
             char * location;
 			BUNDLE target;
 			status = bundle_getArchive(bundle, &archive);
@@ -1171,9 +1171,9 @@ celix_status_t fw_registerService(FRAMEW
 		for (i = 0; i > arrayList_size(framework->serviceListeners); i++) {
 			FW_SERVICE_LISTENER listener = arrayList_get(framework->serviceListeners, i);
 			apr_pool_t *pool;
-			BUNDLE_CONTEXT context;
+			bundle_context_t context;
 			listener_hook_info_t info;
-			BUNDLE_CONTEXT lContext = NULL;
+			bundle_context_t lContext = NULL;
 
 			bundle_getContext(bundle, &context);
 			bundleContext_getMemoryPool(context, &pool);
@@ -1223,7 +1223,7 @@ celix_status_t fw_registerServiceFactory
 }
 
 celix_status_t fw_getServiceReferences(FRAMEWORK framework, ARRAY_LIST *references, BUNDLE bundle, const char * serviceName, char * sfilter) {
-	FILTER filter = NULL;
+	filter_t filter = NULL;
 	int refIdx = 0;
 	apr_pool_t *pool = NULL;
 
@@ -1277,7 +1277,7 @@ bool framework_ungetService(FRAMEWORK fr
 void fw_addServiceListener(FRAMEWORK framework, BUNDLE bundle, SERVICE_LISTENER listener, char * sfilter) {
 //	apr_pool_t *pool;
 //	apr_pool_t *bpool;
-//	BUNDLE_CONTEXT context;
+//	bundle_context_t context;
 //	bundle_getContext(bundle, &context);
 //	bundleContext_getMemoryPool(context, &bpool);
 //	apr_pool_create(&pool, bpool);
@@ -1289,13 +1289,13 @@ void fw_addServiceListener(FRAMEWORK fra
 	FW_SERVICE_LISTENER fwListener = (FW_SERVICE_LISTENER) malloc(sizeof(*fwListener));
 	apr_pool_t *pool = NULL;
 
-	BUNDLE_CONTEXT context = NULL;
+	bundle_context_t context = NULL;
 
 	bundle_getMemoryPool(bundle, &pool);
 
 	fwListener->bundle = bundle;
 	if (sfilter != NULL) {
-		FILTER filter = filter_create(sfilter, pool);
+		filter_t filter = filter_create(sfilter, pool);
 		fwListener->filter = filter;
 	} else {
 		fwListener->filter = NULL;
@@ -1334,14 +1334,14 @@ void fw_removeServiceListener(FRAMEWORK 
 	unsigned int i;
 	FW_SERVICE_LISTENER element;
 
-	BUNDLE_CONTEXT context;
+	bundle_context_t context;
 	bundle_getContext(bundle, &context);
 	bundleContext_getMemoryPool(context, &pool);
 	
 	for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
 		element = (FW_SERVICE_LISTENER) arrayList_get(framework->serviceListeners, i);
 		if (element->listener == listener && element->bundle == bundle) {
-			BUNDLE_CONTEXT lContext = NULL;
+			bundle_context_t lContext = NULL;
 
 			info = apr_palloc(pool, sizeof(*info));
 
@@ -1431,9 +1431,14 @@ void fw_serviceChanged(FRAMEWORK framewo
 		for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
 			int matched = 0;
 			PROPERTIES props = NULL;
+			bool matchResult = false;
+
 			element = (FW_SERVICE_LISTENER) arrayList_get(framework->serviceListeners, i);
 			serviceRegistration_getProperties(registration, &props);
-			matched = (element->filter == NULL) || filter_match(element->filter, props);
+			if (element->filter != NULL) {
+				filter_match(element->filter, props, &matchResult);
+			}
+			matched = (element->filter == NULL) || matchResult;
 			if (matched) {
 				SERVICE_REFERENCE reference = NULL;
 				SERVICE_EVENT event;
@@ -1449,7 +1454,11 @@ void fw_serviceChanged(FRAMEWORK framewo
 
 				element->listener->serviceChanged(element->listener, event);
 			} else if (eventType == MODIFIED) {
-				int matched = (element->filter == NULL) || filter_match(element->filter, oldprops);
+				bool matchResult = false;
+				if (element->filter != NULL) {
+					filter_match(element->filter, oldprops, &matchResult);
+				}
+				int matched = (element->filter == NULL) || matchResult;
 				if (matched) {
 					SERVICE_REFERENCE reference = NULL;
 					SERVICE_EVENT endmatch = (SERVICE_EVENT) malloc(sizeof(*endmatch));
@@ -1481,7 +1490,7 @@ void fw_serviceChanged(FRAMEWORK framewo
 //	return status;
 //}
 
-celix_status_t getManifest(BUNDLE_ARCHIVE archive, apr_pool_t *pool, MANIFEST *manifest) {
+celix_status_t getManifest(bundle_archive_t archive, apr_pool_t *pool, MANIFEST *manifest) {
 	celix_status_t status = CELIX_SUCCESS;
 	char mf[256];
 	long refreshCount;
@@ -1575,7 +1584,7 @@ BUNDLE framework_getBundleById(FRAMEWORK
 	BUNDLE bundle = NULL;
 	while (hashMapIterator_hasNext(iter)) {
 		BUNDLE b = hashMapIterator_nextValue(iter);
-		BUNDLE_ARCHIVE archive = NULL;
+		bundle_archive_t archive = NULL;
 		long bid;
 		bundle_getArchive(b, &archive);
 		bundleArchive_getId(archive, &bid);
@@ -1817,7 +1826,7 @@ static void *APR_THREAD_FUNC framework_s
 		bundle_getState(bundle, &state);
 		if (state == BUNDLE_ACTIVE || state == BUNDLE_STARTING) {
 			char *location;
-			BUNDLE_ARCHIVE archive = NULL;
+			bundle_archive_t archive = NULL;
 
 			bundle_getArchive(bundle, &archive);
 			bundleArchive_getLocation(archive, &location);
@@ -1985,12 +1994,12 @@ celix_status_t fw_invokeBundleListener(F
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+celix_status_t bundleActivator_start(void * userData, bundle_context_t context) {
 	// nothing to do
 	return CELIX_SUCCESS;
 }
 
-celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+celix_status_t bundleActivator_stop(void * userData, bundle_context_t context) {
     celix_status_t status = CELIX_SUCCESS;
 
 	apr_thread_t *shutdownThread;
@@ -2011,6 +2020,6 @@ celix_status_t bundleActivator_stop(void
 	return status;
 }
 
-celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_t context) {
 	return CELIX_SUCCESS;
 }

Added: incubator/celix/trunk/framework/private/src/iowin32.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/iowin32.c?rev=1413494&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/src/iowin32.c (added)
+++ incubator/celix/trunk/framework/private/src/iowin32.c Mon Nov 26 07:47:47 2012
@@ -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;
+}

Modified: incubator/celix/trunk/framework/private/src/manifest.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/manifest.c?rev=1413494&r1=1413493&r2=1413494&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/manifest.c (original)
+++ incubator/celix/trunk/framework/private/src/manifest.c Mon Nov 26 07:47:47 2012
@@ -99,8 +99,11 @@ celix_status_t manifest_read(MANIFEST ma
 		char * lastline;
 		manifest_readAttributes(manifest, manifest->mainAttributes, file);
 
+		apr_pool_t *subpool;
+		apr_pool_create(&subpool, manifest->pool);
 		while (fgets(lbuf, sizeof(lbuf), file) != NULL ) {
 			PROPERTIES attributes;
+
 			len = strlen(lbuf);
 			if (lbuf[--len] != '\n') {
 				printf("MANIFEST: Line too long\n");
@@ -119,7 +122,7 @@ celix_status_t manifest_read(MANIFEST ma
 				if ((tolower(lbuf[0]) == 'n') && (tolower(lbuf[1]) == 'a') &&
 					(tolower(lbuf[2]) == 'm') && (tolower(lbuf[3]) == 'e') &&
 					(lbuf[4] == ':') && (lbuf[5] == ' ')) {
-					name = (char *) malloc((len + 1) - 6);
+					name = (char *) apr_palloc(subpool, (len + 1) - 6);
 					name = strncpy(name, lbuf+6, len - 6);
 					name[len - 6] = '\0';
 				} else {
@@ -129,14 +132,14 @@ celix_status_t manifest_read(MANIFEST ma
 
 				if (fpeek(file) == ' ') {
 					int newlen = len - 6;
-					lastline = (char *) malloc(newlen + 1);
+					lastline = (char *) apr_palloc(subpool, newlen + 1);
 					lastline = strncpy(lastline, lbuf+6, len - 6);
 					lastline[newlen] = '\0';
 					continue;
 				}
 			} else {
 				int newlen = strlen(lastline) + len;
-				char * buf = (char *)malloc(newlen);
+				char * buf = (char *) apr_palloc(subpool, newlen);
 				strcpy(buf, lastline);
 				strncat(buf, lbuf+1, len - 1);
 				buf[newlen] = '\0';
@@ -144,14 +147,12 @@ celix_status_t manifest_read(MANIFEST ma
 				if (fpeek(file) == ' ') {
 					lastline = realloc(lastline, strlen(buf) + 1);
 					lastline = strcpy(lastline, buf);
-					free(buf);
 					continue;
 				}
-				name = (char *) malloc(strlen(buf) + 1);
+				name = (char *) apr_palloc(subpool, strlen(buf) + 1);
 				name = strcpy(name, buf);
 				name[strlen(buf)] = '\0';
 				lastline = NULL;
-				free(buf);
 			}
 
 			attributes = hashMap_get(manifest->attributes, name);
@@ -161,10 +162,9 @@ celix_status_t manifest_read(MANIFEST ma
 			}
 			manifest_readAttributes(manifest, attributes, file);
 
-			free(name);
-			name = NULL;
 			skipEmptyLines = true;
 		}
+		apr_pool_destroy(subpool);
 		fclose(file);
 	} else {
 		printf("Could not read manifest file.\n");
@@ -197,7 +197,10 @@ celix_status_t manifest_readAttributes(M
 	char lbuf[512];
 
 	int len;
+	apr_pool_t *subpool;
+	apr_pool_create(&subpool, manifest->pool);
 	while (fgets(lbuf, sizeof(lbuf), file ) != NULL ) {
+
 		bool lineContinued = false;
 		int i = 0;
 		len = strlen(lbuf);
@@ -214,7 +217,7 @@ celix_status_t manifest_readAttributes(M
 		
 		if (lbuf[0] == ' ') {
 			int newlen = strlen(lastLine) + len;
-			char * buf = (char *)calloc(sizeof(char), newlen);
+			char * buf = (char *) apr_palloc(subpool, newlen);
 
 			// Line continued
 			if (name == NULL) {
@@ -231,10 +234,8 @@ celix_status_t manifest_readAttributes(M
 				lastLine = strcpy(lastLine, buf);
 				continue;
 			}
-			value = (char *) malloc(strlen(buf) + 1);
+			value = (char *) apr_palloc(subpool, strlen(buf) + 1);
 			value = strcpy(value, buf);
-			free(lastLine);
-			free(buf);
 			lastLine = NULL;
 		} else {
 			while (lbuf[i++] != ':') {
@@ -247,17 +248,17 @@ celix_status_t manifest_readAttributes(M
 				printf("MANIFEST: Invalid header\n");
 				return CELIX_FILE_IO_EXCEPTION;
 			}
-			name = (char *) malloc((i + 1) - 2);
+			name = (char *) apr_palloc(subpool, (i + 1) - 2);
 			name = strncpy(name, lbuf, i - 2);
 			name[i - 2] = '\0';
 			if (fpeek(file) == ' ') {
 				int newlen = len - i;
-				lastLine = (char *) malloc(newlen + 1);
+				lastLine = (char *) apr_palloc(subpool, newlen + 1);
 				lastLine = strncpy(lastLine, lbuf+i, len -i);
 				lastLine[newlen] = '\0';
 				continue;
 			}
-			value = (char *) malloc((len + 1) - i);
+			value = (char *) apr_palloc(subpool, (len + 1) - i);
 			value = strncpy(value, lbuf+i, len - i);
 			value[len - i] = '\0';
 		}
@@ -265,10 +266,8 @@ celix_status_t manifest_readAttributes(M
 		if ((properties_set(properties, name, value) != NULL) && (!lineContinued)) {
 			printf("Duplicate entry: %s", name);
 		}
-		free(lastLine);
-		free(name);
-		free(value);
 	}
+	apr_pool_destroy(subpool);
 
 	return CELIX_SUCCESS;
 }



Mime
View raw message