XEmacs 21.2.36 "Notos"
[chise/xemacs-chise.git.1] / src / syswindows.h
index e4389c7..0b505cb 100644 (file)
@@ -65,7 +65,15 @@ extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD);
 #define FONTENUMPROC FONTENUMEXPROC
 #define ntmTm ntmentm
 #elif defined (WIN32_LEAN_AND_MEAN)
+#ifdef HAVE_X_WINDOWS
+/* Christ almighty.  The problems you get when combining two large code bases,
+   neither with any respect for namespace purity. */
+#undef Status
+#endif
 #include <winspool.h>
+#ifdef HAVE_X_WINDOWS
+#define Status int
+#endif
 #include <mmsystem.h>
 #include <shellapi.h>
 #include <ddeml.h>
@@ -166,13 +174,119 @@ typedef NMHDR *LPNMHDR;
 
 /* Definitions for Mule under MS Windows */
 
-/* extern int mswindows_windows9x_p; */
-/* #define EIUNICODE_P (!mswindows_windows9x_p) */
-#define EIUNICODE_P 0
+#include <wchar.h>
+
+#ifdef CYGWIN
+
+/* All but wcscmp and wcslen left out of Cygwin headers -- but present
+   in /usr/include/mingw32/string.h! */
+wchar_t* wcscat (wchar_t*, const wchar_t*);
+wchar_t* wcschr (const wchar_t*, wchar_t);
+int    wcscoll (const wchar_t*, const wchar_t*);
+wchar_t* wcscpy (wchar_t*, const wchar_t*);
+size_t wcscspn (const wchar_t*, const wchar_t*);
+/* Note: No wcserror in CRTDLL. */
+wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t);
+int    wcsncmp(const wchar_t*, const wchar_t*, size_t);
+wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
+wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
+wchar_t* wcsrchr(const wchar_t*, wchar_t);
+size_t wcsspn(const wchar_t*, const wchar_t*);
+wchar_t* wcsstr(const wchar_t*, const wchar_t*);
+wchar_t* wcstok(wchar_t*, const wchar_t*);
+size_t wcsxfrm(wchar_t*, const wchar_t*, size_t);
+
+#endif /* CYGWIN */
+
+// extern int mswindows_windows9x_p;
+/* #define XEUNICODE_P (!mswindows_windows9x_p) */
+#define XEUNICODE_P 0
+
+#define XETCHAR_SIZE (XEUNICODE_P ? sizeof (WCHAR) : sizeof (CHAR))
+#define MAX_XETCHAR_SIZE sizeof (WCHAR)
+#define XETEXT1(arg) (XEUNICODE_P ? ((char *) (L##arg)) : (arg))
+/* We need to do this indirection in case ARG is also a manifest constant.
+   I don't really understand why. --ben */
+#define XETEXT(arg) XETEXT1(arg)
+#define XECOPY_TCHAR(ptr, ch) \
+  (XEUNICODE_P ? (* (LPWSTR) (ptr) = L##ch) : (* (LPSTR) (ptr) = (ch)))
+#define xetcslen(arg) (XEUNICODE_P ? wcslen ((wchar_t *) arg) : strlen (arg))
+#define xetcscmp(s1, s2) \
+  (XEUNICODE_P ? wcscmp ((wchar_t *) s1, (wchar_t *) s2) \
+   : strcmp (s1, s2))
+#define xetcscpy(s1, s2) \
+  (XEUNICODE_P ? (char *) wcscpy ((wchar_t *) s1, (wchar_t *) s2) \
+   : strcpy (s1, s2))
+#define xetcschr(s, ch) \
+  (XEUNICODE_P ? (char *) wcschr ((wchar_t *) s, (WCHAR) ch) \
+   : strchr (s, ch))
+#define xetcsrchr(s, ch) \
+  (XEUNICODE_P ? (char *) wcsrchr ((wchar_t *) s, (WCHAR) ch) \
+   : strrchr (s, ch))
+
+
+#define LOCAL_FILE_FORMAT_TO_TSTR(path, out)           \
+do {                                                   \
+  Bufbyte *lttff;                                      \
+                                                       \
+  LOCAL_TO_WIN32_FILE_FORMAT (path, lttff);            \
+  C_STRING_TO_EXTERNAL (lttff, out, Qmswindows_tstr);  \
+} while (0)
+
+Lisp_Object tstr_to_local_file_format (Extbyte *pathout);
+
+#ifdef CYGWIN
+#define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)                      \
+do {                                                                   \
+  Lisp_Object ltwff1 = (path);                                         \
+  int ltwff2 =                                                         \
+    cygwin_posix_to_win32_path_list_buf_size (XSTRING_DATA (ltwff1));  \
+  pathout = (Bufbyte *) alloca (ltwff2);                               \
+  cygwin_posix_to_win32_path_list (XSTRING_DATA (ltwff1), pathout);    \
+} while (0)
+#else
+#define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)      \
+do {                                                   \
+  (pathout) = XSTRING_DATA (path);                     \
+} while (0)
+#endif
+
+#ifdef CYGWIN
+#define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)      \
+do {                                                   \
+  Bufbyte *wtlff1 = (path);                            \
+  int wtlff2 =                                         \
+    cygwin_win32_to_posix_path_list_buf_size (wtlff1); \
+  Bufbyte *wtlff3 = (Bufbyte *) alloca (wtlff2);       \
+  cygwin_win32_to_posix_path_list (wtlff1, wtlff3);    \
+  (pathout) = build_string (wtlff3);                   \
+} while (0)
+#else
+#define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)      \
+do {                                                   \
+  (pathout) = build_string (path);                     \
+} while (0)
+#endif
+
+extern BOOL (WINAPI *xSwitchToThread) (VOID);
+
+extern HKL (WINAPI *xGetKeyboardLayout) (DWORD);
+extern BOOL (WINAPI *xSetMenuDefaultItem) (HMENU, UINT, UINT);
+extern BOOL (WINAPI *xInsertMenuItemA) (HMENU, UINT, BOOL, LPCMENUITEMINFOA);
+extern BOOL (WINAPI *xInsertMenuItemW) (HMENU, UINT, BOOL, LPCMENUITEMINFOW);
+extern HANDLE (WINAPI *xLoadImageA) (HINSTANCE, LPCSTR, UINT, int, int, UINT);
+extern HANDLE (WINAPI *xLoadImageW) (HINSTANCE, LPCWSTR, UINT, int, int, UINT);
+extern ATOM (WINAPI *xRegisterClassExA) (CONST WNDCLASSEXA *);
+extern ATOM (WINAPI *xRegisterClassExW) (CONST WNDCLASSEXW *);
+
+extern int (WINAPI *xEnumFontFamiliesExA) (HDC, LPLOGFONTA, FONTENUMPROCA,
+                                          LPARAM, DWORD);
+extern int (WINAPI *xEnumFontFamiliesExW) (HDC, LPLOGFONTW, FONTENUMPROCW,
+                                          LPARAM, DWORD);
 
-#define EITCHAR_SIZE (EIUNICODE_P ? sizeof (WCHAR) : sizeof (CHAR))
-#define EITEXT(arg) (EIUNICODE_P ? L##arg : (arg))
-#define EICOPY_TCHAR(ptr, ch) \
-  (EIUNICODE_P ? (* (LPWSTR) (ptr) = L##ch) : (* (LPSTR) (ptr) = (ch)))
+extern DWORD (WINAPI *xSHGetFileInfoA) (LPCSTR, DWORD, SHFILEINFOA FAR *, UINT,
+                                       UINT);
+extern DWORD (WINAPI *xSHGetFileInfoW) (LPCWSTR, DWORD, SHFILEINFOW FAR *,
+                                       UINT, UINT);
 
 #endif /* INCLUDED_syswindows_h_ */