celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1658378 - in /celix/trunk: event_admin/event_admin/private/src/ launcher/private/src/ remote_services/discovery/private/src/ remote_services/remote_service_admin_http/private/src/ remote_services/remote_service_admin_shm/private/src/ shell...
Date Mon, 09 Feb 2015 12:14:53 GMT
Author: abroekhuis
Date: Mon Feb  9 12:14:52 2015
New Revision: 1658378

URL: http://svn.apache.org/r1658378
Log:
CELIX-216: Replaced strtok with strtok_r

Modified:
    celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c
    celix/trunk/launcher/private/src/launcher.c
    celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c
    celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
    celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
    celix/trunk/shell/private/src/help_command.c
    celix/trunk/shell/private/src/install_command.c
    celix/trunk/shell/private/src/ps_command.c
    celix/trunk/shell/private/src/start_command.c
    celix/trunk/shell/private/src/stop_command.c
    celix/trunk/shell/private/src/uninstall_command.c
    celix/trunk/shell/private/src/update_command.c

Modified: celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c (original)
+++ celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c Mon Feb  9 12:14:52
2015
@@ -144,7 +144,7 @@ celix_status_t eventAdmin_createEventCha
      apr_pool_create(&subPool,(*event_admin)->pool);
      char delims[] = "/";
      char *result = NULL;
-     result = strtok( topic, delims );
+     result = strtok_r( topic, delims );
      if(result != NULL){
      strcpy(complete_channel_name, result);
      }
@@ -166,7 +166,7 @@ celix_status_t eventAdmin_createEventCha
      apr_thread_mutex_create(&channel->channelLock,APR_THREAD_MUTEX_NESTED, subPool);
      }
      }
