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 2015/11/03 10:38:56 UTC

[01/13] celix git commit: CELIX-230: Initial refatoring. Got ps up again, usage and description not yet working.

Repository: celix
Updated Branches:
  refs/heads/feature/CELIX-269_depman f5a3cdd1a -> 04b686237


CELIX-230: Initial refatoring. Got ps up again, usage and description not yet working.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/cea3f9ec
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/cea3f9ec
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/cea3f9ec

Branch: refs/heads/feature/CELIX-269_depman
Commit: cea3f9ec04d0ff8dcc76e3c38ba60dc7a55d250f
Parents: b3271bc
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Fri Mar 27 17:35:00 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Fri Mar 27 17:35:00 2015 +0100

----------------------------------------------------------------------
 framework/private/src/service_reference.c |   2 +-
 launcher/private/src/launcher.c           |   2 +
 shell/CMakeLists.txt                      |  28 +---
 shell/private/include/help_command.h      |  33 ----
 shell/private/include/inspect_command.h   |  33 ----
 shell/private/include/install_command.h   |  33 ----
 shell/private/include/log_command.h       |  33 ----
 shell/private/include/ps_command.h        |  33 ----
 shell/private/include/start_command.h     |  33 ----
 shell/private/include/std_commands.h      |  40 +++++
 shell/private/include/stop_command.h      |  33 ----
 shell/private/include/uninstall_command.h |  33 ----
 shell/private/include/update_command.h    |  35 -----
 shell/private/src/activator.c             | 192 +++++++++--------------
 shell/private/src/ps_command.c            | 209 ++++++++++++-------------
 shell/private/src/shell.c                 |  64 ++++----
 shell/public/include/command.h            |  11 +-
 shell/public/include/command_impl.h       |  48 ------
 shell/public/include/shell.h              |   1 -
 shell/public/src/command.c                |  45 ------
 20 files changed, 252 insertions(+), 689 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/framework/private/src/service_reference.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_reference.c b/framework/private/src/service_reference.c
index 9f954c5..a9bfff4 100644
--- a/framework/private/src/service_reference.c
+++ b/framework/private/src/service_reference.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <constants.h>
+#include <stdint.h>
 
 #include "service_reference.h"
 
@@ -37,7 +38,6 @@
 #include "bundle.h"
 #include "celix_log.h"
 
-
 celix_status_t serviceReference_create(bundle_pt bundle, service_registration_pt registration, service_reference_pt *reference) {
 	celix_status_t status = CELIX_SUCCESS;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/launcher/private/src/launcher.c
----------------------------------------------------------------------
diff --git a/launcher/private/src/launcher.c b/launcher/private/src/launcher.c
index 139d355..1a1f71e 100644
--- a/launcher/private/src/launcher.c
+++ b/launcher/private/src/launcher.c
@@ -27,6 +27,8 @@
 #include <string.h>
 #include <stdlib.h>
 #include <libgen.h>
+#include <signal.h>
+
 
 #include <curl/curl.h>
 

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 07f4c6e..8308369 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -23,30 +23,18 @@ if (SHELL)
 	SET_HEADERS("Bundle-Name: Apache Celix Shell") 
 
     bundle(shell SOURCES
-    	public/src/command
     	
      	private/src/activator
     	private/src/shell 
     	private/src/ps_command 
-    	private/src/start_command 
-    	private/src/stop_command
-    	private/src/install_command 
-    	private/src/update_command
-    	private/src/uninstall_command 
-    	private/src/log_command
-    	private/src/inspect_command
-    	private/src/help_command
-        
-        private/include/inspect_command.h
-        private/include/install_command.h
-        private/include/log_command.h
-        private/include/ps_command.h
-        private/include/shell_private.h
-        private/include/start_command.h
-        private/include/stop_command.h
-        private/include/uninstall_command.h
-        private/include/update_command.h
-        private/include/help_command.h
+      #	private/src/start_command 
+      #private/src/stop_command
+      #private/src/install_command 
+      #private/src/update_command
+      #private/src/uninstall_command 
+      #private/src/log_command
+      #private/src/inspect_command
+      #private/src/help_command
     )
     
     install_bundle(shell

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/include/help_command.h
----------------------------------------------------------------------
diff --git a/shell/private/include/help_command.h b/shell/private/include/help_command.h
deleted file mode 100644
index a975cbf..0000000
--- a/shell/private/include/help_command.h
+++ /dev/null
@@ -1,33 +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.h
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef HELP_COMMAND_H_
-#define HELP_COMMAND_H_
-
-command_pt helpCommand_create(bundle_context_pt context);
-void helpCommand_destroy(command_pt command);
-
-#endif /* HELP_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/include/inspect_command.h
----------------------------------------------------------------------
diff --git a/shell/private/include/inspect_command.h b/shell/private/include/inspect_command.h
deleted file mode 100644
index 7ea9e8e..0000000
--- a/shell/private/include/inspect_command.h
+++ /dev/null
@@ -1,33 +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.h
- *
- *  \date       Oct 13, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef INSPECT_COMMAND_H_
-#define INSPECT_COMMAND_H_
-
-command_pt inspectCommand_create(bundle_context_pt context);
-void inspectCommand_destroy(command_pt command);
-
-#endif /* INSPECT_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/include/install_command.h
----------------------------------------------------------------------
diff --git a/shell/private/include/install_command.h b/shell/private/include/install_command.h
deleted file mode 100644
index a8a6571..0000000
--- a/shell/private/include/install_command.h
+++ /dev/null
@@ -1,33 +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.h
- *
- *  \date       Apr 4, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef INSTALL_COMMAND_H_
-#define INSTALL_COMMAND_H_
-
-command_pt installCommand_create(bundle_context_pt context);
-void installCommand_destroy(command_pt command);
-
-#endif /* INSTALL_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/include/log_command.h
----------------------------------------------------------------------
diff --git a/shell/private/include/log_command.h b/shell/private/include/log_command.h
deleted file mode 100644
index 4eac17c..0000000
--- a/shell/private/include/log_command.h
+++ /dev/null
@@ -1,33 +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.h
- *
- *  \date       Jun 26, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef LOG_COMMAND_H_
-#define LOG_COMMAND_H_
-
-command_pt logCommand_create(bundle_context_pt context);
-void logCommand_destroy(command_pt command);
-
-#endif /* LOG_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/include/ps_command.h
----------------------------------------------------------------------
diff --git a/shell/private/include/ps_command.h b/shell/private/include/ps_command.h
deleted file mode 100644
index 941a9f4..0000000
--- a/shell/private/include/ps_command.h
+++ /dev/null
@@ -1,33 +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.
- */
-/*
- * ps_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 PS_COMMAND_H_
-#define PS_COMMAND_H_
-
-command_pt psCommand_create(bundle_context_pt context);
-void psCommand_destroy(command_pt command);
-
-#endif /* PS_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/include/start_command.h
----------------------------------------------------------------------
diff --git a/shell/private/include/start_command.h b/shell/private/include/start_command.h
deleted file mode 100644
index 3d76062..0000000
--- a/shell/private/include/start_command.h
+++ /dev/null
@@ -1,33 +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.h
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef START_COMMAND_H_
-#define START_COMMAND_H_
-
-command_pt startCommand_create(bundle_context_pt context);
-void startCommand_destroy(command_pt command);
-
-#endif /* START_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/include/std_commands.h
----------------------------------------------------------------------
diff --git a/shell/private/include/std_commands.h b/shell/private/include/std_commands.h
new file mode 100644
index 0000000..cb7322c
--- /dev/null
+++ b/shell/private/include/std_commands.h
@@ -0,0 +1,40 @@
+/**
+ *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_
+
+celix_status_t psCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+celix_status_t startCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+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/cea3f9ec/shell/private/include/stop_command.h
----------------------------------------------------------------------
diff --git a/shell/private/include/stop_command.h b/shell/private/include/stop_command.h
deleted file mode 100644
index 3b93924..0000000
--- a/shell/private/include/stop_command.h
+++ /dev/null
@@ -1,33 +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.h
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef STOP_COMMAND_H_
-#define STOP_COMMAND_H_
-
-command_pt stopCommand_create(bundle_context_pt context);
-void stopCommand_destroy(command_pt command);
-
-#endif /* STOP_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/include/uninstall_command.h
----------------------------------------------------------------------
diff --git a/shell/private/include/uninstall_command.h b/shell/private/include/uninstall_command.h
deleted file mode 100644
index 2e2fe97..0000000
--- a/shell/private/include/uninstall_command.h
+++ /dev/null
@@ -1,33 +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.h
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef UNINSTALL_COMMAND_H_
-#define UNINSTALL_COMMAND_H_
-
-command_pt uninstallCommand_create(bundle_context_pt context);
-void uninstallCommand_destroy(command_pt command);
-
-#endif /* UNINSTALL_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/include/update_command.h
----------------------------------------------------------------------
diff --git a/shell/private/include/update_command.h b/shell/private/include/update_command.h
deleted file mode 100644
index 0b83928..0000000
--- a/shell/private/include/update_command.h
+++ /dev/null
@@ -1,35 +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.h
- *
- *  \date       Aug 20, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef UPDATE_COMMAND_H_
-#define UPDATE_COMMAND_H_
-
-#include "command.h"
-
-command_pt updateCommand_create(bundle_context_pt context);
-void updateCommand_destroy(command_pt command);
-
-#endif /* UPDATE_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/src/activator.c
----------------------------------------------------------------------
diff --git a/shell/private/src/activator.c b/shell/private/src/activator.c
index 92ba36e..595894e 100644
--- a/shell/private/src/activator.c
+++ b/shell/private/src/activator.c
@@ -28,32 +28,40 @@
 
 #include "shell_private.h"
 #include "bundle_activator.h"
-#include "command_impl.h"
 #include "bundle_context.h"
 #include "service_registration.h"
 #include "service_listener.h"
+#include "utils.h"
+#include "std_commands.h"
+#include "properties.h"
+
+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;
+};
 
-#include "ps_command.h"
-#include "start_command.h"
-#include "stop_command.h"
-#include "install_command.h"
-#include "uninstall_command.h"
-#include "update_command.h"
-#include "log_command.h"
-#include "inspect_command.h"
-#include "help_command.h"
+static struct command std_commands[] = {
+        {psCommand_execute, "ps", "list installed bundles.", "ps [-l | -s | -u]", NULL, NULL, NULL},
+        {NULL, NULL, NULL, NULL, NULL, NULL, NULL} /*marker for last element*/ 
+};
 
-#include "utils.h"
 
 struct bundle_instance {
 	shell_service_pt shellService;
 	service_registration_pt registration;
 	service_listener_pt listener;
 
-	service_registration_pt psCommand;
-	command_pt psCmd;
-	command_service_pt psCmdSrv;
+  service_registration_pt commandRegistrations;
+  command_service_pt commandServices;
+  properties_pt commandProperties;
 
+    /*
+    ps
 	service_registration_pt startCommand;
 	command_pt startCmd;
 	command_service_pt startCmdSrv;
@@ -85,29 +93,11 @@ struct bundle_instance {
 	service_registration_pt helpCommand;
 	command_pt helpCmd;
 	command_service_pt helpCmdSrv;
+    */
 };
 
 typedef struct bundle_instance *bundle_instance_pt;
 
-static celix_status_t shell_createCommandService(command_pt command, command_service_pt *commandService) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*commandService = calloc(1, sizeof(**commandService));
-
-	if (!*commandService) {
-		status = CELIX_ENOMEM;
-	}
-	else {
-		(*commandService)->command = command;
-		(*commandService)->executeCommand = command->executeCommand;
-		(*commandService)->getName = command_getName;
-		(*commandService)->getShortDescription = command_getShortDescription;
-		(*commandService)->getUsage = command_getUsage;
-	}
-
-	return status;
-}
-
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
 
@@ -121,20 +111,32 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 		free(bi);
 	}
 	else {
-		bi->listener = NULL;
-		bi->psCommand = NULL;
-		bi->startCommand = NULL;
-		bi->stopCommand = NULL;
-		bi->installCommand = NULL;
-		bi->uninstallCommand = NULL;
-		bi->updateCommand = NULL;
-		bi->logCommand = NULL;
-		bi->inspectCommand = NULL;
-		bi->helpCommand = NULL;
-		bi->registration = NULL;
-
 		status = shell_create(context, &bi->shellService);
 
+    int i = 0;
+    while (std_commands[i].exec != NULL) {
+            std_commands[i].props = properties_create();
+            if (std_commands[i].props != NULL) {
+                    properties_set(std_commands[i].props, "command.name", std_commands[i].name);
+                    properties_set(std_commands[i].props, "command.usage", std_commands[i].usage);
+                    properties_set(std_commands[i].props, "command.description", std_commands[i].description);
+
+                    std_commands[i].service = calloc(1, sizeof(struct commandService));
+                    if (std_commands[i].service != NULL) {
+                            std_commands[i].service->handle = context;
+                            std_commands[i].service->executeCommand = std_commands[i].exec;
+                    } else {
+                            status = CELIX_ENOMEM;
+                            break;
+                    }
+            } else {
+                    status = CELIX_ENOMEM;
+                    break;
+            }
+              
+            i += 1;
+    }
+
 		if (status != CELIX_SUCCESS) {
 			printf("shell_create failed\n");
 		}
@@ -171,41 +173,15 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 		}
 
 		if (status == CELIX_SUCCESS) {
-			bi->psCmd = psCommand_create(context);
-			shell_createCommandService(bi->psCmd, &bi->psCmdSrv);
-			bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, bi->psCmdSrv, NULL, &bi->psCommand);
 
-			bi->startCmd = startCommand_create(context);
-			shell_createCommandService(bi->startCmd, &bi->startCmdSrv);
-			bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, bi->startCmdSrv, NULL, &bi->startCommand);
+            int i = 0;
+            while (std_commands[i].exec != NULL) {
+                    status = bundleContext_registerService(context, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, std_commands[i].service, std_commands[i].props, &std_commands[i].reg);
+                    if (status != CELIX_SUCCESS) {
+                            break;
+                    }
+            }
 
-			bi->stopCmd = stopCommand_create(context);
-			shell_createCommandService(bi->stopCmd, &bi->stopCmdSrv);
-			bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, bi->stopCmdSrv, NULL, &bi->stopCommand);
-
-			bi->installCmd = installCommand_create(context);
-			shell_createCommandService(bi->installCmd, &bi->installCmdSrv);
-			bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, bi->installCmdSrv, NULL, &bi->installCommand);
-
-			bi->uninstallCmd = uninstallCommand_create(context);
-			shell_createCommandService(bi->uninstallCmd, &bi->uninstallCmdSrv);
-			bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, bi->uninstallCmdSrv, NULL, &bi->uninstallCommand);
-
-			bi->updateCmd = updateCommand_create(context);
-			shell_createCommandService(bi->updateCmd, &bi->updateCmdSrv);
-			bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, bi->updateCmdSrv, NULL, &bi->updateCommand);
-
-			bi->logCmd = logCommand_create(context);
-			shell_createCommandService(bi->logCmd, &bi->logCmdSrv);
-			bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, bi->logCmdSrv, NULL, &bi->logCommand);
-
-			bi->inspectCmd = inspectCommand_create(context);
-			shell_createCommandService(bi->inspectCmd, &bi->inspectCmdSrv);
-			bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, bi->inspectCmdSrv, NULL, &bi->inspectCommand);
-
-			bi->helpCmd = helpCommand_create(context);
-			shell_createCommandService(bi->helpCmd, &bi->helpCmdSrv);
-			bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, bi->helpCmdSrv, NULL, &bi->helpCommand);
 		}
 		arrayList_destroy(references);
 	}
@@ -217,16 +193,13 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
 	celix_status_t status = CELIX_SUCCESS;
 	bundle_instance_pt bi = (bundle_instance_pt) userData;
 
-	serviceRegistration_unregister(bi->registration);
-	serviceRegistration_unregister(bi->psCommand);
-	serviceRegistration_unregister(bi->startCommand);
-	serviceRegistration_unregister(bi->stopCommand);
-	serviceRegistration_unregister(bi->installCommand);
-	serviceRegistration_unregister(bi->uninstallCommand);
-	serviceRegistration_unregister(bi->updateCommand);
-	serviceRegistration_unregister(bi->logCommand);
-	serviceRegistration_unregister(bi->inspectCommand);
-	serviceRegistration_unregister(bi->helpCommand);
+	//serviceRegistration_unregister(bi->registration);
+            int i = 0;
+            while (std_commands[i].exec != NULL) {
+                    if (std_commands[i].reg!= NULL) {
+                            serviceRegistration_unregister(std_commands[i].reg);
+                    }
+            }
 
 	status = bundleContext_removeServiceListener(context, bi->listener);
 
@@ -236,39 +209,16 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
 	bundle_instance_pt bi = (bundle_instance_pt) userData;
 
-	psCommand_destroy(bi->psCmd);
-	free(bi->psCmdSrv);
-
-	startCommand_destroy(bi->startCmd);
-	free(bi->startCmdSrv);
-
-	stopCommand_destroy(bi->stopCmd);
-	free(bi->stopCmdSrv);
-
-	installCommand_destroy(bi->installCmd);
-	free(bi->installCmdSrv);
-
-	uninstallCommand_destroy(bi->uninstallCmd);
-	free(bi->uninstallCmdSrv);
-
-	updateCommand_destroy(bi->updateCmd);
-	free(bi->updateCmdSrv);
-
-	logCommand_destroy(bi->logCmd);
-	free(bi->logCmdSrv);
-
-	inspectCommand_destroy(bi->inspectCmd);
-	free(bi->inspectCmdSrv);
-
-	inspectCommand_destroy(bi->helpCmd);
-	free(bi->helpCmdSrv);
-
-	free(bi->listener);
-	bi->listener = NULL;
-
-	shell_destroy(&bi->shellService);
-	bi->shellService = NULL;
-	free(bi);
+  int i = 0;
+  while (std_commands[i].exec != NULL) {
+          if (std_commands[i].props != NULL) {
+                  properties_destroy(std_commands[i].props);
+          } 
+          if (std_commands[i].service != NULL) {
+                  free(std_commands[i].service);
+          }
+          i += 1;
+  }
 
 	return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/src/ps_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/ps_command.c b/shell/private/src/ps_command.c
