MCPcopy Create free account
hub / github.com/Tencent/UnLua / inet_aton

Function inet_aton

Plugins/UnLuaExtensions/LuaSocket/Source/src/inet.cpp:498–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496\*-------------------------------------------------------------------------*/
497#ifdef LUASOCKET_INET_ATON
498int inet_aton(const char *cp, struct in_addr *inp)
499{
500 unsigned int a = 0, b = 0, c = 0, d = 0;
501 int n = 0, r;
502 unsigned long int addr = 0;
503 r = sscanf(cp, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n);
504 if (r == 0 || n == 0) return 0;
505 cp += n;
506 if (*cp) return 0;
507 if (a > 255 || b > 255 || c > 255 || d > 255) return 0;
508 if (inp) {
509 addr += a; addr <<= 8;
510 addr += b; addr <<= 8;
511 addr += c; addr <<= 8;
512 addr += d;
513 inp->s_addr = htonl(addr);
514 }
515 return 1;
516}
517#endif
518
519#ifdef LUASOCKET_INET_PTON

Callers 3

inet_gethostFunction · 0.85
opt_set_ip_multicast_ifFunction · 0.85
opt_setmembershipFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected