First phase of porting. pterm now compiles and runs under Linux+gtk.
[u/mdw/putty] / unicode.c
index 60ea85d..f8cd3b5 100644 (file)
--- a/unicode.c
+++ b/unicode.c
@@ -1,4 +1,6 @@
+#ifdef WINDOWS
 #include <windows.h>
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -8,8 +10,6 @@
 #include "putty.h"
 #include "misc.h"
 
-static void get_unitab(int codepage, wchar_t * unitab, int ftype);
-
 /* Character conversion arrays; they are usually taken from windows,
  * the xterm one has the four scanlines that have no unicode 2.0
  * equivalents mapped to their unicode 3.0 locations.
@@ -614,8 +614,7 @@ void lpage_send(int codepage, char *buf, int len, int interactive)
        widesize = len * 2;
     }
 
-    wclen =
-       MultiByteToWideChar(codepage, 0, buf, len, widebuffer, widesize);
+    wclen = mb_to_wc(codepage, 0, buf, len, widebuffer, widesize);
     luni_send(widebuffer, wclen, interactive);
 }
 
@@ -653,8 +652,8 @@ void luni_send(wchar_t * widebuf, int len, int interactive)
        }
     } else if (!uni_tbl) {
        int rv;
-       rv = WideCharToMultiByte(line_codepage, 0, widebuf, len,
-                                linebuffer, linesize, NULL, NULL);
+       rv = wc_to_mb(line_codepage, 0, widebuf, len,
+                     linebuffer, linesize, NULL, NULL);
        if (rv >= 0)
            p = linebuffer + rv;
        else
@@ -1218,7 +1217,7 @@ char *cp_enumerate(int index)
     return cp_list[index].name;
 }
 
-static void get_unitab(int codepage, wchar_t * unitab, int ftype)
+void get_unitab(int codepage, wchar_t * unitab, int ftype)
 {
     char tbuf[4];
     int i, max = 256, flg = MB_ERR_INVALID_CHARS;
@@ -1243,7 +1242,7 @@ static void get_unitab(int codepage, wchar_t * unitab, int ftype)
        for (i = 0; i < max; i++) {
            tbuf[0] = i;
 
-           if (MultiByteToWideChar(codepage, flg, tbuf, 1, unitab + i, 1)
+           if (mb_to_wc(codepage, flg, tbuf, 1, unitab + i, 1)
                != 1)
                unitab[i] = 0xFFFD;
        }