index fbc6470..7511391 100644
--- a/shell/private/src/ps_command.c
+++ b/shell/private/src/ps_command.c
@@ -17,134 +17,117 @@
  *under the License.
  */
 /*
- * ps_command.c
+ * std_shell_commands.c
  *
- *  \date       Aug 13, 2010
+ *  \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 "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle_archive.h"
 #include "module.h"
 #include "bundle.h"
 
-char * psCommand_stateString(bundle_state_e state);
-void psCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
-
-command_pt psCommand_create(bundle_context_pt context) {
-	command_pt command = (command_pt) malloc(sizeof(*command));
-	command->bundleContext = context;
-	command->name = "ps";
-	command->shortDescription = "list installed bundles.";
-	command->usage = "ps [-l | -s | -u]";
-	command->executeCommand = psCommand_execute;
-	return command;
-}
-
-void psCommand_destroy(command_pt command) {
-	free(command);
-}
-
-void psCommand_execute(command_pt command, char * commandline, void (*out)(char *), void (*err)(char *)) {
-	array_list_pt bundles = NULL;
-	celix_status_t status = bundleContext_getBundles(command->bundleContext, &bundles);
-
-	if (status == CELIX_SUCCESS) {
-		bool showLocation = false;
-		bool showSymbolicName = false;
-		bool showUpdateLocation = false;
-		char * msg = "Name";
-		char line[256];
-		unsigned int i;
-
-		char delims[] = " ";
-		char * sub = NULL;
-		char *save_ptr = NULL;
-		sub = strtok_r(commandline, delims, &save_ptr);
-		sub = strtok_r(NULL, delims, &save_ptr);
-		while (sub != NULL) {
-			if (strcmp(sub, "-l") == 0) {
-				showLocation = true;
-				msg = "Location";
-			} else if (strcmp(sub, "-s") == 0) {
-				showSymbolicName = true;
-				msg = "Symbolic name";
-			} else if (strcmp(sub, "-u") == 0) {
-				showUpdateLocation = true;
-				msg = "Update location";
-			}
-			sub = strtok_r(NULL, delims, &save_ptr);
-		}
-
-		sprintf(line, "  %-5s %-12s %s\n", "ID", "State", msg);
-		out(line);
-
-		unsigned int size = arrayList_size(bundles);
-		bundle_pt bundlesA[size];
-		for (i = 0; i < size; i++) {
-			bundlesA[i] = arrayList_get(bundles, i);
-		}
-
-		int j;
-		for(i=0; i < size - 1; i++) {
-			for(j=i+1; j < size; j++) {
-				bundle_pt first = bundlesA[i];
-				bundle_pt second = bundlesA[j];
-
-				bundle_archive_pt farchive = NULL, sarchive = NULL;
-				long fid, sid;
-
-				bundle_getArchive(first, &farchive);
-				bundleArchive_getId(farchive, &fid);
-				bundle_getArchive(second, &sarchive);
-				bundleArchive_getId(sarchive, &sid);
-
-				if(fid > sid)
-				{
-					 // these three lines swap the elements bundles[i] and bundles[j].
-					 bundle_pt temp = bundlesA[i];
-					 bundlesA[i] = bundlesA[j];
-					 bundlesA[j] = temp;
-				}
-			}
-		}
-		for (i = 0; i < size; i++) {
-			//bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
-			bundle_pt bundle = bundlesA[i];
-			bundle_archive_pt archive = NULL;
-			long id;
-			bundle_state_e state;
-			char * stateString = NULL;
-			module_pt module = NULL;
-			char * name = NULL;
-
-			bundle_getArchive(bundle, &archive);
-			bundleArchive_getId(archive, &id);
-			bundle_getState(bundle, &state);
-			stateString = psCommand_stateString(state);
-			bundle_getCurrentModule(bundle, &module);
-			module_getSymbolicName(module, &name);
-			if (showLocation) {
-				bundleArchive_getLocation(archive, &name);
-			} else if (showSymbolicName) {
-				// do nothing
-			} else if (showUpdateLocation) {
-				bundleArchive_getLocation(archive, &name);
-			}
-
-			sprintf(line, "  %-5ld %-12s %s\n", id, stateString, name);
-			out(line);
-		}
-		arrayList_destroy(bundles);
-	}
+static char * psCommand_stateString(bundle_state_e state); 
+
+celix_status_t psCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream) {
+        celix_status_t status = CELIX_SUCCESS;
+        array_list_pt bundles = NULL;
+        bundle_context_pt context = handle;
+
+        status = bundleContext_getBundles(context, &bundles);
+
+        bool showLocation = false;
+        bool showSymbolicName = false;
+        bool showUpdateLocation = false;
+        char * msg = "Name";
+        unsigned int i;
+
+        char delims[] = " ";
+        char * sub = NULL;
+        char *save_ptr = NULL;
+        sub = strtok_r(commandline, delims, &save_ptr);
+        sub = strtok_r(NULL, delims, &save_ptr);
+        while (sub != NULL) {
+                if (strcmp(sub, "-l") == 0) {
+                        showLocation = true;
+                        msg = "Location";
+                } else if (strcmp(sub, "-s") == 0) {
+                        showSymbolicName = true;
+                        msg = "Symbolic name";
+                } else if (strcmp(sub, "-u") == 0) {
+                        showUpdateLocation = true;
+                        msg = "Update location";
+                }
+                sub = strtok_r(NULL, delims, &save_ptr);
+        }
+
+        fprintf(outStream, "  %-5s %-12s %s\n", "ID", "State", msg);
+
+        unsigned int size = arrayList_size(bundles);
+        bundle_pt bundlesA[size];
+        for (i = 0; i < size; i++) {
+                bundlesA[i] = arrayList_get(bundles, i);
+        }
+
+        int j;
+        for(i=0; i < size - 1; i++) {
+                for(j=i+1; j < size; j++) {
+                        bundle_pt first = bundlesA[i];
+                        bundle_pt second = bundlesA[j];
+
+                        bundle_archive_pt farchive = NULL, sarchive = NULL;
+                        long fid, sid;
+
+                        bundle_getArchive(first, &farchive);
+                        bundleArchive_getId(farchive, &fid);
+                        bundle_getArchive(second, &sarchive);
+                        bundleArchive_getId(sarchive, &sid);
+
+                        if(fid > sid)
+                        {
+                                // these three lines swap the elements bundles[i] and bundles[j].
+                                bundle_pt temp = bundlesA[i];
+                                bundlesA[i] = bundlesA[j];
+                                bundlesA[j] = temp;
+                        }
+                }
+        }
+        for (i = 0; i < size; i++) {
+                //bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
+                bundle_pt bundle = bundlesA[i];
+                bundle_archive_pt archive = NULL;
+                long id;
+                bundle_state_e state;
+                char * stateString = NULL;
+                module_pt module = NULL;
+                char * name = NULL;
+
+                bundle_getArchive(bundle, &archive);
+                bundleArchive_getId(archive, &id);
+                bundle_getState(bundle, &state);
+                stateString = psCommand_stateString(state);
+                bundle_getCurrentModule(bundle, &module);
+                module_getSymbolicName(module, &name);
+                if (showLocation) {
+                        bundleArchive_getLocation(archive, &name);
+                } else if (showSymbolicName) {
+                        // do nothing
+                } else if (showUpdateLocation) {
+                        bundleArchive_getLocation(archive, &name);
+                }
+
+                fprintf(outStream, "  %-5ld %-12s %s\n", id, stateString, name);
+        }
+        arrayList_destroy(bundles);
+        return status;
 }
 
-char * psCommand_stateString(bundle_state_e state) {
+static char * psCommand_stateString(bundle_state_e state) {
 	switch (state) {
 		case OSGI_FRAMEWORK_BUNDLE_ACTIVE:
 			return "Active      ";

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/private/src/shell.c
----------------------------------------------------------------------
diff --git a/shell/private/src/shell.c b/shell/private/src/shell.c
index 18ee201..4b3e494 100644
--- a/shell/private/src/shell.c
+++ b/shell/private/src/shell.c
@@ -30,21 +30,10 @@
 
 #include "shell_private.h"
 #include "bundle_activator.h"
-#include "command_impl.h"
 #include "bundle_context.h"
 #include "service_registration.h"
 #include "service_listener.h"
 
-#include "ps_command.h"
-#include "start_command.h"
-#include "stop_command.h"
-#include "install_command.h"
-#include "uninstall_command.h"
-#include "update_command.h"
-#include "log_command.h"
-#include "inspect_command.h"
-#include "help_command.h"
-
 #include "utils.h"
 
 static command_service_pt shell_getCommand(shell_pt shell, char * commandName);
@@ -65,7 +54,6 @@ celix_status_t shell_create(bundle_context_pt context, shell_service_pt* shellSe
 		lclService->getCommands = shell_getCommands;
 		lclService->getCommandDescription = shell_getCommandDescription;
 		lclService->getCommandUsage = shell_getCommandUsage;
-		lclService->getCommandReference = shell_getCommandReference;
 		lclService->executeCommand = shell_executeCommand;
 
 		*shellService = lclService;
@@ -92,10 +80,18 @@ celix_status_t shell_addCommand(shell_pt shell, service_reference_pt reference)
 
 	command_service_pt command = NULL;
 	void *cmd = NULL;
+    char *name = NULL;
 	bundleContext_getService(shell->bundleContext, reference, &cmd);
+  serviceReference_getProperty(reference, "command.name", &name);
 	command = (command_service_pt) cmd;
-	hashMap_put(shell->commandNameMap, command->getName(command->command), command);
-	hashMap_put(shell->commandReferenceMap, reference, command);
+    if (name != NULL) {
+	    hashMap_put(shell->commandNameMap, name, command);
+	    hashMap_put(shell->commandReferenceMap, reference, command);
+    } else {
+            status = CELIX_ILLEGAL_ARGUMENT;
+            fprintf(stderr, "TODO\n");
+            //TODO log to log service
+    }
 
 	return status;
 }
@@ -104,11 +100,13 @@ celix_status_t shell_removeCommand(shell_pt shell, service_reference_pt referenc
 	celix_status_t status = CELIX_SUCCESS;
 
 	command_service_pt command = (command_service_pt) hashMap_remove(shell->commandReferenceMap, reference);
-	if (command != NULL) {
+    char *name = NULL;
+    serviceReference_getProperty(reference, "command.name", &name);
+	if (command != NULL && name != NULL) {
 		bool result = false;
-		hashMap_remove(shell->commandNameMap, command->getName(command->command));
+		hashMap_remove(shell->commandNameMap, name);
 		bundleContext_ungetService(shell->bundleContext, reference, &result);
-	}
+	} 
 
 	return status;
 }
@@ -127,26 +125,21 @@ array_list_pt shell_getCommands(shell_pt shell) {
 }
 
 char * shell_getCommandUsage(shell_pt shell, char * commandName) {
-	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
-	return (command == NULL) ? NULL : command->getUsage(command->command);
+	//command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
+  //  char *usage = NULL;
+  //  bundleContext_getProperty(shell->bundleContext, "command.usage", &usage);
+	//return (command == NULL || usage == NULL) ? NULL : usage;
+  return "TODO";
 }
 
 char * shell_getCommandDescription(shell_pt shell, char * commandName) {
+        /*
 	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
-	return (command == NULL) ? NULL : command->getShortDescription(command->command);
-}
-
-service_reference_pt shell_getCommandReference(shell_pt shell, char * command) {
-	hash_map_iterator_pt iter = hashMapIterator_create(shell->commandReferenceMap);
-	while (hashMapIterator_hasNext(iter)) {
-		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-		command_service_pt cmd = (command_service_pt) hashMapEntry_getValue(entry);
-		if (strcmp(cmd->getName(cmd->command), command) == 0) {
-			return (service_reference_pt) hashMapEntry_getValue(entry);
-		}
-	}
-	hashMapIterator_destroy(iter);
-	return NULL;
+    char *desc = NULL;
+    bundleContext_getProperty(shell->bundleContext, "command.description", &desc);
+	return (command == NULL || desc == NULL) ? NULL : desc;
+  */
+  return "TODO";
 }
 
 void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *)) {
@@ -154,7 +147,10 @@ void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *
 	char * commandName = (pos != strlen(commandLine)) ? string_ndup((char *) commandLine, pos) : strdup(commandLine);
 	command_service_pt command = shell_getCommand(shell, commandName);
 	if (command != NULL) {
-		command->executeCommand(command->command, commandLine, out, error);
+            printf("TODO\n");
+            //FIXME udpate shell_executeCommand with FILE
+		    //command->executeCommand(command->command, commandLine, out, error);
+            command->executeCommand(command->handle, commandLine, stdout, stderr);
 	} else {
 		error("No such command\n");
 	}

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/public/include/command.h
----------------------------------------------------------------------
diff --git a/shell/public/include/command.h b/shell/public/include/command.h
index 81fcd3d..710bf9d 100644
--- a/shell/public/include/command.h
+++ b/shell/public/include/command.h
@@ -27,18 +27,15 @@
 #ifndef COMMAND_H_
 #define COMMAND_H_
 
-static const char * const OSGI_SHELL_COMMAND_SERVICE_NAME = "commandService";
+#include "celix_errno.h"
 
-typedef struct command * command_pt;
+static const char * const OSGI_SHELL_COMMAND_SERVICE_NAME = "commandService";
 
 typedef struct commandService * command_service_pt;
 
 struct commandService {
-	command_pt command;
-	char * (*getName)(command_pt command);
-	char * (*getUsage)(command_pt command);
-	char * (*getShortDescription)(command_pt command);
-	void (*executeCommand)(command_pt command, char * commandLine, void (*out)(char *), void (*error)(char *));
+	void *handle;
+	celix_status_t (*executeCommand)(void *handle, char * commandLine, FILE *outStream, FILE *errorStream);
 };
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/public/include/command_impl.h
----------------------------------------------------------------------
diff --git a/shell/public/include/command_impl.h b/shell/public/include/command_impl.h
deleted file mode 100644
index ae33738..0000000
--- a/shell/public/include/command_impl.h
+++ /dev/null
@@ -1,48 +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_impl.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_PRIVATE_H_
-#define COMMAND_PRIVATE_H_
-
-#include "command.h"
-#include "bundle_context.h"
-
-struct command {
-	char * name;
-	char * usage;
-	char * shortDescription;
-
-	bundle_context_pt bundleContext;
-	void *handle;
-
-	void (*executeCommand)(command_pt command, char * commandLine, void (*out)(char *), void (*error)(char *));
-};
-
-char *command_getName(command_pt command);
-char *command_getUsage(command_pt command);
-char *command_getShortDescription(command_pt command);
-
-#endif /* COMMAND_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/public/include/shell.h
----------------------------------------------------------------------
diff --git a/shell/public/include/shell.h b/shell/public/include/shell.h
index 25706c7..11a79b3 100644
--- a/shell/public/include/shell.h
+++ b/shell/public/include/shell.h
@@ -39,7 +39,6 @@ struct shellService {
 	array_list_pt (*getCommands)(shell_pt shell);
 	char * (*getCommandUsage)(shell_pt shell, char * commandName);
 	char * (*getCommandDescription)(shell_pt shell, char * commandName);
-	service_reference_pt (*getCommandReference)(shell_pt shell, char * command);
 	void (*executeCommand)(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *));
 };
 

http://git-wip-us.apache.org/repos/asf/celix/blob/cea3f9ec/shell/public/src/command.c
----------------------------------------------------------------------
diff --git a/shell/public/src/command.c b/shell/public/src/command.c
deleted file mode 100644
index 955fbe4..0000000
--- a/shell/public/src/command.c
+++ /dev/null
@@ -1,45 +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.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 <stdio.h>
-
-#include "command_impl.h"
-
-char * command_getName(command_pt command) {
-	return command->name;
-}
-
-char * command_getUsage(command_pt command) {
-	return command->usage;
-}
-
-char * command_getShortDescription(command_pt command) {
-	return command->shortDescription;
-}
-
-void command_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *)) {
-	command->executeCommand(command, line, out, err);
-}


[10/13] celix git commit: CELIX-230: Added some comment for the command service. Added some (char *) casts

Posted by pn...@apache.org.
CELIX-230: Added some comment for the command service. Added some (char *) casts


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/4234d9bb
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/4234d9bb
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/4234d9bb

Branch: refs/heads/feature/CELIX-269_depman
Commit: 4234d9bb0898819a56f27ce51f34e7693f079e43
Parents: 8104a77
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Nov 3 10:05:57 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Nov 3 10:05:57 2015 +0100

----------------------------------------------------------------------
 .../calculator_shell/private/src/calculator_shell_activator.c | 6 +++---
 shell/public/include/command.h                                | 7 +++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/4234d9bb/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c b/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c
index 275a67d..ddbe842 100644
--- a/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c
+++ b/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c
@@ -83,7 +83,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 	activator->addCmdSrv->executeCommand = (void *)addCommand_execute;
 	properties_pt props = properties_create();
 	properties_set(props, OSGI_SHELL_COMMAND_NAME, "add");
-	bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, activator->addCmdSrv, props, &activator->addCommand);
+	bundleContext_registerService(context, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, activator->addCmdSrv, props, &activator->addCommand);
 
 
 	activator->sqrtCmdSrv = calloc(1, sizeof(*activator->sqrtCmdSrv));
@@ -91,14 +91,14 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 	activator->sqrtCmdSrv->executeCommand = (void *)sqrtCommand_execute;
 	props = properties_create();
 	properties_set(props, OSGI_SHELL_COMMAND_NAME, "sqrt");
-	bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, activator->sqrtCmdSrv, props, &activator->sqrtCommand);
+	bundleContext_registerService(context, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, activator->sqrtCmdSrv, props, &activator->sqrtCommand);
 
 	activator->subCmdSrv = calloc(1, sizeof(*activator->subCmdSrv));
 	activator->subCmdSrv->handle = context;
 	activator->subCmdSrv->executeCommand = (void *)subCommand_execute;
 	props = properties_create();
 	properties_set(props, OSGI_SHELL_COMMAND_NAME, "sub");
-	bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, activator->subCmdSrv, props, &activator->subCommand);
+	bundleContext_registerService(context, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, activator->subCmdSrv, props, &activator->subCommand);
 
 	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/4234d9bb/shell/public/include/command.h
----------------------------------------------------------------------
diff --git a/shell/public/include/command.h b/shell/public/include/command.h
index 97872c7..9abe789 100644
--- a/shell/public/include/command.h
+++ b/shell/public/include/command.h
@@ -38,6 +38,13 @@ static const char * const OSGI_SHELL_COMMAND_SERVICE_NAME = "commandService";
 
 typedef struct commandService * 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);


[03/13] celix git commit: CELIX-230: * Updated all commands to use new structure and service registration. * Moved static global field to shell activator instance. * (Re)implemented getUsage and getDescription functions of the shell.

Posted by pn...@apache.org.
CELIX-230:
* Updated all commands to use new structure and service registration.
* Moved static global field to shell activator instance.
* (Re)implemented getUsage and getDescription functions of the shell.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/4d52743e
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/4d52743e
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/4d52743e

Branch: refs/heads/feature/CELIX-269_depman
Commit: 4d52743eee05782afd0cb8b1b3f9d2de7808d1aa
Parents: 595f3e9
Author: Alexander Broekhuis <a....@gmail.com>
Authored: Fri Mar 27 22:01:30 2015 +0100
Committer: Alexander Broekhuis <a....@gmail.com>
Committed: Fri Mar 27 22:01:30 2015 +0100

----------------------------------------------------------------------
 shell/CMakeLists.txt                  |  14 ++--
 shell/private/include/shell_private.h |   2 +-
 shell/private/src/activator.c         | 114 ++++++++++-----------------
 shell/private/src/help_command.c      |  44 +++--------
 shell/private/src/inspect_command.c   | 121 ++++++++++-------------------
 shell/private/src/install_command.c   |  49 +++---------
 shell/private/src/log_command.c       |  47 +++--------
 shell/private/src/ps_command.c        |   5 +-
 shell/private/src/shell.c             |  55 ++++++++++---
 shell/private/src/stop_command.c      |  34 +++-----
 shell/private/src/uninstall_command.c |  33 ++------
 shell/private/src/update_command.c    |  42 +++-------
 shell/public/include/shell.h          |   1 +
 13 files changed, 194 insertions(+), 367 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 09777d3..66194ce 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -28,13 +28,13 @@ if (SHELL)
     	private/src/shell 
     	private/src/ps_command 
       private/src/start_command 
-      #private/src/stop_command
-      #private/src/install_command 
-      #private/src/update_command
-      #private/src/uninstall_command 
-      #private/src/log_command
-      #private/src/inspect_command
-      #private/src/help_command
+      private/src/stop_command
+      private/src/install_command
+      private/src/update_command
+      private/src/uninstall_command
+      private/src/log_command
+      private/src/inspect_command
+      private/src/help_command
     )
     
     install_bundle(shell

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/include/shell_private.h
----------------------------------------------------------------------
diff --git a/shell/private/include/shell_private.h b/shell/private/include/shell_private.h
index db609ca..9734ad5 100644
--- a/shell/private/include/shell_private.h
+++ b/shell/private/include/shell_private.h
@@ -45,7 +45,7 @@ celix_status_t shell_addCommand(shell_pt shell, service_reference_pt reference);
 
 char * shell_getCommandUsage(shell_pt shell, char * commandName);
 char * shell_getCommandDescription(shell_pt shell, char * commandName);
-service_reference_pt shell_getCommandReference(shell_pt shell, char * command);
+celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
 void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *));
 void shell_serviceChanged(service_listener_pt listener, service_event_pt event);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/activator.c
----------------------------------------------------------------------
diff --git a/shell/private/src/activator.c b/shell/private/src/activator.c
index ce01b59..cfa8bb3 100644
--- a/shell/private/src/activator.c
+++ b/shell/private/src/activator.c
@@ -24,16 +24,12 @@
  *  \copyright	Apache License, Version 2.0
  */
 #include <stdlib.h>
-#include <string.h>
 
 #include "shell_private.h"
 #include "bundle_activator.h"
-#include "bundle_context.h"
-#include "service_registration.h"
-#include "service_listener.h"
-#include "utils.h"
 #include "std_commands.h"
