+msg_task_t task_message_new(e_message_type type, const char *issuer_hostname, const char *mailbox)
+{
+ message_t msg = xbt_new(s_message_t, 1);
+ msg->type = type;
+ msg->issuer_hostname = issuer_hostname;
+ msg->mailbox = mailbox;
+ msg_task_t task = MSG_task_create(NULL, 0, MESSAGE_SIZE, msg);
+
+ return task;
+}
+
+msg_task_t task_message_chain_new(const char *issuer_hostname, const char *mailbox, const char* prev, const char *next)
+{
+ msg_task_t task = task_message_new(MESSAGE_BUILD_CHAIN, issuer_hostname, mailbox);
+ message_t msg = MSG_task_get_data(task);
+ msg->prev_hostname = prev;
+ msg->next_hostname = next;
+
+ return task;
+}
+
+msg_task_t task_message_data_new(const char *issuer_hostname, const char *mailbox, const char *block, unsigned int len)
+{
+ msg_task_t task = task_message_new(MESSAGE_SEND_DATA, issuer_hostname, mailbox);
+ if (strcmp(mailbox, "host4") == 0) MSG_task_set_category(task, mailbox);
+ message_t msg = MSG_task_get_data(task);
+ msg->data_block = block;
+ msg->data_length = len;
+
+ return task;
+}
+
+msg_task_t task_message_end_data_new(const char *issuer_hostname, const char *mailbox)
+{
+ return task_message_new(MESSAGE_END_DATA, issuer_hostname, mailbox);
+}
+
+void task_message_delete(void *task)
+{
+ message_t msg = MSG_task_get_data(task);
+ xbt_free(msg);
+ MSG_task_destroy(task);
+}
+
+void queue_pending_connection(msg_comm_t comm, xbt_dynar_t q)
+{
+ xbt_dynar_push(q, &comm);
+}
+
+int process_pending_connections(xbt_dynar_t q)
+{
+ unsigned int iter;
+ int status;
+ int empty = 0;
+ msg_comm_t comm;
+
+ xbt_dynar_foreach(q, iter, comm) {
+ empty = 1;
+ if (MSG_comm_test(comm)) {
+ MSG_comm_destroy(comm);
+ status = MSG_comm_get_status(comm);
+ xbt_assert(status == MSG_OK, __FILE__ ": process_pending_connections() failed");
+ xbt_dynar_cursor_rm(q, &iter);
+ empty = 0;
+ }
+ }
+ return empty;
+}
+
+xbt_dynar_t build_hostlist_from_hostcount(int hostcount)
+{
+ xbt_dynar_t host_list = xbt_dynar_new(sizeof(char*), NULL);
+ char *hostname = NULL;
+ msg_host_t h = NULL;
+ int i = 1;
+
+ for (; i < hostcount+1; i++) {
+ hostname = xbt_new(char, HOSTNAME_LENGTH);
+ snprintf(hostname, HOSTNAME_LENGTH, "host%d", i);
+ //XBT_INFO("%s", hostname);
+ h = MSG_get_host_by_name(hostname);
+ if (h == NULL) {
+ XBT_INFO("Unknown host %s. Stopping Now! ", hostname);
+ abort();
+ } else {
+ xbt_dynar_push(host_list, &hostname);
+ }
+ }
+ return host_list;
+}
+
+/*xbt_dynar_t build_hostlist_from_argv(int argc, char *argv[])