annotate src/win32.c @ 531:0493e9f3c27f

[xemacs-hg @ 2001-05-12 11:16:12 by ben] event-msw.c: eliminate cygwin warnings. dired.c, syswindows.h, win32.c: find the Net* functions the hard way to avoid errors on win 9x. find-paths.el: fix error with null EXCLUDE-REGEXP. font-lock.el: fix problem reported by hrvoje with buffers starting with a space. lib-complete.el: add a variable to control where `find-library' looks, analogous to `find-function-source-path'. etags.c: new version from Francesco. Makefile.in.in: i'm getting real tired of incomplete commits. is this getting worse or something?
author ben
date Sat, 12 May 2001 11:16:25 +0000
parents abe6d1db359e
children 183866b06e0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1 /* Utility routines for XEmacs on Windows 9x, NT and Cygwin.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
2 Copyright (C) 2000 Ben Wing.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
3
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
4 This file is part of XEmacs.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
5
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
9 later version.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
10
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
14 for more details.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
15
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to the Free
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
19 02111-1307, USA. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
20
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
21 #include <config.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
22 #include "lisp.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
23
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
24 #include "buffer.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
25 #include "syswindows.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
26
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
27 typedef BOOL (WINAPI *pfSwitchToThread_t) (VOID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
28 pfSwitchToThread_t xSwitchToThread;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
29
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
30 typedef HKL (WINAPI *pfGetKeyboardLayout_t) (DWORD);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
31 pfGetKeyboardLayout_t xGetKeyboardLayout;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
32 typedef BOOL (WINAPI *pfSetMenuDefaultItem_t) (HMENU, UINT, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
33 pfSetMenuDefaultItem_t xSetMenuDefaultItem;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
34 typedef BOOL (WINAPI *pfInsertMenuItemA_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
35 (HMENU, UINT, BOOL, LPCMENUITEMINFOA);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
36 pfInsertMenuItemA_t xInsertMenuItemA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
37 typedef BOOL (WINAPI *pfInsertMenuItemW_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
38 (HMENU, UINT, BOOL, LPCMENUITEMINFOW);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
39 pfInsertMenuItemW_t xInsertMenuItemW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
40 typedef HANDLE (WINAPI *pfLoadImageA_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
41 (HINSTANCE, LPCSTR, UINT, int, int, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
42 pfLoadImageA_t xLoadImageA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
43 typedef HANDLE (WINAPI *pfLoadImageW_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
44 (HINSTANCE, LPCWSTR, UINT, int, int, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
45 pfLoadImageW_t xLoadImageW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
46 typedef ATOM (WINAPI *pfRegisterClassExA_t) (CONST WNDCLASSEXA *);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
47 pfRegisterClassExA_t xRegisterClassExA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
48 typedef ATOM (WINAPI *pfRegisterClassExW_t) (CONST WNDCLASSEXW *);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
49 pfRegisterClassExW_t xRegisterClassExW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
50
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
51 typedef int (WINAPI *pfEnumFontFamiliesExA_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
52 (HDC, LPLOGFONTA, FONTENUMPROCA, LPARAM, DWORD);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
53 pfEnumFontFamiliesExA_t xEnumFontFamiliesExA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
54 typedef int (WINAPI *pfEnumFontFamiliesExW_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
55 (HDC, LPLOGFONTW, FONTENUMPROCW, LPARAM, DWORD);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
56 pfEnumFontFamiliesExW_t xEnumFontFamiliesExW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
57
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
58 typedef DWORD (WINAPI *pfSHGetFileInfoA_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
59 (LPCSTR, DWORD, SHFILEINFOA FAR *, UINT, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
60 pfSHGetFileInfoA_t xSHGetFileInfoA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
61 typedef DWORD (WINAPI *pfSHGetFileInfoW_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
62 (LPCWSTR, DWORD, SHFILEINFOW FAR *, UINT, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
63 pfSHGetFileInfoW_t xSHGetFileInfoW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
64
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
65 typedef NET_API_STATUS (NET_API_FUNCTION *pfNetUserEnum_t)
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
66 (
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
67 IN LPCWSTR servername OPTIONAL,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
68 IN DWORD level,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
69 IN DWORD filter,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
70 OUT LPBYTE *bufptr,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
71 IN DWORD prefmaxlen,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
72 OUT LPDWORD entriesread,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
73 OUT LPDWORD totalentries,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
74 IN OUT LPDWORD resume_handle OPTIONAL
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
75 );
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
76 pfNetUserEnum_t xNetUserEnum;
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
77
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
78 typedef NET_API_STATUS (NET_API_FUNCTION *pfNetApiBufferFree_t)
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
79 (
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
80 IN LPVOID Buffer
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
81 );
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
82 pfNetApiBufferFree_t xNetApiBufferFree;
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
83
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
84 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
85 tstr_to_local_file_format (Extbyte *pathout)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
86 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
87 Bufbyte *ttlff;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
88 Lisp_Object in;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
89
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
90 EXTERNAL_TO_C_STRING (pathout, ttlff, Qmswindows_tstr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
91 WIN32_TO_LOCAL_FILE_FORMAT (ttlff, in);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
92
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
93 return in;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
94 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
95
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
96 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
97 init_potentially_nonexistent_functions (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
98 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
99 HMODULE h_kernel = GetModuleHandle ("kernel32");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
100 HMODULE h_user = GetModuleHandle ("user32");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
101 HMODULE h_gdi = GetModuleHandle ("gdi32");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
102 HMODULE h_shell = GetModuleHandle ("shell32");
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
103 /* the following does not seem to get mapped in automatically */
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
104 HMODULE h_netapi = LoadLibrary ("netapi32.dll");
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
105
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
106 if (h_kernel)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
107 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
108 xSwitchToThread =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
109 (pfSwitchToThread_t) GetProcAddress (h_kernel, "SwitchToThread");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
110 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
111
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
112 if (h_user)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
113 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
114 xGetKeyboardLayout =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
115 (pfGetKeyboardLayout_t) GetProcAddress (h_user, "GetKeyboardLayout");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
116 xSetMenuDefaultItem =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
117 (pfSetMenuDefaultItem_t) GetProcAddress (h_user, "SetMenuDefaultItem");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
118 xInsertMenuItemA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
119 (pfInsertMenuItemA_t) GetProcAddress (h_user, "InsertMenuItemA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
120 xInsertMenuItemW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
121 (pfInsertMenuItemW_t) GetProcAddress (h_user, "InsertMenuItemW");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
122 xLoadImageA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
123 (pfLoadImageA_t) GetProcAddress (h_user, "LoadImageA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
124 xLoadImageW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
125 (pfLoadImageW_t) GetProcAddress (h_user, "LoadImageW");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
126 xRegisterClassExA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
127 (pfRegisterClassExA_t) GetProcAddress (h_user, "RegisterClassExA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
128 xRegisterClassExW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
129 (pfRegisterClassExW_t) GetProcAddress (h_user, "RegisterClassExW");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
130 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
131
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
132 if (h_gdi)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
133 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
134 xEnumFontFamiliesExA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
135 (pfEnumFontFamiliesExA_t) GetProcAddress (h_gdi, "EnumFontFamiliesExA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
136 xEnumFontFamiliesExW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
137 (pfEnumFontFamiliesExW_t) GetProcAddress (h_gdi, "EnumFontFamiliesExW");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
138 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
139
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
140 if (h_shell)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
141 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
142 xSHGetFileInfoA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
143 (pfSHGetFileInfoA_t) GetProcAddress (h_shell, "SHGetFileInfoA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
144 xSHGetFileInfoW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
145 (pfSHGetFileInfoW_t) GetProcAddress (h_shell, "SHGetFileInfoW");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
146 }
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
147
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
148 if (h_netapi)
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
149 {
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
150 xNetUserEnum =
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
151 (pfNetUserEnum_t) GetProcAddress (h_netapi, "NetUserEnum");
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
152 xNetApiBufferFree =
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
153 (pfNetApiBufferFree_t) GetProcAddress (h_netapi, "NetApiBufferFree");
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
154 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
155 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
156
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
157 DEFUN ("mswindows-shell-execute", Fmswindows_shell_execute, 2, 4, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
158 Get Windows to perform OPERATION on DOCUMENT.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
159 This is a wrapper around the ShellExecute system function, which
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
160 invokes the application registered to handle OPERATION for DOCUMENT.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
161 OPERATION is typically \"open\", \"print\" or \"explore\" (but can be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
162 nil for the default action), and DOCUMENT is typically the name of a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
163 document file or URL, but can also be a program executable to run or
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
164 a directory to open in the Windows Explorer.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
165
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
166 If DOCUMENT is a program executable, PARAMETERS can be a string
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
167 containing command line parameters, but otherwise should be nil.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
168
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
169 SHOW-FLAG can be used to control whether the invoked application is hidden
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
170 or minimized. If SHOW-FLAG is nil, the application is displayed normally,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
171 otherwise it is an integer representing a ShowWindow flag:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
172
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
173 0 - start hidden
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
174 1 - start normally
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
175 3 - start maximized
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
176 6 - start minimized
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
177 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
178 (operation, document, parameters, show_flag))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
179 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
180 /* Encode filename and current directory. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
181 Lisp_Object current_dir = Ffile_name_directory (document);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
182 char* path = NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
183 char* doc = NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
184 Extbyte* f=0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
185 int ret;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
186 struct gcpro gcpro1, gcpro2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
187
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
188 CHECK_STRING (document);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
189
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
190 if (NILP (current_dir))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
191 current_dir = current_buffer->directory;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
192
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
193 GCPRO2 (current_dir, document);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
194
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
195 /* Use mule and cygwin-safe APIs top get at file data. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
196 if (STRINGP (current_dir))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
197 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
198 TO_EXTERNAL_FORMAT (LISP_STRING, current_dir,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
199 C_STRING_ALLOCA, f,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
200 Qfile_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
201 #ifdef CYGWIN
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
202 CYGWIN_WIN32_PATH (f, path);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
203 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
204 path = f;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
205 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
206 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
207
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
208 if (STRINGP (document))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
209 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
210 TO_EXTERNAL_FORMAT (LISP_STRING, document,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
211 C_STRING_ALLOCA, f,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
212 Qfile_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
213 #ifdef CYGWIN
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
214 CYGWIN_WIN32_PATH (f, doc);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
215 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
216 doc = f;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
217 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
218 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
219
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
220 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
221
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
222 ret = (int) ShellExecute (NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
223 (STRINGP (operation) ?
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
224 XSTRING_DATA (operation) : NULL),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
225 doc,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
226 (STRINGP (parameters) ?
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
227 XSTRING_DATA (parameters) : NULL),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
228 path,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
229 (INTP (show_flag) ?
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
230 XINT (show_flag) : SW_SHOWDEFAULT));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
231
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
232 if (ret > 32)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
233 return Qt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
234
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
235 if (ret == ERROR_FILE_NOT_FOUND)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
236 signal_simple_error ("file not found", document);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
237 else if (ret == ERROR_PATH_NOT_FOUND)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
238 signal_simple_error ("path not found", current_dir);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
239 else if (ret == ERROR_BAD_FORMAT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
240 signal_simple_error ("bad executable format", document);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
241 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
242 error ("internal error");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
243
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
244 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
245 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
246
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
247 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
248 syms_of_win32 (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
249 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
250 DEFSUBR (Fmswindows_shell_execute);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
251 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
252
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
253 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
254 init_win32 (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
255 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
256 init_potentially_nonexistent_functions ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
257 }