-#include "properties.h"
+
+#define NUMBER_OF_COMMANDS 10
 
 struct command {
     celix_status_t (*exec)(void *handle, char *commandLine, FILE *out, FILE *err);
@@ -45,55 +41,18 @@ struct command {
     properties_pt props;
 };
 
-static struct command std_commands[] = {
-        {psCommand_execute, "ps", "list installed bundles.", "ps [-l | -s | -u]", NULL, NULL, NULL},
-        {startCommand_execute, "start", "start bundle(s).", "start <id> [<id> ...]", NULL, NULL, NULL},
-        {NULL, NULL, NULL, NULL, NULL, NULL, NULL} /*marker for last element*/ 
-};
-
-
 struct bundle_instance {
 	shell_service_pt shellService;
 	service_registration_pt registration;
 	service_listener_pt listener;
 
-    /*
-    ps
-
-	service_registration_pt stopCommand;
-	command_pt stopCmd;
-	command_service_pt stopCmdSrv;
-
-	service_registration_pt installCommand;
-	command_pt installCmd;
-	command_service_pt installCmdSrv;
-
-	service_registration_pt uninstallCommand;
-	command_pt uninstallCmd;
-	command_service_pt uninstallCmdSrv;
-
-	service_registration_pt updateCommand;
-	command_pt updateCmd;
-	command_service_pt updateCmdSrv;
-
-	service_registration_pt logCommand;
-	command_pt logCmd;
-	command_service_pt logCmdSrv;
-
-	service_registration_pt inspectCommand;
-	command_pt inspectCmd;
-	command_service_pt inspectCmdSrv;
-
-	service_registration_pt helpCommand;
-	command_pt helpCmd;
-	command_service_pt helpCmdSrv;
-    */
+    struct command std_commands[NUMBER_OF_COMMANDS];
 };
 
 typedef struct bundle_instance *bundle_instance_pt;
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status;
 
 	bundle_instance_pt bi = (bundle_instance_pt) calloc(1, sizeof(struct bundle_instance));
 
@@ -107,18 +66,29 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 	else {
 		status = shell_create(context, &bi->shellService);
 
-    int i = 0;
-    while (std_commands[i].exec != NULL) {
-            std_commands[i].props = properties_create();
-            if (std_commands[i].props != NULL) {
-                    properties_set(std_commands[i].props, "command.name", std_commands[i].name);
-                    properties_set(std_commands[i].props, "command.usage", std_commands[i].usage);
-                    properties_set(std_commands[i].props, "command.description", std_commands[i].description);
-
-                    std_commands[i].service = calloc(1, sizeof(struct commandService));
-                    if (std_commands[i].service != NULL) {
-                            std_commands[i].service->handle = context;
-                            std_commands[i].service->executeCommand = std_commands[i].exec;
+        bi->std_commands[0] = (struct command) {.exec = psCommand_execute, .name = "ps", .description = "list installed bundles.", .usage = "ps [-l | -s | -u]"};
+        bi->std_commands[1] = (struct command) {.exec = startCommand_execute, .name = "start", .description = "start bundle(s).", .usage = "start <id> [<id> ...]"};
+        bi->std_commands[2] = (struct command) {.exec = stopCommand_execute, .name = "stop", .description = "stop bundle(s).", .usage = "stop <id> [<id> ...]"};
+        bi->std_commands[3] = (struct command) {.exec = installCommand_execute, .name = "install", .description = "install bundle(s).", .usage = "install <file> [<file> ...]"};
+        bi->std_commands[4] = (struct command) {.exec = uninstallCommand_execute, .name = "uninstall", .description = "uninstall bundle(s).", .usage = "uninstall <file> [<file> ...]"};
+        bi->std_commands[5] = (struct command) {.exec = updateCommand_execute, .name = "update", .description = "update bundle(s).", .usage = "update <id> [<URL>]"};
+        bi->std_commands[6] = (struct command) {.exec = helpCommand_execute, .name = "help", .description = "display available commands and description.", .usage = "help <command>]"};
+        bi->std_commands[7] = (struct command) {.exec = logCommand_execute, .name = "log", .description = "print log.", .usage = "log"};
+        bi->std_commands[8] = (struct command) {.exec = inspectCommand_execute, .name = "inspect", .description = "inspect services and components.", .usage = "inspect (service) (capability|requirement) [<id> ...]"};
+        bi->std_commands[9] = (struct command) {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; /*marker for last element*/
+
+        int i = 0;
+        while (bi->std_commands[i].exec != NULL) {
+            bi->std_commands[i].props = properties_create();
+            if (bi->std_commands[i].props != NULL) {
+                    properties_set(bi->std_commands[i].props, "command.name", bi->std_commands[i].name);
+                    properties_set(bi->std_commands[i].props, "command.usage", bi->std_commands[i].usage);
+                    properties_set(bi->std_commands[i].props, "command.description", bi->std_commands[i].description);
+
+                    bi->std_commands[i].service = calloc(1, sizeof(struct commandService));
+                    if (bi->std_commands[i].service != NULL) {
+                        bi->std_commands[i].service->handle = context;
+                        bi->std_commands[i].service->executeCommand = bi->std_commands[i].exec;
                     } else {
                             status = CELIX_ENOMEM;
                             break;
@@ -142,7 +112,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 }
 
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status;
 	bundle_instance_pt bi = (bundle_instance_pt) userData;
 
 	status = bundleContext_registerService(context, (char *) OSGI_SHELL_SERVICE_NAME, bi->shellService, NULL, &bi->registration);
@@ -169,8 +139,8 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 		if (status == CELIX_SUCCESS) {
 
             int i = 0;
-            while (std_commands[i].exec != NULL) {
-                    status = bundleContext_registerService(context, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, std_commands[i].service, std_commands[i].props, &std_commands[i].reg);
+            while (bi->std_commands[i].exec != NULL) {
+                    status = bundleContext_registerService(context, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, bi->std_commands[i].service, bi->std_commands[i].props, &bi->std_commands[i].reg);
                     if (status != CELIX_SUCCESS) {
                             break;
                     }
@@ -185,15 +155,15 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 }
 
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status;
 	bundle_instance_pt bi = (bundle_instance_pt) userData;
 
-	//serviceRegistration_unregister(bi->registration);
             int i = 0;
-            while (std_commands[i].exec != NULL) {
-                    if (std_commands[i].reg!= NULL) {
-                            serviceRegistration_unregister(std_commands[i].reg);
-                            std_commands[i].reg = NULL;
+            while (bi->std_commands[i].exec != NULL) {
+                    if (bi->std_commands[i].reg!= NULL) {
+                            serviceRegistration_unregister(bi->std_commands[i].reg);
+                        bi->std_commands[i].reg = NULL;
+                        bi->std_commands[i].props = NULL;
                     }
                     i += 1;
             }
@@ -207,19 +177,17 @@ celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt contex
 	bundle_instance_pt bi = (bundle_instance_pt) userData;
 
   int i = 0;
-  while (std_commands[i].exec != NULL) {
-          if (std_commands[i].props != NULL) {
-                  properties_destroy(std_commands[i].props);
+  while (bi->std_commands[i].exec != NULL) {
+          if (bi->std_commands[i].props != NULL) {
+                  properties_destroy(bi->std_commands[i].props);
           } 
-          if (std_commands[i].service != NULL) {
-                  free(std_commands[i].service);
+          if (bi->std_commands[i].service != NULL) {
+                  free(bi->std_commands[i].service);
           }
           i += 1;
   }
 
-  if (bi != NULL) {
     free(bi);
-  }
 
 	return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/help_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/help_command.c b/shell/private/src/help_command.c
index b2ed30a..75be274 100644
--- a/shell/private/src/help_command.c
+++ b/shell/private/src/help_command.c
@@ -26,42 +26,23 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
-#include "bundle.h"
 #include "shell.h"
 
-void helpCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
-
-command_pt helpCommand_create(bundle_context_pt context) {
-	command_pt command = (command_pt) malloc(sizeof(*command));
-	command->bundleContext = context;
-	command->name = "help";
-	command->shortDescription = "display available command usage and description.";
-	command->usage = "start [<command> ...]";
-	command->executeCommand = helpCommand_execute;
-	return command;
-}
-
-void helpCommand_destroy(command_pt command) {
-	free(command);
-}
-
-
-void helpCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *)) {
+celix_status_t helpCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
+	bundle_context_pt context = handle;
 	service_reference_pt shellService = NULL;
-	bundleContext_getServiceReference(command->bundleContext, (char *) OSGI_SHELL_SERVICE_NAME, &shellService);
+	bundleContext_getServiceReference(context, (char *) OSGI_SHELL_SERVICE_NAME, &shellService);
 
 	if (shellService != NULL) {
 		shell_service_pt shell = NULL;
-		bundleContext_getService(command->bundleContext, shellService, (void **) &shell);
+		bundleContext_getService(context, shellService, (void **) &shell);
 
 		if (shell != NULL) {
 			char delims[] = " ";
 			char * sub = NULL;
 			char *save_ptr = NULL;
-			char outString[256];
 
 			sub = strtok_r(line, delims, &save_ptr);
 			sub = strtok_r(NULL, delims, &save_ptr);
@@ -71,10 +52,9 @@ void helpCommand_execute(command_pt command, char * line, void (*out)(char *), v
 				array_list_pt commands = shell->getCommands(shell->shell);
 				for (i = 0; i < arrayList_size(commands); i++) {
 					char *name = arrayList_get(commands, i);
-					sprintf(outString, "%s\n", name);
-					out(outString);
+					fprintf(outStream, "%s\n", name);
 				}
-				out("\nUse 'help <command-name>' for more information.\n");
+				fprintf(outStream, "\nUse 'help <command-name>' for more information.\n");
 			} else {
 				bool found = false;
 				while (sub != NULL) {
@@ -87,15 +67,12 @@ void helpCommand_execute(command_pt command, char * line, void (*out)(char *), v
 							char *usage = shell->getCommandUsage(shell->shell, name);
 
 							if (found) {
-								out("---\n");
+								fprintf(outStream, "---\n");
 							}
 							found = true;
-							sprintf(outString, "Command     : %s\n", name);
-							out(outString);
-							sprintf(outString, "Usage       : %s\n", usage);
-							out(outString);
-							sprintf(outString, "Description : %s\n", desc);
-							out(outString);
+							fprintf(outStream, "Command     : %s\n", name);
+							fprintf(outStream, "Usage       : %s\n", usage);
+							fprintf(outStream, "Description : %s\n", desc);
 						}
 					}
 					sub = strtok_r(NULL, delims, &save_ptr);
@@ -103,4 +80,5 @@ void helpCommand_execute(command_pt command, char * line, void (*out)(char *), v
 			}
 		}
 	}
+	return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/inspect_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/inspect_command.c b/shell/private/src/inspect_command.c
index bac1ed9..68b7625 100644
--- a/shell/private/src/inspect_command.c
+++ b/shell/private/src/inspect_command.c
@@ -27,41 +27,23 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
-#include "bundle.h"
-#include "module.h"
-#include "constants.h"
-#include "service_registration.h"
-#include "service_reference.h"
-#include "hash_map.h"
+
+#include "std_commands.h"
 
 #define SERVICE_TYPE "service"
 #define CAPABILITY "capability"
 #define REQUIREMENT "requirement"
 
-void inspectCommand_execute(command_pt command, char * commandline, void (*out)(char *), void (*err)(char *));
-celix_status_t inspectCommand_printExportedServices(command_pt command, array_list_pt ids, void (*out)(char *), void (*err)(char *));
-celix_status_t inspectCommand_printImportedServices(command_pt command, array_list_pt ids, void (*out)(char *), void (*err)(char *));
-
-command_pt inspectCommand_create(bundle_context_pt context) {
-	command_pt command = (command_pt) malloc(sizeof(*command));
-	command->bundleContext = context;
-	command->name = "inspect";
-	command->shortDescription = "inspect dependencies";
-	command->usage = "inspect (service) (capability|requirement) [<id> ...]";
-	command->executeCommand = inspectCommand_execute;
-	return command;
-}
-
-void inspectCommand_destroy(command_pt command) {
-	free(command);
-}
+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);
 
-void inspectCommand_execute(command_pt command, char * commandline, void (*out)(char *), void (*err)(char *)) {
+celix_status_t inspectCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream) {
 	celix_status_t status = CELIX_SUCCESS;
-	char outString[256];
+
+	bundle_context_pt context = handle;
+
 	char *token;
 	strtok_r(commandline, " ", &token);
 	char *type = strtok_r(NULL, " ", &token);
@@ -79,43 +61,36 @@ void inspectCommand_execute(command_pt command, char * commandline, void (*out)(
 
 			if (strcmp(type, SERVICE_TYPE) == 0) {
 				if (strcmp(direction, CAPABILITY) == 0) {
-					status = inspectCommand_printExportedServices(command, ids, out, err);
+					status = inspectCommand_printExportedServices(context, ids, outStream, errStream);
 					if (status != CELIX_SUCCESS) {
-						out("INSPECT: Error\n");
+						fprintf(errStream, "INSPECT: Error\n");
 					}
 				} else if (strcmp(direction, REQUIREMENT) == 0) {
-                    status = inspectCommand_printImportedServices(command, ids, out, err);
+                    status = inspectCommand_printImportedServices(context, ids, outStream, errStream);
                     if (status != CELIX_SUCCESS) {
-                        out("INSPECT: Error\n");
+						fprintf(errStream, "INSPECT: Error\n");
                     }
 				} else {
-				    out("INSPECT: Invalid argument\n");
-                    sprintf(outString, "%s\n", command->usage);
-                    out(outString);
+					fprintf(errStream, "INSPECT: Invalid argument\n");
 				}
 			} else {
-				out("INSPECT: Invalid argument\n");
-				sprintf(outString, "%s\n", command->usage);
-                out(outString);
+				fprintf(errStream, "INSPECT: Invalid argument\n");
 			}
 		} else {
-			out("INSPECT: Too few arguments\n");
-			sprintf(outString, "%s\n", command->usage);
-			out(outString);
+			fprintf(errStream, "INSPECT: Too few arguments\n");
 		}
 	} else {
-		out("INSPECT: Too few arguments\n");
-		sprintf(outString, "%s\n", command->usage);
-		out(outString);
+		fprintf(errStream, "INSPECT: Too few arguments\n");
 	}
+	return status;
 }
 
-celix_status_t inspectCommand_printExportedServices(command_pt command, array_list_pt ids, void (*out)(char *), void (*err)(char *)) {
+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(command->bundleContext, &bundles);
+		status = bundleContext_getBundles(context, &bundles);
 	} else {
 		unsigned int i;
 
@@ -124,13 +99,11 @@ celix_status_t inspectCommand_printExportedServices(command_pt command, array_li
 			char *idStr = (char *) arrayList_get(ids, i);
 			long id = atol(idStr);
 			bundle_pt b = NULL;
-			celix_status_t st = bundleContext_getBundleById(command->bundleContext, id, &b);
+			celix_status_t st = bundleContext_getBundleById(context, id, &b);
 			if (st == CELIX_SUCCESS) {
 				arrayList_add(bundles, b);
 			} else {
-				char line[256];
-				sprintf(line, "INSPECT: Invalid bundle ID: %ld\n", id);
-				out(line);
+				fprintf(outStream, "INSPECT: Invalid bundle ID: %ld\n", id);
 			}
 		}
 	}
@@ -141,26 +114,24 @@ celix_status_t inspectCommand_printExportedServices(command_pt command, array_li
 			bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
 
 			if (i > 0) {
-				out("\n");
+				fprintf(outStream, "\n");
 			}
 
 			if (bundle != NULL) {
 				array_list_pt refs = NULL;
 
 				if (bundle_getRegisteredServices(bundle, &refs) == CELIX_SUCCESS) {
-					char line[256];
 					module_pt module = NULL;
 					char * name = NULL;
 					status = bundle_getCurrentModule(bundle, &module);
 					if (status == CELIX_SUCCESS) {
 						status = module_getSymbolicName(module, &name);
 						if (status == CELIX_SUCCESS) {
-							sprintf(line, "%s provides services:\n", name);
-							out(line);
-							out("==============\n");
+							fprintf(outStream, "%s provides services:\n", name);
+							fprintf(outStream, "==============\n");
 
 							if (refs == NULL || arrayList_size(refs) == 0) {
-								out("Nothing\n");
+								fprintf(outStream, "Nothing\n");
 							} else {
 								unsigned int j = 0;
 								for (j = 0; j < arrayList_size(refs); j++) {
@@ -169,19 +140,18 @@ celix_status_t inspectCommand_printExportedServices(command_pt command, array_li
 									char **keys;
 
 									serviceReference_getPropertyKeys(ref, &keys, &size);
-									for (int i = 0; i < size; i++) {
-									    char *key = keys[i];
+									for (int k = 0; k < size; k++) {
+									    char *key = keys[k];
 									    char *value = NULL;
 									    serviceReference_getProperty(ref, key, &value);
 
-									    sprintf(line, "%s = %s\n", key, value);
-                                        out(line);
+										fprintf(outStream, "%s = %s\n", key, value);
 									}
 
 //									objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
 //									sprintf(line, "ObjectClass = %s\n", objectClass);
 									if ((j + 1) < arrayList_size(refs)) {
-										out("----\n");
+										fprintf(outStream, "----\n");
 									}
 								}
 							}
@@ -196,12 +166,12 @@ celix_status_t inspectCommand_printExportedServices(command_pt command, array_li
 	return status;
 }
 
-celix_status_t inspectCommand_printImportedServices(command_pt command, array_list_pt ids, void (*out)(char *), void (*err)(char *)) {
+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(command->bundleContext, &bundles);
+        status = bundleContext_getBundles(context, &bundles);
     } else {
         unsigned int i;
 
@@ -210,13 +180,11 @@ celix_status_t inspectCommand_printImportedServices(command_pt command, array_li
             char *idStr = (char *) arrayList_get(ids, i);
             long id = atol(idStr);
             bundle_pt b = NULL;
-            celix_status_t st = bundleContext_getBundleById(command->bundleContext, id, &b);
+            celix_status_t st = bundleContext_getBundleById(context, id, &b);
             if (st == CELIX_SUCCESS) {
                 arrayList_add(bundles, b);
             } else {
-                char line[256];
-                sprintf(line, "INSPECT: Invalid bundle ID: %ld\n", id);
-                out(line);
+				fprintf(outStream, "INSPECT: Invalid bundle ID: %ld\n", id);
             }
         }
     }
@@ -227,31 +195,28 @@ celix_status_t inspectCommand_printImportedServices(command_pt command, array_li
             bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
 
             if (i > 0) {
-                out("\n");
+				fprintf(outStream, "\n");
             }
 
             if (bundle != NULL) {
                 array_list_pt refs = NULL;
 
                 if (bundle_getServicesInUse(bundle, &refs) == CELIX_SUCCESS) {
-                    char line[256];
                     module_pt module = NULL;
                     char * name = NULL;
                     status = bundle_getCurrentModule(bundle, &module);
                     if (status == CELIX_SUCCESS) {
                         status = module_getSymbolicName(module, &name);
                         if (status == CELIX_SUCCESS) {
-                            sprintf(line, "%s requires services:\n", name);
-                            out(line);
-                            out("==============\n");
+							fprintf(outStream, "%s requires services:\n", name);
+							fprintf(outStream, "==============\n");
 
                             if (refs == NULL || arrayList_size(refs) == 0) {
-                                out("Nothing\n");
+								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);
-                                    char line[256];
                                     bundle_pt usedBundle = NULL;
                                     module_pt usedModule = NULL;
                                     char *usedSymbolicName = NULL;
@@ -262,26 +227,24 @@ celix_status_t inspectCommand_printImportedServices(command_pt command, array_li
                                     bundle_getCurrentModule(usedBundle, &usedModule);
                                     module_getSymbolicName(usedModule, &usedSymbolicName);
 
-                                    sprintf(line, "%s [%ld]\n", usedSymbolicName, usedBundleId);
-                                    out(line);
+									fprintf(outStream, "%s [%ld]\n", usedSymbolicName, usedBundleId);
 
                                     unsigned int size = 0;
                                     char **keys;
 
                                     serviceReference_getPropertyKeys(ref, &keys, &size);
-                                    for (int i = 0; i < size; i++) {
-                                        char *key = keys[i];
+                                    for (int k = 0; k < size; k++) {
+                                        char *key = keys[k];
                                         char *value = NULL;
                                         serviceReference_getProperty(ref, key, &value);
 
-                                        sprintf(line, "%s = %s\n", key, value);
-                                        out(line);
+										fprintf(outStream, "%s = %s\n", key, value);
                                     }
 
 //                                  objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
 //                                  sprintf(line, "ObjectClass = %s\n", objectClass);
                                     if ((j + 1) < arrayList_size(refs)) {
-                                        out("----\n");
+										fprintf(outStream, "----\n");
                                     }
                                 }
                             }

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/install_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/install_command.c b/shell/private/src/install_command.c
index 352cbfa..067ba2b 100644
--- a/shell/private/src/install_command.c
+++ b/shell/private/src/install_command.c
@@ -26,51 +26,28 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
-#include "bundle_archive.h"
-#include "module.h"
-#include "bundle.h"
-#include "install_command.h"
 
-void installCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
-void installCommand_install(command_pt command, bundle_pt *bundle, char * location, void (*out)(char *), void (*err)(char *));
+void installCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
+	bundle_context_pt context = handle;
 
-command_pt installCommand_create(bundle_context_pt context) {
-	command_pt command = (command_pt) malloc(sizeof(*command));
-	command->bundleContext = context;
-	command->name = "install";
-	command->shortDescription = "install bundle(s).";
-	command->usage = "install <file> [<file> ...]";
-	command->executeCommand = installCommand_execute;
-	return command;
-}
-
-void installCommand_destroy(command_pt command) {
-	free(command);
-}
-
-void installCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *)) {
 	char delims[] = " ";
 	char * sub = NULL;
 	char *save_ptr = NULL;
 	char info[256];
-	char outString[256];
 
 	// ignore the command
 	sub = strtok_r(line, delims, &save_ptr);
 	sub = strtok_r(NULL, delims, &save_ptr);
 	
 	if (sub == NULL) {
-		err("Incorrect number of arguments.\n");
-		sprintf(outString, "%s\n", command->usage);
-		out(outString);
+		fprintf(errStream, "Incorrect number of arguments.\n");
 	} else {
 		info[0] = '\0';
 		while (sub != NULL) {
 			bundle_pt bundle = NULL;
-			installCommand_install(command, &bundle, sub, out, err);
+			bundleContext_installBundle(context, sub, &bundle);
 			if (bundle != NULL) {
 				long id;
 				bundle_archive_pt archive = NULL;
@@ -87,17 +64,13 @@ void installCommand_execute(command_pt command, char * line, void (*out)(char *)
 			sub = strtok_r(NULL, delims, &save_ptr);
 		}
 		if (strchr(info, ',') != NULL) {
-			out("Bundle IDs: ");
-			out(info);
-			out("\n");
+			fprintf(outStream, "Bundle IDs: ");
+			fprintf(outStream, "%s", info);
+			fprintf(outStream, "\n");
 		} else if (strlen(info) > 0) {
-			out("Bundle ID: ");
-			out(info);
-			out("\n");
+			fprintf(outStream, "Bundle ID: ");
+			fprintf(outStream, "%s", info);
+			fprintf(outStream, "\n");
 		}
 	}
-}
-
-void installCommand_install(command_pt command, bundle_pt *bundle, char * location, void (*out)(char *), void (*err)(char *)) {
-	bundleContext_installBundle(command->bundleContext, location, bundle);
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/log_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/log_command.c b/shell/private/src/log_command.c
index 403ed65..95679ca 100644
--- a/shell/private/src/log_command.c
+++ b/shell/private/src/log_command.c
@@ -27,41 +27,23 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_impl.h"
-#include "log_command.h"
 #include "bundle_context.h"
 #include "log_reader_service.h"
-#include "log_entry.h"
 #include "linked_list_iterator.h"
 
-void logCommand_execute(command_pt command, char *line, void (*out)(char *), void (*err)(char *));
-celix_status_t logCommand_levelAsString(command_pt command, log_level_t level, char **string);
+celix_status_t logCommand_levelAsString(bundle_context_pt context, log_level_t level, char **string);
 
-command_pt logCommand_create(bundle_context_pt context) {
-    command_pt command = (command_pt) malloc(sizeof(*command));
-    command->bundleContext = context;
-    command->name = "log";
-    command->shortDescription = "print log";
-    command->usage = "log";
-    command->executeCommand = logCommand_execute;
-    return command;
-}
-
-void logCommand_destroy(command_pt command) {
-    free(command);
-}
-
-void logCommand_execute(command_pt command, char *line, void (*out)(char *), void (*err)(char *)) {
+void logCommand_execute(bundle_context_pt context, char *line, FILE *outStream, FILE *errStream) {
     service_reference_pt readerService = NULL;
 
-    bundleContext_getServiceReference(command->bundleContext, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, &readerService);
+    bundleContext_getServiceReference(context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, &readerService);
     if (readerService != NULL) {
         linked_list_pt list = NULL;
         linked_list_iterator_pt iter = NULL;
         log_reader_service_pt reader = NULL;
 
 
-		bundleContext_getService(command->bundleContext, readerService, (void **) &reader);
+		bundleContext_getService(context, readerService, (void **) &reader);
 		reader->getLog(reader->reader, &list);
 		iter = linkedListIterator_create(list, 0);
 		while (linkedListIterator_hasNext(iter)) {
@@ -70,33 +52,26 @@ void logCommand_execute(command_pt command, char *line, void (*out)(char *), voi
 			char *level = NULL;
 			char errorString[256];
 
-			size_t timeLength = strftime(time, 20, "%Y-%m-%d %H:%M:%S", localtime(&entry->time));
-			logCommand_levelAsString(command, entry->level, &level);
+			logCommand_levelAsString(context, entry->level, &level);
 
 			if (entry->errorCode > 0) {
 				celix_strerror(entry->errorCode, errorString, 256);
-				size_t length = timeLength + strlen(entry->bundleSymbolicName) + strlen(entry->message) + strlen(errorString) + 40;
-		        char line[length];
-				snprintf(line, length, "%s - Bundle: %s - %s - %d %s\n", time, entry->bundleSymbolicName, entry->message, entry->errorCode, errorString);
-				out(line);
+				fprintf(outStream, "%s - Bundle: %s - %s - %d %s\n", time, entry->bundleSymbolicName, entry->message, entry->errorCode, errorString);
 			} else {
-				size_t length = timeLength + strlen(entry->bundleSymbolicName) + strlen(entry->message) + 20;
-				char line[length];
-				snprintf(line, length, "%s - Bundle: %s - %s\n", time, entry->bundleSymbolicName, entry->message);
-				out(line);
+				fprintf(outStream, "%s - Bundle: %s - %s\n", time, entry->bundleSymbolicName, entry->message);
 			}
 		}
 		linkedListIterator_destroy(iter);
 		linkedList_destroy(list);
 		bool result = true;
-		bundleContext_ungetService(command->bundleContext, readerService, &result);
-        bundleContext_ungetServiceReference(command->bundleContext, readerService);
+		bundleContext_ungetService(context, readerService, &result);
+        bundleContext_ungetServiceReference(context, readerService);
     } else {
-        out("No log reader available\n");
+		fprintf(outStream, "No log reader available\n");
     }
 }
 
-celix_status_t logCommand_levelAsString(command_pt command, log_level_t level, char **string) {
+celix_status_t logCommand_levelAsString(bundle_context_pt context, log_level_t level, char **string) {
 	switch (level) {
 	case OSGI_LOGSERVICE_ERROR:
 		*string = "ERROR";

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/ps_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/ps_command.c b/shell/private/src/ps_command.c
index 7511391..ce84e99 100644
--- a/shell/private/src/ps_command.c
+++ b/shell/private/src/ps_command.c
@@ -28,9 +28,8 @@
 
 #include "array_list.h"
 #include "bundle_context.h"
-#include "bundle_archive.h"
-#include "module.h"
-#include "bundle.h"
+
+#include "std_commands.h"
 
 static char * psCommand_stateString(bundle_state_e state); 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/shell.c
----------------------------------------------------------------------
diff --git a/shell/private/src/shell.c b/shell/private/src/shell.c
index 4b3e494..3500d89 100644
--- a/shell/private/src/shell.c
+++ b/shell/private/src/shell.c
@@ -54,6 +54,7 @@ celix_status_t shell_create(bundle_context_pt context, shell_service_pt* shellSe
 		lclService->getCommands = shell_getCommands;
 		lclService->getCommandDescription = shell_getCommandDescription;
 		lclService->getCommandUsage = shell_getCommandUsage;
+		lclService->getCommandReference = shell_getCommandReference;
 		lclService->executeCommand = shell_executeCommand;
 
 		*shellService = lclService;
@@ -125,21 +126,51 @@ array_list_pt shell_getCommands(shell_pt shell) {
 }
 
 char * shell_getCommandUsage(shell_pt shell, char * commandName) {
-	//command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
-  //  char *usage = NULL;
-  //  bundleContext_getProperty(shell->bundleContext, "command.usage", &usage);
-	//return (command == NULL || usage == NULL) ? NULL : usage;
-  return "TODO";
+	char *usage = NULL;
+	service_reference_pt reference = NULL;
+	shell_getCommandReference(shell, commandName, &reference);
+	if (reference) {
+		serviceReference_getProperty(reference, "command.usage", &usage);
+	}
+
+	return usage;
 }
 
 char * shell_getCommandDescription(shell_pt shell, char * commandName) {
-        /*
-	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
-    char *desc = NULL;
-    bundleContext_getProperty(shell->bundleContext, "command.description", &desc);
-	return (command == NULL || desc == NULL) ? NULL : desc;
-  */
-  return "TODO";
+	char *description = NULL;
+	service_reference_pt reference = NULL;
+	shell_getCommandReference(shell, commandName, &reference);
+	if (reference) {
+		serviceReference_getProperty(reference, "command.description", &description);
+	}
+
+	return description;
+}
+
+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->commandReferenceMap);
+		while (hashMapIterator_hasNext(iter)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+			service_reference_pt reference = hashMapEntry_getKey(entry);
+			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;
 }
 
 void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *)) {

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/stop_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/stop_command.c b/shell/private/src/stop_command.c
index 2529d49..a790c74 100644
--- a/shell/private/src/stop_command.c
+++ b/shell/private/src/stop_command.c
@@ -26,41 +26,23 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle.h"
 #include "utils.h"
 
-void stopCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
-
-command_pt stopCommand_create(bundle_context_pt context) {
-	command_pt command = (command_pt) malloc(sizeof(*command));
-	command->bundleContext = context;
-	command->name = "stop";
-	command->shortDescription = "stop bundle(s).";
-	command->usage = "start <id> [<id> ...]";
-	command->executeCommand = stopCommand_execute;
-	return command;
-}
-
-void stopCommand_destroy(command_pt command) {
-	free(command);
-}
-
-void stopCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *)) {
+celix_status_t stopCommand_execute(void *handle, char *line, FILE *outStream, FILE *errStream) {
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = handle;
     char delims[] = " ";
 	char * sub = NULL;
 	char *save_ptr = NULL;
-	char outString[256];
 
 	sub = strtok_r(line, delims, &save_ptr);
 	sub = strtok_r(NULL, delims, &save_ptr);
 
 	if (sub == NULL) {
-		err("Incorrect number of arguments.\n");
-		sprintf(outString, "%s\n", command->usage);
-		out(outString);
+		fprintf(outStream, "Incorrect number of arguments.\n");
 	} else {
 		while (sub != NULL) {
 			bool numeric;
@@ -68,16 +50,18 @@ void stopCommand_execute(command_pt command, char * line, void (*out)(char *), v
 			if (numeric) {
 				long id = atol(sub);
 				bundle_pt bundle = NULL;
-				bundleContext_getBundleById(command->bundleContext, id, &bundle);
+				bundleContext_getBundleById(context, id, &bundle);
 				if (bundle != NULL) {
 					bundle_stopWithOptions(bundle, 0);
 				} else {
-					err("Bundle id is invalid.");
+					fprintf(outStream, "Bundle id is invalid.");
 				}
 			} else {
-				err("Bundle id should be a number (bundle id).\n");
+				fprintf(outStream, "Bundle id should be a number (bundle id).\n");
 			}
 			sub = strtok_r(NULL, delims, &save_ptr);
 		}
 	}
+
+	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/uninstall_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/uninstall_command.c b/shell/private/src/uninstall_command.c
index da57319..973adf2 100644
--- a/shell/private/src/uninstall_command.c
+++ b/shell/private/src/uninstall_command.c
@@ -26,53 +26,32 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
-#include "bundle.h"
-#include "uninstall_command.h"
 
-void uninstallCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
-
-command_pt uninstallCommand_create(bundle_context_pt context) {
-	command_pt command = (command_pt) malloc(sizeof(*command));
-	command->bundleContext = context;
-	command->name = "uninstall";
-	command->shortDescription = "uninstall bundle(s).";
-	command->usage = "uninstall <id> [<id> ...]";
-	command->executeCommand = uninstallCommand_execute;
-	return command;
-}
-
-void uninstallCommand_destroy(command_pt command) {
-	free(command);
-}
-
-
-void uninstallCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *)) {
+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;
-	char outString[256];
 
 	sub = strtok_r(line, delims, &save_ptr);
 	sub = strtok_r(NULL, delims, &save_ptr);
 
 	if (sub == NULL) {
-		err("Incorrect number of arguments.\n");
-		sprintf(outString, "%s\n", command->usage);
-		out(outString);
+		fprintf(errStream, "Incorrect number of arguments.\n");
 	} else {
 		while (sub != NULL) {
 			long id = atol(sub);
 			bundle_pt bundle = NULL;
-			bundleContext_getBundleById(command->bundleContext, id, &bundle);
+			bundleContext_getBundleById(context, id, &bundle);
 			if (bundle != NULL) {
 				bundle_uninstall(bundle);
 			} else {
-				err("Bundle id is invalid.");
+				fprintf(errStream, "Bundle id is invalid.");
 			}
 			sub = strtok_r(NULL, delims, &save_ptr);
 		}
 	}
+	return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/private/src/update_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/update_command.c b/shell/private/src/update_command.c
index 9ddfba0..a0af0b0 100644
--- a/shell/private/src/update_command.c
+++ b/shell/private/src/update_command.c
@@ -27,50 +27,28 @@
 #include <stdlib.h>
 #include <string.h>
 #include <curl/curl.h>
-#include <curl/easy.h>
 
-#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
-#include "bundle.h"
-#include "update_command.h"
 
-void updateCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
-celix_status_t updateCommand_download(command_pt command, char * url, char **inputFile);
+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);
 
-command_pt updateCommand_create(bundle_context_pt context) {
-	command_pt command = (command_pt) malloc(sizeof(*command));
-	command->bundleContext = context;
-	command->name = "update";
-	command->shortDescription = "update bundle.";
-	command->usage = "update <id> [<URL>]";
-	command->executeCommand = updateCommand_execute;
-	return command;
-}
-
-void updateCommand_destroy(command_pt command) {
-	free(command);
-}
-
-
-void updateCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *)) {
+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;
-	char outString[256];
 
 	sub = strtok_r(line, delims, &save_ptr);
 	sub = strtok_r(NULL, delims, &save_ptr);
 
 	if (sub == NULL) {
-		err("Incorrect number of arguments.\n");
-		sprintf(outString, "%s\n", command->usage);
-		out(outString);
+		fprintf(errStream, "Incorrect number of arguments.\n");
 	} else {
 		long id = atol(sub);
-		bundleContext_getBundleById(command->bundleContext, id, &bundle);
+		bundleContext_getBundleById(context, id, &bundle);
 		if (bundle != NULL) {
 			char inputFile[256];
 			sub = strtok_r(NULL, delims, &save_ptr);
@@ -79,24 +57,22 @@ void updateCommand_execute(command_pt command, char * line, void (*out)(char *),
 				char *test = inputFile;
 				printf("URL: %s\n", sub);
 
-				if (updateCommand_download(command, sub, &test) == CELIX_SUCCESS) {
+				if (updateCommand_download(context, sub, &test) == CELIX_SUCCESS) {
 					printf("Update bundle with stream\n");
 					bundle_update(bundle, inputFile);
 				} else {
-					char error[256];
-					sprintf(error, "Unable to download from %s\n", sub);
-					err(error);
+					fprintf(errStream, "Unable to download from %s\n", sub);
 				}
 			} else {
 				bundle_update(bundle, NULL);
 			}
 		} else {
-			err("Bundle id is invalid.\n");
+			fprintf(errStream, "Bundle id is invalid.\n");
 		}
 	}
 }
 
-celix_status_t updateCommand_download(command_pt command, char * url, char **inputFile) {
+celix_status_t updateCommand_download(bundle_context_pt context, char * url, char **inputFile) {
 	CURL *curl = NULL;
 	CURLcode res = 0;
 	curl = curl_easy_init();

http://git-wip-us.apache.org/repos/asf/celix/blob/4d52743e/shell/public/include/shell.h
----------------------------------------------------------------------
diff --git a/shell/public/include/shell.h b/shell/public/include/shell.h
index 11a79b3..9fe60b4 100644
--- a/shell/public/include/shell.h
+++ b/shell/public/include/shell.h
@@ -39,6 +39,7 @@ struct shellService {
 	array_list_pt (*getCommands)(shell_pt shell);
 	char * (*getCommandUsage)(shell_pt shell, char * commandName);
 	char * (*getCommandDescription)(shell_pt shell, char * commandName);
+	celix_status_t (*getCommandReference)(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
 	void (*executeCommand)(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *));
 };
 


[06/13] celix git commit: CELIX-230: Renamed ps_command to lb_command

Posted by pn...@apache.org.
CELIX-230: Renamed ps_command to lb_command


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/3bf493eb
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/3bf493eb
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/3bf493eb

Branch: refs/heads/feature/CELIX-269_depman
Commit: 3bf493eb08c598df9a6f8f23ff9127bdc4efc28e
Parents: c35a74c
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Oct 27 16:26:01 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Oct 27 16:26:01 2015 +0100

----------------------------------------------------------------------
 shell/CMakeLists.txt           |   2 +-
 shell/private/src/lb_command.c | 181 ++++++++++++++++++++++++++++++++++++
 shell/private/src/ps_command.c | 181 ------------------------------------
 3 files changed, 182 insertions(+), 182 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/3bf493eb/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 8e83933..95bddd7 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -26,7 +26,7 @@ if (SHELL)
     	
      	private/src/activator
     	private/src/shell 
-    	private/src/ps_command 
+    	private/src/lb_command
       private/src/start_command 
       private/src/stop_command
       private/src/install_command

http://git-wip-us.apache.org/repos/asf/celix/blob/3bf493eb/shell/private/src/lb_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/lb_command.c b/shell/private/src/lb_command.c
new file mode 100644
index 0000000..fca93de
--- /dev/null
+++ b/shell/private/src/lb_command.c
@@ -0,0 +1,181 @@
+/**
+ *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"
+
+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_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);
+        }
+
+        fprintf(out_ptr, "  %-5s %-12s %s\n", "ID", "State", message_str);
+
+        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 - 1; 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;
+            char *state_str = NULL;
+            module_pt module_ptr = NULL;
+            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) {
+                fprintf(out_ptr, "  %-5ld %-12s %s\n", id, state_str, name_str);
+            }
+
+            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/3bf493eb/shell/private/src/ps_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/ps_command.c b/shell/private/src/ps_command.c
deleted file mode 100644
index fca93de..0000000
--- a/shell/private/src/ps_command.c
+++ /dev/null
@@ -1,181 +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"
-
-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_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);
-        }
-
-        fprintf(out_ptr, "  %-5s %-12s %s\n", "ID", "State", message_str);
-
-        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 - 1; 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;
-            char *state_str = NULL;
-            module_pt module_ptr = NULL;
-            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) {
-                fprintf(out_ptr, "  %-5ld %-12s %s\n", id, state_str, name_str);
-            }
-
-            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     ";
-    }
-}


[07/13] celix git commit: CELIX-230: Refactored shell command for remote service calculator example. Added missing include in command.h

Posted by pn...@apache.org.
CELIX-230: Refactored shell command for remote service calculator example. Added missing include in command.h


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/b63c0d9f
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/b63c0d9f
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/b63c0d9f

Branch: refs/heads/feature/CELIX-269_depman
Commit: b63c0d9fc96ec198437f5360e4cfb6f1152a056b
Parents: 3bf493e
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Oct 27 16:54:44 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Oct 27 16:54:44 2015 +0100

----------------------------------------------------------------------
 .../examples/calculator_shell/CMakeLists.txt    |  1 -
 .../private/include/add_command.h               |  5 +-
 .../private/include/sqrt_command.h              |  5 +-
 .../private/include/sub_command.h               |  5 +-
 .../calculator_shell/private/src/add_command.c  | 46 +++++-----------
 .../private/src/calculator_shell_activator.c    | 55 +++++++++-----------
 .../calculator_shell/private/src/sqrt_command.c | 42 ++++-----------
 .../calculator_shell/private/src/sub_command.c  | 46 +++++-----------
 shell/CMakeLists.txt                            |  6 +--
 shell/public/include/command.h                  |  1 +
 10 files changed, 71 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/remote_services/examples/calculator_shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/CMakeLists.txt b/remote_services/examples/calculator_shell/CMakeLists.txt
index dcb8c8f..b93afca 100644
--- a/remote_services/examples/calculator_shell/CMakeLists.txt
+++ b/remote_services/examples/calculator_shell/CMakeLists.txt
@@ -32,7 +32,6 @@ bundle(calculator_shell SOURCES
     private/include/add_command.h
     private/include/sqrt_command.h
     private/include/sub_command.h
-    ../../../shell/public/src/command.c
 
 
         FILES

http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/remote_services/examples/calculator_shell/private/include/add_command.h
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/include/add_command.h b/remote_services/examples/calculator_shell/private/include/add_command.h
index 1ff9d96..58a7bda 100644
--- a/remote_services/examples/calculator_shell/private/include/add_command.h
+++ b/remote_services/examples/calculator_shell/private/include/add_command.h
@@ -27,9 +27,6 @@
 #ifndef ADD_COMMAND_H_
 #define ADD_COMMAND_H_
 
-#include "command_impl.h"
-
-command_pt addCommand_create(bundle_context_pt context);
-void addCommand_destroy(command_pt command);
+void addCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE *err);
 
 #endif /* ADD_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/remote_services/examples/calculator_shell/private/include/sqrt_command.h
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/include/sqrt_command.h b/remote_services/examples/calculator_shell/private/include/sqrt_command.h
index 257abff..c9d07d2 100644
--- a/remote_services/examples/calculator_shell/private/include/sqrt_command.h
+++ b/remote_services/examples/calculator_shell/private/include/sqrt_command.h
@@ -27,9 +27,6 @@
 #ifndef SQRT_COMMAND_H_
 #define SQRT_COMMAND_H_
 
-#include "command_impl.h"
-
-command_pt sqrtCommand_create(bundle_context_pt context);
-void sqrtCommand_destroy(command_pt command);
+void sqrtCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE *err);
 
 #endif /* SQRT_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/remote_services/examples/calculator_shell/private/include/sub_command.h
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/include/sub_command.h b/remote_services/examples/calculator_shell/private/include/sub_command.h
index d584835..cf13616 100644
--- a/remote_services/examples/calculator_shell/private/include/sub_command.h
+++ b/remote_services/examples/calculator_shell/private/include/sub_command.h
@@ -27,9 +27,6 @@
 #ifndef SUB_COMMAND_H_
 #define SUB_COMMAND_H_
 
-#include "command_impl.h"
-
-command_pt subCommand_create(bundle_context_pt context);
-void subCommand_destroy(command_pt command);
+void subCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE *err);
 
 #endif /* SUB_COMMAND_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/remote_services/examples/calculator_shell/private/src/add_command.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/src/add_command.c b/remote_services/examples/calculator_shell/private/src/add_command.c
index 260add3..838ff25 100644
--- a/remote_services/examples/calculator_shell/private/src/add_command.c
+++ b/remote_services/examples/calculator_shell/private/src/add_command.c
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
+#include <command.h>
 
 #include "array_list.h"
 #include "bundle_context.h"
@@ -34,72 +35,53 @@
 #include "calculator_service.h"
 
 
-void addCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
-celix_status_t addCommand_isNumeric(command_pt command, char *number, bool *ret);
+static celix_status_t addCommand_isNumeric(char *number, bool *ret);
 
-command_pt addCommand_create(bundle_context_pt context) {
-    command_pt command = (command_pt) calloc(1, sizeof(*command));
-    if (command) {
-		command->bundleContext = context;
-		command->name = "add";
-		command->shortDescription = "add the given doubles";
-		command->usage = "add <double> <double>";
-		command->executeCommand = addCommand_execute;
-    }
-    return command;
-}
-
-void addCommand_destroy(command_pt command) {
-	free(command);
-}
-
-void addCommand_execute(command_pt command, char *line, void (*out)(char *), void (*err)(char *)) {
+void addCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE *err) {
 	celix_status_t status = CELIX_SUCCESS;
     service_reference_pt calculatorService = NULL;
 
-    status = bundleContext_getServiceReference(command->bundleContext, (char *) CALCULATOR_SERVICE, &calculatorService);
+    status = bundleContext_getServiceReference(context, (char *) CALCULATOR_SERVICE, &calculatorService);
     if (status == CELIX_SUCCESS) {
     	char *token = line;
     	strtok_r(line, " ", &token);
 		char *aStr = strtok_r(NULL, " ", &token);
 		bool numeric;
-		addCommand_isNumeric(command, aStr, &numeric);
+		addCommand_isNumeric(aStr, &numeric);
 		if (aStr != NULL && numeric) {
 			char *bStr = strtok_r(NULL, " ", &token);
-			addCommand_isNumeric(command, bStr, &numeric);
+			addCommand_isNumeric(bStr, &numeric);
 			if (bStr != NULL && numeric) {
 				calculator_service_pt calculator = NULL;
-				status = bundleContext_getService(command->bundleContext, calculatorService, (void *) &calculator);
+				status = bundleContext_getService(context, calculatorService, (void *) &calculator);
 				if (status == CELIX_SUCCESS) {
 					double a = atof(aStr);
 					double b = atof(bStr);
 					double result = 0;
 					status = calculator->add(calculator->calculator, a, b, &result);
 					if (status == CELIX_SUCCESS) {
-						char line[256];
-						sprintf(line, "CALCULATOR_SHELL: Add: %f + %f = %f\n", a, b, result);
-						out(line);
+						fprintf(out, "CALCULATOR_SHELL: Add: %f + %f = %f\n", a, b, result);
 					} else {
-						out("ADD: Unexpected exception in Calc service\n");
+						fprintf(err, "ADD: Unexpected exception in Calc service\n");
 					}
 				} else {
-					out("No calc service available\n");
+					fprintf(err, "No calc service available\n");
 				}
 			} else {
-				out("ADD: Requires 2 numerical parameter\n");
+				fprintf(err, "ADD: Requires 2 numerical parameter\n");
 			}
 		} else {
-			out("ADD: Requires 2 numerical parameter\n");
+			fprintf(err, "ADD: Requires 2 numerical parameter\n");
 			status = CELIX_ILLEGAL_ARGUMENT;
 		}
     } else {
-        out("No calc service available\n");
+		fprintf(err, "No calc service available\n");
     }
 
     //return status;
 }
 
-celix_status_t addCommand_isNumeric(command_pt command, char *number, bool *ret) {
+static celix_status_t addCommand_isNumeric(char *number, bool *ret) {
 	celix_status_t status = CELIX_SUCCESS;
 	*ret = true;
 	while(*number) {

http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c b/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c
index d0fca76..275a67d 100644
--- a/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c
+++ b/remote_services/examples/calculator_shell/private/src/calculator_shell_activator.c
@@ -25,33 +25,30 @@
  */
 #include <stdlib.h>
 #include <string.h>
+#include <command.h>
 
 #include "bundle_activator.h"
 #include "bundle_context.h"
 #include "service_registration.h"
 
-#include "command_impl.h"
-
 #include "add_command.h"
 #include "sub_command.h"
 #include "sqrt_command.h"
 
 struct activator {
 	service_registration_pt addCommand;
-	command_pt addCmd;
+	command_service_pt addCmd;
 	command_service_pt addCmdSrv;
 
 	service_registration_pt subCommand;
-	command_pt subCmd;
+	command_service_pt subCmd;
 	command_service_pt subCmdSrv;
 
 	service_registration_pt sqrtCommand;
-	command_pt sqrtCmd;
+	command_service_pt sqrtCmd;
 	command_service_pt sqrtCmdSrv;
 };
 
-static celix_status_t calculatorShell_createCommandService(command_pt command, command_service_pt *commandService);
-
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
 	if (status == CELIX_SUCCESS) {
@@ -81,31 +78,31 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 
 	struct activator * activator = (struct activator *) userData;
 
-	activator->addCmd = addCommand_create(context);
-	calculatorShell_createCommandService(activator->addCmd, &activator->addCmdSrv);
-	bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, activator->addCmdSrv, NULL, &activator->addCommand);
+	activator->addCmdSrv = calloc(1, sizeof(*activator->addCmdSrv));
+	activator->addCmdSrv->handle = context;
+	activator->addCmdSrv->executeCommand = (void *)addCommand_execute;
+	properties_pt props = properties_create();
+	properties_set(props, OSGI_SHELL_COMMAND_NAME, "add");
+	bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, activator->addCmdSrv, props, &activator->addCommand);
+
 
-	activator->subCmd = subCommand_create(context);
-	calculatorShell_createCommandService(activator->subCmd, &activator->subCmdSrv);
-	bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, activator->subCmdSrv, NULL, &activator->subCommand);
+	activator->sqrtCmdSrv = calloc(1, sizeof(*activator->sqrtCmdSrv));
+	activator->sqrtCmdSrv->handle = context;
+	activator->sqrtCmdSrv->executeCommand = (void *)sqrtCommand_execute;
+	props = properties_create();
+	properties_set(props, OSGI_SHELL_COMMAND_NAME, "sqrt");
+	bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, activator->sqrtCmdSrv, props, &activator->sqrtCommand);
 
-	activator->sqrtCmd = sqrtCommand_create(context);
-	calculatorShell_createCommandService(activator->sqrtCmd, &activator->sqrtCmdSrv);
-	bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, activator->sqrtCmdSrv, NULL, &activator->sqrtCommand);
+	activator->subCmdSrv = calloc(1, sizeof(*activator->subCmdSrv));
+	activator->subCmdSrv->handle = context;
+	activator->subCmdSrv->executeCommand = (void *)subCommand_execute;
+	props = properties_create();
+	properties_set(props, OSGI_SHELL_COMMAND_NAME, "sub");
+	bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, activator->subCmdSrv, props, &activator->subCommand);
 
 	return status;
 }
 
-static celix_status_t calculatorShell_createCommandService(command_pt command, command_service_pt *commandService) {
-	*commandService = calloc(1, sizeof(**commandService));
-	(*commandService)->command = command;
-	(*commandService)->executeCommand = command->executeCommand;
-	(*commandService)->getName = command_getName;
-	(*commandService)->getShortDescription = command_getShortDescription;
-	(*commandService)->getUsage = command_getUsage;
-
-	return CELIX_SUCCESS;
-}
 
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
     celix_status_t status = CELIX_SUCCESS;
@@ -119,9 +116,9 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
 	free(activator->sqrtCmdSrv);
 
 	if (status == CELIX_SUCCESS) {
-        addCommand_destroy(activator->addCmd);
-        subCommand_destroy(activator->subCmd);
-        sqrtCommand_destroy(activator->sqrtCmd);
+        free(activator->addCmdSrv);
+		free(activator->sqrtCmdSrv);
+		free(activator->subCmdSrv);
 	}
 
 	return status;

http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/remote_services/examples/calculator_shell/private/src/sqrt_command.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/src/sqrt_command.c b/remote_services/examples/calculator_shell/private/src/sqrt_command.c
index 87efde3..3cd0e5d 100644
--- a/remote_services/examples/calculator_shell/private/src/sqrt_command.c
+++ b/remote_services/examples/calculator_shell/private/src/sqrt_command.c
@@ -33,66 +33,46 @@
 #include "sqrt_command.h"
 #include "calculator_service.h"
 
+static celix_status_t sqrtCommand_isNumeric(char *number, bool *ret);
 
-void sqrtCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
-celix_status_t sqrtCommand_isNumeric(command_pt command, char *number, bool *ret);
-
-command_pt sqrtCommand_create(bundle_context_pt context) {
-    command_pt command = (command_pt) calloc(1, sizeof(*command));
-    if (command) {
-		command->bundleContext = context;
-		command->name = "sqrt";
-		command->shortDescription = "calculates the square root of the given double";
-		command->usage = "sqrt <double>";
-		command->executeCommand = sqrtCommand_execute;
-    }
-    return command;
-}
-
-void sqrtCommand_destroy(command_pt command) {
-	free(command);
-}
-
-void sqrtCommand_execute(command_pt command, char *line, void (*out)(char *), void (*err)(char *)) {
+void sqrtCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE *err) {
 	celix_status_t status = CELIX_SUCCESS;
     service_reference_pt calculatorService = NULL;
 
-    status = bundleContext_getServiceReference(command->bundleContext, (char *) CALCULATOR_SERVICE, &calculatorService);
+    status = bundleContext_getServiceReference(context, (char *) CALCULATOR_SERVICE, &calculatorService);
     if (status == CELIX_SUCCESS) {
     	char *token = line;
     	strtok_r(line, " ", &token);
 		char *aStr = strtok_r(NULL, " ", &token);
 		bool numeric;
-		sqrtCommand_isNumeric(command, aStr, &numeric);
+		sqrtCommand_isNumeric(aStr, &numeric);
 		if (aStr != NULL && numeric) {
 			calculator_service_pt calculator = NULL;
-			status = bundleContext_getService(command->bundleContext, calculatorService, (void *) &calculator);
+			status = bundleContext_getService(context, calculatorService, (void *) &calculator);
 			if (status == CELIX_SUCCESS) {
 				double a = atof(aStr);
 				double result = 0;
 				status = calculator->sqrt(calculator->calculator, a, &result);
 				if (status == CELIX_SUCCESS) {
-					char line[256];
-					sprintf(line, "CALCULATOR_SHELL: Sqrt: %f = %f\n", a, result);
-					out(line);
+					fprintf(out, "CALCULATOR_SHELL: Sqrt: %f = %f\n", a, result);
 				} else {
-					out("SQRT: Unexpected exception in Calc service\n");
+					fprintf(err, "SQRT: Unexpected exception in Calc service\n");
 				}
 			} else {
-				out("No calc service available\n");
+				fprintf(err, "No calc service available\n");
 			}
 		} else {
-			out("SQRT: Requires 1 numerical parameter\n");
+			fprintf(err, "SQRT: Requires 1 numerical parameter\n");
 			status = CELIX_ILLEGAL_ARGUMENT;
 		}
     } else {
-        out("No calc service available\n");
+		fprintf(err, "No calc service available\n");
     }
 
     //return status;
 }
 
-celix_status_t sqrtCommand_isNumeric(command_pt command, char *number, bool *ret) {
+static celix_status_t sqrtCommand_isNumeric(char *number, bool *ret) {
 	celix_status_t status = CELIX_SUCCESS;
 	*ret = true;
 	while(*number) {

http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/remote_services/examples/calculator_shell/private/src/sub_command.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/src/sub_command.c b/remote_services/examples/calculator_shell/private/src/sub_command.c
index ff810e6..87fabc2 100644
--- a/remote_services/examples/calculator_shell/private/src/sub_command.c
+++ b/remote_services/examples/calculator_shell/private/src/sub_command.c
@@ -33,73 +33,53 @@
 #include "sub_command.h"
 #include "calculator_service.h"
 
+static celix_status_t subCommand_isNumeric(char *number, bool *ret);
 
-void subCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
-celix_status_t subCommand_isNumeric(command_pt command, char *number, bool *ret);
-
-command_pt subCommand_create(bundle_context_pt context) {
-    command_pt command = (command_pt) calloc(1, sizeof(*command));
-    if (command) {
-		command->bundleContext = context;
-		command->name = "sub";
-		command->shortDescription = "subtract the given doubles";
-		command->usage = "sub <double> <double>";
-		command->executeCommand = subCommand_execute;
-    }
-    return command;
-}
-
-void subCommand_destroy(command_pt command) {
-	free(command);
-}
-
-void subCommand_execute(command_pt command, char *line, void (*out)(char *), void (*err)(char *)) {
+void subCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE *err) {
 	celix_status_t status = CELIX_SUCCESS;
     service_reference_pt calculatorService = NULL;
 
-    status = bundleContext_getServiceReference(command->bundleContext, (char *) CALCULATOR_SERVICE, &calculatorService);
+    status = bundleContext_getServiceReference(context, (char *) CALCULATOR_SERVICE, &calculatorService);
     if (status == CELIX_SUCCESS) {
     	char *token = line;
     	strtok_r(line, " ", &token);
 		char *aStr = strtok_r(NULL, " ", &token);
 		bool numeric;
-		subCommand_isNumeric(command, aStr, &numeric);
+		subCommand_isNumeric(aStr, &numeric);
 		if (aStr != NULL && numeric) {
 			char *bStr = strtok_r(NULL, " ", &token);
-			subCommand_isNumeric(command, bStr, &numeric);
+			subCommand_isNumeric(bStr, &numeric);
 			if (bStr != NULL && numeric) {
 				calculator_service_pt calculator = NULL;
-				status = bundleContext_getService(command->bundleContext, calculatorService, (void *) &calculator);
+				status = bundleContext_getService(context, calculatorService, (void *) &calculator);
 				if (status == CELIX_SUCCESS) {
 					double a = atof(aStr);
 					double b = atof(bStr);
 					double result = 0;
 					status = calculator->sub(calculator->calculator, a, b, &result);
 					if (status == CELIX_SUCCESS) {
-						char line[256];
-						sprintf(line, "CALCULATOR_SHELL: Sub: %f - %f = %f\n", a, b, result);
-						out(line);
+						fprintf(out, "CALCULATOR_SHELL: Sub: %f - %f = %f\n", a, b, result);
 					} else {
-						out("SUB: Unexpected exception in Calc service\n");
+						fprintf(err, "SUB: Unexpected exception in Calc service\n");
 					}
 				} else {
-					out("No calc service available\n");
+					fprintf(err, "No calc service available\n");
 				}
 			} else {
-				out("SUB: Requires 2 numerical parameter\n");
+				fprintf(err, "SUB: Requires 2 numerical parameter\n");
 			}
 		} else {
-			out("SUB: Requires 2 numerical parameter\n");
+			fprintf(err, "SUB: Requires 2 numerical parameter\n");
 			status = CELIX_ILLEGAL_ARGUMENT;
 		}
     } else {
-        out("No calc service available\n");
+		fprintf(err, "No calc service available\n");
     }
 
     //return status;
 }
 
-celix_status_t subCommand_isNumeric(command_pt command, char *number, bool *ret) {
+static celix_status_t subCommand_isNumeric(char *number, bool *ret) {
 	celix_status_t status = CELIX_SUCCESS;
 	*ret = true;
 	while(*number) {

http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 95bddd7..26252c4 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -24,9 +24,9 @@ if (SHELL)
 
     bundle(shell SOURCES
     	
-     	private/src/activator
-    	private/src/shell 
-    	private/src/lb_command
+	  private/src/activator
+	  private/src/shell
+	  private/src/lb_command
       private/src/start_command 
       private/src/stop_command
       private/src/install_command

http://git-wip-us.apache.org/repos/asf/celix/blob/b63c0d9f/shell/public/include/command.h
----------------------------------------------------------------------
diff --git a/shell/public/include/command.h b/shell/public/include/command.h
index fce2ca4..97872c7 100644
--- a/shell/public/include/command.h
+++ b/shell/public/include/command.h
@@ -28,6 +28,7 @@
 #define COMMAND_H_
 
 #include "celix_errno.h"
+#include <stdio.h>
 
 #define OSGI_SHELL_COMMAND_NAME "command.name"
 #define OSGI_SHELL_COMMAND_USAGE "command.usage"


[05/13] celix git commit: CELIX-230: Merge branch 'develop' into shell refactor. Refactored shell service and update shell_tui and remote_shell for refactored shell service

Posted by pn...@apache.org.
CELIX-230: Merge branch 'develop' into shell refactor. Refactored shell service and update shell_tui and remote_shell for refactored shell service

Conflicts:
	launcher/private/src/launcher.c
	shell/private/src/help_command.c


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/c35a74c7
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/c35a74c7
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/c35a74c7

Branch: refs/heads/feature/CELIX-269_depman
Commit: c35a74c762837711df59fcde447889164cb29402
Parents: bafe2ef 6c93851
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Oct 27 16:19:18 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Oct 27 16:19:18 2015 +0100

----------------------------------------------------------------------
 .gitignore                                      |    4 +
 .travis.yml                                     |   41 +
 CMakeLists.txt                                  |   17 +-
 LICENSE                                         |   26 +-
 README.md                                       |    2 +-
 cmake/CMakeCelix.cmake                          |    6 +-
 cmake/FindCppUTest.cmake                        |   34 +-
 cmake/FindFFI.cmake                             |   57 +
 cmake/cmake_celix/CodeCoverage.cmake            |   48 +-
 cmake/cmake_celix/Test.cmake                    |   52 -
 dependency_manager_2/CMakeLists.txt             |    2 +-
 deployment_admin/CMakeLists.txt                 |   10 +-
 deployment_admin/private/src/deployment_admin.c |   55 +-
 .../private/src/deployment_package.c            |    1 +
 device_access/device_access/CMakeLists.txt      |    4 +-
 .../device_access/private/src/device_manager.c  |    1 +
 .../private/src/driver_attributes.c             |    1 +
 .../device_access/private/src/driver_loader.c   |    1 +
 device_access/driver_locator/CMakeLists.txt     |    4 +-
 .../example/base_driver/CMakeLists.txt          |    4 +-
 .../base_driver/private/src/base_driver.c       |    2 +-
 .../example/consuming_driver/CMakeLists.txt     |    4 +-
 .../private/src/consuming_driver.c              |    1 +
 .../example/refining_driver/CMakeLists.txt      |    4 +-
 .../private/src/refining_driver.c               |    1 +
 examples/CMakeLists.txt                         |    7 +-
 examples/deploy.cmake                           |    6 +-
 framework/CMakeLists.txt                        |  144 +-
 framework/private/include/framework_private.h   |    6 +-
 framework/private/mock/bundle_context_mock.c    |   25 +-
 framework/private/mock/bundle_mock.c            |   13 +-
 framework/private/mock/framework_mock.c         |    6 +-
 framework/private/src/bundle_archive.c          |    2 +-
 framework/private/src/bundle_cache.c            |    5 +-
 framework/private/src/celix_launcher.c          |  190 +++
 framework/private/src/celix_log.c               |    5 +-
 framework/private/src/framework.c               |  318 ++--
 framework/private/src/properties.c              |   13 +-
 framework/private/src/service_registration.c    |   13 +-
 framework/private/src/service_registry.c        |    2 +-
 framework/private/test/bundle_context_test.cpp  |   75 +-
 framework/public/include/celix_launcher.h       |   41 +
 framework/public/include/properties.h           |    3 +
 framework/tst/CMakeLists.txt                    |   30 +
 framework/tst/config.properties.in              |    2 +
 framework/tst/framework1.properties.in          |    3 +
 framework/tst/framework2.properties.in          |    3 +
 framework/tst/multiple_frameworks_test.cpp      |   89 ++
 framework/tst/run_tests.cpp                     |    9 +
 framework/tst/single_framework_test.cpp         |   69 +
 launcher/CMakeLists.txt                         |   10 +-
 launcher/private/src/launcher.c                 |  202 ---
 launcher/private/src/main.c                     |   88 ++
 log_service/CMakeLists.txt                      |    2 +-
 log_service/private/src/log_factory.c           |    2 +-
 log_writer/CMakeLists.txt                       |    2 +-
 .../private/src/log_writer_syslog.c             |    2 -
 remote_services/CMakeLists.txt                  |   11 +-
 .../discovery/private/src/discovery.c           |    1 +
 .../discovery/private/src/discovery_activator.c |  186 +--
 .../private/src/endpoint_discovery_poller.c     |  191 ++-
 .../private/src/endpoint_discovery_server.c     |   51 +-
 .../discovery_configured/CMakeLists.txt         |   24 +-
 remote_services/discovery_etcd/CMakeLists.txt   |    2 +-
 .../discovery_etcd/private/include/etcd.h       |    2 +-
 .../discovery_etcd/private/src/discovery_impl.c |    9 +-
 .../discovery_etcd/private/src/etcd.c           |  135 +-
 .../discovery_etcd/private/src/etcd_watcher.c   |   78 +-
 .../discovery_shm/private/src/shm_watcher.c     |    3 +-
 .../public/include/endpoint_listener.h          |   48 -
 remote_services/examples/CMakeLists.txt         |    2 +-
 .../private/src/calculator_endpoint_activator.c |    8 +-
 .../private/src/calculator_proxy_activator.c    |   12 +-
 .../examples/calculator_service/CMakeLists.txt  |    5 +-
 .../private/src/calculator_activator.c          |   12 +-
 .../public/include/calculator_service.h         |    8 +-
 ...apache.celix.calc.api.Calculator2.descriptor |   11 +
 .../examples/calculator_shell/CMakeLists.txt    |    4 +
 .../calculator_shell/private/src/add_command.c  |    3 +-
 .../calculator_shell/private/src/sqrt_command.c |    3 +-
 .../calculator_shell/private/src/sub_command.c  |    3 +-
 remote_services/examples/deploy.cmake           |    4 +-
 .../remote_service_admin/CMakeLists.txt         |    8 +-
 .../private/include/export_registration_impl.h  |    3 -
 .../private/include/remote_service_admin_impl.h |   17 -
 .../private/src/export_registration_impl.c      |   22 +-
 .../private/src/import_registration_impl.c      |   22 +-
 .../private/src/remote_proxy_factory_impl.c     |    7 +
 .../public/include/endpoint_listener.h          |   48 +
 .../public/include/export_registration.h        |   22 +
 .../public/include/import_registration.h        |   22 +
 .../public/include/remote_constants.h           |   38 +
 .../public/include/remote_service_admin.h       |    6 +-
 .../remote_service_admin_dfi/CMakeLists.txt     |   31 +
 .../dynamic_function_interface/CMakeLists.txt   |   22 +
 .../dynamic_function_interface/dfi_log_util.h   |   48 +
 .../dynamic_function_interface/dyn_common.c     |  136 ++
 .../dynamic_function_interface/dyn_common.h     |   32 +
 .../dynamic_function_interface/dyn_function.c   |  320 ++++
 .../dynamic_function_interface/dyn_function.h   |   46 +
 .../dynamic_function_interface/dyn_interface.c  |  416 +++++
 .../dynamic_function_interface/dyn_interface.h  |   48 +
 .../dynamic_function_interface/dyn_type.c       | 1129 +++++++++++++
 .../dynamic_function_interface/dyn_type.h       |  142 ++
 .../dynamic_function_interface/json_rpc.c       |  296 ++++
 .../dynamic_function_interface/json_rpc.h       |   22 +
 .../json_serializer.c                           |  452 ++++++
 .../json_serializer.h                           |   22 +
 .../memstream/README.md                         |   49 +
 .../memstream/fmemopen.c                        |   78 +
 .../memstream/fmemopen.h                        |   52 +
 .../memstream/open_memstream.c                  |  130 ++
 .../memstream/open_memstream.h                  |   15 +
 .../CMakeLists.txt                              |   27 +
 .../avro_descriptor_translator_tests.cpp        |  164 ++
 .../descriptors/example1.descriptor             |   13 +
 .../descriptors/example2.descriptor             |    9 +
 .../descriptors/example3.descriptor             |   11 +
 .../dyn_closure_tests.cpp                       |  146 ++
 .../dyn_function_tests.cpp                      |  237 +++
 .../dyn_interface_tests.cpp                     |  103 ++
 .../dyn_type_tests.cpp                          |  281 ++++
 .../json_rpc_tests.cpp                          |  329 ++++
 .../json_serializer_tests.cpp                   |  462 ++++++
 .../run_tests.cpp                               |    9 +
 .../schemas/complex.avdl                        |   11 +
 .../schemas/complex.avpr                        |   36 +
 .../schemas/invalid1.avpr                       |   29 +
 .../schemas/invalid2.avpr                       |   31 +
 .../schemas/simple.avdl                         |    6 +
 .../schemas/simple.avpr                         |   33 +
 .../schemas/simple_min.avpr                     |    1 +
 .../remote_service_admin_dfi/rsa/CMakeLists.txt |   47 +
 .../private/include/export_registration_dfi.h   |   21 +
 .../private/include/import_registration_dfi.h   |   26 +
 .../private/include/remote_service_admin_dfi.h  |   56 +
 .../rsa/private/src/export_registration_dfi.c   |  222 +++
 .../rsa/private/src/import_registration_dfi.c   |  355 +++++
 .../src/remote_service_admin_activator.c        |  124 ++
 .../rsa/private/src/remote_service_admin_dfi.c  |  737 +++++++++
 .../rsa_tst/CMakeLists.txt                      |   45 +
 .../rsa_tst/bundle/CMakeLists.txt               |   24 +
 .../rsa_tst/bundle/tst_activator.c              |  137 ++
 .../rsa_tst/bundle/tst_service.h                |   17 +
 .../rsa_tst/client.properties.in                |    8 +
 .../rsa_tst/config.properties.in                |    3 +
 .../rsa_tst/rsa_client_server_tests.cpp         |  114 ++
 .../rsa_tst/rsa_tests.cpp                       |  201 +++
 .../rsa_tst/run_tests.cpp                       |    9 +
 .../rsa_tst/server.properties.in                |    7 +
 .../remote_service_admin_http/CMakeLists.txt    |    8 +-
 .../src/remote_service_admin_activator.c        |    3 +-
 .../private/src/remote_service_admin_impl.c     |  160 +-
 .../private/src/remote_service_admin_impl.c     |   27 +-
 .../private/include/topology_manager.h          |    7 +
 .../topology_manager/private/src/activator.c    |  296 ++--
 .../private/src/topology_manager.c              |  940 ++++++-----
 .../utils/private/include/civetweb.h            |    4 +-
 remote_services/utils/private/src/civetweb.c    |   10 +-
 .../utils/public/include/remote_constants.h     |   38 -
 remote_shell/CMakeLists.txt                     |    4 +-
 remote_shell/private/include/shell_mediator.h   |    2 +-
 remote_shell/private/src/activator.c            |    2 +-
 remote_shell/private/src/connection_listener.c  |    1 +
 remote_shell/private/src/remote_shell.c         |   49 +-
 remote_shell/private/src/shell_mediator.c       |   22 +-
 shell/CMakeLists.txt                            |    2 +-
 shell/private/include/shell_private.h           |    2 +-
 shell/private/src/activator.c                   |    6 +-
 shell/private/src/help_command.c                |  121 +-
 shell/private/src/inspect_command.c             |    7 +
 shell/private/src/shell.c                       |   10 +-
 shell/private/src/update_command.c              |    2 +-
 shell/public/include/shell.h                    |    2 +-
 shell_tui/CMakeLists.txt                        |    2 +-
 shell_tui/private/src/shell_tui.c               |    5 +-
 utils/CMakeLists.txt                            |   57 +-
 utils/private/src/hash_map.c                    |   57 +-
 utils/private/src/linked_list.c                 |    2 +-
 utils/private/test/array_list_test.c            |  357 -----
 utils/private/test/array_list_test.cpp          |  500 +++++-
 utils/private/test/celix_threads_test.cpp       |  349 ++++
 utils/private/test/hash_map_test.c              |  478 ------
 utils/private/test/hash_map_test.cpp            | 1492 ++++++++++++++++++
 utils/private/test/hash_map_test_hash.c         |  359 -----
 utils/private/test/linked_list_test.c           |   96 --
 utils/private/test/linked_list_test.cpp         |  794 ++++++++++
 utils/public/include/celix_threads.h            |    2 +-
 utils/public/include/hash_map.h                 |    4 +-
 utils/public/include/linked_list.h              |    2 +-
 190 files changed, 13478 insertions(+), 3180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/remote_shell/private/include/shell_mediator.h
----------------------------------------------------------------------
diff --cc remote_shell/private/include/shell_mediator.h
index e376d76,e376d76..faf86e8
--- a/remote_shell/private/include/shell_mediator.h
+++ b/remote_shell/private/include/shell_mediator.h
@@@ -48,6 -48,6 +48,6 @@@ typedef struct shell_mediator *shell_me
  
  celix_status_t shellMediator_create(bundle_context_pt context, shell_mediator_pt *instance);
  celix_status_t shellMediator_destroy(shell_mediator_pt instance);
--celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, int socket);
++celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, FILE *out, FILE *err);
  
  #endif /* shellMediator_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/remote_shell/private/src/remote_shell.c
----------------------------------------------------------------------
diff --cc remote_shell/private/src/remote_shell.c
index 945946e,41a303d..73b76d4
--- a/remote_shell/private/src/remote_shell.c
+++ b/remote_shell/private/src/remote_shell.c
@@@ -49,7 -50,7 +50,7 @@@
  
  struct connection {
  	remote_shell_pt parent;
--	int socket;
++	FILE *socketStream;
  	fd_set pollset;
  	bool threadRunning;
  };
@@@ -98,26 -99,26 +99,34 @@@ celix_status_t remoteShell_addConnectio
  
  	if (connection != NULL) {
  		connection->parent = instance;
--		connection->socket = socket;
  		connection->threadRunning = false;
++		connection->socketStream = fdopen(socket, "w");
+ 
 -		celixThreadMutex_lock(&instance->mutex);
++		if (connection->socketStream != NULL) {
 +
- 		celixThreadMutex_lock(&instance->mutex);
++			celixThreadMutex_lock(&instance->mutex);
++
++			if (arrayList_size(instance->connections) < instance->maximumConnections) {
++				celix_thread_t connectionRunThread = celix_thread_default;
++				arrayList_add(instance->connections, connection);
++				status = celixThread_create(&connectionRunThread, NULL, &remoteShell_connection_run, connection);
++			} else {
++				status = CELIX_BUNDLE_EXCEPTION;
++				remoteShell_connection_print(connection, RS_MAXIMUM_CONNECTIONS_REACHED);
++			}
++			celixThreadMutex_unlock(&instance->mutex);
  
--		if (arrayList_size(instance->connections) < instance->maximumConnections) {
--			celix_thread_t connectionRunThread = celix_thread_default;
--			arrayList_add(instance->connections, connection);
--			status = celixThread_create(&connectionRunThread, NULL, &remoteShell_connection_run, connection);
  		} else {
  			status = CELIX_BUNDLE_EXCEPTION;
--			remoteShell_connection_print(connection, RS_MAXIMUM_CONNECTIONS_REACHED);
  		}
--		celixThreadMutex_unlock(&instance->mutex);
  	} else {
  		status = CELIX_ENOMEM;
  	}
  
  	if (status != CELIX_SUCCESS) {
--		close(connection->socket);
++		if (connection->socketStream != NULL) {
++			fclose(connection->socketStream);
++		}
  		free(connection);
  	}
  
@@@ -149,6 -150,6 +158,8 @@@ void *remoteShell_connection_run(void *
  	int result;
  	struct timeval timeout; /* Timeout for select */
  
++	int fd = fileno(connection->socketStream);
++
  	connection->threadRunning = true;
  	status = remoteShell_connection_print(connection, RS_WELCOME);
  
@@@ -158,15 -159,15 +169,15 @@@
  			timeout.tv_usec = 0;
  
  			FD_ZERO(&connection->pollset);
--			FD_SET(connection->socket, &connection->pollset);
--			result = select(connection->socket + 1, &connection->pollset, NULL, NULL, &timeout);
++			FD_SET(fd, &connection->pollset);
++			result = select(fd + 1, &connection->pollset, NULL, NULL, &timeout);
  		} while (result == -1 && errno == EINTR && connection->threadRunning == true);
  
  		/* The socket_fd has data available to be read */
--		if (result > 0 && FD_ISSET(connection->socket, &connection->pollset)) {
++		if (result > 0 && FD_ISSET(fd, &connection->pollset)) {
  			char buff[COMMAND_BUFF_SIZE];
  
--			len = recv(connection->socket, buff, COMMAND_BUFF_SIZE - 1, 0);
++			len = recv(fd, buff, COMMAND_BUFF_SIZE - 1, 0);
  			if (len < COMMAND_BUFF_SIZE) {
  				celix_status_t commandStatus = CELIX_SUCCESS;
  				buff[len] = '\0';
@@@ -196,7 -197,7 +207,7 @@@
  	arrayList_removeElement(connection->parent->connections, connection);
  	celixThreadMutex_unlock(&connection->parent->mutex);
  
--	close(connection->socket);
++	fclose(connection->socketStream);
  
  	return NULL;
  }
@@@ -214,7 -215,7 +225,8 @@@ static celix_status_t remoteShell_conne
  		} else if (len == 4 && strncmp("exit", line, 4) == 0) {
  			status = CELIX_FILE_IO_EXCEPTION;
  		} else {
--			status = shellMediator_executeCommand(connection->parent->mediator, line, connection->socket);
++			status = shellMediator_executeCommand(connection->parent->mediator, line, connection->socketStream, connection->socketStream);
++            fflush(connection->socketStream);
  		}
  
  		free(dline);
@@@ -225,5 -226,5 +237,6 @@@
  
  celix_status_t remoteShell_connection_print(connection_pt connection, char *text) {
  	size_t len = strlen(text);
--	return (send(connection->socket, text, len, 0) > 0) ? CELIX_SUCCESS : CELIX_FILE_IO_EXCEPTION;
++    int fd = fileno(connection->socketStream);
++	return (send(fd, text, len, 0) > 0) ? CELIX_SUCCESS : CELIX_FILE_IO_EXCEPTION;
  }

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/remote_shell/private/src/shell_mediator.c
----------------------------------------------------------------------
diff --cc remote_shell/private/src/shell_mediator.c
index 95d3aa0,3f3fb36..ab60f3e
--- a/remote_shell/private/src/shell_mediator.c
+++ b/remote_shell/private/src/shell_mediator.c
@@@ -35,12 -36,12 +36,6 @@@
  #include "log_service.h"
  #include "shell_mediator.h"
  
--//NOTE: multiple instances of shell_mediator are not supported, because we need
--// 		a non ADT - shared between instances - variable.
--static int currentOutputSocket = -1;
--
--static void shellMediator_writeOnCurrentSocket(char *buff);
--
  static celix_status_t shellMediator_addingService(void *handler, service_reference_pt reference, void **service);
  static celix_status_t shellMediator_addedService(void *handler, service_reference_pt reference, void * service);
  static celix_status_t shellMediator_modifiedService(void *handler, service_reference_pt reference, void * service);
@@@ -95,21 -96,21 +90,14 @@@ celix_status_t shellMediator_destroy(sh
  	return status;
  }
  
--static void shellMediator_writeOnCurrentSocket(char *buff) {
--
--	size_t len = strlen(buff);
--	send(currentOutputSocket, buff, len, 0);
--}
--
--celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, int socket) {
++celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, FILE *out, FILE *err) {
  	celix_status_t status = CELIX_SUCCESS;
  
  	celixThreadMutex_lock(&instance->mutex);
  
++
  	if (instance->shellService != NULL) {
--		currentOutputSocket = socket;
--		instance->shellService->executeCommand(instance->shellService->shell, command, shellMediator_writeOnCurrentSocket, shellMediator_writeOnCurrentSocket);
--		currentOutputSocket = -1;
++		instance->shellService->executeCommand(instance->shellService->shell, command, out, err);
  	}
  
  	celixThreadMutex_unlock(&instance->mutex);

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/shell/CMakeLists.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/shell/private/include/shell_private.h
----------------------------------------------------------------------
diff --cc shell/private/include/shell_private.h
index 5761431,db609ca..092f6e3
--- a/shell/private/include/shell_private.h
+++ b/shell/private/include/shell_private.h
@@@ -33,18 -33,20 +33,18 @@@
  #include "command.h"
  
  struct shell {
 -	bundle_context_pt bundleContext;
 -	hash_map_pt commandReferenceMap;
 -	hash_map_pt commandNameMap;
 +	bundle_context_pt bundle_context_ptr;
 +	hash_map_pt command_reference_map_ptr;
 +	hash_map_pt command_name_map_ptr;
  };
  
 -celix_status_t shell_create(bundle_context_pt, shell_service_pt* shellService);
 -celix_status_t shell_destroy(shell_service_pt* shellService);
 -celix_status_t shell_addCommand(shell_pt shell, service_reference_pt reference);
 +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);
 +celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr);
  
 -
 -char * shell_getCommandUsage(shell_pt shell, char * commandName);
 -char * shell_getCommandDescription(shell_pt shell, char * commandName);
 -service_reference_pt shell_getCommandReference(shell_pt shell, char * command);
 -void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *));
 -void shell_serviceChanged(service_listener_pt listener, service_event_pt event);
 +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, void (*out)(char *), void (*error)(char *));
++celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, FILE *out, FILE *err);
 +celix_status_t shell_serviceChanged(service_listener_pt listener_ptr, service_event_pt event_ptr);
  
  #endif /* SHELL_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/shell/private/src/activator.c
----------------------------------------------------------------------
diff --cc shell/private/src/activator.c
index 6915e82,92ba36e..7cb2946
--- a/shell/private/src/activator.c
+++ b/shell/private/src/activator.c
@@@ -51,126 -89,21 +51,126 @@@ struct bundle_instance 
  
  typedef struct bundle_instance *bundle_instance_pt;
  
 -static celix_status_t shell_createCommandService(command_pt command, command_service_pt *commandService) {
 +celix_status_t bundleActivator_create(bundle_context_pt context_ptr, void **_pptr) {
  	celix_status_t status = CELIX_SUCCESS;
  
 -	*commandService = calloc(1, sizeof(**commandService));
 -
 -	if (!*commandService) {
 -		status = CELIX_ENOMEM;
 -	}
 -	else {
 -		(*commandService)->command = command;
 -		(*commandService)->executeCommand = command->executeCommand;
 -		(*commandService)->getName = command_getName;
 -		(*commandService)->getShortDescription = command_getShortDescription;
 -		(*commandService)->getUsage = command_getUsage;
 -	}
 +    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 = "ps",
-                         .description = "list installed bundles.",
-                         .usage = "ps [-l | -s | -u]"
++                        .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);
 +
 +            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;
  }

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/shell/private/src/help_command.c
----------------------------------------------------------------------
diff --cc shell/private/src/help_command.c
index 78b6b01,0a11ba9..b8408ad
--- a/shell/private/src/help_command.c
+++ b/shell/private/src/help_command.c
@@@ -25,92 -25,84 +25,87 @@@
   */
  #include <stdlib.h>
  #include <string.h>
++#include <stdint.h>
  
 -#include "command_impl.h"
  #include "array_list.h"
  #include "bundle_context.h"
 -#include "bundle.h"
  #include "shell.h"
 +#include "std_commands.h"
  
 -void helpCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
 +celix_status_t helpCommand_execute(void *_ptr, char *line_str, FILE *out_ptr, FILE *err_ptr) {
 +	celix_status_t status = CELIX_SUCCESS;
  
 -command_pt helpCommand_create(bundle_context_pt context) {
 -	command_pt command = (command_pt) malloc(sizeof(*command));
 -	command->bundleContext = context;
 -	command->name = "help";
 -	command->shortDescription = "display available command usage and description.";
 -	command->usage = "start [<command> ...]";
 -	command->executeCommand = helpCommand_execute;
 -	return command;
 -}
 +	bundle_context_pt context_ptr = _ptr;
 +	service_reference_pt shell_service_reference_ptr = NULL;
 +	shell_service_pt shell_ptr = NULL;
  
 -void helpCommand_destroy(command_pt command) {
 -	free(command);
 -}
 +	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);
 +	}
  
 -void helpCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *)) {
 -	service_reference_pt shellService = NULL;
 -	bundleContext_getServiceReference(command->bundleContext, (char *) OSGI_SHELL_SERVICE_NAME, &shellService);
 +	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");
- 		} else {
- 			bool found = false;
- 			while (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);
- 					if (strcmp(sub, name) == 0) {
- 						celix_status_t sub_status_desc;
- 						celix_status_t sub_status_usage;
- 
- 						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) {
- 							if (found) {
- 								fprintf(out_ptr, "---\n");
- 							}
- 							found = true;
- 							fprintf(out_ptr, "Command     : %s\n", name);
- 							fprintf(out_ptr, "Usage       : %s\n", usage_str);
- 							fprintf(out_ptr, "Description : %s\n", desc_str);
- 						}
- 
- 						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;
- 						}
- 					}
- 				}
- 				sub = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
- 			}
- 		}
- 	}
- 
- 	return status;
- }
++        uint32_t out_len = 256;
++        char *sub = NULL;
++        char *save_ptr = NULL;
++        char out_str[out_len];
+ 
 -	if (shellService != NULL) {
 -		shell_service_pt shell = NULL;
 -		bundleContext_getService(command->bundleContext, shellService, (void **) &shell);
++        memset(out_str, 0, sizeof(out_str));
+ 
 -		if (shell != NULL) {
 -			char delims[] = " ";
 -			char * sub = NULL;
 -			char *save_ptr = NULL;
 -			char outString[256];
++        strtok_r(line_str, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
++        sub = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
+ 
 -			sub = strtok_r(line, delims, &save_ptr);
 -			sub = strtok_r(NULL, delims, &save_ptr);
++        if (sub == NULL) {
++            unsigned int i;
++            array_list_pt commands = NULL;
+ 
 -			if (sub == NULL) {
 -				int i;
 -				array_list_pt commands = shell->getCommands(shell->shell);
 -				for (i = 0; i < arrayList_size(commands); i++) {
 -					char *name = arrayList_get(commands, i);
 -					sprintf(outString, "%s\n", name);
 -					out(outString);
 -				}
 -				out("\nUse 'help <command-name>' for more information.\n");
 -				arrayList_destroy(commands);
 -			} else {
 -				bool found = false;
 -				while (sub != NULL) {
 -					int i;
 -					array_list_pt commands = shell->getCommands(shell->shell);
 -					for (i = 0; i < arrayList_size(commands); i++) {
 -						char *name = arrayList_get(commands, i);
 -						if (strcmp(sub, name) == 0) {
 -							char *desc = shell->getCommandDescription(shell->shell, name);
 -							char *usage = shell->getCommandUsage(shell->shell, name);
++            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");
++        } 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;
+ 
 -							if (found) {
 -								out("---\n");
 -							}
 -							found = true;
 -							sprintf(outString, "Command     : %s\n", name);
 -							out(outString);
 -							sprintf(outString, "Usage       : %s\n", usage);
 -							out(outString);
 -							sprintf(outString, "Description : %s\n", desc);
 -							out(outString);
 -						}
 -					}
 -					sub = strtok_r(NULL, delims, &save_ptr);
 -					arrayList_destroy(commands);
 -				}
 -			}
 -		}
 -	}
++                    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/c35a74c7/shell/private/src/inspect_command.c
----------------------------------------------------------------------
diff --cc shell/private/src/inspect_command.c
index 68b7625,944d929..24a343b
--- a/shell/private/src/inspect_command.c
+++ b/shell/private/src/inspect_command.c
@@@ -61,31 -79,39 +61,32 @@@ celix_status_t inspectCommand_execute(v
  
  			if (strcmp(type, SERVICE_TYPE) == 0) {
  				if (strcmp(direction, CAPABILITY) == 0) {
 -					status = inspectCommand_printExportedServices(command, ids, out, err);
 +					status = inspectCommand_printExportedServices(context, ids, outStream, errStream);
  					if (status != CELIX_SUCCESS) {
 -						out("INSPECT: Error\n");
 +						fprintf(errStream, "INSPECT: Error\n");
  					}
  				} else if (strcmp(direction, REQUIREMENT) == 0) {
 -                    status = inspectCommand_printImportedServices(command, ids, out, err);
 +                    status = inspectCommand_printImportedServices(context, ids, outStream, errStream);
                      if (status != CELIX_SUCCESS) {
 -                        out("INSPECT: Error\n");
 +						fprintf(errStream, "INSPECT: Error\n");
                      }
  				} else {
 -				    out("INSPECT: Invalid argument\n");
 -                    sprintf(outString, "%s\n", command->usage);
 -                    out(outString);
 +					fprintf(errStream, "INSPECT: Invalid argument\n");
  				}
  			} else {
 -				out("INSPECT: Invalid argument\n");
 -				sprintf(outString, "%s\n", command->usage);
 -                out(outString);
 +				fprintf(errStream, "INSPECT: Invalid argument\n");
  			}
+ 			arrayList_destroy(ids);
  		} else {
 -			out("INSPECT: Too few arguments\n");
 -			sprintf(outString, "%s\n", command->usage);
 -			out(outString);
 +			fprintf(errStream, "INSPECT: Too few arguments\n");
  		}
  	} else {
 -		out("INSPECT: Too few arguments\n");
 -		sprintf(outString, "%s\n", command->usage);
 -		out(outString);
 +		fprintf(errStream, "INSPECT: Too few arguments\n");
  	}
 +	return status;
  }
  
 -celix_status_t inspectCommand_printExportedServices(command_pt command, array_list_pt ids, void (*out)(char *), void (*err)(char *)) {
 +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;
  
@@@ -238,8 -278,10 +242,9 @@@ celix_status_t inspectCommand_printImpo
                                          char *value = NULL;
                                          serviceReference_getProperty(ref, key, &value);
  
 -                                        sprintf(line, "%s = %s\n", key, value);
 -                                        out(line);
 +										fprintf(outStream, "%s = %s\n", key, value);
                                      }
+                                     free(keys);
  
  //                                  objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
  //                                  sprintf(line, "ObjectClass = %s\n", objectClass);

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/shell/private/src/shell.c
----------------------------------------------------------------------
diff --cc shell/private/src/shell.c
index 03c30da,18ee201..8a37e88
--- a/shell/private/src/shell.c
+++ b/shell/private/src/shell.c
@@@ -179,153 -113,65 +179,151 @@@ celix_status_t shell_removeCommand(shel
  	return status;
  }
  
 -array_list_pt shell_getCommands(shell_pt shell) {
 -	array_list_pt commands = NULL;
 -	hash_map_iterator_pt iter = hashMapIterator_create(shell->commandNameMap);
 +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;
  
 -	arrayList_create(&commands);
 -	while (hashMapIterator_hasNext(iter)) {
 -		char * name = hashMapIterator_nextKey(iter);
 -		arrayList_add(commands, name);
 +	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;
 +		}
  	}
 -	hashMapIterator_destroy(iter);
 -	return commands;
 -}
  
 -char * shell_getCommandUsage(shell_pt shell, char * commandName) {
 -	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
 -	return (command == NULL) ? NULL : command->getUsage(command->command);
 +	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;
  }
  
 -char * shell_getCommandDescription(shell_pt shell, char * commandName) {
 -	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
 -	return (command == NULL) ? NULL : command->getShortDescription(command->command);
 +
 +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", usage_pstr);
 +	}
 +
 +	return status;
  }
  
 -service_reference_pt shell_getCommandReference(shell_pt shell, char * command) {
 -	hash_map_iterator_pt iter = hashMapIterator_create(shell->commandReferenceMap);
 -	while (hashMapIterator_hasNext(iter)) {
 -		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
 -		command_service_pt cmd = (command_service_pt) hashMapEntry_getValue(entry);
 -		if (strcmp(cmd->getName(cmd->command), command) == 0) {
 -			return (service_reference_pt) hashMapEntry_getValue(entry);
 +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;
  		}
  	}
 -	hashMapIterator_destroy(iter);
 -	return NULL;
 +
 +	if (status == CELIX_SUCCESS) {
 +		serviceReference_getProperty(reference, "command.description", command_description_pstr);
 +	}
 +
 +	return status;
  }
  
 -void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *)) {
 -	unsigned int pos = strcspn(commandLine, " ");
 -	char * commandName = (pos != strlen(commandLine)) ? string_ndup((char *) commandLine, pos) : strdup(commandLine);
 -	command_service_pt command = shell_getCommand(shell, commandName);
 -	if (command != NULL) {
 -		command->executeCommand(command->command, commandLine, out, error);
 -	} else {
 -		error("No such command\n");
 +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);
 +			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);
  	}
 -	free(commandName);
 +
 +	return status;
  }
  
- celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, void (*out)(char *), void (*error)(char *)) {
 -static command_service_pt shell_getCommand(shell_pt shell, char * commandName) {
 -	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
 -	return (command == NULL) ? NULL : command;
++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 || !error) {
++	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) {
- 			error("No such command");
++			fprintf(err, "No such command\n");
 +			status = CELIX_BUNDLE_EXCEPTION;
 +		}
 +	}
 +
 +	if (status == CELIX_SUCCESS) {
- 		printf("TODO\n");
- 		//FIXME udpate shell_executeCommand with FILE
- 		status = command_ptr->executeCommand(command_ptr->handle, command_line_str, stdout, stderr);
++		status = command_ptr->executeCommand(command_ptr->handle, command_line_str, out, err);
 +	}
 +
 +	return status;
  }
  
 -void shell_serviceChanged(service_listener_pt listener, service_event_pt event) {
 -	shell_pt shell = (shell_pt) listener->handle;
 -	if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED) {
 -		shell_addCommand(shell, event->reference);
 -	} else if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
 -		shell_removeCommand(shell, event->reference);
 +celix_status_t shell_serviceChanged(service_listener_pt listener_ptr, service_event_pt event_ptr) {
 +	celix_status_t status = CELIX_SUCCESS;
 +
 +	if (!listener_ptr || !event_ptr || !listener_ptr->handle || !event_ptr->type || !event_ptr->reference) {
 +		status = CELIX_ILLEGAL_ARGUMENT;
  	}
 +
 +	if (status == CELIX_SUCCESS) {
 +		shell_pt shell_ptr = (shell_pt) listener_ptr->handle;
 +		if (event_ptr->type == OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED) {
 +			status = shell_addCommand(shell_ptr, event_ptr->reference);
 +		} else if (event_ptr->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
 +			status = shell_removeCommand(shell_ptr, event_ptr->reference);
 +		}
 +	}
 +
 +	return status;
  }
  

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/shell/private/src/update_command.c
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/shell/public/include/shell.h
----------------------------------------------------------------------
diff --cc shell/public/include/shell.h
index c6f1792,25706c7..f7c5edd
--- a/shell/public/include/shell.h
+++ b/shell/public/include/shell.h
@@@ -36,12 -36,11 +36,12 @@@ typedef struct shell * shell_pt
  
  struct shellService {
  	shell_pt shell;
 -	array_list_pt (*getCommands)(shell_pt shell);
 -	char * (*getCommandUsage)(shell_pt shell, char * commandName);
 -	char * (*getCommandDescription)(shell_pt shell, char * commandName);
 -	service_reference_pt (*getCommandReference)(shell_pt shell, char * command);
 -	void (*executeCommand)(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *));
 +
 +	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, void (*out)(char *), void (*error)(char *));
++	celix_status_t (*executeCommand)(shell_pt shell_ptr, char * command_line_str, FILE *out, FILE *err);
  };
  
  typedef struct shellService * shell_service_pt;

http://git-wip-us.apache.org/repos/asf/celix/blob/c35a74c7/shell_tui/private/src/shell_tui.c
----------------------------------------------------------------------
diff --cc shell_tui/private/src/shell_tui.c
index 9dae4f0,9dae4f0..c106ece
--- a/shell_tui/private/src/shell_tui.c
+++ b/shell_tui/private/src/shell_tui.c
@@@ -45,9 -45,9 +45,6 @@@ struct shellTuiActivator 
  
  typedef struct shellTuiActivator * shell_tui_activator_pt;
  
--void shellTui_write(char * line) {
--	fprintf(stdout, "%s", line);
--}
  
  static void* shellTui_runnable(void *data) {
  	shell_tui_activator_pt act = (shell_tui_activator_pt) data;
@@@ -83,7 -83,7 +80,7 @@@
  				continue;
  			}
  
--			act->shell->executeCommand(act->shell->shell, line, shellTui_write, shellTui_write);
++			act->shell->executeCommand(act->shell->shell, line, stdout, stderr);
  		}
  	}
  


[13/13] celix git commit: CELIX-269: Updated for shell refactoring

Posted by pn...@apache.org.
CELIX-269: Updated for shell refactoring


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/04b68623
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/04b68623
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/04b68623

Branch: refs/heads/feature/CELIX-269_depman
Commit: 04b686237ca75157a2f3039256cbe7c60d540478
Parents: 9af85ce
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Nov 3 10:37:51 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Nov 3 10:37:51 2015 +0100

----------------------------------------------------------------------
 .../private/include/dm_shell_list_command.h     |  7 ++--
 .../private/src/dm_shell_activator.c            | 31 ++++++++++++-----
 .../private/src/dm_shell_list_command.c         | 35 ++++----------------
 examples/dm_example/deploy.cmake                | 17 ++++++----
 shell/CMakeLists.txt                            |  3 ++
 shell/private/include/shell_private.h           |  2 ++
 shell/private/src/shell.c                       |  9 +++--
 7 files changed, 54 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/04b68623/dependency_manager/private/include/dm_shell_list_command.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_shell_list_command.h b/dependency_manager/private/include/dm_shell_list_command.h
index bbccdc1..01c5065 100644
--- a/dependency_manager/private/include/dm_shell_list_command.h
+++ b/dependency_manager/private/include/dm_shell_list_command.h
@@ -26,9 +26,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_impl.h"
+#include "command.h"
 
-char * dmListCommand_getName(command_pt command);
-char * dmListCommand_getUsage(command_pt command);
-char * dmListCommand_getShortDescription(command_pt command);
-void dmListCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
\ No newline at end of file
+void dmListCommand_execute(bundle_context_pt context, char * line, FILE *out, FILE *err);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/04b68623/dependency_manager/private/src/dm_shell_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_shell_activator.c b/dependency_manager/private/src/dm_shell_activator.c
index 4adfd0a..178b460 100644
--- a/dependency_manager/private/src/dm_shell_activator.c
+++ b/dependency_manager/private/src/dm_shell_activator.c
@@ -32,7 +32,7 @@
 
 struct bundle_instance {
     service_registration_pt reg;
-    command_pt dmListCmd;
+    command_service_pt  dmCommand;
 };
 
 typedef struct bundle_instance * bundle_instance_pt;
@@ -66,13 +66,24 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
     bundle_instance_pt bi = (bundle_instance_pt) userData;
     command_service_pt commandService = calloc(1, sizeof(*commandService));
 
-    commandService->getName             = dmListCommand_getName;
-    commandService->command             = context;
-    commandService->executeCommand      = dmListCommand_execute;
-    commandService->getShortDescription = dmListCommand_getShortDescription;
-    commandService->getUsage            = dmListCommand_getUsage;
+    if (commandService != NULL) {
+        commandService->handle = context;
+        commandService->executeCommand = dmListCommand_execute;
 
-    bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, commandService, NULL, &bi->reg);
+        properties_pt props = properties_create();
+        properties_set(props, OSGI_SHELL_COMMAND_NAME, "dm");
+        properties_set(props, OSGI_SHELL_COMMAND_USAGE, "dm");
+        properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION,
+                       "Gives an overview of the component managemend by a dependency manager.");
+
+        bi->dmCommand = commandService;
+
+        status = bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, commandService, props,
+                                               &bi->reg);
+    } else {
+        status = CELIX_ENOMEM;
+        free(commandService);
+    }
 
     return status;
 }
