PengZheng commented on code in PR #476:
URL: https://github.com/apache/celix/pull/476#discussion_r1155448098
##########
bundles/shell/shell/src/lb_command.c:
##########
@@ -49,16 +46,68 @@ typedef struct lb_options {
char *listGroup;
} lb_options_t;
-static char * psCommand_stateString(bundle_state_e state);
+typedef struct lb_command_bundle_info {
+ long id;
+ char* name;
+ char* symbolicName;
+ celix_version_t* version;
+ char* group;
+ char* location;
+ bundle_state_e state;
+} lb_command_bundle_info_t;
+
+static int lbCommand_bundleInfoCmp(const lb_command_bundle_info_t* a, const
lb_command_bundle_info_t* b) {
+ return (int)(a->id - b->id);
+}
+
+static void lbCommand_collectBundleInfo_callback(void* data, const
celix_bundle_t* bnd) {
+ celix_array_list_t* infoEntries = data;
+ lb_command_bundle_info_t* info = malloc(sizeof(*info));
+ if (info != NULL) {
+ info->id = celix_bundle_getId(bnd);
+ info->name = celix_utils_strdup(celix_bundle_getName(bnd));
+ info->location = celix_utils_strdup(celix_bundle_getLocation(bnd));
+ info->symbolicName =
celix_utils_strdup(celix_bundle_getSymbolicName(bnd));
+ info->version = celix_version_copy(celix_bundle_getVersion(bnd));
+ info->group = celix_utils_strdup(celix_bundle_getGroup(bnd));
+ info->state = celix_bundle_getState(bnd);
+ }
+ celix_arrayList_add(infoEntries, info);
+}
+
+static celix_array_list_t* lbCommand_collectBundleInfo(celix_bundle_context_t
*ctx) {
+ celix_array_list_t* infoEntries = celix_arrayList_create();
+ celix_bundleContext_useBundles(ctx, (void*)infoEntries,
lbCommand_collectBundleInfo_callback);
+ celix_arrayList_sort(infoEntries, (int (*)(const void *, const void
*))lbCommand_bundleInfoCmp);
+ return infoEntries;
+}
+
+static void lbCommand_freeBundleInfoEntries(celix_array_list_t* infoEntries) {
+ if (infoEntries == NULL) {
Review Comment:
This is unnecessary if we only add non-null entry.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]