celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1633946 - in /celix/trunk/remote_shell/private/src: activator.c connection_listener.c remote_shell.c shell_mediator.c
Date Thu, 23 Oct 2014 20:51:02 GMT
Author: bpetri
Date: Thu Oct 23 20:51:02 2014
New Revision: 1633946

URL: http://svn.apache.org/r1633946
Log:
CELIX-119: code indentation fix

Modified:
    celix/trunk/remote_shell/private/src/activator.c
    celix/trunk/remote_shell/private/src/connection_listener.c
    celix/trunk/remote_shell/private/src/remote_shell.c
    celix/trunk/remote_shell/private/src/shell_mediator.c

Modified: celix/trunk/remote_shell/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_shell/private/src/activator.c?rev=1633946&r1=1633945&r2=1633946&view=diff
==============================================================================
--- celix/trunk/remote_shell/private/src/activator.c (original)
+++ celix/trunk/remote_shell/private/src/activator.c Thu Oct 23 20:51:02 2014
@@ -58,54 +58,54 @@ celix_status_t bundleActivator_create(bu
 
 	bundle_instance_pt bi = (bundle_instance_pt) calloc(1, sizeof(struct bundle_instance));
 
-    if (!bi)
-    {
-    	status = CELIX_ENOMEM;
-    }
-    else if (userData != NULL) {
-        	bi->shellMediator = NULL;
-        	bi->remoteShell = NULL;
-        	bi->connectionListener = NULL;
-        	(*userData) = bi;
-    } else {
-    	status = CELIX_ILLEGAL_ARGUMENT;
-    	free(bi);
-    }
+	if (!bi)
+	{
+		status = CELIX_ENOMEM;
+	}
+	else if (userData != NULL) {
+		bi->shellMediator = NULL;
+		bi->remoteShell = NULL;
+		bi->connectionListener = NULL;
+		(*userData) = bi;
+	} else {
+		status = CELIX_ILLEGAL_ARGUMENT;
+		free(bi);
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_instance_pt bi = (bundle_instance_pt)userData;
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_instance_pt bi = (bundle_instance_pt) userData;
 
-    int port = bundleActivator_getPort(context);
-    int maxConn = bundleActivator_getMaximumConnections(context);
+	int port = bundleActivator_getPort(context);
+	int maxConn = bundleActivator_getMaximumConnections(context);
 
-    status = shellMediator_create(context, &bi->shellMediator);
-	status = CELIX_DO_IF(status, remoteShell_create(bi->shellMediator,  maxConn, &bi->remoteShell));
+	status = shellMediator_create(context, &bi->shellMediator);
+	status = CELIX_DO_IF(status, remoteShell_create(bi->shellMediator, maxConn, &bi->remoteShell));
 	status = CELIX_DO_IF(status, connectionListener_create(bi->remoteShell, port, &bi->connectionListener));
-    status = CELIX_DO_IF(status, connectionListener_start(bi->connectionListener));
+	status = CELIX_DO_IF(status, connectionListener_start(bi->connectionListener));
 
-    return status;
+	return status;
 }
 
 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;
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_instance_pt bi = (bundle_instance_pt) userData;
 
-    shellMediator_destroy(bi->shellMediator);
-    connectionListener_stop(bi->connectionListener);
-    remoteShell_stopConnections(bi->remoteShell);
+	shellMediator_destroy(bi->shellMediator);
+	connectionListener_stop(bi->connectionListener);
+	remoteShell_stopConnections(bi->remoteShell);
 
-    return status;
+	return status;
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-    bundle_instance_pt bi = (bundle_instance_pt)userData;
-    connectionListener_destroy(bi->connectionListener);
+	bundle_instance_pt bi = (bundle_instance_pt) userData;
+	connectionListener_destroy(bi->connectionListener);
 
-    return CELIX_SUCCESS;
+	return CELIX_SUCCESS;
 }
 
 static int bundleActivator_getPort(bundle_context_pt context) {
@@ -123,14 +123,14 @@ static int bundleActivator_getProperty(b
 
 	bundleContext_getProperty(context, propertyName, &strValue);
 	if (strValue != NULL) {
-    	char* endptr = strValue;
+		char* endptr = strValue;
 
-    	errno = 0;
-        value = strtol(strValue, &endptr, 10);
-        if (*endptr || errno != 0) {
+		errno = 0;
+		value = strtol(strValue, &endptr, 10);
+		if (*endptr || errno != 0) {
 			printf("incorrect format for %s\n", propertyName);
 			value = defaultValue;
-        }
+		}
 	}
 	else {
 		value = defaultValue;

Modified: celix/trunk/remote_shell/private/src/connection_listener.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_shell/private/src/connection_listener.c?rev=1633946&r1=1633945&r2=1633946&view=diff
==============================================================================
--- celix/trunk/remote_shell/private/src/connection_listener.c (original)
+++ celix/trunk/remote_shell/private/src/connection_listener.c Thu Oct 23 20:51:02 2014
@@ -45,24 +45,24 @@
 
 struct connection_listener {
 	//constant
-    int port;
-    remote_shell_pt remoteShell;
-    celix_thread_mutex_t mutex;
+	int port;
+	remote_shell_pt remoteShell;
+	celix_thread_mutex_t mutex;
 
 	//protected by mutex
-    bool running;
-    celix_thread_t thread;
+	bool running;
+	celix_thread_t thread;
 	fd_set pollset;
 };
 
-static void*  connection_listener_thread(void *data);
+static void* connection_listener_thread(void *data);
 
 celix_status_t connectionListener_create(remote_shell_pt remoteShell, int port, connection_listener_pt
*instance) {
 	celix_status_t status = CELIX_SUCCESS;
-    (*instance) = calloc(1, sizeof(**instance));
+	(*instance) = calloc(1, sizeof(**instance));
 
-    if ((*instance) != NULL) {
-    	(*instance)->port = port;
+	if ((*instance) != NULL) {
+		(*instance)->port = port;
 		(*instance)->remoteShell = remoteShell;
 		(*instance)->running = false;
 
@@ -94,28 +94,25 @@ celix_status_t connectionListener_stop(c
 	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "CONNECTION_LISTENER: Stopping thread\n");
 
 	celixThreadMutex_lock(&instance->mutex);
-	thread=instance->thread;
+	thread = instance->thread;
 
-	pollset=instance->pollset;
+	pollset = instance->pollset;
 	celixThreadMutex_unlock(&instance->mutex);
 
 	celixThread_join(thread, NULL);
 	return status;
 }
 
-
 celix_status_t connectionListener_destroy(connection_listener_pt instance) {
 	free(instance);
 
 	return CELIX_SUCCESS;
 }
 
-
-
 static void* connection_listener_thread(void *data) {
 	celix_status_t status = CELIX_BUNDLE_EXCEPTION;
 	connection_listener_pt instance = data;
-	struct timeval timeout;  /* Timeout for select */
+	struct timeval timeout; /* Timeout for select */
 	fd_set active_fd_set;
 	int listenSocket = 0;
 	int on = 1;
@@ -123,49 +120,49 @@ static void* connection_listener_thread(
 	struct addrinfo *result, *rp;
 	struct addrinfo hints;
 
-    memset(&hints, 0, sizeof(struct addrinfo));
-    hints.ai_family = AF_UNSPEC;    /* Allow IPv4 or IPv6 */
-    hints.ai_socktype = SOCK_STREAM; /* Datagram socket */
-    hints.ai_flags = AI_PASSIVE;    /* For wildcard IP address */
-    hints.ai_protocol = 0;          /* Any protocol */
-    hints.ai_canonname = NULL;
-    hints.ai_addr = NULL;
-    hints.ai_next = NULL;
+	memset(&hints, 0, sizeof(struct addrinfo));
+	hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
+	hints.ai_socktype = SOCK_STREAM; /* Datagram socket */
+	hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */
+	hints.ai_protocol = 0; /* Any protocol */
+	hints.ai_canonname = NULL;
+	hints.ai_addr = NULL;
+	hints.ai_next = NULL;
 
-    char portStr[10];
-    snprintf(&portStr[0], 10, "%d", instance->port);
+	char portStr[10];
+	snprintf(&portStr[0], 10, "%d", instance->port);
 
-    getaddrinfo(NULL, portStr, &hints, &result);
+	getaddrinfo(NULL, portStr, &hints, &result);
 
-    for (rp = result; rp != NULL && status == CELIX_BUNDLE_EXCEPTION; rp = rp->ai_next)
{
+	for (rp = result; rp != NULL && status == CELIX_BUNDLE_EXCEPTION; rp = rp->ai_next)
{
 
 		status = CELIX_BUNDLE_EXCEPTION;
 
 		/* Create socket */
-		listenSocket = socket(rp->ai_family , rp->ai_socktype, rp->ai_protocol);
+		listenSocket = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
 		if (listenSocket < 0) {
 			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error creating socket: %s", strerror(errno));
 		}
-		else if(setsockopt(listenSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on))
< 0) {
+		else if (setsockopt(listenSocket, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on))
< 0) {
 			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "cannot set socket option: %s", strerror(errno));
 		}
 		else if (bind(listenSocket, rp->ai_addr, rp->ai_addrlen) < 0) {
 			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "cannot bind: %s", strerror(errno));
 		}
-		else if (listen(listenSocket,5) < 0) {
+		else if (listen(listenSocket, 5) < 0) {
 			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "listen failed: %s", strerror(errno));
 		}
 		else {
 			status = CELIX_SUCCESS;
 		}
-    }
+	}
 
-    if (status == CELIX_SUCCESS) {
+	if (status == CELIX_SUCCESS) {
 
 		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Remote Shell accepting connections on port %d",
instance->port);
 
 		celixThreadMutex_lock(&instance->mutex);
-		instance->pollset=active_fd_set;
+		instance->pollset = active_fd_set;
 		celixThreadMutex_unlock(&instance->mutex);
 
 		instance->running = true;
@@ -176,23 +173,23 @@ static void* connection_listener_thread(
 				timeout.tv_sec = CONNECTION_LISTENER_TIMEOUT_SEC;
 				timeout.tv_usec = 0;
 
-		    	FD_ZERO (&active_fd_set);
-				FD_SET (listenSocket, &active_fd_set);
+				FD_ZERO(&active_fd_set);
+				FD_SET(listenSocket, &active_fd_set);
 
-				selectRet = select (listenSocket+1, &active_fd_set, NULL, NULL, &timeout);
+				selectRet = select(listenSocket + 1, &active_fd_set, NULL, NULL, &timeout);
 			} while (selectRet == -1 && errno == EINTR && instance->running ==
true);
 			if (selectRet < 0) {
-				 fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "select on listenSocket failed: %s", strerror(errno));
-				 status = CELIX_BUNDLE_EXCEPTION;
+				fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "select on listenSocket failed: %s", strerror(errno));
+				status = CELIX_BUNDLE_EXCEPTION;
 			}
-			else if (selectRet == 0){
+			else if (selectRet == 0) {
 				/* do nothing here */
 			}
-			else if (FD_ISSET(listenSocket,&active_fd_set)) {
-				int acceptedSocket = accept (listenSocket, NULL, NULL);
+			else if (FD_ISSET(listenSocket, &active_fd_set)) {
+				int acceptedSocket = accept(listenSocket, NULL, NULL);
 
 				if (acceptedSocket < 0) {
-					perror ("accept");
+					perror("accept");
 					status = CELIX_BUNDLE_EXCEPTION;
 				}
 				else {
@@ -204,14 +201,14 @@ static void* connection_listener_thread(
 				fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "REMOTE_SHELL: received data on a not-expected
file-descriptor?");
 			}
 		}
-    }
+	}
 
-    if (listenSocket > 0) {
-    	close(listenSocket);
-    }
+	if (listenSocket > 0) {
+		close(listenSocket);
+	}
 
-    freeaddrinfo(result);
+	freeaddrinfo(result);
 
-    return NULL;
+	return NULL;
 }
 

Modified: celix/trunk/remote_shell/private/src/remote_shell.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_shell/private/src/remote_shell.c?rev=1633946&r1=1633945&r2=1633946&view=diff
==============================================================================
--- celix/trunk/remote_shell/private/src/remote_shell.c (original)
+++ celix/trunk/remote_shell/private/src/remote_shell.c Thu Oct 23 20:51:02 2014
@@ -63,8 +63,7 @@ static celix_status_t remoteShell_connec
 static celix_status_t remoteShell_connection_execute(connection_pt connection, char *command);
 static void* remoteShell_connection_run(void *data);
 
-
-celix_status_t remoteShell_create( shell_mediator_pt mediator, int maximumConnections, remote_shell_pt
*instance) {
+celix_status_t remoteShell_create(shell_mediator_pt mediator, int maximumConnections, remote_shell_pt
*instance) {
 	celix_status_t status = CELIX_SUCCESS;
 	(*instance) = calloc(1, sizeof(**instance));
 	if ((*instance) != NULL) {
@@ -104,7 +103,7 @@ celix_status_t remoteShell_addConnection
 		if (arrayList_size(instance->connections) < instance->maximumConnections) {
 			celix_thread_t connectionRunThread = NULL;
 			arrayList_add(instance->connections, connection);
-		    status = celixThread_create(&connectionRunThread, NULL, &remoteShell_connection_run,
connection);
+			status = celixThread_create(&connectionRunThread, NULL, &remoteShell_connection_run,
connection);
 		} else {
 			status = CELIX_BUNDLE_EXCEPTION;
 			remoteShell_connection_print(connection, RS_MAXIMUM_CONNECTIONS_REACHED);
@@ -145,7 +144,7 @@ void *remoteShell_connection_run(void *d
 	connection_pt connection = data;
 	size_t len;
 	int result;
-	struct timeval timeout;  /* Timeout for select */
+	struct timeval timeout; /* Timeout for select */
 
 	connection->threadRunning = true;
 	status = remoteShell_connection_print(connection, RS_WELCOME);
@@ -164,10 +163,10 @@ void *remoteShell_connection_run(void *d
 		if (result > 0 && FD_ISSET(connection->socket, &connection->pollset))
{
 			char buff[COMMAND_BUFF_SIZE];
 
-			len = recv(connection->socket, buff, COMMAND_BUFF_SIZE-1, 0);
+			len = recv(connection->socket, buff, COMMAND_BUFF_SIZE - 1, 0);
 			if (len < COMMAND_BUFF_SIZE) {
 				celix_status_t commandStatus = CELIX_SUCCESS;
-				buff[len]='\0';
+				buff[len] = '\0';
 
 				commandStatus = remoteShell_connection_execute(connection, buff);
 

Modified: celix/trunk/remote_shell/private/src/shell_mediator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_shell/private/src/shell_mediator.c?rev=1633946&r1=1633945&r2=1633946&view=diff
==============================================================================
--- celix/trunk/remote_shell/private/src/shell_mediator.c (original)
+++ celix/trunk/remote_shell/private/src/shell_mediator.c Thu Oct 23 20:51:02 2014
@@ -59,7 +59,7 @@ celix_status_t shellMediator_create(bund
 	service_tracker_customizer_pt customizer = NULL;
 
 	(*instance) = (shell_mediator_pt) calloc(1, sizeof(**instance));
-    if ((*instance) != NULL) {
+	if ((*instance) != NULL) {
 
 		(*instance)->context = context;
 		(*instance)->tracker = NULL;
@@ -69,7 +69,7 @@ celix_status_t shellMediator_create(bund
 
 		status = CELIX_DO_IF(status, serviceTrackerCustomizer_create((*instance), shellMediator_addingService,
shellMediator_addedService,
 				shellMediator_modifiedService, shellMediator_removedService, &customizer));
-		status = CELIX_DO_IF(status, serviceTracker_create(context, (char *)OSGI_SHELL_SERVICE_NAME,
customizer, &(*instance)->tracker));
+		status = CELIX_DO_IF(status, serviceTracker_create(context, (char * )OSGI_SHELL_SERVICE_NAME,
customizer, &(*instance)->tracker));
 
 		if (status == CELIX_SUCCESS) {
 			serviceTracker_open((*instance)->tracker);
@@ -78,21 +78,20 @@ celix_status_t shellMediator_create(bund
 		status = CELIX_ENOMEM;
 	}
 
-    if (status != CELIX_SUCCESS) {
-    	printf("Error creating shell_mediator, error code is %i\n", status);
-    }
+	if (status != CELIX_SUCCESS) {
+		printf("Error creating shell_mediator, error code is %i\n", status);
+	}
 	return status;
 }
 
-
 celix_status_t shellMediator_destroy(shell_mediator_pt instance) {
-    celixThreadMutex_lock(&instance->mutex);
+	celixThreadMutex_lock(&instance->mutex);
 
-    instance->shellService=NULL;
-    serviceTracker_close(instance->tracker);
-    celixThreadMutex_unlock(&instance->mutex);
+	instance->shellService = NULL;
+	serviceTracker_close(instance->tracker);
+	celixThreadMutex_unlock(&instance->mutex);
 
-    return CELIX_SUCCESS;
+	return CELIX_SUCCESS;
 }
 
 static void shellMediator_writeOnCurrentSocket(char *buff) {
@@ -107,9 +106,9 @@ celix_status_t shellMediator_executeComm
 	celixThreadMutex_lock(&instance->mutex);
 
 	if (instance->shellService != NULL) {
-		currentOutputSocket=socket;
+		currentOutputSocket = socket;
 		instance->shellService->executeCommand(instance->shellService->shell, command,
shellMediator_writeOnCurrentSocket, shellMediator_writeOnCurrentSocket);
-		currentOutputSocket=-1;
+		currentOutputSocket = -1;
 	}
 
 	celixThreadMutex_unlock(&instance->mutex);



Mime
View raw message