You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2017/11/20 20:33:03 UTC
[06/46] celix git commit: CELIX-417: Initial refactoring for CMake
usage
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/README.md
----------------------------------------------------------------------
diff --git a/shell/README.md b/shell/README.md
index b830edc..76f1cc7 100644
--- a/shell/README.md
+++ b/shell/README.md
@@ -19,10 +19,15 @@ While the shell can be extended with additional commands by other bundles, it al
Further information about a command can be retrieved by using `help` combined with the command.
+## CMake options
+ BUILD_SHELL=ON
+
## Shell Config Options
-- SHELL_USE_ANSI_COLORS - Wether shell command are allowed to use
+- SHELL_USE_ANSI_COLORS - Whether shell command are allowed to use
ANSI colors when printing info. default is true.
-## CMake options
- BUILD_SHELL=ON
+## Using info
+
+If the Celix Shell is installed The `FindCelix.cmake` will set:
+ - The `Celix::dependency_manager_cxx_static` library target
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/include/command.h
----------------------------------------------------------------------
diff --git a/shell/include/command.h b/shell/include/command.h
new file mode 100644
index 0000000..0e86dcc
--- /dev/null
+++ b/shell/include/command.h
@@ -0,0 +1,57 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * command.h
+ *
+ * \date Aug 13, 2010
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+#ifndef COMMAND_H_
+#define COMMAND_H_
+
+#include "celix_errno.h"
+#include <stdio.h>
+
+#define OSGI_SHELL_COMMAND_NAME "command.name"
+#define OSGI_SHELL_COMMAND_USAGE "command.usage"
+#define OSGI_SHELL_COMMAND_DESCRIPTION "command.description"
+
+static const char * const OSGI_SHELL_COMMAND_SERVICE_NAME = "commandService";
+
+typedef struct commandService command_service_t;
+typedef command_service_t * command_service_pt;
+
+/**
+ * The command service can be used to register additional shell commands.
+ * The service should be register with the following properties:
+ * - command.name: mandatory, name of the command e.g. 'lb'
+ * - command.usage: optional, string describing how tu use the commmand e.g. 'lb [-l | -s | -u]'
+ * - command.descrription: optional, string describing the command e.g. 'list bundles.'
+ */
+struct commandService {
+ void *handle;
+ celix_status_t (*executeCommand)(void *handle, char * commandLine, FILE *outStream, FILE *errorStream);
+};
+
+
+
+
+#endif /* COMMAND_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/include/shell.h
----------------------------------------------------------------------
diff --git a/shell/include/shell.h b/shell/include/shell.h
new file mode 100644
index 0000000..c8e7d60
--- /dev/null
+++ b/shell/include/shell.h
@@ -0,0 +1,51 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * shell.h
+ *
+ * \date Aug 12, 2010
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+#ifndef SHELL_H_
+#define SHELL_H_
+
+#include "array_list.h"
+#include "service_reference.h"
+
+static const char * const OSGI_SHELL_SERVICE_NAME = "shellService";
+
+typedef struct shell shell_t;
+typedef shell_t* shell_pt;
+
+struct shellService {
+ shell_pt shell;
+
+ celix_status_t (*getCommands)(shell_pt shell_ptr, array_list_pt *commands_ptr);
+ celix_status_t (*getCommandUsage)(shell_pt shell_ptr, char *command_name_str, char **usage_str);
+ celix_status_t (*getCommandDescription)(shell_pt shell_ptr, char *command_name_str, char **command_description_str);
+ celix_status_t (*getCommandReference)(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
+ celix_status_t (*executeCommand)(shell_pt shell_ptr, char * command_line_str, FILE *out, FILE *err);
+};
+
+typedef struct shellService shell_service_t;
+typedef shell_service_t* shell_service_pt;
+
+#endif /* SHELL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/include/shell_constants.h
----------------------------------------------------------------------
diff --git a/shell/include/shell_constants.h b/shell/include/shell_constants.h
new file mode 100644
index 0000000..1e7f875
--- /dev/null
+++ b/shell/include/shell_constants.h
@@ -0,0 +1,27 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+
+
+#ifndef SHELL_CONSTANTS_H_
+#define SHELL_CONSTANTS_H_
+
+#define SHELL_USE_ANSI_COLORS "SHELL_USE_ANSI_COLORS"
+#define SHELL_USE_ANSI_COLORS_DEFAULT_VALUE "true"
+
+#endif /* SHELL_CONSTANTS_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/include/shell_private.h
----------------------------------------------------------------------
diff --git a/shell/private/include/shell_private.h b/shell/private/include/shell_private.h
deleted file mode 100644
index 7270fa2..0000000
--- a/shell/private/include/shell_private.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * shell_private.h
- *
- * \date Aug 13, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef SHELL_PRIVATE_H_
-#define SHELL_PRIVATE_H_
-
-#include "bundle_context.h"
-#include "shell.h"
-#include "hash_map.h"
-#include "command.h"
-#include "log_helper.h"
-
-struct shell {
- bundle_context_pt bundle_context_ptr;
- hash_map_pt command_reference_map_ptr;
- hash_map_pt command_name_map_ptr;
- log_helper_pt logHelper;
-};
-
-celix_status_t shell_create(bundle_context_pt context_ptr, shell_service_pt *shell_service_ptr);
-celix_status_t shell_destroy(shell_service_pt *shell_service_ptr);
-celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc);
-celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc);
-
-celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
-celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, FILE *out, FILE *err);
-
-#endif /* SHELL_PRIVATE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/include/std_commands.h
----------------------------------------------------------------------
diff --git a/shell/private/include/std_commands.h b/shell/private/include/std_commands.h
deleted file mode 100644
index ef7f37e..0000000
--- a/shell/private/include/std_commands.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * std_commands.h
- *
- * \date March 27, 2014
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef __STD_COMMANDS_H_
-#define __STD_COMMANDS_H_
-
-#include "celix_errno.h"
-
-#define OSGI_SHELL_COMMAND_SEPARATOR " "
-
-celix_status_t psCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr);
-celix_status_t startCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr);
-celix_status_t stopCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t installCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t uninstallCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t updateCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t logCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t inspectCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t helpCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-
-#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/activator.c
----------------------------------------------------------------------
diff --git a/shell/private/src/activator.c b/shell/private/src/activator.c
deleted file mode 100644
index ac298d8..0000000
--- a/shell/private/src/activator.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- * \date Aug 13, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "shell_private.h"
-#include "bundle_activator.h"
-#include "std_commands.h"
-#include "service_tracker.h"
-#include "constants.h"
-
-#define NUMBER_OF_COMMANDS 10
-
-struct command {
- celix_status_t (*exec)(void *handle, char *commandLine, FILE *out, FILE *err);
- char *name;
- char *description;
- char *usage;
- command_service_pt service;
- service_registration_pt reg;
- properties_pt props;
-};
-
-struct bundle_instance {
- shell_service_pt shellService;
- service_registration_pt registration;
- service_tracker_pt tracker;
-
- struct command std_commands[NUMBER_OF_COMMANDS];
-};
-
-typedef struct bundle_instance *bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context_ptr, void **_pptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- bundle_instance_pt instance_ptr = NULL;
-
- if (!_pptr || !context_ptr) {
- status = CELIX_ENOMEM;
- }
-
- if (status == CELIX_SUCCESS) {
- instance_ptr = (bundle_instance_pt) calloc(1, sizeof(struct bundle_instance));
- if (!instance_ptr) {
- status = CELIX_ENOMEM;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- status = shell_create(context_ptr, &instance_ptr->shellService);
- }
-
- if (status == CELIX_SUCCESS) {
- instance_ptr->std_commands[0] =
- (struct command) {
- .exec = psCommand_execute,
- .name = "lb",
- .description = "list bundles.",
- .usage = "lb [-l | -s | -u]"
- };
- instance_ptr->std_commands[1] =
- (struct command) {
- .exec = startCommand_execute,
- .name = "start",
- .description = "start bundle(s).",
- .usage = "start <id> [<id> ...]"
- };
- instance_ptr->std_commands[2] =
- (struct command) {
- .exec = stopCommand_execute,
- .name = "stop",
- .description = "stop bundle(s).",
- .usage = "stop <id> [<id> ...]"
- };
- instance_ptr->std_commands[3] =
- (struct command) {
- .exec = installCommand_execute,
- .name = "install",
- .description = "install bundle(s).",
- .usage = "install <file> [<file> ...]"
- };
- instance_ptr->std_commands[4] =
- (struct command) {
- .exec = uninstallCommand_execute,
- .name = "uninstall",
- .description = "uninstall bundle(s).",
- .usage = "uninstall <file> [<file> ...]"
- };
- instance_ptr->std_commands[5] =
- (struct command) {
- .exec = updateCommand_execute,
- .name = "update",
- .description = "update bundle(s).",
- .usage = "update <id> [<URL>]"
- };
- instance_ptr->std_commands[6] =
- (struct command) {
- .exec = helpCommand_execute,
- .name = "help",
- .description = "display available commands and description.",
- .usage = "help <command>]"
- };
- instance_ptr->std_commands[7] =
- (struct command) {
- .exec = logCommand_execute,
- .name = "log",
- .description = "print log.",
- .usage = "log"
- };
- instance_ptr->std_commands[8] =
- (struct command) {
- .exec = inspectCommand_execute,
- .name = "inspect",
- .description = "inspect services and components.",
- .usage = "inspect (service) (capability|requirement) [<id> ...]"
- };
- instance_ptr->std_commands[9] =
- (struct command) { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; /*marker for last element*/
-
- unsigned int i = 0;
- while (instance_ptr->std_commands[i].exec != NULL) {
- instance_ptr->std_commands[i].props = properties_create();
- if (!instance_ptr->std_commands[i].props) {
- status = CELIX_BUNDLE_EXCEPTION;
- break;
- }
-
- properties_set(instance_ptr->std_commands[i].props, OSGI_SHELL_COMMAND_NAME, instance_ptr->std_commands[i].name);
- properties_set(instance_ptr->std_commands[i].props, OSGI_SHELL_COMMAND_USAGE, instance_ptr->std_commands[i].usage);
- properties_set(instance_ptr->std_commands[i].props, OSGI_SHELL_COMMAND_DESCRIPTION, instance_ptr->std_commands[i].description);
- properties_set(instance_ptr->std_commands[i].props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-
- instance_ptr->std_commands[i].service = calloc(1, sizeof(*instance_ptr->std_commands[i].service));
- if (!instance_ptr->std_commands[i].service) {
- status = CELIX_ENOMEM;
- break;
- }
-
- instance_ptr->std_commands[i].service->handle = context_ptr;
- instance_ptr->std_commands[i].service->executeCommand = instance_ptr->std_commands[i].exec;
-
- i += 1;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- *_pptr = instance_ptr;
- }
-
-
- if (status != CELIX_SUCCESS) {
- bundleActivator_destroy(instance_ptr, context_ptr);
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_start(void *_ptr, bundle_context_pt context_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
-
- if (!instance_ptr || !context_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- properties_pt props = properties_create();
- properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
- status = bundleContext_registerService(context_ptr, (char *) OSGI_SHELL_SERVICE_NAME, instance_ptr->shellService, props, &instance_ptr->registration);
- }
-
- if (status == CELIX_SUCCESS) {
- service_tracker_customizer_pt cust = NULL;
- serviceTrackerCustomizer_create(instance_ptr->shellService->shell, NULL, (void *)shell_addCommand, NULL, (void *)shell_removeCommand, &cust);
- serviceTracker_create(context_ptr, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, cust, &instance_ptr->tracker);
- serviceTracker_open(instance_ptr->tracker);
- }
-
-
- if (status == CELIX_SUCCESS) {
- for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
- status = bundleContext_registerService(context_ptr, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME,
- instance_ptr->std_commands[i].service,
- instance_ptr->std_commands[i].props,
- &instance_ptr->std_commands[i].reg);
- if (status != CELIX_SUCCESS) {
- break;
- }
-
- }
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_stop(void *_ptr, bundle_context_pt context_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
-
- if (instance_ptr) {
- for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
- if (instance_ptr->std_commands[i].reg != NULL) {
- status = serviceRegistration_unregister(instance_ptr->std_commands[i].reg);
- instance_ptr->std_commands[i].reg = NULL;
- instance_ptr->std_commands[i].props = NULL;
- }
- }
-
- if (instance_ptr->tracker != NULL) {
- serviceTracker_close(instance_ptr->tracker);
- }
- } else {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_destroy(void *_ptr, bundle_context_pt __attribute__((__unused__)) context_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
-
- if (instance_ptr) {
- serviceRegistration_unregister(instance_ptr->registration);
-
- for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
- free(instance_ptr->std_commands[i].service);
- }
-
- shell_destroy(&instance_ptr->shellService);
-
- if (instance_ptr->tracker != NULL) {
- serviceTracker_destroy(instance_ptr->tracker);
- }
-
- free(instance_ptr);
- } else {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- return status;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/help_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/help_command.c b/shell/private/src/help_command.c
deleted file mode 100644
index 48615ae..0000000
--- a/shell/private/src/help_command.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * help_command.c
- *
- * \date Aug 20, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-#include "shell.h"
-#include "std_commands.h"
-
-celix_status_t helpCommand_execute(void *_ptr, char *line_str, FILE *out_ptr, FILE *err_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- bundle_context_pt context_ptr = _ptr;
- service_reference_pt shell_service_reference_ptr = NULL;
- shell_service_pt shell_ptr = NULL;
-
- if (!context_ptr || !line_str || !out_ptr || !err_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- status = bundleContext_getServiceReference(context_ptr, (char *) OSGI_SHELL_SERVICE_NAME, &shell_service_reference_ptr);
- }
-
- if (status == CELIX_SUCCESS) {
- status = bundleContext_getService(context_ptr, shell_service_reference_ptr, (void **) &shell_ptr);
- }
-
- if (status == CELIX_SUCCESS) {
- uint32_t out_len = 256;
- char *sub = NULL;
- char *save_ptr = NULL;
- char out_str[out_len];
-
- memset(out_str, 0, sizeof(out_str));
-
- strtok_r(line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
- sub = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-
- if (sub == NULL) {
- unsigned int i;
- array_list_pt commands = NULL;
-
- status = shell_ptr->getCommands(shell_ptr->shell, &commands);
- for (i = 0; i < arrayList_size(commands); i++) {
- char *name = arrayList_get(commands, i);
- fprintf(out_ptr, "%s\n", name);
- }
- fprintf(out_ptr, "\nUse 'help <command-name>' for more information.\n");
- arrayList_destroy(commands);
- } else {
- celix_status_t sub_status_desc;
- celix_status_t sub_status_usage;
- int i;
- array_list_pt commands = NULL;
- shell_ptr->getCommands(shell_ptr->shell, &commands);
- for (i = 0; i < arrayList_size(commands); i++) {
- char *name = arrayList_get(commands, i);
- if (strcmp(sub, name) == 0) {
- char *usage_str = NULL;
- char *desc_str = NULL;
-
- sub_status_desc = shell_ptr->getCommandDescription(shell_ptr->shell, name, &desc_str);
- sub_status_usage = shell_ptr->getCommandUsage(shell_ptr->shell, name, &usage_str);
-
- if (sub_status_usage == CELIX_SUCCESS && sub_status_desc == CELIX_SUCCESS) {
- fprintf(out_ptr, "Command : %s\n", name);
- fprintf(out_ptr, "Usage : %s\n", usage_str == NULL ? "" : usage_str);
- fprintf(out_ptr, "Description : %s\n", desc_str == NULL ? "" : desc_str);
- } else {
- fprintf(err_ptr, "Error retreiving help info for command '%s'\n", sub);
- }
-
- if (sub_status_desc != CELIX_SUCCESS && status == CELIX_SUCCESS) {
- status = sub_status_desc;
- }
- if (sub_status_usage != CELIX_SUCCESS && status == CELIX_SUCCESS) {
- status = sub_status_usage;
- }
- }
- }
- arrayList_destroy(commands);
- }
- }
-
- return status;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/inspect_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/inspect_command.c b/shell/private/src/inspect_command.c
deleted file mode 100644
index cb93e9c..0000000
--- a/shell/private/src/inspect_command.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * inspect_command.c
- *
- * \date Oct 13, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-
-#include "std_commands.h"
-
-#define SERVICE_TYPE "service"
-#define CAPABILITY "capability"
-#define REQUIREMENT "requirement"
-
-celix_status_t inspectCommand_printExportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream);
-celix_status_t inspectCommand_printImportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream);
-
-celix_status_t inspectCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream) {
- celix_status_t status = CELIX_SUCCESS;
-
- bundle_context_pt context = handle;
-
- char *token;
- strtok_r(commandline, " ", &token);
- char *type = strtok_r(NULL, " ", &token);
- if (type != NULL) {
- char *direction = strtok_r(NULL, " ", &token);
- if (direction != NULL) {
- array_list_pt ids = NULL;
- char *id = strtok_r(NULL, " ", &token);
-
- arrayList_create(&ids);
- while (id != NULL) {
- arrayList_add(ids, id);
- id = strtok_r(NULL, " ", &token);
- }
-
- if (strcmp(type, SERVICE_TYPE) == 0) {
- if (strcmp(direction, CAPABILITY) == 0) {
- status = inspectCommand_printExportedServices(context, ids, outStream, errStream);
- if (status != CELIX_SUCCESS) {
- fprintf(errStream, "INSPECT: Error\n");
- }
- } else if (strcmp(direction, REQUIREMENT) == 0) {
- status = inspectCommand_printImportedServices(context, ids, outStream, errStream);
- if (status != CELIX_SUCCESS) {
- fprintf(errStream, "INSPECT: Error\n");
- }
- } else {
- fprintf(errStream, "INSPECT: Invalid argument\n");
- }
- } else {
- fprintf(errStream, "INSPECT: Invalid argument\n");
- }
- arrayList_destroy(ids);
- } else {
- fprintf(errStream, "INSPECT: Too few arguments\n");
- }
- } else {
- fprintf(errStream, "INSPECT: Too few arguments\n");
- }
- return status;
-}
-
-celix_status_t inspectCommand_printExportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream) {
- celix_status_t status = CELIX_SUCCESS;
- array_list_pt bundles = NULL;
-
- if (arrayList_isEmpty(ids)) {
- status = bundleContext_getBundles(context, &bundles);
- } else {
- unsigned int i;
-
- arrayList_create(&bundles);
- for (i = 0; i < arrayList_size(ids); i++) {
- char *idStr = (char *) arrayList_get(ids, i);
- long id = atol(idStr);
- bundle_pt b = NULL;
- celix_status_t st = bundleContext_getBundleById(context, id, &b);
- if (st == CELIX_SUCCESS) {
- arrayList_add(bundles, b);
- } else {
- fprintf(outStream, "INSPECT: Invalid bundle ID: %ld\n", id);
- }
- }
- }
-
- if (status == CELIX_SUCCESS) {
- unsigned int i = 0;
- for (i = 0; i < arrayList_size(bundles); i++) {
- bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
-
- if (i > 0) {
- fprintf(outStream, "\n");
- }
-
- if (bundle != NULL) {
- array_list_pt refs = NULL;
-
- if (bundle_getRegisteredServices(bundle, &refs) == CELIX_SUCCESS) {
- module_pt module = NULL;
- const char * name = NULL;
- status = bundle_getCurrentModule(bundle, &module);
- if (status == CELIX_SUCCESS) {
- status = module_getSymbolicName(module, &name);
- if (status == CELIX_SUCCESS) {
- fprintf(outStream, "%s provides services:\n", name);
- fprintf(outStream, "==============\n");
-
- if (refs == NULL || arrayList_size(refs) == 0) {
- fprintf(outStream, "Nothing\n");
- } else {
- unsigned int j = 0;
- for (j = 0; j < arrayList_size(refs); j++) {
- service_reference_pt ref = (service_reference_pt) arrayList_get(refs, j);
- unsigned int size = 0;
- char **keys;
-
- serviceReference_getPropertyKeys(ref, &keys, &size);
- for (int k = 0; k < size; k++) {
- char *key = keys[k];
- const char *value = NULL;
- serviceReference_getProperty(ref, key, &value);
-
- fprintf(outStream, "%s = %s\n", key, value);
- }
-
- free(keys);
-
-// objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
-// sprintf(line, "ObjectClass = %s\n", objectClass);
- if ((j + 1) < arrayList_size(refs)) {
- fprintf(outStream, "----\n");
- }
- }
- }
- }
- }
- }
-
- if(refs!=NULL){
- arrayList_destroy(refs);
- }
- }
- }
- }
-
- if (bundles != NULL) {
- arrayList_destroy(bundles);
- }
-
- return status;
-}
-
-celix_status_t inspectCommand_printImportedServices(bundle_context_pt context, array_list_pt ids, FILE *outStream, FILE *errStream) {
- celix_status_t status = CELIX_SUCCESS;
- array_list_pt bundles = NULL;
-
- if (arrayList_isEmpty(ids)) {
- status = bundleContext_getBundles(context, &bundles);
- } else {
- unsigned int i;
-
- arrayList_create(&bundles);
- for (i = 0; i < arrayList_size(ids); i++) {
- char *idStr = (char *) arrayList_get(ids, i);
- long id = atol(idStr);
- bundle_pt b = NULL;
- celix_status_t st = bundleContext_getBundleById(context, id, &b);
- if (st == CELIX_SUCCESS) {
- arrayList_add(bundles, b);
- } else {
- fprintf(outStream, "INSPECT: Invalid bundle ID: %ld\n", id);
- }
- }
- }
-
- if (status == CELIX_SUCCESS) {
- unsigned int i = 0;
- for (i = 0; i < arrayList_size(bundles); i++) {
- bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
-
- if (i > 0) {
- fprintf(outStream, "\n");
- }
-
- if (bundle != NULL) {
- array_list_pt refs = NULL;
-
- if (bundle_getServicesInUse(bundle, &refs) == CELIX_SUCCESS) {
- module_pt module = NULL;
- const char * name = NULL;
- status = bundle_getCurrentModule(bundle, &module);
- if (status == CELIX_SUCCESS) {
- status = module_getSymbolicName(module, &name);
- if (status == CELIX_SUCCESS) {
- fprintf(outStream, "%s requires services:\n", name);
- fprintf(outStream, "==============\n");
-
- if (refs == NULL || arrayList_size(refs) == 0) {
- fprintf(outStream, "Nothing\n");
- } else {
- unsigned int j = 0;
- for (j = 0; j < arrayList_size(refs); j++) {
- service_reference_pt ref = (service_reference_pt) arrayList_get(refs, j);
- bundle_pt usedBundle = NULL;
- module_pt usedModule = NULL;
- const char *usedSymbolicName = NULL;
- long usedBundleId;
-
- serviceReference_getBundle(ref, &usedBundle);
- bundle_getBundleId(usedBundle, &usedBundleId);
- bundle_getCurrentModule(usedBundle, &usedModule);
- module_getSymbolicName(usedModule, &usedSymbolicName);
-
- fprintf(outStream, "%s [%ld]\n", usedSymbolicName, usedBundleId);
-
- unsigned int size = 0;
- char **keys;
-
- serviceReference_getPropertyKeys(ref, &keys, &size);
- for (int k = 0; k < size; k++) {
- char *key = keys[k];
- const char *value = NULL;
- serviceReference_getProperty(ref, key, &value);
-
- fprintf(outStream, "%s = %s\n", key, value);
- }
- free(keys);
-
-// objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
-// sprintf(line, "ObjectClass = %s\n", objectClass);
- if ((j + 1) < arrayList_size(refs)) {
- fprintf(outStream, "----\n");
- }
- }
- }
- }
- }
- }
-
- if(refs!=NULL){
- arrayList_destroy(refs);
- }
- }
- }
- }
-
- arrayList_destroy(bundles);
-
-
- return status;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/install_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/install_command.c b/shell/private/src/install_command.c
deleted file mode 100644
index 067ba2b..0000000
--- a/shell/private/src/install_command.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * install_command.c
- *
- * \date Apr 4, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-
-void installCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
- bundle_context_pt context = handle;
-
- char delims[] = " ";
- char * sub = NULL;
- char *save_ptr = NULL;
- char info[256];
-
- // ignore the command
- sub = strtok_r(line, delims, &save_ptr);
- sub = strtok_r(NULL, delims, &save_ptr);
-
- if (sub == NULL) {
- fprintf(errStream, "Incorrect number of arguments.\n");
- } else {
- info[0] = '\0';
- while (sub != NULL) {
- bundle_pt bundle = NULL;
- bundleContext_installBundle(context, sub, &bundle);
- if (bundle != NULL) {
- long id;
- bundle_archive_pt archive = NULL;
- char bundleId[sizeof(id) + 1];
-
- if (strlen(info) > 0) {
- strcat(info, ", ");
- }
- bundle_getArchive(bundle, &archive);
- bundleArchive_getId(archive, &id);
- sprintf(bundleId, "%ld", id);
- strcat(info, bundleId);
- }
- sub = strtok_r(NULL, delims, &save_ptr);
- }
- if (strchr(info, ',') != NULL) {
- fprintf(outStream, "Bundle IDs: ");
- fprintf(outStream, "%s", info);
- fprintf(outStream, "\n");
- } else if (strlen(info) > 0) {
- fprintf(outStream, "Bundle ID: ");
- fprintf(outStream, "%s", info);
- fprintf(outStream, "\n");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/lb_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/lb_command.c b/shell/private/src/lb_command.c
deleted file mode 100644
index d0504f6..0000000
--- a/shell/private/src/lb_command.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * std_shell_commands.c
- *
- * \date March 27, 2014
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-#include "std_commands.h"
-#include "shell_constants.h"
-
-static const char * const HEAD_COLOR = "\033[4m"; //underline
-static const char * const EVEN_COLOR = "\033[1m"; //bold
-static const char * const ODD_COLOR = "\033[3m"; //italic
-static const char * const END_COLOR = "\033[0m";
-
-static char * psCommand_stateString(bundle_state_e state);
-
-celix_status_t psCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
- celix_status_t status = CELIX_SUCCESS;
- bundle_context_t* ctx = _ptr;
-
- const char* config = NULL;
- bundleContext_getPropertyWithDefault(ctx, SHELL_USE_ANSI_COLORS, SHELL_USE_ANSI_COLORS_DEFAULT_VALUE, &config);
- bool useColors = config != NULL && strncmp("true", config, 5) == 0;
-
- bundle_context_pt context_ptr = _ptr;
- array_list_pt bundles_ptr = NULL;
-
- bool show_location = false;
- bool show_symbolic_name = false;
- bool show_update_location = false;
- char *message_str = "Name";
-
- if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- status = bundleContext_getBundles(context_ptr, &bundles_ptr);
- }
-
- if (status == CELIX_SUCCESS) {
- char *sub_str = NULL;
- char *save_ptr = NULL;
-
- strtok_r(command_line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
- sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
- while (sub_str != NULL) {
- if (strcmp(sub_str, "-l") == 0) {
- show_location = true;
- message_str = "Location";
- } else if (strcmp(sub_str, "-s") == 0) {
- show_symbolic_name = true;
- message_str = "Symbolic name";
- } else if (strcmp(sub_str, "-u") == 0) {
- show_update_location = true;
- message_str = "Update location";
- }
- sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
- }
-
- const char* startColor = "";
- const char* endColor = "";
- if (useColors) {
- startColor = HEAD_COLOR;
- endColor = END_COLOR;
- }
- fprintf(out_ptr, "%s %-5s %-12s %s%s\n", startColor, "ID", "State", message_str, endColor);
-
- unsigned int size = arrayList_size(bundles_ptr);
-
- bundle_pt bundles_array_ptr[size];
-
- for (unsigned int i = 0; i < size; i++) {
- bundles_array_ptr[i] = arrayList_get(bundles_ptr, i);
- }
-
- for (unsigned int i = 0; i < size - 1; i++) {
- for (unsigned int j = i + 1; j < size; j++) {
- bundle_pt first_ptr = bundles_array_ptr[i];
- bundle_pt second_ptr = bundles_array_ptr[j];
-
- bundle_archive_pt first_archive_ptr = NULL;
- bundle_archive_pt second_archive_ptr = NULL;
-
- long first_id;
- long second_id;
-
- bundle_getArchive(first_ptr, &first_archive_ptr);
- bundle_getArchive(second_ptr, &second_archive_ptr);
-
- bundleArchive_getId(first_archive_ptr, &first_id);
- bundleArchive_getId(second_archive_ptr, &second_id);
-
- if (first_id > second_id) {
- bundle_pt temp_ptr = bundles_array_ptr[i];
- bundles_array_ptr[i] = bundles_array_ptr[j];
- bundles_array_ptr[j] = temp_ptr;
- }
- }
- }
-
- for (unsigned int i = 0; i < size; i++) {
- celix_status_t sub_status;
-
- bundle_pt bundle_ptr = bundles_array_ptr[i];
-
- bundle_archive_pt archive_ptr = NULL;
- long id = 0;
- bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
- const char *state_str = NULL;
- module_pt module_ptr = NULL;
- const char *name_str = NULL;
-
- sub_status = bundle_getArchive(bundle_ptr, &archive_ptr);
- if (sub_status == CELIX_SUCCESS) {
- sub_status = bundleArchive_getId(archive_ptr, &id);
- }
-
- if (sub_status == CELIX_SUCCESS) {
- sub_status = bundle_getState(bundle_ptr, &state);
- }
-
- if (sub_status == CELIX_SUCCESS) {
- state_str = psCommand_stateString(state);
-
- sub_status = bundle_getCurrentModule(bundle_ptr, &module_ptr);
- }
-
- if (sub_status == CELIX_SUCCESS) {
- sub_status = module_getSymbolicName(module_ptr, &name_str);
- }
-
- if (sub_status == CELIX_SUCCESS) {
- if (show_location) {
- sub_status = bundleArchive_getLocation(archive_ptr, &name_str);
- } else if (show_symbolic_name) {
- // do nothing
- } else if (show_update_location) {
- sub_status = bundleArchive_getLocation(archive_ptr, &name_str);
- }
- }
-
- if (sub_status == CELIX_SUCCESS) {
- startColor = "";
- endColor = "";
- if (useColors) {
- startColor = i % 2 == 0 ? EVEN_COLOR : ODD_COLOR;
- endColor = END_COLOR;
- }
- fprintf(out_ptr, "%s %-5ld %-12s %s%s\n", startColor, id, state_str, name_str, endColor);
-
- }
-
- if (sub_status != CELIX_SUCCESS) {
- status = sub_status;
- break;
- }
- }
-
- arrayList_destroy(bundles_ptr);
- }
-
- return status;
-}
-
-static char * psCommand_stateString(bundle_state_e state) {
- switch (state) {
- case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
- return "Active ";
- case OSGI_FRAMEWORK_BUNDLE_INSTALLED:
- return "Installed ";
- case OSGI_FRAMEWORK_BUNDLE_RESOLVED:
- return "Resolved ";
- case OSGI_FRAMEWORK_BUNDLE_STARTING:
- return "Starting ";
- case OSGI_FRAMEWORK_BUNDLE_STOPPING:
- return "Stopping ";
- default:
- return "Unknown ";
- }
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/log_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/log_command.c b/shell/private/src/log_command.c
deleted file mode 100644
index 8b0244a..0000000
--- a/shell/private/src/log_command.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * log_command.c
- *
- * \date Jun 26, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "bundle_context.h"
-#include "log_reader_service.h"
-#include "linked_list_iterator.h"
-
-celix_status_t logCommand_levelAsString(bundle_context_pt context, log_level_t level, char **string);
-
-void logCommand_execute(bundle_context_pt context, char *line, FILE *outStream, FILE *errStream) {
- celix_status_t status;
- service_reference_pt readerService = NULL;
-
- status = bundleContext_getServiceReference(context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, &readerService);
- if (status != CELIX_SUCCESS || readerService != NULL) {
- linked_list_pt list = NULL;
- linked_list_iterator_pt iter = NULL;
- log_reader_service_pt reader = NULL;
-
-
- bundleContext_getService(context, readerService, (void **) &reader);
- reader->getLog(reader->reader, &list);
- iter = linkedListIterator_create(list, 0);
- while (linkedListIterator_hasNext(iter)) {
- log_entry_pt entry = linkedListIterator_next(iter);
- char time[20];
- char *level = NULL;
- char errorString[256];
-
- strftime(time, 20, "%Y-%m-%d %H:%M:%S", localtime(&entry->time));
- logCommand_levelAsString(context, entry->level, &level);
-
- if (entry->errorCode > 0) {
- celix_strerror(entry->errorCode, errorString, 256);
- fprintf(outStream, "%s - Bundle: %s - %s - %d %s\n", time, entry->bundleSymbolicName, entry->message, entry->errorCode, errorString);
- } else {
- fprintf(outStream, "%s - Bundle: %s - %s\n", time, entry->bundleSymbolicName, entry->message);
- }
- }
- linkedListIterator_destroy(iter);
- linkedList_destroy(list);
- bool result = true;
- bundleContext_ungetService(context, readerService, &result);
- bundleContext_ungetServiceReference(context, readerService);
- } else {
- fprintf(outStream, "No log reader available\n");
- }
-}
-
-celix_status_t logCommand_levelAsString(bundle_context_pt context, log_level_t level, char **string) {
- switch (level) {
- case OSGI_LOGSERVICE_ERROR:
- *string = "ERROR";
- break;
- case OSGI_LOGSERVICE_WARNING:
- *string = "WARNING";
- break;
- case OSGI_LOGSERVICE_INFO:
- *string = "INFO";
- break;
- case OSGI_LOGSERVICE_DEBUG:
- default:
- *string = "DEBUG";
- break;
- }
-
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/shell.c
----------------------------------------------------------------------
diff --git a/shell/private/src/shell.c b/shell/private/src/shell.c
deleted file mode 100644
index ac8603e..0000000
--- a/shell/private/src/shell.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * shell.c
- *
- * \date Aug 13, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <log_helper.h>
-
-#include "celix_errno.h"
-
-#include "shell_private.h"
-
-
-#include "utils.h"
-
-celix_status_t shell_getCommands(shell_pt shell_ptr, array_list_pt *commands_ptr);
-celix_status_t shell_getCommandUsage(shell_pt shell_ptr, char *command_name_str, char **usage_pstr);
-celix_status_t shell_getCommandDescription(shell_pt shell_ptr, char *command_name_str, char **command_description_pstr);
-
-celix_status_t shell_create(bundle_context_pt context_ptr, shell_service_pt *shell_service_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- if (!context_ptr || !shell_service_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- *shell_service_ptr = calloc(1, sizeof(**shell_service_ptr));
- if (!*shell_service_ptr) {
- status = CELIX_ENOMEM;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- (*shell_service_ptr)->shell = calloc(1, sizeof(*(*shell_service_ptr)->shell));
- if (!(*shell_service_ptr)->shell) {
- status = CELIX_ENOMEM;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- (*shell_service_ptr)->shell->bundle_context_ptr = context_ptr;
- (*shell_service_ptr)->shell->command_name_map_ptr = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
- (*shell_service_ptr)->shell->command_reference_map_ptr = hashMap_create(NULL, NULL, NULL, NULL);
-
- (*shell_service_ptr)->getCommands = shell_getCommands;
- (*shell_service_ptr)->getCommandDescription = shell_getCommandDescription;
- (*shell_service_ptr)->getCommandUsage = shell_getCommandUsage;
- (*shell_service_ptr)->getCommandReference = shell_getCommandReference;
- (*shell_service_ptr)->executeCommand = shell_executeCommand;
-
- status = logHelper_create(context_ptr, &(*shell_service_ptr)->shell->logHelper);
- }
-
- if (status != CELIX_SUCCESS) {
- shell_destroy(shell_service_ptr);
- }
-
- return status;
-}
-
-celix_status_t shell_destroy(shell_service_pt *shell_service_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- if (!shell_service_ptr || !*shell_service_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- if ((*shell_service_ptr)->shell) {
- if ((*shell_service_ptr)->shell->command_name_map_ptr) {
- hashMap_destroy((*shell_service_ptr)->shell->command_name_map_ptr, false, false);
- }
- if ((*shell_service_ptr)->shell->command_reference_map_ptr) {
- hashMap_destroy((*shell_service_ptr)->shell->command_reference_map_ptr, false, false);
- }
- if ((*shell_service_ptr)->shell->logHelper) {
- logHelper_destroy(&((*shell_service_ptr)->shell->logHelper));
- }
- free((*shell_service_ptr)->shell);
- (*shell_service_ptr)->shell = NULL;
- }
- free(*shell_service_ptr);
- *shell_service_ptr = NULL;
- }
-
- return status;
-}
-
-celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc) {
- celix_status_t status = CELIX_SUCCESS;
- command_service_pt command_ptr = NULL;
- const char *name_str = NULL;
-
- if (!shell_ptr || !reference_ptr) {
- return CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- command_ptr = svc;
- }
-
- if (status == CELIX_SUCCESS) {
- status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
- if (!name_str) {
- logHelper_log(shell_ptr->logHelper, OSGI_LOGSERVICE_ERROR, "Command service must contain a 'command.name' property!");
- status = CELIX_BUNDLE_EXCEPTION;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- hashMap_put(shell_ptr->command_name_map_ptr, (char *)name_str, command_ptr);
- hashMap_put(shell_ptr->command_reference_map_ptr, reference_ptr, command_ptr);
- }
-
- if (status != CELIX_SUCCESS) {
- shell_removeCommand(shell_ptr, reference_ptr, svc);
- char err[32];
- celix_strerror(status, err, 32);
- logHelper_log(shell_ptr->logHelper, OSGI_LOGSERVICE_ERROR, "Could not add command, got error %s\n", err);
- }
-
- return status;
-}
-
-celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc) {
- celix_status_t status = CELIX_SUCCESS;
-
- command_service_pt command_ptr = NULL;
- const char *name_str = NULL;
-
- if (!shell_ptr || !reference_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- command_ptr = hashMap_remove(shell_ptr->command_reference_map_ptr, reference_ptr);
- if (!command_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
- if (!name_str) {
- status = CELIX_BUNDLE_EXCEPTION;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- hashMap_remove(shell_ptr->command_name_map_ptr, (char *)name_str);
- }
-
- return status;
-}
-
-celix_status_t shell_getCommands(shell_pt shell_ptr, array_list_pt *commands_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- hash_map_iterator_pt iter = NULL;
-
- if (!shell_ptr || !commands_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- iter = hashMapIterator_create(shell_ptr->command_name_map_ptr);
- if (!iter) {
- status = CELIX_BUNDLE_EXCEPTION;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- arrayList_create(commands_ptr);
- while (hashMapIterator_hasNext(iter)) {
- char *name_str = hashMapIterator_nextKey(iter);
- arrayList_add(*commands_ptr, name_str);
- }
- hashMapIterator_destroy(iter);
- }
-
- return status;
-}
-
-
-celix_status_t shell_getCommandUsage(shell_pt shell_ptr, char *command_name_str, char **usage_pstr) {
- celix_status_t status = CELIX_SUCCESS;
-
- service_reference_pt reference = NULL;
-
- if (!shell_ptr || !command_name_str || !usage_pstr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- status = shell_getCommandReference(shell_ptr, command_name_str, &reference);
- if (!reference) {
- status = CELIX_BUNDLE_EXCEPTION;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- status = serviceReference_getProperty(reference, "command.usage", (const char**)usage_pstr);
- }
-
- return status;
-}
-
-celix_status_t shell_getCommandDescription(shell_pt shell_ptr, char *command_name_str, char **command_description_pstr) {
- celix_status_t status = CELIX_SUCCESS;
-
- service_reference_pt reference = NULL;
-
- if (!shell_ptr || !command_name_str || !command_description_pstr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- status = shell_getCommandReference(shell_ptr, command_name_str, &reference);
- if (!reference) {
- status = CELIX_BUNDLE_EXCEPTION;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- serviceReference_getProperty(reference, "command.description", (const char**)command_description_pstr);
- }
-
- return status;
-}
-
-celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- if (!shell_ptr || !command_name_str || !command_reference_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- *command_reference_ptr = NULL;
- hash_map_iterator_pt iter = hashMapIterator_create(shell_ptr->command_reference_map_ptr);
- while (hashMapIterator_hasNext(iter)) {
- hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
- service_reference_pt reference = hashMapEntry_getKey(entry);
- const char *name_str = NULL;
- serviceReference_getProperty(reference, "command.name", &name_str);
- if (strcmp(name_str, command_name_str) == 0) {
- *command_reference_ptr = (service_reference_pt) hashMapEntry_getKey(entry);
- break;
- }
- }
- hashMapIterator_destroy(iter);
- }
-
- return status;
-}
-
-celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, FILE *out, FILE *err) {
- celix_status_t status = CELIX_SUCCESS;
-
- command_service_pt command_ptr = NULL;
-
- if (!shell_ptr || !command_line_str || !out || !err) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- size_t pos = strcspn(command_line_str, " ");
-
- char *command_name_str = (pos != strlen(command_line_str)) ? strndup(command_line_str, pos) : strdup(command_line_str);
- command_ptr = hashMap_get(shell_ptr->command_name_map_ptr, command_name_str);
- free(command_name_str);
- if (!command_ptr) {
- fprintf(err, "No such command\n");
- status = CELIX_BUNDLE_EXCEPTION;
- }
- }
-
- if (status == CELIX_SUCCESS) {
- status = command_ptr->executeCommand(command_ptr->handle, command_line_str, out, err);
- }
-
- return status;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/start_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/start_command.c b/shell/private/src/start_command.c
deleted file mode 100644
index f43699a..0000000
--- a/shell/private/src/start_command.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * start_command.c
- *
- * \date Aug 20, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "std_commands.h"
-#include "bundle_context.h"
-
-celix_status_t startCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- bundle_context_pt context_ptr = _ptr;
-
- if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- char *sub_str = NULL;
- char *save_ptr = NULL;
-
- strtok_r(command_line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
- sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-
- if (sub_str == NULL) {
- fprintf(out_ptr, "Incorrect number of arguments.\n");
- } else {
- while (sub_str != NULL) {
- celix_status_t sub_status = CELIX_SUCCESS;
-
- bundle_pt bundle_ptr = NULL;
-
- char *end_str = NULL;
- long id = strtol(sub_str, &end_str, 10);
- if (*end_str) {
- sub_status = CELIX_ILLEGAL_ARGUMENT;
- fprintf(err_ptr, "Bundle id '%s' is invalid, problem at %s\n", sub_str, end_str);
- }
-
- if (sub_status == CELIX_SUCCESS) {
- sub_status = bundleContext_getBundleById(context_ptr, id, &bundle_ptr);
- }
-
- if (sub_status == CELIX_SUCCESS) {
- bundle_startWithOptions(bundle_ptr, 0);
- }
-
- if (sub_status != CELIX_SUCCESS) {
- status = sub_status;
- break;
- }
-
- sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
- }
- }
-
- }
-
- return status;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/stop_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/stop_command.c b/shell/private/src/stop_command.c
deleted file mode 100644
index 0093c99..0000000
--- a/shell/private/src/stop_command.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * stop_command.c
- *
- * \date Aug 20, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "bundle_context.h"
-#include "std_commands.h"
-
-celix_status_t stopCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- bundle_context_pt context_ptr = _ptr;
-
- if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
- status = CELIX_ILLEGAL_ARGUMENT;
- }
-
- if (status == CELIX_SUCCESS) {
- char *sub_str = NULL;
- char *save_ptr = NULL;
-
- strtok_r(command_line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
- sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
-
- if (sub_str == NULL) {
- fprintf(out_ptr, "Incorrect number of arguments.\n");
- } else {
- while (sub_str != NULL) {
- celix_status_t sub_status = CELIX_SUCCESS;
-
- bundle_pt bundle_ptr = NULL;
-
- char *end_str = NULL;
- long id = strtol(sub_str, &end_str, 10);
- if (*end_str) {
- sub_status = CELIX_ILLEGAL_ARGUMENT;
- fprintf(err_ptr, "Bundle id '%s' is invalid, problem at %s\n", sub_str, end_str);
- }
-
- if (sub_status == CELIX_SUCCESS) {
- sub_status = bundleContext_getBundleById(context_ptr, id, &bundle_ptr);
- }
-
- if (sub_status == CELIX_SUCCESS) {
- bundle_stopWithOptions(bundle_ptr, 0);
- }
-
- if (sub_status != CELIX_SUCCESS) {
- status = sub_status;
- break;
- }
-
- sub_str = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
- }
- }
- }
-
- return status;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/uninstall_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/uninstall_command.c b/shell/private/src/uninstall_command.c
deleted file mode 100644
index fb30831..0000000
--- a/shell/private/src/uninstall_command.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * uninstall_command.c
- *
- * \date Aug 20, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-
-celix_status_t uninstallCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
- bundle_context_pt context = handle;
- char delims[] = " ";
- char * sub = NULL;
- char *save_ptr = NULL;
- celix_status_t status = CELIX_SUCCESS;
-
- sub = strtok_r(line, delims, &save_ptr);
- sub = strtok_r(NULL, delims, &save_ptr);
-
- if (sub == NULL) {
- fprintf(errStream, "Incorrect number of arguments.\n");
- } else {
- while (sub != NULL) {
- long id = atol(sub);
- bundle_pt bundle = NULL;
- status = bundleContext_getBundleById(context, id, &bundle);
- if (status==CELIX_SUCCESS && bundle!=NULL) {
- bundle_uninstall(bundle);
- } else {
- fprintf(errStream, "Bundle id is invalid.");
- }
- sub = strtok_r(NULL, delims, &save_ptr);
- }
- }
- return status;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/private/src/update_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/update_command.c b/shell/private/src/update_command.c
deleted file mode 100644
index 64999ac..0000000
--- a/shell/private/src/update_command.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * update_command.c
- *
- * \date Aug 20, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- *
- */
-#include <stdlib.h>
-#include <string.h>
-#include <curl/curl.h>
-#include <sys/stat.h>
-
-#include "array_list.h"
-#include "bundle_context.h"
-
-celix_status_t updateCommand_download(bundle_context_pt context, char * url, char **inputFile);
-size_t updateCommand_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream);
-
-void updateCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
- bundle_context_pt context = handle;
- bundle_pt bundle = NULL;
- char delims[] = " ";
- char * sub = NULL;
- char *save_ptr = NULL;
-
- sub = strtok_r(line, delims, &save_ptr);
- sub = strtok_r(NULL, delims, &save_ptr);
-
- if (sub == NULL) {
- fprintf(errStream, "Incorrect number of arguments.\n");
- } else {
- long id = atol(sub);
- celix_status_t ret = bundleContext_getBundleById(context, id, &bundle);
- if (ret==CELIX_SUCCESS && bundle!=NULL) {
- char inputFile[256];
- sub = strtok_r(NULL, delims, &save_ptr);
- inputFile[0] = '\0';
- if (sub != NULL) {
- char *test = inputFile;
- printf("URL: %s\n", sub);
-
- if (updateCommand_download(context, sub, &test) == CELIX_SUCCESS) {
- printf("Update bundle with stream\n");
- bundle_update(bundle, inputFile);
- } else {
- fprintf(errStream, "Unable to download from %s\n", sub);
- }
- } else {
- bundle_update(bundle, NULL);
- }
- } else {
- fprintf(errStream, "Bundle id is invalid.\n");
- }
- }
-}
-
-celix_status_t updateCommand_download(bundle_context_pt context, char * url, char **inputFile) {
- CURL *curl = NULL;
- CURLcode res = CURLE_FILE_COULDNT_READ_FILE;
- curl = curl_easy_init();
- if (curl) {
- FILE *fp = NULL;
- snprintf(*inputFile, 13,"updateXXXXXX");
- umask(0011);
- int fd = mkstemp(*inputFile);
- if (fd) {
- fp = fopen(*inputFile, "wb+");
- if(fp!=NULL){
- printf("Temp file: %s\n", *inputFile);
- curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
- curl_easy_setopt(curl, CURLOPT_URL, url);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, updateCommand_writeData);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
- //curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
- //curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, updateCommand_downloadProgress);
- res = curl_easy_perform(curl);
- fclose(fp);
- }
- /* always cleanup */
- curl_easy_cleanup(curl);
- if(fp==NULL){
- return CELIX_FILE_IO_EXCEPTION;
- }
- }
- }
- if (res != CURLE_OK) {
- printf("Error: %d\n", res);
- *inputFile[0] = '\0';
- return CELIX_ILLEGAL_STATE;
- } else {
- return CELIX_SUCCESS;
- }
-}
-
-size_t updateCommand_writeData(void *ptr, size_t size, size_t nmemb, FILE *stream) {
- size_t written = fwrite(ptr, size, nmemb, stream);
- return written;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/public/include/command.h
----------------------------------------------------------------------
diff --git a/shell/public/include/command.h b/shell/public/include/command.h
deleted file mode 100644
index 0e86dcc..0000000
--- a/shell/public/include/command.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * command.h
- *
- * \date Aug 13, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef COMMAND_H_
-#define COMMAND_H_
-
-#include "celix_errno.h"
-#include <stdio.h>
-
-#define OSGI_SHELL_COMMAND_NAME "command.name"
-#define OSGI_SHELL_COMMAND_USAGE "command.usage"
-#define OSGI_SHELL_COMMAND_DESCRIPTION "command.description"
-
-static const char * const OSGI_SHELL_COMMAND_SERVICE_NAME = "commandService";
-
-typedef struct commandService command_service_t;
-typedef command_service_t * command_service_pt;
-
-/**
- * The command service can be used to register additional shell commands.
- * The service should be register with the following properties:
- * - command.name: mandatory, name of the command e.g. 'lb'
- * - command.usage: optional, string describing how tu use the commmand e.g. 'lb [-l | -s | -u]'
- * - command.descrription: optional, string describing the command e.g. 'list bundles.'
- */
-struct commandService {
- void *handle;
- celix_status_t (*executeCommand)(void *handle, char * commandLine, FILE *outStream, FILE *errorStream);
-};
-
-
-
-
-#endif /* COMMAND_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/public/include/shell.h
----------------------------------------------------------------------
diff --git a/shell/public/include/shell.h b/shell/public/include/shell.h
deleted file mode 100644
index c8e7d60..0000000
--- a/shell/public/include/shell.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * shell.h
- *
- * \date Aug 12, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef SHELL_H_
-#define SHELL_H_
-
-#include "array_list.h"
-#include "service_reference.h"
-
-static const char * const OSGI_SHELL_SERVICE_NAME = "shellService";
-
-typedef struct shell shell_t;
-typedef shell_t* shell_pt;
-
-struct shellService {
- shell_pt shell;
-
- celix_status_t (*getCommands)(shell_pt shell_ptr, array_list_pt *commands_ptr);
- celix_status_t (*getCommandUsage)(shell_pt shell_ptr, char *command_name_str, char **usage_str);
- celix_status_t (*getCommandDescription)(shell_pt shell_ptr, char *command_name_str, char **command_description_str);
- celix_status_t (*getCommandReference)(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
- celix_status_t (*executeCommand)(shell_pt shell_ptr, char * command_line_str, FILE *out, FILE *err);
-};
-
-typedef struct shellService shell_service_t;
-typedef shell_service_t* shell_service_pt;
-
-#endif /* SHELL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/shell/public/include/shell_constants.h
----------------------------------------------------------------------
diff --git a/shell/public/include/shell_constants.h b/shell/public/include/shell_constants.h
deleted file mode 100644
index 1e7f875..0000000
--- a/shell/public/include/shell_constants.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-
-#ifndef SHELL_CONSTANTS_H_
-#define SHELL_CONSTANTS_H_
-
-#define SHELL_USE_ANSI_COLORS "SHELL_USE_ANSI_COLORS"
-#define SHELL_USE_ANSI_COLORS_DEFAULT_VALUE "true"
-
-#endif /* SHELL_CONSTANTS_H_ */