Author: abroekhuis
Date: Mon Apr 23 08:29:43 2012
New Revision: 1329121

URL: http://svn.apache.org/viewvc?rev=1329121&view=rev
Log:
Deployment Admin loggin

Added logger to the deployment admin for the audit log (work in progress). 
Several small code fixes.

Added:
    incubator/celix/trunk/deployment_admin/private/include/log.h
    incubator/celix/trunk/deployment_admin/private/include/log_event.h
    incubator/celix/trunk/deployment_admin/private/include/log_store.h
    incubator/celix/trunk/deployment_admin/private/include/log_sync.h
    incubator/celix/trunk/deployment_admin/private/src/log.c
    incubator/celix/trunk/deployment_admin/private/src/log_store.c
    incubator/celix/trunk/deployment_admin/private/src/log_sync.c
Modified:
    incubator/celix/trunk/deployment_admin/CMakeLists.txt
    incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c
    incubator/celix/trunk/deployment_admin/private/src/miniunz.c
    incubator/celix/trunk/framework/private/src/bundle_archive.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/private/src/miniunz.c
    incubator/celix/trunk/framework/private/src/service_registration.c
    incubator/celix/trunk/framework/private/src/service_tracker.c
    incubator/celix/trunk/framework/public/include/bundle_archive.h
    incubator/celix/trunk/shell/update_command.c

Modified: incubator/celix/trunk/deployment_admin/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/CMakeLists.txt?rev=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/deployment_admin/CMakeLists.txt (original)
+++ incubator/celix/trunk/deployment_admin/CMakeLists.txt Mon Apr 23 08:29:43 
2012
@@ -30,6 +30,9 @@ bundle(deployment_admin SOURCES
        private/src/ioapi
        private/src/miniunz
        private/src/unzip
+       private/src/log
+       private/src/log_store
+       private/src/log_sync
 )
 target_link_libraries(deployment_admin framework curl)
 

Added: incubator/celix/trunk/deployment_admin/private/include/log.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/include/log.h?rev=1329121&view=auto
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/include/log.h (added)
+++ incubator/celix/trunk/deployment_admin/private/include/log.h Mon Apr 23 
08:29:43 2012
@@ -0,0 +1,21 @@
+/*
+ * log.h
+ *
+ *  Created on: Apr 18, 2012
+ *      Author: alexander
+ */
+
+#ifndef LOG_H_
+#define LOG_H_
+
+#include <apr_general.h>
+
+#include "log_event.h"
+#include "log_store.h"
+
+typedef struct log *log_t;
+
+celix_status_t log_create(apr_pool_t *pool, log_store_t store, log_t *log);
+celix_status_t log_log(log_t log, unsigned int type, PROPERTIES properties);
+
+#endif /* LOG_H_ */

Added: incubator/celix/trunk/deployment_admin/private/include/log_event.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/include/log_event.h?rev=1329121&view=auto
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/include/log_event.h (added)
+++ incubator/celix/trunk/deployment_admin/private/include/log_event.h Mon Apr 
23 08:29:43 2012
@@ -0,0 +1,24 @@
+/*
+ * log_event.h
+ *
+ *  Created on: Apr 19, 2012
+ *      Author: alexander
+ */
+
+#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 properties;
+};
+
+typedef struct log_event *log_event_t;
+
+#endif /* LOG_EVENT_H_ */

Added: incubator/celix/trunk/deployment_admin/private/include/log_store.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/include/log_store.h?rev=1329121&view=auto
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/include/log_store.h (added)
+++ incubator/celix/trunk/deployment_admin/private/include/log_store.h Mon Apr 
23 08:29:43 2012
@@ -0,0 +1,26 @@
+/*
+ * log_store.h
+ *
+ *  Created on: Apr 18, 2012
+ *      Author: alexander
+ */
+
+#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_t;
+
+celix_status_t logStore_create(apr_pool_t *pool, log_store_t *store);
+celix_status_t logStore_put(log_store_t store, unsigned int type, PROPERTIES 
properties, log_event_t *event);
+
+celix_status_t logStore_getLogId(log_store_t store, unsigned long *id);
+celix_status_t logStore_getEvents(log_store_t store, ARRAY_LIST *events);
+
+celix_status_t logStore_getHighestId(log_store_t store, long *id);
+
+#endif /* LOG_STORE_H_ */

