Mercurial > hg > xemacs-beta
annotate src/syswindows.h @ 4824:c12b646d84ee
changes to get things to compile under latest cygwin
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 24 Dec 2009 19:45:23 -0600 |
parents | 112f6ed44299 |
children | 11daf37dae4d |
rev | line source |
---|---|
442 | 1 /* Copyright (C) 2000 Free Software Foundation, Inc. |
2367 | 2 Copyright (C) 2000, 2001, 2002, 2004 Ben Wing. |
442 | 3 |
4 This file is part of XEmacs. | |
5 | |
6 XEmacs is free software; you can redistribute it and/or modify it | |
7 under the terms of the GNU General Public License as published by the | |
8 Free Software Foundation; either version 2, or (at your option) any | |
9 later version. | |
10 | |
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with XEmacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 Boston, MA 02111-1307, USA. */ | |
20 | |
21 /* Synched up with: Not in FSF. */ | |
22 | |
23 /* Authorship: | |
24 | |
771 | 25 Current primary author: Ben Wing <ben@xemacs.org> |
26 | |
442 | 27 Created May 2000 by Andy Piper. |
771 | 28 Windows-Mule stuff added by Ben Wing, 2000-2001. |
29 September 2001 Ben Wing reorganized and included nt.h and ntheap.h into | |
30 this file; comments in those files say: | |
31 * Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> | |
32 * Sync'ed with Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> | |
33 (Note: Sync messages from Marc Paquette may indicate | |
34 incomplete synching, so beware.) | |
35 (in ntheap.h only) Geoff Voelker (voelker@cs.washington.edu) 7-29-94 | |
36 | |
442 | 37 */ |
38 | |
39 #ifndef INCLUDED_syswindows_h_ | |
40 #define INCLUDED_syswindows_h_ | |
41 | |
2367 | 42 /* See win32.c for info about the different Windows files in XEmacs. */ |
442 | 43 |
771 | 44 /* ------------------------- Basic includes ------------------------- */ |
442 | 45 |
46 #ifndef WIN32_LEAN_AND_MEAN | |
47 #define WIN32_LEAN_AND_MEAN | |
48 #endif | |
49 | |
665 | 50 #if defined (CYGWIN) || defined (MINGW) |
771 | 51 # define CYGWIN_HEADERS |
52 # ifndef _WIN32_IE | |
53 # define _WIN32_IE 0x0400 | |
54 # endif | |
665 | 55 |
1743 | 56 BEGIN_C_DECLS |
665 | 57 |
4824
c12b646d84ee
changes to get things to compile under latest cygwin
Ben Wing <ben@xemacs.org>
parents:
4538
diff
changeset
|
58 #if 0 /* breaks the build, as of GCC 3.4.4 or earlier */ |
665 | 59 /* Fucking GCC complains about "no previous prototype" for inline |
60 functions. DUH! See DECLARE_INLINE_HEADER. */ | |
61 extern __inline void *GetCurrentFiber (void); | |
62 extern __inline void *GetFiberData (void); | |
4824
c12b646d84ee
changes to get things to compile under latest cygwin
Ben Wing <ben@xemacs.org>
parents:
4538
diff
changeset
|
63 #endif |
665 | 64 |
1743 | 65 END_C_DECLS |
665 | 66 |
67 #endif | |
68 | |
771 | 69 /* Defines for COM so it's usable in both C and C++. XECOMCALLn() calls a |
70 method with the specified number of parameters. XECOMID() surrounds a | |
71 class or interface name when passed to CoCreateInstance, a | |
72 QueryInterface method, or the like. */ | |
73 #ifdef __cplusplus | |
74 #define XECOMCALL0(cl, meth) ((cl)->meth ()) | |
75 #define XECOMCALL1(cl, meth, a1) ((cl)->meth (a1)) | |
76 #define XECOMCALL2(cl, meth, a1, a2) ((cl)->meth (a1, a2)) | |
77 #define XECOMCALL3(cl, meth, a1, a2, a3) ((cl)->meth (a1, a2, a3)) | |
78 #define XECOMCALL4(cl, meth, a1, a2, a3, a4) ((cl)->meth (a1, a2, a3, a4)) | |
79 #define XECOMID(id) (id) | |
80 #else | |
81 #define XECOMCALL0(cl, meth) ((cl)->lpVtbl->meth (cl)) | |
82 #define XECOMCALL1(cl, meth, a1) ((cl)->lpVtbl->meth (cl, a1)) | |
83 #define XECOMCALL2(cl, meth, a1, a2) ((cl)->lpVtbl->meth (cl, a1, a2)) | |
84 #define XECOMCALL3(cl, meth, a1, a2, a3) ((cl)->lpVtbl->meth (cl, a1, a2, a3)) | |
85 #define XECOMCALL4(cl, meth, a1, a2, a3, a4) \ | |
86 ((cl)->lpVtbl->meth (cl, a1, a2, a3, a4)) | |
87 #define XECOMID(id) (&(id)) | |
88 #endif | |
89 | |
90 #define OEMRESOURCE /* Define OCR_ and friend constants */ | |
442 | 91 #include <windows.h> |
92 | |
3728 | 93 #include <aclapi.h> |
94 | |
558 | 95 #if defined (WIN32_LEAN_AND_MEAN) |
96 # ifdef HAVE_X_WINDOWS | |
442 | 97 /* Christ almighty. The problems you get when combining two large code bases, |
98 neither with any respect for namespace purity. */ | |
558 | 99 # undef Status |
100 # endif | |
101 # include <winspool.h> | |
102 # ifdef HAVE_X_WINDOWS | |
103 # define Status int | |
104 # endif | |
105 # include <mmsystem.h> | |
673 | 106 # include <shlobj.h> |
558 | 107 # include <shellapi.h> |
108 # include <ddeml.h> | |
442 | 109 #endif |
110 | |
546 | 111 #include <lmaccess.h> /* next three for NetUserEnum and friends */ |
531 | 112 #include <lmapibuf.h> |
113 #include <lmerr.h> | |
546 | 114 #include <lmcons.h> /* for UNLEN and possibly other constants */ |
531 | 115 |
771 | 116 #include <cderr.h> |
117 #include <commdlg.h> | |
118 | |
119 #ifdef NEED_MSWINDOWS_COMMCTRL | |
120 #include <commctrl.h> | |
442 | 121 #endif |
771 | 122 #ifdef NEED_MSWINDOWS_OBJBASE |
123 #include <objbase.h> | |
442 | 124 #endif |
771 | 125 #ifdef NEED_MSWINDOWS_SHLOBJ |
126 #include <shlobj.h> | |
442 | 127 #endif |
128 | |
771 | 129 #include <zmouse.h> /* WHEEL_PAGESCROLL under Cygwin */ |
130 | |
131 #include <wchar.h> | |
442 | 132 |
771 | 133 /* ------------------------- Cygwin header brokenness ---------------------- */ |
134 | |
135 #ifdef CYGWIN_HEADERS | |
136 | |
1683 | 137 #include <cygwin/stat.h> /* for struct stat */ |
1304 | 138 #include <w32api.h> /* for version info */ |
139 | |
1683 | 140 /* Test for a specific version of w32api */ |
141 #define W32API_VER(major,minor) (((major) << 16) + (minor)) | |
142 #define W32API_INSTALLED_VER \ | |
143 W32API_VER (__W32API_MAJOR_VERSION, __W32API_MINOR_VERSION) | |
1304 | 144 |
771 | 145 /* Various brokennesses in various versions of Cygwin */ |
673 | 146 |
442 | 147 /* windows.h defines. */ |
148 #ifndef SPI_GETWHEELSCROLLLINES | |
149 #define SPI_GETWHEELSCROLLLINES 104 | |
150 #endif | |
771 | 151 |
152 /* commctrl.h defines. */ | |
153 #ifndef TB_SETIMAGELIST | |
154 #define TB_SETIMAGELIST (WM_USER + 48) | |
442 | 155 #endif |
771 | 156 #ifndef TB_GETIMAGELIST |
157 #define TB_GETIMAGELIST (WM_USER + 49) | |
158 #endif | |
159 #ifndef TB_SETDISABLEDIMAGELIST | |
160 #define TB_SETDISABLEDIMAGELIST (WM_USER + 54) | |
161 #endif | |
162 #ifndef TB_GETDISABLEDIMAGELIST | |
163 #define TB_GETDISABLEDIMAGELIST (WM_USER + 55) | |
442 | 164 #endif |
771 | 165 #ifndef TB_SETPADDING |
166 #define TB_SETPADDING (WM_USER + 87) | |
167 #endif | |
168 #ifndef TB_GETBUTTONINFOA | |
169 #define TB_GETBUTTONINFOA (WM_USER + 65) | |
170 #endif | |
171 #ifndef TB_GETBUTTONINFOW | |
172 #define TB_GETBUTTONINFOW (WM_USER + 63) | |
442 | 173 #endif |
771 | 174 #ifndef TB_SETBUTTONINFOA |
175 #define TB_SETBUTTONINFOA (WM_USER + 66) | |
176 #endif | |
177 #ifndef TB_SETBUTTONINFOW | |
178 #define TB_SETBUTTONINFOW (WM_USER + 64) | |
179 #endif | |
180 #ifndef TB_INSERTBUTTONA | |
181 #define TB_INSERTBUTTONA (WM_USER + 21) | |
442 | 182 #endif |
771 | 183 #ifndef TB_INSERTBUTTONW |
184 #define TB_INSERTBUTTONW (WM_USER + 67) | |
185 #endif | |
186 #ifndef TB_ADDBUTTONSA | |
187 #define TB_ADDBUTTONSA (WM_USER + 20) | |
188 #endif | |
189 #ifndef TB_ADDBUTTONSW | |
190 #define TB_ADDBUTTONSW (WM_USER + 68) | |
442 | 191 #endif |
771 | 192 #ifndef LVM_SETBKIMAGEA |
193 #define LVM_SETBKIMAGEA (LVM_FIRST + 68) | |
194 #endif | |
195 #ifndef LVM_SETBKIMAGEW | |
196 #define LVM_SETBKIMAGEW (LVM_FIRST + 138) | |
197 #endif | |
198 #ifndef LVM_GETBKIMAGEA | |
199 #define LVM_GETBKIMAGEA (LVM_FIRST + 69) | |
442 | 200 #endif |
771 | 201 #ifndef LVM_GETBKIMAGEW |
202 #define LVM_GETBKIMAGEW (LVM_FIRST + 139) | |
203 #endif | |
204 #ifndef WC_COMBOBOXEXW | |
205 #define WC_COMBOBOXEXW L"ComboBoxEx32" | |
206 #endif | |
207 #ifndef CBEM_INSERTITEMA | |
208 #define CBEM_INSERTITEMA (WM_USER + 1) | |
442 | 209 #endif |
771 | 210 #ifndef CBEM_INSERTITEMW |
211 #define CBEM_INSERTITEMW (WM_USER + 11) | |
442 | 212 #endif |
771 | 213 #ifndef CBEM_SETITEMA |
214 #define CBEM_SETITEMA (WM_USER + 5) | |
215 #endif | |
216 #ifndef CBEM_SETITEMW | |
217 #define CBEM_SETITEMW (WM_USER + 12) | |
442 | 218 #endif |
771 | 219 #ifndef CBEM_GETITEMA |
220 #define CBEM_GETITEMA (WM_USER + 4) | |
221 #endif | |
222 #ifndef CBEM_GETITEMW | |
223 #define CBEM_GETITEMW (WM_USER + 13) | |
442 | 224 #endif |
771 | 225 #ifndef HDN_GETDISPINFOA |
226 #define HDN_GETDISPINFOA (HDN_FIRST - 9) | |
227 #endif | |
228 #ifndef HDN_GETDISPINFOW | |
229 #define HDN_GETDISPINFOW (HDN_FIRST - 29) | |
230 #endif | |
231 #ifndef TBN_GETDISPINFOA | |
232 #define TBN_GETDISPINFOA (TBN_FIRST - 16) | |
442 | 233 #endif |
771 | 234 #ifndef TBN_GETDISPINFOW |
235 #define TBN_GETDISPINFOW (TBN_FIRST - 17) | |
236 #endif | |
237 #ifndef TBN_GETINFOTIPA | |
238 #define TBN_GETINFOTIPA (TBN_FIRST - 18) | |
442 | 239 #endif |
771 | 240 #ifndef TBN_GETINFOTIPW |
241 #define TBN_GETINFOTIPW (TBN_FIRST - 19) | |
242 #endif | |
243 #ifndef TTN_GETDISPINFOA | |
244 #define TTN_GETDISPINFOA (TTN_FIRST - 0) | |
245 #endif | |
246 #ifndef TTN_GETDISPINFOW | |
247 #define TTN_GETDISPINFOW (TTN_FIRST - 10) | |
442 | 248 #endif |
771 | 249 |
250 #if (_WIN32_IE >= 0x0400) | |
251 | |
252 #ifndef LVN_GETINFOTIPA | |
253 #define LVN_GETINFOTIPA (LVN_FIRST - 57) | |
254 #endif | |
255 #ifndef LVN_GETINFOTIPW | |
256 #define LVN_GETINFOTIPW (LVN_FIRST - 58) | |
442 | 257 #endif |
771 | 258 #ifndef TVN_GETINFOTIPA |
259 #define TVN_GETINFOTIPA (TVN_FIRST - 13) | |
260 #endif | |
261 #ifndef TVN_GETINFOTIPW | |
262 #define TVN_GETINFOTIPW (TVN_FIRST - 14) | |
263 #endif | |
264 #ifndef CBEN_GETDISPINFOA | |
265 #define CBEN_GETDISPINFOA (CBEN_FIRST - 0) | |
442 | 266 #endif |
771 | 267 #ifndef CBEN_GETDISPINFOW |
268 #define CBEN_GETDISPINFOW (CBEN_FIRST - 7) | |
269 #endif | |
270 #ifndef CBEN_DRAGBEGINA | |
271 #define CBEN_DRAGBEGINA (CBEN_FIRST - 8) | |
272 #endif | |
273 #ifndef CBEN_DRAGBEGINW | |
274 #define CBEN_DRAGBEGINW (CBEN_FIRST - 9) | |
442 | 275 #endif |
771 | 276 |
277 #endif /* (_WIN32_IE >= 0x0400) */ | |
278 | |
279 #ifndef CBEN_ENDEDITA | |
280 #define CBEN_ENDEDITA (CBEN_FIRST - 5) | |
442 | 281 #endif |
771 | 282 #ifndef CBEN_ENDEDITW |
283 #define CBEN_ENDEDITW (CBEN_FIRST - 6) | |
284 #endif | |
285 | |
286 #ifndef CBEMAXSTRLEN | |
287 #define CBEMAXSTRLEN 260 | |
442 | 288 #endif |
289 | |
1111 | 290 #ifndef NMCBEENDEDIT |
291 | |
292 typedef struct | |
293 { | |
294 NMHDR hdr; | |
295 BOOL fChanged; | |
296 int iNewSelection; | |
297 WCHAR szText[CBEMAXSTRLEN]; | |
298 int iWhy; | |
771 | 299 } NMCBEENDEDITW, *LPNMCBEENDEDITW, *PNMCBEENDEDITW; |
300 | |
1111 | 301 typedef struct |
302 { | |
303 NMHDR hdr; | |
304 BOOL fChanged; | |
305 int iNewSelection; | |
306 char szText[CBEMAXSTRLEN]; | |
307 int iWhy; | |
771 | 308 } NMCBEENDEDITA, *LPNMCBEENDEDITA,*PNMCBEENDEDITA; |
309 | |
1111 | 310 #endif /* not NMCBEENDEDIT */ |
311 | |
771 | 312 #if (_WIN32_IE >= 0x0400) |
313 | |
1111 | 314 #ifndef NMCBEDRAGBEGIN |
315 | |
316 typedef struct | |
317 { | |
318 NMHDR hdr; | |
319 int iItemid; | |
320 WCHAR szText[CBEMAXSTRLEN]; | |
321 } NMCBEDRAGBEGINW, *LPNMCBEDRAGBEGINW, *PNMCBEDRAGBEGINW; | |
771 | 322 |
1111 | 323 typedef struct |
324 { | |
325 NMHDR hdr; | |
326 int iItemid; | |
327 char szText[CBEMAXSTRLEN]; | |
328 } NMCBEDRAGBEGINA, *LPNMCBEDRAGBEGINA, *PNMCBEDRAGBEGINA; | |
329 | |
330 #endif /* not NMCBEDRAGBEGIN */ | |
331 | |
771 | 332 typedef struct tagNMDATETIMEFORMATA |
333 { | |
1111 | 334 NMHDR nmhdr; |
335 LPCSTR pszFormat; | |
336 SYSTEMTIME st; | |
337 LPCSTR pszDisplay; | |
338 CHAR szDisplay[64]; | |
771 | 339 } NMDATETIMEFORMATA, FAR * LPNMDATETIMEFORMATA; |
340 | |
341 typedef struct tagNMDATETIMEFORMATW | |
342 { | |
1111 | 343 NMHDR nmhdr; |
344 LPCWSTR pszFormat; | |
345 SYSTEMTIME st; | |
346 LPCWSTR pszDisplay; | |
347 WCHAR szDisplay[64]; | |
771 | 348 } NMDATETIMEFORMATW, FAR * LPNMDATETIMEFORMATW; |
349 | |
1683 | 350 #if W32API_INSTALLED_VER < W32API_VER(2,2) |
1304 | 351 |
1111 | 352 typedef struct tagNMTTDISPIFNOA |
353 { | |
354 NMHDR hdr; | |
355 LPSTR lpszText; | |
356 char szText[80]; | |
357 HINSTANCE hinst; | |
358 UINT uFlags; | |
771 | 359 #if (_WIN32_IE >= 0x0300) |
1111 | 360 LPARAM lParam; |
771 | 361 #endif |
362 } NMTTDISPINFOA, FAR *LPNMTTDISPINFOA; | |
363 | |
1111 | 364 typedef struct tagNMTTDISPINFOW |
365 { | |
366 NMHDR hdr; | |
367 LPWSTR lpszText; | |
368 WCHAR szText[80]; | |
369 HINSTANCE hinst; | |
370 UINT uFlags; | |
771 | 371 #if (_WIN32_IE >= 0x0300) |
1111 | 372 LPARAM lParam; |
771 | 373 #endif |
374 } NMTTDISPINFOW, FAR *LPNMTTDISPINFOW; | |
375 | |
1683 | 376 #endif /* W32API_INSTALLED_VER < W32API_VER(2,2) */ |
1304 | 377 |
771 | 378 #endif /* (_WIN32_IE >= 0x0400) */ |
442 | 379 |
771 | 380 /* shlobj.h defines */ |
381 #ifndef BFFM_VALIDATEFAILEDA | |
382 #define BFFM_VALIDATEFAILEDA 3 | |
383 #endif | |
384 #ifndef BFFM_VALIDATEFAILEDW | |
385 #define BFFM_VALIDATEFAILEDW 4 | |
386 #endif | |
387 #ifndef BFFM_SETSELECTIONA | |
388 #define BFFM_SETSELECTIONA (WM_USER + 102) | |
389 #endif | |
390 #ifndef BFFM_SETSELECTIONW | |
391 #define BFFM_SETSELECTIONW (WM_USER + 103) | |
392 #endif | |
393 #ifndef BFFM_SETSTATUSTEXTA | |
394 #define BFFM_SETSTATUSTEXTA (WM_USER + 100) | |
395 #endif | |
396 #ifndef BFFM_SETSTATUSTEXTW | |
397 #define BFFM_SETSTATUSTEXTW (WM_USER + 104) | |
398 #endif | |
399 #ifndef SHARD_PATHA | |
400 #define SHARD_PATHA 2 | |
401 #endif | |
402 #ifndef SHARD_PATHW | |
403 #define SHARD_PATHW 3 | |
404 #endif | |
405 #ifndef SHCNF_PATHA | |
406 #define SHCNF_PATHA 1 | |
407 #endif | |
408 #ifndef SHCNF_PATHW | |
409 #define SHCNF_PATHW 5 | |
410 #endif | |
411 #ifndef SHCNF_PRINTERA | |
412 #define SHCNF_PRINTERA 2 | |
413 #endif | |
414 #ifndef SHCNF_PRINTERW | |
415 #define SHCNF_PRINTERW 6 | |
416 #endif | |
417 #ifndef BFFM_VALIDATEFAILED | |
418 #ifdef UNICODE | |
419 #define BFFM_VALIDATEFAILED BFFM_VALIDATEFAILEDW | |
420 #else | |
421 #define BFFM_VALIDATEFAILED BFFM_VALIDATEFAILEDA | |
422 #endif | |
819 | 423 #endif |
442 | 424 |
800 | 425 /* winnls.h defines */ |
819 | 426 #ifndef MAC_CHARSET |
427 #define MAC_CHARSET 77 | |
428 #endif | |
800 | 429 #ifndef LOCALE_RETURN_NUMBER |
819 | 430 #define LOCALE_RETURN_NUMBER 0x20000000 |
800 | 431 #endif |
432 | |
771 | 433 /* OEM resources */ |
434 #ifndef OCR_ICOCUR | |
435 #define OCR_ICOCUR 32647 | |
436 #define OIC_SAMPLE 32512 | |
437 #define OIC_HAND 32513 | |
438 #define OIC_QUES 32514 | |
439 #define OIC_BANG 32515 | |
440 #define OIC_NOTE 32516 | |
441 #define OIC_WINLOGO 32517 | |
442 #endif | |
443 | |
444 /* More Cygwin stupidity: Current w32api's winuser.h has IME message | |
445 constants and they conflict with imm.h. (NOTE: Currently fixed, but | |
446 I'm sure the problems were present post 1.0.) */ | |
447 #undef WM_IME_STARTCOMPOSITION | |
448 #undef WM_IME_ENDCOMPOSITION | |
449 #undef WM_IME_COMPOSITION | |
450 #undef WM_IME_KEYLAST | |
451 #undef WM_IME_SETCONTEXT | |
452 #undef WM_IME_NOTIFY | |
453 #undef WM_IME_CONTROL | |
454 #undef WM_IME_COMPOSITIONFULL | |
455 #undef WM_IME_SELECT | |
456 #undef WM_IME_CHAR | |
457 #undef WM_IME_KEYDOWN | |
458 #undef WM_IME_KEYUP | |
459 | |
460 #include <imm.h> | |
461 | |
1683 | 462 #if W32API_INSTALLED_VER < W32API_VER(2,4) |
771 | 463 typedef struct _SHQUERYRBINFO |
464 { | |
465 DWORD cbSize; | |
466 __int64 i64Size; | |
467 __int64 i64NumItems; | |
468 } SHQUERYRBINFO, *LPSHQUERYRBINFO; | |
1683 | 469 #endif |
771 | 470 |
471 typedef LPCDLGTEMPLATE LPCDLGTEMPLATEW; | |
472 typedef LPCDLGTEMPLATE LPCDLGTEMPLATEA; | |
473 | |
1685 | 474 #else /* !CYGWIN_HEADERS */ |
475 #define W32API_VER(major,minor) 0 | |
476 #define W32API_INSTALLED_VER 0 | |
771 | 477 #endif /* CYGWIN_HEADERS */ |
478 | |
479 /* Not in VC 6 */ | |
480 #ifndef BIF_NEWDIALOGSTYLE | |
481 #define BIF_NEWDIALOGSTYLE 64 | |
482 #endif | |
442 | 483 |
4538 | 484 #if defined (CYGWIN) && (CYGWIN_VERSION_DLL_COMBINED < 190) |
442 | 485 |
486 /* All but wcscmp and wcslen left out of Cygwin headers -- but present | |
771 | 487 in /usr/include/mingw/string.h! */ |
442 | 488 wchar_t* wcscat (wchar_t*, const wchar_t*); |
489 wchar_t* wcschr (const wchar_t*, wchar_t); | |
490 int wcscoll (const wchar_t*, const wchar_t*); | |
491 wchar_t* wcscpy (wchar_t*, const wchar_t*); | |
771 | 492 wchar_t* wcsdup (const wchar_t*); |
442 | 493 size_t wcscspn (const wchar_t*, const wchar_t*); |
494 /* Note: No wcserror in CRTDLL. */ | |
495 wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t); | |
771 | 496 int wcsncmp (const wchar_t*, const wchar_t*, size_t); |
497 wchar_t* wcsncpy (wchar_t*, const wchar_t*, size_t); | |
498 wchar_t* wcspbrk (const wchar_t*, const wchar_t*); | |
499 wchar_t* wcsrchr (const wchar_t*, wchar_t); | |
500 size_t wcsspn (const wchar_t*, const wchar_t*); | |
501 wchar_t* wcsstr (const wchar_t*, const wchar_t*); | |
502 wchar_t* wcstok (wchar_t*, const wchar_t*); | |
503 size_t wcsxfrm (wchar_t*, const wchar_t*, size_t); | |
442 | 504 |
505 #endif /* CYGWIN */ | |
506 | |
771 | 507 /* ------------------------- Unicode encapsulation ------------------------- */ |
508 | |
2367 | 509 /* See intl-win32.c for more information about Unicode-encapsulation */ |
771 | 510 |
800 | 511 #define ERROR_WHEN_NONINTERCEPTED_FUNS_USED |
512 | |
771 | 513 #include "intl-auto-encap-win32.h" |
514 | |
515 /* would be encapsulatable but for parsing problems */ | |
800 | 516 |
517 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
518 #undef DefWindowProc | |
519 #define DefWindowProc error use qxeDefWindowProc or DefWindowProcA/DefWindowProcW | |
520 #endif | |
771 | 521 LRESULT qxeDefWindowProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); |
800 | 522 |
523 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
524 #undef CallWindowProc | |
525 #define CallWindowProc error use qxeCallWindowProc or CallWindowProcA/CallWindowProcW | |
526 #endif | |
771 | 527 LRESULT qxeCallWindowProc (WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, |
528 WPARAM wParam, LPARAM lParam); | |
800 | 529 |
530 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
531 #undef DefDlgProc | |
532 #define DefDlgProc error use qxeDefDlgProc or DefDlgProcA/DefDlgProcW | |
533 #endif | |
771 | 534 LRESULT qxeDefDlgProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); |
800 | 535 |
536 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
537 #undef SetWindowsHook | |
538 #define SetWindowsHook error use qxeSetWindowsHook or SetWindowsHookA/SetWindowsHookW | |
539 #endif | |
771 | 540 HHOOK qxeSetWindowsHook (int nFilterType, HOOKPROC pfnFilterProc); |
800 | 541 |
542 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
543 #undef DefMDIChildProc | |
544 #define DefMDIChildProc error use qxeDefMDIChildProc or DefMDIChildProcA/DefMDIChildProcW | |
545 #endif | |
771 | 546 LRESULT qxeDefMDIChildProc (HWND hWnd, UINT uMsg, WPARAM wParam, |
547 LPARAM lParam); | |
548 | |
800 | 549 #undef GetEnvironmentStrings |
550 #undef GetEnvironmentStringsA | |
551 #define GetEnvironmentStringsA GetEnvironmentStrings | |
552 Extbyte * qxeGetEnvironmentStrings (void); | |
553 | |
771 | 554 /* would be encapsulatable but for Cygwin problems */ |
800 | 555 |
556 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
1111 | 557 #undef DdeCreateStringHandle |
558 #define DdeCreateStringHandle error use qxeDdeCreateStringHandle or DdeCreateStringHandleA/DdeCreateStringHandleW | |
559 #endif | |
560 HSZ qxeDdeCreateStringHandle (DWORD idInst, const Extbyte * psz, int iCodePage); | |
561 | |
562 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
800 | 563 #undef RegConnectRegistry |
564 #define RegConnectRegistry error use qxeRegConnectRegistry or RegConnectRegistryA/RegConnectRegistryW | |
565 #endif | |
771 | 566 LONG qxeRegConnectRegistry (const Extbyte * lpMachineName, HKEY hKey, PHKEY phkResult); |
800 | 567 |
568 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
569 #undef ExtractIconEx | |
570 #define ExtractIconEx error use qxeExtractIconEx or ExtractIconExA/ExtractIconExW | |
571 #endif | |
771 | 572 UINT qxeExtractIconEx (const Extbyte * lpszFile, int nIconIndex, HICON FAR * phiconLarge, HICON FAR * phiconSmall, UINT nIcons); |
800 | 573 |
574 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
575 #undef GetICMProfile | |
576 #define GetICMProfile error use qxeGetICMProfile or GetICMProfileA/GetICMProfileW | |
577 #endif | |
771 | 578 BOOL qxeGetICMProfile (HDC arg1, LPDWORD arg2, Extbyte * arg3); |
800 | 579 |
580 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
581 #undef UpdateICMRegKey | |
582 #define UpdateICMRegKey error use qxeUpdateICMRegKey or UpdateICMRegKeyA/UpdateICMRegKeyW | |
583 #endif | |
771 | 584 BOOL qxeUpdateICMRegKey (DWORD arg1, Extbyte * arg2, Extbyte * arg3, UINT arg4); |
585 | |
2500 | 586 /* would be encapsulatable but for header changes in different versions of VC++ */ |
587 | |
588 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
589 #undef EnumResourceTypes | |
590 #define EnumResourceTypes error_use_qxeEnumResourceTypes_or_EnumResourceTypesA_and_EnumResourceTypesW | |
591 #endif | |
592 #if MSC_VERSION >= 1300 | |
593 BOOL qxeEnumResourceTypes (HMODULE hModule, ENUMRESTYPEPROCW lpEnumFunc, LONG lParam); | |
594 #else | |
595 BOOL qxeEnumResourceTypes (HMODULE hModule, ENUMRESTYPEPROC lpEnumFunc, LONG lParam); | |
596 #endif | |
597 | |
598 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
599 #undef EnumResourceNames | |
600 #define EnumResourceNames error_use_qxeEnumResourceNames_or_EnumResourceNamesA_and_EnumResourceNamesW | |
601 #endif | |
602 #if MSC_VERSION >= 1300 | |
603 BOOL qxeEnumResourceNames (HMODULE hModule, const Extbyte * lpType, ENUMRESNAMEPROCW lpEnumFunc, LONG lParam); | |
604 #else | |
605 BOOL qxeEnumResourceNames (HMODULE hModule, const Extbyte * lpType, ENUMRESNAMEPROC lpEnumFunc, LONG lParam); | |
606 #endif | |
607 | |
608 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
609 #undef EnumResourceLanguages | |
610 #define EnumResourceLanguages error_use_qxeEnumResourceLanguages_or_EnumResourceLanguagesA_and_EnumResourceLanguagesW | |
611 #endif | |
612 #if MSC_VERSION >= 1300 | |
613 BOOL qxeEnumResourceLanguages (HMODULE hModule, const Extbyte * lpType, const Extbyte * lpName, ENUMRESLANGPROCW lpEnumFunc, LONG lParam); | |
614 #else | |
615 BOOL qxeEnumResourceLanguages (HMODULE hModule, const Extbyte * lpType, const Extbyte * lpName, ENUMRESLANGPROC lpEnumFunc, LONG lParam); | |
616 #endif | |
617 | |
771 | 618 /* files */ |
800 | 619 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED |
620 #undef FindFirstFile | |
621 #define FindFirstFile error use qxeFindFirstFile or FindFirstFileA/FindFirstFileW | |
622 #endif | |
771 | 623 HANDLE qxeFindFirstFile (const Extbyte *lpFileName, |
624 WIN32_FIND_DATAW *lpFindFileData); | |
800 | 625 |
626 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
627 #undef FindNextFile | |
628 #define FindNextFile error use qxeFindNextFile or FindNextFileA/FindNextFileW | |
629 #endif | |
771 | 630 BOOL qxeFindNextFile (HANDLE hFindFile, WIN32_FIND_DATAW *lpFindFileData); |
631 | |
632 /* shell */ | |
800 | 633 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED |
634 #undef SHGetFileInfo | |
635 #define SHGetFileInfo error use qxeSHGetFileInfo or SHGetFileInfoA/SHGetFileInfoW | |
636 #endif | |
771 | 637 DWORD qxeSHGetFileInfo (const Extbyte *pszPath, DWORD dwFileAttributes, |
638 SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags); | |
800 | 639 |
640 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
641 #undef SHBrowseForFolder | |
642 #define SHBrowseForFolder error use qxeSHBrowseForFolder or SHBrowseForFolderA/SHBrowseForFolderW | |
643 #endif | |
771 | 644 LPITEMIDLIST qxeSHBrowseForFolder (LPBROWSEINFOW lpbi); |
800 | 645 |
646 /* Not Unicode-split */ | |
771 | 647 VOID qxeSHAddToRecentDocs (UINT uFlags, LPCVOID pv); |
800 | 648 |
649 /* Not Unicode-split */ | |
771 | 650 VOID qxeSHChangeNotify (LONG wEventId, UINT uFlags, LPCVOID dwItem1, |
651 LPCVOID dwItem2); | |
800 | 652 |
653 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
654 #undef SHGetDataFromIDList | |
655 #define SHGetDataFromIDList error use qxeSHGetDataFromIDList or SHGetDataFromIDListA/SHGetDataFromIDListW | |
656 #endif | |
771 | 657 HRESULT qxeSHGetDataFromIDList (IShellFolder *psf, LPCITEMIDLIST pidl, |
658 int nFormat, PVOID pv, int cb); | |
659 | |
660 /* devmode */ | |
800 | 661 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED |
662 #undef CreateDC | |
663 #define CreateDC error use qxeCreateDC or CreateDCA/CreateDCW | |
664 #endif | |
771 | 665 HDC qxeCreateDC (const Extbyte *lpszDriver, const Extbyte *lpszDevice, |
666 const Extbyte *lpszOutput, CONST DEVMODEW *lpInitData); | |
800 | 667 |
668 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
669 #undef ResetDC | |
670 #define ResetDC error use qxeResetDC or ResetDCA/ResetDCW | |
671 #endif | |
771 | 672 HDC qxeResetDC (HDC hdc, CONST DEVMODEW *lpInitData); |
800 | 673 |
674 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
675 #undef OpenPrinter | |
676 #define OpenPrinter error use qxeOpenPrinter or OpenPrinterA/OpenPrinterW | |
677 #endif | |
771 | 678 DWORD qxeOpenPrinter (Extbyte *pPrinterName, LPHANDLE phPrinter, |
679 LPPRINTER_DEFAULTSW pDefaultconst); | |
800 | 680 |
681 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
682 #undef DocumentProperties | |
683 #define DocumentProperties error use qxeDocumentProperties or DocumentPropertiesA/DocumentPropertiesW | |
684 #endif | |
771 | 685 LONG qxeDocumentProperties (HWND hWnd, HANDLE hPrinter, Extbyte *pDeviceName, |
686 DEVMODEW *pDevModeOutput, DEVMODEW *pDevModeInput, | |
687 DWORD fMode); | |
800 | 688 |
689 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
690 #undef PrintDlg | |
691 #define PrintDlg error use qxePrintDlg or PrintDlgA/PrintDlgW | |
692 #endif | |
771 | 693 BOOL qxePrintDlg (PRINTDLGW *lppd); |
800 | 694 |
695 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
696 #undef PageSetupDlg | |
697 #define PageSetupDlg error use qxePageSetupDlg or PageSetupDlgA/PageSetupDlgW | |
698 #endif | |
771 | 699 BOOL qxePageSetupDlg (PAGESETUPDLGW *lppd); |
700 | |
701 /* fonts */ | |
800 | 702 |
703 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
704 #undef EnumFontFamiliesEx | |
705 #define EnumFontFamiliesEx error use qxeEnumFontFamiliesEx or EnumFontFamiliesExA/EnumFontFamiliesExW | |
706 #endif | |
771 | 707 int qxeEnumFontFamiliesEx (HDC hdc, LOGFONTW *lpLogfont, |
708 FONTENUMPROCW lpEnumFontFamProc, LPARAM lParam, | |
709 DWORD dwFlags); | |
800 | 710 |
711 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
712 #undef CreateFontIndirect | |
713 #define CreateFontIndirect error use qxeCreateFontIndirect or CreateFontIndirectA/CreateFontIndirectW | |
714 #endif | |
771 | 715 HFONT qxeCreateFontIndirect (CONST LOGFONTW *lplf); |
800 | 716 |
2500 | 717 #if defined (HAVE_MS_WINDOWS) |
800 | 718 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED |
719 #undef ImmSetCompositionFont | |
720 #define ImmSetCompositionFont error use qxeImmSetCompositionFont or ImmSetCompositionFontA/ImmSetCompositionFontW | |
721 #endif | |
771 | 722 BOOL qxeImmSetCompositionFont (HIMC imc, LOGFONTW *lplf); |
2500 | 723 #endif /* defined (HAVE_MS_WINDOWS) */ |
800 | 724 |
2500 | 725 #if defined (HAVE_MS_WINDOWS) |
800 | 726 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED |
727 #undef ImmGetCompositionFont | |
728 #define ImmGetCompositionFont error use qxeImmGetCompositionFont or ImmGetCompositionFontA/ImmGetCompositionFontW | |
729 #endif | |
771 | 730 BOOL qxeImmGetCompositionFont (HIMC imc, LOGFONTW *lplf); |
2500 | 731 #endif /* defined (HAVE_MS_WINDOWS) */ |
732 | |
733 #if defined (HAVE_MS_WINDOWS) | |
734 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
735 #undef ImmSetCompositionString | |
736 #define ImmSetCompositionString error_use_qxeImmSetCompositionString_or_ImmSetCompositionStringA_and_ImmSetCompositionStringW | |
737 #endif | |
738 #if MSC_VERSION >= 1300 | |
739 BOOL qxeImmSetCompositionString (HIMC arg1, DWORD dwIndex, LPVOID lpComp, DWORD arg4, LPCVOID lpRead, DWORD arg6); | |
740 #else | |
741 BOOL qxeImmSetCompositionString (HIMC arg1, DWORD dwIndex, LPCVOID lpComp, DWORD arg4, LPCVOID lpRead, DWORD arg6); | |
742 #endif | |
743 #endif /* defined (HAVE_MS_WINDOWS) */ | |
800 | 744 |
745 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
746 #undef GetObject | |
747 #define GetObject error use qxeGetObject or GetObjectA/GetObjectW | |
748 #endif | |
771 | 749 int qxeGetObject (HGDIOBJ hgdiobj, int cbBuffer, LPVOID lpvObject); |
800 | 750 |
751 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
752 #undef GetTextMetrics | |
753 #define GetTextMetrics error use qxeGetTextMetrics or GetTextMetricsA/GetTextMetricsW | |
754 #endif | |
771 | 755 BOOL qxeGetTextMetrics (HDC hdc, LPTEXTMETRICW lptm); |
756 | |
757 /* COMMCTRL.H */ | |
800 | 758 |
759 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
760 #undef SendMessage | |
761 #define SendMessage error use qxeSendMessage or SendMessageA/SendMessageW | |
762 #endif | |
771 | 763 LRESULT qxeSendMessage (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); |
764 | |
765 /* windows */ | |
800 | 766 |
767 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
768 #undef RegisterClass | |
769 #define RegisterClass error use qxeRegisterClass or RegisterClassA/RegisterClassW | |
770 #endif | |
771 | 771 ATOM qxeRegisterClass (CONST WNDCLASSW * lpWndClass); |
800 | 772 |
773 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
774 #undef UnregisterClass | |
775 #define UnregisterClass error use qxeUnregisterClass or UnregisterClassA/UnregisterClassW | |
776 #endif | |
771 | 777 BOOL qxeUnregisterClass (const Extbyte * lpClassName, HINSTANCE hInstance); |
800 | 778 |
779 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
780 #undef RegisterClassEx | |
781 #define RegisterClassEx error use qxeRegisterClassEx or RegisterClassExA/RegisterClassExW | |
782 #endif | |
771 | 783 ATOM qxeRegisterClassEx (CONST WNDCLASSEXW * arg1); |
800 | 784 |
785 #ifdef ERROR_WHEN_NONINTERCEPTED_FUNS_USED | |
786 #undef CreateWindow | |
787 #define CreateWindow error use qxeCreateWindow or CreateWindowA/CreateWindowW | |
788 #endif | |
771 | 789 #define qxeCreateWindow(lpClassName, lpWindowName, dwStyle, x, y, \ |
790 nWidth, nHeight, hWndParent, hMenu, hInstance, \ | |
791 lpParam) \ | |
792 qxeCreateWindowEx (0L, lpClassName, lpWindowName, dwStyle, x, y, \ | |
793 nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) | |
794 | |
795 /* ------------------------- Unicode conversion ------------------------- */ | |
796 | |
797 /* Set early in command-line processing, when -nuni or | |
798 --no-unicode-lib-calls is seen. */ | |
799 extern int no_mswin_unicode_lib_calls; | |
2367 | 800 /* Set early, in init_win32_very_very_early(). */ |
771 | 801 extern int mswindows_windows9x_p; |
802 #define XEUNICODE_P (!mswindows_windows9x_p && !no_mswin_unicode_lib_calls) | |
803 | |
804 #define XELPTSTR LPWSTR | |
805 #define XELPCTSTR LPCWSTR | |
442 | 806 |
807 #define XETCHAR_SIZE (XEUNICODE_P ? sizeof (WCHAR) : sizeof (CHAR)) | |
808 #define MAX_XETCHAR_SIZE sizeof (WCHAR) | |
809 #define XETEXT1(arg) (XEUNICODE_P ? ((char *) (L##arg)) : (arg)) | |
810 /* We need to do this indirection in case ARG is also a manifest constant. | |
811 I don't really understand why. --ben */ | |
812 #define XETEXT(arg) XETEXT1(arg) | |
813 #define XECOPY_TCHAR(ptr, ch) \ | |
814 (XEUNICODE_P ? (* (LPWSTR) (ptr) = L##ch) : (* (LPSTR) (ptr) = (ch))) | |
2421 | 815 #define qxetcslen(arg) \ |
771 | 816 (XEUNICODE_P ? wcslen ((wchar_t *) arg) : strlen (arg)) |
2421 | 817 #define qxetcsbytelen(arg) \ |
771 | 818 (XEUNICODE_P ? wcslen ((wchar_t *) arg) * XETCHAR_SIZE : strlen (arg)) |
2421 | 819 #define qxetcscmp(s1, s2) \ |
442 | 820 (XEUNICODE_P ? wcscmp ((wchar_t *) s1, (wchar_t *) s2) \ |
821 : strcmp (s1, s2)) | |
2421 | 822 #define qxetcscpy(s1, s2) \ |
442 | 823 (XEUNICODE_P ? (char *) wcscpy ((wchar_t *) s1, (wchar_t *) s2) \ |
824 : strcpy (s1, s2)) | |
2421 | 825 #define qxetcsncpy(s1, s2, n) \ |
771 | 826 (XEUNICODE_P ? (char *) wcsncpy ((wchar_t *) s1, (wchar_t *) s2, n) \ |
827 : strncpy (s1, s2, n)) | |
2421 | 828 #define qxetcschr(s, ch) \ |
442 | 829 (XEUNICODE_P ? (char *) wcschr ((wchar_t *) s, (WCHAR) ch) \ |
830 : strchr (s, ch)) | |
2421 | 831 #define qxetcsrchr(s, ch) \ |
442 | 832 (XEUNICODE_P ? (char *) wcsrchr ((wchar_t *) s, (WCHAR) ch) \ |
833 : strrchr (s, ch)) | |
2421 | 834 #define qxetcsdup(s) \ |
771 | 835 (XEUNICODE_P ? (char *) wcsdup ((wchar_t *) s) \ |
836 : xstrdup (s)) | |
442 | 837 |
771 | 838 #define C_STRING_TO_TSTR(in, out) \ |
839 C_STRING_TO_EXTERNAL (in, out, Qmswindows_tstr) | |
840 #define LISP_STRING_TO_TSTR(in, out) \ | |
841 LISP_STRING_TO_EXTERNAL (in, out, Qmswindows_tstr) | |
842 #define TSTR_TO_C_STRING(in, out) \ | |
843 EXTERNAL_TO_C_STRING (in, out, Qmswindows_tstr) | |
844 #define TSTR_TO_C_STRING_MALLOC(in, out) \ | |
845 EXTERNAL_TO_C_STRING_MALLOC (in, out, Qmswindows_tstr) | |
846 | |
847 #define build_tstr_string(in) \ | |
2421 | 848 make_ext_string (in, qxetcsbytelen ((Extbyte *) in), Qmswindows_tstr) |
771 | 849 |
850 #define MAX_ANSI_CHAR_LEN 1 | |
851 #define MAX_UNICODE_CHAR_LEN 2 | |
852 | |
853 DECLARE_INLINE_HEADER (int ansi_char_to_text (int ch, Extbyte *t)) | |
854 { | |
855 ch &= 0xFF; | |
856 t[0] = ch; | |
857 return 1; | |
858 } | |
859 | |
860 DECLARE_INLINE_HEADER (int unicode_char_to_text (int ch, Extbyte *t)) | |
861 { | |
862 t[0] = ch & 0xFF; | |
863 t[1] = (ch >> 8) & 0xFF; | |
864 return 2; | |
865 } | |
442 | 866 |
771 | 867 Extbyte *convert_multibyte_to_unicode_malloc (const Extbyte *src, |
868 Bytecount n, | |
869 int cp, Bytecount *size_out); | |
2367 | 870 Extbyte *convert_unicode_to_multibyte_malloc (const Extbyte *src, |
871 Bytecount n, | |
872 int cp, Bytecount *size_out); | |
867 | 873 Ibyte *convert_multibyte_to_internal_malloc (const Extbyte *src, |
771 | 874 Bytecount n, |
875 int cp, Bytecount *size_out); | |
876 void convert_multibyte_to_unicode_dynarr (const Extbyte *src, Bytecount n, | |
877 int cp, unsigned_char_dynarr *dst); | |
2367 | 878 void convert_unicode_to_multibyte_dynarr (const Extbyte *src, Bytecount n, |
879 int cp, unsigned_char_dynarr *dst); | |
880 | |
881 Bytecount unicode_multibyte_convert_size (const char *srctext, const void *src, | |
882 Bytecount src_size, int to_unicode, | |
883 int cp); | |
884 void *unicode_multibyte_convert_copy_data (const char *srctext, | |
885 void *alloca_data); | |
886 | |
887 /* NOTE: If you make two invocations of the following functions in the same | |
888 subexpression and use the exact same expression for the source in both | |
889 cases, you will lose. In this unlikely case, you may get an abort, and | |
890 need to rewrite the code. | |
891 | |
892 We need to use ALLOCA_FUNCALL_OK here, see NEW_DFC in text.h. | |
893 */ | |
894 | |
895 #ifdef WEXTTEXT_IS_WIDE | |
896 #define MULTIBYTE_TO_WEXTTEXT(str) \ | |
897 ((Wexttext *) \ | |
898 unicode_multibyte_convert_copy_data \ | |
899 (#str, ALLOCA_FUNCALL_OK (unicode_multibyte_convert_size \ | |
900 (#str, str, strlen (str) + 1, 1, CP_ACP)))) | |
901 | |
902 #define WEXTTEXT_TO_MULTIBYTE(str) \ | |
903 ((Extbyte *) \ | |
904 unicode_multibyte_convert_copy_data \ | |
905 (#str, ALLOCA_FUNCALL_OK (unicode_multibyte_convert_size \ | |
906 (#str, str, \ | |
907 (wcslen (str) + 1) * sizeof (WCHAR), 0, \ | |
908 CP_ACP)))) | |
909 #else | |
910 #define MULTIBYTE_TO_WEXTTEXT(str) ((Wexttext *) (str)) | |
911 #define WEXTTEXT_TO_MULTIBYTE(str) ((Extbyte *) (str)) | |
912 #endif | |
913 | |
914 /* #### mbstowcs() uses MB_ERR_INVALID_CHARS in addition to MB_PRECOMPOSED. | |
915 Should we do this? But then we have to handle errors. | |
916 #### Do we already check for invalid sequences in the coding system? */ | |
917 #define MBTOWC_OPTIONS MB_PRECOMPOSED /* | MB_ERR_INVALID_CHARS */ | |
918 /* The following options are what wcstombs() uses in the CRT. It uses | |
919 NULL in place of "~". */ | |
920 #define WCTOMB_OPTIONS WC_COMPOSITECHECK | WC_SEPCHARS | |
921 #define WCTOMB_INVALID_STRING "~" | |
771 | 922 |
923 /* ------------------------- Other Mule stuff ------------------------- */ | |
924 | |
925 LCID mswindows_current_locale (void); | |
926 int mswindows_locale_to_code_page (LCID lcid); | |
927 int mswindows_locale_to_oem_code_page (LCID lcid); | |
928 | |
929 /* ------------------------- Filename conversion ------------------------- */ | |
930 | |
931 #ifdef CYGWIN | |
1743 | 932 |
933 BEGIN_C_DECLS | |
934 | |
771 | 935 void cygwin_win32_to_posix_path_list (const char *, char *); |
936 int cygwin_win32_to_posix_path_list_buf_size (const char *); | |
937 void cygwin_posix_to_win32_path_list (const char *, char *); | |
938 int cygwin_posix_to_win32_path_list_buf_size (const char *); | |
3728 | 939 extern int cygwin_conv_to_full_win32_path (const char *, char *); |
1743 | 940 |
941 END_C_DECLS | |
942 | |
771 | 943 #endif |
944 | |
945 #define LOCAL_FILE_FORMAT_TO_TSTR(path, out) \ | |
946 do { \ | |
2526 | 947 Ibyte *lttff; \ |
771 | 948 \ |
949 LOCAL_TO_WIN32_FILE_FORMAT (XSTRING_DATA (path), lttff); \ | |
2526 | 950 PATHNAME_CONVERT_OUT (lttff, out); \ |
442 | 951 } while (0) |
952 | |
953 Lisp_Object tstr_to_local_file_format (Extbyte *pathout); | |
954 | |
826 | 955 /* Convert from local file format, as used in XEmacs, to valid win32 |
956 filenames as can be given to Windows API routines. Under native XEmacs, | |
957 this is a no-op, but under Cygwin, the local names look different -- | |
958 Cygwin mount points, forward slashes, etc. Currently, under Cygwin, we | |
959 actually allow local names to be of both formats, i.e. Cygwin or Win32 | |
960 native. So we check to see if we have Win32 native already (a cheesy | |
961 check, look for letter plus colon at beginning of name) and do nothing | |
962 in that case. */ | |
963 | |
442 | 964 #ifdef CYGWIN |
771 | 965 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout) \ |
966 do { \ | |
967 /* NOTE: It is a bit evil that here and below we are passing \ | |
968 internal-format data to a function that (nominally) should work \ | |
969 with external-format data. But in point of fact, the Cygwin \ | |
970 conversion functions are *NOT* localized, and will fail if they \ | |
971 get 7-bit ISO2022-encoded data. We know that our internal format \ | |
972 is ASCII-compatible, and so these functions will work fine with \ | |
973 this data. */ \ | |
867 | 974 Ibyte *ltwffp = (path); \ |
771 | 975 if (isalpha (ltwffp[0]) && (IS_DEVICE_SEP (ltwffp[1]))) \ |
976 pathout = ltwffp; \ | |
977 else \ | |
978 { \ | |
979 int ltwff2 = \ | |
980 cygwin_posix_to_win32_path_list_buf_size ((char *) ltwffp); \ | |
2367 | 981 pathout = alloca_ibytes (ltwff2); \ |
771 | 982 cygwin_posix_to_win32_path_list ((char *) ltwffp, (char *) pathout); \ |
983 } \ | |
442 | 984 } while (0) |
985 #else | |
986 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout) \ | |
987 do { \ | |
771 | 988 (pathout) = (path); \ |
442 | 989 } while (0) |
990 #endif | |
991 | |
992 #ifdef CYGWIN | |
593 | 993 #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout) \ |
994 do { \ | |
867 | 995 Ibyte *wtlff1 = (path); \ |
593 | 996 int wtlff2 = \ |
997 cygwin_win32_to_posix_path_list_buf_size ((char *) wtlff1); \ | |
2367 | 998 Ibyte *wtlff3 = alloca_ibytes (wtlff2); \ |
593 | 999 cygwin_win32_to_posix_path_list ((char *) wtlff1, (char *) wtlff3); \ |
771 | 1000 (pathout) = wtlff3; \ |
442 | 1001 } while (0) |
1002 #else | |
1003 #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout) \ | |
1004 do { \ | |
771 | 1005 (pathout) = (path); \ |
442 | 1006 } while (0) |
1007 #endif | |
1008 | |
826 | 1009 /* Convert a local-format file name or URL in internal format into a Win32 |
1010 file name or URL in tstr format. */ | |
1011 | |
1012 #ifdef CYGWIN | |
1013 | |
2526 | 1014 #define LOCAL_FILE_FORMAT_MAYBE_URL_TO_TSTR(lispstr, pathout) \ |
1015 do \ | |
1016 { \ | |
1017 Ibyte *lffmutt_fname1; \ | |
1018 Ibyte *lffmutt_pathint = XSTRING_DATA (lispstr); \ | |
1019 \ | |
1020 if ((lffmutt_fname1 = qxestrchr (lffmutt_pathint, ':')) != NULL \ | |
1021 && *++lffmutt_fname1 == '/' && *++lffmutt_fname1 == '/') \ | |
1022 { \ | |
1023 /* If URL style file, the innards may have Cygwin mount points and \ | |
1024 the like. so separate out the innards, process them, and put back \ | |
1025 together. */ \ | |
1026 if (qxestrncasecmp_ascii (lffmutt_pathint, "file://", 7) == 0) \ | |
1027 { \ | |
1028 Ibyte *lffmutt_path1, *lffmutt_path2; \ | |
1029 LOCAL_TO_WIN32_FILE_FORMAT (lffmutt_pathint + 7, lffmutt_path1); \ | |
1030 if (lffmutt_path1 == lffmutt_pathint + 7) /* Optimization */ \ | |
1031 lffmutt_path2 = lffmutt_pathint; \ | |
1032 else \ | |
1033 { \ | |
867 | 1034 lffmutt_path2 = alloca_ibytes (7 + qxestrlen (lffmutt_path1) \ |
2526 | 1035 + 1); \ |
1036 qxestrncpy (lffmutt_path2, lffmutt_pathint, 7); \ | |
1037 qxestrcpy (lffmutt_path2 + 7, lffmutt_path1); \ | |
1038 } \ | |
1039 C_STRING_TO_TSTR (lffmutt_path2, pathout); \ | |
1040 } \ | |
1041 else \ | |
1042 /* A straight URL, just convert */ \ | |
1043 LISP_STRING_TO_TSTR (lispstr, pathout); \ | |
1044 } \ | |
1045 else \ | |
1046 /* Not URL-style, must be a straight filename. */ \ | |
1047 LOCAL_FILE_FORMAT_TO_TSTR (lispstr, pathout); \ | |
826 | 1048 } while (0) |
1049 | |
1050 #else /* not CYGWIN */ | |
1051 | |
1052 /* URL's (and everything else) are already in the right format */ | |
1053 #define LOCAL_FILE_FORMAT_MAYBE_URL_TO_TSTR(lispstr, pathout) \ | |
1054 LOCAL_FILE_FORMAT_TO_TSTR (lispstr, pathout) | |
1055 | |
1056 #endif /* not CYGWIN */ | |
1057 | |
1058 | |
867 | 1059 Ibyte *urlify_filename (Ibyte *filename); |
1060 Ibyte *mswindows_canonicalize_filename (Ibyte *name); | |
771 | 1061 #define MSWINDOWS_NORMALIZE_FILENAME(name) \ |
867 | 1062 IBYTE_STRING_TO_ALLOCA (mswindows_canonicalize_filename (name), name) |
771 | 1063 |
1064 /* ------------------- Functions needed dynamic binding ------------------- */ | |
1065 | |
1066 typedef BOOL (WINAPI *pfSwitchToThread_t) (VOID); | |
1067 | |
1068 typedef NET_API_STATUS (NET_API_FUNCTION *pfNetUserEnum_t) | |
1069 (LPCWSTR, DWORD, DWORD, LPBYTE *, DWORD, LPDWORD, LPDWORD, LPDWORD); | |
1070 typedef NET_API_STATUS (NET_API_FUNCTION *pfNetApiBufferFree_t) (LPVOID); | |
1071 | |
1072 extern pfSwitchToThread_t xSwitchToThread; | |
1073 | |
1074 extern pfNetUserEnum_t xNetUserEnum; | |
1075 extern pfNetApiBufferFree_t xNetApiBufferFree; | |
1076 | |
1077 /* --------- Useful routines for manipulating memory-mapped files -------- */ | |
1078 | |
1079 typedef struct file_data | |
1080 { | |
867 | 1081 const Ibyte *name; |
771 | 1082 unsigned long size; |
1083 HANDLE file; | |
1084 HANDLE file_mapping; | |
1085 void *file_base; | |
1086 } file_data; | |
1087 | |
1088 #define OFFSET_TO_RVA(var,section) \ | |
1089 (section->VirtualAddress + \ | |
1090 ((DWORD)(var) - section->PointerToRawData)) | |
1091 | |
1092 #define RVA_TO_OFFSET(var,section) \ | |
1093 (section->PointerToRawData + \ | |
1094 ((DWORD)(var) - section->VirtualAddress)) | |
442 | 1095 |
771 | 1096 #define RVA_TO_PTR(var,section,filedata) \ |
1097 ((void *)(RVA_TO_OFFSET(var,section) + \ | |
1098 (char *)(filedata).file_base)) | |
1099 | |
867 | 1100 int open_input_file (file_data *p_file, const Ibyte *name); |
1101 int open_output_file (file_data *p_file, const Ibyte *name, | |
771 | 1102 unsigned long size); |
1103 void close_file_data (file_data *p_file); | |
1104 | |
1105 /* ------------------------- Heap related stuff ------------------------- */ | |
1106 | |
1107 #ifdef WIN32_NATIVE | |
442 | 1108 |
771 | 1109 #define get_reserved_heap_size() reserved_heap_size |
1110 #define get_committed_heap_size() (get_data_end () - get_data_start ()) | |
1111 #define get_heap_start() get_data_start () | |
1112 #define get_heap_end() get_data_end () | |
1113 #define get_page_size() sysinfo_cache.dwPageSize | |
1114 #define get_allocation_unit() sysinfo_cache.dwAllocationGranularity | |
1115 #define get_processor_type() sysinfo_cache.dwProcessorType | |
1116 #define get_nt_major_version() nt_major_version | |
1117 #define get_nt_minor_version() nt_minor_version | |
1118 | |
814 | 1119 unsigned char *get_data_start (void); |
1120 unsigned char *get_data_end (void); | |
771 | 1121 extern unsigned long data_region_size; |
1122 extern unsigned long reserved_heap_size; | |
1123 extern SYSTEM_INFO sysinfo_cache; | |
1124 extern int nt_major_version; | |
1125 extern int nt_minor_version; | |
1126 | |
1127 /* To prevent zero-initialized variables from being placed into the bss | |
1128 section, use non-zero values to represent an uninitialized state. */ | |
1129 #define UNINIT_PTR ((unsigned char*) 0xF0A0F0A0) | |
1130 #define UNINIT_LONG (0xF0A0F0A0L) | |
1131 | |
1132 /* Recreate the heap created during dumping. */ | |
814 | 1133 void recreate_heap (Extbyte *executable_path); |
771 | 1134 |
1135 /* Round the heap to this size. */ | |
814 | 1136 void round_heap (unsigned long size); |
771 | 1137 |
1138 /* Load in the dumped .bss section. */ | |
814 | 1139 void read_in_bss (Extbyte *name); |
771 | 1140 |
1141 /* Map in the dumped heap. */ | |
814 | 1142 void map_in_heap (Extbyte *name); |
771 | 1143 |
1144 /* Cache system info, e.g., the NT page size. */ | |
814 | 1145 void cache_system_info (void); |
771 | 1146 |
1147 /* Round ADDRESS up to be aligned with ALIGN. */ | |
814 | 1148 unsigned char *round_to_next (unsigned char *address, |
1149 unsigned long align); | |
771 | 1150 #endif /* WIN32_NATIVE */ |
1151 | |
1152 /* ------------------------- Misc prototypes ------------------------- */ | |
1153 | |
1154 #ifdef WIN32_NATIVE | |
1155 DECLARE_INLINE_HEADER (int strcasecmp (const char *a, const char *b)) | |
1156 { | |
867 | 1157 return qxestrcasecmp ((const Ibyte *) a, (const Ibyte *) b); |
771 | 1158 } |
1159 #endif /* WIN32_NATIVE */ | |
442 | 1160 |
771 | 1161 /* in nt.c */ |
867 | 1162 int mswindows_access (const Ibyte *path, int mode); |
3025 | 1163 int mswindows_link (const Ibyte *old, const Ibyte *new_); |
867 | 1164 int mswindows_rename (const Ibyte *oldname, const Ibyte *newname); |
1165 int mswindows_unlink (const Ibyte *path); | |
1166 int mswindows_stat (const Ibyte *path, struct stat *buf); | |
771 | 1167 int mswindows_fstat (int desc, struct stat *buf); |
1168 time_t mswindows_convert_time (FILETIME ft); | |
1204 | 1169 int mswindows_is_executable (const Ibyte *filename); |
1170 void mswindows_executable_type (const Ibyte *filename, int *is_dos_app, | |
1171 int *is_cygnus_app); | |
867 | 1172 Ibyte *mswindows_getdcwd (int drivelet); |
771 | 1173 |
872 | 1174 /* in process-nt.c */ |
771 | 1175 extern int mswindows_compare_env (const void *strp1, const void *strp2); |
1176 | |
1177 /* in win32.c */ | |
814 | 1178 Extbyte *mswindows_get_module_file_name (void); |
771 | 1179 void mswindows_output_last_error (char *frob); |
1180 DECLARE_DOESNT_RETURN (mswindows_report_process_error (const char *string, | |
1181 Lisp_Object data, | |
1182 int errnum)); | |
1183 Lisp_Object mswindows_lisp_error (int errnum); | |
2526 | 1184 Ibyte *mswindows_read_link (const Ibyte *fname); |
771 | 1185 |
872 | 1186 /* in intl-win32.c */ |
1187 extern Lisp_Object Qmswindows_tstr, Qmswindows_unicode; | |
1188 extern Lisp_Object Qmswindows_multibyte, Qmswindows_multibyte_to_unicode; | |
1189 | |
442 | 1190 #endif /* INCLUDED_syswindows_h_ */ |