/* Various normally long or blocking system/network function implemented using forktmp() */ #include #include #include "tlmpdia.h" #include "tlmpdia.m" struct ui_ipaddr{ unsigned char adr[4]; bool found; }; /* Find the IP (in ASCII form, so IPv6 and v4 will be supported). Return -1 if not found. */ int ui_gethostbyname (const char *host, SSTRING &ip) { int ret = -1; glocal const char *host = host; glocal SHAREMEM a; glocal.a.p.found = false; (20); struct hostent *ent = gethostbyname(glocal.host); if (ent != NULL){ glocal.a.p.found = true; glocal.a.p.adr[0] = ent->h_addr[0]; glocal.a.p.adr[1] = ent->h_addr[1]; glocal.a.p.adr[2] = ent->h_addr[2]; glocal.a.p.adr[3] = ent->h_addr[3]; } if (glocal.a.p.found){ ret = 0; ip.setfromf ("%ld.%ld.%ld.%ld" ,glocal.a.p.adr[0] ,glocal.a.p.adr[1] ,glocal.a.p.adr[2] ,glocal.a.p.adr[3]); } return ret; }