Copied: incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty)
Modified: incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c?rev=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c (original) +++ incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c Thu Nov 17 12:36:14 2011 @@ -232,8 +232,8 @@ static void paintFrame_destroy(GtkWidget frame->showing = false; - bundleContext_getBundleById(frame->context, 0, &bundle); - bundle_stop(bundle, 0); +// bundleContext_getBundleById(frame->context, 0, &bundle); +// bundle_stop(bundle, 0); } static void paintFrame_destroyWidgets(PAINT_FRAME frame) { Copied: incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/square/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/square/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/square/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/square/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/square/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/triangle/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/triangle/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/triangle/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/triangle/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/triangle/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/examples/receiver-2.0/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/receiver-2.0/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/receiver-2.0/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/receiver-2.0/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/receiver-2.0/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/examples/receiver/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/receiver/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/receiver/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/receiver/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/receiver/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/examples/sender/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/sender/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/sender/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/sender/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/sender/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/examples/whiteboard/publisherA/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/whiteboard/publisherA/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/publisherA/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/whiteboard/publisherA/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/whiteboard/publisherA/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/examples/whiteboard/publisherB/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/whiteboard/publisherB/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/publisherB/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/whiteboard/publisherB/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/whiteboard/publisherB/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/examples/whiteboard/tracker/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/whiteboard/tracker/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/whiteboard/tracker/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/whiteboard/tracker/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/examples/whiteboard/tracker_depman/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/examples/whiteboard/tracker_depman/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker_depman/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/examples/whiteboard/tracker_depman/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/examples/whiteboard/tracker_depman/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Modified: incubator/celix/trunk/framework/private/include/bundle_archive.h URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle_archive.h?rev=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/include/bundle_archive.h (original) +++ incubator/celix/trunk/framework/private/include/bundle_archive.h Thu Nov 17 12:36:14 2011 @@ -35,7 +35,7 @@ typedef struct bundleArchive * BUNDLE_ARCHIVE; -celix_status_t bundleArchive_create(char * archiveRoot, long id, char * location, 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 *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); 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=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/include/bundle_cache.h (original) +++ incubator/celix/trunk/framework/private/include/bundle_cache.h Thu Nov 17 12:36:14 2011 @@ -35,7 +35,7 @@ typedef struct bundleCache * BUNDLE_CACH celix_status_t bundleCache_create(PROPERTIES configurationMap, apr_pool_t *mp, BUNDLE_CACHE *bundle_cache); celix_status_t bundleCache_destroy(BUNDLE_CACHE cache); celix_status_t bundleCache_getArchives(BUNDLE_CACHE cache, ARRAY_LIST *archives); -celix_status_t bundleCache_createArchive(BUNDLE_CACHE cache, long id, char * location, apr_pool_t *bundlePool, BUNDLE_ARCHIVE *archive); +celix_status_t bundleCache_createArchive(BUNDLE_CACHE cache, long id, char * location, char *inputFile, apr_pool_t *bundlePool, BUNDLE_ARCHIVE *archive); celix_status_t bundleCache_delete(BUNDLE_CACHE cache); Modified: incubator/celix/trunk/framework/private/include/bundle_context.h URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle_context.h?rev=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/include/bundle_context.h (original) +++ incubator/celix/trunk/framework/private/include/bundle_context.h Thu Nov 17 12:36:14 2011 @@ -37,6 +37,7 @@ celix_status_t bundleContext_getFramewor celix_status_t bundleContext_getMemoryPool(BUNDLE_CONTEXT context, apr_pool_t **memory_pool); celix_status_t bundleContext_installBundle(BUNDLE_CONTEXT context, char * location, BUNDLE *bundle); +celix_status_t bundleContext_installBundle2(BUNDLE_CONTEXT context, char * location, char *inputFile, BUNDLE *bundle); celix_status_t bundleContext_registerService(BUNDLE_CONTEXT context, char * serviceName, void * svcObj, PROPERTIES properties, SERVICE_REGISTRATION *service_registration); Modified: incubator/celix/trunk/framework/private/include/framework.h URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/framework.h?rev=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/include/framework.h (original) +++ incubator/celix/trunk/framework/private/include/framework.h Thu Nov 17 12:36:14 2011 @@ -43,7 +43,7 @@ void framework_stop(FRAMEWORK framework) celix_status_t fw_getProperty(FRAMEWORK framework, const char *name, char **value); -celix_status_t fw_installBundle(FRAMEWORK framework, BUNDLE * bundle, char * location); +celix_status_t fw_installBundle(FRAMEWORK framework, BUNDLE * bundle, char * location, char *inputFile); celix_status_t fw_uninstallBundle(FRAMEWORK framework, BUNDLE bundle); celix_status_t framework_getBundleEntry(FRAMEWORK framework, BUNDLE bundle, char *name, apr_pool_t *pool, char **entry); Modified: incubator/celix/trunk/framework/private/include/manifest.h URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/manifest.h?rev=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/include/manifest.h (original) +++ incubator/celix/trunk/framework/private/include/manifest.h Thu Nov 17 12:36:14 2011 @@ -31,6 +31,7 @@ struct manifest { PROPERTIES mainAttributes; + HASH_MAP attributes; }; typedef struct manifest * MANIFEST; @@ -39,6 +40,7 @@ void manifest_destroy(MANIFEST manifest) void manifest_clear(MANIFEST manifest); PROPERTIES manifest_getMainAttributes(MANIFEST manifest); +celix_status_t manifest_getEntries(MANIFEST manifest, HASH_MAP *map); celix_status_t manifest_read(char *filename, MANIFEST *manifest); void manifest_write(MANIFEST manifest, char * filename); 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=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/src/bundle_archive.c (original) +++ incubator/celix/trunk/framework/private/src/bundle_archive.c Thu Nov 17 12:36:14 2011 @@ -100,7 +100,7 @@ celix_status_t bundleArchive_reviseInter 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, 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 *bundle_archive) { celix_status_t status = CELIX_SUCCESS; apr_pool_t *revisions_pool; BUNDLE_ARCHIVE archive; @@ -123,7 +123,7 @@ celix_status_t bundleArchive_create(char bundleArchive_initialize(archive); - bundleArchive_revise(archive, location, NULL); + bundleArchive_revise(archive, location, inputFile); *bundle_archive = archive; } else { @@ -185,9 +185,9 @@ celix_status_t bundleArchive_recreate(ch apr_dir_t *dir; if (apr_dir_open(&dir, archiveRoot, mp) == APR_SUCCESS) { apr_finfo_t dp; + long idx; while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) == APR_SUCCESS) { if (dp.filetype == APR_DIR && (strncmp(dp.name, "version", 7) == 0)) { - long idx; sscanf(dp.name, "version%*d.%ld", &idx); } } @@ -195,7 +195,7 @@ celix_status_t bundleArchive_recreate(ch char *location; status = bundleArchive_getRevisionLocation(archive, 0, &location); if (status == CELIX_SUCCESS) { - bundleArchive_revise(archive, location, NULL); + bundleArchive_reviseInternal(archive, true, idx, location, NULL); *bundle_archive = archive; } 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=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/src/bundle_cache.c (original) +++ incubator/celix/trunk/framework/private/src/bundle_cache.c Thu Nov 17 12:36:14 2011 @@ -156,7 +156,7 @@ celix_status_t bundleCache_getArchives(B return status; } -celix_status_t bundleCache_createArchive(BUNDLE_CACHE cache, long id, char * location, apr_pool_t *bundlePool, +celix_status_t bundleCache_createArchive(BUNDLE_CACHE cache, long id, char * location, char *inputFile, apr_pool_t *bundlePool, BUNDLE_ARCHIVE *bundle_archive) { celix_status_t status; char archiveRoot[256]; @@ -165,7 +165,7 @@ celix_status_t bundleCache_createArchive if (cache && location && bundlePool) { sprintf(archiveRoot, "%s/bundle%ld", cache->cacheDir, id); - status = bundleArchive_create(apr_pstrdup(cache->mp, archiveRoot), id, location, bundlePool, bundle_archive); + status = bundleArchive_create(apr_pstrdup(cache->mp, archiveRoot), id, location, inputFile, bundlePool, bundle_archive); } return status; 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=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/src/bundle_context.c (original) +++ incubator/celix/trunk/framework/private/src/bundle_context.c Thu Nov 17 12:36:14 2011 @@ -118,11 +118,15 @@ celix_status_t bundleContext_getMemoryPo } celix_status_t bundleContext_installBundle(BUNDLE_CONTEXT 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 status = CELIX_SUCCESS; BUNDLE b = NULL; if (context != NULL && *bundle == NULL) { - if (fw_installBundle(context->framework, &b, location) != CELIX_SUCCESS) { + if (fw_installBundle(context->framework, &b, location, inputFile) != CELIX_SUCCESS) { status = CELIX_FRAMEWORK_EXCEPTION; } else { *bundle = b; Modified: incubator/celix/trunk/framework/private/src/bundle_revision.c URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_revision.c?rev=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/src/bundle_revision.c (original) +++ incubator/celix/trunk/framework/private/src/bundle_revision.c Thu Nov 17 12:36:14 2011 @@ -32,7 +32,9 @@ celix_status_t bundleRevision_create(cha } else { if (inputFile != NULL) { status = extractBundle(inputFile, root); - } else { + } else if (strcmp(location, "inputstream:") != 0) { + // TODO how to handle this correctly? + // If location != inputstream, extract it, else ignore it and assume this is a cache entry. status = extractBundle(location, root); } Modified: incubator/celix/trunk/framework/private/src/framework.c URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/src/framework.c (original) +++ incubator/celix/trunk/framework/private/src/framework.c Thu Nov 17 12:36:14 2011 @@ -75,7 +75,7 @@ celix_status_t framework_releaseInstallL long framework_getNextBundleId(FRAMEWORK framework); -celix_status_t fw_installBundle2(FRAMEWORK framework, BUNDLE * bundle, long id, char * location, BUNDLE_ARCHIVE archive); +celix_status_t fw_installBundle2(FRAMEWORK framework, BUNDLE * bundle, long id, char * location, char *inputFile, BUNDLE_ARCHIVE archive); celix_status_t fw_refreshBundles(FRAMEWORK framework, BUNDLE bundles[], int size); celix_status_t fw_refreshBundle(FRAMEWORK framework, BUNDLE bundle); @@ -279,7 +279,7 @@ celix_status_t fw_init(FRAMEWORK framewo BUNDLE bundle; char *location; status = bundleArchive_getLocation(archive, &location); - fw_installBundle2(framework, &bundle, id, location, archive); + fw_installBundle2(framework, &bundle, id, location, NULL, archive); } } arrayList_destroy(archives); @@ -391,11 +391,11 @@ celix_status_t fw_getProperty(FRAMEWORK return status; } -celix_status_t fw_installBundle(FRAMEWORK framework, BUNDLE * bundle, char * location) { - return fw_installBundle2(framework, bundle, -1, location, NULL); +celix_status_t fw_installBundle(FRAMEWORK framework, BUNDLE * bundle, char * location, char *inputFile) { + return fw_installBundle2(framework, bundle, -1, location, inputFile, NULL); } -celix_status_t fw_installBundle2(FRAMEWORK framework, BUNDLE * bundle, long id, char * location, BUNDLE_ARCHIVE archive) { +celix_status_t fw_installBundle2(FRAMEWORK framework, BUNDLE * bundle, long id, char * location, char *inputFile, BUNDLE_ARCHIVE archive) { BUNDLE_ARCHIVE bundle_archive = NULL; BUNDLE_STATE state; @@ -422,7 +422,7 @@ celix_status_t fw_installBundle2(FRAMEWO apr_pool_create(&bundlePool, framework->mp); if (archive == NULL) { id = framework_getNextBundleId(framework); - status = bundleCache_createArchive(framework->cache, id, location, bundlePool, &bundle_archive); + status = bundleCache_createArchive(framework->cache, id, location, inputFile, bundlePool, &bundle_archive); if (status != CELIX_SUCCESS) { framework_releaseInstallLock(framework, location); return status; @@ -1224,7 +1224,7 @@ celix_status_t getManifest(BUNDLE_ARCHIV status = bundleArchive_getCurrentRevisionNumber(archive, &revisionNumber); if (status == CELIX_SUCCESS) { if (status == CELIX_SUCCESS) { - sprintf(mf, "%s/version%ld.%ld/MANIFEST/MANIFEST.MF", + sprintf(mf, "%s/version%ld.%ld/META-INF/MANIFEST.MF", archiveRoot, refreshCount, revisionNumber Modified: incubator/celix/trunk/framework/private/src/manifest.c URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/manifest.c?rev=1203167&r1=1203166&r2=1203167&view=diff ============================================================================== --- incubator/celix/trunk/framework/private/src/manifest.c (original) +++ incubator/celix/trunk/framework/private/src/manifest.c Thu Nov 17 12:36:14 2011 @@ -28,8 +28,10 @@ #include "celixbool.h" #include "manifest.h" +#include "utils.h" int fpeek(FILE *stream); +celix_status_t manifest_readAttributes(MANIFEST manifest, PROPERTIES properties, FILE *file); void manifest_clear(MANIFEST manifest) { @@ -39,89 +41,89 @@ PROPERTIES manifest_getMainAttributes(MA return manifest->mainAttributes; } +celix_status_t manifest_getEntries(MANIFEST manifest, HASH_MAP *map) { + *map = manifest->attributes; + return CELIX_SUCCESS; +} + celix_status_t manifest_read(char *filename, MANIFEST *manifest) { celix_status_t status = CELIX_SUCCESS; MANIFEST mf = NULL; mf = (MANIFEST) malloc(sizeof(*mf)); if (mf != NULL) { - PROPERTIES mainAttributes = properties_create(); - - mf->mainAttributes = mainAttributes; + mf->mainAttributes = properties_create(); + mf->attributes = hashMap_create(string_hash, NULL, string_equals, NULL); FILE *file = fopen ( filename, "r" ); if (file != NULL) { - char lbuf [ 512 ]; - char * lastline; + char lbuf[512]; + manifest_readAttributes(mf, mf->mainAttributes, file); + + int len; char * name = NULL; - char * value = NULL; + bool skipEmptyLines = true; + char * lastline; + + while (fgets(lbuf, sizeof(lbuf), file) != NULL ) { + len = strlen(lbuf); + if (lbuf[--len] != '\n') { + printf("MANIFEST: Line too long\n"); + return CELIX_FILE_IO_EXCEPTION; + } + if (len > 0 && lbuf[len - 1] == '\r') { + --len; + } + if (len == 0 && skipEmptyLines) { + continue; + } + skipEmptyLines = false; + + if (name == NULL) { + 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 = strncpy(name, lbuf+6, len - 6); + name[len - 6] = '\0'; + } else { + printf("MANIFEST: Invalid manifest format\n"); + return CELIX_FILE_IO_EXCEPTION; + } + + if (fpeek(file) == ' ') { + int newlen = len - 6; + lastline = (char *) malloc(newlen + 1); + lastline = strncpy(lastline, lbuf+6, len - 6); + lastline[newlen] = '\0'; + continue; + } + } else { + int newlen = strlen(lastline) + len; + char buf[newlen]; + strcpy(buf, lastline); + strncat(buf, lbuf+1, len - 1); + + if (fpeek(file) == ' ') { + lastline = strcpy(lastline, buf); + continue; + } + name = (char *) malloc(strlen(buf) + 1); + name = strcpy(name, buf); + name[strlen(buf)] = '\0'; + lastline = NULL; + } + + PROPERTIES attributes = hashMap_get(mf->attributes, name); + if (attributes == NULL) { + attributes = properties_create(); + hashMap_put(mf->attributes, strdup(name), attributes); + } + manifest_readAttributes(mf, attributes, file); - while ( fgets ( lbuf, sizeof lbuf, file ) != NULL ) { - bool lineContinued = false; - int len = strlen(lbuf); - - if (lbuf[--len] != '\n') { - return CELIX_INVALID_SYNTAX; - } - - if (len > 0 && lbuf[len-1] == '\r') { - --len; - } - - if (len == 0) { - break; - } - - int i = 0; - if (lbuf[0] == ' ') { - // continuation of previous line - if (name == NULL) { - return CELIX_INVALID_SYNTAX; - } - lineContinued = true; - int newlen = strlen(lastline) + len - 1; - char buf [newlen]; - strcpy(buf, lastline); - strncat(buf, lbuf+1, len - 1); - - if (fpeek(file) == ' ') { - lastline = strcpy(lastline, buf); - continue; - } - value = (char *) malloc(strlen(buf) + 1); - value = strcpy(value, buf); - value[strlen(buf)] = '\0'; - lastline = NULL; - } else { - while (lbuf[i++] != ':') { - if (i >= len) { - // throw new IOException("invalid header field"); - return CELIX_INVALID_SYNTAX; - } - } - if (lbuf[i++] != ' ') { - // throw new IOException("invalid header field"); - return CELIX_INVALID_SYNTAX; - } - name = (char *) malloc((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 = strncpy(lastline, lbuf+i, len -i); - continue; - } - value = (char *) malloc((len + 1) - i); - value = strncpy(value, lbuf+i, len - i); - value[len - i] = '\0'; - } - - if ((properties_set(mainAttributes, name, value) != NULL) && (!lineContinued)) { - printf("Duplicate entry: %s", name); - } free(name); - free(value); + name = NULL; + skipEmptyLines = true; } fclose(file); @@ -162,3 +164,79 @@ int fpeek(FILE *stream) { return c; } +celix_status_t manifest_readAttributes(MANIFEST manifest, PROPERTIES properties, FILE *file) { + char *name = NULL; + char *value = NULL; + char *lastLine = NULL; + char lbuf[512]; + + int len; + while (fgets(lbuf, sizeof(lbuf), file ) != NULL ) { + len = strlen(lbuf); + bool lineContinued = false; + if (lbuf[--len] != '\n') { + printf("MANIFEST: Line too long\n"); + return CELIX_FILE_IO_EXCEPTION; + } + if (len > 0 && lbuf[len - 1] == '\r') { + --len; + } + if (len == 0) { + break; + } + int i = 0; + if (lbuf[0] == ' ') { + // Line continued + if (name == NULL) { + printf("MANIFEST: No continued line expected\n"); + return CELIX_FILE_IO_EXCEPTION; + } + lineContinued = true; + int newlen = strlen(lastLine) + len - 1; + char buf[newlen]; + strcpy(buf, lastLine); + strncat(buf, lbuf+1, len - 1); + + if (fpeek(file) == ' ') { + lastLine = strcpy(lastLine, buf); + continue; + } + value = (char *) malloc(strlen(buf) + 1); + value = strcpy(value, buf); + value[strlen(buf)] = '\0'; + lastLine = NULL; + } else { + while (lbuf[i++] != ':') { + if (i >= len) { + printf("MANIFEST: Invalid header\n"); + return CELIX_FILE_IO_EXCEPTION; + } + } + if (lbuf[i++] != ' ') { + printf("MANIFEST: Invalid header\n"); + return CELIX_FILE_IO_EXCEPTION; + } + name = (char *) malloc((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 = strncpy(lastLine, lbuf+i, len -i); + continue; + } + value = (char *) malloc((len + 1) - i); + value = strncpy(value, lbuf+i, len - i); + value[len - i] = '\0'; + } + + if ((properties_set(properties, name, value) != NULL) && (!lineContinued)) { + printf("Duplicate entry: %s", name); + } + free(name); + free(value); + } + + return CELIX_SUCCESS; +} + Copied: incubator/celix/trunk/log_service/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/log_service/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_service/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/log_service/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/log_service/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/log_writer/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/log_writer/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_writer/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/log_writer/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/log_writer/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/remote_services/calc_shell/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/remote_services/calc_shell/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/remote_services/calc_shell/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/remote_services/calc_shell/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/remote_services/discovery/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/remote_services/discovery/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/remote_services/discovery/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/remote_services/discovery/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/remote_services/example_endpoint/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/remote_services/example_endpoint/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/example_endpoint/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/remote_services/example_endpoint/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/remote_services/example_endpoint/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/remote_services/example_proxy/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/remote_services/example_proxy/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/example_proxy/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/remote_services/example_proxy/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/remote_services/example_proxy/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/remote_services/example_service/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/remote_services/example_service/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/example_service/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/remote_services/example_service/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/remote_services/example_service/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/remote_services/remote_service_admin/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/remote_services/remote_service_admin/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/remote_services/remote_service_admin/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/remote_services/remote_service_admin/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/remote_services/topology_manager/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/remote_services/topology_manager/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/remote_services/topology_manager/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/remote_services/topology_manager/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/shell/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/shell/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/shell/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/shell/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty) Copied: incubator/celix/trunk/shell_tui/META-INF/MANIFEST.MF (from r1198848, incubator/celix/trunk/shell_tui/MANIFEST/MANIFEST.MF) URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell_tui/META-INF/MANIFEST.MF?p2=incubator/celix/trunk/shell_tui/META-INF/MANIFEST.MF&p1=incubator/celix/trunk/shell_tui/MANIFEST/MANIFEST.MF&r1=1198848&r2=1203167&rev=1203167&view=diff ============================================================================== (empty)
