aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_hosts.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-08-21 14:48:37 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-08-21 14:48:37 +0000
commit4f65399629a5f9e4556ecbfb550c4fb277265727 (patch)
tree9b04778e7ae6f557e6647ec395bd469f0571ae5a /src/testbed/testbed_api_hosts.c
parentb4fe9e8eec012efb981f90a4d751bb23507aa2c5 (diff)
downloadgnunet-4f65399629a5f9e4556ecbfb550c4fb277265727.tar.gz
gnunet-4f65399629a5f9e4556ecbfb550c4fb277265727.zip
- no need for special parsing of load-leveler generated file since we use MSH from now
Diffstat (limited to 'src/testbed/testbed_api_hosts.c')
-rw-r--r--src/testbed/testbed_api_hosts.c109
1 files changed, 1 insertions, 108 deletions
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 6060810a4..867f829b0 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -583,120 +583,13 @@ GNUNET_TESTBED_hosts_load_from_loadleveler (const struct
583 GNUNET_assert (0); 583 GNUNET_assert (0);
584#else 584#else
585 const char *hostfile; 585 const char *hostfile;
586 char *buf;
587 char *hostname;
588 char **hostnames;
589 struct GNUNET_TESTBED_Host **host_list;
590 ssize_t rsize;
591 uint64_t size;
592 uint64_t offset;
593 enum {
594 SCAN,
595 SKIP,
596 TRIM,
597 READHOST
598 } pstep;
599 unsigned int host;
600 unsigned int nhosts;
601 586
602 if (NULL == (hostfile = getenv ("MP_SAVEHOSTFILE"))) 587 if (NULL == (hostfile = getenv ("MP_SAVEHOSTFILE")))
603 { 588 {
604 GNUNET_break (0); 589 GNUNET_break (0);
605 return 0; 590 return 0;
606 } 591 }
607 if (GNUNET_SYSERR == GNUNET_DISK_file_size (hostfile, &size, GNUNET_YES, 592 return GNUNET_TESTBED_hosts_load_from_file (hostfile, cfg, hosts);
608 GNUNET_YES))
609 {
610 GNUNET_break (0);
611 return 0;
612 }
613 if (0 == size)
614 {
615 GNUNET_break (0);
616 return 0;
617 }
618 buf = GNUNET_malloc (size + 1);
619 rsize = GNUNET_DISK_fn_read (hostfile, buf, (size_t) size);
620 if ( (GNUNET_SYSERR == rsize) || ((ssize_t) size != rsize) )
621 {
622 GNUNET_free (buf);
623 GNUNET_break (0);
624 return 0;
625 }
626 size++;
627 offset = 0;
628 pstep = SCAN;
629 hostname = NULL;
630 hostnames = NULL;
631 nhosts = 0;
632 while (offset < size)
633 {
634 switch (pstep)
635 {
636 case SCAN:
637 if ('!' == buf[offset])
638 pstep = SKIP;
639 else
640 pstep = TRIM;
641 break;
642 case SKIP:
643 if ('\n' == buf[offset])
644 pstep = SCAN;
645 break;
646 case TRIM:
647 if ('!' == buf[offset])
648 {
649 pstep = SKIP;
650 break;
651 }
652 if ( (' ' == buf[offset])
653 || ('\t' == buf[offset])
654 || ('\r' == buf[offset]) )
655 pstep = TRIM;
656 else
657 {
658 pstep = READHOST;
659 hostname = &buf[offset];
660 }
661 break;
662 case READHOST:
663 if (isspace (buf[offset]))
664 {
665 buf[offset] = '\0';
666 for (host = 0; host < nhosts; host++)
667 if (0 == strcmp (hostnames[host], hostname))
668 break;
669 if (host == nhosts)
670 {
671 LOG_DEBUG ("Adding host [%s]\n", hostname);
672 hostname = GNUNET_strdup (hostname);
673 GNUNET_array_append (hostnames, nhosts, hostname);
674 }
675 else
676 LOG_DEBUG ("Not adding host [%s] as it is already included\n", hostname);
677 hostname = NULL;
678 pstep = SCAN;
679 }
680 break;
681 }
682 offset++;
683 }
684 GNUNET_free_non_null (buf);
685 if (NULL == hostnames)
686 return 0;
687 if (NULL == hosts)
688 goto cleanup;
689 qsort (hostnames, nhosts, sizeof (hostnames[0]), cmpstringp);
690 host_list = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * nhosts);
691 for (host = 0; host < nhosts; host++)
692 host_list[host] = GNUNET_TESTBED_host_create (hostnames[host], NULL, cfg, 0);
693 *hosts = host_list;
694
695 cleanup:
696 for (host = 0; host < nhosts; host++)
697 GNUNET_free (hostnames[host]);
698 GNUNET_free(hostnames);
699 return nhosts;
700#endif 593#endif
701} 594}
702 595