X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/134b3ff8dc7cc3ea73a9d456c1ef2e62f73f5e4c..422e163d2e62fd17bddf676642db97c099d2ac36:/src/xbt/xbt_host.c diff --git a/src/xbt/xbt_host.c b/src/xbt/xbt_host.c index c2e8e56701..88eb6eab17 100644 --- a/src/xbt/xbt_host.c +++ b/src/xbt/xbt_host.c @@ -21,6 +21,21 @@ xbt_host_t xbt_host_new(const char *name, int port) { return res; } +/** \brief constructor. Argument should be of form ':'. */ +xbt_host_t xbt_host_from_string(const char *hostport) { + xbt_host_t res=xbt_new(s_xbt_host_t, 1); + char *name=xbt_strdup(hostport); + char *port_str=strchr(hostport,':'); + xbt_assert1(port_str,"argument of xbt_host_from_string should be of form :, it's '%s'", hostport); + *port_str='\0'; + port_str++; + + res->name = xbt_strdup(name); /* it will be shorter now that we cut the port */ + res->port = atoi(port_str); + free(name); + return res; +} + /** \brief destructor */ void xbt_host_free(xbt_host_t host) { if (host) {