Changes in lib/misc.c [b097945:fca4683]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/misc.c
rb097945 rfca4683 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 337 382 /* Convert from one charset to another. 338 383
Note: See TracChangeset
for help on using the changeset viewer.