@@ -84,7 +95,11 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-    free(userData);
+    bundle_instance_pt bi = (bundle_instance_pt) userData;
+    if (bi != NULL) {
+        free(bi->dmCommand);
+    }
+    free(bi);
     return CELIX_SUCCESS;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/04b68623/dependency_manager/private/src/dm_shell_list_command.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_shell_list_command.c b/dependency_manager/private/src/dm_shell_list_command.c
index 1855664..fd7c5d9 100644
--- a/dependency_manager/private/src/dm_shell_list_command.c
+++ b/dependency_manager/private/src/dm_shell_list_command.c
@@ -28,7 +28,6 @@
 #include <dm_dependency_manager.h>
 #include "dm_info.h"
 #include "service_reference.h"
-#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle.h"
@@ -40,23 +39,9 @@ static const char * const WARNING_COLOR = "\033[93m";
 static const char * const NOK_COLOR = "\033[91m";
 static const char * const END_COLOR = "\033[m";
 
-char * dmListCommand_getName(command_pt command) {
-    return "dm";
-}
-
-char * dmListCommand_getUsage(command_pt command) {
-    return "dm [overview|notavail]";
-}
-
-char * dmListCommand_getShortDescription(command_pt command) {
-    return "\t overview: Get an overview of the dependency-managed components with their dependencies.\n\tnotavail: Get an overview of dependency-managed compononentes where required depencies are not available. ";
-}
-
-void dmListCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *)) {
-    char outString[256];
+void dmListCommand_execute(bundle_context_pt context, char * line, FILE *out, FILE *err) {
     array_list_pt servRefs = NULL;
     int i;
-    bundle_context_pt context = (void *)command;
     bundleContext_getServiceReferences(context, DM_INFO_SERVICE_NAME ,NULL, &servRefs);
     char *term = getenv("TERM");
     bool colors = false;
@@ -81,22 +66,18 @@ void dmListCommand_execute(command_pt command, char * line, void (*out)(char *),
                 startColors = compInfo->active ? OK_COLOR : NOK_COLOR;
                 endColors = END_COLOR;
             }
-            sprintf(outString, "Component: Name=%s\n|- ID=%s, %sActive=%s%s, State=%s\n", compInfo->name, compInfo->id, startColors, compInfo->active ?  "true " : "false", endColors, compInfo->state);
-            out(outString);
+            fprintf(out, "Component: Name=%s\n|- ID=%s, %sActive=%s%s, State=%s\n", compInfo->name, compInfo->id, startColors, compInfo->active ?  "true " : "false", endColors, compInfo->state);
 
             int interfCnt;
-            sprintf(outString, "|- Interfaces (%d):\n", arrayList_size(compInfo->interfaces));
-            out(outString);
+            fprintf(out, "|- Interfaces (%d):\n", arrayList_size(compInfo->interfaces));
             for(interfCnt = 0 ;interfCnt < arrayList_size(compInfo->interfaces); interfCnt++) {
                 char * interface;
                 interface = arrayList_get(compInfo->interfaces, interfCnt);
-                sprintf(outString, "   |- Interface: %s\n", interface);
-                out(outString);
+                fprintf(out, "   |- Interface: %s\n", interface);
             }
 
             int depCnt;
-            sprintf(outString, "|- Dependencies (%d):\n", arrayList_size(compInfo->dependency_list));
-            out(outString);
+            fprintf(out, "|- Dependencies (%d):\n", arrayList_size(compInfo->dependency_list));
             for(depCnt = 0 ;depCnt < arrayList_size(compInfo->dependency_list); depCnt++) {
                 dm_service_dependency_info_pt dependency;
                 dependency = arrayList_get(compInfo->dependency_list, depCnt);
@@ -111,17 +92,15 @@ void dmListCommand_execute(command_pt command, char * line, void (*out)(char *),
 
                     endColors = END_COLOR;
                 }
-                sprintf(outString, "   |- Dependency: %sAvailable = %s%s, Required = %s, Filter = %s\n",
+                fprintf(out, "   |- Dependency: %sAvailable = %s%s, Required = %s, Filter = %s\n",
                         startColors,
                         dependency->available ? "true " : "false" ,
                         endColors,
                         dependency->required ? "true " : "false",
                         dependency->filter
                 );
-                out(outString);
             }
-            sprintf(outString, "\n");
-            out(outString);
+            fprintf(out, "\n");
 
             infoServ->destroyInfo(infoServ->handle, info);
         }

http://git-wip-us.apache.org/repos/asf/celix/blob/04b68623/examples/dm_example/deploy.cmake
----------------------------------------------------------------------
diff --git a/examples/dm_example/deploy.cmake b/examples/dm_example/deploy.cmake
index 47072f4..1def6fc 100644
--- a/examples/dm_example/deploy.cmake
+++ b/examples/dm_example/deploy.cmake
@@ -17,13 +17,16 @@
 if (BUILD_EXAMPLES AND BUILD_DEPENDENCY_MANAGER AND BUILD_SHELL AND BUILD_SHELL_TUI)
     deploy("dm_example"
             BUNDLES
-            phase1
-            phase2a
-            phase2b
-            phase3
-            shell
-            shell_tui
-            dm_shell
+                phase1
+                phase2a
+                phase2b
+                phase3
+                shell
+                shell_tui
+                dm_shell
+            PROPERTIES
+                LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+
     )
 endif ()
 

http://git-wip-us.apache.org/repos/asf/celix/blob/04b68623/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 32aa08f..235f348 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -35,6 +35,9 @@ if (SHELL)
       private/src/log_command
       private/src/inspect_command
       private/src/help_command
+
+      ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
+
     )
     
     install_bundle(shell

http://git-wip-us.apache.org/repos/asf/celix/blob/04b68623/shell/private/include/shell_private.h
----------------------------------------------------------------------
diff --git a/shell/private/include/shell_private.h b/shell/private/include/shell_private.h
index 092f6e3..c3a3386 100644
--- a/shell/private/include/shell_private.h
+++ b/shell/private/include/shell_private.h
@@ -31,11 +31,13 @@
 #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);

http://git-wip-us.apache.org/repos/asf/celix/blob/04b68623/shell/private/src/shell.c
----------------------------------------------------------------------
diff --git a/shell/private/src/shell.c b/shell/private/src/shell.c
index 8a37e88..d4fe9cc 100644
--- a/shell/private/src/shell.c
+++ b/shell/private/src/shell.c
@@ -25,6 +25,7 @@
  */
 #include <stdlib.h>
 #include <string.h>
+#include <log_helper.h>
 
 #include "celix_errno.h"
 
@@ -67,6 +68,8 @@ celix_status_t shell_create(bundle_context_pt context_ptr, shell_service_pt *she
 		(*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) {
@@ -120,6 +123,7 @@ celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt referen
 	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;
 		}
 	}
@@ -131,8 +135,9 @@ celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt referen
 
 	if (status != CELIX_SUCCESS) {
 		shell_removeCommand(shell_ptr, reference_ptr);
-		fprintf(stderr, "Could not add Command. TODO\n");
-		//TODO log to log service
+        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;


[09/13] celix git commit: CELIX-230: Removed unneeded install of command.c file

Posted by pn...@apache.org.
CELIX-230: Removed unneeded install of command.c file


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/8104a77b
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/8104a77b
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/8104a77b

Branch: refs/heads/feature/CELIX-269_depman
Commit: 8104a77bc2dafcee37a7e8b237a0b84d6b2a13d1
Parents: 97b6679
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Oct 27 17:02:58 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Oct 27 17:02:58 2015 +0100

----------------------------------------------------------------------
 shell/CMakeLists.txt | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/8104a77b/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 40df757..32aa08f 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -40,8 +40,6 @@ if (SHELL)
     install_bundle(shell
     	HEADERS
     		public/include/shell.h public/include/command.h
-    	RESOURCES 
-    		public/src/command.c
 	)
 
 	include_directories("public/include")


[04/13] celix git commit: CELIX-230: * Updated command error handling * Updated activator error handling * Updated shell error handling

Posted by pn...@apache.org.
CELIX-230:
* Updated command error handling
* Updated activator error handling
* Updated shell error handling


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/bafe2efb
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/bafe2efb
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/bafe2efb

Branch: refs/heads/feature/CELIX-269_depman
Commit: bafe2efb37e8bad0d136cb6b17dd78c16af6de24
Parents: 4d52743
Author: Alexander Broekhuis <a....@gmail.com>
Authored: Sat Mar 28 21:09:53 2015 +0100
Committer: Alexander Broekhuis <a....@gmail.com>
Committed: Sat Mar 28 21:09:53 2015 +0100

----------------------------------------------------------------------
 framework/private/src/bundle_context.c |   3 +
 shell/private/include/shell_private.h  |  20 +-
 shell/private/include/std_commands.h   |   8 +-
 shell/private/src/activator.c          | 298 +++++++++++++++++---------
 shell/private/src/help_command.c       | 104 +++++----
 shell/private/src/log_command.c        |   3 +-
 shell/private/src/ps_command.c         | 219 +++++++++++--------
 shell/private/src/shell.c              | 319 +++++++++++++++++++---------
 shell/private/src/start_command.c      |  76 ++++---
 shell/private/src/stop_command.c       |  81 ++++---
 shell/public/include/command.h         |   4 +
 shell/public/include/shell.h           |   9 +-
 12 files changed, 737 insertions(+), 407 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/framework/private/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_context.c b/framework/private/src/bundle_context.c
index be6333d..76e377f 100644
--- a/framework/private/src/bundle_context.c
+++ b/framework/private/src/bundle_context.c
@@ -278,6 +278,9 @@ celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, b
         status = CELIX_ILLEGAL_ARGUMENT;
     } else {
         *bundle = framework_getBundleById(context->framework, id);
+        if (*bundle == NULL) {
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
     }
 
     framework_logIfError(logger, status, NULL, "Failed to get bundle [id=%ld]", id);

http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/shell/private/include/shell_private.h
----------------------------------------------------------------------
diff --git a/shell/private/include/shell_private.h b/shell/private/include/shell_private.h
index 9734ad5..5761431 100644
--- a/shell/private/include/shell_private.h
+++ b/shell/private/include/shell_private.h
@@ -33,20 +33,18 @@
 #include "command.h"
 
 struct shell {
-	bundle_context_pt bundleContext;
-	hash_map_pt commandReferenceMap;
-	hash_map_pt commandNameMap;
+	bundle_context_pt bundle_context_ptr;
+	hash_map_pt command_reference_map_ptr;
+	hash_map_pt command_name_map_ptr;
 };
 
-celix_status_t shell_create(bundle_context_pt, shell_service_pt* shellService);
-celix_status_t shell_destroy(shell_service_pt* shellService);
-celix_status_t shell_addCommand(shell_pt shell, service_reference_pt reference);
+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);
+celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr);
 
-
-char * shell_getCommandUsage(shell_pt shell, char * commandName);
-char * shell_getCommandDescription(shell_pt shell, char * commandName);
 celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
-void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *));
-void shell_serviceChanged(service_listener_pt listener, service_event_pt event);
+celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, void (*out)(char *), void (*error)(char *));
+celix_status_t shell_serviceChanged(service_listener_pt listener_ptr, service_event_pt event_ptr);
 
 #endif /* SHELL_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/shell/private/include/std_commands.h
