Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
4.8 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. //
  6. // Localization library and MessageIds.
  7. //
  8. #include <nls.h>
  9. #include "localmsg.h"
  10. int
  11. filematch(
  12. char *pszfile,
  13. char **ppszpat,
  14. int cpat,
  15. int fsubdirs
  16. );
  17. typedef struct token_tmp {
  18. char *v4;
  19. char *v6;
  20. char *both;
  21. } token_t;
  22. token_t token[] = {
  23. { "AF_INET", "AF_INET6", NULL },
  24. { "PF_INET", "PF_INET6", NULL },
  25. { "in_addr", "in6_addr", NULL },
  26. { "IN_ADDR", "IN6_ADDR", NULL },
  27. { "PIN_ADDR", "PIN6_ADDR", NULL },
  28. { "LPIN_ADDR", "LPIN6_ADDR", NULL },
  29. { "IPAddr", NULL, "SOCKADDR_STORAGE" },
  30. { "sockaddr_in", "sockaddr_in6", "sockaddr_storage" },
  31. { "SOCKADDR_IN", "SOCKADDR_IN6", "SOCKADDR_STORAGE" },
  32. { "PSOCKADDR_IN", "PSOCKADDR_IN6", "PSOCKADDR_STORAGE" },
  33. { "LPSOCKADDR_IN", "LPSOCKADDR_IN6", "LPSOCKADDR_STORAGE" },
  34. { "INADDR_ANY", "in6addr_any", "getaddrinfo with nodename=NULL and AI_PASSIVE" },
  35. { "INADDR_LOOPBACK", "in6addr_loopback", NULL },
  36. { "IPPROTO_IP", "IPPROTO_IPV6", NULL },
  37. { "IP_MULTICAST_IF", "IPV6_MULTICAST_IF", NULL },
  38. { "IP_MULTICAST_TTL", "IPV6_MULTICAST_HOPS","SIO_MULTICAST_SCOPE" },
  39. { "IP_MULTICAST_LOOP", "IPV6_MULTICAST_LOOP","SIO_MULTIPOINT_LOOPBACK" },
  40. { "IP_ADD_MEMBERSHIP", "IPV6_JOIN_GROUP", "WSAJoinLeaf" },
  41. { "IP_DROP_MEMBERSHIP","IPV6_LEAVE_GROUP", NULL },
  42. { "ip_mreq", "ipv6_mreq", NULL },
  43. { "gethostbyname", NULL, "getaddrinfo" },
  44. { "hostent", NULL, "addrinfo" },
  45. { "HOSTENT", NULL, "ADDRINFO" },
  46. { "PHOSTENT", NULL, "LPADDRINFO" },
  47. { "LPHOSTENT", NULL, "LPADDRINFO" },
  48. { "inet_addr", NULL, "WSAStringToAddress or getaddrinfo with AI_NUMERICHOST"},
  49. { "gethostbyaddr", NULL, "getnameinfo" },
  50. { "inet_ntoa", NULL, "WSAAddressToString or getnameinfo with NI_NUMERICHOST"},
  51. { "IN_MULTICAST", "IN6_IS_ADDR_MULTICAST", NULL },
  52. { "IN_CLASSD", "IN6_IS_ADDR_MULTICAST", NULL },
  53. { "IP_TTL", "IPV6_UNICAST_HOPS", NULL },
  54. { "IN_CLASSA", NULL, NULL },
  55. { "IN_CLASSB", NULL, NULL },
  56. { "IN_CLASSC", NULL, NULL },
  57. { "INADDR_BROADCAST", NULL, NULL },
  58. { "WSAAsyncGetHostByAddr", NULL, "getnameinfo" },
  59. { "WSAAsyncGetHostByName", NULL, "getaddrinfo" },
  60. { NULL, NULL, NULL },
  61. };
  62. void
  63. process_line(filename, lineno, str)
  64. char *filename;
  65. int lineno;
  66. char *str;
  67. {
  68. int i, len;
  69. char *p;
  70. for (i=0; token[i].v4 != NULL; i++) {
  71. p = strstr(str, token[i].v4);
  72. if (p == NULL)
  73. continue;
  74. if (p>str && (isalnum(p[-1]) || p[-1] == '_'))
  75. continue; /* not the start of a token */
  76. len = strlen(token[i].v4);
  77. if (isalnum(p[len]) || p[len] == '_')
  78. continue; /* not the end of a token */
  79. NlsPutMsg(STDOUT, CHECKV4_MESSAGE_0, filename, lineno, token[i].v4);
  80. // printf("%s(%d) : %s : ", filename, lineno, token[i].v4);
  81. if (token[i].both) {
  82. NlsPutMsg(STDOUT, CHECKV4_MESSAGE_1, token[i].both);
  83. // printf("use %s instead", token[i].both);
  84. }
  85. if (token[i].v6) {
  86. if (token[i].both)
  87. NlsPutMsg(STDOUT, CHECKV4_MESSAGE_2);
  88. // printf(", or ");
  89. NlsPutMsg(STDOUT, CHECKV4_MESSAGE_3, token[i].v6);
  90. // printf("use %s in addition for IPv6 support", token[i].v6);
  91. }
  92. if (!token[i].both && !token[i].v6) {
  93. NlsPutMsg(STDOUT, CHECKV4_MESSAGE_4);
  94. // printf("valid for IPv4-only");
  95. }
  96. NlsPutMsg(STDOUT, CHECKV4_MESSAGE_5);
  97. // printf("\n");
  98. }
  99. }
  100. void
  101. process_file(filename)
  102. char *filename;
  103. {
  104. FILE *fp;
  105. char buff[1024];
  106. int lineno;
  107. fp = fopen(filename, "r");
  108. if (fp == NULL) {
  109. NlsPutMsg(STDOUT, CHECKV4_MESSAGE_6, filename);
  110. // printf("%s: cannot open file\n", filename);
  111. return;
  112. }
  113. lineno = 0;
  114. while (fgets(buff, sizeof(buff), fp)) {
  115. lineno++;
  116. process_line(filename, lineno, buff);
  117. }
  118. fclose(fp);
  119. }
  120. int
  121. __cdecl
  122. main(argc, argv)
  123. int argc;
  124. char **argv;
  125. {
  126. int i;
  127. int recurse = 0;
  128. char szfile[MAX_PATH];
  129. argc--;
  130. argv++;
  131. if (argc>0) {
  132. if (!_stricmp(argv[0], "/s")) {
  133. recurse = 1;
  134. argc--;
  135. argv++;
  136. } else if (!_stricmp(argv[0], "/?")) {
  137. NlsPutMsg(STDOUT, CHECKV4_USAGE);
  138. return 1;
  139. }
  140. }
  141. if (argc < 1) {
  142. NlsPutMsg(STDOUT, CHECKV4_MESSAGE_7);
  143. return 1;
  144. }
  145. while (filematch(szfile,argv,argc,recurse) >= 0) {
  146. process_file(szfile);
  147. }
  148. return 0;
  149. }