--- /dev/null
+/* by tino@augsburg.net\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+#include <dirent.h>\r
+\r
+unsigned char\r
+test(void)\r
+{\r
+ DIR *dir;\r
+ struct dirent *dp;\r
+ unsigned char c;\r
+\r
+ if ((dir=opendir("."))==0)\r
+ {\r
+ perror("open .");\r
+ return 0;\r
+ }\r
+ c = 0;\r
+ while ((dp=readdir(dir))!=0)\r
+ {\r
+ size_t len;\r
+\r
+ len = strlen(dp->d_name);\r
+ if (len<4)\r
+ continue;\r
+ if (strcmp(dp->d_name+len-4, ".TST"))\r
+ continue;\r
+ if (len!=5)\r
+ {\r
+ fprintf(stderr, "warning: %s\n", dp->d_name);\r
+ printf(" length");\r
+ continue;\r
+ }\r
+ if (c)\r
+ printf(" double%d\n", c);\r
+ c = dp->d_name[0];\r
+ }\r
+ if (closedir(dir))\r
+ perror("close .");\r
+ return c;\r
+}\r
+\r
+int\r
+main(void)\r
+{\r
+ char name[256];\r
+ unsigned char map[256], upper[256], lower[256];\r
+ int i, j, c;\r
+ FILE *fd;\r
+\r
+ if (test())\r
+ {\r
+ printf("There are *.TST files, please remove\n");\r
+ return 0;\r
+ }\r
+ for (i=0; ++i<256; )\r
+ {\r
+ lower[i] = i;\r
+ upper[i] = 0;\r
+ }\r
+ for (i=256; --i; )\r
+ {\r
+ map[i] = i;\r
+ strcpy(name, "..TST");\r
+ name[0] = i;\r
+ printf("%d:", i);\r
+ if ((fd=fopen(name, "w"))==0)\r
+ printf(" open");\r
+ else\r
+ fclose(fd);\r
+ c = test();\r
+ if (unlink(name))\r
+ printf(" unlink");\r
+ if (c==i)\r
+ printf(" ok");\r
+ else\r
+ printf(" %d", c);\r
+ printf("\n");\r
+ if (c!=i)\r
+ {\r
+ upper[c]++;\r
+ lower[c] = i;\r
+ }\r
+ map[i] = c;\r
+ }\r
+\r
+ /* Uppercase characters are detected above on:\r
+ * The character is mapped to itself and there is a\r
+ * character which maps to it.\r
+ * Lowercase characters are the lowest character pointing to another one.\r
+ * Else it is a one way character.\r
+ *\r
+ * For this reason we have to process the list\r
+ * 1) for 'one way' characters\r
+ * 'one way' is something which is no upper and no lower character.\r
+ * This is an awful, crude and ugly hack due to missing Samba support.\r
+ * 2) for true uppercase/lowercase characters\r
+ * 3) for standalone characters\r
+ * Note that there might be characters which do not fall into 1 to 3.\r
+ */\r
+ printf("\n valid chars =");\r
+ for (i=0; ++i<256; )\r
+ if (map[i] && map[i]!=i && lower[map[i]]!=i)\r
+ {\r
+ if (!upper[i])\r
+ printf(" %d:%d %d:%d %d:%d", /*1*/\r
+ map[i], i, i, map[i], map[i], map[i]);\r
+ else\r
+ fprintf(stderr, "ignoring map %d->%d because of %d->%d\n",\r
+ lower[i], i, i, map[i]);\r
+ }\r
+ for (i=0; ++i<256; )\r
+ if (map[i] && map[i]==i)\r
+ if (upper[i])\r
+ printf(" %d:%d", lower[i], i); /*2*/\r
+ else\r
+ printf(" %d", i); /*3*/\r
+ printf("\n");\r
+ return 0;\r
+}\r