----------------------------------------------------------------------
diff --git a/shell/private/include/std_commands.h b/shell/private/include/std_commands.h
index cb7322c..ef7f37e 100644
--- a/shell/private/include/std_commands.h
+++ b/shell/private/include/std_commands.h
@@ -27,8 +27,12 @@
 #ifndef __STD_COMMANDS_H_
 #define __STD_COMMANDS_H_
 
-celix_status_t psCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
-celix_status_t startCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream);
+#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);

http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/shell/private/src/activator.c
----------------------------------------------------------------------
diff --git a/shell/private/src/activator.c b/shell/private/src/activator.c
index cfa8bb3..6915e82 100644
--- a/shell/private/src/activator.c
+++ b/shell/private/src/activator.c
@@ -51,143 +51,231 @@ struct bundle_instance {
 
 typedef struct bundle_instance *bundle_instance_pt;
 
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status;
+celix_status_t bundleActivator_create(bundle_context_pt context_ptr, void **_pptr) {
+	celix_status_t status = CELIX_SUCCESS;
 
-	bundle_instance_pt bi = (bundle_instance_pt) calloc(1, sizeof(struct bundle_instance));
+    bundle_instance_pt instance_ptr = NULL;
 
-	if (!bi) {
-		status = CELIX_ENOMEM;
-	}
-	else if (userData == NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-		free(bi);
-	}
-	else {
-		status = shell_create(context, &bi->shellService);
-
-        bi->std_commands[0] = (struct command) {.exec = psCommand_execute, .name = "ps", .description = "list installed bundles.", .usage = "ps [-l | -s | -u]"};
-        bi->std_commands[1] = (struct command) {.exec = startCommand_execute, .name = "start", .description = "start bundle(s).", .usage = "start <id> [<id> ...]"};
-        bi->std_commands[2] = (struct command) {.exec = stopCommand_execute, .name = "stop", .description = "stop bundle(s).", .usage = "stop <id> [<id> ...]"};
-        bi->std_commands[3] = (struct command) {.exec = installCommand_execute, .name = "install", .description = "install bundle(s).", .usage = "install <file> [<file> ...]"};
-        bi->std_commands[4] = (struct command) {.exec = uninstallCommand_execute, .name = "uninstall", .description = "uninstall bundle(s).", .usage = "uninstall <file> [<file> ...]"};
-        bi->std_commands[5] = (struct command) {.exec = updateCommand_execute, .name = "update", .description = "update bundle(s).", .usage = "update <id> [<URL>]"};
-        bi->std_commands[6] = (struct command) {.exec = helpCommand_execute, .name = "help", .description = "display available commands and description.", .usage = "help <command>]"};
-        bi->std_commands[7] = (struct command) {.exec = logCommand_execute, .name = "log", .description = "print log.", .usage = "log"};
-        bi->std_commands[8] = (struct command) {.exec = inspectCommand_execute, .name = "inspect", .description = "inspect services and components.", .usage = "inspect (service) (capability|requirement) [<id> ...]"};
-        bi->std_commands[9] = (struct command) {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; /*marker for last element*/
-
-        int i = 0;
-        while (bi->std_commands[i].exec != NULL) {
-            bi->std_commands[i].props = properties_create();
-            if (bi->std_commands[i].props != NULL) {
-                    properties_set(bi->std_commands[i].props, "command.name", bi->std_commands[i].name);
-                    properties_set(bi->std_commands[i].props, "command.usage", bi->std_commands[i].usage);
-                    properties_set(bi->std_commands[i].props, "command.description", bi->std_commands[i].description);
-
-                    bi->std_commands[i].service = calloc(1, sizeof(struct commandService));
-                    if (bi->std_commands[i].service != NULL) {
-                        bi->std_commands[i].service->handle = context;
-                        bi->std_commands[i].service->executeCommand = bi->std_commands[i].exec;
-                    } else {
-                            status = CELIX_ENOMEM;
-                            break;
-                    }
-            } else {
-                    status = CELIX_ENOMEM;
-                    break;
+    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 = "ps",
+                        .description = "list installed bundles.",
+                        .usage = "ps [-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);
+
+            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) {
-			printf("shell_create failed\n");
-		}
+    if (status == CELIX_SUCCESS) {
+        *_pptr = instance_ptr;
+    }
 
-		(*userData) = bi;
-	}
+
+    if (status != CELIX_SUCCESS) {
+        bundleActivator_destroy(instance_ptr, context_ptr);
+    }
 
 	return status;
 }
 
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status;
-	bundle_instance_pt bi = (bundle_instance_pt) userData;
+celix_status_t bundleActivator_start(void *_ptr, bundle_context_pt context_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
 
-	status = bundleContext_registerService(context, (char *) OSGI_SHELL_SERVICE_NAME, bi->shellService, NULL, &bi->registration);
+	bundle_instance_pt instance_ptr  = (bundle_instance_pt) _ptr;
+    array_list_pt references_ptr     = NULL;
+    service_listener_pt listener_ptr = NULL;
 
-	if (status == CELIX_SUCCESS) {
-		array_list_pt references = NULL;
-		service_listener_pt listener = (service_listener_pt) calloc(1, sizeof(*listener));
+    if (!instance_ptr || !context_ptr) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
 
-		bi->listener = listener;
-		listener->handle = bi->shellService->shell;
-		listener->serviceChanged = (void *) shell_serviceChanged;
+    if (status == CELIX_SUCCESS) {
+        status = bundleContext_registerService(context_ptr, (char *) OSGI_SHELL_SERVICE_NAME, instance_ptr->shellService, NULL, &instance_ptr->registration);
+    }
 
-		status = bundleContext_addServiceListener(context, listener, "(objectClass=commandService)");
-		status = bundleContext_getServiceReferences(context, "commandService", NULL, &references);
+	if (status == CELIX_SUCCESS) {
+        listener_ptr = (service_listener_pt) calloc(1, sizeof(*listener_ptr));
+        if (!listener_ptr) {
+            status = CELIX_ENOMEM;
+        }
+    }
 
-		if (status == CELIX_SUCCESS) {
-			int i = 0;
+    if (status == CELIX_SUCCESS) {
+        instance_ptr->listener = listener_ptr;
+        listener_ptr->handle = instance_ptr->shellService->shell;
+        listener_ptr->serviceChanged = (void *) shell_serviceChanged;
+
+        status = bundleContext_addServiceListener(context_ptr, listener_ptr, "(objectClass=commandService)");
+    }
 
-			for (i = 0; i < arrayList_size(references); i++) {
-				shell_addCommand(bi->shellService->shell, arrayList_get(references, i));
-			}
-		}
+    if (status == CELIX_SUCCESS) {
+        status = bundleContext_getServiceReferences(context_ptr, "commandService", NULL, &references_ptr);
+    }
 
-		if (status == CELIX_SUCCESS) {
+    if (status == CELIX_SUCCESS) {
+        for (unsigned int i = 0; i < arrayList_size(references_ptr); i++) {
+            shell_addCommand(instance_ptr->shellService->shell, arrayList_get(references_ptr, i));
+        }
+    }
 
-            int i = 0;
-            while (bi->std_commands[i].exec != NULL) {
-                    status = bundleContext_registerService(context, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, bi->std_commands[i].service, bi->std_commands[i].props, &bi->std_commands[i].reg);
-                    if (status != CELIX_SUCCESS) {
-                            break;
-                    }
-                    i += 1;
+    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;
             }
 
-		}
-		arrayList_destroy(references);
+        }
+		arrayList_destroy(references_ptr);
 	}
 
+    if (status != CELIX_SUCCESS) {
+        bundleActivator_stop(_ptr, context_ptr);
+    }
+
 	return status;
 }
 
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status;
-	bundle_instance_pt bi = (bundle_instance_pt) userData;
-
-            int i = 0;
-            while (bi->std_commands[i].exec != NULL) {
-                    if (bi->std_commands[i].reg!= NULL) {
-                            serviceRegistration_unregister(bi->std_commands[i].reg);
-                        bi->std_commands[i].reg = NULL;
-                        bi->std_commands[i].props = NULL;
-                    }
-                    i += 1;
+celix_status_t bundleActivator_stop(void *_ptr, bundle_context_pt context_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+    celix_status_t sub_status;
+
+	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;
             }
+        }
+    }
 
-	status = bundleContext_removeServiceListener(context, bi->listener);
+	sub_status = bundleContext_removeServiceListener(context_ptr, instance_ptr->listener);
+    if (status == CELIX_SUCCESS && sub_status != CELIX_SUCCESS) {
+        status = sub_status;
+    }
 
 	return status;
 }
 
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	bundle_instance_pt bi = (bundle_instance_pt) userData;
-
-  int i = 0;
-  while (bi->std_commands[i].exec != NULL) {
-          if (bi->std_commands[i].props != NULL) {
-                  properties_destroy(bi->std_commands[i].props);
-          } 
-          if (bi->std_commands[i].service != NULL) {
-                  free(bi->std_commands[i].service);
-          }
-          i += 1;
-  }
-
-    free(bi);
+celix_status_t bundleActivator_destroy(void *_ptr, bundle_context_pt __attribute__((__unused__)) context_ptr) {
+    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++) {
+            free(instance_ptr->std_commands[i].service);
+
+            if (instance_ptr->std_commands[i].props != NULL) {
+                properties_destroy(instance_ptr->std_commands[i].props);
+            }
+        }
+    }
+
+    shell_destroy(&instance_ptr->shellService);
+
+    free(instance_ptr);
 
 	return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/shell/private/src/help_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/help_command.c b/shell/private/src/help_command.c