-     result = strtok( NULL, delims );
+     result = strtok_r( NULL, delims );
      if(result != NULL && status == CELIX_SUCCESS){
      strcat(complete_channel_name, "/");
      strcat(complete_channel_name, result);

Modified: celix/trunk/launcher/private/src/launcher.c
URL: http://svn.apache.org/viewvc/celix/trunk/launcher/private/src/launcher.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/launcher/private/src/launcher.c (original)
+++ celix/trunk/launcher/private/src/launcher.c Mon Feb  9 12:14:52 2015
@@ -112,6 +112,7 @@ int main(int argc, char *argv[]) {
             if (apr_pool_create(&pool, memoryPool) == APR_SUCCESS) {
                 char delims[] = " ";
                 char *result = NULL;
+                char *save_ptr = NULL;
                 linked_list_pt bundles;
                 array_list_pt installed = NULL;
                 bundle_pt bundle = NULL;
@@ -120,11 +121,11 @@ int main(int argc, char *argv[]) {
                 unsigned int i;
 
                 linkedList_create(&bundles);
-                result = strtok(autoStart, delims);
+                result = strtok_r(autoStart, delims, &save_ptr);
                 while (result != NULL) {
                     char * location = apr_pstrdup(memoryPool, result);
                     linkedList_addElement(bundles, location);
-                    result = strtok(NULL, delims);
+                    result = strtok_r(NULL, delims, &save_ptr);
                 }
                 // First install all bundles
                 // Afterwards start them

Modified: celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c (original)
+++ celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c Mon Feb
 9 12:14:52 2015
@@ -90,10 +90,11 @@ celix_status_t endpointDiscoveryPoller_c
 	(*poller)->entries = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
 
 	const char* sep = ",";
-	char* tok = strtok(endpoints, sep);
+	char *save_ptr = NULL;
+	char* tok = strtok_r(endpoints, sep, &save_ptr);
 	while (tok) {
 		endpointDiscoveryPoller_addDiscoveryEndpoint(*poller, strdup(utils_stringTrim(tok)));
-		tok = strtok(NULL, sep);
+		tok = strtok_r(NULL, sep, &save_ptr);
 	}
 	// Clean up after ourselves...
 	free(endpoints);

Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
Mon Feb  9 12:14:52 2015
@@ -391,22 +391,25 @@ celix_status_t remoteServiceAdmin_export
 		array_list_pt interfaces = NULL;
 		arrayList_create(&interfaces);
 		if (strcmp(utils_stringTrim(exports), "*") == 0) {
-			char *interface = strtok(provided, ",");
+			char *save_ptr = NULL;
+			char *interface = strtok_r(provided, ",", &save_ptr);
 			while (interface != NULL) {
 				arrayList_add(interfaces, utils_stringTrim(interface));
-				interface = strtok(NULL, ",");
+				interface = strtok_r(NULL, ",", &save_ptr);
 			}
 		} else {
-			char *pinterface = strtok(provided, ",");
+			char *provided_save_ptr = NULL;
+			char *pinterface = strtok_r(provided, ",", &provided_save_ptr);
 			while (pinterface != NULL) {
-				char *einterface = strtok(exports, ",");
+				char *exports_save_ptr = NULL;
+				char *einterface = strtok_r(exports, ",", &exports_save_ptr);
 				while (einterface != NULL) {
 					if (strcmp(einterface, pinterface) == 0) {
 						arrayList_add(interfaces, einterface);
 					}
-					einterface = strtok(NULL, ",");
+					einterface = strtok_r(NULL, ",", &exports_save_ptr);
 				}
-				pinterface = strtok(NULL, ",");
+				pinterface = strtok_r(NULL, ",", &provided_save_ptr);
 			}
 		}
 

Modified: celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
Mon Feb  9 12:14:52 2015
@@ -484,22 +484,25 @@ celix_status_t remoteServiceAdmin_export
         array_list_pt interfaces = NULL;
         arrayList_create(&interfaces);
         if (strcmp(utils_stringTrim(exports), "*") == 0) {
-            char *interface = strtok(provided, ",");
+        	char *provided_save_ptr = NULL;
+            char *interface = strtok_r(provided, ",", &provided_save_ptr);
             while (interface != NULL) {
                 arrayList_add(interfaces, utils_stringTrim(interface));
-                interface = strtok(NULL, ",");
+                interface = strtok_r(NULL, ",", &provided_save_ptr);
             }
         } else {
-            char *pinterface = strtok(provided, ",");
+        	char *provided_save_ptr = NULL;
+            char *pinterface = strtok_r(provided, ",", &provided_save_ptr);
             while (pinterface != NULL) {
-                char *einterface = strtok(exports, ",");
+            	char *exports_save_ptr = NULL;
+                char *einterface = strtok_r(exports, ",", &exports_save_ptr);
                 while (einterface != NULL) {
                     if (strcmp(einterface, pinterface) == 0) {
                         arrayList_add(interfaces, einterface);
                     }
-                    einterface = strtok(NULL, ",");
+                    einterface = strtok_r(NULL, ",", &exports_save_ptr);
                 }
-                pinterface = strtok(NULL, ",");
+                pinterface = strtok_r(NULL, ",", &provided_save_ptr);
             }
         }
 

Modified: celix/trunk/shell/private/src/help_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/help_command.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/shell/private/src/help_command.c (original)
+++ celix/trunk/shell/private/src/help_command.c Mon Feb  9 12:14:52 2015
@@ -60,10 +60,11 @@ void helpCommand_execute(command_pt comm
 		if (shell != NULL) {
 			char delims[] = " ";
 			char * sub = NULL;
+			char *save_ptr = NULL;
 			char outString[256];
 
-			sub = strtok(line, delims);
-			sub = strtok(NULL, delims);
+			sub = strtok_r(line, delims, &save_ptr);
+			sub = strtok_r(NULL, delims, &save_ptr);
 
 			if (sub == NULL) {
 				int i;
@@ -97,33 +98,9 @@ void helpCommand_execute(command_pt comm
 							out(outString);
 						}
 					}
-					sub = strtok(NULL, delims);
+					sub = strtok_r(NULL, delims, &save_ptr);
 				}
 			}
-
 		}
 	}
-
-//	char delims[] = " ";
-//	char * sub = NULL;
-//	char outString[256];
-//	sub = strtok(line, delims);
-//	sub = strtok(NULL, delims);
-//	if (sub == NULL) {
-//		err("Incorrect number of arguments.\n");
-//		sprintf(outString, "%s\n", command->usage);
-//		out(outString);
-//	} else {
-//		while (sub != NULL) {
-//			long id = atol(sub);
-//			bundle_pt bundle = NULL;
-//			bundleContext_getBundleById(command->bundleContext, id, &bundle);
-//			if (bundle != NULL) {
-//				bundle_startWithOptions(bundle, 0);
-//			} else {
-//				err("Bundle id is invalid.\n");
-//			}
-//			sub = strtok(NULL, delims);
-//		}
-//	}
 }

Modified: celix/trunk/shell/private/src/install_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/install_command.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/shell/private/src/install_command.c (original)
+++ celix/trunk/shell/private/src/install_command.c Mon Feb  9 12:14:52 2015
@@ -54,12 +54,13 @@ void installCommand_destroy(command_pt c
 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(line, delims);
-	sub = strtok(NULL, delims);
+	sub = strtok_r(line, delims, &save_ptr);
+	sub = strtok_r(NULL, delims, &save_ptr);
 	
 	if (sub == NULL) {
 		err("Incorrect number of arguments.\n");
@@ -83,7 +84,7 @@ void installCommand_execute(command_pt c
 				sprintf(bundleId, "%ld", id);
 				strcat(info, bundleId);
 			}
-			sub = strtok(NULL, delims);
+			sub = strtok_r(NULL, delims, &save_ptr);
 		}
 		if (strchr(info, ',') != NULL) {
 			out("Bundle IDs: ");

Modified: celix/trunk/shell/private/src/ps_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/ps_command.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/shell/private/src/ps_command.c (original)
+++ celix/trunk/shell/private/src/ps_command.c Mon Feb  9 12:14:52 2015
@@ -64,8 +64,9 @@ void psCommand_execute(command_pt comman
 
 		char delims[] = " ";
 		char * sub = NULL;
-		sub = strtok(commandline, delims);
-		sub = strtok(NULL, delims);
+		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;
@@ -77,7 +78,7 @@ void psCommand_execute(command_pt comman
 				showUpdateLocation = true;
 				msg = "Update location";
 			}
-			sub = strtok(NULL, delims);
+			sub = strtok_r(NULL, delims, &save_ptr);
 		}
 
 		sprintf(line, "  %-5s %-12s %s\n", "ID", "State", msg);

Modified: celix/trunk/shell/private/src/start_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/start_command.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/shell/private/src/start_command.c (original)
+++ celix/trunk/shell/private/src/start_command.c Mon Feb  9 12:14:52 2015
@@ -51,9 +51,10 @@ void startCommand_destroy(command_pt com
 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(line, delims);
-	sub = strtok(NULL, delims);
+	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);
@@ -68,7 +69,7 @@ void startCommand_execute(command_pt com
 			} else {
 				err("Bundle id is invalid.\n");
 			}
-			sub = strtok(NULL, delims);
+			sub = strtok_r(NULL, delims, &save_ptr);
 		}
 	}
 }

