#include #include #include /* * Analog IPv6 post processor * * Copyright (C) 2012, 2018 R.J. van der Putten, Leiden, Holland, * rob at sput dot nl. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ int main(void) { int i, j, k, len; char c, str[4096]; /* * >( )?8.7.6.5.4.3.2.1.ipvsix => * >( )?1:2:3:4:5:6:7:8 * * And .z. => :: */ bzero(str, 4096); c = 0; while (fgets(str, 4096, stdin)) { i = 0; j = 0; len = strlen(str); while (i < len) { if(strncasecmp(str + i, ".ipvsix", 12) == 0 || \ strncasecmp(str + i, ".ipvsix (", 9) == 0) { if (i - j > 40 || i - j < 3) { i = len; break; } str[i] = 0; str[j] = 0; printf("%s%c", str, c); k = i - 1; if(strncmp(str + k - 1, ".z", 2) == 0) printf(":"); while (k > j) { if (str[k] == '.') { str[k] = 0; if(str[k + 1] != 'z') printf("%s", str + k + 1); printf(":"); } k--; } printf("%s%s", str + j + 1, str + i + 7); break; } if (strncasecmp(str + i, ">      ", 37) == 0) { c = ';'; j = i + 36; } else if (strncasecmp(str + i, ">    ", 25) == 0) { c = ';'; j = i + 24; } else if (strncasecmp(str + i, ">  ", 13) == 0) { c = ';'; j = i + 12; } else if (str[i] == '>') { c = str[i]; j = i; } i++; } if(i >= len) printf("%s", str); } return(0); }