Changeset 7a9d968 for lib/misc.c
- Timestamp:
- 2018-03-10T11:30:39Z (7 years ago)
- Children:
- 5447c59
- Parents:
- 3f44e43 (diff), 4a9c6b0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/misc.c
r3f44e43 r7a9d968 1 /********************************************************************\1 /********************************************************************\ 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * … … 335 335 } 336 336 337 /* Wrap an IPv4 address into IPv6 space. Not thread-safe... */338 char *ipv6_wrap(char *src)339 {340 static char dst[64];341 int i;342 343 for (i = 0; src[i]; i++) {344 if ((src[i] < '0' || src[i] > '9') && src[i] != '.') {345 break;346 }347 }348 349 /* Hmm, it's not even an IP... */350 if (src[i]) {351 return src;352 }353 354 g_snprintf(dst, sizeof(dst), "::ffff:%s", src);355 356 return dst;357 }358 359 /* Unwrap an IPv4 address into IPv6 space. Thread-safe, because it's very simple. :-) */360 char *ipv6_unwrap(char *src)361 {362 int i;363 364 if (g_strncasecmp(src, "::ffff:", 7) != 0) {365 return src;366 }367 368 for (i = 7; src[i]; i++) {369 if ((src[i] < '0' || src[i] > '9') && src[i] != '.') {370 break;371 }372 }373 374 /* Hmm, it's not even an IP... */375 if (src[i]) {376 return src;377 }378 379 return (src + 7);380 }381 382 337 /* Convert from one charset to another. 383 338
Note: See TracChangeset
for help on using the changeset viewer.