Modified: celix/trunk/shell/private/src/stop_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/stop_command.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/shell/private/src/stop_command.c (original)
+++ celix/trunk/shell/private/src/stop_command.c Mon Feb  9 12:14:52 2015
@@ -51,10 +51,11 @@ void stopCommand_destroy(command_pt comm
 void stopCommand_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(line, delims);
-	sub = strtok(NULL, delims);
+	sub = strtok_r(line, delims, &save_ptr);
+	sub = strtok_r(NULL, delims, &save_ptr);
 
 	if (sub == NULL) {
 		err("Incorrect number of arguments.\n");
@@ -76,7 +77,7 @@ void stopCommand_execute(command_pt comm
 			} else {
 				err("Bundle id should be a number (bundle id).\n");
 			}
-			sub = strtok(NULL, delims);
+			sub = strtok_r(NULL, delims, &save_ptr);
 		}
 	}
 }

Modified: celix/trunk/shell/private/src/uninstall_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/uninstall_command.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/shell/private/src/uninstall_command.c (original)
+++ celix/trunk/shell/private/src/uninstall_command.c Mon Feb  9 12:14:52 2015
@@ -52,10 +52,11 @@ void uninstallCommand_destroy(command_pt
 void uninstallCommand_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(line, delims);
-	sub = strtok(NULL, delims);
+	sub = strtok_r(line, delims, &save_ptr);
+	sub = strtok_r(NULL, delims, &save_ptr);
 
 	if (sub == NULL) {
 		err("Incorrect number of arguments.\n");
@@ -71,7 +72,7 @@ void uninstallCommand_execute(command_pt
 			} else {
 				err("Bundle id is invalid.");
 			}
-			sub = strtok(NULL, delims);
+			sub = strtok_r(NULL, delims, &save_ptr);
 		}
 	}
 }

Modified: celix/trunk/shell/private/src/update_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/update_command.c?rev=1658378&r1=1658377&r2=1658378&view=diff
==============================================================================
--- celix/trunk/shell/private/src/update_command.c (original)
+++ celix/trunk/shell/private/src/update_command.c Mon Feb  9 12:14:52 2015
@@ -58,10 +58,11 @@ void updateCommand_execute(command_pt co
     bundle_pt bundle = NULL;
 	char delims[] = " ";
 	char * sub = NULL;
+	char *save_ptr = NULL;
 	char outString[256];
 
-	sub = strtok(line, delims);
-	sub = strtok(NULL, delims);
+	sub = strtok_r(line, delims, &save_ptr);
+	sub = strtok_r(NULL, delims, &save_ptr);
 
 	if (sub == NULL) {
 		err("Incorrect number of arguments.\n");
@@ -72,7 +73,7 @@ void updateCommand_execute(command_pt co
 		bundleContext_getBundleById(command->bundleContext, id, &bundle);
 		if (bundle != NULL) {
 			char inputFile[256];
-			sub = strtok(NULL, delims);
+			sub = strtok_r(NULL, delims, &save_ptr);
 			inputFile[0] = '\0';
 			if (sub != NULL) {
 				char *test = inputFile;



Mime
View raw message