index 75be274..78b6b01 100644
--- a/shell/private/src/help_command.c
+++ b/shell/private/src/help_command.c
@@ -29,56 +29,88 @@
 #include "array_list.h"
 #include "bundle_context.h"
 #include "shell.h"
+#include "std_commands.h"
 
-celix_status_t helpCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
-	bundle_context_pt context = handle;
-	service_reference_pt shellService = NULL;
-	bundleContext_getServiceReference(context, (char *) OSGI_SHELL_SERVICE_NAME, &shellService);
+celix_status_t helpCommand_execute(void *_ptr, char *line_str, FILE *out_ptr, FILE *err_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
 
-	if (shellService != NULL) {
-		shell_service_pt shell = NULL;
-		bundleContext_getService(context, shellService, (void **) &shell);
+	bundle_context_pt context_ptr = _ptr;
+	service_reference_pt shell_service_reference_ptr = NULL;
+	shell_service_pt shell_ptr = NULL;
 
-		if (shell != NULL) {
-			char delims[] = " ";
-			char * sub = NULL;
-			char *save_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);
 
-			sub = strtok_r(line, delims, &save_ptr);
-			sub = strtok_r(NULL, delims, &save_ptr);
+		if (sub == NULL) {
+			unsigned int i;
+			array_list_pt commands = NULL;
 
-			if (sub == NULL) {
-				int i;
-				array_list_pt commands = shell->getCommands(shell->shell);
+			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");
+		} else {
+			bool found = false;
+			while (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(outStream, "%s\n", name);
-				}
-				fprintf(outStream, "\nUse 'help <command-name>' for more information.\n");
-			} else {
-				bool found = false;
-				while (sub != NULL) {
-					int i;
-					array_list_pt commands = shell->getCommands(shell->shell);
-					for (i = 0; i < arrayList_size(commands); i++) {
-						char *name = arrayList_get(commands, i);
-						if (strcmp(sub, name) == 0) {
-							char *desc = shell->getCommandDescription(shell->shell, name);
-							char *usage = shell->getCommandUsage(shell->shell, name);
+					if (strcmp(sub, name) == 0) {
+						celix_status_t sub_status_desc;
+						celix_status_t sub_status_usage;
+
+						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) {
 							if (found) {
-								fprintf(outStream, "---\n");
+								fprintf(out_ptr, "---\n");
 							}
 							found = true;
-							fprintf(outStream, "Command     : %s\n", name);
-							fprintf(outStream, "Usage       : %s\n", usage);
-							fprintf(outStream, "Description : %s\n", desc);
+							fprintf(out_ptr, "Command     : %s\n", name);
+							fprintf(out_ptr, "Usage       : %s\n", usage_str);
+							fprintf(out_ptr, "Description : %s\n", desc_str);
+						}
+
+						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;
 						}
 					}
-					sub = strtok_r(NULL, delims, &save_ptr);
 				}
+				sub = strtok_r(NULL, OSGI_SHELL_COMMAND_SEPARATOR, &save_ptr);
 			}
 		}
 	}
-	return CELIX_SUCCESS;
-}
+
+	return status;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/shell/private/src/log_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/log_command.c b/shell/private/src/log_command.c
index 95679ca..a1f77c1 100644
--- a/shell/private/src/log_command.c
+++ b/shell/private/src/log_command.c
@@ -52,7 +52,8 @@ void logCommand_execute(bundle_context_pt context, char *line, FILE *outStream,
 			char *level = NULL;
 			char errorString[256];
 
-			logCommand_levelAsString(context, entry->level, &level);
+            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);

