convert a string represenation of an IP address into its numeric equivalent
| 277 | typedef unsigned long uint32; |
| 278 | // convert a string represenation of an IP address into its numeric equivalent |
| 279 | static uint32 Inet_AtoN(const char * buf) |
| 280 | { |
| 281 | |
| 282 | uint32 ret = 0; |
| 283 | int shift = 24; // fill out the MSB first |
| 284 | bool startQuad = true; |
| 285 | while((shift >= 0)&&(*buf)) |
| 286 | { |
| 287 | if (startQuad) |
| 288 | { |
| 289 | unsigned char quad = (unsigned char) atoi(buf); |
| 290 | ret |= (((uint32)quad) << shift); |
| 291 | shift -= 8; |
| 292 | } |
| 293 | startQuad = (*buf == '.'); |
| 294 | buf++; |
| 295 | } |
| 296 | return ret; |
| 297 | } |
| 298 | |
| 299 | int |
| 300 | main(int argc, char **argv) |