removed GNUNET_TESTBED_operation_cancel
[oweals/gnunet.git] / src / testbed / testbed_api_hosts.c
index d80a663e345ffd6c69ad9ed9e73c5e3ce115467f..1663f89624126a8dc27c2f0016959435f6908e47 100644 (file)
@@ -189,6 +189,19 @@ GNUNET_TESTBED_host_get_hostname_ (const struct GNUNET_TESTBED_Host *host)
 }
 
 
+/**
+ * Obtain the host's hostname.
+ *
+ * @param host handle to the host, NULL means 'localhost'
+ * @return hostname of the host
+ */
+const char *
+GNUNET_TESTBED_host_get_hostname (const struct GNUNET_TESTBED_Host *host)
+{
+  return GNUNET_TESTBED_host_get_hostname_ (host);
+}
+
+
 /**
  * Obtain the host's username
  *
@@ -298,14 +311,14 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
   struct GNUNET_TESTBED_Host *starting_host;
   char *data;
   char *buf;
-  char *username;
-  char *hostname;
+  char username[256];
+  char hostname[256];
   uint64_t fs;
   short int port;
   int ret;
   unsigned int offset;
   unsigned int count;
-  
+
 
   GNUNET_assert (NULL != filename);
   if (GNUNET_YES != GNUNET_DISK_file_test (filename))
@@ -313,7 +326,7 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
     LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s not found\n"), filename);
     return 0;
   }
-  if (GNUNET_OK != 
+  if (GNUNET_OK !=
       GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
     fs = 0;
   if (0 == fs)
@@ -321,7 +334,7 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
     LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s has no data\n"), filename);
     return 0;
   }
-  data = GNUNET_malloc (fs);  
+  data = GNUNET_malloc (fs);
   if (fs != GNUNET_DISK_fn_read (filename, data, fs))
   {
     GNUNET_free (data);
@@ -339,10 +352,8 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
     if (((data[offset] == '\n')) && (buf != &data[offset]))
     {
       data[offset] = '\0';
-      username = NULL;
-      hostname = NULL;
-      ret = SSCANF (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd",
-                    &username, &hostname, &port);
+      ret = SSCANF (buf, "%255[a-zA-Z0-9_]@%255[a-zA-Z0-9.]:%5hd",
+                    username, hostname, &port);
       if  (3 == ret)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -360,16 +371,14 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
       else
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                     "Error reading line `%s' in hostfile\n", buf);
-      GNUNET_free_non_null (hostname);
-      GNUNET_free_non_null (username);
       buf = &data[offset + 1];
     }
     else if ((data[offset] == '\n') || (data[offset] == '\0'))
-      buf = &data[offset + 1];        
+      buf = &data[offset + 1];
   }
   GNUNET_free (data);
   if (NULL == starting_host)
-    return 0;  
+    return 0;
   *hosts = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * count);
   memcpy (*hosts,
           &host_list[GNUNET_TESTBED_host_get_id_ (starting_host)],
@@ -443,7 +452,6 @@ GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
   }
   rc = GNUNET_malloc (sizeof (struct RegisteredController));
   rc->controller = controller;
-  //host->controller = controller;
   GNUNET_CONTAINER_DLL_insert_tail (host->rc_head, host->rc_tail, rc);
 }
 
@@ -511,7 +519,7 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
   remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes";
   remote_args[argp++] = ssh_addr;
   remote_args[argp++] = "which";
-  remote_args[argp++] = "gnunet-helper-testbed";  
+  remote_args[argp++] = "gnunet-helper-testbed";
   remote_args[argp++] = NULL;
   GNUNET_assert (argp == 11);
   auxp =