Changeset 0156c42
- Timestamp:
- 2017-04-06T20:25:08Z (8 years ago)
- Branches:
- master
- Children:
- b097945
- Parents:
- d179fd90
- git-author:
- Wilmer van der Gaast <wilmer@…> (03-04-17 20:57:11)
- git-committer:
- Wilmer van der Gaast <github@…> (06-04-17 20:25:08)
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/misc.c
rd179fd90 r0156c42 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 -
lib/misc.h
rd179fd90 r0156c42 131 131 G_MODULE_EXPORT void http_encode(char *s); 132 132 133 G_MODULE_EXPORT char *ipv6_wrap(char *src);134 G_MODULE_EXPORT char *ipv6_unwrap(char *src);135 136 133 G_MODULE_EXPORT signed int do_iconv(char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf); 137 134
Note: See TracChangeset
for help on using the changeset viewer.