http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/shell/private/src/ps_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/ps_command.c b/shell/private/src/ps_command.c
index ce84e99..fca93de 100644
--- a/shell/private/src/ps_command.c
+++ b/shell/private/src/ps_command.c
@@ -33,112 +33,149 @@
 
 static char * psCommand_stateString(bundle_state_e state); 
 
-celix_status_t psCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream) {
-        celix_status_t status = CELIX_SUCCESS;
-        array_list_pt bundles = NULL;
-        bundle_context_pt context = handle;
+celix_status_t psCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
+    celix_status_t status = CELIX_SUCCESS;
 
-        status = bundleContext_getBundles(context, &bundles);
+    bundle_context_pt context_ptr = _ptr;
+    array_list_pt bundles_ptr     = NULL;
 
-        bool showLocation = false;
-        bool showSymbolicName = false;
-        bool showUpdateLocation = false;
-        char * msg = "Name";
-        unsigned int i;
+    bool show_location        = false;
+    bool show_symbolic_name   = false;
+    bool show_update_location = false;
+    char *message_str         = "Name";
 
-        char delims[] = " ";
-        char * sub = NULL;
+    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;
-        sub = strtok_r(commandline, delims, &save_ptr);
-        sub = strtok_r(NULL, delims, &save_ptr);
-        while (sub != NULL) {
-                if (strcmp(sub, "-l") == 0) {
-                        showLocation = true;
-                        msg = "Location";
-                } else if (strcmp(sub, "-s") == 0) {
-                        showSymbolicName = true;
-                        msg = "Symbolic name";
-                } else if (strcmp(sub, "-u") == 0) {
-                        showUpdateLocation = true;
-                        msg = "Update location";
-                }
-                sub = strtok_r(NULL, delims, &save_ptr);
+
+        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);
         }
 
-        fprintf(outStream, "  %-5s %-12s %s\n", "ID", "State", msg);
+        fprintf(out_ptr, "  %-5s %-12s %s\n", "ID", "State", message_str);
+
+        unsigned int size = arrayList_size(bundles_ptr);
+        bundle_pt bundles_array_ptr[size];
 