Added: incubator/celix/trunk/deployment_admin/private/include/log_sync.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/include/log_sync.h?rev=1329121&view=auto
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/include/log_sync.h (added)
+++ incubator/celix/trunk/deployment_admin/private/include/log_sync.h Mon Apr 
23 08:29:43 2012
@@ -0,0 +1,17 @@
+/*
+ * log_sync.h
+ *
+ *  Created on: Apr 19, 2012
+ *      Author: alexander
+ */
+
+#ifndef LOG_SYNC_H_
+#define LOG_SYNC_H_
+
+#include "log_store.h"
+
+typedef struct log_sync *log_sync_t;
+
+celix_status_t logSync_create(apr_pool_t *pool, char *targetId, log_store_t 
store, log_sync_t *logSync);
+
+#endif /* LOG_SYNC_H_ */

Modified: incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c?rev=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c 
(original)
+++ incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c Mon 
Apr 23 08:29:43 2012
@@ -9,7 +9,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <curl/curl.h>
-#include <curl/types.h>
 #include <curl/easy.h>
 #include <apr_strings.h>
 
@@ -21,6 +20,10 @@
 #include "bundle.h"
 #include "utils.h"
 
+#include "log.h"
+#include "log_store.h"
+#include "log_sync.h"
+
 #include "resource_processor.h"
 
 #define IDENTIFICATION_ID "deployment_admin.identification"
@@ -72,6 +75,16 @@ celix_status_t deploymentAdmin_create(ap
                        } else {
                                (*admin)->pollUrl = apr_pstrcat(subpool, url, 
(*admin)->targetIdentification, VERSIONS, NULL);
 
+//                             log_store_t store = NULL;
+//                             log_t log = NULL;
+//                             log_sync_t sync = NULL;
+//                             logStore_create(subpool, &store);
+//                             log_create(subpool, store, &log);
+//                             logSync_create(subpool, 
(*admin)->targetIdentification, store, &sync);
+//
+//                             log_log(log, 20000, NULL);
+
+
                                apr_thread_create(&(*admin)->poller, NULL, 
deploymentAdmin_poll, *admin, subpool);
                        }
                }
