2 * $Id: conv.c,v 0.0.0.1 2003/09/10
4 * DEBUG: section 7 ordering conversion
6 * -------------------------------------------------------------------
8 * Open Real-Time Ethernet
10 * Copyright (C) 2001-2006
11 * Department of Control Engineering FEE CTU Prague, Czech Republic
12 * http://dce.felk.cvut.cz
13 * http://www.ocera.org
15 * Author: Petr Smolik petr@smoliku.cz
17 * Project Responsible: Zdenek Hanzalek
18 * --------------------------------------------------------------------
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * This module maintains a hash table of key/value pairs.
31 * Keys can be strings of any size, or numbers up to size
32 * unsigned long (HASHKEYTYPE).
33 * Values should be a pointer to some data you wish to store.
39 /**********************************************************************************/
40 //get part of string, div. by semi.
42 getStringPart(char *string, char divChar, int *iterator, char *buff)
50 if (len < (*iterator))
52 cp = string+(*iterator);
53 if (cp[0] != 0) { //till is length>0
55 dcp = strchr(cp, divChar);
58 tcp = *dcp; //save ending value
59 *dcp = 0; //temporary end of string
60 strcpy((char *)buff, cp);
61 *dcp = tcp; //restore value
63 (*iterator) += dcp-cp+1; //next value
71 /**********************************************************************************/
73 IPAddressToString(IPAddress ipAddress, char *buff)
77 addr.s_addr = htonl(ipAddress);
78 sprintf(buff, "%s", inet_ntoa(addr));
82 /**********************************************************************************/
84 StringToIPAddress(const char *string)
86 IPAddress ipAddress = IPADDRESS_INVALID;
88 #ifdef CONFIG_ORTE_MINGW
89 unsigned long inetAddress = inet_addr(string);
91 in_addr_t inetAddress = inet_addr(string);
94 if (inetAddress != INADDR_NONE) {
95 ipAddress = ntohl(inetAddress);
97 #if defined HAVE_GETHOSTBYNAME
99 struct hostent *hostname;
100 if (ipAddress == IPADDRESS_INVALID) {
101 if ((hostname = gethostbyname(string))) {
102 ipAddress = ntohl(*((long *)(hostname->h_addr_list[0])));
110 /**********************************************************************************/
112 NtpTimeToStringMs(NtpTime time, char *buff)
116 NtpTimeDisAssembToMs(s, msec, time);
117 sprintf(buff, "%d.%03d", s, msec);
121 /**********************************************************************************/
123 NtpTimeToStringUs(NtpTime time, char *buff)
127 NtpTimeDisAssembToUs(s, usec, time);
128 sprintf(buff, "%d.%06d", s, usec);