]> pd.if.org Git - pdclib.old/blobdiff - functions/wctype/wctrans.c
PDCLIB-3 #resolve Implement towctrans/wctrans. Completes wctype.h
[pdclib.old] / functions / wctype / wctrans.c
diff --git a/functions/wctype/wctrans.c b/functions/wctype/wctrans.c
new file mode 100644 (file)
index 0000000..31f36be
--- /dev/null
@@ -0,0 +1,38 @@
+/* wctrans( const char * )\r
+\r
+   This file is part of the Public Domain C Library (PDCLib).\r
+   Permission is granted to use, modify, and / or redistribute at will.\r
+*/\r
+\r
+#include <wctype.h>\r
+#ifndef REGTEST\r
+#include <string.h>\r
+#include <_PDCLIB_locale.h>\r
+\r
+wctrans_t wctrans( const char * property )\r
+{\r
+    if(!property) {\r
+        return 0;\r
+    } else if(strcmp(property, "tolower") == 0) {\r
+        return _PDCLIB_WCTRANS_TOLOWER;\r
+    } else if(strcmp(property, "toupper") == 0) {\r
+        return _PDCLIB_WCTRANS_TOUPPER;\r
+    } else {\r
+        return 0;\r
+    }\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(wctrans("") == 0);\r
+    TESTCASE(wctrans("invalid") == 0);\r
+    TESTCASE(wctrans("toupper") != 0);\r
+    TESTCASE(wctrans("tolower") != 0);\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r