@@ -85,7 +98,6 @@ static void *APR_THREAD_FUNC deploymentA
 
        while (admin->running) {
                //poll ace
-               printf("Read version\n");
                ARRAY_LIST versions = NULL;
                deploymentAdmin_readVersions(admin, &versions);
 
@@ -93,7 +105,6 @@ static void *APR_THREAD_FUNC deploymentA
 
                if (last != NULL) {
                        if (admin->current == NULL || strcmp(last, 
admin->current) > 0) {
-                               printf("install version: %s\n", last);
                                char *request = NULL;
                                if (admin->current == NULL) {
                                        request = apr_pstrcat(admin->pool, 
admin->pollUrl, "/", last, NULL);
@@ -102,7 +113,6 @@ static void *APR_THREAD_FUNC deploymentA
                                        //request = apr_pstrcat(admin->pool, 
VERSIONS, "/", last, "?current=", admin->current, NULL);
                                        request = apr_pstrcat(admin->pool, 
admin->pollUrl, "/", last, NULL);
                                }
-                               printf("Request: %s\n", request);
 
                                char inputFile[MAXNAMLEN];
                                inputFile[0] = '\0';
@@ -110,7 +120,6 @@ static void *APR_THREAD_FUNC deploymentA
                                celix_status_t status = 
deploymentAdmin_download(request, &test);
                                if (status == CELIX_SUCCESS) {
                                        // Handle file
-                                       printf("Handle file\n");
                                        char tmpDir[MAXNAMLEN];
                                        tmpDir[0] = '\0';
                                        tmpnam(tmpDir);
@@ -118,7 +127,6 @@ static void *APR_THREAD_FUNC deploymentA
                                        apr_dir_make(tmpDir, 
APR_UREAD|APR_UWRITE|APR_UEXECUTE, admin->pool);
 
                                        // TODO: update to use bundle cache 
DataFile instead of module entries.
-                                       printf("Extract %s t0 %s\n", test, 
tmpDir);
                                        extractBundle(test, tmpDir);
                                        char *manifest = 
apr_pstrcat(admin->pool, tmpDir, "/META-INF/MANIFEST.MF", NULL);
                                        MANIFEST mf = NULL;
@@ -135,7 +143,6 @@ static void *APR_THREAD_FUNC deploymentA
                                        char *repoDir = 
apr_pstrcat(admin->pool, entry, "repo", NULL);
                                        apr_dir_make(repoDir, 
APR_UREAD|APR_UWRITE|APR_UEXECUTE, admin->pool);
                                        char *repoCache = 
apr_pstrcat(admin->pool, entry, "repo/", name, NULL);
-                                       printf("CAche: %s\n", repoCache);
                                        deploymentAdmin_deleteTree(repoCache, 
admin->pool);
                                        apr_status_t stat = 
apr_file_rename(tmpDir, repoCache, admin->pool);
                                        if (stat != APR_SUCCESS) {
@@ -211,14 +218,12 @@ celix_status_t deploymentAdmin_readVersi
                if (res != CURLE_OK) {
                        status = CELIX_BUNDLE_EXCEPTION;
                }
-               printf("Error: %d\n", res);
                /* always cleanup */
                curl_easy_cleanup(curl);
 
                char *last;
                char *token = apr_strtok(chunk.memory, "\n", &last);
                while (token != NULL) {
-                       printf("Version: %s\n", token);
                        arrayList_add(*versions, apr_pstrdup(admin->pool, 
token));
                        token = apr_strtok(NULL, "\n", &last);
                }
@@ -249,7 +254,6 @@ celix_status_t deploymentAdmin_download(
                if (res != CURLE_OK) {
                        status = CELIX_BUNDLE_EXCEPTION;
                }
-               printf("Error: %d\n", res);
                /* always cleanup */
                curl_easy_cleanup(curl);
                fclose(fp);
@@ -422,9 +426,7 @@ celix_status_t deploymentAdmin_processDe
 
                status = bundleContext_getServiceReferences(admin->context, 
RESOURCE_PROCESSOR_SERVICE, filter, &services);
                if (status == CELIX_SUCCESS) {
-                       printf("REFS\n");
                        if (services != NULL && arrayList_size(services) > 0) {
-                               printf("REFS22\n");
                                SERVICE_REFERENCE 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?

Added: incubator/celix/trunk/deployment_admin/private/src/log.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/src/log.c?rev=1329121&view=auto
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/src/log.c (added)
+++ incubator/celix/trunk/deployment_admin/private/src/log.c Mon Apr 23 
08:29:43 2012
@@ -0,0 +1,39 @@
+/*
+ * log.c
+ *
+ *  Created on: Apr 19, 2012
+ *      Author: alexander
+ */
+#include <apr_general.h>
+
+#include "celix_errno.h"
+
+#include "log.h"
+#include "log_store.h"
+
+struct log {
+       log_store_t logStore;
+};
+
+celix_status_t log_create(apr_pool_t *pool, log_store_t store, log_t *log) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       *log = apr_palloc(pool, sizeof(**log));
+       if (!*log) {
+               status = CELIX_ENOMEM;
+       } else {
+               (*log)->logStore = store;
+       }
+
+       return status;
+}
+
+celix_status_t log_log(log_t log, unsigned int type, PROPERTIES properties) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       log_event_t event = NULL;
+
+       status = logStore_put(log->logStore, type, properties, &event);
+
+       return status;
+}

Added: incubator/celix/trunk/deployment_admin/private/src/log_store.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/src/log_store.c?rev=1329121&view=auto
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/src/log_store.c (added)
+++ incubator/celix/trunk/deployment_admin/private/src/log_store.c Mon Apr 23 
08:29:43 2012
@@ -0,0 +1,79 @@
+/*
+ * log_store.c
+ *
+ *  Created on: Apr 18, 2012
+ *      Author: alexander
+ */
+
+#include <apr_general.h>
+
+#include <time.h>
+
+#include "celix_errno.h"
+#include "array_list.h"
+
+#include "log_store.h"
+#include "log.h"
+
+struct log_store {
+       apr_pool_t *pool;
+
+       unsigned long storeId;
+
+       ARRAY_LIST logEvents;
+};
+
+static celix_status_t logStore_getNextID(log_store_t store, unsigned long *id);
+
+celix_status_t logStore_create(apr_pool_t *pool, log_store_t *store) {
+       celix_status_t status = CELIX_SUCCESS;
+       *store = apr_palloc(pool, sizeof(**store));
+       if (!*store) {
+               status = CELIX_ENOMEM;
+       } else {
+               (*store)->pool = pool;
+               (*store)->storeId = 1;
+               arrayList_create(pool, &(*store)->logEvents);
+       }
+
+       return status;
+}
+
+celix_status_t logStore_put(log_store_t store, unsigned int type, PROPERTIES 
properties, log_event_t *event) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       *event = apr_palloc(store->pool, 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_t store, unsigned long *id) {
+       *id = store->storeId;
+       return CELIX_SUCCESS;
+}
+
+celix_status_t logStore_getEvents(log_store_t store, ARRAY_LIST *events) {
+       *events = store->logEvents;
+       return CELIX_SUCCESS;
+}
+
+celix_status_t logStore_getHighestId(log_store_t store, long *id) {
+       *id = ((long) arrayList_size(store->logEvents)) - 1;
+       return CELIX_SUCCESS;
+}
+
+static celix_status_t logStore_getNextID(log_store_t store, unsigned long *id) 
{
+       *id = arrayList_size(store->logEvents);
+       return CELIX_SUCCESS;
+}
+

Added: incubator/celix/trunk/deployment_admin/private/src/log_sync.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/src/log_sync.c?rev=1329121&view=auto
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/src/log_sync.c (added)
+++ incubator/celix/trunk/deployment_admin/private/src/log_sync.c Mon Apr 23 
08:29:43 2012
@@ -0,0 +1,193 @@
+/*
+ * log_sync.c
+ *
+ *  Created on: Apr 19, 2012
+ *      Author: alexander
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <apr_general.h>
+#include <apr_thread_proc.h>
+#include <apr_strings.h>
+
+#include <curl/curl.h>
+#include <curl/easy.h>
+
+#include "celix_errno.h"
+#include "celixbool.h"
+
+#include "log_sync.h"
+#include "log_event.h"
+
+struct log_sync {
+       apr_pool_t *pool;
+       log_store_t logStore;
+
+       char *targetId;
+       bool running;
+
+       apr_thread_t *syncTask;
+};
+
+struct log_descriptor {
+       char *targetId;
+       unsigned long logId;
+       unsigned long low;
+       unsigned long high;
+};
+
+typedef struct log_descriptor *log_descriptor_t;
+
+celix_status_t logSync_queryLog(log_sync_t logSync, char *targetId, long 
logId, char **queryReply);
+static size_t logSync_readQeury(void *contents, size_t size, size_t nmemb, 
void *userp);
+static void *APR_THREAD_FUNC logSync_synchronize(apr_thread_t *thd, void 
*logSyncP);
+
+celix_status_t logSync_create(apr_pool_t *pool, char *targetId, log_store_t 
store, log_sync_t *logSync) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       *logSync = apr_palloc(pool, sizeof(**logSync));
+       if (!*logSync) {
+               status = CELIX_ENOMEM;
+       } else {
+               (*logSync)->pool = pool;
+               (*logSync)->logStore = store;
+               (*logSync)->targetId = targetId;
+               (*logSync)->syncTask = NULL;
+               (*logSync)->running = true;
+
+               apr_thread_create(&(*logSync)->syncTask, NULL, 
logSync_synchronize, *logSync, pool);
+       }
+
+       return status;
+}
+
+celix_status_t logSync_parseLogDescriptor(log_sync_t logSync, char 
*descriptorString, log_descriptor_t *descriptor) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       printf("Descriptor: %s\n", descriptorString);
+       char *last = NULL;
+       char *targetId = apr_strtok(descriptorString, ",", &last);
+       char *logIdStr = apr_strtok(NULL, ",", &last);
+       long logId = 0;
+       if (logIdStr != NULL) {
+               logId = atol(logIdStr);
+       }
+       char *range = apr_strtok(NULL, ",", &last);
+       printf("Range: %s\n", range);
+
+       long low = 0;
+       long high = 0;
+       if (range != NULL) {
+               char *rangeToken = NULL;
+               low = atol(apr_strtok(range, "-", &rangeToken));
+               high = atol(apr_strtok(NULL, "-", &rangeToken));
+       }
+
+       *descriptor = apr_palloc(logSync->pool, sizeof(**descriptor));
+       if (!*descriptor) {
+               status = CELIX_ENOMEM;
+       } else {
+               (*descriptor)->targetId = targetId;
+               (*descriptor)->logId = logId;
+               (*descriptor)->low = low;
+               (*descriptor)->high = high;
+       }
+
+       return status;
+}
+
+static void *APR_THREAD_FUNC logSync_synchronize(apr_thread_t *thd, void 
*logSyncP) {
+       log_sync_t 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_t descriptor = NULL;
+               logSync_parseLogDescriptor(logSync, logDescriptorString, 
&descriptor);
+
+               long highest = 0;
+               logStore_getHighestId(logSync->logStore, &highest);
+
+//             printf("Highest local: %ld\n", highest);
+//             printf("Highest remote: %ld\n", descriptor->high);
+
+               if (highest >= 0) {
+                       int i;
+                       for (i = descriptor->high + 1; i <= highest; i++) {
+                               ARRAY_LIST events = NULL;
+                               logStore_getEvents(logSync->logStore, &events);
+                               log_event_t event = arrayList_get(events, i);
+//                             printf("Event id: %ld\n", event->id);
+
+
+                       }
+               }
+               sleep(10);
+       }
+
+
+       apr_thread_exit(thd, APR_SUCCESS);
+       return NULL;
+}
+
+struct MemoryStruct {
+       char *memory;
+       size_t size;
+};
+
+celix_status_t logSync_queryLog(log_sync_t logSync, char *targetId, long 
logId, char **queryReply) {
+       // http://localhost:8080/auditlog/query?tid=targetid&logid=logid
+       celix_status_t status = CELIX_SUCCESS;
+
+       char *query = apr_pstrcat(logSync->pool, 
"http://localhost:8080/auditlog/query?tid=";, targetId, "&logid=1", NULL);
+
+       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_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;
+               }
+               printf("Error: %d\n", res);
+               /* always cleanup */
+               curl_easy_cleanup(curl);
+
+               *queryReply = apr_pstrdup(logSync->pool, 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! */
+       printf("not enough memory (realloc returned NULL)\n");
+       exit(EXIT_FAILURE);
+       }
+
+       memcpy(&(mem->memory[mem->size]), contents, realsize);
+       mem->size += realsize;
+       mem->memory[mem->size] = 0;
+
+       return realsize;
+}

Modified: incubator/celix/trunk/deployment_admin/private/src/miniunz.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/src/miniunz.c?rev=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/src/miniunz.c (original)
+++ incubator/celix/trunk/deployment_admin/private/src/miniunz.c Mon Apr 23 
08:29:43 2012
@@ -204,7 +204,6 @@ int do_extract_currentfile(unzFile uf, c
     }
 
     if ((*filename_withoutpath)=='\0') {
-               printf("creating directory: %s\n",filename_inzip);
                char dir[strlen(revisionRoot) + strlen(filename_inzip) + 2];
                strcpy(dir, revisionRoot);
                strcat(dir, "/");

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=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_archive.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_archive.c Mon Apr 23 
08:29:43 2012
@@ -49,6 +49,21 @@ struct bundleArchive {
        apr_pool_t *mp;
 };
 
+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_initialize(BUNDLE_ARCHIVE 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_readLastModified(BUNDLE_ARCHIVE archive, 
time_t *time);
+static celix_status_t bundleArchive_writeLastModified(BUNDLE_ARCHIVE archive);
+
 celix_status_t bundleArchive_createSystemBundleArchive(apr_pool_t *mp, 
BUNDLE_ARCHIVE *bundle_archive) {
     celix_status_t status;
        BUNDLE_ARCHIVE archive;
@@ -61,6 +76,7 @@ celix_status_t bundleArchive_createSyste
         if (archive == NULL) {
             status = CELIX_ENOMEM;
         } else {
+               apr_pool_pre_cleanup_register(mp, archive, 
bundleArchive_destroy);
             if (apr_pool_create(&revisions_pool, mp) == APR_SUCCESS) {
                 if (linkedList_create(revisions_pool, &archive->revisions) == 
CELIX_SUCCESS) {
                     archive->id = 0l;
@@ -86,19 +102,6 @@ celix_status_t bundleArchive_createSyste
     return status;
 }
 
-celix_status_t bundleArchive_getRevisionLocation(BUNDLE_ARCHIVE archive, long 
revNr, char **revision_location);
-celix_status_t bundleArchive_setRevisionLocation(BUNDLE_ARCHIVE archive, char 
* location, long revNr);
-
-celix_status_t bundleArchive_initialize(BUNDLE_ARCHIVE archive);
-
-celix_status_t bundleArchive_deleteTree(char * directory, apr_pool_t *mp);
-
-celix_status_t bundleArchive_createRevisionFromLocation(BUNDLE_ARCHIVE 
archive, char *location, char *inputFile, long revNr, BUNDLE_REVISION 
*bundle_revision);
-celix_status_t bundleArchive_reviseInternal(BUNDLE_ARCHIVE archive, bool 
isReload, long revNr, char * location, char *inputFile);
-
-celix_status_t bundleArchive_readLastModified(BUNDLE_ARCHIVE archive, time_t 
*time);
-celix_status_t bundleArchive_writeLastModified(BUNDLE_ARCHIVE archive);
-
 celix_status_t bundleArchive_create(char * archiveRoot, long id, char * 
location, char *inputFile, apr_pool_t *mp, BUNDLE_ARCHIVE *bundle_archive) {
     celix_status_t status = CELIX_SUCCESS;
     apr_pool_t *revisions_pool;
@@ -109,6 +112,7 @@ celix_status_t bundleArchive_create(char
     } else {
                archive = (BUNDLE_ARCHIVE) 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) {
                                if (linkedList_create(revisions_pool, 
&archive->revisions) == CELIX_SUCCESS) {
                                        archive->id = id;
@@ -139,19 +143,16 @@ celix_status_t bundleArchive_create(char
        return status;
 }
 
-celix_status_t bundleArchive_destroy(BUNDLE_ARCHIVE archive) {
-       celix_status_t status = CELIX_SUCCESS;
-
-       if (archive == NULL) {
-               status = CELIX_ILLEGAL_ARGUMENT;
-       } else {
+static apr_status_t bundleArchive_destroy(void *archiveP) {
+       BUNDLE_ARCHIVE archive = archiveP;
+       if (archive != NULL) {
                if (archive->archiveRootDir != NULL) {
                        apr_dir_close(archive->archiveRootDir);
                }
        }
-
        archive = NULL;
-       return status;
+
+       return APR_SUCCESS;
 }
 
 celix_status_t bundleArchive_recreate(char * archiveRoot, apr_pool_t *mp, 
BUNDLE_ARCHIVE *bundle_archive) {
@@ -162,6 +163,7 @@ celix_status_t bundleArchive_recreate(ch
     status = CELIX_SUCCESS;
        archive = (BUNDLE_ARCHIVE) 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) {
                if (linkedList_create(revisions_pool, &archive->revisions) == 
CELIX_SUCCESS) {
                 apr_dir_t *dir;
@@ -441,7 +443,7 @@ celix_status_t bundleArchive_setLastModi
        return status;
 }
 
-celix_status_t bundleArchive_readLastModified(BUNDLE_ARCHIVE archive, time_t 
*time) {
+static celix_status_t bundleArchive_readLastModified(BUNDLE_ARCHIVE archive, 
time_t *time) {
        char timeStr[20];
        apr_file_t *lastModifiedFile;
        apr_status_t apr_status;
@@ -476,7 +478,7 @@ celix_status_t bundleArchive_readLastMod
        return status;
 }
 
-celix_status_t bundleArchive_writeLastModified(BUNDLE_ARCHIVE archive) {
+static celix_status_t bundleArchive_writeLastModified(BUNDLE_ARCHIVE archive) {
        celix_status_t status = CELIX_SUCCESS;
        apr_file_t *lastModifiedFile;
        char timeStr[20];
@@ -512,7 +514,7 @@ celix_status_t bundleArchive_revise(BUND
        return status;
 }
 
-celix_status_t bundleArchive_reviseInternal(BUNDLE_ARCHIVE archive, bool 
isReload, long revNr, char * location, char *inputFile) {
+static celix_status_t bundleArchive_reviseInternal(BUNDLE_ARCHIVE archive, 
bool isReload, long revNr, char * location, char *inputFile) {
     celix_status_t status;
     BUNDLE_REVISION revision = NULL;
 
@@ -538,7 +540,7 @@ celix_status_t bundleArchive_rollbackRev
        return CELIX_SUCCESS;
 }
 
-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 
archive, char *location, char *inputFile, long revNr, BUNDLE_REVISION 
*bundle_revision) {
     celix_status_t status = CELIX_SUCCESS;
     char root[256];
     long refreshCount;
@@ -567,7 +569,7 @@ celix_status_t bundleArchive_createRevis
        return status;
 }
 
-celix_status_t bundleArchive_getRevisionLocation(BUNDLE_ARCHIVE archive, long 
revNr, char **revision_location) {
+static celix_status_t bundleArchive_getRevisionLocation(BUNDLE_ARCHIVE 
archive, long revNr, char **revision_location) {
     celix_status_t status;
        char revisionLocation[256];
        long refreshCount;
@@ -595,7 +597,7 @@ celix_status_t bundleArchive_getRevision
        return status;
 }
 
-celix_status_t bundleArchive_setRevisionLocation(BUNDLE_ARCHIVE archive, char 
* location, long revNr) {
+static celix_status_t bundleArchive_setRevisionLocation(BUNDLE_ARCHIVE 
archive, char * location, long revNr) {
        celix_status_t status = CELIX_SUCCESS;
 
        char revisionLocation[256];
@@ -635,7 +637,7 @@ celix_status_t bundleArchive_closeAndDel
        return status;
 }
 
-celix_status_t bundleArchive_initialize(BUNDLE_ARCHIVE archive) {
+static celix_status_t bundleArchive_initialize(BUNDLE_ARCHIVE archive) {
        celix_status_t status = CELIX_SUCCESS;
 
        if (archive->archiveRootDir == NULL) {
@@ -689,7 +691,7 @@ celix_status_t bundleArchive_initialize(
        return status;
 }
 
-celix_status_t bundleArchive_deleteTree(char * directory, apr_pool_t *mp) {
+static celix_status_t bundleArchive_deleteTree(char * directory, apr_pool_t 
*mp) {
        apr_dir_t *dir;
        celix_status_t status = CELIX_SUCCESS;
        apr_status_t stat = apr_dir_open(&dir, directory, mp);

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Mon Apr 23 08:29:43 
2012
@@ -230,9 +230,9 @@ celix_status_t framework_destroy(FRAMEWO
                        linkedListIterator_destroy(iter);
                }
 
-               if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
-                       bundleArchive_destroy(archive);
-               }
+//             if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
+//                     bundleArchive_destroy(archive);
+//             }
                bundle_destroy(bundle);
                hashMapIterator_remove(iterator);
        }

Modified: incubator/celix/trunk/framework/private/src/miniunz.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/miniunz.c?rev=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/miniunz.c (original)
+++ incubator/celix/trunk/framework/private/src/miniunz.c Mon Apr 23 08:29:43 
2012
@@ -209,7 +209,6 @@ int do_extract_currentfile(unzFile uf, c
 
     if ((*filename_withoutpath)=='\0') {
                char * dir;
-               printf("creating directory: %s\n",filename_inzip);
                dir = (char *)malloc(strlen(revisionRoot) + 
strlen(filename_inzip) + 2);
                strcpy(dir, revisionRoot);
                strcat(dir, "/");

Modified: incubator/celix/trunk/framework/private/src/service_registration.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registration.c?rev=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registration.c 
(original)
+++ incubator/celix/trunk/framework/private/src/service_registration.c Mon Apr 
23 08:29:43 2012
@@ -26,6 +26,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <apr_strings.h>
+
 #include "service_registration.h"
 #include "constants.h"
 #include "service_factory.h"

Modified: incubator/celix/trunk/framework/private/src/service_tracker.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_tracker.c?rev=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Mon Apr 23 
08:29:43 2012
@@ -25,6 +25,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+
+#include <apr_strings.h>
+
 #include "service_tracker.h"
 #include "bundle_context.h"
 #include "constants.h"

Modified: incubator/celix/trunk/framework/public/include/bundle_archive.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/bundle_archive.h?rev=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/bundle_archive.h (original)
+++ incubator/celix/trunk/framework/public/include/bundle_archive.h Mon Apr 23 
08:29:43 2012
@@ -36,7 +36,6 @@
 typedef struct bundleArchive * BUNDLE_ARCHIVE;
 
 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_destroy(BUNDLE_ARCHIVE archive);
 celix_status_t bundleArchive_createSystemBundleArchive(apr_pool_t *mp, 
BUNDLE_ARCHIVE *bundle_archive);
 celix_status_t bundleArchive_recreate(char * archiveRoot, apr_pool_t *mp, 
BUNDLE_ARCHIVE *bundle_archive);
 celix_status_t bundleArchive_getId(BUNDLE_ARCHIVE archive, long *id);

Modified: incubator/celix/trunk/shell/update_command.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/update_command.c?rev=1329121&r1=1329120&r2=1329121&view=diff
==============================================================================
--- incubator/celix/trunk/shell/update_command.c (original)
+++ incubator/celix/trunk/shell/update_command.c Mon Apr 23 08:29:43 2012
@@ -1,3 +1,4 @@
+
 /**
  *Licensed to the Apache Software Foundation (ASF) under one
  *or more contributor license agreements.  See the NOTICE file
@@ -25,7 +26,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <curl/curl.h>
-#include <curl/types.h>
 #include <curl/easy.h>
 
 #include "command_private.h"


Reply via email to