X-Git-Url: https://rtime.felk.cvut.cz/gitweb/orte.git/blobdiff_plain/0e533cbf823d63261384f7a478689b86927cc36f..51d581878cd8f5949f259a61e762c2b55eb74191:/orte/liborte/conv.c diff --git a/orte/liborte/conv.c b/orte/liborte/conv.c index 0610001..a3ee80c 100644 --- a/orte/liborte/conv.c +++ b/orte/liborte/conv.c @@ -74,6 +74,32 @@ void conv_ntp(NtpTime *ntp,char ef) { #endif } +/**********************************************************************************/ +//get part of string, div. by semi. +int +getStringPart(char *string,char divChar,int iterator,char *buff) { + char *cp; + int len; + + if (!string || !buff) return -1; + len=strlen(string); + if (len0 + char *dcp,tcp; + dcp=strchr(cp,divChar); + if (!dcp) dcp=cp+strlen(cp); + tcp=*dcp; //save ending value + *dcp=0; //temporary end of string + strcpy(buff,cp); + *dcp=tcp; //restore value + if (dcp[0]!=0) iterator=dcp-cp+1;//next value + else iterator=dcp-cp; + return 1; + } + return 0; +} + /**********************************************************************************/ char* IPAddressToString(IPAddress ipAddress,char *buff) { @@ -87,7 +113,20 @@ IPAddressToString(IPAddress ipAddress,char *buff) { /**********************************************************************************/ IPAddress StringToIPAddress(const char *string) { - return ntohl(inet_addr(string)); + IPAddress ipAddress=IPADDRESS_INVALID; + + ipAddress=ntohl(inet_addr(string)); +#if defined HAVE_GETHOSTBYNAME + { + struct hostent *hostname; + if (ipAddress==0) { + if ((hostname=gethostbyname(string))) { + ipAddress=ntohl(*((long*)(hostname->h_addr_list[0]))); + } + } + } +#endif + return ipAddress; } /**********************************************************************************/