-        unsigned int size = arrayList_size(bundles);
-        bundle_pt bundlesA[size];
-        for (i = 0; i < size; i++) {
-                bundlesA[i] = arrayList_get(bundles, i);
+        for (unsigned int i = 0; i < size; i++) {
+            bundles_array_ptr[i] = arrayList_get(bundles_ptr, i);
         }
 
-        int j;
-        for(i=0; i < size - 1; i++) {
-                for(j=i+1; j < size; j++) {
-                        bundle_pt first = bundlesA[i];
-                        bundle_pt second = bundlesA[j];
-
-                        bundle_archive_pt farchive = NULL, sarchive = NULL;
-                        long fid, sid;
-
-                        bundle_getArchive(first, &farchive);
-                        bundleArchive_getId(farchive, &fid);
-                        bundle_getArchive(second, &sarchive);
-                        bundleArchive_getId(sarchive, &sid);
-
-                        if(fid > sid)
-                        {
-                                // these three lines swap the elements bundles[i] and bundles[j].
-                                bundle_pt temp = bundlesA[i];
-                                bundlesA[i] = bundlesA[j];
-                                bundlesA[j] = temp;
-                        }
+        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 (i = 0; i < size; i++) {
-                //bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i);
-                bundle_pt bundle = bundlesA[i];
-                bundle_archive_pt archive = NULL;
-                long id;
-                bundle_state_e state;
-                char * stateString = NULL;
-                module_pt module = NULL;
-                char * name = NULL;
-
-                bundle_getArchive(bundle, &archive);
-                bundleArchive_getId(archive, &id);
-                bundle_getState(bundle, &state);
-                stateString = psCommand_stateString(state);
-                bundle_getCurrentModule(bundle, &module);
-                module_getSymbolicName(module, &name);
-                if (showLocation) {
-                        bundleArchive_getLocation(archive, &name);
-                } else if (showSymbolicName) {
-                        // do nothing
-                } else if (showUpdateLocation) {
-                        bundleArchive_getLocation(archive, &name);
+
+        for (unsigned int i = 0; i < size - 1; 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;
+            char *state_str = NULL;
+            module_pt module_ptr = NULL;
+            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) {
+                fprintf(out_ptr, "  %-5ld %-12s %s\n", id, state_str, name_str);
+            }
 
-                fprintf(outStream, "  %-5ld %-12s %s\n", id, stateString, name);
+            if (sub_status != CELIX_SUCCESS) {
+                status = sub_status;
+                break;
+            }
         }
-        arrayList_destroy(bundles);
-        return status;
+
+        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     ";
-	}
+    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/bafe2efb/shell/private/src/shell.c
----------------------------------------------------------------------
diff --git a/shell/private/src/shell.c b/shell/private/src/shell.c
index 3500d89..03c30da 100644
--- a/shell/private/src/shell.c
+++ b/shell/private/src/shell.c
@@ -29,122 +29,229 @@
 #include "celix_errno.h"
 
 #include "shell_private.h"
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "service_registration.h"
-#include "service_listener.h"
 
 #include "utils.h"
 
-static command_service_pt shell_getCommand(shell_pt shell, char * commandName);
-array_list_pt shell_getCommands(shell_pt shell);
+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, shell_service_pt* shellService) {
-	celix_status_t status = CELIX_ENOMEM;
+celix_status_t shell_create(bundle_context_pt context_ptr, shell_service_pt *shell_service_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
 
-	shell_service_pt lclService = (shell_service_pt) calloc(1, sizeof(struct shellService));
-	shell_pt lclShell = (shell_pt) calloc(1, sizeof(struct shell));
+	if (!context_ptr || !shell_service_ptr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-	if (lclService && lclShell) {
-		lclShell->bundleContext = context;
-		lclShell->commandNameMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
-		lclShell->commandReferenceMap = hashMap_create(NULL, NULL, NULL, NULL);
-		lclService->shell = lclShell;
+	if (status == CELIX_SUCCESS) {
+		*shell_service_ptr =  calloc(1, sizeof(**shell_service_ptr));
+		if (!*shell_service_ptr) {
+			status = CELIX_ENOMEM;
+		}
+	}
 
-		lclService->getCommands = shell_getCommands;
-		lclService->getCommandDescription = shell_getCommandDescription;
-		lclService->getCommandUsage = shell_getCommandUsage;
-		lclService->getCommandReference = shell_getCommandReference;
-		lclService->executeCommand = shell_executeCommand;
+	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;
+	}
 
-		*shellService = lclService;
-		status = CELIX_SUCCESS;
+	if (status != CELIX_SUCCESS) {
+		shell_destroy(shell_service_ptr);
 	}
 
 	return status;
 }
 
-celix_status_t shell_destroy(shell_service_pt* shellService) {
+celix_status_t shell_destroy(shell_service_pt *shell_service_ptr) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	hashMap_destroy((*shellService)->shell->commandNameMap, false, false);
-	hashMap_destroy((*shellService)->shell->commandReferenceMap, false, false);
+	if (!shell_service_ptr || !*shell_service_ptr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-	free((*shellService)->shell);
-	free(*shellService);
+	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);
+			}
+			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, service_reference_pt reference) {
+celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt reference_ptr) {
 	celix_status_t status = CELIX_SUCCESS;
+	command_service_pt command_ptr = NULL;
+	char *name_str = NULL;
+
+	if (!shell_ptr && !reference_ptr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getService(shell_ptr->bundle_context_ptr, reference_ptr, (void **) &command_ptr);
+		if (!command_ptr) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	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_put(shell_ptr->command_name_map_ptr, name_str, command_ptr);
+		hashMap_put(shell_ptr->command_reference_map_ptr, reference_ptr, command_ptr);
+	}
 
-	command_service_pt command = NULL;
-	void *cmd = NULL;
-    char *name = NULL;
-	bundleContext_getService(shell->bundleContext, reference, &cmd);
-  serviceReference_getProperty(reference, "command.name", &name);
-	command = (command_service_pt) cmd;
-    if (name != NULL) {
-	    hashMap_put(shell->commandNameMap, name, command);
-	    hashMap_put(shell->commandReferenceMap, reference, command);
-    } else {
-            status = CELIX_ILLEGAL_ARGUMENT;
-            fprintf(stderr, "TODO\n");
-            //TODO log to log service
-    }
+	if (status != CELIX_SUCCESS) {
+		shell_removeCommand(shell_ptr, reference_ptr);
+		fprintf(stderr, "Could not add Command. TODO\n");
+		//TODO log to log service
+	}
 
 	return status;
 }
 
-celix_status_t shell_removeCommand(shell_pt shell, service_reference_pt reference) {
+celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	command_service_pt command = (command_service_pt) hashMap_remove(shell->commandReferenceMap, reference);
-    char *name = NULL;
-    serviceReference_getProperty(reference, "command.name", &name);
-	if (command != NULL && name != NULL) {
-		bool result = false;
-		hashMap_remove(shell->commandNameMap, name);
-		bundleContext_ungetService(shell->bundleContext, reference, &result);
-	} 
+	command_service_pt command_ptr = NULL;
+	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, name_str);
+	}
+
+	celix_status_t sub_status = bundleContext_ungetService(shell_ptr->bundle_context_ptr, reference_ptr, NULL);
+	if (sub_status != CELIX_SUCCESS && status == CELIX_SUCCESS) {
+		status = sub_status;
+	}
+
+	sub_status = bundleContext_ungetServiceReference(shell_ptr->bundle_context_ptr, reference_ptr);
+	if (sub_status != CELIX_SUCCESS && status == CELIX_SUCCESS) {
+		status = sub_status;
+	}
 
 	return status;
 }
 
-array_list_pt shell_getCommands(shell_pt shell) {
-	array_list_pt commands = NULL;
-	hash_map_iterator_pt iter = hashMapIterator_create(shell->commandNameMap);
+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;
 
-	arrayList_create(&commands);
-	while (hashMapIterator_hasNext(iter)) {
-		char * name = hashMapIterator_nextKey(iter);
-		arrayList_add(commands, name);
+	if (!shell_ptr || !commands_ptr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
 	}
-	hashMapIterator_destroy(iter);
-	return commands;
+
+	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;
 }
 
-char * shell_getCommandUsage(shell_pt shell, char * commandName) {
-	char *usage = NULL;
+
+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;
-	shell_getCommandReference(shell, commandName, &reference);
-	if (reference) {
-		serviceReference_getProperty(reference, "command.usage", &usage);
+
+	if (!shell_ptr || !command_name_str || !usage_pstr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
 	}
 
-	return usage;
+	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", usage_pstr);
+	}
+
+	return status;
 }
 
-char * shell_getCommandDescription(shell_pt shell, char * commandName) {
-	char *description = NULL;
+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;
-	shell_getCommandReference(shell, commandName, &reference);
-	if (reference) {
-		serviceReference_getProperty(reference, "command.description", &description);
+
+	if (!shell_ptr || !command_name_str || !command_description_pstr) {
+		status = CELIX_ILLEGAL_ARGUMENT;
 	}
 
-	return description;
+	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", command_description_pstr);
+	}
+
+	return status;
 }
 
 celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr) {
@@ -156,7 +263,7 @@ celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_
 
 	if (status == CELIX_SUCCESS) {
 		*command_reference_ptr = NULL;
-		hash_map_iterator_pt iter = hashMapIterator_create(shell_ptr->commandReferenceMap);
+		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);
@@ -173,32 +280,52 @@ celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_
 	return status;
 }
 
-void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *)) {
-	unsigned int pos = strcspn(commandLine, " ");
-	char * commandName = (pos != strlen(commandLine)) ? string_ndup((char *) commandLine, pos) : strdup(commandLine);
-	command_service_pt command = shell_getCommand(shell, commandName);
-	if (command != NULL) {
-            printf("TODO\n");
-            //FIXME udpate shell_executeCommand with FILE
-		    //command->executeCommand(command->command, commandLine, out, error);
-            command->executeCommand(command->handle, commandLine, stdout, stderr);
-	} else {
-		error("No such command\n");
-	}
-	free(commandName);
-}
+celix_status_t shell_executeCommand(shell_pt shell_ptr, char *command_line_str, void (*out)(char *), void (*error)(char *)) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	command_service_pt command_ptr = NULL;
+
+	if (!shell_ptr || !command_line_str || !out || !error) {
+		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) {
+			error("No such command");
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		printf("TODO\n");
+		//FIXME udpate shell_executeCommand with FILE
+		status = command_ptr->executeCommand(command_ptr->handle, command_line_str, stdout, stderr);
+	}
 
-static command_service_pt shell_getCommand(shell_pt shell, char * commandName) {
-	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
-	return (command == NULL) ? NULL : command;
+	return status;
 }
 
-void shell_serviceChanged(service_listener_pt listener, service_event_pt event) {
-	shell_pt shell = (shell_pt) listener->handle;
-	if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED) {
-		shell_addCommand(shell, event->reference);
-	} else if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
-		shell_removeCommand(shell, event->reference);
+celix_status_t shell_serviceChanged(service_listener_pt listener_ptr, service_event_pt event_ptr) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (!listener_ptr || !event_ptr || !listener_ptr->handle || !event_ptr->type || !event_ptr->reference) {
+		status = CELIX_ILLEGAL_ARGUMENT;
 	}
+
+	if (status == CELIX_SUCCESS) {
+		shell_pt shell_ptr = (shell_pt) listener_ptr->handle;
+		if (event_ptr->type == OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED) {
+			status = shell_addCommand(shell_ptr, event_ptr->reference);
+		} else if (event_ptr->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
+			status = shell_removeCommand(shell_ptr, event_ptr->reference);
+		}
+	}
+
+	return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/shell/private/src/start_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/start_command.c b/shell/private/src/start_command.c
index 0e5f5e0..f43699a 100644
--- a/shell/private/src/start_command.c
+++ b/shell/private/src/start_command.c
@@ -27,38 +27,58 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "celix_errno.h"
 #include "std_commands.h"
-#include "array_list.h"
 #include "bundle_context.h"
-#include "bundle.h"
 
-celix_status_t startCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
-  celix_status_t status = CELIX_SUCCESS;
-  bundle_context_pt context = handle;
+celix_status_t startCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
+    celix_status_t status = CELIX_SUCCESS;
 
-	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(outStream, "Incorrect number of arguments.\n");
-	} else {
-		while (sub != NULL) {
-			long id = atol(sub);
-			bundle_pt bundle = NULL;
-			bundleContext_getBundleById(context, id, &bundle);
-			if (bundle != NULL) {
-				bundle_startWithOptions(bundle, 0);
-			} else {
-        fprintf(errStream, "Bundle id '%li' is invalid\n", id);
+    bundle_context_pt context_ptr = _ptr;
+
+    if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
         status = CELIX_ILLEGAL_ARGUMENT;
-        break;
-			}
-			sub = strtok_r(NULL, delims, &save_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);
+
+        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;
+    return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/shell/private/src/stop_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/stop_command.c b/shell/private/src/stop_command.c
index a790c74..0093c99 100644
--- a/shell/private/src/stop_command.c
+++ b/shell/private/src/stop_command.c
@@ -26,42 +26,57 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "array_list.h"
 #include "bundle_context.h"
-#include "bundle.h"
-#include "utils.h"
+#include "std_commands.h"
 
-celix_status_t stopCommand_execute(void *handle, char *line, FILE *outStream, FILE *errStream) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_context_pt context = handle;
-    char delims[] = " ";
-	char * sub = NULL;
-	char *save_ptr = NULL;
+celix_status_t stopCommand_execute(void *_ptr, char *command_line_str, FILE *out_ptr, FILE *err_ptr) {
+    celix_status_t status = CELIX_SUCCESS;
 
-	sub = strtok_r(line, delims, &save_ptr);
-	sub = strtok_r(NULL, delims, &save_ptr);
+    bundle_context_pt context_ptr = _ptr;
 
-	if (sub == NULL) {
-		fprintf(outStream, "Incorrect number of arguments.\n");
-	} else {
-		while (sub != NULL) {
-			bool numeric;
-			utils_isNumeric(sub, &numeric);
-			if (numeric) {
-				long id = atol(sub);
-				bundle_pt bundle = NULL;
-				bundleContext_getBundleById(context, id, &bundle);
-				if (bundle != NULL) {
-					bundle_stopWithOptions(bundle, 0);
-				} else {
-					fprintf(outStream, "Bundle id is invalid.");
-				}
-			} else {
-				fprintf(outStream, "Bundle id should be a number (bundle id).\n");
-			}
-			sub = strtok_r(NULL, delims, &save_ptr);
-		}
-	}
+    if (!context_ptr || !command_line_str || !out_ptr || !err_ptr) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
 
-	return status;
+    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/bafe2efb/shell/public/include/command.h
----------------------------------------------------------------------
diff --git a/shell/public/include/command.h b/shell/public/include/command.h
index 710bf9d..fce2ca4 100644
--- a/shell/public/include/command.h
+++ b/shell/public/include/command.h
@@ -29,6 +29,10 @@
 
 #include "celix_errno.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_pt;

http://git-wip-us.apache.org/repos/asf/celix/blob/bafe2efb/shell/public/include/shell.h
----------------------------------------------------------------------
diff --git a/shell/public/include/shell.h b/shell/public/include/shell.h
index 9fe60b4..c6f1792 100644
--- a/shell/public/include/shell.h
+++ b/shell/public/include/shell.h
@@ -36,11 +36,12 @@ typedef struct shell * shell_pt;
 
 struct shellService {
 	shell_pt shell;
-	array_list_pt (*getCommands)(shell_pt shell);
-	char * (*getCommandUsage)(shell_pt shell, char * commandName);
-	char * (*getCommandDescription)(shell_pt shell, char * commandName);
+
+	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);
-	void (*executeCommand)(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char *));
+	celix_status_t (*executeCommand)(shell_pt shell_ptr, char * command_line_str, void (*out)(char *), void (*error)(char *));
 };
 
 typedef struct shellService * shell_service_pt;


[02/13] celix git commit: CELIX-230: Fixed bug, added start command

Posted by pn...@apache.org.
CELIX-230: Fixed bug, added start command


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/595f3e99
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/595f3e99
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/595f3e99

Branch: refs/heads/feature/CELIX-269_depman
Commit: 595f3e9931f5b0ab11d2a2e6ea39360e85a40695
Parents: cea3f9e
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Fri Mar 27 17:58:31 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Fri Mar 27 17:58:31 2015 +0100

----------------------------------------------------------------------
 shell/CMakeLists.txt              |  2 +-
 shell/private/src/activator.c     | 15 +++++++-------
 shell/private/src/start_command.c | 37 ++++++++++++----------------------
 3 files changed, 22 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/595f3e99/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 8308369..09777d3 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -27,7 +27,7 @@ if (SHELL)
      	private/src/activator
     	private/src/shell 
     	private/src/ps_command 
-      #	private/src/start_command 
+      private/src/start_command 
       #private/src/stop_command
       #private/src/install_command 
       #private/src/update_command

http://git-wip-us.apache.org/repos/asf/celix/blob/595f3e99/shell/private/src/activator.c
----------------------------------------------------------------------
diff --git a/shell/private/src/activator.c b/shell/private/src/activator.c
index 595894e..ce01b59 100644
--- a/shell/private/src/activator.c
+++ b/shell/private/src/activator.c
@@ -47,6 +47,7 @@ struct command {
 
 static struct command std_commands[] = {
         {psCommand_execute, "ps", "list installed bundles.", "ps [-l | -s | -u]", NULL, NULL, NULL},
+        {startCommand_execute, "start", "start bundle(s).", "start <id> [<id> ...]", NULL, NULL, NULL},
         {NULL, NULL, NULL, NULL, NULL, NULL, NULL} /*marker for last element*/ 
 };
 
@@ -56,15 +57,8 @@ struct bundle_instance {
 	service_registration_pt registration;
 	service_listener_pt listener;
 
-  service_registration_pt commandRegistrations;
-  command_service_pt commandServices;
-  properties_pt commandProperties;
-
     /*
     ps
-	service_registration_pt startCommand;
-	command_pt startCmd;
-	command_service_pt startCmdSrv;
 
 	service_registration_pt stopCommand;
 	command_pt stopCmd;
@@ -180,6 +174,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
                     if (status != CELIX_SUCCESS) {
                             break;
                     }
+                    i += 1;
             }
 
 		}
@@ -198,7 +193,9 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
             while (std_commands[i].exec != NULL) {
                     if (std_commands[i].reg!= NULL) {
                             serviceRegistration_unregister(std_commands[i].reg);
+                            std_commands[i].reg = NULL;
                     }
+                    i += 1;
             }
 
 	status = bundleContext_removeServiceListener(context, bi->listener);
@@ -220,5 +217,9 @@ celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt contex
           i += 1;
   }
 
+  if (bi != NULL) {
+    free(bi);
+  }
+
 	return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/595f3e99/shell/private/src/start_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/start_command.c b/shell/private/src/start_command.c
index 89103eb..0e5f5e0 100644
--- a/shell/private/src/start_command.c
+++ b/shell/private/src/start_command.c
@@ -25,51 +25,40 @@
  */
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
 
-#include "command_impl.h"
+#include "celix_errno.h"
+#include "std_commands.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle.h"
 
-void startCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *));
+celix_status_t startCommand_execute(void *handle, char * line, FILE *outStream, FILE *errStream) {
+  celix_status_t status = CELIX_SUCCESS;
+  bundle_context_pt context = handle;
 
-command_pt startCommand_create(bundle_context_pt context) {
-	command_pt command = (command_pt) malloc(sizeof(*command));
-	command->bundleContext = context;
-	command->name = "start";
-	command->shortDescription = "start bundle(s).";
-	command->usage = "start <id> [<id> ...]";
-	command->executeCommand = startCommand_execute;
-	return command;
-}
-
-void startCommand_destroy(command_pt command) {
-	free(command);
-}
-
-
-void startCommand_execute(command_pt command, char * line, void (*out)(char *), void (*err)(char *)) {
 	char delims[] = " ";
 	char * sub = NULL;
 	char *save_ptr = NULL;
-	char outString[256];
 	sub = strtok_r(line, delims, &save_ptr);
 	sub = strtok_r(NULL, delims, &save_ptr);
 	if (sub == NULL) {
-		err("Incorrect number of arguments.\n");
-		sprintf(outString, "%s\n", command->usage);
-		out(outString);
+		fprintf(outStream, "Incorrect number of arguments.\n");
 	} else {
 		while (sub != NULL) {
 			long id = atol(sub);
 			bundle_pt bundle = NULL;
-			bundleContext_getBundleById(command->bundleContext, id, &bundle);
+			bundleContext_getBundleById(context, id, &bundle);
 			if (bundle != NULL) {
 				bundle_startWithOptions(bundle, 0);
 			} else {
-				err("Bundle id is invalid.\n");
+        fprintf(errStream, "Bundle id '%li' is invalid\n", id);
+        status = CELIX_ILLEGAL_ARGUMENT;
+        break;
 			}
 			sub = strtok_r(NULL, delims, &save_ptr);
 		}
 	}
+
+  return status;
 }


[12/13] celix git commit: CELIX-269: Merge branch 'feature/CELIX-269_depman' into depman

Posted by pn...@apache.org.
CELIX-269: Merge branch 'feature/CELIX-269_depman' into depman


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/9af85cef
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/9af85cef
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/9af85cef

Branch: refs/heads/feature/CELIX-269_depman
Commit: 9af85cef5ca13c70aa46290850e0b7e9a9d436f4
Parents: f5a3cdd 2e480a2
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Nov 3 10:18:41 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Nov 3 10:18:41 2015 +0100

----------------------------------------------------------------------
 framework/private/src/bundle_context.c          |   3 +
 framework/private/src/service_reference.c       |   1 -
 .../examples/calculator_shell/CMakeLists.txt    |   1 -
 .../private/include/add_command.h               |   5 +-
 .../private/include/sqrt_command.h              |   5 +-
 .../private/include/sub_command.h               |   5 +-
 .../calculator_shell/private/src/add_command.c  |  46 +-
 .../private/src/calculator_shell_activator.c    |  55 ++-
 .../calculator_shell/private/src/sqrt_command.c |  42 +-
 .../calculator_shell/private/src/sub_command.c  |  46 +-
 remote_shell/private/include/shell_mediator.h   |   2 +-
 remote_shell/private/src/remote_shell.c         |  46 +-
 remote_shell/private/src/shell_mediator.c       |  19 +-
 shell/CMakeLists.txt                            |  38 +-
 shell/private/include/help_command.h            |  33 --
 shell/private/include/inspect_command.h         |  33 --
 shell/private/include/install_command.h         |  33 --
 shell/private/include/log_command.h             |  33 --
 shell/private/include/ps_command.h              |  33 --
 shell/private/include/shell_private.h           |  22 +-
 shell/private/include/start_command.h           |  33 --
 shell/private/include/std_commands.h            |  44 ++
 shell/private/include/stop_command.h            |  33 --
 shell/private/include/uninstall_command.h       |  33 --
 shell/private/include/update_command.h          |  35 --
 shell/private/src/activator.c                   | 415 ++++++++++---------
 shell/private/src/help_command.c                | 135 +++---
 shell/private/src/inspect_command.c             | 121 ++----
 shell/private/src/install_command.c             |  49 +--
 shell/private/src/lb_command.c                  | 181 ++++++++
 shell/private/src/log_command.c                 |  48 +--
 shell/private/src/ps_command.c                  | 162 --------
 shell/private/src/shell.c                       | 340 ++++++++++-----
 shell/private/src/start_command.c               |  89 ++--
 shell/private/src/stop_command.c                |  93 ++---
 shell/private/src/uninstall_command.c           |  33 +-
 shell/private/src/update_command.c              |  42 +-
 shell/public/include/command.h                  |  23 +-
 shell/public/include/command_impl.h             |  48 ---
 shell/public/include/shell.h                    |  11 +-
 shell/public/src/command.c                      |  45 --
 shell_tui/private/src/shell_tui.c               |   5 +-
 42 files changed, 1074 insertions(+), 1445 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/9af85cef/framework/private/src/service_reference.c
----------------------------------------------------------------------


[08/13] celix git commit: CELIX-230: Removed unneeded install of command_impl.h header

Posted by pn...@apache.org.
CELIX-230: Removed unneeded install of command_impl.h header


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/97b66794
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/97b66794
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/97b66794

Branch: refs/heads/feature/CELIX-269_depman
Commit: 97b667949b928d410cc6349253b70a22ea5973f0
Parents: b63c0d9
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Oct 27 17:00:09 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Oct 27 17:00:09 2015 +0100

----------------------------------------------------------------------
 shell/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/97b66794/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 26252c4..40df757 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -39,7 +39,7 @@ if (SHELL)
     
     install_bundle(shell
     	HEADERS
-    		public/include/shell.h public/include/command.h public/include/command_impl.h
+    		public/include/shell.h public/include/command.h
     	RESOURCES 
     		public/src/command.c
 	)


[11/13] celix git commit: CELIX-230: Merge branch 'feature/CELIX-230_Refactoring_of_the_shell_command_service' into develop

Posted by pn...@apache.org.
CELIX-230: Merge branch 'feature/CELIX-230_Refactoring_of_the_shell_command_service' into develop

explain why this merge is necessary,


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/2e480a29
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/2e480a29
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/2e480a29

Branch: refs/heads/feature/CELIX-269_depman
Commit: 2e480a297d689d0ab340fdfc32874abfc562b220
Parents: c58615d 4234d9b
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Nov 3 10:07:29 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Nov 3 10:07:29 2015 +0100

----------------------------------------------------------------------
 framework/private/src/bundle_context.c          |   3 +
 framework/private/src/service_reference.c       |   1 -
 .../examples/calculator_shell/CMakeLists.txt    |   1 -
 .../private/include/add_command.h               |   5 +-
 .../private/include/sqrt_command.h              |   5 +-
 .../private/include/sub_command.h               |   5 +-
 .../calculator_shell/private/src/add_command.c  |  46 +-
 .../private/src/calculator_shell_activator.c    |  55 ++-
 .../calculator_shell/private/src/sqrt_command.c |  42 +-
 .../calculator_shell/private/src/sub_command.c  |  46 +-
 remote_shell/private/include/shell_mediator.h   |   2 +-
 remote_shell/private/src/remote_shell.c         |  46 +-
 remote_shell/private/src/shell_mediator.c       |  19 +-
 shell/CMakeLists.txt                            |  38 +-
 shell/private/include/help_command.h            |  33 --
 shell/private/include/inspect_command.h         |  33 --
 shell/private/include/install_command.h         |  33 --
 shell/private/include/log_command.h             |  33 --
 shell/private/include/ps_command.h              |  33 --
 shell/private/include/shell_private.h           |  22 +-
 shell/private/include/start_command.h           |  33 --
 shell/private/include/std_commands.h            |  44 ++
 shell/private/include/stop_command.h            |  33 --
 shell/private/include/uninstall_command.h       |  33 --
 shell/private/include/update_command.h          |  35 --
 shell/private/src/activator.c                   | 415 ++++++++++---------
 shell/private/src/help_command.c                | 135 +++---
 shell/private/src/inspect_command.c             | 121 ++----
 shell/private/src/install_command.c             |  49 +--
 shell/private/src/lb_command.c                  | 181 ++++++++
 shell/private/src/log_command.c                 |  48 +--
 shell/private/src/ps_command.c                  | 162 --------
 shell/private/src/shell.c                       | 340 ++++++++++-----
 shell/private/src/start_command.c               |  89 ++--
 shell/private/src/stop_command.c                |  93 ++---
 shell/private/src/uninstall_command.c           |  33 +-
 shell/private/src/update_command.c              |  42 +-
 shell/public/include/command.h                  |  23 +-
 shell/public/include/command_impl.h             |  48 ---
 shell/public/include/shell.h                    |  11 +-
 shell/public/src/command.c                      |  45 --
 shell_tui/private/src/shell_tui.c               |   5 +-
 42 files changed, 1074 insertions(+), 1445 deletions(-)
----------------------------------------------------------------------